@permguard/permguard 0.0.9

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.js ADDED
@@ -0,0 +1,4614 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ AZAtomicRequestBuilder: () => AZAtomicRequestBuilder,
34
+ AZClient: () => AZClient,
35
+ AZRequestBuilder: () => AZRequestBuilder,
36
+ ActionBuilder: () => ActionBuilder,
37
+ ActorType: () => ActorType,
38
+ ContextBuilder: () => ContextBuilder,
39
+ EvaluationBuilder: () => EvaluationBuilder,
40
+ PrincipalBuilder: () => PrincipalBuilder,
41
+ ResourceBuilder: () => ResourceBuilder,
42
+ SubjectBuilder: () => SubjectBuilder,
43
+ withEndpoint: () => withEndpoint
44
+ });
45
+ module.exports = __toCommonJS(index_exports);
46
+
47
+ // src/azconfig.ts
48
+ function withEndpoint(endpoint, port) {
49
+ return (config) => {
50
+ config.pdpEndpoint = {
51
+ endpoint,
52
+ port
53
+ };
54
+ };
55
+ }
56
+
57
+ // src/internal/az/azreq/grpc/v1/generated/proto/v1/pdp.ts
58
+ var import_runtime_rpc = require("@protobuf-ts/runtime-rpc");
59
+
60
+ // node_modules/@protobuf-ts/runtime/build/es2015/json-typings.js
61
+ function typeofJsonValue(value) {
62
+ let t = typeof value;
63
+ if (t == "object") {
64
+ if (Array.isArray(value))
65
+ return "array";
66
+ if (value === null)
67
+ return "null";
68
+ }
69
+ return t;
70
+ }
71
+ function isJsonObject(value) {
72
+ return value !== null && typeof value == "object" && !Array.isArray(value);
73
+ }
74
+
75
+ // node_modules/@protobuf-ts/runtime/build/es2015/base64.js
76
+ var encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
77
+ var decTable = [];
78
+ for (let i = 0; i < encTable.length; i++)
79
+ decTable[encTable[i].charCodeAt(0)] = i;
80
+ decTable["-".charCodeAt(0)] = encTable.indexOf("+");
81
+ decTable["_".charCodeAt(0)] = encTable.indexOf("/");
82
+ function base64decode(base64Str) {
83
+ let es = base64Str.length * 3 / 4;
84
+ if (base64Str[base64Str.length - 2] == "=")
85
+ es -= 2;
86
+ else if (base64Str[base64Str.length - 1] == "=")
87
+ es -= 1;
88
+ let bytes = new Uint8Array(es), bytePos = 0, groupPos = 0, b, p = 0;
89
+ for (let i = 0; i < base64Str.length; i++) {
90
+ b = decTable[base64Str.charCodeAt(i)];
91
+ if (b === void 0) {
92
+ switch (base64Str[i]) {
93
+ case "=":
94
+ groupPos = 0;
95
+ // reset state when padding found
96
+ case "\n":
97
+ case "\r":
98
+ case " ":
99
+ case " ":
100
+ continue;
101
+ // skip white-space, and padding
102
+ default:
103
+ throw Error(`invalid base64 string.`);
104
+ }
105
+ }
106
+ switch (groupPos) {
107
+ case 0:
108
+ p = b;
109
+ groupPos = 1;
110
+ break;
111
+ case 1:
112
+ bytes[bytePos++] = p << 2 | (b & 48) >> 4;
113
+ p = b;
114
+ groupPos = 2;
115
+ break;
116
+ case 2:
117
+ bytes[bytePos++] = (p & 15) << 4 | (b & 60) >> 2;
118
+ p = b;
119
+ groupPos = 3;
120
+ break;
121
+ case 3:
122
+ bytes[bytePos++] = (p & 3) << 6 | b;
123
+ groupPos = 0;
124
+ break;
125
+ }
126
+ }
127
+ if (groupPos == 1)
128
+ throw Error(`invalid base64 string.`);
129
+ return bytes.subarray(0, bytePos);
130
+ }
131
+ function base64encode(bytes) {
132
+ let base64 = "", groupPos = 0, b, p = 0;
133
+ for (let i = 0; i < bytes.length; i++) {
134
+ b = bytes[i];
135
+ switch (groupPos) {
136
+ case 0:
137
+ base64 += encTable[b >> 2];
138
+ p = (b & 3) << 4;
139
+ groupPos = 1;
140
+ break;
141
+ case 1:
142
+ base64 += encTable[p | b >> 4];
143
+ p = (b & 15) << 2;
144
+ groupPos = 2;
145
+ break;
146
+ case 2:
147
+ base64 += encTable[p | b >> 6];
148
+ base64 += encTable[b & 63];
149
+ groupPos = 0;
150
+ break;
151
+ }
152
+ }
153
+ if (groupPos) {
154
+ base64 += encTable[p];
155
+ base64 += "=";
156
+ if (groupPos == 1)
157
+ base64 += "=";
158
+ }
159
+ return base64;
160
+ }
161
+
162
+ // node_modules/@protobuf-ts/runtime/build/es2015/binary-format-contract.js
163
+ var UnknownFieldHandler;
164
+ (function(UnknownFieldHandler2) {
165
+ UnknownFieldHandler2.symbol = Symbol.for("protobuf-ts/unknown");
166
+ UnknownFieldHandler2.onRead = (typeName, message, fieldNo, wireType, data) => {
167
+ let container = is(message) ? message[UnknownFieldHandler2.symbol] : message[UnknownFieldHandler2.symbol] = [];
168
+ container.push({ no: fieldNo, wireType, data });
169
+ };
170
+ UnknownFieldHandler2.onWrite = (typeName, message, writer) => {
171
+ for (let { no, wireType, data } of UnknownFieldHandler2.list(message))
172
+ writer.tag(no, wireType).raw(data);
173
+ };
174
+ UnknownFieldHandler2.list = (message, fieldNo) => {
175
+ if (is(message)) {
176
+ let all = message[UnknownFieldHandler2.symbol];
177
+ return fieldNo ? all.filter((uf) => uf.no == fieldNo) : all;
178
+ }
179
+ return [];
180
+ };
181
+ UnknownFieldHandler2.last = (message, fieldNo) => UnknownFieldHandler2.list(message, fieldNo).slice(-1)[0];
182
+ const is = (message) => message && Array.isArray(message[UnknownFieldHandler2.symbol]);
183
+ })(UnknownFieldHandler || (UnknownFieldHandler = {}));
184
+ var WireType;
185
+ (function(WireType2) {
186
+ WireType2[WireType2["Varint"] = 0] = "Varint";
187
+ WireType2[WireType2["Bit64"] = 1] = "Bit64";
188
+ WireType2[WireType2["LengthDelimited"] = 2] = "LengthDelimited";
189
+ WireType2[WireType2["StartGroup"] = 3] = "StartGroup";
190
+ WireType2[WireType2["EndGroup"] = 4] = "EndGroup";
191
+ WireType2[WireType2["Bit32"] = 5] = "Bit32";
192
+ })(WireType || (WireType = {}));
193
+
194
+ // node_modules/@protobuf-ts/runtime/build/es2015/goog-varint.js
195
+ function varint64read() {
196
+ let lowBits = 0;
197
+ let highBits = 0;
198
+ for (let shift = 0; shift < 28; shift += 7) {
199
+ let b = this.buf[this.pos++];
200
+ lowBits |= (b & 127) << shift;
201
+ if ((b & 128) == 0) {
202
+ this.assertBounds();
203
+ return [lowBits, highBits];
204
+ }
205
+ }
206
+ let middleByte = this.buf[this.pos++];
207
+ lowBits |= (middleByte & 15) << 28;
208
+ highBits = (middleByte & 112) >> 4;
209
+ if ((middleByte & 128) == 0) {
210
+ this.assertBounds();
211
+ return [lowBits, highBits];
212
+ }
213
+ for (let shift = 3; shift <= 31; shift += 7) {
214
+ let b = this.buf[this.pos++];
215
+ highBits |= (b & 127) << shift;
216
+ if ((b & 128) == 0) {
217
+ this.assertBounds();
218
+ return [lowBits, highBits];
219
+ }
220
+ }
221
+ throw new Error("invalid varint");
222
+ }
223
+ function varint64write(lo, hi, bytes) {
224
+ for (let i = 0; i < 28; i = i + 7) {
225
+ const shift = lo >>> i;
226
+ const hasNext = !(shift >>> 7 == 0 && hi == 0);
227
+ const byte = (hasNext ? shift | 128 : shift) & 255;
228
+ bytes.push(byte);
229
+ if (!hasNext) {
230
+ return;
231
+ }
232
+ }
233
+ const splitBits = lo >>> 28 & 15 | (hi & 7) << 4;
234
+ const hasMoreBits = !(hi >> 3 == 0);
235
+ bytes.push((hasMoreBits ? splitBits | 128 : splitBits) & 255);
236
+ if (!hasMoreBits) {
237
+ return;
238
+ }
239
+ for (let i = 3; i < 31; i = i + 7) {
240
+ const shift = hi >>> i;
241
+ const hasNext = !(shift >>> 7 == 0);
242
+ const byte = (hasNext ? shift | 128 : shift) & 255;
243
+ bytes.push(byte);
244
+ if (!hasNext) {
245
+ return;
246
+ }
247
+ }
248
+ bytes.push(hi >>> 31 & 1);
249
+ }
250
+ var TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
251
+ function int64fromString(dec) {
252
+ let minus = dec[0] == "-";
253
+ if (minus)
254
+ dec = dec.slice(1);
255
+ const base = 1e6;
256
+ let lowBits = 0;
257
+ let highBits = 0;
258
+ function add1e6digit(begin, end) {
259
+ const digit1e6 = Number(dec.slice(begin, end));
260
+ highBits *= base;
261
+ lowBits = lowBits * base + digit1e6;
262
+ if (lowBits >= TWO_PWR_32_DBL) {
263
+ highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0);
264
+ lowBits = lowBits % TWO_PWR_32_DBL;
265
+ }
266
+ }
267
+ add1e6digit(-24, -18);
268
+ add1e6digit(-18, -12);
269
+ add1e6digit(-12, -6);
270
+ add1e6digit(-6);
271
+ return [minus, lowBits, highBits];
272
+ }
273
+ function int64toString(bitsLow, bitsHigh) {
274
+ if (bitsHigh >>> 0 <= 2097151) {
275
+ return "" + (TWO_PWR_32_DBL * bitsHigh + (bitsLow >>> 0));
276
+ }
277
+ let low = bitsLow & 16777215;
278
+ let mid = (bitsLow >>> 24 | bitsHigh << 8) >>> 0 & 16777215;
279
+ let high = bitsHigh >> 16 & 65535;
280
+ let digitA = low + mid * 6777216 + high * 6710656;
281
+ let digitB = mid + high * 8147497;
282
+ let digitC = high * 2;
283
+ let base = 1e7;
284
+ if (digitA >= base) {
285
+ digitB += Math.floor(digitA / base);
286
+ digitA %= base;
287
+ }
288
+ if (digitB >= base) {
289
+ digitC += Math.floor(digitB / base);
290
+ digitB %= base;
291
+ }
292
+ function decimalFrom1e7(digit1e7, needLeadingZeros) {
293
+ let partial = digit1e7 ? String(digit1e7) : "";
294
+ if (needLeadingZeros) {
295
+ return "0000000".slice(partial.length) + partial;
296
+ }
297
+ return partial;
298
+ }
299
+ return decimalFrom1e7(
300
+ digitC,
301
+ /*needLeadingZeros=*/
302
+ 0
303
+ ) + decimalFrom1e7(
304
+ digitB,
305
+ /*needLeadingZeros=*/
306
+ digitC
307
+ ) + // If the final 1e7 digit didn't need leading zeros, we would have
308
+ // returned via the trivial code path at the top.
309
+ decimalFrom1e7(
310
+ digitA,
311
+ /*needLeadingZeros=*/
312
+ 1
313
+ );
314
+ }
315
+ function varint32write(value, bytes) {
316
+ if (value >= 0) {
317
+ while (value > 127) {
318
+ bytes.push(value & 127 | 128);
319
+ value = value >>> 7;
320
+ }
321
+ bytes.push(value);
322
+ } else {
323
+ for (let i = 0; i < 9; i++) {
324
+ bytes.push(value & 127 | 128);
325
+ value = value >> 7;
326
+ }
327
+ bytes.push(1);
328
+ }
329
+ }
330
+ function varint32read() {
331
+ let b = this.buf[this.pos++];
332
+ let result = b & 127;
333
+ if ((b & 128) == 0) {
334
+ this.assertBounds();
335
+ return result;
336
+ }
337
+ b = this.buf[this.pos++];
338
+ result |= (b & 127) << 7;
339
+ if ((b & 128) == 0) {
340
+ this.assertBounds();
341
+ return result;
342
+ }
343
+ b = this.buf[this.pos++];
344
+ result |= (b & 127) << 14;
345
+ if ((b & 128) == 0) {
346
+ this.assertBounds();
347
+ return result;
348
+ }
349
+ b = this.buf[this.pos++];
350
+ result |= (b & 127) << 21;
351
+ if ((b & 128) == 0) {
352
+ this.assertBounds();
353
+ return result;
354
+ }
355
+ b = this.buf[this.pos++];
356
+ result |= (b & 15) << 28;
357
+ for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++)
358
+ b = this.buf[this.pos++];
359
+ if ((b & 128) != 0)
360
+ throw new Error("invalid varint");
361
+ this.assertBounds();
362
+ return result >>> 0;
363
+ }
364
+
365
+ // node_modules/@protobuf-ts/runtime/build/es2015/pb-long.js
366
+ var BI;
367
+ function detectBi() {
368
+ const dv = new DataView(new ArrayBuffer(8));
369
+ const ok = globalThis.BigInt !== void 0 && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function";
370
+ BI = ok ? {
371
+ MIN: BigInt("-9223372036854775808"),
372
+ MAX: BigInt("9223372036854775807"),
373
+ UMIN: BigInt("0"),
374
+ UMAX: BigInt("18446744073709551615"),
375
+ C: BigInt,
376
+ V: dv
377
+ } : void 0;
378
+ }
379
+ detectBi();
380
+ function assertBi(bi) {
381
+ if (!bi)
382
+ throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support");
383
+ }
384
+ var RE_DECIMAL_STR = /^-?[0-9]+$/;
385
+ var TWO_PWR_32_DBL2 = 4294967296;
386
+ var HALF_2_PWR_32 = 2147483648;
387
+ var SharedPbLong = class {
388
+ /**
389
+ * Create a new instance with the given bits.
390
+ */
391
+ constructor(lo, hi) {
392
+ this.lo = lo | 0;
393
+ this.hi = hi | 0;
394
+ }
395
+ /**
396
+ * Is this instance equal to 0?
397
+ */
398
+ isZero() {
399
+ return this.lo == 0 && this.hi == 0;
400
+ }
401
+ /**
402
+ * Convert to a native number.
403
+ */
404
+ toNumber() {
405
+ let result = this.hi * TWO_PWR_32_DBL2 + (this.lo >>> 0);
406
+ if (!Number.isSafeInteger(result))
407
+ throw new Error("cannot convert to safe number");
408
+ return result;
409
+ }
410
+ };
411
+ var PbULong = class _PbULong extends SharedPbLong {
412
+ /**
413
+ * Create instance from a `string`, `number` or `bigint`.
414
+ */
415
+ static from(value) {
416
+ if (BI)
417
+ switch (typeof value) {
418
+ case "string":
419
+ if (value == "0")
420
+ return this.ZERO;
421
+ if (value == "")
422
+ throw new Error("string is no integer");
423
+ value = BI.C(value);
424
+ case "number":
425
+ if (value === 0)
426
+ return this.ZERO;
427
+ value = BI.C(value);
428
+ case "bigint":
429
+ if (!value)
430
+ return this.ZERO;
431
+ if (value < BI.UMIN)
432
+ throw new Error("signed value for ulong");
433
+ if (value > BI.UMAX)
434
+ throw new Error("ulong too large");
435
+ BI.V.setBigUint64(0, value, true);
436
+ return new _PbULong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));
437
+ }
438
+ else
439
+ switch (typeof value) {
440
+ case "string":
441
+ if (value == "0")
442
+ return this.ZERO;
443
+ value = value.trim();
444
+ if (!RE_DECIMAL_STR.test(value))
445
+ throw new Error("string is no integer");
446
+ let [minus, lo, hi] = int64fromString(value);
447
+ if (minus)
448
+ throw new Error("signed value for ulong");
449
+ return new _PbULong(lo, hi);
450
+ case "number":
451
+ if (value == 0)
452
+ return this.ZERO;
453
+ if (!Number.isSafeInteger(value))
454
+ throw new Error("number is no integer");
455
+ if (value < 0)
456
+ throw new Error("signed value for ulong");
457
+ return new _PbULong(value, value / TWO_PWR_32_DBL2);
458
+ }
459
+ throw new Error("unknown value " + typeof value);
460
+ }
461
+ /**
462
+ * Convert to decimal string.
463
+ */
464
+ toString() {
465
+ return BI ? this.toBigInt().toString() : int64toString(this.lo, this.hi);
466
+ }
467
+ /**
468
+ * Convert to native bigint.
469
+ */
470
+ toBigInt() {
471
+ assertBi(BI);
472
+ BI.V.setInt32(0, this.lo, true);
473
+ BI.V.setInt32(4, this.hi, true);
474
+ return BI.V.getBigUint64(0, true);
475
+ }
476
+ };
477
+ PbULong.ZERO = new PbULong(0, 0);
478
+ var PbLong = class _PbLong extends SharedPbLong {
479
+ /**
480
+ * Create instance from a `string`, `number` or `bigint`.
481
+ */
482
+ static from(value) {
483
+ if (BI)
484
+ switch (typeof value) {
485
+ case "string":
486
+ if (value == "0")
487
+ return this.ZERO;
488
+ if (value == "")
489
+ throw new Error("string is no integer");
490
+ value = BI.C(value);
491
+ case "number":
492
+ if (value === 0)
493
+ return this.ZERO;
494
+ value = BI.C(value);
495
+ case "bigint":
496
+ if (!value)
497
+ return this.ZERO;
498
+ if (value < BI.MIN)
499
+ throw new Error("signed long too small");
500
+ if (value > BI.MAX)
501
+ throw new Error("signed long too large");
502
+ BI.V.setBigInt64(0, value, true);
503
+ return new _PbLong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));
504
+ }
505
+ else
506
+ switch (typeof value) {
507
+ case "string":
508
+ if (value == "0")
509
+ return this.ZERO;
510
+ value = value.trim();
511
+ if (!RE_DECIMAL_STR.test(value))
512
+ throw new Error("string is no integer");
513
+ let [minus, lo, hi] = int64fromString(value);
514
+ if (minus) {
515
+ if (hi > HALF_2_PWR_32 || hi == HALF_2_PWR_32 && lo != 0)
516
+ throw new Error("signed long too small");
517
+ } else if (hi >= HALF_2_PWR_32)
518
+ throw new Error("signed long too large");
519
+ let pbl = new _PbLong(lo, hi);
520
+ return minus ? pbl.negate() : pbl;
521
+ case "number":
522
+ if (value == 0)
523
+ return this.ZERO;
524
+ if (!Number.isSafeInteger(value))
525
+ throw new Error("number is no integer");
526
+ return value > 0 ? new _PbLong(value, value / TWO_PWR_32_DBL2) : new _PbLong(-value, -value / TWO_PWR_32_DBL2).negate();
527
+ }
528
+ throw new Error("unknown value " + typeof value);
529
+ }
530
+ /**
531
+ * Do we have a minus sign?
532
+ */
533
+ isNegative() {
534
+ return (this.hi & HALF_2_PWR_32) !== 0;
535
+ }
536
+ /**
537
+ * Negate two's complement.
538
+ * Invert all the bits and add one to the result.
539
+ */
540
+ negate() {
541
+ let hi = ~this.hi, lo = this.lo;
542
+ if (lo)
543
+ lo = ~lo + 1;
544
+ else
545
+ hi += 1;
546
+ return new _PbLong(lo, hi);
547
+ }
548
+ /**
549
+ * Convert to decimal string.
550
+ */
551
+ toString() {
552
+ if (BI)
553
+ return this.toBigInt().toString();
554
+ if (this.isNegative()) {
555
+ let n = this.negate();
556
+ return "-" + int64toString(n.lo, n.hi);
557
+ }
558
+ return int64toString(this.lo, this.hi);
559
+ }
560
+ /**
561
+ * Convert to native bigint.
562
+ */
563
+ toBigInt() {
564
+ assertBi(BI);
565
+ BI.V.setInt32(0, this.lo, true);
566
+ BI.V.setInt32(4, this.hi, true);
567
+ return BI.V.getBigInt64(0, true);
568
+ }
569
+ };
570
+ PbLong.ZERO = new PbLong(0, 0);
571
+
572
+ // node_modules/@protobuf-ts/runtime/build/es2015/binary-reader.js
573
+ var defaultsRead = {
574
+ readUnknownField: true,
575
+ readerFactory: (bytes) => new BinaryReader(bytes)
576
+ };
577
+ function binaryReadOptions(options) {
578
+ return options ? Object.assign(Object.assign({}, defaultsRead), options) : defaultsRead;
579
+ }
580
+ var BinaryReader = class {
581
+ constructor(buf, textDecoder) {
582
+ this.varint64 = varint64read;
583
+ this.uint32 = varint32read;
584
+ this.buf = buf;
585
+ this.len = buf.length;
586
+ this.pos = 0;
587
+ this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
588
+ this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder("utf-8", {
589
+ fatal: true,
590
+ ignoreBOM: true
591
+ });
592
+ }
593
+ /**
594
+ * Reads a tag - field number and wire type.
595
+ */
596
+ tag() {
597
+ let tag = this.uint32(), fieldNo = tag >>> 3, wireType = tag & 7;
598
+ if (fieldNo <= 0 || wireType < 0 || wireType > 5)
599
+ throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
600
+ return [fieldNo, wireType];
601
+ }
602
+ /**
603
+ * Skip one element on the wire and return the skipped data.
604
+ * Supports WireType.StartGroup since v2.0.0-alpha.23.
605
+ */
606
+ skip(wireType) {
607
+ let start = this.pos;
608
+ switch (wireType) {
609
+ case WireType.Varint:
610
+ while (this.buf[this.pos++] & 128) {
611
+ }
612
+ break;
613
+ case WireType.Bit64:
614
+ this.pos += 4;
615
+ case WireType.Bit32:
616
+ this.pos += 4;
617
+ break;
618
+ case WireType.LengthDelimited:
619
+ let len = this.uint32();
620
+ this.pos += len;
621
+ break;
622
+ case WireType.StartGroup:
623
+ let t;
624
+ while ((t = this.tag()[1]) !== WireType.EndGroup) {
625
+ this.skip(t);
626
+ }
627
+ break;
628
+ default:
629
+ throw new Error("cant skip wire type " + wireType);
630
+ }
631
+ this.assertBounds();
632
+ return this.buf.subarray(start, this.pos);
633
+ }
634
+ /**
635
+ * Throws error if position in byte array is out of range.
636
+ */
637
+ assertBounds() {
638
+ if (this.pos > this.len)
639
+ throw new RangeError("premature EOF");
640
+ }
641
+ /**
642
+ * Read a `int32` field, a signed 32 bit varint.
643
+ */
644
+ int32() {
645
+ return this.uint32() | 0;
646
+ }
647
+ /**
648
+ * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
649
+ */
650
+ sint32() {
651
+ let zze = this.uint32();
652
+ return zze >>> 1 ^ -(zze & 1);
653
+ }
654
+ /**
655
+ * Read a `int64` field, a signed 64-bit varint.
656
+ */
657
+ int64() {
658
+ return new PbLong(...this.varint64());
659
+ }
660
+ /**
661
+ * Read a `uint64` field, an unsigned 64-bit varint.
662
+ */
663
+ uint64() {
664
+ return new PbULong(...this.varint64());
665
+ }
666
+ /**
667
+ * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
668
+ */
669
+ sint64() {
670
+ let [lo, hi] = this.varint64();
671
+ let s = -(lo & 1);
672
+ lo = (lo >>> 1 | (hi & 1) << 31) ^ s;
673
+ hi = hi >>> 1 ^ s;
674
+ return new PbLong(lo, hi);
675
+ }
676
+ /**
677
+ * Read a `bool` field, a variant.
678
+ */
679
+ bool() {
680
+ let [lo, hi] = this.varint64();
681
+ return lo !== 0 || hi !== 0;
682
+ }
683
+ /**
684
+ * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
685
+ */
686
+ fixed32() {
687
+ return this.view.getUint32((this.pos += 4) - 4, true);
688
+ }
689
+ /**
690
+ * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
691
+ */
692
+ sfixed32() {
693
+ return this.view.getInt32((this.pos += 4) - 4, true);
694
+ }
695
+ /**
696
+ * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
697
+ */
698
+ fixed64() {
699
+ return new PbULong(this.sfixed32(), this.sfixed32());
700
+ }
701
+ /**
702
+ * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
703
+ */
704
+ sfixed64() {
705
+ return new PbLong(this.sfixed32(), this.sfixed32());
706
+ }
707
+ /**
708
+ * Read a `float` field, 32-bit floating point number.
709
+ */
710
+ float() {
711
+ return this.view.getFloat32((this.pos += 4) - 4, true);
712
+ }
713
+ /**
714
+ * Read a `double` field, a 64-bit floating point number.
715
+ */
716
+ double() {
717
+ return this.view.getFloat64((this.pos += 8) - 8, true);
718
+ }
719
+ /**
720
+ * Read a `bytes` field, length-delimited arbitrary data.
721
+ */
722
+ bytes() {
723
+ let len = this.uint32();
724
+ let start = this.pos;
725
+ this.pos += len;
726
+ this.assertBounds();
727
+ return this.buf.subarray(start, start + len);
728
+ }
729
+ /**
730
+ * Read a `string` field, length-delimited data converted to UTF-8 text.
731
+ */
732
+ string() {
733
+ return this.textDecoder.decode(this.bytes());
734
+ }
735
+ };
736
+
737
+ // node_modules/@protobuf-ts/runtime/build/es2015/assert.js
738
+ function assert(condition, msg) {
739
+ if (!condition) {
740
+ throw new Error(msg);
741
+ }
742
+ }
743
+ var FLOAT32_MAX = 34028234663852886e22;
744
+ var FLOAT32_MIN = -34028234663852886e22;
745
+ var UINT32_MAX = 4294967295;
746
+ var INT32_MAX = 2147483647;
747
+ var INT32_MIN = -2147483648;
748
+ function assertInt32(arg) {
749
+ if (typeof arg !== "number")
750
+ throw new Error("invalid int 32: " + typeof arg);
751
+ if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN)
752
+ throw new Error("invalid int 32: " + arg);
753
+ }
754
+ function assertUInt32(arg) {
755
+ if (typeof arg !== "number")
756
+ throw new Error("invalid uint 32: " + typeof arg);
757
+ if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0)
758
+ throw new Error("invalid uint 32: " + arg);
759
+ }
760
+ function assertFloat32(arg) {
761
+ if (typeof arg !== "number")
762
+ throw new Error("invalid float 32: " + typeof arg);
763
+ if (!Number.isFinite(arg))
764
+ return;
765
+ if (arg > FLOAT32_MAX || arg < FLOAT32_MIN)
766
+ throw new Error("invalid float 32: " + arg);
767
+ }
768
+
769
+ // node_modules/@protobuf-ts/runtime/build/es2015/binary-writer.js
770
+ var defaultsWrite = {
771
+ writeUnknownFields: true,
772
+ writerFactory: () => new BinaryWriter()
773
+ };
774
+ function binaryWriteOptions(options) {
775
+ return options ? Object.assign(Object.assign({}, defaultsWrite), options) : defaultsWrite;
776
+ }
777
+ var BinaryWriter = class {
778
+ constructor(textEncoder) {
779
+ this.stack = [];
780
+ this.textEncoder = textEncoder !== null && textEncoder !== void 0 ? textEncoder : new TextEncoder();
781
+ this.chunks = [];
782
+ this.buf = [];
783
+ }
784
+ /**
785
+ * Return all bytes written and reset this writer.
786
+ */
787
+ finish() {
788
+ this.chunks.push(new Uint8Array(this.buf));
789
+ let len = 0;
790
+ for (let i = 0; i < this.chunks.length; i++)
791
+ len += this.chunks[i].length;
792
+ let bytes = new Uint8Array(len);
793
+ let offset = 0;
794
+ for (let i = 0; i < this.chunks.length; i++) {
795
+ bytes.set(this.chunks[i], offset);
796
+ offset += this.chunks[i].length;
797
+ }
798
+ this.chunks = [];
799
+ return bytes;
800
+ }
801
+ /**
802
+ * Start a new fork for length-delimited data like a message
803
+ * or a packed repeated field.
804
+ *
805
+ * Must be joined later with `join()`.
806
+ */
807
+ fork() {
808
+ this.stack.push({ chunks: this.chunks, buf: this.buf });
809
+ this.chunks = [];
810
+ this.buf = [];
811
+ return this;
812
+ }
813
+ /**
814
+ * Join the last fork. Write its length and bytes, then
815
+ * return to the previous state.
816
+ */
817
+ join() {
818
+ let chunk = this.finish();
819
+ let prev = this.stack.pop();
820
+ if (!prev)
821
+ throw new Error("invalid state, fork stack empty");
822
+ this.chunks = prev.chunks;
823
+ this.buf = prev.buf;
824
+ this.uint32(chunk.byteLength);
825
+ return this.raw(chunk);
826
+ }
827
+ /**
828
+ * Writes a tag (field number and wire type).
829
+ *
830
+ * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
831
+ *
832
+ * Generated code should compute the tag ahead of time and call `uint32()`.
833
+ */
834
+ tag(fieldNo, type) {
835
+ return this.uint32((fieldNo << 3 | type) >>> 0);
836
+ }
837
+ /**
838
+ * Write a chunk of raw bytes.
839
+ */
840
+ raw(chunk) {
841
+ if (this.buf.length) {
842
+ this.chunks.push(new Uint8Array(this.buf));
843
+ this.buf = [];
844
+ }
845
+ this.chunks.push(chunk);
846
+ return this;
847
+ }
848
+ /**
849
+ * Write a `uint32` value, an unsigned 32 bit varint.
850
+ */
851
+ uint32(value) {
852
+ assertUInt32(value);
853
+ while (value > 127) {
854
+ this.buf.push(value & 127 | 128);
855
+ value = value >>> 7;
856
+ }
857
+ this.buf.push(value);
858
+ return this;
859
+ }
860
+ /**
861
+ * Write a `int32` value, a signed 32 bit varint.
862
+ */
863
+ int32(value) {
864
+ assertInt32(value);
865
+ varint32write(value, this.buf);
866
+ return this;
867
+ }
868
+ /**
869
+ * Write a `bool` value, a variant.
870
+ */
871
+ bool(value) {
872
+ this.buf.push(value ? 1 : 0);
873
+ return this;
874
+ }
875
+ /**
876
+ * Write a `bytes` value, length-delimited arbitrary data.
877
+ */
878
+ bytes(value) {
879
+ this.uint32(value.byteLength);
880
+ return this.raw(value);
881
+ }
882
+ /**
883
+ * Write a `string` value, length-delimited data converted to UTF-8 text.
884
+ */
885
+ string(value) {
886
+ let chunk = this.textEncoder.encode(value);
887
+ this.uint32(chunk.byteLength);
888
+ return this.raw(chunk);
889
+ }
890
+ /**
891
+ * Write a `float` value, 32-bit floating point number.
892
+ */
893
+ float(value) {
894
+ assertFloat32(value);
895
+ let chunk = new Uint8Array(4);
896
+ new DataView(chunk.buffer).setFloat32(0, value, true);
897
+ return this.raw(chunk);
898
+ }
899
+ /**
900
+ * Write a `double` value, a 64-bit floating point number.
901
+ */
902
+ double(value) {
903
+ let chunk = new Uint8Array(8);
904
+ new DataView(chunk.buffer).setFloat64(0, value, true);
905
+ return this.raw(chunk);
906
+ }
907
+ /**
908
+ * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
909
+ */
910
+ fixed32(value) {
911
+ assertUInt32(value);
912
+ let chunk = new Uint8Array(4);
913
+ new DataView(chunk.buffer).setUint32(0, value, true);
914
+ return this.raw(chunk);
915
+ }
916
+ /**
917
+ * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
918
+ */
919
+ sfixed32(value) {
920
+ assertInt32(value);
921
+ let chunk = new Uint8Array(4);
922
+ new DataView(chunk.buffer).setInt32(0, value, true);
923
+ return this.raw(chunk);
924
+ }
925
+ /**
926
+ * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
927
+ */
928
+ sint32(value) {
929
+ assertInt32(value);
930
+ value = (value << 1 ^ value >> 31) >>> 0;
931
+ varint32write(value, this.buf);
932
+ return this;
933
+ }
934
+ /**
935
+ * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
936
+ */
937
+ sfixed64(value) {
938
+ let chunk = new Uint8Array(8);
939
+ let view = new DataView(chunk.buffer);
940
+ let long = PbLong.from(value);
941
+ view.setInt32(0, long.lo, true);
942
+ view.setInt32(4, long.hi, true);
943
+ return this.raw(chunk);
944
+ }
945
+ /**
946
+ * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
947
+ */
948
+ fixed64(value) {
949
+ let chunk = new Uint8Array(8);
950
+ let view = new DataView(chunk.buffer);
951
+ let long = PbULong.from(value);
952
+ view.setInt32(0, long.lo, true);
953
+ view.setInt32(4, long.hi, true);
954
+ return this.raw(chunk);
955
+ }
956
+ /**
957
+ * Write a `int64` value, a signed 64-bit varint.
958
+ */
959
+ int64(value) {
960
+ let long = PbLong.from(value);
961
+ varint64write(long.lo, long.hi, this.buf);
962
+ return this;
963
+ }
964
+ /**
965
+ * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
966
+ */
967
+ sint64(value) {
968
+ let long = PbLong.from(value), sign = long.hi >> 31, lo = long.lo << 1 ^ sign, hi = (long.hi << 1 | long.lo >>> 31) ^ sign;
969
+ varint64write(lo, hi, this.buf);
970
+ return this;
971
+ }
972
+ /**
973
+ * Write a `uint64` value, an unsigned 64-bit varint.
974
+ */
975
+ uint64(value) {
976
+ let long = PbULong.from(value);
977
+ varint64write(long.lo, long.hi, this.buf);
978
+ return this;
979
+ }
980
+ };
981
+
982
+ // node_modules/@protobuf-ts/runtime/build/es2015/json-format-contract.js
983
+ var defaultsWrite2 = {
984
+ emitDefaultValues: false,
985
+ enumAsInteger: false,
986
+ useProtoFieldName: false,
987
+ prettySpaces: 0
988
+ };
989
+ var defaultsRead2 = {
990
+ ignoreUnknownFields: false
991
+ };
992
+ function jsonReadOptions(options) {
993
+ return options ? Object.assign(Object.assign({}, defaultsRead2), options) : defaultsRead2;
994
+ }
995
+ function jsonWriteOptions(options) {
996
+ return options ? Object.assign(Object.assign({}, defaultsWrite2), options) : defaultsWrite2;
997
+ }
998
+
999
+ // node_modules/@protobuf-ts/runtime/build/es2015/message-type-contract.js
1000
+ var MESSAGE_TYPE = Symbol.for("protobuf-ts/message-type");
1001
+
1002
+ // node_modules/@protobuf-ts/runtime/build/es2015/lower-camel-case.js
1003
+ function lowerCamelCase(snakeCase) {
1004
+ let capNext = false;
1005
+ const sb = [];
1006
+ for (let i = 0; i < snakeCase.length; i++) {
1007
+ let next = snakeCase.charAt(i);
1008
+ if (next == "_") {
1009
+ capNext = true;
1010
+ } else if (/\d/.test(next)) {
1011
+ sb.push(next);
1012
+ capNext = true;
1013
+ } else if (capNext) {
1014
+ sb.push(next.toUpperCase());
1015
+ capNext = false;
1016
+ } else if (i == 0) {
1017
+ sb.push(next.toLowerCase());
1018
+ } else {
1019
+ sb.push(next);
1020
+ }
1021
+ }
1022
+ return sb.join("");
1023
+ }
1024
+
1025
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-info.js
1026
+ var ScalarType;
1027
+ (function(ScalarType2) {
1028
+ ScalarType2[ScalarType2["DOUBLE"] = 1] = "DOUBLE";
1029
+ ScalarType2[ScalarType2["FLOAT"] = 2] = "FLOAT";
1030
+ ScalarType2[ScalarType2["INT64"] = 3] = "INT64";
1031
+ ScalarType2[ScalarType2["UINT64"] = 4] = "UINT64";
1032
+ ScalarType2[ScalarType2["INT32"] = 5] = "INT32";
1033
+ ScalarType2[ScalarType2["FIXED64"] = 6] = "FIXED64";
1034
+ ScalarType2[ScalarType2["FIXED32"] = 7] = "FIXED32";
1035
+ ScalarType2[ScalarType2["BOOL"] = 8] = "BOOL";
1036
+ ScalarType2[ScalarType2["STRING"] = 9] = "STRING";
1037
+ ScalarType2[ScalarType2["BYTES"] = 12] = "BYTES";
1038
+ ScalarType2[ScalarType2["UINT32"] = 13] = "UINT32";
1039
+ ScalarType2[ScalarType2["SFIXED32"] = 15] = "SFIXED32";
1040
+ ScalarType2[ScalarType2["SFIXED64"] = 16] = "SFIXED64";
1041
+ ScalarType2[ScalarType2["SINT32"] = 17] = "SINT32";
1042
+ ScalarType2[ScalarType2["SINT64"] = 18] = "SINT64";
1043
+ })(ScalarType || (ScalarType = {}));
1044
+ var LongType;
1045
+ (function(LongType2) {
1046
+ LongType2[LongType2["BIGINT"] = 0] = "BIGINT";
1047
+ LongType2[LongType2["STRING"] = 1] = "STRING";
1048
+ LongType2[LongType2["NUMBER"] = 2] = "NUMBER";
1049
+ })(LongType || (LongType = {}));
1050
+ var RepeatType;
1051
+ (function(RepeatType2) {
1052
+ RepeatType2[RepeatType2["NO"] = 0] = "NO";
1053
+ RepeatType2[RepeatType2["PACKED"] = 1] = "PACKED";
1054
+ RepeatType2[RepeatType2["UNPACKED"] = 2] = "UNPACKED";
1055
+ })(RepeatType || (RepeatType = {}));
1056
+ function normalizeFieldInfo(field) {
1057
+ var _a, _b, _c, _d;
1058
+ field.localName = (_a = field.localName) !== null && _a !== void 0 ? _a : lowerCamelCase(field.name);
1059
+ field.jsonName = (_b = field.jsonName) !== null && _b !== void 0 ? _b : lowerCamelCase(field.name);
1060
+ field.repeat = (_c = field.repeat) !== null && _c !== void 0 ? _c : RepeatType.NO;
1061
+ field.opt = (_d = field.opt) !== null && _d !== void 0 ? _d : field.repeat ? false : field.oneof ? false : field.kind == "message";
1062
+ return field;
1063
+ }
1064
+
1065
+ // node_modules/@protobuf-ts/runtime/build/es2015/oneof.js
1066
+ function isOneofGroup(any) {
1067
+ if (typeof any != "object" || any === null || !any.hasOwnProperty("oneofKind")) {
1068
+ return false;
1069
+ }
1070
+ switch (typeof any.oneofKind) {
1071
+ case "string":
1072
+ if (any[any.oneofKind] === void 0)
1073
+ return false;
1074
+ return Object.keys(any).length == 2;
1075
+ case "undefined":
1076
+ return Object.keys(any).length == 1;
1077
+ default:
1078
+ return false;
1079
+ }
1080
+ }
1081
+
1082
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-type-check.js
1083
+ var ReflectionTypeCheck = class {
1084
+ constructor(info) {
1085
+ var _a;
1086
+ this.fields = (_a = info.fields) !== null && _a !== void 0 ? _a : [];
1087
+ }
1088
+ prepare() {
1089
+ if (this.data)
1090
+ return;
1091
+ const req = [], known = [], oneofs = [];
1092
+ for (let field of this.fields) {
1093
+ if (field.oneof) {
1094
+ if (!oneofs.includes(field.oneof)) {
1095
+ oneofs.push(field.oneof);
1096
+ req.push(field.oneof);
1097
+ known.push(field.oneof);
1098
+ }
1099
+ } else {
1100
+ known.push(field.localName);
1101
+ switch (field.kind) {
1102
+ case "scalar":
1103
+ case "enum":
1104
+ if (!field.opt || field.repeat)
1105
+ req.push(field.localName);
1106
+ break;
1107
+ case "message":
1108
+ if (field.repeat)
1109
+ req.push(field.localName);
1110
+ break;
1111
+ case "map":
1112
+ req.push(field.localName);
1113
+ break;
1114
+ }
1115
+ }
1116
+ }
1117
+ this.data = { req, known, oneofs: Object.values(oneofs) };
1118
+ }
1119
+ /**
1120
+ * Is the argument a valid message as specified by the
1121
+ * reflection information?
1122
+ *
1123
+ * Checks all field types recursively. The `depth`
1124
+ * specifies how deep into the structure the check will be.
1125
+ *
1126
+ * With a depth of 0, only the presence of fields
1127
+ * is checked.
1128
+ *
1129
+ * With a depth of 1 or more, the field types are checked.
1130
+ *
1131
+ * With a depth of 2 or more, the members of map, repeated
1132
+ * and message fields are checked.
1133
+ *
1134
+ * Message fields will be checked recursively with depth - 1.
1135
+ *
1136
+ * The number of map entries / repeated values being checked
1137
+ * is < depth.
1138
+ */
1139
+ is(message, depth, allowExcessProperties = false) {
1140
+ if (depth < 0)
1141
+ return true;
1142
+ if (message === null || message === void 0 || typeof message != "object")
1143
+ return false;
1144
+ this.prepare();
1145
+ let keys = Object.keys(message), data = this.data;
1146
+ if (keys.length < data.req.length || data.req.some((n) => !keys.includes(n)))
1147
+ return false;
1148
+ if (!allowExcessProperties) {
1149
+ if (keys.some((k) => !data.known.includes(k)))
1150
+ return false;
1151
+ }
1152
+ if (depth < 1) {
1153
+ return true;
1154
+ }
1155
+ for (const name of data.oneofs) {
1156
+ const group = message[name];
1157
+ if (!isOneofGroup(group))
1158
+ return false;
1159
+ if (group.oneofKind === void 0)
1160
+ continue;
1161
+ const field = this.fields.find((f) => f.localName === group.oneofKind);
1162
+ if (!field)
1163
+ return false;
1164
+ if (!this.field(group[group.oneofKind], field, allowExcessProperties, depth))
1165
+ return false;
1166
+ }
1167
+ for (const field of this.fields) {
1168
+ if (field.oneof !== void 0)
1169
+ continue;
1170
+ if (!this.field(message[field.localName], field, allowExcessProperties, depth))
1171
+ return false;
1172
+ }
1173
+ return true;
1174
+ }
1175
+ field(arg, field, allowExcessProperties, depth) {
1176
+ let repeated = field.repeat;
1177
+ switch (field.kind) {
1178
+ case "scalar":
1179
+ if (arg === void 0)
1180
+ return field.opt;
1181
+ if (repeated)
1182
+ return this.scalars(arg, field.T, depth, field.L);
1183
+ return this.scalar(arg, field.T, field.L);
1184
+ case "enum":
1185
+ if (arg === void 0)
1186
+ return field.opt;
1187
+ if (repeated)
1188
+ return this.scalars(arg, ScalarType.INT32, depth);
1189
+ return this.scalar(arg, ScalarType.INT32);
1190
+ case "message":
1191
+ if (arg === void 0)
1192
+ return true;
1193
+ if (repeated)
1194
+ return this.messages(arg, field.T(), allowExcessProperties, depth);
1195
+ return this.message(arg, field.T(), allowExcessProperties, depth);
1196
+ case "map":
1197
+ if (typeof arg != "object" || arg === null)
1198
+ return false;
1199
+ if (depth < 2)
1200
+ return true;
1201
+ if (!this.mapKeys(arg, field.K, depth))
1202
+ return false;
1203
+ switch (field.V.kind) {
1204
+ case "scalar":
1205
+ return this.scalars(Object.values(arg), field.V.T, depth, field.V.L);
1206
+ case "enum":
1207
+ return this.scalars(Object.values(arg), ScalarType.INT32, depth);
1208
+ case "message":
1209
+ return this.messages(Object.values(arg), field.V.T(), allowExcessProperties, depth);
1210
+ }
1211
+ break;
1212
+ }
1213
+ return true;
1214
+ }
1215
+ message(arg, type, allowExcessProperties, depth) {
1216
+ if (allowExcessProperties) {
1217
+ return type.isAssignable(arg, depth);
1218
+ }
1219
+ return type.is(arg, depth);
1220
+ }
1221
+ messages(arg, type, allowExcessProperties, depth) {
1222
+ if (!Array.isArray(arg))
1223
+ return false;
1224
+ if (depth < 2)
1225
+ return true;
1226
+ if (allowExcessProperties) {
1227
+ for (let i = 0; i < arg.length && i < depth; i++)
1228
+ if (!type.isAssignable(arg[i], depth - 1))
1229
+ return false;
1230
+ } else {
1231
+ for (let i = 0; i < arg.length && i < depth; i++)
1232
+ if (!type.is(arg[i], depth - 1))
1233
+ return false;
1234
+ }
1235
+ return true;
1236
+ }
1237
+ scalar(arg, type, longType) {
1238
+ let argType = typeof arg;
1239
+ switch (type) {
1240
+ case ScalarType.UINT64:
1241
+ case ScalarType.FIXED64:
1242
+ case ScalarType.INT64:
1243
+ case ScalarType.SFIXED64:
1244
+ case ScalarType.SINT64:
1245
+ switch (longType) {
1246
+ case LongType.BIGINT:
1247
+ return argType == "bigint";
1248
+ case LongType.NUMBER:
1249
+ return argType == "number" && !isNaN(arg);
1250
+ default:
1251
+ return argType == "string";
1252
+ }
1253
+ case ScalarType.BOOL:
1254
+ return argType == "boolean";
1255
+ case ScalarType.STRING:
1256
+ return argType == "string";
1257
+ case ScalarType.BYTES:
1258
+ return arg instanceof Uint8Array;
1259
+ case ScalarType.DOUBLE:
1260
+ case ScalarType.FLOAT:
1261
+ return argType == "number" && !isNaN(arg);
1262
+ default:
1263
+ return argType == "number" && Number.isInteger(arg);
1264
+ }
1265
+ }
1266
+ scalars(arg, type, depth, longType) {
1267
+ if (!Array.isArray(arg))
1268
+ return false;
1269
+ if (depth < 2)
1270
+ return true;
1271
+ if (Array.isArray(arg)) {
1272
+ for (let i = 0; i < arg.length && i < depth; i++)
1273
+ if (!this.scalar(arg[i], type, longType))
1274
+ return false;
1275
+ }
1276
+ return true;
1277
+ }
1278
+ mapKeys(map, type, depth) {
1279
+ let keys = Object.keys(map);
1280
+ switch (type) {
1281
+ case ScalarType.INT32:
1282
+ case ScalarType.FIXED32:
1283
+ case ScalarType.SFIXED32:
1284
+ case ScalarType.SINT32:
1285
+ case ScalarType.UINT32:
1286
+ return this.scalars(keys.slice(0, depth).map((k) => parseInt(k)), type, depth);
1287
+ case ScalarType.BOOL:
1288
+ return this.scalars(keys.slice(0, depth).map((k) => k == "true" ? true : k == "false" ? false : k), type, depth);
1289
+ default:
1290
+ return this.scalars(keys, type, depth, LongType.STRING);
1291
+ }
1292
+ }
1293
+ };
1294
+
1295
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-long-convert.js
1296
+ function reflectionLongConvert(long, type) {
1297
+ switch (type) {
1298
+ case LongType.BIGINT:
1299
+ return long.toBigInt();
1300
+ case LongType.NUMBER:
1301
+ return long.toNumber();
1302
+ default:
1303
+ return long.toString();
1304
+ }
1305
+ }
1306
+
1307
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-json-reader.js
1308
+ var ReflectionJsonReader = class {
1309
+ constructor(info) {
1310
+ this.info = info;
1311
+ }
1312
+ prepare() {
1313
+ var _a;
1314
+ if (this.fMap === void 0) {
1315
+ this.fMap = {};
1316
+ const fieldsInput = (_a = this.info.fields) !== null && _a !== void 0 ? _a : [];
1317
+ for (const field of fieldsInput) {
1318
+ this.fMap[field.name] = field;
1319
+ this.fMap[field.jsonName] = field;
1320
+ this.fMap[field.localName] = field;
1321
+ }
1322
+ }
1323
+ }
1324
+ // Cannot parse JSON <type of jsonValue> for <type name>#<fieldName>.
1325
+ assert(condition, fieldName, jsonValue) {
1326
+ if (!condition) {
1327
+ let what = typeofJsonValue(jsonValue);
1328
+ if (what == "number" || what == "boolean")
1329
+ what = jsonValue.toString();
1330
+ throw new Error(`Cannot parse JSON ${what} for ${this.info.typeName}#${fieldName}`);
1331
+ }
1332
+ }
1333
+ /**
1334
+ * Reads a message from canonical JSON format into the target message.
1335
+ *
1336
+ * Repeated fields are appended. Map entries are added, overwriting
1337
+ * existing keys.
1338
+ *
1339
+ * If a message field is already present, it will be merged with the
1340
+ * new data.
1341
+ */
1342
+ read(input, message, options) {
1343
+ this.prepare();
1344
+ const oneofsHandled = [];
1345
+ for (const [jsonKey, jsonValue] of Object.entries(input)) {
1346
+ const field = this.fMap[jsonKey];
1347
+ if (!field) {
1348
+ if (!options.ignoreUnknownFields)
1349
+ throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${jsonKey}`);
1350
+ continue;
1351
+ }
1352
+ const localName = field.localName;
1353
+ let target;
1354
+ if (field.oneof) {
1355
+ if (jsonValue === null && (field.kind !== "enum" || field.T()[0] !== "google.protobuf.NullValue")) {
1356
+ continue;
1357
+ }
1358
+ if (oneofsHandled.includes(field.oneof))
1359
+ throw new Error(`Multiple members of the oneof group "${field.oneof}" of ${this.info.typeName} are present in JSON.`);
1360
+ oneofsHandled.push(field.oneof);
1361
+ target = message[field.oneof] = {
1362
+ oneofKind: localName
1363
+ };
1364
+ } else {
1365
+ target = message;
1366
+ }
1367
+ if (field.kind == "map") {
1368
+ if (jsonValue === null) {
1369
+ continue;
1370
+ }
1371
+ this.assert(isJsonObject(jsonValue), field.name, jsonValue);
1372
+ const fieldObj = target[localName];
1373
+ for (const [jsonObjKey, jsonObjValue] of Object.entries(jsonValue)) {
1374
+ this.assert(jsonObjValue !== null, field.name + " map value", null);
1375
+ let val;
1376
+ switch (field.V.kind) {
1377
+ case "message":
1378
+ val = field.V.T().internalJsonRead(jsonObjValue, options);
1379
+ break;
1380
+ case "enum":
1381
+ val = this.enum(field.V.T(), jsonObjValue, field.name, options.ignoreUnknownFields);
1382
+ if (val === false)
1383
+ continue;
1384
+ break;
1385
+ case "scalar":
1386
+ val = this.scalar(jsonObjValue, field.V.T, field.V.L, field.name);
1387
+ break;
1388
+ }
1389
+ this.assert(val !== void 0, field.name + " map value", jsonObjValue);
1390
+ let key = jsonObjKey;
1391
+ if (field.K == ScalarType.BOOL)
1392
+ key = key == "true" ? true : key == "false" ? false : key;
1393
+ key = this.scalar(key, field.K, LongType.STRING, field.name).toString();
1394
+ fieldObj[key] = val;
1395
+ }
1396
+ } else if (field.repeat) {
1397
+ if (jsonValue === null)
1398
+ continue;
1399
+ this.assert(Array.isArray(jsonValue), field.name, jsonValue);
1400
+ const fieldArr = target[localName];
1401
+ for (const jsonItem of jsonValue) {
1402
+ this.assert(jsonItem !== null, field.name, null);
1403
+ let val;
1404
+ switch (field.kind) {
1405
+ case "message":
1406
+ val = field.T().internalJsonRead(jsonItem, options);
1407
+ break;
1408
+ case "enum":
1409
+ val = this.enum(field.T(), jsonItem, field.name, options.ignoreUnknownFields);
1410
+ if (val === false)
1411
+ continue;
1412
+ break;
1413
+ case "scalar":
1414
+ val = this.scalar(jsonItem, field.T, field.L, field.name);
1415
+ break;
1416
+ }
1417
+ this.assert(val !== void 0, field.name, jsonValue);
1418
+ fieldArr.push(val);
1419
+ }
1420
+ } else {
1421
+ switch (field.kind) {
1422
+ case "message":
1423
+ if (jsonValue === null && field.T().typeName != "google.protobuf.Value") {
1424
+ this.assert(field.oneof === void 0, field.name + " (oneof member)", null);
1425
+ continue;
1426
+ }
1427
+ target[localName] = field.T().internalJsonRead(jsonValue, options, target[localName]);
1428
+ break;
1429
+ case "enum":
1430
+ if (jsonValue === null)
1431
+ continue;
1432
+ let val = this.enum(field.T(), jsonValue, field.name, options.ignoreUnknownFields);
1433
+ if (val === false)
1434
+ continue;
1435
+ target[localName] = val;
1436
+ break;
1437
+ case "scalar":
1438
+ if (jsonValue === null)
1439
+ continue;
1440
+ target[localName] = this.scalar(jsonValue, field.T, field.L, field.name);
1441
+ break;
1442
+ }
1443
+ }
1444
+ }
1445
+ }
1446
+ /**
1447
+ * Returns `false` for unrecognized string representations.
1448
+ *
1449
+ * google.protobuf.NullValue accepts only JSON `null` (or the old `"NULL_VALUE"`).
1450
+ */
1451
+ enum(type, json, fieldName, ignoreUnknownFields) {
1452
+ if (type[0] == "google.protobuf.NullValue")
1453
+ assert(json === null || json === "NULL_VALUE", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
1454
+ if (json === null)
1455
+ return 0;
1456
+ switch (typeof json) {
1457
+ case "number":
1458
+ assert(Number.isInteger(json), `Unable to parse field ${this.info.typeName}#${fieldName}, enum can only be integral number, got ${json}.`);
1459
+ return json;
1460
+ case "string":
1461
+ let localEnumName = json;
1462
+ if (type[2] && json.substring(0, type[2].length) === type[2])
1463
+ localEnumName = json.substring(type[2].length);
1464
+ let enumNumber = type[1][localEnumName];
1465
+ if (typeof enumNumber === "undefined" && ignoreUnknownFields) {
1466
+ return false;
1467
+ }
1468
+ assert(typeof enumNumber == "number", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} has no value for "${json}".`);
1469
+ return enumNumber;
1470
+ }
1471
+ assert(false, `Unable to parse field ${this.info.typeName}#${fieldName}, cannot parse enum value from ${typeof json}".`);
1472
+ }
1473
+ scalar(json, type, longType, fieldName) {
1474
+ let e;
1475
+ try {
1476
+ switch (type) {
1477
+ // float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
1478
+ // Either numbers or strings are accepted. Exponent notation is also accepted.
1479
+ case ScalarType.DOUBLE:
1480
+ case ScalarType.FLOAT:
1481
+ if (json === null)
1482
+ return 0;
1483
+ if (json === "NaN")
1484
+ return Number.NaN;
1485
+ if (json === "Infinity")
1486
+ return Number.POSITIVE_INFINITY;
1487
+ if (json === "-Infinity")
1488
+ return Number.NEGATIVE_INFINITY;
1489
+ if (json === "") {
1490
+ e = "empty string";
1491
+ break;
1492
+ }
1493
+ if (typeof json == "string" && json.trim().length !== json.length) {
1494
+ e = "extra whitespace";
1495
+ break;
1496
+ }
1497
+ if (typeof json != "string" && typeof json != "number") {
1498
+ break;
1499
+ }
1500
+ let float = Number(json);
1501
+ if (Number.isNaN(float)) {
1502
+ e = "not a number";
1503
+ break;
1504
+ }
1505
+ if (!Number.isFinite(float)) {
1506
+ e = "too large or small";
1507
+ break;
1508
+ }
1509
+ if (type == ScalarType.FLOAT)
1510
+ assertFloat32(float);
1511
+ return float;
1512
+ // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
1513
+ case ScalarType.INT32:
1514
+ case ScalarType.FIXED32:
1515
+ case ScalarType.SFIXED32:
1516
+ case ScalarType.SINT32:
1517
+ case ScalarType.UINT32:
1518
+ if (json === null)
1519
+ return 0;
1520
+ let int32;
1521
+ if (typeof json == "number")
1522
+ int32 = json;
1523
+ else if (json === "")
1524
+ e = "empty string";
1525
+ else if (typeof json == "string") {
1526
+ if (json.trim().length !== json.length)
1527
+ e = "extra whitespace";
1528
+ else
1529
+ int32 = Number(json);
1530
+ }
1531
+ if (int32 === void 0)
1532
+ break;
1533
+ if (type == ScalarType.UINT32)
1534
+ assertUInt32(int32);
1535
+ else
1536
+ assertInt32(int32);
1537
+ return int32;
1538
+ // int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted.
1539
+ case ScalarType.INT64:
1540
+ case ScalarType.SFIXED64:
1541
+ case ScalarType.SINT64:
1542
+ if (json === null)
1543
+ return reflectionLongConvert(PbLong.ZERO, longType);
1544
+ if (typeof json != "number" && typeof json != "string")
1545
+ break;
1546
+ return reflectionLongConvert(PbLong.from(json), longType);
1547
+ case ScalarType.FIXED64:
1548
+ case ScalarType.UINT64:
1549
+ if (json === null)
1550
+ return reflectionLongConvert(PbULong.ZERO, longType);
1551
+ if (typeof json != "number" && typeof json != "string")
1552
+ break;
1553
+ return reflectionLongConvert(PbULong.from(json), longType);
1554
+ // bool:
1555
+ case ScalarType.BOOL:
1556
+ if (json === null)
1557
+ return false;
1558
+ if (typeof json !== "boolean")
1559
+ break;
1560
+ return json;
1561
+ // string:
1562
+ case ScalarType.STRING:
1563
+ if (json === null)
1564
+ return "";
1565
+ if (typeof json !== "string") {
1566
+ e = "extra whitespace";
1567
+ break;
1568
+ }
1569
+ try {
1570
+ encodeURIComponent(json);
1571
+ } catch (e2) {
1572
+ e2 = "invalid UTF8";
1573
+ break;
1574
+ }
1575
+ return json;
1576
+ // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
1577
+ // Either standard or URL-safe base64 encoding with/without paddings are accepted.
1578
+ case ScalarType.BYTES:
1579
+ if (json === null || json === "")
1580
+ return new Uint8Array(0);
1581
+ if (typeof json !== "string")
1582
+ break;
1583
+ return base64decode(json);
1584
+ }
1585
+ } catch (error) {
1586
+ e = error.message;
1587
+ }
1588
+ this.assert(false, fieldName + (e ? " - " + e : ""), json);
1589
+ }
1590
+ };
1591
+
1592
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-json-writer.js
1593
+ var ReflectionJsonWriter = class {
1594
+ constructor(info) {
1595
+ var _a;
1596
+ this.fields = (_a = info.fields) !== null && _a !== void 0 ? _a : [];
1597
+ }
1598
+ /**
1599
+ * Converts the message to a JSON object, based on the field descriptors.
1600
+ */
1601
+ write(message, options) {
1602
+ const json = {}, source = message;
1603
+ for (const field of this.fields) {
1604
+ if (!field.oneof) {
1605
+ let jsonValue2 = this.field(field, source[field.localName], options);
1606
+ if (jsonValue2 !== void 0)
1607
+ json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue2;
1608
+ continue;
1609
+ }
1610
+ const group = source[field.oneof];
1611
+ if (group.oneofKind !== field.localName)
1612
+ continue;
1613
+ const opt = field.kind == "scalar" || field.kind == "enum" ? Object.assign(Object.assign({}, options), { emitDefaultValues: true }) : options;
1614
+ let jsonValue = this.field(field, group[field.localName], opt);
1615
+ assert(jsonValue !== void 0);
1616
+ json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
1617
+ }
1618
+ return json;
1619
+ }
1620
+ field(field, value, options) {
1621
+ let jsonValue = void 0;
1622
+ if (field.kind == "map") {
1623
+ assert(typeof value == "object" && value !== null);
1624
+ const jsonObj = {};
1625
+ switch (field.V.kind) {
1626
+ case "scalar":
1627
+ for (const [entryKey, entryValue] of Object.entries(value)) {
1628
+ const val = this.scalar(field.V.T, entryValue, field.name, false, true);
1629
+ assert(val !== void 0);
1630
+ jsonObj[entryKey.toString()] = val;
1631
+ }
1632
+ break;
1633
+ case "message":
1634
+ const messageType = field.V.T();
1635
+ for (const [entryKey, entryValue] of Object.entries(value)) {
1636
+ const val = this.message(messageType, entryValue, field.name, options);
1637
+ assert(val !== void 0);
1638
+ jsonObj[entryKey.toString()] = val;
1639
+ }
1640
+ break;
1641
+ case "enum":
1642
+ const enumInfo = field.V.T();
1643
+ for (const [entryKey, entryValue] of Object.entries(value)) {
1644
+ assert(entryValue === void 0 || typeof entryValue == "number");
1645
+ const val = this.enum(enumInfo, entryValue, field.name, false, true, options.enumAsInteger);
1646
+ assert(val !== void 0);
1647
+ jsonObj[entryKey.toString()] = val;
1648
+ }
1649
+ break;
1650
+ }
1651
+ if (options.emitDefaultValues || Object.keys(jsonObj).length > 0)
1652
+ jsonValue = jsonObj;
1653
+ } else if (field.repeat) {
1654
+ assert(Array.isArray(value));
1655
+ const jsonArr = [];
1656
+ switch (field.kind) {
1657
+ case "scalar":
1658
+ for (let i = 0; i < value.length; i++) {
1659
+ const val = this.scalar(field.T, value[i], field.name, field.opt, true);
1660
+ assert(val !== void 0);
1661
+ jsonArr.push(val);
1662
+ }
1663
+ break;
1664
+ case "enum":
1665
+ const enumInfo = field.T();
1666
+ for (let i = 0; i < value.length; i++) {
1667
+ assert(value[i] === void 0 || typeof value[i] == "number");
1668
+ const val = this.enum(enumInfo, value[i], field.name, field.opt, true, options.enumAsInteger);
1669
+ assert(val !== void 0);
1670
+ jsonArr.push(val);
1671
+ }
1672
+ break;
1673
+ case "message":
1674
+ const messageType = field.T();
1675
+ for (let i = 0; i < value.length; i++) {
1676
+ const val = this.message(messageType, value[i], field.name, options);
1677
+ assert(val !== void 0);
1678
+ jsonArr.push(val);
1679
+ }
1680
+ break;
1681
+ }
1682
+ if (options.emitDefaultValues || jsonArr.length > 0 || options.emitDefaultValues)
1683
+ jsonValue = jsonArr;
1684
+ } else {
1685
+ switch (field.kind) {
1686
+ case "scalar":
1687
+ jsonValue = this.scalar(field.T, value, field.name, field.opt, options.emitDefaultValues);
1688
+ break;
1689
+ case "enum":
1690
+ jsonValue = this.enum(field.T(), value, field.name, field.opt, options.emitDefaultValues, options.enumAsInteger);
1691
+ break;
1692
+ case "message":
1693
+ jsonValue = this.message(field.T(), value, field.name, options);
1694
+ break;
1695
+ }
1696
+ }
1697
+ return jsonValue;
1698
+ }
1699
+ /**
1700
+ * Returns `null` as the default for google.protobuf.NullValue.
1701
+ */
1702
+ enum(type, value, fieldName, optional, emitDefaultValues, enumAsInteger) {
1703
+ if (type[0] == "google.protobuf.NullValue")
1704
+ return !emitDefaultValues && !optional ? void 0 : null;
1705
+ if (value === void 0) {
1706
+ assert(optional);
1707
+ return void 0;
1708
+ }
1709
+ if (value === 0 && !emitDefaultValues && !optional)
1710
+ return void 0;
1711
+ assert(typeof value == "number");
1712
+ assert(Number.isInteger(value));
1713
+ if (enumAsInteger || !type[1].hasOwnProperty(value))
1714
+ return value;
1715
+ if (type[2])
1716
+ return type[2] + type[1][value];
1717
+ return type[1][value];
1718
+ }
1719
+ message(type, value, fieldName, options) {
1720
+ if (value === void 0)
1721
+ return options.emitDefaultValues ? null : void 0;
1722
+ return type.internalJsonWrite(value, options);
1723
+ }
1724
+ scalar(type, value, fieldName, optional, emitDefaultValues) {
1725
+ if (value === void 0) {
1726
+ assert(optional);
1727
+ return void 0;
1728
+ }
1729
+ const ed = emitDefaultValues || optional;
1730
+ switch (type) {
1731
+ // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
1732
+ case ScalarType.INT32:
1733
+ case ScalarType.SFIXED32:
1734
+ case ScalarType.SINT32:
1735
+ if (value === 0)
1736
+ return ed ? 0 : void 0;
1737
+ assertInt32(value);
1738
+ return value;
1739
+ case ScalarType.FIXED32:
1740
+ case ScalarType.UINT32:
1741
+ if (value === 0)
1742
+ return ed ? 0 : void 0;
1743
+ assertUInt32(value);
1744
+ return value;
1745
+ // float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
1746
+ // Either numbers or strings are accepted. Exponent notation is also accepted.
1747
+ case ScalarType.FLOAT:
1748
+ assertFloat32(value);
1749
+ case ScalarType.DOUBLE:
1750
+ if (value === 0)
1751
+ return ed ? 0 : void 0;
1752
+ assert(typeof value == "number");
1753
+ if (Number.isNaN(value))
1754
+ return "NaN";
1755
+ if (value === Number.POSITIVE_INFINITY)
1756
+ return "Infinity";
1757
+ if (value === Number.NEGATIVE_INFINITY)
1758
+ return "-Infinity";
1759
+ return value;
1760
+ // string:
1761
+ case ScalarType.STRING:
1762
+ if (value === "")
1763
+ return ed ? "" : void 0;
1764
+ assert(typeof value == "string");
1765
+ return value;
1766
+ // bool:
1767
+ case ScalarType.BOOL:
1768
+ if (value === false)
1769
+ return ed ? false : void 0;
1770
+ assert(typeof value == "boolean");
1771
+ return value;
1772
+ // JSON value will be a decimal string. Either numbers or strings are accepted.
1773
+ case ScalarType.UINT64:
1774
+ case ScalarType.FIXED64:
1775
+ assert(typeof value == "number" || typeof value == "string" || typeof value == "bigint");
1776
+ let ulong = PbULong.from(value);
1777
+ if (ulong.isZero() && !ed)
1778
+ return void 0;
1779
+ return ulong.toString();
1780
+ // JSON value will be a decimal string. Either numbers or strings are accepted.
1781
+ case ScalarType.INT64:
1782
+ case ScalarType.SFIXED64:
1783
+ case ScalarType.SINT64:
1784
+ assert(typeof value == "number" || typeof value == "string" || typeof value == "bigint");
1785
+ let long = PbLong.from(value);
1786
+ if (long.isZero() && !ed)
1787
+ return void 0;
1788
+ return long.toString();
1789
+ // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
1790
+ // Either standard or URL-safe base64 encoding with/without paddings are accepted.
1791
+ case ScalarType.BYTES:
1792
+ assert(value instanceof Uint8Array);
1793
+ if (!value.byteLength)
1794
+ return ed ? "" : void 0;
1795
+ return base64encode(value);
1796
+ }
1797
+ }
1798
+ };
1799
+
1800
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-scalar-default.js
1801
+ function reflectionScalarDefault(type, longType = LongType.STRING) {
1802
+ switch (type) {
1803
+ case ScalarType.BOOL:
1804
+ return false;
1805
+ case ScalarType.UINT64:
1806
+ case ScalarType.FIXED64:
1807
+ return reflectionLongConvert(PbULong.ZERO, longType);
1808
+ case ScalarType.INT64:
1809
+ case ScalarType.SFIXED64:
1810
+ case ScalarType.SINT64:
1811
+ return reflectionLongConvert(PbLong.ZERO, longType);
1812
+ case ScalarType.DOUBLE:
1813
+ case ScalarType.FLOAT:
1814
+ return 0;
1815
+ case ScalarType.BYTES:
1816
+ return new Uint8Array(0);
1817
+ case ScalarType.STRING:
1818
+ return "";
1819
+ default:
1820
+ return 0;
1821
+ }
1822
+ }
1823
+
1824
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-binary-reader.js
1825
+ var ReflectionBinaryReader = class {
1826
+ constructor(info) {
1827
+ this.info = info;
1828
+ }
1829
+ prepare() {
1830
+ var _a;
1831
+ if (!this.fieldNoToField) {
1832
+ const fieldsInput = (_a = this.info.fields) !== null && _a !== void 0 ? _a : [];
1833
+ this.fieldNoToField = new Map(fieldsInput.map((field) => [field.no, field]));
1834
+ }
1835
+ }
1836
+ /**
1837
+ * Reads a message from binary format into the target message.
1838
+ *
1839
+ * Repeated fields are appended. Map entries are added, overwriting
1840
+ * existing keys.
1841
+ *
1842
+ * If a message field is already present, it will be merged with the
1843
+ * new data.
1844
+ */
1845
+ read(reader, message, options, length) {
1846
+ this.prepare();
1847
+ const end = length === void 0 ? reader.len : reader.pos + length;
1848
+ while (reader.pos < end) {
1849
+ const [fieldNo, wireType] = reader.tag(), field = this.fieldNoToField.get(fieldNo);
1850
+ if (!field) {
1851
+ let u = options.readUnknownField;
1852
+ if (u == "throw")
1853
+ throw new Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.info.typeName}`);
1854
+ let d = reader.skip(wireType);
1855
+ if (u !== false)
1856
+ (u === true ? UnknownFieldHandler.onRead : u)(this.info.typeName, message, fieldNo, wireType, d);
1857
+ continue;
1858
+ }
1859
+ let target = message, repeated = field.repeat, localName = field.localName;
1860
+ if (field.oneof) {
1861
+ target = target[field.oneof];
1862
+ if (target.oneofKind !== localName)
1863
+ target = message[field.oneof] = {
1864
+ oneofKind: localName
1865
+ };
1866
+ }
1867
+ switch (field.kind) {
1868
+ case "scalar":
1869
+ case "enum":
1870
+ let T = field.kind == "enum" ? ScalarType.INT32 : field.T;
1871
+ let L = field.kind == "scalar" ? field.L : void 0;
1872
+ if (repeated) {
1873
+ let arr = target[localName];
1874
+ if (wireType == WireType.LengthDelimited && T != ScalarType.STRING && T != ScalarType.BYTES) {
1875
+ let e = reader.uint32() + reader.pos;
1876
+ while (reader.pos < e)
1877
+ arr.push(this.scalar(reader, T, L));
1878
+ } else
1879
+ arr.push(this.scalar(reader, T, L));
1880
+ } else
1881
+ target[localName] = this.scalar(reader, T, L);
1882
+ break;
1883
+ case "message":
1884
+ if (repeated) {
1885
+ let arr = target[localName];
1886
+ let msg = field.T().internalBinaryRead(reader, reader.uint32(), options);
1887
+ arr.push(msg);
1888
+ } else
1889
+ target[localName] = field.T().internalBinaryRead(reader, reader.uint32(), options, target[localName]);
1890
+ break;
1891
+ case "map":
1892
+ let [mapKey, mapVal] = this.mapEntry(field, reader, options);
1893
+ target[localName][mapKey] = mapVal;
1894
+ break;
1895
+ }
1896
+ }
1897
+ }
1898
+ /**
1899
+ * Read a map field, expecting key field = 1, value field = 2
1900
+ */
1901
+ mapEntry(field, reader, options) {
1902
+ let length = reader.uint32();
1903
+ let end = reader.pos + length;
1904
+ let key = void 0;
1905
+ let val = void 0;
1906
+ while (reader.pos < end) {
1907
+ let [fieldNo, wireType] = reader.tag();
1908
+ switch (fieldNo) {
1909
+ case 1:
1910
+ if (field.K == ScalarType.BOOL)
1911
+ key = reader.bool().toString();
1912
+ else
1913
+ key = this.scalar(reader, field.K, LongType.STRING);
1914
+ break;
1915
+ case 2:
1916
+ switch (field.V.kind) {
1917
+ case "scalar":
1918
+ val = this.scalar(reader, field.V.T, field.V.L);
1919
+ break;
1920
+ case "enum":
1921
+ val = reader.int32();
1922
+ break;
1923
+ case "message":
1924
+ val = field.V.T().internalBinaryRead(reader, reader.uint32(), options);
1925
+ break;
1926
+ }
1927
+ break;
1928
+ default:
1929
+ throw new Error(`Unknown field ${fieldNo} (wire type ${wireType}) in map entry for ${this.info.typeName}#${field.name}`);
1930
+ }
1931
+ }
1932
+ if (key === void 0) {
1933
+ let keyRaw = reflectionScalarDefault(field.K);
1934
+ key = field.K == ScalarType.BOOL ? keyRaw.toString() : keyRaw;
1935
+ }
1936
+ if (val === void 0)
1937
+ switch (field.V.kind) {
1938
+ case "scalar":
1939
+ val = reflectionScalarDefault(field.V.T, field.V.L);
1940
+ break;
1941
+ case "enum":
1942
+ val = 0;
1943
+ break;
1944
+ case "message":
1945
+ val = field.V.T().create();
1946
+ break;
1947
+ }
1948
+ return [key, val];
1949
+ }
1950
+ scalar(reader, type, longType) {
1951
+ switch (type) {
1952
+ case ScalarType.INT32:
1953
+ return reader.int32();
1954
+ case ScalarType.STRING:
1955
+ return reader.string();
1956
+ case ScalarType.BOOL:
1957
+ return reader.bool();
1958
+ case ScalarType.DOUBLE:
1959
+ return reader.double();
1960
+ case ScalarType.FLOAT:
1961
+ return reader.float();
1962
+ case ScalarType.INT64:
1963
+ return reflectionLongConvert(reader.int64(), longType);
1964
+ case ScalarType.UINT64:
1965
+ return reflectionLongConvert(reader.uint64(), longType);
1966
+ case ScalarType.FIXED64:
1967
+ return reflectionLongConvert(reader.fixed64(), longType);
1968
+ case ScalarType.FIXED32:
1969
+ return reader.fixed32();
1970
+ case ScalarType.BYTES:
1971
+ return reader.bytes();
1972
+ case ScalarType.UINT32:
1973
+ return reader.uint32();
1974
+ case ScalarType.SFIXED32:
1975
+ return reader.sfixed32();
1976
+ case ScalarType.SFIXED64:
1977
+ return reflectionLongConvert(reader.sfixed64(), longType);
1978
+ case ScalarType.SINT32:
1979
+ return reader.sint32();
1980
+ case ScalarType.SINT64:
1981
+ return reflectionLongConvert(reader.sint64(), longType);
1982
+ }
1983
+ }
1984
+ };
1985
+
1986
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-binary-writer.js
1987
+ var ReflectionBinaryWriter = class {
1988
+ constructor(info) {
1989
+ this.info = info;
1990
+ }
1991
+ prepare() {
1992
+ if (!this.fields) {
1993
+ const fieldsInput = this.info.fields ? this.info.fields.concat() : [];
1994
+ this.fields = fieldsInput.sort((a, b) => a.no - b.no);
1995
+ }
1996
+ }
1997
+ /**
1998
+ * Writes the message to binary format.
1999
+ */
2000
+ write(message, writer, options) {
2001
+ this.prepare();
2002
+ for (const field of this.fields) {
2003
+ let value, emitDefault, repeated = field.repeat, localName = field.localName;
2004
+ if (field.oneof) {
2005
+ const group = message[field.oneof];
2006
+ if (group.oneofKind !== localName)
2007
+ continue;
2008
+ value = group[localName];
2009
+ emitDefault = true;
2010
+ } else {
2011
+ value = message[localName];
2012
+ emitDefault = false;
2013
+ }
2014
+ switch (field.kind) {
2015
+ case "scalar":
2016
+ case "enum":
2017
+ let T = field.kind == "enum" ? ScalarType.INT32 : field.T;
2018
+ if (repeated) {
2019
+ assert(Array.isArray(value));
2020
+ if (repeated == RepeatType.PACKED)
2021
+ this.packed(writer, T, field.no, value);
2022
+ else
2023
+ for (const item of value)
2024
+ this.scalar(writer, T, field.no, item, true);
2025
+ } else if (value === void 0)
2026
+ assert(field.opt);
2027
+ else
2028
+ this.scalar(writer, T, field.no, value, emitDefault || field.opt);
2029
+ break;
2030
+ case "message":
2031
+ if (repeated) {
2032
+ assert(Array.isArray(value));
2033
+ for (const item of value)
2034
+ this.message(writer, options, field.T(), field.no, item);
2035
+ } else {
2036
+ this.message(writer, options, field.T(), field.no, value);
2037
+ }
2038
+ break;
2039
+ case "map":
2040
+ assert(typeof value == "object" && value !== null);
2041
+ for (const [key, val] of Object.entries(value))
2042
+ this.mapEntry(writer, options, field, key, val);
2043
+ break;
2044
+ }
2045
+ }
2046
+ let u = options.writeUnknownFields;
2047
+ if (u !== false)
2048
+ (u === true ? UnknownFieldHandler.onWrite : u)(this.info.typeName, message, writer);
2049
+ }
2050
+ mapEntry(writer, options, field, key, value) {
2051
+ writer.tag(field.no, WireType.LengthDelimited);
2052
+ writer.fork();
2053
+ let keyValue = key;
2054
+ switch (field.K) {
2055
+ case ScalarType.INT32:
2056
+ case ScalarType.FIXED32:
2057
+ case ScalarType.UINT32:
2058
+ case ScalarType.SFIXED32:
2059
+ case ScalarType.SINT32:
2060
+ keyValue = Number.parseInt(key);
2061
+ break;
2062
+ case ScalarType.BOOL:
2063
+ assert(key == "true" || key == "false");
2064
+ keyValue = key == "true";
2065
+ break;
2066
+ }
2067
+ this.scalar(writer, field.K, 1, keyValue, true);
2068
+ switch (field.V.kind) {
2069
+ case "scalar":
2070
+ this.scalar(writer, field.V.T, 2, value, true);
2071
+ break;
2072
+ case "enum":
2073
+ this.scalar(writer, ScalarType.INT32, 2, value, true);
2074
+ break;
2075
+ case "message":
2076
+ this.message(writer, options, field.V.T(), 2, value);
2077
+ break;
2078
+ }
2079
+ writer.join();
2080
+ }
2081
+ message(writer, options, handler, fieldNo, value) {
2082
+ if (value === void 0)
2083
+ return;
2084
+ handler.internalBinaryWrite(value, writer.tag(fieldNo, WireType.LengthDelimited).fork(), options);
2085
+ writer.join();
2086
+ }
2087
+ /**
2088
+ * Write a single scalar value.
2089
+ */
2090
+ scalar(writer, type, fieldNo, value, emitDefault) {
2091
+ let [wireType, method, isDefault] = this.scalarInfo(type, value);
2092
+ if (!isDefault || emitDefault) {
2093
+ writer.tag(fieldNo, wireType);
2094
+ writer[method](value);
2095
+ }
2096
+ }
2097
+ /**
2098
+ * Write an array of scalar values in packed format.
2099
+ */
2100
+ packed(writer, type, fieldNo, value) {
2101
+ if (!value.length)
2102
+ return;
2103
+ assert(type !== ScalarType.BYTES && type !== ScalarType.STRING);
2104
+ writer.tag(fieldNo, WireType.LengthDelimited);
2105
+ writer.fork();
2106
+ let [, method] = this.scalarInfo(type);
2107
+ for (let i = 0; i < value.length; i++)
2108
+ writer[method](value[i]);
2109
+ writer.join();
2110
+ }
2111
+ /**
2112
+ * Get information for writing a scalar value.
2113
+ *
2114
+ * Returns tuple:
2115
+ * [0]: appropriate WireType
2116
+ * [1]: name of the appropriate method of IBinaryWriter
2117
+ * [2]: whether the given value is a default value
2118
+ *
2119
+ * If argument `value` is omitted, [2] is always false.
2120
+ */
2121
+ scalarInfo(type, value) {
2122
+ let t = WireType.Varint;
2123
+ let m;
2124
+ let i = value === void 0;
2125
+ let d = value === 0;
2126
+ switch (type) {
2127
+ case ScalarType.INT32:
2128
+ m = "int32";
2129
+ break;
2130
+ case ScalarType.STRING:
2131
+ d = i || !value.length;
2132
+ t = WireType.LengthDelimited;
2133
+ m = "string";
2134
+ break;
2135
+ case ScalarType.BOOL:
2136
+ d = value === false;
2137
+ m = "bool";
2138
+ break;
2139
+ case ScalarType.UINT32:
2140
+ m = "uint32";
2141
+ break;
2142
+ case ScalarType.DOUBLE:
2143
+ t = WireType.Bit64;
2144
+ m = "double";
2145
+ break;
2146
+ case ScalarType.FLOAT:
2147
+ t = WireType.Bit32;
2148
+ m = "float";
2149
+ break;
2150
+ case ScalarType.INT64:
2151
+ d = i || PbLong.from(value).isZero();
2152
+ m = "int64";
2153
+ break;
2154
+ case ScalarType.UINT64:
2155
+ d = i || PbULong.from(value).isZero();
2156
+ m = "uint64";
2157
+ break;
2158
+ case ScalarType.FIXED64:
2159
+ d = i || PbULong.from(value).isZero();
2160
+ t = WireType.Bit64;
2161
+ m = "fixed64";
2162
+ break;
2163
+ case ScalarType.BYTES:
2164
+ d = i || !value.byteLength;
2165
+ t = WireType.LengthDelimited;
2166
+ m = "bytes";
2167
+ break;
2168
+ case ScalarType.FIXED32:
2169
+ t = WireType.Bit32;
2170
+ m = "fixed32";
2171
+ break;
2172
+ case ScalarType.SFIXED32:
2173
+ t = WireType.Bit32;
2174
+ m = "sfixed32";
2175
+ break;
2176
+ case ScalarType.SFIXED64:
2177
+ d = i || PbLong.from(value).isZero();
2178
+ t = WireType.Bit64;
2179
+ m = "sfixed64";
2180
+ break;
2181
+ case ScalarType.SINT32:
2182
+ m = "sint32";
2183
+ break;
2184
+ case ScalarType.SINT64:
2185
+ d = i || PbLong.from(value).isZero();
2186
+ m = "sint64";
2187
+ break;
2188
+ }
2189
+ return [t, m, i || d];
2190
+ }
2191
+ };
2192
+
2193
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-create.js
2194
+ function reflectionCreate(type) {
2195
+ const msg = type.messagePrototype ? Object.create(type.messagePrototype) : Object.defineProperty({}, MESSAGE_TYPE, { value: type });
2196
+ for (let field of type.fields) {
2197
+ let name = field.localName;
2198
+ if (field.opt)
2199
+ continue;
2200
+ if (field.oneof)
2201
+ msg[field.oneof] = { oneofKind: void 0 };
2202
+ else if (field.repeat)
2203
+ msg[name] = [];
2204
+ else
2205
+ switch (field.kind) {
2206
+ case "scalar":
2207
+ msg[name] = reflectionScalarDefault(field.T, field.L);
2208
+ break;
2209
+ case "enum":
2210
+ msg[name] = 0;
2211
+ break;
2212
+ case "map":
2213
+ msg[name] = {};
2214
+ break;
2215
+ }
2216
+ }
2217
+ return msg;
2218
+ }
2219
+
2220
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-merge-partial.js
2221
+ function reflectionMergePartial(info, target, source) {
2222
+ let fieldValue, input = source, output;
2223
+ for (let field of info.fields) {
2224
+ let name = field.localName;
2225
+ if (field.oneof) {
2226
+ const group = input[field.oneof];
2227
+ if ((group === null || group === void 0 ? void 0 : group.oneofKind) == void 0) {
2228
+ continue;
2229
+ }
2230
+ fieldValue = group[name];
2231
+ output = target[field.oneof];
2232
+ output.oneofKind = group.oneofKind;
2233
+ if (fieldValue == void 0) {
2234
+ delete output[name];
2235
+ continue;
2236
+ }
2237
+ } else {
2238
+ fieldValue = input[name];
2239
+ output = target;
2240
+ if (fieldValue == void 0) {
2241
+ continue;
2242
+ }
2243
+ }
2244
+ if (field.repeat)
2245
+ output[name].length = fieldValue.length;
2246
+ switch (field.kind) {
2247
+ case "scalar":
2248
+ case "enum":
2249
+ if (field.repeat)
2250
+ for (let i = 0; i < fieldValue.length; i++)
2251
+ output[name][i] = fieldValue[i];
2252
+ else
2253
+ output[name] = fieldValue;
2254
+ break;
2255
+ case "message":
2256
+ let T = field.T();
2257
+ if (field.repeat)
2258
+ for (let i = 0; i < fieldValue.length; i++)
2259
+ output[name][i] = T.create(fieldValue[i]);
2260
+ else if (output[name] === void 0)
2261
+ output[name] = T.create(fieldValue);
2262
+ else
2263
+ T.mergePartial(output[name], fieldValue);
2264
+ break;
2265
+ case "map":
2266
+ switch (field.V.kind) {
2267
+ case "scalar":
2268
+ case "enum":
2269
+ Object.assign(output[name], fieldValue);
2270
+ break;
2271
+ case "message":
2272
+ let T2 = field.V.T();
2273
+ for (let k of Object.keys(fieldValue))
2274
+ output[name][k] = T2.create(fieldValue[k]);
2275
+ break;
2276
+ }
2277
+ break;
2278
+ }
2279
+ }
2280
+ }
2281
+
2282
+ // node_modules/@protobuf-ts/runtime/build/es2015/reflection-equals.js
2283
+ function reflectionEquals(info, a, b) {
2284
+ if (a === b)
2285
+ return true;
2286
+ if (!a || !b)
2287
+ return false;
2288
+ for (let field of info.fields) {
2289
+ let localName = field.localName;
2290
+ let val_a = field.oneof ? a[field.oneof][localName] : a[localName];
2291
+ let val_b = field.oneof ? b[field.oneof][localName] : b[localName];
2292
+ switch (field.kind) {
2293
+ case "enum":
2294
+ case "scalar":
2295
+ let t = field.kind == "enum" ? ScalarType.INT32 : field.T;
2296
+ if (!(field.repeat ? repeatedPrimitiveEq(t, val_a, val_b) : primitiveEq(t, val_a, val_b)))
2297
+ return false;
2298
+ break;
2299
+ case "map":
2300
+ if (!(field.V.kind == "message" ? repeatedMsgEq(field.V.T(), objectValues(val_a), objectValues(val_b)) : repeatedPrimitiveEq(field.V.kind == "enum" ? ScalarType.INT32 : field.V.T, objectValues(val_a), objectValues(val_b))))
2301
+ return false;
2302
+ break;
2303
+ case "message":
2304
+ let T = field.T();
2305
+ if (!(field.repeat ? repeatedMsgEq(T, val_a, val_b) : T.equals(val_a, val_b)))
2306
+ return false;
2307
+ break;
2308
+ }
2309
+ }
2310
+ return true;
2311
+ }
2312
+ var objectValues = Object.values;
2313
+ function primitiveEq(type, a, b) {
2314
+ if (a === b)
2315
+ return true;
2316
+ if (type !== ScalarType.BYTES)
2317
+ return false;
2318
+ let ba = a;
2319
+ let bb = b;
2320
+ if (ba.length !== bb.length)
2321
+ return false;
2322
+ for (let i = 0; i < ba.length; i++)
2323
+ if (ba[i] != bb[i])
2324
+ return false;
2325
+ return true;
2326
+ }
2327
+ function repeatedPrimitiveEq(type, a, b) {
2328
+ if (a.length !== b.length)
2329
+ return false;
2330
+ for (let i = 0; i < a.length; i++)
2331
+ if (!primitiveEq(type, a[i], b[i]))
2332
+ return false;
2333
+ return true;
2334
+ }
2335
+ function repeatedMsgEq(type, a, b) {
2336
+ if (a.length !== b.length)
2337
+ return false;
2338
+ for (let i = 0; i < a.length; i++)
2339
+ if (!type.equals(a[i], b[i]))
2340
+ return false;
2341
+ return true;
2342
+ }
2343
+
2344
+ // node_modules/@protobuf-ts/runtime/build/es2015/message-type.js
2345
+ var baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
2346
+ var MessageType = class {
2347
+ constructor(name, fields, options) {
2348
+ this.defaultCheckDepth = 16;
2349
+ this.typeName = name;
2350
+ this.fields = fields.map(normalizeFieldInfo);
2351
+ this.options = options !== null && options !== void 0 ? options : {};
2352
+ this.messagePrototype = Object.create(null, Object.assign(Object.assign({}, baseDescriptors), { [MESSAGE_TYPE]: { value: this } }));
2353
+ this.refTypeCheck = new ReflectionTypeCheck(this);
2354
+ this.refJsonReader = new ReflectionJsonReader(this);
2355
+ this.refJsonWriter = new ReflectionJsonWriter(this);
2356
+ this.refBinReader = new ReflectionBinaryReader(this);
2357
+ this.refBinWriter = new ReflectionBinaryWriter(this);
2358
+ }
2359
+ create(value) {
2360
+ let message = reflectionCreate(this);
2361
+ if (value !== void 0) {
2362
+ reflectionMergePartial(this, message, value);
2363
+ }
2364
+ return message;
2365
+ }
2366
+ /**
2367
+ * Clone the message.
2368
+ *
2369
+ * Unknown fields are discarded.
2370
+ */
2371
+ clone(message) {
2372
+ let copy = this.create();
2373
+ reflectionMergePartial(this, copy, message);
2374
+ return copy;
2375
+ }
2376
+ /**
2377
+ * Determines whether two message of the same type have the same field values.
2378
+ * Checks for deep equality, traversing repeated fields, oneof groups, maps
2379
+ * and messages recursively.
2380
+ * Will also return true if both messages are `undefined`.
2381
+ */
2382
+ equals(a, b) {
2383
+ return reflectionEquals(this, a, b);
2384
+ }
2385
+ /**
2386
+ * Is the given value assignable to our message type
2387
+ * and contains no [excess properties](https://www.typescriptlang.org/docs/handbook/interfaces.html#excess-property-checks)?
2388
+ */
2389
+ is(arg, depth = this.defaultCheckDepth) {
2390
+ return this.refTypeCheck.is(arg, depth, false);
2391
+ }
2392
+ /**
2393
+ * Is the given value assignable to our message type,
2394
+ * regardless of [excess properties](https://www.typescriptlang.org/docs/handbook/interfaces.html#excess-property-checks)?
2395
+ */
2396
+ isAssignable(arg, depth = this.defaultCheckDepth) {
2397
+ return this.refTypeCheck.is(arg, depth, true);
2398
+ }
2399
+ /**
2400
+ * Copy partial data into the target message.
2401
+ */
2402
+ mergePartial(target, source) {
2403
+ reflectionMergePartial(this, target, source);
2404
+ }
2405
+ /**
2406
+ * Create a new message from binary format.
2407
+ */
2408
+ fromBinary(data, options) {
2409
+ let opt = binaryReadOptions(options);
2410
+ return this.internalBinaryRead(opt.readerFactory(data), data.byteLength, opt);
2411
+ }
2412
+ /**
2413
+ * Read a new message from a JSON value.
2414
+ */
2415
+ fromJson(json, options) {
2416
+ return this.internalJsonRead(json, jsonReadOptions(options));
2417
+ }
2418
+ /**
2419
+ * Read a new message from a JSON string.
2420
+ * This is equivalent to `T.fromJson(JSON.parse(json))`.
2421
+ */
2422
+ fromJsonString(json, options) {
2423
+ let value = JSON.parse(json);
2424
+ return this.fromJson(value, options);
2425
+ }
2426
+ /**
2427
+ * Write the message to canonical JSON value.
2428
+ */
2429
+ toJson(message, options) {
2430
+ return this.internalJsonWrite(message, jsonWriteOptions(options));
2431
+ }
2432
+ /**
2433
+ * Convert the message to canonical JSON string.
2434
+ * This is equivalent to `JSON.stringify(T.toJson(t))`
2435
+ */
2436
+ toJsonString(message, options) {
2437
+ var _a;
2438
+ let value = this.toJson(message, options);
2439
+ return JSON.stringify(value, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0);
2440
+ }
2441
+ /**
2442
+ * Write the message to binary format.
2443
+ */
2444
+ toBinary(message, options) {
2445
+ let opt = binaryWriteOptions(options);
2446
+ return this.internalBinaryWrite(message, opt.writerFactory(), opt).finish();
2447
+ }
2448
+ /**
2449
+ * This is an internal method. If you just want to read a message from
2450
+ * JSON, use `fromJson()` or `fromJsonString()`.
2451
+ *
2452
+ * Reads JSON value and merges the fields into the target
2453
+ * according to protobuf rules. If the target is omitted,
2454
+ * a new instance is created first.
2455
+ */
2456
+ internalJsonRead(json, options, target) {
2457
+ if (json !== null && typeof json == "object" && !Array.isArray(json)) {
2458
+ let message = target !== null && target !== void 0 ? target : this.create();
2459
+ this.refJsonReader.read(json, message, options);
2460
+ return message;
2461
+ }
2462
+ throw new Error(`Unable to parse message ${this.typeName} from JSON ${typeofJsonValue(json)}.`);
2463
+ }
2464
+ /**
2465
+ * This is an internal method. If you just want to write a message
2466
+ * to JSON, use `toJson()` or `toJsonString().
2467
+ *
2468
+ * Writes JSON value and returns it.
2469
+ */
2470
+ internalJsonWrite(message, options) {
2471
+ return this.refJsonWriter.write(message, options);
2472
+ }
2473
+ /**
2474
+ * This is an internal method. If you just want to write a message
2475
+ * in binary format, use `toBinary()`.
2476
+ *
2477
+ * Serializes the message in binary format and appends it to the given
2478
+ * writer. Returns passed writer.
2479
+ */
2480
+ internalBinaryWrite(message, writer, options) {
2481
+ this.refBinWriter.write(message, writer, options);
2482
+ return writer;
2483
+ }
2484
+ /**
2485
+ * This is an internal method. If you just want to read a message from
2486
+ * binary data, use `fromBinary()`.
2487
+ *
2488
+ * Reads data from binary format and merges the fields into
2489
+ * the target according to protobuf rules. If the target is
2490
+ * omitted, a new instance is created first.
2491
+ */
2492
+ internalBinaryRead(reader, length, options, target) {
2493
+ let message = target !== null && target !== void 0 ? target : this.create();
2494
+ this.refBinReader.read(reader, message, options, length);
2495
+ return message;
2496
+ }
2497
+ };
2498
+
2499
+ // src/internal/az/azreq/grpc/v1/generated/google/protobuf/struct.ts
2500
+ var NullValue = /* @__PURE__ */ ((NullValue2) => {
2501
+ NullValue2[NullValue2["NULL_VALUE"] = 0] = "NULL_VALUE";
2502
+ return NullValue2;
2503
+ })(NullValue || {});
2504
+ var Struct$Type = class extends MessageType {
2505
+ constructor() {
2506
+ super("google.protobuf.Struct", [
2507
+ { no: 1, name: "fields", kind: "map", K: 9, V: { kind: "message", T: () => Value } }
2508
+ ]);
2509
+ }
2510
+ /**
2511
+ * Encode `Struct` to JSON object.
2512
+ */
2513
+ internalJsonWrite(message, options) {
2514
+ let json = {};
2515
+ for (let [k, v] of Object.entries(message.fields)) {
2516
+ json[k] = Value.toJson(v);
2517
+ }
2518
+ return json;
2519
+ }
2520
+ /**
2521
+ * Decode `Struct` from JSON object.
2522
+ */
2523
+ internalJsonRead(json, options, target) {
2524
+ if (!isJsonObject(json))
2525
+ throw new globalThis.Error("Unable to parse message " + this.typeName + " from JSON " + typeofJsonValue(json) + ".");
2526
+ if (!target)
2527
+ target = this.create();
2528
+ for (let [k, v] of globalThis.Object.entries(json)) {
2529
+ target.fields[k] = Value.fromJson(v);
2530
+ }
2531
+ return target;
2532
+ }
2533
+ create(value) {
2534
+ const message = globalThis.Object.create(this.messagePrototype);
2535
+ message.fields = {};
2536
+ if (value !== void 0)
2537
+ reflectionMergePartial(this, message, value);
2538
+ return message;
2539
+ }
2540
+ internalBinaryRead(reader, length, options, target) {
2541
+ let message = target != null ? target : this.create(), end = reader.pos + length;
2542
+ while (reader.pos < end) {
2543
+ let [fieldNo, wireType] = reader.tag();
2544
+ switch (fieldNo) {
2545
+ case /* map<string, google.protobuf.Value> fields */
2546
+ 1:
2547
+ this.binaryReadMap1(message.fields, reader, options);
2548
+ break;
2549
+ default:
2550
+ let u = options.readUnknownField;
2551
+ if (u === "throw")
2552
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
2553
+ let d = reader.skip(wireType);
2554
+ if (u !== false)
2555
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
2556
+ }
2557
+ }
2558
+ return message;
2559
+ }
2560
+ binaryReadMap1(map, reader, options) {
2561
+ let len = reader.uint32(), end = reader.pos + len, key, val;
2562
+ while (reader.pos < end) {
2563
+ let [fieldNo, wireType] = reader.tag();
2564
+ switch (fieldNo) {
2565
+ case 1:
2566
+ key = reader.string();
2567
+ break;
2568
+ case 2:
2569
+ val = Value.internalBinaryRead(reader, reader.uint32(), options);
2570
+ break;
2571
+ default:
2572
+ throw new globalThis.Error("unknown map entry field for field google.protobuf.Struct.fields");
2573
+ }
2574
+ }
2575
+ map[key != null ? key : ""] = val != null ? val : Value.create();
2576
+ }
2577
+ internalBinaryWrite(message, writer, options) {
2578
+ for (let k of globalThis.Object.keys(message.fields)) {
2579
+ writer.tag(1, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k);
2580
+ writer.tag(2, WireType.LengthDelimited).fork();
2581
+ Value.internalBinaryWrite(message.fields[k], writer, options);
2582
+ writer.join().join();
2583
+ }
2584
+ let u = options.writeUnknownFields;
2585
+ if (u !== false)
2586
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
2587
+ return writer;
2588
+ }
2589
+ };
2590
+ var Struct = new Struct$Type();
2591
+ var Value$Type = class extends MessageType {
2592
+ constructor() {
2593
+ super("google.protobuf.Value", [
2594
+ { no: 1, name: "null_value", kind: "enum", oneof: "kind", T: () => ["google.protobuf.NullValue", NullValue] },
2595
+ {
2596
+ no: 2,
2597
+ name: "number_value",
2598
+ kind: "scalar",
2599
+ oneof: "kind",
2600
+ T: 1
2601
+ /*ScalarType.DOUBLE*/
2602
+ },
2603
+ {
2604
+ no: 3,
2605
+ name: "string_value",
2606
+ kind: "scalar",
2607
+ oneof: "kind",
2608
+ T: 9
2609
+ /*ScalarType.STRING*/
2610
+ },
2611
+ {
2612
+ no: 4,
2613
+ name: "bool_value",
2614
+ kind: "scalar",
2615
+ oneof: "kind",
2616
+ T: 8
2617
+ /*ScalarType.BOOL*/
2618
+ },
2619
+ { no: 5, name: "struct_value", kind: "message", oneof: "kind", T: () => Struct },
2620
+ { no: 6, name: "list_value", kind: "message", oneof: "kind", T: () => ListValue }
2621
+ ]);
2622
+ }
2623
+ /**
2624
+ * Encode `Value` to JSON value.
2625
+ */
2626
+ internalJsonWrite(message, options) {
2627
+ if (message.kind.oneofKind === void 0)
2628
+ throw new globalThis.Error();
2629
+ switch (message.kind.oneofKind) {
2630
+ case void 0:
2631
+ throw new globalThis.Error();
2632
+ case "boolValue":
2633
+ return message.kind.boolValue;
2634
+ case "nullValue":
2635
+ return null;
2636
+ case "numberValue":
2637
+ let numberValue = message.kind.numberValue;
2638
+ if (typeof numberValue == "number" && !Number.isFinite(numberValue))
2639
+ throw new globalThis.Error();
2640
+ return numberValue;
2641
+ case "stringValue":
2642
+ return message.kind.stringValue;
2643
+ case "listValue":
2644
+ let listValueField = this.fields.find((f) => f.no === 6);
2645
+ if ((listValueField == null ? void 0 : listValueField.kind) !== "message")
2646
+ throw new globalThis.Error();
2647
+ return listValueField.T().toJson(message.kind.listValue);
2648
+ case "structValue":
2649
+ let structValueField = this.fields.find((f) => f.no === 5);
2650
+ if ((structValueField == null ? void 0 : structValueField.kind) !== "message")
2651
+ throw new globalThis.Error();
2652
+ return structValueField.T().toJson(message.kind.structValue);
2653
+ }
2654
+ }
2655
+ /**
2656
+ * Decode `Value` from JSON value.
2657
+ */
2658
+ internalJsonRead(json, options, target) {
2659
+ if (!target)
2660
+ target = this.create();
2661
+ switch (typeof json) {
2662
+ case "number":
2663
+ target.kind = { oneofKind: "numberValue", numberValue: json };
2664
+ break;
2665
+ case "string":
2666
+ target.kind = { oneofKind: "stringValue", stringValue: json };
2667
+ break;
2668
+ case "boolean":
2669
+ target.kind = { oneofKind: "boolValue", boolValue: json };
2670
+ break;
2671
+ case "object":
2672
+ if (json === null) {
2673
+ target.kind = { oneofKind: "nullValue", nullValue: 0 /* NULL_VALUE */ };
2674
+ } else if (globalThis.Array.isArray(json)) {
2675
+ target.kind = { oneofKind: "listValue", listValue: ListValue.fromJson(json) };
2676
+ } else {
2677
+ target.kind = { oneofKind: "structValue", structValue: Struct.fromJson(json) };
2678
+ }
2679
+ break;
2680
+ default:
2681
+ throw new globalThis.Error("Unable to parse " + this.typeName + " from JSON " + typeofJsonValue(json));
2682
+ }
2683
+ return target;
2684
+ }
2685
+ create(value) {
2686
+ const message = globalThis.Object.create(this.messagePrototype);
2687
+ message.kind = { oneofKind: void 0 };
2688
+ if (value !== void 0)
2689
+ reflectionMergePartial(this, message, value);
2690
+ return message;
2691
+ }
2692
+ internalBinaryRead(reader, length, options, target) {
2693
+ let message = target != null ? target : this.create(), end = reader.pos + length;
2694
+ while (reader.pos < end) {
2695
+ let [fieldNo, wireType] = reader.tag();
2696
+ switch (fieldNo) {
2697
+ case /* google.protobuf.NullValue null_value */
2698
+ 1:
2699
+ message.kind = {
2700
+ oneofKind: "nullValue",
2701
+ nullValue: reader.int32()
2702
+ };
2703
+ break;
2704
+ case /* double number_value */
2705
+ 2:
2706
+ message.kind = {
2707
+ oneofKind: "numberValue",
2708
+ numberValue: reader.double()
2709
+ };
2710
+ break;
2711
+ case /* string string_value */
2712
+ 3:
2713
+ message.kind = {
2714
+ oneofKind: "stringValue",
2715
+ stringValue: reader.string()
2716
+ };
2717
+ break;
2718
+ case /* bool bool_value */
2719
+ 4:
2720
+ message.kind = {
2721
+ oneofKind: "boolValue",
2722
+ boolValue: reader.bool()
2723
+ };
2724
+ break;
2725
+ case /* google.protobuf.Struct struct_value */
2726
+ 5:
2727
+ message.kind = {
2728
+ oneofKind: "structValue",
2729
+ structValue: Struct.internalBinaryRead(reader, reader.uint32(), options, message.kind.structValue)
2730
+ };
2731
+ break;
2732
+ case /* google.protobuf.ListValue list_value */
2733
+ 6:
2734
+ message.kind = {
2735
+ oneofKind: "listValue",
2736
+ listValue: ListValue.internalBinaryRead(reader, reader.uint32(), options, message.kind.listValue)
2737
+ };
2738
+ break;
2739
+ default:
2740
+ let u = options.readUnknownField;
2741
+ if (u === "throw")
2742
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
2743
+ let d = reader.skip(wireType);
2744
+ if (u !== false)
2745
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
2746
+ }
2747
+ }
2748
+ return message;
2749
+ }
2750
+ internalBinaryWrite(message, writer, options) {
2751
+ if (message.kind.oneofKind === "nullValue")
2752
+ writer.tag(1, WireType.Varint).int32(message.kind.nullValue);
2753
+ if (message.kind.oneofKind === "numberValue")
2754
+ writer.tag(2, WireType.Bit64).double(message.kind.numberValue);
2755
+ if (message.kind.oneofKind === "stringValue")
2756
+ writer.tag(3, WireType.LengthDelimited).string(message.kind.stringValue);
2757
+ if (message.kind.oneofKind === "boolValue")
2758
+ writer.tag(4, WireType.Varint).bool(message.kind.boolValue);
2759
+ if (message.kind.oneofKind === "structValue")
2760
+ Struct.internalBinaryWrite(message.kind.structValue, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
2761
+ if (message.kind.oneofKind === "listValue")
2762
+ ListValue.internalBinaryWrite(message.kind.listValue, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
2763
+ let u = options.writeUnknownFields;
2764
+ if (u !== false)
2765
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
2766
+ return writer;
2767
+ }
2768
+ };
2769
+ var Value = new Value$Type();
2770
+ var ListValue$Type = class extends MessageType {
2771
+ constructor() {
2772
+ super("google.protobuf.ListValue", [
2773
+ { no: 1, name: "values", kind: "message", repeat: 1, T: () => Value }
2774
+ ]);
2775
+ }
2776
+ /**
2777
+ * Encode `ListValue` to JSON array.
2778
+ */
2779
+ internalJsonWrite(message, options) {
2780
+ return message.values.map((v) => Value.toJson(v));
2781
+ }
2782
+ /**
2783
+ * Decode `ListValue` from JSON array.
2784
+ */
2785
+ internalJsonRead(json, options, target) {
2786
+ if (!globalThis.Array.isArray(json))
2787
+ throw new globalThis.Error("Unable to parse " + this.typeName + " from JSON " + typeofJsonValue(json));
2788
+ if (!target)
2789
+ target = this.create();
2790
+ let values = json.map((v) => Value.fromJson(v));
2791
+ target.values.push(...values);
2792
+ return target;
2793
+ }
2794
+ create(value) {
2795
+ const message = globalThis.Object.create(this.messagePrototype);
2796
+ message.values = [];
2797
+ if (value !== void 0)
2798
+ reflectionMergePartial(this, message, value);
2799
+ return message;
2800
+ }
2801
+ internalBinaryRead(reader, length, options, target) {
2802
+ let message = target != null ? target : this.create(), end = reader.pos + length;
2803
+ while (reader.pos < end) {
2804
+ let [fieldNo, wireType] = reader.tag();
2805
+ switch (fieldNo) {
2806
+ case /* repeated google.protobuf.Value values */
2807
+ 1:
2808
+ message.values.push(Value.internalBinaryRead(reader, reader.uint32(), options));
2809
+ break;
2810
+ default:
2811
+ let u = options.readUnknownField;
2812
+ if (u === "throw")
2813
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
2814
+ let d = reader.skip(wireType);
2815
+ if (u !== false)
2816
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
2817
+ }
2818
+ }
2819
+ return message;
2820
+ }
2821
+ internalBinaryWrite(message, writer, options) {
2822
+ for (let i = 0; i < message.values.length; i++)
2823
+ Value.internalBinaryWrite(message.values[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
2824
+ let u = options.writeUnknownFields;
2825
+ if (u !== false)
2826
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
2827
+ return writer;
2828
+ }
2829
+ };
2830
+ var ListValue = new ListValue$Type();
2831
+
2832
+ // src/internal/az/azreq/grpc/v1/generated/proto/v1/pdp.ts
2833
+ var PolicyStore$Type = class extends MessageType {
2834
+ constructor() {
2835
+ super("policydecisionpoint.PolicyStore", [
2836
+ {
2837
+ no: 1,
2838
+ name: "Kind",
2839
+ kind: "scalar",
2840
+ jsonName: "Kind",
2841
+ T: 9
2842
+ /*ScalarType.STRING*/
2843
+ },
2844
+ {
2845
+ no: 2,
2846
+ name: "ID",
2847
+ kind: "scalar",
2848
+ jsonName: "ID",
2849
+ T: 9
2850
+ /*ScalarType.STRING*/
2851
+ }
2852
+ ]);
2853
+ }
2854
+ create(value) {
2855
+ const message = globalThis.Object.create(this.messagePrototype);
2856
+ message.kind = "";
2857
+ message.iD = "";
2858
+ if (value !== void 0)
2859
+ reflectionMergePartial(this, message, value);
2860
+ return message;
2861
+ }
2862
+ internalBinaryRead(reader, length, options, target) {
2863
+ let message = target != null ? target : this.create(), end = reader.pos + length;
2864
+ while (reader.pos < end) {
2865
+ let [fieldNo, wireType] = reader.tag();
2866
+ switch (fieldNo) {
2867
+ case /* string Kind = 1 [json_name = "Kind"];*/
2868
+ 1:
2869
+ message.kind = reader.string();
2870
+ break;
2871
+ case /* string ID = 2 [json_name = "ID"];*/
2872
+ 2:
2873
+ message.iD = reader.string();
2874
+ break;
2875
+ default:
2876
+ let u = options.readUnknownField;
2877
+ if (u === "throw")
2878
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
2879
+ let d = reader.skip(wireType);
2880
+ if (u !== false)
2881
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
2882
+ }
2883
+ }
2884
+ return message;
2885
+ }
2886
+ internalBinaryWrite(message, writer, options) {
2887
+ if (message.kind !== "")
2888
+ writer.tag(1, WireType.LengthDelimited).string(message.kind);
2889
+ if (message.iD !== "")
2890
+ writer.tag(2, WireType.LengthDelimited).string(message.iD);
2891
+ let u = options.writeUnknownFields;
2892
+ if (u !== false)
2893
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
2894
+ return writer;
2895
+ }
2896
+ };
2897
+ var PolicyStore = new PolicyStore$Type();
2898
+ var Principal$Type = class extends MessageType {
2899
+ constructor() {
2900
+ super("policydecisionpoint.Principal", [
2901
+ {
2902
+ no: 1,
2903
+ name: "Type",
2904
+ kind: "scalar",
2905
+ jsonName: "Type",
2906
+ T: 9
2907
+ /*ScalarType.STRING*/
2908
+ },
2909
+ {
2910
+ no: 2,
2911
+ name: "ID",
2912
+ kind: "scalar",
2913
+ jsonName: "ID",
2914
+ T: 9
2915
+ /*ScalarType.STRING*/
2916
+ },
2917
+ {
2918
+ no: 3,
2919
+ name: "Source",
2920
+ kind: "scalar",
2921
+ jsonName: "Source",
2922
+ opt: true,
2923
+ T: 9
2924
+ /*ScalarType.STRING*/
2925
+ },
2926
+ {
2927
+ no: 4,
2928
+ name: "IdentityToken",
2929
+ kind: "scalar",
2930
+ jsonName: "IdentityToken",
2931
+ opt: true,
2932
+ T: 9
2933
+ /*ScalarType.STRING*/
2934
+ },
2935
+ {
2936
+ no: 5,
2937
+ name: "AccessToken",
2938
+ kind: "scalar",
2939
+ jsonName: "AccessToken",
2940
+ opt: true,
2941
+ T: 9
2942
+ /*ScalarType.STRING*/
2943
+ }
2944
+ ]);
2945
+ }
2946
+ create(value) {
2947
+ const message = globalThis.Object.create(this.messagePrototype);
2948
+ message.type = "";
2949
+ message.iD = "";
2950
+ if (value !== void 0)
2951
+ reflectionMergePartial(this, message, value);
2952
+ return message;
2953
+ }
2954
+ internalBinaryRead(reader, length, options, target) {
2955
+ let message = target != null ? target : this.create(), end = reader.pos + length;
2956
+ while (reader.pos < end) {
2957
+ let [fieldNo, wireType] = reader.tag();
2958
+ switch (fieldNo) {
2959
+ case /* string Type = 1 [json_name = "Type"];*/
2960
+ 1:
2961
+ message.type = reader.string();
2962
+ break;
2963
+ case /* string ID = 2 [json_name = "ID"];*/
2964
+ 2:
2965
+ message.iD = reader.string();
2966
+ break;
2967
+ case /* optional string Source = 3 [json_name = "Source"];*/
2968
+ 3:
2969
+ message.source = reader.string();
2970
+ break;
2971
+ case /* optional string IdentityToken = 4 [json_name = "IdentityToken"];*/
2972
+ 4:
2973
+ message.identityToken = reader.string();
2974
+ break;
2975
+ case /* optional string AccessToken = 5 [json_name = "AccessToken"];*/
2976
+ 5:
2977
+ message.accessToken = reader.string();
2978
+ break;
2979
+ default:
2980
+ let u = options.readUnknownField;
2981
+ if (u === "throw")
2982
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
2983
+ let d = reader.skip(wireType);
2984
+ if (u !== false)
2985
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
2986
+ }
2987
+ }
2988
+ return message;
2989
+ }
2990
+ internalBinaryWrite(message, writer, options) {
2991
+ if (message.type !== "")
2992
+ writer.tag(1, WireType.LengthDelimited).string(message.type);
2993
+ if (message.iD !== "")
2994
+ writer.tag(2, WireType.LengthDelimited).string(message.iD);
2995
+ if (message.source !== void 0)
2996
+ writer.tag(3, WireType.LengthDelimited).string(message.source);
2997
+ if (message.identityToken !== void 0)
2998
+ writer.tag(4, WireType.LengthDelimited).string(message.identityToken);
2999
+ if (message.accessToken !== void 0)
3000
+ writer.tag(5, WireType.LengthDelimited).string(message.accessToken);
3001
+ let u = options.writeUnknownFields;
3002
+ if (u !== false)
3003
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3004
+ return writer;
3005
+ }
3006
+ };
3007
+ var Principal = new Principal$Type();
3008
+ var Entities$Type = class extends MessageType {
3009
+ constructor() {
3010
+ super("policydecisionpoint.Entities", [
3011
+ {
3012
+ no: 1,
3013
+ name: "Schema",
3014
+ kind: "scalar",
3015
+ jsonName: "Schema",
3016
+ T: 9
3017
+ /*ScalarType.STRING*/
3018
+ },
3019
+ { no: 2, name: "Items", kind: "message", jsonName: "Items", repeat: 1, T: () => Struct }
3020
+ ]);
3021
+ }
3022
+ create(value) {
3023
+ const message = globalThis.Object.create(this.messagePrototype);
3024
+ message.schema = "";
3025
+ message.items = [];
3026
+ if (value !== void 0)
3027
+ reflectionMergePartial(this, message, value);
3028
+ return message;
3029
+ }
3030
+ internalBinaryRead(reader, length, options, target) {
3031
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3032
+ while (reader.pos < end) {
3033
+ let [fieldNo, wireType] = reader.tag();
3034
+ switch (fieldNo) {
3035
+ case /* string Schema = 1 [json_name = "Schema"];*/
3036
+ 1:
3037
+ message.schema = reader.string();
3038
+ break;
3039
+ case /* repeated google.protobuf.Struct Items = 2 [json_name = "Items"];*/
3040
+ 2:
3041
+ message.items.push(Struct.internalBinaryRead(reader, reader.uint32(), options));
3042
+ break;
3043
+ default:
3044
+ let u = options.readUnknownField;
3045
+ if (u === "throw")
3046
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3047
+ let d = reader.skip(wireType);
3048
+ if (u !== false)
3049
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3050
+ }
3051
+ }
3052
+ return message;
3053
+ }
3054
+ internalBinaryWrite(message, writer, options) {
3055
+ if (message.schema !== "")
3056
+ writer.tag(1, WireType.LengthDelimited).string(message.schema);
3057
+ for (let i = 0; i < message.items.length; i++)
3058
+ Struct.internalBinaryWrite(message.items[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join();
3059
+ let u = options.writeUnknownFields;
3060
+ if (u !== false)
3061
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3062
+ return writer;
3063
+ }
3064
+ };
3065
+ var Entities = new Entities$Type();
3066
+ var Subject$Type = class extends MessageType {
3067
+ constructor() {
3068
+ super("policydecisionpoint.Subject", [
3069
+ {
3070
+ no: 1,
3071
+ name: "Type",
3072
+ kind: "scalar",
3073
+ jsonName: "Type",
3074
+ T: 9
3075
+ /*ScalarType.STRING*/
3076
+ },
3077
+ {
3078
+ no: 2,
3079
+ name: "ID",
3080
+ kind: "scalar",
3081
+ jsonName: "ID",
3082
+ T: 9
3083
+ /*ScalarType.STRING*/
3084
+ },
3085
+ {
3086
+ no: 3,
3087
+ name: "Source",
3088
+ kind: "scalar",
3089
+ jsonName: "Source",
3090
+ opt: true,
3091
+ T: 9
3092
+ /*ScalarType.STRING*/
3093
+ },
3094
+ { no: 4, name: "Properties", kind: "message", jsonName: "Properties", T: () => Struct }
3095
+ ]);
3096
+ }
3097
+ create(value) {
3098
+ const message = globalThis.Object.create(this.messagePrototype);
3099
+ message.type = "";
3100
+ message.iD = "";
3101
+ if (value !== void 0)
3102
+ reflectionMergePartial(this, message, value);
3103
+ return message;
3104
+ }
3105
+ internalBinaryRead(reader, length, options, target) {
3106
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3107
+ while (reader.pos < end) {
3108
+ let [fieldNo, wireType] = reader.tag();
3109
+ switch (fieldNo) {
3110
+ case /* string Type = 1 [json_name = "Type"];*/
3111
+ 1:
3112
+ message.type = reader.string();
3113
+ break;
3114
+ case /* string ID = 2 [json_name = "ID"];*/
3115
+ 2:
3116
+ message.iD = reader.string();
3117
+ break;
3118
+ case /* optional string Source = 3 [json_name = "Source"];*/
3119
+ 3:
3120
+ message.source = reader.string();
3121
+ break;
3122
+ case /* optional google.protobuf.Struct Properties = 4 [json_name = "Properties"];*/
3123
+ 4:
3124
+ message.properties = Struct.internalBinaryRead(reader, reader.uint32(), options, message.properties);
3125
+ break;
3126
+ default:
3127
+ let u = options.readUnknownField;
3128
+ if (u === "throw")
3129
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3130
+ let d = reader.skip(wireType);
3131
+ if (u !== false)
3132
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3133
+ }
3134
+ }
3135
+ return message;
3136
+ }
3137
+ internalBinaryWrite(message, writer, options) {
3138
+ if (message.type !== "")
3139
+ writer.tag(1, WireType.LengthDelimited).string(message.type);
3140
+ if (message.iD !== "")
3141
+ writer.tag(2, WireType.LengthDelimited).string(message.iD);
3142
+ if (message.source !== void 0)
3143
+ writer.tag(3, WireType.LengthDelimited).string(message.source);
3144
+ if (message.properties)
3145
+ Struct.internalBinaryWrite(message.properties, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
3146
+ let u = options.writeUnknownFields;
3147
+ if (u !== false)
3148
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3149
+ return writer;
3150
+ }
3151
+ };
3152
+ var Subject = new Subject$Type();
3153
+ var Resource$Type = class extends MessageType {
3154
+ constructor() {
3155
+ super("policydecisionpoint.Resource", [
3156
+ {
3157
+ no: 1,
3158
+ name: "Type",
3159
+ kind: "scalar",
3160
+ jsonName: "Type",
3161
+ T: 9
3162
+ /*ScalarType.STRING*/
3163
+ },
3164
+ {
3165
+ no: 2,
3166
+ name: "ID",
3167
+ kind: "scalar",
3168
+ jsonName: "ID",
3169
+ T: 9
3170
+ /*ScalarType.STRING*/
3171
+ },
3172
+ { no: 3, name: "Properties", kind: "message", jsonName: "Properties", T: () => Struct }
3173
+ ]);
3174
+ }
3175
+ create(value) {
3176
+ const message = globalThis.Object.create(this.messagePrototype);
3177
+ message.type = "";
3178
+ message.iD = "";
3179
+ if (value !== void 0)
3180
+ reflectionMergePartial(this, message, value);
3181
+ return message;
3182
+ }
3183
+ internalBinaryRead(reader, length, options, target) {
3184
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3185
+ while (reader.pos < end) {
3186
+ let [fieldNo, wireType] = reader.tag();
3187
+ switch (fieldNo) {
3188
+ case /* string Type = 1 [json_name = "Type"];*/
3189
+ 1:
3190
+ message.type = reader.string();
3191
+ break;
3192
+ case /* string ID = 2 [json_name = "ID"];*/
3193
+ 2:
3194
+ message.iD = reader.string();
3195
+ break;
3196
+ case /* optional google.protobuf.Struct Properties = 3 [json_name = "Properties"];*/
3197
+ 3:
3198
+ message.properties = Struct.internalBinaryRead(reader, reader.uint32(), options, message.properties);
3199
+ break;
3200
+ default:
3201
+ let u = options.readUnknownField;
3202
+ if (u === "throw")
3203
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3204
+ let d = reader.skip(wireType);
3205
+ if (u !== false)
3206
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3207
+ }
3208
+ }
3209
+ return message;
3210
+ }
3211
+ internalBinaryWrite(message, writer, options) {
3212
+ if (message.type !== "")
3213
+ writer.tag(1, WireType.LengthDelimited).string(message.type);
3214
+ if (message.iD !== "")
3215
+ writer.tag(2, WireType.LengthDelimited).string(message.iD);
3216
+ if (message.properties)
3217
+ Struct.internalBinaryWrite(message.properties, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3218
+ let u = options.writeUnknownFields;
3219
+ if (u !== false)
3220
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3221
+ return writer;
3222
+ }
3223
+ };
3224
+ var Resource = new Resource$Type();
3225
+ var Action$Type = class extends MessageType {
3226
+ constructor() {
3227
+ super("policydecisionpoint.Action", [
3228
+ {
3229
+ no: 1,
3230
+ name: "Name",
3231
+ kind: "scalar",
3232
+ jsonName: "Name",
3233
+ T: 9
3234
+ /*ScalarType.STRING*/
3235
+ },
3236
+ { no: 2, name: "Properties", kind: "message", jsonName: "Properties", T: () => Struct }
3237
+ ]);
3238
+ }
3239
+ create(value) {
3240
+ const message = globalThis.Object.create(this.messagePrototype);
3241
+ message.name = "";
3242
+ if (value !== void 0)
3243
+ reflectionMergePartial(this, message, value);
3244
+ return message;
3245
+ }
3246
+ internalBinaryRead(reader, length, options, target) {
3247
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3248
+ while (reader.pos < end) {
3249
+ let [fieldNo, wireType] = reader.tag();
3250
+ switch (fieldNo) {
3251
+ case /* string Name = 1 [json_name = "Name"];*/
3252
+ 1:
3253
+ message.name = reader.string();
3254
+ break;
3255
+ case /* optional google.protobuf.Struct Properties = 2 [json_name = "Properties"];*/
3256
+ 2:
3257
+ message.properties = Struct.internalBinaryRead(reader, reader.uint32(), options, message.properties);
3258
+ break;
3259
+ default:
3260
+ let u = options.readUnknownField;
3261
+ if (u === "throw")
3262
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3263
+ let d = reader.skip(wireType);
3264
+ if (u !== false)
3265
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3266
+ }
3267
+ }
3268
+ return message;
3269
+ }
3270
+ internalBinaryWrite(message, writer, options) {
3271
+ if (message.name !== "")
3272
+ writer.tag(1, WireType.LengthDelimited).string(message.name);
3273
+ if (message.properties)
3274
+ Struct.internalBinaryWrite(message.properties, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
3275
+ let u = options.writeUnknownFields;
3276
+ if (u !== false)
3277
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3278
+ return writer;
3279
+ }
3280
+ };
3281
+ var Action = new Action$Type();
3282
+ var AuthorizationModelRequest$Type = class extends MessageType {
3283
+ constructor() {
3284
+ super("policydecisionpoint.AuthorizationModelRequest", [
3285
+ {
3286
+ no: 1,
3287
+ name: "ZoneID",
3288
+ kind: "scalar",
3289
+ jsonName: "ZoneID",
3290
+ T: 3,
3291
+ L: 0
3292
+ /*LongType.BIGINT*/
3293
+ },
3294
+ { no: 2, name: "PolicyStore", kind: "message", jsonName: "PolicyStore", T: () => PolicyStore },
3295
+ { no: 3, name: "Principal", kind: "message", jsonName: "Principal", T: () => Principal },
3296
+ { no: 4, name: "Entities", kind: "message", jsonName: "Entities", T: () => Entities }
3297
+ ]);
3298
+ }
3299
+ create(value) {
3300
+ const message = globalThis.Object.create(this.messagePrototype);
3301
+ message.zoneID = /* @__PURE__ */ BigInt("0");
3302
+ if (value !== void 0)
3303
+ reflectionMergePartial(this, message, value);
3304
+ return message;
3305
+ }
3306
+ internalBinaryRead(reader, length, options, target) {
3307
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3308
+ while (reader.pos < end) {
3309
+ let [fieldNo, wireType] = reader.tag();
3310
+ switch (fieldNo) {
3311
+ case /* int64 ZoneID = 1 [json_name = "ZoneID"];*/
3312
+ 1:
3313
+ message.zoneID = reader.int64().toBigInt();
3314
+ break;
3315
+ case /* policydecisionpoint.PolicyStore PolicyStore = 2 [json_name = "PolicyStore"];*/
3316
+ 2:
3317
+ message.policyStore = PolicyStore.internalBinaryRead(reader, reader.uint32(), options, message.policyStore);
3318
+ break;
3319
+ case /* optional policydecisionpoint.Principal Principal = 3 [json_name = "Principal"];*/
3320
+ 3:
3321
+ message.principal = Principal.internalBinaryRead(reader, reader.uint32(), options, message.principal);
3322
+ break;
3323
+ case /* optional policydecisionpoint.Entities Entities = 4 [json_name = "Entities"];*/
3324
+ 4:
3325
+ message.entities = Entities.internalBinaryRead(reader, reader.uint32(), options, message.entities);
3326
+ break;
3327
+ default:
3328
+ let u = options.readUnknownField;
3329
+ if (u === "throw")
3330
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3331
+ let d = reader.skip(wireType);
3332
+ if (u !== false)
3333
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3334
+ }
3335
+ }
3336
+ return message;
3337
+ }
3338
+ internalBinaryWrite(message, writer, options) {
3339
+ if (message.zoneID !== /* @__PURE__ */ BigInt("0"))
3340
+ writer.tag(1, WireType.Varint).int64(message.zoneID);
3341
+ if (message.policyStore)
3342
+ PolicyStore.internalBinaryWrite(message.policyStore, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
3343
+ if (message.principal)
3344
+ Principal.internalBinaryWrite(message.principal, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3345
+ if (message.entities)
3346
+ Entities.internalBinaryWrite(message.entities, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
3347
+ let u = options.writeUnknownFields;
3348
+ if (u !== false)
3349
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3350
+ return writer;
3351
+ }
3352
+ };
3353
+ var AuthorizationModelRequest = new AuthorizationModelRequest$Type();
3354
+ var EvaluationRequest$Type = class extends MessageType {
3355
+ constructor() {
3356
+ super("policydecisionpoint.EvaluationRequest", [
3357
+ {
3358
+ no: 1,
3359
+ name: "RequestID",
3360
+ kind: "scalar",
3361
+ jsonName: "RequestID",
3362
+ opt: true,
3363
+ T: 9
3364
+ /*ScalarType.STRING*/
3365
+ },
3366
+ { no: 2, name: "Subject", kind: "message", jsonName: "Subject", T: () => Subject },
3367
+ { no: 3, name: "Resource", kind: "message", jsonName: "Resource", T: () => Resource },
3368
+ { no: 4, name: "Action", kind: "message", jsonName: "Action", T: () => Action },
3369
+ { no: 5, name: "Context", kind: "message", jsonName: "Context", T: () => Struct }
3370
+ ]);
3371
+ }
3372
+ create(value) {
3373
+ const message = globalThis.Object.create(this.messagePrototype);
3374
+ if (value !== void 0)
3375
+ reflectionMergePartial(this, message, value);
3376
+ return message;
3377
+ }
3378
+ internalBinaryRead(reader, length, options, target) {
3379
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3380
+ while (reader.pos < end) {
3381
+ let [fieldNo, wireType] = reader.tag();
3382
+ switch (fieldNo) {
3383
+ case /* optional string RequestID = 1 [json_name = "RequestID"];*/
3384
+ 1:
3385
+ message.requestID = reader.string();
3386
+ break;
3387
+ case /* optional policydecisionpoint.Subject Subject = 2 [json_name = "Subject"];*/
3388
+ 2:
3389
+ message.subject = Subject.internalBinaryRead(reader, reader.uint32(), options, message.subject);
3390
+ break;
3391
+ case /* optional policydecisionpoint.Resource Resource = 3 [json_name = "Resource"];*/
3392
+ 3:
3393
+ message.resource = Resource.internalBinaryRead(reader, reader.uint32(), options, message.resource);
3394
+ break;
3395
+ case /* optional policydecisionpoint.Action Action = 4 [json_name = "Action"];*/
3396
+ 4:
3397
+ message.action = Action.internalBinaryRead(reader, reader.uint32(), options, message.action);
3398
+ break;
3399
+ case /* optional google.protobuf.Struct Context = 5 [json_name = "Context"];*/
3400
+ 5:
3401
+ message.context = Struct.internalBinaryRead(reader, reader.uint32(), options, message.context);
3402
+ break;
3403
+ default:
3404
+ let u = options.readUnknownField;
3405
+ if (u === "throw")
3406
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3407
+ let d = reader.skip(wireType);
3408
+ if (u !== false)
3409
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3410
+ }
3411
+ }
3412
+ return message;
3413
+ }
3414
+ internalBinaryWrite(message, writer, options) {
3415
+ if (message.requestID !== void 0)
3416
+ writer.tag(1, WireType.LengthDelimited).string(message.requestID);
3417
+ if (message.subject)
3418
+ Subject.internalBinaryWrite(message.subject, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
3419
+ if (message.resource)
3420
+ Resource.internalBinaryWrite(message.resource, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3421
+ if (message.action)
3422
+ Action.internalBinaryWrite(message.action, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
3423
+ if (message.context)
3424
+ Struct.internalBinaryWrite(message.context, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
3425
+ let u = options.writeUnknownFields;
3426
+ if (u !== false)
3427
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3428
+ return writer;
3429
+ }
3430
+ };
3431
+ var EvaluationRequest = new EvaluationRequest$Type();
3432
+ var AuthorizationCheckRequest$Type = class extends MessageType {
3433
+ constructor() {
3434
+ super("policydecisionpoint.AuthorizationCheckRequest", [
3435
+ { no: 1, name: "AuthorizationModel", kind: "message", jsonName: "AuthorizationModel", T: () => AuthorizationModelRequest },
3436
+ {
3437
+ no: 2,
3438
+ name: "RequestID",
3439
+ kind: "scalar",
3440
+ jsonName: "RequestID",
3441
+ opt: true,
3442
+ T: 9
3443
+ /*ScalarType.STRING*/
3444
+ },
3445
+ { no: 3, name: "Subject", kind: "message", jsonName: "Subject", T: () => Subject },
3446
+ { no: 4, name: "Resource", kind: "message", jsonName: "Resource", T: () => Resource },
3447
+ { no: 5, name: "Action", kind: "message", jsonName: "Action", T: () => Action },
3448
+ { no: 6, name: "Context", kind: "message", jsonName: "Context", T: () => Struct },
3449
+ { no: 7, name: "Evaluations", kind: "message", jsonName: "Evaluations", repeat: 1, T: () => EvaluationRequest }
3450
+ ]);
3451
+ }
3452
+ create(value) {
3453
+ const message = globalThis.Object.create(this.messagePrototype);
3454
+ message.evaluations = [];
3455
+ if (value !== void 0)
3456
+ reflectionMergePartial(this, message, value);
3457
+ return message;
3458
+ }
3459
+ internalBinaryRead(reader, length, options, target) {
3460
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3461
+ while (reader.pos < end) {
3462
+ let [fieldNo, wireType] = reader.tag();
3463
+ switch (fieldNo) {
3464
+ case /* policydecisionpoint.AuthorizationModelRequest AuthorizationModel = 1 [json_name = "AuthorizationModel"];*/
3465
+ 1:
3466
+ message.authorizationModel = AuthorizationModelRequest.internalBinaryRead(reader, reader.uint32(), options, message.authorizationModel);
3467
+ break;
3468
+ case /* optional string RequestID = 2 [json_name = "RequestID"];*/
3469
+ 2:
3470
+ message.requestID = reader.string();
3471
+ break;
3472
+ case /* optional policydecisionpoint.Subject Subject = 3 [json_name = "Subject"];*/
3473
+ 3:
3474
+ message.subject = Subject.internalBinaryRead(reader, reader.uint32(), options, message.subject);
3475
+ break;
3476
+ case /* optional policydecisionpoint.Resource Resource = 4 [json_name = "Resource"];*/
3477
+ 4:
3478
+ message.resource = Resource.internalBinaryRead(reader, reader.uint32(), options, message.resource);
3479
+ break;
3480
+ case /* optional policydecisionpoint.Action Action = 5 [json_name = "Action"];*/
3481
+ 5:
3482
+ message.action = Action.internalBinaryRead(reader, reader.uint32(), options, message.action);
3483
+ break;
3484
+ case /* optional google.protobuf.Struct Context = 6 [json_name = "Context"];*/
3485
+ 6:
3486
+ message.context = Struct.internalBinaryRead(reader, reader.uint32(), options, message.context);
3487
+ break;
3488
+ case /* repeated policydecisionpoint.EvaluationRequest Evaluations = 7 [json_name = "Evaluations"];*/
3489
+ 7:
3490
+ message.evaluations.push(EvaluationRequest.internalBinaryRead(reader, reader.uint32(), options));
3491
+ break;
3492
+ default:
3493
+ let u = options.readUnknownField;
3494
+ if (u === "throw")
3495
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3496
+ let d = reader.skip(wireType);
3497
+ if (u !== false)
3498
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3499
+ }
3500
+ }
3501
+ return message;
3502
+ }
3503
+ internalBinaryWrite(message, writer, options) {
3504
+ if (message.authorizationModel)
3505
+ AuthorizationModelRequest.internalBinaryWrite(message.authorizationModel, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
3506
+ if (message.requestID !== void 0)
3507
+ writer.tag(2, WireType.LengthDelimited).string(message.requestID);
3508
+ if (message.subject)
3509
+ Subject.internalBinaryWrite(message.subject, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3510
+ if (message.resource)
3511
+ Resource.internalBinaryWrite(message.resource, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
3512
+ if (message.action)
3513
+ Action.internalBinaryWrite(message.action, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
3514
+ if (message.context)
3515
+ Struct.internalBinaryWrite(message.context, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
3516
+ for (let i = 0; i < message.evaluations.length; i++)
3517
+ EvaluationRequest.internalBinaryWrite(message.evaluations[i], writer.tag(7, WireType.LengthDelimited).fork(), options).join();
3518
+ let u = options.writeUnknownFields;
3519
+ if (u !== false)
3520
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3521
+ return writer;
3522
+ }
3523
+ };
3524
+ var AuthorizationCheckRequest = new AuthorizationCheckRequest$Type();
3525
+ var ReasonResponse$Type = class extends MessageType {
3526
+ constructor() {
3527
+ super("policydecisionpoint.ReasonResponse", [
3528
+ {
3529
+ no: 1,
3530
+ name: "Code",
3531
+ kind: "scalar",
3532
+ jsonName: "Code",
3533
+ T: 9
3534
+ /*ScalarType.STRING*/
3535
+ },
3536
+ {
3537
+ no: 2,
3538
+ name: "Message",
3539
+ kind: "scalar",
3540
+ jsonName: "Message",
3541
+ T: 9
3542
+ /*ScalarType.STRING*/
3543
+ }
3544
+ ]);
3545
+ }
3546
+ create(value) {
3547
+ const message = globalThis.Object.create(this.messagePrototype);
3548
+ message.code = "";
3549
+ message.message = "";
3550
+ if (value !== void 0)
3551
+ reflectionMergePartial(this, message, value);
3552
+ return message;
3553
+ }
3554
+ internalBinaryRead(reader, length, options, target) {
3555
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3556
+ while (reader.pos < end) {
3557
+ let [fieldNo, wireType] = reader.tag();
3558
+ switch (fieldNo) {
3559
+ case /* string Code = 1 [json_name = "Code"];*/
3560
+ 1:
3561
+ message.code = reader.string();
3562
+ break;
3563
+ case /* string Message = 2 [json_name = "Message"];*/
3564
+ 2:
3565
+ message.message = reader.string();
3566
+ break;
3567
+ default:
3568
+ let u = options.readUnknownField;
3569
+ if (u === "throw")
3570
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3571
+ let d = reader.skip(wireType);
3572
+ if (u !== false)
3573
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3574
+ }
3575
+ }
3576
+ return message;
3577
+ }
3578
+ internalBinaryWrite(message, writer, options) {
3579
+ if (message.code !== "")
3580
+ writer.tag(1, WireType.LengthDelimited).string(message.code);
3581
+ if (message.message !== "")
3582
+ writer.tag(2, WireType.LengthDelimited).string(message.message);
3583
+ let u = options.writeUnknownFields;
3584
+ if (u !== false)
3585
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3586
+ return writer;
3587
+ }
3588
+ };
3589
+ var ReasonResponse = new ReasonResponse$Type();
3590
+ var ContextResponse$Type = class extends MessageType {
3591
+ constructor() {
3592
+ super("policydecisionpoint.ContextResponse", [
3593
+ {
3594
+ no: 1,
3595
+ name: "ID",
3596
+ kind: "scalar",
3597
+ jsonName: "ID",
3598
+ T: 9
3599
+ /*ScalarType.STRING*/
3600
+ },
3601
+ { no: 2, name: "ReasonAdmin", kind: "message", jsonName: "ReasonAdmin", T: () => ReasonResponse },
3602
+ { no: 3, name: "ReasonUser", kind: "message", jsonName: "ReasonUser", T: () => ReasonResponse }
3603
+ ]);
3604
+ }
3605
+ create(value) {
3606
+ const message = globalThis.Object.create(this.messagePrototype);
3607
+ message.iD = "";
3608
+ if (value !== void 0)
3609
+ reflectionMergePartial(this, message, value);
3610
+ return message;
3611
+ }
3612
+ internalBinaryRead(reader, length, options, target) {
3613
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3614
+ while (reader.pos < end) {
3615
+ let [fieldNo, wireType] = reader.tag();
3616
+ switch (fieldNo) {
3617
+ case /* string ID = 1 [json_name = "ID"];*/
3618
+ 1:
3619
+ message.iD = reader.string();
3620
+ break;
3621
+ case /* policydecisionpoint.ReasonResponse ReasonAdmin = 2 [json_name = "ReasonAdmin"];*/
3622
+ 2:
3623
+ message.reasonAdmin = ReasonResponse.internalBinaryRead(reader, reader.uint32(), options, message.reasonAdmin);
3624
+ break;
3625
+ case /* policydecisionpoint.ReasonResponse ReasonUser = 3 [json_name = "ReasonUser"];*/
3626
+ 3:
3627
+ message.reasonUser = ReasonResponse.internalBinaryRead(reader, reader.uint32(), options, message.reasonUser);
3628
+ break;
3629
+ default:
3630
+ let u = options.readUnknownField;
3631
+ if (u === "throw")
3632
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3633
+ let d = reader.skip(wireType);
3634
+ if (u !== false)
3635
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3636
+ }
3637
+ }
3638
+ return message;
3639
+ }
3640
+ internalBinaryWrite(message, writer, options) {
3641
+ if (message.iD !== "")
3642
+ writer.tag(1, WireType.LengthDelimited).string(message.iD);
3643
+ if (message.reasonAdmin)
3644
+ ReasonResponse.internalBinaryWrite(message.reasonAdmin, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
3645
+ if (message.reasonUser)
3646
+ ReasonResponse.internalBinaryWrite(message.reasonUser, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3647
+ let u = options.writeUnknownFields;
3648
+ if (u !== false)
3649
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3650
+ return writer;
3651
+ }
3652
+ };
3653
+ var ContextResponse = new ContextResponse$Type();
3654
+ var EvaluationResponse$Type = class extends MessageType {
3655
+ constructor() {
3656
+ super("policydecisionpoint.EvaluationResponse", [
3657
+ {
3658
+ no: 1,
3659
+ name: "Decision",
3660
+ kind: "scalar",
3661
+ jsonName: "Decision",
3662
+ T: 8
3663
+ /*ScalarType.BOOL*/
3664
+ },
3665
+ {
3666
+ no: 2,
3667
+ name: "RequestID",
3668
+ kind: "scalar",
3669
+ jsonName: "RequestID",
3670
+ opt: true,
3671
+ T: 9
3672
+ /*ScalarType.STRING*/
3673
+ },
3674
+ { no: 3, name: "Context", kind: "message", jsonName: "Context", T: () => ContextResponse }
3675
+ ]);
3676
+ }
3677
+ create(value) {
3678
+ const message = globalThis.Object.create(this.messagePrototype);
3679
+ message.decision = false;
3680
+ if (value !== void 0)
3681
+ reflectionMergePartial(this, message, value);
3682
+ return message;
3683
+ }
3684
+ internalBinaryRead(reader, length, options, target) {
3685
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3686
+ while (reader.pos < end) {
3687
+ let [fieldNo, wireType] = reader.tag();
3688
+ switch (fieldNo) {
3689
+ case /* bool Decision = 1 [json_name = "Decision"];*/
3690
+ 1:
3691
+ message.decision = reader.bool();
3692
+ break;
3693
+ case /* optional string RequestID = 2 [json_name = "RequestID"];*/
3694
+ 2:
3695
+ message.requestID = reader.string();
3696
+ break;
3697
+ case /* optional policydecisionpoint.ContextResponse Context = 3 [json_name = "Context"];*/
3698
+ 3:
3699
+ message.context = ContextResponse.internalBinaryRead(reader, reader.uint32(), options, message.context);
3700
+ break;
3701
+ default:
3702
+ let u = options.readUnknownField;
3703
+ if (u === "throw")
3704
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3705
+ let d = reader.skip(wireType);
3706
+ if (u !== false)
3707
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3708
+ }
3709
+ }
3710
+ return message;
3711
+ }
3712
+ internalBinaryWrite(message, writer, options) {
3713
+ if (message.decision !== false)
3714
+ writer.tag(1, WireType.Varint).bool(message.decision);
3715
+ if (message.requestID !== void 0)
3716
+ writer.tag(2, WireType.LengthDelimited).string(message.requestID);
3717
+ if (message.context)
3718
+ ContextResponse.internalBinaryWrite(message.context, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3719
+ let u = options.writeUnknownFields;
3720
+ if (u !== false)
3721
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3722
+ return writer;
3723
+ }
3724
+ };
3725
+ var EvaluationResponse = new EvaluationResponse$Type();
3726
+ var AuthorizationCheckResponse$Type = class extends MessageType {
3727
+ constructor() {
3728
+ super("policydecisionpoint.AuthorizationCheckResponse", [
3729
+ {
3730
+ no: 1,
3731
+ name: "Decision",
3732
+ kind: "scalar",
3733
+ jsonName: "Decision",
3734
+ T: 8
3735
+ /*ScalarType.BOOL*/
3736
+ },
3737
+ {
3738
+ no: 2,
3739
+ name: "RequestID",
3740
+ kind: "scalar",
3741
+ jsonName: "RequestID",
3742
+ opt: true,
3743
+ T: 9
3744
+ /*ScalarType.STRING*/
3745
+ },
3746
+ { no: 3, name: "Context", kind: "message", jsonName: "Context", T: () => ContextResponse },
3747
+ { no: 4, name: "Evaluations", kind: "message", jsonName: "Evaluations", repeat: 1, T: () => EvaluationResponse }
3748
+ ]);
3749
+ }
3750
+ create(value) {
3751
+ const message = globalThis.Object.create(this.messagePrototype);
3752
+ message.decision = false;
3753
+ message.evaluations = [];
3754
+ if (value !== void 0)
3755
+ reflectionMergePartial(this, message, value);
3756
+ return message;
3757
+ }
3758
+ internalBinaryRead(reader, length, options, target) {
3759
+ let message = target != null ? target : this.create(), end = reader.pos + length;
3760
+ while (reader.pos < end) {
3761
+ let [fieldNo, wireType] = reader.tag();
3762
+ switch (fieldNo) {
3763
+ case /* bool Decision = 1 [json_name = "Decision"];*/
3764
+ 1:
3765
+ message.decision = reader.bool();
3766
+ break;
3767
+ case /* optional string RequestID = 2 [json_name = "RequestID"];*/
3768
+ 2:
3769
+ message.requestID = reader.string();
3770
+ break;
3771
+ case /* optional policydecisionpoint.ContextResponse Context = 3 [json_name = "Context"];*/
3772
+ 3:
3773
+ message.context = ContextResponse.internalBinaryRead(reader, reader.uint32(), options, message.context);
3774
+ break;
3775
+ case /* repeated policydecisionpoint.EvaluationResponse Evaluations = 4 [json_name = "Evaluations"];*/
3776
+ 4:
3777
+ message.evaluations.push(EvaluationResponse.internalBinaryRead(reader, reader.uint32(), options));
3778
+ break;
3779
+ default:
3780
+ let u = options.readUnknownField;
3781
+ if (u === "throw")
3782
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3783
+ let d = reader.skip(wireType);
3784
+ if (u !== false)
3785
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3786
+ }
3787
+ }
3788
+ return message;
3789
+ }
3790
+ internalBinaryWrite(message, writer, options) {
3791
+ if (message.decision !== false)
3792
+ writer.tag(1, WireType.Varint).bool(message.decision);
3793
+ if (message.requestID !== void 0)
3794
+ writer.tag(2, WireType.LengthDelimited).string(message.requestID);
3795
+ if (message.context)
3796
+ ContextResponse.internalBinaryWrite(message.context, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
3797
+ for (let i = 0; i < message.evaluations.length; i++)
3798
+ EvaluationResponse.internalBinaryWrite(message.evaluations[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join();
3799
+ let u = options.writeUnknownFields;
3800
+ if (u !== false)
3801
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3802
+ return writer;
3803
+ }
3804
+ };
3805
+ var AuthorizationCheckResponse = new AuthorizationCheckResponse$Type();
3806
+ var V1PDPService = new import_runtime_rpc.ServiceType("policydecisionpoint.V1PDPService", [
3807
+ { name: "AuthorizationCheck", options: {}, I: AuthorizationCheckRequest, O: AuthorizationCheckResponse }
3808
+ ]);
3809
+
3810
+ // src/internal/az/azreq/grpc/v1/generated/proto/v1/pdp.client.ts
3811
+ var import_runtime_rpc2 = require("@protobuf-ts/runtime-rpc");
3812
+ var V1PDPServiceClient = class {
3813
+ constructor(_transport) {
3814
+ this._transport = _transport;
3815
+ this.typeName = V1PDPService.typeName;
3816
+ this.methods = V1PDPService.methods;
3817
+ this.options = V1PDPService.options;
3818
+ }
3819
+ /**
3820
+ * @generated from protobuf rpc: AuthorizationCheck(policydecisionpoint.AuthorizationCheckRequest) returns (policydecisionpoint.AuthorizationCheckResponse);
3821
+ */
3822
+ authorizationCheck(input, options) {
3823
+ const method = this.methods[0], opt = this._transport.mergeOptions(options);
3824
+ return (0, import_runtime_rpc2.stackIntercept)("unary", this._transport, method, opt, input);
3825
+ }
3826
+ };
3827
+
3828
+ // src/internal/az/azreq/grpc/v1/pdp_grpc_mapper.ts
3829
+ function mapPolicyStoreToGrpcPolicyStore(policyStore) {
3830
+ if (!policyStore) return null;
3831
+ return PolicyStore.create({
3832
+ kind: policyStore.kind,
3833
+ iD: policyStore.id
3834
+ });
3835
+ }
3836
+ function mapPrincipalToGrpcPrincipal(principal) {
3837
+ if (!principal) return null;
3838
+ return Principal.create({
3839
+ type: principal.type,
3840
+ iD: principal.id,
3841
+ source: principal.source
3842
+ });
3843
+ }
3844
+ function mapEntitiesToGrpcEntities(entities) {
3845
+ var _a;
3846
+ if (!entities) return null;
3847
+ return Entities.create({
3848
+ schema: entities.schema,
3849
+ items: (_a = entities.items) == null ? void 0 : _a.map((item) => Struct.fromJson(item))
3850
+ });
3851
+ }
3852
+ function mapSubjectToGrpcSubject(subject) {
3853
+ if (!subject) return null;
3854
+ return Subject.create({
3855
+ type: subject.type,
3856
+ iD: subject.id,
3857
+ source: subject.source,
3858
+ properties: subject.properties ? Struct.fromJson(subject.properties) : void 0
3859
+ });
3860
+ }
3861
+ function mapResourceToGrpcResource(resource) {
3862
+ if (!resource) return null;
3863
+ return Resource.create({
3864
+ type: resource.type,
3865
+ iD: resource.id,
3866
+ properties: resource.properties ? Struct.fromJson(resource.properties) : void 0
3867
+ });
3868
+ }
3869
+ function mapActionToGrpcAction(action) {
3870
+ if (!action) return null;
3871
+ return Action.create({
3872
+ name: action.name,
3873
+ properties: action.properties ? Struct.fromJson(action.properties) : void 0
3874
+ });
3875
+ }
3876
+ function mapEvaluationToGrpcEvaluationRequest(evaluation) {
3877
+ var _a, _b, _c;
3878
+ if (!evaluation) return null;
3879
+ return EvaluationRequest.create({
3880
+ requestID: evaluation.request_id,
3881
+ subject: evaluation.subject ? (_a = mapSubjectToGrpcSubject(evaluation.subject)) != null ? _a : void 0 : void 0,
3882
+ resource: evaluation.resource ? (_b = mapResourceToGrpcResource(evaluation.resource)) != null ? _b : void 0 : void 0,
3883
+ action: evaluation.action ? (_c = mapActionToGrpcAction(evaluation.action)) != null ? _c : void 0 : void 0,
3884
+ context: evaluation.context ? Struct.fromJson(evaluation.context) : void 0
3885
+ });
3886
+ }
3887
+ function mapAuthZModelToGrpcAuthorizationModelRequest(azModel) {
3888
+ var _a, _b, _c;
3889
+ if (!azModel) return null;
3890
+ return AuthorizationModelRequest.create({
3891
+ zoneID: BigInt(azModel.zone_id),
3892
+ policyStore: azModel.policy_store ? (_a = mapPolicyStoreToGrpcPolicyStore(azModel.policy_store)) != null ? _a : void 0 : void 0,
3893
+ principal: azModel.principal ? (_b = mapPrincipalToGrpcPrincipal(azModel.principal)) != null ? _b : void 0 : void 0,
3894
+ entities: azModel.entities ? (_c = mapEntitiesToGrpcEntities(azModel.entities)) != null ? _c : void 0 : void 0
3895
+ });
3896
+ }
3897
+ function mapAZRequestToGrpcAuthorizationCheckRequest(azRequest) {
3898
+ var _a, _b, _c, _d, _e;
3899
+ return AuthorizationCheckRequest.create({
3900
+ requestID: azRequest.request_id,
3901
+ authorizationModel: azRequest.authorization_model ? (_a = mapAuthZModelToGrpcAuthorizationModelRequest(
3902
+ azRequest.authorization_model
3903
+ )) != null ? _a : void 0 : void 0,
3904
+ subject: azRequest.subject ? (_b = mapSubjectToGrpcSubject(azRequest.subject)) != null ? _b : void 0 : void 0,
3905
+ resource: azRequest.resource ? (_c = mapResourceToGrpcResource(azRequest.resource)) != null ? _c : void 0 : void 0,
3906
+ action: azRequest.action ? (_d = mapActionToGrpcAction(azRequest.action)) != null ? _d : void 0 : void 0,
3907
+ context: azRequest.context ? Struct.fromJson(azRequest.context) : void 0,
3908
+ evaluations: (_e = azRequest.evaluations) == null ? void 0 : _e.map(
3909
+ (evaluation) => mapEvaluationToGrpcEvaluationRequest(evaluation)
3910
+ )
3911
+ });
3912
+ }
3913
+ function mapGrpcReasonResponseToReasonResponse(reasonResponse) {
3914
+ if (!reasonResponse) return null;
3915
+ return {
3916
+ Code: reasonResponse.code,
3917
+ Message: reasonResponse.message
3918
+ };
3919
+ }
3920
+ function mapGrpcContextResponseToContextResponse(contextResponse) {
3921
+ if (!contextResponse) return null;
3922
+ return {
3923
+ ID: contextResponse.iD,
3924
+ ReasonAdmin: contextResponse.reasonAdmin ? mapGrpcReasonResponseToReasonResponse(contextResponse.reasonAdmin) : void 0,
3925
+ ReasonUser: contextResponse.reasonUser ? mapGrpcReasonResponseToReasonResponse(contextResponse.reasonUser) : null
3926
+ };
3927
+ }
3928
+ function mapGrpcEvaluationResponseToEvaluationResponse(evaluationResponse) {
3929
+ if (!evaluationResponse) return null;
3930
+ return {
3931
+ Decision: evaluationResponse.decision,
3932
+ RequestID: evaluationResponse.requestID || "",
3933
+ Context: evaluationResponse.context ? mapGrpcContextResponseToContextResponse(evaluationResponse.context) : void 0
3934
+ };
3935
+ }
3936
+ function mapGrpcAuthorizationCheckResponseToAZResponse(response) {
3937
+ var _a;
3938
+ return {
3939
+ Decision: response.decision,
3940
+ RequestID: response.requestID || "",
3941
+ Context: response.context ? mapGrpcContextResponseToContextResponse(response.context) : void 0,
3942
+ Evaluations: (_a = response.evaluations) == null ? void 0 : _a.map(
3943
+ (evaluation) => mapGrpcEvaluationResponseToEvaluationResponse(evaluation)
3944
+ )
3945
+ };
3946
+ }
3947
+
3948
+ // src/internal/az/azreq/grpc/v1/pdp_client.ts
3949
+ var import_runtime_rpc3 = require("@protobuf-ts/runtime-rpc");
3950
+ var import_grpc_transport = require("@protobuf-ts/grpc-transport");
3951
+ var import_grpc_js = require("@grpc/grpc-js");
3952
+ var PDPClient = class {
3953
+ /**
3954
+ * Creates a new PDPClient.
3955
+ * @param endpoint - The gRPC server endpoint.
3956
+ */
3957
+ constructor(endpoint) {
3958
+ const transport = new import_grpc_transport.GrpcTransport({
3959
+ host: endpoint,
3960
+ channelCredentials: import_grpc_js.ChannelCredentials.createInsecure()
3961
+ });
3962
+ this.client = new V1PDPServiceClient(transport);
3963
+ }
3964
+ /**
3965
+ * Checks the authorization request with the PDP service.
3966
+ * @param request - The authorization request.
3967
+ * @returns A promise that resolves to the authorization response.
3968
+ */
3969
+ async authorizationCheck(request) {
3970
+ if (!request) {
3971
+ throw new Error("Invalid request: request cannot be null or undefined");
3972
+ }
3973
+ const grpcRequest = mapAZRequestToGrpcAuthorizationCheckRequest(request);
3974
+ try {
3975
+ const response = await this.client.authorizationCheck(grpcRequest).response;
3976
+ return mapGrpcAuthorizationCheckResponseToAZResponse(response);
3977
+ } catch (err) {
3978
+ if (err instanceof import_runtime_rpc3.RpcError) {
3979
+ throw new Error(`gRPC call failed: ${err.message}`);
3980
+ }
3981
+ throw err;
3982
+ }
3983
+ }
3984
+ };
3985
+
3986
+ // src/azclient.ts
3987
+ var AZClient = class {
3988
+ /**
3989
+ * Creates a new AZClient.
3990
+ * @param opts - Optional configuration options.
3991
+ */
3992
+ constructor(...opts) {
3993
+ this.azConfig = {
3994
+ pdpEndpoint: {
3995
+ endpoint: "localhost",
3996
+ port: 9094
3997
+ }
3998
+ };
3999
+ opts.forEach((opt) => opt(this.azConfig));
4000
+ }
4001
+ /**
4002
+ * Checks the input authorization request with the authorization server.
4003
+ * @param req - The authorization request.
4004
+ * @returns A tuple containing:
4005
+ * - A boolean indicating the decision (true if authorized, false otherwise).
4006
+ * - The full authorization response.
4007
+ * - An error, if any.
4008
+ */
4009
+ async check(req) {
4010
+ var _a, _b;
4011
+ const target = `${(_a = this.azConfig.pdpEndpoint) == null ? void 0 : _a.endpoint}:${(_b = this.azConfig.pdpEndpoint) == null ? void 0 : _b.port}`;
4012
+ const pdpClient = new PDPClient(target);
4013
+ try {
4014
+ const response = await pdpClient.authorizationCheck(req);
4015
+ return { decision: response.Decision, response, error: null };
4016
+ } catch (err) {
4017
+ const error = err instanceof Error ? err : new Error(String(err));
4018
+ return { decision: false, response: null, error };
4019
+ }
4020
+ }
4021
+ };
4022
+
4023
+ // src/az/azreq/builder_action.ts
4024
+ var import_lodash = __toESM(require("lodash"));
4025
+ var ActionBuilder = class {
4026
+ /**
4027
+ * Creates a new ActionBuilder instance.
4028
+ * @param name - The name of the action.
4029
+ */
4030
+ constructor(name) {
4031
+ this.action = {
4032
+ name
4033
+ };
4034
+ }
4035
+ /**
4036
+ * Sets a property of the action.
4037
+ * @param key - The property key.
4038
+ * @param value - The property value.
4039
+ * @returns The ActionBuilder instance for method chaining.
4040
+ */
4041
+ withProperty(key, value) {
4042
+ if (!this.action.properties) {
4043
+ this.action.properties = {};
4044
+ }
4045
+ this.action.properties[key] = value;
4046
+ return this;
4047
+ }
4048
+ /**
4049
+ * Builds the Action object.
4050
+ * @returns The constructed Action object.
4051
+ */
4052
+ build() {
4053
+ return import_lodash.default.cloneDeep(this.action);
4054
+ }
4055
+ };
4056
+
4057
+ // src/az/azreq/builder_context.ts
4058
+ var import_lodash2 = __toESM(require("lodash"));
4059
+ var ContextBuilder = class {
4060
+ /**
4061
+ * Creates a new ContextBuilder instance.
4062
+ */
4063
+ constructor() {
4064
+ this.context = {};
4065
+ }
4066
+ /**
4067
+ * Sets a property of the context.
4068
+ * @param key - The property key.
4069
+ * @param value - The property value.
4070
+ * @returns The ContextBuilder instance for method chaining.
4071
+ */
4072
+ withProperty(key, value) {
4073
+ if (!this.context) {
4074
+ this.context = {};
4075
+ }
4076
+ this.context[key] = value;
4077
+ return this;
4078
+ }
4079
+ /**
4080
+ * Builds the Context object.
4081
+ * @returns The constructed Context object (a map of key-value pairs).
4082
+ */
4083
+ build() {
4084
+ return import_lodash2.default.cloneDeep(this.context);
4085
+ }
4086
+ };
4087
+
4088
+ // src/az/azreq/builder_evaluation.ts
4089
+ var import_lodash3 = __toESM(require("lodash"));
4090
+ var EvaluationBuilder = class {
4091
+ /**
4092
+ * Creates a new EvaluationBuilder instance.
4093
+ * @param subject - The subject of the evaluation.
4094
+ * @param resource - The resource of the evaluation.
4095
+ * @param action - The action of the evaluation.
4096
+ */
4097
+ constructor(subject, resource, action) {
4098
+ this.azEvaluation = {
4099
+ subject,
4100
+ resource,
4101
+ action
4102
+ };
4103
+ }
4104
+ /**
4105
+ * Sets the request ID of the evaluation.
4106
+ * @param requestID - The request ID.
4107
+ * @returns The EvaluationBuilder instance for method chaining.
4108
+ */
4109
+ withRequestID(requestID) {
4110
+ this.azEvaluation.request_id = requestID;
4111
+ return this;
4112
+ }
4113
+ /**
4114
+ * Sets the context of the evaluation.
4115
+ * @param context - The context (a map of key-value pairs).
4116
+ * @returns The EvaluationBuilder instance for method chaining.
4117
+ */
4118
+ withContext(context) {
4119
+ this.azEvaluation.context = context;
4120
+ return this;
4121
+ }
4122
+ /**
4123
+ * Builds the Evaluation object.
4124
+ * @returns The constructed Evaluation object.
4125
+ */
4126
+ build() {
4127
+ return import_lodash3.default.cloneDeep(this.azEvaluation);
4128
+ }
4129
+ };
4130
+
4131
+ // src/az/azreq/builder_principal.ts
4132
+ var import_lodash4 = __toESM(require("lodash"));
4133
+ var PrincipalDefaultKind = "user";
4134
+ var PrincipalBuilder = class {
4135
+ /**
4136
+ * Creates a new PrincipalBuilder instance.
4137
+ * @param id - The ID of the principal.
4138
+ */
4139
+ constructor(id) {
4140
+ this.principal = {
4141
+ type: PrincipalDefaultKind,
4142
+ id
4143
+ };
4144
+ }
4145
+ /**
4146
+ * Sets the kind of the principal.
4147
+ * @param kind - The kind of the principal.
4148
+ * @returns The PrincipalBuilder instance for method chaining.
4149
+ */
4150
+ withKind(kind) {
4151
+ this.principal.type = kind;
4152
+ return this;
4153
+ }
4154
+ /**
4155
+ * Sets the source of the principal.
4156
+ * @param source - The source of the principal.
4157
+ * @returns The PrincipalBuilder instance for method chaining.
4158
+ */
4159
+ withSource(source) {
4160
+ this.principal.source = source;
4161
+ return this;
4162
+ }
4163
+ /**
4164
+ * Builds the Principal object.
4165
+ * @returns The constructed Principal object.
4166
+ */
4167
+ build() {
4168
+ return import_lodash4.default.cloneDeep(this.principal);
4169
+ }
4170
+ };
4171
+
4172
+ // src/az/azreq/builder_request_composed.ts
4173
+ var import_lodash5 = __toESM(require("lodash"));
4174
+ var AZRequestBuilder = class {
4175
+ /**
4176
+ * Creates a new AZRequestBuilder instance.
4177
+ * @param zoneID - The zone ID.
4178
+ * @param ledgerID - The ledger ID.
4179
+ */
4180
+ constructor(zoneID, ledgerID) {
4181
+ this.azRequest = {
4182
+ authorization_model: {
4183
+ zone_id: zoneID,
4184
+ policy_store: {
4185
+ kind: "ledger",
4186
+ id: ledgerID
4187
+ },
4188
+ entities: {
4189
+ schema: "",
4190
+ items: []
4191
+ }
4192
+ },
4193
+ evaluations: []
4194
+ };
4195
+ }
4196
+ /**
4197
+ * Sets the principal of the AZRequest.
4198
+ * @param principal - The principal object.
4199
+ * @returns The AZRequestBuilder instance for method chaining.
4200
+ */
4201
+ withPrincipal(principal) {
4202
+ this.azRequest.authorization_model.principal = principal;
4203
+ return this;
4204
+ }
4205
+ /**
4206
+ * Sets the request ID of the AZRequest.
4207
+ * @param requestID - The request ID.
4208
+ * @returns The AZRequestBuilder instance for method chaining.
4209
+ */
4210
+ withRequestID(requestID) {
4211
+ this.azRequest.request_id = requestID;
4212
+ return this;
4213
+ }
4214
+ /**
4215
+ * Sets the subject of the AZRequest.
4216
+ * @param subject - The subject object.
4217
+ * @returns The AZRequestBuilder instance for method chaining.
4218
+ */
4219
+ withSubject(subject) {
4220
+ this.azRequest.subject = subject;
4221
+ return this;
4222
+ }
4223
+ /**
4224
+ * Sets the resource of the AZRequest.
4225
+ * @param resource - The resource object.
4226
+ * @returns The AZRequestBuilder instance for method chaining.
4227
+ */
4228
+ withResource(resource) {
4229
+ this.azRequest.resource = resource;
4230
+ return this;
4231
+ }
4232
+ /**
4233
+ * Sets the action of the AZRequest.
4234
+ * @param action - The action object.
4235
+ * @returns The AZRequestBuilder instance for method chaining.
4236
+ */
4237
+ withAction(action) {
4238
+ this.azRequest.action = action;
4239
+ return this;
4240
+ }
4241
+ /**
4242
+ * Sets the context of the AZRequest.
4243
+ * @param context - The context object (a map of key-value pairs).
4244
+ * @returns The AZRequestBuilder instance for method chaining.
4245
+ */
4246
+ withContext(context) {
4247
+ this.azRequest.context = context;
4248
+ return this;
4249
+ }
4250
+ /**
4251
+ * Sets the entities map to the AZRequest.
4252
+ * @param schema - The schema of the entities.
4253
+ * @param entities - The entities map.
4254
+ * @returns The AZRequestBuilder instance for method chaining.
4255
+ */
4256
+ withEntitiesMap(schema, entities) {
4257
+ this.azRequest.authorization_model.entities.schema = schema;
4258
+ this.azRequest.authorization_model.entities.items = [entities];
4259
+ return this;
4260
+ }
4261
+ /**
4262
+ * Sets the entities items to the AZRequest.
4263
+ * @param schema - The schema of the entities.
4264
+ * @param entities - The entities items (array of maps).
4265
+ * @returns The AZRequestBuilder instance for method chaining.
4266
+ */
4267
+ withEntitiesItems(schema, entities) {
4268
+ this.azRequest.authorization_model.entities.schema = schema;
4269
+ this.azRequest.authorization_model.entities.items = entities;
4270
+ if (!this.azRequest.authorization_model.entities.items) {
4271
+ this.azRequest.authorization_model.entities.items = [];
4272
+ }
4273
+ return this;
4274
+ }
4275
+ /**
4276
+ * Adds an evaluation to the AZRequest.
4277
+ * @param evaluation - The evaluation object.
4278
+ * @returns The AZRequestBuilder instance for method chaining.
4279
+ */
4280
+ withEvaluation(evaluation) {
4281
+ var _a;
4282
+ (_a = this.azRequest.evaluations) == null ? void 0 : _a.push(evaluation);
4283
+ return this;
4284
+ }
4285
+ /**
4286
+ * Builds the AZRequest object.
4287
+ * @returns The constructed AZRequest object.
4288
+ */
4289
+ build() {
4290
+ return import_lodash5.default.cloneDeep(this.azRequest);
4291
+ }
4292
+ };
4293
+
4294
+ // src/az/azreq/model.ts
4295
+ var ActorType = /* @__PURE__ */ ((ActorType2) => {
4296
+ ActorType2["UserType"] = "USER";
4297
+ ActorType2["RoleActorType"] = "ROLE-ACTOR";
4298
+ ActorType2["TwinActorType"] = "TWIN-ACTOR";
4299
+ return ActorType2;
4300
+ })(ActorType || {});
4301
+
4302
+ // src/az/azreq/builder_subject.ts
4303
+ var import_lodash6 = __toESM(require("lodash"));
4304
+ var SubjectDefaultKind = "user";
4305
+ var SubjectBuilder = class {
4306
+ /**
4307
+ * Creates a new SubjectBuilder instance.
4308
+ * @param id - The ID of the subject.
4309
+ */
4310
+ constructor(id) {
4311
+ this.subject = {
4312
+ type: SubjectDefaultKind,
4313
+ id
4314
+ };
4315
+ }
4316
+ /**
4317
+ * Sets the kind of the subject.
4318
+ * @param kind - The kind of the subject.
4319
+ * @returns The SubjectBuilder instance for method chaining.
4320
+ */
4321
+ withKind(kind) {
4322
+ this.subject.type = kind;
4323
+ return this;
4324
+ }
4325
+ /**
4326
+ * Sets the source of the subject.
4327
+ * @param source - The source of the subject.
4328
+ * @returns The SubjectBuilder instance for method chaining.
4329
+ */
4330
+ withSource(source) {
4331
+ this.subject.source = source;
4332
+ return this;
4333
+ }
4334
+ /**
4335
+ * Sets a property of the subject.
4336
+ * @param key - The property key.
4337
+ * @param value - The property value.
4338
+ * @returns The SubjectBuilder instance for method chaining.
4339
+ */
4340
+ withProperty(key, value) {
4341
+ if (!this.subject.properties) {
4342
+ this.subject.properties = {};
4343
+ }
4344
+ this.subject.properties[key] = value;
4345
+ return this;
4346
+ }
4347
+ /**
4348
+ * Sets the type of the subject to UserType.
4349
+ * @returns The SubjectBuilder instance for method chaining.
4350
+ */
4351
+ withUserType() {
4352
+ this.subject.type = "USER" /* UserType */;
4353
+ return this;
4354
+ }
4355
+ /**
4356
+ * Sets the type of the subject to RoleActorType.
4357
+ * @returns The SubjectBuilder instance for method chaining.
4358
+ */
4359
+ withRoleActorType() {
4360
+ this.subject.type = "ROLE-ACTOR" /* RoleActorType */;
4361
+ return this;
4362
+ }
4363
+ /**
4364
+ * Sets the type of the subject to TwinActorType.
4365
+ * @returns The SubjectBuilder instance for method chaining.
4366
+ */
4367
+ withTwinActorType() {
4368
+ this.subject.type = "TWIN-ACTOR" /* TwinActorType */;
4369
+ return this;
4370
+ }
4371
+ /**
4372
+ * Sets the type of the subject.
4373
+ * @param subType - The type of the subject.
4374
+ * @returns The SubjectBuilder instance for method chaining.
4375
+ */
4376
+ withType(subType) {
4377
+ this.subject.type = subType;
4378
+ return this;
4379
+ }
4380
+ /**
4381
+ * Builds the Subject object.
4382
+ * @returns The constructed Subject object.
4383
+ */
4384
+ build() {
4385
+ return import_lodash6.default.cloneDeep(this.subject);
4386
+ }
4387
+ };
4388
+
4389
+ // src/az/azreq/builder_resource.ts
4390
+ var import_lodash7 = __toESM(require("lodash"));
4391
+ var ResourceBuilder = class {
4392
+ /**
4393
+ * Creates a new ResourceBuilder instance.
4394
+ * @param kind - The kind (type) of the resource.
4395
+ */
4396
+ constructor(kind) {
4397
+ this.resource = {
4398
+ type: kind
4399
+ };
4400
+ }
4401
+ /**
4402
+ * Sets the ID of the resource.
4403
+ * @param id - The ID of the resource.
4404
+ * @returns The ResourceBuilder instance for method chaining.
4405
+ */
4406
+ withID(id) {
4407
+ this.resource.id = id;
4408
+ return this;
4409
+ }
4410
+ /**
4411
+ * Sets a property of the resource.
4412
+ * @param key - The property key.
4413
+ * @param value - The property value.
4414
+ * @returns The ResourceBuilder instance for method chaining.
4415
+ */
4416
+ withProperty(key, value) {
4417
+ if (!this.resource.properties) {
4418
+ this.resource.properties = {};
4419
+ }
4420
+ this.resource.properties[key] = value;
4421
+ return this;
4422
+ }
4423
+ /**
4424
+ * Builds the Resource object.
4425
+ * @returns The constructed Resource object.
4426
+ */
4427
+ build() {
4428
+ return import_lodash7.default.cloneDeep(this.resource);
4429
+ }
4430
+ };
4431
+
4432
+ // src/az/azreq/builder_request_atomic.ts
4433
+ var AZAtomicRequestBuilder = class {
4434
+ /**
4435
+ * Creates a new AZAtomicRequestBuilder instance.
4436
+ * @param zoneID - The zone ID.
4437
+ * @param ledgerID - The ledger ID.
4438
+ * @param subjectID - The subject ID.
4439
+ * @param resourceKind - The resource kind.
4440
+ * @param actionName - The action name.
4441
+ */
4442
+ constructor(zoneID, ledgerID, subjectID, resourceKind, actionName) {
4443
+ this.azRequestBuilder = new AZRequestBuilder(zoneID, ledgerID);
4444
+ this.azSubjectBuilder = new SubjectBuilder(subjectID);
4445
+ this.azResourceBuilder = new ResourceBuilder(resourceKind);
4446
+ this.azActionBuilder = new ActionBuilder(actionName);
4447
+ this.azContextBuilder = new ContextBuilder();
4448
+ }
4449
+ /**
4450
+ * Sets the entities map to the AZRequest.
4451
+ * @param schema - The schema of the entities.
4452
+ * @param entities - The entities map.
4453
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4454
+ */
4455
+ withEntitiesMap(schema, entities) {
4456
+ this.azRequestBuilder.withEntitiesMap(schema, entities);
4457
+ return this;
4458
+ }
4459
+ /**
4460
+ * Sets the entities items to the AZRequest.
4461
+ * @param schema - The schema of the entities.
4462
+ * @param entities - The entities items.
4463
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4464
+ */
4465
+ withEntitiesItems(schema, entities) {
4466
+ this.azRequestBuilder.withEntitiesItems(schema, entities);
4467
+ return this;
4468
+ }
4469
+ /**
4470
+ * Sets the request ID of the AZRequest.
4471
+ * @param requestID - The request ID.
4472
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4473
+ */
4474
+ withRequestID(requestID) {
4475
+ this.requestID = requestID;
4476
+ return this;
4477
+ }
4478
+ /**
4479
+ * Sets the principal of the AZRequest.
4480
+ * @param principal - The principal.
4481
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4482
+ */
4483
+ withPrincipal(principal) {
4484
+ this.principal = principal;
4485
+ return this;
4486
+ }
4487
+ /**
4488
+ * Sets the kind of the subject for the AZRequest.
4489
+ * @param kind - The subject kind.
4490
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4491
+ */
4492
+ withSubjectKind(kind) {
4493
+ this.azSubjectBuilder.withKind(kind);
4494
+ return this;
4495
+ }
4496
+ /**
4497
+ * Sets the source of the subject for the AZRequest.
4498
+ * @param source - The subject source.
4499
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4500
+ */
4501
+ withSubjectSource(source) {
4502
+ this.azSubjectBuilder.withSource(source);
4503
+ return this;
4504
+ }
4505
+ /**
4506
+ * Sets a property of the subject for the AZRequest.
4507
+ * @param key - The property key.
4508
+ * @param value - The property value.
4509
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4510
+ */
4511
+ withSubjectProperty(key, value) {
4512
+ this.azSubjectBuilder.withProperty(key, value);
4513
+ return this;
4514
+ }
4515
+ /**
4516
+ * Sets the ID of the resource for the AZRequest.
4517
+ * @param id - The resource ID.
4518
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4519
+ */
4520
+ withResourceID(id) {
4521
+ this.azResourceBuilder.withID(id);
4522
+ return this;
4523
+ }
4524
+ /**
4525
+ * Sets a property of the resource for the AZRequest.
4526
+ * @param key - The property key.
4527
+ * @param value - The property value.
4528
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4529
+ */
4530
+ withResourceProperty(key, value) {
4531
+ this.azResourceBuilder.withProperty(key, value);
4532
+ return this;
4533
+ }
4534
+ /**
4535
+ * Sets a property of the action for the AZRequest.
4536
+ * @param key - The property key.
4537
+ * @param value - The property value.
4538
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4539
+ */
4540
+ withActionProperty(key, value) {
4541
+ this.azActionBuilder.withProperty(key, value);
4542
+ return this;
4543
+ }
4544
+ /**
4545
+ * Sets a property of the context for the AZRequest.
4546
+ * @param key - The property key.
4547
+ * @param value - The property value.
4548
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4549
+ */
4550
+ withContextProperty(key, value) {
4551
+ this.azContextBuilder.withProperty(key, value);
4552
+ return this;
4553
+ }
4554
+ /**
4555
+ * Sets the type of the subject to UserType.
4556
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4557
+ */
4558
+ withSubjectUserType() {
4559
+ this.azSubjectBuilder.withKind("USER" /* UserType */);
4560
+ return this;
4561
+ }
4562
+ /**
4563
+ * Sets the type of the subject to RoleActorType.
4564
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4565
+ */
4566
+ withSubjectRoleActorType() {
4567
+ this.azSubjectBuilder.withKind("ROLE-ACTOR" /* RoleActorType */);
4568
+ return this;
4569
+ }
4570
+ /**
4571
+ * Sets the type of the subject to TwinActorType.
4572
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4573
+ */
4574
+ withSubjectTwinActorType() {
4575
+ this.azSubjectBuilder.withKind("TWIN-ACTOR" /* TwinActorType */);
4576
+ return this;
4577
+ }
4578
+ /**
4579
+ * Sets the type of the subject.
4580
+ * @param kind - The type of the subject.
4581
+ * @returns The AZAtomicRequestBuilder instance for method chaining.
4582
+ */
4583
+ withSubjectType(kind) {
4584
+ this.azSubjectBuilder.withKind(kind);
4585
+ return this;
4586
+ }
4587
+ /**
4588
+ * Builds the AZAtomicRequest object.
4589
+ * @returns The constructed AZRequest object.
4590
+ */
4591
+ build() {
4592
+ const subject = this.azSubjectBuilder.build();
4593
+ const resource = this.azResourceBuilder.build();
4594
+ const action = this.azActionBuilder.build();
4595
+ const context = this.azContextBuilder.build();
4596
+ this.azRequestBuilder.withPrincipal(this.principal).withRequestID(this.requestID).withSubject(subject).withResource(resource).withAction(action).withContext(context);
4597
+ return this.azRequestBuilder.build();
4598
+ }
4599
+ };
4600
+ // Annotate the CommonJS export names for ESM import in node:
4601
+ 0 && (module.exports = {
4602
+ AZAtomicRequestBuilder,
4603
+ AZClient,
4604
+ AZRequestBuilder,
4605
+ ActionBuilder,
4606
+ ActorType,
4607
+ ContextBuilder,
4608
+ EvaluationBuilder,
4609
+ PrincipalBuilder,
4610
+ ResourceBuilder,
4611
+ SubjectBuilder,
4612
+ withEndpoint
4613
+ });
4614
+ //# sourceMappingURL=index.js.map