starknetkit
Version:
<!-- logo --> <p align="center"> <img width='300' src="https://starknetkit-website-git-blo-1541-argentlabs.vercel.app/starknetKit-logo.svg"> </p>
2,007 lines • 154 kB
JavaScript
import { constants as ze } from "starknet";
import { g as ur, c as Ve } from "./connector-d58f0dd8.js";
import { P as Wt } from "./lastConnected-c0cae438.js";
const fn = "https://web.ready.co", Ea = `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2" y="2" width="28" height="28" rx="5.6" fill="black"/>
<g clip-path="url(#clip0_9_981)">
<path d="M10.5 20.9999H21.5C21.9166 20.9999 22.2736 20.7452 22.424 20.383L18.1419 16.3631L16.3739 18.0018C16.163 18.1973 15.837 18.1973 15.6261 18.0018L13.8581 16.3631L9.57603 20.383C9.72637 20.7452 10.0834 20.9999 10.5 20.9999Z" fill="white"/>
<path d="M18.8771 15.6817L22.5 19.0828V12.3239L18.8771 15.6817Z" fill="white"/>
<path d="M13.1229 15.6817L9.5 12.3239V19.0828L13.1229 15.6817Z" fill="white"/>
<path d="M22 10.9999H10C9.8752 10.9999 9.76108 11.0456 9.67348 11.1212L15.7734 16.7748C15.9012 16.8933 16.0988 16.8933 16.2266 16.7748L22.3265 11.1212C22.2389 11.0456 22.1248 10.9999 22 10.9999Z" fill="white"/>
</g>
<rect x="20" y="20" width="12" height="12" rx="2.4" fill="#FF875B"/>
<path d="M26.9611 22.6222H25.0397C24.9755 22.6222 24.924 22.675 24.9226 22.7406C24.8838 24.5841 23.9398 26.3339 22.3148 27.5732C22.2633 27.6126 22.2515 27.6865 22.2892 27.7397L23.4134 29.3279C23.4517 29.3819 23.5262 29.3941 23.5786 29.3544C24.5947 28.5845 25.4119 27.6558 26.0004 26.6264C26.5889 27.6558 27.4062 28.5845 28.4222 29.3544C28.4746 29.3941 28.5492 29.3819 28.5875 29.3279L29.7117 27.7397C29.7493 27.6865 29.7376 27.6126 29.686 27.5732C28.0611 26.3339 27.117 24.5841 27.0782 22.7406C27.0768 22.675 27.0253 22.6222 26.9611 22.6222Z" fill="white"/>
<defs>
<clipPath id="clip0_9_981">
<rect width="16" height="16" fill="white" transform="translate(8 7.99991)"/>
</clipPath>
</defs>
</svg>`, Ca = "https://static.hydrogen.argent47.net/webwallet/iframe_whitelist_testnet.json", Ra = "https://static.argent.net/webwallet/iframe_whitelist_mainnet.json", Oa = (t) => t === ze.StarknetChainId.SN_MAIN ? ze.StarknetChainId.SN_MAIN : ze.StarknetChainId.SN_SEPOLIA, G = ze.NetworkName, pn = G.SN_SEPOLIA;
function Sa(t) {
try {
const { origin: e } = new URL(t);
if (e.includes("localhost") || e.includes("127.0.0.1"))
return pn;
if (e.includes("hydrogen") || e.includes("sepolia-web.staging"))
return G.SN_SEPOLIA;
if (e.includes("staging"))
return G.SN_MAIN;
if (e.includes("dev") || e.includes("sepolia-web.ready.co"))
return G.SN_SEPOLIA;
if (e.includes("ready.co"))
return G.SN_MAIN;
} catch {
console.warn(
"Could not determine network from target URL, defaulting to mainnet-alpha"
);
}
return G.SN_MAIN;
}
function hn(t) {
return t;
}
function mn(t) {
return t.length === 0 ? hn : t.length === 1 ? t[0] : function(r) {
return t.reduce((n, s) => s(n), r);
};
}
function yn(t) {
return typeof t == "object" && t !== null && "subscribe" in t;
}
function Ke(t) {
const e = {
subscribe(r) {
let n = null, s = !1, i = !1, a = !1;
function o() {
if (n === null) {
a = !0;
return;
}
i || (i = !0, typeof n == "function" ? n() : n && n.unsubscribe());
}
return n = t({
next(c) {
s || r.next?.(c);
},
error(c) {
s || (s = !0, r.error?.(c), o());
},
complete() {
s || (s = !0, r.complete?.(), o());
}
}), a && o(), {
unsubscribe: o
};
},
pipe(...r) {
return mn(r)(e);
}
};
return e;
}
function dr(t) {
return (e) => {
let r = 0, n = null;
const s = [];
function i() {
n || (n = e.subscribe({
next(o) {
for (const c of s)
c.next?.(o);
},
error(o) {
for (const c of s)
c.error?.(o);
},
complete() {
for (const o of s)
o.complete?.();
}
}));
}
function a() {
if (r === 0 && n) {
const o = n;
n = null, o.unsubscribe();
}
}
return {
subscribe(o) {
return r++, s.push(o), i(), {
unsubscribe() {
r--, a();
const c = s.findIndex((u) => u === o);
c > -1 && s.splice(c, 1);
}
};
}
};
};
}
function gn(t) {
return (e) => ({
subscribe(r) {
let n = 0;
return e.subscribe({
next(i) {
r.next?.(t(i, n++));
},
error(i) {
r.error?.(i);
},
complete() {
r.complete?.();
}
});
}
});
}
function lr(t) {
return (e) => ({
subscribe(r) {
return e.subscribe({
next(n) {
t.next?.(n), r.next?.(n);
},
error(n) {
t.error?.(n), r.error?.(n);
},
complete() {
t.complete?.(), r.complete?.();
}
});
}
});
}
let _n = class fr extends Error {
constructor(e) {
super(e), this.name = "ObservableAbortError", Object.setPrototypeOf(this, fr.prototype);
}
};
function pr(t) {
let e;
return {
promise: new Promise((n, s) => {
let i = !1;
function a() {
i || (i = !0, s(new _n("This operation was aborted.")), o.unsubscribe());
}
const o = t.subscribe({
next(c) {
i = !0, n(c), a();
},
error(c) {
i = !0, s(c), a();
},
complete() {
i = !0, a();
}
});
e = a;
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
abort: e
};
}
const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
isObservable: yn,
map: gn,
observable: Ke,
observableToPromise: pr,
share: dr,
tap: lr
}, Symbol.toStringTag, { value: "Module" }));
function hr(t) {
return Ke((e) => {
function r(s = 0, i = t.op) {
const a = t.links[s];
if (!a)
throw new Error("No more links to execute - did you forget to add an ending link?");
return a({
op: i,
next(c) {
return r(s + 1, c);
}
});
}
return r().subscribe(e);
});
}
function Ht(t) {
return Array.isArray(t) ? t : [
t
];
}
function bn(t) {
return (e) => {
const r = Ht(t.true).map((s) => s(e)), n = Ht(t.false).map((s) => s(e));
return (s) => Ke((i) => {
const a = t.condition(s.op) ? r : n;
return hr({
op: s.op,
links: a
}).subscribe(i);
});
};
}
function mr(t) {
const e = /* @__PURE__ */ Object.create(null);
for (const r in t) {
const n = t[r];
e[n] = r;
}
return e;
}
const et = {
/**
* Invalid JSON was received by the server.
* An error occurred on the server while parsing the JSON text.
*/
PARSE_ERROR: -32700,
/**
* The JSON sent is not a valid Request object.
*/
BAD_REQUEST: -32600,
// Internal JSON-RPC error
INTERNAL_SERVER_ERROR: -32603,
NOT_IMPLEMENTED: -32603,
// Implementation specific errors
UNAUTHORIZED: -32001,
FORBIDDEN: -32003,
NOT_FOUND: -32004,
METHOD_NOT_SUPPORTED: -32005,
TIMEOUT: -32008,
CONFLICT: -32009,
PRECONDITION_FAILED: -32012,
PAYLOAD_TOO_LARGE: -32013,
UNPROCESSABLE_CONTENT: -32022,
TOO_MANY_REQUESTS: -32029,
CLIENT_CLOSED_REQUEST: -32099
};
mr(et);
mr(et);
const wn = {
PARSE_ERROR: 400,
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
NOT_FOUND: 404,
FORBIDDEN: 403,
METHOD_NOT_SUPPORTED: 405,
TIMEOUT: 408,
CONFLICT: 409,
PRECONDITION_FAILED: 412,
PAYLOAD_TOO_LARGE: 413,
UNPROCESSABLE_CONTENT: 422,
TOO_MANY_REQUESTS: 429,
CLIENT_CLOSED_REQUEST: 499,
INTERNAL_SERVER_ERROR: 500,
NOT_IMPLEMENTED: 501
};
function xn(t) {
return wn[t] ?? 500;
}
function yr(t) {
return xn(t.code);
}
const gr = () => {
};
function _r(t, e) {
return new Proxy(gr, {
get(n, s) {
if (!(typeof s != "string" || s === "then"))
return _r(t, [
...e,
s
]);
},
apply(n, s, i) {
const a = e[e.length - 1] === "apply";
return t({
args: a ? i.length >= 2 ? i[1] : [] : i,
path: a ? e.slice(0, -1) : e
});
}
});
}
const Pt = (t) => _r(t, []), Nt = (t) => new Proxy(gr, {
get(e, r) {
if (!(typeof r != "string" || r === "then"))
return t(r);
}
});
function kn(t) {
const { path: e, error: r, config: n } = t, { code: s } = t.error, i = {
message: r.message,
code: et[s],
data: {
code: s,
httpStatus: yr(r)
}
};
return n.isDev && typeof t.error.stack == "string" && (i.data.stack = t.error.stack), typeof e == "string" && (i.data.path = e), n.errorFormatter({
...t,
shape: i
});
}
function Ft(t, e) {
return "error" in e ? {
...e,
error: t.transformer.output.serialize(e.error)
} : "data" in e.result ? {
...e,
result: {
...e.result,
data: t.transformer.output.serialize(e.result.data)
}
} : e;
}
function Tn(t, e) {
return Array.isArray(e) ? e.map((r) => Ft(t, r)) : Ft(t, e);
}
function En(t) {
return !!t && !Array.isArray(t) && typeof t == "object";
}
class Cn extends Error {
}
function Lt(t) {
if (t instanceof Error)
return t;
const e = typeof t;
if (!(e === "undefined" || e === "function" || t === null)) {
if (e !== "object")
return new Error(String(t));
if (En(t)) {
const r = new Cn();
for (const n in t)
r[n] = t[n];
return r;
}
}
}
const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
createFlatProxy: Nt,
createRecursiveProxy: Pt,
getCauseFromUnknown: Lt,
getErrorShape: kn,
transformTRPCResponse: Tn
}, Symbol.toStringTag, { value: "Module" }));
function Jt(t) {
return !!t && !Array.isArray(t) && typeof t == "object";
}
function On(t) {
return t instanceof vr || /**
* @deprecated
* Delete in next major
*/
t instanceof Error && t.name === "TRPCClientError";
}
function Sn(t) {
return Jt(t) && Jt(t.error) && typeof t.error.code == "number" && typeof t.error.message == "string";
}
let vr = class be extends Error {
static from(e, r = {}) {
const n = e;
return On(n) ? (r.meta && (n.meta = {
...n.meta,
...r.meta
}), n) : Sn(n) ? new be(n.error.message, {
...r,
result: n
}) : n instanceof Error ? new be(n.message, {
...r,
cause: Lt(n)
}) : new be("Unknown error", {
...r,
cause: n
});
}
constructor(e, r) {
const n = r?.cause;
super(e, {
cause: n
}), this.meta = r?.meta, this.cause = n, this.shape = r?.result?.error, this.data = r?.result?.error.data, this.name = "TRPCClientError", Object.setPrototypeOf(this, be.prototype);
}
};
function Pn(t) {
return typeof FormData > "u" ? !1 : t instanceof FormData;
}
const dt = {
css: {
query: [
"72e3ff",
"3fb0d8"
],
mutation: [
"c5a3fc",
"904dfc"
],
subscription: [
"ff49e1",
"d83fbe"
]
},
ansi: {
regular: {
// Cyan background, black and white text respectively
query: [
"\x1B[30;46m",
"\x1B[97;46m"
],
// Magenta background, black and white text respectively
mutation: [
"\x1B[30;45m",
"\x1B[97;45m"
],
// Green background, black and white text respectively
subscription: [
"\x1B[30;42m",
"\x1B[97;42m"
]
},
bold: {
query: [
"\x1B[1;30;46m",
"\x1B[1;97;46m"
],
mutation: [
"\x1B[1;30;45m",
"\x1B[1;97;45m"
],
subscription: [
"\x1B[1;30;42m",
"\x1B[1;97;42m"
]
}
}
};
function Nn(t) {
const { direction: e, type: r, path: n, id: s, input: i } = t, a = [], o = [];
if (t.colorMode === "ansi") {
const [m, y] = dt.ansi.regular[r], [k, T] = dt.ansi.bold[r], N = "\x1B[0m";
return a.push(e === "up" ? m : y, e === "up" ? ">>" : "<<", r, e === "up" ? k : T, `#${s}`, n, N), e === "up" ? o.push({
input: t.input
}) : o.push({
input: t.input,
// strip context from result cause it's too noisy in terminal wihtout collapse mode
result: "result" in t.result ? t.result.result : t.result,
elapsedMs: t.elapsedMs
}), {
parts: a,
args: o
};
}
const [c, u] = dt.css[r], l = `
background-color: #${e === "up" ? c : u};
color: ${e === "up" ? "black" : "white"};
padding: 2px;
`;
return a.push("%c", e === "up" ? ">>" : "<<", r, `#${s}`, `%c${n}%c`, "%O"), o.push(l, `${l}; font-weight: bold;`, `${l}; font-weight: normal;`), e === "up" ? o.push({
input: i,
context: t.context
}) : o.push({
input: i,
result: t.result,
elapsedMs: t.elapsedMs,
context: t.context
}), {
parts: a,
args: o
};
}
const Ln = ({ c: t = console, colorMode: e = "css" }) => (r) => {
const n = r.input, s = Pn(n) ? Object.fromEntries(n) : n, { parts: i, args: a } = Nn({
...r,
colorMode: e,
input: s
}), o = r.direction === "down" && r.result && (r.result instanceof Error || "error" in r.result.result) ? "error" : "log";
t[o].apply(null, [
i.join(" ")
].concat(a));
};
function In(t = {}) {
const { enabled: e = () => !0 } = t, r = t.colorMode ?? (typeof window > "u" ? "ansi" : "css"), { logger: n = Ln({
c: t.console,
colorMode: r
}) } = t;
return () => ({ op: s, next: i }) => Ke((a) => {
e({
...s,
direction: "up"
}) && n({
...s,
direction: "up"
});
const o = Date.now();
function c(u) {
const l = Date.now() - o;
e({
...s,
direction: "down",
result: u
}) && n({
...s,
direction: "down",
elapsedMs: l,
result: u
});
}
return i(s).pipe(lr({
next(u) {
c(u);
},
error(u) {
c(u);
}
})).subscribe(a);
});
}
let jn = class {
$request({ type: e, input: r, path: n, context: s = {} }) {
return hr({
links: this.links,
op: {
id: ++this.requestId,
type: e,
path: n,
input: r,
context: s
}
}).pipe(dr());
}
requestAsPromise(e) {
const r = this.$request(e), { promise: n, abort: s } = pr(r);
return new Promise((a, o) => {
e.signal?.addEventListener("abort", s), n.then((c) => {
a(c.result.data);
}).catch((c) => {
o(vr.from(c));
});
});
}
query(e, r, n) {
return this.requestAsPromise({
type: "query",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
mutation(e, r, n) {
return this.requestAsPromise({
type: "mutation",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
subscription(e, r, n) {
return this.$request({
type: "subscription",
path: e,
input: r,
context: n?.context
}).subscribe({
next(i) {
i.result.type === "started" ? n.onStarted?.() : i.result.type === "stopped" ? n.onStopped?.() : n.onData?.(i.result.data);
},
error(i) {
n.onError?.(i);
},
complete() {
n.onComplete?.();
}
});
}
constructor(e) {
this.requestId = 0;
const r = (() => {
const n = e.transformer;
return n ? "input" in n ? e.transformer : {
input: n,
output: n
} : {
input: {
serialize: (s) => s,
deserialize: (s) => s
},
output: {
serialize: (s) => s,
deserialize: (s) => s
}
};
})();
this.runtime = {
transformer: {
serialize: (n) => r.input.serialize(n),
deserialize: (n) => r.output.deserialize(n)
},
combinedTransformer: r
}, this.links = e.links.map((n) => n(this.runtime));
}
};
const An = {
query: "query",
mutate: "mutation",
subscribe: "subscription"
}, $n = (t) => An[t];
function Mn(t) {
return Nt((e) => t.hasOwnProperty(e) ? t[e] : e === "__untypedClient" ? t : Pt(({ path: r, args: n }) => {
const s = [
e,
...r
], i = $n(s.pop()), a = s.join(".");
return t[i](a, ...n);
}));
}
function Dn(t) {
const e = new jn(t);
return Mn(e);
}
function Zn(t) {
if (t instanceof fe || t instanceof Error && t.name === "TRPCError")
return t;
const e = new fe({
code: "INTERNAL_SERVER_ERROR",
cause: t
});
return t instanceof Error && t.stack && (e.stack = t.stack), e;
}
class fe extends Error {
constructor(e) {
const r = Lt(e.cause), n = e.message ?? r?.message ?? e.code;
super(n, {
cause: r
}), this.code = e.code, this.name = "TRPCError", this.cause || (this.cause = r);
}
}
function Un(t) {
return "input" in t ? t : {
input: t,
output: t
};
}
const Te = {
_default: !0,
input: {
serialize: (t) => t,
deserialize: (t) => t
},
output: {
serialize: (t) => t,
deserialize: (t) => t
}
}, Ee = ({ shape: t }) => t;
function qn(t) {
return Object.assign(/* @__PURE__ */ Object.create(null), t);
}
const Bn = [
"query",
"mutation",
"subscription"
];
function Vn(t) {
return "router" in t._def;
}
const zn = {
_ctx: null,
_errorShape: null,
_meta: null,
queries: {},
mutations: {},
subscriptions: {},
errorFormatter: Ee,
transformer: Te
}, Wn = [
/**
* Then is a reserved word because otherwise we can't return a promise that returns a Proxy
* since JS will think that `.then` is something that exists
*/
"then"
];
function br(t) {
return function(r) {
const n = new Set(Object.keys(r).filter((c) => Wn.includes(c)));
if (n.size > 0)
throw new Error("Reserved words used in `router({})` call: " + Array.from(n).join(", "));
const s = qn({});
function i(c, u = "") {
for (const [l, m] of Object.entries(c ?? {})) {
const y = `${u}${l}`;
if (Vn(m)) {
i(m._def.procedures, `${y}.`);
continue;
}
if (s[y])
throw new Error(`Duplicate key: ${y}`);
s[y] = m;
}
}
i(r);
const a = {
_config: t,
router: !0,
procedures: s,
...zn,
record: r,
queries: Object.entries(s).filter((c) => c[1]._def.query).reduce((c, [u, l]) => ({
...c,
[u]: l
}), {}),
mutations: Object.entries(s).filter((c) => c[1]._def.mutation).reduce((c, [u, l]) => ({
...c,
[u]: l
}), {}),
subscriptions: Object.entries(s).filter((c) => c[1]._def.subscription).reduce((c, [u, l]) => ({
...c,
[u]: l
}), {})
}, o = {
...r,
_def: a,
createCaller(c) {
return wr()(o)(c);
},
getErrorShape(c) {
const { path: u, error: l } = c, { code: m } = c.error, y = {
message: l.message,
code: et[m],
data: {
code: m,
httpStatus: yr(l)
}
};
return t.isDev && typeof c.error.stack == "string" && (y.data.stack = c.error.stack), typeof u == "string" && (y.data.path = u), this._def._config.errorFormatter({
...c,
shape: y
});
}
};
return o;
};
}
function Hn(t) {
const { type: e, path: r } = t;
if (!(r in t.procedures) || !t.procedures[r]?._def[e])
throw new fe({
code: "NOT_FOUND",
message: `No "${e}"-procedure on path "${r}"`
});
const n = t.procedures[r];
return n(t);
}
function wr() {
return function(e) {
const r = e._def;
return function(s) {
return Pt(({ path: a, args: o }) => {
if (a.length === 1 && Bn.includes(a[0]))
return Hn({
procedures: r.procedures,
path: o[0],
rawInput: o[1],
ctx: s,
type: a[0]
});
const c = a.join("."), u = r.procedures[c];
let l = "query";
return u._def.mutation ? l = "mutation" : u._def.subscription && (l = "subscription"), u({
path: c,
rawInput: o[0],
ctx: s,
type: l
});
});
};
};
}
const Yt = typeof window > "u" || "Deno" in window || globalThis.process?.env?.NODE_ENV === "test" || !!globalThis.process?.env?.JEST_WORKER_ID || !!globalThis.process?.env?.VITEST_WORKER_ID;
function Gt(t) {
const e = t;
if (typeof e == "function")
return e;
if (typeof e.parseAsync == "function")
return e.parseAsync.bind(e);
if (typeof e.parse == "function")
return e.parse.bind(e);
if (typeof e.validateSync == "function")
return e.validateSync.bind(e);
if (typeof e.create == "function")
return e.create.bind(e);
if (typeof e.assert == "function")
return (r) => (e.assert(r), r);
throw new Error("Could not find a validator fn");
}
function xr(t, ...e) {
const r = Object.assign(/* @__PURE__ */ Object.create(null), t);
for (const n of e)
for (const s in n) {
if (s in r && r[s] !== n[s])
throw new Error(`Duplicate key ${s}`);
r[s] = n[s];
}
return r;
}
function Fn() {
function t(r) {
return {
_middlewares: r,
unstable_pipe(n) {
const s = "_middlewares" in n ? n._middlewares : [
n
];
return t([
...r,
...s
]);
}
};
}
function e(r) {
return t([
r
]);
}
return e;
}
function Qt(t) {
return t && typeof t == "object" && !Array.isArray(t);
}
function Jn(t) {
const e = async ({ next: r, rawInput: n, input: s }) => {
let i;
try {
i = await t(n);
} catch (o) {
throw new fe({
code: "BAD_REQUEST",
cause: o
});
}
const a = Qt(s) && Qt(i) ? {
...s,
...i
} : i;
return r({
input: a
});
};
return e._type = "input", e;
}
function Yn(t) {
const e = async ({ next: r }) => {
const n = await r();
if (!n.ok)
return n;
try {
const s = await t(n.data);
return {
...n,
data: s
};
} catch (s) {
throw new fe({
message: "Output validation failed",
code: "INTERNAL_SERVER_ERROR",
cause: s
});
}
};
return e._type = "output", e;
}
const kr = "middlewareMarker";
function ce(t, e) {
const { middlewares: r = [], inputs: n, meta: s, ...i } = e;
return Tr({
...xr(t, i),
inputs: [
...t.inputs,
...n ?? []
],
middlewares: [
...t.middlewares,
...r
],
meta: t.meta && s ? {
...t.meta,
...s
} : s ?? t.meta
});
}
function Tr(t = {}) {
const e = {
inputs: [],
middlewares: [],
...t
};
return {
_def: e,
input(r) {
const n = Gt(r);
return ce(e, {
inputs: [
r
],
middlewares: [
Jn(n)
]
});
},
output(r) {
const n = Gt(r);
return ce(e, {
output: r,
middlewares: [
Yn(n)
]
});
},
meta(r) {
return ce(e, {
meta: r
});
},
/**
* @deprecated
* This functionality is deprecated and will be removed in the next major version.
*/
unstable_concat(r) {
return ce(e, r._def);
},
use(r) {
const n = "_middlewares" in r ? r._middlewares : [
r
];
return ce(e, {
middlewares: n
});
},
query(r) {
return lt({
...e,
query: !0
}, r);
},
mutation(r) {
return lt({
...e,
mutation: !0
}, r);
},
subscription(r) {
return lt({
...e,
subscription: !0
}, r);
}
};
}
function lt(t, e) {
const r = ce(t, {
resolver: e,
middlewares: [
async function(s) {
const i = await e(s);
return {
marker: kr,
ok: !0,
data: i,
ctx: s.ctx
};
}
]
});
return Qn(r._def);
}
const Gn = `
This is a client-only function.
If you want to call this function on the server, see https://trpc.io/docs/server/server-side-calls
`.trim();
function Qn(t) {
const e = async function(n) {
if (!n || !("rawInput" in n))
throw new Error(Gn);
const s = async (a = {
index: 0,
ctx: n.ctx
}) => {
try {
const o = t.middlewares[a.index];
return await o({
ctx: a.ctx,
type: n.type,
path: n.path,
rawInput: a.rawInput ?? n.rawInput,
meta: t.meta,
input: a.input,
next(u) {
const l = u;
return s({
index: a.index + 1,
ctx: l && "ctx" in l ? {
...a.ctx,
...l.ctx
} : a.ctx,
input: l && "input" in l ? l.input : a.input,
rawInput: l && "rawInput" in l ? l.rawInput : a.rawInput
});
}
});
} catch (o) {
return {
ok: !1,
error: Zn(o),
marker: kr
};
}
}, i = await s();
if (!i)
throw new fe({
code: "INTERNAL_SERVER_ERROR",
message: "No result from middlewares - did you forget to `return next()`?"
});
if (!i.ok)
throw i.error;
return i.data;
};
return e._def = t, e.meta = t.meta, e;
}
function Xn(...t) {
const e = xr({}, ...t.map((i) => i._def.record)), r = t.reduce((i, a) => {
if (a._def._config.errorFormatter && a._def._config.errorFormatter !== Ee) {
if (i !== Ee && i !== a._def._config.errorFormatter)
throw new Error("You seem to have several error formatters");
return a._def._config.errorFormatter;
}
return i;
}, Ee), n = t.reduce((i, a) => {
if (a._def._config.transformer && a._def._config.transformer !== Te) {
if (i !== Te && i !== a._def._config.transformer)
throw new Error("You seem to have several transformers");
return a._def._config.transformer;
}
return i;
}, Te);
return br({
errorFormatter: r,
transformer: n,
isDev: t.some((i) => i._def._config.isDev),
allowOutsideOfServer: t.some((i) => i._def._config.allowOutsideOfServer),
isServer: t.some((i) => i._def._config.isServer),
$types: t[0]?._def._config.$types
})(e);
}
class We {
context() {
return new We();
}
meta() {
return new We();
}
create(e) {
return es()(e);
}
}
const Kn = new We();
function es() {
return function(e) {
const r = e?.errorFormatter ?? Ee, s = {
transformer: Un(e?.transformer ?? Te),
isDev: e?.isDev ?? globalThis.process?.env?.NODE_ENV !== "production",
allowOutsideOfServer: e?.allowOutsideOfServer ?? !1,
errorFormatter: r,
isServer: e?.isServer ?? Yt,
/**
* @internal
*/
$types: Nt((i) => {
throw new Error(`Tried to access "$types.${i}" which is not available at runtime`);
})
};
if (!(e?.isServer ?? Yt) && e?.allowOutsideOfServer !== !0)
throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.");
return {
/**
* These are just types, they can't be used
* @internal
*/
_config: s,
/**
* Builder object for creating procedures
* @see https://trpc.io/docs/server/procedures
*/
procedure: Tr({
meta: e?.defaultMeta
}),
/**
* Create reusable middlewares
* @see https://trpc.io/docs/server/middlewares
*/
middleware: Fn(),
/**
* Create a router
* @see https://trpc.io/docs/server/routers
*/
router: br(s),
/**
* Merge Routers
* @see https://trpc.io/docs/server/merging-routers
*/
mergeRouters: Xn,
/**
* Create a server-side caller for a router
* @see https://trpc.io/docs/server/server-side-calls
*/
createCallerFactory: wr()
};
};
}
var vt = {}, tt = {}, ye = {}, S = {};
const ge = /* @__PURE__ */ ur(vn);
var It = {}, Er = ge;
function Cr(t) {
return Er.observable((e) => {
function r(s = 0, i = t.op) {
const a = t.links[s];
if (!a)
throw new Error("No more links to execute - did you forget to add an ending link?");
return a({
op: i,
next(c) {
return r(s + 1, c);
}
});
}
return r().subscribe(e);
});
}
function Xt(t) {
return Array.isArray(t) ? t : [
t
];
}
function ts(t) {
return (e) => {
const r = Xt(t.true).map((s) => s(e)), n = Xt(t.false).map((s) => s(e));
return (s) => Er.observable((i) => {
const a = t.condition(s.op) ? r : n;
return Cr({
op: s.op,
links: a
}).subscribe(i);
});
};
}
It.createChain = Cr;
It.splitLink = ts;
var _e = {};
const Rr = /* @__PURE__ */ ur(Rn);
var ve = {};
function bt(t) {
return !!t && !Array.isArray(t) && typeof t == "object";
}
function rs(t, e) {
if ("error" in t) {
const n = e.transformer.deserialize(t.error);
return {
ok: !1,
error: {
...t,
error: n
}
};
}
return {
ok: !0,
result: {
...t.result,
...(!t.result.type || t.result.type === "data") && {
type: "data",
data: e.transformer.deserialize(t.result.data)
}
}
};
}
class ft extends Error {
constructor() {
super("Unable to transform response from server");
}
}
function ns(t, e) {
let r;
try {
r = rs(t, e);
} catch {
throw new ft();
}
if (!r.ok && (!bt(r.error.error) || typeof r.error.error.code != "number"))
throw new ft();
if (r.ok && !bt(r.result))
throw new ft();
return r;
}
ve.isObject = bt;
ve.transformResult = ns;
var ss = Rr, Kt = ve;
function is(t) {
return t instanceof Or || /**
* @deprecated
* Delete in next major
*/
t instanceof Error && t.name === "TRPCClientError";
}
function as(t) {
return Kt.isObject(t) && Kt.isObject(t.error) && typeof t.error.code == "number" && typeof t.error.message == "string";
}
let Or = class we extends Error {
static from(e, r = {}) {
const n = e;
return is(n) ? (r.meta && (n.meta = {
...n.meta,
...r.meta
}), n) : as(n) ? new we(n.error.message, {
...r,
result: n
}) : n instanceof Error ? new we(n.message, {
...r,
cause: ss.getCauseFromUnknown(n)
}) : new we("Unknown error", {
...r,
cause: n
});
}
constructor(e, r) {
const n = r?.cause;
super(e, {
cause: n
}), this.meta = r?.meta, this.cause = n, this.shape = r?.result?.error, this.data = r?.result?.error.data, this.name = "TRPCClientError", Object.setPrototypeOf(this, we.prototype);
}
};
_e.TRPCClientError = Or;
var W = {}, os = _e;
const er = (t) => typeof t == "function";
function Sr(t) {
if (t)
return t;
if (typeof window < "u" && er(window.fetch))
return window.fetch;
if (typeof globalThis < "u" && er(globalThis.fetch))
return globalThis.fetch;
throw new Error("No fetch implementation found");
}
function cs(t) {
return t || (typeof window < "u" && window.AbortController ? window.AbortController : typeof globalThis < "u" && globalThis.AbortController ? globalThis.AbortController : null);
}
function us(t) {
return {
url: t.url.toString().replace(/\/$/, ""),
fetch: t.fetch,
AbortController: cs(t.AbortController)
};
}
function ds(t) {
const e = {};
for (let r = 0; r < t.length; r++) {
const n = t[r];
e[r] = n;
}
return e;
}
const ls = {
query: "GET",
mutation: "POST"
};
function Pr(t) {
return "input" in t ? t.runtime.transformer.serialize(t.input) : ds(t.inputs.map((e) => t.runtime.transformer.serialize(e)));
}
const Nr = (t) => {
let e = t.url + "/" + t.path;
const r = [];
if ("inputs" in t && r.push("batch=1"), t.type === "query") {
const n = Pr(t);
n !== void 0 && r.push(`input=${encodeURIComponent(JSON.stringify(n))}`);
}
return r.length && (e += "?" + r.join("&")), e;
}, Lr = (t) => {
if (t.type === "query")
return;
const e = Pr(t);
return e !== void 0 ? JSON.stringify(e) : void 0;
}, fs = (t) => jr({
...t,
contentTypeHeader: "application/json",
getUrl: Nr,
getBody: Lr
});
async function Ir(t, e) {
const r = t.getUrl(t), n = t.getBody(t), { type: s } = t, i = await t.headers();
/* istanbul ignore if -- @preserve */
if (s === "subscription")
throw new Error("Subscriptions should use wsLink");
const a = {
...t.contentTypeHeader ? {
"content-type": t.contentTypeHeader
} : {},
...t.batchModeHeader ? {
"trpc-batch-mode": t.batchModeHeader
} : {},
...i
};
return Sr(t.fetch)(r, {
method: ls[s],
signal: e?.signal,
body: n,
headers: a
});
}
function jr(t) {
const e = t.AbortController ? new t.AbortController() : null, r = {};
let n = !1;
return {
promise: new Promise((a, o) => {
Ir(t, e).then((c) => (r.response = c, n = !0, c.json())).then((c) => {
r.responseJSON = c, a({
json: c,
meta: r
});
}).catch((c) => {
n = !0, o(os.TRPCClientError.from(c, {
meta: r
}));
});
}),
cancel: () => {
n || e?.abort();
}
};
}
W.fetchHTTPResponse = Ir;
W.getBody = Lr;
W.getFetch = Sr;
W.getUrl = Nr;
W.httpRequest = jr;
W.jsonHttpRequester = fs;
W.resolveHTTPLinkOptions = us;
var jt = {}, ps = ge, hs = ve, tr = _e, wt = W;
const pt = () => {
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
};
function ht(t) {
let e = null, r = null;
const n = () => {
clearTimeout(r), r = null, e = null;
};
function s(o) {
const c = [
[]
];
let u = 0;
for (; ; ) {
const l = o[u];
if (!l)
break;
const m = c[c.length - 1];
if (l.aborted) {
l.reject?.(new Error("Aborted")), u++;
continue;
}
if (t.validate(m.concat(l).map((k) => k.key))) {
m.push(l), u++;
continue;
}
if (m.length === 0) {
l.reject?.(new Error("Input is too big for a single dispatch")), u++;
continue;
}
c.push([]);
}
return c;
}
function i() {
const o = s(e);
n();
for (const c of o) {
if (!c.length)
continue;
const u = {
items: c,
cancel: pt
};
for (const k of c)
k.batch = u;
const l = (k, T) => {
const N = u.items[k];
N.resolve?.(T), N.batch = null, N.reject = null, N.resolve = null;
}, { promise: m, cancel: y } = t.fetch(u.items.map((k) => k.key), l);
u.cancel = y, m.then((k) => {
for (let T = 0; T < k.length; T++) {
const N = k[T];
l(T, N);
}
for (const T of u.items)
T.reject?.(new Error("Missing result")), T.batch = null;
}).catch((k) => {
for (const T of u.items)
T.reject?.(k), T.batch = null;
});
}
}
function a(o) {
const c = {
aborted: !1,
key: o,
batch: null,
resolve: pt,
reject: pt
}, u = new Promise((m, y) => {
c.reject = y, c.resolve = m, e || (e = []), e.push(c);
});
return r || (r = setTimeout(i)), {
promise: u,
cancel: () => {
c.aborted = !0, c.batch?.items.every((m) => m.aborted) && (c.batch.cancel(), c.batch = null);
}
};
}
return {
load: a
};
}
function Ar(t) {
return function(r) {
const n = wt.resolveHTTPLinkOptions(r), s = r.maxURLLength ?? 1 / 0;
return (i) => {
const a = (m) => {
const y = (T) => {
if (s === 1 / 0)
return !0;
const N = T.map((H) => H.path).join(","), ae = T.map((H) => H.input);
return wt.getUrl({
...n,
runtime: i,
type: m,
path: N,
inputs: ae
}).length <= s;
}, k = t({
...n,
runtime: i,
type: m,
opts: r
});
return {
validate: y,
fetch: k
};
}, o = ht(a("query")), c = ht(a("mutation")), u = ht(a("subscription")), l = {
query: o,
subscription: u,
mutation: c
};
return ({ op: m }) => ps.observable((y) => {
const k = l[m.type], { promise: T, cancel: N } = k.load(m);
let ae;
return T.then(($) => {
ae = $;
const H = hs.transformResult($.json, i);
if (!H.ok) {
y.error(tr.TRPCClientError.from(H.error, {
meta: $.meta
}));
return;
}
y.next({
context: $.meta,
result: H.result
}), y.complete();
}).catch(($) => {
y.error(tr.TRPCClientError.from($, {
meta: ae?.meta
}));
}), () => {
N();
};
});
};
};
}
const ms = (t) => (e) => {
const r = e.map((a) => a.path).join(","), n = e.map((a) => a.input), { promise: s, cancel: i } = wt.jsonHttpRequester({
...t,
path: r,
inputs: n,
headers() {
return t.opts.headers ? typeof t.opts.headers == "function" ? t.opts.headers({
opList: e
}) : t.opts.headers : {};
}
});
return {
promise: s.then((a) => (Array.isArray(a.json) ? a.json : e.map(() => a.json)).map((u) => ({
meta: a.meta,
json: u
}))),
cancel: i
};
}, ys = Ar(ms);
jt.createHTTPBatchLink = Ar;
jt.httpBatchLink = ys;
var rt = {};
Object.defineProperty(rt, "__esModule", { value: !0 });
var gs = ge, _s = ve, rr = _e, $r = W;
function Mr(t) {
return (e) => {
const r = $r.resolveHTTPLinkOptions(e);
return (n) => ({ op: s }) => gs.observable((i) => {
const { path: a, input: o, type: c } = s, { promise: u, cancel: l } = t.requester({
...r,
runtime: n,
type: c,
path: a,
input: o,
headers() {
return e.headers ? typeof e.headers == "function" ? e.headers({
op: s
}) : e.headers : {};
}
});
let m;
return u.then((y) => {
m = y.meta;
const k = _s.transformResult(y.json, n);
if (!k.ok) {
i.error(rr.TRPCClientError.from(k.error, {
meta: m
}));
return;
}
i.next({
context: y.meta,
result: k.result
}), i.complete();
}).catch((y) => {
i.error(rr.TRPCClientError.from(y, {
meta: m
}));
}), () => {
l();
};
});
};
}
const vs = Mr({
requester: $r.jsonHttpRequester
});
rt.httpLink = vs;
rt.httpLinkFactory = Mr;
var At = {};
Object.defineProperty(At, "__esModule", { value: !0 });
var nr = ge;
function bs(t) {
return typeof FormData > "u" ? !1 : t instanceof FormData;
}
const mt = {
css: {
query: [
"72e3ff",
"3fb0d8"
],
mutation: [
"c5a3fc",
"904dfc"
],
subscription: [
"ff49e1",
"d83fbe"
]
},
ansi: {
regular: {
// Cyan background, black and white text respectively
query: [
"\x1B[30;46m",
"\x1B[97;46m"
],
// Magenta background, black and white text respectively
mutation: [
"\x1B[30;45m",
"\x1B[97;45m"
],
// Green background, black and white text respectively
subscription: [
"\x1B[30;42m",
"\x1B[97;42m"
]
},
bold: {
query: [
"\x1B[1;30;46m",
"\x1B[1;97;46m"
],
mutation: [
"\x1B[1;30;45m",
"\x1B[1;97;45m"
],
subscription: [
"\x1B[1;30;42m",
"\x1B[1;97;42m"
]
}
}
};
function ws(t) {
const { direction: e, type: r, path: n, id: s, input: i } = t, a = [], o = [];
if (t.colorMode === "ansi") {
const [m, y] = mt.ansi.regular[r], [k, T] = mt.ansi.bold[r], N = "\x1B[0m";
return a.push(e === "up" ? m : y, e === "up" ? ">>" : "<<", r, e === "up" ? k : T, `#${s}`, n, N), e === "up" ? o.push({
input: t.input
}) : o.push({
input: t.input,
// strip context from result cause it's too noisy in terminal wihtout collapse mode
result: "result" in t.result ? t.result.result : t.result,
elapsedMs: t.elapsedMs
}), {
parts: a,
args: o
};
}
const [c, u] = mt.css[r], l = `
background-color: #${e === "up" ? c : u};
color: ${e === "up" ? "black" : "white"};
padding: 2px;
`;
return a.push("%c", e === "up" ? ">>" : "<<", r, `#${s}`, `%c${n}%c`, "%O"), o.push(l, `${l}; font-weight: bold;`, `${l}; font-weight: normal;`), e === "up" ? o.push({
input: i,
context: t.context
}) : o.push({
input: i,
result: t.result,
elapsedMs: t.elapsedMs,
context: t.context
}), {
parts: a,
args: o
};
}
const xs = ({ c: t = console, colorMode: e = "css" }) => (r) => {
const n = r.input, s = bs(n) ? Object.fromEntries(n) : n, { parts: i, args: a } = ws({
...r,
colorMode: e,
input: s
}), o = r.direction === "down" && r.result && (r.result instanceof Error || "error" in r.result.result) ? "error" : "log";
t[o].apply(null, [
i.join(" ")
].concat(a));
};
function ks(t = {}) {
const { enabled: e = () => !0 } = t, r = t.colorMode ?? (typeof window > "u" ? "ansi" : "css"), { logger: n = xs({
c: t.console,
colorMode: r
}) } = t;
return () => ({ op: s, next: i }) => nr.observable((a) => {
e({
...s,
direction: "up"
}) && n({
...s,
direction: "up"
});
const o = Date.now();
function c(u) {
const l = Date.now() - o;
e({
...s,
direction: "down",
result: u
}) && n({
...s,
direction: "down",
elapsedMs: l,
result: u
});
}
return i(s).pipe(nr.tap({
next(u) {
c(u);
},
error(u) {
c(u);
}
})).subscribe(a);
});
}
At.loggerLink = ks;
var nt = {};
Object.defineProperty(nt, "__esModule", { value: !0 });
var Ts = ge, Es = ve, Dr = _e;
/* istanbul ignore next -- @preserve */
const Cs = (t) => t === 0 ? 0 : Math.min(1e3 * 2 ** t, 3e4);
function Rs(t) {
const { url: e, WebSocket: r = WebSocket, retryDelayMs: n = Cs, onOpen: s, onClose: i } = t;
/* istanbul ignore next -- @preserve */
if (!r)
throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
let a = [];
const o = /* @__PURE__ */ Object.create(null);
let c = 0, u = null, l = null, m = Vt(), y = "connecting";
function k() {
y !== "open" || u || (u = setTimeout(() => {
u = null, a.length === 1 ? m.send(JSON.stringify(a.pop())) : m.send(JSON.stringify(a)), a = [];
}));
}
function T() {
if (l !== null || y === "closed")
return;
const R = n(c++);
ae(R);
}
function N() {
y = "connecting";
const R = m;
m = Vt(), $(R);
}
function ae(R) {
l || (y = "connecting", l = setTimeout(N, R));
}
function $(R) {
Object.values(o).some((oe) => oe.ws === R) || R.close();
}
function H() {
Object.values(o).forEach((R) => {
R.type === "subscription" && R.callbacks.complete();
});
}
function Bt(R) {
a.some((P) => P.id === R.op.id) || zt(R.op, R.callbacks);
}
function Vt() {
const R = typeof e == "function" ? e() : e, P = new r(R);
clearTimeout(l), l = null, P.addEventListener("open", () => {
/* istanbul ignore next -- @preserve */
P === m && (c = 0, y = "open", s?.(), k());
}), P.addEventListener("error", () => {
P === m && T();
});
const oe = (j) => {
if (j.method === "reconnect" && P === m) {
y === "open" && i?.(), N();
for (const E of Object.values(o))
E.type === "subscription" && Bt(E);
}
}, ut = (j) => {
const E = j.id !== null && o[j.id];
if (E) {
if (E.callbacks.next?.(j), E.ws !== m && P === m) {
const F = E.ws;
E.ws = m, $(F);
}
"result" in j && j.result.type === "stopped" && P === m && E.callbacks.complete();
}
};
return P.addEventListener("message", ({ data: j }) => {
const E = JSON.parse(j);
"method" in E ? oe(E) : ut(E), (P !== m || y === "closed") && $(P);
}), P.addEventListener("close", ({ code: j }) => {
y === "open" && i?.({
code: j
}), m === P && T();
for (const [E, F] of Object.entries(o))
if (F.ws === P) {
if (y === "closed") {
delete o[E], F.callbacks.complete?.();
continue;
}
F.type === "subscription" ? Bt(F) : (delete o[E], F.callbacks.error?.(Dr.TRPCClientError.from(new $t("WebSocket closed prematurely"))));
}
}), P;
}
function zt(R, P) {
const { type: oe, input: ut, path: j, id: E } = R, F = {
id: E,
method: oe,
params: {
input: ut,
path: j
}
};
return o[E] = {
ws: m,
type: oe,
callbacks: P,
op: R
}, a.push(F), k(), () => {
const dn = o[E]?.callbacks;
delete o[E], a = a.filter((ln) => ln.id !== E), dn?.complete?.(), m.readyState === r.OPEN && R.type === "subscription" && (a.push({
id: E,
method: "subscription.stop"
}), k());
};
}
return {
close: () => {
y = "closed", i?.(), H(), $(m), clearTimeout(l), l = null;
},
request: zt,
getConnection() {
return m;
}
};
}
class $t extends Error {
constructor(e) {
super(e), this.name = "TRPCWebSocketClosedError", Object.setPrototypeOf(this, $t.prototype);
}
}
function Os(t) {
return (e) => {
const { client: r } = t;
return ({ op: n }) => Ts.observable((s) => {
const { type: i, path: a, id: o, context: c } = n, u = e.transformer.serialize(n.input), l = r.request({
type: i,
path: a,
input: u,
id: o,
context: c
}, {
error(m) {
s.error(m), l();
},
complete() {
s.complete();
},
next(m) {
const y = Es.transformResult(m, e);
if (!y.ok) {
s.error(Dr.TRPCClientError.from(y.error));
return;
}
s.next({
result: y.result
}), n.type !== "subscription" && (l(), s.complete());
}
});
return () => {
l();
};
});
};
}
nt.createWSClient = Rs;
nt.wsLink = Os;
Object.defineProperty(S, "__esModule", { value: !0 });
var sr = ge, Zr = It, Ur = _e, ir = Rr, Ce = W, qr = jt, Mt = rt, Ss = At, Br = nt;
class st {
$request({ type: e, input: r, path: n, context: s = {} }) {
return Zr.createChain({
links: this.links,
op: {
id: ++this.requestId,
type: e,
path: n,
input: r,
context: s
}
}).pipe(sr.share());
}
requestAsPromise(e) {
const r = this.$request(e), { promise: n, abort: s } = sr.observableToPromise(r);
return new Promise((a, o) => {
e.signal?.addEventListener("abort", s), n.then((c) => {
a(c.result.data);
}).catch((c) => {
o(Ur.TRPCClientError.from(c));
});
});
}
query(e, r, n) {
return this.requestAsPromise({
type: "query",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
mutation(e, r, n) {
return this.requestAsPromise({
type: "mutation",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
subscription(e, r, n) {
return this.$request({
type: "subscription",
path: e,
input: r,
context: n?.context
}).subscribe({
next(i) {
i.result.type === "started" ? n.onStarted?.() : i.result.type === "stopped" ? n.onStopped?.() : n.onData?.(i.result.data);
},
error(i) {
n.onError?.(i);
},
complete() {
n.onComplete?.();
}
});
}
constructor(e) {
this.requestId = 0;
const r = (() => {
const n = e.transformer;
return n ? "input" in n ? e.transformer : {
input: n,
output: n
} : {
input: {
serialize: (s) => s,
deserialize: (s) => s
},
output: {
serialize: (s) => s,
deserialize: (s) => s
}
};
})();
this.runtime = {
transformer: {
serialize: (n) => r.input.serialize(n),
deserialize: (n) => r.output.deserialize(n)
},
combinedTransformer: r
}, this.links = e.links.map((n) => n(this.runtime));
}
}
function Ps(t) {
return new st(t);
}
function Ns(t) {
return new st(t);
}
const Ls = {
query: "query",
mutate: "mutation",
subscribe: "subscription"
}, Vr = (t) => Ls[t];
function zr(t) {
return ir.createFlatProxy((e) => t.hasOwnProperty(e) ? t[e] : e === "__untypedClient" ? t : ir.createRecursiveProxy(({ path: r, args: n }) => {
const s = [
e,
...r
], i = Vr(s.pop()), a = s.join(".");
return t[i](a, ...n);
}));
}
function Is(t) {
const e = new st(t);
return zr(e);
}
function js(t) {
return t.__untypedClient;
}
function As(t) {
if (t)
return t;
if (typeof window < "u" && window.TextDecoder)
return new window.TextDecoder();
if (typeof globalThis < "u" && globalThis.TextDecoder)
return new globalThis.TextDecoder();
throw new Error("No TextDecoder implementation found");
}
async function $s(t) {
const e = t.parse ?? JSON.parse, r = (n) => {
if (t.signal?.aborted || !n || n === "}")
return;
const s = n.indexOf(":"), i = n.substring(2, s - 1), a = n.substring(s + 1);
t.onSingle(Number(i), e(a));
};
await Ms(t.readableStream, r, t.textDecoder);
}
async function Ms(t, e