starknetkit
Version:
<!-- logo --> <p align="center"> <img width='300' src="https://starknetkit-website-git-blo-1541-argentlabs.vercel.app/starknetKit-logo.svg"> </p>
28 lines • 106 kB
JavaScript
"use strict";const ze=require("starknet"),le=require("./connector-391e8980.cjs"),Wt=require("./lastConnected-2e5632be.cjs"),ur="https://web.ready.co",fn=`<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2" y="2" width="28" height="28" rx="5.6" fill="black"/>
<g clip-path="url(#clip0_9_981)">
<path d="M10.5 20.9999H21.5C21.9166 20.9999 22.2736 20.7452 22.424 20.383L18.1419 16.3631L16.3739 18.0018C16.163 18.1973 15.837 18.1973 15.6261 18.0018L13.8581 16.3631L9.57603 20.383C9.72637 20.7452 10.0834 20.9999 10.5 20.9999Z" fill="white"/>
<path d="M18.8771 15.6817L22.5 19.0828V12.3239L18.8771 15.6817Z" fill="white"/>
<path d="M13.1229 15.6817L9.5 12.3239V19.0828L13.1229 15.6817Z" fill="white"/>
<path d="M22 10.9999H10C9.8752 10.9999 9.76108 11.0456 9.67348 11.1212L15.7734 16.7748C15.9012 16.8933 16.0988 16.8933 16.2266 16.7748L22.3265 11.1212C22.2389 11.0456 22.1248 10.9999 22 10.9999Z" fill="white"/>
</g>
<rect x="20" y="20" width="12" height="12" rx="2.4" fill="#FF875B"/>
<path d="M26.9611 22.6222H25.0397C24.9755 22.6222 24.924 22.675 24.9226 22.7406C24.8838 24.5841 23.9398 26.3339 22.3148 27.5732C22.2633 27.6126 22.2515 27.6865 22.2892 27.7397L23.4134 29.3279C23.4517 29.3819 23.5262 29.3941 23.5786 29.3544C24.5947 28.5845 25.4119 27.6558 26.0004 26.6264C26.5889 27.6558 27.4062 28.5845 28.4222 29.3544C28.4746 29.3941 28.5492 29.3819 28.5875 29.3279L29.7117 27.7397C29.7493 27.6865 29.7376 27.6126 29.686 27.5732C28.0611 26.3339 27.117 24.5841 27.0782 22.7406C27.0768 22.675 27.0253 22.6222 26.9611 22.6222Z" fill="white"/>
<defs>
<clipPath id="clip0_9_981">
<rect width="16" height="16" fill="white" transform="translate(8 7.99991)"/>
</clipPath>
</defs>
</svg>`,pn="https://static.hydrogen.argent47.net/webwallet/iframe_whitelist_testnet.json",hn="https://static.argent.net/webwallet/iframe_whitelist_mainnet.json",mn=t=>t===ze.constants.StarknetChainId.SN_MAIN?ze.constants.StarknetChainId.SN_MAIN:ze.constants.StarknetChainId.SN_SEPOLIA,G=ze.constants.NetworkName,yn=G.SN_SEPOLIA;function gn(t){try{const{origin:e}=new URL(t);if(e.includes("localhost")||e.includes("127.0.0.1"))return yn;if(e.includes("hydrogen")||e.includes("sepolia-web.staging"))return G.SN_SEPOLIA;if(e.includes("staging"))return G.SN_MAIN;if(e.includes("dev")||e.includes("sepolia-web.ready.co"))return G.SN_SEPOLIA;if(e.includes("ready.co"))return G.SN_MAIN}catch{console.warn("Could not determine network from target URL, defaulting to mainnet-alpha")}return G.SN_MAIN}function _n(t){return t}function vn(t){return t.length===0?_n:t.length===1?t[0]:function(r){return t.reduce((n,s)=>s(n),r)}}function bn(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function Ke(t){const e={subscribe(r){let n=null,s=!1,i=!1,a=!1;function o(){if(n===null){a=!0;return}i||(i=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){s||r.next?.(c)},error(c){s||(s=!0,r.error?.(c),o())},complete(){s||(s=!0,r.complete?.(),o())}}),a&&o(),{unsubscribe:o}},pipe(...r){return vn(r)(e)}};return e}function lr(t){return e=>{let r=0,n=null;const s=[];function i(){n||(n=e.subscribe({next(o){for(const c of s)c.next?.(o)},error(o){for(const c of s)c.error?.(o)},complete(){for(const o of s)o.complete?.()}}))}function a(){if(r===0&&n){const o=n;n=null,o.unsubscribe()}}return{subscribe(o){return r++,s.push(o),i(),{unsubscribe(){r--,a();const c=s.findIndex(u=>u===o);c>-1&&s.splice(c,1)}}}}}}function wn(t){return e=>({subscribe(r){let n=0;return e.subscribe({next(i){r.next?.(t(i,n++))},error(i){r.error?.(i)},complete(){r.complete?.()}})}})}function dr(t){return e=>({subscribe(r){return e.subscribe({next(n){t.next?.(n),r.next?.(n)},error(n){t.error?.(n),r.error?.(n)},complete(){t.complete?.(),r.complete?.()}})}})}let xn=class fr extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,fr.prototype)}};function pr(t){let e;return{promise:new Promise((n,s)=>{let i=!1;function a(){i||(i=!0,s(new xn("This operation was aborted.")),o.unsubscribe())}const o=t.subscribe({next(c){i=!0,n(c),a()},error(c){i=!0,s(c),a()},complete(){i=!0,a()}});e=a}),abort:e}}const Tn=Object.freeze(Object.defineProperty({__proto__:null,isObservable:bn,map:wn,observable:Ke,observableToPromise:pr,share:lr,tap:dr},Symbol.toStringTag,{value:"Module"}));function hr(t){return Ke(e=>{function r(s=0,i=t.op){const a=t.links[s];if(!a)throw new Error("No more links to execute - did you forget to add an ending link?");return a({op:i,next(c){return r(s+1,c)}})}return r().subscribe(e)})}function Ht(t){return Array.isArray(t)?t:[t]}function kn(t){return e=>{const r=Ht(t.true).map(s=>s(e)),n=Ht(t.false).map(s=>s(e));return s=>Ke(i=>{const a=t.condition(s.op)?r:n;return hr({op:s.op,links:a}).subscribe(i)})}}function mr(t){const e=Object.create(null);for(const r in t){const n=t[r];e[n]=r}return e}const et={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};mr(et);mr(et);const En={PARSE_ERROR:400,BAD_REQUEST:400,UNAUTHORIZED:401,NOT_FOUND:404,FORBIDDEN:403,METHOD_NOT_SUPPORTED:405,TIMEOUT:408,CONFLICT:409,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNPROCESSABLE_CONTENT:422,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501};function Cn(t){return En[t]??500}function yr(t){return Cn(t.code)}const gr=()=>{};function _r(t,e){return new Proxy(gr,{get(n,s){if(!(typeof s!="string"||s==="then"))return _r(t,[...e,s])},apply(n,s,i){const a=e[e.length-1]==="apply";return t({args:a?i.length>=2?i[1]:[]:i,path:a?e.slice(0,-1):e})}})}const Pt=t=>_r(t,[]),Nt=t=>new Proxy(gr,{get(e,r){if(!(typeof r!="string"||r==="then"))return t(r)}});function Rn(t){const{path:e,error:r,config:n}=t,{code:s}=t.error,i={message:r.message,code:et[s],data:{code:s,httpStatus:yr(r)}};return n.isDev&&typeof t.error.stack=="string"&&(i.data.stack=t.error.stack),typeof e=="string"&&(i.data.path=e),n.errorFormatter({...t,shape:i})}function Ft(t,e){return"error"in e?{...e,error:t.transformer.output.serialize(e.error)}:"data"in e.result?{...e,result:{...e.result,data:t.transformer.output.serialize(e.result.data)}}:e}function On(t,e){return Array.isArray(e)?e.map(r=>Ft(t,r)):Ft(t,e)}function Sn(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}class Pn extends Error{}function Lt(t){if(t instanceof Error)return t;const e=typeof t;if(!(e==="undefined"||e==="function"||t===null)){if(e!=="object")return new Error(String(t));if(Sn(t)){const r=new Pn;for(const n in t)r[n]=t[n];return r}}}const Nn=Object.freeze(Object.defineProperty({__proto__:null,createFlatProxy:Nt,createRecursiveProxy:Pt,getCauseFromUnknown:Lt,getErrorShape:Rn,transformTRPCResponse:On},Symbol.toStringTag,{value:"Module"}));function Jt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function Ln(t){return t instanceof vr||t instanceof Error&&t.name==="TRPCClientError"}function In(t){return Jt(t)&&Jt(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}let vr=class we extends Error{static from(e,r={}){const n=e;return Ln(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):In(n)?new we(n.error.message,{...r,result:n}):n instanceof Error?new we(n.message,{...r,cause:Lt(n)}):new we("Unknown error",{...r,cause:n})}constructor(e,r){const n=r?.cause;super(e,{cause:n}),this.meta=r?.meta,this.cause=n,this.shape=r?.result?.error,this.data=r?.result?.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,we.prototype)}};function jn(t){return typeof FormData>"u"?!1:t instanceof FormData}const lt={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1B[30;46m","\x1B[97;46m"],mutation:["\x1B[30;45m","\x1B[97;45m"],subscription:["\x1B[30;42m","\x1B[97;42m"]},bold:{query:["\x1B[1;30;46m","\x1B[1;97;46m"],mutation:["\x1B[1;30;45m","\x1B[1;97;45m"],subscription:["\x1B[1;30;42m","\x1B[1;97;42m"]}}};function An(t){const{direction:e,type:r,path:n,id:s,input:i}=t,a=[],o=[];if(t.colorMode==="ansi"){const[m,y]=lt.ansi.regular[r],[T,k]=lt.ansi.bold[r],N="\x1B[0m";return a.push(e==="up"?m:y,e==="up"?">>":"<<",r,e==="up"?T:k,`#${s}`,n,N),e==="up"?o.push({input:t.input}):o.push({input:t.input,result:"result"in t.result?t.result.result:t.result,elapsedMs:t.elapsedMs}),{parts:a,args:o}}const[c,u]=lt.css[r],d=`
background-color: #${e==="up"?c:u};
color: ${e==="up"?"black":"white"};
padding: 2px;
`;return a.push("%c",e==="up"?">>":"<<",r,`#${s}`,`%c${n}%c`,"%O"),o.push(d,`${d}; font-weight: bold;`,`${d}; font-weight: normal;`),e==="up"?o.push({input:i,context:t.context}):o.push({input:i,result:t.result,elapsedMs:t.elapsedMs,context:t.context}),{parts:a,args:o}}const $n=({c:t=console,colorMode:e="css"})=>r=>{const n=r.input,s=jn(n)?Object.fromEntries(n):n,{parts:i,args:a}=An({...r,colorMode:e,input:s}),o=r.direction==="down"&&r.result&&(r.result instanceof Error||"error"in r.result.result)?"error":"log";t[o].apply(null,[i.join(" ")].concat(a))};function Mn(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),{logger:n=$n({c:t.console,colorMode:r})}=t;return()=>({op:s,next:i})=>Ke(a=>{e({...s,direction:"up"})&&n({...s,direction:"up"});const o=Date.now();function c(u){const d=Date.now()-o;e({...s,direction:"down",result:u})&&n({...s,direction:"down",elapsedMs:d,result:u})}return i(s).pipe(dr({next(u){c(u)},error(u){c(u)}})).subscribe(a)})}let Dn=class{$request({type:e,input:r,path:n,context:s={}}){return hr({links:this.links,op:{id:++this.requestId,type:e,path:n,input:r,context:s}}).pipe(lr())}requestAsPromise(e){const r=this.$request(e),{promise:n,abort:s}=pr(r);return new Promise((a,o)=>{e.signal?.addEventListener("abort",s),n.then(c=>{a(c.result.data)}).catch(c=>{o(vr.from(c))})})}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n?.context,signal:n?.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n?.context,signal:n?.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n?.context}).subscribe({next(i){i.result.type==="started"?n.onStarted?.():i.result.type==="stopped"?n.onStopped?.():n.onData?.(i.result.data)},error(i){n.onError?.(i)},complete(){n.onComplete?.()}})}constructor(e){this.requestId=0;const r=(()=>{const n=e.transformer;return n?"input"in n?e.transformer:{input:n,output:n}:{input:{serialize:s=>s,deserialize:s=>s},output:{serialize:s=>s,deserialize:s=>s}}})();this.runtime={transformer:{serialize:n=>r.input.serialize(n),deserialize:n=>r.output.deserialize(n)},combinedTransformer:r},this.links=e.links.map(n=>n(this.runtime))}};const Zn={query:"query",mutate:"mutation",subscribe:"subscription"},Un=t=>Zn[t];function qn(t){return Nt(e=>t.hasOwnProperty(e)?t[e]:e==="__untypedClient"?t:Pt(({path:r,args:n})=>{const s=[e,...r],i=Un(s.pop()),a=s.join(".");return t[i](a,...n)}))}function Bn(t){const e=new Dn(t);return qn(e)}function Vn(t){if(t instanceof pe||t instanceof Error&&t.name==="TRPCError")return t;const e=new pe({code:"INTERNAL_SERVER_ERROR",cause:t});return t instanceof Error&&t.stack&&(e.stack=t.stack),e}class pe extends Error{constructor(e){const r=Lt(e.cause),n=e.message??r?.message??e.code;super(n,{cause:r}),this.code=e.code,this.name="TRPCError",this.cause||(this.cause=r)}}function zn(t){return"input"in t?t:{input:t,output:t}}const Ee={_default:!0,input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}},Ce=({shape:t})=>t;function Wn(t){return Object.assign(Object.create(null),t)}const Hn=["query","mutation","subscription"];function Fn(t){return"router"in t._def}const Jn={_ctx:null,_errorShape:null,_meta:null,queries:{},mutations:{},subscriptions:{},errorFormatter:Ce,transformer:Ee},Yn=["then"];function br(t){return function(r){const n=new Set(Object.keys(r).filter(c=>Yn.includes(c)));if(n.size>0)throw new Error("Reserved words used in `router({})` call: "+Array.from(n).join(", "));const s=Wn({});function i(c,u=""){for(const[d,m]of Object.entries(c??{})){const y=`${u}${d}`;if(Fn(m)){i(m._def.procedures,`${y}.`);continue}if(s[y])throw new Error(`Duplicate key: ${y}`);s[y]=m}}i(r);const a={_config:t,router:!0,procedures:s,...Jn,record:r,queries:Object.entries(s).filter(c=>c[1]._def.query).reduce((c,[u,d])=>({...c,[u]:d}),{}),mutations:Object.entries(s).filter(c=>c[1]._def.mutation).reduce((c,[u,d])=>({...c,[u]:d}),{}),subscriptions:Object.entries(s).filter(c=>c[1]._def.subscription).reduce((c,[u,d])=>({...c,[u]:d}),{})},o={...r,_def:a,createCaller(c){return wr()(o)(c)},getErrorShape(c){const{path:u,error:d}=c,{code:m}=c.error,y={message:d.message,code:et[m],data:{code:m,httpStatus:yr(d)}};return t.isDev&&typeof c.error.stack=="string"&&(y.data.stack=c.error.stack),typeof u=="string"&&(y.data.path=u),this._def._config.errorFormatter({...c,shape:y})}};return o}}function Gn(t){const{type:e,path:r}=t;if(!(r in t.procedures)||!t.procedures[r]?._def[e])throw new pe({code:"NOT_FOUND",message:`No "${e}"-procedure on path "${r}"`});const n=t.procedures[r];return n(t)}function wr(){return function(e){const r=e._def;return function(s){return Pt(({path:a,args:o})=>{if(a.length===1&&Hn.includes(a[0]))return Gn({procedures:r.procedures,path:o[0],rawInput:o[1],ctx:s,type:a[0]});const c=a.join("."),u=r.procedures[c];let d="query";return u._def.mutation?d="mutation":u._def.subscription&&(d="subscription"),u({path:c,rawInput:o[0],ctx:s,type:d})})}}}const Yt=typeof window>"u"||"Deno"in window||globalThis.process?.env?.NODE_ENV==="test"||!!globalThis.process?.env?.JEST_WORKER_ID||!!globalThis.process?.env?.VITEST_WORKER_ID;function Gt(t){const e=t;if(typeof e=="function")return e;if(typeof e.parseAsync=="function")return e.parseAsync.bind(e);if(typeof e.parse=="function")return e.parse.bind(e);if(typeof e.validateSync=="function")return e.validateSync.bind(e);if(typeof e.create=="function")return e.create.bind(e);if(typeof e.assert=="function")return r=>(e.assert(r),r);throw new Error("Could not find a validator fn")}function xr(t,...e){const r=Object.assign(Object.create(null),t);for(const n of e)for(const s in n){if(s in r&&r[s]!==n[s])throw new Error(`Duplicate key ${s}`);r[s]=n[s]}return r}function Qn(){function t(r){return{_middlewares:r,unstable_pipe(n){const s="_middlewares"in n?n._middlewares:[n];return t([...r,...s])}}}function e(r){return t([r])}return e}function Qt(t){return t&&typeof t=="object"&&!Array.isArray(t)}function Xn(t){const e=async({next:r,rawInput:n,input:s})=>{let i;try{i=await t(n)}catch(o){throw new pe({code:"BAD_REQUEST",cause:o})}const a=Qt(s)&&Qt(i)?{...s,...i}:i;return r({input:a})};return e._type="input",e}function Kn(t){const e=async({next:r})=>{const n=await r();if(!n.ok)return n;try{const s=await t(n.data);return{...n,data:s}}catch(s){throw new pe({message:"Output validation failed",code:"INTERNAL_SERVER_ERROR",cause:s})}};return e._type="output",e}const Tr="middlewareMarker";function ce(t,e){const{middlewares:r=[],inputs:n,meta:s,...i}=e;return kr({...xr(t,i),inputs:[...t.inputs,...n??[]],middlewares:[...t.middlewares,...r],meta:t.meta&&s?{...t.meta,...s}:s??t.meta})}function kr(t={}){const e={inputs:[],middlewares:[],...t};return{_def:e,input(r){const n=Gt(r);return ce(e,{inputs:[r],middlewares:[Xn(n)]})},output(r){const n=Gt(r);return ce(e,{output:r,middlewares:[Kn(n)]})},meta(r){return ce(e,{meta:r})},unstable_concat(r){return ce(e,r._def)},use(r){const n="_middlewares"in r?r._middlewares:[r];return ce(e,{middlewares:n})},query(r){return dt({...e,query:!0},r)},mutation(r){return dt({...e,mutation:!0},r)},subscription(r){return dt({...e,subscription:!0},r)}}}function dt(t,e){const r=ce(t,{resolver:e,middlewares:[async function(s){const i=await e(s);return{marker:Tr,ok:!0,data:i,ctx:s.ctx}}]});return ts(r._def)}const es=`
This is a client-only function.
If you want to call this function on the server, see https://trpc.io/docs/server/server-side-calls
`.trim();function ts(t){const e=async function(n){if(!n||!("rawInput"in n))throw new Error(es);const s=async(a={index:0,ctx:n.ctx})=>{try{const o=t.middlewares[a.index];return await o({ctx:a.ctx,type:n.type,path:n.path,rawInput:a.rawInput??n.rawInput,meta:t.meta,input:a.input,next(u){const d=u;return s({index:a.index+1,ctx:d&&"ctx"in d?{...a.ctx,...d.ctx}:a.ctx,input:d&&"input"in d?d.input:a.input,rawInput:d&&"rawInput"in d?d.rawInput:a.rawInput})}})}catch(o){return{ok:!1,error:Vn(o),marker:Tr}}},i=await s();if(!i)throw new pe({code:"INTERNAL_SERVER_ERROR",message:"No result from middlewares - did you forget to `return next()`?"});if(!i.ok)throw i.error;return i.data};return e._def=t,e.meta=t.meta,e}function rs(...t){const e=xr({},...t.map(i=>i._def.record)),r=t.reduce((i,a)=>{if(a._def._config.errorFormatter&&a._def._config.errorFormatter!==Ce){if(i!==Ce&&i!==a._def._config.errorFormatter)throw new Error("You seem to have several error formatters");return a._def._config.errorFormatter}return i},Ce),n=t.reduce((i,a)=>{if(a._def._config.transformer&&a._def._config.transformer!==Ee){if(i!==Ee&&i!==a._def._config.transformer)throw new Error("You seem to have several transformers");return a._def._config.transformer}return i},Ee);return br({errorFormatter:r,transformer:n,isDev:t.some(i=>i._def._config.isDev),allowOutsideOfServer:t.some(i=>i._def._config.allowOutsideOfServer),isServer:t.some(i=>i._def._config.isServer),$types:t[0]?._def._config.$types})(e)}class We{context(){return new We}meta(){return new We}create(e){return ss()(e)}}const ns=new We;function ss(){return function(e){const r=e?.errorFormatter??Ce,s={transformer:zn(e?.transformer??Ee),isDev:e?.isDev??globalThis.process?.env?.NODE_ENV!=="production",allowOutsideOfServer:e?.allowOutsideOfServer??!1,errorFormatter:r,isServer:e?.isServer??Yt,$types:Nt(i=>{throw new Error(`Tried to access "$types.${i}" which is not available at runtime`)})};if(!(e?.isServer??Yt)&&e?.allowOutsideOfServer!==!0)throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.");return{_config:s,procedure:kr({meta:e?.defaultMeta}),middleware:Qn(),router:br(s),mergeRouters:rs,createCallerFactory:wr()}}}var vt={},tt={},ge={},S={};const _e=le.getAugmentedNamespace(Tn);var It={},Er=_e;function Cr(t){return Er.observable(e=>{function r(s=0,i=t.op){const a=t.links[s];if(!a)throw new Error("No more links to execute - did you forget to add an ending link?");return a({op:i,next(c){return r(s+1,c)}})}return r().subscribe(e)})}function Xt(t){return Array.isArray(t)?t:[t]}function is(t){return e=>{const r=Xt(t.true).map(s=>s(e)),n=Xt(t.false).map(s=>s(e));return s=>Er.observable(i=>{const a=t.condition(s.op)?r:n;return Cr({op:s.op,links:a}).subscribe(i)})}}It.createChain=Cr;It.splitLink=is;var ve={};const Rr=le.getAugmentedNamespace(Nn);var be={};function bt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function as(t,e){if("error"in t){const n=e.transformer.deserialize(t.error);return{ok:!1,error:{...t,error:n}}}return{ok:!0,result:{...t.result,...(!t.result.type||t.result.type==="data")&&{type:"data",data:e.transformer.deserialize(t.result.data)}}}}class ft extends Error{constructor(){super("Unable to transform response from server")}}function os(t,e){let r;try{r=as(t,e)}catch{throw new ft}if(!r.ok&&(!bt(r.error.error)||typeof r.error.error.code!="number"))throw new ft;if(r.ok&&!bt(r.result))throw new ft;return r}be.isObject=bt;be.transformResult=os;var cs=Rr,Kt=be;function us(t){return t instanceof Or||t instanceof Error&&t.name==="TRPCClientError"}function ls(t){return Kt.isObject(t)&&Kt.isObject(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}let Or=class xe extends Error{static from(e,r={}){const n=e;return us(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):ls(n)?new xe(n.error.message,{...r,result:n}):n instanceof Error?new xe(n.message,{...r,cause:cs.getCauseFromUnknown(n)}):new xe("Unknown error",{...r,cause:n})}constructor(e,r){const n=r?.cause;super(e,{cause:n}),this.meta=r?.meta,this.cause=n,this.shape=r?.result?.error,this.data=r?.result?.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,xe.prototype)}};ve.TRPCClientError=Or;var W={},ds=ve;const er=t=>typeof t=="function";function Sr(t){if(t)return t;if(typeof window<"u"&&er(window.fetch))return window.fetch;if(typeof globalThis<"u"&&er(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function fs(t){return t||(typeof window<"u"&&window.AbortController?window.AbortController:typeof globalThis<"u"&&globalThis.AbortController?globalThis.AbortController:null)}function ps(t){return{url:t.url.toString().replace(/\/$/,""),fetch:t.fetch,AbortController:fs(t.AbortController)}}function hs(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const ms={query:"GET",mutation:"POST"};function Pr(t){return"input"in t?t.runtime.transformer.serialize(t.input):hs(t.inputs.map(e=>t.runtime.transformer.serialize(e)))}const Nr=t=>{let e=t.url+"/"+t.path;const r=[];if("inputs"in t&&r.push("batch=1"),t.type==="query"){const n=Pr(t);n!==void 0&&r.push(`input=${encodeURIComponent(JSON.stringify(n))}`)}return r.length&&(e+="?"+r.join("&")),e},Lr=t=>{if(t.type==="query")return;const e=Pr(t);return e!==void 0?JSON.stringify(e):void 0},ys=t=>jr({...t,contentTypeHeader:"application/json",getUrl:Nr,getBody:Lr});async function Ir(t,e){const r=t.getUrl(t),n=t.getBody(t),{type:s}=t,i=await t.headers();/* istanbul ignore if -- @preserve */if(s==="subscription")throw new Error("Subscriptions should use wsLink");const a={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.batchModeHeader?{"trpc-batch-mode":t.batchModeHeader}:{},...i};return Sr(t.fetch)(r,{method:ms[s],signal:e?.signal,body:n,headers:a})}function jr(t){const e=t.AbortController?new t.AbortController:null,r={};let n=!1;return{promise:new Promise((a,o)=>{Ir(t,e).then(c=>(r.response=c,n=!0,c.json())).then(c=>{r.responseJSON=c,a({json:c,meta:r})}).catch(c=>{n=!0,o(ds.TRPCClientError.from(c,{meta:r}))})}),cancel:()=>{n||e?.abort()}}}W.fetchHTTPResponse=Ir;W.getBody=Lr;W.getFetch=Sr;W.getUrl=Nr;W.httpRequest=jr;W.jsonHttpRequester=ys;W.resolveHTTPLinkOptions=ps;var jt={},gs=_e,_s=be,tr=ve,wt=W;const pt=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function ht(t){let e=null,r=null;const n=()=>{clearTimeout(r),r=null,e=null};function s(o){const c=[[]];let u=0;for(;;){const d=o[u];if(!d)break;const m=c[c.length-1];if(d.aborted){d.reject?.(new Error("Aborted")),u++;continue}if(t.validate(m.concat(d).map(T=>T.key))){m.push(d),u++;continue}if(m.length===0){d.reject?.(new Error("Input is too big for a single dispatch")),u++;continue}c.push([])}return c}function i(){const o=s(e);n();for(const c of o){if(!c.length)continue;const u={items:c,cancel:pt};for(const T of c)T.batch=u;const d=(T,k)=>{const N=u.items[T];N.resolve?.(k),N.batch=null,N.reject=null,N.resolve=null},{promise:m,cancel:y}=t.fetch(u.items.map(T=>T.key),d);u.cancel=y,m.then(T=>{for(let k=0;k<T.length;k++){const N=T[k];d(k,N)}for(const k of u.items)k.reject?.(new Error("Missing result")),k.batch=null}).catch(T=>{for(const k of u.items)k.reject?.(T),k.batch=null})}}function a(o){const c={aborted:!1,key:o,batch:null,resolve:pt,reject:pt},u=new Promise((m,y)=>{c.reject=y,c.resolve=m,e||(e=[]),e.push(c)});return r||(r=setTimeout(i)),{promise:u,cancel:()=>{c.aborted=!0,c.batch?.items.every(m=>m.aborted)&&(c.batch.cancel(),c.batch=null)}}}return{load:a}}function Ar(t){return function(r){const n=wt.resolveHTTPLinkOptions(r),s=r.maxURLLength??1/0;return i=>{const a=m=>{const y=k=>{if(s===1/0)return!0;const N=k.map(H=>H.path).join(","),ae=k.map(H=>H.input);return wt.getUrl({...n,runtime:i,type:m,path:N,inputs:ae}).length<=s},T=t({...n,runtime:i,type:m,opts:r});return{validate:y,fetch:T}},o=ht(a("query")),c=ht(a("mutation")),u=ht(a("subscription")),d={query:o,subscription:u,mutation:c};return({op:m})=>gs.observable(y=>{const T=d[m.type],{promise:k,cancel:N}=T.load(m);let ae;return k.then($=>{ae=$;const H=_s.transformResult($.json,i);if(!H.ok){y.error(tr.TRPCClientError.from(H.error,{meta:$.meta}));return}y.next({context:$.meta,result:H.result}),y.complete()}).catch($=>{y.error(tr.TRPCClientError.from($,{meta:ae?.meta}))}),()=>{N()}})}}}const vs=t=>e=>{const r=e.map(a=>a.path).join(","),n=e.map(a=>a.input),{promise:s,cancel:i}=wt.jsonHttpRequester({...t,path:r,inputs:n,headers(){return t.opts.headers?typeof t.opts.headers=="function"?t.opts.headers({opList:e}):t.opts.headers:{}}});return{promise:s.then(a=>(Array.isArray(a.json)?a.json:e.map(()=>a.json)).map(u=>({meta:a.meta,json:u}))),cancel:i}},bs=Ar(vs);jt.createHTTPBatchLink=Ar;jt.httpBatchLink=bs;var rt={};Object.defineProperty(rt,"__esModule",{value:!0});var ws=_e,xs=be,rr=ve,$r=W;function Mr(t){return e=>{const r=$r.resolveHTTPLinkOptions(e);return n=>({op:s})=>ws.observable(i=>{const{path:a,input:o,type:c}=s,{promise:u,cancel:d}=t.requester({...r,runtime:n,type:c,path:a,input:o,headers(){return e.headers?typeof e.headers=="function"?e.headers({op:s}):e.headers:{}}});let m;return u.then(y=>{m=y.meta;const T=xs.transformResult(y.json,n);if(!T.ok){i.error(rr.TRPCClientError.from(T.error,{meta:m}));return}i.next({context:y.meta,result:T.result}),i.complete()}).catch(y=>{i.error(rr.TRPCClientError.from(y,{meta:m}))}),()=>{d()}})}}const Ts=Mr({requester:$r.jsonHttpRequester});rt.httpLink=Ts;rt.httpLinkFactory=Mr;var At={};Object.defineProperty(At,"__esModule",{value:!0});var nr=_e;function ks(t){return typeof FormData>"u"?!1:t instanceof FormData}const mt={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1B[30;46m","\x1B[97;46m"],mutation:["\x1B[30;45m","\x1B[97;45m"],subscription:["\x1B[30;42m","\x1B[97;42m"]},bold:{query:["\x1B[1;30;46m","\x1B[1;97;46m"],mutation:["\x1B[1;30;45m","\x1B[1;97;45m"],subscription:["\x1B[1;30;42m","\x1B[1;97;42m"]}}};function Es(t){const{direction:e,type:r,path:n,id:s,input:i}=t,a=[],o=[];if(t.colorMode==="ansi"){const[m,y]=mt.ansi.regular[r],[T,k]=mt.ansi.bold[r],N="\x1B[0m";return a.push(e==="up"?m:y,e==="up"?">>":"<<",r,e==="up"?T:k,`#${s}`,n,N),e==="up"?o.push({input:t.input}):o.push({input:t.input,result:"result"in t.result?t.result.result:t.result,elapsedMs:t.elapsedMs}),{parts:a,args:o}}const[c,u]=mt.css[r],d=`
background-color: #${e==="up"?c:u};
color: ${e==="up"?"black":"white"};
padding: 2px;
`;return a.push("%c",e==="up"?">>":"<<",r,`#${s}`,`%c${n}%c`,"%O"),o.push(d,`${d}; font-weight: bold;`,`${d}; font-weight: normal;`),e==="up"?o.push({input:i,context:t.context}):o.push({input:i,result:t.result,elapsedMs:t.elapsedMs,context:t.context}),{parts:a,args:o}}const Cs=({c:t=console,colorMode:e="css"})=>r=>{const n=r.input,s=ks(n)?Object.fromEntries(n):n,{parts:i,args:a}=Es({...r,colorMode:e,input:s}),o=r.direction==="down"&&r.result&&(r.result instanceof Error||"error"in r.result.result)?"error":"log";t[o].apply(null,[i.join(" ")].concat(a))};function Rs(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),{logger:n=Cs({c:t.console,colorMode:r})}=t;return()=>({op:s,next:i})=>nr.observable(a=>{e({...s,direction:"up"})&&n({...s,direction:"up"});const o=Date.now();function c(u){const d=Date.now()-o;e({...s,direction:"down",result:u})&&n({...s,direction:"down",elapsedMs:d,result:u})}return i(s).pipe(nr.tap({next(u){c(u)},error(u){c(u)}})).subscribe(a)})}At.loggerLink=Rs;var nt={};Object.defineProperty(nt,"__esModule",{value:!0});var Os=_e,Ss=be,Dr=ve;/* istanbul ignore next -- @preserve */const Ps=t=>t===0?0:Math.min(1e3*2**t,3e4);function Ns(t){const{url:e,WebSocket:r=WebSocket,retryDelayMs:n=Ps,onOpen:s,onClose:i}=t;/* istanbul ignore next -- @preserve */if(!r)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");let a=[];const o=Object.create(null);let c=0,u=null,d=null,m=Vt(),y="connecting";function T(){y!=="open"||u||(u=setTimeout(()=>{u=null,a.length===1?m.send(JSON.stringify(a.pop())):m.send(JSON.stringify(a)),a=[]}))}function k(){if(d!==null||y==="closed")return;const R=n(c++);ae(R)}function N(){y="connecting";const R=m;m=Vt(),$(R)}function ae(R){d||(y="connecting",d=setTimeout(N,R))}function $(R){Object.values(o).some(oe=>oe.ws===R)||R.close()}function H(){Object.values(o).forEach(R=>{R.type==="subscription"&&R.callbacks.complete()})}function Bt(R){a.some(P=>P.id===R.op.id)||zt(R.op,R.callbacks)}function Vt(){const R=typeof e=="function"?e():e,P=new r(R);clearTimeout(d),d=null,P.addEventListener("open",()=>{/* istanbul ignore next -- @preserve */P===m&&(c=0,y="open",s?.(),T())}),P.addEventListener("error",()=>{P===m&&k()});const oe=j=>{if(j.method==="reconnect"&&P===m){y==="open"&&i?.(),N();for(const E of Object.values(o))E.type==="subscription"&&Bt(E)}},ut=j=>{const E=j.id!==null&&o[j.id];if(E){if(E.callbacks.next?.(j),E.ws!==m&&P===m){const F=E.ws;E.ws=m,$(F)}"result"in j&&j.result.type==="stopped"&&P===m&&E.callbacks.complete()}};return P.addEventListener("message",({data:j})=>{const E=JSON.parse(j);"method"in E?oe(E):ut(E),(P!==m||y==="closed")&&$(P)}),P.addEventListener("close",({code:j})=>{y==="open"&&i?.({code:j}),m===P&&k();for(const[E,F]of Object.entries(o))if(F.ws===P){if(y==="closed"){delete o[E],F.callbacks.complete?.();continue}F.type==="subscription"?Bt(F):(delete o[E],F.callbacks.error?.(Dr.TRPCClientError.from(new $t("WebSocket closed prematurely"))))}}),P}function zt(R,P){const{type:oe,input:ut,path:j,id:E}=R,F={id:E,method:oe,params:{input:ut,path:j}};return o[E]={ws:m,type:oe,callbacks:P,op:R},a.push(F),T(),()=>{const ln=o[E]?.callbacks;delete o[E],a=a.filter(dn=>dn.id!==E),ln?.complete?.(),m.readyState===r.OPEN&&R.type==="subscription"&&(a.push({id:E,method:"subscription.stop"}),T())}}return{close:()=>{y="closed",i?.(),H(),$(m),clearTimeout(d),d=null},request:zt,getConnection(){return m}}}class $t extends Error{constructor(e){super(e),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,$t.prototype)}}function Ls(t){return e=>{const{client:r}=t;return({op:n})=>Os.observable(s=>{const{type:i,path:a,id:o,context:c}=n,u=e.transformer.serialize(n.input),d=r.request({type:i,path:a,input:u,id:o,context:c},{error(m){s.error(m),d()},complete(){s.complete()},next(m){const y=Ss.transformResult(m,e);if(!y.ok){s.error(Dr.TRPCClientError.from(y.error));return}s.next({result:y.result}),n.type!=="subscription"&&(d(),s.complete())}});return()=>{d()}})}}nt.createWSClient=Ns;nt.wsLink=Ls;Object.defineProperty(S,"__esModule",{value:!0});var sr=_e,Zr=It,Ur=ve,ir=Rr,Re=W,qr=jt,Mt=rt,Is=At,Br=nt;class st{$request({type:e,input:r,path:n,context:s={}}){return Zr.createChain({links:this.links,op:{id:++this.requestId,type:e,path:n,input:r,context:s}}).pipe(sr.share())}requestAsPromise(e){const r=this.$request(e),{promise:n,abort:s}=sr.observableToPromise(r);return new Promise((a,o)=>{e.signal?.addEventListener("abort",s),n.then(c=>{a(c.result.data)}).catch(c=>{o(Ur.TRPCClientError.from(c))})})}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n?.context,signal:n?.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n?.context,signal:n?.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n?.context}).subscribe({next(i){i.result.type==="started"?n.onStarted?.():i.result.type==="stopped"?n.onStopped?.():n.onData?.(i.result.data)},error(i){n.onError?.(i)},complete(){n.onComplete?.()}})}constructor(e){this.requestId=0;const r=(()=>{const n=e.transformer;return n?"input"in n?e.transformer:{input:n,output:n}:{input:{serialize:s=>s,deserialize:s=>s},output:{serialize:s=>s,deserialize:s=>s}}})();this.runtime={transformer:{serialize:n=>r.input.serialize(n),deserialize:n=>r.output.deserialize(n)},combinedTransformer:r},this.links=e.links.map(n=>n(this.runtime))}}function js(t){return new st(t)}function As(t){return new st(t)}const $s={query:"query",mutate:"mutation",subscribe:"subscription"},Vr=t=>$s[t];function zr(t){return ir.createFlatProxy(e=>t.hasOwnProperty(e)?t[e]:e==="__untypedClient"?t:ir.createRecursiveProxy(({path:r,args:n})=>{const s=[e,...r],i=Vr(s.pop()),a=s.join(".");return t[i](a,...n)}))}function Ms(t){const e=new st(t);return zr(e)}function Ds(t){return t.__untypedClient}function Zs(t){if(t)return t;if(typeof window<"u"&&window.TextDecoder)return new window.TextDecoder;if(typeof globalThis<"u"&&globalThis.TextDecoder)return new globalThis.TextDecoder;throw new Error("No TextDecoder implementation found")}async function Us(t){const e=t.parse??JSON.parse,r=n=>{if(t.signal?.aborted||!n||n==="}")return;const s=n.indexOf(":"),i=n.substring(2,s-1),a=n.substring(s+1);t.onSingle(Number(i),e(a))};await qs(t.readableStream,r,t.textDecoder)}async function qs(t,e,r){let n="";const s=i=>{const o=r.decode(i).split(`
`);if(o.length===1)n+=o[0];else if(o.length>1){e(n+o[0]);for(let c=1;c<o.length-1;c++)e(o[c]);n=o[o.length-1]}};"getReader"in t?await Vs(t,s):await Bs(t,s),e(n)}function Bs(t,e){return new Promise(r=>{t.on("data",e),t.on("end",r)})}async function Vs(t,e){const r=t.getReader();let n=await r.read();for(;!n.done;)e(n.value),n=await r.read()}const zs=(t,e)=>{const r=t.AbortController?new t.AbortController:null,n=Re.fetchHTTPResponse({...t,contentTypeHeader:"application/json",batchModeHeader:"stream",getUrl:Re.getUrl,getBody:Re.getBody},r),s=()=>r?.abort(),i=n.then(async a=>{if(!a.body)throw new Error("Received response without body");const o={response:a};return Us({readableStream:a.body,onSingle:e,parse:c=>({json:JSON.parse(c),meta:o}),signal:r?.signal,textDecoder:t.textDecoder})});return{cancel:s,promise:i}},Ws=t=>{const e=Zs(t.opts.textDecoder);return(r,n)=>{const s=r.map(c=>c.path).join(","),i=r.map(c=>c.input),{cancel:a,promise:o}=zs({...t,textDecoder:e,path:s,inputs:i,headers(){return t.opts.headers?typeof t.opts.headers=="function"?t.opts.headers({opList:r}):t.opts.headers:{}}},(c,u)=>{n(c,u)});return{promise:o.then(()=>[]),cancel:a}}},Hs=qr.createHTTPBatchLink(Ws),Fs=t=>{if("input"in t){if(!(t.input instanceof FormData))throw new Error("Input is not FormData");return t.input}},Js=t=>{if(t.type!=="mutation")throw new Error("We only handle mutations with formdata");return Re.httpRequest({...t,getUrl(){return`${t.url}/${t.path}`},getBody:Fs})},Ys=Mt.httpLinkFactory({requester:Js});S.splitLink=Zr.splitLink;S.TRPCClientError=Ur.TRPCClientError;S.getFetch=Re.getFetch;S.httpBatchLink=qr.httpBatchLink;S.httpLink=Mt.httpLink;S.httpLinkFactory=Mt.httpLinkFactory;S.loggerLink=Is.loggerLink;S.createWSClient=Br.createWSClient;S.wsLink=Br.wsLink;S.TRPCUntypedClient=st;S.clientCallTypeToProcedureType=Vr;S.createTRPCClient=As;S.createTRPCClientProxy=zr;S.createTRPCProxyClient=Ms;S.createTRPCUntypedClient=js;S.experimental_formDataLink=Ys;S.getUntypedClient=Ds;S.unstable_httpBatchStreamLink=Hs;var re={},Dt={};function Gs(t){return t}function Qs(t){return t.length===0?Gs:t.length===1?t[0]:function(r){return t.reduce((n,s)=>s(n),r)}}function Xs(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function Ks(t){const e={subscribe(r){let n=null,s=!1,i=!1,a=!1;function o(){if(n===null){a=!0;return}i||(i=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){s||r.next?.(c)},error(c){s||(s=!0,r.error?.(c),o())},complete(){s||(s=!0,r.complete?.(),o())}}),a&&o(),{unsubscribe:o}},pipe(...r){return Qs(r)(e)}};return e}Dt.isObservable=Xs;Dt.observable=Ks;Object.defineProperty(re,"__esModule",{value:!0});var Wr=Dt;function ei(t){return e=>{let r=0,n=null;const s=[];function i(){n||(n=e.subscribe({next(o){for(const c of s)c.next?.(o)},error(o){for(const c of s)c.error?.(o)},complete(){for(const o of s)o.complete?.()}}))}function a(){if(r===0&&n){const o=n;n=null,o.unsubscribe()}}return{subscribe(o){return r++,s.push(o),i(),{unsubscribe(){r--,a();const c=s.findIndex(u=>u===o);c>-1&&s.splice(c,1)}}}}}}function ti(t){return e=>({subscribe(r){let n=0;return e.subscribe({next(i){r.next?.(t(i,n++))},error(i){r.error?.(i)},complete(){r.complete?.()}})}})}function ri(t){return e=>({subscribe(r){return e.subscribe({next(n){t.next?.(n),r.next?.(n)},error(n){t.error?.(n),r.error?.(n)},complete(){t.complete?.(),r.complete?.()}})}})}class Zt extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,Zt.prototype)}}function ni(t){let e;return{promise:new Promise((n,s)=>{let i=!1;function a(){i||(i=!0,s(new Zt("This operation was aborted.")),o.unsubscribe())}const o=t.subscribe({next(c){i=!0,n(c),a()},error(c){i=!0,s(c),a()},complete(){i=!0,a()}});e=a}),abort:e}}re.isObservable=Wr.isObservable;re.observable=Wr.observable;re.map=ti;re.observableToPromise=ni;re.share=ei;re.tap=ri;var q={};Object.defineProperty(q,"__esModule",{value:!0});q.isTRPCRequestWithId=q.isTRPCRequest=q.isTRPCResponse=q.isTRPCMessage=void 0;function ar(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function si(t){return t==null}function Hr(t){return!!(ar(t)&&"trpc"in t&&ar(t.trpc))}q.isTRPCMessage=Hr;function Ut(t){return Hr(t)&&"id"in t.trpc&&!si(t.trpc.id)}function ii(t){return Ut(t)&&("error"in t.trpc||"result"in t.trpc)}q.isTRPCResponse=ii;function Fr(t){return Ut(t)&&"method"in t.trpc}q.isTRPCRequest=Fr;function ai(t){return Fr(t)&&Ut(t)}q.isTRPCRequestWithId=ai;Object.defineProperty(ge,"__esModule",{value:!0});ge.createBaseLink=void 0;const yt=S,oi=re,ci=q,ui=t=>e=>({op:r})=>(0,oi.observable)(n=>{const s=[],{id:i,type:a,path:o}=r;try{const c=e.transformer.serialize(r.input),u=()=>{n.error(new yt.TRPCClientError("Port disconnected prematurely"))};t.addCloseListener(u),s.push(()=>t.removeCloseListener(u));const d=m=>{if(!(0,ci.isTRPCResponse)(m))return;const{trpc:y}=m;if(i===y.id){if("error"in y)return n.error(yt.TRPCClientError.from(y));n.next({result:Object.assign(Object.assign({},y.result),(!y.result.type||y.result.type==="data")&&{type:"data",data:e.transformer.deserialize(y.result.data)})}),(a!=="subscription"||y.result.type==="stopped")&&n.complete()}};t.addMessageListener(d),s.push(()=>t.removeMessageListener(d)),t.postMessage({trpc:{id:i,jsonrpc:void 0,method:a,params:{path:o,input:c}}})}catch(c){n.error(new yt.TRPCClientError(c instanceof Error?c.message:"Unknown error"))}return()=>{a==="subscription"&&t.postMessage({trpc:{id:i,jsonrpc:void 0,method:"subscription.stop"}}),s.forEach(c=>c())}});ge.createBaseLink=ui;Object.defineProperty(tt,"__esModule",{value:!0});tt.chromeLink=void 0;const li=ge,di=t=>(0,li.createBaseLink)({postMessage(e){t.port.postMessage(e)},addMessageListener(e){t.port.onMessage.addListener(e)},removeMessageListener(e){t.port.onMessage.removeListener(e)},addCloseListener(e){t.port.onDisconnect.addListener(e)},removeCloseListener(e){t.port.onDisconnect.removeListener(e)}});tt.chromeLink=di;var it={};Object.defineProperty(it,"__esModule",{value:!0});it.windowLink=void 0;const fi=ge,pi=t=>{var e;const r=new Map,n=t.window,s=(e=t.postWindow)!==null&&e!==void 0?e:n;return(0,fi.createBaseLink)({postMessage(i){s.postMessage(i,{targetOrigin:t.postOrigin})},addMessageListener(i){const a=o=>{i(o.data)};r.set(i,a),n.addEventListener("message",a)},removeMessageListener(i){const a=r.get(i);a&&n.removeEventListener("message",a)},addCloseListener(i){n.addEventListener("beforeunload",i)},removeCloseListener(i){n.removeEventListener("beforeunload",i)}})};it.windowLink=pi;var at={},ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.TRPC_BROWSER_LOADED_EVENT=void 0;ot.TRPC_BROWSER_LOADED_EVENT="TRPC_BROWSER::POPUP_LOADED";Object.defineProperty(at,"__esModule",{value:!0});at.popupLink=void 0;const hi=ot,mi=ge,yi=t=>{const e=new Map,r=new Set;let n=null;async function s(i){if(!n||n.closed){n=t.createPopup(),await Promise.race([new Promise(a=>{var o;try{(o=n?.addEventListener)===null||o===void 0||o.call(n,"load",a)}catch{}}),new Promise(a=>{i.addEventListener("message",o=>{o.data===hi.TRPC_BROWSER_LOADED_EVENT&&a()})}),new Promise(a=>{console.warn("Could not detect if popup loading succeeded after 15s timeout, continuing anyway"),setTimeout(a,15e3)})]);try{if(!n.addEventListener)throw new Error("popupWindow.addEventListener is not a function");n.addEventListener("beforeunload",()=>{n=null})}catch{const o=setInterval(()=>{n&&n.closed&&(n=null,r.forEach(c=>{c()}),clearInterval(o))},1e3)}}return n}return(0,mi.createBaseLink)({async postMessage(i){return(await s(t.listenWindow)).postMessage(i,{targetOrigin:t.postOrigin})},addMessageListener(i){const a=o=>{i(o.data)};e.set(i,a),t.listenWindow.addEventListener("message",a)},removeMessageListener(i){const a=e.get(i);a&&t.listenWindow.removeEventListener("message",a)},addCloseListener(i){t.listenWindow.addEventListener("beforeunload",i),r.add(i)},removeCloseListener(i){t.listenWindow.removeEventListener("beforeunload",i),r.delete(i)}})};at.popupLink=yi;(function(t){var e=le.commonjsGlobal&&le.commonjsGlobal.__createBinding||(Object.create?function(n,s,i,a){a===void 0&&(a=i);var o=Object.getOwnPropertyDescriptor(s,i);(!o||("get"in o?!s.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return s[i]}}),Object.defineProperty(n,a,o)}:function(n,s,i,a){a===void 0&&(a=i),n[a]=s[i]}),r=le.commonjsGlobal&&le.commonjsGlobal.__exportStar||function(n,s){for(var i in n)i!=="default"&&!Object.prototype.hasOwnProperty.call(s,i)&&e(s,n,i)};Object.defineProperty(t,"__esModule",{value:!0}),r(tt,t),r(it,t),r(at,t)})(vt);var x;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(const a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(x||(x={}));var xt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(xt||(xt={}));const h=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Q=t=>{switch(typeof t){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}},f=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),gi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class A extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof A))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}A.create=t=>new A(t);const he=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===h.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,x.assertNever(t)}return{message:r}};let Jr=he;function _i(t){Jr=t}function He(){return Jr}const Fe=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},vi=[];function p(t,e){const r=He(),n=Fe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===he?void 0:he].filter(s=>!!s)});t.common.issues.push(n)}class L{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return L.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return v;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const v=Object.freeze({status:"aborted"}),de=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),Tt=t=>t.status==="aborted",kt=t=>t.status==="dirty",Oe=t=>t.status==="valid",Se=t=>typeof Promise<"u"&&t instanceof Promise;function Je(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function Yr(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Privat