@learncard/core 6.1.0 → 6.3.1

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/core.esm.js CHANGED
@@ -2888,9 +2888,9 @@ var require_package = __commonJS({
2888
2888
  }
2889
2889
  });
2890
2890
 
2891
- // (disabled):../../node_modules/.pnpm/buffer@5.2.1/node_modules/buffer/index.js
2891
+ // (disabled):../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js
2892
2892
  var require_buffer = __commonJS({
2893
- "(disabled):../../node_modules/.pnpm/buffer@5.2.1/node_modules/buffer/index.js"() {
2893
+ "(disabled):../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js"() {
2894
2894
  }
2895
2895
  });
2896
2896
 
@@ -2937,12 +2937,12 @@ var require_bn = __commonJS({
2937
2937
  }
2938
2938
  BN3.BN = BN3;
2939
2939
  BN3.wordSize = 26;
2940
- var Buffer2;
2940
+ var Buffer3;
2941
2941
  try {
2942
2942
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
2943
- Buffer2 = window.Buffer;
2943
+ Buffer3 = window.Buffer;
2944
2944
  } else {
2945
- Buffer2 = require_buffer().Buffer;
2945
+ Buffer3 = require_buffer().Buffer;
2946
2946
  }
2947
2947
  } catch (e) {
2948
2948
  }
@@ -3383,8 +3383,8 @@ var require_bn = __commonJS({
3383
3383
  return this.toString(16);
3384
3384
  }, "toJSON");
3385
3385
  BN3.prototype.toBuffer = /* @__PURE__ */ __name(function toBuffer(endian, length2) {
3386
- assert2(typeof Buffer2 !== "undefined");
3387
- return this.toArrayLike(Buffer2, endian, length2);
3386
+ assert2(typeof Buffer3 !== "undefined");
3387
+ return this.toArrayLike(Buffer3, endian, length2);
3388
3388
  }, "toBuffer");
3389
3389
  BN3.prototype.toArray = /* @__PURE__ */ __name(function toArray(endian, length2) {
3390
3390
  return this.toArrayLike(Array, endian, length2);
@@ -23420,12 +23420,12 @@ var require_bn2 = __commonJS({
23420
23420
  }
23421
23421
  BN3.BN = BN3;
23422
23422
  BN3.wordSize = 26;
23423
- var Buffer2;
23423
+ var Buffer3;
23424
23424
  try {
23425
23425
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
23426
- Buffer2 = window.Buffer;
23426
+ Buffer3 = window.Buffer;
23427
23427
  } else {
23428
- Buffer2 = require_buffer().Buffer;
23428
+ Buffer3 = require_buffer().Buffer;
23429
23429
  }
23430
23430
  } catch (e) {
23431
23431
  }
@@ -23890,9 +23890,9 @@ var require_bn2 = __commonJS({
23890
23890
  BN3.prototype.toJSON = /* @__PURE__ */ __name(function toJSON2() {
23891
23891
  return this.toString(16, 2);
23892
23892
  }, "toJSON");
23893
- if (Buffer2) {
23893
+ if (Buffer3) {
23894
23894
  BN3.prototype.toBuffer = /* @__PURE__ */ __name(function toBuffer(endian, length2) {
23895
- return this.toArrayLike(Buffer2, endian, length2);
23895
+ return this.toArrayLike(Buffer3, endian, length2);
23896
23896
  }, "toBuffer");
23897
23897
  }
23898
23898
  BN3.prototype.toArray = /* @__PURE__ */ __name(function toArray(endian, length2) {
@@ -27428,7 +27428,7 @@ var require_lodash = __commonJS({
27428
27428
  var hasOwnProperty2 = objectProto.hasOwnProperty;
27429
27429
  var objectToString = objectProto.toString;
27430
27430
  var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
27431
- var Buffer2 = moduleExports ? root.Buffer : void 0;
27431
+ var Buffer3 = moduleExports ? root.Buffer : void 0;
27432
27432
  var Symbol2 = root.Symbol;
27433
27433
  var Uint8Array2 = root.Uint8Array;
27434
27434
  var getPrototype = overArg(Object.getPrototypeOf, Object);
@@ -27436,7 +27436,7 @@ var require_lodash = __commonJS({
27436
27436
  var propertyIsEnumerable = objectProto.propertyIsEnumerable;
27437
27437
  var splice = arrayProto.splice;
27438
27438
  var nativeGetSymbols = Object.getOwnPropertySymbols;
27439
- var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
27439
+ var nativeIsBuffer = Buffer3 ? Buffer3.isBuffer : void 0;
27440
27440
  var nativeKeys = overArg(Object.keys, Object);
27441
27441
  var DataView2 = getNative(root, "DataView");
27442
27442
  var Map2 = getNative(root, "Map");
@@ -28460,7 +28460,7 @@ var require_dataloader = __commonJS({
28460
28460
  }
28461
28461
  __name(DataLoader3, "DataLoader");
28462
28462
  var _proto = DataLoader3.prototype;
28463
- _proto.load = /* @__PURE__ */ __name(function load2(key2) {
28463
+ _proto.load = /* @__PURE__ */ __name(function load3(key2) {
28464
28464
  if (key2 === null || key2 === void 0) {
28465
28465
  throw new TypeError("The loader.load() function must be called with a value, " + ("but got: " + String(key2) + "."));
28466
28466
  }
@@ -29268,6 +29268,1667 @@ var require_src3 = __commonJS({
29268
29268
  }
29269
29269
  });
29270
29270
 
29271
+ // ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
29272
+ var require_base64_js = __commonJS({
29273
+ "../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports) {
29274
+ "use strict";
29275
+ exports.byteLength = byteLength;
29276
+ exports.toByteArray = toByteArray;
29277
+ exports.fromByteArray = fromByteArray;
29278
+ var lookup = [];
29279
+ var revLookup = [];
29280
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
29281
+ var code5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
29282
+ for (i = 0, len = code5.length; i < len; ++i) {
29283
+ lookup[i] = code5[i];
29284
+ revLookup[code5.charCodeAt(i)] = i;
29285
+ }
29286
+ var i;
29287
+ var len;
29288
+ revLookup["-".charCodeAt(0)] = 62;
29289
+ revLookup["_".charCodeAt(0)] = 63;
29290
+ function getLens(b64) {
29291
+ var len2 = b64.length;
29292
+ if (len2 % 4 > 0) {
29293
+ throw new Error("Invalid string. Length must be a multiple of 4");
29294
+ }
29295
+ var validLen = b64.indexOf("=");
29296
+ if (validLen === -1)
29297
+ validLen = len2;
29298
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
29299
+ return [validLen, placeHoldersLen];
29300
+ }
29301
+ __name(getLens, "getLens");
29302
+ function byteLength(b64) {
29303
+ var lens = getLens(b64);
29304
+ var validLen = lens[0];
29305
+ var placeHoldersLen = lens[1];
29306
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
29307
+ }
29308
+ __name(byteLength, "byteLength");
29309
+ function _byteLength(b64, validLen, placeHoldersLen) {
29310
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
29311
+ }
29312
+ __name(_byteLength, "_byteLength");
29313
+ function toByteArray(b64) {
29314
+ var tmp;
29315
+ var lens = getLens(b64);
29316
+ var validLen = lens[0];
29317
+ var placeHoldersLen = lens[1];
29318
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
29319
+ var curByte = 0;
29320
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
29321
+ var i2;
29322
+ for (i2 = 0; i2 < len2; i2 += 4) {
29323
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
29324
+ arr[curByte++] = tmp >> 16 & 255;
29325
+ arr[curByte++] = tmp >> 8 & 255;
29326
+ arr[curByte++] = tmp & 255;
29327
+ }
29328
+ if (placeHoldersLen === 2) {
29329
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
29330
+ arr[curByte++] = tmp & 255;
29331
+ }
29332
+ if (placeHoldersLen === 1) {
29333
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
29334
+ arr[curByte++] = tmp >> 8 & 255;
29335
+ arr[curByte++] = tmp & 255;
29336
+ }
29337
+ return arr;
29338
+ }
29339
+ __name(toByteArray, "toByteArray");
29340
+ function tripletToBase64(num) {
29341
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
29342
+ }
29343
+ __name(tripletToBase64, "tripletToBase64");
29344
+ function encodeChunk(uint8, start, end) {
29345
+ var tmp;
29346
+ var output = [];
29347
+ for (var i2 = start; i2 < end; i2 += 3) {
29348
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
29349
+ output.push(tripletToBase64(tmp));
29350
+ }
29351
+ return output.join("");
29352
+ }
29353
+ __name(encodeChunk, "encodeChunk");
29354
+ function fromByteArray(uint8) {
29355
+ var tmp;
29356
+ var len2 = uint8.length;
29357
+ var extraBytes = len2 % 3;
29358
+ var parts = [];
29359
+ var maxChunkLength = 16383;
29360
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
29361
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
29362
+ }
29363
+ if (extraBytes === 1) {
29364
+ tmp = uint8[len2 - 1];
29365
+ parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
29366
+ } else if (extraBytes === 2) {
29367
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
29368
+ parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
29369
+ }
29370
+ return parts.join("");
29371
+ }
29372
+ __name(fromByteArray, "fromByteArray");
29373
+ }
29374
+ });
29375
+
29376
+ // ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
29377
+ var require_ieee754 = __commonJS({
29378
+ "../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports) {
29379
+ exports.read = function(buffer2, offset, isLE, mLen, nBytes) {
29380
+ var e, m;
29381
+ var eLen = nBytes * 8 - mLen - 1;
29382
+ var eMax = (1 << eLen) - 1;
29383
+ var eBias = eMax >> 1;
29384
+ var nBits = -7;
29385
+ var i = isLE ? nBytes - 1 : 0;
29386
+ var d = isLE ? -1 : 1;
29387
+ var s = buffer2[offset + i];
29388
+ i += d;
29389
+ e = s & (1 << -nBits) - 1;
29390
+ s >>= -nBits;
29391
+ nBits += eLen;
29392
+ for (; nBits > 0; e = e * 256 + buffer2[offset + i], i += d, nBits -= 8) {
29393
+ }
29394
+ m = e & (1 << -nBits) - 1;
29395
+ e >>= -nBits;
29396
+ nBits += mLen;
29397
+ for (; nBits > 0; m = m * 256 + buffer2[offset + i], i += d, nBits -= 8) {
29398
+ }
29399
+ if (e === 0) {
29400
+ e = 1 - eBias;
29401
+ } else if (e === eMax) {
29402
+ return m ? NaN : (s ? -1 : 1) * Infinity;
29403
+ } else {
29404
+ m = m + Math.pow(2, mLen);
29405
+ e = e - eBias;
29406
+ }
29407
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
29408
+ };
29409
+ exports.write = function(buffer2, value, offset, isLE, mLen, nBytes) {
29410
+ var e, m, c;
29411
+ var eLen = nBytes * 8 - mLen - 1;
29412
+ var eMax = (1 << eLen) - 1;
29413
+ var eBias = eMax >> 1;
29414
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
29415
+ var i = isLE ? 0 : nBytes - 1;
29416
+ var d = isLE ? 1 : -1;
29417
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
29418
+ value = Math.abs(value);
29419
+ if (isNaN(value) || value === Infinity) {
29420
+ m = isNaN(value) ? 1 : 0;
29421
+ e = eMax;
29422
+ } else {
29423
+ e = Math.floor(Math.log(value) / Math.LN2);
29424
+ if (value * (c = Math.pow(2, -e)) < 1) {
29425
+ e--;
29426
+ c *= 2;
29427
+ }
29428
+ if (e + eBias >= 1) {
29429
+ value += rt / c;
29430
+ } else {
29431
+ value += rt * Math.pow(2, 1 - eBias);
29432
+ }
29433
+ if (value * c >= 2) {
29434
+ e++;
29435
+ c /= 2;
29436
+ }
29437
+ if (e + eBias >= eMax) {
29438
+ m = 0;
29439
+ e = eMax;
29440
+ } else if (e + eBias >= 1) {
29441
+ m = (value * c - 1) * Math.pow(2, mLen);
29442
+ e = e + eBias;
29443
+ } else {
29444
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
29445
+ e = 0;
29446
+ }
29447
+ }
29448
+ for (; mLen >= 8; buffer2[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
29449
+ }
29450
+ e = e << mLen | m;
29451
+ eLen += mLen;
29452
+ for (; eLen > 0; buffer2[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
29453
+ }
29454
+ buffer2[offset + i - d] |= s * 128;
29455
+ };
29456
+ }
29457
+ });
29458
+
29459
+ // ../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js
29460
+ var require_buffer2 = __commonJS({
29461
+ "../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js"(exports) {
29462
+ "use strict";
29463
+ var base642 = require_base64_js();
29464
+ var ieee754 = require_ieee754();
29465
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
29466
+ exports.Buffer = Buffer3;
29467
+ exports.SlowBuffer = SlowBuffer;
29468
+ exports.INSPECT_MAX_BYTES = 50;
29469
+ var K_MAX_LENGTH = 2147483647;
29470
+ exports.kMaxLength = K_MAX_LENGTH;
29471
+ Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
29472
+ if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
29473
+ console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
29474
+ }
29475
+ function typedArraySupport() {
29476
+ try {
29477
+ var arr = new Uint8Array(1);
29478
+ var proto = { foo: function() {
29479
+ return 42;
29480
+ } };
29481
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
29482
+ Object.setPrototypeOf(arr, proto);
29483
+ return arr.foo() === 42;
29484
+ } catch (e) {
29485
+ return false;
29486
+ }
29487
+ }
29488
+ __name(typedArraySupport, "typedArraySupport");
29489
+ Object.defineProperty(Buffer3.prototype, "parent", {
29490
+ enumerable: true,
29491
+ get: function() {
29492
+ if (!Buffer3.isBuffer(this))
29493
+ return void 0;
29494
+ return this.buffer;
29495
+ }
29496
+ });
29497
+ Object.defineProperty(Buffer3.prototype, "offset", {
29498
+ enumerable: true,
29499
+ get: function() {
29500
+ if (!Buffer3.isBuffer(this))
29501
+ return void 0;
29502
+ return this.byteOffset;
29503
+ }
29504
+ });
29505
+ function createBuffer(length2) {
29506
+ if (length2 > K_MAX_LENGTH) {
29507
+ throw new RangeError('The value "' + length2 + '" is invalid for option "size"');
29508
+ }
29509
+ var buf2 = new Uint8Array(length2);
29510
+ Object.setPrototypeOf(buf2, Buffer3.prototype);
29511
+ return buf2;
29512
+ }
29513
+ __name(createBuffer, "createBuffer");
29514
+ function Buffer3(arg, encodingOrOffset, length2) {
29515
+ if (typeof arg === "number") {
29516
+ if (typeof encodingOrOffset === "string") {
29517
+ throw new TypeError('The "string" argument must be of type string. Received type number');
29518
+ }
29519
+ return allocUnsafe(arg);
29520
+ }
29521
+ return from4(arg, encodingOrOffset, length2);
29522
+ }
29523
+ __name(Buffer3, "Buffer");
29524
+ Buffer3.poolSize = 8192;
29525
+ function from4(value, encodingOrOffset, length2) {
29526
+ if (typeof value === "string") {
29527
+ return fromString6(value, encodingOrOffset);
29528
+ }
29529
+ if (ArrayBuffer.isView(value)) {
29530
+ return fromArrayView(value);
29531
+ }
29532
+ if (value == null) {
29533
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
29534
+ }
29535
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
29536
+ return fromArrayBuffer(value, encodingOrOffset, length2);
29537
+ }
29538
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
29539
+ return fromArrayBuffer(value, encodingOrOffset, length2);
29540
+ }
29541
+ if (typeof value === "number") {
29542
+ throw new TypeError('The "value" argument must not be of type number. Received type number');
29543
+ }
29544
+ var valueOf = value.valueOf && value.valueOf();
29545
+ if (valueOf != null && valueOf !== value) {
29546
+ return Buffer3.from(valueOf, encodingOrOffset, length2);
29547
+ }
29548
+ var b = fromObject(value);
29549
+ if (b)
29550
+ return b;
29551
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
29552
+ return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length2);
29553
+ }
29554
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
29555
+ }
29556
+ __name(from4, "from");
29557
+ Buffer3.from = function(value, encodingOrOffset, length2) {
29558
+ return from4(value, encodingOrOffset, length2);
29559
+ };
29560
+ Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
29561
+ Object.setPrototypeOf(Buffer3, Uint8Array);
29562
+ function assertSize(size) {
29563
+ if (typeof size !== "number") {
29564
+ throw new TypeError('"size" argument must be of type number');
29565
+ } else if (size < 0) {
29566
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
29567
+ }
29568
+ }
29569
+ __name(assertSize, "assertSize");
29570
+ function alloc2(size, fill, encoding) {
29571
+ assertSize(size);
29572
+ if (size <= 0) {
29573
+ return createBuffer(size);
29574
+ }
29575
+ if (fill !== void 0) {
29576
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
29577
+ }
29578
+ return createBuffer(size);
29579
+ }
29580
+ __name(alloc2, "alloc");
29581
+ Buffer3.alloc = function(size, fill, encoding) {
29582
+ return alloc2(size, fill, encoding);
29583
+ };
29584
+ function allocUnsafe(size) {
29585
+ assertSize(size);
29586
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
29587
+ }
29588
+ __name(allocUnsafe, "allocUnsafe");
29589
+ Buffer3.allocUnsafe = function(size) {
29590
+ return allocUnsafe(size);
29591
+ };
29592
+ Buffer3.allocUnsafeSlow = function(size) {
29593
+ return allocUnsafe(size);
29594
+ };
29595
+ function fromString6(string2, encoding) {
29596
+ if (typeof encoding !== "string" || encoding === "") {
29597
+ encoding = "utf8";
29598
+ }
29599
+ if (!Buffer3.isEncoding(encoding)) {
29600
+ throw new TypeError("Unknown encoding: " + encoding);
29601
+ }
29602
+ var length2 = byteLength(string2, encoding) | 0;
29603
+ var buf2 = createBuffer(length2);
29604
+ var actual = buf2.write(string2, encoding);
29605
+ if (actual !== length2) {
29606
+ buf2 = buf2.slice(0, actual);
29607
+ }
29608
+ return buf2;
29609
+ }
29610
+ __name(fromString6, "fromString");
29611
+ function fromArrayLike2(array) {
29612
+ var length2 = array.length < 0 ? 0 : checked(array.length) | 0;
29613
+ var buf2 = createBuffer(length2);
29614
+ for (var i = 0; i < length2; i += 1) {
29615
+ buf2[i] = array[i] & 255;
29616
+ }
29617
+ return buf2;
29618
+ }
29619
+ __name(fromArrayLike2, "fromArrayLike");
29620
+ function fromArrayView(arrayView) {
29621
+ if (isInstance(arrayView, Uint8Array)) {
29622
+ var copy = new Uint8Array(arrayView);
29623
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
29624
+ }
29625
+ return fromArrayLike2(arrayView);
29626
+ }
29627
+ __name(fromArrayView, "fromArrayView");
29628
+ function fromArrayBuffer(array, byteOffset, length2) {
29629
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
29630
+ throw new RangeError('"offset" is outside of buffer bounds');
29631
+ }
29632
+ if (array.byteLength < byteOffset + (length2 || 0)) {
29633
+ throw new RangeError('"length" is outside of buffer bounds');
29634
+ }
29635
+ var buf2;
29636
+ if (byteOffset === void 0 && length2 === void 0) {
29637
+ buf2 = new Uint8Array(array);
29638
+ } else if (length2 === void 0) {
29639
+ buf2 = new Uint8Array(array, byteOffset);
29640
+ } else {
29641
+ buf2 = new Uint8Array(array, byteOffset, length2);
29642
+ }
29643
+ Object.setPrototypeOf(buf2, Buffer3.prototype);
29644
+ return buf2;
29645
+ }
29646
+ __name(fromArrayBuffer, "fromArrayBuffer");
29647
+ function fromObject(obj) {
29648
+ if (Buffer3.isBuffer(obj)) {
29649
+ var len = checked(obj.length) | 0;
29650
+ var buf2 = createBuffer(len);
29651
+ if (buf2.length === 0) {
29652
+ return buf2;
29653
+ }
29654
+ obj.copy(buf2, 0, 0, len);
29655
+ return buf2;
29656
+ }
29657
+ if (obj.length !== void 0) {
29658
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
29659
+ return createBuffer(0);
29660
+ }
29661
+ return fromArrayLike2(obj);
29662
+ }
29663
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
29664
+ return fromArrayLike2(obj.data);
29665
+ }
29666
+ }
29667
+ __name(fromObject, "fromObject");
29668
+ function checked(length2) {
29669
+ if (length2 >= K_MAX_LENGTH) {
29670
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
29671
+ }
29672
+ return length2 | 0;
29673
+ }
29674
+ __name(checked, "checked");
29675
+ function SlowBuffer(length2) {
29676
+ if (+length2 != length2) {
29677
+ length2 = 0;
29678
+ }
29679
+ return Buffer3.alloc(+length2);
29680
+ }
29681
+ __name(SlowBuffer, "SlowBuffer");
29682
+ Buffer3.isBuffer = /* @__PURE__ */ __name(function isBuffer3(b) {
29683
+ return b != null && b._isBuffer === true && b !== Buffer3.prototype;
29684
+ }, "isBuffer");
29685
+ Buffer3.compare = /* @__PURE__ */ __name(function compare4(a, b) {
29686
+ if (isInstance(a, Uint8Array))
29687
+ a = Buffer3.from(a, a.offset, a.byteLength);
29688
+ if (isInstance(b, Uint8Array))
29689
+ b = Buffer3.from(b, b.offset, b.byteLength);
29690
+ if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
29691
+ throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
29692
+ }
29693
+ if (a === b)
29694
+ return 0;
29695
+ var x = a.length;
29696
+ var y = b.length;
29697
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
29698
+ if (a[i] !== b[i]) {
29699
+ x = a[i];
29700
+ y = b[i];
29701
+ break;
29702
+ }
29703
+ }
29704
+ if (x < y)
29705
+ return -1;
29706
+ if (y < x)
29707
+ return 1;
29708
+ return 0;
29709
+ }, "compare");
29710
+ Buffer3.isEncoding = /* @__PURE__ */ __name(function isEncoding(encoding) {
29711
+ switch (String(encoding).toLowerCase()) {
29712
+ case "hex":
29713
+ case "utf8":
29714
+ case "utf-8":
29715
+ case "ascii":
29716
+ case "latin1":
29717
+ case "binary":
29718
+ case "base64":
29719
+ case "ucs2":
29720
+ case "ucs-2":
29721
+ case "utf16le":
29722
+ case "utf-16le":
29723
+ return true;
29724
+ default:
29725
+ return false;
29726
+ }
29727
+ }, "isEncoding");
29728
+ Buffer3.concat = /* @__PURE__ */ __name(function concat4(list, length2) {
29729
+ if (!Array.isArray(list)) {
29730
+ throw new TypeError('"list" argument must be an Array of Buffers');
29731
+ }
29732
+ if (list.length === 0) {
29733
+ return Buffer3.alloc(0);
29734
+ }
29735
+ var i;
29736
+ if (length2 === void 0) {
29737
+ length2 = 0;
29738
+ for (i = 0; i < list.length; ++i) {
29739
+ length2 += list[i].length;
29740
+ }
29741
+ }
29742
+ var buffer2 = Buffer3.allocUnsafe(length2);
29743
+ var pos = 0;
29744
+ for (i = 0; i < list.length; ++i) {
29745
+ var buf2 = list[i];
29746
+ if (isInstance(buf2, Uint8Array)) {
29747
+ if (pos + buf2.length > buffer2.length) {
29748
+ Buffer3.from(buf2).copy(buffer2, pos);
29749
+ } else {
29750
+ Uint8Array.prototype.set.call(buffer2, buf2, pos);
29751
+ }
29752
+ } else if (!Buffer3.isBuffer(buf2)) {
29753
+ throw new TypeError('"list" argument must be an Array of Buffers');
29754
+ } else {
29755
+ buf2.copy(buffer2, pos);
29756
+ }
29757
+ pos += buf2.length;
29758
+ }
29759
+ return buffer2;
29760
+ }, "concat");
29761
+ function byteLength(string2, encoding) {
29762
+ if (Buffer3.isBuffer(string2)) {
29763
+ return string2.length;
29764
+ }
29765
+ if (ArrayBuffer.isView(string2) || isInstance(string2, ArrayBuffer)) {
29766
+ return string2.byteLength;
29767
+ }
29768
+ if (typeof string2 !== "string") {
29769
+ throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string2);
29770
+ }
29771
+ var len = string2.length;
29772
+ var mustMatch = arguments.length > 2 && arguments[2] === true;
29773
+ if (!mustMatch && len === 0)
29774
+ return 0;
29775
+ var loweredCase = false;
29776
+ for (; ; ) {
29777
+ switch (encoding) {
29778
+ case "ascii":
29779
+ case "latin1":
29780
+ case "binary":
29781
+ return len;
29782
+ case "utf8":
29783
+ case "utf-8":
29784
+ return utf8ToBytes2(string2).length;
29785
+ case "ucs2":
29786
+ case "ucs-2":
29787
+ case "utf16le":
29788
+ case "utf-16le":
29789
+ return len * 2;
29790
+ case "hex":
29791
+ return len >>> 1;
29792
+ case "base64":
29793
+ return base64ToBytes2(string2).length;
29794
+ default:
29795
+ if (loweredCase) {
29796
+ return mustMatch ? -1 : utf8ToBytes2(string2).length;
29797
+ }
29798
+ encoding = ("" + encoding).toLowerCase();
29799
+ loweredCase = true;
29800
+ }
29801
+ }
29802
+ }
29803
+ __name(byteLength, "byteLength");
29804
+ Buffer3.byteLength = byteLength;
29805
+ function slowToString(encoding, start, end) {
29806
+ var loweredCase = false;
29807
+ if (start === void 0 || start < 0) {
29808
+ start = 0;
29809
+ }
29810
+ if (start > this.length) {
29811
+ return "";
29812
+ }
29813
+ if (end === void 0 || end > this.length) {
29814
+ end = this.length;
29815
+ }
29816
+ if (end <= 0) {
29817
+ return "";
29818
+ }
29819
+ end >>>= 0;
29820
+ start >>>= 0;
29821
+ if (end <= start) {
29822
+ return "";
29823
+ }
29824
+ if (!encoding)
29825
+ encoding = "utf8";
29826
+ while (true) {
29827
+ switch (encoding) {
29828
+ case "hex":
29829
+ return hexSlice(this, start, end);
29830
+ case "utf8":
29831
+ case "utf-8":
29832
+ return utf8Slice2(this, start, end);
29833
+ case "ascii":
29834
+ return asciiSlice(this, start, end);
29835
+ case "latin1":
29836
+ case "binary":
29837
+ return latin1Slice(this, start, end);
29838
+ case "base64":
29839
+ return base64Slice(this, start, end);
29840
+ case "ucs2":
29841
+ case "ucs-2":
29842
+ case "utf16le":
29843
+ case "utf-16le":
29844
+ return utf16leSlice(this, start, end);
29845
+ default:
29846
+ if (loweredCase)
29847
+ throw new TypeError("Unknown encoding: " + encoding);
29848
+ encoding = (encoding + "").toLowerCase();
29849
+ loweredCase = true;
29850
+ }
29851
+ }
29852
+ }
29853
+ __name(slowToString, "slowToString");
29854
+ Buffer3.prototype._isBuffer = true;
29855
+ function swap(b, n, m) {
29856
+ var i = b[n];
29857
+ b[n] = b[m];
29858
+ b[m] = i;
29859
+ }
29860
+ __name(swap, "swap");
29861
+ Buffer3.prototype.swap16 = /* @__PURE__ */ __name(function swap16() {
29862
+ var len = this.length;
29863
+ if (len % 2 !== 0) {
29864
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
29865
+ }
29866
+ for (var i = 0; i < len; i += 2) {
29867
+ swap(this, i, i + 1);
29868
+ }
29869
+ return this;
29870
+ }, "swap16");
29871
+ Buffer3.prototype.swap32 = /* @__PURE__ */ __name(function swap32() {
29872
+ var len = this.length;
29873
+ if (len % 4 !== 0) {
29874
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
29875
+ }
29876
+ for (var i = 0; i < len; i += 4) {
29877
+ swap(this, i, i + 3);
29878
+ swap(this, i + 1, i + 2);
29879
+ }
29880
+ return this;
29881
+ }, "swap32");
29882
+ Buffer3.prototype.swap64 = /* @__PURE__ */ __name(function swap64() {
29883
+ var len = this.length;
29884
+ if (len % 8 !== 0) {
29885
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
29886
+ }
29887
+ for (var i = 0; i < len; i += 8) {
29888
+ swap(this, i, i + 7);
29889
+ swap(this, i + 1, i + 6);
29890
+ swap(this, i + 2, i + 5);
29891
+ swap(this, i + 3, i + 4);
29892
+ }
29893
+ return this;
29894
+ }, "swap64");
29895
+ Buffer3.prototype.toString = /* @__PURE__ */ __name(function toString6() {
29896
+ var length2 = this.length;
29897
+ if (length2 === 0)
29898
+ return "";
29899
+ if (arguments.length === 0)
29900
+ return utf8Slice2(this, 0, length2);
29901
+ return slowToString.apply(this, arguments);
29902
+ }, "toString");
29903
+ Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
29904
+ Buffer3.prototype.equals = /* @__PURE__ */ __name(function equals4(b) {
29905
+ if (!Buffer3.isBuffer(b))
29906
+ throw new TypeError("Argument must be a Buffer");
29907
+ if (this === b)
29908
+ return true;
29909
+ return Buffer3.compare(this, b) === 0;
29910
+ }, "equals");
29911
+ Buffer3.prototype.inspect = /* @__PURE__ */ __name(function inspect5() {
29912
+ var str = "";
29913
+ var max = exports.INSPECT_MAX_BYTES;
29914
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
29915
+ if (this.length > max)
29916
+ str += " ... ";
29917
+ return "<Buffer " + str + ">";
29918
+ }, "inspect");
29919
+ if (customInspectSymbol) {
29920
+ Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
29921
+ }
29922
+ Buffer3.prototype.compare = /* @__PURE__ */ __name(function compare4(target, start, end, thisStart, thisEnd) {
29923
+ if (isInstance(target, Uint8Array)) {
29924
+ target = Buffer3.from(target, target.offset, target.byteLength);
29925
+ }
29926
+ if (!Buffer3.isBuffer(target)) {
29927
+ throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target);
29928
+ }
29929
+ if (start === void 0) {
29930
+ start = 0;
29931
+ }
29932
+ if (end === void 0) {
29933
+ end = target ? target.length : 0;
29934
+ }
29935
+ if (thisStart === void 0) {
29936
+ thisStart = 0;
29937
+ }
29938
+ if (thisEnd === void 0) {
29939
+ thisEnd = this.length;
29940
+ }
29941
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
29942
+ throw new RangeError("out of range index");
29943
+ }
29944
+ if (thisStart >= thisEnd && start >= end) {
29945
+ return 0;
29946
+ }
29947
+ if (thisStart >= thisEnd) {
29948
+ return -1;
29949
+ }
29950
+ if (start >= end) {
29951
+ return 1;
29952
+ }
29953
+ start >>>= 0;
29954
+ end >>>= 0;
29955
+ thisStart >>>= 0;
29956
+ thisEnd >>>= 0;
29957
+ if (this === target)
29958
+ return 0;
29959
+ var x = thisEnd - thisStart;
29960
+ var y = end - start;
29961
+ var len = Math.min(x, y);
29962
+ var thisCopy = this.slice(thisStart, thisEnd);
29963
+ var targetCopy = target.slice(start, end);
29964
+ for (var i = 0; i < len; ++i) {
29965
+ if (thisCopy[i] !== targetCopy[i]) {
29966
+ x = thisCopy[i];
29967
+ y = targetCopy[i];
29968
+ break;
29969
+ }
29970
+ }
29971
+ if (x < y)
29972
+ return -1;
29973
+ if (y < x)
29974
+ return 1;
29975
+ return 0;
29976
+ }, "compare");
29977
+ function bidirectionalIndexOf(buffer2, val, byteOffset, encoding, dir) {
29978
+ if (buffer2.length === 0)
29979
+ return -1;
29980
+ if (typeof byteOffset === "string") {
29981
+ encoding = byteOffset;
29982
+ byteOffset = 0;
29983
+ } else if (byteOffset > 2147483647) {
29984
+ byteOffset = 2147483647;
29985
+ } else if (byteOffset < -2147483648) {
29986
+ byteOffset = -2147483648;
29987
+ }
29988
+ byteOffset = +byteOffset;
29989
+ if (numberIsNaN(byteOffset)) {
29990
+ byteOffset = dir ? 0 : buffer2.length - 1;
29991
+ }
29992
+ if (byteOffset < 0)
29993
+ byteOffset = buffer2.length + byteOffset;
29994
+ if (byteOffset >= buffer2.length) {
29995
+ if (dir)
29996
+ return -1;
29997
+ else
29998
+ byteOffset = buffer2.length - 1;
29999
+ } else if (byteOffset < 0) {
30000
+ if (dir)
30001
+ byteOffset = 0;
30002
+ else
30003
+ return -1;
30004
+ }
30005
+ if (typeof val === "string") {
30006
+ val = Buffer3.from(val, encoding);
30007
+ }
30008
+ if (Buffer3.isBuffer(val)) {
30009
+ if (val.length === 0) {
30010
+ return -1;
30011
+ }
30012
+ return arrayIndexOf(buffer2, val, byteOffset, encoding, dir);
30013
+ } else if (typeof val === "number") {
30014
+ val = val & 255;
30015
+ if (typeof Uint8Array.prototype.indexOf === "function") {
30016
+ if (dir) {
30017
+ return Uint8Array.prototype.indexOf.call(buffer2, val, byteOffset);
30018
+ } else {
30019
+ return Uint8Array.prototype.lastIndexOf.call(buffer2, val, byteOffset);
30020
+ }
30021
+ }
30022
+ return arrayIndexOf(buffer2, [val], byteOffset, encoding, dir);
30023
+ }
30024
+ throw new TypeError("val must be string, number or Buffer");
30025
+ }
30026
+ __name(bidirectionalIndexOf, "bidirectionalIndexOf");
30027
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
30028
+ var indexSize = 1;
30029
+ var arrLength = arr.length;
30030
+ var valLength = val.length;
30031
+ if (encoding !== void 0) {
30032
+ encoding = String(encoding).toLowerCase();
30033
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
30034
+ if (arr.length < 2 || val.length < 2) {
30035
+ return -1;
30036
+ }
30037
+ indexSize = 2;
30038
+ arrLength /= 2;
30039
+ valLength /= 2;
30040
+ byteOffset /= 2;
30041
+ }
30042
+ }
30043
+ function read2(buf2, i2) {
30044
+ if (indexSize === 1) {
30045
+ return buf2[i2];
30046
+ } else {
30047
+ return buf2.readUInt16BE(i2 * indexSize);
30048
+ }
30049
+ }
30050
+ __name(read2, "read");
30051
+ var i;
30052
+ if (dir) {
30053
+ var foundIndex = -1;
30054
+ for (i = byteOffset; i < arrLength; i++) {
30055
+ if (read2(arr, i) === read2(val, foundIndex === -1 ? 0 : i - foundIndex)) {
30056
+ if (foundIndex === -1)
30057
+ foundIndex = i;
30058
+ if (i - foundIndex + 1 === valLength)
30059
+ return foundIndex * indexSize;
30060
+ } else {
30061
+ if (foundIndex !== -1)
30062
+ i -= i - foundIndex;
30063
+ foundIndex = -1;
30064
+ }
30065
+ }
30066
+ } else {
30067
+ if (byteOffset + valLength > arrLength)
30068
+ byteOffset = arrLength - valLength;
30069
+ for (i = byteOffset; i >= 0; i--) {
30070
+ var found = true;
30071
+ for (var j = 0; j < valLength; j++) {
30072
+ if (read2(arr, i + j) !== read2(val, j)) {
30073
+ found = false;
30074
+ break;
30075
+ }
30076
+ }
30077
+ if (found)
30078
+ return i;
30079
+ }
30080
+ }
30081
+ return -1;
30082
+ }
30083
+ __name(arrayIndexOf, "arrayIndexOf");
30084
+ Buffer3.prototype.includes = /* @__PURE__ */ __name(function includes(val, byteOffset, encoding) {
30085
+ return this.indexOf(val, byteOffset, encoding) !== -1;
30086
+ }, "includes");
30087
+ Buffer3.prototype.indexOf = /* @__PURE__ */ __name(function indexOf(val, byteOffset, encoding) {
30088
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
30089
+ }, "indexOf");
30090
+ Buffer3.prototype.lastIndexOf = /* @__PURE__ */ __name(function lastIndexOf(val, byteOffset, encoding) {
30091
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
30092
+ }, "lastIndexOf");
30093
+ function hexWrite(buf2, string2, offset, length2) {
30094
+ offset = Number(offset) || 0;
30095
+ var remaining = buf2.length - offset;
30096
+ if (!length2) {
30097
+ length2 = remaining;
30098
+ } else {
30099
+ length2 = Number(length2);
30100
+ if (length2 > remaining) {
30101
+ length2 = remaining;
30102
+ }
30103
+ }
30104
+ var strLen = string2.length;
30105
+ if (length2 > strLen / 2) {
30106
+ length2 = strLen / 2;
30107
+ }
30108
+ for (var i = 0; i < length2; ++i) {
30109
+ var parsed = parseInt(string2.substr(i * 2, 2), 16);
30110
+ if (numberIsNaN(parsed))
30111
+ return i;
30112
+ buf2[offset + i] = parsed;
30113
+ }
30114
+ return i;
30115
+ }
30116
+ __name(hexWrite, "hexWrite");
30117
+ function utf8Write(buf2, string2, offset, length2) {
30118
+ return blitBuffer(utf8ToBytes2(string2, buf2.length - offset), buf2, offset, length2);
30119
+ }
30120
+ __name(utf8Write, "utf8Write");
30121
+ function asciiWrite(buf2, string2, offset, length2) {
30122
+ return blitBuffer(asciiToBytes(string2), buf2, offset, length2);
30123
+ }
30124
+ __name(asciiWrite, "asciiWrite");
30125
+ function base64Write(buf2, string2, offset, length2) {
30126
+ return blitBuffer(base64ToBytes2(string2), buf2, offset, length2);
30127
+ }
30128
+ __name(base64Write, "base64Write");
30129
+ function ucs2Write(buf2, string2, offset, length2) {
30130
+ return blitBuffer(utf16leToBytes(string2, buf2.length - offset), buf2, offset, length2);
30131
+ }
30132
+ __name(ucs2Write, "ucs2Write");
30133
+ Buffer3.prototype.write = /* @__PURE__ */ __name(function write(string2, offset, length2, encoding) {
30134
+ if (offset === void 0) {
30135
+ encoding = "utf8";
30136
+ length2 = this.length;
30137
+ offset = 0;
30138
+ } else if (length2 === void 0 && typeof offset === "string") {
30139
+ encoding = offset;
30140
+ length2 = this.length;
30141
+ offset = 0;
30142
+ } else if (isFinite(offset)) {
30143
+ offset = offset >>> 0;
30144
+ if (isFinite(length2)) {
30145
+ length2 = length2 >>> 0;
30146
+ if (encoding === void 0)
30147
+ encoding = "utf8";
30148
+ } else {
30149
+ encoding = length2;
30150
+ length2 = void 0;
30151
+ }
30152
+ } else {
30153
+ throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
30154
+ }
30155
+ var remaining = this.length - offset;
30156
+ if (length2 === void 0 || length2 > remaining)
30157
+ length2 = remaining;
30158
+ if (string2.length > 0 && (length2 < 0 || offset < 0) || offset > this.length) {
30159
+ throw new RangeError("Attempt to write outside buffer bounds");
30160
+ }
30161
+ if (!encoding)
30162
+ encoding = "utf8";
30163
+ var loweredCase = false;
30164
+ for (; ; ) {
30165
+ switch (encoding) {
30166
+ case "hex":
30167
+ return hexWrite(this, string2, offset, length2);
30168
+ case "utf8":
30169
+ case "utf-8":
30170
+ return utf8Write(this, string2, offset, length2);
30171
+ case "ascii":
30172
+ case "latin1":
30173
+ case "binary":
30174
+ return asciiWrite(this, string2, offset, length2);
30175
+ case "base64":
30176
+ return base64Write(this, string2, offset, length2);
30177
+ case "ucs2":
30178
+ case "ucs-2":
30179
+ case "utf16le":
30180
+ case "utf-16le":
30181
+ return ucs2Write(this, string2, offset, length2);
30182
+ default:
30183
+ if (loweredCase)
30184
+ throw new TypeError("Unknown encoding: " + encoding);
30185
+ encoding = ("" + encoding).toLowerCase();
30186
+ loweredCase = true;
30187
+ }
30188
+ }
30189
+ }, "write");
30190
+ Buffer3.prototype.toJSON = /* @__PURE__ */ __name(function toJSON2() {
30191
+ return {
30192
+ type: "Buffer",
30193
+ data: Array.prototype.slice.call(this._arr || this, 0)
30194
+ };
30195
+ }, "toJSON");
30196
+ function base64Slice(buf2, start, end) {
30197
+ if (start === 0 && end === buf2.length) {
30198
+ return base642.fromByteArray(buf2);
30199
+ } else {
30200
+ return base642.fromByteArray(buf2.slice(start, end));
30201
+ }
30202
+ }
30203
+ __name(base64Slice, "base64Slice");
30204
+ function utf8Slice2(buf2, start, end) {
30205
+ end = Math.min(buf2.length, end);
30206
+ var res = [];
30207
+ var i = start;
30208
+ while (i < end) {
30209
+ var firstByte = buf2[i];
30210
+ var codePoint = null;
30211
+ var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
30212
+ if (i + bytesPerSequence <= end) {
30213
+ var secondByte, thirdByte, fourthByte, tempCodePoint;
30214
+ switch (bytesPerSequence) {
30215
+ case 1:
30216
+ if (firstByte < 128) {
30217
+ codePoint = firstByte;
30218
+ }
30219
+ break;
30220
+ case 2:
30221
+ secondByte = buf2[i + 1];
30222
+ if ((secondByte & 192) === 128) {
30223
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
30224
+ if (tempCodePoint > 127) {
30225
+ codePoint = tempCodePoint;
30226
+ }
30227
+ }
30228
+ break;
30229
+ case 3:
30230
+ secondByte = buf2[i + 1];
30231
+ thirdByte = buf2[i + 2];
30232
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
30233
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
30234
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
30235
+ codePoint = tempCodePoint;
30236
+ }
30237
+ }
30238
+ break;
30239
+ case 4:
30240
+ secondByte = buf2[i + 1];
30241
+ thirdByte = buf2[i + 2];
30242
+ fourthByte = buf2[i + 3];
30243
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
30244
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
30245
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
30246
+ codePoint = tempCodePoint;
30247
+ }
30248
+ }
30249
+ }
30250
+ }
30251
+ if (codePoint === null) {
30252
+ codePoint = 65533;
30253
+ bytesPerSequence = 1;
30254
+ } else if (codePoint > 65535) {
30255
+ codePoint -= 65536;
30256
+ res.push(codePoint >>> 10 & 1023 | 55296);
30257
+ codePoint = 56320 | codePoint & 1023;
30258
+ }
30259
+ res.push(codePoint);
30260
+ i += bytesPerSequence;
30261
+ }
30262
+ return decodeCodePointsArray2(res);
30263
+ }
30264
+ __name(utf8Slice2, "utf8Slice");
30265
+ var MAX_ARGUMENTS_LENGTH2 = 4096;
30266
+ function decodeCodePointsArray2(codePoints) {
30267
+ var len = codePoints.length;
30268
+ if (len <= MAX_ARGUMENTS_LENGTH2) {
30269
+ return String.fromCharCode.apply(String, codePoints);
30270
+ }
30271
+ var res = "";
30272
+ var i = 0;
30273
+ while (i < len) {
30274
+ res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH2));
30275
+ }
30276
+ return res;
30277
+ }
30278
+ __name(decodeCodePointsArray2, "decodeCodePointsArray");
30279
+ function asciiSlice(buf2, start, end) {
30280
+ var ret = "";
30281
+ end = Math.min(buf2.length, end);
30282
+ for (var i = start; i < end; ++i) {
30283
+ ret += String.fromCharCode(buf2[i] & 127);
30284
+ }
30285
+ return ret;
30286
+ }
30287
+ __name(asciiSlice, "asciiSlice");
30288
+ function latin1Slice(buf2, start, end) {
30289
+ var ret = "";
30290
+ end = Math.min(buf2.length, end);
30291
+ for (var i = start; i < end; ++i) {
30292
+ ret += String.fromCharCode(buf2[i]);
30293
+ }
30294
+ return ret;
30295
+ }
30296
+ __name(latin1Slice, "latin1Slice");
30297
+ function hexSlice(buf2, start, end) {
30298
+ var len = buf2.length;
30299
+ if (!start || start < 0)
30300
+ start = 0;
30301
+ if (!end || end < 0 || end > len)
30302
+ end = len;
30303
+ var out = "";
30304
+ for (var i = start; i < end; ++i) {
30305
+ out += hexSliceLookupTable[buf2[i]];
30306
+ }
30307
+ return out;
30308
+ }
30309
+ __name(hexSlice, "hexSlice");
30310
+ function utf16leSlice(buf2, start, end) {
30311
+ var bytes = buf2.slice(start, end);
30312
+ var res = "";
30313
+ for (var i = 0; i < bytes.length - 1; i += 2) {
30314
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
30315
+ }
30316
+ return res;
30317
+ }
30318
+ __name(utf16leSlice, "utf16leSlice");
30319
+ Buffer3.prototype.slice = /* @__PURE__ */ __name(function slice2(start, end) {
30320
+ var len = this.length;
30321
+ start = ~~start;
30322
+ end = end === void 0 ? len : ~~end;
30323
+ if (start < 0) {
30324
+ start += len;
30325
+ if (start < 0)
30326
+ start = 0;
30327
+ } else if (start > len) {
30328
+ start = len;
30329
+ }
30330
+ if (end < 0) {
30331
+ end += len;
30332
+ if (end < 0)
30333
+ end = 0;
30334
+ } else if (end > len) {
30335
+ end = len;
30336
+ }
30337
+ if (end < start)
30338
+ end = start;
30339
+ var newBuf = this.subarray(start, end);
30340
+ Object.setPrototypeOf(newBuf, Buffer3.prototype);
30341
+ return newBuf;
30342
+ }, "slice");
30343
+ function checkOffset(offset, ext, length2) {
30344
+ if (offset % 1 !== 0 || offset < 0)
30345
+ throw new RangeError("offset is not uint");
30346
+ if (offset + ext > length2)
30347
+ throw new RangeError("Trying to access beyond buffer length");
30348
+ }
30349
+ __name(checkOffset, "checkOffset");
30350
+ Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = /* @__PURE__ */ __name(function readUIntLE(offset, byteLength2, noAssert) {
30351
+ offset = offset >>> 0;
30352
+ byteLength2 = byteLength2 >>> 0;
30353
+ if (!noAssert)
30354
+ checkOffset(offset, byteLength2, this.length);
30355
+ var val = this[offset];
30356
+ var mul3 = 1;
30357
+ var i = 0;
30358
+ while (++i < byteLength2 && (mul3 *= 256)) {
30359
+ val += this[offset + i] * mul3;
30360
+ }
30361
+ return val;
30362
+ }, "readUIntLE");
30363
+ Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = /* @__PURE__ */ __name(function readUIntBE(offset, byteLength2, noAssert) {
30364
+ offset = offset >>> 0;
30365
+ byteLength2 = byteLength2 >>> 0;
30366
+ if (!noAssert) {
30367
+ checkOffset(offset, byteLength2, this.length);
30368
+ }
30369
+ var val = this[offset + --byteLength2];
30370
+ var mul3 = 1;
30371
+ while (byteLength2 > 0 && (mul3 *= 256)) {
30372
+ val += this[offset + --byteLength2] * mul3;
30373
+ }
30374
+ return val;
30375
+ }, "readUIntBE");
30376
+ Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = /* @__PURE__ */ __name(function readUInt8(offset, noAssert) {
30377
+ offset = offset >>> 0;
30378
+ if (!noAssert)
30379
+ checkOffset(offset, 1, this.length);
30380
+ return this[offset];
30381
+ }, "readUInt8");
30382
+ Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = /* @__PURE__ */ __name(function readUInt16LE(offset, noAssert) {
30383
+ offset = offset >>> 0;
30384
+ if (!noAssert)
30385
+ checkOffset(offset, 2, this.length);
30386
+ return this[offset] | this[offset + 1] << 8;
30387
+ }, "readUInt16LE");
30388
+ Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = /* @__PURE__ */ __name(function readUInt16BE(offset, noAssert) {
30389
+ offset = offset >>> 0;
30390
+ if (!noAssert)
30391
+ checkOffset(offset, 2, this.length);
30392
+ return this[offset] << 8 | this[offset + 1];
30393
+ }, "readUInt16BE");
30394
+ Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = /* @__PURE__ */ __name(function readUInt32LE(offset, noAssert) {
30395
+ offset = offset >>> 0;
30396
+ if (!noAssert)
30397
+ checkOffset(offset, 4, this.length);
30398
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
30399
+ }, "readUInt32LE");
30400
+ Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = /* @__PURE__ */ __name(function readUInt32BE(offset, noAssert) {
30401
+ offset = offset >>> 0;
30402
+ if (!noAssert)
30403
+ checkOffset(offset, 4, this.length);
30404
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
30405
+ }, "readUInt32BE");
30406
+ Buffer3.prototype.readIntLE = /* @__PURE__ */ __name(function readIntLE(offset, byteLength2, noAssert) {
30407
+ offset = offset >>> 0;
30408
+ byteLength2 = byteLength2 >>> 0;
30409
+ if (!noAssert)
30410
+ checkOffset(offset, byteLength2, this.length);
30411
+ var val = this[offset];
30412
+ var mul3 = 1;
30413
+ var i = 0;
30414
+ while (++i < byteLength2 && (mul3 *= 256)) {
30415
+ val += this[offset + i] * mul3;
30416
+ }
30417
+ mul3 *= 128;
30418
+ if (val >= mul3)
30419
+ val -= Math.pow(2, 8 * byteLength2);
30420
+ return val;
30421
+ }, "readIntLE");
30422
+ Buffer3.prototype.readIntBE = /* @__PURE__ */ __name(function readIntBE(offset, byteLength2, noAssert) {
30423
+ offset = offset >>> 0;
30424
+ byteLength2 = byteLength2 >>> 0;
30425
+ if (!noAssert)
30426
+ checkOffset(offset, byteLength2, this.length);
30427
+ var i = byteLength2;
30428
+ var mul3 = 1;
30429
+ var val = this[offset + --i];
30430
+ while (i > 0 && (mul3 *= 256)) {
30431
+ val += this[offset + --i] * mul3;
30432
+ }
30433
+ mul3 *= 128;
30434
+ if (val >= mul3)
30435
+ val -= Math.pow(2, 8 * byteLength2);
30436
+ return val;
30437
+ }, "readIntBE");
30438
+ Buffer3.prototype.readInt8 = /* @__PURE__ */ __name(function readInt8(offset, noAssert) {
30439
+ offset = offset >>> 0;
30440
+ if (!noAssert)
30441
+ checkOffset(offset, 1, this.length);
30442
+ if (!(this[offset] & 128))
30443
+ return this[offset];
30444
+ return (255 - this[offset] + 1) * -1;
30445
+ }, "readInt8");
30446
+ Buffer3.prototype.readInt16LE = /* @__PURE__ */ __name(function readInt16LE(offset, noAssert) {
30447
+ offset = offset >>> 0;
30448
+ if (!noAssert)
30449
+ checkOffset(offset, 2, this.length);
30450
+ var val = this[offset] | this[offset + 1] << 8;
30451
+ return val & 32768 ? val | 4294901760 : val;
30452
+ }, "readInt16LE");
30453
+ Buffer3.prototype.readInt16BE = /* @__PURE__ */ __name(function readInt16BE(offset, noAssert) {
30454
+ offset = offset >>> 0;
30455
+ if (!noAssert)
30456
+ checkOffset(offset, 2, this.length);
30457
+ var val = this[offset + 1] | this[offset] << 8;
30458
+ return val & 32768 ? val | 4294901760 : val;
30459
+ }, "readInt16BE");
30460
+ Buffer3.prototype.readInt32LE = /* @__PURE__ */ __name(function readInt32LE(offset, noAssert) {
30461
+ offset = offset >>> 0;
30462
+ if (!noAssert)
30463
+ checkOffset(offset, 4, this.length);
30464
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
30465
+ }, "readInt32LE");
30466
+ Buffer3.prototype.readInt32BE = /* @__PURE__ */ __name(function readInt32BE(offset, noAssert) {
30467
+ offset = offset >>> 0;
30468
+ if (!noAssert)
30469
+ checkOffset(offset, 4, this.length);
30470
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
30471
+ }, "readInt32BE");
30472
+ Buffer3.prototype.readFloatLE = /* @__PURE__ */ __name(function readFloatLE(offset, noAssert) {
30473
+ offset = offset >>> 0;
30474
+ if (!noAssert)
30475
+ checkOffset(offset, 4, this.length);
30476
+ return ieee754.read(this, offset, true, 23, 4);
30477
+ }, "readFloatLE");
30478
+ Buffer3.prototype.readFloatBE = /* @__PURE__ */ __name(function readFloatBE(offset, noAssert) {
30479
+ offset = offset >>> 0;
30480
+ if (!noAssert)
30481
+ checkOffset(offset, 4, this.length);
30482
+ return ieee754.read(this, offset, false, 23, 4);
30483
+ }, "readFloatBE");
30484
+ Buffer3.prototype.readDoubleLE = /* @__PURE__ */ __name(function readDoubleLE(offset, noAssert) {
30485
+ offset = offset >>> 0;
30486
+ if (!noAssert)
30487
+ checkOffset(offset, 8, this.length);
30488
+ return ieee754.read(this, offset, true, 52, 8);
30489
+ }, "readDoubleLE");
30490
+ Buffer3.prototype.readDoubleBE = /* @__PURE__ */ __name(function readDoubleBE(offset, noAssert) {
30491
+ offset = offset >>> 0;
30492
+ if (!noAssert)
30493
+ checkOffset(offset, 8, this.length);
30494
+ return ieee754.read(this, offset, false, 52, 8);
30495
+ }, "readDoubleBE");
30496
+ function checkInt(buf2, value, offset, ext, max, min) {
30497
+ if (!Buffer3.isBuffer(buf2))
30498
+ throw new TypeError('"buffer" argument must be a Buffer instance');
30499
+ if (value > max || value < min)
30500
+ throw new RangeError('"value" argument is out of bounds');
30501
+ if (offset + ext > buf2.length)
30502
+ throw new RangeError("Index out of range");
30503
+ }
30504
+ __name(checkInt, "checkInt");
30505
+ Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = /* @__PURE__ */ __name(function writeUIntLE(value, offset, byteLength2, noAssert) {
30506
+ value = +value;
30507
+ offset = offset >>> 0;
30508
+ byteLength2 = byteLength2 >>> 0;
30509
+ if (!noAssert) {
30510
+ var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
30511
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
30512
+ }
30513
+ var mul3 = 1;
30514
+ var i = 0;
30515
+ this[offset] = value & 255;
30516
+ while (++i < byteLength2 && (mul3 *= 256)) {
30517
+ this[offset + i] = value / mul3 & 255;
30518
+ }
30519
+ return offset + byteLength2;
30520
+ }, "writeUIntLE");
30521
+ Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = /* @__PURE__ */ __name(function writeUIntBE(value, offset, byteLength2, noAssert) {
30522
+ value = +value;
30523
+ offset = offset >>> 0;
30524
+ byteLength2 = byteLength2 >>> 0;
30525
+ if (!noAssert) {
30526
+ var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
30527
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
30528
+ }
30529
+ var i = byteLength2 - 1;
30530
+ var mul3 = 1;
30531
+ this[offset + i] = value & 255;
30532
+ while (--i >= 0 && (mul3 *= 256)) {
30533
+ this[offset + i] = value / mul3 & 255;
30534
+ }
30535
+ return offset + byteLength2;
30536
+ }, "writeUIntBE");
30537
+ Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = /* @__PURE__ */ __name(function writeUInt8(value, offset, noAssert) {
30538
+ value = +value;
30539
+ offset = offset >>> 0;
30540
+ if (!noAssert)
30541
+ checkInt(this, value, offset, 1, 255, 0);
30542
+ this[offset] = value & 255;
30543
+ return offset + 1;
30544
+ }, "writeUInt8");
30545
+ Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = /* @__PURE__ */ __name(function writeUInt16LE(value, offset, noAssert) {
30546
+ value = +value;
30547
+ offset = offset >>> 0;
30548
+ if (!noAssert)
30549
+ checkInt(this, value, offset, 2, 65535, 0);
30550
+ this[offset] = value & 255;
30551
+ this[offset + 1] = value >>> 8;
30552
+ return offset + 2;
30553
+ }, "writeUInt16LE");
30554
+ Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = /* @__PURE__ */ __name(function writeUInt16BE(value, offset, noAssert) {
30555
+ value = +value;
30556
+ offset = offset >>> 0;
30557
+ if (!noAssert)
30558
+ checkInt(this, value, offset, 2, 65535, 0);
30559
+ this[offset] = value >>> 8;
30560
+ this[offset + 1] = value & 255;
30561
+ return offset + 2;
30562
+ }, "writeUInt16BE");
30563
+ Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = /* @__PURE__ */ __name(function writeUInt32LE(value, offset, noAssert) {
30564
+ value = +value;
30565
+ offset = offset >>> 0;
30566
+ if (!noAssert)
30567
+ checkInt(this, value, offset, 4, 4294967295, 0);
30568
+ this[offset + 3] = value >>> 24;
30569
+ this[offset + 2] = value >>> 16;
30570
+ this[offset + 1] = value >>> 8;
30571
+ this[offset] = value & 255;
30572
+ return offset + 4;
30573
+ }, "writeUInt32LE");
30574
+ Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = /* @__PURE__ */ __name(function writeUInt32BE(value, offset, noAssert) {
30575
+ value = +value;
30576
+ offset = offset >>> 0;
30577
+ if (!noAssert)
30578
+ checkInt(this, value, offset, 4, 4294967295, 0);
30579
+ this[offset] = value >>> 24;
30580
+ this[offset + 1] = value >>> 16;
30581
+ this[offset + 2] = value >>> 8;
30582
+ this[offset + 3] = value & 255;
30583
+ return offset + 4;
30584
+ }, "writeUInt32BE");
30585
+ Buffer3.prototype.writeIntLE = /* @__PURE__ */ __name(function writeIntLE(value, offset, byteLength2, noAssert) {
30586
+ value = +value;
30587
+ offset = offset >>> 0;
30588
+ if (!noAssert) {
30589
+ var limit = Math.pow(2, 8 * byteLength2 - 1);
30590
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
30591
+ }
30592
+ var i = 0;
30593
+ var mul3 = 1;
30594
+ var sub = 0;
30595
+ this[offset] = value & 255;
30596
+ while (++i < byteLength2 && (mul3 *= 256)) {
30597
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
30598
+ sub = 1;
30599
+ }
30600
+ this[offset + i] = (value / mul3 >> 0) - sub & 255;
30601
+ }
30602
+ return offset + byteLength2;
30603
+ }, "writeIntLE");
30604
+ Buffer3.prototype.writeIntBE = /* @__PURE__ */ __name(function writeIntBE(value, offset, byteLength2, noAssert) {
30605
+ value = +value;
30606
+ offset = offset >>> 0;
30607
+ if (!noAssert) {
30608
+ var limit = Math.pow(2, 8 * byteLength2 - 1);
30609
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
30610
+ }
30611
+ var i = byteLength2 - 1;
30612
+ var mul3 = 1;
30613
+ var sub = 0;
30614
+ this[offset + i] = value & 255;
30615
+ while (--i >= 0 && (mul3 *= 256)) {
30616
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
30617
+ sub = 1;
30618
+ }
30619
+ this[offset + i] = (value / mul3 >> 0) - sub & 255;
30620
+ }
30621
+ return offset + byteLength2;
30622
+ }, "writeIntBE");
30623
+ Buffer3.prototype.writeInt8 = /* @__PURE__ */ __name(function writeInt8(value, offset, noAssert) {
30624
+ value = +value;
30625
+ offset = offset >>> 0;
30626
+ if (!noAssert)
30627
+ checkInt(this, value, offset, 1, 127, -128);
30628
+ if (value < 0)
30629
+ value = 255 + value + 1;
30630
+ this[offset] = value & 255;
30631
+ return offset + 1;
30632
+ }, "writeInt8");
30633
+ Buffer3.prototype.writeInt16LE = /* @__PURE__ */ __name(function writeInt16LE(value, offset, noAssert) {
30634
+ value = +value;
30635
+ offset = offset >>> 0;
30636
+ if (!noAssert)
30637
+ checkInt(this, value, offset, 2, 32767, -32768);
30638
+ this[offset] = value & 255;
30639
+ this[offset + 1] = value >>> 8;
30640
+ return offset + 2;
30641
+ }, "writeInt16LE");
30642
+ Buffer3.prototype.writeInt16BE = /* @__PURE__ */ __name(function writeInt16BE(value, offset, noAssert) {
30643
+ value = +value;
30644
+ offset = offset >>> 0;
30645
+ if (!noAssert)
30646
+ checkInt(this, value, offset, 2, 32767, -32768);
30647
+ this[offset] = value >>> 8;
30648
+ this[offset + 1] = value & 255;
30649
+ return offset + 2;
30650
+ }, "writeInt16BE");
30651
+ Buffer3.prototype.writeInt32LE = /* @__PURE__ */ __name(function writeInt32LE(value, offset, noAssert) {
30652
+ value = +value;
30653
+ offset = offset >>> 0;
30654
+ if (!noAssert)
30655
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
30656
+ this[offset] = value & 255;
30657
+ this[offset + 1] = value >>> 8;
30658
+ this[offset + 2] = value >>> 16;
30659
+ this[offset + 3] = value >>> 24;
30660
+ return offset + 4;
30661
+ }, "writeInt32LE");
30662
+ Buffer3.prototype.writeInt32BE = /* @__PURE__ */ __name(function writeInt32BE(value, offset, noAssert) {
30663
+ value = +value;
30664
+ offset = offset >>> 0;
30665
+ if (!noAssert)
30666
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
30667
+ if (value < 0)
30668
+ value = 4294967295 + value + 1;
30669
+ this[offset] = value >>> 24;
30670
+ this[offset + 1] = value >>> 16;
30671
+ this[offset + 2] = value >>> 8;
30672
+ this[offset + 3] = value & 255;
30673
+ return offset + 4;
30674
+ }, "writeInt32BE");
30675
+ function checkIEEE754(buf2, value, offset, ext, max, min) {
30676
+ if (offset + ext > buf2.length)
30677
+ throw new RangeError("Index out of range");
30678
+ if (offset < 0)
30679
+ throw new RangeError("Index out of range");
30680
+ }
30681
+ __name(checkIEEE754, "checkIEEE754");
30682
+ function writeFloat(buf2, value, offset, littleEndian, noAssert) {
30683
+ value = +value;
30684
+ offset = offset >>> 0;
30685
+ if (!noAssert) {
30686
+ checkIEEE754(buf2, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
30687
+ }
30688
+ ieee754.write(buf2, value, offset, littleEndian, 23, 4);
30689
+ return offset + 4;
30690
+ }
30691
+ __name(writeFloat, "writeFloat");
30692
+ Buffer3.prototype.writeFloatLE = /* @__PURE__ */ __name(function writeFloatLE(value, offset, noAssert) {
30693
+ return writeFloat(this, value, offset, true, noAssert);
30694
+ }, "writeFloatLE");
30695
+ Buffer3.prototype.writeFloatBE = /* @__PURE__ */ __name(function writeFloatBE(value, offset, noAssert) {
30696
+ return writeFloat(this, value, offset, false, noAssert);
30697
+ }, "writeFloatBE");
30698
+ function writeDouble(buf2, value, offset, littleEndian, noAssert) {
30699
+ value = +value;
30700
+ offset = offset >>> 0;
30701
+ if (!noAssert) {
30702
+ checkIEEE754(buf2, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
30703
+ }
30704
+ ieee754.write(buf2, value, offset, littleEndian, 52, 8);
30705
+ return offset + 8;
30706
+ }
30707
+ __name(writeDouble, "writeDouble");
30708
+ Buffer3.prototype.writeDoubleLE = /* @__PURE__ */ __name(function writeDoubleLE(value, offset, noAssert) {
30709
+ return writeDouble(this, value, offset, true, noAssert);
30710
+ }, "writeDoubleLE");
30711
+ Buffer3.prototype.writeDoubleBE = /* @__PURE__ */ __name(function writeDoubleBE(value, offset, noAssert) {
30712
+ return writeDouble(this, value, offset, false, noAssert);
30713
+ }, "writeDoubleBE");
30714
+ Buffer3.prototype.copy = /* @__PURE__ */ __name(function copy(target, targetStart, start, end) {
30715
+ if (!Buffer3.isBuffer(target))
30716
+ throw new TypeError("argument should be a Buffer");
30717
+ if (!start)
30718
+ start = 0;
30719
+ if (!end && end !== 0)
30720
+ end = this.length;
30721
+ if (targetStart >= target.length)
30722
+ targetStart = target.length;
30723
+ if (!targetStart)
30724
+ targetStart = 0;
30725
+ if (end > 0 && end < start)
30726
+ end = start;
30727
+ if (end === start)
30728
+ return 0;
30729
+ if (target.length === 0 || this.length === 0)
30730
+ return 0;
30731
+ if (targetStart < 0) {
30732
+ throw new RangeError("targetStart out of bounds");
30733
+ }
30734
+ if (start < 0 || start >= this.length)
30735
+ throw new RangeError("Index out of range");
30736
+ if (end < 0)
30737
+ throw new RangeError("sourceEnd out of bounds");
30738
+ if (end > this.length)
30739
+ end = this.length;
30740
+ if (target.length - targetStart < end - start) {
30741
+ end = target.length - targetStart + start;
30742
+ }
30743
+ var len = end - start;
30744
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
30745
+ this.copyWithin(targetStart, start, end);
30746
+ } else {
30747
+ Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
30748
+ }
30749
+ return len;
30750
+ }, "copy");
30751
+ Buffer3.prototype.fill = /* @__PURE__ */ __name(function fill(val, start, end, encoding) {
30752
+ if (typeof val === "string") {
30753
+ if (typeof start === "string") {
30754
+ encoding = start;
30755
+ start = 0;
30756
+ end = this.length;
30757
+ } else if (typeof end === "string") {
30758
+ encoding = end;
30759
+ end = this.length;
30760
+ }
30761
+ if (encoding !== void 0 && typeof encoding !== "string") {
30762
+ throw new TypeError("encoding must be a string");
30763
+ }
30764
+ if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
30765
+ throw new TypeError("Unknown encoding: " + encoding);
30766
+ }
30767
+ if (val.length === 1) {
30768
+ var code5 = val.charCodeAt(0);
30769
+ if (encoding === "utf8" && code5 < 128 || encoding === "latin1") {
30770
+ val = code5;
30771
+ }
30772
+ }
30773
+ } else if (typeof val === "number") {
30774
+ val = val & 255;
30775
+ } else if (typeof val === "boolean") {
30776
+ val = Number(val);
30777
+ }
30778
+ if (start < 0 || this.length < start || this.length < end) {
30779
+ throw new RangeError("Out of range index");
30780
+ }
30781
+ if (end <= start) {
30782
+ return this;
30783
+ }
30784
+ start = start >>> 0;
30785
+ end = end === void 0 ? this.length : end >>> 0;
30786
+ if (!val)
30787
+ val = 0;
30788
+ var i;
30789
+ if (typeof val === "number") {
30790
+ for (i = start; i < end; ++i) {
30791
+ this[i] = val;
30792
+ }
30793
+ } else {
30794
+ var bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
30795
+ var len = bytes.length;
30796
+ if (len === 0) {
30797
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
30798
+ }
30799
+ for (i = 0; i < end - start; ++i) {
30800
+ this[i + start] = bytes[i % len];
30801
+ }
30802
+ }
30803
+ return this;
30804
+ }, "fill");
30805
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
30806
+ function base64clean(str) {
30807
+ str = str.split("=")[0];
30808
+ str = str.trim().replace(INVALID_BASE64_RE, "");
30809
+ if (str.length < 2)
30810
+ return "";
30811
+ while (str.length % 4 !== 0) {
30812
+ str = str + "=";
30813
+ }
30814
+ return str;
30815
+ }
30816
+ __name(base64clean, "base64clean");
30817
+ function utf8ToBytes2(string2, units) {
30818
+ units = units || Infinity;
30819
+ var codePoint;
30820
+ var length2 = string2.length;
30821
+ var leadSurrogate = null;
30822
+ var bytes = [];
30823
+ for (var i = 0; i < length2; ++i) {
30824
+ codePoint = string2.charCodeAt(i);
30825
+ if (codePoint > 55295 && codePoint < 57344) {
30826
+ if (!leadSurrogate) {
30827
+ if (codePoint > 56319) {
30828
+ if ((units -= 3) > -1)
30829
+ bytes.push(239, 191, 189);
30830
+ continue;
30831
+ } else if (i + 1 === length2) {
30832
+ if ((units -= 3) > -1)
30833
+ bytes.push(239, 191, 189);
30834
+ continue;
30835
+ }
30836
+ leadSurrogate = codePoint;
30837
+ continue;
30838
+ }
30839
+ if (codePoint < 56320) {
30840
+ if ((units -= 3) > -1)
30841
+ bytes.push(239, 191, 189);
30842
+ leadSurrogate = codePoint;
30843
+ continue;
30844
+ }
30845
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
30846
+ } else if (leadSurrogate) {
30847
+ if ((units -= 3) > -1)
30848
+ bytes.push(239, 191, 189);
30849
+ }
30850
+ leadSurrogate = null;
30851
+ if (codePoint < 128) {
30852
+ if ((units -= 1) < 0)
30853
+ break;
30854
+ bytes.push(codePoint);
30855
+ } else if (codePoint < 2048) {
30856
+ if ((units -= 2) < 0)
30857
+ break;
30858
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
30859
+ } else if (codePoint < 65536) {
30860
+ if ((units -= 3) < 0)
30861
+ break;
30862
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
30863
+ } else if (codePoint < 1114112) {
30864
+ if ((units -= 4) < 0)
30865
+ break;
30866
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
30867
+ } else {
30868
+ throw new Error("Invalid code point");
30869
+ }
30870
+ }
30871
+ return bytes;
30872
+ }
30873
+ __name(utf8ToBytes2, "utf8ToBytes");
30874
+ function asciiToBytes(str) {
30875
+ var byteArray = [];
30876
+ for (var i = 0; i < str.length; ++i) {
30877
+ byteArray.push(str.charCodeAt(i) & 255);
30878
+ }
30879
+ return byteArray;
30880
+ }
30881
+ __name(asciiToBytes, "asciiToBytes");
30882
+ function utf16leToBytes(str, units) {
30883
+ var c, hi, lo;
30884
+ var byteArray = [];
30885
+ for (var i = 0; i < str.length; ++i) {
30886
+ if ((units -= 2) < 0)
30887
+ break;
30888
+ c = str.charCodeAt(i);
30889
+ hi = c >> 8;
30890
+ lo = c % 256;
30891
+ byteArray.push(lo);
30892
+ byteArray.push(hi);
30893
+ }
30894
+ return byteArray;
30895
+ }
30896
+ __name(utf16leToBytes, "utf16leToBytes");
30897
+ function base64ToBytes2(str) {
30898
+ return base642.toByteArray(base64clean(str));
30899
+ }
30900
+ __name(base64ToBytes2, "base64ToBytes");
30901
+ function blitBuffer(src2, dst, offset, length2) {
30902
+ for (var i = 0; i < length2; ++i) {
30903
+ if (i + offset >= dst.length || i >= src2.length)
30904
+ break;
30905
+ dst[i + offset] = src2[i];
30906
+ }
30907
+ return i;
30908
+ }
30909
+ __name(blitBuffer, "blitBuffer");
30910
+ function isInstance(obj, type) {
30911
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
30912
+ }
30913
+ __name(isInstance, "isInstance");
30914
+ function numberIsNaN(obj) {
30915
+ return obj !== obj;
30916
+ }
30917
+ __name(numberIsNaN, "numberIsNaN");
30918
+ var hexSliceLookupTable = function() {
30919
+ var alphabet3 = "0123456789abcdef";
30920
+ var table = new Array(256);
30921
+ for (var i = 0; i < 16; ++i) {
30922
+ var i16 = i * 16;
30923
+ for (var j = 0; j < 16; ++j) {
30924
+ table[i16 + j] = alphabet3[i] + alphabet3[j];
30925
+ }
30926
+ }
30927
+ return table;
30928
+ }();
30929
+ }
30930
+ });
30931
+
29271
30932
  // src/wallet/plugins/EthereumPlugin/erc20.abi.json
