UNPKG

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 102 kB
"use strict";const Re=require("starknet"),ae=require("./connector-e4ffe813.cjs"),qt=require("./lastConnected-2e5632be.cjs"),an=t=>t===Re.constants.StarknetChainId.SN_MAIN?Re.constants.StarknetChainId.SN_MAIN:Re.constants.StarknetChainId.SN_SEPOLIA,cr="https://web.ready.co",on=`<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>`,cn="https://static.hydrogen.argent47.net/webwallet/iframe_whitelist_testnet.json",un="https://static.argent.net/webwallet/iframe_whitelist_mainnet.json",J=Re.constants.NetworkName,dn=J.SN_SEPOLIA;function ln(t){try{const{origin:e}=new URL(t);if(e.includes("localhost")||e.includes("127.0.0.1"))return dn;if(e.includes("hydrogen")||e.includes("sepolia-web.staging"))return J.SN_SEPOLIA;if(e.includes("staging"))return J.SN_MAIN;if(e.includes("dev")||e.includes("sepolia-web.ready.co"))return J.SN_SEPOLIA;if(e.includes("ready.co"))return J.SN_MAIN}catch{console.warn("Could not determine network from target URL, defaulting to mainnet-alpha")}return J.SN_MAIN}function fn(t){return t}function pn(t){return t.length===0?fn:t.length===1?t[0]:function(r){return t.reduce((n,s)=>s(n),r)}}function hn(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function Ie(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 pn(r)(e)}};return e}function ur(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 mn(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 yn=class lr extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,lr.prototype)}};function fr(t){let e;return{promise:new Promise((n,s)=>{let i=!1;function a(){i||(i=!0,s(new yn("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 gn=Object.freeze(Object.defineProperty({__proto__:null,isObservable:hn,map:mn,observable:Ie,observableToPromise:fr,share:ur,tap:dr},Symbol.toStringTag,{value:"Module"}));function pr(t){return Ie(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 zt(t){return Array.isArray(t)?t:[t]}function _n(t){return e=>{const r=zt(t.true).map(s=>s(e)),n=zt(t.false).map(s=>s(e));return s=>Ie(i=>{const a=t.condition(s.op)?r:n;return pr({op:s.op,links:a}).subscribe(i)})}}function hr(t){const e=Object.create(null);for(const r in t){const n=t[r];e[n]=r}return e}const $e={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};hr($e);hr($e);const vn={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 bn(t){return vn[t]??500}function mr(t){return bn(t.code)}const yr=()=>{};function gr(t,e){return new Proxy(yr,{get(n,s){if(!(typeof s!="string"||s==="then"))return gr(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 Et=t=>gr(t,[]),Rt=t=>new Proxy(yr,{get(e,r){if(!(typeof r!="string"||r==="then"))return t(r)}});function wn(t){const{path:e,error:r,config:n}=t,{code:s}=t.error,i={message:r.message,code:$e[s],data:{code:s,httpStatus:mr(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 Bt(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 xn(t,e){return Array.isArray(e)?e.map(r=>Bt(t,r)):Bt(t,e)}function kn(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}class Tn extends Error{}function Ot(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(kn(t)){const r=new Tn;for(const n in t)r[n]=t[n];return r}}}const Cn=Object.freeze(Object.defineProperty({__proto__:null,createFlatProxy:Rt,createRecursiveProxy:Et,getCauseFromUnknown:Ot,getErrorShape:wn,transformTRPCResponse:xn},Symbol.toStringTag,{value:"Module"}));function Ft(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function En(t){return t instanceof _r||t instanceof Error&&t.name==="TRPCClientError"}function Rn(t){return Ft(t)&&Ft(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}let _r=class ve extends Error{static from(e,r={}){const n=e;return En(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):Rn(n)?new ve(n.error.message,{...r,result:n}):n instanceof Error?new ve(n.message,{...r,cause:Ot(n)}):new ve("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,ve.prototype)}};function On(t){return typeof FormData>"u"?!1:t instanceof FormData}const We={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 Sn(t){const{direction:e,type:r,path:n,id:s,input:i}=t,a=[],o=[];if(t.colorMode==="ansi"){const[h,y]=We.ansi.regular[r],[k,C]=We.ansi.bold[r],A="\x1B[0m";return a.push(e==="up"?h:y,e==="up"?">>":"<<",r,e==="up"?k:C,`#${s}`,n,A),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]=We.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 Pn=({c:t=console,colorMode:e="css"})=>r=>{const n=r.input,s=On(n)?Object.fromEntries(n):n,{parts:i,args:a}=Sn({...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 Nn(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),{logger:n=Pn({c:t.console,colorMode:r})}=t;return()=>({op:s,next:i})=>Ie(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 An=class{$request({type:e,input:r,path:n,context:s={}}){return pr({links:this.links,op:{id:++this.requestId,type:e,path:n,input:r,context:s}}).pipe(ur())}requestAsPromise(e){const r=this.$request(e),{promise:n,abort:s}=fr(r);return new Promise((a,o)=>{e.signal?.addEventListener("abort",s),n.then(c=>{a(c.result.data)}).catch(c=>{o(_r.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 Ln={query:"query",mutate:"mutation",subscribe:"subscription"},In=t=>Ln[t];function $n(t){return Rt(e=>t.hasOwnProperty(e)?t[e]:e==="__untypedClient"?t:Et(({path:r,args:n})=>{const s=[e,...r],i=In(s.pop()),a=s.join(".");return t[i](a,...n)}))}function jn(t){const e=new An(t);return $n(e)}function Mn(t){if(t instanceof ce||t instanceof Error&&t.name==="TRPCError")return t;const e=new ce({code:"INTERNAL_SERVER_ERROR",cause:t});return t instanceof Error&&t.stack&&(e.stack=t.stack),e}class ce extends Error{constructor(e){const r=Ot(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 Dn(t){return"input"in t?t:{input:t,output:t}}const xe={_default:!0,input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}},ke=({shape:t})=>t;function Zn(t){return Object.assign(Object.create(null),t)}const Un=["query","mutation","subscription"];function qn(t){return"router"in t._def}const zn={_ctx:null,_errorShape:null,_meta:null,queries:{},mutations:{},subscriptions:{},errorFormatter:ke,transformer:xe},Bn=["then"];function vr(t){return function(r){const n=new Set(Object.keys(r).filter(c=>Bn.includes(c)));if(n.size>0)throw new Error("Reserved words used in `router({})` call: "+Array.from(n).join(", "));const s=Zn({});function i(c,u=""){for(const[d,h]of Object.entries(c??{})){const y=`${u}${d}`;if(qn(h)){i(h._def.procedures,`${y}.`);continue}if(s[y])throw new Error(`Duplicate key: ${y}`);s[y]=h}}i(r);const a={_config:t,router:!0,procedures:s,...zn,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 br()(o)(c)},getErrorShape(c){const{path:u,error:d}=c,{code:h}=c.error,y={message:d.message,code:$e[h],data:{code:h,httpStatus:mr(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 Fn(t){const{type:e,path:r}=t;if(!(r in t.procedures)||!t.procedures[r]?._def[e])throw new ce({code:"NOT_FOUND",message:`No "${e}"-procedure on path "${r}"`});const n=t.procedures[r];return n(t)}function br(){return function(e){const r=e._def;return function(s){return Et(({path:a,args:o})=>{if(a.length===1&&Un.includes(a[0]))return Fn({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 Wt=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 Vt(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 wr(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 Wn(){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 Ht(t){return t&&typeof t=="object"&&!Array.isArray(t)}function Vn(t){const e=async({next:r,rawInput:n,input:s})=>{let i;try{i=await t(n)}catch(o){throw new ce({code:"BAD_REQUEST",cause:o})}const a=Ht(s)&&Ht(i)?{...s,...i}:i;return r({input:a})};return e._type="input",e}function Hn(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 ce({message:"Output validation failed",code:"INTERNAL_SERVER_ERROR",cause:s})}};return e._type="output",e}const xr="middlewareMarker";function ne(t,e){const{middlewares:r=[],inputs:n,meta:s,...i}=e;return kr({...wr(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=Vt(r);return ne(e,{inputs:[r],middlewares:[Vn(n)]})},output(r){const n=Vt(r);return ne(e,{output:r,middlewares:[Hn(n)]})},meta(r){return ne(e,{meta:r})},unstable_concat(r){return ne(e,r._def)},use(r){const n="_middlewares"in r?r._middlewares:[r];return ne(e,{middlewares:n})},query(r){return Ve({...e,query:!0},r)},mutation(r){return Ve({...e,mutation:!0},r)},subscription(r){return Ve({...e,subscription:!0},r)}}}function Ve(t,e){const r=ne(t,{resolver:e,middlewares:[async function(s){const i=await e(s);return{marker:xr,ok:!0,data:i,ctx:s.ctx}}]});return Gn(r._def)}const Jn=` 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 Gn(t){const e=async function(n){if(!n||!("rawInput"in n))throw new Error(Jn);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:Mn(o),marker:xr}}},i=await s();if(!i)throw new ce({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 Yn(...t){const e=wr({},...t.map(i=>i._def.record)),r=t.reduce((i,a)=>{if(a._def._config.errorFormatter&&a._def._config.errorFormatter!==ke){if(i!==ke&&i!==a._def._config.errorFormatter)throw new Error("You seem to have several error formatters");return a._def._config.errorFormatter}return i},ke),n=t.reduce((i,a)=>{if(a._def._config.transformer&&a._def._config.transformer!==xe){if(i!==xe&&i!==a._def._config.transformer)throw new Error("You seem to have several transformers");return a._def._config.transformer}return i},xe);return vr({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 Oe{context(){return new Oe}meta(){return new Oe}create(e){return Xn()(e)}}const Qn=new Oe;function Xn(){return function(e){const r=e?.errorFormatter??ke,s={transformer:Dn(e?.transformer??xe),isDev:e?.isDev??globalThis.process?.env?.NODE_ENV!=="production",allowOutsideOfServer:e?.allowOutsideOfServer??!1,errorFormatter:r,isServer:e?.isServer??Wt,$types:Rt(i=>{throw new Error(`Tried to access "$types.${i}" which is not available at runtime`)})};if(!(e?.isServer??Wt)&&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:Wn(),router:vr(s),mergeRouters:Yn,createCallerFactory:br()}}}var tt={},je={},me={},P={};const ye=ae.getAugmentedNamespace(gn);var St={},Tr=ye;function Cr(t){return Tr.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 Jt(t){return Array.isArray(t)?t:[t]}function Kn(t){return e=>{const r=Jt(t.true).map(s=>s(e)),n=Jt(t.false).map(s=>s(e));return s=>Tr.observable(i=>{const a=t.condition(s.op)?r:n;return Cr({op:s.op,links:a}).subscribe(i)})}}St.createChain=Cr;St.splitLink=Kn;var ge={};const Er=ae.getAugmentedNamespace(Cn);var _e={};function rt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function es(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 He extends Error{constructor(){super("Unable to transform response from server")}}function ts(t,e){let r;try{r=es(t,e)}catch{throw new He}if(!r.ok&&(!rt(r.error.error)||typeof r.error.error.code!="number"))throw new He;if(r.ok&&!rt(r.result))throw new He;return r}_e.isObject=rt;_e.transformResult=ts;var rs=Er,Gt=_e;function ns(t){return t instanceof Rr||t instanceof Error&&t.name==="TRPCClientError"}function ss(t){return Gt.isObject(t)&&Gt.isObject(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}let Rr=class be extends Error{static from(e,r={}){const n=e;return ns(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):ss(n)?new be(n.error.message,{...r,result:n}):n instanceof Error?new be(n.message,{...r,cause:rs.getCauseFromUnknown(n)}):new be("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,be.prototype)}};ge.TRPCClientError=Rr;var B={},is=ge;const Yt=t=>typeof t=="function";function Or(t){if(t)return t;if(typeof window<"u"&&Yt(window.fetch))return window.fetch;if(typeof globalThis<"u"&&Yt(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function as(t){return t||(typeof window<"u"&&window.AbortController?window.AbortController:typeof globalThis<"u"&&globalThis.AbortController?globalThis.AbortController:null)}function os(t){return{url:t.url.toString().replace(/\/$/,""),fetch:t.fetch,AbortController:as(t.AbortController)}}function cs(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const us={query:"GET",mutation:"POST"};function Sr(t){return"input"in t?t.runtime.transformer.serialize(t.input):cs(t.inputs.map(e=>t.runtime.transformer.serialize(e)))}const Pr=t=>{let e=t.url+"/"+t.path;const r=[];if("inputs"in t&&r.push("batch=1"),t.type==="query"){const n=Sr(t);n!==void 0&&r.push(`input=${encodeURIComponent(JSON.stringify(n))}`)}return r.length&&(e+="?"+r.join("&")),e},Nr=t=>{if(t.type==="query")return;const e=Sr(t);return e!==void 0?JSON.stringify(e):void 0},ds=t=>Lr({...t,contentTypeHeader:"application/json",getUrl:Pr,getBody:Nr});async function Ar(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 Or(t.fetch)(r,{method:us[s],signal:e?.signal,body:n,headers:a})}function Lr(t){const e=t.AbortController?new t.AbortController:null,r={};let n=!1;return{promise:new Promise((a,o)=>{Ar(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(is.TRPCClientError.from(c,{meta:r}))})}),cancel:()=>{n||e?.abort()}}}B.fetchHTTPResponse=Ar;B.getBody=Nr;B.getFetch=Or;B.getUrl=Pr;B.httpRequest=Lr;B.jsonHttpRequester=ds;B.resolveHTTPLinkOptions=os;var Pt={},ls=ye,fs=_e,Qt=ge,nt=B;const Je=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function Ge(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 h=c[c.length-1];if(d.aborted){d.reject?.(new Error("Aborted")),u++;continue}if(t.validate(h.concat(d).map(k=>k.key))){h.push(d),u++;continue}if(h.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:Je};for(const k of c)k.batch=u;const d=(k,C)=>{const A=u.items[k];A.resolve?.(C),A.batch=null,A.reject=null,A.resolve=null},{promise:h,cancel:y}=t.fetch(u.items.map(k=>k.key),d);u.cancel=y,h.then(k=>{for(let C=0;C<k.length;C++){const A=k[C];d(C,A)}for(const C of u.items)C.reject?.(new Error("Missing result")),C.batch=null}).catch(k=>{for(const C of u.items)C.reject?.(k),C.batch=null})}}function a(o){const c={aborted:!1,key:o,batch:null,resolve:Je,reject:Je},u=new Promise((h,y)=>{c.reject=y,c.resolve=h,e||(e=[]),e.push(c)});return r||(r=setTimeout(i)),{promise:u,cancel:()=>{c.aborted=!0,c.batch?.items.every(h=>h.aborted)&&(c.batch.cancel(),c.batch=null)}}}return{load:a}}function Ir(t){return function(r){const n=nt.resolveHTTPLinkOptions(r),s=r.maxURLLength??1/0;return i=>{const a=h=>{const y=C=>{if(s===1/0)return!0;const A=C.map(F=>F.path).join(","),te=C.map(F=>F.input);return nt.getUrl({...n,runtime:i,type:h,path:A,inputs:te}).length<=s},k=t({...n,runtime:i,type:h,opts:r});return{validate:y,fetch:k}},o=Ge(a("query")),c=Ge(a("mutation")),u=Ge(a("subscription")),d={query:o,subscription:u,mutation:c};return({op:h})=>ls.observable(y=>{const k=d[h.type],{promise:C,cancel:A}=k.load(h);let te;return C.then(j=>{te=j;const F=fs.transformResult(j.json,i);if(!F.ok){y.error(Qt.TRPCClientError.from(F.error,{meta:j.meta}));return}y.next({context:j.meta,result:F.result}),y.complete()}).catch(j=>{y.error(Qt.TRPCClientError.from(j,{meta:te?.meta}))}),()=>{A()}})}}}const ps=t=>e=>{const r=e.map(a=>a.path).join(","),n=e.map(a=>a.input),{promise:s,cancel:i}=nt.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}},hs=Ir(ps);Pt.createHTTPBatchLink=Ir;Pt.httpBatchLink=hs;var Me={};Object.defineProperty(Me,"__esModule",{value:!0});var ms=ye,ys=_e,Xt=ge,$r=B;function jr(t){return e=>{const r=$r.resolveHTTPLinkOptions(e);return n=>({op:s})=>ms.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 h;return u.then(y=>{h=y.meta;const k=ys.transformResult(y.json,n);if(!k.ok){i.error(Xt.TRPCClientError.from(k.error,{meta:h}));return}i.next({context:y.meta,result:k.result}),i.complete()}).catch(y=>{i.error(Xt.TRPCClientError.from(y,{meta:h}))}),()=>{d()}})}}const gs=jr({requester:$r.jsonHttpRequester});Me.httpLink=gs;Me.httpLinkFactory=jr;var Nt={};Object.defineProperty(Nt,"__esModule",{value:!0});var Kt=ye;function _s(t){return typeof FormData>"u"?!1:t instanceof FormData}const Ye={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 vs(t){const{direction:e,type:r,path:n,id:s,input:i}=t,a=[],o=[];if(t.colorMode==="ansi"){const[h,y]=Ye.ansi.regular[r],[k,C]=Ye.ansi.bold[r],A="\x1B[0m";return a.push(e==="up"?h:y,e==="up"?">>":"<<",r,e==="up"?k:C,`#${s}`,n,A),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]=Ye.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 bs=({c:t=console,colorMode:e="css"})=>r=>{const n=r.input,s=_s(n)?Object.fromEntries(n):n,{parts:i,args:a}=vs({...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 ws(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),{logger:n=bs({c:t.console,colorMode:r})}=t;return()=>({op:s,next:i})=>Kt.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(Kt.tap({next(u){c(u)},error(u){c(u)}})).subscribe(a)})}Nt.loggerLink=ws;var De={};Object.defineProperty(De,"__esModule",{value:!0});var xs=ye,ks=_e,Mr=ge;/* istanbul ignore next -- @preserve */const Ts=t=>t===0?0:Math.min(1e3*2**t,3e4);function Cs(t){const{url:e,WebSocket:r=WebSocket,retryDelayMs:n=Ts,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,h=Zt(),y="connecting";function k(){y!=="open"||u||(u=setTimeout(()=>{u=null,a.length===1?h.send(JSON.stringify(a.pop())):h.send(JSON.stringify(a)),a=[]}))}function C(){if(d!==null||y==="closed")return;const O=n(c++);te(O)}function A(){y="connecting";const O=h;h=Zt(),j(O)}function te(O){d||(y="connecting",d=setTimeout(A,O))}function j(O){Object.values(o).some(re=>re.ws===O)||O.close()}function F(){Object.values(o).forEach(O=>{O.type==="subscription"&&O.callbacks.complete()})}function Dt(O){a.some(N=>N.id===O.op.id)||Ut(O.op,O.callbacks)}function Zt(){const O=typeof e=="function"?e():e,N=new r(O);clearTimeout(d),d=null,N.addEventListener("open",()=>{/* istanbul ignore next -- @preserve */N===h&&(c=0,y="open",s?.(),k())}),N.addEventListener("error",()=>{N===h&&C()});const re=$=>{if($.method==="reconnect"&&N===h){y==="open"&&i?.(),A();for(const E of Object.values(o))E.type==="subscription"&&Dt(E)}},Fe=$=>{const E=$.id!==null&&o[$.id];if(E){if(E.callbacks.next?.($),E.ws!==h&&N===h){const W=E.ws;E.ws=h,j(W)}"result"in $&&$.result.type==="stopped"&&N===h&&E.callbacks.complete()}};return N.addEventListener("message",({data:$})=>{const E=JSON.parse($);"method"in E?re(E):Fe(E),(N!==h||y==="closed")&&j(N)}),N.addEventListener("close",({code:$})=>{y==="open"&&i?.({code:$}),h===N&&C();for(const[E,W]of Object.entries(o))if(W.ws===N){if(y==="closed"){delete o[E],W.callbacks.complete?.();continue}W.type==="subscription"?Dt(W):(delete o[E],W.callbacks.error?.(Mr.TRPCClientError.from(new At("WebSocket closed prematurely"))))}}),N}function Ut(O,N){const{type:re,input:Fe,path:$,id:E}=O,W={id:E,method:re,params:{input:Fe,path:$}};return o[E]={ws:h,type:re,callbacks:N,op:O},a.push(W),k(),()=>{const nn=o[E]?.callbacks;delete o[E],a=a.filter(sn=>sn.id!==E),nn?.complete?.(),h.readyState===r.OPEN&&O.type==="subscription"&&(a.push({id:E,method:"subscription.stop"}),k())}}return{close:()=>{y="closed",i?.(),F(),j(h),clearTimeout(d),d=null},request:Ut,getConnection(){return h}}}class At extends Error{constructor(e){super(e),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,At.prototype)}}function Es(t){return e=>{const{client:r}=t;return({op:n})=>xs.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(h){s.error(h),d()},complete(){s.complete()},next(h){const y=ks.transformResult(h,e);if(!y.ok){s.error(Mr.TRPCClientError.from(y.error));return}s.next({result:y.result}),n.type!=="subscription"&&(d(),s.complete())}});return()=>{d()}})}}De.createWSClient=Cs;De.wsLink=Es;Object.defineProperty(P,"__esModule",{value:!0});var er=ye,Dr=St,Zr=ge,tr=Er,Te=B,Ur=Pt,Lt=Me,Rs=Nt,qr=De;class Ze{$request({type:e,input:r,path:n,context:s={}}){return Dr.createChain({links:this.links,op:{id:++this.requestId,type:e,path:n,input:r,context:s}}).pipe(er.share())}requestAsPromise(e){const r=this.$request(e),{promise:n,abort:s}=er.observableToPromise(r);return new Promise((a,o)=>{e.signal?.addEventListener("abort",s),n.then(c=>{a(c.result.data)}).catch(c=>{o(Zr.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 Os(t){return new Ze(t)}function Ss(t){return new Ze(t)}const Ps={query:"query",mutate:"mutation",subscribe:"subscription"},zr=t=>Ps[t];function Br(t){return tr.createFlatProxy(e=>t.hasOwnProperty(e)?t[e]:e==="__untypedClient"?t:tr.createRecursiveProxy(({path:r,args:n})=>{const s=[e,...r],i=zr(s.pop()),a=s.join(".");return t[i](a,...n)}))}function Ns(t){const e=new Ze(t);return Br(e)}function As(t){return t.__untypedClient}function Ls(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 Is(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 $s(t.readableStream,r,t.textDecoder)}async function $s(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 Ms(t,s):await js(t,s),e(n)}function js(t,e){return new Promise(r=>{t.on("data",e),t.on("end",r)})}async function Ms(t,e){const r=t.getReader();let n=await r.read();for(;!n.done;)e(n.value),n=await r.read()}const Ds=(t,e)=>{const r=t.AbortController?new t.AbortController:null,n=Te.fetchHTTPResponse({...t,contentTypeHeader:"application/json",batchModeHeader:"stream",getUrl:Te.getUrl,getBody:Te.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 Is({readableStream:a.body,onSingle:e,parse:c=>({json:JSON.parse(c),meta:o}),signal:r?.signal,textDecoder:t.textDecoder})});return{cancel:s,promise:i}},Zs=t=>{const e=Ls(t.opts.textDecoder);return(r,n)=>{const s=r.map(c=>c.path).join(","),i=r.map(c=>c.input),{cancel:a,promise:o}=Ds({...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}}},Us=Ur.createHTTPBatchLink(Zs),qs=t=>{if("input"in t){if(!(t.input instanceof FormData))throw new Error("Input is not FormData");return t.input}},zs=t=>{if(t.type!=="mutation")throw new Error("We only handle mutations with formdata");return Te.httpRequest({...t,getUrl(){return`${t.url}/${t.path}`},getBody:qs})},Bs=Lt.httpLinkFactory({requester:zs});P.splitLink=Dr.splitLink;P.TRPCClientError=Zr.TRPCClientError;P.getFetch=Te.getFetch;P.httpBatchLink=Ur.httpBatchLink;P.httpLink=Lt.httpLink;P.httpLinkFactory=Lt.httpLinkFactory;P.loggerLink=Rs.loggerLink;P.createWSClient=qr.createWSClient;P.wsLink=qr.wsLink;P.TRPCUntypedClient=Ze;P.clientCallTypeToProcedureType=zr;P.createTRPCClient=Ss;P.createTRPCClientProxy=Br;P.createTRPCProxyClient=Ns;P.createTRPCUntypedClient=Os;P.experimental_formDataLink=Bs;P.getUntypedClient=As;P.unstable_httpBatchStreamLink=Us;var K={},It={};function Fs(t){return t}function Ws(t){return t.length===0?Fs:t.length===1?t[0]:function(r){return t.reduce((n,s)=>s(n),r)}}function Vs(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function Hs(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 Ws(r)(e)}};return e}It.isObservable=Vs;It.observable=Hs;Object.defineProperty(K,"__esModule",{value:!0});var Fr=It;function Js(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 Gs(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 Ys(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 $t extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,$t.prototype)}}function Qs(t){let e;return{promise:new Promise((n,s)=>{let i=!1;function a(){i||(i=!0,s(new $t("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}}K.isObservable=Fr.isObservable;K.observable=Fr.observable;K.map=Gs;K.observableToPromise=Qs;K.share=Js;K.tap=Ys;var U={};Object.defineProperty(U,"__esModule",{value:!0});U.isTRPCRequestWithId=U.isTRPCRequest=U.isTRPCResponse=U.isTRPCMessage=void 0;function rr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Xs(t){return t==null}function Wr(t){return!!(rr(t)&&"trpc"in t&&rr(t.trpc))}U.isTRPCMessage=Wr;function jt(t){return Wr(t)&&"id"in t.trpc&&!Xs(t.trpc.id)}function Ks(t){return jt(t)&&("error"in t.trpc||"result"in t.trpc)}U.isTRPCResponse=Ks;function Vr(t){return jt(t)&&"method"in t.trpc}U.isTRPCRequest=Vr;function ei(t){return Vr(t)&&jt(t)}U.isTRPCRequestWithId=ei;Object.defineProperty(me,"__esModule",{value:!0});me.createBaseLink=void 0;const Qe=P,ti=K,ri=U,ni=t=>e=>({op:r})=>(0,ti.observable)(n=>{const s=[],{id:i,type:a,path:o}=r;try{const c=e.transformer.serialize(r.input),u=()=>{n.error(new Qe.TRPCClientError("Port disconnected prematurely"))};t.addCloseListener(u),s.push(()=>t.removeCloseListener(u));const d=h=>{if(!(0,ri.isTRPCResponse)(h))return;const{trpc:y}=h;if(i===y.id){if("error"in y)return n.error(Qe.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 Qe.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())}});me.createBaseLink=ni;Object.defineProperty(je,"__esModule",{value:!0});je.chromeLink=void 0;const si=me,ii=t=>(0,si.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)}});je.chromeLink=ii;var Ue={};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.windowLink=void 0;const ai=me,oi=t=>{var e;const r=new Map,n=t.window,s=(e=t.postWindow)!==null&&e!==void 0?e:n,i=(a,o,c)=>{try{n[`${a}EventListener`](o,c)}catch(u){console.error(`Failed to ${a} ${o} listener:`,u)}};return(0,ai.createBaseLink)({postMessage(a){s.postMessage(a,{targetOrigin:t.postOrigin})},addMessageListener(a){const o=c=>{a(c.data)};r.set(a,o),i("add","message",o)},removeMessageListener(a){const o=r.get(a);o&&i("remove","message",o)},addCloseListener(a){i("add","beforeunload",a)},removeCloseListener(a){i("remove","beforeunload",a)}})};Ue.windowLink=oi;var qe={},ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.TRPC_BROWSER_LOADED_EVENT=void 0;ze.TRPC_BROWSER_LOADED_EVENT="TRPC_BROWSER::POPUP_LOADED";Object.defineProperty(qe,"__esModule",{value:!0});qe.popupLink=void 0;const ci=ze,ui=me,di=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===ci.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,ui.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)}})};qe.popupLink=di;(function(t){var e=ae.commonjsGlobal&&ae.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=ae.commonjsGlobal&&ae.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(je,t),r(Ue,t),r(qe,t)})(tt);var x;(function(t){t.assertEqual=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"&&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 nr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(nr||(nr={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}},l=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"]);class H extends Error{get errors(){return this.issues}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}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 H))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)if(s.path.length>0){const i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}H.create=t=>new H(t);const li=(t,e)=>{let r;switch(t.code){case l.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case l.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case l.invalid_union:r="Invalid input";break;case l.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case l.invalid_enum_value:r=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case l.invalid_arguments:r="Invalid function arguments";break;case l.invalid_return_type:r="Invalid function return type";break;case l.invalid_date:r="Invalid date";break;case l.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 l.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==="bigint"?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 l.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 l.custom:r="Invalid input";break;case l.invalid_intersection_types:r="Intersection results could not be merged";break;case l.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case l.not_finite:r="Number must be finite";break;default:r=e.defaultError,x.assertNever(t)}return{message:r}},st=li;let fi=st;function pi(){return fi}const hi=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}};function f(t,e){const r=pi(),n=hi({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===st?void 0:st].filter(s=>!!s)});t.common.issues.push(n)}class I{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 I.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"}),we=t=>({status:"dirty",value:t}),D=t=>({status:"valid",value:t}),sr=t=>t.status==="aborted",ir=t=>t.status==="dirty",ue=t=>t.status==="valid",Se=t=>typeof Promise<"u"&&t instanceof Promise;var m;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));class z{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._ca