@sortsys/v2-client 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3019 -24
- package/dist/index.js +3 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var{create:YX,defineProperty:c8,getOwnPropertyDescriptor:WX,getOwnPropertyNames:u8,getPrototypeOf:HX}=Object,VX=Object.prototype.hasOwnProperty,y=(X,B)=>function(){return B||(0,X[u8(X)[0]])((B={exports:{}}).exports,B),B.exports},DX=(X,B,Z,Q)=>{if(B&&typeof B==="object"||typeof B==="function"){for(var G=u8(B),Y=0,W=G.length,H;Y<W;Y++)if(H=G[Y],!VX.call(X,H)&&H!==Z)c8(X,H,{get:((V)=>B[V]).bind(null,H),enumerable:!(Q=WX(B,H))||Q.enumerable})}return X},T=(X,B,Z)=>(Z=X!=null?YX(HX(X)):{},DX(B||!X||!X.__esModule?c8(Z,"default",{value:X,enumerable:!0}):Z,X)),p8=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(X,B){function Z(Q){return B.exports=Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(G){return typeof G}:function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},B.exports.__esModule=!0,B.exports.default=B.exports,Z(Q)}B.exports=Z,B.exports.__esModule=!0,B.exports.default=B.exports}}),KX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(X,B){var Z=p8().default;function Q(G,Y){if(Z(G)!="object"||!G)return G;var W=G[Symbol.toPrimitive];if(W!==void 0){var H=W.call(G,Y||"default");if(Z(H)!="object")return H;throw TypeError("@@toPrimitive must return a primitive value.")}return(Y==="string"?String:Number)(G)}B.exports=Q,B.exports.__esModule=!0,B.exports.default=B.exports}}),AX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(X,B){var Z=p8().default,Q=KX();function G(Y){var W=Q(Y,"string");return Z(W)=="symbol"?W:W+""}B.exports=G,B.exports.__esModule=!0,B.exports.default=B.exports}}),v=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(X,B){var Z=AX();function Q(G,Y,W){return(Y=Z(Y))in G?Object.defineProperty(G,Y,{value:W,enumerable:!0,configurable:!0,writable:!0}):G[Y]=W,G}B.exports=Q,B.exports.__esModule=!0,B.exports.default=B.exports}}),R=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(X,B){var Z=v();function Q(Y,W){var H=Object.keys(Y);if(Object.getOwnPropertySymbols){var V=Object.getOwnPropertySymbols(Y);W&&(V=V.filter(function(D){return Object.getOwnPropertyDescriptor(Y,D).enumerable})),H.push.apply(H,V)}return H}function G(Y){for(var W=1;W<arguments.length;W++){var H=arguments[W]!=null?arguments[W]:{};W%2?Q(Object(H),!0).forEach(function(V){Z(Y,V,H[V])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(H)):Q(Object(H)).forEach(function(V){Object.defineProperty(Y,V,Object.getOwnPropertyDescriptor(H,V))})}return Y}B.exports=G,B.exports.__esModule=!0,B.exports.default=B.exports}});function m(X){let B={subscribe(Z){let Q=null,G=!1,Y=!1,W=!1;function H(){if(Q===null){W=!0;return}if(Y)return;if(Y=!0,typeof Q==="function")Q();else if(Q)Q.unsubscribe()}if(Q=X({next(V){var D;if(G)return;(D=Z.next)===null||D===void 0||D.call(Z,V)},error(V){var D;if(G)return;G=!0,(D=Z.error)===null||D===void 0||D.call(Z,V),H()},complete(){var V;if(G)return;G=!0,(V=Z.complete)===null||V===void 0||V.call(Z),H()}}),W)H();return{unsubscribe:H}},pipe(...Z){return Z.reduce(UX,B)}};return B}function UX(X,B){return B(X)}function V8(X){let B=new AbortController;return new Promise((Q,G)=>{let Y=!1;function W(){if(Y)return;Y=!0,H.unsubscribe()}B.signal.addEventListener("abort",()=>{G(B.signal.reason)});let H=X.subscribe({next(V){Y=!0,Q(V),W()},error(V){G(V)},complete(){B.abort(),W()}})})}function D8(X){return(B)=>{let Z=0,Q=null,G=[];function Y(){if(Q)return;Q=B.subscribe({next(H){for(let D of G){var V;(V=D.next)===null||V===void 0||V.call(D,H)}},error(H){for(let D of G){var V;(V=D.error)===null||V===void 0||V.call(D,H)}},complete(){for(let V of G){var H;(H=V.complete)===null||H===void 0||H.call(V)}}})}function W(){if(Z===0&&Q){let H=Q;Q=null,H.unsubscribe()}}return m((H)=>{return Z++,G.push(H),Y(),{unsubscribe(){Z--,W();let V=G.findIndex((D)=>D===H);if(V>-1)G.splice(V,1)}}})}}var SB=Symbol();function T0(X){let B=X,Z=[],Q=(W)=>{if(B!==void 0)W.next(B);Z.push(W)},G=(W)=>{Z.splice(Z.indexOf(W),1)},Y=m((W)=>{return Q(W),()=>{G(W)}});return Y.next=(W)=>{if(B===W)return;B=W;for(let H of Z)H.next(W)},Y.get=()=>B,Y}function n8(X){return m((B)=>{function Z(G=0,Y=X.op){let W=X.links[G];if(!W)throw Error("No more links to execute - did you forget to add an ending link?");return W({op:Y,next(V){return Z(G+1,V)}})}return Z().subscribe(B)})}function b(X){return!!X&&!Array.isArray(X)&&typeof X==="object"}function E0(){return Object.create(null)}var B0={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603,UNAUTHORIZED:-32001,PAYMENT_REQUIRED:-32002,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNSUPPORTED_MEDIA_TYPE:-32015,UNPROCESSABLE_CONTENT:-32022,PRECONDITION_REQUIRED:-32028,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};var i8=[B0.BAD_GATEWAY,B0.SERVICE_UNAVAILABLE,B0.GATEWAY_TIMEOUT,B0.INTERNAL_SERVER_ERROR];var{create:zX,defineProperty:o8,getOwnPropertyDescriptor:NX,getOwnPropertyNames:s8,getPrototypeOf:FX}=Object,JX=Object.prototype.hasOwnProperty,U0=(X,B)=>function(){return B||(0,X[s8(X)[0]])((B={exports:{}}).exports,B),B.exports},MX=(X,B,Z,Q)=>{if(B&&typeof B==="object"||typeof B==="function"){for(var G=s8(B),Y=0,W=G.length,H;Y<W;Y++)if(H=G[Y],!JX.call(X,H)&&H!==Z)o8(X,H,{get:((V)=>B[V]).bind(null,H),enumerable:!(Q=NX(B,H))||Q.enumerable})}return X},q0=(X,B,Z)=>(Z=X!=null?zX(FX(X)):{},MX(B||!X||!X.__esModule?o8(Z,"default",{value:X,enumerable:!0}):Z,X)),t8=()=>{},a8=(X)=>{if(Object.freeze)Object.freeze(X)};function r8(X,B,Z){var Q;let G=B.join(".");return(Q=Z[G])!==null&&Q!==void 0||(Z[G]=new Proxy(t8,{get(Y,W){if(typeof W!=="string"||W==="then")return;return r8(X,[...B,W],Z)},apply(Y,W,H){let V=B[B.length-1],D={args:H,path:B};if(V==="call")D={args:H.length>=2?[H[1]]:[],path:B.slice(0,-1)};else if(V==="apply")D={args:H.length>=2?H[1]:[],path:B.slice(0,-1)};return a8(D.args),a8(D.path),X(D)}})),Z[G]}var x0=(X)=>r8(X,[],E0()),K8=(X)=>{return new Proxy(t8,{get(B,Z){if(Z==="then")return;return X(Z)}})};var e8=U0({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(X,B){function Z(Q){return B.exports=Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(G){return typeof G}:function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},B.exports.__esModule=!0,B.exports.default=B.exports,Z(Q)}B.exports=Z,B.exports.__esModule=!0,B.exports.default=B.exports}}),LX=U0({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(X,B){var Z=e8().default;function Q(G,Y){if(Z(G)!="object"||!G)return G;var W=G[Symbol.toPrimitive];if(W!==void 0){var H=W.call(G,Y||"default");if(Z(H)!="object")return H;throw TypeError("@@toPrimitive must return a primitive value.")}return(Y==="string"?String:Number)(G)}B.exports=Q,B.exports.__esModule=!0,B.exports.default=B.exports}}),IX=U0({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(X,B){var Z=e8().default,Q=LX();function G(Y){var W=Q(Y,"string");return Z(W)=="symbol"?W:W+""}B.exports=G,B.exports.__esModule=!0,B.exports.default=B.exports}}),A8=U0({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(X,B){var Z=IX();function Q(G,Y,W){return(Y=Z(Y))in G?Object.defineProperty(G,Y,{value:W,enumerable:!0,configurable:!0,writable:!0}):G[Y]=W,G}B.exports=Q,B.exports.__esModule=!0,B.exports.default=B.exports}}),C0=U0({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(X,B){var Z=A8();function Q(Y,W){var H=Object.keys(Y);if(Object.getOwnPropertySymbols){var V=Object.getOwnPropertySymbols(Y);W&&(V=V.filter(function(D){return Object.getOwnPropertyDescriptor(Y,D).enumerable})),H.push.apply(H,V)}return H}function G(Y){for(var W=1;W<arguments.length;W++){var H=arguments[W]!=null?arguments[W]:{};W%2?Q(Object(H),!0).forEach(function(V){Z(Y,V,H[V])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(H)):Q(Object(H)).forEach(function(V){Object.defineProperty(Y,V,Object.getOwnPropertyDescriptor(H,V))})}return Y}B.exports=G,B.exports.__esModule=!0,B.exports.default=B.exports}}),iB=q0(C0(),1);var tB=q0(A8(),1);var P0=q0(C0(),1);function EX(X,B){if("error"in X){let Q=B.deserialize(X.error);return{ok:!1,error:(0,P0.default)((0,P0.default)({},X),{},{error:Q})}}return{ok:!0,result:(0,P0.default)((0,P0.default)({},X.result),(!X.result.type||X.result.type==="data")&&{type:"data",data:B.deserialize(X.result.data)})}}var U8=class extends Error{constructor(){super("Unable to transform response from server")}};function q8(X,B){let Z;try{Z=EX(X,B)}catch(Q){throw new U8}if(!Z.ok&&(!b(Z.error.error)||typeof Z.error.error.code!=="number"))throw new U8;if(Z.ok&&!b(Z.result))throw new U8;return Z}var rB=q0(C0(),1);var eB=Symbol();var R0=T(v(),1),Z0=T(R(),1);function X1(X){return X instanceof f}function RX(X){return b(X)&&b(X.error)&&typeof X.error.code==="number"&&typeof X.error.message==="string"}function OX(X,B){if(typeof X==="string")return X;if(b(X)&&typeof X.message==="string")return X.message;return B}var f=class X extends Error{constructor(B,Z){var Q,G;let Y=Z===null||Z===void 0?void 0:Z.cause;super(B,{cause:Y});(0,R0.default)(this,"cause",void 0),(0,R0.default)(this,"shape",void 0),(0,R0.default)(this,"data",void 0),(0,R0.default)(this,"meta",void 0),this.meta=Z===null||Z===void 0?void 0:Z.meta,this.cause=Y,this.shape=Z===null||Z===void 0||(Q=Z.result)===null||Q===void 0?void 0:Q.error,this.data=Z===null||Z===void 0||(G=Z.result)===null||G===void 0?void 0:G.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,X.prototype)}static from(B,Z={}){let Q=B;if(X1(Q)){if(Z.meta)Q.meta=(0,Z0.default)((0,Z0.default)({},Q.meta),Z.meta);return Q}if(RX(Q))return new X(Q.error.message,(0,Z0.default)((0,Z0.default)({},Z),{},{result:Q,cause:Z.cause}));return new X(OX(Q,"Unknown error"),(0,Z0.default)((0,Z0.default)({},Z),{},{cause:Q}))}};function O0(X){let B=X;if(!B)return{input:{serialize:(Z)=>Z,deserialize:(Z)=>Z},output:{serialize:(Z)=>Z,deserialize:(Z)=>Z}};if("input"in B)return B;return{input:B,output:B}}var B1=(X)=>typeof X==="function";function Z1(X){if(X)return X;if(typeof window<"u"&&B1(window.fetch))return window.fetch;if(typeof globalThis<"u"&&B1(globalThis.fetch))return globalThis.fetch;throw Error("No fetch implementation found")}var z0=T(R(),1);function k0(X){return{url:X.url.toString(),fetch:X.fetch,transformer:O0(X.transformer),methodOverride:X.methodOverride}}function kX(X){let B={};for(let Z=0;Z<X.length;Z++){let Q=X[Z];B[Z]=Q}return B}var $X={query:"GET",mutation:"POST",subscription:"PATCH"};function Q1(X){return"input"in X?X.transformer.input.serialize(X.input):kX(X.inputs.map((B)=>X.transformer.input.serialize(B)))}var N0=(X)=>{let B=X.url.split("?"),Q=B[0].replace(/\/$/,"")+"/"+X.path,G=[];if(B[1])G.push(B[1]);if("inputs"in X)G.push("batch=1");if(X.type==="query"||X.type==="subscription"){let Y=Q1(X);if(Y!==void 0&&X.methodOverride!=="POST")G.push(`input=${encodeURIComponent(JSON.stringify(Y))}`)}if(G.length)Q+="?"+G.join("&");return Q},G1=(X)=>{if(X.type==="query"&&X.methodOverride!=="POST")return;let B=Q1(X);return B!==void 0?JSON.stringify(B):void 0},z8=(X)=>{return W1((0,z0.default)((0,z0.default)({},X),{},{contentTypeHeader:"application/json",getUrl:N0,getBody:G1}))},fX=class extends Error{constructor(){super("AbortError");this.name="AbortError",this.message="AbortError"}},SX=(X)=>{var B;if(!(X===null||X===void 0?void 0:X.aborted))return;if((B=X.throwIfAborted)===null||B===void 0||B.call(X),typeof DOMException<"u")throw new DOMException("AbortError","AbortError");throw new fX};async function Y1(X){var B,Z;SX(X.signal);let Q=X.getUrl(X),G=X.getBody(X),Y=(B=X.methodOverride)!==null&&B!==void 0?B:$X[X.type],W=await(async()=>{let V=await X.headers();if(Symbol.iterator in V)return Object.fromEntries(V);return V})(),H=(0,z0.default)((0,z0.default)((0,z0.default)({},X.contentTypeHeader&&Y!=="GET"?{"content-type":X.contentTypeHeader}:{}),X.trpcAcceptHeader?{[(Z=X.trpcAcceptHeaderKey)!==null&&Z!==void 0?Z:"trpc-accept"]:X.trpcAcceptHeader}:void 0),W);return Z1(X.fetch)(Q,{method:Y,signal:X.signal,body:G,headers:H})}async function W1(X){let B={},Z=await Y1(X);B.response=Z;let Q=await Z.json();return B.responseJSON=Q,{json:Q,meta:B}}var V7=T(R(),1);var H1=()=>{throw Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function N8(X){let B=null,Z=null,Q=()=>{clearTimeout(Z),Z=null,B=null};function G(H){let V=[[]],D=0;while(!0){let F=H[D];if(!F)break;let K=V[V.length-1];if(F.aborted){var z;(z=F.reject)===null||z===void 0||z.call(F,Error("Aborted")),D++;continue}if(X.validate(K.concat(F).map((U)=>U.key))){K.push(F),D++;continue}if(K.length===0){var q;(q=F.reject)===null||q===void 0||q.call(F,Error("Input is too big for a single dispatch")),D++;continue}V.push([])}return V}function Y(){let H=G(B);Q();for(let V of H){if(!V.length)continue;let D={items:V};for(let q of V)q.batch=D;X.fetch(D.items.map((q)=>q.key)).then(async(q)=>{await Promise.all(q.map(async(K,N)=>{let U=D.items[N];try{var A;let J=await Promise.resolve(K);(A=U.resolve)===null||A===void 0||A.call(U,J)}catch(J){var M;(M=U.reject)===null||M===void 0||M.call(U,J)}U.batch=null,U.reject=null,U.resolve=null}));for(let K of D.items){var F;(F=K.reject)===null||F===void 0||F.call(K,Error("Missing result")),K.batch=null}}).catch((q)=>{for(let K of D.items){var F;(F=K.reject)===null||F===void 0||F.call(K,q),K.batch=null}})}}function W(H){var V;let D={aborted:!1,key:H,batch:null,resolve:H1,reject:H1},z=new Promise((q,F)=>{var K;D.reject=F,D.resolve=q,(K=B)!==null&&K!==void 0||(B=[]),B.push(D)});return(V=Z)!==null&&V!==void 0||(Z=setTimeout(Y)),z}return{load:W}}function V1(...X){let B=new AbortController,Z=X.length,Q=0,G=()=>{if(++Q===Z)B.abort()};for(let Y of X)if(Y===null||Y===void 0?void 0:Y.aborted)G();else Y===null||Y===void 0||Y.addEventListener("abort",G,{once:!0});return B.signal}var $0=T(R(),1);function F8(X){var B,Z;let Q=k0(X),G=(B=X.maxURLLength)!==null&&B!==void 0?B:1/0,Y=(Z=X.maxItems)!==null&&Z!==void 0?Z:1/0;return()=>{let W=(z)=>{return{validate(q){if(G===1/0&&Y===1/0)return!0;if(q.length>Y)return!1;let F=q.map((U)=>U.path).join(","),K=q.map((U)=>U.input);return N0((0,$0.default)((0,$0.default)({},Q),{},{type:z,path:F,inputs:K,signal:null})).length<=G},async fetch(q){let F=q.map((J)=>J.path).join(","),K=q.map((J)=>J.input),N=V1(...q.map((J)=>J.signal)),U=await z8((0,$0.default)((0,$0.default)({},Q),{},{path:F,inputs:K,type:z,headers(){if(!X.headers)return{};if(typeof X.headers==="function")return X.headers({opList:q});return X.headers},signal:N}));return(Array.isArray(U.json)?U.json:q.map(()=>U.json)).map((J)=>({meta:U.meta,json:J}))}}},H=N8(W("query")),V=N8(W("mutation")),D={query:H,mutation:V};return({op:z})=>{return m((q)=>{if(z.type==="subscription")throw Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");let K=D[z.type].load(z),N=void 0;return K.then((U)=>{N=U;let A=q8(U.json,Q.transformer.output);if(!A.ok){q.error(f.from(A.error,{meta:U.meta}));return}q.next({context:U.meta,result:A.result}),q.complete()}).catch((U)=>{q.error(f.from(U,{meta:N===null||N===void 0?void 0:N.meta}))}),()=>{}})}}}var J7=T(R(),1);var J8=(X,...B)=>{return typeof X==="function"?X(...B):X},E7=T(v(),1);function jX(){let X,B;return{promise:new Promise((Q,G)=>{X=Q,B=G}),resolve:X,reject:B}}async function yX(X){let B=await J8(X.url);if(!X.connectionParams)return B;let Q=`${B.includes("?")?"&":"?"}connectionParams=1`;return B+Q}async function gX(X,B){let Z={method:"connectionParams",data:await J8(X)};return B.encode(Z)}var x7=T(v(),1);var u=T(v(),1);function hX(X){let{promise:B,resolve:Z,reject:Q}=jX();return X.addEventListener("open",()=>{X.removeEventListener("error",Q),Z()}),X.addEventListener("error",Q),B}function vX(X,{intervalMs:B,pongTimeoutMs:Z}){let Q,G;function Y(){Q=setTimeout(()=>{X.send("PING"),G=setTimeout(()=>{X.close()},Z)},B)}function W(){clearTimeout(Q),Y()}function H(){clearTimeout(G),W()}X.addEventListener("open",Y),X.addEventListener("message",({data:V})=>{if(clearTimeout(Q),Y(),V==="PONG")H()}),X.addEventListener("close",()=>{clearTimeout(Q),clearTimeout(G)})}var mX=class X{constructor(B){var Z;if((0,u.default)(this,"id",++X.connectCount),(0,u.default)(this,"WebSocketPonyfill",void 0),(0,u.default)(this,"urlOptions",void 0),(0,u.default)(this,"keepAliveOpts",void 0),(0,u.default)(this,"encoder",void 0),(0,u.default)(this,"wsObservable",T0(null)),(0,u.default)(this,"openPromise",null),this.WebSocketPonyfill=(Z=B.WebSocketPonyfill)!==null&&Z!==void 0?Z:WebSocket,!this.WebSocketPonyfill)throw 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");this.urlOptions=B.urlOptions,this.keepAliveOpts=B.keepAlive,this.encoder=B.encoder}get ws(){return this.wsObservable.get()}set ws(B){this.wsObservable.next(B)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var B=this;if(B.openPromise)return B.openPromise;B.id=++X.connectCount;let Z=yX(B.urlOptions).then((Q)=>new B.WebSocketPonyfill(Q));B.openPromise=Z.then(async(Q)=>{if(B.ws=Q,Q.binaryType="arraybuffer",Q.addEventListener("message",function({data:G}){if(G==="PING")this.send("PONG")}),B.keepAliveOpts.enabled)vX(Q,B.keepAliveOpts);if(Q.addEventListener("close",()=>{if(B.ws===Q)B.ws=null}),await hX(Q),B.urlOptions.connectionParams)Q.send(await gX(B.urlOptions.connectionParams,B.encoder))});try{await B.openPromise}finally{B.openPromise=null}}async close(){var B=this;try{await B.openPromise}finally{var Z;(Z=B.ws)===null||Z===void 0||Z.close()}}};(0,u.default)(mX,"connectCount",0);var C7=T(v(),1),P7=T(R(),1);var M8=T(v(),1),D1=T(R(),1),dX=class{constructor(X){(0,M8.default)(this,"links",void 0),(0,M8.default)(this,"runtime",void 0),(0,M8.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=X.links.map((B)=>B(this.runtime))}$request(X){var B;return n8({links:this.links,op:(0,D1.default)((0,D1.default)({},X),{},{context:(B=X.context)!==null&&B!==void 0?B:{},id:++this.requestId})}).pipe(D8())}async requestAsPromise(X){var B=this;try{let Z=B.$request(X);return(await V8(Z)).result.data}catch(Z){throw f.from(Z)}}query(X,B,Z){return this.requestAsPromise({type:"query",path:X,input:B,context:Z===null||Z===void 0?void 0:Z.context,signal:Z===null||Z===void 0?void 0:Z.signal})}mutation(X,B,Z){return this.requestAsPromise({type:"mutation",path:X,input:B,context:Z===null||Z===void 0?void 0:Z.context,signal:Z===null||Z===void 0?void 0:Z.signal})}subscription(X,B,Z){return this.$request({type:"subscription",path:X,input:B,context:Z.context,signal:Z.signal}).subscribe({next(G){switch(G.result.type){case"state":{var Y;(Y=Z.onConnectionStateChange)===null||Y===void 0||Y.call(Z,G.result);break}case"started":{var W;(W=Z.onStarted)===null||W===void 0||W.call(Z,{context:G.context});break}case"stopped":{var H;(H=Z.onStopped)===null||H===void 0||H.call(Z);break}case"data":case void 0:{var V;(V=Z.onData)===null||V===void 0||V.call(Z,G.result.data);break}}},error(G){var Y;(Y=Z.onError)===null||Y===void 0||Y.call(Z,G)},complete(){var G;(G=Z.onComplete)===null||G===void 0||G.call(Z)}})}};var _X=Symbol.for("trpc_untypedClient"),bX={query:"query",mutate:"mutation",subscribe:"subscription"},lX=(X)=>{return bX[X]};function cX(X){let B=x0(({path:Z,args:Q})=>{let G=[...Z],Y=lX(G.pop()),W=G.join(".");return X[Y](W,...Q)});return K8((Z)=>{if(Z===_X)return X;return B[Z]})}function K1(X){let B=new dX(X);return cX(B)}var BQ=T(R(),1);var ZQ=T(R(),1);var uX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(X,B){function Z(G){var Y,W,H,V=2;for(typeof Symbol<"u"&&(W=Symbol.asyncIterator,H=Symbol.iterator);V--;){if(W&&(Y=G[W])!=null)return Y.call(G);if(H&&(Y=G[H])!=null)return new Q(Y.call(G));W="@@asyncIterator",H="@@iterator"}throw TypeError("Object is not async iterable")}function Q(G){function Y(W){if(Object(W)!==W)return Promise.reject(TypeError(W+" is not an object."));var H=W.done;return Promise.resolve(W.value).then(function(V){return{value:V,done:H}})}return Q=function(H){this.s=H,this.n=H.next},Q.prototype={s:null,n:null,next:function(){return Y(this.n.apply(this.s,arguments))},return:function(H){var V=this.s.return;return V===void 0?Promise.resolve({value:H,done:!0}):Y(V.apply(this.s,arguments))},throw:function(H){var V=this.s.return;return V===void 0?Promise.reject(H):Y(V.apply(this.s,arguments))}},new Q(G)}B.exports=Z,B.exports.__esModule=!0,B.exports.default=B.exports}}),QQ=T(uX(),1);var GQ=T(R(),1);var pX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(X,B){function Z(){var Q=typeof SuppressedError=="function"?SuppressedError:function(H,V){var D=Error();return D.name="SuppressedError",D.error=H,D.suppressed=V,D},G={},Y=[];function W(H,V){if(V!=null){if(Object(V)!==V)throw TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(H)var D=V[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(D===void 0&&(D=V[Symbol.dispose||Symbol.for("Symbol.dispose")],H))var z=D;if(typeof D!="function")throw TypeError("Object is not disposable.");z&&(D=function(){try{z.call(V)}catch(F){return Promise.reject(F)}}),Y.push({v:V,d:D,a:H})}else H&&Y.push({d:V,a:H});return V}return{e:G,u:W.bind(null,!1),a:W.bind(null,!0),d:function(){var V,D=this.e,z=0;function q(){for(;V=Y.pop();)try{if(!V.a&&z===1)return z=0,Y.push(V),Promise.resolve().then(q);if(V.d){var K=V.d.call(V.v);if(V.a)return z|=2,Promise.resolve(K).then(q,F)}else z|=1}catch(N){return F(N)}if(z===1)return D!==G?Promise.reject(D):Promise.resolve();if(D!==G)throw D}function F(K){return D=D!==G?new Q(K,D):K,q()}return q()}}}B.exports=Z,B.exports.__esModule=!0,B.exports.default=B.exports}}),A1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(X,B){function Z(Q,G){this.v=Q,this.k=G}B.exports=Z,B.exports.__esModule=!0,B.exports.default=B.exports}}),nX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(X,B){var Z=A1();function Q(G){return new Z(G,0)}B.exports=Q,B.exports.__esModule=!0,B.exports.default=B.exports}}),iX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(X,B){var Z=A1();function Q(Y){return function(){return new G(Y.apply(this,arguments))}}function G(Y){var W,H;function V(z,q){try{var F=Y[z](q),K=F.value,N=K instanceof Z;Promise.resolve(N?K.v:K).then(function(U){if(N){var A=z==="return"?"return":"next";if(!K.k||U.done)return V(A,U);U=Y[A](U).value}D(F.done?"return":"normal",U)},function(U){V("throw",U)})}catch(U){D("throw",U)}}function D(z,q){switch(z){case"return":W.resolve({value:q,done:!0});break;case"throw":W.reject(q);break;default:W.resolve({value:q,done:!1})}(W=W.next)?V(W.key,W.arg):H=null}this._invoke=function(z,q){return new Promise(function(F,K){var N={key:z,arg:q,resolve:F,reject:K,next:null};H?H=H.next=N:(W=H=N,V(z,q))})},typeof Y.return!="function"&&(this.return=void 0)}G.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},G.prototype.next=function(Y){return this._invoke("next",Y)},G.prototype.throw=function(Y){return this._invoke("throw",Y)},G.prototype.return=function(Y){return this._invoke("return",Y)},B.exports=Q,B.exports.__esModule=!0,B.exports.default=B.exports}}),YQ=T(pX(),1),WQ=T(nX(),1),HQ=T(iX(),1),VQ=T(R(),1);class L8{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(X,B){this.keyToValue.set(X,B),this.valueToKey.set(B,X)}getByKey(X){return this.keyToValue.get(X)}getByValue(X){return this.valueToKey.get(X)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class F0{constructor(X){this.generateIdentifier=X,this.kv=new L8}register(X,B){if(this.kv.getByValue(X))return;if(!B)B=this.generateIdentifier(X);this.kv.set(B,X)}clear(){this.kv.clear()}getIdentifier(X){return this.kv.getByValue(X)}getValue(X){return this.kv.getByKey(X)}}class I8 extends F0{constructor(){super((X)=>X.name);this.classToAllowedProps=new Map}register(X,B){if(typeof B==="object"){if(B.allowProps)this.classToAllowedProps.set(X,B.allowProps);super.register(X,B.identifier)}else super.register(X,B)}getAllowedProps(X){return this.classToAllowedProps.get(X)}}function aX(X){if("values"in Object)return Object.values(X);let B=[];for(let Z in X)if(X.hasOwnProperty(Z))B.push(X[Z]);return B}function U1(X,B){let Z=aX(X);if("find"in Z)return Z.find(B);let Q=Z;for(let G=0;G<Q.length;G++){let Y=Q[G];if(B(Y))return Y}return}function s(X,B){Object.entries(X).forEach(([Z,Q])=>B(Q,Z))}function Q0(X,B){return X.indexOf(B)!==-1}function w8(X,B){for(let Z=0;Z<X.length;Z++){let Q=X[Z];if(B(Q))return Q}return}class T8{constructor(){this.transfomers={}}register(X){this.transfomers[X.name]=X}findApplicable(X){return U1(this.transfomers,(B)=>B.isApplicable(X))}findByName(X){return this.transfomers[X]}}var oX=(X)=>Object.prototype.toString.call(X).slice(8,-1),E8=(X)=>typeof X>"u",sX=(X)=>X===null,t=(X)=>{if(typeof X!=="object"||X===null)return!1;if(X===Object.prototype)return!1;if(Object.getPrototypeOf(X)===null)return!0;return Object.getPrototypeOf(X)===Object.prototype},f0=(X)=>t(X)&&Object.keys(X).length===0,g=(X)=>Array.isArray(X),tX=(X)=>typeof X==="string",rX=(X)=>typeof X==="number"&&!isNaN(X),eX=(X)=>typeof X==="boolean",q1=(X)=>X instanceof RegExp,p=(X)=>X instanceof Map,n=(X)=>X instanceof Set,x8=(X)=>oX(X)==="Symbol",z1=(X)=>X instanceof Date&&!isNaN(X.valueOf()),S0=(X)=>X instanceof Error,C8=(X)=>typeof X==="number"&&isNaN(X),N1=(X)=>eX(X)||sX(X)||E8(X)||rX(X)||tX(X)||x8(X),F1=(X)=>typeof X==="bigint",J1=(X)=>X===1/0||X===-1/0,M1=(X)=>ArrayBuffer.isView(X)&&!(X instanceof DataView),L1=(X)=>X instanceof URL;var j0=(X)=>X.replace(/\\/g,"\\\\").replace(/\./g,"\\."),y0=(X)=>X.map(String).map(j0).join("."),G0=(X,B)=>{let Z=[],Q="";for(let Y=0;Y<X.length;Y++){let W=X.charAt(Y);if(!B&&W==="\\"){let D=X.charAt(Y+1);if(D==="\\"){Q+="\\",Y++;continue}else if(D!==".")throw Error("invalid path")}if(W==="\\"&&X.charAt(Y+1)==="."){Q+=".",Y++;continue}if(W==="."){Z.push(Q),Q="";continue}Q+=W}let G=Q;return Z.push(G),Z};function d(X,B,Z,Q){return{isApplicable:X,annotation:B,transform:Z,untransform:Q}}var I1=[d(E8,"undefined",()=>null,()=>{return}),d(F1,"bigint",(X)=>X.toString(),(X)=>{if(typeof BigInt<"u")return BigInt(X);return console.error("Please add a BigInt polyfill."),X}),d(z1,"Date",(X)=>X.toISOString(),(X)=>new Date(X)),d(S0,"Error",(X,B)=>{let Z={name:X.name,message:X.message};if("cause"in X)Z.cause=X.cause;return B.allowedErrorProps.forEach((Q)=>{Z[Q]=X[Q]}),Z},(X,B)=>{let Z=Error(X.message,{cause:X.cause});return Z.name=X.name,Z.stack=X.stack,B.allowedErrorProps.forEach((Q)=>{Z[Q]=X[Q]}),Z}),d(q1,"regexp",(X)=>""+X,(X)=>{let B=X.slice(1,X.lastIndexOf("/")),Z=X.slice(X.lastIndexOf("/")+1);return new RegExp(B,Z)}),d(n,"set",(X)=>[...X.values()],(X)=>new Set(X)),d(p,"map",(X)=>[...X.entries()],(X)=>new Map(X)),d((X)=>C8(X)||J1(X),"number",(X)=>{if(C8(X))return"NaN";if(X>0)return"Infinity";else return"-Infinity"},Number),d((X)=>X===0&&1/X===-1/0,"number",()=>{return"-0"},Number),d(L1,"URL",(X)=>X.toString(),(X)=>new URL(X))];function g0(X,B,Z,Q){return{isApplicable:X,annotation:B,transform:Z,untransform:Q}}var w1=g0((X,B)=>{if(x8(X))return!!B.symbolRegistry.getIdentifier(X);return!1},(X,B)=>{return["symbol",B.symbolRegistry.getIdentifier(X)]},(X)=>X.description,(X,B,Z)=>{let Q=Z.symbolRegistry.getValue(B[1]);if(!Q)throw Error("Trying to deserialize unknown symbol");return Q}),XB=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((X,B)=>{return X[B.name]=B,X},{}),T1=g0(M1,(X)=>["typed-array",X.constructor.name],(X)=>[...X],(X,B)=>{let Z=XB[B[1]];if(!Z)throw Error("Trying to deserialize unknown typed array");return new Z(X)});function P8(X,B){if(X?.constructor)return!!B.classRegistry.getIdentifier(X.constructor);return!1}var E1=g0(P8,(X,B)=>{return["class",B.classRegistry.getIdentifier(X.constructor)]},(X,B)=>{let Z=B.classRegistry.getAllowedProps(X.constructor);if(!Z)return{...X};let Q={};return Z.forEach((G)=>{Q[G]=X[G]}),Q},(X,B,Z)=>{let Q=Z.classRegistry.getValue(B[1]);if(!Q)throw Error(`Trying to deserialize unknown class '${B[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(Q.prototype),X)}),x1=g0((X,B)=>{return!!B.customTransformerRegistry.findApplicable(X)},(X,B)=>{return["custom",B.customTransformerRegistry.findApplicable(X).name]},(X,B)=>{return B.customTransformerRegistry.findApplicable(X).serialize(X)},(X,B,Z)=>{let Q=Z.customTransformerRegistry.findByName(B[1]);if(!Q)throw Error("Trying to deserialize unknown custom value");return Q.deserialize(X)}),BB=[E1,w1,x1,T1],R8=(X,B)=>{let Z=w8(BB,(G)=>G.isApplicable(X,B));if(Z)return{value:Z.transform(X,B),type:Z.annotation(X,B)};let Q=w8(I1,(G)=>G.isApplicable(X,B));if(Q)return{value:Q.transform(X,B),type:Q.annotation};return},C1={};I1.forEach((X)=>{C1[X.annotation]=X});var P1=(X,B,Z)=>{if(g(B))switch(B[0]){case"symbol":return w1.untransform(X,B,Z);case"class":return E1.untransform(X,B,Z);case"custom":return x1.untransform(X,B,Z);case"typed-array":return T1.untransform(X,B,Z);default:throw Error("Unknown transformation: "+B)}else{let Q=C1[B];if(!Q)throw Error("Unknown transformation: "+B);return Q.untransform(X,Z)}};var Y0=(X,B)=>{if(B>X.size)throw Error("index out of bounds");let Z=X.keys();while(B>0)Z.next(),B--;return Z.next().value};function R1(X){if(Q0(X,"__proto__"))throw Error("__proto__ is not allowed as a property");if(Q0(X,"prototype"))throw Error("prototype is not allowed as a property");if(Q0(X,"constructor"))throw Error("constructor is not allowed as a property")}var O1=(X,B)=>{R1(B);for(let Z=0;Z<B.length;Z++){let Q=B[Z];if(n(X))X=Y0(X,+Q);else if(p(X)){let G=+Q,Y=+B[++Z]===0?"key":"value",W=Y0(X,G);switch(Y){case"key":X=W;break;case"value":X=X.get(W);break}}else X=X[Q]}return X},h0=(X,B,Z)=>{if(R1(B),B.length===0)return Z(X);let Q=X;for(let Y=0;Y<B.length-1;Y++){let W=B[Y];if(g(Q)){let H=+W;Q=Q[H]}else if(t(Q))Q=Q[W];else if(n(Q)){let H=+W;Q=Y0(Q,H)}else if(p(Q)){if(Y===B.length-2)break;let V=+W,D=+B[++Y]===0?"key":"value",z=Y0(Q,V);switch(D){case"key":Q=z;break;case"value":Q=Q.get(z);break}}}let G=B[B.length-1];if(g(Q))Q[+G]=Z(Q[+G]);else if(t(Q))Q[G]=Z(Q[G]);if(n(Q)){let Y=Y0(Q,+G),W=Z(Y);if(Y!==W)Q.delete(Y),Q.add(W)}if(p(Q)){let Y=+B[B.length-2],W=Y0(Q,Y);switch(+G===0?"key":"value"){case"key":{let V=Z(W);if(Q.set(V,Q.get(W)),V!==W)Q.delete(W);break}case"value":{Q.set(W,Z(Q.get(W)));break}}}return X};var k1=(X)=>X<1;function O8(X,B,Z,Q=[]){if(!X)return;let G=k1(Z);if(!g(X)){s(X,(H,V)=>O8(H,B,Z,[...Q,...G0(V,G)]));return}let[Y,W]=X;if(W)s(W,(H,V)=>{O8(H,B,Z,[...Q,...G0(V,G)])});B(Y,Q)}function $1(X,B,Z,Q){return O8(B,(G,Y)=>{X=h0(X,Y,(W)=>P1(W,G,Q))},Z),X}function f1(X,B,Z){let Q=k1(Z);function G(Y,W){let H=O1(X,G0(W,Q));Y.map((V)=>G0(V,Q)).forEach((V)=>{X=h0(X,V,()=>H)})}if(g(B)){let[Y,W]=B;if(Y.forEach((H)=>{X=h0(X,G0(H,Q),()=>X)}),W)s(W,G)}else s(B,G);return X}var ZB=(X,B)=>t(X)||g(X)||p(X)||n(X)||S0(X)||P8(X,B);function QB(X,B,Z){let Q=Z.get(X);if(Q)Q.push(B);else Z.set(X,[B])}function S1(X,B){let Z={},Q=void 0;if(X.forEach((G)=>{if(G.length<=1)return;if(!B)G=G.map((H)=>H.map(String)).sort((H,V)=>H.length-V.length);let[Y,...W]=G;if(Y.length===0)Q=W.map(y0);else Z[y0(Y)]=W.map(y0)}),Q)if(f0(Z))return[Q];else return[Q,Z];else return f0(Z)?void 0:Z}var k8=(X,B,Z,Q,G=[],Y=[],W=new Map)=>{let H=N1(X);if(!H){QB(X,G,B);let K=W.get(X);if(K)return Q?{transformedValue:null}:K}if(!ZB(X,Z)){let K=R8(X,Z),N=K?{transformedValue:K.value,annotations:[K.type]}:{transformedValue:X};if(!H)W.set(X,N);return N}if(Q0(Y,X))return{transformedValue:null};let V=R8(X,Z),D=V?.value??X,z=g(D)?[]:{},q={};s(D,(K,N)=>{if(N==="__proto__"||N==="constructor"||N==="prototype")throw Error(`Detected property ${N}. This is a prototype pollution risk, please remove it from your object.`);let U=k8(K,B,Z,Q,[...G,N],[...Y,X],W);if(z[N]=U.transformedValue,g(U.annotations))q[j0(N)]=U.annotations;else if(t(U.annotations))s(U.annotations,(A,M)=>{q[j0(N)+"."+M]=A})});let F=f0(q)?{transformedValue:z,annotations:V?[V.type]:void 0}:{transformedValue:z,annotations:V?[V.type,q]:q};if(!H)W.set(X,F);return F};function v0(X){return Object.prototype.toString.call(X).slice(8,-1)}function m0(X){return v0(X)==="Array"}function $8(X){if(v0(X)!=="Object")return!1;let B=Object.getPrototypeOf(X);return!!B&&B.constructor===Object&&B===Object.prototype}function GB(X,B,Z,Q,G){let Y={}.propertyIsEnumerable.call(Q,B)?"enumerable":"nonenumerable";if(Y==="enumerable")X[B]=Z;if(G&&Y==="nonenumerable")Object.defineProperty(X,B,{value:Z,enumerable:!1,writable:!0,configurable:!0})}function d0(X,B={}){if(m0(X))return X.map((G)=>d0(G,B));if(!$8(X))return X;let Z=Object.getOwnPropertyNames(X),Q=Object.getOwnPropertySymbols(X);return[...Z,...Q].reduce((G,Y)=>{if(Y==="__proto__")return G;if(m0(B.props)&&!B.props.includes(Y))return G;let W=X[Y],H=d0(W,B);return GB(G,Y,H,X,B.nonenumerable),G},{})}class I{constructor({dedupe:X=!1}={}){this.classRegistry=new I8,this.symbolRegistry=new F0((B)=>B.description??""),this.customTransformerRegistry=new T8,this.allowedErrorProps=[],this.dedupe=X}serialize(X){let B=new Map,Z=k8(X,B,this,this.dedupe),Q={json:Z.transformedValue};if(Z.annotations)Q.meta={...Q.meta,values:Z.annotations};let G=S1(B,this.dedupe);if(G)Q.meta={...Q.meta,referentialEqualities:G};if(Q.meta)Q.meta.v=1;return Q}deserialize(X,B){let{json:Z,meta:Q}=X,G=B?.inPlace?Z:d0(Z);if(Q?.values)G=$1(G,Q.values,Q.v??0,this);if(Q?.referentialEqualities)G=f1(G,Q.referentialEqualities,Q.v??0);return G}stringify(X){return JSON.stringify(this.serialize(X))}parse(X){return this.deserialize(JSON.parse(X),{inPlace:!0})}registerClass(X,B){this.classRegistry.register(X,B)}registerSymbol(X,B){this.symbolRegistry.register(X,B)}registerCustom(X,B){this.customTransformerRegistry.register({name:B,...X})}allowErrorProps(...X){this.allowedErrorProps.push(...X)}}I.defaultInstance=new I;I.serialize=I.defaultInstance.serialize.bind(I.defaultInstance);I.deserialize=I.defaultInstance.deserialize.bind(I.defaultInstance);I.stringify=I.defaultInstance.stringify.bind(I.defaultInstance);I.parse=I.defaultInstance.parse.bind(I.defaultInstance);I.registerClass=I.defaultInstance.registerClass.bind(I.defaultInstance);I.registerSymbol=I.defaultInstance.registerSymbol.bind(I.defaultInstance);I.registerCustom=I.defaultInstance.registerCustom.bind(I.defaultInstance);I.allowErrorProps=I.defaultInstance.allowErrorProps.bind(I.defaultInstance);var J0=I;var{serialize:E9,deserialize:x9,stringify:C9,parse:P9,registerClass:R9,registerCustom:O9,registerSymbol:k9,allowErrorProps:$9}=I;var YB=new TextEncoder,WB=new TextDecoder;function f8(X){let B=YB.encode(X),Z="";for(let Q of B)Z+=String.fromCharCode(Q);return btoa(Z)}function HB(X){let B=atob(X),Z=new Uint8Array(B.length);for(let Q=0;Q<B.length;Q++)Z[Q]=B.charCodeAt(Q);return WB.decode(Z)}class S8{dbName;storeName;version;db;initP;constructor(X,B="kv",Z=1){this.dbName=X;this.storeName=B;this.version=Z;this.initP=this.open()}async open(){this.db=await new Promise((X,B)=>{let Z=indexedDB.open(this.dbName,this.version);Z.onupgradeneeded=()=>{let Q=Z.result;if(!Q.objectStoreNames.contains(this.storeName))Q.createObjectStore(this.storeName)},Z.onsuccess=()=>{Z.result.onversionchange=()=>Z.result.close(),X(Z.result)},Z.onerror=()=>B(Z.error)})}async withTx(X,B){return await this.initP,new Promise((Z,Q)=>{let G=this.db.transaction(this.storeName,X),Y=G.objectStore(this.storeName),W;try{W=B(Y)}catch(V){G.abort(),Q(V);return}let H;if(W)W.onsuccess=()=>H=W.result,W.onerror=()=>Q(W.error);G.oncomplete=()=>Z(H),G.onerror=()=>Q(G.error),G.onabort=()=>Q(G.error)})}async get(X){let B=f8(X);return await this.withTx("readonly",(Q)=>Q.get(B))??null}async set(X,B){let Z=f8(X);await this.withTx("readwrite",(Q)=>Q.put(B,Z))}async del(X){let B=f8(X);await this.withTx("readwrite",(Z)=>Z.delete(B))}async clear(){await this.withTx("readwrite",(X)=>X.clear())}async keys(){let X=await this.withTx("readonly",(Z)=>Z.getAllKeys()),B=new Set;for(let Z of X){if(typeof Z!=="string")continue;try{B.add(HB(Z))}catch{}}return B}}class j8{maxSize;map=new Map;constructor(X){this.maxSize=X;if(X<=0)throw Error("maxSize must be > 0")}get(X){let B=this.map.get(X);if(B===void 0)return;return this.map.delete(X),this.map.set(X,B),B}set(X,B){if(this.map.has(X))this.map.delete(X);if(this.map.set(X,B),this.map.size>this.maxSize){let Z=this.map.keys().next().value;this.map.delete(Z)}}delete(X){this.map.delete(X)}clear(){this.map.clear()}keys(){return this.map.keys()}}function _0(){try{return typeof window==="object"}catch(X){return!1}}function j1(){let X=(Q)=>Q.buffer.slice(Q.byteOffset,Q.byteOffset+Q.byteLength),B=(Q)=>new Uint8Array(Q);if(!_0()||!("indexedDB"in globalThis)){let Q=new j8(500);return{async getBytes(G){let Y=Q.get(G);return Y?new Uint8Array(Y):null},async setBytes(G,Y){Q.set(G,new Uint8Array(Y))},async delete(G){Q.delete(G)},async clear(){Q.clear()},async keys(){return new Set(Q.keys())}}}let Z=null;try{Z=new S8("sortsys-v2-cache")}catch{throw Error("failed to create cache")}return{async getBytes(Q){let G=await Z.get(Q);if(!G)return null;if(G.exp!==0&&G.exp<=Date.now())return await Z.del(Q),null;return B(G.value)},async setBytes(Q,G){let Y={value:X(G),exp:Date.now()+259200000};try{await Z.set(Q,Y)}catch{}},async delete(Q){try{await Z.del(Q)}catch{}},async clear(){try{await Z.clear()}catch{}},async keys(){try{return await Z.keys()}catch{return new Set}}}}var y8=function(X,B){return y8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Z,Q){Z.__proto__=Q}||function(Z,Q){for(var G in Q)if(Object.prototype.hasOwnProperty.call(Q,G))Z[G]=Q[G]},y8(X,B)};function i(X,B){if(typeof B!=="function"&&B!==null)throw TypeError("Class extends value "+String(B)+" is not a constructor or null");y8(X,B);function Z(){this.constructor=X}X.prototype=B===null?Object.create(B):(Z.prototype=B.prototype,new Z)}function y1(X,B,Z,Q){function G(Y){return Y instanceof Z?Y:new Z(function(W){W(Y)})}return new(Z||(Z=Promise))(function(Y,W){function H(z){try{D(Q.next(z))}catch(q){W(q)}}function V(z){try{D(Q.throw(z))}catch(q){W(q)}}function D(z){z.done?Y(z.value):G(z.value).then(H,V)}D((Q=Q.apply(X,B||[])).next())})}function b0(X,B){var Z={label:0,sent:function(){if(Y[0]&1)throw Y[1];return Y[1]},trys:[],ops:[]},Q,G,Y,W=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return W.next=H(0),W.throw=H(1),W.return=H(2),typeof Symbol==="function"&&(W[Symbol.iterator]=function(){return this}),W;function H(D){return function(z){return V([D,z])}}function V(D){if(Q)throw TypeError("Generator is already executing.");while(W&&(W=0,D[0]&&(Z=0)),Z)try{if(Q=1,G&&(Y=D[0]&2?G.return:D[0]?G.throw||((Y=G.return)&&Y.call(G),0):G.next)&&!(Y=Y.call(G,D[1])).done)return Y;if(G=0,Y)D=[D[0]&2,Y.value];switch(D[0]){case 0:case 1:Y=D;break;case 4:return Z.label++,{value:D[1],done:!1};case 5:Z.label++,G=D[1],D=[0];continue;case 7:D=Z.ops.pop(),Z.trys.pop();continue;default:if((Y=Z.trys,!(Y=Y.length>0&&Y[Y.length-1]))&&(D[0]===6||D[0]===2)){Z=0;continue}if(D[0]===3&&(!Y||D[1]>Y[0]&&D[1]<Y[3])){Z.label=D[1];break}if(D[0]===6&&Z.label<Y[1]){Z.label=Y[1],Y=D;break}if(Y&&Z.label<Y[2]){Z.label=Y[2],Z.ops.push(D);break}if(Y[2])Z.ops.pop();Z.trys.pop();continue}D=B.call(X,Z)}catch(z){D=[6,z],G=0}finally{Q=Y=0}if(D[0]&5)throw D[1];return{value:D[0]?D[1]:void 0,done:!0}}}function l(X){var B=typeof Symbol==="function"&&Symbol.iterator,Z=B&&X[B],Q=0;if(Z)return Z.call(X);if(X&&typeof X.length==="number")return{next:function(){if(X&&Q>=X.length)X=void 0;return{value:X&&X[Q++],done:!X}}};throw TypeError(B?"Object is not iterable.":"Symbol.iterator is not defined.")}function W0(X,B){var Z=typeof Symbol==="function"&&X[Symbol.iterator];if(!Z)return X;var Q=Z.call(X),G,Y=[],W;try{while((B===void 0||B-- >0)&&!(G=Q.next()).done)Y.push(G.value)}catch(H){W={error:H}}finally{try{if(G&&!G.done&&(Z=Q.return))Z.call(Q)}finally{if(W)throw W.error}}return Y}function H0(X,B,Z){if(Z||arguments.length===2){for(var Q=0,G=B.length,Y;Q<G;Q++)if(Y||!(Q in B)){if(!Y)Y=Array.prototype.slice.call(B,0,Q);Y[Q]=B[Q]}}return X.concat(Y||Array.prototype.slice.call(B))}function r(X){return this instanceof r?(this.v=X,this):new r(X)}function g1(X,B,Z){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var Q=Z.apply(X,B||[]),G,Y=[];return G=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),H("next"),H("throw"),H("return",W),G[Symbol.asyncIterator]=function(){return this},G;function W(K){return function(N){return Promise.resolve(N).then(K,q)}}function H(K,N){if(Q[K]){if(G[K]=function(U){return new Promise(function(A,M){Y.push([K,U,A,M])>1||V(K,U)})},N)G[K]=N(G[K])}}function V(K,N){try{D(Q[K](N))}catch(U){F(Y[0][3],U)}}function D(K){K.value instanceof r?Promise.resolve(K.value.v).then(z,q):F(Y[0][2],K)}function z(K){V("next",K)}function q(K){V("throw",K)}function F(K,N){if(K(N),Y.shift(),Y.length)V(Y[0][0],Y[0][1])}}function h1(X){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var B=X[Symbol.asyncIterator],Z;return B?B.call(X):(X=typeof l==="function"?l(X):X[Symbol.iterator](),Z={},Q("next"),Q("throw"),Q("return"),Z[Symbol.asyncIterator]=function(){return this},Z);function Q(Y){Z[Y]=X[Y]&&function(W){return new Promise(function(H,V){W=X[Y](W),G(H,V,W.done,W.value)})}}function G(Y,W,H,V){Promise.resolve(V).then(function(D){Y({value:D,done:H})},W)}}function w(X){return typeof X==="function"}function l0(X){var B=function(Q){Error.call(Q),Q.stack=Error().stack},Z=X(B);return Z.prototype=Object.create(Error.prototype),Z.prototype.constructor=Z,Z}var c0=l0(function(X){return function(Z){X(this),this.message=Z?Z.length+` errors occurred during unsubscription:
|
|
2
|
-
`+
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=Z}});function M0(X,B){if(X){var Z=X.indexOf(B);0<=Z&&X.splice(Z,1)}}var V0=function(){function X(B){this.initialTeardown=B,this.closed=!1,this._parentage=null,this._finalizers=null}return X.prototype.unsubscribe=function(){var B,Z,Q,G,Y;if(!this.closed){this.closed=!0;var W=this._parentage;if(W)if(this._parentage=null,Array.isArray(W))try{for(var H=l(W),V=H.next();!V.done;V=H.next()){var D=V.value;D.remove(this)}}catch(U){B={error:U}}finally{try{if(V&&!V.done&&(Z=H.return))Z.call(H)}finally{if(B)throw B.error}}else W.remove(this);var z=this.initialTeardown;if(w(z))try{z()}catch(U){Y=U instanceof c0?U.errors:[U]}var q=this._finalizers;if(q){this._finalizers=null;try{for(var F=l(q),K=F.next();!K.done;K=F.next()){var N=K.value;try{v1(N)}catch(U){if(Y=Y!==null&&Y!==void 0?Y:[],U instanceof c0)Y=H0(H0([],W0(Y)),W0(U.errors));else Y.push(U)}}}catch(U){Q={error:U}}finally{try{if(K&&!K.done&&(G=F.return))G.call(F)}finally{if(Q)throw Q.error}}}if(Y)throw new c0(Y)}},X.prototype.add=function(B){var Z;if(B&&B!==this)if(this.closed)v1(B);else{if(B instanceof X){if(B.closed||B._hasParent(this))return;B._addParent(this)}(this._finalizers=(Z=this._finalizers)!==null&&Z!==void 0?Z:[]).push(B)}},X.prototype._hasParent=function(B){var Z=this._parentage;return Z===B||Array.isArray(Z)&&Z.includes(B)},X.prototype._addParent=function(B){var Z=this._parentage;this._parentage=Array.isArray(Z)?(Z.push(B),Z):Z?[Z,B]:B},X.prototype._removeParent=function(B){var Z=this._parentage;if(Z===B)this._parentage=null;else if(Array.isArray(Z))M0(Z,B)},X.prototype.remove=function(B){var Z=this._finalizers;if(Z&&M0(Z,B),B instanceof X)B._removeParent(this)},X.EMPTY=function(){var B=new X;return B.closed=!0,B}(),X}();var g8=V0.EMPTY;function u0(X){return X instanceof V0||X&&"closed"in X&&w(X.remove)&&w(X.add)&&w(X.unsubscribe)}function v1(X){if(w(X))X();else X.unsubscribe()}var h={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var D0={setTimeout:function(X,B){var Z=[];for(var Q=2;Q<arguments.length;Q++)Z[Q-2]=arguments[Q];var G=D0.delegate;if(G===null||G===void 0?void 0:G.setTimeout)return G.setTimeout.apply(G,H0([X,B],W0(Z)));return setTimeout.apply(void 0,H0([X,B],W0(Z)))},clearTimeout:function(X){var B=D0.delegate;return((B===null||B===void 0?void 0:B.clearTimeout)||clearTimeout)(X)},delegate:void 0};function p0(X){D0.setTimeout(function(){var B=h.onUnhandledError;if(B)B(X);else throw X})}function h8(){}var m1=function(){return v8("C",void 0,void 0)}();function d1(X){return v8("E",void 0,X)}function _1(X){return v8("N",X,void 0)}function v8(X,B,Z){return{kind:X,value:B,error:Z}}var e=null;function K0(X){if(h.useDeprecatedSynchronousErrorHandling){var B=!e;if(B)e={errorThrown:!1,error:null};if(X(),B){var Z=e,Q=Z.errorThrown,G=Z.error;if(e=null,Q)throw G}}else X()}function b1(X){if(h.useDeprecatedSynchronousErrorHandling&&e)e.errorThrown=!0,e.error=X}var L0=function(X){i(B,X);function B(Z){var Q=X.call(this)||this;if(Q.isStopped=!1,Z){if(Q.destination=Z,u0(Z))Z.add(Q)}else Q.destination=AB;return Q}return B.create=function(Z,Q,G){return new i0(Z,Q,G)},B.prototype.next=function(Z){if(this.isStopped)d8(_1(Z),this);else this._next(Z)},B.prototype.error=function(Z){if(this.isStopped)d8(d1(Z),this);else this.isStopped=!0,this._error(Z)},B.prototype.complete=function(){if(this.isStopped)d8(m1,this);else this.isStopped=!0,this._complete()},B.prototype.unsubscribe=function(){if(!this.closed)this.isStopped=!0,X.prototype.unsubscribe.call(this),this.destination=null},B.prototype._next=function(Z){this.destination.next(Z)},B.prototype._error=function(Z){try{this.destination.error(Z)}finally{this.unsubscribe()}},B.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},B}(V0);var VB=Function.prototype.bind;function m8(X,B){return VB.call(X,B)}var DB=function(){function X(B){this.partialObserver=B}return X.prototype.next=function(B){var Z=this.partialObserver;if(Z.next)try{Z.next(B)}catch(Q){n0(Q)}},X.prototype.error=function(B){var Z=this.partialObserver;if(Z.error)try{Z.error(B)}catch(Q){n0(Q)}else n0(B)},X.prototype.complete=function(){var B=this.partialObserver;if(B.complete)try{B.complete()}catch(Z){n0(Z)}},X}(),i0=function(X){i(B,X);function B(Z,Q,G){var Y=X.call(this)||this,W;if(w(Z)||!Z)W={next:Z!==null&&Z!==void 0?Z:void 0,error:Q!==null&&Q!==void 0?Q:void 0,complete:G!==null&&G!==void 0?G:void 0};else{var H;if(Y&&h.useDeprecatedNextContext)H=Object.create(Z),H.unsubscribe=function(){return Y.unsubscribe()},W={next:Z.next&&m8(Z.next,H),error:Z.error&&m8(Z.error,H),complete:Z.complete&&m8(Z.complete,H)};else W=Z}return Y.destination=new DB(W),Y}return B}(L0);function n0(X){if(h.useDeprecatedSynchronousErrorHandling)b1(X);else p0(X)}function KB(X){throw X}function d8(X,B){var Z=h.onStoppedNotification;Z&&D0.setTimeout(function(){return Z(X,B)})}var AB={closed:!0,next:h8,error:KB,complete:h8};var A0=function(){return typeof Symbol==="function"&&Symbol.observable||"@@observable"}();function a0(X){return X}function l1(X){if(X.length===0)return a0;if(X.length===1)return X[0];return function(Z){return X.reduce(function(Q,G){return G(Q)},Z)}}var P=function(){function X(B){if(B)this._subscribe=B}return X.prototype.lift=function(B){var Z=new X;return Z.source=this,Z.operator=B,Z},X.prototype.subscribe=function(B,Z,Q){var G=this,Y=qB(B)?B:new i0(B,Z,Q);return K0(function(){var W=G,H=W.operator,V=W.source;Y.add(H?H.call(Y,V):V?G._subscribe(Y):G._trySubscribe(Y))}),Y},X.prototype._trySubscribe=function(B){try{return this._subscribe(B)}catch(Z){B.error(Z)}},X.prototype.forEach=function(B,Z){var Q=this;return Z=c1(Z),new Z(function(G,Y){var W=new i0({next:function(H){try{B(H)}catch(V){Y(V),W.unsubscribe()}},error:Y,complete:G});Q.subscribe(W)})},X.prototype._subscribe=function(B){var Z;return(Z=this.source)===null||Z===void 0?void 0:Z.subscribe(B)},X.prototype[A0]=function(){return this},X.prototype.pipe=function(){var B=[];for(var Z=0;Z<arguments.length;Z++)B[Z]=arguments[Z];return l1(B)(this)},X.prototype.toPromise=function(B){var Z=this;return B=c1(B),new B(function(Q,G){var Y;Z.subscribe(function(W){return Y=W},function(W){return G(W)},function(){return Q(Y)})})},X.create=function(B){return new X(B)},X}();function c1(X){var B;return(B=X!==null&&X!==void 0?X:h.Promise)!==null&&B!==void 0?B:Promise}function UB(X){return X&&w(X.next)&&w(X.error)&&w(X.complete)}function qB(X){return X&&X instanceof L0||UB(X)&&u0(X)}var u1=l0(function(X){return function(){X(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var o0=function(X){i(B,X);function B(){var Z=X.call(this)||this;return Z.closed=!1,Z.currentObservers=null,Z.observers=[],Z.isStopped=!1,Z.hasError=!1,Z.thrownError=null,Z}return B.prototype.lift=function(Z){var Q=new p1(this,this);return Q.operator=Z,Q},B.prototype._throwIfClosed=function(){if(this.closed)throw new u1},B.prototype.next=function(Z){var Q=this;K0(function(){var G,Y;if(Q._throwIfClosed(),!Q.isStopped){if(!Q.currentObservers)Q.currentObservers=Array.from(Q.observers);try{for(var W=l(Q.currentObservers),H=W.next();!H.done;H=W.next()){var V=H.value;V.next(Z)}}catch(D){G={error:D}}finally{try{if(H&&!H.done&&(Y=W.return))Y.call(W)}finally{if(G)throw G.error}}}})},B.prototype.error=function(Z){var Q=this;K0(function(){if(Q._throwIfClosed(),!Q.isStopped){Q.hasError=Q.isStopped=!0,Q.thrownError=Z;var G=Q.observers;while(G.length)G.shift().error(Z)}})},B.prototype.complete=function(){var Z=this;K0(function(){if(Z._throwIfClosed(),!Z.isStopped){Z.isStopped=!0;var Q=Z.observers;while(Q.length)Q.shift().complete()}})},B.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(B.prototype,"observed",{get:function(){var Z;return((Z=this.observers)===null||Z===void 0?void 0:Z.length)>0},enumerable:!1,configurable:!0}),B.prototype._trySubscribe=function(Z){return this._throwIfClosed(),X.prototype._trySubscribe.call(this,Z)},B.prototype._subscribe=function(Z){return this._throwIfClosed(),this._checkFinalizedStatuses(Z),this._innerSubscribe(Z)},B.prototype._innerSubscribe=function(Z){var Q=this,G=this,Y=G.hasError,W=G.isStopped,H=G.observers;if(Y||W)return g8;return this.currentObservers=null,H.push(Z),new V0(function(){Q.currentObservers=null,M0(H,Z)})},B.prototype._checkFinalizedStatuses=function(Z){var Q=this,G=Q.hasError,Y=Q.thrownError,W=Q.isStopped;if(G)Z.error(Y);else if(W)Z.complete()},B.prototype.asObservable=function(){var Z=new P;return Z.source=this,Z},B.create=function(Z,Q){return new p1(Z,Q)},B}(P);var p1=function(X){i(B,X);function B(Z,Q){var G=X.call(this)||this;return G.destination=Z,G.source=Q,G}return B.prototype.next=function(Z){var Q,G;(G=(Q=this.destination)===null||Q===void 0?void 0:Q.next)===null||G===void 0||G.call(Q,Z)},B.prototype.error=function(Z){var Q,G;(G=(Q=this.destination)===null||Q===void 0?void 0:Q.error)===null||G===void 0||G.call(Q,Z)},B.prototype.complete=function(){var Z,Q;(Q=(Z=this.destination)===null||Z===void 0?void 0:Z.complete)===null||Q===void 0||Q.call(Z)},B.prototype._subscribe=function(Z){var Q,G;return(G=(Q=this.source)===null||Q===void 0?void 0:Q.subscribe(Z))!==null&&G!==void 0?G:g8},B}(o0);function zB(X){return w(X===null||X===void 0?void 0:X.lift)}function a(X){return function(B){if(zB(B))return B.lift(function(Z){try{return X(Z,this)}catch(Q){this.error(Q)}});throw TypeError("Unable to lift unknown Observable type")}}function X0(X,B,Z,Q,G){return new NB(X,B,Z,Q,G)}var NB=function(X){i(B,X);function B(Z,Q,G,Y,W,H){var V=X.call(this,Z)||this;return V.onFinalize=W,V.shouldUnsubscribe=H,V._next=Q?function(D){try{Q(D)}catch(z){Z.error(z)}}:X.prototype._next,V._error=Y?function(D){try{Y(D)}catch(z){Z.error(z)}finally{this.unsubscribe()}}:X.prototype._error,V._complete=G?function(){try{G()}catch(D){Z.error(D)}finally{this.unsubscribe()}}:X.prototype._complete,V}return B.prototype.unsubscribe=function(){var Z;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var Q=this.closed;X.prototype.unsubscribe.call(this),!Q&&((Z=this.onFinalize)===null||Z===void 0||Z.call(this))}},B}(L0);function n1(X,B){return a(function(Z,Q){var G=0;Z.subscribe(X0(Q,function(Y){Q.next(X.call(B,Y,G++))}))})}var s0=function(X){return X&&typeof X.length==="number"&&typeof X!=="function"};function t0(X){return w(X===null||X===void 0?void 0:X.then)}function r0(X){return w(X[A0])}function e0(X){return Symbol.asyncIterator&&w(X===null||X===void 0?void 0:X[Symbol.asyncIterator])}function X8(X){return TypeError("You provided "+(X!==null&&typeof X==="object"?"an invalid object":"'"+X+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function FB(){if(typeof Symbol!=="function"||!Symbol.iterator)return"@@iterator";return Symbol.iterator}var B8=FB();function Z8(X){return w(X===null||X===void 0?void 0:X[B8])}function Q8(X){return g1(this,arguments,function(){var Z,Q,G,Y;return b0(this,function(W){switch(W.label){case 0:Z=X.getReader(),W.label=1;case 1:W.trys.push([1,,9,10]),W.label=2;case 2:return[4,r(Z.read())];case 3:if(Q=W.sent(),G=Q.value,Y=Q.done,!Y)return[3,5];return[4,r(void 0)];case 4:return[2,W.sent()];case 5:return[4,r(G)];case 6:return[4,W.sent()];case 7:return W.sent(),[3,2];case 8:return[3,10];case 9:return Z.releaseLock(),[7];case 10:return[2]}})})}function G8(X){return w(X===null||X===void 0?void 0:X.getReader)}function _(X){if(X instanceof P)return X;if(X!=null){if(r0(X))return JB(X);if(s0(X))return MB(X);if(t0(X))return LB(X);if(e0(X))return i1(X);if(Z8(X))return IB(X);if(G8(X))return wB(X)}throw X8(X)}function JB(X){return new P(function(B){var Z=X[A0]();if(w(Z.subscribe))return Z.subscribe(B);throw TypeError("Provided object does not correctly implement Symbol.observable")})}function MB(X){return new P(function(B){for(var Z=0;Z<X.length&&!B.closed;Z++)B.next(X[Z]);B.complete()})}function LB(X){return new P(function(B){X.then(function(Z){if(!B.closed)B.next(Z),B.complete()},function(Z){return B.error(Z)}).then(null,p0)})}function IB(X){return new P(function(B){var Z,Q;try{for(var G=l(X),Y=G.next();!Y.done;Y=G.next()){var W=Y.value;if(B.next(W),B.closed)return}}catch(H){Z={error:H}}finally{try{if(Y&&!Y.done&&(Q=G.return))Q.call(G)}finally{if(Z)throw Z.error}}B.complete()})}function i1(X){return new P(function(B){TB(X,B).catch(function(Z){return B.error(Z)})})}function wB(X){return i1(Q8(X))}function TB(X,B){var Z,Q,G,Y;return y1(this,void 0,void 0,function(){var W,H;return b0(this,function(V){switch(V.label){case 0:V.trys.push([0,5,6,11]),Z=h1(X),V.label=1;case 1:return[4,Z.next()];case 2:if(Q=V.sent(),!!Q.done)return[3,4];if(W=Q.value,B.next(W),B.closed)return[2];V.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return H=V.sent(),G={error:H},[3,11];case 6:if(V.trys.push([6,,9,10]),!(Q&&!Q.done&&(Y=Z.return)))return[3,8];return[4,Y.call(Z)];case 7:V.sent(),V.label=8;case 8:return[3,10];case 9:if(G)throw G.error;return[7];case 10:return[7];case 11:return B.complete(),[2]}})})}function S(X,B,Z,Q,G){if(Q===void 0)Q=0;if(G===void 0)G=!1;var Y=B.schedule(function(){if(Z(),G)X.add(this.schedule(null,Q));else this.unsubscribe()},Q);if(X.add(Y),!G)return Y}function a1(X,B,Z,Q,G,Y,W,H){var V=[],D=0,z=0,q=!1,F=function(){if(q&&!V.length&&!D)B.complete()},K=function(U){return D<Q?N(U):V.push(U)},N=function(U){Y&&B.next(U),D++;var A=!1;_(Z(U,z++)).subscribe(X0(B,function(M){if(G===null||G===void 0||G(M),Y)K(M);else B.next(M)},function(){A=!0},void 0,function(){if(A)try{D--;var M=function(){var J=V.shift();if(W)S(B,W,function(){return N(J)});else N(J)};while(V.length&&D<Q)M();F()}catch(J){B.error(J)}}))};return X.subscribe(X0(B,K,function(){q=!0,F()})),function(){H===null||H===void 0||H()}}function _8(X,B,Z){if(Z===void 0)Z=1/0;if(w(B))return _8(function(Q,G){return n1(function(Y,W){return B(Q,Y,G,W)})(_(X(Q,G)))},Z);else if(typeof B==="number")Z=B;return a(function(Q,G){return a1(Q,G,X,Z)})}function o1(X){if(X===void 0)X=1/0;return _8(a0,X)}function s1(){return o1(1)}function t1(X){return X&&w(X.schedule)}function EB(X){return X[X.length-1]}function r1(X){return t1(EB(X))?X.pop():void 0}function Y8(X,B){if(B===void 0)B=0;return a(function(Z,Q){Z.subscribe(X0(Q,function(G){return S(Q,X,function(){return Q.next(G)},B)},function(){return S(Q,X,function(){return Q.complete()},B)},function(G){return S(Q,X,function(){return Q.error(G)},B)}))})}function W8(X,B){if(B===void 0)B=0;return a(function(Z,Q){Q.add(X.schedule(function(){return Z.subscribe(Q)},B))})}function e1(X,B){return _(X).pipe(W8(B),Y8(B))}function XX(X,B){return _(X).pipe(W8(B),Y8(B))}function BX(X,B){return new P(function(Z){var Q=0;return B.schedule(function(){if(Q===X.length)Z.complete();else if(Z.next(X[Q++]),!Z.closed)this.schedule()})})}function ZX(X,B){return new P(function(Z){var Q;return S(Z,B,function(){Q=X[B8](),S(Z,B,function(){var G,Y,W;try{G=Q.next(),Y=G.value,W=G.done}catch(H){Z.error(H);return}if(W)Z.complete();else Z.next(Y)},0,!0)}),function(){return w(Q===null||Q===void 0?void 0:Q.return)&&Q.return()}})}function H8(X,B){if(!X)throw Error("Iterable cannot be null");return new P(function(Z){S(Z,B,function(){var Q=X[Symbol.asyncIterator]();S(Z,B,function(){Q.next().then(function(G){if(G.done)Z.complete();else Z.next(G.value)})},0,!0)})})}function QX(X,B){return H8(Q8(X),B)}function GX(X,B){if(X!=null){if(r0(X))return e1(X,B);if(s0(X))return BX(X,B);if(t0(X))return XX(X,B);if(e0(X))return H8(X,B);if(Z8(X))return ZX(X,B);if(G8(X))return QX(X,B)}throw X8(X)}function I0(X,B){return B?GX(X,B):_(X)}function b8(){var X=[];for(var B=0;B<arguments.length;B++)X[B]=arguments[B];return s1()(I0(X,r1(X)))}function xB(X){function B(Z){if(Z===null||typeof Z!=="object")return Z;if(Array.isArray(Z))return Z.map(B);let Q={};for(let G of Object.keys(Z).sort()){let Y=Z[G];if(Y===void 0||typeof Y==="function"||typeof Y==="symbol")continue;Q[G]=B(Y)}return Q}return JSON.stringify(B(X))}var CB=new TextDecoder,l8=new TextEncoder;function PB(X){return l8.encode(X)}function RB(X){let B=xB(X),Z=PB(B),Q=0xcbf29ce484222325n,G=0x100000001b3n,Y=0xffffffffffffffffn;for(let W=0;W<Z.length;W++)Q^=BigInt(Z[W]),Q=Q*G&Y;return Q.toString(16).padStart(16,"0")}function OB(X){if(!(X instanceof f))return!1;return X?.data?.httpCode===401}function sK(X,B){let Z=B?.cache??j1(),Q=null,G=K1({links:[F8({url:X,transformer:J0,headers:(A)=>{if(!Q)return{};return{Authorization:`Bearer ${Q}`}}})]});function Y(A,M){let J=RB(M??null);return`trpc:${A}.query:${J}`}let W={};function H(A,M){if(A in W)return W[A];let J=M().finally(()=>{setTimeout(()=>{if(W[A]===J)delete W[A]},250)});return W[A]=J,J}async function V(A){return Z.getBytes(A).then((M)=>{if(!M)return null;try{return J0.parse(CB.decode(M))}catch(J){return null}})}let D=[];function z(A){if(A.startsWith("trpc:"))A=A.split(":")[1];for(let[M,J]of D){let L=M.split(":")[1].split(".").slice(0,-1).join(".");if(A.startsWith(L))(async()=>J())()}}let q=new o0,F=!!Q;function K(){let A=!!Q;if(A===F)return;F=A,q.next()}let N=Object.freeze({async query(A,M,J){let E=J?.strategy??"network-first",L=G;for(let x of`${A}.query`.split("."))L=L?.[x];if(!L)throw Error(`could not resolve query path ${A}`);let C=Y(A,M);async function k(){try{return[await H(C,()=>L(M))??null,null]}catch(x){if(x instanceof f){if(U(x),x?.code==="ConnectionRefused")return[null,null];return[null,x]}return[null,f.from(x)]}}async function c(x){let[o,O]=x;if(O||!o)return await Z.delete(C),[null,O];let j=l8.encode(J0.stringify(o));return await Z.setBytes(C,j),[o,null]}if(E==="cache-only")return[await V(C),null];if(E==="network-only")return await c(await k());if(E==="cache-first"){let x=await V(C);if(x)return[x,null];return await c(await k())}if(E==="network-first"){let[x,o]=await k();if(x)return await c([x,null]);if(x=await V(C),x)return[x,null];return[null,o]}throw Error(`invalid strategy for _query: ${E}`)},async invalidate(A){if(A.startsWith("trpc:")){await Z.delete(A),delete W[A],z(A);return}let M=A,J=`${M}.query`,E=[];for(let L of await Z.keys()){if(!L.startsWith("trpc:"))continue;if(L.split(":")[1]!==J)continue;E.push(Z.delete(L)),delete W[L]}for(let L of Object.keys(W)){if(!L.startsWith("trpc:"))continue;if(L.split(":")[1]===J)delete W[L]}await Promise.all(E),z(M)},async invalidateCascading(A){let M=A;if(A.startsWith("trpc:")){if(M=A.split(":")[1]??"",M.endsWith(".query"))M=M.slice(0,-6)}if(!M.includes("."))return;let J=M.split(".").slice(0,-1).join("."),E=[];for(let L of await Z.keys()){if(!L.startsWith("trpc:"))continue;let C=L.split(":")[1];if(!C.endsWith(".query"))continue;let k=C.slice(0,-6);if(k===J||k.startsWith(`${J}.`))E.push(Z.delete(L)),delete W[L]}for(let L of Object.keys(W)){if(!L.startsWith("trpc:"))continue;let C=L.split(":")[1];if(!C.endsWith(".query"))continue;let k=C.slice(0,-6);if(k===J||k.startsWith(`${J}.`))delete W[L]}await Promise.all(E);for(let[L,C]of D){let k=L.split(":")[1];if(!k.endsWith(".query"))continue;let c=k.slice(0,-6);if(c===J||c.startsWith(`${J}.`))(async()=>C())()}},streamQuery(A,M,J){J??={},J.strategy??="cache-first";let E=G;for(let O of`${A}.query`.split("."))E=E?.[O];if(!E)throw Error(`could not resolve query path ${A}`);let L=Y(A,M);async function C(){try{return[await H(L,()=>E(M))??null,null]}catch(O){if(O instanceof f){if(U(O),O?.code==="ConnectionRefused")return[null,null];return[null,O]}return[null,f.from(O)]}}async function k(O){let[j,$]=O;if($||!j)return await Z.delete(L),[null,$];let w0=l8.encode(J0.stringify(j));return await Z.setBytes(L,w0),[j,null]}async function*c(){if(J.strategy==="cache-first"||J.strategy==="cache-only"){let $=await V(L);if($)yield[$,null];if(J.strategy==="cache-only")return}let[O,j]=await k(await C());if(yield[O,j],j&&J?.strategy==="network-first")yield[await V(L),null]}let x=I0(c()),o=new P((O)=>{let j=async()=>{let[$,w0]=await C();if($&&!w0)O.next([$,w0])};return D.push([L,j]),()=>{for(let $=0;$<D.length;$++)if(D[$][1]===j){D.splice($,1);return}}});return b8(x,o)},async mutate(A,M,J){let E=G;for(let L of`${A}.mutate`.split("."))E=E?.[L];if(!E)throw Error(`could not resolve mutation path ${A}`);try{let L=await E(M);return await N.invalidateCascading(A),[L,null]}catch(L){if(U(L),!(L instanceof Error))return[null,Error("unexpected error")];return[null,L]}},async login(A){let[M,J]=await N.mutate("auth.login",A);if(J)throw J;if(!M)throw Error("Login failed: missing response payload");N.setToken(M.token)},setToken(A){if(Q=A,_0()&&typeof localStorage<"u")if(A)localStorage.setItem("__sortsys-v2_token",A);else localStorage.removeItem("__sortsys-v2_token");K()},async logout(){if(await Z.clear(),!Q){N.setToken(null);return}await N.mutate("auth.logout",void 0).catch(()=>{}),N.setToken(null)},listenAuthState:(A)=>{let M=q.subscribe(()=>{A()});return()=>M.unsubscribe()},loggedIn(){return!!Q},async restoreSession(){if(_0())N.setToken(localStorage.getItem("__sortsys-v2_token"))},async clearCache(){return Z.clear()}});function U(A){if(!OB(A))return;N.logout().catch(()=>{})}return N}export{sK as createClient};
|
|
1
|
+
var{create:G1,defineProperty:l0,getOwnPropertyDescriptor:Y1,getOwnPropertyNames:c0,getPrototypeOf:W1}=Object,H1=Object.prototype.hasOwnProperty,y=(X,Z)=>function(){return Z||(0,X[c0(X)[0]])((Z={exports:{}}).exports,Z),Z.exports},V1=(X,Z,B,Q)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(var G=c0(Z),Y=0,W=G.length,H;Y<W;Y++)if(H=G[Y],!H1.call(X,H)&&H!==B)l0(X,H,{get:((V)=>Z[V]).bind(null,H),enumerable:!(Q=Y1(Z,H))||Q.enumerable})}return X},T=(X,Z,B)=>(B=X!=null?G1(W1(X)):{},V1(Z||!X||!X.__esModule?l0(B,"default",{value:X,enumerable:!0}):B,X)),u0=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(X,Z){function B(Q){return Z.exports=B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(G){return typeof G}:function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},Z.exports.__esModule=!0,Z.exports.default=Z.exports,B(Q)}Z.exports=B,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),D1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(X,Z){var B=u0().default;function Q(G,Y){if(B(G)!="object"||!G)return G;var W=G[Symbol.toPrimitive];if(W!==void 0){var H=W.call(G,Y||"default");if(B(H)!="object")return H;throw TypeError("@@toPrimitive must return a primitive value.")}return(Y==="string"?String:Number)(G)}Z.exports=Q,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),K1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(X,Z){var B=u0().default,Q=D1();function G(Y){var W=Q(Y,"string");return B(W)=="symbol"?W:W+""}Z.exports=G,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),v=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(X,Z){var B=K1();function Q(G,Y,W){return(Y=B(Y))in G?Object.defineProperty(G,Y,{value:W,enumerable:!0,configurable:!0,writable:!0}):G[Y]=W,G}Z.exports=Q,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),R=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(X,Z){var B=v();function Q(Y,W){var H=Object.keys(Y);if(Object.getOwnPropertySymbols){var V=Object.getOwnPropertySymbols(Y);W&&(V=V.filter(function(D){return Object.getOwnPropertyDescriptor(Y,D).enumerable})),H.push.apply(H,V)}return H}function G(Y){for(var W=1;W<arguments.length;W++){var H=arguments[W]!=null?arguments[W]:{};W%2?Q(Object(H),!0).forEach(function(V){B(Y,V,H[V])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(H)):Q(Object(H)).forEach(function(V){Object.defineProperty(Y,V,Object.getOwnPropertyDescriptor(H,V))})}return Y}Z.exports=G,Z.exports.__esModule=!0,Z.exports.default=Z.exports}});function m(X){let Z={subscribe(B){let Q=null,G=!1,Y=!1,W=!1;function H(){if(Q===null){W=!0;return}if(Y)return;if(Y=!0,typeof Q==="function")Q();else if(Q)Q.unsubscribe()}if(Q=X({next(V){var D;if(G)return;(D=B.next)===null||D===void 0||D.call(B,V)},error(V){var D;if(G)return;G=!0,(D=B.error)===null||D===void 0||D.call(B,V),H()},complete(){var V;if(G)return;G=!0,(V=B.complete)===null||V===void 0||V.call(B),H()}}),W)H();return{unsubscribe:H}},pipe(...B){return B.reduce(A1,Z)}};return Z}function A1(X,Z){return Z(X)}function H0(X){let Z=new AbortController;return new Promise((Q,G)=>{let Y=!1;function W(){if(Y)return;Y=!0,H.unsubscribe()}Z.signal.addEventListener("abort",()=>{G(Z.signal.reason)});let H=X.subscribe({next(V){Y=!0,Q(V),W()},error(V){G(V)},complete(){Z.abort(),W()}})})}function V0(X){return(Z)=>{let B=0,Q=null,G=[];function Y(){if(Q)return;Q=Z.subscribe({next(H){for(let D of G){var V;(V=D.next)===null||V===void 0||V.call(D,H)}},error(H){for(let D of G){var V;(V=D.error)===null||V===void 0||V.call(D,H)}},complete(){for(let V of G){var H;(H=V.complete)===null||H===void 0||H.call(V)}}})}function W(){if(B===0&&Q){let H=Q;Q=null,H.unsubscribe()}}return m((H)=>{return B++,G.push(H),Y(),{unsubscribe(){B--,W();let V=G.findIndex((D)=>D===H);if(V>-1)G.splice(V,1)}}})}}var fZ=Symbol();function T8(X){let Z=X,B=[],Q=(W)=>{if(Z!==void 0)W.next(Z);B.push(W)},G=(W)=>{B.splice(B.indexOf(W),1)},Y=m((W)=>{return Q(W),()=>{G(W)}});return Y.next=(W)=>{if(Z===W)return;Z=W;for(let H of B)H.next(W)},Y.get=()=>Z,Y}function p0(X){return m((Z)=>{function B(G=0,Y=X.op){let W=X.links[G];if(!W)throw Error("No more links to execute - did you forget to add an ending link?");return W({op:Y,next(V){return B(G+1,V)}})}return B().subscribe(Z)})}var A8={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603,UNAUTHORIZED:-32001,PAYMENT_REQUIRED:-32002,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNSUPPORTED_MEDIA_TYPE:-32015,UNPROCESSABLE_CONTENT:-32022,PRECONDITION_REQUIRED:-32028,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};var n0=[A8.BAD_GATEWAY,A8.SERVICE_UNAVAILABLE,A8.GATEWAY_TIMEOUT,A8.INTERNAL_SERVER_ERROR];function c(X){return!!X&&!Array.isArray(X)&&typeof X==="object"}var{create:U1,defineProperty:a0,getOwnPropertyDescriptor:q1,getOwnPropertyNames:o0,getPrototypeOf:z1}=Object,N1=Object.prototype.hasOwnProperty,U8=(X,Z)=>function(){return Z||(0,X[o0(X)[0]])((Z={exports:{}}).exports,Z),Z.exports},F1=(X,Z,B,Q)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(var G=o0(Z),Y=0,W=G.length,H;Y<W;Y++)if(H=G[Y],!N1.call(X,H)&&H!==B)a0(X,H,{get:((V)=>Z[V]).bind(null,H),enumerable:!(Q=q1(Z,H))||Q.enumerable})}return X},q8=(X,Z,B)=>(B=X!=null?U1(z1(X)):{},F1(Z||!X||!X.__esModule?a0(B,"default",{value:X,enumerable:!0}):B,X)),s0=()=>{},i0=(X)=>{if(Object.freeze)Object.freeze(X)};function t0(X,Z,B){var Q;let G=Z.join(".");return(Q=B[G])!==null&&Q!==void 0||(B[G]=new Proxy(s0,{get(Y,W){if(typeof W!=="string"||W==="then")return;return t0(X,[...Z,W],B)},apply(Y,W,H){let V=Z[Z.length-1],D={args:H,path:Z};if(V==="call")D={args:H.length>=2?[H[1]]:[],path:Z.slice(0,-1)};else if(V==="apply")D={args:H.length>=2?H[1]:[],path:Z.slice(0,-1)};return i0(D.args),i0(D.path),X(D)}})),B[G]}var E8=(X)=>t0(X,[],Object.create(null)),D0=(X)=>{return new Proxy(s0,{get(Z,B){if(B==="then")return;return X(B)}})};var r0=U8({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(X,Z){function B(Q){return Z.exports=B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(G){return typeof G}:function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},Z.exports.__esModule=!0,Z.exports.default=Z.exports,B(Q)}Z.exports=B,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),J1=U8({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(X,Z){var B=r0().default;function Q(G,Y){if(B(G)!="object"||!G)return G;var W=G[Symbol.toPrimitive];if(W!==void 0){var H=W.call(G,Y||"default");if(B(H)!="object")return H;throw TypeError("@@toPrimitive must return a primitive value.")}return(Y==="string"?String:Number)(G)}Z.exports=Q,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),M1=U8({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(X,Z){var B=r0().default,Q=J1();function G(Y){var W=Q(Y,"string");return B(W)=="symbol"?W:W+""}Z.exports=G,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),K0=U8({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(X,Z){var B=M1();function Q(G,Y,W){return(Y=B(Y))in G?Object.defineProperty(G,Y,{value:W,enumerable:!0,configurable:!0,writable:!0}):G[Y]=W,G}Z.exports=Q,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),x8=U8({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(X,Z){var B=K0();function Q(Y,W){var H=Object.keys(Y);if(Object.getOwnPropertySymbols){var V=Object.getOwnPropertySymbols(Y);W&&(V=V.filter(function(D){return Object.getOwnPropertyDescriptor(Y,D).enumerable})),H.push.apply(H,V)}return H}function G(Y){for(var W=1;W<arguments.length;W++){var H=arguments[W]!=null?arguments[W]:{};W%2?Q(Object(H),!0).forEach(function(V){B(Y,V,H[V])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(H)):Q(Object(H)).forEach(function(V){Object.defineProperty(Y,V,Object.getOwnPropertyDescriptor(H,V))})}return Y}Z.exports=G,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),pZ=q8(x8(),1);var oZ=q8(K0(),1);var C8=q8(x8(),1);function T1(X,Z){if("error"in X){let Q=Z.deserialize(X.error);return{ok:!1,error:(0,C8.default)((0,C8.default)({},X),{},{error:Q})}}return{ok:!0,result:(0,C8.default)((0,C8.default)({},X.result),(!X.result.type||X.result.type==="data")&&{type:"data",data:Z.deserialize(X.result.data)})}}var A0=class extends Error{constructor(){super("Unable to transform response from server")}};function U0(X,Z){let B;try{B=T1(X,Z)}catch(Q){throw new A0}if(!B.ok&&(!c(B.error.error)||typeof B.error.error.code!=="number"))throw new A0;if(B.ok&&!c(B.result))throw new A0;return B}var sZ=q8(x8(),1);var tZ=Symbol();var P8=T(v(),1),Z8=T(R(),1);function e0(X){return X instanceof f}function P1(X){return c(X)&&c(X.error)&&typeof X.error.code==="number"&&typeof X.error.message==="string"}function R1(X,Z){if(typeof X==="string")return X;if(c(X)&&typeof X.message==="string")return X.message;return Z}var f=class X extends Error{constructor(Z,B){var Q,G;let Y=B===null||B===void 0?void 0:B.cause;super(Z,{cause:Y});(0,P8.default)(this,"cause",void 0),(0,P8.default)(this,"shape",void 0),(0,P8.default)(this,"data",void 0),(0,P8.default)(this,"meta",void 0),this.meta=B===null||B===void 0?void 0:B.meta,this.cause=Y,this.shape=B===null||B===void 0||(Q=B.result)===null||Q===void 0?void 0:Q.error,this.data=B===null||B===void 0||(G=B.result)===null||G===void 0?void 0:G.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,X.prototype)}static from(Z,B={}){let Q=Z;if(e0(Q)){if(B.meta)Q.meta=(0,Z8.default)((0,Z8.default)({},Q.meta),B.meta);return Q}if(P1(Q))return new X(Q.error.message,(0,Z8.default)((0,Z8.default)({},B),{},{result:Q}));return new X(R1(Q,"Unknown error"),(0,Z8.default)((0,Z8.default)({},B),{},{cause:Q}))}};function R8(X){let Z=X;if(!Z)return{input:{serialize:(B)=>B,deserialize:(B)=>B},output:{serialize:(B)=>B,deserialize:(B)=>B}};if("input"in Z)return Z;return{input:Z,output:Z}}var XX=(X)=>typeof X==="function";function ZX(X){if(X)return X;if(typeof window<"u"&&XX(window.fetch))return window.fetch;if(typeof globalThis<"u"&&XX(globalThis.fetch))return globalThis.fetch;throw Error("No fetch implementation found")}var z8=T(R(),1);function O8(X){return{url:X.url.toString(),fetch:X.fetch,transformer:R8(X.transformer),methodOverride:X.methodOverride}}function O1(X){let Z={};for(let B=0;B<X.length;B++){let Q=X[B];Z[B]=Q}return Z}var k1={query:"GET",mutation:"POST",subscription:"PATCH"};function BX(X){return"input"in X?X.transformer.input.serialize(X.input):O1(X.inputs.map((Z)=>X.transformer.input.serialize(Z)))}var N8=(X)=>{let Z=X.url.split("?"),Q=Z[0].replace(/\/$/,"")+"/"+X.path,G=[];if(Z[1])G.push(Z[1]);if("inputs"in X)G.push("batch=1");if(X.type==="query"||X.type==="subscription"){let Y=BX(X);if(Y!==void 0&&X.methodOverride!=="POST")G.push(`input=${encodeURIComponent(JSON.stringify(Y))}`)}if(G.length)Q+="?"+G.join("&");return Q},QX=(X)=>{if(X.type==="query"&&X.methodOverride!=="POST")return;let Z=BX(X);return Z!==void 0?JSON.stringify(Z):void 0},q0=(X)=>{return YX((0,z8.default)((0,z8.default)({},X),{},{contentTypeHeader:"application/json",getUrl:N8,getBody:QX}))},$1=class extends Error{constructor(){super("AbortError");this.name="AbortError",this.message="AbortError"}},f1=(X)=>{var Z;if(!(X===null||X===void 0?void 0:X.aborted))return;if((Z=X.throwIfAborted)===null||Z===void 0||Z.call(X),typeof DOMException<"u")throw new DOMException("AbortError","AbortError");throw new $1};async function GX(X){var Z;f1(X.signal);let B=X.getUrl(X),Q=X.getBody(X),G=(Z=X.methodOverride)!==null&&Z!==void 0?Z:k1[X.type],Y=await(async()=>{let H=await X.headers();if(Symbol.iterator in H)return Object.fromEntries(H);return H})(),W=(0,z8.default)((0,z8.default)((0,z8.default)({},X.contentTypeHeader&&G!=="GET"?{"content-type":X.contentTypeHeader}:{}),X.trpcAcceptHeader?{"trpc-accept":X.trpcAcceptHeader}:void 0),Y);return ZX(X.fetch)(B,{method:G,signal:X.signal,body:Q,headers:W})}async function YX(X){let Z={},B=await GX(X);Z.response=B;let Q=await B.json();return Z.responseJSON=Q,{json:Q,meta:Z}}var c7=T(R(),1);var WX=()=>{throw Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function z0(X){let Z=null,B=null,Q=()=>{clearTimeout(B),B=null,Z=null};function G(H){let V=[[]],D=0;while(!0){let F=H[D];if(!F)break;let K=V[V.length-1];if(F.aborted){var z;(z=F.reject)===null||z===void 0||z.call(F,Error("Aborted")),D++;continue}if(X.validate(K.concat(F).map((U)=>U.key))){K.push(F),D++;continue}if(K.length===0){var q;(q=F.reject)===null||q===void 0||q.call(F,Error("Input is too big for a single dispatch")),D++;continue}V.push([])}return V}function Y(){let H=G(Z);Q();for(let V of H){if(!V.length)continue;let D={items:V};for(let q of V)q.batch=D;X.fetch(D.items.map((q)=>q.key)).then(async(q)=>{await Promise.all(q.map(async(K,N)=>{let U=D.items[N];try{var A;let J=await Promise.resolve(K);(A=U.resolve)===null||A===void 0||A.call(U,J)}catch(J){var M;(M=U.reject)===null||M===void 0||M.call(U,J)}U.batch=null,U.reject=null,U.resolve=null}));for(let K of D.items){var F;(F=K.reject)===null||F===void 0||F.call(K,Error("Missing result")),K.batch=null}}).catch((q)=>{for(let K of D.items){var F;(F=K.reject)===null||F===void 0||F.call(K,q),K.batch=null}})}}function W(H){var V;let D={aborted:!1,key:H,batch:null,resolve:WX,reject:WX},z=new Promise((q,F)=>{var K;D.reject=F,D.resolve=q,(K=Z)!==null&&K!==void 0||(Z=[]),Z.push(D)});return(V=B)!==null&&V!==void 0||(B=setTimeout(Y)),z}return{load:W}}function HX(...X){let Z=new AbortController,B=X.length,Q=0,G=()=>{if(++Q===B)Z.abort()};for(let Y of X)if(Y===null||Y===void 0?void 0:Y.aborted)G();else Y===null||Y===void 0||Y.addEventListener("abort",G,{once:!0});return Z.signal}var k8=T(R(),1);function N0(X){var Z,B;let Q=O8(X),G=(Z=X.maxURLLength)!==null&&Z!==void 0?Z:1/0,Y=(B=X.maxItems)!==null&&B!==void 0?B:1/0;return()=>{let W=(z)=>{return{validate(q){if(G===1/0&&Y===1/0)return!0;if(q.length>Y)return!1;let F=q.map((U)=>U.path).join(","),K=q.map((U)=>U.input);return N8((0,k8.default)((0,k8.default)({},Q),{},{type:z,path:F,inputs:K,signal:null})).length<=G},async fetch(q){let F=q.map((J)=>J.path).join(","),K=q.map((J)=>J.input),N=HX(...q.map((J)=>J.signal)),U=await q0((0,k8.default)((0,k8.default)({},Q),{},{path:F,inputs:K,type:z,headers(){if(!X.headers)return{};if(typeof X.headers==="function")return X.headers({opList:q});return X.headers},signal:N}));return(Array.isArray(U.json)?U.json:q.map(()=>U.json)).map((J)=>({meta:U.meta,json:J}))}}},H=z0(W("query")),V=z0(W("mutation")),D={query:H,mutation:V};return({op:z})=>{return m((q)=>{if(z.type==="subscription")throw Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");let K=D[z.type].load(z),N=void 0;return K.then((U)=>{N=U;let A=U0(U.json,Q.transformer.output);if(!A.ok){q.error(f.from(A.error,{meta:U.meta}));return}q.next({context:U.meta,result:A.result}),q.complete()}).catch((U)=>{q.error(f.from(U,{meta:N===null||N===void 0?void 0:N.meta}))}),()=>{}})}}}var r7=T(R(),1);var F0=(X,...Z)=>{return typeof X==="function"?X(...Z):X},GB=T(v(),1);function S1(){let X,Z;return{promise:new Promise((Q,G)=>{X=Q,Z=G}),resolve:X,reject:Z}}async function j1(X){let Z=await F0(X.url);if(!X.connectionParams)return Z;let Q=`${Z.includes("?")?"&":"?"}connectionParams=1`;return Z+Q}async function y1(X){let Z={method:"connectionParams",data:await F0(X)};return JSON.stringify(Z)}var YB=T(v(),1);var o=T(v(),1);function g1(X){let{promise:Z,resolve:B,reject:Q}=S1();return X.addEventListener("open",()=>{X.removeEventListener("error",Q),B()}),X.addEventListener("error",Q),Z}function h1(X,{intervalMs:Z,pongTimeoutMs:B}){let Q,G;function Y(){Q=setTimeout(()=>{X.send("PING"),G=setTimeout(()=>{X.close()},B)},Z)}function W(){clearTimeout(Q),Y()}function H(){clearTimeout(G),W()}X.addEventListener("open",Y),X.addEventListener("message",({data:V})=>{if(clearTimeout(Q),Y(),V==="PONG")H()}),X.addEventListener("close",()=>{clearTimeout(Q),clearTimeout(G)})}var v1=class X{constructor(Z){var B;if((0,o.default)(this,"id",++X.connectCount),(0,o.default)(this,"WebSocketPonyfill",void 0),(0,o.default)(this,"urlOptions",void 0),(0,o.default)(this,"keepAliveOpts",void 0),(0,o.default)(this,"wsObservable",T8(null)),(0,o.default)(this,"openPromise",null),this.WebSocketPonyfill=(B=Z.WebSocketPonyfill)!==null&&B!==void 0?B:WebSocket,!this.WebSocketPonyfill)throw 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");this.urlOptions=Z.urlOptions,this.keepAliveOpts=Z.keepAlive}get ws(){return this.wsObservable.get()}set ws(Z){this.wsObservable.next(Z)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var Z=this;if(Z.openPromise)return Z.openPromise;Z.id=++X.connectCount;let B=j1(Z.urlOptions).then((Q)=>new Z.WebSocketPonyfill(Q));Z.openPromise=B.then(async(Q)=>{if(Z.ws=Q,Q.addEventListener("message",function({data:G}){if(G==="PING")this.send("PONG")}),Z.keepAliveOpts.enabled)h1(Q,Z.keepAliveOpts);if(Q.addEventListener("close",()=>{if(Z.ws===Q)Z.ws=null}),await g1(Q),Z.urlOptions.connectionParams)Q.send(await y1(Z.urlOptions.connectionParams))});try{await Z.openPromise}finally{Z.openPromise=null}}async close(){var Z=this;try{await Z.openPromise}finally{var B;(B=Z.ws)===null||B===void 0||B.close()}}};(0,o.default)(v1,"connectCount",0);var WB=T(v(),1),HB=T(R(),1);var J0=T(v(),1),VX=T(R(),1),m1=class{constructor(X){(0,J0.default)(this,"links",void 0),(0,J0.default)(this,"runtime",void 0),(0,J0.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=X.links.map((Z)=>Z(this.runtime))}$request(X){var Z;return p0({links:this.links,op:(0,VX.default)((0,VX.default)({},X),{},{context:(Z=X.context)!==null&&Z!==void 0?Z:{},id:++this.requestId})}).pipe(V0())}async requestAsPromise(X){var Z=this;try{let B=Z.$request(X);return(await H0(B)).result.data}catch(B){throw f.from(B)}}query(X,Z,B){return this.requestAsPromise({type:"query",path:X,input:Z,context:B===null||B===void 0?void 0:B.context,signal:B===null||B===void 0?void 0:B.signal})}mutation(X,Z,B){return this.requestAsPromise({type:"mutation",path:X,input:Z,context:B===null||B===void 0?void 0:B.context,signal:B===null||B===void 0?void 0:B.signal})}subscription(X,Z,B){return this.$request({type:"subscription",path:X,input:Z,context:B.context,signal:B.signal}).subscribe({next(G){switch(G.result.type){case"state":{var Y;(Y=B.onConnectionStateChange)===null||Y===void 0||Y.call(B,G.result);break}case"started":{var W;(W=B.onStarted)===null||W===void 0||W.call(B,{context:G.context});break}case"stopped":{var H;(H=B.onStopped)===null||H===void 0||H.call(B);break}case"data":case void 0:{var V;(V=B.onData)===null||V===void 0||V.call(B,G.result.data);break}}},error(G){var Y;(Y=B.onError)===null||Y===void 0||Y.call(B,G)},complete(){var G;(G=B.onComplete)===null||G===void 0||G.call(B)}})}};var d1=Symbol.for("trpc_untypedClient"),_1={query:"query",mutate:"mutation",subscribe:"subscription"},b1=(X)=>{return _1[X]};function l1(X){let Z=E8(({path:B,args:Q})=>{let G=[...B],Y=b1(G.pop()),W=G.join(".");return X[Y](W,...Q)});return D0((B)=>{if(B===d1)return X;return Z[B]})}function DX(X){let Z=new m1(X);return l1(Z)}var gB=T(R(),1);var hB=T(R(),1);var c1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(X,Z){function B(G){var Y,W,H,V=2;for(typeof Symbol<"u"&&(W=Symbol.asyncIterator,H=Symbol.iterator);V--;){if(W&&(Y=G[W])!=null)return Y.call(G);if(H&&(Y=G[H])!=null)return new Q(Y.call(G));W="@@asyncIterator",H="@@iterator"}throw TypeError("Object is not async iterable")}function Q(G){function Y(W){if(Object(W)!==W)return Promise.reject(TypeError(W+" is not an object."));var H=W.done;return Promise.resolve(W.value).then(function(V){return{value:V,done:H}})}return Q=function(H){this.s=H,this.n=H.next},Q.prototype={s:null,n:null,next:function(){return Y(this.n.apply(this.s,arguments))},return:function(H){var V=this.s.return;return V===void 0?Promise.resolve({value:H,done:!0}):Y(V.apply(this.s,arguments))},throw:function(H){var V=this.s.return;return V===void 0?Promise.reject(H):Y(V.apply(this.s,arguments))}},new Q(G)}Z.exports=B,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),vB=T(c1(),1);var mB=T(R(),1);var u1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(X,Z){function B(){var Q=typeof SuppressedError=="function"?SuppressedError:function(H,V){var D=Error();return D.name="SuppressedError",D.error=H,D.suppressed=V,D},G={},Y=[];function W(H,V){if(V!=null){if(Object(V)!==V)throw TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(H)var D=V[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(D===void 0&&(D=V[Symbol.dispose||Symbol.for("Symbol.dispose")],H))var z=D;if(typeof D!="function")throw TypeError("Object is not disposable.");z&&(D=function(){try{z.call(V)}catch(F){return Promise.reject(F)}}),Y.push({v:V,d:D,a:H})}else H&&Y.push({d:V,a:H});return V}return{e:G,u:W.bind(null,!1),a:W.bind(null,!0),d:function(){var V,D=this.e,z=0;function q(){for(;V=Y.pop();)try{if(!V.a&&z===1)return z=0,Y.push(V),Promise.resolve().then(q);if(V.d){var K=V.d.call(V.v);if(V.a)return z|=2,Promise.resolve(K).then(q,F)}else z|=1}catch(N){return F(N)}if(z===1)return D!==G?Promise.reject(D):Promise.resolve();if(D!==G)throw D}function F(K){return D=D!==G?new Q(K,D):K,q()}return q()}}}Z.exports=B,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),KX=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(X,Z){function B(Q,G){this.v=Q,this.k=G}Z.exports=B,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),p1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(X,Z){var B=KX();function Q(G){return new B(G,0)}Z.exports=Q,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),n1=y({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(X,Z){var B=KX();function Q(Y){return function(){return new G(Y.apply(this,arguments))}}function G(Y){var W,H;function V(z,q){try{var F=Y[z](q),K=F.value,N=K instanceof B;Promise.resolve(N?K.v:K).then(function(U){if(N){var A=z==="return"?"return":"next";if(!K.k||U.done)return V(A,U);U=Y[A](U).value}D(F.done?"return":"normal",U)},function(U){V("throw",U)})}catch(U){D("throw",U)}}function D(z,q){switch(z){case"return":W.resolve({value:q,done:!0});break;case"throw":W.reject(q);break;default:W.resolve({value:q,done:!1})}(W=W.next)?V(W.key,W.arg):H=null}this._invoke=function(z,q){return new Promise(function(F,K){var N={key:z,arg:q,resolve:F,reject:K,next:null};H?H=H.next=N:(W=H=N,V(z,q))})},typeof Y.return!="function"&&(this.return=void 0)}G.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},G.prototype.next=function(Y){return this._invoke("next",Y)},G.prototype.throw=function(Y){return this._invoke("throw",Y)},G.prototype.return=function(Y){return this._invoke("return",Y)},Z.exports=Q,Z.exports.__esModule=!0,Z.exports.default=Z.exports}}),dB=T(u1(),1),_B=T(p1(),1),bB=T(n1(),1),lB=T(R(),1);class M0{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(X,Z){this.keyToValue.set(X,Z),this.valueToKey.set(Z,X)}getByKey(X){return this.keyToValue.get(X)}getByValue(X){return this.valueToKey.get(X)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class F8{constructor(X){this.generateIdentifier=X,this.kv=new M0}register(X,Z){if(this.kv.getByValue(X))return;if(!Z)Z=this.generateIdentifier(X);this.kv.set(Z,X)}clear(){this.kv.clear()}getIdentifier(X){return this.kv.getByValue(X)}getValue(X){return this.kv.getByKey(X)}}class L0 extends F8{constructor(){super((X)=>X.name);this.classToAllowedProps=new Map}register(X,Z){if(typeof Z==="object"){if(Z.allowProps)this.classToAllowedProps.set(X,Z.allowProps);super.register(X,Z.identifier)}else super.register(X,Z)}getAllowedProps(X){return this.classToAllowedProps.get(X)}}function i1(X){if("values"in Object)return Object.values(X);let Z=[];for(let B in X)if(X.hasOwnProperty(B))Z.push(X[B]);return Z}function AX(X,Z){let B=i1(X);if("find"in B)return B.find(Z);let Q=B;for(let G=0;G<Q.length;G++){let Y=Q[G];if(Z(Y))return Y}return}function s(X,Z){Object.entries(X).forEach(([B,Q])=>Z(Q,B))}function B8(X,Z){return X.indexOf(Z)!==-1}function I0(X,Z){for(let B=0;B<X.length;B++){let Q=X[B];if(Z(Q))return Q}return}class w0{constructor(){this.transfomers={}}register(X){this.transfomers[X.name]=X}findApplicable(X){return AX(this.transfomers,(Z)=>Z.isApplicable(X))}findByName(X){return this.transfomers[X]}}var a1=(X)=>Object.prototype.toString.call(X).slice(8,-1),T0=(X)=>typeof X>"u",o1=(X)=>X===null,t=(X)=>{if(typeof X!=="object"||X===null)return!1;if(X===Object.prototype)return!1;if(Object.getPrototypeOf(X)===null)return!0;return Object.getPrototypeOf(X)===Object.prototype},$8=(X)=>t(X)&&Object.keys(X).length===0,g=(X)=>Array.isArray(X),s1=(X)=>typeof X==="string",t1=(X)=>typeof X==="number"&&!isNaN(X),r1=(X)=>typeof X==="boolean",UX=(X)=>X instanceof RegExp,u=(X)=>X instanceof Map,p=(X)=>X instanceof Set,E0=(X)=>a1(X)==="Symbol",qX=(X)=>X instanceof Date&&!isNaN(X.valueOf()),f8=(X)=>X instanceof Error,x0=(X)=>typeof X==="number"&&isNaN(X),zX=(X)=>r1(X)||o1(X)||T0(X)||t1(X)||s1(X)||E0(X),NX=(X)=>typeof X==="bigint",FX=(X)=>X===1/0||X===-1/0,JX=(X)=>ArrayBuffer.isView(X)&&!(X instanceof DataView),MX=(X)=>X instanceof URL;var S8=(X)=>X.replace(/\\/g,"\\\\").replace(/\./g,"\\."),j8=(X)=>X.map(String).map(S8).join("."),Q8=(X,Z)=>{let B=[],Q="";for(let Y=0;Y<X.length;Y++){let W=X.charAt(Y);if(!Z&&W==="\\"){let D=X.charAt(Y+1);if(D==="\\"){Q+="\\",Y++;continue}else if(D!==".")throw Error("invalid path")}if(W==="\\"&&X.charAt(Y+1)==="."){Q+=".",Y++;continue}if(W==="."){B.push(Q),Q="";continue}Q+=W}let G=Q;return B.push(G),B};function d(X,Z,B,Q){return{isApplicable:X,annotation:Z,transform:B,untransform:Q}}var LX=[d(T0,"undefined",()=>null,()=>{return}),d(NX,"bigint",(X)=>X.toString(),(X)=>{if(typeof BigInt<"u")return BigInt(X);return console.error("Please add a BigInt polyfill."),X}),d(qX,"Date",(X)=>X.toISOString(),(X)=>new Date(X)),d(f8,"Error",(X,Z)=>{let B={name:X.name,message:X.message};if("cause"in X)B.cause=X.cause;return Z.allowedErrorProps.forEach((Q)=>{B[Q]=X[Q]}),B},(X,Z)=>{let B=Error(X.message,{cause:X.cause});return B.name=X.name,B.stack=X.stack,Z.allowedErrorProps.forEach((Q)=>{B[Q]=X[Q]}),B}),d(UX,"regexp",(X)=>""+X,(X)=>{let Z=X.slice(1,X.lastIndexOf("/")),B=X.slice(X.lastIndexOf("/")+1);return new RegExp(Z,B)}),d(p,"set",(X)=>[...X.values()],(X)=>new Set(X)),d(u,"map",(X)=>[...X.entries()],(X)=>new Map(X)),d((X)=>x0(X)||FX(X),"number",(X)=>{if(x0(X))return"NaN";if(X>0)return"Infinity";else return"-Infinity"},Number),d((X)=>X===0&&1/X===-1/0,"number",()=>{return"-0"},Number),d(MX,"URL",(X)=>X.toString(),(X)=>new URL(X))];function y8(X,Z,B,Q){return{isApplicable:X,annotation:Z,transform:B,untransform:Q}}var IX=y8((X,Z)=>{if(E0(X))return!!Z.symbolRegistry.getIdentifier(X);return!1},(X,Z)=>{return["symbol",Z.symbolRegistry.getIdentifier(X)]},(X)=>X.description,(X,Z,B)=>{let Q=B.symbolRegistry.getValue(Z[1]);if(!Q)throw Error("Trying to deserialize unknown symbol");return Q}),e1=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((X,Z)=>{return X[Z.name]=Z,X},{}),wX=y8(JX,(X)=>["typed-array",X.constructor.name],(X)=>[...X],(X,Z)=>{let B=e1[Z[1]];if(!B)throw Error("Trying to deserialize unknown typed array");return new B(X)});function C0(X,Z){if(X?.constructor)return!!Z.classRegistry.getIdentifier(X.constructor);return!1}var TX=y8(C0,(X,Z)=>{return["class",Z.classRegistry.getIdentifier(X.constructor)]},(X,Z)=>{let B=Z.classRegistry.getAllowedProps(X.constructor);if(!B)return{...X};let Q={};return B.forEach((G)=>{Q[G]=X[G]}),Q},(X,Z,B)=>{let Q=B.classRegistry.getValue(Z[1]);if(!Q)throw Error(`Trying to deserialize unknown class '${Z[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(Q.prototype),X)}),EX=y8((X,Z)=>{return!!Z.customTransformerRegistry.findApplicable(X)},(X,Z)=>{return["custom",Z.customTransformerRegistry.findApplicable(X).name]},(X,Z)=>{return Z.customTransformerRegistry.findApplicable(X).serialize(X)},(X,Z,B)=>{let Q=B.customTransformerRegistry.findByName(Z[1]);if(!Q)throw Error("Trying to deserialize unknown custom value");return Q.deserialize(X)}),XZ=[TX,IX,EX,wX],P0=(X,Z)=>{let B=I0(XZ,(G)=>G.isApplicable(X,Z));if(B)return{value:B.transform(X,Z),type:B.annotation(X,Z)};let Q=I0(LX,(G)=>G.isApplicable(X,Z));if(Q)return{value:Q.transform(X,Z),type:Q.annotation};return},xX={};LX.forEach((X)=>{xX[X.annotation]=X});var CX=(X,Z,B)=>{if(g(Z))switch(Z[0]){case"symbol":return IX.untransform(X,Z,B);case"class":return TX.untransform(X,Z,B);case"custom":return EX.untransform(X,Z,B);case"typed-array":return wX.untransform(X,Z,B);default:throw Error("Unknown transformation: "+Z)}else{let Q=xX[Z];if(!Q)throw Error("Unknown transformation: "+Z);return Q.untransform(X,B)}};var G8=(X,Z)=>{if(Z>X.size)throw Error("index out of bounds");let B=X.keys();while(Z>0)B.next(),Z--;return B.next().value};function PX(X){if(B8(X,"__proto__"))throw Error("__proto__ is not allowed as a property");if(B8(X,"prototype"))throw Error("prototype is not allowed as a property");if(B8(X,"constructor"))throw Error("constructor is not allowed as a property")}var RX=(X,Z)=>{PX(Z);for(let B=0;B<Z.length;B++){let Q=Z[B];if(p(X))X=G8(X,+Q);else if(u(X)){let G=+Q,Y=+Z[++B]===0?"key":"value",W=G8(X,G);switch(Y){case"key":X=W;break;case"value":X=X.get(W);break}}else X=X[Q]}return X},g8=(X,Z,B)=>{if(PX(Z),Z.length===0)return B(X);let Q=X;for(let Y=0;Y<Z.length-1;Y++){let W=Z[Y];if(g(Q)){let H=+W;Q=Q[H]}else if(t(Q))Q=Q[W];else if(p(Q)){let H=+W;Q=G8(Q,H)}else if(u(Q)){if(Y===Z.length-2)break;let V=+W,D=+Z[++Y]===0?"key":"value",z=G8(Q,V);switch(D){case"key":Q=z;break;case"value":Q=Q.get(z);break}}}let G=Z[Z.length-1];if(g(Q))Q[+G]=B(Q[+G]);else if(t(Q))Q[G]=B(Q[G]);if(p(Q)){let Y=G8(Q,+G),W=B(Y);if(Y!==W)Q.delete(Y),Q.add(W)}if(u(Q)){let Y=+Z[Z.length-2],W=G8(Q,Y);switch(+G===0?"key":"value"){case"key":{let V=B(W);if(Q.set(V,Q.get(W)),V!==W)Q.delete(W);break}case"value":{Q.set(W,B(Q.get(W)));break}}}return X};var OX=(X)=>X<1;function R0(X,Z,B,Q=[]){if(!X)return;let G=OX(B);if(!g(X)){s(X,(H,V)=>R0(H,Z,B,[...Q,...Q8(V,G)]));return}let[Y,W]=X;if(W)s(W,(H,V)=>{R0(H,Z,B,[...Q,...Q8(V,G)])});Z(Y,Q)}function kX(X,Z,B,Q){return R0(Z,(G,Y)=>{X=g8(X,Y,(W)=>CX(W,G,Q))},B),X}function $X(X,Z,B){let Q=OX(B);function G(Y,W){let H=RX(X,Q8(W,Q));Y.map((V)=>Q8(V,Q)).forEach((V)=>{X=g8(X,V,()=>H)})}if(g(Z)){let[Y,W]=Z;if(Y.forEach((H)=>{X=g8(X,Q8(H,Q),()=>X)}),W)s(W,G)}else s(Z,G);return X}var ZZ=(X,Z)=>t(X)||g(X)||u(X)||p(X)||f8(X)||C0(X,Z);function BZ(X,Z,B){let Q=B.get(X);if(Q)Q.push(Z);else B.set(X,[Z])}function fX(X,Z){let B={},Q=void 0;if(X.forEach((G)=>{if(G.length<=1)return;if(!Z)G=G.map((H)=>H.map(String)).sort((H,V)=>H.length-V.length);let[Y,...W]=G;if(Y.length===0)Q=W.map(j8);else B[j8(Y)]=W.map(j8)}),Q)if($8(B))return[Q];else return[Q,B];else return $8(B)?void 0:B}var O0=(X,Z,B,Q,G=[],Y=[],W=new Map)=>{let H=zX(X);if(!H){BZ(X,G,Z);let K=W.get(X);if(K)return Q?{transformedValue:null}:K}if(!ZZ(X,B)){let K=P0(X,B),N=K?{transformedValue:K.value,annotations:[K.type]}:{transformedValue:X};if(!H)W.set(X,N);return N}if(B8(Y,X))return{transformedValue:null};let V=P0(X,B),D=V?.value??X,z=g(D)?[]:{},q={};s(D,(K,N)=>{if(N==="__proto__"||N==="constructor"||N==="prototype")throw Error(`Detected property ${N}. This is a prototype pollution risk, please remove it from your object.`);let U=O0(K,Z,B,Q,[...G,N],[...Y,X],W);if(z[N]=U.transformedValue,g(U.annotations))q[S8(N)]=U.annotations;else if(t(U.annotations))s(U.annotations,(A,M)=>{q[S8(N)+"."+M]=A})});let F=$8(q)?{transformedValue:z,annotations:V?[V.type]:void 0}:{transformedValue:z,annotations:V?[V.type,q]:q};if(!H)W.set(X,F);return F};function h8(X){return Object.prototype.toString.call(X).slice(8,-1)}function v8(X){return h8(X)==="Array"}function k0(X){if(h8(X)!=="Object")return!1;let Z=Object.getPrototypeOf(X);return!!Z&&Z.constructor===Object&&Z===Object.prototype}function QZ(X,Z,B,Q,G){let Y={}.propertyIsEnumerable.call(Q,Z)?"enumerable":"nonenumerable";if(Y==="enumerable")X[Z]=B;if(G&&Y==="nonenumerable")Object.defineProperty(X,Z,{value:B,enumerable:!1,writable:!0,configurable:!0})}function m8(X,Z={}){if(v8(X))return X.map((G)=>m8(G,Z));if(!k0(X))return X;let B=Object.getOwnPropertyNames(X),Q=Object.getOwnPropertySymbols(X);return[...B,...Q].reduce((G,Y)=>{if(Y==="__proto__")return G;if(v8(Z.props)&&!Z.props.includes(Y))return G;let W=X[Y],H=m8(W,Z);return QZ(G,Y,H,X,Z.nonenumerable),G},{})}class I{constructor({dedupe:X=!1}={}){this.classRegistry=new L0,this.symbolRegistry=new F8((Z)=>Z.description??""),this.customTransformerRegistry=new w0,this.allowedErrorProps=[],this.dedupe=X}serialize(X){let Z=new Map,B=O0(X,Z,this,this.dedupe),Q={json:B.transformedValue};if(B.annotations)Q.meta={...Q.meta,values:B.annotations};let G=fX(Z,this.dedupe);if(G)Q.meta={...Q.meta,referentialEqualities:G};if(Q.meta)Q.meta.v=1;return Q}deserialize(X,Z){let{json:B,meta:Q}=X,G=Z?.inPlace?B:m8(B);if(Q?.values)G=kX(G,Q.values,Q.v??0,this);if(Q?.referentialEqualities)G=$X(G,Q.referentialEqualities,Q.v??0);return G}stringify(X){return JSON.stringify(this.serialize(X))}parse(X){return this.deserialize(JSON.parse(X),{inPlace:!0})}registerClass(X,Z){this.classRegistry.register(X,Z)}registerSymbol(X,Z){this.symbolRegistry.register(X,Z)}registerCustom(X,Z){this.customTransformerRegistry.register({name:Z,...X})}allowErrorProps(...X){this.allowedErrorProps.push(...X)}}I.defaultInstance=new I;I.serialize=I.defaultInstance.serialize.bind(I.defaultInstance);I.deserialize=I.defaultInstance.deserialize.bind(I.defaultInstance);I.stringify=I.defaultInstance.stringify.bind(I.defaultInstance);I.parse=I.defaultInstance.parse.bind(I.defaultInstance);I.registerClass=I.defaultInstance.registerClass.bind(I.defaultInstance);I.registerSymbol=I.defaultInstance.registerSymbol.bind(I.defaultInstance);I.registerCustom=I.defaultInstance.registerCustom.bind(I.defaultInstance);I.allowErrorProps=I.defaultInstance.allowErrorProps.bind(I.defaultInstance);var J8=I;var{serialize:kQ,deserialize:$Q,stringify:fQ,parse:SQ,registerClass:jQ,registerCustom:yQ,registerSymbol:gQ,allowErrorProps:hQ}=I;var GZ=new TextEncoder,YZ=new TextDecoder;function $0(X){let Z=GZ.encode(X),B="";for(let Q of Z)B+=String.fromCharCode(Q);return btoa(B)}function WZ(X){let Z=atob(X),B=new Uint8Array(Z.length);for(let Q=0;Q<Z.length;Q++)B[Q]=Z.charCodeAt(Q);return YZ.decode(B)}class f0{dbName;storeName;version;db;initP;constructor(X,Z="kv",B=1){this.dbName=X;this.storeName=Z;this.version=B;this.initP=this.open()}async open(){this.db=await new Promise((X,Z)=>{let B=indexedDB.open(this.dbName,this.version);B.onupgradeneeded=()=>{let Q=B.result;if(!Q.objectStoreNames.contains(this.storeName))Q.createObjectStore(this.storeName)},B.onsuccess=()=>{B.result.onversionchange=()=>B.result.close(),X(B.result)},B.onerror=()=>Z(B.error)})}async withTx(X,Z){return await this.initP,new Promise((B,Q)=>{let G=this.db.transaction(this.storeName,X),Y=G.objectStore(this.storeName),W;try{W=Z(Y)}catch(V){G.abort(),Q(V);return}let H;if(W)W.onsuccess=()=>H=W.result,W.onerror=()=>Q(W.error);G.oncomplete=()=>B(H),G.onerror=()=>Q(G.error),G.onabort=()=>Q(G.error)})}async get(X){let Z=$0(X);return await this.withTx("readonly",(Q)=>Q.get(Z))??null}async set(X,Z){let B=$0(X);await this.withTx("readwrite",(Q)=>Q.put(Z,B))}async del(X){let Z=$0(X);await this.withTx("readwrite",(B)=>B.delete(Z))}async clear(){await this.withTx("readwrite",(X)=>X.clear())}async keys(){let X=await this.withTx("readonly",(B)=>B.getAllKeys()),Z=new Set;for(let B of X){if(typeof B!=="string")continue;try{Z.add(WZ(B))}catch{}}return Z}}class S0{maxSize;map=new Map;constructor(X){this.maxSize=X;if(X<=0)throw Error("maxSize must be > 0")}get(X){let Z=this.map.get(X);if(Z===void 0)return;return this.map.delete(X),this.map.set(X,Z),Z}set(X,Z){if(this.map.has(X))this.map.delete(X);if(this.map.set(X,Z),this.map.size>this.maxSize){let B=this.map.keys().next().value;this.map.delete(B)}}delete(X){this.map.delete(X)}clear(){this.map.clear()}keys(){return this.map.keys()}}function d8(){try{return typeof window==="object"}catch(X){return!1}}function SX(){let X=(Q)=>Q.buffer.slice(Q.byteOffset,Q.byteOffset+Q.byteLength),Z=(Q)=>new Uint8Array(Q);if(!d8()||!("indexedDB"in globalThis)){let Q=new S0(500);return{async getBytes(G){let Y=Q.get(G);return Y?new Uint8Array(Y):null},async setBytes(G,Y){Q.set(G,new Uint8Array(Y))},async delete(G){Q.delete(G)},async clear(){Q.clear()},async keys(){return new Set(Q.keys())}}}let B=null;try{B=new f0("sortsys-v2-cache")}catch{throw Error("failed to create cache")}return{async getBytes(Q){let G=await B.get(Q);if(!G)return null;if(G.exp!==0&&G.exp<=Date.now())return await B.del(Q),null;return Z(G.value)},async setBytes(Q,G){let Y={value:X(G),exp:Date.now()+259200000};try{await B.set(Q,Y)}catch{}},async delete(Q){try{await B.del(Q)}catch{}},async clear(){try{await B.clear()}catch{}},async keys(){try{return await B.keys()}catch{return new Set}}}}var j0=function(X,Z){return j0=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(B,Q){B.__proto__=Q}||function(B,Q){for(var G in Q)if(Object.prototype.hasOwnProperty.call(Q,G))B[G]=Q[G]},j0(X,Z)};function n(X,Z){if(typeof Z!=="function"&&Z!==null)throw TypeError("Class extends value "+String(Z)+" is not a constructor or null");j0(X,Z);function B(){this.constructor=X}X.prototype=Z===null?Object.create(Z):(B.prototype=Z.prototype,new B)}function jX(X,Z,B,Q){function G(Y){return Y instanceof B?Y:new B(function(W){W(Y)})}return new(B||(B=Promise))(function(Y,W){function H(z){try{D(Q.next(z))}catch(q){W(q)}}function V(z){try{D(Q.throw(z))}catch(q){W(q)}}function D(z){z.done?Y(z.value):G(z.value).then(H,V)}D((Q=Q.apply(X,Z||[])).next())})}function _8(X,Z){var B={label:0,sent:function(){if(Y[0]&1)throw Y[1];return Y[1]},trys:[],ops:[]},Q,G,Y,W=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return W.next=H(0),W.throw=H(1),W.return=H(2),typeof Symbol==="function"&&(W[Symbol.iterator]=function(){return this}),W;function H(D){return function(z){return V([D,z])}}function V(D){if(Q)throw TypeError("Generator is already executing.");while(W&&(W=0,D[0]&&(B=0)),B)try{if(Q=1,G&&(Y=D[0]&2?G.return:D[0]?G.throw||((Y=G.return)&&Y.call(G),0):G.next)&&!(Y=Y.call(G,D[1])).done)return Y;if(G=0,Y)D=[D[0]&2,Y.value];switch(D[0]){case 0:case 1:Y=D;break;case 4:return B.label++,{value:D[1],done:!1};case 5:B.label++,G=D[1],D=[0];continue;case 7:D=B.ops.pop(),B.trys.pop();continue;default:if((Y=B.trys,!(Y=Y.length>0&&Y[Y.length-1]))&&(D[0]===6||D[0]===2)){B=0;continue}if(D[0]===3&&(!Y||D[1]>Y[0]&&D[1]<Y[3])){B.label=D[1];break}if(D[0]===6&&B.label<Y[1]){B.label=Y[1],Y=D;break}if(Y&&B.label<Y[2]){B.label=Y[2],B.ops.push(D);break}if(Y[2])B.ops.pop();B.trys.pop();continue}D=Z.call(X,B)}catch(z){D=[6,z],G=0}finally{Q=Y=0}if(D[0]&5)throw D[1];return{value:D[0]?D[1]:void 0,done:!0}}}function b(X){var Z=typeof Symbol==="function"&&Symbol.iterator,B=Z&&X[Z],Q=0;if(B)return B.call(X);if(X&&typeof X.length==="number")return{next:function(){if(X&&Q>=X.length)X=void 0;return{value:X&&X[Q++],done:!X}}};throw TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")}function Y8(X,Z){var B=typeof Symbol==="function"&&X[Symbol.iterator];if(!B)return X;var Q=B.call(X),G,Y=[],W;try{while((Z===void 0||Z-- >0)&&!(G=Q.next()).done)Y.push(G.value)}catch(H){W={error:H}}finally{try{if(G&&!G.done&&(B=Q.return))B.call(Q)}finally{if(W)throw W.error}}return Y}function W8(X,Z,B){if(B||arguments.length===2){for(var Q=0,G=Z.length,Y;Q<G;Q++)if(Y||!(Q in Z)){if(!Y)Y=Array.prototype.slice.call(Z,0,Q);Y[Q]=Z[Q]}}return X.concat(Y||Array.prototype.slice.call(Z))}function r(X){return this instanceof r?(this.v=X,this):new r(X)}function yX(X,Z,B){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var Q=B.apply(X,Z||[]),G,Y=[];return G=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),H("next"),H("throw"),H("return",W),G[Symbol.asyncIterator]=function(){return this},G;function W(K){return function(N){return Promise.resolve(N).then(K,q)}}function H(K,N){if(Q[K]){if(G[K]=function(U){return new Promise(function(A,M){Y.push([K,U,A,M])>1||V(K,U)})},N)G[K]=N(G[K])}}function V(K,N){try{D(Q[K](N))}catch(U){F(Y[0][3],U)}}function D(K){K.value instanceof r?Promise.resolve(K.value.v).then(z,q):F(Y[0][2],K)}function z(K){V("next",K)}function q(K){V("throw",K)}function F(K,N){if(K(N),Y.shift(),Y.length)V(Y[0][0],Y[0][1])}}function gX(X){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var Z=X[Symbol.asyncIterator],B;return Z?Z.call(X):(X=typeof b==="function"?b(X):X[Symbol.iterator](),B={},Q("next"),Q("throw"),Q("return"),B[Symbol.asyncIterator]=function(){return this},B);function Q(Y){B[Y]=X[Y]&&function(W){return new Promise(function(H,V){W=X[Y](W),G(H,V,W.done,W.value)})}}function G(Y,W,H,V){Promise.resolve(V).then(function(D){Y({value:D,done:H})},W)}}function w(X){return typeof X==="function"}function b8(X){var Z=function(Q){Error.call(Q),Q.stack=Error().stack},B=X(Z);return B.prototype=Object.create(Error.prototype),B.prototype.constructor=B,B}var l8=b8(function(X){return function(B){X(this),this.message=B?B.length+` errors occurred during unsubscription:
|
|
2
|
+
`+B.map(function(Q,G){return G+1+") "+Q.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=B}});function M8(X,Z){if(X){var B=X.indexOf(Z);0<=B&&X.splice(B,1)}}var H8=function(){function X(Z){this.initialTeardown=Z,this.closed=!1,this._parentage=null,this._finalizers=null}return X.prototype.unsubscribe=function(){var Z,B,Q,G,Y;if(!this.closed){this.closed=!0;var W=this._parentage;if(W)if(this._parentage=null,Array.isArray(W))try{for(var H=b(W),V=H.next();!V.done;V=H.next()){var D=V.value;D.remove(this)}}catch(U){Z={error:U}}finally{try{if(V&&!V.done&&(B=H.return))B.call(H)}finally{if(Z)throw Z.error}}else W.remove(this);var z=this.initialTeardown;if(w(z))try{z()}catch(U){Y=U instanceof l8?U.errors:[U]}var q=this._finalizers;if(q){this._finalizers=null;try{for(var F=b(q),K=F.next();!K.done;K=F.next()){var N=K.value;try{hX(N)}catch(U){if(Y=Y!==null&&Y!==void 0?Y:[],U instanceof l8)Y=W8(W8([],Y8(Y)),Y8(U.errors));else Y.push(U)}}}catch(U){Q={error:U}}finally{try{if(K&&!K.done&&(G=F.return))G.call(F)}finally{if(Q)throw Q.error}}}if(Y)throw new l8(Y)}},X.prototype.add=function(Z){var B;if(Z&&Z!==this)if(this.closed)hX(Z);else{if(Z instanceof X){if(Z.closed||Z._hasParent(this))return;Z._addParent(this)}(this._finalizers=(B=this._finalizers)!==null&&B!==void 0?B:[]).push(Z)}},X.prototype._hasParent=function(Z){var B=this._parentage;return B===Z||Array.isArray(B)&&B.includes(Z)},X.prototype._addParent=function(Z){var B=this._parentage;this._parentage=Array.isArray(B)?(B.push(Z),B):B?[B,Z]:Z},X.prototype._removeParent=function(Z){var B=this._parentage;if(B===Z)this._parentage=null;else if(Array.isArray(B))M8(B,Z)},X.prototype.remove=function(Z){var B=this._finalizers;if(B&&M8(B,Z),Z instanceof X)Z._removeParent(this)},X.EMPTY=function(){var Z=new X;return Z.closed=!0,Z}(),X}();var y0=H8.EMPTY;function c8(X){return X instanceof H8||X&&"closed"in X&&w(X.remove)&&w(X.add)&&w(X.unsubscribe)}function hX(X){if(w(X))X();else X.unsubscribe()}var h={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var V8={setTimeout:function(X,Z){var B=[];for(var Q=2;Q<arguments.length;Q++)B[Q-2]=arguments[Q];var G=V8.delegate;if(G===null||G===void 0?void 0:G.setTimeout)return G.setTimeout.apply(G,W8([X,Z],Y8(B)));return setTimeout.apply(void 0,W8([X,Z],Y8(B)))},clearTimeout:function(X){var Z=V8.delegate;return((Z===null||Z===void 0?void 0:Z.clearTimeout)||clearTimeout)(X)},delegate:void 0};function u8(X){V8.setTimeout(function(){var Z=h.onUnhandledError;if(Z)Z(X);else throw X})}function g0(){}var vX=function(){return h0("C",void 0,void 0)}();function mX(X){return h0("E",void 0,X)}function dX(X){return h0("N",X,void 0)}function h0(X,Z,B){return{kind:X,value:Z,error:B}}var e=null;function D8(X){if(h.useDeprecatedSynchronousErrorHandling){var Z=!e;if(Z)e={errorThrown:!1,error:null};if(X(),Z){var B=e,Q=B.errorThrown,G=B.error;if(e=null,Q)throw G}}else X()}function _X(X){if(h.useDeprecatedSynchronousErrorHandling&&e)e.errorThrown=!0,e.error=X}var L8=function(X){n(Z,X);function Z(B){var Q=X.call(this)||this;if(Q.isStopped=!1,B){if(Q.destination=B,c8(B))B.add(Q)}else Q.destination=KZ;return Q}return Z.create=function(B,Q,G){return new n8(B,Q,G)},Z.prototype.next=function(B){if(this.isStopped)m0(dX(B),this);else this._next(B)},Z.prototype.error=function(B){if(this.isStopped)m0(mX(B),this);else this.isStopped=!0,this._error(B)},Z.prototype.complete=function(){if(this.isStopped)m0(vX,this);else this.isStopped=!0,this._complete()},Z.prototype.unsubscribe=function(){if(!this.closed)this.isStopped=!0,X.prototype.unsubscribe.call(this),this.destination=null},Z.prototype._next=function(B){this.destination.next(B)},Z.prototype._error=function(B){try{this.destination.error(B)}finally{this.unsubscribe()}},Z.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},Z}(H8);var HZ=Function.prototype.bind;function v0(X,Z){return HZ.call(X,Z)}var VZ=function(){function X(Z){this.partialObserver=Z}return X.prototype.next=function(Z){var B=this.partialObserver;if(B.next)try{B.next(Z)}catch(Q){p8(Q)}},X.prototype.error=function(Z){var B=this.partialObserver;if(B.error)try{B.error(Z)}catch(Q){p8(Q)}else p8(Z)},X.prototype.complete=function(){var Z=this.partialObserver;if(Z.complete)try{Z.complete()}catch(B){p8(B)}},X}(),n8=function(X){n(Z,X);function Z(B,Q,G){var Y=X.call(this)||this,W;if(w(B)||!B)W={next:B!==null&&B!==void 0?B:void 0,error:Q!==null&&Q!==void 0?Q:void 0,complete:G!==null&&G!==void 0?G:void 0};else{var H;if(Y&&h.useDeprecatedNextContext)H=Object.create(B),H.unsubscribe=function(){return Y.unsubscribe()},W={next:B.next&&v0(B.next,H),error:B.error&&v0(B.error,H),complete:B.complete&&v0(B.complete,H)};else W=B}return Y.destination=new VZ(W),Y}return Z}(L8);function p8(X){if(h.useDeprecatedSynchronousErrorHandling)_X(X);else u8(X)}function DZ(X){throw X}function m0(X,Z){var B=h.onStoppedNotification;B&&V8.setTimeout(function(){return B(X,Z)})}var KZ={closed:!0,next:g0,error:DZ,complete:g0};var K8=function(){return typeof Symbol==="function"&&Symbol.observable||"@@observable"}();function i8(X){return X}function bX(X){if(X.length===0)return i8;if(X.length===1)return X[0];return function(B){return X.reduce(function(Q,G){return G(Q)},B)}}var P=function(){function X(Z){if(Z)this._subscribe=Z}return X.prototype.lift=function(Z){var B=new X;return B.source=this,B.operator=Z,B},X.prototype.subscribe=function(Z,B,Q){var G=this,Y=UZ(Z)?Z:new n8(Z,B,Q);return D8(function(){var W=G,H=W.operator,V=W.source;Y.add(H?H.call(Y,V):V?G._subscribe(Y):G._trySubscribe(Y))}),Y},X.prototype._trySubscribe=function(Z){try{return this._subscribe(Z)}catch(B){Z.error(B)}},X.prototype.forEach=function(Z,B){var Q=this;return B=lX(B),new B(function(G,Y){var W=new n8({next:function(H){try{Z(H)}catch(V){Y(V),W.unsubscribe()}},error:Y,complete:G});Q.subscribe(W)})},X.prototype._subscribe=function(Z){var B;return(B=this.source)===null||B===void 0?void 0:B.subscribe(Z)},X.prototype[K8]=function(){return this},X.prototype.pipe=function(){var Z=[];for(var B=0;B<arguments.length;B++)Z[B]=arguments[B];return bX(Z)(this)},X.prototype.toPromise=function(Z){var B=this;return Z=lX(Z),new Z(function(Q,G){var Y;B.subscribe(function(W){return Y=W},function(W){return G(W)},function(){return Q(Y)})})},X.create=function(Z){return new X(Z)},X}();function lX(X){var Z;return(Z=X!==null&&X!==void 0?X:h.Promise)!==null&&Z!==void 0?Z:Promise}function AZ(X){return X&&w(X.next)&&w(X.error)&&w(X.complete)}function UZ(X){return X&&X instanceof L8||AZ(X)&&c8(X)}function qZ(X){return w(X===null||X===void 0?void 0:X.lift)}function i(X){return function(Z){if(qZ(Z))return Z.lift(function(B){try{return X(B,this)}catch(Q){this.error(Q)}});throw TypeError("Unable to lift unknown Observable type")}}function X8(X,Z,B,Q,G){return new zZ(X,Z,B,Q,G)}var zZ=function(X){n(Z,X);function Z(B,Q,G,Y,W,H){var V=X.call(this,B)||this;return V.onFinalize=W,V.shouldUnsubscribe=H,V._next=Q?function(D){try{Q(D)}catch(z){B.error(z)}}:X.prototype._next,V._error=Y?function(D){try{Y(D)}catch(z){B.error(z)}finally{this.unsubscribe()}}:X.prototype._error,V._complete=G?function(){try{G()}catch(D){B.error(D)}finally{this.unsubscribe()}}:X.prototype._complete,V}return Z.prototype.unsubscribe=function(){var B;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var Q=this.closed;X.prototype.unsubscribe.call(this),!Q&&((B=this.onFinalize)===null||B===void 0||B.call(this))}},Z}(L8);var cX=b8(function(X){return function(){X(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var a8=function(X){n(Z,X);function Z(){var B=X.call(this)||this;return B.closed=!1,B.currentObservers=null,B.observers=[],B.isStopped=!1,B.hasError=!1,B.thrownError=null,B}return Z.prototype.lift=function(B){var Q=new uX(this,this);return Q.operator=B,Q},Z.prototype._throwIfClosed=function(){if(this.closed)throw new cX},Z.prototype.next=function(B){var Q=this;D8(function(){var G,Y;if(Q._throwIfClosed(),!Q.isStopped){if(!Q.currentObservers)Q.currentObservers=Array.from(Q.observers);try{for(var W=b(Q.currentObservers),H=W.next();!H.done;H=W.next()){var V=H.value;V.next(B)}}catch(D){G={error:D}}finally{try{if(H&&!H.done&&(Y=W.return))Y.call(W)}finally{if(G)throw G.error}}}})},Z.prototype.error=function(B){var Q=this;D8(function(){if(Q._throwIfClosed(),!Q.isStopped){Q.hasError=Q.isStopped=!0,Q.thrownError=B;var G=Q.observers;while(G.length)G.shift().error(B)}})},Z.prototype.complete=function(){var B=this;D8(function(){if(B._throwIfClosed(),!B.isStopped){B.isStopped=!0;var Q=B.observers;while(Q.length)Q.shift().complete()}})},Z.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(Z.prototype,"observed",{get:function(){var B;return((B=this.observers)===null||B===void 0?void 0:B.length)>0},enumerable:!1,configurable:!0}),Z.prototype._trySubscribe=function(B){return this._throwIfClosed(),X.prototype._trySubscribe.call(this,B)},Z.prototype._subscribe=function(B){return this._throwIfClosed(),this._checkFinalizedStatuses(B),this._innerSubscribe(B)},Z.prototype._innerSubscribe=function(B){var Q=this,G=this,Y=G.hasError,W=G.isStopped,H=G.observers;if(Y||W)return y0;return this.currentObservers=null,H.push(B),new H8(function(){Q.currentObservers=null,M8(H,B)})},Z.prototype._checkFinalizedStatuses=function(B){var Q=this,G=Q.hasError,Y=Q.thrownError,W=Q.isStopped;if(G)B.error(Y);else if(W)B.complete()},Z.prototype.asObservable=function(){var B=new P;return B.source=this,B},Z.create=function(B,Q){return new uX(B,Q)},Z}(P);var uX=function(X){n(Z,X);function Z(B,Q){var G=X.call(this)||this;return G.destination=B,G.source=Q,G}return Z.prototype.next=function(B){var Q,G;(G=(Q=this.destination)===null||Q===void 0?void 0:Q.next)===null||G===void 0||G.call(Q,B)},Z.prototype.error=function(B){var Q,G;(G=(Q=this.destination)===null||Q===void 0?void 0:Q.error)===null||G===void 0||G.call(Q,B)},Z.prototype.complete=function(){var B,Q;(Q=(B=this.destination)===null||B===void 0?void 0:B.complete)===null||Q===void 0||Q.call(B)},Z.prototype._subscribe=function(B){var Q,G;return(G=(Q=this.source)===null||Q===void 0?void 0:Q.subscribe(B))!==null&&G!==void 0?G:y0},Z}(a8);function pX(X){return X&&w(X.schedule)}function NZ(X){return X[X.length-1]}function nX(X){return pX(NZ(X))?X.pop():void 0}var o8=function(X){return X&&typeof X.length==="number"&&typeof X!=="function"};function s8(X){return w(X===null||X===void 0?void 0:X.then)}function t8(X){return w(X[K8])}function r8(X){return Symbol.asyncIterator&&w(X===null||X===void 0?void 0:X[Symbol.asyncIterator])}function e8(X){return TypeError("You provided "+(X!==null&&typeof X==="object"?"an invalid object":"'"+X+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function FZ(){if(typeof Symbol!=="function"||!Symbol.iterator)return"@@iterator";return Symbol.iterator}var X0=FZ();function Z0(X){return w(X===null||X===void 0?void 0:X[X0])}function B0(X){return yX(this,arguments,function(){var B,Q,G,Y;return _8(this,function(W){switch(W.label){case 0:B=X.getReader(),W.label=1;case 1:W.trys.push([1,,9,10]),W.label=2;case 2:return[4,r(B.read())];case 3:if(Q=W.sent(),G=Q.value,Y=Q.done,!Y)return[3,5];return[4,r(void 0)];case 4:return[2,W.sent()];case 5:return[4,r(G)];case 6:return[4,W.sent()];case 7:return W.sent(),[3,2];case 8:return[3,10];case 9:return B.releaseLock(),[7];case 10:return[2]}})})}function Q0(X){return w(X===null||X===void 0?void 0:X.getReader)}function _(X){if(X instanceof P)return X;if(X!=null){if(t8(X))return JZ(X);if(o8(X))return MZ(X);if(s8(X))return LZ(X);if(r8(X))return iX(X);if(Z0(X))return IZ(X);if(Q0(X))return wZ(X)}throw e8(X)}function JZ(X){return new P(function(Z){var B=X[K8]();if(w(B.subscribe))return B.subscribe(Z);throw TypeError("Provided object does not correctly implement Symbol.observable")})}function MZ(X){return new P(function(Z){for(var B=0;B<X.length&&!Z.closed;B++)Z.next(X[B]);Z.complete()})}function LZ(X){return new P(function(Z){X.then(function(B){if(!Z.closed)Z.next(B),Z.complete()},function(B){return Z.error(B)}).then(null,u8)})}function IZ(X){return new P(function(Z){var B,Q;try{for(var G=b(X),Y=G.next();!Y.done;Y=G.next()){var W=Y.value;if(Z.next(W),Z.closed)return}}catch(H){B={error:H}}finally{try{if(Y&&!Y.done&&(Q=G.return))Q.call(G)}finally{if(B)throw B.error}}Z.complete()})}function iX(X){return new P(function(Z){TZ(X,Z).catch(function(B){return Z.error(B)})})}function wZ(X){return iX(B0(X))}function TZ(X,Z){var B,Q,G,Y;return jX(this,void 0,void 0,function(){var W,H;return _8(this,function(V){switch(V.label){case 0:V.trys.push([0,5,6,11]),B=gX(X),V.label=1;case 1:return[4,B.next()];case 2:if(Q=V.sent(),!!Q.done)return[3,4];if(W=Q.value,Z.next(W),Z.closed)return[2];V.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return H=V.sent(),G={error:H},[3,11];case 6:if(V.trys.push([6,,9,10]),!(Q&&!Q.done&&(Y=B.return)))return[3,8];return[4,Y.call(B)];case 7:V.sent(),V.label=8;case 8:return[3,10];case 9:if(G)throw G.error;return[7];case 10:return[7];case 11:return Z.complete(),[2]}})})}function S(X,Z,B,Q,G){if(Q===void 0)Q=0;if(G===void 0)G=!1;var Y=Z.schedule(function(){if(B(),G)X.add(this.schedule(null,Q));else this.unsubscribe()},Q);if(X.add(Y),!G)return Y}function G0(X,Z){if(Z===void 0)Z=0;return i(function(B,Q){B.subscribe(X8(Q,function(G){return S(Q,X,function(){return Q.next(G)},Z)},function(){return S(Q,X,function(){return Q.complete()},Z)},function(G){return S(Q,X,function(){return Q.error(G)},Z)}))})}function Y0(X,Z){if(Z===void 0)Z=0;return i(function(B,Q){Q.add(X.schedule(function(){return B.subscribe(Q)},Z))})}function aX(X,Z){return _(X).pipe(Y0(Z),G0(Z))}function oX(X,Z){return _(X).pipe(Y0(Z),G0(Z))}function sX(X,Z){return new P(function(B){var Q=0;return Z.schedule(function(){if(Q===X.length)B.complete();else if(B.next(X[Q++]),!B.closed)this.schedule()})})}function tX(X,Z){return new P(function(B){var Q;return S(B,Z,function(){Q=X[X0](),S(B,Z,function(){var G,Y,W;try{G=Q.next(),Y=G.value,W=G.done}catch(H){B.error(H);return}if(W)B.complete();else B.next(Y)},0,!0)}),function(){return w(Q===null||Q===void 0?void 0:Q.return)&&Q.return()}})}function W0(X,Z){if(!X)throw Error("Iterable cannot be null");return new P(function(B){S(B,Z,function(){var Q=X[Symbol.asyncIterator]();S(B,Z,function(){Q.next().then(function(G){if(G.done)B.complete();else B.next(G.value)})},0,!0)})})}function rX(X,Z){return W0(B0(X),Z)}function eX(X,Z){if(X!=null){if(t8(X))return aX(X,Z);if(o8(X))return sX(X,Z);if(s8(X))return oX(X,Z);if(r8(X))return W0(X,Z);if(Z0(X))return tX(X,Z);if(Q0(X))return rX(X,Z)}throw e8(X)}function I8(X,Z){return Z?eX(X,Z):_(X)}function X1(X,Z){return i(function(B,Q){var G=0;B.subscribe(X8(Q,function(Y){Q.next(X.call(Z,Y,G++))}))})}function Z1(X,Z,B,Q,G,Y,W,H){var V=[],D=0,z=0,q=!1,F=function(){if(q&&!V.length&&!D)Z.complete()},K=function(U){return D<Q?N(U):V.push(U)},N=function(U){Y&&Z.next(U),D++;var A=!1;_(B(U,z++)).subscribe(X8(Z,function(M){if(G===null||G===void 0||G(M),Y)K(M);else Z.next(M)},function(){A=!0},void 0,function(){if(A)try{D--;var M=function(){var J=V.shift();if(W)S(Z,W,function(){return N(J)});else N(J)};while(V.length&&D<Q)M();F()}catch(J){Z.error(J)}}))};return X.subscribe(X8(Z,K,function(){q=!0,F()})),function(){H===null||H===void 0||H()}}function d0(X,Z,B){if(B===void 0)B=1/0;if(w(Z))return d0(function(Q,G){return X1(function(Y,W){return Z(Q,Y,G,W)})(_(X(Q,G)))},B);else if(typeof Z==="number")B=Z;return i(function(Q,G){return Z1(Q,G,X,B)})}function B1(X){if(X===void 0)X=1/0;return d0(i8,X)}function Q1(){return B1(1)}function _0(){var X=[];for(var Z=0;Z<arguments.length;Z++)X[Z]=arguments[Z];return Q1()(I8(X,nX(X)))}function EZ(X){function Z(B){if(B===null||typeof B!=="object")return B;if(Array.isArray(B))return B.map(Z);let Q={};for(let G of Object.keys(B).sort()){let Y=B[G];if(Y===void 0||typeof Y==="function"||typeof Y==="symbol")continue;Q[G]=Z(Y)}return Q}return JSON.stringify(Z(X))}var xZ=new TextDecoder,b0=new TextEncoder;function CZ(X){return b0.encode(X)}function PZ(X){let Z=EZ(X),B=CZ(Z),Q=0xcbf29ce484222325n,G=0x100000001b3n,Y=0xffffffffffffffffn;for(let W=0;W<B.length;W++)Q^=BigInt(B[W]),Q=Q*G&Y;return Q.toString(16).padStart(16,"0")}function RZ(X){if(!(X instanceof f))return!1;return X?.data?.httpCode===401}function a5(X,Z){let B=Z?.cache??SX(),Q=null,G=DX({links:[N0({url:X,transformer:J8,headers:(A)=>{if(!Q)return{};return{Authorization:`Bearer ${Q}`}}})]});function Y(A,M){let J=PZ(M??null);return`trpc:${A}.query:${J}`}let W={};function H(A,M){if(A in W)return W[A];let J=M().finally(()=>{setTimeout(()=>{if(W[A]===J)delete W[A]},250)});return W[A]=J,J}async function V(A){return B.getBytes(A).then((M)=>{if(!M)return null;try{return J8.parse(xZ.decode(M))}catch(J){return null}})}let D=[];function z(A){if(A.startsWith("trpc:"))A=A.split(":")[1];for(let[M,J]of D){let L=M.split(":")[1].split(".").slice(0,-1).join(".");if(A.startsWith(L))(async()=>J())()}}let q=new a8,F=!!Q;function K(){let A=!!Q;if(A===F)return;F=A,q.next()}let N=Object.freeze({async query(A,M,J){let E=J?.strategy??"network-first",L=G;for(let x of`${A}.query`.split("."))L=L?.[x];if(!L)throw Error(`could not resolve query path ${A}`);let C=Y(A,M);async function k(){try{return[await H(C,()=>L(M))??null,null]}catch(x){if(x instanceof f){if(U(x),x?.code==="ConnectionRefused")return[null,null];return[null,x]}return[null,f.from(x)]}}async function l(x){let[a,O]=x;if(O||!a)return await B.delete(C),[null,O];let j=b0.encode(J8.stringify(a));return await B.setBytes(C,j),[a,null]}if(E==="cache-only")return[await V(C),null];if(E==="network-only")return await l(await k());if(E==="cache-first"){let x=await V(C);if(x)return[x,null];return await l(await k())}if(E==="network-first"){let[x,a]=await k();if(x)return await l([x,null]);if(x=await V(C),x)return[x,null];return[null,a]}throw Error(`invalid strategy for _query: ${E}`)},async invalidate(A){if(A.startsWith("trpc:")){await B.delete(A),delete W[A],z(A);return}let M=A,J=`${M}.query`,E=[];for(let L of await B.keys()){if(!L.startsWith("trpc:"))continue;if(L.split(":")[1]!==J)continue;E.push(B.delete(L)),delete W[L]}for(let L of Object.keys(W)){if(!L.startsWith("trpc:"))continue;if(L.split(":")[1]===J)delete W[L]}await Promise.all(E),z(M)},async invalidateCascading(A){let M=A;if(A.startsWith("trpc:")){if(M=A.split(":")[1]??"",M.endsWith(".query"))M=M.slice(0,-6)}if(!M.includes("."))return;let J=M.split(".").slice(0,-1).join("."),E=[];for(let L of await B.keys()){if(!L.startsWith("trpc:"))continue;let C=L.split(":")[1];if(!C.endsWith(".query"))continue;let k=C.slice(0,-6);if(k===J||k.startsWith(`${J}.`))E.push(B.delete(L)),delete W[L]}for(let L of Object.keys(W)){if(!L.startsWith("trpc:"))continue;let C=L.split(":")[1];if(!C.endsWith(".query"))continue;let k=C.slice(0,-6);if(k===J||k.startsWith(`${J}.`))delete W[L]}await Promise.all(E);for(let[L,C]of D){let k=L.split(":")[1];if(!k.endsWith(".query"))continue;let l=k.slice(0,-6);if(l===J||l.startsWith(`${J}.`))(async()=>C())()}},streamQuery(A,M,J){J??={},J.strategy??="cache-first";let E=G;for(let O of`${A}.query`.split("."))E=E?.[O];if(!E)throw Error(`could not resolve query path ${A}`);let L=Y(A,M);async function C(){try{return[await H(L,()=>E(M))??null,null]}catch(O){if(O instanceof f){if(U(O),O?.code==="ConnectionRefused")return[null,null];return[null,O]}return[null,f.from(O)]}}async function k(O){let[j,$]=O;if($||!j)return await B.delete(L),[null,$];let w8=b0.encode(J8.stringify(j));return await B.setBytes(L,w8),[j,null]}async function*l(){if(J.strategy==="cache-first"||J.strategy==="cache-only"){let $=await V(L);if($)yield[$,null];if(J.strategy==="cache-only")return}let[O,j]=await k(await C());if(yield[O,j],j&&J?.strategy==="network-first")yield[await V(L),null]}let x=I8(l()),a=new P((O)=>{let j=async()=>{let[$,w8]=await C();if($&&!w8)O.next([$,w8])};return D.push([L,j]),()=>{for(let $=0;$<D.length;$++)if(D[$][1]===j){D.splice($,1);return}}});return _0(x,a)},async mutate(A,M,J){let E=G;for(let L of`${A}.mutate`.split("."))E=E?.[L];if(!E)throw Error(`could not resolve mutation path ${A}`);try{let L=await E(M);return await N.invalidateCascading(A),[L,null]}catch(L){if(U(L),!(L instanceof Error))return[null,Error("unexpected error")];return[null,L]}},async login(A){let[M,J]=await N.mutate("auth.login",A);if(J)throw J;if(!M)throw Error("Login failed: missing response payload");N.setToken(M.token)},setToken(A){if(Q=A,d8()&&typeof localStorage<"u")if(A)localStorage.setItem("__sortsys-v2_token",A);else localStorage.removeItem("__sortsys-v2_token");K()},async logout(){if(await B.clear(),!Q){N.setToken(null);return}await N.mutate("auth.logout",void 0).catch(()=>{}),N.setToken(null)},listenAuthState:(A)=>{let M=q.subscribe(()=>{A()});return()=>M.unsubscribe()},loggedIn(){return!!Q},async restoreSession(){if(d8())N.setToken(localStorage.getItem("__sortsys-v2_token"))},async clearCache(){return B.clear()}});function U(A){if(!RZ(A))return;N.logout().catch(()=>{})}return N}export{a5 as createClient};
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sortsys/v2-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"devDependencies": {
|
|
6
|
+
"@types/bun": "^1.3.11",
|
|
6
7
|
"dts-bundle-generator": "^9.5.1"
|
|
7
8
|
},
|
|
8
9
|
"exports": {
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
"access": "public"
|
|
19
20
|
},
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "rm -rf dist && bun build src/index.ts --production --outfile dist/index.js && bunx dts-bundle-generator -o dist/index.d.ts src/index.ts --project tsconfig.
|
|
22
|
+
"build": "rm -rf dist && bun build src/index.ts --production --outfile dist/index.js && bunx dts-bundle-generator -o dist/index.d.ts src/index.ts --project tsconfig.json --no-check --external-inlines=@trpc/server @trpc/client express-serve-static-core qs range-parser --export-referenced-types=false"
|
|
22
23
|
},
|
|
23
24
|
"type": "module",
|
|
24
25
|
"types": "dist/index.d.ts",
|