29272
30933
  var require_erc20_abi = __commonJS({
29273
30934
  "src/wallet/plugins/EthereumPlugin/erc20.abi.json"(exports, module2) {
@@ -35278,34 +36939,6 @@ import "abort-controller/polyfill";
35278
36939
  import crypto2 from "isomorphic-webcrypto";
35279
36940
  if (typeof window === "undefined" && !globalThis.crypto)
35280
36941
  globalThis.crypto = crypto2;
35281
- var crypto_default = crypto2;
35282
-
35283
- // src/wallet/base/functions/passwordToKey.ts
35284
- var passwordToKey = /* @__PURE__ */ __name((password, salt = "salt", iterations = 1e5, digest2 = "SHA-256") => __async(void 0, null, function* () {
35285
- var saltBuffer = Buffer.from(salt);
35286
- var passphraseKey = Buffer.from(password);
35287
- return crypto_default.subtle.importKey("raw", passphraseKey, { name: "PBKDF2" }, false, [
35288
- "deriveBits",
35289
- "deriveKey"
35290
- ]).then(function(key2) {
35291
- return crypto_default.subtle.deriveKey({
35292
- name: "PBKDF2",
35293
- salt: saltBuffer,
35294
- iterations,
35295
- hash: digest2
35296
- }, key2, { name: "AES-CBC", length: 256 }, true, ["encrypt", "decrypt"]);
35297
- }).then((webKey) => {
35298
- return crypto_default.subtle.exportKey("raw", webKey);
35299
- }).then((buffer2) => {
35300
- return new Uint8Array(buffer2);
35301
- });
35302
- }), "passwordToKey");
35303
-
35304
- // src/wallet/base/functions/seedToId.ts
35305
- var seedToId = /* @__PURE__ */ __name((seed) => __async(void 0, null, function* () {
35306
- const buffer2 = yield crypto_default.subtle.digest("SHA-256", seed);
35307
- return `urn:digest:${Buffer.from(new Int8Array(buffer2)).toString("hex")}`;
35308
- }), "seedToId");
35309
36942
 
35310
36943
  // src/wallet/base/wallet.ts
35311
36944
  var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async(void 0, null, function* () {
@@ -36081,20 +37714,20 @@ var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async(void 0, null, fu
36081
37714
  issueCredential: (_wallet, credential, options, keypair) => __async(void 0, null, function* () {
36082
37715
  return JSON.parse(yield issueCredential(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
36083
37716
  }),
36084
- verifyCredential: (_wallet, credential) => __async(void 0, null, function* () {
36085
- return JSON.parse(yield verifyCredential(JSON.stringify(credential), "{}"));
37717
+ verifyCredential: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, options = {}) {
37718
+ return JSON.parse(yield verifyCredential(JSON.stringify(credential), JSON.stringify(options)));
36086
37719
  }),
36087
37720
  issuePresentation: (_wallet, presentation, options, keypair) => __async(void 0, null, function* () {
36088
37721
  return JSON.parse(yield issuePresentation(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair)));
36089
37722
  }),
36090
- verifyPresentation: (_wallet, presentation) => __async(void 0, null, function* () {
36091
- return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), "{}"));
37723
+ verifyPresentation: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, presentation, options = {}) {
37724
+ return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), JSON.stringify(options)));
36092
37725
  }),
36093
37726
  contextLoader: (_wallet, url) => __async(void 0, null, function* () {
36094
37727
  return JSON.parse(yield contextLoader(url));
36095
37728
  }),
36096
- resolveDid: (_wallet, did) => __async(void 0, null, function* () {
36097
- return JSON.parse(yield resolveDID(did, "{}"));
37729
+ resolveDid: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, did, inputMetadata = {}) {
37730
+ return JSON.parse(yield resolveDID(did, JSON.stringify(inputMetadata)));
36098
37731
  })
36099
37732
  }
