@learncard/core 6.0.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
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) {
@@ -36013,7 +37674,7 @@ function getImports() {
36013
37674
  const ret = wasm.memory;
36014
37675
  return addHeapObject(ret);
36015
37676
  };
36016
- imports.wbg.__wbindgen_closure_wrapper10020 = function(arg0, arg1, arg2) {
37677
+ imports.wbg.__wbindgen_closure_wrapper10021 = function(arg0, arg1, arg2) {
36017
37678
  const ret = makeMutClosure(arg0, arg1, 3552, __wbg_adapter_24);
36018
37679
  return addHeapObject(ret);
36019
37680
  };
@@ -36050,7 +37711,7 @@ var didkit_wasm_default = init;
36050
37711
 
36051
37712
  // src/didkit/index.ts
36052
37713
  var initialized = false;
36053
- var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/soErM6xgSNqxVeJZzo7v") => __async(void 0, null, function* () {
37714
+ var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/R0BsvnoVRhezGazRDUy5") => __async(void 0, null, function* () {
36054
37715
  if (initialized)
36055
37716
  return;
36056
37717
  initialized = true;
@@ -36081,20 +37742,20 @@ var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async(void 0, null, fu
36081
37742
  issueCredential: (_wallet, credential, options, keypair) => __async(void 0, null, function* () {
36082
37743
  return JSON.parse(yield issueCredential(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
36083
37744
  }),
36084
- verifyCredential: (_wallet, credential) => __async(void 0, null, function* () {
36085
- return JSON.parse(yield verifyCredential(JSON.stringify(credential), "{}"));
37745
+ verifyCredential: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, options = {}) {
37746
+ return JSON.parse(yield verifyCredential(JSON.stringify(credential), JSON.stringify(options)));
36086
37747
  }),
36087
37748
  issuePresentation: (_wallet, presentation, options, keypair) => __async(void 0, null, function* () {
36088
37749
  return JSON.parse(yield issuePresentation(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair)));
36089
37750
  }),
36090
- verifyPresentation: (_wallet, presentation) => __async(void 0, null, function* () {
36091
- return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), "{}"));
37751
+ verifyPresentation: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, presentation, options = {}) {
37752
+ return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), JSON.stringify(options)));
36092
37753
  }),
36093
37754
  contextLoader: (_wallet, url) => __async(void 0, null, function* () {
36094
37755
  return JSON.parse(yield contextLoader(url));
36095
37756
  }),
36096
- resolveDid: (_wallet, did) => __async(void 0, null, function* () {
36097
- return JSON.parse(yield resolveDID(did, "{}"));
37757
+ resolveDid: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, did, inputMetadata = {}) {
37758
+ return JSON.parse(yield resolveDID(did, JSON.stringify(inputMetadata)));
36098
37759
  })
36099
37760
  }
36100
37761
  };
@@ -36115,6 +37776,1574 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
36115
37776
  }
36116
37777
  }), "ExpirationPlugin");
36117
37778
 
