@voxket-ai/voxket-live
Version:
A React widget for embedding Voxket-powered audio/video/chat experiences.
1,660 lines • 3.09 MB
JavaScript
var OD = Object.defineProperty;
var vw = (t) => {
throw TypeError(t);
};
var DD = (t, e, n) => e in t ? OD(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var we = (t, e, n) => DD(t, typeof e != "symbol" ? e + "" : e, n), bw = (t, e, n) => e.has(t) || vw("Cannot " + n);
var tt = (t, e, n) => (bw(t, e, "read from private field"), n ? n.call(t) : e.get(t)), un = (t, e, n) => e.has(t) ? vw("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), wn = (t, e, n, i) => (bw(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n);
import * as N from "react";
import je, { createContext as Mo, useRef as Tt, useLayoutEffect as LD, useEffect as Kt, useId as Fb, useContext as Gn, useInsertionEffect as Ub, useMemo as Oi, useCallback as $t, Children as FD, isValidElement as UD, useState as qe, Fragment as rA, createElement as BD, forwardRef as jD, Component as VD, version as oA } from "react";
import { jsx as S, Fragment as Yn, jsxs as M } from "react/jsx-runtime";
import sA, { clsx as zD } from "clsx";
import { X as GD, Clock as HD, Paperclip as KD, SendHorizontal as qD, Mic as WD, MicOff as QD, Camera as $D, CameraOff as aA, SwitchCamera as Bb, Monitor as cA, MessageCircle as YD, MessageCircleOff as JD, PhoneOff as XD, Download as ZD, Image as e2, Video as t2, Music as n2, Archive as i2, FileText as r2, LayoutGrid as lA, Users as o2, User as dA } from "lucide-react";
import s2 from "@emotion/styled";
import "@emotion/react";
import { createRoot as uA } from "react-dom/client";
function a2(t, e) {
return e.forEach(function(n) {
n && typeof n != "string" && !Array.isArray(n) && Object.keys(n).forEach(function(i) {
if (i !== "default" && !(i in t)) {
var r = Object.getOwnPropertyDescriptor(n, i);
Object.defineProperty(t, i, r.get ? r : { enumerable: !0, get: function() {
return n[i];
} });
}
});
}), Object.freeze(t);
}
var c2 = Object.defineProperty, l2 = (t, e, n) => e in t ? c2(t, e, {
enumerable: !0,
configurable: !0,
writable: !0,
value: n
}) : t[e] = n, yw = (t, e, n) => l2(t, typeof e != "symbol" ? e + "" : e, n);
let Si = class {
constructor() {
yw(this, "_locking"), yw(this, "_locks"), this._locking = Promise.resolve(), this._locks = 0;
}
isLocked() {
return this._locks > 0;
}
lock() {
this._locks += 1;
let e;
const n = new Promise((r) => e = () => {
this._locks -= 1, r();
}), i = this._locking.then(() => e);
return this._locking = this._locking.then(() => n), i;
}
};
function En(t, e) {
if (!t)
throw new Error(e);
}
const d2 = 34028234663852886e22, u2 = -34028234663852886e22, h2 = 4294967295, p2 = 2147483647, f2 = -2147483648;
function qu(t) {
if (typeof t != "number") throw new Error("invalid int 32: " + typeof t);
if (!Number.isInteger(t) || t > p2 || t < f2) throw new Error("invalid int 32: " + t);
}
function Sg(t) {
if (typeof t != "number") throw new Error("invalid uint 32: " + typeof t);
if (!Number.isInteger(t) || t > h2 || t < 0) throw new Error("invalid uint 32: " + t);
}
function hA(t) {
if (typeof t != "number") throw new Error("invalid float 32: " + typeof t);
if (Number.isFinite(t) && (t > d2 || t < u2))
throw new Error("invalid float 32: " + t);
}
const pA = Symbol("@bufbuild/protobuf/enum-type");
function m2(t) {
const e = t[pA];
return En(e, "missing enum type on enum object"), e;
}
function fA(t, e, n, i) {
t[pA] = mA(e, n.map((r) => ({
no: r.no,
name: r.name,
localName: t[r.no]
})));
}
function mA(t, e, n) {
const i = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ Object.create(null), o = [];
for (const s of e) {
const a = gA(s);
o.push(a), i[s.name] = a, r[s.no] = a;
}
return {
typeName: t,
values: o,
// We do not surface options at this time
// options: opt?.options ?? Object.create(null),
findName(s) {
return i[s];
},
findNumber(s) {
return r[s];
}
};
}
function g2(t, e, n) {
const i = {};
for (const r of e) {
const o = gA(r);
i[o.localName] = o.no, i[o.no] = o.localName;
}
return fA(i, t, e), i;
}
function gA(t) {
return "localName" in t ? t : Object.assign(Object.assign({}, t), {
localName: t.name
});
}
let jb = class {
/**
* Compare with a message of the same type.
* Note that this function disregards extensions and unknown fields.
*/
equals(e) {
return this.getType().runtime.util.equals(this.getType(), this, e);
}
/**
* Create a deep copy.
*/
clone() {
return this.getType().runtime.util.clone(this);
}
/**
* Parse from binary data, merging fields.
*
* Repeated fields are appended. Map entries are added, overwriting
* existing keys.
*
* If a message field is already present, it will be merged with the
* new data.
*/
fromBinary(e, n) {
const i = this.getType(), r = i.runtime.bin, o = r.makeReadOptions(n);
return r.readMessage(this, o.readerFactory(e), e.byteLength, o), this;
}
/**
* Parse a message from a JSON value.
*/
fromJson(e, n) {
const i = this.getType(), r = i.runtime.json, o = r.makeReadOptions(n);
return r.readMessage(i, e, o, this), this;
}
/**
* Parse a message from a JSON string.
*/
fromJsonString(e, n) {
let i;
try {
i = JSON.parse(e);
} catch (r) {
throw new Error("cannot decode ".concat(this.getType().typeName, " from JSON: ").concat(r instanceof Error ? r.message : String(r)));
}
return this.fromJson(i, n);
}
/**
* Serialize the message to binary data.
*/
toBinary(e) {
const n = this.getType(), i = n.runtime.bin, r = i.makeWriteOptions(e), o = r.writerFactory();
return i.writeMessage(this, o, r), o.finish();
}
/**
* Serialize the message to a JSON value, a JavaScript value that can be
* passed to JSON.stringify().
*/
toJson(e) {
const n = this.getType(), i = n.runtime.json, r = i.makeWriteOptions(e);
return i.writeMessage(this, r);
}
/**
* Serialize the message to a JSON string.
*/
toJsonString(e) {
var n;
const i = this.toJson(e);
return JSON.stringify(i, null, (n = e == null ? void 0 : e.prettySpaces) !== null && n !== void 0 ? n : 0);
}
/**
* Override for serialization behavior. This will be invoked when calling
* JSON.stringify on this message (i.e. JSON.stringify(msg)).
*
* Note that this will not serialize google.protobuf.Any with a packed
* message because the protobuf JSON format specifies that it needs to be
* unpacked, and this is only possible with a type registry to look up the
* message type. As a result, attempting to serialize a message with this
* type will throw an Error.
*
* This method is protected because you should not need to invoke it
* directly -- instead use JSON.stringify or toJsonString for
* stringified JSON. Alternatively, if actual JSON is desired, you should
* use toJson.
*/
toJSON() {
return this.toJson({
emitDefaultValues: !0
});
}
/**
* Retrieve the MessageType of this message - a singleton that represents
* the protobuf message declaration and provides metadata for reflection-
* based operations.
*/
getType() {
return Object.getPrototypeOf(this).constructor;
}
};
function v2(t, e, n, i) {
var r;
const o = (r = i == null ? void 0 : i.localName) !== null && r !== void 0 ? r : e.substring(e.lastIndexOf(".") + 1), s = {
[o]: function(a) {
t.util.initFields(this), t.util.initPartial(a, this);
}
}[o];
return Object.setPrototypeOf(s.prototype, new jb()), Object.assign(s, {
runtime: t,
typeName: e,
fields: t.util.newFieldList(n),
fromBinary(a, c) {
return new s().fromBinary(a, c);
},
fromJson(a, c) {
return new s().fromJson(a, c);
},
fromJsonString(a, c) {
return new s().fromJsonString(a, c);
},
equals(a, c) {
return t.util.equals(s, a, c);
}
}), s;
}
function b2() {
let t = 0, e = 0;
for (let i = 0; i < 28; i += 7) {
let r = this.buf[this.pos++];
if (t |= (r & 127) << i, (r & 128) == 0)
return this.assertBounds(), [t, e];
}
let n = this.buf[this.pos++];
if (t |= (n & 15) << 28, e = (n & 112) >> 4, (n & 128) == 0)
return this.assertBounds(), [t, e];
for (let i = 3; i <= 31; i += 7) {
let r = this.buf[this.pos++];
if (e |= (r & 127) << i, (r & 128) == 0)
return this.assertBounds(), [t, e];
}
throw new Error("invalid varint");
}
function xf(t, e, n) {
for (let o = 0; o < 28; o = o + 7) {
const s = t >>> o, a = !(!(s >>> 7) && e == 0), c = (a ? s | 128 : s) & 255;
if (n.push(c), !a)
return;
}
const i = t >>> 28 & 15 | (e & 7) << 4, r = e >> 3 != 0;
if (n.push((r ? i | 128 : i) & 255), !!r) {
for (let o = 3; o < 31; o = o + 7) {
const s = e >>> o, a = !!(s >>> 7), c = (a ? s | 128 : s) & 255;
if (n.push(c), !a)
return;
}
n.push(e >>> 31 & 1);
}
}
const Wu = 4294967296;
function ww(t) {
const e = t[0] === "-";
e && (t = t.slice(1));
const n = 1e6;
let i = 0, r = 0;
function o(s, a) {
const c = Number(t.slice(s, a));
r *= n, i = i * n + c, i >= Wu && (r = r + (i / Wu | 0), i = i % Wu);
}
return o(-24, -18), o(-18, -12), o(-12, -6), o(-6), e ? bA(i, r) : Vb(i, r);
}
function y2(t, e) {
let n = Vb(t, e);
const i = n.hi & 2147483648;
i && (n = bA(n.lo, n.hi));
const r = vA(n.lo, n.hi);
return i ? "-" + r : r;
}
function vA(t, e) {
if ({
lo: t,
hi: e
} = w2(t, e), e <= 2097151)
return String(Wu * e + t);
const n = t & 16777215, i = (t >>> 24 | e << 8) & 16777215, r = e >> 16 & 65535;
let o = n + i * 6777216 + r * 6710656, s = i + r * 8147497, a = r * 2;
const c = 1e7;
return o >= c && (s += Math.floor(o / c), o %= c), s >= c && (a += Math.floor(s / c), s %= c), a.toString() + kw(s) + kw(o);
}
function w2(t, e) {
return {
lo: t >>> 0,
hi: e >>> 0
};
}
function Vb(t, e) {
return {
lo: t | 0,
hi: e | 0
};
}
function bA(t, e) {
return e = ~e, t ? t = ~t + 1 : e += 1, Vb(t, e);
}
const kw = (t) => {
const e = String(t);
return "0000000".slice(e.length) + e;
};
function Sw(t, e) {
if (t >= 0) {
for (; t > 127; )
e.push(t & 127 | 128), t = t >>> 7;
e.push(t);
} else {
for (let n = 0; n < 9; n++)
e.push(t & 127 | 128), t = t >> 7;
e.push(1);
}
}
function k2() {
let t = this.buf[this.pos++], e = t & 127;
if ((t & 128) == 0)
return this.assertBounds(), e;
if (t = this.buf[this.pos++], e |= (t & 127) << 7, (t & 128) == 0)
return this.assertBounds(), e;
if (t = this.buf[this.pos++], e |= (t & 127) << 14, (t & 128) == 0)
return this.assertBounds(), e;
if (t = this.buf[this.pos++], e |= (t & 127) << 21, (t & 128) == 0)
return this.assertBounds(), e;
t = this.buf[this.pos++], e |= (t & 15) << 28;
for (let n = 5; (t & 128) !== 0 && n < 10; n++) t = this.buf[this.pos++];
if ((t & 128) != 0) throw new Error("invalid varint");
return this.assertBounds(), e >>> 0;
}
function S2() {
const t = new DataView(new ArrayBuffer(8));
if (typeof BigInt == "function" && typeof t.getBigInt64 == "function" && typeof t.getBigUint64 == "function" && typeof t.setBigInt64 == "function" && typeof t.setBigUint64 == "function" && (typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
const r = BigInt("-9223372036854775808"), o = BigInt("9223372036854775807"), s = BigInt("0"), a = BigInt("18446744073709551615");
return {
zero: BigInt(0),
supported: !0,
parse(c) {
const l = typeof c == "bigint" ? c : BigInt(c);
if (l > o || l < r)
throw new Error("int64 invalid: ".concat(c));
return l;
},
uParse(c) {
const l = typeof c == "bigint" ? c : BigInt(c);
if (l > a || l < s)
throw new Error("uint64 invalid: ".concat(c));
return l;
},
enc(c) {
return t.setBigInt64(0, this.parse(c), !0), {
lo: t.getInt32(0, !0),
hi: t.getInt32(4, !0)
};
},
uEnc(c) {
return t.setBigInt64(0, this.uParse(c), !0), {
lo: t.getInt32(0, !0),
hi: t.getInt32(4, !0)
};
},
dec(c, l) {
return t.setInt32(0, c, !0), t.setInt32(4, l, !0), t.getBigInt64(0, !0);
},
uDec(c, l) {
return t.setInt32(0, c, !0), t.setInt32(4, l, !0), t.getBigUint64(0, !0);
}
};
}
const n = (r) => En(/^-?[0-9]+$/.test(r), "int64 invalid: ".concat(r)), i = (r) => En(/^[0-9]+$/.test(r), "uint64 invalid: ".concat(r));
return {
zero: "0",
supported: !1,
parse(r) {
return typeof r != "string" && (r = r.toString()), n(r), r;
},
uParse(r) {
return typeof r != "string" && (r = r.toString()), i(r), r;
},
enc(r) {
return typeof r != "string" && (r = r.toString()), n(r), ww(r);
},
uEnc(r) {
return typeof r != "string" && (r = r.toString()), i(r), ww(r);
},
dec(r, o) {
return y2(r, o);
},
uDec(r, o) {
return vA(r, o);
}
};
}
const mn = S2();
var oe;
(function(t) {
t[t.DOUBLE = 1] = "DOUBLE", t[t.FLOAT = 2] = "FLOAT", t[t.INT64 = 3] = "INT64", t[t.UINT64 = 4] = "UINT64", t[t.INT32 = 5] = "INT32", t[t.FIXED64 = 6] = "FIXED64", t[t.FIXED32 = 7] = "FIXED32", t[t.BOOL = 8] = "BOOL", t[t.STRING = 9] = "STRING", t[t.BYTES = 12] = "BYTES", t[t.UINT32 = 13] = "UINT32", t[t.SFIXED32 = 15] = "SFIXED32", t[t.SFIXED64 = 16] = "SFIXED64", t[t.SINT32 = 17] = "SINT32", t[t.SINT64 = 18] = "SINT64";
})(oe || (oe = {}));
var hs;
(function(t) {
t[t.BIGINT = 0] = "BIGINT", t[t.STRING = 1] = "STRING";
})(hs || (hs = {}));
function jo(t, e, n) {
if (e === n)
return !0;
if (t == oe.BYTES) {
if (!(e instanceof Uint8Array) || !(n instanceof Uint8Array) || e.length !== n.length)
return !1;
for (let i = 0; i < e.length; i++)
if (e[i] !== n[i])
return !1;
return !0;
}
switch (t) {
case oe.UINT64:
case oe.FIXED64:
case oe.INT64:
case oe.SFIXED64:
case oe.SINT64:
return e == n;
}
return !1;
}
function Cc(t, e) {
switch (t) {
case oe.BOOL:
return !1;
case oe.UINT64:
case oe.FIXED64:
case oe.INT64:
case oe.SFIXED64:
case oe.SINT64:
return e == 0 ? mn.zero : "0";
case oe.DOUBLE:
case oe.FLOAT:
return 0;
case oe.BYTES:
return new Uint8Array(0);
case oe.STRING:
return "";
default:
return 0;
}
}
function yA(t, e) {
switch (t) {
case oe.BOOL:
return e === !1;
case oe.STRING:
return e === "";
case oe.BYTES:
return e instanceof Uint8Array && !e.byteLength;
default:
return e == 0;
}
}
var In;
(function(t) {
t[t.Varint = 0] = "Varint", t[t.Bit64 = 1] = "Bit64", t[t.LengthDelimited = 2] = "LengthDelimited", t[t.StartGroup = 3] = "StartGroup", t[t.EndGroup = 4] = "EndGroup", t[t.Bit32 = 5] = "Bit32";
})(In || (In = {}));
let T2 = class {
constructor(e) {
this.stack = [], this.textEncoder = e ?? new TextEncoder(), this.chunks = [], this.buf = [];
}
/**
* Return all bytes written and reset this writer.
*/
finish() {
this.chunks.push(new Uint8Array(this.buf));
let e = 0;
for (let r = 0; r < this.chunks.length; r++) e += this.chunks[r].length;
let n = new Uint8Array(e), i = 0;
for (let r = 0; r < this.chunks.length; r++)
n.set(this.chunks[r], i), i += this.chunks[r].length;
return this.chunks = [], n;
}
/**
* Start a new fork for length-delimited data like a message
* or a packed repeated field.
*
* Must be joined later with `join()`.
*/
fork() {
return this.stack.push({
chunks: this.chunks,
buf: this.buf
}), this.chunks = [], this.buf = [], this;
}
/**
* Join the last fork. Write its length and bytes, then
* return to the previous state.
*/
join() {
let e = this.finish(), n = this.stack.pop();
if (!n) throw new Error("invalid state, fork stack empty");
return this.chunks = n.chunks, this.buf = n.buf, this.uint32(e.byteLength), this.raw(e);
}
/**
* Writes a tag (field number and wire type).
*
* Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
*
* Generated code should compute the tag ahead of time and call `uint32()`.
*/
tag(e, n) {
return this.uint32((e << 3 | n) >>> 0);
}
/**
* Write a chunk of raw bytes.
*/
raw(e) {
return this.buf.length && (this.chunks.push(new Uint8Array(this.buf)), this.buf = []), this.chunks.push(e), this;
}
/**
* Write a `uint32` value, an unsigned 32 bit varint.
*/
uint32(e) {
for (Sg(e); e > 127; )
this.buf.push(e & 127 | 128), e = e >>> 7;
return this.buf.push(e), this;
}
/**
* Write a `int32` value, a signed 32 bit varint.
*/
int32(e) {
return qu(e), Sw(e, this.buf), this;
}
/**
* Write a `bool` value, a variant.
*/
bool(e) {
return this.buf.push(e ? 1 : 0), this;
}
/**
* Write a `bytes` value, length-delimited arbitrary data.
*/
bytes(e) {
return this.uint32(e.byteLength), this.raw(e);
}
/**
* Write a `string` value, length-delimited data converted to UTF-8 text.
*/
string(e) {
let n = this.textEncoder.encode(e);
return this.uint32(n.byteLength), this.raw(n);
}
/**
* Write a `float` value, 32-bit floating point number.
*/
float(e) {
hA(e);
let n = new Uint8Array(4);
return new DataView(n.buffer).setFloat32(0, e, !0), this.raw(n);
}
/**
* Write a `double` value, a 64-bit floating point number.
*/
double(e) {
let n = new Uint8Array(8);
return new DataView(n.buffer).setFloat64(0, e, !0), this.raw(n);
}
/**
* Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
*/
fixed32(e) {
Sg(e);
let n = new Uint8Array(4);
return new DataView(n.buffer).setUint32(0, e, !0), this.raw(n);
}
/**
* Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
*/
sfixed32(e) {
qu(e);
let n = new Uint8Array(4);
return new DataView(n.buffer).setInt32(0, e, !0), this.raw(n);
}
/**
* Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
*/
sint32(e) {
return qu(e), e = (e << 1 ^ e >> 31) >>> 0, Sw(e, this.buf), this;
}
/**
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
*/
sfixed64(e) {
let n = new Uint8Array(8), i = new DataView(n.buffer), r = mn.enc(e);
return i.setInt32(0, r.lo, !0), i.setInt32(4, r.hi, !0), this.raw(n);
}
/**
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
*/
fixed64(e) {
let n = new Uint8Array(8), i = new DataView(n.buffer), r = mn.uEnc(e);
return i.setInt32(0, r.lo, !0), i.setInt32(4, r.hi, !0), this.raw(n);
}
/**
* Write a `int64` value, a signed 64-bit varint.
*/
int64(e) {
let n = mn.enc(e);
return xf(n.lo, n.hi, this.buf), this;
}
/**
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
*/
sint64(e) {
let n = mn.enc(e), i = n.hi >> 31, r = n.lo << 1 ^ i, o = (n.hi << 1 | n.lo >>> 31) ^ i;
return xf(r, o, this.buf), this;
}
/**
* Write a `uint64` value, an unsigned 64-bit varint.
*/
uint64(e) {
let n = mn.uEnc(e);
return xf(n.lo, n.hi, this.buf), this;
}
}, C2 = class {
constructor(e, n) {
this.varint64 = b2, this.uint32 = k2, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength), this.textDecoder = n ?? new TextDecoder();
}
/**
* Reads a tag - field number and wire type.
*/
tag() {
let e = this.uint32(), n = e >>> 3, i = e & 7;
if (n <= 0 || i < 0 || i > 5) throw new Error("illegal tag: field no " + n + " wire type " + i);
return [n, i];
}
/**
* Skip one element and return the skipped data.
*
* When skipping StartGroup, provide the tags field number to check for
* matching field number in the EndGroup tag.
*/
skip(e, n) {
let i = this.pos;
switch (e) {
case In.Varint:
for (; this.buf[this.pos++] & 128; )
;
break;
// eslint-disable-next-line
// @ts-ignore TS7029: Fallthrough case in switch
case In.Bit64:
this.pos += 4;
// eslint-disable-next-line
// @ts-ignore TS7029: Fallthrough case in switch
case In.Bit32:
this.pos += 4;
break;
case In.LengthDelimited:
let r = this.uint32();
this.pos += r;
break;
case In.StartGroup:
for (; ; ) {
const [o, s] = this.tag();
if (s === In.EndGroup) {
if (n !== void 0 && o !== n)
throw new Error("invalid end group tag");
break;
}
this.skip(s, o);
}
break;
default:
throw new Error("cant skip wire type " + e);
}
return this.assertBounds(), this.buf.subarray(i, this.pos);
}
/**
* Throws error if position in byte array is out of range.
*/
assertBounds() {
if (this.pos > this.len) throw new RangeError("premature EOF");
}
/**
* Read a `int32` field, a signed 32 bit varint.
*/
int32() {
return this.uint32() | 0;
}
/**
* Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
*/
sint32() {
let e = this.uint32();
return e >>> 1 ^ -(e & 1);
}
/**
* Read a `int64` field, a signed 64-bit varint.
*/
int64() {
return mn.dec(...this.varint64());
}
/**
* Read a `uint64` field, an unsigned 64-bit varint.
*/
uint64() {
return mn.uDec(...this.varint64());
}
/**
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
*/
sint64() {
let [e, n] = this.varint64(), i = -(e & 1);
return e = (e >>> 1 | (n & 1) << 31) ^ i, n = n >>> 1 ^ i, mn.dec(e, n);
}
/**
* Read a `bool` field, a variant.
*/
bool() {
let [e, n] = this.varint64();
return e !== 0 || n !== 0;
}
/**
* Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
*/
fixed32() {
return this.view.getUint32((this.pos += 4) - 4, !0);
}
/**
* Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
*/
sfixed32() {
return this.view.getInt32((this.pos += 4) - 4, !0);
}
/**
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
*/
fixed64() {
return mn.uDec(this.sfixed32(), this.sfixed32());
}
/**
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
*/
sfixed64() {
return mn.dec(this.sfixed32(), this.sfixed32());
}
/**
* Read a `float` field, 32-bit floating point number.
*/
float() {
return this.view.getFloat32((this.pos += 4) - 4, !0);
}
/**
* Read a `double` field, a 64-bit floating point number.
*/
double() {
return this.view.getFloat64((this.pos += 8) - 8, !0);
}
/**
* Read a `bytes` field, length-delimited arbitrary data.
*/
bytes() {
let e = this.uint32(), n = this.pos;
return this.pos += e, this.assertBounds(), this.buf.subarray(n, n + e);
}
/**
* Read a `string` field, length-delimited data converted to UTF-8 text.
*/
string() {
return this.textDecoder.decode(this.bytes());
}
};
function E2(t, e, n, i) {
let r;
return {
typeName: e,
extendee: n,
get field() {
if (!r) {
const o = typeof i == "function" ? i() : i;
o.name = e.split(".").pop(), o.jsonName = "[".concat(e, "]"), r = t.util.newFieldList([o]).list()[0];
}
return r;
},
runtime: t
};
}
function wA(t) {
const e = t.field.localName, n = /* @__PURE__ */ Object.create(null);
return n[e] = x2(t), [n, () => n[e]];
}
function x2(t) {
const e = t.field;
if (e.repeated)
return [];
if (e.default !== void 0)
return e.default;
switch (e.kind) {
case "enum":
return e.T.values[0].no;
case "scalar":
return Cc(e.T, e.L);
case "message":
const n = e.T, i = new n();
return n.fieldWrapper ? n.fieldWrapper.unwrapField(i) : i;
case "map":
throw "map fields are not allowed to be extensions";
}
}
function A2(t, e) {
if (!e.repeated && (e.kind == "enum" || e.kind == "scalar")) {
for (let n = t.length - 1; n >= 0; --n)
if (t[n].no == e.no)
return [t[n]];
return [];
}
return t.filter((n) => n.no === e.no);
}
let mo = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""), Cp = [];
for (let t = 0; t < mo.length; t++) Cp[mo[t].charCodeAt(0)] = t;
Cp[45] = mo.indexOf("+");
Cp[95] = mo.indexOf("/");
const kA = {
/**
* Decodes a base64 string to a byte array.
*
* - ignores white-space, including line breaks and tabs
* - allows inner padding (can decode concatenated base64 strings)
* - does not require padding
* - understands base64url encoding:
* "-" instead of "+",
* "_" instead of "/",
* no padding
*/
dec(t) {
let e = t.length * 3 / 4;
t[t.length - 2] == "=" ? e -= 2 : t[t.length - 1] == "=" && (e -= 1);
let n = new Uint8Array(e), i = 0, r = 0, o, s = 0;
for (let a = 0; a < t.length; a++) {
if (o = Cp[t.charCodeAt(a)], o === void 0)
switch (t[a]) {
// @ts-ignore TS7029: Fallthrough case in switch
case "=":
r = 0;
// reset state when padding found
// @ts-ignore TS7029: Fallthrough case in switch
case `
`:
case "\r":
case " ":
case " ":
continue;
// skip white-space, and padding
default:
throw Error("invalid base64 string.");
}
switch (r) {
case 0:
s = o, r = 1;
break;
case 1:
n[i++] = s << 2 | (o & 48) >> 4, s = o, r = 2;
break;
case 2:
n[i++] = (s & 15) << 4 | (o & 60) >> 2, s = o, r = 3;
break;
case 3:
n[i++] = (s & 3) << 6 | o, r = 0;
break;
}
}
if (r == 1) throw Error("invalid base64 string.");
return n.subarray(0, i);
},
/**
* Encode a byte array to a base64 string.
*/
enc(t) {
let e = "", n = 0, i, r = 0;
for (let o = 0; o < t.length; o++)
switch (i = t[o], n) {
case 0:
e += mo[i >> 2], r = (i & 3) << 4, n = 1;
break;
case 1:
e += mo[r | i >> 4], r = (i & 15) << 2, n = 2;
break;
case 2:
e += mo[r | i >> 6], e += mo[i & 63], n = 0;
break;
}
return n && (e += mo[r], e += "=", n == 1 && (e += "=")), e;
}
};
function _2(t, e, n) {
TA(e, t);
const i = e.runtime.bin.makeReadOptions(n), r = A2(t.getType().runtime.bin.listUnknownFields(t), e.field), [o, s] = wA(e);
for (const a of r)
e.runtime.bin.readField(o, i.readerFactory(a.data), e.field, a.wireType, i);
return s();
}
function R2(t, e, n, i) {
TA(e, t);
const r = e.runtime.bin.makeReadOptions(i), o = e.runtime.bin.makeWriteOptions(i);
if (SA(t, e)) {
const l = t.getType().runtime.bin.listUnknownFields(t).filter((d) => d.no != e.field.no);
t.getType().runtime.bin.discardUnknownFields(t);
for (const d of l)
t.getType().runtime.bin.onUnknownField(t, d.no, d.wireType, d.data);
}
const s = o.writerFactory();
let a = e.field;
!a.opt && !a.repeated && (a.kind == "enum" || a.kind == "scalar") && (a = Object.assign(Object.assign({}, e.field), {
opt: !0
})), e.runtime.bin.writeField(a, n, s, o);
const c = r.readerFactory(s.finish());
for (; c.pos < c.len; ) {
const [l, d] = c.tag(), u = c.skip(d, l);
t.getType().runtime.bin.onUnknownField(t, l, d, u);
}
}
function SA(t, e) {
const n = t.getType();
return e.extendee.typeName === n.typeName && !!n.runtime.bin.listUnknownFields(t).find((i) => i.no == e.field.no);
}
function TA(t, e) {
En(t.extendee.typeName == e.getType().typeName, "extension ".concat(t.typeName, " can only be applied to message ").concat(t.extendee.typeName));
}
function CA(t, e) {
const n = t.localName;
if (t.repeated)
return e[n].length > 0;
if (t.oneof)
return e[t.oneof.localName].case === n;
switch (t.kind) {
case "enum":
case "scalar":
return t.opt || t.req ? e[n] !== void 0 : t.kind == "enum" ? e[n] !== t.T.values[0].no : !yA(t.T, e[n]);
case "message":
return e[n] !== void 0;
case "map":
return Object.keys(e[n]).length > 0;
}
}
function Tw(t, e) {
const n = t.localName, i = !t.opt && !t.req;
if (t.repeated)
e[n] = [];
else if (t.oneof)
e[t.oneof.localName] = {
case: void 0
};
else
switch (t.kind) {
case "map":
e[n] = {};
break;
case "enum":
e[n] = i ? t.T.values[0].no : void 0;
break;
case "scalar":
e[n] = i ? Cc(t.T, t.L) : void 0;
break;
case "message":
e[n] = void 0;
break;
}
}
function go(t, e) {
if (t === null || typeof t != "object" || !Object.getOwnPropertyNames(jb.prototype).every((i) => i in t && typeof t[i] == "function"))
return !1;
const n = t.getType();
return n === null || typeof n != "function" || !("typeName" in n) || typeof n.typeName != "string" ? !1 : e === void 0 ? !0 : n.typeName == e.typeName;
}
function EA(t, e) {
return go(e) || !t.fieldWrapper ? e : t.fieldWrapper.wrapField(e);
}
oe.DOUBLE, oe.FLOAT, oe.INT64, oe.UINT64, oe.INT32, oe.UINT32, oe.BOOL, oe.STRING, oe.BYTES;
const Cw = {
ignoreUnknownFields: !1
}, Ew = {
emitDefaultValues: !1,
enumAsInteger: !1,
useProtoFieldName: !1,
prettySpaces: 0
};
function I2(t) {
return t ? Object.assign(Object.assign({}, Cw), t) : Cw;
}
function P2(t) {
return t ? Object.assign(Object.assign({}, Ew), t) : Ew;
}
const Ih = Symbol(), Qu = Symbol();
function N2() {
return {
makeReadOptions: I2,
makeWriteOptions: P2,
readMessage(t, e, n, i) {
if (e == null || Array.isArray(e) || typeof e != "object")
throw new Error("cannot decode message ".concat(t.typeName, " from JSON: ").concat(Dr(e)));
i = i ?? new t();
const r = /* @__PURE__ */ new Map(), o = n.typeRegistry;
for (const [s, a] of Object.entries(e)) {
const c = t.fields.findJsonName(s);
if (c) {
if (c.oneof) {
if (a === null && c.kind == "scalar")
continue;
const l = r.get(c.oneof);
if (l !== void 0)
throw new Error("cannot decode message ".concat(t.typeName, ' from JSON: multiple keys for oneof "').concat(c.oneof.name, '" present: "').concat(l, '", "').concat(s, '"'));
r.set(c.oneof, s);
}
xw(i, a, c, n, t);
} else {
let l = !1;
if (o != null && o.findExtension && s.startsWith("[") && s.endsWith("]")) {
const d = o.findExtension(s.substring(1, s.length - 1));
if (d && d.extendee.typeName == t.typeName) {
l = !0;
const [u, h] = wA(d);
xw(u, a, d.field, n, d), R2(i, d, h(), n);
}
}
if (!l && !n.ignoreUnknownFields)
throw new Error("cannot decode message ".concat(t.typeName, ' from JSON: key "').concat(s, '" is unknown'));
}
}
return i;
},
writeMessage(t, e) {
const n = t.getType(), i = {};
let r;
try {
for (r of n.fields.byNumber()) {
if (!CA(r, t)) {
if (r.req)
throw "required field not set";
if (!e.emitDefaultValues || !O2(r))
continue;
}
const s = r.oneof ? t[r.oneof.localName].value : t[r.localName], a = Aw(r, s, e);
a !== void 0 && (i[e.useProtoFieldName ? r.name : r.jsonName] = a);
}
const o = e.typeRegistry;
if (o != null && o.findExtensionFor)
for (const s of n.runtime.bin.listUnknownFields(t)) {
const a = o.findExtensionFor(n.typeName, s.no);
if (a && SA(t, a)) {
const c = _2(t, a, e), l = Aw(a.field, c, e);
l !== void 0 && (i[a.field.jsonName] = l);
}
}
} catch (o) {
const s = r ? "cannot encode field ".concat(n.typeName, ".").concat(r.name, " to JSON") : "cannot encode message ".concat(n.typeName, " to JSON"), a = o instanceof Error ? o.message : String(o);
throw new Error(s + (a.length > 0 ? ": ".concat(a) : ""));
}
return i;
},
readScalar(t, e, n) {
return Dl(t, e, n ?? hs.BIGINT, !0);
},
writeScalar(t, e, n) {
if (e !== void 0 && (n || yA(t, e)))
return $u(t, e);
},
debug: Dr
};
}
function Dr(t) {
if (t === null)
return "null";
switch (typeof t) {
case "object":
return Array.isArray(t) ? "array" : "object";
case "string":
return t.length > 100 ? "string" : '"'.concat(t.split('"').join('\\"'), '"');
default:
return String(t);
}
}
function xw(t, e, n, i, r) {
let o = n.localName;
if (n.repeated) {
if (En(n.kind != "map"), e === null)
return;
if (!Array.isArray(e))
throw new Error("cannot decode field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(e)));
const s = t[o];
for (const a of e) {
if (a === null)
throw new Error("cannot decode field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(a)));
switch (n.kind) {
case "message":
s.push(n.T.fromJson(a, i));
break;
case "enum":
const c = Af(n.T, a, i.ignoreUnknownFields, !0);
c !== Qu && s.push(c);
break;
case "scalar":
try {
s.push(Dl(n.T, a, n.L, !0));
} catch (l) {
let d = "cannot decode field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(a));
throw l instanceof Error && l.message.length > 0 && (d += ": ".concat(l.message)), new Error(d);
}
break;
}
}
} else if (n.kind == "map") {
if (e === null)
return;
if (typeof e != "object" || Array.isArray(e))
throw new Error("cannot decode field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(e)));
const s = t[o];
for (const [a, c] of Object.entries(e)) {
if (c === null)
throw new Error("cannot decode field ".concat(r.typeName, ".").concat(n.name, " from JSON: map value null"));
let l;
try {
l = M2(n.K, a);
} catch (d) {
let u = "cannot decode map key for field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(e));
throw d instanceof Error && d.message.length > 0 && (u += ": ".concat(d.message)), new Error(u);
}
switch (n.V.kind) {
case "message":
s[l] = n.V.T.fromJson(c, i);
break;
case "enum":
const d = Af(n.V.T, c, i.ignoreUnknownFields, !0);
d !== Qu && (s[l] = d);
break;
case "scalar":
try {
s[l] = Dl(n.V.T, c, hs.BIGINT, !0);
} catch (u) {
let h = "cannot decode map value for field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(e));
throw u instanceof Error && u.message.length > 0 && (h += ": ".concat(u.message)), new Error(h);
}
break;
}
}
} else
switch (n.oneof && (t = t[n.oneof.localName] = {
case: o
}, o = "value"), n.kind) {
case "message":
const s = n.T;
if (e === null && s.typeName != "google.protobuf.Value")
return;
let a = t[o];
go(a) ? a.fromJson(e, i) : (t[o] = a = s.fromJson(e, i), s.fieldWrapper && !n.oneof && (t[o] = s.fieldWrapper.unwrapField(a)));
break;
case "enum":
const c = Af(n.T, e, i.ignoreUnknownFields, !1);
switch (c) {
case Ih:
Tw(n, t);
break;
case Qu:
break;
default:
t[o] = c;
break;
}
break;
case "scalar":
try {
const l = Dl(n.T, e, n.L, !1);
switch (l) {
case Ih:
Tw(n, t);
break;
default:
t[o] = l;
break;
}
} catch (l) {
let d = "cannot decode field ".concat(r.typeName, ".").concat(n.name, " from JSON: ").concat(Dr(e));
throw l instanceof Error && l.message.length > 0 && (d += ": ".concat(l.message)), new Error(d);
}
break;
}
}
function M2(t, e) {
if (t === oe.BOOL)
switch (e) {
case "true":
e = !0;
break;
case "false":
e = !1;
break;
}
return Dl(t, e, hs.BIGINT, !0).toString();
}
function Dl(t, e, n, i) {
if (e === null)
return i ? Cc(t, n) : Ih;
switch (t) {
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
// Either numbers or strings are accepted. Exponent notation is also accepted.
case oe.DOUBLE:
case oe.FLOAT:
if (e === "NaN") return Number.NaN;
if (e === "Infinity") return Number.POSITIVE_INFINITY;
if (e === "-Infinity") return Number.NEGATIVE_INFINITY;
if (e === "" || typeof e == "string" && e.trim().length !== e.length || typeof e != "string" && typeof e != "number")
break;
const r = Number(e);
if (Number.isNaN(r) || !Number.isFinite(r))
break;
return t == oe.FLOAT && hA(r), r;
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
case oe.INT32:
case oe.FIXED32:
case oe.SFIXED32:
case oe.SINT32:
case oe.UINT32:
let o;
if (typeof e == "number" ? o = e : typeof e == "string" && e.length > 0 && e.trim().length === e.length && (o = Number(e)), o === void 0) break;
return t == oe.UINT32 || t == oe.FIXED32 ? Sg(o) : qu(o), o;
// int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted.
case oe.INT64:
case oe.SFIXED64:
case oe.SINT64:
if (typeof e != "number" && typeof e != "string") break;
const s = mn.parse(e);
return n ? s.toString() : s;
case oe.FIXED64:
case oe.UINT64:
if (typeof e != "number" && typeof e != "string") break;
const a = mn.uParse(e);
return n ? a.toString() : a;
// bool:
case oe.BOOL:
if (typeof e != "boolean") break;
return e;
// string:
case oe.STRING:
if (typeof e != "string")
break;
try {
encodeURIComponent(e);
} catch {
throw new Error("invalid UTF8");
}
return e;
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
// Either standard or URL-safe base64 encoding with/without paddings are accepted.
case oe.BYTES:
if (e === "") return new Uint8Array(0);
if (typeof e != "string") break;
return kA.dec(e);
}
throw new Error();
}
function Af(t, e, n, i) {
if (e === null)
return t.typeName == "google.protobuf.NullValue" ? 0 : i ? t.values[0].no : Ih;
switch (typeof e) {
case "number":
if (Number.isInteger(e))
return e;
break;
case "string":
const r = t.findName(e);
if (r !== void 0)
return r.no;
if (n)
return Qu;
break;
}
throw new Error("cannot decode enum ".concat(t.typeName, " from JSON: ").concat(Dr(e)));
}
function O2(t) {
return t.repeated || t.kind == "map" ? !0 : !(t.oneof || t.kind == "message" || t.opt || t.req);
}
function Aw(t, e, n) {
if (t.kind == "map") {
En(typeof e == "object" && e != null);
const i = {}, r = Object.entries(e);
switch (t.V.kind) {
case "scalar":
for (const [s, a] of r)
i[s.toString()] = $u(t.V.T, a);
break;
case "message":
for (const [s, a] of r)
i[s.toString()] = a.toJson(n);
break;
case "enum":
const o = t.V.T;
for (const [s, a] of r)
i[s.toString()] = _f(o, a, n.enumAsInteger);
break;
}
return n.emitDefaultValues || r.length > 0 ? i : void 0;
}
if (t.repeated) {
En(Array.isArray(e));
const i = [];
switch (t.kind) {
case "scalar":
for (let r = 0; r < e.length; r++)
i.push($u(t.T, e[r]));
break;
case "enum":
for (let r = 0; r < e.length; r++)
i.push(_f(t.T, e[r], n.enumAsInteger));
break;
case "message":
for (let r = 0; r < e.length; r++)
i.push(e[r].toJson(n));
break;
}
return n.emitDefaultValues || i.length > 0 ? i : void 0;
}
switch (t.kind) {
case "scalar":
return $u(t.T, e);
case "enum":
return _f(t.T, e, n.enumAsInteger);
case "message":
return EA(t.T, e).toJson(n);
}
}
function _f(t, e, n) {
var i;
if (En(typeof e == "number"), t.typeName == "google.protobuf.NullValue")
return null;
if (n)
return e;
const r = t.findNumber(e);
return (i = r == null ? void 0 : r.name) !== null && i !== void 0 ? i : e;
}
function $u(t, e) {
switch (t) {
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
case oe.INT32:
case oe.SFIXED32:
case oe.SINT32:
case oe.FIXED32:
case oe.UINT32:
return En(typeof e == "number"), e;
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
// Either numbers or strings are accepted. Exponent notation is also accepted.
case oe.FLOAT:
// assertFloat32(value);
case oe.DOUBLE:
return En(typeof e == "number"), Number.isNaN(e) ? "NaN" : e === Number.POSITIVE_INFINITY ? "Infinity" : e === Number.NEGATIVE_INFINITY ? "-Infinity" : e;
// string:
case oe.STRING:
return En(typeof e == "string"), e;
// bool:
case oe.BOOL:
return En(typeof e == "boolean"), e;
// JSON value will be a decimal string. Either numbers or strings are accepted.
case oe.UINT64:
case oe.FIXED64:
case oe.INT64:
case oe.SFIXED64:
case oe.SINT64:
return En(typeof e == "bigint" || typeof e == "string" || typeof e == "number"), e.toString();
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
// Either standard or URL-safe base64 encoding with/without paddings are accepted.
case oe.BYTES:
return En(e instanceof Uint8Array), kA.enc(e);
}
}
const Ea = Symbol("@bufbuild/protobuf/unknown-fields"), _w = {
readUnknownFields: !0,
readerFactory: (t) => new C2(t)
}, Rw = {
writeUnknownFields: !0,
writerFactory: () => new T2()
};
function D2(t) {
return t ? Object.assign(Object.assign({}, _w), t) : _w;
}
function L2(t) {
return t ? Object.assign(Object.assign({}, Rw), t) : Rw;
}
function F2() {
return {
makeReadOptions: D2,
makeWriteOptions: L2,
listUnknownFields(t) {
var e;
return (e = t[Ea]) !== null && e !== void 0 ? e : [];
},
discardUnknownFields(t) {
delete t[Ea];
},
writeUnknownFields(t, e) {
const i = t[Ea];
if (i)
for (const r of i)
e.tag(r.no, r.wireType).raw(r.data);
},
onUnknownField(t, e, n, i) {
const r = t;
Array.isArray(r[Ea]) || (r[Ea] = []), r[Ea].push({
no: e,
wireType: n,
data: i
});
},
readMessage(t, e, n, i, r) {
const o = t.getType(), s = r ? e.len : e.pos + n;
let a, c;
for (; e.pos < s && ([a, c] = e.tag(), !(r === !0 && c == In.EndGroup)); ) {
const l = o.fields.find(a);
if (!l) {
const d = e.skip(c, a);
i.readUnknownFields && this.onUnknownField(t, a, c, d);
continue;
}
Iw(t, e, l, c, i);
}
if (r && // eslint-disable-line @typescript-eslint/strict-boolean-expressions
(c != In.EndGroup || a !== n))
throw new Error("invalid end group tag");
},
readField: Iw,
writeMessage(t, e, n) {
const i = t.getType();
for (const r of i.fields.byNumber()) {
if (!CA(r, t)) {
if (r.req)
throw new Error("cannot encode field ".concat(i.typeName, ".").concat(r.name, " to binary: required field not set"));
continue;
}
const o = r.oneof ? t[r.oneof.localName].value : t[r.localName];
Pw(r, o, e, n);
}
return n.writeUnknownFields && this.writeUnknownFields(t, e), e;
},
writeField(t, e, n, i) {
e !== void 0 && Pw(t, e, n, i);
}
};
}
function Iw(t, e, n, i, r) {
let {
repeated: o,
localName: s
} = n;
switch (n.oneof && (t = t[n.oneof.localName], t.case != s && delete t.value, t.case = s, s = "value"), n.kind) {
case "scalar":
case "enum":
const a = n.kind == "enum" ? oe.INT32 : n.T;
let c = Ph;
if (n.kind == "scalar" && n.L > 0 && (c = B2), o) {
let h = t[s];
if (i == In.LengthDelimited && a != oe.STRING && a != oe.BYTES) {
let m = e.uint32() + e.pos;
for (; e.pos < m; )
h.push(c(e, a));
} else
h.push(c(e, a));
} else
t[s] = c(e, a);
break;
case "message":
const l = n.T;
o ? t[s].push(Yu(e, new l(), r, n)) : go(t[s]) ? Yu(e, t[s], r, n) : (t[s] = Yu(e, new l(), r, n), l.fieldWrapper && !n.oneof && !n.repeated && (t[s] = l.fieldWrapper.unwrapField(t[s])));
break;
case "map":
let [d, u] = U2(n, e, r);
t[s][d] = u;
break;
}
}
function Yu(t, e, n, i) {
const r = e.getType().runtime.bin, o = i == null ? void 0 : i.delimited;
return r.readMessage(
e,
t,
o ? i.no : t.uint32(),
// eslint-disable-line @typescript-eslint/strict-boolean-expressions
n,
o
), e;
}
function U2(t, e, n) {
const i = e.uint32(), r = e.pos + i;
let o, s;
for (; e.pos < r; ) {
const [a] = e.tag();
switch (a) {
case 1:
o = Ph(e, t.K);
break;
case 2:
switch (t.V.kind) {
case "scalar":
s = Ph(e, t.V.T);
break;
case "enum":
s = e.int32();
break;
case "message":
s = Yu(e, new t.V.T(), n, void 0);
break;
}
break;
}
}
if (o === void 0 && (o = Cc(t.K, hs.BIGINT)), typeof o != "string" && typeof o != "number" && (o = o.toString()), s === void 0)
switch (t.V.kind) {
case "scalar":
s = Cc(t.V.T, hs.BIGINT);
break;
case "enum":
s = t.V.T.values[0].no;
break;
case "message":
s = new t.V.T();
break;
}
return [o, s];
}
function B2(t, e) {
const n = Ph(t, e);
return typeof n == "bigint" ? n.toString() : n;
}
function Ph(t, e) {
switch (e) {
case oe.STRING:
return t.string();
case oe.BOOL:
return t.bool();
case oe.DOUBLE:
return t.double();
case oe.FLOAT:
return t.float();
case oe.INT32:
return t.int32();
case oe.INT64:
return t.int64();
case oe.UINT64:
return t.uint64();
case oe.FIXED64:
return t.fixed64();
case oe.BYTES:
return t.bytes();
case oe.FIXED32:
return t.fixed32();
case oe.SFIXED32:
return t.sfixed32();
case oe.SFIXED64:
return t.sfixed64();
case oe.SINT64:
return t.sint64();
case oe.UINT32:
return t.uint32();
case oe.SINT32:
return t.sint32();
}
}
function Pw(t, e, n, i) {
En(e !== void 0);
const r = t.repeated;
switch (t.kind) {
case "scalar":
case "enum":
let o = t.kind == "enum" ? oe.INT32 : t.T;
if (r)
if (En(Array.isArray(e)), t.packed)
V2(n, o, t.no, e);
else
for (const s of e)
Ll(n, o, t.no, s);
else
Ll(n, o, t.no, e);
break;
case "message":
if (r) {
En(Array.isArray(e));
for (const s of e)
Nw(n, i, t, s);
} else
Nw(n, i, t, e);
break;
case "map":
En(typeof e == "object" && e != null);
for (const [s, a] of Object.entries(e))
j2(n, i, t, s, a);
break;
}
}
function j2(t, e, n, i, r) {
t.tag(n.no, In.LengthDelimited), t.fork();
let o = i;
switch (n.K) {
case oe.INT32:
case oe.FIXED32:
case oe.UINT32:
case oe.SFIXED32:
case oe.SINT32:
o = Number.parseInt(i);
break;
case oe.BOOL:
En(i == "true" || i == "false"), o = i == "true";
break;
}
switch (Ll(t, n.K, 1, o), n.V.kind) {
case "scalar":
Ll(t, n.V.T, 2, r);
break;
case "enum":
Ll(t, oe.INT32, 2, r);
break;
case "message":
En(r !== void 0), t.tag(2, In.LengthDelimited).bytes(r.toBinary(e));
break;
}
t.join();
}
function Nw(t, e, n, i) {
const r = EA(n.T, i);
n.delimited ? t.tag(n.no, In.StartGroup).raw(r.toBinary(e)).tag(n.no, In.EndGroup) : t.tag(n.no, In.LengthDelimited).bytes(r.toBinary(e));
}
function Ll(t, e, n, i) {
En(i !== void 0);
let [r, o] = xA(e);
t.tag(n, r)[o](i);
}
function V2(t, e, n, i) {
if (!i.length)
return;
t.tag(n, In.LengthDelimited).fork();
let [, r] = xA(e);
for (let o = 0; o < i.length; o++)
t[r](i[o]);
t.join();
}
function xA(t) {
let e = In.Varint;
switch (t) {
case oe.BYTES:
case oe.STRING:
e = In.LengthDelimited;
break;
case oe.DOUBLE:
case oe.FIXED64:
case oe.SFIXED64:
e = In.Bit64;
break;
case oe.FIX