36100
37733
  };
@@ -36115,8 +37748,1493 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
36115
37748
  }
36116
37749
  }), "ExpirationPlugin");
36117
37750
 
36118
- // src/wallet/helpers/wallet.helpers.ts
36119
- var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
37751
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/utils.js
37752
+ var RPC_ERRORS = {
37753
+ ParseError: {
37754
+ message: "Parse error",
37755
+ code: -32700
37756
+ },
37757
+ InvalidRequest: {
37758
+ message: "Invalid Request",
37759
+ code: -32600
37760
+ },
37761
+ MethodNotFound: {
37762
+ message: "Method not found",
37763
+ code: -32601
37764
+ },
37765
+ InvalidParams: {
37766
+ message: "Invalid params",
37767
+ code: -32602
37768
+ },
37769
+ InternalError: {
37770
+ message: "Internal Error",
37771
+ code: -32603
37772
+ },
37773
+ ServerError: {
37774
+ message: "Server error",
37775
+ code: -32e3
37776
+ }
37777
+ };
37778
+ function parseUrl(url, base4) {
37779
+ if (base4 === void 0) {
37780
+ base4 = window.location.href;
37781
+ }
37782
+ if (typeof URL === "function") {
37783
+ return new URL(url, base4);
37784
+ }
37785
+ if (typeof url !== "string") {
37786
+ throw new TypeError('"url" must be a string.');
37787
+ }
37788
+ if (!url.includes(":")) {
37789
+ if (base4.startsWith("http") && !url.startsWith("/")) {
37790
+ url = base4 + "/" + url;
37791
+ } else {
37792
+ url = base4 + url;
37793
+ }
37794
+ }
37795
+ const parser = document.createElement("a");
37796
+ parser.href = url;
37797
+ let origin = (parser.protocol || window.location.protocol) + "//";
37798
+ if (parser.host) {
37799
+ if (parser.protocol === "http:" && parser.port === "80" || parser.protocol === "https:" && parser.port === "443") {
37800
+ origin += parser.hostname;
37801
+ } else {
37802
+ origin += parser.host;
37803
+ }
37804
+ } else {
37805
+ origin += window.location.host;
37806
+ }
37807
+ let pathname = parser.pathname;
37808
+ if (!pathname.startsWith("/")) {
37809
+ pathname = "/" + pathname;
37810
+ }
37811
+ return {
37812
+ host: parser.host || window.location.host,
37813
+ hostname: parser.hostname,
37814
+ origin,
37815
+ protocol: parser.protocol,
37816
+ pathname
37817
+ };
37818
+ }
37819
+ __name(parseUrl, "parseUrl");
37820
+ function uuidv4(a, b) {
37821
+ for (b = a = ""; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : "-")
37822
+ ;
37823
+ return b;
37824
+ }
37825
+ __name(uuidv4, "uuidv4");
37826
+ function isValidMessage(message) {
37827
+ return message && typeof message === "object" && message.jsonrpc === "2.0" && message.id && typeof message.id === "string";
37828
+ }
37829
+ __name(isValidMessage, "isValidMessage");
37830
+ function isValidRequest(message) {
37831
+ return isValidMessage(message) && Array.isArray(message.params);
37832
+ }
37833
+ __name(isValidRequest, "isValidRequest");
37834
+ function isValidResponse(message) {
37835
+ return isValidMessage(message) && !!("result" in message ^ "error" in message) && (!("error" in message) || isValidError(message.error));
37836
+ }
37837
+ __name(isValidResponse, "isValidResponse");
37838
+ function isValidError(error) {
37839
+ return error && typeof error === "object" && typeof error.code === "number" && typeof error.message === "string";
37840
+ }
37841
+ __name(isValidError, "isValidError");
37842
+ function serializeError(error) {
37843
+ const err = {
37844
+ message: error.message
37845
+ };
37846
+ if (error.constructor.name !== "Error") {
37847
+ err.constructor = error.constructor.name;
37848
+ }
37849
+ if ("name" in error) {
37850
+ err.name = error.name;
37851
+ }
37852
+ if ("code" in error) {
37853
+ err.code = error.code;
37854
+ } else {
37855
+ err.code = RPC_ERRORS.ServerError.code;
37856
+ }
37857
+ if ("details" in error) {
37858
+ err.details = error.details;
37859
+ }
37860
+ return err;
37861
+ }
37862
+ __name(serializeError, "serializeError");
37863
+ function deserializeError(error) {
37864
+ let err;
37865
+ if (error.constructor === "DOMException") {
37866
+ err = new DOMException(error.message, error.name);
37867
+ } else {
37868
+ err = new Error(error.message);
37869
+ if ("code" in error) {
37870
+ err.code = error.code;
37871
+ }
37872
+ }
37873
+ if (error.details) {
37874
+ err.details = error.details;
37875
+ }
37876
+ return err;
37877
+ }
37878
+ __name(deserializeError, "deserializeError");
37879
+ function createMessageListener({ listener: listener2, origin, handle, expectRequest }) {
37880
+ if (isHandlePromise(handle)) {
37881
+ const promise = handle;
37882
+ handle = false;
37883
+ promise.then((h) => handle = h);
37884
+ }
37885
+ return (e) => {
37886
+ if (!(e.source === handle && e.origin === origin && (expectRequest && isValidRequest(e.data) || !expectRequest && isValidResponse(e.data)))) {
37887
+ return;
37888
+ }
37889
+ listener2(e.data, e);
37890
+ };
37891
+ }
37892
+ __name(createMessageListener, "createMessageListener");
37893
+ function destructureMethodName(fqMethodName) {
37894
+ let [name5, ...rest] = fqMethodName.split(".");
37895
+ const method = rest.pop();
37896
+ name5 = [name5, ...rest].join(".");
37897
+ return { name: name5, method };
37898
+ }
37899
+ __name(destructureMethodName, "destructureMethodName");
37900
+ function isHandlePromise(handle) {
37901
+ try {
37902
+ return typeof handle.then === "function";
37903
+ } catch (e) {
37904
+ }
37905
+ return false;
37906
+ }
37907
+ __name(isHandlePromise, "isHandlePromise");
37908
+
37909
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/Client.js
37910
+ var RPC_CLIENT_CALL_TIMEOUT = 3e4;
37911
+ var Client = class {
37912
+ constructor() {
37913
+ this.origin = null;
37914
+ this._handle = null;
37915
+ this._listener = null;
37916
+ this._pending = /* @__PURE__ */ new Map();
37917
+ }
37918
+ connect(origin, options) {
37919
+ return __async(this, null, function* () {
37920
+ if (this._listener) {
37921
+ throw new Error("Already connected.");
37922
+ }
37923
+ options = options || {};
37924
+ const self2 = this;
37925
+ self2.origin = parseUrl(origin).origin;
37926
+ self2._handle = options.handle || window.opener || window.parent;
37927
+ const pending = self2._pending;
37928
+ self2._listener = createMessageListener({
37929
+ origin: self2.origin,
37930
+ handle: self2._handle,
37931
+ expectRequest: false,
37932
+ listener: (message) => {
37933
+ if (!pending.has(message.id)) {
37934
+ return;
37935
+ }
37936
+ const { resolve, reject, cancelTimeout } = pending.get(message.id);
37937
+ cancelTimeout();
37938
+ if ("result" in message) {
37939
+ return resolve(message.result);
37940
+ }
37941
+ reject(deserializeError(message.error));
37942
+ }
37943
+ });
37944
+ window.addEventListener("message", self2._listener);
37945
+ return new Injector(self2);
37946
+ });
37947
+ }
37948
+ send(_0, _1, _2) {
37949
+ return __async(this, arguments, function* (qualifiedMethodName, parameters, {
37950
+ timeout = RPC_CLIENT_CALL_TIMEOUT
37951
+ }) {
37952
+ if (!this._listener) {
37953
+ throw new Error("RPC client not connected.");
37954
+ }
37955
+ const self2 = this;
37956
+ const message = {
37957
+ jsonrpc: "2.0",
37958
+ id: uuidv4(),
37959
+ method: qualifiedMethodName,
37960
+ params: parameters
37961
+ };
37962
+ if (isHandlePromise(self2._handle)) {
37963
+ const handle = yield self2._handle;
37964
+ handle.postMessage(message, self2.origin);
37965
+ } else {
37966
+ self2._handle.postMessage(message, self2.origin);
37967
+ }
37968
+ return new Promise((resolve, reject) => {
37969
+ const pending = self2._pending;
37970
+ let cancelTimeout;
37971
+ if (timeout > 0) {
37972
+ const timeoutId = setTimeout(() => {
37973
+ pending.delete(message.id);
37974
+ reject(new Error("RPC call timed out."));
37975
+ }, timeout);
37976
+ cancelTimeout = /* @__PURE__ */ __name(() => {
37977
+ pending.delete(message.id);
37978
+ clearTimeout(timeoutId);
37979
+ }, "cancelTimeout");
37980
+ } else {
37981
+ cancelTimeout = /* @__PURE__ */ __name(() => {
37982
+ pending.delete(message.id);
37983
+ }, "cancelTimeout");
37984
+ }
37985
+ pending.set(message.id, { resolve, reject, cancelTimeout });
37986
+ });
37987
+ });
37988
+ }
37989
+ close() {
37990
+ if (this._listener) {
37991
+ window.removeEventListener("message", this._listener);
37992
+ this._handle = this.origin = this._listener = null;
37993
+ for (const value of this._pending.values()) {
37994
+ value.reject(new Error("RPC client closed."));
37995
+ }
37996
+ this._pending = /* @__PURE__ */ new Map();
37997
+ }
37998
+ }
37999
+ };
38000
+ __name(Client, "Client");
38001
+ var Injector = class {
38002
+ constructor(client) {
38003
+ this.client = client;
38004
+ this._apis = /* @__PURE__ */ new Map();
38005
+ }
38006
+ define(name5, definition) {
38007
+ if (!(name5 && typeof name5 === "string")) {
38008
+ throw new TypeError("`name` must be a non-empty string.");
38009
+ }
38010
+ if (!(definition && typeof definition === "object" && Array.isArray(definition.functions))) {
38011
+ throw new TypeError("`definition.function` must be an array of function names or function definition objects to be defined.");
38012
+ }
38013
+ const self2 = this;
38014
+ const api = {};
38015
+ definition.functions.forEach((fn) => {
38016
+ if (typeof fn === "string") {
38017
+ fn = { name: fn, options: {} };
38018
+ }
38019
+ api[fn.name] = function() {
38020
+ return __async(this, arguments, function* () {
38021
+ return self2.client.send(name5 + "." + fn.name, [...arguments], fn.options);
38022
+ });
38023
+ };
38024
+ });
38025
+ self2._apis[name5] = api;
38026
+ return api;
38027
+ }
38028
+ get(name5, definition) {
38029
+ const api = this._apis[name5];
38030
+ if (!api) {
38031
+ if (definition) {
38032
+ return this.define(name5, definition);
38033
+ }
38034
+ throw new Error(`API "${name5}" has not been defined.`);
38035
+ }
38036
+ return this._apis[name5];
38037
+ }
38038
+ };
38039
+ __name(Injector, "Injector");
38040
+
38041
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/EventEmitter.js
38042
+ var EventEmitter = class {
38043
+ constructor({ deserialize = /* @__PURE__ */ __name((e) => e, "deserialize"), waitUntil = /* @__PURE__ */ __name(() => __async(this, null, function* () {
38044
+ }), "waitUntil") } = {}) {
38045
+ this._listeners = [];
38046
+ this._deserialize = deserialize;
38047
+ this._waitUntil = waitUntil;
38048
+ }
38049
+ emit(event) {
38050
+ return __async(this, null, function* () {
38051
+ event = this._deserialize(event);
38052
+ (this._listeners[event.type] || []).forEach((l) => l(event));
38053
+ return this._waitUntil(event);
38054
+ });
38055
+ }
38056
+ addEventListener(eventType, fn) {
38057
+ if (!this._listeners[eventType]) {
38058
+ this._listeners[eventType] = [fn];
38059
+ } else {
38060
+ this._listeners[eventType].push(fn);
38061
+ }
38062
+ }
38063
+ removeEventListener(eventType, fn) {
38064
+ const listeners = this._listeners[eventType];
38065
+ if (!listeners) {
38066
+ return;
38067
+ }
38068
+ const idx = listeners.indexOf(fn);
38069
+ if (idx !== -1) {
38070
+ listeners.splice(idx, 1);
38071
+ }
38072
+ }
38073
+ };
38074
+ __name(EventEmitter, "EventEmitter");
38075
+
38076
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/Server.js
38077
+ var Server = class {
38078
+ constructor() {
38079
+ this.origin = null;
38080
+ this._handle = null;
38081
+ this._apis = /* @__PURE__ */ new Map();
38082
+ }
38083
+ define(name5, api) {
38084
+ if (!(name5 && typeof name5 === "string")) {
38085
+ throw new TypeError("`name` must be a non-empty string.");
38086
+ }
38087
+ if (!(api && api !== "object")) {
38088
+ throw new TypeError("`api` must be an object.");
38089
+ }
38090
+ if (name5 in this._apis) {
38091
+ throw new Error(`The "${name5}" API is already defined.`);
38092
+ }
38093
+ this._apis[name5] = api;
38094
+ }
38095
+ listen(origin, options) {
38096
+ return __async(this, null, function* () {
38097
+ if (this._listener) {
38098
+ throw new Error("Already listening.");
38099
+ }
38100
+ options = options || {};
38101
+ const self2 = this;
38102
+ self2.origin = parseUrl(origin).origin;
38103
+ self2._handle = options.handle || window.opener || window.parent;
38104
+ const ignoreUnknownApi = options.ignoreUnknownApi === "true" || false;
38105
+ self2._listener = createMessageListener({
38106
+ origin: self2.origin,
38107
+ handle: self2._handle,
38108
+ expectRequest: true,
38109
+ listener: (message) => {
38110
+ const { name: name5, method } = destructureMethodName(message.method);
38111
+ const api = self2._apis[name5];
38112
+ if (method && method.startsWith("_")) {
38113
+ return sendMethodNotFound(self2._handle, self2.origin, message);
38114
+ }
38115
+ if (!api && ignoreUnknownApi) {
38116
+ return;
38117
+ }
38118
+ if (!api || typeof api[method] !== "function") {
38119
+ return sendMethodNotFound(self2._handle, self2.origin, message);
38120
+ }
38121
+ const fn = api[method];
38122
+ (() => __async(this, null, function* () {
38123
+ const response = {
38124
+ jsonrpc: "2.0",
38125
+ id: message.id
38126
+ };
38127
+ try {
38128
+ response.result = yield fn.apply(api, message.params);
38129
+ } catch (e) {
38130
+ response.error = serializeError(e);
38131
+ }
38132
+ if (self2._handle) {
38133
+ if (isHandlePromise(self2._handle)) {
38134
+ self2._handle.then((h) => h.postMessage(response, self2.origin));
38135
+ } else {
38136
+ self2._handle.postMessage(response, self2.origin);
38137
+ }
38138
+ }
38139
+ }))();
38140
+ }
38141
+ });
38142
+ window.addEventListener("message", self2._listener);
38143
+ });
38144
+ }
38145
+ close() {
38146
+ if (this._listener) {
38147
+ window.removeEventListener("message", this._listener);
38148
+ this._handle = this.origin = this._listener = null;
38149
+ }
38150
+ }
38151
+ };
38152
+ __name(Server, "Server");
38153
+ function sendMethodNotFound(handle, origin, message) {
38154
+ const response = {
38155
+ jsonrpc: "2.0",
38156
+ id: message.id,
38157
+ error: Object.assign({}, RPC_ERRORS.MethodNotFound)
38158
+ };
38159
+ if (isHandlePromise(handle)) {
38160
+ return handle.then((h) => h.postMessage(response, origin));
38161
+ } else {
38162
+ return handle.postMessage(response, origin);
38163
+ }
38164
+ }
38165
+ __name(sendMethodNotFound, "sendMethodNotFound");
38166
+
38167
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebApp.js
38168
+ var WebApp = class {
38169
+ constructor(relyingOrigin) {
38170
+ this.relyingOrigin = parseUrl(relyingOrigin).origin;
38171
+ this.client = null;
38172
+ this.injector = null;
38173
+ this.client = new Client();
38174
+ this.server = new Server();
38175
+ this._control = null;
38176
+ this._connected = false;
38177
+ }
38178
+ connect() {
38179
+ return __async(this, null, function* () {
38180
+ this.injector = yield this.client.connect(this.relyingOrigin);
38181
+ this._connected = true;
38182
+ this._control = this.injector.define("core.control", {
38183
+ functions: ["ready", "show", "hide"]
38184
+ });
38185
+ this.server.listen(this.relyingOrigin);
38186
+ return this.injector;
38187
+ });
38188
+ }
38189
+ ready() {
38190
+ return __async(this, null, function* () {
38191
+ if (!this._connected) {
38192
+ throw new Error('WebApp not connected. Did you call ".connect()"?');
38193
+ }
38194
+ yield this._control.ready();
38195
+ return this;
38196
+ });
38197
+ }
38198
+ close() {
38199
+ if (this._connected) {
38200
+ this.server.close();
38201
+ this.client.close();
38202
+ this._connected = false;
38203
+ }
38204
+ }
38205
+ show() {
38206
+ return __async(this, null, function* () {
38207
+ if (!this._connected) {
38208
+ throw new Error('Cannot "show" yet; not connected. Did you call ".connect()"?');
38209
+ }
38210
+ return this._control.show();
38211
+ });
38212
+ }
38213
+ hide() {
38214
+ return __async(this, null, function* () {
38215
+ if (!this._connected) {
38216
+ throw new Error('Cannot "hide" yet; not connected. Did you call ".connect()?"');
38217
+ }
38218
+ return this._control.hide();
38219
+ });
38220
+ }
38221
+ };
38222
+ __name(WebApp, "WebApp");
38223
+
38224
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowDialog.js
38225
+ var WebAppWindowDialog = class {
38226
+ constructor() {
38227
+ this._closeEventListeners = /* @__PURE__ */ new Set();
38228
+ }
38229
+ addEventListener(name5, listener2) {
38230
+ if (name5 !== "close") {
38231
+ throw new Error(`Unknown event "${name5}".`);
38232
+ }
38233
+ if (typeof listener2 !== "function") {
38234
+ throw new TypeError('"listener" must be a function.');
38235
+ }
38236
+ this._closeEventListeners.add(listener2);
38237
+ }
38238
+ removeEventListener(name5, listener2) {
38239
+ if (name5 !== "close") {
38240
+ throw new Error(`Unknown event "${name5}".`);
38241
+ }
38242
+ if (typeof listener2 !== "function") {
38243
+ throw new TypeError('"listener" must be a function.');
38244
+ }
38245
+ this._closeEventListeners.delete(listener2);
38246
+ }
38247
+ show() {
38248
+ }
38249
+ close() {
38250
+ for (const listener2 of this._closeEventListeners) {
38251
+ listener2({});
38252
+ }
38253
+ }
38254
+ destroy() {
38255
+ this._closeEventListeners.clear();
38256
+ }
38257
+ };
38258
+ __name(WebAppWindowDialog, "WebAppWindowDialog");
38259
+
38260
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowInlineDialog.js
38261
+ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
38262
+ constructor({ url, handle, className }) {
38263
+ super();
38264
+ this.url = url;
38265
+ this.handle = handle;
38266
+ this.dialog = document.createElement("dialog");
38267
+ applyStyle(this.dialog, {
38268
+ position: "fixed",
38269
+ top: 0,
38270
+ left: 0,
38271
+ width: "100%",
38272
+ height: "100%",
38273
+ "max-width": "100%",
38274
+ "max-height": "100%",
38275
+ display: "none",
38276
+ margin: 0,
38277
+ padding: 0,
38278
+ border: "none",
38279
+ background: "transparent",
38280
+ color: "black",
38281
+ "box-sizing": "border-box",
38282
+ overflow: "hidden",
38283
+ "z-index": 1e6
38284
+ });
38285
+ this.dialog.className = "web-app-window";
38286
+ if (typeof className === "string") {
38287
+ this.dialog.className = this.dialog.className + " " + className;
38288
+ }
38289
+ const style = document.createElement("style");
38290
+ style.appendChild(document.createTextNode(`dialog.web-app-window::backdrop {
38291
+ background-color: transparent;
38292
+ }`));
38293
+ this.container = document.createElement("div");
38294
+ applyStyle(this.container, {
38295
+ position: "relative",
38296
+ width: "100%",
38297
+ height: "100%",
38298
+ margin: 0,
38299
+ padding: 0,
38300
+ display: "flex",
38301
+ "flex-direction": "column"
38302
+ });
38303
+ this.container.className = "web-app-window-backdrop";
38304
+ this.iframe = document.createElement("iframe");
38305
+ this.iframe.src = url;
38306
+ this.iframe.scrolling = "auto";
38307
+ applyStyle(this.iframe, {
38308
+ position: "fixed",
38309
+ top: 0,
38310
+ left: 0,
38311
+ width: "100%",
38312
+ height: "100%",
38313
+ border: "none",
38314
+ background: "transparent",
38315
+ overflow: "hidden",
38316
+ margin: 0,
38317
+ padding: 0,
38318
+ "flex-grow": 1
38319
+ });
38320
+ this.dialog.appendChild(style);
38321
+ this.container.appendChild(this.iframe);
38322
+ this.dialog.appendChild(this.container);
38323
+ this.dialog.addEventListener("cancel", (e) => {
38324
+ e.preventDefault();
38325
+ this.hide();
38326
+ });
38327
+ document.body.appendChild(this.dialog);
38328
+ this.handle = this.iframe.contentWindow;
38329
+ }
38330
+ show() {
38331
+ this.dialog.style.display = "block";
38332
+ if (this.dialog.showModal) {
38333
+ this.dialog.showModal();
38334
+ }
38335
+ }
38336
+ close() {
38337
+ this.dialog.style.display = "none";
38338
+ if (this.dialog.close) {
38339
+ try {
38340
+ this.dialog.close();
38341
+ } catch (e) {
38342
+ console.error(e);
38343
+ }
38344
+ }
38345
+ super.close();
38346
+ }
38347
+ destroy() {
38348
+ this.dialog.parentNode.removeChild(this.dialog);
38349
+ super.destroy();
38350
+ }
38351
+ };
38352
+ __name(WebAppWindowInlineDialog, "WebAppWindowInlineDialog");
38353
+ function applyStyle(element, style) {
38354
+ for (const name5 in style) {
38355
+ element.style[name5] = style[name5];
38356
+ }
38357
+ }
38358
+ __name(applyStyle, "applyStyle");
38359
+
38360
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowPopupDialog.js
38361
+ var WebAppWindowPopupDialog = class extends WebAppWindowDialog {
38362
+ constructor({ url, handle, bounds = { width: 500, height: 400 } }) {
38363
+ super();
38364
+ this.url = url;
38365
+ this.handle = handle;
38366
+ this._locationChanging = false;
38367
+ if (!handle) {
38368
+ this._openWindow({ url, name: "web-app-window", bounds });
38369
+ }
38370
+ this.destroyed = false;
38371
+ this._removeListeners = () => {
38372
+ };
38373
+ }
38374
+ show() {
38375
+ }
38376
+ close() {
38377
+ this.destroy();
38378
+ }
38379
+ destroy() {
38380
+ if (this.handle && !this.destroyed) {
38381
+ this.handle.close();
38382
+ super.close();
38383
+ this.handle = null;
38384
+ this.destroyed = true;
38385
+ this._removeListeners();
38386
+ super.destroy();
38387
+ }
38388
+ }
38389
+ isClosed() {
38390
+ return !this.handle || this.handle.closed;
38391
+ }
38392
+ _openWindow({ url, name: name5, bounds }) {
38393
+ const { x, y } = bounds;
38394
+ let { width = 500, height = 400 } = bounds;
38395
+ width = Math.min(width, window.innerWidth);
38396
+ height = Math.min(height, window.innerHeight);
38397
+ const left = x !== void 0 ? x : window.screenX + (window.innerWidth - width) / 2;
38398
+ const top = y !== void 0 ? y : window.screenY + (window.innerHeight - height) / 2;
38399
+ const features = `popup=yes,menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=${width},height=${height},left=${left},top=${top}`;
38400
+ this._locationChanging = true;
38401
+ this.handle = window.open(url, name5, features);
38402
+ this._addListeners();
38403
+ }
38404
+ setLocation(url) {
38405
+ this.url = url;
38406
+ this._locationChanging = true;
38407
+ this.handle.location.replace(url);
38408
+ }
38409
+ _addListeners() {
38410
+ const destroyDialog = /* @__PURE__ */ __name(() => this.destroy(), "destroyDialog");
38411
+ const loadDialog = /* @__PURE__ */ __name(() => {
38412
+ this._locationChanging = false;
38413
+ }, "loadDialog");
38414
+ const unloadDialog = /* @__PURE__ */ __name(() => {
38415
+ if (this._locationChanging) {
38416
+ return;
38417
+ }
38418
+ this.destroy();
38419
+ }, "unloadDialog");
38420
+ this.handle.addEventListener("unload", unloadDialog);
38421
+ this.handle.addEventListener("load", loadDialog);
38422
+ window.addEventListener("beforeUnload", destroyDialog, { once: true });
38423
+ const intervalId = setInterval(() => {
38424
+ if (this.isClosed()) {
38425
+ this.destroy();
38426
+ clearInterval(intervalId);
38427
+ }
38428
+ }, 250);
38429
+ this._removeListeners = () => {
38430
+ clearInterval(intervalId);
38431
+ this.handle.removeListener("unload", unloadDialog);
38432
+ this.handle.removeListener("load", loadDialog);
38433
+ window.removeEventListener("beforeUnload", destroyDialog);
38434
+ };
38435
+ }
38436
+ };
38437
+ __name(WebAppWindowPopupDialog, "WebAppWindowPopupDialog");
38438
+
38439
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindow.js
38440
+ var LOAD_WINDOW_TIMEOUT = 6e4;
38441
+ var WebAppWindow = class {
38442
+ constructor(url, {
38443
+ timeout = LOAD_WINDOW_TIMEOUT,
38444
+ dialog = null,
38445
+ handle,
38446
+ popup = false,
38447
+ className = null,
38448
+ customize = null,
38449
+ bounds
38450
+ } = {}) {
38451
+ this.visible = false;
38452
+ this.dialog = dialog;
38453
+ this.handle = null;
38454
+ this.popup = popup;
38455
+ this.windowControl = null;
38456
+ this._destroyed = false;
38457
+ this._ready = false;
38458
+ this._private = {};
38459
+ this._timeoutId = null;
38460
+ if (handle && handle._dialog) {
38461
+ this.dialog = dialog = handle._dialog;
38462
+ }
38463
+ this._private._readyPromise = new Promise((resolve, reject) => {
38464
+ this._timeoutId = setTimeout(() => reject(new DOMException("Loading Web application window timed out.", "TimeoutError")), timeout);
38465
+ this._private._resolveReady = (value) => {
38466
+ clearTimeout(this.timeoutId);
38467
+ this._timeoutId = null;
38468
+ resolve(value);
38469
+ };
38470
+ this._private._rejectReady = (err) => {
38471
+ clearTimeout(this.timeoutId);
38472
+ this._timeoutId = null;
38473
+ reject(err);
38474
+ };
38475
+ });
38476
+ this._private.isReady = () => __async(this, null, function* () {
38477
+ return this._private._readyPromise;
38478
+ });
38479
+ this._private.destroy = () => {
38480
+ if (this._timeoutId) {
38481
+ this._private._rejectReady(new DOMException("Web application window closed before ready.", "AbortError"));
38482
+ }
38483
+ if (!this._destroyed) {
38484
+ this.dialog.destroy();
38485
+ this.dialog = null;
38486
+ this._destroyed = true;
38487
+ }
38488
+ };
38489
+ if (customize) {
38490
+ if (!typeof customize === "function") {
38491
+ throw new TypeError("`options.customize` must be a function.");
38492
+ }
38493
+ }
38494
+ if (!this.dialog) {
38495
+ if (this.popup) {
38496
+ this.dialog = new WebAppWindowPopupDialog({ url, handle, bounds });
38497
+ } else {
38498
+ this.dialog = new WebAppWindowInlineDialog({ url, handle, className });
38499
+ }
38500
+ } else if (this.popup && bounds) {
38501
+ if (bounds) {
38502
+ const { top: y, left: x, width, height } = bounds;
38503
+ if (x !== void 0 && y !== void 0) {
38504
+ this.dialog.handle.moveTo(x, y);
38505
+ }
38506
+ if (width !== void 0 && height !== void 0) {
38507
+ this.dialog.handle.resizeTo(width, height);
38508
+ }
38509
+ }
38510
+ }
38511
+ this.handle = this.dialog.handle;
38512
+ if (customize) {
38513
+ try {
38514
+ customize({
38515
+ dialog: this.dialog.dialog,
38516
+ container: this.dialog.container,
38517
+ iframe: this.dialog.iframe,
38518
+ webAppWindow: this
38519
+ });
38520
+ } catch (e) {
38521
+ console.error(e);
38522
+ }
38523
+ }
38524
+ }
38525
+ ready() {
38526
+ this._ready = true;
38527
+ this._private._resolveReady(true);
38528
+ }
38529
+ show() {
38530
+ if (!this.visible) {
38531
+ this.visible = true;
38532
+ const body = document.querySelector("body");
38533
+ this._bodyOverflowStyle = body.style.overflow;
38534
+ body.style.overflow = "hidden";
38535
+ if (!this._destroyed) {
38536
+ this.dialog.show();
38537
+ } else if (this.windowControl.show) {
38538
+ this.windowControl.show();
38539
+ }
38540
+ }
38541
+ }
38542
+ hide() {
38543
+ if (this.visible) {
38544
+ this.visible = false;
38545
+ const body = document.querySelector("body");
38546
+ if (this._bodyOverflowStyle) {
38547
+ body.style.overflow = this._bodyOverflowStyle;
38548
+ } else {
38549
+ body.style.overflow = "";
38550
+ }
38551
+ if (!this._destroyed) {
38552
+ this.dialog.close();
38553
+ } else if (this.windowControl.hide) {
38554
+ this.windowControl.hide();
38555
+ }
38556
+ }
38557
+ }
38558
+ };
38559
+ __name(WebAppWindow, "WebAppWindow");
38560
+
38561
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppContext.js
38562
+ var WEB_APP_CONTEXT_LOAD_TIMEOUT = 1e4;
38563
+ var WebAppContext = class {
38564
+ constructor() {
38565
+ this.client = new Client();
38566
+ this.server = new Server();
38567
+ this.injector = null;
38568
+ this.control = null;
38569
+ this.loaded = false;
38570
+ this.closed = false;
38571
+ }
38572
+ createWindow(_0) {
38573
+ return __async(this, arguments, function* (url, {
38574
+ timeout = WEB_APP_CONTEXT_LOAD_TIMEOUT,
38575
+ iframe,
38576
+ dialog = null,
38577
+ popup = false,
38578
+ handle,
38579
+ windowControl,
38580
+ className,
38581
+ customize,
38582
+ bounds
38583
+ } = {}) {
38584
+ if (this.loaded) {
38585
+ throw new Error("AppContext already loaded.");
38586
+ }
38587
+ this.loaded = true;
38588
+ this.control = new WebAppWindow(url, {
38589
+ timeout,
38590
+ dialog,
38591
+ iframe,
38592
+ popup,
38593
+ handle,
38594
+ windowControl,
38595
+ className,
38596
+ customize,
38597
+ bounds
38598
+ });
38599
+ window.addEventListener("pagehide", () => this.close(), { once: true });
38600
+ this.server.define("core.control", this.control);
38601
+ const origin = parseUrl(url).origin;
38602
+ this.server.listen(origin, {
38603
+ handle: this.control.handle,
38604
+ ignoreUnknownApi: true
38605
+ });
38606
+ yield this.control._private.isReady();
38607
+ this.injector = yield this.client.connect(origin, {
38608
+ handle: this.control.handle
38609
+ });
38610
+ return this.injector;
38611
+ });
38612
+ }
38613
+ close() {
38614
+ if (!this.closed) {
38615
+ this.closed = true;
38616
+ this.control._private.destroy();
38617
+ this.server.close();
38618
+ this.client.close();
38619
+ }
38620
+ }
38621
+ };
38622
+ __name(WebAppContext, "WebAppContext");
38623
+
38624
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialRequestEvent.js
38625
+ var CredentialRequestEvent = class {
38626
+ constructor({
38627
+ credentialHandler,
38628
+ credentialRequestOrigin,
38629
+ credentialRequestOptions,
38630
+ hintKey
38631
+ }) {
38632
+ this.type = "credentialrequest";
38633
+ this._credentialHandler = credentialHandler;
38634
+ this.credentialRequestOrigin = credentialRequestOrigin;
38635
+ this.credentialRequestOptions = credentialRequestOptions;
38636
+ this.hintKey = hintKey;
38637
+ }
38638
+ openWindow(url) {
38639
+ return __async(this, null, function* () {
38640
+ yield this._credentialHandler.show();
38641
+ const appWindow = new WebAppWindow(url, {
38642
+ className: "credential-handler"
38643
+ });
38644
+ appWindow.ready();
38645
+ appWindow.show();
38646
+ appWindow.handle._dialog = appWindow.dialog;
38647
+ return appWindow.handle;
38648
+ });
38649
+ }
38650
+ respondWith(handlerResponse) {
38651
+ this._promise = handlerResponse;
38652
+ }
38653
+ };
38654
+ __name(CredentialRequestEvent, "CredentialRequestEvent");
38655
+
38656
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialStoreEvent.js
38657
+ var CredentialStoreEvent = class {
38658
+ constructor({
38659
+ credentialHandler,
38660
+ credentialRequestOrigin,
38661
+ credential,
38662
+ hintKey
38663
+ }) {
38664
+ this.type = "credentialstore";
38665
+ this._credentialHandler = credentialHandler;
38666
+ this.credentialRequestOrigin = credentialRequestOrigin;
38667
+ this.credential = credential;
38668
+ this.hintKey = hintKey;
38669
+ }
38670
+ openWindow(url) {
38671
+ return __async(this, null, function* () {
38672
+ yield this._credentialHandler.show();
38673
+ const appWindow = new WebAppWindow(url);
38674
+ appWindow.ready();
38675
+ appWindow.show();
38676
+ appWindow.handle._dialog = appWindow.dialog;
38677
+ return appWindow.handle;
38678
+ });
38679
+ }
38680
+ respondWith(handlerResponse) {
38681
+ this._promise = handlerResponse;
38682
+ }
38683
+ };
38684
+ __name(CredentialStoreEvent, "CredentialStoreEvent");
38685
+
38686
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerService.js
38687
+ var CredentialHandlerService = class {
38688
+ constructor(credentialHandler) {
38689
+ this._credentialHandler = credentialHandler;
38690
+ }
38691
+ request(credentialRequestEvent) {
38692
+ return __async(this, null, function* () {
38693
+ return yield this._credentialHandler._emitter.emit(new CredentialRequestEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialRequestEvent)));
38694
+ });
38695
+ }
38696
+ store(credentialStoreEvent) {
38697
+ return __async(this, null, function* () {
38698
+ return yield this._credentialHandler._emitter.emit(new CredentialStoreEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialStoreEvent)));
38699
+ });
38700
+ }
38701
+ };
38702
+ __name(CredentialHandlerService, "CredentialHandlerService");
38703
+
38704
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandler.js
38705
+ var EVENT_TYPES = ["credentialrequest", "credentialstore"];
38706
+ var CredentialHandler = class extends WebApp {
38707
+ constructor(mediatorOrigin, inline = false) {
38708
+ if (typeof mediatorOrigin !== "string") {
38709
+ throw new TypeError('"mediatorOrigin" must be a string.');
38710
+ }
38711
+ super(mediatorOrigin, inline);
38712
+ this._emitter = new EventEmitter({
38713
+ waitUntil(event) {
38714
+ return __async(this, null, function* () {
38715
+ return event._promise || Promise.reject(new DOMException('No "credentialrequest" event handler found.', "NotFoundError"));
38716
+ });
38717
+ }
38718
+ });
38719
+ }
38720
+ connect() {
38721
+ return __async(this, null, function* () {
38722
+ const injector = yield __superGet(CredentialHandler.prototype, this, "connect").call(this);
38723
+ this.server.define("credentialHandler", new CredentialHandlerService(this));
38724
+ yield this.ready();
38725
+ return injector;
38726
+ });
38727
+ }
38728
+ addEventListener(eventType, fn) {
38729
+ if (!EVENT_TYPES.includes(eventType)) {
38730
+ throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
38731
+ }
38732
+ return this._emitter.addEventListener(eventType, fn);
38733
+ }
38734
+ removeEventListener(eventType, fn) {
38735
+ if (!EVENT_TYPES.includes(eventType)) {
38736
+ throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
38737
+ }
38738
+ return this._emitter.removeEventListener(eventType, fn);
38739
+ }
38740
+ };
38741
+ __name(CredentialHandler, "CredentialHandler");
38742
+
38743
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHints.js
38744
+ var CredentialHints = class {
38745
+ constructor(url, injector) {
38746
+ const remote = injector.get("credentialHints", {
38747
+ functions: ["delete", "get", "keys", "has", "set", "clear"]
38748
+ });
38749
+ for (let methodName in remote) {
38750
+ if (methodName !== "set") {
38751
+ const method = remote[methodName].bind(this, url);
38752
+ this[methodName] = function(...args) {
38753
+ this._deprecateNotice();
38754
+ return method(...args);
38755
+ };
38756
+ }
38757
+ }
38758
+ this._remoteSet = remote.set.bind(this, url);
38759
+ }
38760
+ set(hintKey, credentialHint) {
38761
+ return __async(this, null, function* () {
38762
+ this._deprecateNotice();
38763
+ credentialHint.icons = credentialHint.icons || [];
38764
+ const promises = credentialHint.icons.map((icon) => imageToDataUrl(icon.src).then((fetchedImage) => {
38765
+ icon.fetchedImage = fetchedImage;
38766
+ }));
38767
+ yield Promise.all(promises);
38768
+ return this._remoteSet(hintKey, credentialHint);
38769
+ });
38770
+ }
38771
+ _deprecateNotice() {
38772
+ console.warn("Credential hints are deprecated and no longer used.");
38773
+ }
38774
+ };
38775
+ __name(CredentialHints, "CredentialHints");
38776
+ function imageToDataUrl(url) {
38777
+ return new Promise((resolve) => {
38778
+ const img = new Image();
38779
+ img.crossOrigin = "Anonymous";
38780
+ img.onload = () => {
38781
+ let canvas = document.createElement("canvas");
38782
+ const ctx = canvas.getContext("2d");
38783
+ canvas.height = img.height;
38784
+ canvas.width = img.width;
38785
+ ctx.drawImage(img, 0, 0);
38786
+ const dataUrl = canvas.toDataURL();
38787
+ resolve(dataUrl);
38788
+ canvas = null;
38789
+ };
38790
+ img.onerror = () => resolve(null);
38791
+ img.src = url;
38792
+ });
38793
+ }
38794
+ __name(imageToDataUrl, "imageToDataUrl");
38795
+
38796
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialManager.js
38797
+ var CredentialManager = class {
38798
+ constructor(url, injector) {
38799
+ if (!(url && typeof url === "string")) {
38800
+ throw new TypeError('"url" must be a non-empty string.');
38801
+ }
38802
+ this.hints = new CredentialHints(url, injector);
38803
+ }
38804
+ static requestPermission() {
38805
+ return __async(this, null, function* () {
38806
+ const status = yield navigator.credentialsPolyfill.permissions.request({ name: "credentialhandler" });
38807
+ return status.state;
38808
+ });
38809
+ }
38810
+ };
38811
+ __name(CredentialManager, "CredentialManager");
38812
+
38813
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerRegistration.js
38814
+ var CredentialHandlerRegistration = class {
38815
+ constructor(url, injector) {
38816
+ if (!(url && typeof url === "string")) {
38817
+ throw new TypeError('"url" must be a non-empty string.');
38818
+ }
38819
+ this.credentialManager = new CredentialManager(url, injector);
38820
+ }
38821
+ };
38822
+ __name(CredentialHandlerRegistration, "CredentialHandlerRegistration");
38823
+
38824
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlers.js
38825
+ var CredentialHandlers = class {
38826
+ constructor(injector) {
38827
+ this._init = (() => __async(this, null, function* () {
38828
+ this._injector = yield injector;
38829
+ this._remote = this._injector.get("credentialHandlers", {
38830
+ functions: [
38831
+ "register",
38832
+ "unregister",
38833
+ "getRegistration",
38834
+ "hasRegistration"
38835
+ ]
38836
+ });
38837
+ }))();
38838
+ }
38839
+ register(url) {
38840
+ return __async(this, null, function* () {
38841
+ this._deprecateNotice();
38842
+ yield this._init;
38843
+ url = yield this._remote.register("credential", url);
38844
+ return new CredentialHandlerRegistration(url, this._injector);
38845
+ });
38846
+ }
38847
+ unregister(url) {
38848
+ return __async(this, null, function* () {
38849
+ this._deprecateNotice();
38850
+ yield this._init;
38851
+ return this._remote.unregister("credential", url);
38852
+ });
38853
+ }
38854
+ getRegistration(url) {
38855
+ return __async(this, null, function* () {
38856
+ this._deprecateNotice();
38857
+ yield this._init;
38858
+ url = yield this._remote.getRegistration("credential", url);
38859
+ if (!url) {
38860
+ return null;
38861
+ }
38862
+ return new CredentialHandlerRegistration(url, this._injector);
38863
+ });
38864
+ }
38865
+ hasRegistration(url) {
38866
+ return __async(this, null, function* () {
38867
+ this._deprecateNotice();
38868
+ yield this._init;
38869
+ return yield this._remote.hasRegistration("credential", url);
38870
+ });
38871
+ }
38872
+ _deprecateNotice() {
38873
+ console.warn('Credential handler registration APIs are deprecated. The credential handler specified in "manifest.json" is now automatically registered when a user grants permission to install a credential handler via "CredentialManager.requestPermission()".');
38874
+ }
38875
+ };
38876
+ __name(CredentialHandlers, "CredentialHandlers");
38877
+
38878
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/WebCredential.js
38879
+ var WebCredential2 = class {
38880
+ constructor(dataType, data, { recommendedHandlerOrigins = [] } = {}) {
38881
+ if (typeof dataType !== "string") {
38882
+ throw new TypeError('"dataType" must be a string.');
38883
+ }
38884
+ this.type = "web";
38885
+ this.dataType = dataType;
38886
+ this.data = data;
38887
+ this.options = { recommendedHandlerOrigins };
38888
+ }
38889
+ };
38890
+ __name(WebCredential2, "WebCredential");
38891
+
38892
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialsContainer.js
38893
+ var CREDENTIAL_GET_TIMEOUT = 0;
38894
+ var CREDENTIAL_STORE_TIMEOUT = 0;
38895
+ var CredentialsContainer = class {
38896
+ constructor(injector) {
38897
+ this._nativeCredentialsContainer = {
38898
+ get: navigator.credentials && navigator.credentials.get && navigator.credentials.get.bind(navigator.credentials),
38899
+ store: navigator.credentials && navigator.credentials.store && navigator.credentials.store.bind(navigator.credentials)
38900
+ };
38901
+ this._init = (() => __async(this, null, function* () {
38902
+ this._remote = (yield injector).get("credentialsContainer", {
38903
+ functions: [
38904
+ { name: "get", options: { timeout: CREDENTIAL_GET_TIMEOUT } },
38905
+ { name: "store", options: { timeout: CREDENTIAL_STORE_TIMEOUT } }
38906
+ ]
38907
+ });
38908
+ }))();
38909
+ }
38910
+ get() {
38911
+ return __async(this, arguments, function* (options = {}) {
38912
+ if (options.web) {
38913
+ yield this._init;
38914
+ const credential = yield this._remote.get(options);
38915
+ if (!credential) {
38916
+ return null;
38917
+ }
38918
+ return new WebCredential2(credential.dataType, credential.data);
38919
+ }
38920
+ if (this._nativeCredentialsContainer.get) {
38921
+ return this._nativeCredentialsContainer.get(options);
38922
+ }
38923
+ throw new DOMException("Not implemented.", "NotSupportedError");
38924
+ });
38925
+ }
38926
+ store(credential) {
38927
+ return __async(this, null, function* () {
38928
+ if (credential instanceof WebCredential2) {
38929
+ yield this._init;
38930
+ const result = yield this._remote.store(credential);
38931
+ if (!result) {
38932
+ return null;
38933
+ }
38934
+ return new WebCredential2(result.dataType, result.data);
38935
+ }
38936
+ if (this._nativeCredentialsContainer.store) {
38937
+ return this._nativeCredentialsContainer.store(credential);
38938
+ }
38939
+ throw new DOMException("Not implemented.", "NotSupportedError");
38940
+ });
38941
+ }
38942
+ };
38943
+ __name(CredentialsContainer, "CredentialsContainer");
38944
+
38945
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/PermissionManager.js
38946
+ var PERMISSION_REQUEST_TIMEOUT = 0;
38947
+ var PermissionManager = class {
38948
+ constructor(injector) {
38949
+ this._init = (() => __async(this, null, function* () {
38950
+ this._remote = (yield injector).get("permissionManager", {
38951
+ functions: [
38952
+ "query",
38953
+ { name: "request", options: { timeout: PERMISSION_REQUEST_TIMEOUT } },
38954
+ "revoke"
38955
+ ]
38956
+ });
38957
+ }))();
38958
+ }
38959
+ query(permissionDesc) {
38960
+ return __async(this, null, function* () {
38961
+ yield this._init;
38962
+ return yield this._remote.query(permissionDesc);
38963
+ });
38964
+ }
38965
+ request(permissionDesc) {
38966
+ return __async(this, null, function* () {
38967
+ yield this._init;
38968
+ return yield this._remote.request(permissionDesc);
38969
+ });
38970
+ }
38971
+ revoke(permissionDesc) {
38972
+ return __async(this, null, function* () {
38973
+ yield this._init;
38974
+ return yield this._remote.revoke(permissionDesc);
38975
+ });
38976
+ }
38977
+ };
38978
+ __name(PermissionManager, "PermissionManager");
38979
+
38980
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/index.js
38981
+ var DEFAULT_MEDIATOR_ORIGIN = "https://authn.io";
38982
+ var loaded;
38983
+ function loadOnce(options) {
38984
+ return __async(this, null, function* () {
38985
+ if (loaded) {
38986
+ return loaded;
38987
+ }
38988
+ loaded = true;
38989
+ return load2(options);
38990
+ });
38991
+ }
38992
+ __name(loadOnce, "loadOnce");
38993
+ function load2() {
38994
+ return __async(this, arguments, function* (options = {
38995
+ mediatorOrigin: DEFAULT_MEDIATOR_ORIGIN
38996
+ }) {
38997
+ let mediatorUrl;
38998
+ if (typeof options === "string") {
38999
+ mediatorUrl = options;
39000
+ } else if (options && typeof options === "object" && typeof options.mediatorOrigin === "string") {
39001
+ mediatorUrl = `${options.mediatorOrigin}/mediator`;
39002
+ } else {
39003
+ throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');
39004
+ }
39005
+ const appContext = new WebAppContext();
39006
+ const injector = appContext.createWindow(mediatorUrl, {
39007
+ className: "credential-mediator",
39008
+ timeout: 3e4
39009
+ });
39010
+ const style = document.createElement("style");
39011
+ style.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
39012
+ background-color: rgba(0, 0, 0, 0.25);
39013
+ }`));
39014
+ document.body.appendChild(style);
39015
+ const polyfill = {};
39016
+ polyfill.permissions = new PermissionManager(injector);
39017
+ polyfill.CredentialHandlers = new CredentialHandlers(injector);
39018
+ polyfill.CredentialHandler = CredentialHandler;
39019
+ polyfill.CredentialManager = CredentialManager;
39020
+ polyfill.credentials = new CredentialsContainer(injector);
39021
+ polyfill.WebCredential = WebCredential2;
39022
+ navigator.credentialsPolyfill = polyfill;
39023
+ if ("credentials" in navigator) {
39024
+ navigator.credentials.get = polyfill.credentials.get.bind(polyfill.credentials);
39025
+ navigator.credentials.store = polyfill.credentials.store.bind(polyfill.credentials);
39026
+ } else {
39027
+ navigator.credentials = polyfill.credentials;
39028
+ }
39029
+ window.CredentialManager = CredentialManager;
39030
+ window.WebCredential = WebCredential2;
39031
+ return polyfill;
39032
+ });
39033
+ }
39034
+ __name(load2, "load");
39035
+
39036
+ // ../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/CredentialEventProxy.js
39037
+ var PROXY_EVENT_TIMEOUT = 6e4;
39038
+ var CredentialEventProxy = class extends WebApp {
39039
+ constructor() {
39040
+ super(window.location.origin);
39041
+ }
39042
+ receive() {
39043
+ return __async(this, null, function* () {
39044
+ const self2 = this;
39045
+ yield self2.connect();
39046
+ return new Promise((resolveReceive, rejectReceive) => {
39047
+ const timeoutId = setTimeout(() => {
39048
+ rejectReceive(new Error("Timed out waiting to receive event."));
39049
+ }, PROXY_EVENT_TIMEOUT);
39050
+ self2.server.define("credentialEventProxy", {
39051
+ send(event) {
39052
+ return __async(this, null, function* () {
39053
+ resolveReceive(event);
39054
+ clearTimeout(timeoutId);
39055
+ return new Promise((resolveSend, rejectSend) => {
39056
+ event.respondWith = (promise) => {
39057
+ try {
39058
+ resolveSend(promise);
39059
+ } catch (e) {
39060
+ rejectSend(e);
39061
+ }
39062
+ };
39063
+ });
39064
+ });
39065
+ }
39066
+ });
39067
+ self2.ready();
39068
+ });
39069
+ });
39070
+ }
39071
+ };
39072
+ __name(CredentialEventProxy, "CredentialEventProxy");
39073
+
39074
+ // ../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/index.js
39075
+ var DEFAULT_MEDIATOR = "https://authn.io";
39076
+ function installHandler() {
39077
+ return __async(this, null, function* () {
39078
+ const CredentialManager2 = navigator.credentialsPolyfill.CredentialManager;
39079
+ const result = yield CredentialManager2.requestPermission();
39080
+ if (result !== "granted") {
39081
+ throw new Error("Permission denied.");
39082
+ }
39083
+ });
39084
+ }
39085
+ __name(installHandler, "installHandler");
39086
+ function activateHandler(_0) {
39087
+ return __async(this, arguments, function* ({
39088
+ mediatorOrigin = DEFAULT_MEDIATOR,
39089
+ get: get2,
39090
+ store
39091
+ }) {
39092
+ if (!(get2 || store)) {
39093
+ throw new Error('"get" or "store" function(s) must be specified.');
39094
+ }
39095
+ const CredentialHandler2 = navigator.credentialsPolyfill.CredentialHandler;
39096
+ const self2 = new CredentialHandler2(mediatorOrigin);
39097
+ if (get2) {
39098
+ if (typeof get2 !== "function") {
39099
+ throw new TypeError('"get" must be a function.');
39100
+ }
39101
+ self2.addEventListener("credentialrequest", (event) => listener({ event, get: get2 }));
39102
+ }
39103
+ if (store) {
39104
+ if (typeof store !== "function") {
39105
+ throw new TypeError('"store" must be a function.');
39106
+ }
39107
+ self2.addEventListener("credentialstore", (event) => listener({ event, store }));
39108
+ }
39109
+ yield self2.connect();
39110
+ });
39111
+ }
39112
+ __name(activateHandler, "activateHandler");
39113
+ function receiveCredentialEvent() {
39114
+ return __async(this, null, function* () {
39115
+ const proxy = new CredentialEventProxy();
39116
+ return proxy.receive();
39117
+ });
39118
+ }
39119
+ __name(receiveCredentialEvent, "receiveCredentialEvent");
39120
+ function listener({ event, get: get2, store }) {
39121
+ event.respondWith(createResponse({ event, get: get2, store }));
39122
+ }
39123
+ __name(listener, "listener");
39124
+ function createResponse(_0) {
39125
+ return __async(this, arguments, function* ({ event, get: get2, store }) {
39126
+ const result = yield (get2 || store)({ event });
39127
+ if (!(result && typeof result === "object")) {
39128
+ throw new TypeError('Return value of "get" or "store" hook must be an object.');
39129
+ }
39130
+ if (result.type === "response") {
39131
+ return { dataType: result.dataType, data: result.data };
39132
+ }
39133
+ if (result.type === "redirect") {
39134
+ const appContext = new WebAppContext();
39135
+ const handle = yield event.openWindow(result.url);
39136
+ const windowReady = appContext.createWindow(result.url, {
39137
+ handle,
39138
+ popup: false,
39139
+ timeout: 6e5
39140
+ });
39141
+ const injector = yield windowReady;
39142
+ const proxy = injector.get("credentialEventProxy", {
39143
+ functions: [{ name: "send", options: { timeout: 0 } }]
39144
+ });
39145
+ return proxy.send({
39146
+ type: event.type,
39147
+ credentialRequestOptions: event.credentialRequestOptions,
39148
+ credentialRequestOrigin: event.credentialRequestOrigin,
39149
+ credential: event.credential,
39150
+ hintKey: event.hintKey
39151
+ });
39152
+ }
39153
+ throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".');
39154
+ });
39155
+ }
39156
+ __name(createResponse, "createResponse");
39157
+
39158
+ // src/wallet/plugins/chapi/chapi.ts
39159
+ var getCHAPIPlugin = /* @__PURE__ */ __name(() => __async(void 0, null, function* () {
39160
+ if (typeof window === "undefined") {
39161
+ return {
39162
+ pluginMethods: {
39163
+ installChapiHandler: () => __async(void 0, null, function* () {
39164
+ throw new Error("CHAPI is only available inside of a browser!");
39165
+ }),
39166
+ activateChapiHandler: () => __async(void 0, null, function* () {
39167
+ throw new Error("CHAPI is only available inside of a browser!");
39168
+ }),
39169
+ receiveChapiEvent: () => __async(void 0, null, function* () {
39170
+ throw new Error("CHAPI is only available inside of a browser!");
39171
+ }),
39172
+ storeCredentialViaChapiDidAuth: () => __async(void 0, null, function* () {
39173
+ throw new Error("CHAPI is only available inside of a browser!");
39174
+ }),
39175
+ storePresentationViaChapi: () => __async(void 0, null, function* () {
39176
+ throw new Error("CHAPI is only available inside of a browser!");
39177
+ })
39178
+ }
39179
+ };
39180
+ }
39181
+ yield loadOnce();
39182
+ return {
39183
+ pluginMethods: {
39184
+ installChapiHandler: () => __async(void 0, null, function* () {
39185
+ return installHandler();
39186
+ }),
39187
+ activateChapiHandler: (_0, _1) => __async(void 0, [_0, _1], function* (_wallet, {
39188
+ mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,
39189
+ get: get2,
39190
+ store
39191
+ }) {
39192
+ return activateHandler({ mediatorOrigin, get: get2, store });
39193
+ }),
39194
+ receiveChapiEvent: () => __async(void 0, null, function* () {
39195
+ return receiveCredentialEvent();
39196
+ }),
39197
+ storeCredentialViaChapiDidAuth: (wallet, credential) => __async(void 0, null, function* () {
39198
+ var _a, _b, _c;
39199
+ const challenge = crypto.randomUUID();
39200
+ const domain = window.location.origin;
39201
+ const vpr = {
39202
+ web: {
39203
+ VerifiablePresentation: {
39204
+ query: { type: "DIDAuthentication" },
39205
+ challenge,
39206
+ domain
39207
+ }
39208
+ }
39209
+ };
39210
+ const res = yield navigator.credentials.get(vpr);
39211
+ if (!res)
39212
+ return { success: false, reason: "did not auth" };
39213
+ const verification = yield wallet.pluginMethods.verifyPresentation(res.data, {
39214
+ challenge,
39215
+ domain,
39216
+ proofPurpose: "authentication"
39217
+ });
39218
+ if (verification.warnings.length > 0 || verification.errors.length > 0) {
39219
+ return { success: false, reason: "auth failed verification" };
39220
+ }
39221
+ const subject = (_c = (_b = (_a = res.data) == null ? void 0 : _a.proof) == null ? void 0 : _b.verificationMethod) == null ? void 0 : _c.split("#")[0];
39222
+ if (!Array.isArray(credential.credentialSubject)) {
39223
+ credential.credentialSubject.id = subject;
39224
+ }
39225
+ const vp = yield wallet.pluginMethods.getTestVp(yield wallet.pluginMethods.issueCredential(credential));
39226
+ const success = yield wallet.pluginMethods.storePresentationViaChapi(vp);
39227
+ if (success)
39228
+ return { success: true };
39229
+ return { success: false, reason: "did not store" };
39230
+ }),
39231
+ storePresentationViaChapi: (_wallet, presentation) => __async(void 0, null, function* () {
39232
+ const wc = new WebCredential("VerifiablePresentation", presentation);
39233
+ return window.navigator.credentials.store(wc);
39234
+ })
39235
+ }
39236
+ };
39237
+ }), "getCHAPIPlugin");
36120
39238
 
36121
39239
  // src/wallet/plugins/vc-templates/templates.ts
36122
39240
  var VC_TEMPLATES = {
@@ -36165,9 +39283,9 @@ var VC_TEMPLATES = {
36165
39283
  };
36166
39284
 
36167
39285
  // src/wallet/plugins/vc-templates/vc-templates.ts
36168
- var getVCTemplatesPlugin = /* @__PURE__ */ __name((wallet) => {
39286
+ var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
36169
39287
  return {
36170
- pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
39288
+ pluginMethods: {
36171
39289
  newCredential: (_wallet, args = { type: "basic" }) => {
36172
39290
  var _a, _b;
36173
39291
  const did = args.did || ((_b = (_a = _wallet.pluginMethods).getSubjectDid) == null ? void 0 : _b.call(_a, "key"));
@@ -36195,7 +39313,7 @@ var getVCTemplatesPlugin = /* @__PURE__ */ __name((wallet) => {
36195
39313
  verifiableCredential: credential
36196
39314
  };
36197
39315
  })
36198
- })
39316
+ }
36199
39317
  };
36200
39318
  }, "getVCTemplatesPlugin");
36201
39319
 
@@ -39255,6 +42373,13 @@ var IDXCredentialValidator = mod.object({
39255
42373
  title: mod.string(),
39256
42374
  storageType: StorageTypeValidator.optional()
39257
42375
  });
42376
+ var JWKValidator = mod.object({
42377
+ kty: mod.string(),
42378
+ crv: mod.string(),
42379
+ x: mod.string(),
42380
+ y: mod.string().optional(),
42381
+ d: mod.string()
42382
+ });
39258
42383
 
39259
42384
  // ../../node_modules/.pnpm/date-fns@2.28.0/node_modules/date-fns/esm/_lib/toInteger/index.js
39260
42385
  function toInteger(dirtyNumber) {
@@ -40868,14 +43993,20 @@ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
40868
43993
  var emptyWallet = /* @__PURE__ */ __name((..._0) => __async(void 0, [..._0], function* ({ didkit } = {}) {
40869
43994
  const didkitWallet = yield (yield generateWallet()).addPlugin(yield getDidKitPlugin(didkit));
40870
43995
  const expirationWallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
40871
- const wallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin(expirationWallet));
43996
+ const templatesWallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin());
43997
+ const wallet = yield templatesWallet.addPlugin(yield getCHAPIPlugin());
40872
43998
  return {
40873
43999
  _wallet: wallet,
40874
44000
  newCredential: wallet.pluginMethods.newCredential,
40875
44001
  newPresentation: wallet.pluginMethods.newPresentation,
40876
44002
  verifyCredential: verifyCredential2(wallet),
40877
44003
  verifyPresentation: wallet.pluginMethods.verifyPresentation,
40878
- resolveDid: wallet.pluginMethods.resolveDid
44004
+ resolveDid: wallet.pluginMethods.resolveDid,
44005
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
44006
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
44007
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
44008
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
44009
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
40879
44010
  };
40880
44011
  }), "emptyWallet");
40881
44012
 
@@ -48878,75 +52009,75 @@ var PatchError = function(_super) {
48878
52009
  var JsonPatchError = PatchError;
48879
52010
  var deepClone = _deepClone;
48880
52011
  var objOps = {
48881
- add: function(obj, key2, document) {
52012
+ add: function(obj, key2, document2) {
48882
52013
  obj[key2] = this.value;
48883
- return { newDocument: document };
52014
+ return { newDocument: document2 };
48884
52015
  },
48885
- remove: function(obj, key2, document) {
52016
+ remove: function(obj, key2, document2) {
48886
52017
  var removed = obj[key2];
48887
52018
  delete obj[key2];
48888
- return { newDocument: document, removed };
52019
+ return { newDocument: document2, removed };
48889
52020
  },
48890
- replace: function(obj, key2, document) {
52021
+ replace: function(obj, key2, document2) {
48891
52022
  var removed = obj[key2];
48892
52023
  obj[key2] = this.value;
48893
- return { newDocument: document, removed };
52024
+ return { newDocument: document2, removed };
48894
52025
  },
48895
- move: function(obj, key2, document) {
48896
- var removed = getValueByPointer(document, this.path);
52026
+ move: function(obj, key2, document2) {
52027
+ var removed = getValueByPointer(document2, this.path);
48897
52028
  if (removed) {
48898
52029
  removed = _deepClone(removed);
48899
52030
  }
48900
- var originalValue = applyOperation(document, { op: "remove", path: this.from }).removed;
48901
- applyOperation(document, { op: "add", path: this.path, value: originalValue });
48902
- return { newDocument: document, removed };
52031
+ var originalValue = applyOperation(document2, { op: "remove", path: this.from }).removed;
52032
+ applyOperation(document2, { op: "add", path: this.path, value: originalValue });
52033
+ return { newDocument: document2, removed };
48903
52034
  },
48904
- copy: function(obj, key2, document) {
48905
- var valueToCopy = getValueByPointer(document, this.from);
48906
- applyOperation(document, { op: "add", path: this.path, value: _deepClone(valueToCopy) });
48907
- return { newDocument: document };
52035
+ copy: function(obj, key2, document2) {
52036
+ var valueToCopy = getValueByPointer(document2, this.from);
52037
+ applyOperation(document2, { op: "add", path: this.path, value: _deepClone(valueToCopy) });
52038
+ return { newDocument: document2 };
48908
52039
  },
48909
- test: function(obj, key2, document) {
48910
- return { newDocument: document, test: _areEquals(obj[key2], this.value) };
52040
+ test: function(obj, key2, document2) {
52041
+ return { newDocument: document2, test: _areEquals(obj[key2], this.value) };
48911
52042
  },
48912
- _get: function(obj, key2, document) {
52043
+ _get: function(obj, key2, document2) {
48913
52044
  this.value = obj[key2];
48914
- return { newDocument: document };
52045
+ return { newDocument: document2 };
48915
52046
  }
48916
52047
  };
48917
52048
  var arrOps = {
48918
- add: function(arr, i, document) {
52049
+ add: function(arr, i, document2) {
48919
52050
  if (isInteger2(i)) {
48920
52051
  arr.splice(i, 0, this.value);
48921
52052
  } else {
48922
52053
  arr[i] = this.value;
48923
52054
  }
48924
- return { newDocument: document, index: i };
52055
+ return { newDocument: document2, index: i };
48925
52056
  },
48926
- remove: function(arr, i, document) {
52057
+ remove: function(arr, i, document2) {
48927
52058
  var removedList = arr.splice(i, 1);
48928
- return { newDocument: document, removed: removedList[0] };
52059
+ return { newDocument: document2, removed: removedList[0] };
48929
52060
  },
48930
- replace: function(arr, i, document) {
52061
+ replace: function(arr, i, document2) {
48931
52062
  var removed = arr[i];
48932
52063
  arr[i] = this.value;
48933
- return { newDocument: document, removed };
52064
+ return { newDocument: document2, removed };
48934
52065
  },
48935
52066
  move: objOps.move,
48936
52067
  copy: objOps.copy,
48937
52068
  test: objOps.test,
48938
52069
  _get: objOps._get
48939
52070
  };
48940
- function getValueByPointer(document, pointer) {
52071
+ function getValueByPointer(document2, pointer) {
48941
52072
  if (pointer == "") {
48942
- return document;
52073
+ return document2;
48943
52074
  }
48944
52075
  var getOriginalDestination = { op: "_get", path: pointer };
48945
- applyOperation(document, getOriginalDestination);
52076
+ applyOperation(document2, getOriginalDestination);
48946
52077
  return getOriginalDestination.value;
48947
52078
  }
48948
52079
  __name(getValueByPointer, "getValueByPointer");
48949
- function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
52080
+ function applyOperation(document2, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
48950
52081
  if (validateOperation === void 0) {
48951
52082
  validateOperation = false;
48952
52083
  }
@@ -48961,54 +52092,54 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
48961
52092
  }
48962
52093
  if (validateOperation) {
48963
52094
  if (typeof validateOperation == "function") {
48964
- validateOperation(operation, 0, document, operation.path);
52095
+ validateOperation(operation, 0, document2, operation.path);
48965
52096
  } else {
48966
52097
  validator(operation, 0);
48967
52098
  }
48968
52099
  }
48969
52100
  if (operation.path === "") {
48970
- var returnValue = { newDocument: document };
52101
+ var returnValue = { newDocument: document2 };
48971
52102
  if (operation.op === "add") {
48972
52103
  returnValue.newDocument = operation.value;
48973
52104
  return returnValue;
48974
52105
  } else if (operation.op === "replace") {
48975
52106
  returnValue.newDocument = operation.value;
48976
- returnValue.removed = document;
52107
+ returnValue.removed = document2;
48977
52108
  return returnValue;
48978
52109
  } else if (operation.op === "move" || operation.op === "copy") {
48979
- returnValue.newDocument = getValueByPointer(document, operation.from);
52110
+ returnValue.newDocument = getValueByPointer(document2, operation.from);
48980
52111
  if (operation.op === "move") {
48981
- returnValue.removed = document;
52112
+ returnValue.removed = document2;
48982
52113
  }
48983
52114
  return returnValue;
48984
52115
  } else if (operation.op === "test") {
48985
- returnValue.test = _areEquals(document, operation.value);
52116
+ returnValue.test = _areEquals(document2, operation.value);
48986
52117
  if (returnValue.test === false) {
48987
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52118
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
48988
52119
  }
48989
- returnValue.newDocument = document;
52120
+ returnValue.newDocument = document2;
48990
52121
  return returnValue;
48991
52122
  } else if (operation.op === "remove") {
48992
- returnValue.removed = document;
52123
+ returnValue.removed = document2;
48993
52124
  returnValue.newDocument = null;
48994
52125
  return returnValue;
48995
52126
  } else if (operation.op === "_get") {
48996
- operation.value = document;
52127
+ operation.value = document2;
48997
52128
  return returnValue;
48998
52129
  } else {
48999
52130
  if (validateOperation) {
49000
- throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
52131
+ throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document2);
49001
52132
  } else {
49002
52133
  return returnValue;
49003
52134
  }
49004
52135
  }
49005
52136
  } else {
49006
52137
  if (!mutateDocument) {
49007
- document = _deepClone(document);
52138
+ document2 = _deepClone(document2);
49008
52139
  }
49009
52140
  var path = operation.path || "";
49010
52141
  var keys = path.split("/");
49011
- var obj = document;
52142
+ var obj = document2;
49012
52143
  var t = 1;
49013
52144
  var len = keys.length;
49014
52145
  var existingPathFragment = void 0;
@@ -49035,7 +52166,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
49035
52166
  existingPathFragment = operation.path;
49036
52167
  }
49037
52168
  if (existingPathFragment !== void 0) {
49038
- validateFunction(operation, 0, document, existingPathFragment);
52169
+ validateFunction(operation, 0, document2, existingPathFragment);
49039
52170
  }
49040
52171
  }
49041
52172
  }
@@ -49045,39 +52176,39 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
49045
52176
  key2 = obj.length;
49046
52177
  } else {
49047
52178
  if (validateOperation && !isInteger2(key2)) {
49048
- throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document);
52179
+ throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document2);
49049
52180
  } else if (isInteger2(key2)) {
49050
52181
  key2 = ~~key2;
49051
52182
  }
49052
52183
  }
49053
52184
  if (t >= len) {
49054
52185
  if (validateOperation && operation.op === "add" && key2 > obj.length) {
49055
- throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document);
52186
+ throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document2);
49056
52187
  }
49057
- var returnValue = arrOps[operation.op].call(operation, obj, key2, document);
52188
+ var returnValue = arrOps[operation.op].call(operation, obj, key2, document2);
49058
52189
  if (returnValue.test === false) {
49059
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52190
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49060
52191
  }
49061
52192
  return returnValue;
49062
52193
  }
49063
52194
  } else {
49064
52195
  if (t >= len) {
49065
- var returnValue = objOps[operation.op].call(operation, obj, key2, document);
52196
+ var returnValue = objOps[operation.op].call(operation, obj, key2, document2);
49066
52197
  if (returnValue.test === false) {
49067
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52198
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49068
52199
  }
49069
52200
  return returnValue;
49070
52201
  }
49071
52202
  }
49072
52203
  obj = obj[key2];
49073
52204
  if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
49074
- throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
52205
+ throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document2);
49075
52206
  }
49076
52207
  }
49077
52208
  }
49078
52209
  }
49079
52210
  __name(applyOperation, "applyOperation");
49080
- function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
52211
+ function applyPatch(document2, patch, validateOperation, mutateDocument, banPrototypeModifications) {
49081
52212
  if (mutateDocument === void 0) {
49082
52213
  mutateDocument = true;
49083
52214
  }
@@ -49090,72 +52221,72 @@ function applyPatch(document, patch, validateOperation, mutateDocument, banProto
49090
52221
  }
49091
52222
  }
49092
52223
  if (!mutateDocument) {
49093
- document = _deepClone(document);
52224
+ document2 = _deepClone(document2);
49094
52225
  }
49095
52226
  var results = new Array(patch.length);
49096
52227
  for (var i = 0, length_1 = patch.length; i < length_1; i++) {
49097
- results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
49098
- document = results[i].newDocument;
52228
+ results[i] = applyOperation(document2, patch[i], validateOperation, true, banPrototypeModifications, i);
52229
+ document2 = results[i].newDocument;
49099
52230
  }
49100
- results.newDocument = document;
52231
+ results.newDocument = document2;
49101
52232
  return results;
49102
52233
  }
49103
52234
  __name(applyPatch, "applyPatch");
49104
- function applyReducer(document, operation, index) {
49105
- var operationResult = applyOperation(document, operation);
52235
+ function applyReducer(document2, operation, index) {
52236
+ var operationResult = applyOperation(document2, operation);
49106
52237
  if (operationResult.test === false) {
49107
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52238
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49108
52239
  }
49109
52240
  return operationResult.newDocument;
49110
52241
  }
49111
52242
  __name(applyReducer, "applyReducer");
49112
- function validator(operation, index, document, existingPathFragment) {
52243
+ function validator(operation, index, document2, existingPathFragment) {
49113
52244
  if (typeof operation !== "object" || operation === null || Array.isArray(operation)) {
49114
- throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document);
52245
+ throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document2);
49115
52246
  } else if (!objOps[operation.op]) {
49116
- throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
52247
+ throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document2);
49117
52248
  } else if (typeof operation.path !== "string") {
49118
- throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document);
52249
+ throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document2);
49119
52250
  } else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) {
49120
- throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document);
52251
+ throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document2);
49121
52252
  } else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") {
49122
- throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document);
52253
+ throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document2);
49123
52254
  } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) {
49124
- throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document);
52255
+ throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document2);
49125
52256
  } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && hasUndefined(operation.value)) {
49126
- throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document);
49127
- } else if (document) {
52257
+ throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document2);
52258
+ } else if (document2) {
49128
52259
  if (operation.op == "add") {
49129
52260
  var pathLen = operation.path.split("/").length;
49130
52261
  var existingPathLen = existingPathFragment.split("/").length;
49131
52262
  if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
49132
- throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document);
52263
+ throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document2);
49133
52264
  }
49134
52265
  } else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") {
49135
52266
  if (operation.path !== existingPathFragment) {
49136
- throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
52267
+ throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document2);
49137
52268
  }
49138
52269
  } else if (operation.op === "move" || operation.op === "copy") {
49139
52270
  var existingValue = { op: "_get", path: operation.from, value: void 0 };
49140
- var error = validate5([existingValue], document);
52271
+ var error = validate5([existingValue], document2);
49141
52272
  if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") {
49142
- throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document);
52273
+ throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document2);
49143
52274
  }
49144
52275
  }
49145
52276
  }
49146
52277
  }
49147
52278
  __name(validator, "validator");
49148
- function validate5(sequence, document, externalValidator) {
52279
+ function validate5(sequence, document2, externalValidator) {
49149
52280
  try {
49150
52281
  if (!Array.isArray(sequence)) {
49151
52282
  throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
49152
52283
  }
49153
- if (document) {
49154
- applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);
52284
+ if (document2) {
52285
+ applyPatch(_deepClone(document2), _deepClone(sequence), externalValidator || true);
49155
52286
  } else {
49156
52287
  externalValidator = externalValidator || validator;
49157
52288
  for (var i = 0; i < sequence.length; i++) {
49158
- externalValidator(sequence[i], i, document, void 0);
52289
+ externalValidator(sequence[i], i, document2, void 0);
49159
52290
  }
49160
52291
  }
49161
52292
  } catch (e) {
@@ -49383,11 +52514,11 @@ var fast_json_patch_default = Object.assign({}, core_exports, duplex_exports, {
49383
52514
  unescapePathComponent
49384
52515
  });
49385
52516
 
49386
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
52517
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
49387
52518
  var import_lodash3 = __toESM(require_lodash(), 1);
49388
52519
  var import_random3 = __toESM(require_random(), 1);
49389
52520
 
49390
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/streamopts.js
52521
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/streamopts.js
49391
52522
  var SyncOptions;
49392
52523
  (function(SyncOptions2) {
49393
52524
  SyncOptions2[SyncOptions2["PREFER_CACHE"] = 0] = "PREFER_CACHE";
@@ -49395,7 +52526,7 @@ var SyncOptions;
49395
52526
  SyncOptions2[SyncOptions2["NEVER_SYNC"] = 2] = "NEVER_SYNC";
49396
52527
  })(SyncOptions || (SyncOptions = {}));
49397
52528
 
49398
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream.js
52529
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream.js
49399
52530
  var import_lodash = __toESM(require_lodash(), 1);
49400
52531
 
49401
52532
  // ../../node_modules/.pnpm/tslib@2.4.0/node_modules/tslib/modules/index.js
@@ -51289,7 +54420,7 @@ function throttle(durationSelector, config2) {
51289
54420
  }
51290
54421
  __name(throttle, "throttle");
51291
54422
 
51292
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream.js
54423
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream.js
51293
54424
  var SignatureStatus;
51294
54425
  (function(SignatureStatus2) {
51295
54426
  SignatureStatus2[SignatureStatus2["GENESIS"] = 0] = "GENESIS";
@@ -51368,10 +54499,10 @@ function StreamStatic() {
51368
54499
  }
51369
54500
  __name(StreamStatic, "StreamStatic");
51370
54501
 
51371
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
54502
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
51372
54503
  import fetch2 from "cross-fetch";
51373
54504
 
51374
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/abort-signal-utils.js
54505
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/abort-signal-utils.js
51375
54506
  function mergeAbortSignals(signals) {
51376
54507
  const controller = new AbortController();
51377
54508
  if (signals.length === 0) {
@@ -51421,7 +54552,7 @@ function abortable2(original, fn) {
51421
54552
  }
51422
54553
  __name(abortable2, "abortable");
51423
54554
 
51424
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
54555
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
51425
54556
  var DEFAULT_FETCH_TIMEOUT = 60 * 1e3 * 3;
51426
54557
  function fetchJson(_0) {
51427
54558
  return __async(this, arguments, function* (url, opts = {}) {
@@ -51446,10 +54577,10 @@ function fetchJson(_0) {
51446
54577
  }
51447
54578
  __name(fetchJson, "fetchJson");
51448
54579
 
51449
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
54580
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
51450
54581
  var import_lodash2 = __toESM(require_lodash(), 1);
51451
54582
 
51452
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/cid-utils.js
54583
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/cid-utils.js
51453
54584
  init_cid();
51454
54585
  function toCID(givenCid) {
51455
54586
  const cid = CID.asCID(givenCid);
@@ -51466,7 +54597,7 @@ function toCID(givenCid) {
51466
54597
  }
51467
54598
  __name(toCID, "toCID");
51468
54599
 
51469
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
54600
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
51470
54601
  var TILE_TYPE_ID = 0;
51471
54602
  var StreamUtils = class {
51472
54603
  static streamIdFromState(state) {
@@ -51646,7 +54777,7 @@ var StreamUtils = class {
51646
54777
  };
51647
54778
  __name(StreamUtils, "StreamUtils");
51648
54779
 
51649
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/accountid-utils.js
54780
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/accountid-utils.js
51650
54781
  function normalizeAccountId(accountId) {
51651
54782
  if (typeof accountId === "string" && accountId.includes("@")) {
51652
54783
  const [address, chainId] = accountId.split("@");
@@ -51659,7 +54790,7 @@ function normalizeAccountId(accountId) {
51659
54790
  }
51660
54791
  __name(normalizeAccountId, "normalizeAccountId");
51661
54792
 
51662
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream-state-subject.js
54793
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream-state-subject.js
51663
54794
  var StreamStateSubject = class extends BehaviorSubject {
51664
54795
  next(next) {
51665
54796
  const current = this.value;
@@ -51670,7 +54801,7 @@ var StreamStateSubject = class extends BehaviorSubject {
51670
54801
  };
51671
54802
  __name(StreamStateSubject, "StreamStateSubject");
51672
54803
 
51673
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
54804
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
51674
54805
  var __decorate4 = function(decorators, target, key2, desc) {
51675
54806
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
51676
54807
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -51906,7 +55037,7 @@ TileDocument = TileDocument_1 = __decorate4([
51906
55037
  StreamStatic()
51907
55038
  ], TileDocument);
51908
55039
 
51909
- // ../../node_modules/.pnpm/@glazed+tile-loader@0.2.1/node_modules/@glazed/tile-loader/dist/index.js
55040
+ // ../../node_modules/.pnpm/@glazed+tile-loader@0.2.1_@opentelemetry+api@1.1.0/node_modules/@glazed/tile-loader/dist/index.js
51910
55041
  var import_dataloader = __toESM(require_dataloader(), 1);
51911
55042
  function _checkPrivateRedeclaration2(obj, privateCollection) {
51912
55043
  if (privateCollection.has(obj)) {
@@ -52065,7 +55196,7 @@ var TileLoader = class extends import_dataloader.default {
52065
55196
  };
52066
55197
  __name(TileLoader, "TileLoader");
52067
55198
 
52068
- // ../../node_modules/.pnpm/@glazed+datamodel@0.3.1/node_modules/@glazed/datamodel/dist/index.js
55199
+ // ../../node_modules/.pnpm/@glazed+datamodel@0.3.1_@opentelemetry+api@1.1.0/node_modules/@glazed/datamodel/dist/index.js
52069
55200
  function _checkPrivateRedeclaration3(obj, privateCollection) {
52070
55201
  if (privateCollection.has(obj)) {
52071
55202
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52185,7 +55316,7 @@ var DataModel = class {
52185
55316
  };
52186
55317
  __name(DataModel, "DataModel");
52187
55318
 
52188
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/proxy.js
55319
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/proxy.js
52189
55320
  function _checkPrivateRedeclaration4(obj, privateCollection) {
52190
55321
  if (privateCollection.has(obj)) {
52191
55322
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52331,7 +55462,7 @@ var TileProxy = class {
52331
55462
  };
52332
55463
  __name(TileProxy, "TileProxy");
52333
55464
 
52334
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/utils.js
55465
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/utils.js
52335
55466
  var didRegex = /^did:([A-Za-z0-9]+):([A-Za-z0-9.\-:_]+)$/;
52336
55467
  function isDIDstring(did) {
52337
55468
  return didRegex.test(did);
@@ -52354,7 +55485,7 @@ function getIDXMetadata(did) {
52354
55485
  }
52355
55486
  __name(getIDXMetadata, "getIDXMetadata");
52356
55487
 
52357
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/index.js
55488
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/index.js
52358
55489
  function _checkPrivateRedeclaration5(obj, privateCollection) {
52359
55490
  if (privateCollection.has(obj)) {
52360
55491
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52751,13 +55882,13 @@ var DIDDataStore = class {
52751
55882
  };
52752
55883
  __name(DIDDataStore, "DIDDataStore");
52753
55884
 
52754
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/utils.js
55885
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/utils.js
52755
55886
  function typeStreamID(streamId) {
52756
55887
  return typeof streamId === "string" ? StreamID.fromString(streamId) : streamId;
52757
55888
  }
52758
55889
  __name(typeStreamID, "typeStreamID");
52759
55890
 
52760
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/document.js
55891
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/document.js
52761
55892
  var Document = class extends Observable {
52762
55893
  constructor(initial, _apiUrl, syncInterval) {
52763
55894
  super((subscriber) => {
@@ -52856,7 +55987,7 @@ var Document = class extends Observable {
52856
55987
  };
52857
55988
  __name(Document, "Document");
52858
55989
 
52859
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-caip10-link@2.1.0/node_modules/@ceramicnetwork/stream-caip10-link/lib/caip10-link.js
55990
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-caip10-link@2.1.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-caip10-link/lib/caip10-link.js
52860
55991
  var import_lodash4 = __toESM(require_lodash(), 1);
52861
55992
  var __decorate5 = function(decorators, target, key2, desc) {
52862
55993
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
@@ -52975,7 +56106,7 @@ Caip10Link = Caip10Link_1 = __decorate5([
52975
56106
  StreamStatic()
52976
56107
  ], Caip10Link);
52977
56108
 
52978
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-model@0.3.0/node_modules/@ceramicnetwork/stream-model/lib/model.js
56109
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-model@0.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-model/lib/model.js
52979
56110
  var import_random4 = __toESM(require_random(), 1);
52980
56111
  init_cid();
52981
56112
  init_digest();
@@ -53176,7 +56307,7 @@ Model = Model_1 = __decorate6([
53176
56307
  StreamStatic()
53177
56308
  ], Model);
53178
56309
 
53179
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-model-instance@0.3.0/node_modules/@ceramicnetwork/stream-model-instance/lib/model-instance-document.js
56310
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-model-instance@0.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-model-instance/lib/model-instance-document.js
53180
56311
  var import_random5 = __toESM(require_random(), 1);
53181
56312
  var __decorate7 = function(decorators, target, key2, desc) {
53182
56313
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
@@ -53331,7 +56462,7 @@ ModelInstanceDocument = ModelInstanceDocument_1 = __decorate7([
53331
56462
  StreamStatic()
53332
56463
  ], ModelInstanceDocument);
53333
56464
 
53334
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/remote-pin-api.js
56465
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/remote-pin-api.js
53335
56466
  var RemotePinApi = class {
53336
56467
  constructor(_apiUrl) {
53337
56468
  this._apiUrl = _apiUrl;
@@ -53384,7 +56515,7 @@ var RemotePinApi = class {
53384
56515
  };
53385
56516
  __name(RemotePinApi, "RemotePinApi");
53386
56517
 
53387
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/remote-index-api.js
56518
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/remote-index-api.js
53388
56519
  var RemoteIndexApi = class {
53389
56520
  constructor(apiUrl) {
53390
56521
  this._fetchJson = fetchJson;
@@ -53412,7 +56543,7 @@ var RemoteIndexApi = class {
53412
56543
  };
53413
56544
  __name(RemoteIndexApi, "RemoteIndexApi");
53414
56545
 
53415
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js
56546
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js
53416
56547
  var API_PATH = "/api/v0/";
53417
56548
  var CERAMIC_HOST = "http://localhost:7007";
53418
56549
  var DEFAULT_CLIENT_CONFIG = {
@@ -53506,14 +56637,14 @@ var CeramicClient = class {
53506
56637
  return __async(this, arguments, function* (streamId, commit, opts = {}) {
53507
56638
  opts = __spreadValues(__spreadValues({}, DEFAULT_APPLY_COMMIT_OPTS), opts);
53508
56639
  const effectiveStreamId = typeStreamID(streamId);
53509
- const document = yield Document.applyCommit(this._apiUrl, effectiveStreamId, commit, opts, this._config.syncInterval);
56640
+ const document2 = yield Document.applyCommit(this._apiUrl, effectiveStreamId, commit, opts, this._config.syncInterval);
53510
56641
  const fromCache = this._streamCache.get(effectiveStreamId.toString());
53511
56642
  if (fromCache) {
53512
- fromCache.next(document.state);
53513
- return this.buildStreamFromDocument(document);
56643
+ fromCache.next(document2.state);
56644
+ return this.buildStreamFromDocument(document2);
53514
56645
  } else {
53515
- this._streamCache.set(effectiveStreamId.toString(), document);
53516
- return this.buildStreamFromDocument(document);
56646
+ this._streamCache.set(effectiveStreamId.toString(), document2);
56647
+ return this.buildStreamFromDocument(document2);
53517
56648
  }
53518
56649
  });
53519
56650
  }
@@ -53680,6 +56811,11 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53680
56811
  };
53681
56812
  }), "getIDXPlugin");
53682
56813
 
56814
+ // ../learn-card-helpers/dist/helpers.esm.js
56815
+ var __defProp2 = Object.defineProperty;
56816
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
56817
+ var isHex = /* @__PURE__ */ __name2((str) => /^[0-9a-f]+$/i.test(str), "isHex");
56818
+
53683
56819
  // src/wallet/plugins/didkey/helpers.ts
53684
56820
  var ED25519_METHODS = ["key", "tz", "pkh:tz", "pkh:tezos", "pkh:sol", "pkh:solana"];
53685
56821
  var SECP256K1_METHODS = [
@@ -53696,7 +56832,6 @@ var SECP256K1_METHODS = [
53696
56832
  "pkh:eip155",
53697
56833
  "pkh:bip122"
53698
56834
  ];
53699
- var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
53700
56835
  var getAlgorithmForDidMethod = /* @__PURE__ */ __name((didMethod) => {
53701
56836
  if (ED25519_METHODS.includes(didMethod))
53702
56837
  return "ed25519";
@@ -53747,50 +56882,50 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async(void 0, n
53747
56882
 
53748
56883
  // src/wallet/plugins/vc/issueCredential.ts
53749
56884
  var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
53750
- return (wallet, credential) => __async(void 0, null, function* () {
56885
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (wallet, credential, signingOptions = {}) {
53751
56886
  const kp = wallet.pluginMethods.getSubjectKeypair();
53752
56887
  if (!kp)
53753
56888
  throw new Error("Cannot issue credential: Could not get subject keypair");
53754
- const options = {
56889
+ const options = __spreadValues({
53755
56890
  verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
53756
56891
  proofPurpose: "assertionMethod"
53757
- };
56892
+ }, signingOptions);
53758
56893
  return initWallet.pluginMethods.issueCredential(credential, options, kp);
53759
56894
  });
53760
56895
  }, "issueCredential");
53761
56896
 
53762
56897
  // src/wallet/plugins/vc/verifyCredential.ts
53763
56898
  var verifyCredential3 = /* @__PURE__ */ __name((initWallet) => {
53764
- return (_wallet, credential) => __async(void 0, null, function* () {
53765
- return initWallet.pluginMethods.verifyCredential(credential);
56899
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, options = {}) {
56900
+ return initWallet.pluginMethods.verifyCredential(credential, options);
53766
56901
  });
53767
56902
  }, "verifyCredential");
53768
56903
 
53769
56904
  // src/wallet/plugins/vc/issuePresentation.ts
53770
56905
  var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
53771
- return (wallet, presentation) => __async(void 0, null, function* () {
56906
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (wallet, presentation, signingOptions = {}) {
53772
56907
  const kp = wallet.pluginMethods.getSubjectKeypair();
53773
56908
  if (!kp)
53774
56909
  throw new Error("Cannot issue credential: Could not get subject keypair");
53775
- const options = {
56910
+ const options = __spreadValues({
53776
56911
  verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
53777
56912
  proofPurpose: "assertionMethod"
53778
- };
56913
+ }, signingOptions);
53779
56914
  return initWallet.pluginMethods.issuePresentation(presentation, options, kp);
53780
56915
  });
53781
56916
  }, "issuePresentation");
53782
56917
 
53783
56918
  // src/wallet/plugins/vc/verifyPresentation.ts
53784
56919
  var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
53785
- return (_wallet, presentation) => __async(void 0, null, function* () {
53786
- return initWallet.pluginMethods.verifyPresentation(presentation);
56920
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, presentation, options = {}) {
56921
+ return initWallet.pluginMethods.verifyPresentation(presentation, options);
53787
56922
  });
53788
56923
  }, "verifyPresentation");
53789
56924
 
53790
56925
  // src/wallet/plugins/vc/vc.ts
53791
56926
  var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
53792
56927
  return {
53793
- pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
56928
+ pluginMethods: {
53794
56929
  issueCredential: issueCredential2(wallet),
53795
56930
  verifyCredential: verifyCredential3(wallet),
53796
56931
  issuePresentation: issuePresentation2(wallet),
@@ -53816,11 +56951,12 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
53816
56951
  verifiableCredential: credential
53817
56952
  };
53818
56953
  })
53819
- })
56954
+ }
53820
56955
  };
53821
56956
  }, "getVCPlugin");
53822
56957
 
53823
56958
  // src/wallet/plugins/EthereumPlugin/index.ts
56959
+ var import_buffer = __toESM(require_buffer2());
53824
56960
  import { ethers as ethers2 } from "ethers";
53825
56961
 
53826
56962
  // src/wallet/plugins/EthereumPlugin/helpers.ts
@@ -53888,7 +57024,7 @@ var ERC20ABI = require_erc20_abi();
53888
57024
  var getEthereumPlugin = /* @__PURE__ */ __name((initWallet, config2) => {
53889
57025
  let { infuraProjectId, network = "mainnet" } = config2;
53890
57026
  const secpKeypair = initWallet.pluginMethods.getSubjectKeypair("secp256k1");
53891
- const privateKey = Buffer.from(secpKeypair.d, "base64").toString("hex");
57027
+ const privateKey = import_buffer.Buffer.from(secpKeypair.d, "base64").toString("hex");
53892
57028
  let ethersWallet = new ethers2.Wallet(privateKey);
53893
57029
  const publicKey = ethersWallet.address;
53894
57030
  const getProvider = /* @__PURE__ */ __name(() => {
@@ -54627,11 +57763,11 @@ var Transformer = class {
54627
57763
  }
54628
57764
  _getDocument(_0) {
54629
57765
  return __async(this, arguments, function* ({ url }) {
54630
- const { document } = yield this.documentLoader(url);
54631
- if (typeof document === "string") {
54632
- return JSON.parse(document);
57766
+ const { document: document2 } = yield this.documentLoader(url);
57767
+ if (typeof document2 === "string") {
57768
+ return JSON.parse(document2);
54633
57769
  }
54634
- return document;
57770
+ return document2;
54635
57771
  });
54636
57772
  }
54637
57773
  _getTermType({ activeCtx, def }) {
@@ -57170,11 +60306,12 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57170
60306
  const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
57171
60307
  const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
57172
60308
  const didkeyAndVCWallet = yield didkeyWallet.addPlugin(getVCPlugin(didkeyWallet));
57173
- const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin(didkeyAndVCWallet));
60309
+ const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin());
57174
60310
  const idxWallet = yield templateWallet.addPlugin(yield getIDXPlugin(templateWallet, ceramicIdx));
57175
60311
  const expirationWallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
57176
60312
  const ethWallet = yield expirationWallet.addPlugin(getEthereumPlugin(expirationWallet, ethereumConfig));
57177
- const wallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
60313
+ const vpqrWallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
60314
+ const wallet = yield vpqrWallet.addPlugin(yield getCHAPIPlugin());
57178
60315
  return {
57179
60316
  _wallet: wallet,
57180
60317
  did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
@@ -57209,15 +60346,140 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57209
60346
  transferTokens: wallet.pluginMethods.transferTokens,
57210
60347
  getCurrentNetwork: wallet.pluginMethods.getCurrentNetwork,
57211
60348
  changeNetwork: wallet.pluginMethods.changeNetwork,
57212
- addInfuraProjectId: wallet.pluginMethods.addInfuraProjectId
60349
+ addInfuraProjectId: wallet.pluginMethods.addInfuraProjectId,
60350
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
60351
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
60352
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
60353
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
60354
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
57213
60355
  };
57214
60356
  }), "walletFromKey");
57215
60357
 
60358
+ // src/wallet/plugins/vc-api/helpers.ts
60359
+ var post = /* @__PURE__ */ __name((url, data) => __async(void 0, null, function* () {
60360
+ return fetch(url, {
60361
+ method: "POST",
60362
+ headers: { "Content-Type": "application/json" },
60363
+ body: JSON.stringify(data)
60364
+ });
60365
+ }), "post");
60366
+ var isSuccessful = /* @__PURE__ */ __name((status) => status.toString().startsWith("2"), "isSuccessful");
60367
+
60368
+ // src/wallet/plugins/vc-api/index.ts
60369
+ var getVCAPIPlugin = /* @__PURE__ */ __name((_0) => __async(void 0, [_0], function* ({
60370
+ url: _url,
60371
+ did: _did
60372
+ }) {
60373
+ const url = _url.endsWith("/") ? _url.slice(0, -1) : _url;
60374
+ let did = _did;
60375
+ if (!did) {
60376
+ const res = yield fetch(`${url}/did`);
60377
+ if (res.status === 200)
60378
+ did = yield res.text();
60379
+ }
60380
+ if (!did)
60381
+ throw new Error("Could not retrieve did from VC API! Please suppy a did.");
60382
+ return {
60383
+ pluginMethods: {
60384
+ getSubjectDid: () => did,
60385
+ issueCredential: (_wallet, credential, options) => __async(void 0, null, function* () {
60386
+ yield UnsignedVCValidator.parseAsync(credential);
60387
+ const response = yield post(`${url}/credentials/issue`, { credential, options });
60388
+ if (!isSuccessful(response.status)) {
60389
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60390
+ }
60391
+ return VCValidator.parseAsync(yield response.json());
60392
+ }),
60393
+ verifyCredential: (_wallet, verifiableCredential, options) => __async(void 0, null, function* () {
60394
+ yield VCValidator.parseAsync(verifiableCredential);
60395
+ const response = yield post(`${url}/credentials/verify`, {
60396
+ verifiableCredential,
60397
+ options
60398
+ });
60399
+ if (!isSuccessful(response.status)) {
60400
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60401
+ }
60402
+ return VerificationCheckValidator.parseAsync(yield response.json());
60403
+ }),
60404
+ issuePresentation: (_wallet, presentation, options) => __async(void 0, null, function* () {
60405
+ yield UnsignedVPValidator.parseAsync(presentation);
60406
+ const response = yield post(`${url}/presentations/issue`, {
60407
+ presentation,
60408
+ options
60409
+ });
60410
+ if (!isSuccessful(response.status)) {
60411
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60412
+ }
60413
+ return VPValidator.parseAsync(yield response.json());
60414
+ }),
60415
+ verifyPresentation: (_wallet, verifiablePresentation, options) => __async(void 0, null, function* () {
60416
+ yield VPValidator.parseAsync(verifiablePresentation);
60417
+ const response = yield post(`${url}/presentations/verify`, {
60418
+ verifiablePresentation,
60419
+ options
60420
+ });
60421
+ if (!isSuccessful(response.status)) {
60422
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60423
+ }
60424
+ return VerificationCheckValidator.parseAsync(yield response.json());
60425
+ }),
60426
+ getTestVc: (_wallet, subject = "did:example:d23dd687a7dc6787646f2eb98d0") => {
60427
+ return {
60428
+ "@context": ["https://www.w3.org/2018/credentials/v1"],
60429
+ id: "http://example.org/credentials/3731",
60430
+ type: ["VerifiableCredential"],
60431
+ issuer: did,
60432
+ issuanceDate: "2020-08-19T21:41:50Z",
60433
+ credentialSubject: { id: subject }
60434
+ };
60435
+ },
60436
+ getTestVp: (_wallet, _credential) => __async(void 0, null, function* () {
60437
+ const credential = _credential || (yield _wallet.pluginMethods.issueCredential(_wallet.pluginMethods.getTestVc()));
60438
+ return {
60439
+ "@context": ["https://www.w3.org/2018/credentials/v1"],
60440
+ type: ["VerifiablePresentation"],
60441
+ holder: did,
60442
+ verifiableCredential: credential
60443
+ };
60444
+ })
60445
+ }
60446
+ };
60447
+ }), "getVCAPIPlugin");
60448
+
60449
+ // src/wallet/initializers/apiWallet.ts
60450
+ var walletFromApiUrl = /* @__PURE__ */ __name((_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (url, did, { defaultContents = [] } = {}) {
60451
+ const apiWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getVCAPIPlugin({ url, did }));
60452
+ const expirationWallet = yield apiWallet.addPlugin(ExpirationPlugin(apiWallet));
60453
+ const templateWallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin());
60454
+ const wallet = yield templateWallet.addPlugin(yield getCHAPIPlugin());
60455
+ return {
60456
+ _wallet: wallet,
60457
+ did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
60458
+ newCredential: wallet.pluginMethods.newCredential,
60459
+ newPresentation: wallet.pluginMethods.newPresentation,
60460
+ issueCredential: wallet.pluginMethods.issueCredential,
60461
+ verifyCredential: verifyCredential2(wallet),
60462
+ issuePresentation: wallet.pluginMethods.issuePresentation,
60463
+ verifyPresentation: wallet.pluginMethods.verifyPresentation,
60464
+ getTestVc: wallet.pluginMethods.getTestVc,
60465
+ getTestVp: wallet.pluginMethods.getTestVp,
60466
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
60467
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
60468
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
60469
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
60470
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
60471
+ };
60472
+ }), "walletFromApiUrl");
60473
+
57216
60474
  // src/wallet/init.ts
57217
60475
  function initLearnCard() {
57218
60476
  return __async(this, arguments, function* (config2 = {}) {
60477
+ if ("vcApi" in config2) {
60478
+ const _a = config2, { vcApi, did } = _a, apiConfig = __objRest(_a, ["vcApi", "did"]);
60479
+ return walletFromApiUrl(typeof vcApi === "string" ? vcApi : "https://bridge.learncard.com", vcApi === true ? "did:key:z6MkjSz4mYqcn7dePGuktJ5PxecMkXQQHWRg8Lm6okATyFVh" : did, apiConfig);
60480
+ }
57219
60481
  if ("seed" in config2) {
57220
- const _a = config2, { seed } = _a, keyConfig = __objRest(_a, ["seed"]);
60482
+ const _b = config2, { seed } = _b, keyConfig = __objRest(_b, ["seed"]);
57221
60483
  return walletFromKey(seed, keyConfig);
57222
60484
  }
57223
60485
  return emptyWallet(config2);
@@ -57229,6 +60491,7 @@ export {
57229
60491
  ExpirationPlugin,
57230
60492
  emptyWallet,
57231
60493
  generateWallet,
60494
+ getCHAPIPlugin,
57232
60495
  getDidKeyPlugin,
57233
60496
  getDidKitPlugin,
57234
60497
  getEthereumPlugin,
@@ -57236,10 +60499,50 @@ export {
57236
60499
  getVCPlugin,
57237
60500
  getVpqrPlugin,
57238
60501
  initLearnCard,
57239
- passwordToKey,
57240
- seedToId,
60502
+ walletFromApiUrl,
57241
60503
  walletFromKey
57242
60504
  };
60505
+ /*!
60506
+ * A CredentialHandlerRegistration provides a CredentialManager to enable Web
60507
+ * apps to register Profiles that can be presented to websites.
60508
+ *
60509
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60510
+ */
60511
+ /*!
60512
+ * A CredentialRequestEvent is emitted when a request has been made for
60513
+ * credentials.
60514
+ *
60515
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60516
+ */
60517
+ /*!
60518
+ * A CredentialStoreEvent is emitted when a request has been made to
60519
+ * store a credential.
60520
+ *
60521
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60522
+ */
60523
+ /*!
60524
+ * A WebApp is a remote application that runs in a WebAppContext.
60525
+ *
60526
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60527
+ */
60528
+ /*!
60529
+ * A WebCredential is a Credential that can be retrieved from or stored by a
60530
+ * "credential handler" that runs in a third party Web application.
60531
+ *
60532
+ * Copyright (c) 2017-2021 Digital Bazaar, Inc. All rights reserved.
60533
+ */
60534
+ /*!
60535
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60536
+ */
60537
+ /*!
60538
+ * Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
60539
+ */
60540
+ /*!
60541
+ * Copyright (c) 2017-2022 Digital Bazaar, Inc. All rights reserved.
60542
+ */
60543
+ /*!
60544
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
60545
+ */
57243
60546
  /*!
57244
60547
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
57245
60548
  */
@@ -57252,6 +60555,36 @@ export {
57252
60555
  /*!
57253
60556
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
57254
60557
  */
60558
+ /*!
60559
+ * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
60560
+ */
60561
+ /*!
60562
+ * JSON-RPC for Web Request Polyfills.
60563
+ *
60564
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60565
+ */
60566
+ /*!
60567
+ * The buffer module from node.js, for the browser.
60568
+ *
60569
+ * @author Feross Aboukhadijeh <https://feross.org>
60570
+ * @license MIT
60571
+ */
60572
+ /*!
60573
+ * The core CredentialHandler class.
60574
+ *
60575
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60576
+ */
60577
+ /*!
60578
+ * Utilities for Web Request RPC.
60579
+ *
60580
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60581
+ */
60582
+ /*!
60583
+ * Wrapper for native CredentialsContainer that uses remote Credential Mediator
60584
+ * for WebCredential-related operations.
60585
+ *
60586
+ * Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
60587
+ */
57255
60588
  /*!
57256
60589
  * https://github.com/Starcounter-Jack/JSON-Patch
57257
60590
  * (c) 2017-2021 Joachim Wester
@@ -57262,6 +60595,7 @@ export {
57262
60595
  * (c) 2017-2022 Joachim Wester
57263
60596
  * MIT licensed
57264
60597
  */
60598
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
57265
60599
  /**
57266
60600
  * @module QRCode
57267
60601
  * @package @nuintun/qrcode