37779
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/utils.js
37780
+ var RPC_ERRORS = {
37781
+ ParseError: {
37782
+ message: "Parse error",
37783
+ code: -32700
37784
+ },
37785
+ InvalidRequest: {
37786
+ message: "Invalid Request",
37787
+ code: -32600
37788
+ },
37789
+ MethodNotFound: {
37790
+ message: "Method not found",
37791
+ code: -32601
37792
+ },
37793
+ InvalidParams: {
37794
+ message: "Invalid params",
37795
+ code: -32602
37796
+ },
37797
+ InternalError: {
37798
+ message: "Internal Error",
37799
+ code: -32603
37800
+ },
37801
+ ServerError: {
37802
+ message: "Server error",
37803
+ code: -32e3
37804
+ }
37805
+ };
37806
+ function parseUrl(url, base4) {
37807
+ if (base4 === void 0) {
37808
+ base4 = window.location.href;
37809
+ }
37810
+ if (typeof URL === "function") {
37811
+ return new URL(url, base4);
37812
+ }
37813
+ if (typeof url !== "string") {
37814
+ throw new TypeError('"url" must be a string.');
37815
+ }
37816
+ if (!url.includes(":")) {
37817
+ if (base4.startsWith("http") && !url.startsWith("/")) {
37818
+ url = base4 + "/" + url;
37819
+ } else {
37820
+ url = base4 + url;
37821
+ }
37822
+ }
37823
+ const parser = document.createElement("a");
37824
+ parser.href = url;
37825
+ let origin = (parser.protocol || window.location.protocol) + "//";
37826
+ if (parser.host) {
37827
+ if (parser.protocol === "http:" && parser.port === "80" || parser.protocol === "https:" && parser.port === "443") {
37828
+ origin += parser.hostname;
37829
+ } else {
37830
+ origin += parser.host;
37831
+ }
37832
+ } else {
37833
+ origin += window.location.host;
37834
+ }
37835
+ let pathname = parser.pathname;
37836
+ if (!pathname.startsWith("/")) {
37837
+ pathname = "/" + pathname;
37838
+ }
37839
+ return {
37840
+ host: parser.host || window.location.host,
37841
+ hostname: parser.hostname,
37842
+ origin,
37843
+ protocol: parser.protocol,
37844
+ pathname
37845
+ };
37846
+ }
37847
+ __name(parseUrl, "parseUrl");
37848
+ function uuidv4(a, b) {
37849
+ for (b = a = ""; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : "-")
37850
+ ;
37851
+ return b;
37852
+ }
37853
+ __name(uuidv4, "uuidv4");
37854
+ function isValidMessage(message) {
37855
+ return message && typeof message === "object" && message.jsonrpc === "2.0" && message.id && typeof message.id === "string";
37856
+ }
37857
+ __name(isValidMessage, "isValidMessage");
37858
+ function isValidRequest(message) {
37859
+ return isValidMessage(message) && Array.isArray(message.params);
37860
+ }
37861
+ __name(isValidRequest, "isValidRequest");
37862
+ function isValidResponse(message) {
37863
+ return isValidMessage(message) && !!("result" in message ^ "error" in message) && (!("error" in message) || isValidError(message.error));
37864
+ }
37865
+ __name(isValidResponse, "isValidResponse");
37866
+ function isValidError(error) {
37867
+ return error && typeof error === "object" && typeof error.code === "number" && typeof error.message === "string";
37868
+ }
37869
+ __name(isValidError, "isValidError");
37870
+ function serializeError(error) {
37871
+ const err = {
37872
+ message: error.message
37873
+ };
37874
+ if (error.constructor.name !== "Error") {
37875
+ err.constructor = error.constructor.name;
37876
+ }
37877
+ if ("name" in error) {
37878
+ err.name = error.name;
37879
+ }
37880
+ if ("code" in error) {
37881
+ err.code = error.code;
37882
+ } else {
37883
+ err.code = RPC_ERRORS.ServerError.code;
37884
+ }
37885
+ if ("details" in error) {
37886
+ err.details = error.details;
37887
+ }
37888
+ return err;
37889
+ }
37890
+ __name(serializeError, "serializeError");
37891
+ function deserializeError(error) {
37892
+ let err;
37893
+ if (error.constructor === "DOMException") {
37894
+ err = new DOMException(error.message, error.name);
37895
+ } else {
37896
+ err = new Error(error.message);
37897
+ if ("code" in error) {
37898
+ err.code = error.code;
37899
+ }
37900
+ }
37901
+ if (error.details) {
37902
+ err.details = error.details;
37903
+ }
37904
+ return err;
37905
+ }
37906
+ __name(deserializeError, "deserializeError");
37907
+ function createMessageListener({ listener: listener2, origin, handle, expectRequest }) {
37908
+ if (isHandlePromise(handle)) {
37909
+ const promise = handle;
37910
+ handle = false;
37911
+ promise.then((h) => handle = h);
37912
+ }
37913
+ return (e) => {
37914
+ if (!(e.source === handle && e.origin === origin && (expectRequest && isValidRequest(e.data) || !expectRequest && isValidResponse(e.data)))) {
37915
+ return;
37916
+ }
37917
+ listener2(e.data, e);
37918
+ };
37919
+ }
37920
+ __name(createMessageListener, "createMessageListener");
37921
+ function destructureMethodName(fqMethodName) {
37922
+ let [name5, ...rest] = fqMethodName.split(".");
37923
+ const method = rest.pop();
37924
+ name5 = [name5, ...rest].join(".");
37925
+ return { name: name5, method };
37926
+ }
37927
+ __name(destructureMethodName, "destructureMethodName");
37928
+ function isHandlePromise(handle) {
37929
+ try {
37930
+ return typeof handle.then === "function";
37931
+ } catch (e) {
37932
+ }
37933
+ return false;
37934
+ }
37935
+ __name(isHandlePromise, "isHandlePromise");
37936
+
37937
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/Client.js
37938
+ var RPC_CLIENT_CALL_TIMEOUT = 3e4;
37939
+ var Client = class {
37940
+ constructor() {
37941
+ this.origin = null;
37942
+ this._handle = null;
37943
+ this._listener = null;
37944
+ this._pending = /* @__PURE__ */ new Map();
37945
+ }
37946
+ connect(origin, options) {
37947
+ return __async(this, null, function* () {
37948
+ if (this._listener) {
37949
+ throw new Error("Already connected.");
37950
+ }
37951
+ options = options || {};
37952
+ const self2 = this;
37953
+ self2.origin = parseUrl(origin).origin;
37954
+ self2._handle = options.handle || window.opener || window.parent;
37955
+ const pending = self2._pending;
37956
+ self2._listener = createMessageListener({
37957
+ origin: self2.origin,
37958
+ handle: self2._handle,
37959
+ expectRequest: false,
37960
+ listener: (message) => {
37961
+ if (!pending.has(message.id)) {
37962
+ return;
37963
+ }
37964
+ const { resolve, reject, cancelTimeout } = pending.get(message.id);
37965
+ cancelTimeout();
37966
+ if ("result" in message) {
37967
+ return resolve(message.result);
37968
+ }
37969
+ reject(deserializeError(message.error));
37970
+ }
37971
+ });
37972
+ window.addEventListener("message", self2._listener);
37973
+ return new Injector(self2);
37974
+ });
37975
+ }
37976
+ send(_0, _1, _2) {
37977
+ return __async(this, arguments, function* (qualifiedMethodName, parameters, {
37978
+ timeout = RPC_CLIENT_CALL_TIMEOUT
37979
+ }) {
37980
+ if (!this._listener) {
37981
+ throw new Error("RPC client not connected.");
37982
+ }
37983
+ const self2 = this;
37984
+ const message = {
37985
+ jsonrpc: "2.0",
37986
+ id: uuidv4(),
37987
+ method: qualifiedMethodName,
37988
+ params: parameters
37989
+ };
37990
+ if (isHandlePromise(self2._handle)) {
37991
+ const handle = yield self2._handle;
37992
+ handle.postMessage(message, self2.origin);
37993
+ } else {
37994
+ self2._handle.postMessage(message, self2.origin);
37995
+ }
37996
+ return new Promise((resolve, reject) => {
37997
+ const pending = self2._pending;
37998
+ let cancelTimeout;
37999
+ if (timeout > 0) {
38000
+ const timeoutId = setTimeout(() => {
38001
+ pending.delete(message.id);
38002
+ reject(new Error("RPC call timed out."));
38003
+ }, timeout);
38004
+ cancelTimeout = /* @__PURE__ */ __name(() => {
38005
+ pending.delete(message.id);
38006
+ clearTimeout(timeoutId);
38007
+ }, "cancelTimeout");
38008
+ } else {
38009
+ cancelTimeout = /* @__PURE__ */ __name(() => {
38010
+ pending.delete(message.id);
38011
+ }, "cancelTimeout");
38012
+ }
38013
+ pending.set(message.id, { resolve, reject, cancelTimeout });
38014
+ });
38015
+ });
38016
+ }
38017
+ close() {
38018
+ if (this._listener) {
38019
+ window.removeEventListener("message", this._listener);
38020
+ this._handle = this.origin = this._listener = null;
38021
+ for (const value of this._pending.values()) {
38022
+ value.reject(new Error("RPC client closed."));
38023
+ }
38024
+ this._pending = /* @__PURE__ */ new Map();
38025
+ }
38026
+ }
38027
+ };
38028
+ __name(Client, "Client");
38029
+ var Injector = class {
38030
+ constructor(client) {
38031
+ this.client = client;
38032
+ this._apis = /* @__PURE__ */ new Map();
38033
+ }
38034
+ define(name5, definition) {
38035
+ if (!(name5 && typeof name5 === "string")) {
38036
+ throw new TypeError("`name` must be a non-empty string.");
38037
+ }
38038
+ if (!(definition && typeof definition === "object" && Array.isArray(definition.functions))) {
38039
+ throw new TypeError("`definition.function` must be an array of function names or function definition objects to be defined.");
38040
+ }
38041
+ const self2 = this;
38042
+ const api = {};
38043
+ definition.functions.forEach((fn) => {
38044
+ if (typeof fn === "string") {
38045
+ fn = { name: fn, options: {} };
38046
+ }
38047
+ api[fn.name] = function() {
38048
+ return __async(this, arguments, function* () {
38049
+ return self2.client.send(name5 + "." + fn.name, [...arguments], fn.options);
38050
+ });
38051
+ };
38052
+ });
38053
+ self2._apis[name5] = api;
38054
+ return api;
38055
+ }
38056
+ get(name5, definition) {
38057
+ const api = this._apis[name5];
38058
+ if (!api) {
38059
+ if (definition) {
38060
+ return this.define(name5, definition);
38061
+ }
38062
+ throw new Error(`API "${name5}" has not been defined.`);
38063
+ }
38064
+ return this._apis[name5];
38065
+ }
38066
+ };
38067
+ __name(Injector, "Injector");
38068
+
38069
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/EventEmitter.js
38070
+ var EventEmitter = class {
38071
+ constructor({ deserialize = /* @__PURE__ */ __name((e) => e, "deserialize"), waitUntil = /* @__PURE__ */ __name(() => __async(this, null, function* () {
38072
+ }), "waitUntil") } = {}) {
38073
+ this._listeners = [];
38074
+ this._deserialize = deserialize;
38075
+ this._waitUntil = waitUntil;
38076
+ }
38077
+ emit(event) {
38078
+ return __async(this, null, function* () {
38079
+ event = this._deserialize(event);
38080
+ (this._listeners[event.type] || []).forEach((l) => l(event));
38081
+ return this._waitUntil(event);
38082
+ });
38083
+ }
38084
+ addEventListener(eventType, fn) {
38085
+ if (!this._listeners[eventType]) {
38086
+ this._listeners[eventType] = [fn];
38087
+ } else {
38088
+ this._listeners[eventType].push(fn);
38089
+ }
38090
+ }
38091
+ removeEventListener(eventType, fn) {
38092
+ const listeners = this._listeners[eventType];
38093
+ if (!listeners) {
38094
+ return;
38095
+ }
38096
+ const idx = listeners.indexOf(fn);
38097
+ if (idx !== -1) {
38098
+ listeners.splice(idx, 1);
38099
+ }
38100
+ }
38101
+ };
38102
+ __name(EventEmitter, "EventEmitter");
38103
+
38104
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/Server.js
38105
+ var Server = class {
38106
+ constructor() {
38107
+ this.origin = null;
38108
+ this._handle = null;
38109
+ this._apis = /* @__PURE__ */ new Map();
38110
+ }
38111
+ define(name5, api) {
38112
+ if (!(name5 && typeof name5 === "string")) {
38113
+ throw new TypeError("`name` must be a non-empty string.");
38114
+ }
38115
+ if (!(api && api !== "object")) {
38116
+ throw new TypeError("`api` must be an object.");
38117
+ }
38118
+ if (name5 in this._apis) {
38119
+ throw new Error(`The "${name5}" API is already defined.`);
38120
+ }
38121
+ this._apis[name5] = api;
38122
+ }
38123
+ listen(origin, options) {
38124
+ return __async(this, null, function* () {
38125
+ if (this._listener) {
38126
+ throw new Error("Already listening.");
38127
+ }
38128
+ options = options || {};
38129
+ const self2 = this;
38130
+ self2.origin = parseUrl(origin).origin;
38131
+ self2._handle = options.handle || window.opener || window.parent;
38132
+ const ignoreUnknownApi = options.ignoreUnknownApi === "true" || false;
38133
+ self2._listener = createMessageListener({
38134
+ origin: self2.origin,
38135
+ handle: self2._handle,
38136
+ expectRequest: true,
38137
+ listener: (message) => {
38138
+ const { name: name5, method } = destructureMethodName(message.method);
38139
+ const api = self2._apis[name5];
38140
+ if (method && method.startsWith("_")) {
38141
+ return sendMethodNotFound(self2._handle, self2.origin, message);
38142
+ }
38143
+ if (!api && ignoreUnknownApi) {
38144
+ return;
38145
+ }
38146
+ if (!api || typeof api[method] !== "function") {
38147
+ return sendMethodNotFound(self2._handle, self2.origin, message);
38148
+ }
38149
+ const fn = api[method];
38150
+ (() => __async(this, null, function* () {
38151
+ const response = {
38152
+ jsonrpc: "2.0",
38153
+ id: message.id
38154
+ };
38155
+ try {
38156
+ response.result = yield fn.apply(api, message.params);
38157
+ } catch (e) {
38158
+ response.error = serializeError(e);
38159
+ }
38160
+ if (self2._handle) {
38161
+ if (isHandlePromise(self2._handle)) {
38162
+ self2._handle.then((h) => h.postMessage(response, self2.origin));
38163
+ } else {
38164
+ self2._handle.postMessage(response, self2.origin);
38165
+ }
38166
+ }
38167
+ }))();
38168
+ }
38169
+ });
38170
+ window.addEventListener("message", self2._listener);
38171
+ });
38172
+ }
38173
+ close() {
38174
+ if (this._listener) {
38175
+ window.removeEventListener("message", this._listener);
38176
+ this._handle = this.origin = this._listener = null;
38177
+ }
38178
+ }
38179
+ };
38180
+ __name(Server, "Server");
38181
+ function sendMethodNotFound(handle, origin, message) {
38182
+ const response = {
38183
+ jsonrpc: "2.0",
38184
+ id: message.id,
38185
+ error: Object.assign({}, RPC_ERRORS.MethodNotFound)
38186
+ };
38187
+ if (isHandlePromise(handle)) {
38188
+ return handle.then((h) => h.postMessage(response, origin));
38189
+ } else {
38190
+ return handle.postMessage(response, origin);
38191
+ }
38192
+ }
38193
+ __name(sendMethodNotFound, "sendMethodNotFound");
38194
+
38195
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebApp.js
38196
+ var WebApp = class {
38197
+ constructor(relyingOrigin) {
38198
+ this.relyingOrigin = parseUrl(relyingOrigin).origin;
38199
+ this.client = null;
38200
+ this.injector = null;
38201
+ this.client = new Client();
38202
+ this.server = new Server();
38203
+ this._control = null;
38204
+ this._connected = false;
38205
+ }
38206
+ connect() {
38207
+ return __async(this, null, function* () {
38208
+ this.injector = yield this.client.connect(this.relyingOrigin);
38209
+ this._connected = true;
38210
+ this._control = this.injector.define("core.control", {
38211
+ functions: ["ready", "show", "hide"]
38212
+ });
38213
+ this.server.listen(this.relyingOrigin);
38214
+ return this.injector;
38215
+ });
38216
+ }
38217
+ ready() {
38218
+ return __async(this, null, function* () {
38219
+ if (!this._connected) {
38220
+ throw new Error('WebApp not connected. Did you call ".connect()"?');
38221
+ }
38222
+ yield this._control.ready();
38223
+ return this;
38224
+ });
38225
+ }
38226
+ close() {
38227
+ if (this._connected) {
38228
+ this.server.close();
38229
+ this.client.close();
38230
+ this._connected = false;
38231
+ }
38232
+ }
38233
+ show() {
38234
+ return __async(this, null, function* () {
38235
+ if (!this._connected) {
38236
+ throw new Error('Cannot "show" yet; not connected. Did you call ".connect()"?');
38237
+ }
38238
+ return this._control.show();
38239
+ });
38240
+ }
38241
+ hide() {
38242
+ return __async(this, null, function* () {
38243
+ if (!this._connected) {
38244
+ throw new Error('Cannot "hide" yet; not connected. Did you call ".connect()?"');
38245
+ }
38246
+ return this._control.hide();
38247
+ });
38248
+ }
38249
+ };
38250
+ __name(WebApp, "WebApp");
38251
+
38252
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowDialog.js
38253
+ var WebAppWindowDialog = class {
38254
+ constructor() {
38255
+ this._closeEventListeners = /* @__PURE__ */ new Set();
38256
+ }
38257
+ addEventListener(name5, listener2) {
38258
+ if (name5 !== "close") {
38259
+ throw new Error(`Unknown event "${name5}".`);
38260
+ }
38261
+ if (typeof listener2 !== "function") {
38262
+ throw new TypeError('"listener" must be a function.');
38263
+ }
38264
+ this._closeEventListeners.add(listener2);
38265
+ }
38266
+ removeEventListener(name5, listener2) {
38267
+ if (name5 !== "close") {
38268
+ throw new Error(`Unknown event "${name5}".`);
38269
+ }
38270
+ if (typeof listener2 !== "function") {
38271
+ throw new TypeError('"listener" must be a function.');
38272
+ }
38273
+ this._closeEventListeners.delete(listener2);
38274
+ }
38275
+ show() {
38276
+ }
38277
+ close() {
38278
+ for (const listener2 of this._closeEventListeners) {
38279
+ listener2({});
38280
+ }
38281
+ }
38282
+ destroy() {
38283
+ this._closeEventListeners.clear();
38284
+ }
38285
+ };
38286
+ __name(WebAppWindowDialog, "WebAppWindowDialog");
38287
+
38288
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowInlineDialog.js
38289
+ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
38290
+ constructor({ url, handle, className }) {
38291
+ super();
38292
+ this.url = url;
38293
+ this.handle = handle;
38294
+ this.dialog = document.createElement("dialog");
38295
+ applyStyle(this.dialog, {
38296
+ position: "fixed",
38297
+ top: 0,
38298
+ left: 0,
38299
+ width: "100%",
38300
+ height: "100%",
38301
+ "max-width": "100%",
38302
+ "max-height": "100%",
38303
+ display: "none",
38304
+ margin: 0,
38305
+ padding: 0,
38306
+ border: "none",
38307
+ background: "transparent",
38308
+ color: "black",
38309
+ "box-sizing": "border-box",
38310
+ overflow: "hidden",
38311
+ "z-index": 1e6
38312
+ });
38313
+ this.dialog.className = "web-app-window";
38314
+ if (typeof className === "string") {
38315
+ this.dialog.className = this.dialog.className + " " + className;
38316
+ }
38317
+ const style = document.createElement("style");
38318
+ style.appendChild(document.createTextNode(`dialog.web-app-window::backdrop {
38319
+ background-color: transparent;
38320
+ }`));
38321
+ this.container = document.createElement("div");
38322
+ applyStyle(this.container, {
38323
+ position: "relative",
38324
+ width: "100%",
38325
+ height: "100%",
38326
+ margin: 0,
38327
+ padding: 0,
38328
+ display: "flex",
38329
+ "flex-direction": "column"
38330
+ });
38331
+ this.container.className = "web-app-window-backdrop";
38332
+ this.iframe = document.createElement("iframe");
38333
+ this.iframe.src = url;
38334
+ this.iframe.scrolling = "auto";
38335
+ applyStyle(this.iframe, {
38336
+ position: "fixed",
38337
+ top: 0,
38338
+ left: 0,
38339
+ width: "100%",
38340
+ height: "100%",
38341
+ border: "none",
38342
+ background: "transparent",
38343
+ overflow: "hidden",
38344
+ margin: 0,
38345
+ padding: 0,
38346
+ "flex-grow": 1
38347
+ });
38348
+ this.dialog.appendChild(style);
38349
+ this.container.appendChild(this.iframe);
38350
+ this.dialog.appendChild(this.container);
38351
+ this.dialog.addEventListener("cancel", (e) => {
38352
+ e.preventDefault();
38353
+ this.hide();
38354
+ });
38355
+ document.body.appendChild(this.dialog);
38356
+ this.handle = this.iframe.contentWindow;
38357
+ }
38358
+ show() {
38359
+ this.dialog.style.display = "block";
38360
+ if (this.dialog.showModal) {
38361
+ this.dialog.showModal();
38362
+ }
38363
+ }
38364
+ close() {
38365
+ this.dialog.style.display = "none";
38366
+ if (this.dialog.close) {
38367
+ try {
38368
+ this.dialog.close();
38369
+ } catch (e) {
38370
+ console.error(e);
38371
+ }
38372
+ }
38373
+ super.close();
38374
+ }
38375
+ destroy() {
38376
+ this.dialog.parentNode.removeChild(this.dialog);
38377
+ super.destroy();
38378
+ }
38379
+ };
38380
+ __name(WebAppWindowInlineDialog, "WebAppWindowInlineDialog");
38381
+ function applyStyle(element, style) {
38382
+ for (const name5 in style) {
38383
+ element.style[name5] = style[name5];
38384
+ }
38385
+ }
38386
+ __name(applyStyle, "applyStyle");
38387
+
38388
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowPopupDialog.js
38389
+ var WebAppWindowPopupDialog = class extends WebAppWindowDialog {
38390
+ constructor({ url, handle, bounds = { width: 500, height: 400 } }) {
38391
+ super();
38392
+ this.url = url;
38393
+ this.handle = handle;
38394
+ this._locationChanging = false;
38395
+ if (!handle) {
38396
+ this._openWindow({ url, name: "web-app-window", bounds });
38397
+ }
38398
+ this.destroyed = false;
38399
+ this._removeListeners = () => {
38400
+ };
38401
+ }
38402
+ show() {
38403
+ }
38404
+ close() {
38405
+ this.destroy();
38406
+ }
38407
+ destroy() {
38408
+ if (this.handle && !this.destroyed) {
38409
+ this.handle.close();
38410
+ super.close();
38411
+ this.handle = null;
38412
+ this.destroyed = true;
38413
+ this._removeListeners();
38414
+ super.destroy();
38415
+ }
38416
+ }
38417
+ isClosed() {
38418
+ return !this.handle || this.handle.closed;
38419
+ }
38420
+ _openWindow({ url, name: name5, bounds }) {
38421
+ const { x, y } = bounds;
38422
+ let { width = 500, height = 400 } = bounds;
38423
+ width = Math.min(width, window.innerWidth);
38424
+ height = Math.min(height, window.innerHeight);
38425
+ const left = x !== void 0 ? x : window.screenX + (window.innerWidth - width) / 2;
38426
+ const top = y !== void 0 ? y : window.screenY + (window.innerHeight - height) / 2;
38427
+ const features = `popup=yes,menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=${width},height=${height},left=${left},top=${top}`;
38428
+ this._locationChanging = true;
38429
+ this.handle = window.open(url, name5, features);
38430
+ this._addListeners();
38431
+ }
38432
+ setLocation(url) {
38433
+ this.url = url;
38434
+ this._locationChanging = true;
38435
+ this.handle.location.replace(url);
38436
+ }
38437
+ _addListeners() {
38438
+ const destroyDialog = /* @__PURE__ */ __name(() => this.destroy(), "destroyDialog");
38439
+ const loadDialog = /* @__PURE__ */ __name(() => {
38440
+ this._locationChanging = false;
38441
+ }, "loadDialog");
38442
+ const unloadDialog = /* @__PURE__ */ __name(() => {
38443
+ if (this._locationChanging) {
38444
+ return;
38445
+ }
38446
+ this.destroy();
38447
+ }, "unloadDialog");
38448
+ this.handle.addEventListener("unload", unloadDialog);
38449
+ this.handle.addEventListener("load", loadDialog);
38450
+ window.addEventListener("beforeUnload", destroyDialog, { once: true });
38451
+ const intervalId = setInterval(() => {
38452
+ if (this.isClosed()) {
38453
+ this.destroy();
38454
+ clearInterval(intervalId);
38455
+ }
38456
+ }, 250);
38457
+ this._removeListeners = () => {
38458
+ clearInterval(intervalId);
38459
+ this.handle.removeListener("unload", unloadDialog);
38460
+ this.handle.removeListener("load", loadDialog);
38461
+ window.removeEventListener("beforeUnload", destroyDialog);
38462
+ };
38463
+ }
38464
+ };
38465
+ __name(WebAppWindowPopupDialog, "WebAppWindowPopupDialog");
38466
+
38467
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindow.js
38468
+ var LOAD_WINDOW_TIMEOUT = 6e4;
38469
+ var WebAppWindow = class {
38470
+ constructor(url, {
38471
+ timeout = LOAD_WINDOW_TIMEOUT,
38472
+ dialog = null,
38473
+ handle,
38474
+ popup = false,
38475
+ className = null,
38476
+ customize = null,
38477
+ bounds
38478
+ } = {}) {
38479
+ this.visible = false;
38480
+ this.dialog = dialog;
38481
+ this.handle = null;
38482
+ this.popup = popup;
38483
+ this.windowControl = null;
38484
+ this._destroyed = false;
38485
+ this._ready = false;
38486
+ this._private = {};
38487
+ this._timeoutId = null;
38488
+ if (handle && handle._dialog) {
38489
+ this.dialog = dialog = handle._dialog;
38490
+ }
38491
+ this._private._readyPromise = new Promise((resolve, reject) => {
38492
+ this._timeoutId = setTimeout(() => reject(new DOMException("Loading Web application window timed out.", "TimeoutError")), timeout);
38493
+ this._private._resolveReady = (value) => {
38494
+ clearTimeout(this.timeoutId);
38495
+ this._timeoutId = null;
38496
+ resolve(value);
38497
+ };
38498
+ this._private._rejectReady = (err) => {
38499
+ clearTimeout(this.timeoutId);
38500
+ this._timeoutId = null;
38501
+ reject(err);
38502
+ };
38503
+ });
38504
+ this._private.isReady = () => __async(this, null, function* () {
38505
+ return this._private._readyPromise;
38506
+ });
38507
+ this._private.destroy = () => {
38508
+ if (this._timeoutId) {
38509
+ this._private._rejectReady(new DOMException("Web application window closed before ready.", "AbortError"));
38510
+ }
38511
+ if (!this._destroyed) {
38512
+ this.dialog.destroy();
38513
+ this.dialog = null;
38514
+ this._destroyed = true;
38515
+ }
38516
+ };
38517
+ if (customize) {
38518
+ if (!typeof customize === "function") {
38519
+ throw new TypeError("`options.customize` must be a function.");
38520
+ }
38521
+ }
38522
+ if (!this.dialog) {
38523
+ if (this.popup) {
38524
+ this.dialog = new WebAppWindowPopupDialog({ url, handle, bounds });
38525
+ } else {
38526
+ this.dialog = new WebAppWindowInlineDialog({ url, handle, className });
38527
+ }
38528
+ } else if (this.popup && bounds) {
38529
+ if (bounds) {
38530
+ const { top: y, left: x, width, height } = bounds;
38531
+ if (x !== void 0 && y !== void 0) {
38532
+ this.dialog.handle.moveTo(x, y);
38533
+ }
38534
+ if (width !== void 0 && height !== void 0) {
38535
+ this.dialog.handle.resizeTo(width, height);
38536
+ }
38537
+ }
38538
+ }
38539
+ this.handle = this.dialog.handle;
38540
+ if (customize) {
38541
+ try {
38542
+ customize({
38543
+ dialog: this.dialog.dialog,
38544
+ container: this.dialog.container,
38545
+ iframe: this.dialog.iframe,
38546
+ webAppWindow: this
38547
+ });
38548
+ } catch (e) {
38549
+ console.error(e);
38550
+ }
38551
+ }
38552
+ }
38553
+ ready() {
38554
+ this._ready = true;
38555
+ this._private._resolveReady(true);
38556
+ }
38557
+ show() {
38558
+ if (!this.visible) {
38559
+ this.visible = true;
38560
+ const body = document.querySelector("body");
38561
+ this._bodyOverflowStyle = body.style.overflow;
38562
+ body.style.overflow = "hidden";
38563
+ if (!this._destroyed) {
38564
+ this.dialog.show();
38565
+ } else if (this.windowControl.show) {
38566
+ this.windowControl.show();
38567
+ }
38568
+ }
38569
+ }
38570
+ hide() {
38571
+ if (this.visible) {
38572
+ this.visible = false;
38573
+ const body = document.querySelector("body");
38574
+ if (this._bodyOverflowStyle) {
38575
+ body.style.overflow = this._bodyOverflowStyle;
38576
+ } else {
38577
+ body.style.overflow = "";
38578
+ }
38579
+ if (!this._destroyed) {
38580
+ this.dialog.close();
38581
+ } else if (this.windowControl.hide) {
38582
+ this.windowControl.hide();
38583
+ }
38584
+ }
38585
+ }
38586
+ };
38587
+ __name(WebAppWindow, "WebAppWindow");
38588
+
38589
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppContext.js
38590
+ var WEB_APP_CONTEXT_LOAD_TIMEOUT = 1e4;
38591
+ var WebAppContext = class {
38592
+ constructor() {
38593
+ this.client = new Client();
38594
+ this.server = new Server();
38595
+ this.injector = null;
38596
+ this.control = null;
38597
+ this.loaded = false;
38598
+ this.closed = false;
38599
+ }
38600
+ createWindow(_0) {
38601
+ return __async(this, arguments, function* (url, {
38602
+ timeout = WEB_APP_CONTEXT_LOAD_TIMEOUT,
38603
+ iframe,
38604
+ dialog = null,
38605
+ popup = false,
38606
+ handle,
38607
+ windowControl,
38608
+ className,
38609
+ customize,
38610
+ bounds
38611
+ } = {}) {
38612
+ if (this.loaded) {
38613
+ throw new Error("AppContext already loaded.");
38614
+ }
38615
+ this.loaded = true;
38616
+ this.control = new WebAppWindow(url, {
38617
+ timeout,
38618
+ dialog,
38619
+ iframe,
38620
+ popup,
38621
+ handle,
38622
+ windowControl,
38623
+ className,
38624
+ customize,
38625
+ bounds
38626
+ });
38627
+ window.addEventListener("pagehide", () => this.close(), { once: true });
38628
+ this.server.define("core.control", this.control);
38629
+ const origin = parseUrl(url).origin;
38630
+ this.server.listen(origin, {
38631
+ handle: this.control.handle,
38632
+ ignoreUnknownApi: true
38633
+ });
38634
+ yield this.control._private.isReady();
38635
+ this.injector = yield this.client.connect(origin, {
38636
+ handle: this.control.handle
38637
+ });
38638
+ return this.injector;
38639
+ });
38640
+ }
38641
+ close() {
38642
+ if (!this.closed) {
38643
+ this.closed = true;
38644
+ this.control._private.destroy();
38645
+ this.server.close();
38646
+ this.client.close();
38647
+ }
38648
+ }
38649
+ };
38650
+ __name(WebAppContext, "WebAppContext");
38651
+
38652
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialRequestEvent.js
38653
+ var CredentialRequestEvent = class {
38654
+ constructor({
38655
+ credentialHandler,
38656
+ credentialRequestOrigin,
38657
+ credentialRequestOptions,
38658
+ hintKey
38659
+ }) {
38660
+ this.type = "credentialrequest";
38661
+ this._credentialHandler = credentialHandler;
38662
+ this.credentialRequestOrigin = credentialRequestOrigin;
38663
+ this.credentialRequestOptions = credentialRequestOptions;
38664
+ this.hintKey = hintKey;
38665
+ }
38666
+ openWindow(url) {
38667
+ return __async(this, null, function* () {
38668
+ yield this._credentialHandler.show();
38669
+ const appWindow = new WebAppWindow(url, {
38670
+ className: "credential-handler"
38671
+ });
38672
+ appWindow.ready();
38673
+ appWindow.show();
38674
+ appWindow.handle._dialog = appWindow.dialog;
38675
+ return appWindow.handle;
38676
+ });
38677
+ }
38678
+ respondWith(handlerResponse) {
38679
+ this._promise = handlerResponse;
38680
+ }
38681
+ };
38682
+ __name(CredentialRequestEvent, "CredentialRequestEvent");
38683
+
38684
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialStoreEvent.js
38685
+ var CredentialStoreEvent = class {
38686
+ constructor({
38687
+ credentialHandler,
38688
+ credentialRequestOrigin,
38689
+ credential,
38690
+ hintKey
38691
+ }) {
38692
+ this.type = "credentialstore";
38693
+ this._credentialHandler = credentialHandler;
38694
+ this.credentialRequestOrigin = credentialRequestOrigin;
38695
+ this.credential = credential;
38696
+ this.hintKey = hintKey;
38697
+ }
38698
+ openWindow(url) {
38699
+ return __async(this, null, function* () {
38700
+ yield this._credentialHandler.show();
38701
+ const appWindow = new WebAppWindow(url);
38702
+ appWindow.ready();
38703
+ appWindow.show();
38704
+ appWindow.handle._dialog = appWindow.dialog;
38705
+ return appWindow.handle;
38706
+ });
38707
+ }
38708
+ respondWith(handlerResponse) {
38709
+ this._promise = handlerResponse;
38710
+ }
38711
+ };
38712
+ __name(CredentialStoreEvent, "CredentialStoreEvent");
38713
+
38714
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerService.js
38715
+ var CredentialHandlerService = class {
38716
+ constructor(credentialHandler) {
38717
+ this._credentialHandler = credentialHandler;
38718
+ }
38719
+ request(credentialRequestEvent) {
38720
+ return __async(this, null, function* () {
38721
+ return yield this._credentialHandler._emitter.emit(new CredentialRequestEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialRequestEvent)));
38722
+ });
38723
+ }
38724
+ store(credentialStoreEvent) {
38725
+ return __async(this, null, function* () {
38726
+ return yield this._credentialHandler._emitter.emit(new CredentialStoreEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialStoreEvent)));
38727
+ });
38728
+ }
38729
+ };
38730
+ __name(CredentialHandlerService, "CredentialHandlerService");
38731
+
38732
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandler.js
38733
+ var EVENT_TYPES = ["credentialrequest", "credentialstore"];
38734
+ var CredentialHandler = class extends WebApp {
38735
+ constructor(mediatorOrigin, inline = false) {
38736
+ if (typeof mediatorOrigin !== "string") {
38737
+ throw new TypeError('"mediatorOrigin" must be a string.');
38738
+ }
38739
+ super(mediatorOrigin, inline);
38740
+ this._emitter = new EventEmitter({
38741
+ waitUntil(event) {
38742
+ return __async(this, null, function* () {
38743
+ return event._promise || Promise.reject(new DOMException('No "credentialrequest" event handler found.', "NotFoundError"));
38744
+ });
38745
+ }
38746
+ });
38747
+ }
38748
+ connect() {
38749
+ return __async(this, null, function* () {
38750
+ const injector = yield __superGet(CredentialHandler.prototype, this, "connect").call(this);
38751
+ this.server.define("credentialHandler", new CredentialHandlerService(this));
38752
+ yield this.ready();
38753
+ return injector;
38754
+ });
38755
+ }
38756
+ addEventListener(eventType, fn) {
38757
+ if (!EVENT_TYPES.includes(eventType)) {
38758
+ throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
38759
+ }
38760
+ return this._emitter.addEventListener(eventType, fn);
38761
+ }
38762
+ removeEventListener(eventType, fn) {
38763
+ if (!EVENT_TYPES.includes(eventType)) {
38764
+ throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
38765
+ }
38766
+ return this._emitter.removeEventListener(eventType, fn);
38767
+ }
38768
+ };
38769
+ __name(CredentialHandler, "CredentialHandler");
38770
+
38771
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHints.js
38772
+ var CredentialHints = class {
38773
+ constructor(url, injector) {
38774
+ const remote = injector.get("credentialHints", {
38775
+ functions: ["delete", "get", "keys", "has", "set", "clear"]
38776
+ });
38777
+ for (let methodName in remote) {
38778
+ if (methodName !== "set") {
38779
+ const method = remote[methodName].bind(this, url);
38780
+ this[methodName] = function(...args) {
38781
+ this._deprecateNotice();
38782
+ return method(...args);
38783
+ };
38784
+ }
38785
+ }
38786
+ this._remoteSet = remote.set.bind(this, url);
38787
+ }
38788
+ set(hintKey, credentialHint) {
38789
+ return __async(this, null, function* () {
38790
+ this._deprecateNotice();
38791
+ credentialHint.icons = credentialHint.icons || [];
38792
+ const promises = credentialHint.icons.map((icon) => imageToDataUrl(icon.src).then((fetchedImage) => {
38793
+ icon.fetchedImage = fetchedImage;
38794
+ }));
38795
+ yield Promise.all(promises);
38796
+ return this._remoteSet(hintKey, credentialHint);
38797
+ });
38798
+ }
38799
+ _deprecateNotice() {
38800
+ console.warn("Credential hints are deprecated and no longer used.");
38801
+ }
38802
+ };
38803
+ __name(CredentialHints, "CredentialHints");
38804
+ function imageToDataUrl(url) {
38805
+ return new Promise((resolve) => {
38806
+ const img = new Image();
38807
+ img.crossOrigin = "Anonymous";
38808
+ img.onload = () => {
38809
+ let canvas = document.createElement("canvas");
38810
+ const ctx = canvas.getContext("2d");
38811
+ canvas.height = img.height;
38812
+ canvas.width = img.width;
38813
+ ctx.drawImage(img, 0, 0);
38814
+ const dataUrl = canvas.toDataURL();
38815
+ resolve(dataUrl);
38816
+ canvas = null;
38817
+ };
38818
+ img.onerror = () => resolve(null);
38819
+ img.src = url;
38820
+ });
38821
+ }
38822
+ __name(imageToDataUrl, "imageToDataUrl");
38823
+
38824
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialManager.js
38825
+ var CredentialManager = class {
38826
+ constructor(url, injector) {
38827
+ if (!(url && typeof url === "string")) {
38828
+ throw new TypeError('"url" must be a non-empty string.');
38829
+ }
38830
+ this.hints = new CredentialHints(url, injector);
38831
+ }
38832
+ static requestPermission() {
38833
+ return __async(this, null, function* () {
38834
+ const status = yield navigator.credentialsPolyfill.permissions.request({ name: "credentialhandler" });
38835
+ return status.state;
38836
+ });
38837
+ }
38838
+ };
38839
+ __name(CredentialManager, "CredentialManager");
38840
+
38841
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerRegistration.js
38842
+ var CredentialHandlerRegistration = class {
38843
+ constructor(url, injector) {
38844
+ if (!(url && typeof url === "string")) {
38845
+ throw new TypeError('"url" must be a non-empty string.');
38846
+ }
38847
+ this.credentialManager = new CredentialManager(url, injector);
38848
+ }
38849
+ };
38850
+ __name(CredentialHandlerRegistration, "CredentialHandlerRegistration");
38851
+
38852
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlers.js
38853
+ var CredentialHandlers = class {
38854
+ constructor(injector) {
38855
+ this._init = (() => __async(this, null, function* () {
38856
+ this._injector = yield injector;
38857
+ this._remote = this._injector.get("credentialHandlers", {
38858
+ functions: [
38859
+ "register",
38860
+ "unregister",
38861
+ "getRegistration",
38862
+ "hasRegistration"
38863
+ ]
38864
+ });
38865
+ }))();
38866
+ }
38867
+ register(url) {
38868
+ return __async(this, null, function* () {
38869
+ this._deprecateNotice();
38870
+ yield this._init;
38871
+ url = yield this._remote.register("credential", url);
38872
+ return new CredentialHandlerRegistration(url, this._injector);
38873
+ });
38874
+ }
38875
+ unregister(url) {
38876
+ return __async(this, null, function* () {
38877
+ this._deprecateNotice();
38878
+ yield this._init;
38879
+ return this._remote.unregister("credential", url);
38880
+ });
38881
+ }
38882
+ getRegistration(url) {
38883
+ return __async(this, null, function* () {
38884
+ this._deprecateNotice();
38885
+ yield this._init;
38886
+ url = yield this._remote.getRegistration("credential", url);
38887
+ if (!url) {
38888
+ return null;
38889
+ }
38890
+ return new CredentialHandlerRegistration(url, this._injector);
38891
+ });
38892
+ }
38893
+ hasRegistration(url) {
38894
+ return __async(this, null, function* () {
38895
+ this._deprecateNotice();
38896
+ yield this._init;
38897
+ return yield this._remote.hasRegistration("credential", url);
38898
+ });
38899
+ }
38900
+ _deprecateNotice() {
38901
+ 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()".');
38902
+ }
38903
+ };
38904
+ __name(CredentialHandlers, "CredentialHandlers");
38905
+
38906
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/WebCredential.js
38907
+ var WebCredential2 = class {
38908
+ constructor(dataType, data, { recommendedHandlerOrigins = [] } = {}) {
38909
+ if (typeof dataType !== "string") {
38910
+ throw new TypeError('"dataType" must be a string.');
38911
+ }
38912
+ this.type = "web";
38913
+ this.dataType = dataType;
38914
+ this.data = data;
38915
+ this.options = { recommendedHandlerOrigins };
38916
+ }
38917
+ };
38918
+ __name(WebCredential2, "WebCredential");
38919
+
38920
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialsContainer.js
38921
+ var CREDENTIAL_GET_TIMEOUT = 0;
38922
+ var CREDENTIAL_STORE_TIMEOUT = 0;
38923
+ var CredentialsContainer = class {
38924
+ constructor(injector) {
38925
+ this._nativeCredentialsContainer = {
38926
+ get: navigator.credentials && navigator.credentials.get && navigator.credentials.get.bind(navigator.credentials),
38927
+ store: navigator.credentials && navigator.credentials.store && navigator.credentials.store.bind(navigator.credentials)
38928
+ };
38929
+ this._init = (() => __async(this, null, function* () {
38930
+ this._remote = (yield injector).get("credentialsContainer", {
38931
+ functions: [
38932
+ { name: "get", options: { timeout: CREDENTIAL_GET_TIMEOUT } },
38933
+ { name: "store", options: { timeout: CREDENTIAL_STORE_TIMEOUT } }
38934
+ ]
38935
+ });
38936
+ }))();
38937
+ }
38938
+ get() {
38939
+ return __async(this, arguments, function* (options = {}) {
38940
+ if (options.web) {
38941
+ yield this._init;
38942
+ const credential = yield this._remote.get(options);
38943
+ if (!credential) {
38944
+ return null;
38945
+ }
38946
+ return new WebCredential2(credential.dataType, credential.data);
38947
+ }
38948
+ if (this._nativeCredentialsContainer.get) {
38949
+ return this._nativeCredentialsContainer.get(options);
38950
+ }
38951
+ throw new DOMException("Not implemented.", "NotSupportedError");
38952
+ });
38953
+ }
38954
+ store(credential) {
38955
+ return __async(this, null, function* () {
38956
+ if (credential instanceof WebCredential2) {
38957
+ yield this._init;
38958
+ const result = yield this._remote.store(credential);
38959
+ if (!result) {
38960
+ return null;
38961
+ }
38962
+ return new WebCredential2(result.dataType, result.data);
38963
+ }
38964
+ if (this._nativeCredentialsContainer.store) {
38965
+ return this._nativeCredentialsContainer.store(credential);
38966
+ }
38967
+ throw new DOMException("Not implemented.", "NotSupportedError");
38968
+ });
38969
+ }
38970
+ };
38971
+ __name(CredentialsContainer, "CredentialsContainer");
38972
+
38973
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/PermissionManager.js
38974
+ var PERMISSION_REQUEST_TIMEOUT = 0;
38975
+ var PermissionManager = class {
38976
+ constructor(injector) {
38977
+ this._init = (() => __async(this, null, function* () {
38978
+ this._remote = (yield injector).get("permissionManager", {
38979
+ functions: [
38980
+ "query",
38981
+ { name: "request", options: { timeout: PERMISSION_REQUEST_TIMEOUT } },
38982
+ "revoke"
38983
+ ]
38984
+ });
38985
+ }))();
38986
+ }
38987
+ query(permissionDesc) {
38988
+ return __async(this, null, function* () {
38989
+ yield this._init;
38990
+ return yield this._remote.query(permissionDesc);
38991
+ });
38992
+ }
38993
+ request(permissionDesc) {
38994
+ return __async(this, null, function* () {
38995
+ yield this._init;
38996
+ return yield this._remote.request(permissionDesc);
38997
+ });
38998
+ }
38999
+ revoke(permissionDesc) {
39000
+ return __async(this, null, function* () {
39001
+ yield this._init;
39002
+ return yield this._remote.revoke(permissionDesc);
39003
+ });
39004
+ }
39005
+ };
39006
+ __name(PermissionManager, "PermissionManager");
39007
+
39008
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/index.js
39009
+ var DEFAULT_MEDIATOR_ORIGIN = "https://authn.io";
39010
+ var loaded;
39011
+ function loadOnce(options) {
39012
+ return __async(this, null, function* () {
39013
+ if (loaded) {
39014
+ return loaded;
39015
+ }
39016
+ loaded = true;
39017
+ return load2(options);
39018
+ });
39019
+ }
39020
+ __name(loadOnce, "loadOnce");
39021
+ function load2() {
39022
+ return __async(this, arguments, function* (options = {
39023
+ mediatorOrigin: DEFAULT_MEDIATOR_ORIGIN
39024
+ }) {
39025
+ let mediatorUrl;
39026
+ if (typeof options === "string") {
39027
+ mediatorUrl = options;
39028
+ } else if (options && typeof options === "object" && typeof options.mediatorOrigin === "string") {
39029
+ mediatorUrl = `${options.mediatorOrigin}/mediator`;
39030
+ } else {
39031
+ throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');
39032
+ }
39033
+ const appContext = new WebAppContext();
39034
+ const injector = appContext.createWindow(mediatorUrl, {
39035
+ className: "credential-mediator",
39036
+ timeout: 3e4
39037
+ });
39038
+ const style = document.createElement("style");
39039
+ style.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
39040
+ background-color: rgba(0, 0, 0, 0.25);
39041
+ }`));
39042
+ document.body.appendChild(style);
39043
+ const polyfill = {};
39044
+ polyfill.permissions = new PermissionManager(injector);
39045
+ polyfill.CredentialHandlers = new CredentialHandlers(injector);
39046
+ polyfill.CredentialHandler = CredentialHandler;
39047
+ polyfill.CredentialManager = CredentialManager;
39048
+ polyfill.credentials = new CredentialsContainer(injector);
39049
+ polyfill.WebCredential = WebCredential2;
39050
+ navigator.credentialsPolyfill = polyfill;
39051
+ if ("credentials" in navigator) {
39052
+ navigator.credentials.get = polyfill.credentials.get.bind(polyfill.credentials);
39053
+ navigator.credentials.store = polyfill.credentials.store.bind(polyfill.credentials);
39054
+ } else {
39055
+ navigator.credentials = polyfill.credentials;
39056
+ }
39057
+ window.CredentialManager = CredentialManager;
39058
+ window.WebCredential = WebCredential2;
39059
+ return polyfill;
39060
+ });
39061
+ }
39062
+ __name(load2, "load");
39063
+
39064
+ // ../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/CredentialEventProxy.js
39065
+ var PROXY_EVENT_TIMEOUT = 6e4;
39066
+ var CredentialEventProxy = class extends WebApp {
39067
+ constructor() {
39068
+ super(window.location.origin);
39069
+ }
39070
+ receive() {
39071
+ return __async(this, null, function* () {
39072
+ const self2 = this;
39073
+ yield self2.connect();
39074
+ return new Promise((resolveReceive, rejectReceive) => {
39075
+ const timeoutId = setTimeout(() => {
39076
+ rejectReceive(new Error("Timed out waiting to receive event."));
39077
+ }, PROXY_EVENT_TIMEOUT);
39078
+ self2.server.define("credentialEventProxy", {
39079
+ send(event) {
39080
+ return __async(this, null, function* () {
39081
+ resolveReceive(event);
39082
+ clearTimeout(timeoutId);
39083
+ return new Promise((resolveSend, rejectSend) => {
39084
+ event.respondWith = (promise) => {
39085
+ try {
39086
+ resolveSend(promise);
39087
+ } catch (e) {
39088
+ rejectSend(e);
39089
+ }
39090
+ };
39091
+ });
39092
+ });
39093
+ }
39094
+ });
39095
+ self2.ready();
39096
+ });
39097
+ });
39098
+ }
39099
+ };
39100
+ __name(CredentialEventProxy, "CredentialEventProxy");
39101
+
39102
+ // ../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/index.js
39103
+ var DEFAULT_MEDIATOR = "https://authn.io";
39104
+ function installHandler() {
39105
+ return __async(this, null, function* () {
39106
+ const CredentialManager2 = navigator.credentialsPolyfill.CredentialManager;
39107
+ const result = yield CredentialManager2.requestPermission();
39108
+ if (result !== "granted") {
39109
+ throw new Error("Permission denied.");
39110
+ }
39111
+ });
39112
+ }
39113
+ __name(installHandler, "installHandler");
39114
+ function activateHandler(_0) {
39115
+ return __async(this, arguments, function* ({
39116
+ mediatorOrigin = DEFAULT_MEDIATOR,
39117
+ get: get2,
39118
+ store
39119
+ }) {
39120
+ if (!(get2 || store)) {
39121
+ throw new Error('"get" or "store" function(s) must be specified.');
39122
+ }
39123
+ const CredentialHandler2 = navigator.credentialsPolyfill.CredentialHandler;
39124
+ const self2 = new CredentialHandler2(mediatorOrigin);
39125
+ if (get2) {
39126
+ if (typeof get2 !== "function") {
39127
+ throw new TypeError('"get" must be a function.');
39128
+ }
39129
+ self2.addEventListener("credentialrequest", (event) => listener({ event, get: get2 }));
39130
+ }
39131
+ if (store) {
39132
+ if (typeof store !== "function") {
39133
+ throw new TypeError('"store" must be a function.');
39134
+ }
39135
+ self2.addEventListener("credentialstore", (event) => listener({ event, store }));
39136
+ }
39137
+ yield self2.connect();
39138
+ });
39139
+ }
39140
+ __name(activateHandler, "activateHandler");
39141
+ function receiveCredentialEvent() {
39142
+ return __async(this, null, function* () {
39143
+ const proxy = new CredentialEventProxy();
39144
+ return proxy.receive();
39145
+ });
39146
+ }
39147
+ __name(receiveCredentialEvent, "receiveCredentialEvent");
39148
+ function listener({ event, get: get2, store }) {
39149
+ event.respondWith(createResponse({ event, get: get2, store }));
39150
+ }
39151
+ __name(listener, "listener");
39152
+ function createResponse(_0) {
39153
+ return __async(this, arguments, function* ({ event, get: get2, store }) {
39154
+ const result = yield (get2 || store)({ event });
39155
+ if (!(result && typeof result === "object")) {
39156
+ throw new TypeError('Return value of "get" or "store" hook must be an object.');
39157
+ }
39158
+ if (result.type === "response") {
39159
+ return { dataType: result.dataType, data: result.data };
39160
+ }
39161
+ if (result.type === "redirect") {
39162
+ const appContext = new WebAppContext();
39163
+ const handle = yield event.openWindow(result.url);
39164
+ const windowReady = appContext.createWindow(result.url, {
39165
+ handle,
39166
+ popup: false,
39167
+ timeout: 6e5
39168
+ });
39169
+ const injector = yield windowReady;
39170
+ const proxy = injector.get("credentialEventProxy", {
39171
+ functions: [{ name: "send", options: { timeout: 0 } }]
39172
+ });
39173
+ return proxy.send({
39174
+ type: event.type,
39175
+ credentialRequestOptions: event.credentialRequestOptions,
39176
+ credentialRequestOrigin: event.credentialRequestOrigin,
39177
+ credential: event.credential,
39178
+ hintKey: event.hintKey
39179
+ });
39180
+ }
39181
+ throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".');
39182
+ });
39183
+ }
39184
+ __name(createResponse, "createResponse");
39185
+
39186
+ // src/wallet/plugins/chapi/chapi.ts
39187
+ var getCHAPIPlugin = /* @__PURE__ */ __name(() => __async(void 0, null, function* () {
39188
+ if (typeof window === "undefined") {
39189
+ return {
39190
+ pluginMethods: {
39191
+ installChapiHandler: () => __async(void 0, null, function* () {
39192
+ throw new Error("CHAPI is only available inside of a browser!");
39193
+ }),
39194
+ activateChapiHandler: () => __async(void 0, null, function* () {
39195
+ throw new Error("CHAPI is only available inside of a browser!");
39196
+ }),
39197
+ receiveChapiEvent: () => __async(void 0, null, function* () {
39198
+ throw new Error("CHAPI is only available inside of a browser!");
39199
+ }),
39200
+ storeCredentialViaChapiDidAuth: () => __async(void 0, null, function* () {
39201
+ throw new Error("CHAPI is only available inside of a browser!");
39202
+ }),
39203
+ storePresentationViaChapi: () => __async(void 0, null, function* () {
39204
+ throw new Error("CHAPI is only available inside of a browser!");
39205
+ })
39206
+ }
39207
+ };
39208
+ }
39209
+ yield loadOnce();
39210
+ return {
39211
+ pluginMethods: {
39212
+ installChapiHandler: () => __async(void 0, null, function* () {
39213
+ return installHandler();
39214
+ }),
39215
+ activateChapiHandler: (_0, _1) => __async(void 0, [_0, _1], function* (_wallet, {
39216
+ mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,
39217
+ get: get2,
39218
+ store
39219
+ }) {
39220
+ return activateHandler({ mediatorOrigin, get: get2, store });
39221
+ }),
39222
+ receiveChapiEvent: () => __async(void 0, null, function* () {
39223
+ return receiveCredentialEvent();
39224
+ }),
39225
+ storeCredentialViaChapiDidAuth: (wallet, credential) => __async(void 0, null, function* () {
39226
+ var _a, _b, _c;
39227
+ const challenge = crypto.randomUUID();
39228
+ const domain = window.location.origin;
39229
+ const vpr = {
39230
+ web: {
39231
+ VerifiablePresentation: {
39232
+ query: { type: "DIDAuthentication" },
39233
+ challenge,
39234
+ domain
39235
+ }
39236
+ }
39237
+ };
39238
+ const res = yield navigator.credentials.get(vpr);
39239
+ if (!res)
39240
+ return { success: false, reason: "did not auth" };
39241
+ const verification = yield wallet.pluginMethods.verifyPresentation(res.data, {
39242
+ challenge,
39243
+ domain
39244
+ });
39245
+ if (verification.warnings.length > 0 || verification.errors.length > 0) {
39246
+ return { success: false, reason: "auth failed verification" };
39247
+ }
39248
+ const subject = (_c = (_b = (_a = res.data) == null ? void 0 : _a.proof) == null ? void 0 : _b.verificationMethod) == null ? void 0 : _c.split("#")[0];
39249
+ if (!Array.isArray(credential.credentialSubject)) {
39250
+ credential.credentialSubject.id = subject;
39251
+ }
39252
+ const vp = yield wallet.pluginMethods.issuePresentation(yield wallet.pluginMethods.getTestVp(yield wallet.pluginMethods.issueCredential(credential)));
39253
+ const success = yield wallet.pluginMethods.storePresentationViaChapi(vp);
39254
+ if (success)
39255
+ return { success: true };
39256
+ return { success: false, reason: "did not store" };
39257
+ }),
39258
+ storePresentationViaChapi: (_wallet, presentation) => __async(void 0, null, function* () {
39259
+ const wc = new WebCredential("VerifiablePresentation", presentation);
39260
+ return window.navigator.credentials.store(wc);
39261
+ })
39262
+ }
39263
+ };
39264
+ }), "getCHAPIPlugin");
39265
+
39266
+ // src/wallet/plugins/vc-templates/templates.ts
39267
+ var VC_TEMPLATES = {
39268
+ basic: ({
39269
+ did = "did:example:d23dd687a7dc6787646f2eb98d0",
39270
+ subject = "did:example:d23dd687a7dc6787646f2eb98d0",
39271
+ issuanceDate = "2020-08-19T21:41:50Z"
39272
+ } = {}) => ({
39273
+ "@context": ["https://www.w3.org/2018/credentials/v1"],
39274
+ id: "http://example.org/credentials/3731",
39275
+ type: ["VerifiableCredential"],
39276
+ issuer: did,
39277
+ issuanceDate,
39278
+ credentialSubject: { id: subject }
39279
+ }),
39280
+ achievement: ({
39281
+ did = "did:example:d23dd687a7dc6787646f2eb98d0",
39282
+ subject = "did:example:d23dd687a7dc6787646f2eb98d0",
39283
+ name: name5 = "Teamwork Badge",
39284
+ achievementName = "Teamwork",
39285
+ description = "This badge recognizes the development of the capacity to collaborate within a group environment.",
39286
+ criteriaNarrative = "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",
39287
+ issuanceDate = "2020-08-19T21:41:50Z"
39288
+ } = {}) => ({
39289
+ "@context": [
39290
+ "https://www.w3.org/2018/credentials/v1",
39291
+ "https://imsglobal.github.io/openbadges-specification/context.json"
39292
+ ],
39293
+ id: "http://example.com/credentials/3527",
39294
+ type: ["VerifiableCredential", "OpenBadgeCredential"],
39295
+ issuer: did,
39296
+ issuanceDate,
39297
+ name: name5,
39298
+ credentialSubject: {
39299
+ id: subject,
39300
+ type: ["AchievementSubject"],
39301
+ achievement: {
39302
+ id: "https://example.com/achievements/21st-century-skills/teamwork",
39303
+ type: ["Achievement"],
39304
+ criteria: { narrative: criteriaNarrative },
39305
+ description,
39306
+ name: achievementName
39307
+ }
39308
+ }
39309
+ })
39310
+ };
39311
+
39312
+ // src/wallet/plugins/vc-templates/vc-templates.ts
39313
+ var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
39314
+ return {
39315
+ pluginMethods: {
39316
+ newCredential: (_wallet, args = { type: "basic" }) => {
39317
+ var _a, _b;
39318
+ const did = args.did || ((_b = (_a = _wallet.pluginMethods).getSubjectDid) == null ? void 0 : _b.call(_a, "key"));
39319
+ if (!did)
39320
+ throw new Error("Could not get issuer did!");
39321
+ const defaults = {
39322
+ did,
39323
+ subject: "did:example:d23dd687a7dc6787646f2eb98d0",
39324
+ issuanceDate: "2020-08-19T21:41:50Z"
39325
+ };
39326
+ const _c = args, { type = "basic" } = _c, functionArgs = __objRest(_c, ["type"]);
39327
+ if (!(type in VC_TEMPLATES))
39328
+ throw new Error("Invalid Test VC Type!");
39329
+ return VC_TEMPLATES[type](__spreadValues(__spreadValues({}, defaults), functionArgs));
39330
+ },
39331
+ newPresentation: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, args = {}) {
39332
+ var _a, _b;
39333
+ const did = (args == null ? void 0 : args.did) || ((_b = (_a = _wallet.pluginMethods).getSubjectDid) == null ? void 0 : _b.call(_a, "key"));
39334
+ if (!did)
39335
+ throw new Error("Could not get issuer did!");
39336
+ return {
39337
+ "@context": ["https://www.w3.org/2018/credentials/v1"],
39338
+ type: ["VerifiablePresentation"],
39339
+ holder: did,
39340
+ verifiableCredential: credential
39341
+ };
39342
+ })
39343
+ }
39344
+ };
39345
+ }, "getVCTemplatesPlugin");
39346
+
36118
39347
  // ../../node_modules/.pnpm/zod@3.17.3/node_modules/zod/lib/index.mjs
36119
39348
  var util;
36120
39349
  (function(util2) {
@@ -38859,12 +42088,12 @@ var ImageValidator = mod.string().or(mod.object({
38859
42088
  caption: mod.string().optional()
38860
42089
  }));
38861
42090
  var GeoCoordinatesValidator = mod.object({
38862
- type: mod.string().array().nonempty(),
42091
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
38863
42092
  latitude: mod.number(),
38864
42093
  longitude: mod.number()
38865
42094
  });
38866
42095
  var AddressValidator = mod.object({
38867
- type: mod.string().array().nonempty(),
42096
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
38868
42097
  addressCountry: mod.string().optional(),
38869
42098
  addressCountryCode: mod.string().optional(),
38870
42099
  addressRegion: mod.string().optional(),
@@ -38895,7 +42124,7 @@ var IdentifierTypeValidator = mod.enum([
38895
42124
  "identifier"
38896
42125
  ]).or(mod.string());
38897
42126
  var IdentifierEntryValidator = mod.object({
38898
- type: mod.string().array().nonempty(),
42127
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
38899
42128
  identifier: mod.string(),
38900
42129
  identifierType: IdentifierTypeValidator
38901
42130
  });
@@ -39115,7 +42344,7 @@ var AchievementSubjectValidator = mod.object({
39115
42344
  activityStartDate: mod.string().optional(),
39116
42345
  creditsEarned: mod.number().optional(),
39117
42346
  achievement: AchievementValidator.optional(),
39118
- identifier: IdentityObjectValidator.optional(),
42347
+ identifier: IdentityObjectValidator.array().optional(),
39119
42348
  image: ImageValidator.optional(),
39120
42349
  licenseNumber: mod.string().optional(),
39121
42350
  narrative: mod.string().optional(),
@@ -39136,7 +42365,7 @@ var EvidenceValidator = mod.object({
39136
42365
  var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
39137
42366
  name: mod.string().optional(),
39138
42367
  description: mod.string().optional(),
39139
- image: mod.string().optional(),
42368
+ image: ImageValidator.optional(),
39140
42369
  credentialSubject: AchievementSubjectValidator.or(AchievementSubjectValidator.array()),
39141
42370
  endorsement: UnsignedVCValidator.array().optional(),
39142
42371
  evidence: EvidenceValidator.array().optional()
@@ -40783,12 +44012,21 @@ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
40783
44012
  // src/wallet/initializers/emptyWallet.ts
40784
44013
  var emptyWallet = /* @__PURE__ */ __name((..._0) => __async(void 0, [..._0], function* ({ didkit } = {}) {
40785
44014
  const didkitWallet = yield (yield generateWallet()).addPlugin(yield getDidKitPlugin(didkit));
40786
- const wallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
44015
+ const expirationWallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
44016
+ const templatesWallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin());
44017
+ const wallet = yield templatesWallet.addPlugin(yield getCHAPIPlugin());
40787
44018
  return {
40788
44019
  _wallet: wallet,
44020
+ newCredential: wallet.pluginMethods.newCredential,
44021
+ newPresentation: wallet.pluginMethods.newPresentation,
40789
44022
  verifyCredential: verifyCredential2(wallet),
40790
44023
  verifyPresentation: wallet.pluginMethods.verifyPresentation,
40791
- resolveDid: wallet.pluginMethods.resolveDid
44024
+ resolveDid: wallet.pluginMethods.resolveDid,
44025
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
44026
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
44027
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
44028
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
44029
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
40792
44030
  };
40793
44031
  }), "emptyWallet");
40794
44032
 
@@ -48791,75 +52029,75 @@ var PatchError = function(_super) {
48791
52029
  var JsonPatchError = PatchError;
48792
52030
  var deepClone = _deepClone;
48793
52031
  var objOps = {
48794
- add: function(obj, key2, document) {
52032
+ add: function(obj, key2, document2) {
48795
52033
  obj[key2] = this.value;
48796
- return { newDocument: document };
52034
+ return { newDocument: document2 };
48797
52035
  },
48798
- remove: function(obj, key2, document) {
52036
+ remove: function(obj, key2, document2) {
48799
52037
  var removed = obj[key2];
48800
52038
  delete obj[key2];
48801
- return { newDocument: document, removed };
52039
+ return { newDocument: document2, removed };
48802
52040
  },
48803
- replace: function(obj, key2, document) {
52041
+ replace: function(obj, key2, document2) {
48804
52042
  var removed = obj[key2];
48805
52043
  obj[key2] = this.value;
48806
- return { newDocument: document, removed };
52044
+ return { newDocument: document2, removed };
48807
52045
  },
48808
- move: function(obj, key2, document) {
48809
- var removed = getValueByPointer(document, this.path);
52046
+ move: function(obj, key2, document2) {
52047
+ var removed = getValueByPointer(document2, this.path);
48810
52048
  if (removed) {
48811
52049
  removed = _deepClone(removed);
48812
52050
  }
48813
- var originalValue = applyOperation(document, { op: "remove", path: this.from }).removed;
48814
- applyOperation(document, { op: "add", path: this.path, value: originalValue });
48815
- return { newDocument: document, removed };
52051
+ var originalValue = applyOperation(document2, { op: "remove", path: this.from }).removed;
52052
+ applyOperation(document2, { op: "add", path: this.path, value: originalValue });
52053
+ return { newDocument: document2, removed };
48816
52054
  },
48817
- copy: function(obj, key2, document) {
48818
- var valueToCopy = getValueByPointer(document, this.from);
48819
- applyOperation(document, { op: "add", path: this.path, value: _deepClone(valueToCopy) });
48820
- return { newDocument: document };
52055
+ copy: function(obj, key2, document2) {
52056
+ var valueToCopy = getValueByPointer(document2, this.from);
52057
+ applyOperation(document2, { op: "add", path: this.path, value: _deepClone(valueToCopy) });
52058
+ return { newDocument: document2 };
48821
52059
  },
48822
- test: function(obj, key2, document) {
48823
- return { newDocument: document, test: _areEquals(obj[key2], this.value) };
52060
+ test: function(obj, key2, document2) {
52061
+ return { newDocument: document2, test: _areEquals(obj[key2], this.value) };
48824
52062
  },
48825
- _get: function(obj, key2, document) {
52063
+ _get: function(obj, key2, document2) {
48826
52064
  this.value = obj[key2];
48827
- return { newDocument: document };
52065
+ return { newDocument: document2 };
48828
52066
  }
48829
52067
  };
48830
52068
  var arrOps = {
48831
- add: function(arr, i, document) {
52069
+ add: function(arr, i, document2) {
48832
52070
  if (isInteger2(i)) {
48833
52071
  arr.splice(i, 0, this.value);
48834
52072
  } else {
48835
52073
  arr[i] = this.value;
48836
52074
  }
48837
- return { newDocument: document, index: i };
52075
+ return { newDocument: document2, index: i };
48838
52076
  },
48839
- remove: function(arr, i, document) {
52077
+ remove: function(arr, i, document2) {
48840
52078
  var removedList = arr.splice(i, 1);
48841
- return { newDocument: document, removed: removedList[0] };
52079
+ return { newDocument: document2, removed: removedList[0] };
48842
52080
  },
48843
- replace: function(arr, i, document) {
52081
+ replace: function(arr, i, document2) {
48844
52082
  var removed = arr[i];
48845
52083
  arr[i] = this.value;
48846
- return { newDocument: document, removed };
52084
+ return { newDocument: document2, removed };
48847
52085
  },
48848
52086
  move: objOps.move,
48849
52087
  copy: objOps.copy,
48850
52088
  test: objOps.test,
48851
52089
  _get: objOps._get
48852
52090
  };
48853
- function getValueByPointer(document, pointer) {
52091
+ function getValueByPointer(document2, pointer) {
48854
52092
  if (pointer == "") {
48855
- return document;
52093
+ return document2;
48856
52094
  }
48857
52095
  var getOriginalDestination = { op: "_get", path: pointer };
48858
- applyOperation(document, getOriginalDestination);
52096
+ applyOperation(document2, getOriginalDestination);
48859
52097
  return getOriginalDestination.value;
48860
52098
  }
48861
52099
  __name(getValueByPointer, "getValueByPointer");
48862
- function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
52100
+ function applyOperation(document2, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
48863
52101
  if (validateOperation === void 0) {
48864
52102
  validateOperation = false;
48865
52103
  }
@@ -48874,54 +52112,54 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
48874
52112
  }
48875
52113
  if (validateOperation) {
48876
52114
  if (typeof validateOperation == "function") {
48877
- validateOperation(operation, 0, document, operation.path);
52115
+ validateOperation(operation, 0, document2, operation.path);
48878
52116
  } else {
48879
52117
  validator(operation, 0);
48880
52118
  }
48881
52119
  }
48882
52120
  if (operation.path === "") {
48883
- var returnValue = { newDocument: document };
52121
+ var returnValue = { newDocument: document2 };
48884
52122
  if (operation.op === "add") {
48885
52123
  returnValue.newDocument = operation.value;
48886
52124
  return returnValue;
48887
52125
  } else if (operation.op === "replace") {
48888
52126
  returnValue.newDocument = operation.value;
48889
- returnValue.removed = document;
52127
+ returnValue.removed = document2;
48890
52128
  return returnValue;
48891
52129
  } else if (operation.op === "move" || operation.op === "copy") {
48892
- returnValue.newDocument = getValueByPointer(document, operation.from);
52130
+ returnValue.newDocument = getValueByPointer(document2, operation.from);
48893
52131
  if (operation.op === "move") {
48894
- returnValue.removed = document;
52132
+ returnValue.removed = document2;
48895
52133
  }
48896
52134
  return returnValue;
48897
52135
  } else if (operation.op === "test") {
48898
- returnValue.test = _areEquals(document, operation.value);
52136
+ returnValue.test = _areEquals(document2, operation.value);
48899
52137
  if (returnValue.test === false) {
48900
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52138
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
48901
52139
  }
48902
- returnValue.newDocument = document;
52140
+ returnValue.newDocument = document2;
48903
52141
  return returnValue;
48904
52142
  } else if (operation.op === "remove") {
48905
- returnValue.removed = document;
52143
+ returnValue.removed = document2;
48906
52144
  returnValue.newDocument = null;
48907
52145
  return returnValue;
48908
52146
  } else if (operation.op === "_get") {
48909
- operation.value = document;
52147
+ operation.value = document2;
48910
52148
  return returnValue;
48911
52149
  } else {
48912
52150
  if (validateOperation) {
48913
- throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
52151
+ throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document2);
48914
52152
  } else {
48915
52153
  return returnValue;
48916
52154
  }
48917
52155
  }
48918
52156
  } else {
48919
52157
  if (!mutateDocument) {
48920
- document = _deepClone(document);
52158
+ document2 = _deepClone(document2);
48921
52159
  }
48922
52160
  var path = operation.path || "";
48923
52161
  var keys = path.split("/");
48924
- var obj = document;
52162
+ var obj = document2;
48925
52163
  var t = 1;
48926
52164
  var len = keys.length;
48927
52165
  var existingPathFragment = void 0;
@@ -48948,7 +52186,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
48948
52186
  existingPathFragment = operation.path;
48949
52187
  }
48950
52188
  if (existingPathFragment !== void 0) {
48951
- validateFunction(operation, 0, document, existingPathFragment);
52189
+ validateFunction(operation, 0, document2, existingPathFragment);
48952
52190
  }
48953
52191
  }
48954
52192
  }
@@ -48958,39 +52196,39 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
48958
52196
  key2 = obj.length;
48959
52197
  } else {
48960
52198
  if (validateOperation && !isInteger2(key2)) {
48961
- 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);
52199
+ 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);
48962
52200
  } else if (isInteger2(key2)) {
48963
52201
  key2 = ~~key2;
48964
52202
  }
48965
52203
  }
48966
52204
  if (t >= len) {
48967
52205
  if (validateOperation && operation.op === "add" && key2 > obj.length) {
48968
- 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);
52206
+ 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);
48969
52207
  }
48970
- var returnValue = arrOps[operation.op].call(operation, obj, key2, document);
52208
+ var returnValue = arrOps[operation.op].call(operation, obj, key2, document2);
48971
52209
  if (returnValue.test === false) {
48972
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52210
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
48973
52211
  }
48974
52212
  return returnValue;
48975
52213
  }
48976
52214
  } else {
48977
52215
  if (t >= len) {
48978
- var returnValue = objOps[operation.op].call(operation, obj, key2, document);
52216
+ var returnValue = objOps[operation.op].call(operation, obj, key2, document2);
48979
52217
  if (returnValue.test === false) {
48980
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52218
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
48981
52219
  }
48982
52220
  return returnValue;
48983
52221
  }
48984
52222
  }
48985
52223
  obj = obj[key2];
48986
52224
  if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
48987
- throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
52225
+ throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document2);
48988
52226
  }
48989
52227
  }
48990
52228
  }
48991
52229
  }
48992
52230
  __name(applyOperation, "applyOperation");
48993
- function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
52231
+ function applyPatch(document2, patch, validateOperation, mutateDocument, banPrototypeModifications) {
48994
52232
  if (mutateDocument === void 0) {
48995
52233
  mutateDocument = true;
48996
52234
  }
@@ -49003,72 +52241,72 @@ function applyPatch(document, patch, validateOperation, mutateDocument, banProto
49003
52241
  }
49004
52242
  }
49005
52243
  if (!mutateDocument) {
49006
- document = _deepClone(document);
52244
+ document2 = _deepClone(document2);
49007
52245
  }
49008
52246
  var results = new Array(patch.length);
49009
52247
  for (var i = 0, length_1 = patch.length; i < length_1; i++) {
49010
- results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
49011
- document = results[i].newDocument;
52248
+ results[i] = applyOperation(document2, patch[i], validateOperation, true, banPrototypeModifications, i);
52249
+ document2 = results[i].newDocument;
49012
52250
  }
49013
- results.newDocument = document;
52251
+ results.newDocument = document2;
49014
52252
  return results;
49015
52253
  }
49016
52254
  __name(applyPatch, "applyPatch");
49017
- function applyReducer(document, operation, index) {
49018
- var operationResult = applyOperation(document, operation);
52255
+ function applyReducer(document2, operation, index) {
52256
+ var operationResult = applyOperation(document2, operation);
49019
52257
  if (operationResult.test === false) {
49020
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52258
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49021
52259
  }
49022
52260
  return operationResult.newDocument;
49023
52261
  }
49024
52262
  __name(applyReducer, "applyReducer");
49025
- function validator(operation, index, document, existingPathFragment) {
52263
+ function validator(operation, index, document2, existingPathFragment) {
49026
52264
  if (typeof operation !== "object" || operation === null || Array.isArray(operation)) {
49027
- throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document);
52265
+ throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document2);
49028
52266
  } else if (!objOps[operation.op]) {
49029
- throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
52267
+ throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document2);
49030
52268
  } else if (typeof operation.path !== "string") {
49031
- throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document);
52269
+ throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document2);
49032
52270
  } else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) {
49033
- throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document);
52271
+ throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document2);
49034
52272
  } else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") {
49035
- throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document);
52273
+ throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document2);
49036
52274
  } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) {
49037
- throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document);
52275
+ throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document2);
49038
52276
  } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && hasUndefined(operation.value)) {
49039
- throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document);
49040
- } else if (document) {
52277
+ throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document2);
52278
+ } else if (document2) {
49041
52279
  if (operation.op == "add") {
49042
52280
  var pathLen = operation.path.split("/").length;
49043
52281
  var existingPathLen = existingPathFragment.split("/").length;
49044
52282
  if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
49045
- throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document);
52283
+ throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document2);
49046
52284
  }
49047
52285
  } else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") {
49048
52286
  if (operation.path !== existingPathFragment) {
49049
- throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
52287
+ throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document2);
49050
52288
  }
49051
52289
  } else if (operation.op === "move" || operation.op === "copy") {
49052
52290
  var existingValue = { op: "_get", path: operation.from, value: void 0 };
49053
- var error = validate5([existingValue], document);
52291
+ var error = validate5([existingValue], document2);
49054
52292
  if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") {
49055
- throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document);
52293
+ throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document2);
49056
52294
  }
49057
52295
  }
49058
52296
  }
49059
52297
  }
49060
52298
  __name(validator, "validator");
49061
- function validate5(sequence, document, externalValidator) {
52299
+ function validate5(sequence, document2, externalValidator) {
49062
52300
  try {
49063
52301
  if (!Array.isArray(sequence)) {
49064
52302
  throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
49065
52303
  }
49066
- if (document) {
49067
- applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);
52304
+ if (document2) {
52305
+ applyPatch(_deepClone(document2), _deepClone(sequence), externalValidator || true);
49068
52306
  } else {
49069
52307
  externalValidator = externalValidator || validator;
49070
52308
  for (var i = 0; i < sequence.length; i++) {
49071
- externalValidator(sequence[i], i, document, void 0);
52309
+ externalValidator(sequence[i], i, document2, void 0);
49072
52310
  }
49073
52311
  }
49074
52312
  } catch (e) {
@@ -49296,11 +52534,11 @@ var fast_json_patch_default = Object.assign({}, core_exports, duplex_exports, {
49296
52534
  unescapePathComponent
49297
52535
  });
49298
52536
 
49299
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
52537
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
49300
52538
  var import_lodash3 = __toESM(require_lodash(), 1);
49301
52539
  var import_random3 = __toESM(require_random(), 1);
49302
52540
 
49303
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/streamopts.js
52541
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/streamopts.js
49304
52542
  var SyncOptions;
49305
52543
  (function(SyncOptions2) {
49306
52544
  SyncOptions2[SyncOptions2["PREFER_CACHE"] = 0] = "PREFER_CACHE";
@@ -49308,7 +52546,7 @@ var SyncOptions;
49308
52546
  SyncOptions2[SyncOptions2["NEVER_SYNC"] = 2] = "NEVER_SYNC";
49309
52547
  })(SyncOptions || (SyncOptions = {}));
49310
52548
 
49311
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream.js
52549
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream.js
49312
52550
  var import_lodash = __toESM(require_lodash(), 1);
49313
52551
 
49314
52552
  // ../../node_modules/.pnpm/tslib@2.4.0/node_modules/tslib/modules/index.js
@@ -51202,7 +54440,7 @@ function throttle(durationSelector, config2) {
51202
54440
  }
51203
54441
  __name(throttle, "throttle");
51204
54442
 
51205
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream.js
54443
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream.js
51206
54444
  var SignatureStatus;
51207
54445
  (function(SignatureStatus2) {
51208
54446
  SignatureStatus2[SignatureStatus2["GENESIS"] = 0] = "GENESIS";
@@ -51281,10 +54519,10 @@ function StreamStatic() {
51281
54519
  }
51282
54520
  __name(StreamStatic, "StreamStatic");
51283
54521
 
51284
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
54522
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
51285
54523
  import fetch2 from "cross-fetch";
51286
54524
 
51287
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/abort-signal-utils.js
54525
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/abort-signal-utils.js
51288
54526
  function mergeAbortSignals(signals) {
51289
54527
  const controller = new AbortController();
51290
54528
  if (signals.length === 0) {
@@ -51334,7 +54572,7 @@ function abortable2(original, fn) {
51334
54572
  }
51335
54573
  __name(abortable2, "abortable");
51336
54574
 
51337
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
54575
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
51338
54576
  var DEFAULT_FETCH_TIMEOUT = 60 * 1e3 * 3;
51339
54577
  function fetchJson(_0) {
51340
54578
  return __async(this, arguments, function* (url, opts = {}) {
@@ -51359,10 +54597,10 @@ function fetchJson(_0) {
51359
54597
  }
51360
54598
  __name(fetchJson, "fetchJson");
51361
54599
 
51362
- // ../../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
51363
54601
  var import_lodash2 = __toESM(require_lodash(), 1);
51364
54602
 
51365
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/cid-utils.js
54603
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/cid-utils.js
51366
54604
  init_cid();
51367
54605
  function toCID(givenCid) {
51368
54606
  const cid = CID.asCID(givenCid);
@@ -51379,7 +54617,7 @@ function toCID(givenCid) {
51379
54617
  }
51380
54618
  __name(toCID, "toCID");
51381
54619
 
51382
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
54620
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
51383
54621
  var TILE_TYPE_ID = 0;
51384
54622
  var StreamUtils = class {
51385
54623
  static streamIdFromState(state) {
@@ -51559,7 +54797,7 @@ var StreamUtils = class {
51559
54797
  };
51560
54798
  __name(StreamUtils, "StreamUtils");
51561
54799
 
51562
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/accountid-utils.js
54800
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/accountid-utils.js
51563
54801
  function normalizeAccountId(accountId) {
51564
54802
  if (typeof accountId === "string" && accountId.includes("@")) {
51565
54803
  const [address, chainId] = accountId.split("@");
@@ -51572,7 +54810,7 @@ function normalizeAccountId(accountId) {
51572
54810
  }
51573
54811
  __name(normalizeAccountId, "normalizeAccountId");
51574
54812
 
51575
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream-state-subject.js
54813
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream-state-subject.js
51576
54814
  var StreamStateSubject = class extends BehaviorSubject {
51577
54815
  next(next) {
51578
54816
  const current = this.value;
@@ -51583,7 +54821,7 @@ var StreamStateSubject = class extends BehaviorSubject {
51583
54821
  };
51584
54822
  __name(StreamStateSubject, "StreamStateSubject");
51585
54823
 
51586
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
54824
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
51587
54825
  var __decorate4 = function(decorators, target, key2, desc) {
51588
54826
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
51589
54827
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -51819,7 +55057,7 @@ TileDocument = TileDocument_1 = __decorate4([
51819
55057
  StreamStatic()
51820
55058
  ], TileDocument);
51821
55059
 
51822
- // ../../node_modules/.pnpm/@glazed+tile-loader@0.2.1/node_modules/@glazed/tile-loader/dist/index.js
55060
+ // ../../node_modules/.pnpm/@glazed+tile-loader@0.2.1_@opentelemetry+api@1.1.0/node_modules/@glazed/tile-loader/dist/index.js
51823
55061
  var import_dataloader = __toESM(require_dataloader(), 1);
51824
55062
  function _checkPrivateRedeclaration2(obj, privateCollection) {
51825
55063
  if (privateCollection.has(obj)) {
@@ -51978,7 +55216,7 @@ var TileLoader = class extends import_dataloader.default {
51978
55216
  };
51979
55217
  __name(TileLoader, "TileLoader");
51980
55218
 
51981
- // ../../node_modules/.pnpm/@glazed+datamodel@0.3.1/node_modules/@glazed/datamodel/dist/index.js
55219
+ // ../../node_modules/.pnpm/@glazed+datamodel@0.3.1_@opentelemetry+api@1.1.0/node_modules/@glazed/datamodel/dist/index.js
51982
55220
  function _checkPrivateRedeclaration3(obj, privateCollection) {
51983
55221
  if (privateCollection.has(obj)) {
51984
55222
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52098,7 +55336,7 @@ var DataModel = class {
52098
55336
  };
52099
55337
  __name(DataModel, "DataModel");
52100
55338
 
52101
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/proxy.js
55339
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/proxy.js
52102
55340
  function _checkPrivateRedeclaration4(obj, privateCollection) {
52103
55341
  if (privateCollection.has(obj)) {
52104
55342
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52244,7 +55482,7 @@ var TileProxy = class {
52244
55482
  };
52245
55483
  __name(TileProxy, "TileProxy");
52246
55484
 
52247
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/utils.js
55485
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/utils.js
52248
55486
  var didRegex = /^did:([A-Za-z0-9]+):([A-Za-z0-9.\-:_]+)$/;
52249
55487
  function isDIDstring(did) {
52250
55488
  return didRegex.test(did);
@@ -52267,7 +55505,7 @@ function getIDXMetadata(did) {
52267
55505
  }
52268
55506
  __name(getIDXMetadata, "getIDXMetadata");
52269
55507
 
52270
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/index.js
55508
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/index.js
52271
55509
  function _checkPrivateRedeclaration5(obj, privateCollection) {
52272
55510
  if (privateCollection.has(obj)) {
52273
55511
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52664,13 +55902,13 @@ var DIDDataStore = class {
52664
55902
  };
52665
55903
  __name(DIDDataStore, "DIDDataStore");
52666
55904
 
52667
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/utils.js
55905
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/utils.js
52668
55906
  function typeStreamID(streamId) {
52669
55907
  return typeof streamId === "string" ? StreamID.fromString(streamId) : streamId;
52670
55908
  }
52671
55909
  __name(typeStreamID, "typeStreamID");
52672
55910
 
52673
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/document.js
55911
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/document.js
52674
55912
  var Document = class extends Observable {
52675
55913
  constructor(initial, _apiUrl, syncInterval) {
52676
55914
  super((subscriber) => {
@@ -52769,7 +56007,7 @@ var Document = class extends Observable {
52769
56007
  };
52770
56008
  __name(Document, "Document");
52771
56009
 
52772
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-caip10-link@2.1.0/node_modules/@ceramicnetwork/stream-caip10-link/lib/caip10-link.js
56010
+ // ../../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
52773
56011
  var import_lodash4 = __toESM(require_lodash(), 1);
52774
56012
  var __decorate5 = function(decorators, target, key2, desc) {
52775
56013
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
@@ -52888,7 +56126,7 @@ Caip10Link = Caip10Link_1 = __decorate5([
52888
56126
  StreamStatic()
52889
56127
  ], Caip10Link);
52890
56128
 
52891
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-model@0.3.0/node_modules/@ceramicnetwork/stream-model/lib/model.js
56129
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-model@0.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-model/lib/model.js
52892
56130
  var import_random4 = __toESM(require_random(), 1);
52893
56131
  init_cid();
52894
56132
  init_digest();
@@ -53089,7 +56327,7 @@ Model = Model_1 = __decorate6([
53089
56327
  StreamStatic()
53090
56328
  ], Model);
53091
56329
 
53092
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-model-instance@0.3.0/node_modules/@ceramicnetwork/stream-model-instance/lib/model-instance-document.js
56330
+ // ../../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
53093
56331
  var import_random5 = __toESM(require_random(), 1);
53094
56332
  var __decorate7 = function(decorators, target, key2, desc) {
53095
56333
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
@@ -53244,7 +56482,7 @@ ModelInstanceDocument = ModelInstanceDocument_1 = __decorate7([
53244
56482
  StreamStatic()
53245
56483
  ], ModelInstanceDocument);
53246
56484
 
53247
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/remote-pin-api.js
56485
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/remote-pin-api.js
53248
56486
  var RemotePinApi = class {
53249
56487
  constructor(_apiUrl) {
53250
56488
  this._apiUrl = _apiUrl;
@@ -53297,7 +56535,7 @@ var RemotePinApi = class {
53297
56535
  };
53298
56536
  __name(RemotePinApi, "RemotePinApi");
53299
56537
 
53300
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/remote-index-api.js
56538
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/remote-index-api.js
53301
56539
  var RemoteIndexApi = class {
53302
56540
  constructor(apiUrl) {
53303
56541
  this._fetchJson = fetchJson;
@@ -53325,7 +56563,7 @@ var RemoteIndexApi = class {
53325
56563
  };
53326
56564
  __name(RemoteIndexApi, "RemoteIndexApi");
53327
56565
 
53328
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js
56566
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js
53329
56567
  var API_PATH = "/api/v0/";
53330
56568
  var CERAMIC_HOST = "http://localhost:7007";
53331
56569
  var DEFAULT_CLIENT_CONFIG = {
@@ -53419,14 +56657,14 @@ var CeramicClient = class {
53419
56657
  return __async(this, arguments, function* (streamId, commit, opts = {}) {
53420
56658
  opts = __spreadValues(__spreadValues({}, DEFAULT_APPLY_COMMIT_OPTS), opts);
53421
56659
  const effectiveStreamId = typeStreamID(streamId);
53422
- const document = yield Document.applyCommit(this._apiUrl, effectiveStreamId, commit, opts, this._config.syncInterval);
56660
+ const document2 = yield Document.applyCommit(this._apiUrl, effectiveStreamId, commit, opts, this._config.syncInterval);
53423
56661
  const fromCache = this._streamCache.get(effectiveStreamId.toString());
53424
56662
  if (fromCache) {
53425
- fromCache.next(document.state);
53426
- return this.buildStreamFromDocument(document);
56663
+ fromCache.next(document2.state);
56664
+ return this.buildStreamFromDocument(document2);
53427
56665
  } else {
53428
- this._streamCache.set(effectiveStreamId.toString(), document);
53429
- return this.buildStreamFromDocument(document);
56666
+ this._streamCache.set(effectiveStreamId.toString(), document2);
56667
+ return this.buildStreamFromDocument(document2);
53430
56668
  }
53431
56669
  });
53432
56670
  }
@@ -53593,6 +56831,11 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53593
56831
  };
53594
56832
  }), "getIDXPlugin");
53595
56833
 
56834
+ // ../learn-card-helpers/dist/helpers.esm.js
56835
+ var __defProp2 = Object.defineProperty;
56836
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
56837
+ var isHex = /* @__PURE__ */ __name2((str) => /^[0-9a-f]+$/i.test(str), "isHex");
56838
+
53596
56839
  // src/wallet/plugins/didkey/helpers.ts
53597
56840
  var ED25519_METHODS = ["key", "tz", "pkh:tz", "pkh:tezos", "pkh:sol", "pkh:solana"];
53598
56841
  var SECP256K1_METHODS = [
@@ -53609,7 +56852,6 @@ var SECP256K1_METHODS = [
53609
56852
  "pkh:eip155",
53610
56853
  "pkh:bip122"
53611
56854
  ];
53612
- var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
53613
56855
  var getAlgorithmForDidMethod = /* @__PURE__ */ __name((didMethod) => {
53614
56856
  if (ED25519_METHODS.includes(didMethod))
53615
56857
  return "ed25519";
@@ -53658,55 +56900,52 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async(void 0, n
53658
56900
  };
53659
56901
  }), "getDidKeyPlugin");
53660
56902
 
53661
- // src/wallet/helpers/wallet.helpers.ts
53662
- var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
53663
-
53664
56903
  // src/wallet/plugins/vc/issueCredential.ts
53665
56904
  var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
53666
- return (wallet, credential) => __async(void 0, null, function* () {
56905
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (wallet, credential, signingOptions = {}) {
53667
56906
  const kp = wallet.pluginMethods.getSubjectKeypair();
53668
56907
  if (!kp)
53669
56908
  throw new Error("Cannot issue credential: Could not get subject keypair");
53670
- const options = {
56909
+ const options = __spreadValues({
53671
56910
  verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
53672
56911
  proofPurpose: "assertionMethod"
53673
- };
56912
+ }, signingOptions);
53674
56913
  return initWallet.pluginMethods.issueCredential(credential, options, kp);
53675
56914
  });
53676
56915
  }, "issueCredential");
53677
56916
 
53678
56917
  // src/wallet/plugins/vc/verifyCredential.ts
53679
56918
  var verifyCredential3 = /* @__PURE__ */ __name((initWallet) => {
53680
- return (_wallet, credential) => __async(void 0, null, function* () {
53681
- return initWallet.pluginMethods.verifyCredential(credential);
56919
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, options = {}) {
56920
+ return initWallet.pluginMethods.verifyCredential(credential, options);
53682
56921
  });
53683
56922
  }, "verifyCredential");
53684
56923
 
53685
56924
  // src/wallet/plugins/vc/issuePresentation.ts
53686
56925
  var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
53687
- return (wallet, presentation) => __async(void 0, null, function* () {
56926
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (wallet, presentation, signingOptions = {}) {
53688
56927
  const kp = wallet.pluginMethods.getSubjectKeypair();
53689
56928
  if (!kp)
53690
56929
  throw new Error("Cannot issue credential: Could not get subject keypair");
53691
- const options = {
56930
+ const options = __spreadValues({
53692
56931
  verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
53693
56932
  proofPurpose: "assertionMethod"
53694
- };
56933
+ }, signingOptions);
53695
56934
  return initWallet.pluginMethods.issuePresentation(presentation, options, kp);
53696
56935
  });
53697
56936
  }, "issuePresentation");
53698
56937
 
53699
56938
  // src/wallet/plugins/vc/verifyPresentation.ts
53700
56939
  var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
53701
- return (_wallet, presentation) => __async(void 0, null, function* () {
53702
- return initWallet.pluginMethods.verifyPresentation(presentation);
56940
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, presentation, options = {}) {
56941
+ return initWallet.pluginMethods.verifyPresentation(presentation, options);
53703
56942
  });
53704
56943
  }, "verifyPresentation");
53705
56944
 
53706
56945
  // src/wallet/plugins/vc/vc.ts
53707
- var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, function* () {
56946
+ var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
53708
56947
  return {
53709
- pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
56948
+ pluginMethods: {
53710
56949
  issueCredential: issueCredential2(wallet),
53711
56950
  verifyCredential: verifyCredential3(wallet),
53712
56951
  issuePresentation: issuePresentation2(wallet),
@@ -53732,11 +56971,12 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, funct
53732
56971
  verifiableCredential: credential
53733
56972
  };
53734
56973
  })
53735
- })
56974
+ }
53736
56975
  };
53737
- }), "getVCPlugin");
56976
+ }, "getVCPlugin");
53738
56977
 
53739
56978
  // src/wallet/plugins/EthereumPlugin/index.ts
56979
+ var import_buffer = __toESM(require_buffer2());
53740
56980
  import { ethers as ethers2 } from "ethers";
53741
56981
 
53742
56982
  // src/wallet/plugins/EthereumPlugin/helpers.ts
@@ -53804,7 +57044,7 @@ var ERC20ABI = require_erc20_abi();
53804
57044
  var getEthereumPlugin = /* @__PURE__ */ __name((initWallet, config2) => {
53805
57045
  let { infuraProjectId, network = "mainnet" } = config2;
53806
57046
  const secpKeypair = initWallet.pluginMethods.getSubjectKeypair("secp256k1");
53807
- const privateKey = Buffer.from(secpKeypair.d, "base64").toString("hex");
57047
+ const privateKey = import_buffer.Buffer.from(secpKeypair.d, "base64").toString("hex");
53808
57048
  let ethersWallet = new ethers2.Wallet(privateKey);
53809
57049
  const publicKey = ethersWallet.address;
53810
57050
  const getProvider = /* @__PURE__ */ __name(() => {
@@ -54543,11 +57783,11 @@ var Transformer = class {
54543
57783
  }
54544
57784
  _getDocument(_0) {
54545
57785
  return __async(this, arguments, function* ({ url }) {
54546
- const { document } = yield this.documentLoader(url);
54547
- if (typeof document === "string") {
54548
- return JSON.parse(document);
57786
+ const { document: document2 } = yield this.documentLoader(url);
57787
+ if (typeof document2 === "string") {
57788
+ return JSON.parse(document2);
54549
57789
  }
54550
- return document;
57790
+ return document2;
54551
57791
  });
54552
57792
  }
54553
57793
  _getTermType({ activeCtx, def }) {
@@ -57085,15 +60325,19 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57085
60325
  } = {}) {
57086
60326
  const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
57087
60327
  const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
57088
- const didkeyAndVCWallet = yield didkeyWallet.addPlugin(yield getVCPlugin(didkeyWallet));
57089
- const idxWallet = yield didkeyAndVCWallet.addPlugin(yield getIDXPlugin(didkeyAndVCWallet, ceramicIdx));
60328
+ const didkeyAndVCWallet = yield didkeyWallet.addPlugin(getVCPlugin(didkeyWallet));
60329
+ const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin());
60330
+ const idxWallet = yield templateWallet.addPlugin(yield getIDXPlugin(templateWallet, ceramicIdx));
57090
60331
  const expirationWallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
57091
60332
  const ethWallet = yield expirationWallet.addPlugin(getEthereumPlugin(expirationWallet, ethereumConfig));
57092
- const wallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
60333
+ const vpqrWallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
60334
+ const wallet = yield vpqrWallet.addPlugin(yield getCHAPIPlugin());
57093
60335
  return {
57094
60336
  _wallet: wallet,
57095
60337
  did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
57096
60338
  keypair: (type = "ed25519") => wallet.pluginMethods.getSubjectKeypair(type),
60339
+ newCredential: wallet.pluginMethods.newCredential,
60340
+ newPresentation: wallet.pluginMethods.newPresentation,
57097
60341
  issueCredential: wallet.pluginMethods.issueCredential,
57098
60342
  verifyCredential: verifyCredential2(wallet),
57099
60343
  issuePresentation: wallet.pluginMethods.issuePresentation,
@@ -57122,7 +60366,12 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57122
60366
  transferTokens: wallet.pluginMethods.transferTokens,
57123
60367
  getCurrentNetwork: wallet.pluginMethods.getCurrentNetwork,
57124
60368
  changeNetwork: wallet.pluginMethods.changeNetwork,
57125
- addInfuraProjectId: wallet.pluginMethods.addInfuraProjectId
60369
+ addInfuraProjectId: wallet.pluginMethods.addInfuraProjectId,
60370
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
60371
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
60372
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
60373
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
60374
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
57126
60375
  };
57127
60376
  }), "walletFromKey");
57128
60377
 
@@ -57142,6 +60391,7 @@ export {
57142
60391
  ExpirationPlugin,
57143
60392
  emptyWallet,
57144
60393
  generateWallet,
60394
+ getCHAPIPlugin,
57145
60395
  getDidKeyPlugin,
57146
60396
  getDidKitPlugin,
57147
60397
  getEthereumPlugin,
@@ -57153,6 +60403,47 @@ export {
57153
60403
  seedToId,
57154
60404
  walletFromKey
57155
60405
  };
60406
+ /*!
60407
+ * A CredentialHandlerRegistration provides a CredentialManager to enable Web
60408
+ * apps to register Profiles that can be presented to websites.
60409
+ *
60410
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60411
+ */
60412
+ /*!
60413
+ * A CredentialRequestEvent is emitted when a request has been made for
60414
+ * credentials.
60415
+ *
60416
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60417
+ */
60418
+ /*!
60419
+ * A CredentialStoreEvent is emitted when a request has been made to
60420
+ * store a credential.
60421
+ *
60422
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60423
+ */
60424
+ /*!
60425
+ * A WebApp is a remote application that runs in a WebAppContext.
60426
+ *
60427
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60428
+ */
60429
+ /*!
60430
+ * A WebCredential is a Credential that can be retrieved from or stored by a
60431
+ * "credential handler" that runs in a third party Web application.
60432
+ *
60433
+ * Copyright (c) 2017-2021 Digital Bazaar, Inc. All rights reserved.
60434
+ */
60435
+ /*!
60436
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60437
+ */
60438
+ /*!
60439
+ * Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
60440
+ */
60441
+ /*!
60442
+ * Copyright (c) 2017-2022 Digital Bazaar, Inc. All rights reserved.
60443
+ */
60444
+ /*!
60445
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
60446
+ */
57156
60447
  /*!
57157
60448
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
57158
60449
  */
@@ -57165,6 +60456,36 @@ export {
57165
60456
  /*!
57166
60457
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
57167
60458
  */
60459
+ /*!
60460
+ * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
60461
+ */
60462
+ /*!
60463
+ * JSON-RPC for Web Request Polyfills.
60464
+ *
60465
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60466
+ */
60467
+ /*!
60468
+ * The buffer module from node.js, for the browser.
60469
+ *
60470
+ * @author Feross Aboukhadijeh <https://feross.org>
60471
+ * @license MIT
60472
+ */
60473
+ /*!
60474
+ * The core CredentialHandler class.
60475
+ *
60476
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60477
+ */
60478
+ /*!
60479
+ * Utilities for Web Request RPC.
60480
+ *
60481
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60482
+ */
60483
+ /*!
60484
+ * Wrapper for native CredentialsContainer that uses remote Credential Mediator
60485
+ * for WebCredential-related operations.
60486
+ *
60487
+ * Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
60488
+ */
57168
60489
  /*!
57169
60490
  * https://github.com/Starcounter-Jack/JSON-Patch
57170
60491
  * (c) 2017-2021 Joachim Wester
@@ -57175,6 +60496,7 @@ export {
57175
60496
  * (c) 2017-2022 Joachim Wester
57176
60497
  * MIT licensed
57177
60498
  */
60499
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
57178
60500
  /**
57179
60501
  * @module QRCode
57180
60502
  * @package @nuintun/qrcode