offsite 0.0.84 → 0.0.86

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.
@@ -0,0 +1,67 @@
1
+ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{c as n,l as r,r as i}from"./utils-U6QfaJBO.js";import{A as a,C as o,D as s,E as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,k as x,l as S,m as C,n as w,o as ee,p as te,r as ne,s as re,u as ie,v as ae,w as oe,x as se,y as ce}from"./tags-DrTyXsO5.js";function T(e){return e[e.length-1]}function le(e,t){return typeof e==`function`?e(t):e}var ue=Object.prototype.hasOwnProperty;function de(e){for(let t in e)if(ue.call(e,t))return!0;return!1}var fe=()=>Object.create(null),pe=(e,t)=>me(e,t,!0);function me(e,t,n,r=0){if(e===t)return e;if(r++>500)return t;let i=Array.isArray(e)&&Array.isArray(t);if(!i&&!(he(e)&&he(t)))return t;let a=Object.keys(e),o=a.length,s=Object.keys(t),c=s.length;if(i?o!==e.length||c!==t.length||o&&T(a)!==`${o-1}`||c&&T(s)!==`${c-1}`:o!==Object.getOwnPropertyNames(e).length||c!==Object.getOwnPropertyNames(t).length||Object.getOwnPropertySymbols(t).length)return t;let l=0,u,d,f;if(i){for(;l<c&&(f=l,d=e[f],u=t[f],u=d===u?d:typeof d==`object`?me(d,u,n,r):u,u===d);l++);if(l===c&&o===c)return e}else{let i=o===c,p=!0;for(;l<c;l++){f=s[l],d=e[f];let o=t[f];u=d===o?d:typeof d==`object`?me(d,o,n,r):o,i&&=u===d&&(a[l]===f||ue.call(e,f)),p&&=Object.is(u,o),a[l]=u}if(i)return Object.getOwnPropertySymbols(e).length?t:e;if(p)return t}let p=i?s.fill(0):n?fe():{};for(let o=0;o<c;o++)f=i?o:s[o],i?(d=e[f],o>l&&(u=t[f],u=d===u?d:typeof d==`object`?me(d,u,n,r):u),p[f]=o<l?d:u):p[f]=a[o];return p}function he(e){return!e||typeof e!=`object`?!1:(Object.getPrototypeOf(e)?.constructor??Object)===Object}function ge(e,t,n,r){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=t[i];if(a!==o&&!ge(a,o,n,r))return!1}return!0}if(he(e)&&he(t)){if(n){for(let i in t)if((r||t[i]!==void 0)&&!ge(e[i],t[i],n,r))return!1;return!0}let i=0;if(r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;for(let a in t)if((r||t[a]!==void 0)&&(i--===0||!ge(e[a],t[a],n,r)))return!1;return i===0}return!1}var _e=/[\x00-\x1f\x7f"<>`{}]/g;function ve(e){return e.replace(_e,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function ye(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return ve(t)}var be=[`http:`,`https:`,`mailto:`,`tel:`];function xe(e){if(e[0]!==`/`&&e.includes(`:`))return/^[\x00-\x20]*([a-z][a-z\d+.\t\n\r-]*:)/i.exec(e)?.[1]?.replace(/[\t\n\r]/g,``).toLowerCase()}var Se=/^[\x00-\x20]*[\\/][\t\n\r]*[\\/]/;function Ce(e,t){if(!e)return!1;if(Se.test(e))return!0;let n=xe(e);return n?!t.has(n):!1}function we(e){if(!e)return e;let t=e;if(/[%\\\x00-\x1f\x7f]/.test(e)){let n=/%25|%5C/gi,r=0,i;for(t=``;(i=n.exec(e))!==null;)t+=ye(e.slice(r,i.index))+i[0],r=n.lastIndex;t+=ye(r?e.slice(r):e)}return t}function Te(e){return/[\s\u0080-\uFFFF]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Ee(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function De(){throw Error(`Invariant failed`)}function Oe(e){return e.replace(/\/{2,}/g,`/`)}function ke(e){return e===`/`?e:e.replace(/^\/+/,``)}function Ae(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/+$/,``):e}function je(e){return Ae(ke(e))}function Me(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Ne(e,t,n=`never`,r){if(t.includes(`//`)&&(t=Oe(t)),t.startsWith(`/`))return t.length===1||n===`preserve`?t:n===`always`?t.endsWith(`/`)?t:`${t}/`:t.endsWith(`/`)?t.slice(0,-1):t;let i=t===`.`,a;if(r){a=i?e:e+`\0`+t;let n=r.get(a);if(n)return n}let o;if(i)o=e.split(`/`);else{for(e.includes(`//`)&&(e=Oe(e)),o=e.split(`/`);o.length>1&&T(o)===``;)o.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&o.push(r):o=[r]:r===`..`?o.length>1?o.pop():o=[``]:r===`.`||o.push(r)}}o.length>1&&(T(o)===``?n===`never`&&o.pop():n===`always`&&o.push(``));let s=o.join(`/`),c=(i?Oe(s):s)||`/`;return a&&r&&r.set(a,c),c}function Pe(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=new RegExp([...t.keys()].join(`|`).replace(/[.*()]/g,`\\$&`),`g`);return e=>e.replace(n,e=>t.get(e)??e)}function Fe(e){return e==null||e===``}function Ie(e,t,n){if(typeof t!=`string`)return``+(t??void 0);let r=e===`_splat`;if(r&&(!t||/^[a-zA-Z0-9\-._~!/]*$/.test(t)))return t;let i=encodeURIComponent(t);return r&&(i=i.replaceAll(`%2F`,`/`)),n?n(i):i}function Le(e,t,n,r,i){let a=e.endsWith(`/`)?`/`:``,o=``;for(let e of t){if(typeof e==`string`){o+=e;continue}let[t,s,c,l]=e,u=t===2,d=u&&l!==void 0?l+a:l,f=n[s];if(t!==3||f!=null){if(i&&(i[s]=f,u&&(i[`*`]=f)),u&&Fe(f)){if(c===`/`&&!d)continue;f=``}o+=c+Ie(s,f,r)+(d||``)}}return o+a||`/`}function Re(e){return e?.isNotFound===!0}function ze(){try{return sessionStorage}catch{return}}var Be=`tsr-scroll-restoration-v1_3`,Ve=ze();function He(){try{return JSON.parse(Ve?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}var Ue=He(),We=`data-scroll-restoration-id`,Ge=e=>e.state.__TSR_key||e.href;function Ke(e){let t=e.getAttribute(We);if(t)return`[${We}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var qe=!1,Je=`window`;function Ye(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function Xe(e){let t=new Set;for(let n of e){if(n===Je)continue;let e=Ye(n);e&&t.add(e)}return t}function Ze(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.e=!0);let i=e.options.getScrollRestorationKey||Ge,a=new Set,o=e=>{let t=Ue[e]||={};for(let e of a)e===document?t[Je]={scrollX,scrollY}:e.isConnected&&(t[Ke(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.s&&(r.s=!0,qe=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{qe||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{history.scrollRestoration=`auto`,o(i(e.stores.resolvedLocation.get()??e.stores.location.get()));try{Ve?.setItem(Be,JSON.stringify(Ue))}catch{}}),addEventListener(`pageshow`,e=>{e.persisted&&(history.scrollRestoration=`manual`)})),r.r||(r.r=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.n,c=r.h,l;if(a.clear(),r.n=!0,r.h=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.e&&d&&d!==u){let e=Ue[d];if(e){let t=Ue[u];for(let n in e){if(n===Je){if(s)continue}else{let e=Ye(n);if(!e||s&&o&&(l??=Xe(o),l.has(e)))continue}t||=Ue[u]={},t[n]??=e[n]}}}qe=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=Xe(o));let t=e&&i&&c,s=r.e?Ue[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===Je){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=Ye(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{qe=!1}}))}function Qe(e,t=String){let n;for(let r in e){let i=e[r];i!==void 0&&(n||=new URLSearchParams).set(r,t(i))}return n?n.toString():``}function $e(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function et(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=$e(r):Array.isArray(t)?t.push($e(r)):n[e]=[t,$e(r)]}return n}var tt=/^(?:\s|["[{\d-]|fa|nu|tr)/,nt=it(JSON.parse),rt=at(JSON.stringify,JSON.parse);function it(e){let t=e===JSON.parse;return n=>{n[0]===`?`&&(n=n.slice(1));let r=et(n);for(let n in r){let i=r[n];if(typeof i==`string`){if(t&&!tt.test(i))continue;try{r[n]=e(i)}catch{}}}return r}}function at(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!tt.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=Qe(e,r);return t?`?${t}`:``}}var ot=`__root__`;function st(e){e.statusCode=e.statusCode||e.code||307;let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function ct(e){return e instanceof Response&&!!e.options}function lt(e){let t=new Map,n,r;return{get(e){let n=t.get(e);if(n)return n.visited=!0,n.value},set(i,a){let o=t.get(i);if(o){o.value=a;return}if(t.size>=e){let e=n?.next().value;for(;!e||e.visited;)e?e.visited=!1:n=t.values(),e=n.next().value;e===r&&(n=void 0),t.delete(e.key)}let s={key:i,value:a,visited:!1};r=s,t.set(i,s)},clear(){t.clear(),n=void 0,r=void 0}}}var ut=4,dt=5;function ft(e){let t=e.names;if(t)return t;let n=[];for(let t of e)typeof t!=`string`&&n.push(t[1]);return e.names=n}function pt(e,t,n){let r=e.slice(t,n);if(r.charCodeAt(0)===36)return r.length===1?[2,`_splat`,``,void 0]:[1,r.slice(1),``,``];let i=r.indexOf(`{`);if(i>=0){let a=r.indexOf(`}`,i),o=r.charCodeAt(i+1)===45,s=i+(o?3:2);if(a>=0&&r.charCodeAt(s-1)===36&&(!o||s<a)){let c=r.slice(s,a);return[o?3:c?1:2,c||`_splat`,r.slice(0,i),e.slice(t+a+1,c?n:e.length)]}}return r}function mt(e,t,n,r,i,a){let o=n,s=t.fullPath??t.from,c=t.options,l=s.length,u=s.endsWith(`/`)?l-1:l,d=c?.caseSensitive??e,f=c?.params?.parse??c?.parseParams,p,m=a?n-1:0;if(!r||s.includes(`$`)){p=a?.slice()??[];let e=T(p);e&&typeof e!=`string`&&e[0]===2&&(p[p.length-1]=[e[0],e[1],e[2],e[3]===void 0?void 0:e[3]+s.substring(n-(s[n-2]===`/`?2:1),u)],m=l)}for(;o<l;){let e=o,t=s.indexOf(`/`,e),n=t===-1?l:t,a=pt(s,e,n);o=n+1;let c;if(typeof a==`string`){if(!r)continue;let e=a,t;d?t=r.static??=new Map:(e=a.toLowerCase(),t=r.staticInsensitive??=new Map);let n=t.get(e);if(n)c=n;else{let n=gt(r);c=n,t.set(e,n)}}else{let t=a[0],h=a[2],g=a[3]??``;if(t===2&&(n=l,o=n+1),p&&m<n&&(m<e-1&&p.push(s.slice(m,e-1)),a[2]=`/`+h,t===2&&a[3]!==void 0&&u<l&&(a[3]=g.slice(0,-1)),p.push(a),m=n),!r)continue;let _=d&&!!(h||g);d||(h=h.toLowerCase(),g=g.toLowerCase());let v=t===1?r.dynamic??=[]:t===3?r.optional??=[]:r.wildcard??=[],y=t!==2&&!f&&v.find(e=>!e.parse&&e.caseSensitive===_&&e.prefix===h&&e.suffix===g);if(y)c=y;else{let e=gt(r,t,_,h,g);c=e,v.push(e),v.length===2&&i?.push(v)}}r=c}p&&m<u&&p.push(s.slice(m,u));let h=p?.slice();if(!r)return h;if(f&&t.children&&!t.isRoot&&t.id&&t.id.charCodeAt(t.id.lastIndexOf(`/`)+1)===95){let e=gt(r,dt);(r.pathless??=[]).push(e),r=e}let g=(t.path||!t.children)&&!t.isRoot;if(g&&u<l){let e=gt(r,ut);r.index=e,r=e}return r.parse=f??null,r.priority=c?.params?.priority??0,r.route||(r.data=h,g&&(r.route=t)),[r,o,h]}function ht(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function gt(e,t=0,n,r,i){return{kind:t,depth:e?e.depth+1:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,data:void 0,parent:e,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function _t(e,t){let n=gt(),r=[];function i(e,t,n,a){let[o,s,c]=mt(!1,e,t,n,r,a);if(e.children)for(let t of e.children)i(t,s,o,c)}for(let t of e)i(t,1,n);for(let e of r)e.sort(ht);t.masksTree=n,t.flatCache=lt(1e3)}function vt(e,t){e||=`/`;let n=t.flatCache.get(e);if(n!==void 0)return n;let r=St(e,t.masksTree);return t.flatCache.set(e,r),r}function yt(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=gt(),mt(t,{from:e},1,o),i.singleCache.set(a,o)),St(r,o,n)}function bt(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=St(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=wt(a.route)),t.matchCache.set(r,a),a}function xt(e,t=!1){let n=gt(),r=[],i={},a={},o=0;function s(e,n,c,l){if(e.init(o),e.id in i&&De(),i[e.id]=e,o!==0&&e.path){let t=Ae(e.fullPath);(!a[t]||e.fullPath.endsWith(`/`))&&(a[t]=e)}o++;let[u,d,f]=mt(t,e,n,c,r,l);if(e._interpolation=f,e.children)for(let t of e.children)s(t,d,u,f)}s(e,1,n);for(let e of r)e.sort(ht);return{processedTree:{segmentTree:n,singleCache:lt(1e3),matchCache:lt(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:a}}function St(e,t,n=!1){let r=e.split(`/`),i=Et(e,r,t,n);if(!i)return null;let[a]=Ct(e,r,i);return{route:i.node.route,rawParams:a}}function Ct(e,t,n){let r=Tt(n.node),i=n.node.data&&ft(n.node.data),a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.param??0;for(;s<r.length;o++,s++,c++){let u=r[s];if(u.kind===ut)break;if(u.kind===dt){o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1||u.kind===3){let e=i[l++];if(u.kind===3&&n.skipped&1<<s){o--,c=f-1;continue}let t=u.suffix||u.prefix?d.substring(u.prefix.length,d.length-u.suffix.length):d;(t||u.kind===1)&&(a[e]=decodeURIComponent(t))}else if(u.kind===2){let t=u,n=e.substring(f+t.prefix.length,e.length-t.suffix.length),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,param:l}]}function wt(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Tt(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Et(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!T(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!At(l,n))continue;if(i.parse){if(!kt(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==ut&&At(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===ut||i.kind===2)&&At(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(kt(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&Ot(f,o))return n;At(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!r||!_&&(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)){if(a){if(_)continue;let e=t.slice(u).join(`/`),i=e.slice(-a.length);if((n.caseSensitive?i:i.toLowerCase())!==a||e.length-a.length<r.length)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+Dt(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+Dt(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+Dt(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+Dt(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function Dt(e,t){return 2**(e-t-1)}function Ot(e,t){return e===2**(t-1)-1}function kt(e,t,n){let r,i;try{[r,i]=Ct(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function At(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===ut)>(e.node.kind===ut)||t.node.kind===ut==(e.node.kind===ut)&&t.node.depth>e.node.depth)))}function jt(e,t,n){let r=je(e),i=`/${r}`,a=t?i:i.toLowerCase(),o=`${a}/`,s={input:({url:e})=>{let n=t?e.pathname:e.pathname.toLowerCase();return n===a?e.pathname=`/`:n.startsWith(o)&&(e.pathname=e.pathname.slice(i.length)),e},output:({url:e})=>(e.pathname=Oe(`/${r}${e.pathname}`),e)};return n?{input:({url:e})=>Mt(n,s.input({url:e})),output:({url:e})=>s.output({url:Nt(n,e)})}:s}function Mt(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Nt(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Pt(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{Ee(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var Ft=`__TSR_index`,It=`popstate`,Lt=`beforeunload`,Rt=/^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;function zt(e){let t=Rt.exec(e);return t?`/`+e.slice(t[0].length):e}function Bt(e){return/[\x00-\x1f\x7f]/.test(e)&&(e=e.replace(/[\x00-\x1f\x7f]/g,e=>`
2
+ \r`.includes(e)?``:encodeURIComponent(e))),zt(e)}function Vt(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async n=>{let r=n.navigateOpts?.ignoreBlocker?void 0:e.getBlockers?.();if(typeof document<`u`&&r?.length&&(n.type===`PUSH`||n.type===`REPLACE`))for(let i of r){let r=Wt(n.path,n.state);if(await i.blockerFn({currentLocation:t,nextLocation:r,action:n.type})){e.onBlocked?.();return}}n.task()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Ft];i=Ht(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Ft];i=Ht(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t,n?.ignoreBlocker??!1),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Ft]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r,_getBlockers:()=>e.getBlockers?.()??[]}}function Ht(e,t){let n=Gt();return{...t,key:n,__TSR_key:n,[Ft]:e}}function Ut(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=t=>Bt(e?.createHref?e.createHref(t):t),c=e?.parseLocation??(()=>Wt(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=Gt();t.history.replaceState({[Ft]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(t,n,r)=>{let i=e?.createHref?s(n):void 0,a=!!g;a||(u=l),l=Wt(n,r),g=[i??l.href,r,g?.[2]||t],a||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(m=!1,f){f=!1;return}let e=c(),n=e.state[Ft]-l.state[Ft],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let r=a();if(typeof document<`u`&&r.length){for(let i of r)if(await i.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(-n),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0||typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=Vt({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0,m=!0),t.history.back()),forward:e=>{e&&(p=!0,m=!0),t.history.forward()},go:(e,n)=>{d=!0,n&&(p=!0,m=!0),t.history.go(e)},createHref:s,flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Lt,x,{capture:!0}),t.removeEventListener(It,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return S._ignoreNextBeforeUnload=e=>{m=!1;try{e=new URL(e,t.document.baseURI).href,m=/^https?:/.test(e)&&(!e.includes(`#`)||e.split(`#`)[0]!==t.location.href.split(`#`)[0])}catch{}},t.addEventListener(Lt,x,{capture:!0}),t.addEventListener(It,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function Wt(e,t){let n=Bt(e),r=n.indexOf(`#`),i=n.indexOf(`?`);if(!t){let e=Gt();t={[Ft]:0,key:e,__TSR_key:e}}return{href:n,pathname:n.slice(0,r>-1?i>-1?Math.min(r,i):r:i>-1?i:n.length),hash:r>-1?n.slice(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t}}function Gt(){return(Math.random()+1).toString(36).slice(7)}function Kt(e,t){return e.protocol!==`http:`&&e.protocol!==`https:`||e.origin!==t||!!e.username||!!e.password}function qt(e){return e.pathname+e.search+e.hash}function Jt(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function Yt(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function Xt({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function Zt(e){return e.findIndex(e=>e.status===`error`||e.status===`notFound`||e._notFound)+1}function Qt(e,t,n,r,i,a){r&&(t=t.slice(0,r)),i&&(n=n.slice(0,i));for(let r of t){if(a&&e._tx!==a)return;n.some(e=>e.routeId===r.routeId)||e.routesById[r.routeId].options.onLeave?.(r)}for(let r of n){if(a&&e._tx!==a)return;e.routesById[r.routeId].options[t.some(e=>e.routeId===r.routeId)?`onStay`:`onEnter`]?.(r)}}var $t=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={n:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options;this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.staticLocations=new WeakMap,this.protocolAllowlist=new Set(this.options.protocolAllowlist),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:Ut()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`;let n=this.options.basepath??`/`,r=this.options.rewrite,i=this.basepath!==n||t?.rewrite!==r||t?.caseSensitive!==this.options.caseSensitive;if(i&&(this.basepath=n,this.rewrite=n!==`/`&&je(n)?jt(n,this.options.caseSensitive,r):r),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;e=this.buildRouteTree(),this.setRoutes(e)}if(this.stores)i&&this.stores.location.set(this.latestLocation);else if(this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Pt(this.latestLocation,e),Ze(this)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=xt(this.routeTree,this.options.caseSensitive);return this.options.routeMasks&&_t(this.options.routeMasks,e.processedTree),{...e,resolvePathCache:lt(1e3)}},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i},a)=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:we(e),external:!1,searchStr:o,search:pe(t?.search,i),hash:we(r.slice(1)),state:me(t?.state,a)}}let o=Mt(this.rewrite,new URL(i,this.origin)),s=this.options.parseSearch(o.search),c=this.options.stringifySearch(s);return o.search=c,{href:o.href.replace(o.origin,``),publicHref:i,pathname:we(zt(o.pathname)),external:!!this.rewrite&&Kt(o,this.origin),searchStr:c,search:pe(t?.search,s),hash:we(o.hash.slice(1)),state:me(t?.state,a)}},r=n(e,e.state),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i,{...i.state,__tempLocation:void 0,key:r.state.key,__TSR_key:r.state.__TSR_key});return e.maskedLocation=r,e}return r},this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=bt(Ae(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{{let t=this.staticLocations.get(e);if(t)return t}let t=!1,n=(n={})=>{if(n.href){let e=Wt(n.href,{});n={...n,to:Mt(this.rewrite,new URL(e.pathname,this.origin)).pathname,search:this.options.parseSearch(e.search),hash:e.hash.slice(1)}}let r=e._fromLocation||this._pendingLocation||this.latestLocation,i,a=()=>(t=!0,r),o=()=>i??=this.matchRoutesLightweight(a()),s=n.to?`${n.to}`:`.`,c=Ne(s[0]===`/`?``:n.unsafeRelative===`path`?a().pathname:n.from??o()[1],s,this.options.trailingSlash,this.resolvePathCache),l=this.routesByPath[Ae(c)],u=c.includes(`$`),d;if(l)d=l._branch??=wt(l);else if(u)d=[];else{let[e,t,n]=this.getMatchedRoutes(c);d=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(d=[...d,this.options.notFoundRoute])}let f=u?l?._interpolation??mt(!1,{fullPath:c},0):void 0,p;for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t){let e=o()[3];if(p??=an(n.params,e),!de(p))break;p===e&&(p=Object.assign(fe(),p));try{Object.assign(p,t(p))}catch{}}}p??=an(n.params,on(n.params,f)?o()[3]:sn);let m=e.leaveParams?c:zt(we(f?Le(c,f,p,this.pathParamsDecoder):c)),h=cn(d,e._includeValidateSearch),g=()=>{let t=o()[2];if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(n=>{if(n.options.validateSearch)try{Object.assign(e,rn(n.options.validateSearch,{...e,...t}))}catch{}}),t=e}return t},_=h.length?ln(h,g(),n):n.search===!0?g():typeof n.search==`function`?n.search(g()):n.search||sn,v=this.options.stringifySearch(_),y=n.hash===!0?a().hash:typeof n.hash==`function`?n.hash(a().hash):n.hash||void 0,b=y?`#${y}`:``,x=n.state?n.state===!0?a().state:typeof n.state==`function`?n.state(a().state):n.state:sn,S=`${m}${v}${b}`,C,w,ee=!1;if(this.rewrite){let e=new URL(S,this.origin),t=e.origin,n=Nt(this.rewrite,e);C=qt(e),Kt(n,t)?(w=n.href,ee=!0):w=zt(qt(n))}else C=Te(S),w=C;return{publicHref:w,href:C,pathname:m,search:_,searchStr:v,state:x,hash:y??``,external:ee,unmaskOnReload:n.unmaskOnReload}},r=n(e);if(e.mask)r.maskedLocation=n({from:e.from,...e.mask});else if(this.options.routeMasks){let t=vt(r.pathname,this.processedTree);if(t){let i=Object.assign(fe(),t.rawParams),{from:a,params:o,...s}=t.route,c=an(o,i);r.maskedLocation=n({from:e.from,...s,params:c})}}return!t&&e._fromLocation&&this.staticLocations.set(e,r),r},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=n.maskedLocation??n;if(r.external)return en(this,r.publicHref,{replace:n.replace,ignoreBlocker:t});let i,a=Ae(this.latestLocation.href)===Ae(n.href)&&ge(Xt(n.state),Xt(this.latestLocation.state)),o=this._commitPromise,s,c=new Promise(e=>{s=e});if(c.resolve=()=>{s(),o?.resolve()},this._commitPromise=c,a)this.load();else{let{maskedLocation:r,hashScrollIntoView:a,...o}=n;r&&(o={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state={...o.state,__hashScrollIntoViewOptions:a??this.options.defaultHashScrollIntoView??!0},this.shouldViewTransition=e,i=n.replace?`REPLACE`:`PUSH`,this.history[i===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:i}})}return this._scroll.n=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,...a}={})=>{let o=this.buildLocation({...a,_includeValidateSearch:!0});this._pendingLocation=o;let s=this.commitLocation({...o,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===o&&(this._pendingLocation=void 0)}),s},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=n?xe(n):void 0;if(a||t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i}),a=t.maskedLocation??t;n??=a.publicHref,r??=a.publicHref}let t=!a&&r?r:n;return en(this,t,i)}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.h=e.action.type===`PUSH`||e.action.type===`REPLACE`),await er(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(Yt(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set,a=e=>{(!n||n(e))&&i.add(e.id)};t.forEach(a),this._cache.forEach(a),r?.forEach(e=>e.forEach(a)),this._tx?.[3].forEach(a);let o=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),o.push(e));let s=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&Jt(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(s);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i){let t=this._flights?.get(e);this._flights?.delete(e),t&&!t[2]&&o.push(t[1])}for(let e of o)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.options,n=e.headers.get(`Location`)||t.href;if(!n){let e=this.buildLocation(t);n=(e.maskedLocation??e).publicHref||`/`}let r;if(Se.test(n)||(r=xe(n))&&!this.protocolAllowlist.has(r))throw Error(`Redirect blocked: unsafe protocol`);if(r===`http:`||r===`https:`){let e=new URL(n);e.pathname.startsWith(`//`)?n=e.href:Kt(e,this.origin)||(n=qt(e),r=void 0)}return r&&(t.reloadDocument=!0),t.href=n,e.headers.set(`Location`,n),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=mn,this.preloadRoute=e=>tr(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?Ne(e.from||``,e.to,this.options.trailingSlash,this.resolvePathCache):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=yt(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!ge(o.rawParams,e.params,!0)?!1:t?.includeSearch??!0?ge(a.search,r.search,!0)?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,e.pathParamsAllowedCharacters?.length&&(this.pathParamsDecoder=Pe(e.pathParamsAllowedCharacters)),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??rt,parseSearch:e.parseSearch??nt,protocolAllowlist:e.protocolAllowlist??be}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes(e){Object.assign(this,e),this.lightweightCache=new WeakMap,this.staticLocations=new WeakMap;let t=this.options.notFoundRoute;t&&(t.init(99999999999),this.routesById[t.id]!==t&&(t._interpolation=mt(!1,t,0)),this.routesById[t.id]=t)}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:Ae(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?un(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=rn(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof tn||(r=new tn(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let g=fe(),_=i._interpolation?Le(i.fullPath,i._interpolation,r,this.pathParamsDecoder,g):i.fullPath,v=i.id+_+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(g,d);let x;if(!b)try{dn(i,d)}catch(e){if(x=Re(e)||ct(e)?e:new nn(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:pe(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=Jt(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:_,updatedAt:Date.now(),search:y?pe(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?me(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?pe(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=T(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=T(a),c={...e.search};for(let e of a)try{Object.assign(c,rn(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=o;for(let t of a)try{dn(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}};async function en(e,t,{replace:n,ignoreBlocker:r}){if(!Ce(t,e.protocolAllowlist)){if(!r){let t=e.history._getBlockers();for(let r of t)if(r?.blockerFn&&await r.blockerFn({currentLocation:e.history.location,nextLocation:e.history.location,action:n?`REPLACE`:`PUSH`}))return}e.history._ignoreNextBeforeUnload?.(t),n?window.location.replace(t):window.location.href=t}}var tn=class extends Error{},nn=class extends Error{};function rn(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new tn(`Async validation not supported`);if(n.issues)throw new tn(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function an(e,t){if(e===void 0||e===!0)return t;let n=Object.create(null);return e===!1||e===null?n:typeof e==`function`?(Object.assign(n,t),Object.assign(n,e(n))):Object.assign(n,t,e)}function on(e,t){return typeof e==`function`?!0:!t||e===!1||e===null?!1:e===void 0||e===!0||t.some(t=>typeof t!=`string`&&!ue.call(e,t[1]))}var sn=Object.freeze({});function cn(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r].options;`search`in i?i.search?.middlewares&&n.push(...i.search.middlewares):(i.preSearchFilters||i.postSearchFilters)&&n.push(({search:e,next:t})=>{let n=t(i.preSearchFilters?i.preSearchFilters.reduce((e,t)=>t(e),e):e);return i.postSearchFilters?i.postSearchFilters.reduce((e,t)=>t(e),n):n});let a=i.validateSearch;t&&a&&n.push(({search:e,next:t,meta:n})=>{let r=t(e);try{let e=rn(a,r);if(n&&e)for(let t in e)t in r||(n.defaulted||=new Map).set(t,e[t]);return{...r,...e}}catch{}return r})}return n}function ln(e,t,n){let r=(t,i,a)=>{if(t>=e.length){if(!n.search)return{};if(n.search===!0)return i;let e=le(n.search,i);return a&&(a.explicit=e),e}return e[t]({search:i,next:(e,n)=>{if(n){let n=a||{};return{search:r(t+1,e,n),meta:n}}return r(t+1,e,a)},meta:a})};return r(0,t)}function un(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return ot}function dn(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function fn(e,t){return e.options[t]?.preload?.()}function pn(e,t){let n=fn(e,`component`),r=fn(e,`pendingComponent`);return t&&(r?r=r.then(t):t()),n&&r?Promise.all([n,r]).then(()=>{}):n??r}function mn(e,t,n){let r=()=>t===!1?void 0:t?fn(e,t):pn(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function hn(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}function gn(e,t,n){let r=e._tx;return t&&r?.[2]===n&&!r[3].some(e=>e.routeId===t)}var _n=0,vn=1,yn=2,E=3,bn=[4];function xn(e){return typeof e[0]==`number`}function Sn(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).then(()=>t.removeEventListener(`abort`,i))})}function Cn(e,t){return e.routesById[t.routeId]}function wn(e,t,n){return ct(e)?[E,e]:Re(e)?(e.routeId||=n,[yn,e]):t?(typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),[vn,e]):[_n,e]}function Tn(e,t){let n=wn(t,!0,e.id);if(n[0]!==vn)return n;try{e.options.onError?.(n[1])}catch(t){n=wn(t,!0,e.id)}return n}function En(e,t,n,r,i){return i[0].signal.aborted?bn:Vn(e,t,n,Tn(n,r),i)}async function Dn(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[3];for(let i=n[6]??0;i<r;i++){let r=s[i],u=Cn(e,r);r.abortController=n[0];let d=s[i-1]?.context??e.options.context??{},f={params:r.params,location:o,navigate:t=>e.navigate({...t,_fromLocation:o}),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:u.id};try{let e=r._ctx||=u.options.context?u.options.context({...f,deps:r.loaderDeps,context:d})||{}:void 0;r.context={...d,...e}}catch(a){return kn(e,r),[i,En(e,t,u,a,n)]}if(c.aborted)return[i,bn];let p=r.paramsError??r.searchError;if(p!==void 0)return kn(e,r),[i,En(e,t,u,p,n)];let m=u.options.beforeLoad;if(!m)continue;let h=r.status;i>=a&&(r.status=`pending`,n[7]?.());try{jn(e,r,`beforeLoad`,n[0]);let a=m({...f,search:r.search,context:r.context,...e.options.additionalContext}),o=await(typeof a?.then==`function`?Sn(a,c):a);if(c.aborted)return[i,bn];let s=Vn(e,t,u,wn(o,!1,u.id),n);if(s[0]!==_n)return kn(e,r),[i,s];r.context={...r.context,...o}}catch(a){return kn(e,r),[i,En(e,t,u,a,n)]}finally{r.status=h,jn(e,r,!1,n[0])}}i()}function On(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function kn(e,t){let n=t._flight;t._flight=void 0,On(e,t,n)?.abort()}function D(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=On(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function An(e){for(let t of e){let e=t._flight;e&&e[2]++}}function jn(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function Mn(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:t=>e.navigate({...t,_fromLocation:s}),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function Nn(e,t,n,r,i,a,o){let s=o[0],c=s.signal;if(c.aborted)return bn;if(!i)return[_n,void 0];let l=n._flight;jn(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(Mn(e,t,n,r,s,a,!!o[3]))).then(e=>wn(e,!1,r.id),e=>wn(e,!0,r.id)).then(t=>(t[0]!==_n&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===vn&&l[2]?Tn(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],Vn(e,t,r,await Sn(l[0],c),o)}catch(t){if(t!==c||!c.aborted)throw t;return kn(e,n),bn}finally{jn(e,n,!1,s)}}function Pn(e,t,n){t[0]!==E&&(e.status=`success`,e.error=void 0,t[0]===_n?(e.loaderData=t[1],e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):e.invalid=!0)}function Fn(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&kn(e,r)}function In(e,t){return t[0]===vn||t[0]===yn?{...e,status:t[0]===vn?`error`:`notFound`,error:t[1],_flight:void 0}:e}function Ln(e,t,n,r,i,a,o){let s=t[1][n],c=Cn(e,s),l=!!a[3],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(Mn(e,t,s,c,a[0],i,l))),a[0].signal.aborted&&(p=bn)),!p){if(s.status!==`success`)f=!0;else{let t=l||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[5]||s.cause===`enter`||a[2].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(n){s.invalid=!0,kn(e,s),p=En(e,t,c,n,a)}let m=c.options.loader,h=typeof m==`function`,g=h?m:m?.handler,_=!l||c.options.preload!==!1,v=_&&m?e._flights?.get(s.id):void 0;v===s._flight||p?v=void 0:v&&!f&&!l&&d===void 0?f=!0:f||(v=void 0);let y=!(!m||!f||s.status!==`success`||l||a[4]||((h?void 0:m.staleReloadMode)??e.options.defaultStaleReloadMode)===`blocking`),b=f&&_,x=b&&!y&&(s.status!==`success`||!!m),S=n>=o?a[7]:void 0,C=c.lazyFn&&c._lazy!==!0?S:void 0;if(b&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),v&&v[2]++,x){let t=s._flight;s._flight=v,On(e,s,t)?.abort(),n>=o&&(s.status=`pending`),S?.()}b||(s.isFetching=!1);let w=!p&&x?Nn(e,t,s,c,g,i,a).then(t=>(Pn(s,t,l),t[0]===_n&&(m&&!a[0].signal.aborted&&Fn(e,s,u),n>=o&&(s.status=`pending`)),t)):Promise.resolve(p??[_n,s.loaderData]),ee=(async()=>{try{let e=mn(c,void 0,C);e&&await Sn(e,a[0].signal)}catch(r){if(!t[1].some((e,t)=>t<=n&&(e.status===`error`||e.status===`notFound`||e._notFound)))return[n,En(e,t,c,r,a)]}let r=await w;x&&r[0]===_n&&s.status===`pending`&&!a[0].signal.aborted&&(s.status=`success`,S?.())})();if(r.push([n,w,ee]),!y)return w.then(e=>In(s,e));let te={...s,status:`pending`,preload:!1,_flight:v};s.invalid=!1,s.isFetching=`loader`;let ne=Nn(e,t,te,c,g,i,a).then(e=>(s.isFetching=!1,Pn(te,e,!1),e));return(t[2]??=[]).push([n,ne,ee,te]),ne.then(e=>In(te,e))}async function Rn(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=Cn(e,t[n]);try{let e=mn(i,!1);e&&await Sn(e,r)}catch(e){if(e===r&&r.aborted)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function zn(e,t){t[2]&&=(D(e,t[2].map(e=>e[3])),void 0)}async function Bn(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=E)throw[a,t];!i&&t[0]!==_n&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===E)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}function Vn(e,t,n,r,i,a){for(;r[0]===E;){let o=r[1],s=o.options;try{if((s.href||o.headers.has(`Location`))&&(e.resolveRedirect(o),s.reloadDocument)||(s.reloadDocument?i[3]:i[1]>=20))return r;let n=e.buildLocation({...s,_fromLocation:t[0],_includeValidateSearch:!0}),a=n.maskedLocation??n;if(a.external){let t=o.clone();return t.options={...s},t.headers.set(`Location`,a.publicHref),e.resolveRedirect(t),i[3]?[E,t]:[E,t,a]}return[E,o,n]}catch(e){r=a?[vn,e]:Tn(n,e),a=!0}}return r}async function Hn(e,t,n,r,i,a){let o=t[1],s=await i,c=!1,l=o.findIndex(e=>e._notFound),u=t=>t[1][0]===yn?Rn(e,o,t,r.signal):t[0],d=l<0?o.length:l;if((s?.[1][0]??0)>=E)d=0;else if(s){d=s[2]??=await u(s);for(let e of n){if(e[0]>=d)break;let t=await e[1];if(t[0]!==_n&&t[0]<E&&!(`loaderData`in o[e[0]])){s=[e[0],t],d=s[2]=await u(s);break}}}for(let e of n){if(e[0]>=d)break;let t=await e[2];if(t){s=t;break}}if((s?.[1][0]??0)>=E){let n=s[1];if(n[0]!==E||n[1].options.reloadDocument||n[2])return zn(e,t),n;c=!0,s=[0,[vn,Error(`Too many redirects`)]]}let f=s?s[2]??await u(s):l;if(f>=0){let i=s?.[1],l=i?.[0],u=o[f],d=i?.[1],p=()=>{i&&(u._notFound=void 0,l===vn?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};p(),i||a?.();let m=Cn(e,u);try{await Sn(i?Promise.resolve().then(()=>mn(m,l===vn?`errorComponent`:`notFoundComponent`)):Promise.all([mn(m),mn(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal&&r.signal.aborted)return zn(e,t),bn}i?c&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),zn(e,t),D(e,o),p()):u.status=`success`}return t}async function Un(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=Cn(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await Sn(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n&&n.aborted)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function Wn(e,t,n,r){let i=[t,n],a=r[0].signal,o;try{let t=e.stores.matches.get(),s=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&s>=0){let t=await Rn(e,n,void 0,a,s);n[s]._notFound=void 0,n[t]._notFound=!0,s=t}let c=s<0?n.length:s+1,l=0;for(;l<c&&l!==s;){let e=n[l],i=r[2][l],a=t[l];if(i?.id!==e.id||i.status!==`success`||e.preload||a?.id!==e.id||a.status!==`success`||(l++,i._notFound||a._notFound))break}let u=[],d=r[6]??0,f=d?Promise.resolve(n[d-1]):void 0,p=()=>{for(let t=d;t<c&&!a.aborted;t++)f=Ln(e,i,t,u,f,r,l)},m=await Dn(e,i,r,c,p,l);if(m){if(r[4]=!0,c=m[0],m[1][0]===yn){let t=await Rn(e,n,m,a);m[2]=t,c=Math.min(c,t+1)}else m[1][0]>=E&&(c=0);p()}if(!a.aborted&&!r[3]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let h=Hn(e,i,u,r[0],Bn(u,m,i[2]),r[7]);i[2]?.length&&(i[3]=Bn(i[2],void 0,void 0,h.then(e=>xn(e)?0:hn(n).length,()=>0))),o=await h}catch(t){if(zn(e,i),t===a&&a.aborted)return bn;throw t}return xn(o)?o:Un(e,o,a,r[6]===n.length?r[6]:0)}function Gn(e,t){if(e._tx!==t)return;let n=t[3],r=e.stores.matches.get(),i=e._pending;for(let a=0;a<n.length;a++){let o=n[a],s=o.status===`success`&&!o._notFound,c=r[a]?.id===o.id&&r[a]?.status===`pending`;if(s&&!c)continue;let l=Cn(e,o),u=s||o.invalid?0:l.options.pendingMs??e.options.defaultPendingMs,d=l.options.pendingComponent??e.options.defaultPendingComponent;if(!d||typeof u!=`number`||u===1/0){i&&(i[0]=t,i[2]=0,i[4]=!0);return}let f=l.options.pendingMinMs??e.options.defaultPendingMinMs??0,p=!1;if(i?.[1]===o.id?(p=i[0]!==t,i[0]=t):(clearTimeout(i?.[3]),e._pending=i=void 0),i||(e._pending=i=[t,o.id,c?Date.now()+f:t[4]+u,void 0,c||void 0,d]),i[4]&&!p&&i[5]===d)return;if(i[5]=d,!i[4]){clearTimeout(i[3]);let n=i[2]-Date.now();if(n>0){i[3]=setTimeout(()=>Gn(e,t),n);return}i[2]=0}let m=n.map(e=>({...e,_flight:void 0}));m[a].status=`pending`;let h=i[4]=e.startTransition(()=>e.stores.setMatches(m),m).then(t=>(t&&e._pending===i&&i[4]===h&&!i[2]&&(i[2]=Date.now()+f),t));return}}function Kn(e,t){let n=e._pending;e._tx!==t&&e._tx?.[3].some(e=>e.id===n?.[1])||(clearTimeout(n?.[3]),e._pending=void 0)}async function qn(e,t){let n=e._pending;if(!n)return;clearTimeout(n[3]);let r=n[2]-Date.now();if(!n[4]||r<=0||!hn(t[3]).some(e=>e.id===n[1]))return;let i;try{await Sn(new Promise(e=>{i=setTimeout(e,r)}),t[0].signal)}catch{}clearTimeout(i)}function Jn(e,t){e._committed=t,e.stores.setMatches(t)}function Yn(e,t,n,r){let i=e._committed,a=e._lifecycleEnd,o=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let s=hn(n).length,c=new Map;{let t=Date.now(),r=new Set;for(let e=0;e<n.length;e++){let t=n[e];(e<s||t.status===`success`)&&r.add(t.id)}for(let n of[...i,...o.values()]){if(n.status!==`success`||r.has(n.id))continue;let i=Cn(e,n);!i.options.loader||t-n.updatedAt>=(n.preload?i.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:i.options.gcTime??e.options.defaultGcTime??3e5)||c.set(n.id,o.get(n.id)===n?n:{...n,_flight:void 0,isFetching:!1,context:{}})}}t[3]=[],e._cache=c;let l=e._lifecycleEnd=Zt(n);Jn(e,n),D(e,[...o.values(),...i].filter(e=>e._flight&&c.get(e.id)!==e),n),Qt(e,i,n,a,l,t)}async function Xn(e,t){let n=e._tx;for(;n&&n!==t;)t=n,await n[5],n=e._tx}function Zn(e,t,n){let r=n[1].options,i=n[2];if(!i)return e.navigate({...r,replace:!0,ignoreBlocker:!0});if(r.reloadDocument)return e.navigate({href:(i.maskedLocation??i).publicHref,reloadDocument:!0,replace:!0,ignoreBlocker:!0});i._redirects=t[1]+1,e._pendingLocation=i;let a=e.commitLocation({...i,viewTransition:r.viewTransition,replace:!0,resetScroll:r.resetScroll,hashScrollIntoView:r.hashScrollIntoView,ignoreBlocker:!0});return queueMicrotask(()=>{e._pendingLocation===i&&(e._pendingLocation=void 0)}),a}async function Qn(e,t,n,r,i){let a=n.map(e=>({...e}));An(a);for(let t of r)kn(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await Hn(e,o,r,t[0],i)}catch(t){throw D(e,a),t}if(xn(s))D(e,a),s[0]===E&&e._tx===t&&e._committed===n&&await Zn(e,t,s);else if(await Un(e,s,t[0].signal),e._tx!==t||e._committed!==n)D(e,a);else{for(let t of a){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),kn(e,n))}Jn(e,a),D(e,n,a)}}async function $n(e,t,n,r,i,a){let o=await Wn(e,t[2],t[3],[t[0],t[1],e._committed,void 0,i,n,a,r]);if(xn(o)){let n=o[0]===E&&e._tx===t;if((!n||o[1].options.reloadDocument)&&Kn(e,t),D(e,t[3]),t[3]=[],!n)return;if(e._tx!==t){Kn(e,t);return}await Zn(e,t,o);return}let s=o[1];if(e._tx===t&&await qn(e,t),e._tx!==t){Kn(e,t),D(e,s),zn(e,o);return}let c=t[2],l=Yt(c,e.stores.resolvedLocation.get()),u=o[2];await e.startViewTransition(async()=>{if(e._tx===t&&await qn(e,t),e._tx!==t){Kn(e,t),D(e,s),zn(e,o);return}let n=await e.startTransition(()=>{Kn(e,t),Yn(e,t,s,a),e._tx===t&&(e.emit({type:`onLoad`,...l}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...l}))},s);e._tx===t?(u?.length&&Qn(e,t,s,u,o[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(c),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...l}),n&&e._tx===t&&e.emit({type:`onRendered`,...l})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)):zn(e,o)})}async function er(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),!u.signal.aborted){let t=Yt(a,r);e.emit({type:`onBeforeNavigate`,...t}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...t})}if(u.signal.aborted){await Xn(e,n);return}let f=i.href===a.href,p=u,m=e.matchRoutes(a,{_controller:u});An(m);let h=l?c[1](m):void 0;if(h?p=l:l?.abort(),u.signal.aborted){D(e,m),await Xn(e,n);return}e._preflight=void 0;let g,_=()=>$n(e,y,f,()=>Gn(e,y),t?.sync,h),v=t?.sync?new Promise(e=>g=e):Promise.resolve().then(_),y=[p,s,a,m,Date.now(),v.then(()=>Xn(e,y))];if(e._tx=y,n){for(let t of e.stores.matches.get()){if(e._tx!==y)break;t.isFetching&&jn(e,t,!1)}n[0].abort(),D(e,n[3],y[3],!0)}e._tx===y?(e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),(h||!e._committed.length&&m[0]?.status!==`success`&&!m.some(e=>e._notFound))&&Gn(e,y),g?.(_()),await y[5]):(D(e,y[3]),y[3]=[],g?.(),await Xn(e,y))}async function tr(e,t){let n=e.buildLocation(t);for(let t=0;;t++){let r=e._committed,i=new AbortController,a,o,s;try{try{a=e.matchRoutes(n,{_controller:i}),An(a),o=(e._preloads??=new Map).set(i,a),s=await Wn(e,n,a,[i,t,r,!0])}finally{o&&(o=o.delete(i),D(e,a)),i.abort()}if(!xn(s))return s[1];if(!o||s.length<3)return;n=s[2]}catch(e){Re(e)||console.error(e);return}}}var nr=`Error preloading route! ☝️`,rr=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e,this._branch=void 0;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=ot:this.parentRoute||De();let r=n?ot:t?.path;r&&r!==`/`&&(r=ke(r));let i=t?.id||r,a=n?ot:Oe((this.parentRoute.id===`__root__`?``:this.parentRoute.id)+`/`+(i??``));r===`__root__`&&(r=`/`);let o=a===`__root__`?`/`:r===void 0?this.parentRoute.fullPath:Oe(this.parentRoute.fullPath+`/`+r);this._path=r,this._id=a,this._fullPath=o,this._to=Ae(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>st({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},ir=class extends rr{constructor(e){super(e)}},O=e(r(),1),ar=O.createContext(null);function or(e){return O.useContext(ar)}function sr(e,t){let n=e.stores.location,r=new Set,i,a,o=n=>{gn(e,t,n)||(i=n,r.forEach(e=>e()))};return[()=>i??n.get(),e=>(r.size||(i=n.get(),a=n.subscribe(o).unsubscribe),r.add(e),()=>{r.delete(e),r.size||(a(),i=void 0)})]}var cr=O.createContext(void 0),lr=O.createContext(void 0);function ur({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0)n=e.nextSub;else{for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function dr(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var fr=[],pr=0,{link:mr,unlink:hr,propagate:gr,checkDirty:_r,shallowPropagate:vr}=ur({update(e){return e._update()},notify(e){fr[br++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,Cr(e))}}),yr=0,br=0,k,xr=0;function Sr(e){try{++xr,e()}finally{--xr||wr()}}function Cr(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=hr(n,e)}function wr(){if(!(xr>0)){for(;yr<br;){let e=fr[yr];fr[yr++]=void 0,e.notify()}yr=0,br=0}}function Tr(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return k!==void 0&&mr(i,k,pr),i._snapshot},subscribe(e){let t=dr(e),n={current:!1},r=Er(()=>{i.get(),n.current?(k=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=k,o=t?.compare??Object.is;if(n)k=i,++pr,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{k=a,n&&(i.flags&=-5),Cr(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&_r(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&vr(e)}}else e&32&&(i.flags=e&-33);return k!==void 0&&mr(i,k,pr),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(gr(e),vr(e),wr())}},i}function Er(e){let t=()=>{let t=k;k=n,++pr,n.depsTail=void 0,n.flags=6;try{return e()}finally{k=t,n.flags&=-5,Cr(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&_r(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,Cr(this)}};return t(),n}var Dr=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Or=t(((e,t)=>{t.exports=Dr()})),kr=t((e=>{var t=r(),n=Or();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ar=t(((e,t)=>{t.exports=kr()}))();function jr(e,t){return e===t}function Mr(e,t=e=>e,n){let r=n?.compare??jr,i=(0,O.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,O.useCallback)(()=>e.get(),[e]);return(0,Ar.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Nr={};function Pr(e,t){let n=O.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=me(n.current,i):i}}function Fr(e){let t=or(),n=O.useContext(e.from?lr:cr),r=e.from??n,i=t.stores.getMatchStore(r),a=Pr(e,t),o=Mr(i,e=>e?a(e):Nr);if(o!==Nr)return o;(e.shouldThrow??!0)&&De()}function Ir(e){return Fr({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Lr(e){let{select:t,...n}=e;return Fr({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Rr(e){return Fr({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function zr(e){return Fr({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function Br(e){let t=or();return O.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Vr(e){return Fr({...e,select:t=>e.select?e.select(t.context):t.context})}var Hr=n();function Ur(...e){let t=O.useRef(e),n=t.current;return e.forEach((e,t)=>{ge(n[t],e,!1,!0)||(n[t]=e)}),t.current}function Wr(e,t){e.preloadRoute(t).catch(e=>{console.warn(e),console.warn(nr)})}function Gr(e,t){let n=typeof e==`string`&&xe(e);if(n)return t.has(n)?e:null}function Kr(e,t,n,r){let i=Me(e.pathname,r),a=Me(t.pathname,r);return(n?.exact?i!==a:!i.startsWith(a)||i.length!==a.length&&i[a.length]!==`/`)||(n?.includeSearch??!0)&&!ge(e.search,t.search,!n?.exact,n?.explicitUndefined)?!1:!n?.includeHash||e.hash===t.hash}function qr(e,t,n){let r=or(),i=O.useRef(null),a=O.useCallback(e=>{if(i.current=e,typeof t==`function`)return t(e);t&&(t.current=e)},[t]),{activeOptions:o,to:s,preload:c,preloadDelay:l,disabled:u,target:d,onClick:f,onBlur:p,onFocus:m,onMouseEnter:h,onMouseLeave:g,onTouchStart:_}=e,[v,y,b]=Ur(e.search,e.params,o),x=O.useContext(cr),S=(r.stores._linkScopes??={})[x]??=sr(r,x),[C,w,ee]=O.useMemo(()=>{let t=Gr(s,r.protocolAllowlist);if(t!==void 0){let n=[t??void 0];return[e,()=>n]}let n={...e},i,a,o,c=()=>{let e=S[0]();if(e!==i){n._fromLocation=e;let t=r.buildLocation(n),o=ti(t,r,u),s=u||o&&!xe(o)?Kr(e,t,b,r.basepath):void 0;a&&a[0]===o&&a[1]===s||(a=[o,s]),i=e}return a};return[n,c,b?.includeHash&&(()=>{let e=c();return e[1]?o??=[e[0],!1]:e})]},[r,S,e.from,e.hash,e.href,s,v,y,e.state,e.mask,e.unsafeRelative,b,u]),[te,ne]=O.useSyncExternalStore(S[1],w,ee||w),re=ne===void 0&&te,ie=u||te===void 0,ae=O.useRef(!1),oe=e.reloadDocument||re||ie?!1:c??r.options.defaultPreload,se=l??r.options.defaultPreloadDelay??0,ce=O.useCallback(e=>{let t=e?.isIntersecting;t??oe===`intent`?se?i.t??=setTimeout(()=>{i.t=void 0,Wr(r,C)},se):Wr(r,C):t===!1&&$r(i)},[r,C,i,oe,se]);O.useEffect(()=>{if(!oe)return;oe===`render`&&!ae.current&&(ae.current=!0,Wr(r,C));let e=!0,t;return oe===`viewport`&&i.current&&typeof IntersectionObserver==`function`&&(t=new IntersectionObserver(t=>{e&&ce(t.pop())},{rootMargin:`100px`}),t.observe(i.current)),()=>{e=!1,t?.disconnect(),$r(i)}},[r,C,oe,ce,i]);let T=Zr(e,n);if(T.ref=t?a:i,re)return T.href=re,T;let le=t=>{let n=d??t.currentTarget.getAttribute(`target`);ie||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||n&&n!==`_self`||t.button!==0||(t.preventDefault(),$r(i),r.navigate({...e,_fromLocation:C._fromLocation}))},ue=()=>{oe===`intent`&&Wr(r,C)},de=()=>{oe===`intent`&&$r(i)};return T.onClick=ei(f,le),T.onBlur=ei(p,de),T.onFocus=ei(m,ce),T.onMouseEnter=ei(h,ce),T.onMouseLeave=ei(g,de),T.onTouchStart=ei(_,ue),Qr(T,e,ne,te,ie,n)}var Jr={},Yr={className:`active`},Xr=new Set([`to`,`params`,`search`,`hash`,`state`,`mask`,`from`,`unsafeRelative`,`reloadDocument`,`preload`,`preloadDelay`,`preloadIntentProximity`,`hashScrollIntoView`,`replace`,`startTransition`,`resetScroll`,`viewTransition`,`ignoreBlocker`,`activeProps`,`inactiveProps`,`activeOptions`,`_asChild`]);function Zr(e,t){let n={};for(let r in e)Xr.has(r)||r===`type`&&t!==void 0||r===`disabled`&&t===`a`||(n[r]=e[r]);return n}function Qr(e,t,n,r,i,a){let{activeProps:o,inactiveProps:s,className:c,style:l,target:u}=t,d=le(n?o:s,{})??(n?Yr:Jr);Object.assign(e,d),e.href=r,a!==`a`&&(e.disabled=i),e.target=u;let f=d.style;(l||f)&&(e.style=l&&f?{...l,...f}:l||f);let p=d.className;return(c||p)&&(e.className=c?p?`${c} ${p}`:c:p),i&&(e.role=`link`,e[`aria-disabled`]=!0),n&&(e[`data-status`]=`active`,e[`aria-current`]=`page`),e}var $r=e=>{clearTimeout(e.t),e.t=void 0},ei=(e,t)=>e?n=>n.defaultPrevented||(e(n),n.defaultPrevented||t(n)):t;function ti(e,t,n){if(n)return;let r=e.maskedLocation??e,i=r.external?r.publicHref:t.history.createHref(r.publicHref)||`/`;if(!r.external&&i===r.publicHref||!Ce(i,t.protocolAllowlist))return i}var ni=O.memo(O.forwardRef((e,t)=>{let n=e._asChild||`a`,r=qr(e,t,n),i=typeof e.children==`function`?e.children({isActive:r[`data-status`]===`active`}):e.children;return O.createElement(n,r,i)}),ri);function ri(e,t){let n=0;for(let r in t)if(n++,e[r]!==t[r]&&(!Xr.has(r)||!ge(e[r],t[r],!1,!0)))return!1;for(let t in e)n--;return n===0}var ii=class extends rr{constructor(e){super(e),this.useMatch=e=>Fr({...e,from:this.id}),this.useRouteContext=e=>Vr({...e,from:this.id}),this.useSearch=e=>zr({...e,from:this.id}),this.useParams=e=>Rr({...e,from:this.id}),this.useLoaderDeps=e=>Lr({...e,from:this.id}),this.useLoaderData=e=>Ir({...e,from:this.id}),this.useNavigate=()=>Br({from:this.fullPath}),this.Link=O.forwardRef((e,t)=>(0,Hr.jsx)(ni,{ref:t,from:this.fullPath,...e}))}};function ai(e){return new ii(e)}var oi=class extends ir{constructor(e){super(e),this.useMatch=e=>Fr({...e,from:this.id}),this.useRouteContext=e=>Vr({...e,from:this.id}),this.useSearch=e=>zr({...e,from:this.id}),this.useParams=e=>Rr({...e,from:this.id}),this.useLoaderDeps=e=>Lr({...e,from:this.id}),this.useLoaderData=e=>Ir({...e,from:this.id}),this.useNavigate=()=>Br({from:this.fullPath}),this.Link=O.forwardRef((e,t)=>(0,Hr.jsx)(ni,{ref:t,from:this.fullPath,...e}))}};function si(e){return new oi(e)}var ci=e=>({createMutableStore:Tr,createReadonlyStore:Tr,batch:Sr}),li=e=>new ui(e),ui=class extends $t{constructor(e){super(e,ci)}},di=`global`;function fi(e,t,n){let r=new Uint8Array(5+n.length);return r[0]=e,new DataView(r.buffer).setUint32(1,t),r.set(n,5),r}function pi(e){if(e.length<5)throw Error(`terminal frame is too short`);return{kind:e[0],id:new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(1),data:e.subarray(5)}}var A={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},mi={silent:{level:-1},fatal:{level:A.fatal},error:{level:A.error},warn:{level:A.warn},log:{level:A.log},info:{level:A.info},success:{level:A.success},fail:{level:A.fail},ready:{level:A.info},start:{level:A.info},box:{level:A.info},debug:{level:A.debug},trace:{level:A.trace},verbose:{level:A.verbose}};function hi(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function gi(e,t,n=`.`,r){if(!hi(t))return gi(e,{},n,r);let i=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:hi(a)&&hi(i[t])?gi(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function _i(e){return(...t)=>t.reduce((t,n)=>gi(t,n,``,e),{})}var vi=_i();function yi(e){return Object.prototype.toString.call(e)===`[object Object]`}function bi(e){return!(!yi(e)||!e.message&&!e.args||e.stack)}var xi=!1,Si=[],j=class e{options;_lastLog;_mockFn;constructor(e={}){let t=e.types||mi;this.options=vi({...e,defaults:{...e.defaults},level:Ci(e.level,t),reporters:[...e.reporters||[]]},{types:mi,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let e in t){let n={type:e,...this.options.defaults,...t[e]};this[e]=this._wrapLogFn(n),this[e].raw=this._wrapLogFn(n,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=Ci(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error(`prompt is not supported!`);return this.options.prompt(e,t)}create(t){let n=new e({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+`:`+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(t!==-1)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console[`__`+e]||(console[`__`+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console[`__`+e]&&(console[e]=console[`__`+e],delete console[`__`+e])}wrapStd(){this._wrapStream(this.options.stdout,`log`),this._wrapStream(this.options.stderr,`log`)}_wrapStream(e,t){e&&(e.__write||=e.write,e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){xi=!0}resumeLogs(){xi=!1;let e=Si.splice(0);for(let t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,typeof t==`function`)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>{if(xi)Si.push([this,e,n,t]);else return this._logFn(e,n,t)}}_logFn(e,t,n){if((e.level||0)>this.level)return!1;let r={date:new Date,args:[],...e,level:Ci(e.level,this.options.types)};!n&&t.length===1&&bi(t[0])?Object.assign(r,t[0]):r.args=[...t],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
3
+ `)),r.args.push(`
4
+ `+r.additional.join(`
5
+ `)),delete r.additional),r.type=typeof r.type==`string`?r.type.toLowerCase():`log`,r.tag=typeof r.tag==`string`?r.tag:``;let i=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);let a=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,a<this.options.throttle)try{let e=JSON.stringify([r.type,r.tag,r.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}};function Ci(e,t={},n=3){return e===void 0?n:typeof e==`number`?e:t[e]&&t[e].level!==void 0?t[e].level:n}j.prototype.add=j.prototype.addReporter,j.prototype.remove=j.prototype.removeReporter,j.prototype.clear=j.prototype.removeReporter,j.prototype.withScope=j.prototype.withTag,j.prototype.mock=j.prototype.mockTypes,j.prototype.pause=j.prototype.pauseLogs,j.prototype.resume=j.prototype.resumeLogs;function wi(e={}){return new j(e)}var Ti=class{options;defaultColor;levelColorMap;typeColorMap;constructor(e){this.options={...e},this.defaultColor=`#7f8c8d`,this.levelColorMap={0:`#c0392b`,1:`#f39c12`,3:`#00BCD4`},this.typeColorMap={success:`#2ecc71`}}_getLogFn(e){return e<1?console.__error||console.error:e===1?console.__warn||console.warn:console.__log||console.log}log(e){let t=this._getLogFn(e.level),n=e.type===`log`?``:e.type,r=e.tag||``,i=`
6
+ background: ${this.typeColorMap[e.type]||this.levelColorMap[e.level]||this.defaultColor};
7
+ border-radius: 0.5em;
8
+ color: white;
9
+ font-weight: bold;
10
+ padding: 2px 0.5em;
11
+ `,a=`%c${[r,n].filter(Boolean).join(`:`)}`;typeof e.args[0]==`string`?t(`${a}%c ${e.args[0]}`,i,``,...e.args.slice(1)):t(a,i,...e.args)}};function Ei(e={}){return wi({reporters:e.reporters||[new Ti({})],prompt(e,t={}){return t.type===`confirm`?Promise.resolve(confirm(e)):Promise.resolve(prompt(e))},...e})}Ei();function Di(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Oi(e,t){let n,r=()=>{if(n)return n;let r=indexedDB.open(e);return r.onupgradeneeded=()=>r.result.createObjectStore(t),n=Di(r),n.then(e=>{e.onclose=()=>n=void 0},()=>{n=void 0}),n};return(e,n)=>r().then(r=>n(r.transaction(t,e).objectStore(t)))}var ki;function Ai(){return ki||=Oi(`keyval-store`,`keyval`),ki}function ji(e,t=Ai()){return t(`readonly`,t=>Di(t.get(e)))}function Mi(e,t,n=Ai()){return n(`readwrite`,n=>(n.put(t,e),Di(n.transaction)))}function Ni(e,t=Ai()){return t(`readwrite`,t=>(t.delete(e),Di(t.transaction)))}var Pi=Oi(`offsite`,`tokens`);function Fi(e){return ji(e,Pi)}function Ii(e,t){return Mi(e,t,Pi)}function Li(e){return Ni(e,Pi)}var Ri=1e3,zi=5e3,Bi=1e3,Vi=[],Hi,Ui=Ei({level:A.verbose,throttle:0});Ui.addReporter({log:Ki});var Wi=Ui.withTag(`app`);function Gi(){window.addEventListener(`error`,e=>Wi.error(`uncaught error:`,e.error??e.message)),window.addEventListener(`unhandledrejection`,e=>Wi.error(`unhandled rejection:`,e.reason)),Wi.info(`started on ${location.origin} in ${navigator.userAgent}`)}function Ki(e){Vi.push({time:e.date.getTime(),type:e.type,tag:e.tag,message:e.args.map(Xi).join(` `)}),Vi.length>Bi&&Vi.splice(0,Vi.length-Bi),qi(Ri)}function qi(e){Hi??=window.setTimeout(()=>void Ji(),e)}async function Ji(){let e=Vi.splice(0),t;try{let n=JSON.parse(localStorage.getItem(`machines`)??`[]`).find(e=>e.addresses.includes(location.origin)),r=n===void 0?void 0:await Fi(n.id);t=await fetch(`/api/logs`,{method:`POST`,headers:r===void 0?{}:{authorization:`Bearer ${r}`},body:JSON.stringify(e)})}catch{Yi(e);return}t.status>=500?Yi(e):(Hi=void 0,t.ok||console.warn(`the server refused ${e.length} log entries: ${await t.text()}`),Vi.length>0&&qi(Ri))}function Yi(e){Vi.unshift(...e),Vi.length>Bi&&Vi.splice(0,Vi.length-Bi),Hi=void 0,qi(zi)}function Xi(e){if(typeof e==`string`)return e;if(e instanceof Error)return e.stack!==void 0&&e.stack.startsWith(String(e))?e.stack:[String(e),e.stack].join(`
12
+ `);try{return JSON.stringify(e)??String(e)}catch{return String(e)}}var Zi=1e3,Qi=3e4,$i=1e4,ea=1e4,ta=3e3,na=3e4,ra=3e5,ia=[`sessions.send`,`sessions.rewind`,`sessions.fork`,`git.commit`,`git.push`,`git.pullRequest`,`git.createPullRequest`],aa=Ui.withTag(`connection`),oa=new Set,M=new Map,sa=0;function ca(){window.setInterval(()=>{for(let e of M.keys())ga(e)},$i),document.addEventListener(`visibilitychange`,()=>{document.hidden||la()}),window.addEventListener(`online`,la)}function la(){for(let[e,t]of M)t.connected?ga(e):t.timer!==void 0&&(window.clearTimeout(t.timer),t.timer=void 0,t.failures=0,_a(e,t,0))}function ua(e,t){if(M.has(e))return;let n={urls:t,url:t[0],socket:null,connected:!1,ping:null,timer:void 0,failures:0,pending:new Map};M.set(e,n),_a(e,n,0)}function da(e){let t=M.get(e);t!==void 0&&(M.delete(e),window.clearTimeout(t.timer),t.socket!==null&&(t.socket.onclose=null,t.socket.close()),xa(e,t))}function fa(e){oa.add(e)}function pa(e){return M.get(e)?.connected===!0}function ma(e){let t=M.get(e);if(t===void 0)throw Error(`This machine is not connected`);return t.url}function N(e,t,n){let r=M.get(e);if(r===void 0||r.socket===null||!r.connected)return Promise.reject(Error(r===void 0?`That machine was removed`:`Not connected to ${new URL(r.url).host}; reconnecting`));sa+=1;let i=sa;r.socket.send(JSON.stringify({id:i,method:t,params:n}));let a=ia.includes(t)?ra:na;return new Promise((e,n)=>{let o=window.setTimeout(()=>{r.pending.delete(i),n(Error(`${new URL(r.url).host} did not answer ${t} within ${a/1e3} seconds`))},a);r.pending.set(i,{resolve:t=>{window.clearTimeout(o),e(t)},reject:e=>{window.clearTimeout(o),n(e)}})})}function ha(e,t,n,r){let i=M.get(e);i!==void 0&&i.socket!==null&&i.connected&&i.socket.send(fi(t,n,r))}async function ga(e){let t=M.get(e);return t!==void 0&&(t.ping??=Sa(e,t).finally(()=>{t.ping=null}),await t.ping)}async function _a(e,t,n){let r=t.urls[n%t.urls.length];t.url=r,aa.debug(`connecting to ${r}, attempt ${n+1}`);let i=await va(e,r).catch(e=>{aa.warn(`could not get a ticket from ${r}:`,e)});if(M.get(e)!==t)return;if(i===`unpaired`){aa.warn(`${r} says this browser is not paired`);for(let t of oa)t.unpaired?.(e);return}if(i===void 0){ya(e,t,n);return}let a=i===null?``:`?${new URLSearchParams({ticket:i})}`,o=new WebSocket(`${r.replace(/^http/,`ws`)}/ws${a}`);o.binaryType=`arraybuffer`;let s=window.setTimeout(()=>o.close(),ta);o.onopen=()=>{if(window.clearTimeout(s),t.socket!==o)o.close();else{t.connected=!0,t.failures=0,aa.info(`connected to ${r}`);for(let t of oa)t.open?.(e,r)}},o.onmessage=n=>{t.socket===o&&Ca(e,t,n.data)},o.onclose=i=>{window.clearTimeout(s),t.socket===o&&(aa.info(`the connection to ${r} closed (code ${i.code})`),t.connected?(xa(e,t),ba(e,t,0)):ya(e,t,n))},t.socket=o}async function va(e,t){let n=await Fi(e),r=await fetch(`${t}/api/ticket`,{method:`POST`,headers:n===void 0?{}:{authorization:`Bearer ${n}`},signal:AbortSignal.timeout(ta)});if(r.status===401)return`unpaired`;if(!r.ok)throw Error(await r.text());return(await r.json()).ticket}function ya(e,t,n){if((n+1)%t.urls.length!==0)_a(e,t,n+1);else{for(let t of oa)t.close?.(e);ba(e,t,n+1)}}function ba(e,t,n){let r=Math.min(Qi,Zi*2**t.failures)*(.8+Math.random()*.4);t.failures+=1,aa.debug(`reconnecting to ${new URL(t.url).host} in ${Math.round(r/1e3)}s`),t.timer=window.setTimeout(()=>{t.timer=void 0,_a(e,t,n)},r)}function xa(e,t){for(let e of t.pending.values())e.reject(Error(`Disconnected from ${new URL(t.url).host}`));t.pending.clear(),t.connected=!1;for(let t of oa)t.close?.(e)}async function Sa(e,t){let n=t.socket;if(n===null||!t.connected)return!1;let r=await Promise.race([N(e,`ping`,void 0).then(()=>!0,()=>!1),new Promise(e=>window.setTimeout(()=>e(!1),ea))]);return r||t.socket!==n||!t.connected?r:(aa.warn(`${t.url} did not answer a ping, reconnecting`),n.onclose=null,n.close(),xa(e,t),M.get(e)===t&&ba(e,t,0),!1)}function Ca(e,t,n){if(n instanceof ArrayBuffer){let t=pi(new Uint8Array(n));for(let n of oa)n.frame?.(e,t);return}let r=JSON.parse(String(n));if(r.type===`reply`)wa(t,r);else if(r.type===`terminal`)for(let t of oa)t.terminal?.(e,r.event);else for(let t of oa)t.event?.(e,r)}function wa(e,t){let n=e.pending.get(t.id);n!==void 0&&(e.pending.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve(t.result))}function Ta(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function Ea(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function Da(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Oa(e,t,n){return ka(e,t,void 0,void 0,void 0,void 0,n)}function ka(e,t,n,r,i,a,o){let s=o(e,t,n,r,i,a);if(s!==void 0)return s;if(typeof e==typeof t)switch(typeof e){case`bigint`:case`string`:case`boolean`:case`symbol`:case`undefined`:return e===t;case`number`:return e===t||Object.is(e,t);case`function`:return e===t;case`object`:return Aa(e,t,a,o)}return Aa(e,t,a,o)}function Aa(e,t,n,r){if(Object.is(e,t))return!0;let i=s(e),a=s(t);if(i===`[object Arguments]`&&(i=ae),a===`[object Arguments]`&&(a=ae),i!==a)return!1;switch(i){case se:return e.toString()===t.toString();case f:return Da(e.valueOf(),t.valueOf());case ee:case h:case u:return Object.is(e.valueOf(),t.valueOf());case ce:return e.source===t.source&&e.flags===t.flags;case _:return e===t}n??=new Map;let T=n.get(e),le=n.get(t);if(T!=null&&le!=null)return T===t;n.set(e,t),n.set(t,e);try{switch(i){case v:if(e.size!==t.size)return!1;for(let[i,a]of e.entries())if(!t.has(i)||!ka(a,t.get(i),i,e,t,n,r))return!1;return!0;case m:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),a=Array.from(t.values());for(let o=0;o<i.length;o++){let s=i[o],c=a.findIndex(i=>ka(s,i,void 0,e,t,n,r));if(c===-1)return!1;a.splice(c,1)}return!0}case ne:case d:case c:case o:case oe:case p:case y:case te:case C:case b:case ie:case g:if(x(e)!==x(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!ka(e[i],t[i],i,e,t,n,r))return!1;return!0;case w:return e.byteLength===t.byteLength&&Aa(new Uint8Array(e),new Uint8Array(t),n,r);case re:return e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset?!1:Aa(new Uint8Array(e),new Uint8Array(t),n,r);case S:return e.name===t.name&&e.message===t.message;case ae:{if(!(Aa(e.constructor,t.constructor,n,r)||Ea(e)&&Ea(t)))return!1;let i=[...Object.keys(e),...l(e)],a=[...Object.keys(t),...l(t)];if(i.length!==a.length)return!1;for(let a=0;a<i.length;a++){let o=i[a],s=e[o];if(!Object.hasOwn(t,o))return!1;let c=t[o];if(!ka(s,c,o,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function ja(e,t){return Oa(e,t,a)}var Ma=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Na=(e=>e?Ma(e):Ma),Pa=e=>e;function Fa(e,t=Pa){let n=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return O.useDebugValue(n),n}var Ia=e=>{let t=Na(e),n=e=>Fa(t,e);return Object.assign(n,t),n},La=(e=>e?Ia(e):Ia);function Ra(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var za=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return za(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return za(t)(e)}}}},Ba=(e,t)=>(n,r,i)=>{let a={storage:Ra(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(...e)=>(f(...e),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return za(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},Va=`composerDrafts`,Ha={text:``,images:[],files:[],settings:null},Ua=Oi(`offsite-drafts`,`drafts`),Wa=Oi(`offsite-draft-files`,`files`),Ga=Ta(e=>void Mi(Va,e,Ua),300),Ka={getItem:async e=>await ji(e,Ua)??null,setItem:(e,t)=>Ga(t),removeItem:e=>Ni(e,Ua)},qa={drafts:{},stash:[]},P=La()(Ba(()=>qa,{name:Va,storage:Ka,skipHydration:!0,version:1,migrate:()=>qa}));window.addEventListener(`pagehide`,Ga.flush);function Ja(){return P.persist.rehydrate()}function Ya(e){return P(t=>t.drafts[e]??Ha)}function Xa(e,t){let n=eo(e),r=t(n),i=P.getState().stash;for(let e of n.files)!r.files.some(t=>t.id===e.id)&&!i.some(t=>t.files.some(t=>t.id===e.id))&&Ni(e.id,Wa);P.setState(t=>{let n={...t.drafts,[e]:r};return r.text===``&&r.images.length===0&&r.files.length===0&&r.settings===null&&delete n[e],{drafts:n}})}async function Za(e){let t=crypto.randomUUID();return await Mi(t,e,Wa),t}async function Qa(e){return await ji(e,Wa)}function $a(e){Xa(e,()=>Ha)}function eo(e){return P.getState().drafts[e]??Ha}function to(e){return P.getState().drafts[e]?.settings??null}function no(e,t){Xa(e,e=>({...e,settings:t}))}function ro(){return P(e=>e.stash)}function io(){return P.getState().stash}function ao(e){return e.text.trim()!==``||e.images.length>0||e.files.length>0}function oo(e){let t=eo(e);P.setState(e=>({stash:[{id:crypto.randomUUID(),createdAt:Date.now(),text:t.text,images:t.images,files:t.files},...e.stash]})),Xa(e,e=>({...e,text:``,images:[],files:[]}))}function so(e,t,n){let r=P.getState().stash.find(e=>e.id===t);if(r===void 0)throw Error(`This stashed prompt no longer exists`);ao(eo(e))&&oo(e),P.setState(e=>({stash:e.stash.filter(e=>e.id!==t)}));let i=r.text.replace(/\[Image #(\d+)\]/g,(e,t)=>{let i=r.images.findIndex(e=>e.number===Number(t));return i===-1?e:`[Image #${n+i+1}]`});return Xa(e,e=>({...e,text:i,images:r.images.map((e,t)=>({...e,number:n+t+1})),files:r.files})),i}function co(e){let t=P.getState().stash.find(t=>t.id===e);if(t!==void 0){P.setState(t=>({stash:t.stash.filter(t=>t.id!==e)}));for(let e of t.files)Ni(e.id,Wa)}}function lo(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function uo(e,t=`|`){return e.map(e=>Fo(e)).join(t)}function fo(e,t){return typeof t==`bigint`?t.toString():t}var po=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function mo(e){return new po(e)}function ho(e){return e==null}function go(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function _o(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function vo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function yo(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function bo(e){return yo(e._zod.def)??e._zod.def.shape}function xo(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return vo(this,t,e),e},enumerable:!0,configurable:!0})}function So(e,t,n){t in e?vo(e,t,n):e[t]=n}function Co(e,t,n,r){let i=bo(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?xo(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):So(e,a,r?r(n.value,a):n.value))}}function wo(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?xo(e,n,()=>t[n]):So(e,n,r.value))}}function F(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function To(e){return JSON.stringify(e)}function Eo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Do=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Oo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ko=mo(()=>{if(ws.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ao(e){if(Oo(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Oo(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function jo(e){return Ao(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Mo=new Set([`string`,`number`,`symbol`]);function No(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Po(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function I(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Fo(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Io(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Lo={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ro={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function zo(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Co(i,e,Bo(e,t)),Po(e,F(n,{shape:i,checks:[]}))}function Bo(e,t){let n=bo(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Vo(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Bo(e,t)),a={};return Co(a,e,Reflect.ownKeys(bo(e)).filter(e=>!i.has(e))),Po(e,F(n,{shape:a,checks:[]}))}function Ho(e,t){if(!Ao(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=bo(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Po(e,F(e._zod.def,{shape:Uo(e,t)}))}function Uo(e,t){let n={};return Co(n,e,Reflect.ownKeys(bo(e))),wo(n,t),n}function Wo(e,t){if(!Ao(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Po(e,F(e._zod.def,{shape:Uo(e,t)}))}function Go(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Co(n,e,Reflect.ownKeys(bo(e))),Co(n,t,Reflect.ownKeys(bo(t))),Po(e,F(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ko(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Bo(t,n)):void 0,o={};return Co(o,t,Reflect.ownKeys(bo(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Po(t,F(t._zod.def,{shape:o,checks:[]}))}function qo(e,t,n){let r=n?new Set(Bo(t,n)):void 0,i={};return Co(i,t,Reflect.ownKeys(bo(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Po(t,F(t._zod.def,{shape:i}))}function Jo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Yo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Xo(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Zo(e){return typeof e==`string`?e:e?.message}function Qo(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function $o(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function es(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Zo(e.inst?._zod.def?.error?.(e))??Zo(a?.(e))??Zo(t?.error?.(e))??Zo(n.customError?.(e))??Zo(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var ts=/[\uD800-\uDBFF]/;function ns(e){let t=e.length;if(!ts.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function rs(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function is(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function as(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function os(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):us(e,n,r.value)}}function ss(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function cs(e,t,n){return ss(e,t,n,!1)}function ls(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return ss(this,n,r(this))},set(e){ss(this,n,e)}})}return t}function us(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ss(this,t,n.bind(this))},set(e){ss(this,t,e)}})}function ds(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var fs,ps=!1,ms={configurable:!0,get(){ps=!0}};function L(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&fs!==e._zod?fs=void 0:(fs=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ms);let e=ps;ps=!1;try{let r=n(this);return ps?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),ps||=e,r}catch(n){throw delete this[t],ps||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function hs(e,t,n,r){let i=ds(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var gs=`~constantCatch`;function _s(e){let t=()=>e;return t[gs]=!0,t}var vs,ys={value:void 0,enumerable:!1},bs=`captureStackTrace`in Error?Error:null;function xs(e){let t=bs;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return bs=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function R(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){ys.value=new a(r);try{Object.defineProperty(n,"_zod",ys)}finally{ys.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),os(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?xs(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ss=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Cs=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(vs=globalThis).__zod_globalConfig??(vs.__zod_globalConfig={});var ws=globalThis.__zod_globalConfig;function Ts(e){return e&&Object.assign(ws,e),ws}function Es(){let e=this._zod;return e.message??=JSON.stringify(e.def,fo,2),e.message}function Ds(e){this._zod.message=e}var Os={get:Es,set:Ds,enumerable:!0,configurable:!0},ks={value:void 0,enumerable:!1},As=new WeakSet([Object.prototype,Error.prototype]),js=R(`$ZodError`,(e,t)=>{e.name=`$ZodError`,ks.value=t,Object.defineProperty(e,"issues",ks),ks.value=void 0,Object.defineProperty(e,"message",Os);let n=Object.getPrototypeOf(e);As.has(n)||(As.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Ms(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Ns(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Ms(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ps(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Fs(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Is(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Fs(e.path)}`);return t.join(`
13
+ `)}function Ls(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Rs=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ss;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>es(e,o,Ts())));throw Do(n,a?.callee??t),n}return s.value};return t},zs=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>es(e,o,Ts())));throw Do(n,a?.callee??t),n}return s.value};return t},Bs=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ss;return a.issues.length?Vs(e,a.issues,i):{success:!0,data:a.value}};function Vs(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>es(e,n,Ts()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Hs=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Vs(e,a.issues,i):{success:!0,data:a.value}},Us=Symbol.for(`zod.compile.invalid`),Ws=Symbol.for(`zod.compile.fallback`),Gs=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Us)return!0;if(r.definite===!0&&n===void 0)return!1}return Ks(e,t,n)});function Ks(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Ws]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ss;return a.issues.length===0}var qs=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Js=e=>{let t=Rs(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ls(n,a))};return n},Ys=e=>{let t=Rs(e),n=(e,r,i,a)=>t(e,r,i,Ls(n,a));return n},Xs=e=>{let t=zs(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ls(n,a))};return n},Zs=e=>{let t=zs(e),n=async(e,r,i,a)=>await t(e,r,i,Ls(n,a));return n},Qs=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Bs(e)(t,n,i)},$s=e=>(t,n,r)=>Bs(e)(t,n,r),ec=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Hs(e)(t,n,i)},tc=e=>async(t,n,r)=>Hs(e)(t,n,r),nc=/^[cC][0-9a-z]{6,}$/,rc=/^[0-9a-z]+$/,ic=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ac=/^[0-9a-vA-V]{20}$/,oc=/^[A-Za-z0-9]{27}$/,sc=/^[a-zA-Z0-9_-]{21}$/;function cc(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var lc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,uc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dc=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,fc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pc=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function mc(){return new RegExp(pc,`u`)}var hc=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,gc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_c=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,vc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,xc=/^https?$/,Sc=/^\+[1-9]\d{6,14}$/,Cc=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function wc(e){return RegExp(`^${e}$`)}var Tc=wc(Cc);function Ec(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Dc(e){return RegExp(`^${Ec(e)}$`)}function Oc(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Ec({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Ec({precision:e.precision})}`:n;return RegExp(`^${Cc}T(?:${r})$`)}var kc=/^[\s\S]{0,}$/,Ac=/^-?\d+(?:\.\d+)?$/,jc=/^(?:true|false)$/i,Mc=/^[^A-Z]*$/,Nc=/^[^a-z]*$/,z=R(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Pc=e=>{let t=e.value;return!ho(t)&&t.length!==void 0},Fc={number:`number`,bigint:`bigint`,object:`date`},Ic=R(`$ZodCheckLessThan`,(e,t)=>{z.init(e,t);let n=Fc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Fc[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Lc=R(`$ZodCheckGreaterThan`,(e,t)=>{z.init(e,t);let n=Fc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Fc[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Rc=R(`$ZodCheckMultipleOf`,(e,t)=>{z.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):_o(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),zc=R(`$ZodCheckNumberFormat`,(e,t)=>{z.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Lo[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Bc=R(`$ZodCheckMaxLength`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=Pc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?ns(r):i)<=t.maximum)return;let a=rs(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vc=R(`$ZodCheckMinLength`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=Pc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?ns(r):i)>=t.minimum)return;let a=rs(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Hc=R(`$ZodCheckLengthEquals`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=Pc),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?ns(r):i;if(a===t.length)return;let o=rs(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Uc=R(`$ZodCheckStringFormat`,(e,t)=>{var n,r;z.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Wc=R(`$ZodCheckRegex`,(e,t)=>{Uc.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gc=R(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Mc,Uc.init(e,t)}),Kc=R(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Nc,Uc.init(e,t)}),qc=R(`$ZodCheckIncludes`,(e,t)=>{z.init(e,t);let n=No(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Jc=R(`$ZodCheckStartsWith`,(e,t)=>{z.init(e,t);let n=RegExp(`^${No(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Yc=R(`$ZodCheckEndsWith`,(e,t)=>{z.init(e,t);let n=RegExp(`.*${No(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Xc=R(`$ZodCheckOverwrite`,(e,t)=>{z.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Zc=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
14
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
15
+ `)}\n};`)(...Object.values(this.closed))}},Qc={major:4,minor:6,patch:7},B=R(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qc;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Jo(t),a;for(let o of n){if(o._zod.def.when){if(Yo(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Ss;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&($o(t.issues,n,e),i||=Jo(t,n))});else{if(t.issues.length===n)continue;$o(t.issues,n,e),i||=Jo(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Jo(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ss;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Ss;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return cs(this,`~standard`,tl(this))},set"~standard"(e){ss(this,`~standard`,e)}}),$c=(e,t)=>e.issues.length?{issues:e.issues.map(e=>es(e,t,Ts()))}:{value:e.value};async function el(e,t){let n={async:!0};return $c(await e._zod.run({value:t,issues:[]},n),n)}function tl(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return $c(r,n)}catch{}return el(e,t)},vendor:`zod`,version:1}}var nl=R(`$ZodString`,(e,t)=>{B.init(e,t),e._zod.pattern=t.pattern??kc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),V=R(`$ZodStringFormat`,(e,t)=>{Uc.init(e,t),nl.init(e,t)}),rl=R(`$ZodGUID`,(e,t)=>{t.pattern??=uc,V.init(e,t)}),il=R(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=dc(e)}else t.pattern??=dc();V.init(e,t)}),al=R(`$ZodEmail`,(e,t)=>{t.pattern??=fc,V.init(e,t)});function ol(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function sl(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?ol(e)||2:cl(e,t)}function cl(e,t){if(!t.normalize&&t.protocol?.source===xc.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var ll=/[\t\n\r]/g;function ul(e){return e.replace(ll,``)}function dl(e,t){return t.lastIndex=0,t.test(e.hostname)}function fl(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var pl=R(`$ZodURL`,(e,t)=>{V.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=sl(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=ul(r);return}t.hostname&&!dl(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!fl(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:ul(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ml=R(`$ZodEmoji`,(e,t)=>{t.pattern??=mc(),V.init(e,t)}),hl=R(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?sc:cc(t.length),V.init(e,t)}),gl=R(`$ZodCUID`,(e,t)=>{t.pattern??=nc,V.init(e,t)}),_l=R(`$ZodCUID2`,(e,t)=>{t.pattern??=rc,V.init(e,t)}),vl=R(`$ZodULID`,(e,t)=>{t.pattern??=ic,V.init(e,t)}),yl=R(`$ZodXID`,(e,t)=>{t.pattern??=ac,V.init(e,t)}),bl=R(`$ZodKSUID`,(e,t)=>{t.pattern??=oc,V.init(e,t)}),xl=R(`$ZodISODateTime`,(e,t)=>{t.pattern??=Oc(t),V.init(e,t)}),Sl=R(`$ZodISODate`,(e,t)=>{t.pattern??=Tc,V.init(e,t)}),Cl=R(`$ZodISOTime`,(e,t)=>{t.pattern??=Dc(t),V.init(e,t)}),wl=R(`$ZodISODuration`,(e,t)=>{t.pattern??=lc,V.init(e,t)}),Tl=R(`$ZodIPv4`,(e,t)=>{t.pattern??=hc,V.init(e,t)}),El=/^[0-9a-fA-F:.]+$/;function Dl(e){return El.test(e)?ol(`http://[${e}]`):!1}var Ol=R(`$ZodIPv6`,(e,t)=>{t.pattern??=gc,V.init(e,t),e._zod.check=n=>{Dl(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),kl=R(`$ZodCIDRv4`,(e,t)=>{t.pattern??=_c,V.init(e,t)});function Al(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Dl(n)}var jl=R(`$ZodCIDRv6`,(e,t)=>{t.pattern??=vc,V.init(e,t),e._zod.check=n=>{Al(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Ml(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Nl=/^[0-9a-zA-Z+/]*={0,2}$/,Pl=R(`$ZodBase64`,(e,t)=>{t.pattern??=Nl,V.init(e,t),e._zod.check=n=>{Ml(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Fl=/^[A-Za-z0-9_-]*$/;function Il(e){if(!Fl.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ml(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Ll=R(`$ZodBase64URL`,(e,t)=>{t.pattern??=Fl,V.init(e,t),e._zod.check=n=>{Il(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Rl=R(`$ZodE164`,(e,t)=>{t.pattern??=Sc,V.init(e,t)});function zl(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Bl=R(`$ZodJWT`,(e,t)=>{V.init(e,t),e._zod.check=n=>{zl(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Vl=R(`$ZodNumber`,(e,t)=>{B.init(e,t),e._zod.pattern=Ac,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Hl=R(`$ZodNumberFormat`,(e,t)=>{zc.init(e,t),Vl.init(e,t)}),Ul=R(`$ZodBoolean`,(e,t)=>{B.init(e,t),e._zod.pattern=jc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Wl=R(`$ZodUnknown`,(e,t)=>{B.init(e,t),e._zod.parse=e=>e}),Gl=R(`$ZodNever`,(e,t)=>{B.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Kl(e,t){let n=Qo(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Qo(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,$o(n.issues,t,e),n}}return i(n,a)}}var ql=e=>Array.isArray(e)?e.length:-1;function Jl(e,t,n){e.issues.length&&t.issues.push(...Xo(n,e.issues)),t.value[n]=e.value}var Yl=R(`$ZodArray`,(e,t)=>{B.init(e,t);let n=ws.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Jl(t,r,e)));else if(Jl(c,r,e),s&&c.issues.length!==0&&Jo(c))break}return o.length?Promise.all(o).then(()=>r):r},Kl(e,ql)});function Xl(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Xo(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Zl=[];function Ql(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Zl,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Io(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function $l(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(Jo(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Xl(e,n,i,t,d,f))):Xl(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var eu=R(`$ZodObject`,(e,t)=>{B.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=mo(()=>Ql(t));L(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||vo(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Oo,o=t.catchall,s,c=ws.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(Jo(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Xl(n,t,e,r,a,o))):Xl(s,t,e,r,a,o)}return o?$l(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),tu=R(`$ZodObjectJIT`,(e,t)=>{eu.init(e,t);let n=e._zod.parse,r=mo(()=>Ql(t)),i=ws.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Zc([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
16
+ let ${e}_ab = false;
17
+ for (let i = 0; i < ${e}.issues.length; i++) {
18
+ const iss = ${e}.issues[i];
19
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
20
+ payload.issues.push(iss);
21
+ if (iss.continue !== true) ${e}_ab = true;
22
+ }
23
+ if (${e}_ab && ctx && ctx.abortEarly) {
24
+ payload.value = newResult;
25
+ return payload;
26
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:To(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
27
+ const ${n}_present = ${i};
28
+ if (!${n}.issues.length || ${n}_present) {
29
+ if (${n}.issues.length) {${c(n,r)}
30
+ }
31
+
32
+ if (${e}) {
33
+ newResult[${r}] = ${n}.value;
34
+ }
35
+ }
36
+
37
+ `)}else f?(o.write(`
38
+ if (${n}.issues.length) {${c(n,r)}
39
+ }
40
+ `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
41
+ if (${n}.value !== undefined || ${i}) {
42
+ newResult[${r}] = ${n}.value;
43
+ }
44
+ `)):o.write(`
45
+ const ${n}_present = ${i};
46
+ if (${n}.issues.length) {${c(n,r)}
47
+ }
48
+ if (!${n}_present && !${n}.issues.length) {
49
+ payload.issues.push({
50
+ code: "invalid_type",
51
+ expected: "nonoptional",
52
+ input: undefined,
53
+ path: [${r}]
54
+ });
55
+ if (ctx && ctx.abortEarly) {
56
+ payload.value = newResult;
57
+ return payload;
58
+ }
59
+ }
60
+
61
+ if (${n}_present) {
62
+ newResult[${r}] = ${n}.value;
63
+ }
64
+
65
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Oo,c=!ws.jitless,l=c&&ko.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?$l([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function nu(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Jo(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>es(e,r,Ts())))}),t)}var ru=R(`$ZodUnion`,(e,t)=>{B.init(e,t),L(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),L(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),L(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),L(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>go(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>nu(t,r,e,i)):nu(o,r,e,i)}});function iu(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var au=R(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ru.init(e,t);let n=e._zod.parse;L(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||vo(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=yo(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=mo(()=>iu(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Oo(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),ou=R(`$ZodIntersection`,(e,t)=>{B.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>cu(e,t,n)):cu(e,i,a)}});function su(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ao(e)&&Ao(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=su(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=su(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cu(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=su(t.value,n.value);if(!c.valid){if(Jo(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var lu=R(`$ZodEnum`,(e,t)=>{B.init(e,t);let n=lo(t.entries),r=new Set(n);e._zod.values=r,L(e,`pattern`,e=>{let t=lo(e.def.entries).filter(e=>Mo.has(typeof e));return RegExp(t.length?`^(${t.map(e=>No(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),uu=R(`$ZodLiteral`,(e,t)=>{B.init(e,t);let n=new Set(t.values);e._zod.values=n,L(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?No(e):e?No(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),du=R(`$ZodTransform`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,ws.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Cs(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Ss;return n.value=i,n}});function fu(e,t){return e.value=t.issues.length?void 0:t.value,e}var pu=R(`$ZodOptional`,(e,t)=>{B.init(e,t),L(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,L(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),L(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${go(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>fu(e,t)):fu(e,r)}return t.innerType._zod.run(e,n)}}),mu=R(`$ZodExactOptional`,(e,t)=>{pu.init(e,t),L(e,`values`,e=>e.def.innerType._zod.values),L(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),hu=R(`$ZodNullable`,(e,t)=>{B.init(e,t),L(e,`optin`,e=>e.def.innerType._zod.optin),L(e,`optout`,e=>e.def.innerType._zod.optout),L(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${go(t.source)}|null)$`):void 0}),L(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),gu=R(`$ZodDefault`,(e,t)=>{B.init(e,t),e._zod.optin=`defaulted`,L(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>_u(e,t)):_u(r,t)}});function _u(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var vu=R(`$ZodPrefault`,(e,t)=>{B.init(e,t),e._zod.optin=`defaulted`,L(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),yu=R(`$ZodNonOptional`,(e,t)=>{B.init(e,t),L(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>bu(t,e)):bu(i,e)}});function bu(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function xu(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>es(e,r,Ts()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Su=R(`$ZodCatch`,(e,t)=>{B.init(e,t),L(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),L(e,`optout`,e=>e.def.innerType._zod.optout),L(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>xu(e,r,t,n)):xu(e,r,t,n)}}),Cu=R(`$ZodPipe`,(e,t)=>{B.init(e,t),L(e,`values`,e=>e.def.in._zod.values),L(e,`optin`,e=>e.def.in._zod.optin),L(e,`optout`,e=>e.def.out._zod.optout),L(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>wu(e,t.in,n)):wu(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>wu(e,t.out,n)):wu(r,t.out,n)}});function wu(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Tu=R(`$ZodReadonly`,(e,t)=>{B.init(e,t),L(e,`propValues`,e=>e.def.innerType._zod.propValues),L(e,`values`,e=>e.def.innerType._zod.values),L(e,`optin`,e=>e.def.innerType?._zod?.optin),L(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Eu):Eu(r)}});function Eu(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Du=R(`$ZodCustom`,(e,t)=>{z.init(e,t),B.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ou(t,n,r,e));Ou(i,n,r,e)}});function Ou(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(as(e))}}var ku=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Au=`~memo`,ju=[];function Mu(e){return typeof e==`object`&&!!e}function Nu(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Pu=new WeakMap,Fu=0,Iu=1,Lu=2;function Ru(e,t,n){let r=Pu.get(e);if(r!==void 0)return r?Lu:Fu;if(t.has(e))return Lu;t.add(e);let i=Fu,a=e=>{if(i!==Lu&&e?._zod){let r=Ru(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Fu;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Iu:o.value?._zod?Ru(o.value,t,n):Fu;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=yo(c);s(e?o(e,!0):Iu),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Ru(r,t,!1):Iu);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),zu(e,i)}function zu(e,t){return t!==Iu&&Pu.set(e,t===Lu),t}function Bu(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Vu,Hu=[],Uu={alloc(e,t,n){let r=Vu;if(!r)return n;Vu=void 0;let i={value:n,issues:null};return r.set(t.value,i),Hu.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Gu(n,e.value))throw new ku;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Ru(e,new Set,!1);if(i===Fu)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Lu||r?n=!0:r=!0}let l=s.value;if(!Mu(l))return t(s,c);let u=c[Au];u||(u={buckets:new WeakMap,backEdges:void 0},c[Au]=u);let d;i===c?d=a:(d=Bu(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Nu(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Vu=d;let p=Hu.length,m=t(s,c);Vu=void 0;let h=Hu.length>p?Hu.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Nu(e.issues):ju),e)):(h&&(h.issues=m.issues.length?Nu(m.issues):ju),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Wu(){return Uu}function Gu(e,t){let n=e[Au]?.backEdges;return n!==void 0&&Mu(t)&&n.has(t)}var Ku=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(is(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Fo(e.values[0])}`:`Invalid option: expected one of ${uo(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${uo(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function qu(){return{localeError:Ku()}}var Ju,Yu=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Xu(){return new Yu}(Ju=globalThis).__zod_globalRegistry??(Ju.__zod_globalRegistry=Xu());var Zu=globalThis.__zod_globalRegistry;function Qu(e){return e.checks&&=[...e.checks],e}function $u(e,t){return new e(Qu({type:`string`,...I(t)}))}function ed(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...I(t)})}function td(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...I(t)})}function nd(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...I(t)})}function rd(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...I(t)})}function id(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...I(t)})}function ad(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...I(t)})}function od(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...I(t)})}function sd(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...I(t)})}function cd(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...I(t)})}function ld(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...I(t)})}function ud(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...I(t)})}function dd(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...I(t)})}function fd(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...I(t)})}function pd(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...I(t)})}function md(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...I(t)})}function hd(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...I(t)})}function gd(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...I(t)})}function _d(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...I(t)})}function vd(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...I(t)})}function yd(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...I(t)})}function bd(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...I(t)})}function xd(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...I(t)})}function Sd(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...I(t)})}function Cd(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...I(t)})}function wd(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...I(t)})}function Td(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...I(t)})}function Ed(e,t){return new e(Qu({type:`number`,checks:[],...I(t)}))}function Dd(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...I(t)})}function Od(e,t){return new e({type:`boolean`,...I(t)})}function kd(e){return new e({type:`unknown`})}function Ad(e,t){return new e({type:`never`,...I(t)})}function jd(e,t){return new Ic({check:`less_than`,...I(t),value:e,inclusive:!1})}function Md(e,t){return new Ic({check:`less_than`,...I(t),value:e,inclusive:!0})}function Nd(e,t){return new Lc({check:`greater_than`,...I(t),value:e,inclusive:!1})}function Pd(e,t){return new Lc({check:`greater_than`,...I(t),value:e,inclusive:!0})}function Fd(e,t){return new Rc({check:`multiple_of`,...I(t),value:e})}function Id(e,t){return new Bc({check:`max_length`,...I(t),maximum:e})}function Ld(e,t){return new Vc({check:`min_length`,...I(t),minimum:e})}function Rd(e,t){return new Hc({check:`length_equals`,...I(t),length:e})}function zd(e,t){return new Wc({check:`string_format`,format:`regex`,...I(t),pattern:e})}function Bd(e){return new Gc({check:`string_format`,format:`lowercase`,...I(e)})}function Vd(e){return new Kc({check:`string_format`,format:`uppercase`,...I(e)})}function Hd(e,t){return new qc({check:`string_format`,format:`includes`,...I(t),includes:e})}function Ud(e,t){return new Jc({check:`string_format`,format:`starts_with`,...I(t),prefix:e})}function Wd(e,t){return new Yc({check:`string_format`,format:`ends_with`,...I(t),suffix:e})}function Gd(e){return new Xc({check:`overwrite`,tx:e})}function Kd(e){return Gd(t=>t.normalize(e))}function qd(){return Gd(e=>e.trim())}function Jd(){return Gd(e=>e.toLowerCase())}function Yd(){return Gd(e=>e.toUpperCase())}function Xd(){return Gd(e=>Eo(e))}function Zd(e,t,n){return new e({type:`array`,element:t,...I(n)})}function Qd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...I(n)})}function $d(e,t){let n=ef(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(as(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(as(r))}},e(t.value,t)),t);return n}function ef(e,t){let n=new z({check:`custom`,...I(t)});return n._zod.check=e,n}function tf(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&vo(e,t,n[t]);return e}function nf(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Zu,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function rf(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function H(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,H(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&tf(o.schema,c),t.io===`input`&&U(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function af(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function of(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${af(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+af(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
66
+
67
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function sf(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;sf(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var cf=new Set([`type`,`properties`,`required`,`additionalProperties`]),lf=[`oneOf`,`anyOf`];function uf(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function df(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!cf.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??uf(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}vo(n,r,e.length===1?e[0]:df(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=uf(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function ff(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of cf)if(t in e)return;let n=t.filter(e=>lf.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=df(t);else{let e=n[0],i=lf.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>df([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,tf(e,r))}function pf(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):tf(i,s),tf(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())sf(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])ff(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}tf(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,vo(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:hf(t,`input`,e.processors),output:hf(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function U(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return U(r.element,n);if(r.type===`set`)return U(r.valueType,n);if(r.type===`lazy`)return U(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return U(r.innerType,n);if(r.type===`intersection`)return U(r.left,n)||U(r.right,n);if(r.type===`record`||r.type===`map`)return U(r.keyType,n)||U(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:U(r.in,n)||U(r.out,n);if(r.type===`object`){for(let e in r.shape)if(U(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(U(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(U(e,n))return!0;return!!(r.rest&&U(r.rest,n))}return!1}var mf=(e,t={})=>n=>{let r=nf({...n,processors:t});return H(e,r),of(r,e),pf(r,e)},hf=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=nf({...i??{},target:a,io:t,processors:n});return H(e,o),of(o,e),pf(o,e)},gf=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},_f=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},vf=(e,t)=>{gf(e,`minimum`,t),_f(e,`maximum`,t)},yf=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},bf=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},xf=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Sf=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Cf=(e,t)=>gf(e,`minimum`,t.minimum),wf=(e,t)=>_f(e,`maximum`,t.maximum),Tf=e=>(t,n)=>{Sf(t,n.format);let[r,i]=e[n.format];gf(t,`minimum`,r),_f(t,`maximum`,i)},Ef={greater_than:(e,t)=>gf(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>_f(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>yf(e,t.value),number_format:Tf(Lo),bigint_format:Tf(Ro),min_length:Cf,max_length:wf,length_equals:(e,t)=>vf(e,t.length),min_size:Cf,max_size:wf,size_equals:(e,t)=>vf(e,t.size),string_format:(e,t)=>{Sf(e,t.format),t.pattern&&bf(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>xf(e,t.mime)};function Df(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ef[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&gf(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&gf(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&_f(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&_f(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&yf(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&xf(t,i.mime);for(let e of i.patterns??[])bf(t,e);return t}var Of={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},kf=new Map([[Nl,yc],[Fl,bc]]),Af=e=>kf.get(e)??e,jf=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Df(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Of[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Af);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Mf=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Df(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):rf(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Nf=(e,t,n,r)=>{n.type=`boolean`},Pf=(e,t,n,r)=>{n.not={}},Ff=(e,t,n,r)=>{let i=e._zod.def,a=lo(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},If=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(rf(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(rf(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Lf=(e,t,n,r)=>{rf(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Rf=(e,t,n,r)=>{rf(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},zf=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Df(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=H(a.element,t,{...r,path:[...r.path,`items`]})};function Bf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Bf(t.out):t.type===`catch`?Bf(t.innerType):e._zod.optin}var Vf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&rf(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)vo(i.properties,e,H(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Bf(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=H(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Hf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>H(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Uf=(e,t,n,r)=>{let i=e._zod.def,a=H(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=H(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Wf=(e,t,n,r)=>{let i=e._zod.def,a=H(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Gf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Kf=Symbol();function qf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(rf(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Kf):JSON.parse(o)}var Jf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=qf(i.defaultValue,e,t,n,r);o!==Kf&&(n.default=o)},Yf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=qf(i.defaultValue,e,t,n,r);o!==Kf&&(n._prefault=o)},Xf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{rf(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Zf=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;H(o,t,r);let s=t.seen.get(e);s.ref=o},Qf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},$f=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ep=new WeakSet([Object.prototype,Error.prototype]);function tp(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var W=R(`ZodError`,(e,t)=>{js.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ep.has(n)||(ep.add(n),tp(n,`format`,e=>t=>Ps(e,t)),tp(n,`flatten`,e=>t=>Ns(e,t)),tp(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fo,2)}),tp(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),np=Rs(W),rp=zs(W),ip=Bs(W),ap=Hs(W),op=Js(W),sp=Ys(W),cp=Xs(W),lp=Zs(W),up=Qs(W),dp=$s(W),fp=ec(W),pp=tc(W);function mp(){ws.localeError||Ts(qu())}function hp(){ws.memoizer||Ts({memoizer:Wu()})}var G=R(`ZodType`,(e,t)=>(mp(),B.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(F(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Po(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Nm(e,t))},superRefine(e,t){return this.check(Pm(e,t))},overwrite(e){return this.check(Gd(e))},optional(){return hm(this)},exactOptional(){return _m(this)},nullable(){return ym(this)},nullish(){return hm(ym(this))},nonoptional(e){return Tm(this,e)},array(){return Qp(this)},or(e){return rm([this,e])},and(e){return sm(this,e)},transform(e){return km(this,pm(e))},default(e){return xm(this,e)},prefault(e){return Cm(this,e)},catch(e){return Dm(this,e)},pipe(e){return km(this,e)},readonly(){return jm(this)},describe(e){let t=this.clone();return Zu.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zu.get(this);let t=this.clone();return Zu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return cs(this,`~standard`,{...tl(this),jsonSchema:{input:hf(this,`input`),output:hf(this,`output`)}})},set"~standard"(e){ss(this,`~standard`,e)},parse:function e(t,n){return np(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await rp(this,t,n,{callee:e})},safeParse(e,t){return ip(this,e,t)},async safeParseAsync(e,t){return ap(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ss(this,`spa`,e)},validate(e,t){return Gs(this,e,t)},validateAsync(e,t){return qs(this,e,t)},encode:function e(t,n){return op(this,t,n,{callee:e})},decode:function e(t,n){return sp(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await cp(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await lp(this,t,n,{callee:e})},safeEncode(e,t){return up(this,e,t)},safeDecode(e,t){return dp(this,e,t)},async safeEncodeAsync(e,t){return fp(this,e,t)},async safeDecodeAsync(e,t){return pp(this,e,t)},toJSONSchema(e){return mf(this,{})(e)},get description(){return Zu.get(this)?.description},get _def(){return this._zod.def}}),gp=R(`_ZodString`,(e,t)=>{nl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jf(e,t,n,r)},ls({format:e=>Df(e).format??null,minLength:e=>Df(e).minimum??null,maxLength:e=>Df(e).maximum??null},{regex(...e){return this.check(zd(...e))},includes(...e){return this.check(Hd(...e))},startsWith(...e){return this.check(Ud(...e))},endsWith(...e){return this.check(Wd(...e))},min(...e){return this.check(Ld(...e))},max(...e){return this.check(Id(...e))},length(...e){return this.check(Rd(...e))},nonempty(...e){return this.check(Ld(1,...e))},lowercase(e){return this.check(Bd(e))},uppercase(e){return this.check(Vd(e))},trim(){return this.check(qd())},normalize(...e){return this.check(Kd(...e))},toLowerCase(){return this.check(Jd())},toUpperCase(){return this.check(Yd())},slugify(){return this.check(Xd())}})),_p=R(`ZodString`,(e,t)=>{nl.init(e,t),gp.init(e,t)},{email(e){return this.check(ed(Cp,e))},url(e){return this.check(od(Ep,e))},jwt(e){return this.check(xd(Vp,e))},emoji(e){return this.check(sd(Dp,e))},guid(e){return this.check(td(wp,e))},uuid(e){return this.check(nd(Tp,e))},uuidv4(e){return this.check(rd(Tp,e))},uuidv6(e){return this.check(id(Tp,e))},uuidv7(e){return this.check(ad(Tp,e))},nanoid(e){return this.check(cd(Op,e))},cuid(e){return this.check(ld(kp,e))},cuid2(e){return this.check(ud(Ap,e))},ulid(e){return this.check(dd(jp,e))},base64(e){return this.check(vd(Rp,e))},base64url(e){return this.check(yd(zp,e))},xid(e){return this.check(fd(Mp,e))},ksuid(e){return this.check(pd(Np,e))},ipv4(e){return this.check(md(Pp,e))},ipv6(e){return this.check(hd(Fp,e))},cidrv4(e){return this.check(gd(Ip,e))},cidrv6(e){return this.check(_d(Lp,e))},e164(e){return this.check(bd(Bp,e))},datetime(e){return this.check(Sd(yp,e))},date(e){return this.check(Cd(bp,e))},time(e){return this.check(wd(xp,e))},duration(e){return this.check(Td(Sp,e))}});function vp(e){return $u(_p,e)}var K=R(`ZodStringFormat`,(e,t)=>{V.init(e,t),gp.init(e,t)}),yp=R(`ZodISODateTime`,(e,t)=>{xl.init(e,t),K.init(e,t)}),bp=R(`ZodISODate`,(e,t)=>{Sl.init(e,t),K.init(e,t)}),xp=R(`ZodISOTime`,(e,t)=>{Cl.init(e,t),K.init(e,t)}),Sp=R(`ZodISODuration`,(e,t)=>{wl.init(e,t),K.init(e,t)}),Cp=R(`ZodEmail`,(e,t)=>{al.init(e,t),K.init(e,t)}),wp=R(`ZodGUID`,(e,t)=>{rl.init(e,t),K.init(e,t)}),Tp=R(`ZodUUID`,(e,t)=>{il.init(e,t),K.init(e,t)}),Ep=R(`ZodURL`,(e,t)=>{pl.init(e,t),K.init(e,t)}),Dp=R(`ZodEmoji`,(e,t)=>{ml.init(e,t),K.init(e,t)}),Op=R(`ZodNanoID`,(e,t)=>{hl.init(e,t),K.init(e,t)}),kp=R(`ZodCUID`,(e,t)=>{gl.init(e,t),K.init(e,t)}),Ap=R(`ZodCUID2`,(e,t)=>{_l.init(e,t),K.init(e,t)}),jp=R(`ZodULID`,(e,t)=>{vl.init(e,t),K.init(e,t)}),Mp=R(`ZodXID`,(e,t)=>{yl.init(e,t),K.init(e,t)}),Np=R(`ZodKSUID`,(e,t)=>{bl.init(e,t),K.init(e,t)}),Pp=R(`ZodIPv4`,(e,t)=>{Tl.init(e,t),K.init(e,t)}),Fp=R(`ZodIPv6`,(e,t)=>{Ol.init(e,t),K.init(e,t)}),Ip=R(`ZodCIDRv4`,(e,t)=>{kl.init(e,t),K.init(e,t)}),Lp=R(`ZodCIDRv6`,(e,t)=>{jl.init(e,t),K.init(e,t)}),Rp=R(`ZodBase64`,(e,t)=>{Pl.init(e,t),K.init(e,t)}),zp=R(`ZodBase64URL`,(e,t)=>{Ll.init(e,t),K.init(e,t)}),Bp=R(`ZodE164`,(e,t)=>{Rl.init(e,t),K.init(e,t)}),Vp=R(`ZodJWT`,(e,t)=>{Bl.init(e,t),K.init(e,t)}),Hp=R(`ZodNumber`,(e,t)=>{Vl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mf(e,t,n,r),e.isFinite=!0},ls({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Df(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Df(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Df(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Df(e).format??null},{gt(e,t){return this.check(Nd(e,t))},gte(e,t){return this.check(Pd(e,t))},min(e,t){return this.check(Pd(e,t))},lt(e,t){return this.check(jd(e,t))},lte(e,t){return this.check(Md(e,t))},max(e,t){return this.check(Md(e,t))},int(e){return this.check(Gp(e))},safe(e){return this.check(Gp(e))},positive(e){return this.check(Nd(0,e))},nonnegative(e){return this.check(Pd(0,e))},negative(e){return this.check(jd(0,e))},nonpositive(e){return this.check(Md(0,e))},multipleOf(e,t){return this.check(Fd(e,t))},step(e,t){return this.check(Fd(e,t))},finite(){return this}}));function Up(e){return Ed(Hp,e)}var Wp=R(`ZodNumberFormat`,(e,t)=>{Hl.init(e,t),Hp.init(e,t)});function Gp(e){return Dd(Wp,e)}var Kp=R(`ZodBoolean`,(e,t)=>{Ul.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nf(e,t,n,r)});function q(e){return Od(Kp,e)}var qp=R(`ZodUnknown`,(e,t)=>{Wl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Jp(){return kd(qp)}var Yp=R(`ZodNever`,(e,t)=>{Gl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pf(e,t,n,r)});function Xp(e){return Ad(Yp,e)}var Zp=R(`ZodArray`,(e,t)=>{hp(),Yl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zf(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Ld(e,t))},nonempty(e){return this.check(Ld(1,e))},max(e,t){return this.check(Id(e,t))},length(e,t){return this.check(Rd(e,t))},unwrap(){return this.element}});function Qp(e,t){return Zd(Zp,e,t)}var $p=R(`ZodObject`,(e,t)=>{hp(),tu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vf(e,t,n,r),hs(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return lm(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(F(this._zod.def,{catchall:e}))},passthrough(){return this.clone(F(this._zod.def,{catchall:Jp()}))},loose(){return this.clone(F(this._zod.def,{catchall:Jp()}))},strict(){return this.clone(F(this._zod.def,{catchall:Xp()}))},strip(){return this.clone(F(this._zod.def,{catchall:void 0}))},extend(e){return Ho(this,e)},safeExtend(e){return Wo(this,e)},merge(e){return Go(this,e)},pick(e){return zo(this,e)},omit(e){return Vo(this,e)},partial(...e){return Ko(mm,this,e[0])},exactPartial(...e){return Ko(gm,this,e[0],`exactPartial`)},required(...e){return qo(wm,this,e[0])}});function em(e,t){return new $p({type:`object`,shape:e??{},...I(t)})}function tm(e,t){return new $p({type:`object`,shape:e,catchall:Xp(),...I(t)})}var nm=R(`ZodUnion`,(e,t)=>{ru.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hf(e,t,n,r),e.options=t.options});function rm(e,t){return new nm({type:`union`,options:e,...I(t)})}var im=R(`ZodDiscriminatedUnion`,(e,t)=>{nm.init(e,t),au.init(e,t)});function am(e,t,n){return new im({type:`union`,options:t,discriminator:e,...I(n)})}var om=R(`ZodIntersection`,(e,t)=>{ou.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uf(e,t,n,r)});function sm(e,t){return new om({type:`intersection`,left:e,right:t})}var cm=R(`ZodEnum`,(e,t)=>{lu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ff(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new cm({...t,checks:[],...I(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new cm({...t,checks:[],...I(r),entries:i})}});function lm(e,t){return new cm({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var um=R(`ZodLiteral`,(e,t)=>{uu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>If(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function dm(e,t){return new um({type:`literal`,values:Array.isArray(e)?e:[e],...I(t)})}var fm=R(`ZodTransform`,(e,t)=>{hp(),du.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rf(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Cs(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(as(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(as(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function pm(e){return new fm({type:`transform`,transform:e})}var mm=R(`ZodOptional`,(e,t)=>{pu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$f(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hm(e){return new mm({type:`optional`,innerType:e})}var gm=R(`ZodExactOptional`,(e,t)=>{mu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$f(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _m(e){return new gm({type:`optional`,innerType:e})}var vm=R(`ZodNullable`,(e,t)=>{hu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ym(e){return new vm({type:`nullable`,innerType:e})}var bm=R(`ZodDefault`,(e,t)=>{gu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xm(e,t){return new bm({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():jo(t)}})}var Sm=R(`ZodPrefault`,(e,t)=>{vu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cm(e,t){return new Sm({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():jo(t)}})}var wm=R(`ZodNonOptional`,(e,t)=>{yu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tm(e,t){return new wm({type:`nonoptional`,innerType:e,...I(t)})}var Em=R(`ZodCatch`,(e,t)=>{Su.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Dm(e,t){return new Em({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:_s(t)})}var Om=R(`ZodPipe`,(e,t)=>{Cu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zf(e,t,n,r),e.in=t.in,e.out=t.out});function km(e,t){return new Om({type:`pipe`,in:e,out:t})}var Am=R(`ZodReadonly`,(e,t)=>{Tu.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jm(e){return new Am({type:`readonly`,innerType:e})}var Mm=R(`ZodCustom`,(e,t)=>{Du.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lf(e,t,n,r)});function Nm(e,t={}){return Qd(Mm,e,t)}function Pm(e,t){return $d(e,t)}var Fm=`no-project`;function Im(){return J.parseLocation(J.history.location).search}function Lm(){let e=/^\/terminal\/([^/]+)$/.exec(J.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Y().machines.some(e=>e.id===t)?t:null}function Rm(){let e=Rr({strict:!1,select:e=>e.machine??null});return mg(t=>t.machines.some(t=>t.id===e)?e:null)}function zm(){return Im().project??`global`}function Bm(){return zr({strict:!1,select:e=>e.project??`global`})}function Vm(e){let t=Im();return t.machine===void 0||t.project===void 0||!e.includes(t.machine)?null:{machine:t.machine,projectId:t.project,sessionId:t.session??null}}function Hm(e){ah({...Im(),...e},!0,J.history.location.state.layer)}function Um(e,t){ah({...Im(),...e},!1,t)}function Wm(e){let t=Y();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){Hm({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){Hm({panel:`browser`,browse:e});return}let n=hg(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);Hm({panel:`browser`,browse:`${n.path}/${e}`})}function Gm(e,t){J.history.location.state.layer===e?J.history.back():t()}var Km=[],qm=!1,Jm=!1,Ym=!1;function Xm(){return J.history.location.state.guard===!0}function Zm(){return Ym}function Qm(){qm||(Km.length>0&&!Xm()?J.history.push(J.history.location.href,{guard:!0}):Km.length===0&&Xm()&&(qm=!0,J.history.back()))}function $m(){Jm=Xm(),J.history.subscribe(({action:e})=>{let t=Jm;Jm=Xm(),e.type===`PUSH`||e.type===`REPLACE`?Ym=!1:(Ym=t,Ym&&qm?qm=!1:Ym&&Km.at(-1)?.(),setTimeout(Qm))}),setTimeout(Qm)}function eh(e,t){let n=(0,O.useEffectEvent)(t);(0,O.useEffect)(()=>{if(!e)return;function t(){n()}return Km.push(t),setTimeout(Qm),()=>{Km.splice(Km.indexOf(t),1),setTimeout(Qm)}},[e])}var th=`terminalProjects`;function nh(){return JSON.parse(localStorage.getItem(th)??`[]`)}function rh(){let e=Im();if(Lm()!==null||e.machine===void 0||e.project===void 0||e.session===void 0)return;let t=`${e.machine} ${e.project}`,n=nh().filter(e=>e!==t);localStorage.setItem(th,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function ih(e=!1){let t=Y().selection;if(t===null){ah({project:Lm()===null?void 0:Im().project},!0,J.history.location.state.layer);return}let n=Im(),r=n.machine===t.machine&&n.project===t.projectId&&n.session===void 0&&(t.sessionId===null||Y().loaded),i=nh().includes(`${t.machine} ${t.projectId}`),a={machine:t.machine,project:t.projectId,session:t.sessionId??void 0,bottom:r?n.bottom:t.sessionId!==null&&i?`terminal`:void 0};if(Lm()!==null){J.navigate({to:`/`,search:a,replace:e||Xm(),state:{layer:`chat`},resetScroll:!1});return}let o=n.machine===a.machine&&n.project===a.project&&n.session===a.session,s=n.machine!==void 0&&n.session===void 0&&a.session===void 0;e||o||r||s?Hm(a):Um(a,`chat`)}function ah(e,t,n){let r=Lm(),i=Xm(),a=t&&i?{layer:n,guard:i}:{layer:n};r===null?J.navigate({to:`/`,search:e,replace:t||i,state:a,resetScroll:!1}):J.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t||i,state:a,resetScroll:!1})}function oh(e,t=null,n=!1){let r=Z(Y(),e.machine),i=Y().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),X({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?i?.sessionId===null&&i.machine===e.machine?Y().settings:Hg(r):to(bg(e))??Vg(r.composer,Y().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??r.composer?.provider??`claude`),context:null,replacing:null,paletteOpen:!1,unseen:Y().unseen.filter(t=>e.sessionId===null||t!==zh(e.machine,e.sessionId))}),ih(n),Kg(e.machine),e.sessionId!==null&&r.status===`online`&&sh(e.machine,e.projectId,e.sessionId,!0,t)}function sh(e,t,n,r,i){N(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Y().sessions.some(n=>n.machine===e&&n.id===t.id)||X({sessions:[...Y().sessions,{...t,machine:e}]})}).catch($)}function ch(){X({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),ih()}function lh(){let e=Y().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function uh(e,t,n=!1){oh({machine:e,projectId:hg(Y(),e,t)?.scratch===!0?Fm:t,sessionId:null},null,n)}function dh(){let e=Y(),t=localStorage.getItem(`lastProject`),n=t===null?null:JSON.parse(t),r=e.machines.filter(e=>e.system?.scratchAvailable===!0);if(n!==null&&n.projectId===`no-project`&&r.some(e=>e.id===n.machine))return n;let i=(n===null?void 0:e.projects.find(e=>e.machine===n.machine&&e.id===n.projectId))??e.projects.find(e=>!e.scratch);return i===void 0?r.length>0?{machine:r[0].id,projectId:Fm}:null:{machine:i.machine,projectId:i.id}}function fh(e,t){let n=Lm();(n!==e||zm()!==t)&&(J.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null||Xm(),state:{layer:`chat`},resetScroll:!1}),ch())}async function ph(e,t,n,r){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),X({sentAt:Date.now()}),await N(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t});let i=Y().replacing;n.sessionId===null&&i!==null&&i.machine===n.machine&&i.sessionId!==null&&(X({replacing:null}),await Th(i.machine,i.sessionId,i.projectId))}function mh(e){let t=Y().selection;t!==null&&t.sessionId!==null&&N(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function hh(e){let t=Y().selection;t!==null&&t.sessionId!==null&&N(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function gh(){let e=Y().selection;e!==null&&e.sessionId!==null&&N(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function _h(e,t,n){N(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function vh(e,t,n){let r=Y().selection;r!==null&&r.sessionId!==null&&N(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function yh(e){let t=Y().selection;if(t!==null&&t.sessionId!==null)try{let n=await N(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});oh({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function bh(){let e=Y().selection,t=Y().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await N(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Y().selection!==e||Y().before!==t)return;X({earlier:[...n.items,...Y().earlier],before:n.before})}catch(e){$(e)}}async function xh(e,t){let n=Y().selection;if(n!==null&&n.sessionId!==null)try{let r=await N(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Y().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Y().items;X({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Sh(e,t,n){let r=Y();function i(n){return n.machine===e&&n.id===t}let a=[...r.sessions,...r.inactive].find(i);if(a!==void 0){let e={...a,...n};X({sessions:r.sessions.some(i)?r.sessions.map(t=>i(t)?e:t):e.status===`inactive`?r.sessions:[...r.sessions,e],inactive:e.status===`inactive`?r.inactive.some(i)?r.inactive.map(t=>i(t)?e:t):[e,...r.inactive]:r.inactive.filter(e=>!i(e))})}try{await N(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Ch(e){let t=zh(e.machine,e.id);X({generatingTitles:[...Y().generatingTitles,t]});try{await N(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{X({generatingTitles:Y().generatingTitles.filter(e=>e!==t)})}}async function wh(e,t,n){let r=Y().selection;if(r?.machine===e&&r.sessionId===t){let i=Y().sessions.filter(r=>(r.status===`pinned`||r.status===`active`||r.status===`snoozed`)&&(r.machine!==e||r.id!==t)&&(n===null||r.machine===n.machine&&(r.projectId===n.projectId||n.projectId===`no-project`&&hg(Y(),r.machine,r.projectId)?.scratch===!0))).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);i===void 0?uh(r.machine,r.projectId,!0):oh({machine:i.machine,projectId:i.projectId,sessionId:i.id},null,!0)}await Sh(e,t,{status:`inactive`})}async function Th(e,t,n){X({sessions:Y().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Y().inactive.filter(n=>n.machine!==e||n.id!==t)}),$a(zh(e,t));let r=Y().selection;r?.machine===e&&r.sessionId===t&&uh(e,r.projectId,!0);try{await N(e,`sessions.remove`,{id:t,projectId:n})}catch(e){$(e)}}var Eh=em({machine:vp().optional().catch(void 0),project:vp().optional().catch(void 0),session:vp().optional().catch(void 0),panel:lm([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:vp().optional().catch(void 0),bottom:dm(`terminal`).optional().catch(void 0),terminal:vp().optional().catch(void 0)}),Dh=si({validateSearch:Eh}),Oh=ai({getParentRoute:()=>Dh,path:`/`}),kh=ai({getParentRoute:()=>Dh,path:`/terminal`,beforeLoad:()=>{let e=lh();throw st(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Ah=ai({getParentRoute:()=>Dh,path:`/terminal/$machine`});if(window.history.state?.__TSR_index===void 0&&(location.pathname.startsWith(`/terminal`)||new URLSearchParams(location.search).has(`machine`))){let e=`${location.pathname}${location.search}${location.hash}`,t=Math.random().toString(36).slice(2),n=Math.random().toString(36).slice(2);window.history.replaceState({__TSR_index:0,__TSR_key:t,key:t},``,`/`),window.history.pushState({__TSR_index:1,__TSR_key:n,key:n,layer:`chat`},``,e)}var J=li({routeTree:Dh.addChildren([Oh,kh,Ah]),disableGlobalCatchBoundary:!0,parseSearch:e=>Eh.parse(Object.fromEntries(new URLSearchParams(e))),stringifySearch:e=>{let t=new URLSearchParams;for(let n of Object.entries(e))n[1]!==void 0&&t.set(n[0],String(n[1]));let n=t.toString();return n===``?``:`?${n}`}}),jh=Ui.withTag(`machines`),Mh=`machines`,Nh=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function Ph(){let e=localStorage.getItem(Mh);return e===null?[]:JSON.parse(e)}function Fh(e){localStorage.setItem(Mh,JSON.stringify(e))}async function Ih(e){if(!(`caches`in window))return;let t=e.map(e=>({id:e.id,addresses:e.addresses}));await(await caches.open(`offsite-worker`)).put(`/machines`,new Response(JSON.stringify(t)))}function Lh(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));J.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:Rh(t).address,code:e.get(`code`)}}function Rh(e){let t=e.trim(),n=new URL(/^[a-z]+:\/\//i.test(t)?t:`http://${t}`);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`Use an http:// or https:// address`);let r=new URLSearchParams(n.hash.slice(1)),i=r.get(`machine`);return{address:i===null?n.origin:Rh(i).address,code:r.get(`code`)}}function zh(e,t){return`${e} ${t}`}function Bh(e){return{id:e.id,addresses:e.addresses,via:null,status:`connecting`,name:e.label??e.name,hostname:e.name,label:e.label,icon:e.icon,pairedAt:e.pairedAt??null,config:null,composer:null,appIcon:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function Vh(e){return e.projects.map(t=>({...t,machine:e.id}))}function Hh(){let e=Ph(),t=Y().machines;for(let n of t)e.some(e=>e.id===n.id)||Zh(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Y();X({machines:[...e.machines,Bh(n)],projects:[...e.projects,...Vh(n)]}),ua(n.id,n.addresses)}else Q(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(Q(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),Yh(n.id))}let n=e.map(e=>e.id);X({machines:[...Y().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function Uh(e,t){let n=Y().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await Wh(n.id,t),n.id;let r=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);return t!==null&&await Ii(r,await Gh(e,t)),X({machines:[...Y().machines,Bh({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),Qh(),ua(r,e),r}async function Wh(e,t){await Ii(e,await Gh(Z(Y(),e).addresses,t)),Q(e,{pairedAt:Date.now()}),Qh(),Yh(e)}async function Gh(e,t){let n;for(let r of e){let e=await fetch(`${r}/api/pair`,{method:`POST`,headers:{authorization:`Bearer ${t}`}}).catch(e=>(n??=e,null));if(e!==null){if(!e.ok)throw Error(await e.text());return(await e.json()).token}}throw Error(`Could not reach the machine to pair: ${String(n)}`)}function Kh(e,t){let n=Z(Y(),e),r={...n,...t};Q(e,{...t,name:r.label??r.hostname}),Qh(),r.addresses.join(` `)!==n.addresses.join(` `)&&Yh(e)}function qh(e){X({machines:[...Y().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),Qh()}function Jh(e){Ih(e).catch(e=>jh.error(`could not share the machines with the service worker`,e))}function Yh(e){da(e),Q(e,{status:`connecting`,via:null}),ua(e,Z(Y(),e).addresses)}function Xh(e){Zh(e),Qh(),Li(e).catch(e=>jh.error(`could not remove the device token`,e))}function Zh(e){da(e);let t=Y(),n=t.machines.filter(t=>t.id!==e);X({machines:n,projects:t.projects.filter(t=>t.machine!==e),sessions:t.sessions.filter(t=>t.machine!==e),inactive:t.inactive.filter(t=>t.machine!==e),unseen:t.unseen.filter(t=>!t.startsWith(`${e} `)),...t.settingsMachine===e&&{settingsMachine:n.at(0)?.id??null},...t.selection?.machine===e&&{selection:null}}),ih()}function Qh(){let e=Y(),t=e.machines.map(t=>({id:t.id,addresses:t.addresses,name:t.hostname,label:t.label,icon:t.icon,pairedAt:t.pairedAt,projects:e.projects.filter(e=>e.machine===t.id).map(e=>({id:e.id,path:e.path,name:e.name,logo:e.logo,hidden:e.hidden,scratch:e.scratch}))}));Fh(t),Jh(t)}var $h=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}],eg=Ui.withTag(`prefs`),tg=tm({theme:vp().refine(e=>$h.some(t=>t.id===e)).default($h[0].id),terminal:tm({font:tm({family:vp().default(`FiraCode Nerd Font`),size:Up().default(14),lineHeight:Up().default(1.35),ligatures:q().default(!0)}).prefault({}),cursor:tm({style:lm([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),padding:tm({top:Up().default(4),right:Up().default(4),bottom:Up().default(0),left:Up().default(4)}).prefault({}),scrollback:Up().default(1e3),boldIsBright:q().default(!0),behavior:tm({modernizeShiftEnter:q().default(!0),pasteBrowserImages:q().default(!0),captureShortcuts:q().default(!0),bellFlash:q().default(!0),bellSound:q().default(!0),clickToMoveCursor:q().default(!0),optionAsMeta:lm([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:q().default(!0),confirmCloseBusyTab:q().default(!0)}).prefault({})}).prefault({}),editor:tm({font:tm({family:vp().default(`FiraCode Nerd Font`),size:Up().default(15.3),lineHeight:Up().default(1.8),ligatures:q().default(!0),features:vp().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:tm({style:lm([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),tabSize:Up().default(2),wordWrap:q().default(!0),graph:q().default(!0)}).prefault({}),diff:tm({split:q().default(!1),wrap:q().default(!0),collapsed:q().default(!1)}).prefault({}),rewind:lm([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:q().default(!1),toolbar:Qp(lm([`diff`,`terminal`,`tasks`,`browser`,`editor`])).default([`diff`,`terminal`,`editor`])}),ng=`prefs`,rg=tg.parse({});function ig(){let e=localStorage.getItem(ng);if(e===null)return structuredClone(rg);let t=tg.safeParse(JSON.parse(e));return t.success?t.data:(eg.warn(`invalid stored prefs, using the defaults:\n${Is(t.error)}`),structuredClone(rg))}function ag(e){localStorage.setItem(ng,JSON.stringify(e))}function og(){let e=Y().prefs.theme,t=$h.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function sg(){let e=mg(e=>e.prefs.theme),t=$h.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function cg(){let e=og(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}var lg=Ui.withTag(`ui`),ug={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},dg;function fg(e){dg=Na()(()=>e)}function pg(e){return dg.subscribe(e)}function Y(){return dg.getState()}function mg(e){return Fa(dg,e)}function X(e){dg.setState(e)}function Z(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function hg(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function gg(e){return e.selection?.machine??e.machines.at(0)?.id??null}function Q(e,t){X({machines:Y().machines.map(n=>n.id===e?{...n,...t}:n)})}function _g(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function vg(e){let t=e.selection;if(t!==null)return _g(e.machines,t.machine,t.sessionId)}function yg(e){return vg(e)?.running===!0}function bg(e){return e.sessionId===null?`new`:zh(e.machine,e.sessionId)}function xg(e){X({draft:e})}function Sg(e){X({paletteOpen:e})}function Cg(e){X({editor:e})}function wg(e){X({exporting:e})}function Tg(e){X({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:gg(Y()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Eg(e){X({usageOpen:e,paletteOpen:!1})}function Dg(e){X({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Y().settingsOpen&&{settingsMachine:gg(Y())}})}function Og(e){X({prefs:e}),ag(e),cg()}function $(e){lg.warn(`showing an error:`,e),X({errors:[...Y().errors,i(e)]})}function kg(){X({errors:[]})}function Ag(e){let t=new Map;function n(t,n){Y().machines.some(e=>e.id===t)&&e.apply(t,n)}async function r(r,a){let o=await e.save(r,a),s=t.get(r);s!==void 0&&(--s.writes,s.writes>0||(o===null?await i(r):n(r,o)))}async function i(r){let i=t.get(r)?.version;try{let a=await e.load(r),o=t.get(r);o!==void 0&&o.writes===0&&o.version===i&&n(r,a)}catch(e){$(e)}}return{update(n,i){e.set(n,i);let a=t.get(n)??{writes:0,version:0,timer:void 0};t.set(n,a),a.timer===void 0&&(a.writes+=1),a.version+=1,window.clearTimeout(a.timer),a.timer=window.setTimeout(()=>{a.timer=void 0,r(n,i)},300)},receive(e,r){(t.get(e)?.writes??0)===0&&n(e,r)}}}var jg=Ag({set:Lg,save:async(e,t)=>{try{let n=await N(e,`config.save`,t);return Q(e,{configError:null}),n}catch(t){return Q(e,{configError:i(t)}),null}},load:async e=>(await N(e,`config.get`,void 0)).config,apply:Lg}),Mg=Ag({set:(e,t)=>Q(e,{composer:t}),save:async(e,t)=>{try{return await N(e,`composer.save`,t)}catch(e){return $(e),null}},load:e=>N(e,`composer.get`,void 0),apply:Rg}),Ng=jg.update,Pg=jg.receive,Fg=Mg.update,Ig=Mg.receive;function Lg(e,t){let n=Z(Y(),e).config;Q(e,{config:t}),n!==null&&ja(n.newThreads,t.newThreads)||Gg(e)}function Rg(e,t){let n=Z(Y(),e).composer;Q(e,{composer:t});let r=Y().selection;if(r===null||r.machine!==e)return;if(r.sessionId===null){n===null&&Gg(e);return}if(_g(Y().machines,e,r.sessionId)!==void 0)return;let i=to(bg(r))??Vg(t,Y().settings.provider),a=i.provider!==Y().settings.provider||i.accountId!==Y().settings.accountId;X({settings:i}),a&&Jg()}var zg=null,Bg={provider:`claude`,accountId:null,model:null,effort:null,mode:null,plan:!1};function Vg(e,t){return e===null?{...Bg,provider:t}:{provider:t,...e[t]}}function Hg(e){if(e.config===null)return Bg;let t=e.config.newThreads;return{...Vg(e.composer,t.provider),accountId:t.accountId,model:t.models[t.provider],effort:null}}function Ug(e){let t={...Y().settings,...e};X({settings:t});let n=Y().selection;if(n===null)return;n.sessionId!==null&&no(bg(n),t);let r=Z(Y(),n.machine).composer;r!==null&&Fg(n.machine,{...r,provider:t.provider,[t.provider]:{accountId:t.accountId,model:t.model,effort:t.effort,mode:t.mode,plan:t.plan}}),e.accountId!==void 0&&Jg(),n.sessionId!==null&&_g(Y().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&N(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($)}function Wg(e,t){if(Q(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Y().selection?.machine!==e)return;let n=Y().settings,r=[...[...t.claudeAccounts,...t.codexAccounts].filter(e=>e.valid).map(e=>({provider:e.provider,accountId:e.id})),...t.openCode.available?[{provider:`opencode`,accountId:null}]:[]];if(r.some(e=>e.provider===n.provider&&e.accountId===n.accountId))return;let i=r.find(e=>e.provider===n.provider),a=Y().selection?.sessionId===null?r.at(0):void 0;if(i!==void 0)Ug({accountId:i.accountId});else if(a!==void 0){let t=Z(Y(),e);Ug({...Vg(t.composer,a.provider),accountId:a.accountId,model:t.config===null?null:t.config.newThreads.models[a.provider],effort:null})}else n.accountId!==null&&Ug({accountId:null})}function Gg(e){let t=Y().selection;t?.machine===e&&t.sessionId===null&&(X({settings:Hg(Z(Y(),e))}),Kg(e))}function Kg(e){let t=Z(Y(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&Wg(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Jg()}async function qg(e){try{Wg(e,await N(e,`accounts.list`,void 0))}catch(e){$(e)}}async function Jg(){let e=Y().selection;if(e===null)return;let{provider:t,accountId:n}=Y().settings;if(t!==`opencode`&&n===null)X({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if(zg?.key!==r){let i=N(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){zg?.result===i&&(zg=null)}i.then(a,a),zg={key:r,result:i}}let i=await zg.result;if(Y().selection?.machine!==e.machine||Y().selection?.projectId!==e.projectId||Y().settings.provider!==t||Y().settings.accountId!==n)return;X({capabilities:i});let a=Y().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&Ug({effort:e});return}let o=i.models.find(e=>!e.hidden&&e.value===i.defaultModel)??i.models.find(e=>!e.hidden);if(o===void 0)return;Ug({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var Yg=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{qh as $,Za as $t,Eg as A,Vm as At,$h as B,am as Bt,Q as C,Yt as Cn,Im as Ct,Sg as D,de as Dn,Um as Dt,wg as E,Ae as En,Wm as Et,cg as F,eh as Ft,zh as G,Xa as Gt,Nh as H,em as Ht,og as I,Rm as It,Qh as J,io as Jt,Wh as K,eo as Kt,sg as L,Bm as Lt,X as M,ih as Mt,Og as N,Lm as Nt,Tg as O,rh as Ot,mg as P,zm as Pt,Xh as Q,so as Qt,rg as R,Fm as Rt,xg as S,ar as Sn,mh as St,$ as T,Re as Tn,Zm as Tt,Kh as U,vp as Ut,Uh as V,dm as Vt,Ph as W,co as Wt,Hh as X,Qa as Xt,Rh as Y,ao as Yt,Yh as Z,Ja as Zt,Z as _,di as _n,vh as _t,qg as a,N as an,wh as at,vg as b,cr as bn,hh as bt,Ig as c,fa as cn,gh as ct,_g as d,ca as dn,bh as dt,no as en,Bh as et,fg as f,Ui as fn,sh as ft,Y as g,Mi as gn,Th as gt,bg as h,ji as hn,Ch as ht,Vg as i,ja as in,ch as it,pg as j,$m as jt,Dg as k,Hm as kt,Pg as l,ma as ln,dh as lt,kg as m,Oi as mn,fh as mt,Ug as n,Ya as nn,Jh as nt,Jg as o,ua as on,Sh as ot,gg as p,Gi as pn,oh as pt,Lh as q,to as qt,Bg as r,ro as rn,J as rt,Wg as s,pa as sn,yh as st,Yg as t,oo as tn,Vh as tt,Ng as u,ha as un,xh as ut,hg as v,zr as vn,ph as vt,Cg as w,ot as wn,Gm as wt,yg as x,or as xn,_h as xt,ug as y,Mr as yn,uh as yt,ig as z,q as zt};