@mcp-use/inspector 0.14.0-canary.11 → 0.14.0-canary.12

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.
@@ -1,4 +1,4 @@
1
- import{r as h,R as ce,b as Ai}from"./index-y9BdsFxs.js";var lt={exports:{}},Na;function $i(){if(Na)return lt.exports;Na=1;var e={decodeValues:!0,map:!1,silent:!1};function t(l){return typeof l!="string"||l in{}}function r(){return Object.create(null)}function a(l){return typeof l=="string"&&!!l.trim()}function n(l,u){var c=l.split(";").filter(a),d=c.shift(),m=o(d),p=m.name,f=m.value;if(u=u?Object.assign({},e,u):e,t(p))return null;try{f=u.decodeValues?decodeURIComponent(f):f}catch(y){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",y)}var g=r();return g.name=p,g.value=f,c.forEach(function(y){var w=y.split("="),R=w.shift().trimLeft().toLowerCase();if(!t(R)){var C=w.join("=");if(R==="expires")g.expires=new Date(C);else if(R==="max-age"){var P=parseInt(C,10);Number.isNaN(P)||(g.maxAge=P)}else R==="secure"?g.secure=!0:R==="httponly"?g.httpOnly=!0:R==="samesite"?g.sameSite=C:R==="partitioned"?g.partitioned=!0:R&&(g[R]=C)}}),g}function o(l){var u="",c="",d=l.split("=");return d.length>1?(u=d.shift(),c=d.join("=")):c=l,{name:u,value:c}}function i(l,u){if(u=u?Object.assign({},e,u):e,!l)return u.map?r():[];if(l.headers)if(typeof l.headers.getSetCookie=="function")l=l.headers.getSetCookie();else if(l.headers["set-cookie"])l=l.headers["set-cookie"];else{var c=l.headers[Object.keys(l.headers).find(function(m){return m.toLowerCase()==="set-cookie"})];!c&&l.headers.cookie&&!u.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),l=c}if(Array.isArray(l)||(l=[l]),u.map){var d=r();return l.filter(a).reduce(function(m,p){var f=n(p,u);return f&&!t(f.name)&&(m[f.name]=f),m},d)}else return l.filter(a).map(function(m){return n(m,u)}).filter(Boolean)}function s(l){if(Array.isArray(l))return l;if(typeof l!="string")return[];var u=[],c=0,d,m,p,f,g;function y(){for(;c<l.length&&/\s/.test(l.charAt(c));)c+=1;return c<l.length}function w(){return m=l.charAt(c),m!=="="&&m!==";"&&m!==","}for(;c<l.length;){for(d=c,g=!1;y();)if(m=l.charAt(c),m===","){for(p=c,c+=1,y(),f=c;c<l.length&&w();)c+=1;c<l.length&&l.charAt(c)==="="?(g=!0,c=f,u.push(l.substring(d,p)),d=c):c=p+1}else c+=1;(!g||c>=l.length)&&u.push(l.substring(d,l.length))}return u}return lt.exports=i,lt.exports.parse=i,lt.exports.parseString=n,lt.exports.splitCookiesString=s,lt.exports}var Ii=$i();var Cn=e=>{throw TypeError(e)},Hi=(e,t,r)=>t.has(e)||Cn("Cannot "+r),Er=(e,t,r)=>(Hi(e,t,"read from private field"),r?r.call(e):t.get(e)),ji=(e,t,r)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ui=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Ui||{}),Aa="popstate";function xn(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((p,f)=>c(p,typeof p=="string"?null:p.state,f===0?"default":void 0));let o=l(r??n.length-1),i="POP",s=null;function l(p){return Math.min(Math.max(p,0),n.length-1)}function u(){return n[o]}function c(p,f=null,g){let y=Ae(n?u().pathname:"/",p,f,g);return K(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function d(p){return typeof p=="string"?p:he(p)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:d,createURL(p){return new URL(d(p),"http://localhost")},encodeLocation(p){let f=typeof p=="string"?xe(p):p;return{pathname:f.pathname||"",search:f.search||"",hash:f.hash||""}},push(p,f){i="PUSH";let g=c(p,f);o+=1,n.splice(o,n.length,g),a&&s&&s({action:i,location:g,delta:1})},replace(p,f){i="REPLACE";let g=c(p,f);n[o]=g,a&&s&&s({action:i,location:g,delta:0})},go(p){i="POP";let f=l(o+p),g=n[f];o=f,s&&s({action:i,location:g,delta:p})},listen(p){return s=p,()=>{s=null}}}}function Pn(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return Ae("",{pathname:o,search:i,hash:s},n.state&&n.state.usr||null,n.state&&n.state.key||"default")}function r(a,n){return typeof n=="string"?n:he(n)}return Dn(t,r,null,e)}function Ln(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=xe(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ae("",{pathname:i,search:s,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function r(n,o){let i=n.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let l=n.location.href,u=l.indexOf("#");s=u===-1?l:l.slice(0,u)}return s+"#"+(typeof o=="string"?o:he(o))}function a(n,o){K(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Dn(t,r,a,e)}function I(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function K(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function zi(){return Math.random().toString(36).substring(2,10)}function $a(e,t){return{usr:e.state,key:e.key,idx:t}}function Ae(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?xe(t):t,state:r,key:t&&t.key||a||zi()}}function he({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function xe(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function Dn(e,t,r,a={}){let{window:n=document.defaultView,v5Compat:o=!1}=a,i=n.history,s="POP",l=null,u=c();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function c(){return(i.state||{idx:null}).idx}function d(){s="POP";let y=c(),w=y==null?null:y-u;u=y,l&&l({action:s,location:g.location,delta:w})}function m(y,w){s="PUSH";let R=Ae(g.location,y,w);r&&r(R,y),u=c()+1;let C=$a(R,u),P=g.createHref(R);try{i.pushState(C,"",P)}catch(x){if(x instanceof DOMException&&x.name==="DataCloneError")throw x;n.location.assign(P)}o&&l&&l({action:s,location:g.location,delta:1})}function p(y,w){s="REPLACE";let R=Ae(g.location,y,w);r&&r(R,y),u=c();let C=$a(R,u),P=g.createHref(R);i.replaceState(C,"",P),o&&l&&l({action:s,location:g.location,delta:0})}function f(y){return Tn(y)}let g={get action(){return s},get location(){return e(n,i)},listen(y){if(l)throw new Error("A history only accepts one active listener");return n.addEventListener(Aa,d),l=y,()=>{n.removeEventListener(Aa,d),l=null}},createHref(y){return t(n,y)},createURL:f,encodeLocation(y){let w=f(y);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:m,replace:p,go(y){return i.go(y)}};return g}function Tn(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),I(r,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:he(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=r+a),new URL(a,r)}function cc(e){return{defaultValue:e}}var xt,Ne=class{constructor(e){if(ji(this,xt,new Map),e)for(let[t,r]of e)this.set(t,r)}get(e){if(Er(this,xt).has(e))return Er(this,xt).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Er(this,xt).set(e,t)}};xt=new WeakMap;var Bi=new Set(["lazy","caseSensitive","path","id","index","children"]);function Wi(e){return Bi.has(e)}var Vi=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Yi(e){return Vi.has(e)}function Ji(e){return e.index===!0}function We(e,t,r=[],a={},n=!1){return e.map((o,i)=>{let s=[...r,String(i)],l=typeof o.id=="string"?o.id:s.join("-");if(I(o.index!==!0||!o.children,"Cannot specify children on an index route"),I(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),Ji(o)){let u={...o,id:l};return a[l]=Ia(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Ia(u,t(u)),o.children&&(u.children=We(o.children,t,s,a,n)),u}})}function Ia(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function ve(e,t,r="/"){return Pt(e,t,r,!1)}function Pt(e,t,r,a){let n=typeof t=="string"?xe(t):t,o=ne(n.pathname||"/",r);if(o==null)return null;let i=kn(e);Ki(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Mn(o);s=al(i[l],u,a)}return s}function _n(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],loaderData:t[r.id],handle:r.handle}}function kn(e,t=[],r=[],a="",n=!1){let o=(i,s,l=n,u)=>{let c={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(c.relativePath.startsWith("/")){if(!c.relativePath.startsWith(a)&&l)return;I(c.relativePath.startsWith(a),`Absolute route path "${c.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(a.length)}let d=_e([a,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(I(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),kn(i.children,t,m,d,l)),!(i.path==null&&!i.index)&&t.push({path:d,score:tl(d,i.index),routesMeta:m})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of On(i.path))o(i,s,!0,l)}),t}function On(e){let t=e.split("/");if(t.length===0)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(a.length===0)return n?[o,""]:[o];let i=On(a.join("/")),s=[];return s.push(...i.map(l=>l===""?o:[o,l].join("/"))),n&&s.push(...i),s.map(l=>e.startsWith("/")&&l===""?"/":l)}function Ki(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:rl(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}var Xi=/^:[\w-]+$/,Gi=3,Qi=2,Zi=1,qi=10,el=-2,Ha=e=>e==="*";function tl(e,t){let r=e.split("/"),a=r.length;return r.some(Ha)&&(a+=el),t&&(a+=Qi),r.filter(n=>!Ha(n)).reduce((n,o)=>n+(Xi.test(o)?Gi:o===""?Zi:qi),a)}function rl(e,t){return e.length===t.length&&e.slice(0,-1).every((a,n)=>a===t[n])?e[e.length-1]-t[t.length-1]:0}function al(e,t,r=!1){let{routesMeta:a}=e,n={},o="/",i=[];for(let s=0;s<a.length;++s){let l=a[s],u=s===a.length-1,c=o==="/"?t:t.slice(o.length)||"/",d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},c),m=l.route;if(!d&&u&&r&&!a[a.length-1].route.index&&(d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},c)),!d)return null;Object.assign(n,d.params),i.push({params:n,pathname:_e([o,d.pathname]),pathnameBase:ll(_e([o,d.pathnameBase])),route:m}),d.pathnameBase!=="/"&&(o=_e([o,d.pathnameBase]))}return i}function dc(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(K(!1,`Route path "${r}" will be treated as if it were "${r.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${r.replace(/\*$/,"/*")}".`),r=r.replace(/\*$/,"/*"));const a=r.startsWith("/")?"/":"",n=i=>i==null?"":typeof i=="string"?i:String(i),o=r.split(/\/+/).map((i,s,l)=>{if(s===l.length-1&&i==="*")return n(t["*"]);const c=i.match(/^:([\w-]+)(\??)$/);if(c){const[,d,m]=c;let p=t[d];return I(m==="?"||p!=null,`Missing ":${d}" param`),encodeURIComponent(n(p))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function Lt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=Fn(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce((u,{paramName:c,isOptional:d},m)=>{if(c==="*"){let f=s[m]||"";i=o.slice(0,o.length-f.length).replace(/(.)\/+$/,"$1")}const p=s[m];return d&&!p?u[c]=void 0:u[c]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Fn(e,t=!1,r=!0){K(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,l)=>(a.push({paramName:s,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),n+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":e!==""&&e!=="/"&&(n+="(?:(?=\\/|$))"),[new RegExp(n,t?void 0:"i"),a]}function Mn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return K(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ne(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&a!=="/"?null:e.slice(r)||"/"}function nl({basename:e,pathname:t}){return t==="/"?e:_e([e,t])}var ol=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nr=e=>ol.test(e);function il(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?xe(e):e,o;if(r)if(nr(r))o=r;else{if(r.includes("//")){let i=r;r=r.replace(/\/\/+/g,"/"),K(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${r}`)}r.startsWith("/")?o=ja(r.substring(1),"/"):o=ja(r,t)}else o=t;return{pathname:o,search:sl(a),hash:ul(n)}}function ja(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(n=>{n===".."?r.length>1&&r.pop():n!=="."&&r.push(n)}),r.length>1?r.join("/"):"/"}function br(e,t,r,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Nn(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function or(e){let t=Nn(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function ir(e,t,r,a=!1){let n;typeof e=="string"?n=xe(e):(n={...e},I(!n.pathname||!n.pathname.includes("?"),br("?","pathname","search",n)),I(!n.pathname||!n.pathname.includes("#"),br("#","pathname","hash",n)),I(!n.search||!n.search.includes("#"),br("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let d=t.length-1;if(!a&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),d-=1;n.pathname=m.join("/")}s=d>=0?t[d]:"/"}let l=il(n,s),u=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}var _e=e=>e.join("/").replace(/\/\/+/g,"/"),ll=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),sl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ul=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cl=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function dl(e,t){return new cl(e,typeof t=="number"?{status:t}:t)}var lr=(e,t=302)=>{let r=t;typeof r=="number"?r={status:r}:typeof r.status>"u"&&(r.status=302);let a=new Headers(r.headers);return a.set("Location",e),new Response(null,{...r,headers:a})},fl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},hl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Replace","true"),r},me=class{constructor(e,t,r,a=!1){this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function re(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ct(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var je=Symbol("Uninstrumented");function An(e,t){let r={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(n=>n({id:t.id,index:t.index,path:t.path,instrument(o){let i=Object.keys(r);for(let s of i)o[s]&&r[s].push(o[s])}}));let a={};if(typeof t.lazy=="function"&&r.lazy.length>0){let n=tt(r.lazy,t.lazy,()=>{});n&&(a.lazy=n)}if(typeof t.lazy=="object"){let n=t.lazy;["middleware","loader","action"].forEach(o=>{let i=n[o],s=r[`lazy.${o}`];if(typeof i=="function"&&s.length>0){let l=tt(s,i,()=>{});l&&(a.lazy=Object.assign(a.lazy||{},{[o]:l}))}})}return["loader","action"].forEach(n=>{let o=t[n];if(typeof o=="function"&&r[n].length>0){let i=o[je]??o,s=tt(r[n],i,(...l)=>Ua(l[0]));s&&(s[je]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[je]??n,i=tt(r.middleware,o,(...s)=>Ua(s[0]));return i?(i[je]=o,i):n})),a}function ml(e,t){let r={navigate:[],fetch:[]};if(t.forEach(a=>a({instrument(n){let o=Object.keys(n);for(let i of o)n[i]&&r[i].push(n[i])}})),r.navigate.length>0){let a=e.navigate[je]??e.navigate,n=tt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?he(i):".",...za(e,s??{})}});n&&(n[je]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[je]??e.fetch,n=tt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...za(e,l??{})}});n&&(n[je]=a,e.fetch=n)}return e}function pl(e,t){let r={request:[]};t.forEach(n=>n({instrument(o){let i=Object.keys(o);for(let s of i)o[s]&&r[s].push(o[s])}}));let a=e;return r.request.length>0&&(a=tt(r.request,e,(...n)=>{let[o,i]=n;return{request:In(o),context:i!=null?Hn(i):i}})),a}function tt(e,t,r){return e.length===0?null:async(...a)=>{let n=await $n(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function $n(e,t,r,a){let n=e[a],o;if(n){let i,s=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=$n(e,t,r,a-1),o=await i,I(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await n(s,t)}catch(l){console.error("An instrumentation function threw an error:",l)}i||await s(),await i}else try{o={type:"success",value:await r()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function Ua(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:In(t),params:{...a},unstable_pattern:n,context:Hn(r)}}function za(e,t){return{currentUrl:he(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function In(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function Hn(e){if(vl(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var yl=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function vl(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===yl}var jn=["POST","PUT","PATCH","DELETE"],gl=new Set(jn),wl=["GET",...jn],Rl=new Set(wl),Un=new Set([301,302,303,307,308]),El=new Set([307,308]),Yt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Kr={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},et={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},zn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Bn="remix-router-transitions",Wn=Symbol("ResetLoaderData");function Xr(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";I(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||zn,o=n;if(e.unstable_instrumentations){let v=e.unstable_instrumentations;o=b=>({...n(b),...An(v.map(S=>S.route).filter(Boolean),b)})}let i={},s=We(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let c=e.dataStrategy||Ll,d={...e.future},m=null,p=new Set,f=null,g=null,y=null,w=e.hydrationData!=null,R=ve(s,e.history.location,u),C=!1,P=null,x;if(R==null&&!e.patchRoutesOnNavigation){let v=te(404,{pathname:e.history.location.pathname}),{matches:b,route:S}=ut(s);x=!0,R=b,P={[S.id]:v}}else if(R&&!e.hydrationData&&At(R,s,e.history.location.pathname).active&&(R=null),R)if(R.some(v=>v.route.lazy))x=!1;else if(!R.some(v=>Gr(v.route)))x=!0;else{let v=e.hydrationData?e.hydrationData.loaderData:null,b=e.hydrationData?e.hydrationData.errors:null;if(b){let S=R.findIndex(D=>b[D.route.id]!==void 0);x=R.slice(0,S+1).every(D=>!Or(D.route,v,b))}else x=R.every(S=>!Or(S.route,v,b))}else{x=!1,R=[];let v=At(null,s,e.history.location.pathname);v.active&&v.matches&&(C=!0,R=v.matches)}let L,E={historyAction:e.history.action,location:e.history.location,matches:R,initialized:x,navigation:Yt,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||P,fetchers:new Map,blockers:new Map},O="POP",_=!1,k,M=!1,V=new Map,X=null,z=!1,J=!1,le=new Set,Y=new Map,Ee=0,pe=-1,Pe=new Map,ye=new Set,be=new Map,Le=new Map,De=new Set,Je=new Map,Mt,gt=null;function gi(){if(m=e.history.listen(({action:v,location:b,delta:S})=>{if(Mt){Mt(),Mt=void 0;return}K(Je.size===0||S!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let D=_a({currentLocation:E.location,nextLocation:b,historyAction:v});if(D&&S!=null){let T=new Promise(N=>{Mt=N});e.history.go(S*-1),Nt(D,{state:"blocked",location:b,proceed(){Nt(D,{state:"proceeding",proceed:void 0,reset:void 0,location:b}),T.then(()=>e.history.go(S))},reset(){let N=new Map(E.blockers);N.set(D,et),se({blockers:N})}});return}return Ke(v,b)}),r){Ml(t,V);let v=()=>Nl(t,V);t.addEventListener("pagehide",v),X=()=>t.removeEventListener("pagehide",v)}return E.initialized||Ke("POP",E.location,{initialHydration:!0}),L}function wi(){m&&m(),X&&X(),p.clear(),k&&k.abort(),E.fetchers.forEach((v,b)=>gr(b)),E.blockers.forEach((v,b)=>Ta(b))}function Ri(v){return p.add(v),()=>p.delete(v)}function se(v,b={}){v.matches&&(v.matches=v.matches.map(T=>{let N=i[T.route.id],A=T.route;return A.element!==N.element||A.errorElement!==N.errorElement||A.hydrateFallbackElement!==N.hydrateFallbackElement?{...T,route:N}:T})),E={...E,...v};let S=[],D=[];E.fetchers.forEach((T,N)=>{T.state==="idle"&&(De.has(N)?S.push(N):D.push(N))}),De.forEach(T=>{!E.fetchers.has(T)&&!Y.has(T)&&S.push(T)}),[...p].forEach(T=>T(E,{deletedFetchers:S,viewTransitionOpts:b.viewTransitionOpts,flushSync:b.flushSync===!0})),S.forEach(T=>gr(T)),D.forEach(T=>E.fetchers.delete(T))}function ot(v,b,{flushSync:S}={}){let D=E.actionData!=null&&E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&E.navigation.state==="loading"&&v.state?._isRedirect!==!0,T;b.actionData?Object.keys(b.actionData).length>0?T=b.actionData:T=null:D?T=E.actionData:T=null;let N=b.loaderData?en(E.loaderData,b.loaderData,b.matches||[],b.errors):E.loaderData,A=E.blockers;A.size>0&&(A=new Map(A),A.forEach((H,j)=>A.set(j,et)));let F=z?!1:Oa(v,b.matches||E.matches),$=_===!0||E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&v.state?._isRedirect!==!0;l&&(s=l,l=void 0),z||O==="POP"||(O==="PUSH"?e.history.push(v,v.state):O==="REPLACE"&&e.history.replace(v,v.state));let U;if(O==="POP"){let H=V.get(E.location.pathname);H&&H.has(v.pathname)?U={currentLocation:E.location,nextLocation:v}:V.has(v.pathname)&&(U={currentLocation:v,nextLocation:E.location})}else if(M){let H=V.get(E.location.pathname);H?H.add(v.pathname):(H=new Set([v.pathname]),V.set(E.location.pathname,H)),U={currentLocation:E.location,nextLocation:v}}se({...b,actionData:T,loaderData:N,historyAction:O,location:v,initialized:!0,navigation:Yt,revalidation:"idle",restoreScrollPosition:F,preventScrollReset:$,blockers:A},{viewTransitionOpts:U,flushSync:S===!0}),O="POP",_=!1,M=!1,z=!1,J=!1,gt?.resolve(),gt=null}async function ba(v,b){if(typeof v=="number"){e.history.go(v);return}let S=kr(E.location,E.matches,u,v,b?.fromRouteId,b?.relative),{path:D,submission:T,error:N}=Wa(!1,S,b),A=E.location,F=Ae(E.location,D,b&&b.state);F={...F,...e.history.encodeLocation(F)};let $=b&&b.replace!=null?b.replace:void 0,U="PUSH";$===!0?U="REPLACE":$===!1||T!=null&&de(T.formMethod)&&T.formAction===E.location.pathname+E.location.search&&(U="REPLACE");let H=b&&"preventScrollReset"in b?b.preventScrollReset===!0:void 0,j=(b&&b.flushSync)===!0,B=_a({currentLocation:A,nextLocation:F,historyAction:U});if(B){Nt(B,{state:"blocked",location:F,proceed(){Nt(B,{state:"proceeding",proceed:void 0,reset:void 0,location:F}),ba(v,b)},reset(){let Z=new Map(E.blockers);Z.set(B,et),se({blockers:Z})}});return}await Ke(U,F,{submission:T,pendingError:N,preventScrollReset:H,replace:b&&b.replace,enableViewTransition:b&&b.viewTransition,flushSync:j})}function Ei(){gt||(gt=Al()),vr(),se({revalidation:"loading"});let v=gt.promise;return E.navigation.state==="submitting"?v:E.navigation.state==="idle"?(Ke(E.historyAction,E.location,{startUninterruptedRevalidation:!0}),v):(Ke(O||E.historyAction,E.navigation.location,{overrideNavigation:E.navigation,enableViewTransition:M===!0}),v)}async function Ke(v,b,S){k&&k.abort(),k=null,O=v,z=(S&&S.startUninterruptedRevalidation)===!0,Oi(E.location,E.matches),_=(S&&S.preventScrollReset)===!0,M=(S&&S.enableViewTransition)===!0;let D=l||s,T=S&&S.overrideNavigation,N=S?.initialHydration&&E.matches&&E.matches.length>0&&!C?E.matches:ve(D,b,u),A=(S&&S.flushSync)===!0;if(N&&E.initialized&&!J&&Tl(E.location,b)&&!(S&&S.submission&&de(S.submission.formMethod))){ot(b,{matches:N},{flushSync:A});return}let F=At(N,D,b.pathname);if(F.active&&F.matches&&(N=F.matches),!N){let{error:oe,notFoundMatches:G,route:Q}=wr(b.pathname);ot(b,{matches:G,loaderData:{},errors:{[Q.id]:oe}},{flushSync:A});return}k=new AbortController;let $=st(e.history,b,k.signal,S&&S.submission),U=e.getContext?await e.getContext():new Ne,H;if(S&&S.pendingError)H=[Ce(N).route.id,{type:"error",error:S.pendingError}];else if(S&&S.submission&&de(S.submission.formMethod)){let oe=await bi($,b,S.submission,N,U,F.active,S&&S.initialHydration===!0,{replace:S.replace,flushSync:A});if(oe.shortCircuited)return;if(oe.pendingActionResult){let[G,Q]=oe.pendingActionResult;if(ie(Q)&&re(Q.error)&&Q.error.status===404){k=null,ot(b,{matches:oe.matches,loaderData:{},errors:{[G]:Q.error}});return}}N=oe.matches||N,H=oe.pendingActionResult,T=Sr(b,S.submission),A=!1,F.active=!1,$=st(e.history,$.url,$.signal)}let{shortCircuited:j,matches:B,loaderData:Z,errors:ae}=await Si($,b,N,U,F.active,T,S&&S.submission,S&&S.fetcherSubmission,S&&S.replace,S&&S.initialHydration===!0,A,H);j||(k=null,ot(b,{matches:B||N,...tn(H),loaderData:Z,errors:ae}))}async function bi(v,b,S,D,T,N,A,F={}){vr();let $=Ol(b,S);if(se({navigation:$},{flushSync:F.flushSync===!0}),N){let j=await $t(D,b.pathname,v.signal);if(j.type==="aborted")return{shortCircuited:!0};if(j.type==="error"){if(j.partialMatches.length===0){let{matches:Z,route:ae}=ut(s);return{matches:Z,pendingActionResult:[ae.id,{type:"error",error:j.error}]}}let B=Ce(j.partialMatches).route.id;return{matches:j.partialMatches,pendingActionResult:[B,{type:"error",error:j.error}]}}else if(j.matches)D=j.matches;else{let{notFoundMatches:B,error:Z,route:ae}=wr(b.pathname);return{matches:B,pendingActionResult:[ae.id,{type:"error",error:Z}]}}}let U,H=dt(D,b);if(!H.route.action&&!H.route.lazy)U={type:"error",error:te(405,{method:v.method,pathname:b.pathname,routeId:H.route.id})};else{let j=ze(o,i,v,D,H,A?[]:a,T),B=await wt(v,j,T,null);if(U=B[H.route.id],!U){for(let Z of D)if(B[Z.route.id]){U=B[Z.route.id];break}}if(v.signal.aborted)return{shortCircuited:!0}}if(Ue(U)){let j;return F&&F.replace!=null?j=F.replace:j=Qa(U.response.headers.get("Location"),new URL(v.url),u)===E.location.pathname+E.location.search,await Xe(v,U,!0,{submission:S,replace:j}),{shortCircuited:!0}}if(ie(U)){let j=Ce(D,H.route.id);return(F&&F.replace)!==!0&&(O="PUSH"),{matches:D,pendingActionResult:[j.route.id,U,H.route.id]}}return{matches:D,pendingActionResult:[H.route.id,U]}}async function Si(v,b,S,D,T,N,A,F,$,U,H,j){let B=N||Sr(b,A),Z=A||F||rn(B),ae=!z&&!U;if(T){if(ae){let ue=Sa(j);se({navigation:B,...ue!==void 0?{actionData:ue}:{}},{flushSync:H})}let W=await $t(S,b.pathname,v.signal);if(W.type==="aborted")return{shortCircuited:!0};if(W.type==="error"){if(W.partialMatches.length===0){let{matches:it,route:Ze}=ut(s);return{matches:it,loaderData:{},errors:{[Ze.id]:W.error}}}let ue=Ce(W.partialMatches).route.id;return{matches:W.partialMatches,loaderData:{},errors:{[ue]:W.error}}}else if(W.matches)S=W.matches;else{let{error:ue,notFoundMatches:it,route:Ze}=wr(b.pathname);return{matches:it,loaderData:{},errors:{[Ze.id]:ue}}}}let oe=l||s,{dsMatches:G,revalidatingFetchers:Q}=Va(v,D,o,i,e.history,E,S,Z,b,U?[]:a,U===!0,J,le,De,be,ye,oe,u,e.patchRoutesOnNavigation!=null,j);if(pe=++Ee,!e.dataStrategy&&!G.some(W=>W.shouldLoad)&&!G.some(W=>W.route.middleware&&W.route.middleware.length>0)&&Q.length===0){let W=La();return ot(b,{matches:S,loaderData:{},errors:j&&ie(j[1])?{[j[0]]:j[1].error}:null,...tn(j),...W?{fetchers:new Map(E.fetchers)}:{}},{flushSync:H}),{shortCircuited:!0}}if(ae){let W={};if(!T){W.navigation=B;let ue=Sa(j);ue!==void 0&&(W.actionData=ue)}Q.length>0&&(W.fetchers=Ci(Q)),se(W,{flushSync:H})}Q.forEach(W=>{Fe(W.key),W.controller&&Y.set(W.key,W.controller)});let Ge=()=>Q.forEach(W=>Fe(W.key));k&&k.signal.addEventListener("abort",Ge);let{loaderResults:Rt,fetcherResults:He}=await Ca(G,Q,v,D);if(v.signal.aborted)return{shortCircuited:!0};k&&k.signal.removeEventListener("abort",Ge),Q.forEach(W=>Y.delete(W.key));let Te=Ut(Rt);if(Te)return await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};if(Te=Ut(He),Te)return ye.add(Te.key),await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};let{loaderData:Rr,errors:Et}=qa(E,S,Rt,j,Q,He);U&&E.errors&&(Et={...E.errors,...Et});let Qe=La(),It=Da(pe),Ht=Qe||It||Q.length>0;return{matches:S,loaderData:Rr,errors:Et,...Ht?{fetchers:new Map(E.fetchers)}:{}}}function Sa(v){if(v&&!ie(v[1]))return{[v[0]]:v[1].data};if(E.actionData)return Object.keys(E.actionData).length===0?null:E.actionData}function Ci(v){return v.forEach(b=>{let S=E.fetchers.get(b.key),D=bt(void 0,S?S.data:void 0);E.fetchers.set(b.key,D)}),new Map(E.fetchers)}async function xi(v,b,S,D){Fe(v);let T=(D&&D.flushSync)===!0,N=l||s,A=kr(E.location,E.matches,u,S,b,D?.relative),F=ve(N,A,u),$=At(F,N,A);if($.active&&$.matches&&(F=$.matches),!F){Oe(v,b,te(404,{pathname:A}),{flushSync:T});return}let{path:U,submission:H,error:j}=Wa(!0,A,D);if(j){Oe(v,b,j,{flushSync:T});return}let B=e.getContext?await e.getContext():new Ne,Z=(D&&D.preventScrollReset)===!0;if(H&&de(H.formMethod)){await Pi(v,b,U,F,B,$.active,T,Z,H);return}be.set(v,{routeId:b,path:U}),await Li(v,b,U,F,B,$.active,T,Z,H)}async function Pi(v,b,S,D,T,N,A,F,$){vr(),be.delete(v);let U=E.fetchers.get(v);ke(v,Fl($,U),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal,$);if(N){let ee=await $t(D,new URL(j.url).pathname,j.signal,v);if(ee.type==="aborted")return;if(ee.type==="error"){Oe(v,b,ee.error,{flushSync:A});return}else if(ee.matches)D=ee.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);if(!B.route.action&&!B.route.lazy){let ee=te(405,{method:$.formMethod,pathname:S,routeId:b});Oe(v,b,ee,{flushSync:A});return}Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),oe=await wt(j,ae,T,v),G=oe[B.route.id];if(!G){for(let ee of ae)if(oe[ee.route.id]){G=oe[ee.route.id];break}}if(j.signal.aborted){Y.get(v)===H&&Y.delete(v);return}if(De.has(v)){if(Ue(G)||ie(G)){ke(v,Me(void 0));return}}else{if(Ue(G))if(Y.delete(v),pe>Z){ke(v,Me(void 0));return}else return ye.add(v),ke(v,bt($)),Xe(j,G,!1,{fetcherSubmission:$,preventScrollReset:F});if(ie(G)){Oe(v,b,G.error);return}}let Q=E.navigation.location||E.location,Ge=st(e.history,Q,H.signal),Rt=l||s,He=E.navigation.state!=="idle"?ve(Rt,E.navigation.location,u):E.matches;I(He,"Didn't find any matches after fetcher action");let Te=++Ee;Pe.set(v,Te);let Rr=bt($,G.data);E.fetchers.set(v,Rr);let{dsMatches:Et,revalidatingFetchers:Qe}=Va(Ge,T,o,i,e.history,E,He,$,Q,a,!1,J,le,De,be,ye,Rt,u,e.patchRoutesOnNavigation!=null,[B.route.id,G]);Qe.filter(ee=>ee.key!==v).forEach(ee=>{let jt=ee.key,Ma=E.fetchers.get(jt),Ni=bt(void 0,Ma?Ma.data:void 0);E.fetchers.set(jt,Ni),Fe(jt),ee.controller&&Y.set(jt,ee.controller)}),se({fetchers:new Map(E.fetchers)});let It=()=>Qe.forEach(ee=>Fe(ee.key));H.signal.addEventListener("abort",It);let{loaderResults:Ht,fetcherResults:W}=await Ca(Et,Qe,Ge,T);if(H.signal.aborted)return;if(H.signal.removeEventListener("abort",It),Pe.delete(v),Y.delete(v),Qe.forEach(ee=>Y.delete(ee.key)),E.fetchers.has(v)){let ee=Me(G.data);E.fetchers.set(v,ee)}let ue=Ut(Ht);if(ue)return Xe(Ge,ue.result,!1,{preventScrollReset:F});if(ue=Ut(W),ue)return ye.add(ue.key),Xe(Ge,ue.result,!1,{preventScrollReset:F});let{loaderData:it,errors:Ze}=qa(E,He,Ht,void 0,Qe,W);Da(Te),E.navigation.state==="loading"&&Te>pe?(I(O,"Expected pending action"),k&&k.abort(),ot(E.navigation.location,{matches:He,loaderData:it,errors:Ze,fetchers:new Map(E.fetchers)})):(se({errors:Ze,loaderData:en(E.loaderData,it,He,Ze),fetchers:new Map(E.fetchers)}),J=!1)}async function Li(v,b,S,D,T,N,A,F,$){let U=E.fetchers.get(v);ke(v,bt($,U?U.data:void 0),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal);if(N){let Q=await $t(D,new URL(j.url).pathname,j.signal,v);if(Q.type==="aborted")return;if(Q.type==="error"){Oe(v,b,Q.error,{flushSync:A});return}else if(Q.matches)D=Q.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),G=(await wt(j,ae,T,v))[B.route.id];if(Y.get(v)===H&&Y.delete(v),!j.signal.aborted){if(De.has(v)){ke(v,Me(void 0));return}if(Ue(G))if(pe>Z){ke(v,Me(void 0));return}else{ye.add(v),await Xe(j,G,!1,{preventScrollReset:F});return}if(ie(G)){Oe(v,b,G.error);return}ke(v,Me(G.data))}}async function Xe(v,b,S,{submission:D,fetcherSubmission:T,preventScrollReset:N,replace:A}={}){b.response.headers.has("X-Remix-Revalidate")&&(J=!0);let F=b.response.headers.get("Location");I(F,"Expected a Location header on the redirect Response"),F=Qa(F,new URL(v.url),u);let $=Ae(E.location,F,{_isRedirect:!0});if(r){let ae=!1;if(b.response.headers.has("X-Remix-Reload-Document"))ae=!0;else if(nr(F)){const oe=Tn(F,!0);ae=oe.origin!==t.location.origin||ne(oe.pathname,u)==null}if(ae){A?t.location.replace(F):t.location.assign(F);return}}k=null;let U=A===!0||b.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:H,formAction:j,formEncType:B}=E.navigation;!D&&!T&&H&&j&&B&&(D=rn(E.navigation));let Z=D||T;if(El.has(b.response.status)&&Z&&de(Z.formMethod))await Ke(U,$,{submission:{...Z,formAction:F},preventScrollReset:N||_,enableViewTransition:S?M:void 0});else{let ae=Sr($,D);await Ke(U,$,{overrideNavigation:ae,fetcherSubmission:T,preventScrollReset:N||_,enableViewTransition:S?M:void 0})}}async function wt(v,b,S,D){let T,N={};try{T=await Zn(c,v,b,D,S,!1)}catch(A){return b.filter(F=>F.shouldLoad).forEach(F=>{N[F.route.id]={type:"error",error:A}}),N}if(v.signal.aborted)return N;for(let[A,F]of Object.entries(T))if(oo(F)){let $=F.result;N[A]={type:"redirect",response:to($,v,A,b,u)}}else N[A]=await eo(F);return N}async function Ca(v,b,S,D){let T=wt(S,v,D,null),N=Promise.all(b.map(async $=>{if($.matches&&$.match&&$.request&&$.controller){let H=(await wt($.request,$.matches,D,$.key))[$.match.route.id];return{[$.key]:H}}else return Promise.resolve({[$.key]:{type:"error",error:te(404,{pathname:$.path})}})})),A=await T,F=(await N).reduce(($,U)=>Object.assign($,U),{});return{loaderResults:A,fetcherResults:F}}function vr(){J=!0,be.forEach((v,b)=>{Y.has(b)&&le.add(b),Fe(b)})}function ke(v,b,S={}){E.fetchers.set(v,b),se({fetchers:new Map(E.fetchers)},{flushSync:(S&&S.flushSync)===!0})}function Oe(v,b,S,D={}){let T=Ce(E.matches,b);gr(v),se({errors:{[T.route.id]:S},fetchers:new Map(E.fetchers)},{flushSync:(D&&D.flushSync)===!0})}function xa(v){return Le.set(v,(Le.get(v)||0)+1),De.has(v)&&De.delete(v),E.fetchers.get(v)||Kr}function Di(v,b){Fe(v,b?.reason),ke(v,Me(null))}function gr(v){let b=E.fetchers.get(v);Y.has(v)&&!(b&&b.state==="loading"&&Pe.has(v))&&Fe(v),be.delete(v),Pe.delete(v),ye.delete(v),De.delete(v),le.delete(v),E.fetchers.delete(v)}function Ti(v){let b=(Le.get(v)||0)-1;b<=0?(Le.delete(v),De.add(v)):Le.set(v,b),se({fetchers:new Map(E.fetchers)})}function Fe(v,b){let S=Y.get(v);S&&(S.abort(b),Y.delete(v))}function Pa(v){for(let b of v){let S=xa(b),D=Me(S.data);E.fetchers.set(b,D)}}function La(){let v=[],b=!1;for(let S of ye){let D=E.fetchers.get(S);I(D,`Expected fetcher: ${S}`),D.state==="loading"&&(ye.delete(S),v.push(S),b=!0)}return Pa(v),b}function Da(v){let b=[];for(let[S,D]of Pe)if(D<v){let T=E.fetchers.get(S);I(T,`Expected fetcher: ${S}`),T.state==="loading"&&(Fe(S),Pe.delete(S),b.push(S))}return Pa(b),b.length>0}function _i(v,b){let S=E.blockers.get(v)||et;return Je.get(v)!==b&&Je.set(v,b),S}function Ta(v){E.blockers.delete(v),Je.delete(v)}function Nt(v,b){let S=E.blockers.get(v)||et;I(S.state==="unblocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="proceeding"||S.state==="blocked"&&b.state==="unblocked"||S.state==="proceeding"&&b.state==="unblocked",`Invalid blocker state transition: ${S.state} -> ${b.state}`);let D=new Map(E.blockers);D.set(v,b),se({blockers:D})}function _a({currentLocation:v,nextLocation:b,historyAction:S}){if(Je.size===0)return;Je.size>1&&K(!1,"A router only supports one blocker at a time");let D=Array.from(Je.entries()),[T,N]=D[D.length-1],A=E.blockers.get(T);if(!(A&&A.state==="proceeding")&&N({currentLocation:v,nextLocation:b,historyAction:S}))return T}function wr(v){let b=te(404,{pathname:v}),S=l||s,{matches:D,route:T}=ut(S);return{notFoundMatches:D,route:T,error:b}}function ki(v,b,S){if(f=v,y=b,g=S||null,!w&&E.navigation===Yt){w=!0;let D=Oa(E.location,E.matches);D!=null&&se({restoreScrollPosition:D})}return()=>{f=null,y=null,g=null}}function ka(v,b){return g&&g(v,b.map(D=>_n(D,E.loaderData)))||v.key}function Oi(v,b){if(f&&y){let S=ka(v,b);f[S]=y()}}function Oa(v,b){if(f){let S=ka(v,b),D=f[S];if(typeof D=="number")return D}return null}function At(v,b,S){if(e.patchRoutesOnNavigation)if(v){if(Object.keys(v[0].params).length>0)return{active:!0,matches:Pt(b,S,u,!0)}}else return{active:!0,matches:Pt(b,S,u,!0)||[]};return{active:!1,matches:null}}async function $t(v,b,S,D){if(!e.patchRoutesOnNavigation)return{type:"success",matches:v};let T=v;for(;;){let N=l==null,A=l||s,F=i;try{await e.patchRoutesOnNavigation({signal:S,path:b,matches:T,fetcherKey:D,patch:(H,j)=>{S.aborted||Ya(H,j,A,F,o,!1)}})}catch(H){return{type:"error",error:H,partialMatches:T}}finally{N&&!S.aborted&&(s=[...s])}if(S.aborted)return{type:"aborted"};let $=ve(A,b,u),U=null;if($){if(Object.keys($[0].params).length===0)return{type:"success",matches:$};if(U=Pt(A,b,u,!0),!(U&&T.length<U.length&&Fa(T,U.slice(0,T.length))))return{type:"success",matches:$}}if(U||(U=Pt(A,b,u,!0)),!U||Fa(T,U))return{type:"success",matches:null};T=U}}function Fa(v,b){return v.length===b.length&&v.every((S,D)=>S.route.id===b[D].route.id)}function Fi(v){i={},l=We(v,o,void 0,i)}function Mi(v,b,S=!1){let D=l==null;Ya(v,b,l||s,i,o,S),D&&(s=[...s],se({}))}return L={get basename(){return u},get future(){return d},get state(){return E},get routes(){return s},get window(){return t},initialize:gi,subscribe:Ri,enableScrollRestoration:ki,navigate:ba,fetch:xi,revalidate:Ei,createHref:v=>e.history.createHref(v),encodeLocation:v=>e.history.encodeLocation(v),getFetcher:xa,resetFetcher:Di,deleteFetcher:Ti,dispose:wi,getBlocker:_i,deleteBlocker:Ta,patchRoutes:Mi,_internalFetchControllers:Y,_internalSetRoutes:Fi,_internalSetStateDoNotUseOrYouWillBreakYourApp(v){se(v)}},e.unstable_instrumentations&&(L=ml(L,e.unstable_instrumentations.map(v=>v.router).filter(Boolean))),L}function Vn(e,t){I(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||zn,o=n;if(t?.unstable_instrumentations){let p=t.unstable_instrumentations;o=f=>({...n(f),...An(p.map(g=>g.route).filter(Boolean),f)})}let i=We(e,o,void 0,r);async function s(p,{requestContext:f,filterMatchesToLoad:g,skipLoaderErrorBubbling:y,skipRevalidation:w,dataStrategy:R,generateMiddlewareResponse:C}={}){let P=new URL(p.url),x=p.method,L=Ae("",he(P),null,"default"),E=ve(i,L,a);if(f=f??new Ne,!Ar(x)&&x!=="HEAD"){let _=te(405,{method:x}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}else if(!E){let _=te(404,{pathname:L.pathname}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}if(C){I(f instanceof Ne,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Xa(E,r,o);let _,k=await Ga({request:p,unstable_pattern:ct(E.map(M=>M.route.path)),matches:E,params:E[0].params,context:f},async()=>await C(async(V,X={})=>{let z=await u(V,L,E,f,R||null,y===!0,null,"filterMatchesToLoad"in X?X.filterMatchesToLoad??null:g??null,w===!0);return q(z)?z:(_={location:L,basename:a,...z},_)}),async(M,V)=>{if(Zt(M))return M;if(q(M))try{M=new me(M.status,M.statusText,await qn(M))}catch(X){M=X}if(Be(M)&&(M=_l(M)),_){V in _.loaderData&&(_.loaderData[V]=void 0);let X=Yn(i,_,M,y?V:Ce(E,V).route.id);return C(()=>Promise.resolve(X))}else{let X=y?V:Ce(E,E.find(J=>J.route.id===V||J.route.loader)?.route.id||V).route.id,z={matches:E,location:L,basename:a,loaderData:{},actionData:null,errors:{[X]:M},statusCode:re(M)?M.status:500,actionHeaders:{},loaderHeaders:{}};return C(()=>Promise.resolve(z))}});return I(q(k),"Expected a response in query()"),k}catch(_){if(q(_))return _;throw _}}let O=await u(p,L,E,f,R||null,y===!0,null,g||null,w===!0);return q(O)?O:{location:L,basename:a,...O}}async function l(p,{routeId:f,requestContext:g,dataStrategy:y,generateMiddlewareResponse:w}={}){let R=new URL(p.url),C=p.method,P=Ae("",he(R),null,"default"),x=ve(i,P,a);if(g=g??new Ne,!Ar(C)&&C!=="HEAD"&&C!=="OPTIONS")throw te(405,{method:C});if(!x)throw te(404,{pathname:P.pathname});let L=f?x.find(_=>_.route.id===f):dt(x,P);if(f&&!L)throw te(403,{pathname:P.pathname,routeId:f});if(!L)throw te(404,{pathname:P.pathname});if(w)return I(g instanceof Ne,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Xa(x,r,o),await Ga({request:p,unstable_pattern:ct(x.map(k=>k.route.path)),matches:x,params:x[0].params,context:g},async()=>await w(async M=>{let V=await u(M,P,x,g,y||null,!1,L,null,!1),X=O(V);return q(X)?X:typeof X=="string"?new Response(X):Response.json(X)}),k=>{if(Be(k))return Promise.resolve(Nr(k));if(q(k))return Promise.resolve(k);throw k});let E=await u(p,P,x,g,y||null,!1,L,null,!1);return O(E);function O(_){if(q(_))return _;let k=_.errors?Object.values(_.errors)[0]:void 0;if(k!==void 0)throw k;if(_.actionData)return Object.values(_.actionData)[0];if(_.loaderData)return Object.values(_.loaderData)[0]}}async function u(p,f,g,y,w,R,C,P,x){I(p.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(de(p.method))return await c(p,g,C||dt(g,f),y,w,R,C!=null,P,x);let L=await d(p,g,y,w,R,C,P);return q(L)?L:{...L,actionData:null,actionHeaders:{}}}catch(L){if(no(L)&&q(L.result)){if(L.type==="error")throw L.result;return L.result}if(Zt(L))return L;throw L}}async function c(p,f,g,y,w,R,C,P,x){let L;if(!g.route.action&&!g.route.lazy){let _=te(405,{method:p.method,pathname:new URL(p.url).pathname,routeId:g.route.id});if(C)throw _;L={type:"error",error:_}}else{let _=ze(o,r,p,f,g,[],y);L=(await m(p,_,C,y,w))[g.route.id],p.signal.aborted&&Ba(p,C)}if(Ue(L))throw new Response(null,{status:L.response.status,headers:{Location:L.response.headers.get("Location")}});if(C){if(ie(L))throw L.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:L.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(x)if(ie(L)){let _=R?g:Ce(f,g.route.id);return{statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}},matches:f,loaderData:{},errors:{[_.route.id]:L.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:L.data},actionHeaders:L.headers?{[g.route.id]:L.headers}:{},matches:f,loaderData:{},errors:null,statusCode:L.statusCode||200,loaderHeaders:{}};let E=new Request(p.url,{headers:p.headers,redirect:p.redirect,signal:p.signal});if(ie(L)){let _=R?g:Ce(f,g.route.id);return{...await d(E,f,y,w,R,null,P,[_.route.id,L]),statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}}}}return{...await d(E,f,y,w,R,null,P),actionData:{[g.route.id]:L.data},...L.statusCode?{statusCode:L.statusCode}:{},actionHeaders:L.headers?{[g.route.id]:L.headers}:{}}}async function d(p,f,g,y,w,R,C,P){let x=R!=null;if(x&&!R?.route.loader&&!R?.route.lazy)throw te(400,{method:p.method,pathname:new URL(p.url).pathname,routeId:R?.route.id});let L;if(R)L=ze(o,r,p,f,R,[],g);else{let _=P&&ie(P[1])?f.findIndex(M=>M.route.id===P[0])-1:void 0,k=ct(f.map(M=>M.route.path));L=f.map((M,V)=>_!=null&&V>_?Dt(o,r,p,k,M,[],g,!1):Dt(o,r,p,k,M,[],g,(M.route.loader||M.route.lazy)!=null&&(!C||C(M))))}if(!y&&!L.some(_=>_.shouldLoad))return{matches:f,loaderData:{},errors:P&&ie(P[1])?{[P[0]]:P[1].error}:null,statusCode:200,loaderHeaders:{}};let E=await m(p,L,x,g,y);return p.signal.aborted&&Ba(p,x),{...ro(f,E,P,!0,w),matches:f}}async function m(p,f,g,y,w){let R=await Zn(w||Fr,p,f,null,y,!0),C={};return await Promise.all(f.map(async P=>{if(!(P.route.id in R))return;let x=R[P.route.id];if(oo(x)){let L=x.result;throw to(L,p,P.route.id,f,a)}if(g){if(q(x.result))throw x;if(Be(x.result))throw Nr(x.result)}C[P.route.id]=await eo(x)})),C}return{dataRoutes:i,query:s,queryRoute:l}}function Yn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:re(r)?r.status:500,errors:{[n]:r}}}function Ba(e,t){if(e.signal.reason!==void 0)throw e.signal.reason;let r=t?"queryRoute":"query";throw new Error(`${r}() call aborted without an \`AbortSignal.reason\`: ${e.method} ${e.url}`)}function bl(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function kr(e,t,r,a,n,o){let i,s;if(n){i=[];for(let u of t)if(i.push(u),u.route.id===n){s=u;break}}else i=t,s=t[t.length-1];let l=ir(a||".",or(i),ne(e.pathname,r)||e.pathname,o==="path");if(a==null&&(l.search=e.search,l.hash=e.hash),(a==null||a===""||a===".")&&s){let u=Zr(l.search);if(s.route.index&&!u)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!s.route.index&&u){let c=new URLSearchParams(l.search),d=c.getAll("index");c.delete("index"),d.filter(p=>p).forEach(p=>c.append("index",p));let m=c.toString();l.search=m?`?${m}`:""}}return r!=="/"&&(l.pathname=nl({basename:r,pathname:l.pathname})),he(l)}function Wa(e,t,r){if(!r||!bl(r))return{path:t};if(r.formMethod&&!Ar(r.formMethod))return{path:t,error:te(405,{method:r.formMethod})};let a=()=>({path:t,error:te(400,{type:"invalid-body"})}),o=(r.formMethod||"get").toUpperCase(),i=ao(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!de(o))return a();let d=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,[p,f])=>`${m}${p}=${f}
1
+ import{r as h,R as ce,b as Ai}from"./index-rJak6aaF.js";var lt={exports:{}},Na;function $i(){if(Na)return lt.exports;Na=1;var e={decodeValues:!0,map:!1,silent:!1};function t(l){return typeof l!="string"||l in{}}function r(){return Object.create(null)}function a(l){return typeof l=="string"&&!!l.trim()}function n(l,u){var c=l.split(";").filter(a),d=c.shift(),m=o(d),p=m.name,f=m.value;if(u=u?Object.assign({},e,u):e,t(p))return null;try{f=u.decodeValues?decodeURIComponent(f):f}catch(y){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",y)}var g=r();return g.name=p,g.value=f,c.forEach(function(y){var w=y.split("="),R=w.shift().trimLeft().toLowerCase();if(!t(R)){var C=w.join("=");if(R==="expires")g.expires=new Date(C);else if(R==="max-age"){var P=parseInt(C,10);Number.isNaN(P)||(g.maxAge=P)}else R==="secure"?g.secure=!0:R==="httponly"?g.httpOnly=!0:R==="samesite"?g.sameSite=C:R==="partitioned"?g.partitioned=!0:R&&(g[R]=C)}}),g}function o(l){var u="",c="",d=l.split("=");return d.length>1?(u=d.shift(),c=d.join("=")):c=l,{name:u,value:c}}function i(l,u){if(u=u?Object.assign({},e,u):e,!l)return u.map?r():[];if(l.headers)if(typeof l.headers.getSetCookie=="function")l=l.headers.getSetCookie();else if(l.headers["set-cookie"])l=l.headers["set-cookie"];else{var c=l.headers[Object.keys(l.headers).find(function(m){return m.toLowerCase()==="set-cookie"})];!c&&l.headers.cookie&&!u.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),l=c}if(Array.isArray(l)||(l=[l]),u.map){var d=r();return l.filter(a).reduce(function(m,p){var f=n(p,u);return f&&!t(f.name)&&(m[f.name]=f),m},d)}else return l.filter(a).map(function(m){return n(m,u)}).filter(Boolean)}function s(l){if(Array.isArray(l))return l;if(typeof l!="string")return[];var u=[],c=0,d,m,p,f,g;function y(){for(;c<l.length&&/\s/.test(l.charAt(c));)c+=1;return c<l.length}function w(){return m=l.charAt(c),m!=="="&&m!==";"&&m!==","}for(;c<l.length;){for(d=c,g=!1;y();)if(m=l.charAt(c),m===","){for(p=c,c+=1,y(),f=c;c<l.length&&w();)c+=1;c<l.length&&l.charAt(c)==="="?(g=!0,c=f,u.push(l.substring(d,p)),d=c):c=p+1}else c+=1;(!g||c>=l.length)&&u.push(l.substring(d,l.length))}return u}return lt.exports=i,lt.exports.parse=i,lt.exports.parseString=n,lt.exports.splitCookiesString=s,lt.exports}var Ii=$i();var Cn=e=>{throw TypeError(e)},Hi=(e,t,r)=>t.has(e)||Cn("Cannot "+r),Er=(e,t,r)=>(Hi(e,t,"read from private field"),r?r.call(e):t.get(e)),ji=(e,t,r)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ui=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Ui||{}),Aa="popstate";function xn(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((p,f)=>c(p,typeof p=="string"?null:p.state,f===0?"default":void 0));let o=l(r??n.length-1),i="POP",s=null;function l(p){return Math.min(Math.max(p,0),n.length-1)}function u(){return n[o]}function c(p,f=null,g){let y=Ae(n?u().pathname:"/",p,f,g);return K(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function d(p){return typeof p=="string"?p:he(p)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:d,createURL(p){return new URL(d(p),"http://localhost")},encodeLocation(p){let f=typeof p=="string"?xe(p):p;return{pathname:f.pathname||"",search:f.search||"",hash:f.hash||""}},push(p,f){i="PUSH";let g=c(p,f);o+=1,n.splice(o,n.length,g),a&&s&&s({action:i,location:g,delta:1})},replace(p,f){i="REPLACE";let g=c(p,f);n[o]=g,a&&s&&s({action:i,location:g,delta:0})},go(p){i="POP";let f=l(o+p),g=n[f];o=f,s&&s({action:i,location:g,delta:p})},listen(p){return s=p,()=>{s=null}}}}function Pn(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return Ae("",{pathname:o,search:i,hash:s},n.state&&n.state.usr||null,n.state&&n.state.key||"default")}function r(a,n){return typeof n=="string"?n:he(n)}return Dn(t,r,null,e)}function Ln(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=xe(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ae("",{pathname:i,search:s,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function r(n,o){let i=n.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let l=n.location.href,u=l.indexOf("#");s=u===-1?l:l.slice(0,u)}return s+"#"+(typeof o=="string"?o:he(o))}function a(n,o){K(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Dn(t,r,a,e)}function I(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function K(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function zi(){return Math.random().toString(36).substring(2,10)}function $a(e,t){return{usr:e.state,key:e.key,idx:t}}function Ae(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?xe(t):t,state:r,key:t&&t.key||a||zi()}}function he({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function xe(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function Dn(e,t,r,a={}){let{window:n=document.defaultView,v5Compat:o=!1}=a,i=n.history,s="POP",l=null,u=c();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function c(){return(i.state||{idx:null}).idx}function d(){s="POP";let y=c(),w=y==null?null:y-u;u=y,l&&l({action:s,location:g.location,delta:w})}function m(y,w){s="PUSH";let R=Ae(g.location,y,w);r&&r(R,y),u=c()+1;let C=$a(R,u),P=g.createHref(R);try{i.pushState(C,"",P)}catch(x){if(x instanceof DOMException&&x.name==="DataCloneError")throw x;n.location.assign(P)}o&&l&&l({action:s,location:g.location,delta:1})}function p(y,w){s="REPLACE";let R=Ae(g.location,y,w);r&&r(R,y),u=c();let C=$a(R,u),P=g.createHref(R);i.replaceState(C,"",P),o&&l&&l({action:s,location:g.location,delta:0})}function f(y){return Tn(y)}let g={get action(){return s},get location(){return e(n,i)},listen(y){if(l)throw new Error("A history only accepts one active listener");return n.addEventListener(Aa,d),l=y,()=>{n.removeEventListener(Aa,d),l=null}},createHref(y){return t(n,y)},createURL:f,encodeLocation(y){let w=f(y);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:m,replace:p,go(y){return i.go(y)}};return g}function Tn(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),I(r,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:he(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=r+a),new URL(a,r)}function cc(e){return{defaultValue:e}}var xt,Ne=class{constructor(e){if(ji(this,xt,new Map),e)for(let[t,r]of e)this.set(t,r)}get(e){if(Er(this,xt).has(e))return Er(this,xt).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Er(this,xt).set(e,t)}};xt=new WeakMap;var Bi=new Set(["lazy","caseSensitive","path","id","index","children"]);function Wi(e){return Bi.has(e)}var Vi=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Yi(e){return Vi.has(e)}function Ji(e){return e.index===!0}function We(e,t,r=[],a={},n=!1){return e.map((o,i)=>{let s=[...r,String(i)],l=typeof o.id=="string"?o.id:s.join("-");if(I(o.index!==!0||!o.children,"Cannot specify children on an index route"),I(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),Ji(o)){let u={...o,id:l};return a[l]=Ia(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Ia(u,t(u)),o.children&&(u.children=We(o.children,t,s,a,n)),u}})}function Ia(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function ve(e,t,r="/"){return Pt(e,t,r,!1)}function Pt(e,t,r,a){let n=typeof t=="string"?xe(t):t,o=ne(n.pathname||"/",r);if(o==null)return null;let i=kn(e);Ki(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Mn(o);s=al(i[l],u,a)}return s}function _n(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],loaderData:t[r.id],handle:r.handle}}function kn(e,t=[],r=[],a="",n=!1){let o=(i,s,l=n,u)=>{let c={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(c.relativePath.startsWith("/")){if(!c.relativePath.startsWith(a)&&l)return;I(c.relativePath.startsWith(a),`Absolute route path "${c.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(a.length)}let d=_e([a,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(I(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),kn(i.children,t,m,d,l)),!(i.path==null&&!i.index)&&t.push({path:d,score:tl(d,i.index),routesMeta:m})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of On(i.path))o(i,s,!0,l)}),t}function On(e){let t=e.split("/");if(t.length===0)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(a.length===0)return n?[o,""]:[o];let i=On(a.join("/")),s=[];return s.push(...i.map(l=>l===""?o:[o,l].join("/"))),n&&s.push(...i),s.map(l=>e.startsWith("/")&&l===""?"/":l)}function Ki(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:rl(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}var Xi=/^:[\w-]+$/,Gi=3,Qi=2,Zi=1,qi=10,el=-2,Ha=e=>e==="*";function tl(e,t){let r=e.split("/"),a=r.length;return r.some(Ha)&&(a+=el),t&&(a+=Qi),r.filter(n=>!Ha(n)).reduce((n,o)=>n+(Xi.test(o)?Gi:o===""?Zi:qi),a)}function rl(e,t){return e.length===t.length&&e.slice(0,-1).every((a,n)=>a===t[n])?e[e.length-1]-t[t.length-1]:0}function al(e,t,r=!1){let{routesMeta:a}=e,n={},o="/",i=[];for(let s=0;s<a.length;++s){let l=a[s],u=s===a.length-1,c=o==="/"?t:t.slice(o.length)||"/",d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},c),m=l.route;if(!d&&u&&r&&!a[a.length-1].route.index&&(d=Lt({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},c)),!d)return null;Object.assign(n,d.params),i.push({params:n,pathname:_e([o,d.pathname]),pathnameBase:ll(_e([o,d.pathnameBase])),route:m}),d.pathnameBase!=="/"&&(o=_e([o,d.pathnameBase]))}return i}function dc(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(K(!1,`Route path "${r}" will be treated as if it were "${r.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${r.replace(/\*$/,"/*")}".`),r=r.replace(/\*$/,"/*"));const a=r.startsWith("/")?"/":"",n=i=>i==null?"":typeof i=="string"?i:String(i),o=r.split(/\/+/).map((i,s,l)=>{if(s===l.length-1&&i==="*")return n(t["*"]);const c=i.match(/^:([\w-]+)(\??)$/);if(c){const[,d,m]=c;let p=t[d];return I(m==="?"||p!=null,`Missing ":${d}" param`),encodeURIComponent(n(p))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function Lt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=Fn(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce((u,{paramName:c,isOptional:d},m)=>{if(c==="*"){let f=s[m]||"";i=o.slice(0,o.length-f.length).replace(/(.)\/+$/,"$1")}const p=s[m];return d&&!p?u[c]=void 0:u[c]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Fn(e,t=!1,r=!0){K(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,l)=>(a.push({paramName:s,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),n+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":e!==""&&e!=="/"&&(n+="(?:(?=\\/|$))"),[new RegExp(n,t?void 0:"i"),a]}function Mn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return K(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ne(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&a!=="/"?null:e.slice(r)||"/"}function nl({basename:e,pathname:t}){return t==="/"?e:_e([e,t])}var ol=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nr=e=>ol.test(e);function il(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?xe(e):e,o;if(r)if(nr(r))o=r;else{if(r.includes("//")){let i=r;r=r.replace(/\/\/+/g,"/"),K(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${r}`)}r.startsWith("/")?o=ja(r.substring(1),"/"):o=ja(r,t)}else o=t;return{pathname:o,search:sl(a),hash:ul(n)}}function ja(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(n=>{n===".."?r.length>1&&r.pop():n!=="."&&r.push(n)}),r.length>1?r.join("/"):"/"}function br(e,t,r,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Nn(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function or(e){let t=Nn(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function ir(e,t,r,a=!1){let n;typeof e=="string"?n=xe(e):(n={...e},I(!n.pathname||!n.pathname.includes("?"),br("?","pathname","search",n)),I(!n.pathname||!n.pathname.includes("#"),br("#","pathname","hash",n)),I(!n.search||!n.search.includes("#"),br("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let d=t.length-1;if(!a&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),d-=1;n.pathname=m.join("/")}s=d>=0?t[d]:"/"}let l=il(n,s),u=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}var _e=e=>e.join("/").replace(/\/\/+/g,"/"),ll=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),sl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ul=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,cl=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function dl(e,t){return new cl(e,typeof t=="number"?{status:t}:t)}var lr=(e,t=302)=>{let r=t;typeof r=="number"?r={status:r}:typeof r.status>"u"&&(r.status=302);let a=new Headers(r.headers);return a.set("Location",e),new Response(null,{...r,headers:a})},fl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},hl=(e,t)=>{let r=lr(e,t);return r.headers.set("X-Remix-Replace","true"),r},me=class{constructor(e,t,r,a=!1){this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function re(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ct(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var je=Symbol("Uninstrumented");function An(e,t){let r={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(n=>n({id:t.id,index:t.index,path:t.path,instrument(o){let i=Object.keys(r);for(let s of i)o[s]&&r[s].push(o[s])}}));let a={};if(typeof t.lazy=="function"&&r.lazy.length>0){let n=tt(r.lazy,t.lazy,()=>{});n&&(a.lazy=n)}if(typeof t.lazy=="object"){let n=t.lazy;["middleware","loader","action"].forEach(o=>{let i=n[o],s=r[`lazy.${o}`];if(typeof i=="function"&&s.length>0){let l=tt(s,i,()=>{});l&&(a.lazy=Object.assign(a.lazy||{},{[o]:l}))}})}return["loader","action"].forEach(n=>{let o=t[n];if(typeof o=="function"&&r[n].length>0){let i=o[je]??o,s=tt(r[n],i,(...l)=>Ua(l[0]));s&&(s[je]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[je]??n,i=tt(r.middleware,o,(...s)=>Ua(s[0]));return i?(i[je]=o,i):n})),a}function ml(e,t){let r={navigate:[],fetch:[]};if(t.forEach(a=>a({instrument(n){let o=Object.keys(n);for(let i of o)n[i]&&r[i].push(n[i])}})),r.navigate.length>0){let a=e.navigate[je]??e.navigate,n=tt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?he(i):".",...za(e,s??{})}});n&&(n[je]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[je]??e.fetch,n=tt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...za(e,l??{})}});n&&(n[je]=a,e.fetch=n)}return e}function pl(e,t){let r={request:[]};t.forEach(n=>n({instrument(o){let i=Object.keys(o);for(let s of i)o[s]&&r[s].push(o[s])}}));let a=e;return r.request.length>0&&(a=tt(r.request,e,(...n)=>{let[o,i]=n;return{request:In(o),context:i!=null?Hn(i):i}})),a}function tt(e,t,r){return e.length===0?null:async(...a)=>{let n=await $n(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function $n(e,t,r,a){let n=e[a],o;if(n){let i,s=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=$n(e,t,r,a-1),o=await i,I(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await n(s,t)}catch(l){console.error("An instrumentation function threw an error:",l)}i||await s(),await i}else try{o={type:"success",value:await r()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function Ua(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:In(t),params:{...a},unstable_pattern:n,context:Hn(r)}}function za(e,t){return{currentUrl:he(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function In(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function Hn(e){if(vl(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var yl=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function vl(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===yl}var jn=["POST","PUT","PATCH","DELETE"],gl=new Set(jn),wl=["GET",...jn],Rl=new Set(wl),Un=new Set([301,302,303,307,308]),El=new Set([307,308]),Yt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Kr={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},et={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},zn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Bn="remix-router-transitions",Wn=Symbol("ResetLoaderData");function Xr(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";I(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||zn,o=n;if(e.unstable_instrumentations){let v=e.unstable_instrumentations;o=b=>({...n(b),...An(v.map(S=>S.route).filter(Boolean),b)})}let i={},s=We(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let c=e.dataStrategy||Ll,d={...e.future},m=null,p=new Set,f=null,g=null,y=null,w=e.hydrationData!=null,R=ve(s,e.history.location,u),C=!1,P=null,x;if(R==null&&!e.patchRoutesOnNavigation){let v=te(404,{pathname:e.history.location.pathname}),{matches:b,route:S}=ut(s);x=!0,R=b,P={[S.id]:v}}else if(R&&!e.hydrationData&&At(R,s,e.history.location.pathname).active&&(R=null),R)if(R.some(v=>v.route.lazy))x=!1;else if(!R.some(v=>Gr(v.route)))x=!0;else{let v=e.hydrationData?e.hydrationData.loaderData:null,b=e.hydrationData?e.hydrationData.errors:null;if(b){let S=R.findIndex(D=>b[D.route.id]!==void 0);x=R.slice(0,S+1).every(D=>!Or(D.route,v,b))}else x=R.every(S=>!Or(S.route,v,b))}else{x=!1,R=[];let v=At(null,s,e.history.location.pathname);v.active&&v.matches&&(C=!0,R=v.matches)}let L,E={historyAction:e.history.action,location:e.history.location,matches:R,initialized:x,navigation:Yt,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||P,fetchers:new Map,blockers:new Map},O="POP",_=!1,k,M=!1,V=new Map,X=null,z=!1,J=!1,le=new Set,Y=new Map,Ee=0,pe=-1,Pe=new Map,ye=new Set,be=new Map,Le=new Map,De=new Set,Je=new Map,Mt,gt=null;function gi(){if(m=e.history.listen(({action:v,location:b,delta:S})=>{if(Mt){Mt(),Mt=void 0;return}K(Je.size===0||S!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let D=_a({currentLocation:E.location,nextLocation:b,historyAction:v});if(D&&S!=null){let T=new Promise(N=>{Mt=N});e.history.go(S*-1),Nt(D,{state:"blocked",location:b,proceed(){Nt(D,{state:"proceeding",proceed:void 0,reset:void 0,location:b}),T.then(()=>e.history.go(S))},reset(){let N=new Map(E.blockers);N.set(D,et),se({blockers:N})}});return}return Ke(v,b)}),r){Ml(t,V);let v=()=>Nl(t,V);t.addEventListener("pagehide",v),X=()=>t.removeEventListener("pagehide",v)}return E.initialized||Ke("POP",E.location,{initialHydration:!0}),L}function wi(){m&&m(),X&&X(),p.clear(),k&&k.abort(),E.fetchers.forEach((v,b)=>gr(b)),E.blockers.forEach((v,b)=>Ta(b))}function Ri(v){return p.add(v),()=>p.delete(v)}function se(v,b={}){v.matches&&(v.matches=v.matches.map(T=>{let N=i[T.route.id],A=T.route;return A.element!==N.element||A.errorElement!==N.errorElement||A.hydrateFallbackElement!==N.hydrateFallbackElement?{...T,route:N}:T})),E={...E,...v};let S=[],D=[];E.fetchers.forEach((T,N)=>{T.state==="idle"&&(De.has(N)?S.push(N):D.push(N))}),De.forEach(T=>{!E.fetchers.has(T)&&!Y.has(T)&&S.push(T)}),[...p].forEach(T=>T(E,{deletedFetchers:S,viewTransitionOpts:b.viewTransitionOpts,flushSync:b.flushSync===!0})),S.forEach(T=>gr(T)),D.forEach(T=>E.fetchers.delete(T))}function ot(v,b,{flushSync:S}={}){let D=E.actionData!=null&&E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&E.navigation.state==="loading"&&v.state?._isRedirect!==!0,T;b.actionData?Object.keys(b.actionData).length>0?T=b.actionData:T=null:D?T=E.actionData:T=null;let N=b.loaderData?en(E.loaderData,b.loaderData,b.matches||[],b.errors):E.loaderData,A=E.blockers;A.size>0&&(A=new Map(A),A.forEach((H,j)=>A.set(j,et)));let F=z?!1:Oa(v,b.matches||E.matches),$=_===!0||E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&v.state?._isRedirect!==!0;l&&(s=l,l=void 0),z||O==="POP"||(O==="PUSH"?e.history.push(v,v.state):O==="REPLACE"&&e.history.replace(v,v.state));let U;if(O==="POP"){let H=V.get(E.location.pathname);H&&H.has(v.pathname)?U={currentLocation:E.location,nextLocation:v}:V.has(v.pathname)&&(U={currentLocation:v,nextLocation:E.location})}else if(M){let H=V.get(E.location.pathname);H?H.add(v.pathname):(H=new Set([v.pathname]),V.set(E.location.pathname,H)),U={currentLocation:E.location,nextLocation:v}}se({...b,actionData:T,loaderData:N,historyAction:O,location:v,initialized:!0,navigation:Yt,revalidation:"idle",restoreScrollPosition:F,preventScrollReset:$,blockers:A},{viewTransitionOpts:U,flushSync:S===!0}),O="POP",_=!1,M=!1,z=!1,J=!1,gt?.resolve(),gt=null}async function ba(v,b){if(typeof v=="number"){e.history.go(v);return}let S=kr(E.location,E.matches,u,v,b?.fromRouteId,b?.relative),{path:D,submission:T,error:N}=Wa(!1,S,b),A=E.location,F=Ae(E.location,D,b&&b.state);F={...F,...e.history.encodeLocation(F)};let $=b&&b.replace!=null?b.replace:void 0,U="PUSH";$===!0?U="REPLACE":$===!1||T!=null&&de(T.formMethod)&&T.formAction===E.location.pathname+E.location.search&&(U="REPLACE");let H=b&&"preventScrollReset"in b?b.preventScrollReset===!0:void 0,j=(b&&b.flushSync)===!0,B=_a({currentLocation:A,nextLocation:F,historyAction:U});if(B){Nt(B,{state:"blocked",location:F,proceed(){Nt(B,{state:"proceeding",proceed:void 0,reset:void 0,location:F}),ba(v,b)},reset(){let Z=new Map(E.blockers);Z.set(B,et),se({blockers:Z})}});return}await Ke(U,F,{submission:T,pendingError:N,preventScrollReset:H,replace:b&&b.replace,enableViewTransition:b&&b.viewTransition,flushSync:j})}function Ei(){gt||(gt=Al()),vr(),se({revalidation:"loading"});let v=gt.promise;return E.navigation.state==="submitting"?v:E.navigation.state==="idle"?(Ke(E.historyAction,E.location,{startUninterruptedRevalidation:!0}),v):(Ke(O||E.historyAction,E.navigation.location,{overrideNavigation:E.navigation,enableViewTransition:M===!0}),v)}async function Ke(v,b,S){k&&k.abort(),k=null,O=v,z=(S&&S.startUninterruptedRevalidation)===!0,Oi(E.location,E.matches),_=(S&&S.preventScrollReset)===!0,M=(S&&S.enableViewTransition)===!0;let D=l||s,T=S&&S.overrideNavigation,N=S?.initialHydration&&E.matches&&E.matches.length>0&&!C?E.matches:ve(D,b,u),A=(S&&S.flushSync)===!0;if(N&&E.initialized&&!J&&Tl(E.location,b)&&!(S&&S.submission&&de(S.submission.formMethod))){ot(b,{matches:N},{flushSync:A});return}let F=At(N,D,b.pathname);if(F.active&&F.matches&&(N=F.matches),!N){let{error:oe,notFoundMatches:G,route:Q}=wr(b.pathname);ot(b,{matches:G,loaderData:{},errors:{[Q.id]:oe}},{flushSync:A});return}k=new AbortController;let $=st(e.history,b,k.signal,S&&S.submission),U=e.getContext?await e.getContext():new Ne,H;if(S&&S.pendingError)H=[Ce(N).route.id,{type:"error",error:S.pendingError}];else if(S&&S.submission&&de(S.submission.formMethod)){let oe=await bi($,b,S.submission,N,U,F.active,S&&S.initialHydration===!0,{replace:S.replace,flushSync:A});if(oe.shortCircuited)return;if(oe.pendingActionResult){let[G,Q]=oe.pendingActionResult;if(ie(Q)&&re(Q.error)&&Q.error.status===404){k=null,ot(b,{matches:oe.matches,loaderData:{},errors:{[G]:Q.error}});return}}N=oe.matches||N,H=oe.pendingActionResult,T=Sr(b,S.submission),A=!1,F.active=!1,$=st(e.history,$.url,$.signal)}let{shortCircuited:j,matches:B,loaderData:Z,errors:ae}=await Si($,b,N,U,F.active,T,S&&S.submission,S&&S.fetcherSubmission,S&&S.replace,S&&S.initialHydration===!0,A,H);j||(k=null,ot(b,{matches:B||N,...tn(H),loaderData:Z,errors:ae}))}async function bi(v,b,S,D,T,N,A,F={}){vr();let $=Ol(b,S);if(se({navigation:$},{flushSync:F.flushSync===!0}),N){let j=await $t(D,b.pathname,v.signal);if(j.type==="aborted")return{shortCircuited:!0};if(j.type==="error"){if(j.partialMatches.length===0){let{matches:Z,route:ae}=ut(s);return{matches:Z,pendingActionResult:[ae.id,{type:"error",error:j.error}]}}let B=Ce(j.partialMatches).route.id;return{matches:j.partialMatches,pendingActionResult:[B,{type:"error",error:j.error}]}}else if(j.matches)D=j.matches;else{let{notFoundMatches:B,error:Z,route:ae}=wr(b.pathname);return{matches:B,pendingActionResult:[ae.id,{type:"error",error:Z}]}}}let U,H=dt(D,b);if(!H.route.action&&!H.route.lazy)U={type:"error",error:te(405,{method:v.method,pathname:b.pathname,routeId:H.route.id})};else{let j=ze(o,i,v,D,H,A?[]:a,T),B=await wt(v,j,T,null);if(U=B[H.route.id],!U){for(let Z of D)if(B[Z.route.id]){U=B[Z.route.id];break}}if(v.signal.aborted)return{shortCircuited:!0}}if(Ue(U)){let j;return F&&F.replace!=null?j=F.replace:j=Qa(U.response.headers.get("Location"),new URL(v.url),u)===E.location.pathname+E.location.search,await Xe(v,U,!0,{submission:S,replace:j}),{shortCircuited:!0}}if(ie(U)){let j=Ce(D,H.route.id);return(F&&F.replace)!==!0&&(O="PUSH"),{matches:D,pendingActionResult:[j.route.id,U,H.route.id]}}return{matches:D,pendingActionResult:[H.route.id,U]}}async function Si(v,b,S,D,T,N,A,F,$,U,H,j){let B=N||Sr(b,A),Z=A||F||rn(B),ae=!z&&!U;if(T){if(ae){let ue=Sa(j);se({navigation:B,...ue!==void 0?{actionData:ue}:{}},{flushSync:H})}let W=await $t(S,b.pathname,v.signal);if(W.type==="aborted")return{shortCircuited:!0};if(W.type==="error"){if(W.partialMatches.length===0){let{matches:it,route:Ze}=ut(s);return{matches:it,loaderData:{},errors:{[Ze.id]:W.error}}}let ue=Ce(W.partialMatches).route.id;return{matches:W.partialMatches,loaderData:{},errors:{[ue]:W.error}}}else if(W.matches)S=W.matches;else{let{error:ue,notFoundMatches:it,route:Ze}=wr(b.pathname);return{matches:it,loaderData:{},errors:{[Ze.id]:ue}}}}let oe=l||s,{dsMatches:G,revalidatingFetchers:Q}=Va(v,D,o,i,e.history,E,S,Z,b,U?[]:a,U===!0,J,le,De,be,ye,oe,u,e.patchRoutesOnNavigation!=null,j);if(pe=++Ee,!e.dataStrategy&&!G.some(W=>W.shouldLoad)&&!G.some(W=>W.route.middleware&&W.route.middleware.length>0)&&Q.length===0){let W=La();return ot(b,{matches:S,loaderData:{},errors:j&&ie(j[1])?{[j[0]]:j[1].error}:null,...tn(j),...W?{fetchers:new Map(E.fetchers)}:{}},{flushSync:H}),{shortCircuited:!0}}if(ae){let W={};if(!T){W.navigation=B;let ue=Sa(j);ue!==void 0&&(W.actionData=ue)}Q.length>0&&(W.fetchers=Ci(Q)),se(W,{flushSync:H})}Q.forEach(W=>{Fe(W.key),W.controller&&Y.set(W.key,W.controller)});let Ge=()=>Q.forEach(W=>Fe(W.key));k&&k.signal.addEventListener("abort",Ge);let{loaderResults:Rt,fetcherResults:He}=await Ca(G,Q,v,D);if(v.signal.aborted)return{shortCircuited:!0};k&&k.signal.removeEventListener("abort",Ge),Q.forEach(W=>Y.delete(W.key));let Te=Ut(Rt);if(Te)return await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};if(Te=Ut(He),Te)return ye.add(Te.key),await Xe(v,Te.result,!0,{replace:$}),{shortCircuited:!0};let{loaderData:Rr,errors:Et}=qa(E,S,Rt,j,Q,He);U&&E.errors&&(Et={...E.errors,...Et});let Qe=La(),It=Da(pe),Ht=Qe||It||Q.length>0;return{matches:S,loaderData:Rr,errors:Et,...Ht?{fetchers:new Map(E.fetchers)}:{}}}function Sa(v){if(v&&!ie(v[1]))return{[v[0]]:v[1].data};if(E.actionData)return Object.keys(E.actionData).length===0?null:E.actionData}function Ci(v){return v.forEach(b=>{let S=E.fetchers.get(b.key),D=bt(void 0,S?S.data:void 0);E.fetchers.set(b.key,D)}),new Map(E.fetchers)}async function xi(v,b,S,D){Fe(v);let T=(D&&D.flushSync)===!0,N=l||s,A=kr(E.location,E.matches,u,S,b,D?.relative),F=ve(N,A,u),$=At(F,N,A);if($.active&&$.matches&&(F=$.matches),!F){Oe(v,b,te(404,{pathname:A}),{flushSync:T});return}let{path:U,submission:H,error:j}=Wa(!0,A,D);if(j){Oe(v,b,j,{flushSync:T});return}let B=e.getContext?await e.getContext():new Ne,Z=(D&&D.preventScrollReset)===!0;if(H&&de(H.formMethod)){await Pi(v,b,U,F,B,$.active,T,Z,H);return}be.set(v,{routeId:b,path:U}),await Li(v,b,U,F,B,$.active,T,Z,H)}async function Pi(v,b,S,D,T,N,A,F,$){vr(),be.delete(v);let U=E.fetchers.get(v);ke(v,Fl($,U),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal,$);if(N){let ee=await $t(D,new URL(j.url).pathname,j.signal,v);if(ee.type==="aborted")return;if(ee.type==="error"){Oe(v,b,ee.error,{flushSync:A});return}else if(ee.matches)D=ee.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);if(!B.route.action&&!B.route.lazy){let ee=te(405,{method:$.formMethod,pathname:S,routeId:b});Oe(v,b,ee,{flushSync:A});return}Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),oe=await wt(j,ae,T,v),G=oe[B.route.id];if(!G){for(let ee of ae)if(oe[ee.route.id]){G=oe[ee.route.id];break}}if(j.signal.aborted){Y.get(v)===H&&Y.delete(v);return}if(De.has(v)){if(Ue(G)||ie(G)){ke(v,Me(void 0));return}}else{if(Ue(G))if(Y.delete(v),pe>Z){ke(v,Me(void 0));return}else return ye.add(v),ke(v,bt($)),Xe(j,G,!1,{fetcherSubmission:$,preventScrollReset:F});if(ie(G)){Oe(v,b,G.error);return}}let Q=E.navigation.location||E.location,Ge=st(e.history,Q,H.signal),Rt=l||s,He=E.navigation.state!=="idle"?ve(Rt,E.navigation.location,u):E.matches;I(He,"Didn't find any matches after fetcher action");let Te=++Ee;Pe.set(v,Te);let Rr=bt($,G.data);E.fetchers.set(v,Rr);let{dsMatches:Et,revalidatingFetchers:Qe}=Va(Ge,T,o,i,e.history,E,He,$,Q,a,!1,J,le,De,be,ye,Rt,u,e.patchRoutesOnNavigation!=null,[B.route.id,G]);Qe.filter(ee=>ee.key!==v).forEach(ee=>{let jt=ee.key,Ma=E.fetchers.get(jt),Ni=bt(void 0,Ma?Ma.data:void 0);E.fetchers.set(jt,Ni),Fe(jt),ee.controller&&Y.set(jt,ee.controller)}),se({fetchers:new Map(E.fetchers)});let It=()=>Qe.forEach(ee=>Fe(ee.key));H.signal.addEventListener("abort",It);let{loaderResults:Ht,fetcherResults:W}=await Ca(Et,Qe,Ge,T);if(H.signal.aborted)return;if(H.signal.removeEventListener("abort",It),Pe.delete(v),Y.delete(v),Qe.forEach(ee=>Y.delete(ee.key)),E.fetchers.has(v)){let ee=Me(G.data);E.fetchers.set(v,ee)}let ue=Ut(Ht);if(ue)return Xe(Ge,ue.result,!1,{preventScrollReset:F});if(ue=Ut(W),ue)return ye.add(ue.key),Xe(Ge,ue.result,!1,{preventScrollReset:F});let{loaderData:it,errors:Ze}=qa(E,He,Ht,void 0,Qe,W);Da(Te),E.navigation.state==="loading"&&Te>pe?(I(O,"Expected pending action"),k&&k.abort(),ot(E.navigation.location,{matches:He,loaderData:it,errors:Ze,fetchers:new Map(E.fetchers)})):(se({errors:Ze,loaderData:en(E.loaderData,it,He,Ze),fetchers:new Map(E.fetchers)}),J=!1)}async function Li(v,b,S,D,T,N,A,F,$){let U=E.fetchers.get(v);ke(v,bt($,U?U.data:void 0),{flushSync:A});let H=new AbortController,j=st(e.history,S,H.signal);if(N){let Q=await $t(D,new URL(j.url).pathname,j.signal,v);if(Q.type==="aborted")return;if(Q.type==="error"){Oe(v,b,Q.error,{flushSync:A});return}else if(Q.matches)D=Q.matches;else{Oe(v,b,te(404,{pathname:S}),{flushSync:A});return}}let B=dt(D,S);Y.set(v,H);let Z=Ee,ae=ze(o,i,j,D,B,a,T),G=(await wt(j,ae,T,v))[B.route.id];if(Y.get(v)===H&&Y.delete(v),!j.signal.aborted){if(De.has(v)){ke(v,Me(void 0));return}if(Ue(G))if(pe>Z){ke(v,Me(void 0));return}else{ye.add(v),await Xe(j,G,!1,{preventScrollReset:F});return}if(ie(G)){Oe(v,b,G.error);return}ke(v,Me(G.data))}}async function Xe(v,b,S,{submission:D,fetcherSubmission:T,preventScrollReset:N,replace:A}={}){b.response.headers.has("X-Remix-Revalidate")&&(J=!0);let F=b.response.headers.get("Location");I(F,"Expected a Location header on the redirect Response"),F=Qa(F,new URL(v.url),u);let $=Ae(E.location,F,{_isRedirect:!0});if(r){let ae=!1;if(b.response.headers.has("X-Remix-Reload-Document"))ae=!0;else if(nr(F)){const oe=Tn(F,!0);ae=oe.origin!==t.location.origin||ne(oe.pathname,u)==null}if(ae){A?t.location.replace(F):t.location.assign(F);return}}k=null;let U=A===!0||b.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:H,formAction:j,formEncType:B}=E.navigation;!D&&!T&&H&&j&&B&&(D=rn(E.navigation));let Z=D||T;if(El.has(b.response.status)&&Z&&de(Z.formMethod))await Ke(U,$,{submission:{...Z,formAction:F},preventScrollReset:N||_,enableViewTransition:S?M:void 0});else{let ae=Sr($,D);await Ke(U,$,{overrideNavigation:ae,fetcherSubmission:T,preventScrollReset:N||_,enableViewTransition:S?M:void 0})}}async function wt(v,b,S,D){let T,N={};try{T=await Zn(c,v,b,D,S,!1)}catch(A){return b.filter(F=>F.shouldLoad).forEach(F=>{N[F.route.id]={type:"error",error:A}}),N}if(v.signal.aborted)return N;for(let[A,F]of Object.entries(T))if(oo(F)){let $=F.result;N[A]={type:"redirect",response:to($,v,A,b,u)}}else N[A]=await eo(F);return N}async function Ca(v,b,S,D){let T=wt(S,v,D,null),N=Promise.all(b.map(async $=>{if($.matches&&$.match&&$.request&&$.controller){let H=(await wt($.request,$.matches,D,$.key))[$.match.route.id];return{[$.key]:H}}else return Promise.resolve({[$.key]:{type:"error",error:te(404,{pathname:$.path})}})})),A=await T,F=(await N).reduce(($,U)=>Object.assign($,U),{});return{loaderResults:A,fetcherResults:F}}function vr(){J=!0,be.forEach((v,b)=>{Y.has(b)&&le.add(b),Fe(b)})}function ke(v,b,S={}){E.fetchers.set(v,b),se({fetchers:new Map(E.fetchers)},{flushSync:(S&&S.flushSync)===!0})}function Oe(v,b,S,D={}){let T=Ce(E.matches,b);gr(v),se({errors:{[T.route.id]:S},fetchers:new Map(E.fetchers)},{flushSync:(D&&D.flushSync)===!0})}function xa(v){return Le.set(v,(Le.get(v)||0)+1),De.has(v)&&De.delete(v),E.fetchers.get(v)||Kr}function Di(v,b){Fe(v,b?.reason),ke(v,Me(null))}function gr(v){let b=E.fetchers.get(v);Y.has(v)&&!(b&&b.state==="loading"&&Pe.has(v))&&Fe(v),be.delete(v),Pe.delete(v),ye.delete(v),De.delete(v),le.delete(v),E.fetchers.delete(v)}function Ti(v){let b=(Le.get(v)||0)-1;b<=0?(Le.delete(v),De.add(v)):Le.set(v,b),se({fetchers:new Map(E.fetchers)})}function Fe(v,b){let S=Y.get(v);S&&(S.abort(b),Y.delete(v))}function Pa(v){for(let b of v){let S=xa(b),D=Me(S.data);E.fetchers.set(b,D)}}function La(){let v=[],b=!1;for(let S of ye){let D=E.fetchers.get(S);I(D,`Expected fetcher: ${S}`),D.state==="loading"&&(ye.delete(S),v.push(S),b=!0)}return Pa(v),b}function Da(v){let b=[];for(let[S,D]of Pe)if(D<v){let T=E.fetchers.get(S);I(T,`Expected fetcher: ${S}`),T.state==="loading"&&(Fe(S),Pe.delete(S),b.push(S))}return Pa(b),b.length>0}function _i(v,b){let S=E.blockers.get(v)||et;return Je.get(v)!==b&&Je.set(v,b),S}function Ta(v){E.blockers.delete(v),Je.delete(v)}function Nt(v,b){let S=E.blockers.get(v)||et;I(S.state==="unblocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="blocked"||S.state==="blocked"&&b.state==="proceeding"||S.state==="blocked"&&b.state==="unblocked"||S.state==="proceeding"&&b.state==="unblocked",`Invalid blocker state transition: ${S.state} -> ${b.state}`);let D=new Map(E.blockers);D.set(v,b),se({blockers:D})}function _a({currentLocation:v,nextLocation:b,historyAction:S}){if(Je.size===0)return;Je.size>1&&K(!1,"A router only supports one blocker at a time");let D=Array.from(Je.entries()),[T,N]=D[D.length-1],A=E.blockers.get(T);if(!(A&&A.state==="proceeding")&&N({currentLocation:v,nextLocation:b,historyAction:S}))return T}function wr(v){let b=te(404,{pathname:v}),S=l||s,{matches:D,route:T}=ut(S);return{notFoundMatches:D,route:T,error:b}}function ki(v,b,S){if(f=v,y=b,g=S||null,!w&&E.navigation===Yt){w=!0;let D=Oa(E.location,E.matches);D!=null&&se({restoreScrollPosition:D})}return()=>{f=null,y=null,g=null}}function ka(v,b){return g&&g(v,b.map(D=>_n(D,E.loaderData)))||v.key}function Oi(v,b){if(f&&y){let S=ka(v,b);f[S]=y()}}function Oa(v,b){if(f){let S=ka(v,b),D=f[S];if(typeof D=="number")return D}return null}function At(v,b,S){if(e.patchRoutesOnNavigation)if(v){if(Object.keys(v[0].params).length>0)return{active:!0,matches:Pt(b,S,u,!0)}}else return{active:!0,matches:Pt(b,S,u,!0)||[]};return{active:!1,matches:null}}async function $t(v,b,S,D){if(!e.patchRoutesOnNavigation)return{type:"success",matches:v};let T=v;for(;;){let N=l==null,A=l||s,F=i;try{await e.patchRoutesOnNavigation({signal:S,path:b,matches:T,fetcherKey:D,patch:(H,j)=>{S.aborted||Ya(H,j,A,F,o,!1)}})}catch(H){return{type:"error",error:H,partialMatches:T}}finally{N&&!S.aborted&&(s=[...s])}if(S.aborted)return{type:"aborted"};let $=ve(A,b,u),U=null;if($){if(Object.keys($[0].params).length===0)return{type:"success",matches:$};if(U=Pt(A,b,u,!0),!(U&&T.length<U.length&&Fa(T,U.slice(0,T.length))))return{type:"success",matches:$}}if(U||(U=Pt(A,b,u,!0)),!U||Fa(T,U))return{type:"success",matches:null};T=U}}function Fa(v,b){return v.length===b.length&&v.every((S,D)=>S.route.id===b[D].route.id)}function Fi(v){i={},l=We(v,o,void 0,i)}function Mi(v,b,S=!1){let D=l==null;Ya(v,b,l||s,i,o,S),D&&(s=[...s],se({}))}return L={get basename(){return u},get future(){return d},get state(){return E},get routes(){return s},get window(){return t},initialize:gi,subscribe:Ri,enableScrollRestoration:ki,navigate:ba,fetch:xi,revalidate:Ei,createHref:v=>e.history.createHref(v),encodeLocation:v=>e.history.encodeLocation(v),getFetcher:xa,resetFetcher:Di,deleteFetcher:Ti,dispose:wi,getBlocker:_i,deleteBlocker:Ta,patchRoutes:Mi,_internalFetchControllers:Y,_internalSetRoutes:Fi,_internalSetStateDoNotUseOrYouWillBreakYourApp(v){se(v)}},e.unstable_instrumentations&&(L=ml(L,e.unstable_instrumentations.map(v=>v.router).filter(Boolean))),L}function Vn(e,t){I(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||zn,o=n;if(t?.unstable_instrumentations){let p=t.unstable_instrumentations;o=f=>({...n(f),...An(p.map(g=>g.route).filter(Boolean),f)})}let i=We(e,o,void 0,r);async function s(p,{requestContext:f,filterMatchesToLoad:g,skipLoaderErrorBubbling:y,skipRevalidation:w,dataStrategy:R,generateMiddlewareResponse:C}={}){let P=new URL(p.url),x=p.method,L=Ae("",he(P),null,"default"),E=ve(i,L,a);if(f=f??new Ne,!Ar(x)&&x!=="HEAD"){let _=te(405,{method:x}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}else if(!E){let _=te(404,{pathname:L.pathname}),{matches:k,route:M}=ut(i),V={basename:a,location:L,matches:k,loaderData:{},actionData:null,errors:{[M.id]:_},statusCode:_.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(V)):V}if(C){I(f instanceof Ne,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Xa(E,r,o);let _,k=await Ga({request:p,unstable_pattern:ct(E.map(M=>M.route.path)),matches:E,params:E[0].params,context:f},async()=>await C(async(V,X={})=>{let z=await u(V,L,E,f,R||null,y===!0,null,"filterMatchesToLoad"in X?X.filterMatchesToLoad??null:g??null,w===!0);return q(z)?z:(_={location:L,basename:a,...z},_)}),async(M,V)=>{if(Zt(M))return M;if(q(M))try{M=new me(M.status,M.statusText,await qn(M))}catch(X){M=X}if(Be(M)&&(M=_l(M)),_){V in _.loaderData&&(_.loaderData[V]=void 0);let X=Yn(i,_,M,y?V:Ce(E,V).route.id);return C(()=>Promise.resolve(X))}else{let X=y?V:Ce(E,E.find(J=>J.route.id===V||J.route.loader)?.route.id||V).route.id,z={matches:E,location:L,basename:a,loaderData:{},actionData:null,errors:{[X]:M},statusCode:re(M)?M.status:500,actionHeaders:{},loaderHeaders:{}};return C(()=>Promise.resolve(z))}});return I(q(k),"Expected a response in query()"),k}catch(_){if(q(_))return _;throw _}}let O=await u(p,L,E,f,R||null,y===!0,null,g||null,w===!0);return q(O)?O:{location:L,basename:a,...O}}async function l(p,{routeId:f,requestContext:g,dataStrategy:y,generateMiddlewareResponse:w}={}){let R=new URL(p.url),C=p.method,P=Ae("",he(R),null,"default"),x=ve(i,P,a);if(g=g??new Ne,!Ar(C)&&C!=="HEAD"&&C!=="OPTIONS")throw te(405,{method:C});if(!x)throw te(404,{pathname:P.pathname});let L=f?x.find(_=>_.route.id===f):dt(x,P);if(f&&!L)throw te(403,{pathname:P.pathname,routeId:f});if(!L)throw te(404,{pathname:P.pathname});if(w)return I(g instanceof Ne,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Xa(x,r,o),await Ga({request:p,unstable_pattern:ct(x.map(k=>k.route.path)),matches:x,params:x[0].params,context:g},async()=>await w(async M=>{let V=await u(M,P,x,g,y||null,!1,L,null,!1),X=O(V);return q(X)?X:typeof X=="string"?new Response(X):Response.json(X)}),k=>{if(Be(k))return Promise.resolve(Nr(k));if(q(k))return Promise.resolve(k);throw k});let E=await u(p,P,x,g,y||null,!1,L,null,!1);return O(E);function O(_){if(q(_))return _;let k=_.errors?Object.values(_.errors)[0]:void 0;if(k!==void 0)throw k;if(_.actionData)return Object.values(_.actionData)[0];if(_.loaderData)return Object.values(_.loaderData)[0]}}async function u(p,f,g,y,w,R,C,P,x){I(p.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(de(p.method))return await c(p,g,C||dt(g,f),y,w,R,C!=null,P,x);let L=await d(p,g,y,w,R,C,P);return q(L)?L:{...L,actionData:null,actionHeaders:{}}}catch(L){if(no(L)&&q(L.result)){if(L.type==="error")throw L.result;return L.result}if(Zt(L))return L;throw L}}async function c(p,f,g,y,w,R,C,P,x){let L;if(!g.route.action&&!g.route.lazy){let _=te(405,{method:p.method,pathname:new URL(p.url).pathname,routeId:g.route.id});if(C)throw _;L={type:"error",error:_}}else{let _=ze(o,r,p,f,g,[],y);L=(await m(p,_,C,y,w))[g.route.id],p.signal.aborted&&Ba(p,C)}if(Ue(L))throw new Response(null,{status:L.response.status,headers:{Location:L.response.headers.get("Location")}});if(C){if(ie(L))throw L.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:L.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(x)if(ie(L)){let _=R?g:Ce(f,g.route.id);return{statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}},matches:f,loaderData:{},errors:{[_.route.id]:L.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:L.data},actionHeaders:L.headers?{[g.route.id]:L.headers}:{},matches:f,loaderData:{},errors:null,statusCode:L.statusCode||200,loaderHeaders:{}};let E=new Request(p.url,{headers:p.headers,redirect:p.redirect,signal:p.signal});if(ie(L)){let _=R?g:Ce(f,g.route.id);return{...await d(E,f,y,w,R,null,P,[_.route.id,L]),statusCode:re(L.error)?L.error.status:L.statusCode!=null?L.statusCode:500,actionData:null,actionHeaders:{...L.headers?{[g.route.id]:L.headers}:{}}}}return{...await d(E,f,y,w,R,null,P),actionData:{[g.route.id]:L.data},...L.statusCode?{statusCode:L.statusCode}:{},actionHeaders:L.headers?{[g.route.id]:L.headers}:{}}}async function d(p,f,g,y,w,R,C,P){let x=R!=null;if(x&&!R?.route.loader&&!R?.route.lazy)throw te(400,{method:p.method,pathname:new URL(p.url).pathname,routeId:R?.route.id});let L;if(R)L=ze(o,r,p,f,R,[],g);else{let _=P&&ie(P[1])?f.findIndex(M=>M.route.id===P[0])-1:void 0,k=ct(f.map(M=>M.route.path));L=f.map((M,V)=>_!=null&&V>_?Dt(o,r,p,k,M,[],g,!1):Dt(o,r,p,k,M,[],g,(M.route.loader||M.route.lazy)!=null&&(!C||C(M))))}if(!y&&!L.some(_=>_.shouldLoad))return{matches:f,loaderData:{},errors:P&&ie(P[1])?{[P[0]]:P[1].error}:null,statusCode:200,loaderHeaders:{}};let E=await m(p,L,x,g,y);return p.signal.aborted&&Ba(p,x),{...ro(f,E,P,!0,w),matches:f}}async function m(p,f,g,y,w){let R=await Zn(w||Fr,p,f,null,y,!0),C={};return await Promise.all(f.map(async P=>{if(!(P.route.id in R))return;let x=R[P.route.id];if(oo(x)){let L=x.result;throw to(L,p,P.route.id,f,a)}if(g){if(q(x.result))throw x;if(Be(x.result))throw Nr(x.result)}C[P.route.id]=await eo(x)})),C}return{dataRoutes:i,query:s,queryRoute:l}}function Yn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:re(r)?r.status:500,errors:{[n]:r}}}function Ba(e,t){if(e.signal.reason!==void 0)throw e.signal.reason;let r=t?"queryRoute":"query";throw new Error(`${r}() call aborted without an \`AbortSignal.reason\`: ${e.method} ${e.url}`)}function bl(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function kr(e,t,r,a,n,o){let i,s;if(n){i=[];for(let u of t)if(i.push(u),u.route.id===n){s=u;break}}else i=t,s=t[t.length-1];let l=ir(a||".",or(i),ne(e.pathname,r)||e.pathname,o==="path");if(a==null&&(l.search=e.search,l.hash=e.hash),(a==null||a===""||a===".")&&s){let u=Zr(l.search);if(s.route.index&&!u)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!s.route.index&&u){let c=new URLSearchParams(l.search),d=c.getAll("index");c.delete("index"),d.filter(p=>p).forEach(p=>c.append("index",p));let m=c.toString();l.search=m?`?${m}`:""}}return r!=="/"&&(l.pathname=nl({basename:r,pathname:l.pathname})),he(l)}function Wa(e,t,r){if(!r||!bl(r))return{path:t};if(r.formMethod&&!Ar(r.formMethod))return{path:t,error:te(405,{method:r.formMethod})};let a=()=>({path:t,error:te(400,{type:"invalid-body"})}),o=(r.formMethod||"get").toUpperCase(),i=ao(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!de(o))return a();let d=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,[p,f])=>`${m}${p}=${f}
2
2
  `,""):String(r.body);return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:void 0,text:d}}}else if(r.formEncType==="application/json"){if(!de(o))return a();try{let d=typeof r.body=="string"?JSON.parse(r.body):r.body;return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:d,text:void 0}}}catch{return a()}}}I(typeof FormData=="function","FormData is not available in this environment");let s,l;if(r.formData)s=Mr(r.formData),l=r.formData;else if(r.body instanceof FormData)s=Mr(r.body),l=r.body;else if(r.body instanceof URLSearchParams)s=r.body,l=Za(s);else if(r.body==null)s=new URLSearchParams,l=new FormData;else try{s=new URLSearchParams(r.body),l=Za(s)}catch{return a()}let u={formMethod:o,formAction:i,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:l,json:void 0,text:void 0};if(de(u.formMethod))return{path:t,submission:u};let c=xe(t);return e&&c.search&&Zr(c.search)&&s.append("index",""),c.search=`?${s}`,{path:he(c),submission:u}}function Va(e,t,r,a,n,o,i,s,l,u,c,d,m,p,f,g,y,w,R,C){let P=C?ie(C[1])?C[1].error:C[1].data:void 0,x=n.createURL(o.location),L=n.createURL(l),E;if(c&&o.errors){let z=Object.keys(o.errors)[0];E=i.findIndex(J=>J.route.id===z)}else if(C&&ie(C[1])){let z=C[0];E=i.findIndex(J=>J.route.id===z)-1}let O=C?C[1].statusCode:void 0,_=O&&O>=400,k={currentUrl:x,currentParams:o.matches[0]?.params||{},nextUrl:L,nextParams:i[0].params,...s,actionResult:P,actionStatus:O},M=ct(i.map(z=>z.route.path)),V=i.map((z,J)=>{let{route:le}=z,Y=null;if(E!=null&&J>E?Y=!1:le.lazy?Y=!0:Gr(le)?c?Y=Or(le,o.loaderData,o.errors):Sl(o.loaderData,o.matches[J],z)&&(Y=!0):Y=!1,Y!==null)return Dt(r,a,e,M,z,u,t,Y);let Ee=_?!1:d||x.pathname+x.search===L.pathname+L.search||x.search!==L.search||Cl(o.matches[J],z),pe={...k,defaultShouldRevalidate:Ee},Pe=Qt(z,pe);return Dt(r,a,e,M,z,u,t,Pe,pe)}),X=[];return f.forEach((z,J)=>{if(c||!i.some(Le=>Le.route.id===z.routeId)||p.has(J))return;let le=o.fetchers.get(J),Y=le&&le.state!=="idle"&&le.data===void 0,Ee=ve(y,z.path,w);if(!Ee){if(R&&Y)return;X.push({key:J,routeId:z.routeId,path:z.path,matches:null,match:null,request:null,controller:null});return}if(g.has(J))return;let pe=dt(Ee,z.path),Pe=new AbortController,ye=st(n,z.path,Pe.signal),be=null;if(m.has(J))m.delete(J),be=ze(r,a,ye,Ee,pe,u,t);else if(Y)d&&(be=ze(r,a,ye,Ee,pe,u,t));else{let Le={...k,defaultShouldRevalidate:_?!1:d};Qt(pe,Le)&&(be=ze(r,a,ye,Ee,pe,u,t,Le))}be&&X.push({key:J,routeId:z.routeId,path:z.path,matches:be,match:pe,request:ye,controller:Pe})}),{dsMatches:V,revalidatingFetchers:X}}function Gr(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Or(e,t,r){if(e.lazy)return!0;if(!Gr(e))return!1;let a=t!=null&&e.id in t,n=r!=null&&r[e.id]!==void 0;return!a&&n?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!a&&!n}function Sl(e,t,r){let a=!t||r.route.id!==t.route.id,n=!e.hasOwnProperty(r.route.id);return a||n}function Cl(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Qt(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function Ya(e,t,r,a,n,o){let i;if(e){let u=a[e];I(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=r;let s=[],l=[];if(t.forEach(u=>{let c=i.find(d=>Jn(u,d));c?l.push({existingRoute:c,newRoute:u}):s.push(u)}),s.length>0){let u=We(s,n,[e||"_","patch",String(i?.length||"0")],a);i.push(...u)}if(o&&l.length>0)for(let u=0;u<l.length;u++){let{existingRoute:c,newRoute:d}=l[u],m=c,[p]=We([d],n,[],{},!0);Object.assign(m,{element:p.element?p.element:m.element,errorElement:p.errorElement?p.errorElement:m.errorElement,hydrateFallbackElement:p.hydrateFallbackElement?p.hydrateFallbackElement:m.hydrateFallbackElement})}}function Jn(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((r,a)=>t.children?.some(n=>Jn(r,n))):!1}var Ja=new WeakMap,Qr=({key:e,route:t,manifest:r,mapRouteProperties:a})=>{let n=r[t.id];if(I(n,"No route found in manifest"),!n.lazy||typeof n.lazy!="object")return;let o=n.lazy[e];if(!o)return;let i=Ja.get(n);i||(i={},Ja.set(n,i));let s=i[e];if(s)return s;let l=(async()=>{let u=Wi(e),d=n[e]!==void 0&&e!=="hasErrorBoundary";if(u)K(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(d)K(!1,`Route "${n.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let m=await o();m!=null&&(Object.assign(n,{[e]:m}),Object.assign(n,a(n)))}typeof n.lazy=="object"&&(n.lazy[e]=void 0,Object.values(n.lazy).every(m=>m===void 0)&&(n.lazy=void 0))})();return i[e]=l,l},Ka=new WeakMap;function xl(e,t,r,a,n){let o=r[e.id];if(I(o,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let c=Ka.get(o);if(c)return{lazyRoutePromise:c,lazyHandlerPromise:c};let d=(async()=>{I(typeof e.lazy=="function","No lazy route function found");let m=await e.lazy(),p={};for(let f in m){let g=m[f];if(g===void 0)continue;let y=Yi(f),R=o[f]!==void 0&&f!=="hasErrorBoundary";y?K(!y,"Route property "+f+" is not a supported property to be returned from a lazy route function. This property will be ignored."):R?K(!R,`Route "${o.id}" has a static property "${f}" defined but its lazy function is also returning a value for this property. The lazy route property "${f}" will be ignored.`):p[f]=g}Object.assign(o,p),Object.assign(o,{...a(o),lazy:void 0})})();return Ka.set(o,d),d.catch(()=>{}),{lazyRoutePromise:d,lazyHandlerPromise:d}}let i=Object.keys(e.lazy),s=[],l;for(let c of i){if(n&&n.includes(c))continue;let d=Qr({key:c,route:e,manifest:r,mapRouteProperties:a});d&&(s.push(d),c===t&&(l=d))}let u=s.length>0?Promise.all(s).then(()=>{}):void 0;return u?.catch(()=>{}),l?.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:l}}function Pl(e){return e!==void 0}function Xa(e,t,r){let a=e.map(({route:n})=>{if(!(typeof n.lazy!="object"||!n.lazy.middleware))return Qr({key:"middleware",route:n,manifest:t,mapRouteProperties:r})}).filter(Pl);return a.length>0?Promise.all(a):void 0}async function Fr(e){let t=e.matches.filter(n=>n.shouldLoad),r={};return(await Promise.all(t.map(n=>n.resolve()))).forEach((n,o)=>{r[t[o].route.id]=n}),r}async function Ll(e){return e.matches.some(t=>t.route.middleware)?Kn(e,()=>Fr(e)):Fr(e)}function Ga(e,t,r){return Xn(e,t,a,q,r);function a(n){return Be(n)?Nr(n):n}}function Kn(e,t){return Xn(e,t,a=>a,kl,r);function r(a,n,o){if(o)return Promise.resolve(Object.assign(o.value,{[n]:{type:"error",result:a}}));{let{matches:i}=e,s=Math.min(Math.max(i.findIndex(u=>u.route.id===n),0),Math.max(i.findIndex(u=>u.unstable_shouldCallHandler()),0)),l=Ce(i,i[s].route.id).route.id;return Promise.resolve({[l]:{type:"error",result:a}})}}}async function Xn(e,t,r,a,n){let{matches:o,request:i,params:s,context:l,unstable_pattern:u}=e,c=o.flatMap(m=>m.route.middleware?m.route.middleware.map(p=>[m.route.id,p]):[]);return await Gn({request:i,params:s,context:l,unstable_pattern:u},c,t,r,a,n)}async function Gn(e,t,r,a,n,o,i=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??new Error(`Request aborted: ${s.method} ${s.url}`);let l=t[i];if(!l)return await r();let[u,c]=l,d,m=async()=>{if(d)throw new Error("You may only call `next()` once per middleware");try{return d={value:await Gn(e,t,r,a,n,o,i+1)},d.value}catch(p){return d={value:await o(p,u,d)},d.value}};try{let p=await c(e,m),f=p!=null?a(p):void 0;return n(f)?f:d?f??d.value:(d={value:await m()},d.value)}catch(p){return await o(p,u,d)}}function Qn(e,t,r,a,n){let o=Qr({key:"middleware",route:a.route,manifest:t,mapRouteProperties:e}),i=xl(a.route,de(r.method)?"action":"loader",t,e,n);return{middleware:o,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function Dt(e,t,r,a,n,o,i,s,l=null){let u=!1,c=Qn(e,t,r,n,o);return{...n,_lazyPromises:c,shouldLoad:s,unstable_shouldRevalidateArgs:l,unstable_shouldCallHandler(d){return u=!0,l?typeof d=="boolean"?Qt(n,{...l,defaultShouldRevalidate:d}):Qt(n,l):s},resolve(d){let{lazy:m,loader:p,middleware:f}=n.route,g=u||s||d&&!de(r.method)&&(m||p),y=f&&f.length>0&&!p&&!m;return g&&(de(r.method)||!y)?Dl({request:r,unstable_pattern:a,match:n,lazyHandlerPromise:c?.handler,lazyRoutePromise:c?.route,handlerOverride:d,scopedContext:i}):Promise.resolve({type:"data",result:void 0})}}}function ze(e,t,r,a,n,o,i,s=null){return a.map(l=>l.route.id!==n.route.id?{...l,shouldLoad:!1,unstable_shouldRevalidateArgs:s,unstable_shouldCallHandler:()=>!1,_lazyPromises:Qn(e,t,r,l,o),resolve:()=>Promise.resolve({type:"data",result:void 0})}:Dt(e,t,r,ct(a.map(u=>u.route.path)),l,o,i,!0,s))}async function Zn(e,t,r,a,n,o){r.some(u=>u._lazyPromises?.middleware)&&await Promise.all(r.map(u=>u._lazyPromises?.middleware));let i={request:t,unstable_pattern:ct(r.map(u=>u.route.path)),params:r[0].params,context:n,matches:r},l=await e({...i,fetcherKey:a,runClientMiddleware:o?()=>{throw new Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:u=>{let c=i;return Kn(c,()=>u({...c,fetcherKey:a,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(r.flatMap(u=>[u._lazyPromises?.handler,u._lazyPromises?.route]))}catch{}return l}async function Dl({request:e,unstable_pattern:t,match:r,lazyHandlerPromise:a,lazyRoutePromise:n,handlerOverride:o,scopedContext:i}){let s,l,u=de(e.method),c=u?"action":"loader",d=m=>{let p,f=new Promise((w,R)=>p=R);l=()=>p(),e.signal.addEventListener("abort",l);let g=w=>typeof m!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${c}" [routeId: ${r.route.id}]`)):m({request:e,unstable_pattern:t,params:r.params,context:i},...w!==void 0?[w]:[]),y=(async()=>{try{return{type:"data",result:await(o?o(R=>g(R)):g())}}catch(w){return{type:"error",result:w}}})();return Promise.race([y,f])};try{let m=u?r.route.action:r.route.loader;if(a||n)if(m){let p,[f]=await Promise.all([d(m).catch(g=>{p=g}),a,n]);if(p!==void 0)throw p;s=f}else{await a;let p=u?r.route.action:r.route.loader;if(p)[s]=await Promise.all([d(p),n]);else if(c==="action"){let f=new URL(e.url),g=f.pathname+f.search;throw te(405,{method:e.method,pathname:g,routeId:r.route.id})}else return{type:"data",result:void 0}}else if(m)s=await d(m);else{let p=new URL(e.url),f=p.pathname+p.search;throw te(404,{pathname:f})}}catch(m){return{type:"error",result:m}}finally{l&&e.signal.removeEventListener("abort",l)}return s}async function qn(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function eo(e){let{result:t,type:r}=e;if(q(t)){let a;try{a=await qn(t)}catch(n){return{type:"error",error:n}}return r==="error"?{type:"error",error:new me(t.status,t.statusText,a),statusCode:t.status,headers:t.headers}:{type:"data",data:a,statusCode:t.status,headers:t.headers}}return r==="error"?Be(t)?t.data instanceof Error?{type:"error",error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:new me(t.init?.status||500,void 0,t.data),statusCode:re(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:re(t)?t.status:void 0}:Be(t)?{type:"data",data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}function to(e,t,r,a,n){let o=e.headers.get("Location");if(I(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!nr(o)){let i=a.slice(0,a.findIndex(s=>s.route.id===r)+1);o=kr(new URL(t.url),i,n,o),e.headers.set("Location",o)}return e}function Qa(e,t,r){if(nr(e)){let a=e,n=a.startsWith("//")?new URL(t.protocol+a):new URL(a),o=ne(n.pathname,r)!=null;if(n.origin===t.origin&&o)return n.pathname+n.search+n.hash}return e}function st(e,t,r,a){let n=e.createURL(ao(t)).toString(),o={signal:r};if(a&&de(a.formMethod)){let{formMethod:i,formEncType:s}=a;o.method=i.toUpperCase(),s==="application/json"?(o.headers=new Headers({"Content-Type":s}),o.body=JSON.stringify(a.json)):s==="text/plain"?o.body=a.text:s==="application/x-www-form-urlencoded"&&a.formData?o.body=Mr(a.formData):o.body=a.formData}return new Request(n,o)}function Mr(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,typeof a=="string"?a:a.name);return t}function Za(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function ro(e,t,r,a=!1,n=!1){let o={},i=null,s,l=!1,u={},c=r&&ie(r[1])?r[1].error:void 0;return e.forEach(d=>{if(!(d.route.id in t))return;let m=d.route.id,p=t[m];if(I(!Ue(p),"Cannot handle redirect results in processLoaderData"),ie(p)){let f=p.error;if(c!==void 0&&(f=c,c=void 0),i=i||{},n)i[m]=f;else{let g=Ce(e,m);i[g.route.id]==null&&(i[g.route.id]=f)}a||(o[m]=Wn),l||(l=!0,s=re(p.error)?p.error.status:500),p.headers&&(u[m]=p.headers)}else o[m]=p.data,p.statusCode&&p.statusCode!==200&&!l&&(s=p.statusCode),p.headers&&(u[m]=p.headers)}),c!==void 0&&r&&(i={[r[0]]:c},r[2]&&(o[r[2]]=void 0)),{loaderData:o,errors:i,statusCode:s||200,loaderHeaders:u}}function qa(e,t,r,a,n,o){let{loaderData:i,errors:s}=ro(t,r,a);return n.filter(l=>!l.matches||l.matches.some(u=>u.shouldLoad)).forEach(l=>{let{key:u,match:c,controller:d}=l;if(d&&d.signal.aborted)return;let m=o[u];if(I(m,"Did not find corresponding fetcher result"),ie(m)){let p=Ce(e.matches,c?.route.id);s&&s[p.route.id]||(s={...s,[p.route.id]:m.error}),e.fetchers.delete(u)}else if(Ue(m))I(!1,"Unhandled fetcher revalidation redirect");else{let p=Me(m.data);e.fetchers.set(u,p)}}),{loaderData:i,errors:s}}function en(e,t,r,a){let n=Object.entries(t).filter(([,o])=>o!==Wn).reduce((o,[i,s])=>(o[i]=s,o),{});for(let o of r){let i=o.route.id;if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&o.route.loader&&(n[i]=e[i]),a&&a.hasOwnProperty(i))break}return n}function tn(e){return e?ie(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Ce(e,t){return(t?e.slice(0,e.findIndex(a=>a.route.id===t)+1):[...e]).reverse().find(a=>a.route.hasErrorBoundary===!0)||e[0]}function ut(e){let t=e.length===1?e[0]:e.find(r=>r.index||!r.path||r.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function te(e,{pathname:t,routeId:r,method:a,type:n,message:o}={}){let i="Unknown Server Error",s="Unknown @remix-run/router error";return e===400?(i="Bad Request",a&&t&&r?s=`You made a ${a} request to "${t}" but did not provide a \`loader\` for route "${r}", so there is no way to handle the request.`:n==="invalid-body"&&(s="Unable to encode submission body")):e===403?(i="Forbidden",s=`Route "${r}" does not match URL "${t}"`):e===404?(i="Not Found",s=`No route matches URL "${t}"`):e===405&&(i="Method Not Allowed",a&&t&&r?s=`You made a ${a.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${r}", so there is no way to handle the request.`:a&&(s=`Invalid request method "${a.toUpperCase()}"`)),new me(e||500,i,new Error(s),!0)}function Ut(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[a,n]=t[r];if(Ue(n))return{key:a,result:n}}}function ao(e){let t=typeof e=="string"?xe(e):e;return he({...t,hash:""})}function Tl(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function Nr(e){return Response.json(e.data,e.init??void 0)}function _l(e){return new me(e.init?.status??500,e.init?.statusText??"Internal Server Error",e.data)}function kl(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,r])=>typeof t=="string"&&no(r))}function no(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function oo(e){return q(e.result)&&Un.has(e.result.status)}function ie(e){return e.type==="error"}function Ue(e){return(e&&e.type)==="redirect"}function Be(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function q(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function sr(e){return Un.has(e)}function Zt(e){return q(e)&&sr(e.status)&&e.headers.has("Location")}function Ar(e){return Rl.has(e.toUpperCase())}function de(e){return gl.has(e.toUpperCase())}function Zr(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function dt(e,t){let r=typeof t=="string"?xe(t).search:t.search;if(e[e.length-1].route.index&&Zr(r||""))return e[e.length-1];let a=Nn(e);return a[a.length-1]}function rn(e){let{formMethod:t,formAction:r,formEncType:a,text:n,formData:o,json:i}=e;if(!(!t||!r||!a)){if(n!=null)return{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:void 0,text:n};if(o!=null)return{formMethod:t,formAction:r,formEncType:a,formData:o,json:void 0,text:void 0};if(i!==void 0)return{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:i,text:void 0}}}function Sr(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Ol(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function bt(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function Fl(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Me(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Ml(e,t){try{let r=e.sessionStorage.getItem(Bn);if(r){let a=JSON.parse(r);for(let[n,o]of Object.entries(a||{}))o&&Array.isArray(o)&&t.set(n,new Set(o||[]))}}catch{}}function Nl(e,t){if(t.size>0){let r={};for(let[a,n]of t)r[a]=[...n];try{e.sessionStorage.setItem(Bn,JSON.stringify(r))}catch(a){K(!1,`Failed to save applied view transitions in sessionStorage (${a}).`)}}}function Al(){let e,t,r=new Promise((a,n)=>{e=async o=>{a(o);try{await r}catch{}},t=async o=>{n(o);try{await r}catch{}}});return{promise:r,resolve:e,reject:t}}var $e=h.createContext(null);$e.displayName="DataRouter";var Ye=h.createContext(null);Ye.displayName="DataRouterState";var io=h.createContext(!1);function $l(){return h.useContext(io)}var ur=h.createContext({isTransitioning:!1});ur.displayName="ViewTransition";var cr=h.createContext(new Map);cr.displayName="Fetchers";var mt=h.createContext(null);mt.displayName="Await";var fc=e=>h.createElement(mt.Provider,e),ge=h.createContext(null);ge.displayName="Navigation";var pt=h.createContext(null);pt.displayName="Location";var we=h.createContext({outlet:null,matches:[],isDataRoute:!1});we.displayName="Route";var qr=h.createContext(null);qr.displayName="RouteError";function Il(e,{relative:t}={}){I(rt(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:a}=h.useContext(ge),{hash:n,pathname:o,search:i}=Ot(e,{relative:t}),s=o;return r!=="/"&&(s=o==="/"?r:_e([r,o])),a.createHref({pathname:s,search:i,hash:n})}function rt(){return h.useContext(pt)!=null}function Re(){return I(rt(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(pt).location}function hc(){return h.useContext(pt).navigationType}function mc(e){I(rt(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=Re();return h.useMemo(()=>Lt(e,Mn(t)),[t,e])}var lo="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function so(e){h.useContext(ge).static||h.useLayoutEffect(e)}function ea(){let{isDataRoute:e}=h.useContext(we);return e?Zl():Hl()}function Hl(){I(rt(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext($e),{basename:t,navigator:r}=h.useContext(ge),{matches:a}=h.useContext(we),{pathname:n}=Re(),o=JSON.stringify(or(a)),i=h.useRef(!1);return so(()=>{i.current=!0}),h.useCallback((l,u={})=>{if(K(i.current,lo),!i.current)return;if(typeof l=="number"){r.go(l);return}let c=ir(l,JSON.parse(o),n,u.relative==="path");e==null&&t!=="/"&&(c.pathname=c.pathname==="/"?t:_e([t,c.pathname])),(u.replace?r.replace:r.push)(c,u.state,u)},[t,r,o,n,e])}var uo=h.createContext(null);function pc(){return h.useContext(uo)}function jl(e){let t=h.useContext(we).outlet;return h.useMemo(()=>t&&h.createElement(uo.Provider,{value:e},t),[t,e])}function ta(){let{matches:e}=h.useContext(we),t=e[e.length-1];return t?t.params:{}}function Ot(e,{relative:t}={}){let{matches:r}=h.useContext(we),{pathname:a}=Re(),n=JSON.stringify(or(r));return h.useMemo(()=>ir(e,JSON.parse(n),a,t==="path"),[e,n,a,t])}function Ul(e,t){return ra(e,t)}function ra(e,t,r,a,n){I(rt(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(ge),{matches:i}=h.useContext(we),s=i[i.length-1],l=s?s.params:{},u=s?s.pathname:"/",c=s?s.pathnameBase:"/",d=s&&s.route;{let R=d&&d.path||"";fo(u,!d||R.endsWith("*")||R.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${R}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
3
3
 
4
4
  Please change the parent <Route path="${R}"> to <Route path="${R==="/"?"*":`${R}/*`}">.`)}let m=Re(),p;if(t){let R=typeof t=="string"?xe(t):t;I(c==="/"||R.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${R.pathname}" was given in the \`location\` prop.`),p=R}else p=m;let f=p.pathname||"/",g=f;if(c!=="/"){let R=c.replace(/^\//,"").split("/");g="/"+f.replace(/^\//,"").split("/").slice(R.length).join("/")}let y=ve(e,{pathname:g});K(d||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),K(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=co(y&&y.map(R=>Object.assign({},R,{params:Object.assign({},l,R.params),pathname:_e([c,o.encodeLocation?o.encodeLocation(R.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?c:_e([c,o.encodeLocation?o.encodeLocation(R.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),i,r,a,n);return t&&w?h.createElement(pt.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},w):w}function zl(){let e=dr(),t=re(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",n={padding:"0.5rem",backgroundColor:a},o={padding:"2px 4px",backgroundColor:a},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:o},"ErrorBoundary")," or"," ",h.createElement("code",{style:o},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:n},r):null,i)}var Bl=h.createElement(zl,null),Wl=class extends h.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?h.createElement(we.Provider,{value:this.props.routeContext},h.createElement(qr.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Vl({routeContext:e,match:t,children:r}){let a=h.useContext($e);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),h.createElement(we.Provider,{value:e},r)}function co(e,t=[],r=null,a=null,n=null){if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,i=r?.errors;if(i!=null){let c=o.findIndex(d=>d.route.id&&i?.[d.route.id]!==void 0);I(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,l=-1;if(r)for(let c=0;c<o.length;c++){let d=o[c];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(l=c),d.route.id){let{loaderData:m,errors:p}=r,f=d.route.loader&&!m.hasOwnProperty(d.route.id)&&(!p||p[d.route.id]===void 0);if(d.route.lazy||f){s=!0,l>=0?o=o.slice(0,l+1):o=[o[0]];break}}}let u=r&&a?(c,d)=>{a(c,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:d})}:void 0;return o.reduceRight((c,d,m)=>{let p,f=!1,g=null,y=null;r&&(p=i&&d.route.id?i[d.route.id]:void 0,g=d.route.errorElement||Bl,s&&(l<0&&m===0?(fo("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,y=null):l===m&&(f=!0,y=d.route.hydrateFallbackElement||null)));let w=t.concat(o.slice(0,m+1)),R=()=>{let C;return p?C=g:f?C=y:d.route.Component?C=h.createElement(d.route.Component,null):d.route.element?C=d.route.element:C=c,h.createElement(Vl,{match:d,routeContext:{outlet:c,matches:w,isDataRoute:r!=null},children:C})};return r&&(d.route.ErrorBoundary||d.route.errorElement||m===0)?h.createElement(Wl,{location:r.location,revalidation:r.revalidation,component:g,error:p,children:R(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:u}):R()},null)}function aa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function na(e){let t=h.useContext($e);return I(t,aa(e)),t}function Ie(e){let t=h.useContext(Ye);return I(t,aa(e)),t}function Yl(e){let t=h.useContext(we);return I(t,aa(e)),t}function yt(e){let t=Yl(e),r=t.matches[t.matches.length-1];return I(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Jl(){return yt("useRouteId")}function Kl(){return Ie("useNavigation").navigation}function yc(){let e=na("useRevalidator"),t=Ie("useRevalidator"),r=h.useCallback(async()=>{await e.router.revalidate()},[e.router]);return h.useMemo(()=>({revalidate:r,state:t.revalidation}),[r,t.revalidation])}function oa(){let{matches:e,loaderData:t}=Ie("useMatches");return h.useMemo(()=>e.map(r=>_n(r,t)),[e,t])}function ia(){let e=Ie("useLoaderData"),t=yt("useLoaderData");return e.loaderData[t]}function vc(e){return Ie("useRouteLoaderData").loaderData[e]}function la(){let e=Ie("useActionData"),t=yt("useLoaderData");return e.actionData?e.actionData[t]:void 0}function dr(){let e=h.useContext(qr),t=Ie("useRouteError"),r=yt("useRouteError");return e!==void 0?e:t.errors?.[r]}function Xl(){return h.useContext(mt)?._data}function gc(){return h.useContext(mt)?._error}var Gl=0;function Ql(e){let{router:t,basename:r}=na("useBlocker"),a=Ie("useBlocker"),[n,o]=h.useState(""),i=h.useCallback(s=>{if(typeof e!="function")return!!e;if(r==="/")return e(s);let{currentLocation:l,nextLocation:u,historyAction:c}=s;return e({currentLocation:{...l,pathname:ne(l.pathname,r)||l.pathname},nextLocation:{...u,pathname:ne(u.pathname,r)||u.pathname},historyAction:c})},[r,e]);return h.useEffect(()=>{let s=String(++Gl);return o(s),()=>t.deleteBlocker(s)},[t]),h.useEffect(()=>{n!==""&&t.getBlocker(n,i)},[t,n,i]),n&&a.blockers.has(n)?a.blockers.get(n):et}function Zl(){let{router:e}=na("useNavigate"),t=yt("useNavigate"),r=h.useRef(!1);return so(()=>{r.current=!0}),h.useCallback(async(n,o={})=>{K(r.current,lo),r.current&&(typeof n=="number"?e.navigate(n):await e.navigate(n,{fromRouteId:t,...o}))},[e,t])}var an={};function fo(e,t,r){!t&&!an[e]&&(an[e]=!0,K(!1,r))}function wc(...e){const t=yt("useRoute"),r=e[0]??t,a=Ie("useRoute"),n=a.matches.find(({route:o})=>o.id===r);if(n!==void 0)return{handle:n.route.handle,loaderData:a.loaderData[r],actionData:a.actionData?.[r]}}var nn={};function Tt(e,t){!e&&!nn[t]&&(nn[t]=!0,console.warn(t))}function Ft(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&K(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:h.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&K(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:h.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&K(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:h.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var sa=["HydrateFallback","hydrateFallbackElement"];function ql(e,t){return Xr({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:xn({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:e,hydrationRouteProperties:sa,mapRouteProperties:Ft,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,unstable_instrumentations:t?.unstable_instrumentations}).initialize()}var es=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",e(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",t(r))}})}};function ts({router:e,flushSync:t,unstable_onError:r}){let[a,n]=h.useState(e.state),[o,i]=h.useState(),[s,l]=h.useState({isTransitioning:!1}),[u,c]=h.useState(),[d,m]=h.useState(),[p,f]=h.useState(),g=h.useRef(new Map),y=h.useCallback(x=>{n(L=>(x.errors&&r&&Object.entries(x.errors).forEach(([E,O])=>{L.errors?.[E]!==O&&r(O,{location:x.location,params:x.matches[0]?.params??{}})}),x))},[r]),w=h.useCallback((x,{deletedFetchers:L,flushSync:E,viewTransitionOpts:O})=>{x.fetchers.forEach((k,M)=>{k.data!==void 0&&g.current.set(M,k.data)}),L.forEach(k=>g.current.delete(k)),Tt(E===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let _=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(Tt(O==null||_,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!O||!_){t&&E?t(()=>y(x)):h.startTransition(()=>y(x));return}if(t&&E){t(()=>{d&&(u&&u.resolve(),d.skipTransition()),l({isTransitioning:!0,flushSync:!0,currentLocation:O.currentLocation,nextLocation:O.nextLocation})});let k=e.window.document.startViewTransition(()=>{t(()=>y(x))});k.finished.finally(()=>{t(()=>{c(void 0),m(void 0),i(void 0),l({isTransitioning:!1})})}),t(()=>m(k));return}d?(u&&u.resolve(),d.skipTransition(),f({state:x,currentLocation:O.currentLocation,nextLocation:O.nextLocation})):(i(x),l({isTransitioning:!0,flushSync:!1,currentLocation:O.currentLocation,nextLocation:O.nextLocation}))},[e.window,t,d,u,y]);h.useLayoutEffect(()=>e.subscribe(w),[e,w]),h.useEffect(()=>{s.isTransitioning&&!s.flushSync&&c(new es)},[s]),h.useEffect(()=>{if(u&&o&&e.window){let x=o,L=u.promise,E=e.window.document.startViewTransition(async()=>{h.startTransition(()=>y(x)),await L});E.finished.finally(()=>{c(void 0),m(void 0),i(void 0),l({isTransitioning:!1})}),m(E)}},[o,u,e.window,y]),h.useEffect(()=>{u&&o&&a.location.key===o.location.key&&u.resolve()},[u,d,a.location,o]),h.useEffect(()=>{!s.isTransitioning&&p&&(i(p.state),l({isTransitioning:!0,flushSync:!1,currentLocation:p.currentLocation,nextLocation:p.nextLocation}),f(void 0))},[s.isTransitioning,p]);let R=h.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:x=>e.navigate(x),push:(x,L,E)=>e.navigate(x,{state:L,preventScrollReset:E?.preventScrollReset}),replace:(x,L,E)=>e.navigate(x,{replace:!0,state:L,preventScrollReset:E?.preventScrollReset})}),[e]),C=e.basename||"/",P=h.useMemo(()=>({router:e,navigator:R,static:!1,basename:C,unstable_onError:r}),[e,R,C,r]);return h.createElement(h.Fragment,null,h.createElement($e.Provider,{value:P},h.createElement(Ye.Provider,{value:a},h.createElement(cr.Provider,{value:g.current},h.createElement(ur.Provider,{value:s},h.createElement(at,{basename:C,location:a.location,navigationType:a.historyAction,navigator:R},h.createElement(rs,{routes:e.routes,future:e.future,state:a,unstable_onError:r})))))),null)}var rs=h.memo(as);function as({routes:e,future:t,state:r,unstable_onError:a}){return ra(e,void 0,r,a,t)}function Rc({basename:e,children:t,initialEntries:r,initialIndex:a}){let n=h.useRef();n.current==null&&(n.current=xn({initialEntries:r,initialIndex:a,v5Compat:!0}));let o=n.current,[i,s]=h.useState({action:o.action,location:o.location}),l=h.useCallback(u=>{h.startTransition(()=>s(u))},[s]);return h.useLayoutEffect(()=>o.listen(l),[o,l]),h.createElement(at,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o})}function Ec({to:e,replace:t,state:r,relative:a}){I(rt(),"<Navigate> may be used only in the context of a <Router> component.");let{static:n}=h.useContext(ge);K(!n,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=h.useContext(we),{pathname:i}=Re(),s=ea(),l=ir(e,or(o),i,a==="path"),u=JSON.stringify(l);return h.useEffect(()=>{s(JSON.parse(u),{replace:t,state:r,relative:a})},[s,u,a,t,r]),null}function ns(e){return jl(e.context)}function os(e){I(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function at({basename:e="/",children:t=null,location:r,navigationType:a="POP",navigator:n,static:o=!1}){I(!rt(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=h.useMemo(()=>({basename:i,navigator:n,static:o,future:{}}),[i,n,o]);typeof r=="string"&&(r=xe(r));let{pathname:l="/",search:u="",hash:c="",state:d=null,key:m="default"}=r,p=h.useMemo(()=>{let f=ne(l,i);return f==null?null:{location:{pathname:f,search:u,hash:c,state:d,key:m},navigationType:a}},[i,l,u,c,d,m,a]);return K(p!=null,`<Router basename="${i}"> is not able to match the URL "${l}${u}${c}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:h.createElement(ge.Provider,{value:s},h.createElement(pt.Provider,{children:t,value:p}))}function bc({children:e,location:t}){return Ul(qt(e),t)}function Sc({children:e,errorElement:t,resolve:r}){let a=h.useContext($e),n=h.useContext(Ye),o=h.useCallback((i,s)=>{a&&a.unstable_onError&&n&&a.unstable_onError(i,{location:n.location,params:n.matches?.[0]?.params||{},errorInfo:s})},[a,n]);return h.createElement(is,{resolve:r,errorElement:t,onError:o},h.createElement(ls,null,e))}var is=class extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:r}=this.props,a=null,n=0;if(!(r instanceof Promise))n=1,a=Promise.resolve(),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_data",{get:()=>r});else if(this.state.error){n=2;let o=this.state.error;a=Promise.reject().catch(()=>{}),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_error",{get:()=>o})}else r._tracked?(a=r,n="_error"in a?2:"_data"in a?1:0):(n=0,Object.defineProperty(r,"_tracked",{get:()=>!0}),a=r.then(o=>Object.defineProperty(r,"_data",{get:()=>o}),o=>{this.props.onError?.(o),Object.defineProperty(r,"_error",{get:()=>o})}));if(n===2&&!t)throw a._error;if(n===2)return h.createElement(mt.Provider,{value:a,children:t});if(n===1)return h.createElement(mt.Provider,{value:a,children:e});throw a}};function ls({children:e}){let t=Xl(),r=typeof e=="function"?e(t):e;return h.createElement(h.Fragment,null,r)}function qt(e,t=[]){let r=[];return h.Children.forEach(e,(a,n)=>{if(!h.isValidElement(a))return;let o=[...t,n];if(a.type===h.Fragment){r.push.apply(r,qt(a.props.children,o));return}I(a.type===os,`[${typeof a.type=="string"?a.type:a.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),I(!a.props.index||!a.props.children,"An index route cannot have child routes.");let i={id:a.props.id||o.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,middleware:a.props.middleware,loader:a.props.loader,action:a.props.action,hydrateFallbackElement:a.props.hydrateFallbackElement,HydrateFallback:a.props.HydrateFallback,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.hasErrorBoundary===!0||a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(i.children=qt(a.props.children,o)),r.push(i)}),r}var Cc=qt;function xc(e){return co(e)}function ho(){return{params:ta(),loaderData:ia(),actionData:la(),matches:oa()}}function Pc({children:e}){const t=ho();return h.cloneElement(e,t)}function ss(e){return function(){const r=ho();return h.createElement(e,r)}}function mo(){return{params:ta(),loaderData:ia(),actionData:la()}}function Lc({children:e}){const t=mo();return h.cloneElement(e,t)}function us(e){return function(){const r=mo();return h.createElement(e,r)}}function po(){return{params:ta(),loaderData:ia(),actionData:la(),error:dr()}}function Dc({children:e}){const t=po();return h.cloneElement(e,t)}function cs(e){return function(){const r=po();return h.createElement(e,r)}}var Jt="get",Kt="application/x-www-form-urlencoded";function fr(e){return e!=null&&typeof e.tagName=="string"}function ds(e){return fr(e)&&e.tagName.toLowerCase()==="button"}function fs(e){return fr(e)&&e.tagName.toLowerCase()==="form"}function hs(e){return fr(e)&&e.tagName.toLowerCase()==="input"}function ms(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ps(e,t){return e.button===0&&(!t||t==="_self")&&!ms(e)}function $r(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let a=e[r];return t.concat(Array.isArray(a)?a.map(n=>[r,n]):[[r,a]])},[]))}function ys(e,t){let r=$r(e);return t&&t.forEach((a,n)=>{r.has(n)||t.getAll(n).forEach(o=>{r.append(n,o)})}),r}var zt=null;function vs(){if(zt===null)try{new FormData(document.createElement("form"),0),zt=!1}catch{zt=!0}return zt}var gs=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Cr(e){return e!=null&&!gs.has(e)?(K(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Kt}"`),null):e}function ws(e,t){let r,a,n,o,i;if(fs(e)){let s=e.getAttribute("action");a=s?ne(s,t):null,r=e.getAttribute("method")||Jt,n=Cr(e.getAttribute("enctype"))||Kt,o=new FormData(e)}else if(ds(e)||hs(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||s.getAttribute("action");if(a=l?ne(l,t):null,r=e.getAttribute("formmethod")||s.getAttribute("method")||Jt,n=Cr(e.getAttribute("formenctype"))||Cr(s.getAttribute("enctype"))||Kt,o=new FormData(s,e),!vs()){let{name:u,type:c,value:d}=e;if(c==="image"){let m=u?`${u}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else u&&o.append(u,d)}}else{if(fr(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Jt,a=null,n=Kt,i=e}return o&&n==="text/plain"&&(i=o,o=void 0),{action:a,method:r.toLowerCase(),encType:n,formData:o,body:i}}var yo=-1,vo=-2,go=-3,wo=-4,ua=-5,Ro=-6,Eo=-7,bo="B",So="D",ft="E",Ir="M",Co="N",ht="P",xo="R",Hr="S",Po="Y",Lo="U",jr="Z",Do=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};function Rs(){const e=new TextDecoder;let t="";return new TransformStream({transform(r,a){const n=e.decode(r,{stream:!0}),o=(t+n).split(`
@@ -1,2 +1,2 @@
1
- import{c as at,f as rt,g as mt,O as Ct,h as Ot,J as yt,R as G}from"./index-DLuEx6sZ.js";import{i as ut,y as It,z as vt,B as _t,D as Et,E as Tt,F as wt,H as St,t as lt,I as Rt,J as At,K as x,r as xt,L as kt,M as Nt}from"./index-BImPVgbs.js";import"./embeddings-BEd7QUVp.js";import"./index-y9BdsFxs.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const e=I(ut(t)?It(t):t),{$schema:n,...s}=e;return s}function bt(t){const e=I(t),{$schema:n,...s}=e;return s}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Mt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let k;const Dt=new Uint8Array(16);function Gt(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(Dt)}const Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Ut};function ct(t,e,n){if(U.randomUUID&&!t)return U.randomUUID();t=t||{};const s=t.random??t.rng?.()??Gt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Mt(s)}const b="__gemini_function_call_thought_signatures__",Lt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Pt=t=>t();function jt(t){return wt.isInstance(t)?t.role:t.type}function Ft(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function Kt(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Ht(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function $t(t){return{providerName:"Google Gemini",fromStandardTextBlock(n){return{text:n.text}},fromStandardImageBlock(n){if(!t)throw new Error("This model does not support images");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardAudioBlock(n){if(!t)throw new Error("This model does not support audio");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardFileBlock(n){if(!t)throw new Error("This model does not support files");if(n.source_type==="text")return{text:n.text};if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)}}}function L(t,e){if(Rt(t))return At(t,$t(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return Kt(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function Yt(t,e,n,s){if(St(t)){const u=t.name??Ht(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const c=Array.isArray(t.content)?t.content.map(p=>L(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:c}}}}]:[{functionResponse:{name:u,response:{result:c}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>L(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[b];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const c=Pt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?Lt:""});return{functionCall:{name:u.name,args:u.args},...c?{thoughtSignature:c}:{}}})),[...o,...i]}function P(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!vt(o))throw new Error("Unsupported message input");const u=jt(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const c=Ft(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const r=Yt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const d=i.content[i.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...r),{mergeWithPreviousContent:!1,content:i.content}}let l=c;(l==="function"||l==="system"&&!n)&&(l="user");const f={role:l,parts:r};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,f]}},{content:[],mergeWithPreviousContent:!1}).content}function Bt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.length===1&&s.parts[0].text?a=s.parts[0].text:Array.isArray(s?.parts)&&s.parts.length>0?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];const u=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});let c="";return typeof a=="string"?c=a:Array.isArray(a)&&a.length>0&&(c=a.find(l=>"text"in l)?.text??c),{generations:[{text:c,message:new _t({content:a??"",tool_calls:o?.map(r=>({type:"tool_call",id:r.id,name:r.functionCall.name,args:r.functionCall.args})),additional_kwargs:{...i,[b]:u},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function qt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.every(r=>"text"in r)?a=s.parts.map(r=>r.text).join(""):Array.isArray(s?.parts)?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let u="";a&&typeof a=="string"?u=a:Array.isArray(a)&&(u=a.find(l=>"text"in l)?.text??"");const c=[];o&&c.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const p=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});return new Et({text:u,message:new Tt({content:a||"",name:s?s.role:void 0,tool_call_chunks:c,additional_kwargs:{[b]:p},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Wt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:{name:e.name,description:e.description,parameters:n}}return rt(e)?{name:e.function.name,description:e.function.description??"A function available to call.",parameters:bt(e.function.parameters)}:e})}]}function j(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends mt{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await xt(this.zodSchema,t);if(e.success)return e.data;throw new Ct(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(i=>{const{message:o}=i;return!("tool_calls"in o)||!Array.isArray(o.tool_calls)?[]:o.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},K;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(K||(K={}));var H;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(H||(H={}));var $;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})($||($={}));const Y=["user","model","function","system"];var B;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(B||(B={}));var q;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(q||(q={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var V;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(V||(V={}));var T;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(T||(T={}));var J;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(J||(J={}));var E;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(E||(E={}));var z;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(z||(z={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class dt extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class ft extends m{}const Vt="https://generativelanguage.googleapis.com",Jt="v1beta",zt="0.24.1",Zt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class Qt{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Jt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||Vt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function Xt(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Zt}/${zt}`),e.join(" ")}async function te(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",Xt(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function ee(t,e,n,s,i,o){const a=new Qt(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},oe(o)),{method:"POST",headers:await te(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:c}=await ee(t,e,n,s,i,o);return ne(u,c,a)}async function ne(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){se(i,t)}return s.ok||await ie(s,t),s}function se(t,e){let n=t;throw n.name==="AbortError"?(n=new ft(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof dt||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ie(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new dt(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function oe(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function M(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return ae(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ae(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
1
+ import{c as at,f as rt,g as mt,O as Ct,h as Ot,J as yt,R as G}from"./index-dPGaXGit.js";import{i as ut,y as It,z as vt,B as _t,D as Et,E as Tt,F as wt,H as St,t as lt,I as Rt,J as At,K as x,r as xt,L as kt,M as Nt}from"./index-5tcyL8PS.js";import"./embeddings-DmOKcAlW.js";import"./index-rJak6aaF.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const e=I(ut(t)?It(t):t),{$schema:n,...s}=e;return s}function bt(t){const e=I(t),{$schema:n,...s}=e;return s}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Mt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let k;const Dt=new Uint8Array(16);function Gt(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(Dt)}const Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Ut};function ct(t,e,n){if(U.randomUUID&&!t)return U.randomUUID();t=t||{};const s=t.random??t.rng?.()??Gt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Mt(s)}const b="__gemini_function_call_thought_signatures__",Lt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Pt=t=>t();function jt(t){return wt.isInstance(t)?t.role:t.type}function Ft(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function Kt(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Ht(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function $t(t){return{providerName:"Google Gemini",fromStandardTextBlock(n){return{text:n.text}},fromStandardImageBlock(n){if(!t)throw new Error("This model does not support images");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardAudioBlock(n){if(!t)throw new Error("This model does not support audio");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardFileBlock(n){if(!t)throw new Error("This model does not support files");if(n.source_type==="text")return{text:n.text};if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)}}}function L(t,e){if(Rt(t))return At(t,$t(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return Kt(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function Yt(t,e,n,s){if(St(t)){const u=t.name??Ht(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const c=Array.isArray(t.content)?t.content.map(p=>L(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:c}}}}]:[{functionResponse:{name:u,response:{result:c}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>L(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[b];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const c=Pt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?Lt:""});return{functionCall:{name:u.name,args:u.args},...c?{thoughtSignature:c}:{}}})),[...o,...i]}function P(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!vt(o))throw new Error("Unsupported message input");const u=jt(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const c=Ft(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const r=Yt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const d=i.content[i.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...r),{mergeWithPreviousContent:!1,content:i.content}}let l=c;(l==="function"||l==="system"&&!n)&&(l="user");const f={role:l,parts:r};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,f]}},{content:[],mergeWithPreviousContent:!1}).content}function Bt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.length===1&&s.parts[0].text?a=s.parts[0].text:Array.isArray(s?.parts)&&s.parts.length>0?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];const u=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});let c="";return typeof a=="string"?c=a:Array.isArray(a)&&a.length>0&&(c=a.find(l=>"text"in l)?.text??c),{generations:[{text:c,message:new _t({content:a??"",tool_calls:o?.map(r=>({type:"tool_call",id:r.id,name:r.functionCall.name,args:r.functionCall.args})),additional_kwargs:{...i,[b]:u},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function qt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.every(r=>"text"in r)?a=s.parts.map(r=>r.text).join(""):Array.isArray(s?.parts)?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let u="";a&&typeof a=="string"?u=a:Array.isArray(a)&&(u=a.find(l=>"text"in l)?.text??"");const c=[];o&&c.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const p=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});return new Et({text:u,message:new Tt({content:a||"",name:s?s.role:void 0,tool_call_chunks:c,additional_kwargs:{[b]:p},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Wt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:{name:e.name,description:e.description,parameters:n}}return rt(e)?{name:e.function.name,description:e.function.description??"A function available to call.",parameters:bt(e.function.parameters)}:e})}]}function j(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends mt{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await xt(this.zodSchema,t);if(e.success)return e.data;throw new Ct(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(i=>{const{message:o}=i;return!("tool_calls"in o)||!Array.isArray(o.tool_calls)?[]:o.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},K;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(K||(K={}));var H;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(H||(H={}));var $;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})($||($={}));const Y=["user","model","function","system"];var B;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(B||(B={}));var q;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(q||(q={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var V;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(V||(V={}));var T;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(T||(T={}));var J;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(J||(J={}));var E;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(E||(E={}));var z;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(z||(z={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class dt extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class ft extends m{}const Vt="https://generativelanguage.googleapis.com",Jt="v1beta",zt="0.24.1",Zt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class Qt{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Jt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||Vt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function Xt(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Zt}/${zt}`),e.join(" ")}async function te(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",Xt(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function ee(t,e,n,s,i,o){const a=new Qt(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},oe(o)),{method:"POST",headers:await te(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:c}=await ee(t,e,n,s,i,o);return ne(u,c,a)}async function ne(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){se(i,t)}return s.ok||await ie(s,t),s}function se(t,e){let n=t;throw n.name==="AbortError"?(n=new ft(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof dt||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ie(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new dt(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function oe(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function M(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return ae(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ae(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
2
2
  `+a.executableCode.code+"\n```\n"),a.codeExecutionResult&&o.push("\n```\n"+a.codeExecutionResult.output+"\n```\n");return o.length>0?o.join(""):""}function Z(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.functionCall&&o.push(a.functionCall);if(o.length>0)return o}const re=[T.RECITATION,T.SAFETY,T.LANGUAGE];function A(t){return!!t.finishReason&&re.includes(t.finishReason)}function O(t){var e,n,s;let i="";if((!t.candidates||t.candidates.length===0)&&t.promptFeedback)i+="Response was blocked",!((e=t.promptFeedback)===null||e===void 0)&&e.blockReason&&(i+=` due to ${t.promptFeedback.blockReason}`),!((n=t.promptFeedback)===null||n===void 0)&&n.blockReasonMessage&&(i+=`: ${t.promptFeedback.blockReasonMessage}`);else if(!((s=t.candidates)===null||s===void 0)&&s[0]){const o=t.candidates[0];A(o)&&(i+=`Candidate was blocked due to ${o.finishReason}`,o.finishMessage&&(i+=`: ${o.finishMessage}`))}return i}function w(t){return this instanceof w?(this.v=t,this):new w(t)}function ue(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){s[f]&&(i[f]=function(d){return new Promise(function(g,C){o.push([f,d,g,C])>1||u(f,d)})})}function u(f,d){try{c(s[f](d))}catch(g){l(o[0][3],g)}}function c(f){f.value instanceof w?Promise.resolve(f.value.v).then(p,r):l(o[0][2],f)}function p(f){u("next",f)}function r(f){u("throw",f)}function l(f,d){f(d),o.shift(),o.length&&u(o[0][0],o[0][1])}}const Q=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function le(t){const e=t.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),n=fe(e),[s,i]=n.tee();return{stream:de(s),response:ce(i)}}async function ce(t){const e=[],n=t.getReader();for(;;){const{done:s,value:i}=await n.read();if(s)return M(pe(e));e.push(i)}}function de(t){return ue(this,arguments,function*(){const n=t.getReader();for(;;){const{value:s,done:i}=yield w(n.read());if(i)break;yield yield w(M(s))}})}function fe(t){const e=t.getReader();return new ReadableStream({start(s){let i="";return o();function o(){return e.read().then(({value:a,done:u})=>{if(u){if(i.trim()){s.error(new m("Failed to parse stream"));return}s.close();return}i+=a;let c=i.match(Q),p;for(;c;){try{p=JSON.parse(c[1])}catch{s.error(new m(`Error parsing JSON response: "${c[1]}"`));return}s.enqueue(p),i=i.substring(c[0].length),c=i.match(Q)}return o()}).catch(a=>{let u=a;throw u.stack=a.stack,u.name==="AbortError"?u=new ft("Request aborted when reading from the stream"):u=new m("Error reading from the stream"),u})}}})}function pe(t){const e=t[t.length-1],n={promptFeedback:e?.promptFeedback};for(const s of t){if(s.candidates){let i=0;for(const o of s.candidates)if(n.candidates||(n.candidates=[]),n.candidates[i]||(n.candidates[i]={index:i}),n.candidates[i].citationMetadata=o.citationMetadata,n.candidates[i].groundingMetadata=o.groundingMetadata,n.candidates[i].finishReason=o.finishReason,n.candidates[i].finishMessage=o.finishMessage,n.candidates[i].safetyRatings=o.safetyRatings,o.content&&o.content.parts){n.candidates[i].content||(n.candidates[i].content={role:o.content.role||"user",parts:[]});const a={};for(const u of o.content.parts)u.text&&(a.text=u.text),u.functionCall&&(a.functionCall=u.functionCall),u.executableCode&&(a.executableCode=u.executableCode),u.codeExecutionResult&&(a.codeExecutionResult=u.codeExecutionResult),Object.keys(a).length===0&&(a.text=""),n.candidates[i].content.parts.push(a)}i++}s.usageMetadata&&(n.usageMetadata=s.usageMetadata)}return n}async function pt(t,e,n,s){const i=await R(e,v.STREAM_GENERATE_CONTENT,t,!0,JSON.stringify(n),s);return le(i)}async function gt(t,e,n,s){const o=await(await R(e,v.GENERATE_CONTENT,t,!1,JSON.stringify(n),s)).json();return{response:M(o)}}function ht(t){if(t!=null){if(typeof t=="string")return{role:"system",parts:[{text:t}]};if(t.text)return{role:"system",parts:[t]};if(t.parts)return t.role?t:{role:"system",parts:t.parts}}}function S(t){let e=[];if(typeof t=="string")e=[{text:t}];else for(const n of t)typeof n=="string"?e.push({text:n}):e.push(n);return ge(e)}function ge(t){const e={role:"user",parts:[]},n={role:"function",parts:[]};let s=!1,i=!1;for(const o of t)"functionResponse"in o?(n.parts.push(o),i=!0):(e.parts.push(o),s=!0);if(s&&i)throw new m("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!s&&!i)throw new m("No content is provided for sending chat message.");return s?e:n}function he(t,e){var n;let s={model:e?.model,generationConfig:e?.generationConfig,safetySettings:e?.safetySettings,tools:e?.tools,toolConfig:e?.toolConfig,systemInstruction:e?.systemInstruction,cachedContent:(n=e?.cachedContent)===null||n===void 0?void 0:n.name,contents:[]};const i=t.generateContentRequest!=null;if(t.contents){if(i)throw new y("CountTokensRequest must have one of contents or generateContentRequest, not both.");s.contents=t.contents}else if(i)s=Object.assign(Object.assign({},s),t.generateContentRequest);else{const o=S(t);s.contents=[o]}return{generateContentRequest:s}}function X(t){let e;return t.contents?e=t:e={contents:[S(t)]},t.systemInstruction&&(e.systemInstruction=ht(t.systemInstruction)),e}function me(t){return typeof t=="string"||Array.isArray(t)?{content:S(t)}:t}const tt=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],Ce={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function Oe(t){let e=!1;for(const n of t){const{role:s,parts:i}=n;if(!e&&s!=="user")throw new m(`First content should be with role 'user', got ${s}`);if(!Y.includes(s))throw new m(`Each item should include role field. Got ${s} but valid roles are: ${JSON.stringify(Y)}`);if(!Array.isArray(i))throw new m("Content should have 'parts' property with an array of Parts");if(i.length===0)throw new m("Each Content should have at least one part");const o={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(const u of i)for(const c of tt)c in u&&(o[c]+=1);const a=Ce[s];for(const u of tt)if(!a.includes(u)&&o[u]>0)throw new m(`Content with role '${s}' can't contain '${u}' part`);e=!0}}function et(t){var e;if(t.candidates===void 0||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;if(n===void 0||n.parts===void 0||n.parts.length===0)return!1;for(const s of n.parts)if(s===void 0||Object.keys(s).length===0||s.text!==void 0&&s.text==="")return!1;return!0}const nt="SILENT_ERROR";class ye{constructor(e,n,s,i={}){this.model=n,this.params=s,this._requestOptions=i,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=e,s?.history&&(Oe(s.history),this._history=s.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(e,n={}){var s,i,o,a,u,c;await this._sendPromise;const p=S(e),r={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(c=this.params)===null||c===void 0?void 0:c.cachedContent,contents:[...this._history,p]},l=Object.assign(Object.assign({},this._requestOptions),n);let f;return this._sendPromise=this._sendPromise.then(()=>gt(this._apiKey,this.model,r,l)).then(d=>{var g;if(et(d.response)){this._history.push(p);const C=Object.assign({parts:[],role:"model"},(g=d.response.candidates)===null||g===void 0?void 0:g[0].content);this._history.push(C)}else{const C=O(d.response);C&&console.warn(`sendMessage() was unsuccessful. ${C}. Inspect response object for details.`)}f=d}).catch(d=>{throw this._sendPromise=Promise.resolve(),d}),await this._sendPromise,f}async sendMessageStream(e,n={}){var s,i,o,a,u,c;await this._sendPromise;const p=S(e),r={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(c=this.params)===null||c===void 0?void 0:c.cachedContent,contents:[...this._history,p]},l=Object.assign(Object.assign({},this._requestOptions),n),f=pt(this._apiKey,this.model,r,l);return this._sendPromise=this._sendPromise.then(()=>f).catch(d=>{throw new Error(nt)}).then(d=>d.response).then(d=>{if(et(d)){this._history.push(p);const g=Object.assign({},d.candidates[0].content);g.role||(g.role="model"),this._history.push(g)}else{const g=O(d);g&&console.warn(`sendMessageStream() was unsuccessful. ${g}. Inspect response object for details.`)}}).catch(d=>{d.message!==nt&&console.error(d)}),f}}async function Ie(t,e,n,s){return(await R(e,v.COUNT_TOKENS,t,!1,JSON.stringify(n),s)).json()}async function ve(t,e,n,s){return(await R(e,v.EMBED_CONTENT,t,!1,JSON.stringify(n),s)).json()}async function _e(t,e,n,s){const i=n.requests.map(a=>Object.assign(Object.assign({},a),{model:e}));return(await R(e,v.BATCH_EMBED_CONTENTS,t,!1,JSON.stringify({requests:i}),s)).json()}class st{constructor(e,n,s={}){this.apiKey=e,this._requestOptions=s,n.model.includes("/")?this.model=n.model:this.model=`models/${n.model}`,this.generationConfig=n.generationConfig||{},this.safetySettings=n.safetySettings||[],this.tools=n.tools,this.toolConfig=n.toolConfig,this.systemInstruction=ht(n.systemInstruction),this.cachedContent=n.cachedContent}async generateContent(e,n={}){var s;const i=X(e),o=Object.assign(Object.assign({},this._requestOptions),n);return gt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}async generateContentStream(e,n={}){var s;const i=X(e),o=Object.assign(Object.assign({},this._requestOptions),n);return pt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}startChat(e){var n;return new ye(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(n=this.cachedContent)===null||n===void 0?void 0:n.name},e),this._requestOptions)}async countTokens(e,n={}){const s=he(e,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),i=Object.assign(Object.assign({},this._requestOptions),n);return Ie(this.apiKey,this.model,s,i)}async embedContent(e,n={}){const s=me(e),i=Object.assign(Object.assign({},this._requestOptions),n);return ve(this.apiKey,this.model,s,i)}async batchEmbedContents(e,n={}){const s=Object.assign(Object.assign({},this._requestOptions),n);return _e(this.apiKey,this.model,e,s)}}class it{constructor(e){this.apiKey=e}getGenerativeModel(e,n){if(!e.model)throw new m("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new st(this.apiKey,e,n)}getGenerativeModelFromCachedContent(e,n,s){if(!e.name)throw new y("Cached content must contain a `name` field.");if(!e.model)throw new y("Cached content must contain a `model` field.");const i=["model","systemInstruction"];for(const a of i)if(n?.[a]&&e[a]&&n?.[a]!==e[a]){if(a==="model"){const u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,c=e.model.startsWith("models/")?e.model.replace("models/",""):e.model;if(u===c)continue}throw new y(`Different value for "${a}" specified in modelParams (${n[a]}) and cachedContent (${e[a]})`)}const o=Object.assign(Object.assign({},n),{model:e.model,tools:e.tools,toolConfig:e.toolConfig,systemInstruction:e.systemInstruction,cachedContent:e});return new st(this.apiKey,o,s)}}function ot(t,e){const n=Ee(t),s=we(n,e);return{tools:n,toolConfig:s}}function Ee(t){let e=[];const n=[];return t.forEach(i=>{if(at(i)){const[o]=Wt([i]);o.functionDeclarations&&e.push(...o.functionDeclarations)}else if(rt(i)){const{functionDeclarations:o}=Te(i);if(o)e.push(...o);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else n.push(i)}),n.find(i=>"functionDeclarations"in i)?n.map(i=>{if(e?.length>0&&"functionDeclarations"in i){const o={functionDeclarations:[...i.functionDeclarations||[],...e]};return e=[],o}return i}):[...n,...e.length>0?[{functionDeclarations:e}]:[]]}function Te(t){return{functionDeclarations:[{name:t.function.name,description:t.function.description,parameters:I(t.function.parameters)}]}}function we(t,e){if(!t.length||!e)return;const{toolChoice:n,allowedFunctionNames:s}=e,i={any:E.ANY,auto:E.AUTO,none:E.NONE};if(n&&["any","auto","none"].includes(n))return{functionCallingConfig:{mode:i[n]??"MODE_UNSPECIFIED",allowedFunctionNames:s}};if(typeof n=="string"||s)return{functionCallingConfig:{mode:E.ANY,allowedFunctionNames:[...s??[],...n&&typeof n=="string"?[n]:[]]}}}const Se={"gemini-embedding-001":{maxInputTokens:2048,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-image":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-preview-05-20":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-flash-lite-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-flash-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-05-06":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.0-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash-preview-native-audio":{maxInputTokens:131072,imageInputs:!1,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.0-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-06-05":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite-preview-06-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-image-preview":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-04-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-pro-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-pro":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-flash":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-1.5-flash-8b":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-pro":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1}};var Re=Se,be=class extends Ot{static lc_name(){return"ChatGoogleGenerativeAI"}lc_serializable=!0;get lc_secrets(){return{apiKey:"GOOGLE_API_KEY"}}lc_namespace=["langchain","chat_models","google_genai"];get lc_aliases(){return{apiKey:"google_api_key"}}model;temperature;maxOutputTokens;topP;topK;stopSequences=[];safetySettings;apiKey;streaming=!1;json;streamUsage=!0;convertSystemMessageToHumanContent;thinkingConfig;client;get _isMultimodalModel(){return this.model.includes("vision")||this.model.startsWith("gemini-1.5")||this.model.startsWith("gemini-2")||this.model.startsWith("gemma-3-")&&!this.model.startsWith("gemma-3-1b")||this.model.startsWith("gemini-3")}constructor(t){if(super(t),this.model=t.model.replace(/^models\//,""),this.maxOutputTokens=t.maxOutputTokens??this.maxOutputTokens,this.maxOutputTokens&&this.maxOutputTokens<0)throw new Error("`maxOutputTokens` must be a positive integer");if(this.temperature=t.temperature??this.temperature,this.temperature&&(this.temperature<0||this.temperature>2))throw new Error("`temperature` must be in the range of [0.0,2.0]");if(this.topP=t.topP??this.topP,this.topP&&this.topP<0)throw new Error("`topP` must be a positive integer");if(this.topP&&this.topP>1)throw new Error("`topP` must be below 1.");if(this.topK=t.topK??this.topK,this.topK&&this.topK<0)throw new Error("`topK` must be a positive integer");if(this.stopSequences=t.stopSequences??this.stopSequences,this.apiKey=t.apiKey??kt("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environment variable GOOGLE_API_KEY or in the `apiKey` field of the ChatGoogleGenerativeAI constructor");if(this.safetySettings=t.safetySettings??this.safetySettings,this.safetySettings&&this.safetySettings.length>0&&new Set(this.safetySettings.map(n=>n.category)).size!==this.safetySettings.length)throw new Error("The categories in `safetySettings` array must be unique");this.streaming=t.streaming??this.streaming,this.json=t.json,this.thinkingConfig=t.thinkingConfig??this.thinkingConfig,this.client=new it(this.apiKey).getGenerativeModel({model:this.model,safetySettings:this.safetySettings,generationConfig:{stopSequences:this.stopSequences,maxOutputTokens:this.maxOutputTokens,temperature:this.temperature,topP:this.topP,topK:this.topK,...this.json?{responseMimeType:"application/json"}:{},...this.thinkingConfig?{thinkingConfig:this.thinkingConfig}:{}}},{apiVersion:t.apiVersion,baseUrl:t.baseUrl,customHeaders:t.customHeaders}),this.streamUsage=t.streamUsage??this.streamUsage}useCachedContent(t,e,n){this.apiKey&&(this.client=new it(this.apiKey).getGenerativeModelFromCachedContent(t,e,n))}get useSystemInstruction(){return typeof this.convertSystemMessageToHumanContent=="boolean"?!this.convertSystemMessageToHumanContent:this.computeUseSystemInstruction}get computeUseSystemInstruction(){return this.model==="gemini-1.0-pro-001"||this.model.startsWith("gemini-pro-vision")||this.model.startsWith("gemini-1.0-pro-vision")?!1:this.model!=="gemini-pro"}getLsParams(t){return{ls_provider:"google_genai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:this.client.generationConfig.temperature,ls_max_tokens:this.client.generationConfig.maxOutputTokens,ls_stop:t.stop}}_combineLLMOutput(){return[]}_llmType(){return"googlegenerativeai"}bindTools(t,e){return this.withConfig({tools:ot(t)?.tools,...e})}invocationParams(t){const e=t?.tools?.length?ot(t.tools,{toolChoice:t.tool_choice,allowedFunctionNames:t.allowedFunctionNames}):void 0;return t?.responseSchema?(this.client.generationConfig.responseSchema=t.responseSchema,this.client.generationConfig.responseMimeType="application/json"):(this.client.generationConfig.responseSchema=void 0,this.client.generationConfig.responseMimeType=this.json?"application/json":void 0),{...e?.tools?{tools:e.tools}:{},...e?.toolConfig?{toolConfig:e.toolConfig}:{}}}async _generate(t,e,n){const s=P(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[p]=s;this.client.systemInstruction=p,i=s.slice(1)}const o=this.invocationParams(e);if(this.streaming){const p={},r=this._streamResponseChunks(t,e,n),l={};for await(const d of r){const g=d.generationInfo?.completion??0;l[g]===void 0?l[g]=d:l[g]=l[g].concat(d)}return{generations:Object.entries(l).sort(([d],[g])=>parseInt(d,10)-parseInt(g,10)).map(([d,g])=>g),llmOutput:{estimatedTokenUsage:p}}}const a=await this.completionWithRetry({...o,contents:i});let u;"usageMetadata"in a.response&&(u=j(a.response.usageMetadata,this.model));const c=Bt(a.response,{usageMetadata:u});return c.generations?.length>0&&await n?.handleLLMNewToken(c.generations[0]?.text??""),c}async*_streamResponseChunks(t,e,n){const s=P(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[f]=s;this.client.systemInstruction=f,i=s.slice(1)}const a={...this.invocationParams(e),contents:i},u=await this.caller.callWithOptions({signal:e?.signal},async()=>{const{stream:f}=await this.client.generateContentStream(a);return f});let c,p=0,r=0,l=0;for await(const f of u){if("usageMetadata"in f&&f.usageMetadata!==void 0&&this.streamUsage!==!1&&e.streamUsage!==!1){c=j(f.usageMetadata,this.model);const g=f.usageMetadata.promptTokenCount??0;c.input_tokens=Math.max(0,g-p),p=g;const C=f.usageMetadata.candidatesTokenCount??0;c.output_tokens=Math.max(0,C-r),r=C;const D=f.usageMetadata.totalTokenCount??0;c.total_tokens=Math.max(0,D-l),l=D}const d=qt(f,{usageMetadata:c});d&&(yield d,await n?.handleLLMNewToken(d.text??""))}}async completionWithRetry(t,e){return this.caller.callWithOptions({signal:e?.signal},async()=>{try{return await this.client.generateContent(t)}catch(n){throw n.message?.includes("400 Bad Request")&&(n.status=400),n}})}get profile(){return Re[this.model]??{}}withStructuredOutput(t,e){const n=t,s=e?.name,i=e?.method,o=e?.includeRaw;if(i==="jsonMode")throw new Error('ChatGoogleGenerativeAI only supports "jsonSchema" or "functionCalling" as a method.');let a,u;if(i==="functionCalling"){let l=s??"extract",f;if(ut(n)){const d=N(n);f=[{functionDeclarations:[{name:l,description:d.description??"A function available to call.",parameters:d}]}],u=new F({returnSingle:!0,keyName:l,zodSchema:n})}else{let d;typeof n.name=="string"&&typeof n.parameters=="object"&&n.parameters!=null?(d=n,d.parameters=I(n.parameters),l=n.name):d={name:l,description:n.description??"",parameters:I(n)},f=[{functionDeclarations:[d]}],u=new F({returnSingle:!0,keyName:l})}a=this.bindTools(f).withConfig({allowedFunctionNames:[l]})}else{const l=N(n);a=this.withConfig({responseSchema:l}),u=new yt}if(!o)return a.pipe(u).withConfig({runName:"ChatGoogleGenerativeAIStructuredOutput"});const c=G.assign({parsed:(l,f)=>u.invoke(l.raw,f)}),p=G.assign({parsed:()=>null}),r=c.withFallbacks({fallbacks:[p]});return Nt.from([{raw:a},r]).withConfig({runName:"StructuredOutputRunnable"})}};export{be as ChatGoogleGenerativeAI};
@@ -1,4 +1,4 @@
1
- import{F as Es,aK as Ra,aL as I,V as $a,U as Pa,y as $e,L as Jn,i as Xe,ad as Ea,ap as Ma,M as Na,I as Ms,J as Ns,B as Se,f as js,aM as ja,E as mn,aN as Kn,aO as Ua,aP as La,aQ as Da,K as Zn,aR as zn,aS as Fa,t as Ba,D as Gt}from"./index-BImPVgbs.js";import{c as Wa,j as qa,h as Ja,f as Us,S as Hn,J as Vn,R as Xn}from"./index-DLuEx6sZ.js";import{x as Ka,y as Za,o as K,m as ee,v as Ls,n as J,i as At,s as Q,q as gn,z as za}from"./index-y9BdsFxs.js";import{J as Gn,c as Ha,p as Ds,m as at}from"./llms-BEhi1hX3.js";import"./embeddings-BEd7QUVp.js";import"./index-Ba2qnGU3.js";function Ge(t,e){return t.lc_error_code=e,t.message=`${t.message}
1
+ import{F as Es,aK as Ra,aL as I,V as $a,U as Pa,y as $e,L as Jn,i as Xe,ad as Ea,ap as Ma,M as Na,I as Ms,J as Ns,B as Se,f as js,aM as ja,E as mn,aN as Kn,aO as Ua,aP as La,aQ as Da,K as Zn,aR as zn,aS as Fa,t as Ba,D as Gt}from"./index-5tcyL8PS.js";import{c as Wa,j as qa,h as Ja,f as Us,S as Hn,J as Vn,R as Xn}from"./index-dPGaXGit.js";import{x as Ka,y as Za,o as K,m as ee,v as Ls,n as J,i as At,s as Q,q as gn,z as za}from"./index-rJak6aaF.js";import{J as Gn,c as Ha,p as Ds,m as at}from"./llms-DKIS8zd3.js";import"./embeddings-DmOKcAlW.js";import"./index-mdT8Rmhl.js";function Ge(t,e){return t.lc_error_code=e,t.message=`${t.message}
2
2
 
3
3
  Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${e}/
4
4
  `,t}function O(t,e,n,s,r){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}function c(t,e,n,s){if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?s:n==="a"?s.call(t):s?s.value:e.get(t)}let Fs=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return Fs=t.randomUUID.bind(t),t.randomUUID();const e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^n()&15>>+s/4).toString(16))};function Qt(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const Yt=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class x extends Error{}class q extends x{constructor(e,n,s,r){super(`${q.makeMessage(e,n,s)}`),this.status=e,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=n;const a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,n,s){const r=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)"}static generate(e,n,s,r){if(!e||!r)return new Rt({message:s,cause:Yt(n)});const a=n?.error;return e===400?new Bs(e,a,s,r):e===401?new Ws(e,a,s,r):e===403?new qs(e,a,s,r):e===404?new Js(e,a,s,r):e===409?new Ks(e,a,s,r):e===422?new Zs(e,a,s,r):e===429?new zs(e,a,s,r):e>=500?new Hs(e,a,s,r):new q(e,a,s,r)}}class Y extends q{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Rt extends q{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class $t extends Rt{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Bs extends q{}class Ws extends q{}class qs extends q{}class Js extends q{}class Ks extends q{}class Zs extends q{}class zs extends q{}class Hs extends q{}class Vs extends x{constructor(){super("Could not parse response content as the length limit was reached")}}class Xs extends x{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Pe extends Error{constructor(e){super(e)}}const Va=/^[a-z][a-z0-9+.-]*:/i,Xa=t=>Va.test(t);let H=t=>(H=Array.isArray,H(t)),Qn=H;function Gs(t){return typeof t!="object"?{}:t??{}}function Ga(t){if(!t)return!0;for(const e in t)return!1;return!0}function Qa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Wt(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}const Ya=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new x(`${t} must be an integer`);if(e<0)throw new x(`${t} must be a positive integer`);return e},ei=t=>{try{return JSON.parse(t)}catch{return}},Ke=t=>new Promise(e=>setTimeout(e,t)),Oe="6.10.0",ti=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function ni(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const si=()=>{const t=ni();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Oe,"X-Stainless-OS":es(Deno.build.os),"X-Stainless-Arch":Yn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Oe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Oe,"X-Stainless-OS":es(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Yn(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=ri();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Oe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Oe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ri(){if(typeof navigator>"u"||!navigator)return null;const t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:n}of t){const s=n.exec(navigator.userAgent);if(s){const r=s[1]||0,a=s[2]||0,i=s[3]||0;return{browser:e,version:`${r}.${a}.${i}`}}}return null}const Yn=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",es=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown");let ts;const ai=()=>ts??(ts=si());function ii(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Qs(...t){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function Ys(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return Qs({start(){},async pull(n){const{done:s,value:r}=await e.next();s?n.close():n.enqueue(r)},async cancel(){await e.return?.()}})}function er(t){if(t[Symbol.asyncIterator])return t;const e=t.getReader();return{async next(){try{const n=await e.read();return n?.done&&e.releaseLock(),n}catch(n){throw e.releaseLock(),n}},async return(){const n=e.cancel();return e.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function oi(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}const e=t.getReader(),n=e.cancel();e.releaseLock(),await n}const ui=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),tr="RFC3986",nr=t=>String(t),ns={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:nr},li="RFC1738";let en=(t,e)=>(en=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),en(t,e));const re=(()=>{const t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})(),qt=1024,ci=(t,e,n,s,r)=>{if(t.length===0)return t;let a=t;if(typeof t=="symbol"?a=Symbol.prototype.toString.call(t):typeof t!="string"&&(a=String(t)),n==="iso-8859-1")return escape(a).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});let i="";for(let o=0;o<a.length;o+=qt){const l=a.length>=qt?a.slice(o,o+qt):a,u=[];for(let m=0;m<l.length;++m){let p=l.charCodeAt(m);if(p===45||p===46||p===95||p===126||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||r===li&&(p===40||p===41)){u[u.length]=l.charAt(m);continue}if(p<128){u[u.length]=re[p];continue}if(p<2048){u[u.length]=re[192|p>>6]+re[128|p&63];continue}if(p<55296||p>=57344){u[u.length]=re[224|p>>12]+re[128|p>>6&63]+re[128|p&63];continue}m+=1,p=65536+((p&1023)<<10|l.charCodeAt(m)&1023),u[u.length]=re[240|p>>18]+re[128|p>>12&63]+re[128|p>>6&63]+re[128|p&63]}i+=u.join("")}return i};function di(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function ss(t,e){if(H(t)){const n=[];for(let s=0;s<t.length;s+=1)n.push(e(t[s]));return n}return e(t)}const sr={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},rr=function(t,e){Array.prototype.push.apply(t,H(e)?e:[e])};let rs;const j={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ci,encodeValuesOnly:!1,format:tr,formatter:nr,indices:!1,serializeDate(t){return(rs??(rs=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function pi(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}const Jt={};function ar(t,e,n,s,r,a,i,o,l,u,m,p,f,d,b,w,$,h){let g=t,T=h,C=0,Z=!1;for(;(T=T.get(Jt))!==void 0&&!Z;){const P=T.get(t);if(C+=1,typeof P<"u"){if(P===C)throw new RangeError("Cyclic object value");Z=!0}typeof T.get(Jt)>"u"&&(C=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=f?.(g):n==="comma"&&H(g)&&(g=ss(g,function(P){return P instanceof Date?f?.(P):P})),g===null){if(a)return l&&!w?l(e,j.encoder,$,"key",d):e;g=""}if(pi(g)||di(g)){if(l){const P=w?e:l(e,j.encoder,$,"key",d);return[b?.(P)+"="+b?.(l(g,j.encoder,$,"value",d))]}return[b?.(e)+"="+b?.(String(g))]}const U=[];if(typeof g>"u")return U;let R;if(n==="comma"&&H(g))w&&l&&(g=ss(g,l)),R=[{value:g.length>0?g.join(",")||null:void 0}];else if(H(u))R=u;else{const P=Object.keys(g);R=m?P.sort(m):P}const F=o?String(e).replace(/\./g,"%2E"):String(e),L=s&&H(g)&&g.length===1?F+"[]":F;if(r&&H(g)&&g.length===0)return L+"[]";for(let P=0;P<R.length;++P){const M=R[P],Wn=typeof M=="object"&&typeof M.value<"u"?M.value:g[M];if(i&&Wn===null)continue;const Bt=p&&o?M.replace(/\./g,"%2E"):M,Aa=H(g)?typeof n=="function"?n(L,Bt):L:L+(p?"."+Bt:"["+Bt+"]");h.set(t,C);const qn=new WeakMap;qn.set(Jt,h),rr(U,ar(Wn,Aa,n,s,r,a,i,o,n==="comma"&&w&&H(g)?null:l,u,m,p,f,d,b,w,$,qn))}return U}function fi(t=j){if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=t.charset||j.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=tr;if(typeof t.format<"u"){if(!en(ns,t.format))throw new TypeError("Unknown format option provided.");n=t.format}const s=ns[n];let r=j.filter;(typeof t.filter=="function"||H(t.filter))&&(r=t.filter);let a;if(t.arrayFormat&&t.arrayFormat in sr?a=t.arrayFormat:"indices"in t?a=t.indices?"indices":"repeat":a=j.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const i=typeof t.allowDots>"u"?t.encodeDotInKeys?!0:j.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:j.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:j.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:j.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?j.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:j.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:j.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:j.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:j.encodeValuesOnly,filter:r,format:n,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:j.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:j.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:j.strictNullHandling}}function hi(t,e={}){let n=t;const s=fi(e);let r,a;typeof s.filter=="function"?(a=s.filter,n=a("",n)):H(s.filter)&&(a=s.filter,r=a);const i=[];if(typeof n!="object"||n===null)return"";const o=sr[s.arrayFormat],l=o==="comma"&&s.commaRoundTrip;r||(r=Object.keys(n)),s.sort&&r.sort(s.sort);const u=new WeakMap;for(let f=0;f<r.length;++f){const d=r[f];s.skipNulls&&n[d]===null||rr(i,ar(n[d],d,o,l,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,u))}const m=i.join(s.delimiter);let p=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),m.length>0?p+m:""}function mi(t){let e=0;for(const r of t)e+=r.length;const n=new Uint8Array(e);let s=0;for(const r of t)n.set(r,s),s+=r.length;return n}let as;function _n(t){let e;return(as??(e=new globalThis.TextEncoder,as=e.encode.bind(e)))(t)}let is;function os(t){let e;return(is??(e=new globalThis.TextDecoder,is=e.decode.bind(e)))(t)}var V,X;class Pt{constructor(){V.set(this,void 0),X.set(this,void 0),O(this,V,new Uint8Array),O(this,X,null)}decode(e){if(e==null)return[];const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?_n(e):e;O(this,V,mi([c(this,V,"f"),n]));const s=[];let r;for(;(r=gi(c(this,V,"f"),c(this,X,"f")))!=null;){if(r.carriage&&c(this,X,"f")==null){O(this,X,r.index);continue}if(c(this,X,"f")!=null&&(r.index!==c(this,X,"f")+1||r.carriage)){s.push(os(c(this,V,"f").subarray(0,c(this,X,"f")-1))),O(this,V,c(this,V,"f").subarray(c(this,X,"f"))),O(this,X,null);continue}const a=c(this,X,"f")!==null?r.preceding-1:r.preceding,i=os(c(this,V,"f").subarray(0,a));s.push(i),O(this,V,c(this,V,"f").subarray(r.index)),O(this,X,null)}return s}flush(){return c(this,V,"f").length?this.decode(`