@learncard/core 6.1.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2881,9 +2881,9 @@ var require_package = __commonJS({
2881
2881
  }
2882
2882
  });
2883
2883
 
2884
- // (disabled):../../node_modules/.pnpm/buffer@5.2.1/node_modules/buffer/index.js
2884
+ // (disabled):../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js
2885
2885
  var require_buffer = __commonJS({
2886
- "(disabled):../../node_modules/.pnpm/buffer@5.2.1/node_modules/buffer/index.js"() {
2886
+ "(disabled):../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js"() {
2887
2887
  }
2888
2888
  });
2889
2889
 
@@ -2930,12 +2930,12 @@ var require_bn = __commonJS({
2930
2930
  }
2931
2931
  BN3.BN = BN3;
2932
2932
  BN3.wordSize = 26;
2933
- var Buffer2;
2933
+ var Buffer3;
2934
2934
  try {
2935
2935
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
2936
- Buffer2 = window.Buffer;
2936
+ Buffer3 = window.Buffer;
2937
2937
  } else {
2938
- Buffer2 = require_buffer().Buffer;
2938
+ Buffer3 = require_buffer().Buffer;
2939
2939
  }
2940
2940
  } catch (e) {
2941
2941
  }
@@ -3376,8 +3376,8 @@ var require_bn = __commonJS({
3376
3376
  return this.toString(16);
3377
3377
  }, "toJSON");
3378
3378
  BN3.prototype.toBuffer = /* @__PURE__ */ __name(function toBuffer(endian, length2) {
3379
- assert2(typeof Buffer2 !== "undefined");
3380
- return this.toArrayLike(Buffer2, endian, length2);
3379
+ assert2(typeof Buffer3 !== "undefined");
3380
+ return this.toArrayLike(Buffer3, endian, length2);
3381
3381
  }, "toBuffer");
3382
3382
  BN3.prototype.toArray = /* @__PURE__ */ __name(function toArray(endian, length2) {
3383
3383
  return this.toArrayLike(Array, endian, length2);
@@ -23413,12 +23413,12 @@ var require_bn2 = __commonJS({
23413
23413
  }
23414
23414
  BN3.BN = BN3;
23415
23415
  BN3.wordSize = 26;
23416
- var Buffer2;
23416
+ var Buffer3;
23417
23417
  try {
23418
23418
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
23419
- Buffer2 = window.Buffer;
23419
+ Buffer3 = window.Buffer;
23420
23420
  } else {
23421
- Buffer2 = require_buffer().Buffer;
23421
+ Buffer3 = require_buffer().Buffer;
23422
23422
  }
23423
23423
  } catch (e) {
23424
23424
  }
@@ -23883,9 +23883,9 @@ var require_bn2 = __commonJS({
23883
23883
  BN3.prototype.toJSON = /* @__PURE__ */ __name(function toJSON2() {
23884
23884
  return this.toString(16, 2);
23885
23885
  }, "toJSON");
23886
- if (Buffer2) {
23886
+ if (Buffer3) {
23887
23887
  BN3.prototype.toBuffer = /* @__PURE__ */ __name(function toBuffer(endian, length2) {
23888
- return this.toArrayLike(Buffer2, endian, length2);
23888
+ return this.toArrayLike(Buffer3, endian, length2);
23889
23889
  }, "toBuffer");
23890
23890
  }
23891
23891
  BN3.prototype.toArray = /* @__PURE__ */ __name(function toArray(endian, length2) {
@@ -27421,7 +27421,7 @@ var require_lodash = __commonJS({
27421
27421
  var hasOwnProperty2 = objectProto.hasOwnProperty;
27422
27422
  var objectToString = objectProto.toString;
27423
27423
  var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
27424
- var Buffer2 = moduleExports ? root.Buffer : void 0;
27424
+ var Buffer3 = moduleExports ? root.Buffer : void 0;
27425
27425
  var Symbol2 = root.Symbol;
27426
27426
  var Uint8Array2 = root.Uint8Array;
27427
27427
  var getPrototype = overArg(Object.getPrototypeOf, Object);
@@ -27429,7 +27429,7 @@ var require_lodash = __commonJS({
27429
27429
  var propertyIsEnumerable = objectProto.propertyIsEnumerable;
27430
27430
  var splice = arrayProto.splice;
27431
27431
  var nativeGetSymbols = Object.getOwnPropertySymbols;
27432
- var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
27432
+ var nativeIsBuffer = Buffer3 ? Buffer3.isBuffer : void 0;
27433
27433
  var nativeKeys = overArg(Object.keys, Object);
27434
27434
  var DataView2 = getNative(root, "DataView");
27435
27435
  var Map2 = getNative(root, "Map");
@@ -28453,7 +28453,7 @@ var require_dataloader = __commonJS({
28453
28453
  }
28454
28454
  __name(DataLoader3, "DataLoader");
28455
28455
  var _proto = DataLoader3.prototype;
28456
- _proto.load = /* @__PURE__ */ __name(function load2(key2) {
28456
+ _proto.load = /* @__PURE__ */ __name(function load3(key2) {
28457
28457
  if (key2 === null || key2 === void 0) {
28458
28458
  throw new TypeError("The loader.load() function must be called with a value, " + ("but got: " + String(key2) + "."));
28459
28459
  }
@@ -29261,6 +29261,1667 @@ var require_src3 = __commonJS({
29261
29261
  }
29262
29262
  });
29263
29263
 
29264
+ // ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
29265
+ var require_base64_js = __commonJS({
29266
+ "../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports) {
29267
+ "use strict";
29268
+ exports.byteLength = byteLength;
29269
+ exports.toByteArray = toByteArray;
29270
+ exports.fromByteArray = fromByteArray;
29271
+ var lookup = [];
29272
+ var revLookup = [];
29273
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
29274
+ var code5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
29275
+ for (i = 0, len = code5.length; i < len; ++i) {
29276
+ lookup[i] = code5[i];
29277
+ revLookup[code5.charCodeAt(i)] = i;
29278
+ }
29279
+ var i;
29280
+ var len;
29281
+ revLookup["-".charCodeAt(0)] = 62;
29282
+ revLookup["_".charCodeAt(0)] = 63;
29283
+ function getLens(b64) {
29284
+ var len2 = b64.length;
29285
+ if (len2 % 4 > 0) {
29286
+ throw new Error("Invalid string. Length must be a multiple of 4");
29287
+ }
29288
+ var validLen = b64.indexOf("=");
29289
+ if (validLen === -1)
29290
+ validLen = len2;
29291
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
29292
+ return [validLen, placeHoldersLen];
29293
+ }
29294
+ __name(getLens, "getLens");
29295
+ function byteLength(b64) {
29296
+ var lens = getLens(b64);
29297
+ var validLen = lens[0];
29298
+ var placeHoldersLen = lens[1];
29299
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
29300
+ }
29301
+ __name(byteLength, "byteLength");
29302
+ function _byteLength(b64, validLen, placeHoldersLen) {
29303
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
29304
+ }
29305
+ __name(_byteLength, "_byteLength");
29306
+ function toByteArray(b64) {
29307
+ var tmp;
29308
+ var lens = getLens(b64);
29309
+ var validLen = lens[0];
29310
+ var placeHoldersLen = lens[1];
29311
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
29312
+ var curByte = 0;
29313
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
29314
+ var i2;
29315
+ for (i2 = 0; i2 < len2; i2 += 4) {
29316
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
29317
+ arr[curByte++] = tmp >> 16 & 255;
29318
+ arr[curByte++] = tmp >> 8 & 255;
29319
+ arr[curByte++] = tmp & 255;
29320
+ }
29321
+ if (placeHoldersLen === 2) {
29322
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
29323
+ arr[curByte++] = tmp & 255;
29324
+ }
29325
+ if (placeHoldersLen === 1) {
29326
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
29327
+ arr[curByte++] = tmp >> 8 & 255;
29328
+ arr[curByte++] = tmp & 255;
29329
+ }
29330
+ return arr;
29331
+ }
29332
+ __name(toByteArray, "toByteArray");
29333
+ function tripletToBase64(num) {
29334
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
29335
+ }
29336
+ __name(tripletToBase64, "tripletToBase64");
29337
+ function encodeChunk(uint8, start, end) {
29338
+ var tmp;
29339
+ var output = [];
29340
+ for (var i2 = start; i2 < end; i2 += 3) {
29341
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
29342
+ output.push(tripletToBase64(tmp));
29343
+ }
29344
+ return output.join("");
29345
+ }
29346
+ __name(encodeChunk, "encodeChunk");
29347
+ function fromByteArray(uint8) {
29348
+ var tmp;
29349
+ var len2 = uint8.length;
29350
+ var extraBytes = len2 % 3;
29351
+ var parts = [];
29352
+ var maxChunkLength = 16383;
29353
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
29354
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
29355
+ }
29356
+ if (extraBytes === 1) {
29357
+ tmp = uint8[len2 - 1];
29358
+ parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
29359
+ } else if (extraBytes === 2) {
29360
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
29361
+ parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
29362
+ }
29363
+ return parts.join("");
29364
+ }
29365
+ __name(fromByteArray, "fromByteArray");
29366
+ }
29367
+ });
29368
+
29369
+ // ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
29370
+ var require_ieee754 = __commonJS({
29371
+ "../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports) {
29372
+ exports.read = function(buffer2, offset, isLE, mLen, nBytes) {
29373
+ var e, m;
29374
+ var eLen = nBytes * 8 - mLen - 1;
29375
+ var eMax = (1 << eLen) - 1;
29376
+ var eBias = eMax >> 1;
29377
+ var nBits = -7;
29378
+ var i = isLE ? nBytes - 1 : 0;
29379
+ var d = isLE ? -1 : 1;
29380
+ var s = buffer2[offset + i];
29381
+ i += d;
29382
+ e = s & (1 << -nBits) - 1;
29383
+ s >>= -nBits;
29384
+ nBits += eLen;
29385
+ for (; nBits > 0; e = e * 256 + buffer2[offset + i], i += d, nBits -= 8) {
29386
+ }
29387
+ m = e & (1 << -nBits) - 1;
29388
+ e >>= -nBits;
29389
+ nBits += mLen;
29390
+ for (; nBits > 0; m = m * 256 + buffer2[offset + i], i += d, nBits -= 8) {
29391
+ }
29392
+ if (e === 0) {
29393
+ e = 1 - eBias;
29394
+ } else if (e === eMax) {
29395
+ return m ? NaN : (s ? -1 : 1) * Infinity;
29396
+ } else {
29397
+ m = m + Math.pow(2, mLen);
29398
+ e = e - eBias;
29399
+ }
29400
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
29401
+ };
29402
+ exports.write = function(buffer2, value, offset, isLE, mLen, nBytes) {
29403
+ var e, m, c;
29404
+ var eLen = nBytes * 8 - mLen - 1;
29405
+ var eMax = (1 << eLen) - 1;
29406
+ var eBias = eMax >> 1;
29407
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
29408
+ var i = isLE ? 0 : nBytes - 1;
29409
+ var d = isLE ? 1 : -1;
29410
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
29411
+ value = Math.abs(value);
29412
+ if (isNaN(value) || value === Infinity) {
29413
+ m = isNaN(value) ? 1 : 0;
29414
+ e = eMax;
29415
+ } else {
29416
+ e = Math.floor(Math.log(value) / Math.LN2);
29417
+ if (value * (c = Math.pow(2, -e)) < 1) {
29418
+ e--;
29419
+ c *= 2;
29420
+ }
29421
+ if (e + eBias >= 1) {
29422
+ value += rt / c;
29423
+ } else {
29424
+ value += rt * Math.pow(2, 1 - eBias);
29425
+ }
29426
+ if (value * c >= 2) {
29427
+ e++;
29428
+ c /= 2;
29429
+ }
29430
+ if (e + eBias >= eMax) {
29431
+ m = 0;
29432
+ e = eMax;
29433
+ } else if (e + eBias >= 1) {
29434
+ m = (value * c - 1) * Math.pow(2, mLen);
29435
+ e = e + eBias;
29436
+ } else {
29437
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
29438
+ e = 0;
29439
+ }
29440
+ }
29441
+ for (; mLen >= 8; buffer2[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
29442
+ }
29443
+ e = e << mLen | m;
29444
+ eLen += mLen;
29445
+ for (; eLen > 0; buffer2[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
29446
+ }
29447
+ buffer2[offset + i - d] |= s * 128;
29448
+ };
29449
+ }
29450
+ });
29451
+
29452
+ // ../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js
29453
+ var require_buffer2 = __commonJS({
29454
+ "../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js"(exports) {
29455
+ "use strict";
29456
+ var base642 = require_base64_js();
29457
+ var ieee754 = require_ieee754();
29458
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
29459
+ exports.Buffer = Buffer3;
29460
+ exports.SlowBuffer = SlowBuffer;
29461
+ exports.INSPECT_MAX_BYTES = 50;
29462
+ var K_MAX_LENGTH = 2147483647;
29463
+ exports.kMaxLength = K_MAX_LENGTH;
29464
+ Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
29465
+ if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
29466
+ 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.");
29467
+ }
29468
+ function typedArraySupport() {
29469
+ try {
29470
+ var arr = new Uint8Array(1);
29471
+ var proto = { foo: function() {
29472
+ return 42;
29473
+ } };
29474
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
29475
+ Object.setPrototypeOf(arr, proto);
29476
+ return arr.foo() === 42;
29477
+ } catch (e) {
29478
+ return false;
29479
+ }
29480
+ }
29481
+ __name(typedArraySupport, "typedArraySupport");
29482
+ Object.defineProperty(Buffer3.prototype, "parent", {
29483
+ enumerable: true,
29484
+ get: function() {
29485
+ if (!Buffer3.isBuffer(this))
29486
+ return void 0;
29487
+ return this.buffer;
29488
+ }
29489
+ });
29490
+ Object.defineProperty(Buffer3.prototype, "offset", {
29491
+ enumerable: true,
29492
+ get: function() {
29493
+ if (!Buffer3.isBuffer(this))
29494
+ return void 0;
29495
+ return this.byteOffset;
29496
+ }
29497
+ });
29498
+ function createBuffer(length2) {
29499
+ if (length2 > K_MAX_LENGTH) {
29500
+ throw new RangeError('The value "' + length2 + '" is invalid for option "size"');
29501
+ }
29502
+ var buf2 = new Uint8Array(length2);
29503
+ Object.setPrototypeOf(buf2, Buffer3.prototype);
29504
+ return buf2;
29505
+ }
29506
+ __name(createBuffer, "createBuffer");
29507
+ function Buffer3(arg, encodingOrOffset, length2) {
29508
+ if (typeof arg === "number") {
29509
+ if (typeof encodingOrOffset === "string") {
29510
+ throw new TypeError('The "string" argument must be of type string. Received type number');
29511
+ }
29512
+ return allocUnsafe(arg);
29513
+ }
29514
+ return from4(arg, encodingOrOffset, length2);
29515
+ }
29516
+ __name(Buffer3, "Buffer");
29517
+ Buffer3.poolSize = 8192;
29518
+ function from4(value, encodingOrOffset, length2) {
29519
+ if (typeof value === "string") {
29520
+ return fromString6(value, encodingOrOffset);
29521
+ }
29522
+ if (ArrayBuffer.isView(value)) {
29523
+ return fromArrayView(value);
29524
+ }
29525
+ if (value == null) {
29526
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
29527
+ }
29528
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
29529
+ return fromArrayBuffer(value, encodingOrOffset, length2);
29530
+ }
29531
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
29532
+ return fromArrayBuffer(value, encodingOrOffset, length2);
29533
+ }
29534
+ if (typeof value === "number") {
29535
+ throw new TypeError('The "value" argument must not be of type number. Received type number');
29536
+ }
29537
+ var valueOf = value.valueOf && value.valueOf();
29538
+ if (valueOf != null && valueOf !== value) {
29539
+ return Buffer3.from(valueOf, encodingOrOffset, length2);
29540
+ }
29541
+ var b = fromObject(value);
29542
+ if (b)
29543
+ return b;
29544
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
29545
+ return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length2);
29546
+ }
29547
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
29548
+ }
29549
+ __name(from4, "from");
29550
+ Buffer3.from = function(value, encodingOrOffset, length2) {
29551
+ return from4(value, encodingOrOffset, length2);
29552
+ };
29553
+ Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
29554
+ Object.setPrototypeOf(Buffer3, Uint8Array);
29555
+ function assertSize(size) {
29556
+ if (typeof size !== "number") {
29557
+ throw new TypeError('"size" argument must be of type number');
29558
+ } else if (size < 0) {
29559
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
29560
+ }
29561
+ }
29562
+ __name(assertSize, "assertSize");
29563
+ function alloc2(size, fill, encoding) {
29564
+ assertSize(size);
29565
+ if (size <= 0) {
29566
+ return createBuffer(size);
29567
+ }
29568
+ if (fill !== void 0) {
29569
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
29570
+ }
29571
+ return createBuffer(size);
29572
+ }
29573
+ __name(alloc2, "alloc");
29574
+ Buffer3.alloc = function(size, fill, encoding) {
29575
+ return alloc2(size, fill, encoding);
29576
+ };
29577
+ function allocUnsafe(size) {
29578
+ assertSize(size);
29579
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
29580
+ }
29581
+ __name(allocUnsafe, "allocUnsafe");
29582
+ Buffer3.allocUnsafe = function(size) {
29583
+ return allocUnsafe(size);
29584
+ };
29585
+ Buffer3.allocUnsafeSlow = function(size) {
29586
+ return allocUnsafe(size);
29587
+ };
29588
+ function fromString6(string2, encoding) {
29589
+ if (typeof encoding !== "string" || encoding === "") {
29590
+ encoding = "utf8";
29591
+ }
29592
+ if (!Buffer3.isEncoding(encoding)) {
29593
+ throw new TypeError("Unknown encoding: " + encoding);
29594
+ }
29595
+ var length2 = byteLength(string2, encoding) | 0;
29596
+ var buf2 = createBuffer(length2);
29597
+ var actual = buf2.write(string2, encoding);
29598
+ if (actual !== length2) {
29599
+ buf2 = buf2.slice(0, actual);
29600
+ }
29601
+ return buf2;
29602
+ }
29603
+ __name(fromString6, "fromString");
29604
+ function fromArrayLike2(array) {
29605
+ var length2 = array.length < 0 ? 0 : checked(array.length) | 0;
29606
+ var buf2 = createBuffer(length2);
29607
+ for (var i = 0; i < length2; i += 1) {
29608
+ buf2[i] = array[i] & 255;
29609
+ }
29610
+ return buf2;
29611
+ }
29612
+ __name(fromArrayLike2, "fromArrayLike");
29613
+ function fromArrayView(arrayView) {
29614
+ if (isInstance(arrayView, Uint8Array)) {
29615
+ var copy = new Uint8Array(arrayView);
29616
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
29617
+ }
29618
+ return fromArrayLike2(arrayView);
29619
+ }
29620
+ __name(fromArrayView, "fromArrayView");
29621
+ function fromArrayBuffer(array, byteOffset, length2) {
29622
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
29623
+ throw new RangeError('"offset" is outside of buffer bounds');
29624
+ }
29625
+ if (array.byteLength < byteOffset + (length2 || 0)) {
29626
+ throw new RangeError('"length" is outside of buffer bounds');
29627
+ }
29628
+ var buf2;
29629
+ if (byteOffset === void 0 && length2 === void 0) {
29630
+ buf2 = new Uint8Array(array);
29631
+ } else if (length2 === void 0) {
29632
+ buf2 = new Uint8Array(array, byteOffset);
29633
+ } else {
29634
+ buf2 = new Uint8Array(array, byteOffset, length2);
29635
+ }
29636
+ Object.setPrototypeOf(buf2, Buffer3.prototype);
29637
+ return buf2;
29638
+ }
29639
+ __name(fromArrayBuffer, "fromArrayBuffer");
29640
+ function fromObject(obj) {
29641
+ if (Buffer3.isBuffer(obj)) {
29642
+ var len = checked(obj.length) | 0;
29643
+ var buf2 = createBuffer(len);
29644
+ if (buf2.length === 0) {
29645
+ return buf2;
29646
+ }
29647
+ obj.copy(buf2, 0, 0, len);
29648
+ return buf2;
29649
+ }
29650
+ if (obj.length !== void 0) {
29651
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
29652
+ return createBuffer(0);
29653
+ }
29654
+ return fromArrayLike2(obj);
29655
+ }
29656
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
29657
+ return fromArrayLike2(obj.data);
29658
+ }
29659
+ }
29660
+ __name(fromObject, "fromObject");
29661
+ function checked(length2) {
29662
+ if (length2 >= K_MAX_LENGTH) {
29663
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
29664
+ }
29665
+ return length2 | 0;
29666
+ }
29667
+ __name(checked, "checked");
29668
+ function SlowBuffer(length2) {
29669
+ if (+length2 != length2) {
29670
+ length2 = 0;
29671
+ }
29672
+ return Buffer3.alloc(+length2);
29673
+ }
29674
+ __name(SlowBuffer, "SlowBuffer");
29675
+ Buffer3.isBuffer = /* @__PURE__ */ __name(function isBuffer3(b) {
29676
+ return b != null && b._isBuffer === true && b !== Buffer3.prototype;
29677
+ }, "isBuffer");
29678
+ Buffer3.compare = /* @__PURE__ */ __name(function compare4(a, b) {
29679
+ if (isInstance(a, Uint8Array))
29680
+ a = Buffer3.from(a, a.offset, a.byteLength);
29681
+ if (isInstance(b, Uint8Array))
29682
+ b = Buffer3.from(b, b.offset, b.byteLength);
29683
+ if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
29684
+ throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
29685
+ }
29686
+ if (a === b)
29687
+ return 0;
29688
+ var x = a.length;
29689
+ var y = b.length;
29690
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
29691
+ if (a[i] !== b[i]) {
29692
+ x = a[i];
29693
+ y = b[i];
29694
+ break;
29695
+ }
29696
+ }
29697
+ if (x < y)
29698
+ return -1;
29699
+ if (y < x)
29700
+ return 1;
29701
+ return 0;
29702
+ }, "compare");
29703
+ Buffer3.isEncoding = /* @__PURE__ */ __name(function isEncoding(encoding) {
29704
+ switch (String(encoding).toLowerCase()) {
29705
+ case "hex":
29706
+ case "utf8":
29707
+ case "utf-8":
29708
+ case "ascii":
29709
+ case "latin1":
29710
+ case "binary":
29711
+ case "base64":
29712
+ case "ucs2":
29713
+ case "ucs-2":
29714
+ case "utf16le":
29715
+ case "utf-16le":
29716
+ return true;
29717
+ default:
29718
+ return false;
29719
+ }
29720
+ }, "isEncoding");
29721
+ Buffer3.concat = /* @__PURE__ */ __name(function concat4(list, length2) {
29722
+ if (!Array.isArray(list)) {
29723
+ throw new TypeError('"list" argument must be an Array of Buffers');
29724
+ }
29725
+ if (list.length === 0) {
29726
+ return Buffer3.alloc(0);
29727
+ }
29728
+ var i;
29729
+ if (length2 === void 0) {
29730
+ length2 = 0;
29731
+ for (i = 0; i < list.length; ++i) {
29732
+ length2 += list[i].length;
29733
+ }
29734
+ }
29735
+ var buffer2 = Buffer3.allocUnsafe(length2);
29736
+ var pos = 0;
29737
+ for (i = 0; i < list.length; ++i) {
29738
+ var buf2 = list[i];
29739
+ if (isInstance(buf2, Uint8Array)) {
29740
+ if (pos + buf2.length > buffer2.length) {
29741
+ Buffer3.from(buf2).copy(buffer2, pos);
29742
+ } else {
29743
+ Uint8Array.prototype.set.call(buffer2, buf2, pos);
29744
+ }
29745
+ } else if (!Buffer3.isBuffer(buf2)) {
29746
+ throw new TypeError('"list" argument must be an Array of Buffers');
29747
+ } else {
29748
+ buf2.copy(buffer2, pos);
29749
+ }
29750
+ pos += buf2.length;
29751
+ }
29752
+ return buffer2;
29753
+ }, "concat");
29754
+ function byteLength(string2, encoding) {
29755
+ if (Buffer3.isBuffer(string2)) {
29756
+ return string2.length;
29757
+ }
29758
+ if (ArrayBuffer.isView(string2) || isInstance(string2, ArrayBuffer)) {
29759
+ return string2.byteLength;
29760
+ }
29761
+ if (typeof string2 !== "string") {
29762
+ throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string2);
29763
+ }
29764
+ var len = string2.length;
29765
+ var mustMatch = arguments.length > 2 && arguments[2] === true;
29766
+ if (!mustMatch && len === 0)
29767
+ return 0;
29768
+ var loweredCase = false;
29769
+ for (; ; ) {
29770
+ switch (encoding) {
29771
+ case "ascii":
29772
+ case "latin1":
29773
+ case "binary":
29774
+ return len;
29775
+ case "utf8":
29776
+ case "utf-8":
29777
+ return utf8ToBytes2(string2).length;
29778
+ case "ucs2":
29779
+ case "ucs-2":
29780
+ case "utf16le":
29781
+ case "utf-16le":
29782
+ return len * 2;
29783
+ case "hex":
29784
+ return len >>> 1;
29785
+ case "base64":
29786
+ return base64ToBytes2(string2).length;
29787
+ default:
29788
+ if (loweredCase) {
29789
+ return mustMatch ? -1 : utf8ToBytes2(string2).length;
29790
+ }
29791
+ encoding = ("" + encoding).toLowerCase();
29792
+ loweredCase = true;
29793
+ }
29794
+ }
29795
+ }
29796
+ __name(byteLength, "byteLength");
29797
+ Buffer3.byteLength = byteLength;
29798
+ function slowToString(encoding, start, end) {
29799
+ var loweredCase = false;
29800
+ if (start === void 0 || start < 0) {
29801
+ start = 0;
29802
+ }
29803
+ if (start > this.length) {
29804
+ return "";
29805
+ }
29806
+ if (end === void 0 || end > this.length) {
29807
+ end = this.length;
29808
+ }
29809
+ if (end <= 0) {
29810
+ return "";
29811
+ }
29812
+ end >>>= 0;
29813
+ start >>>= 0;
29814
+ if (end <= start) {
29815
+ return "";
29816
+ }
29817
+ if (!encoding)
29818
+ encoding = "utf8";
29819
+ while (true) {
29820
+ switch (encoding) {
29821
+ case "hex":
29822
+ return hexSlice(this, start, end);
29823
+ case "utf8":
29824
+ case "utf-8":
29825
+ return utf8Slice2(this, start, end);
29826
+ case "ascii":
29827
+ return asciiSlice(this, start, end);
29828
+ case "latin1":
29829
+ case "binary":
29830
+ return latin1Slice(this, start, end);
29831
+ case "base64":
29832
+ return base64Slice(this, start, end);
29833
+ case "ucs2":
29834
+ case "ucs-2":
29835
+ case "utf16le":
29836
+ case "utf-16le":
29837
+ return utf16leSlice(this, start, end);
29838
+ default:
29839
+ if (loweredCase)
29840
+ throw new TypeError("Unknown encoding: " + encoding);
29841
+ encoding = (encoding + "").toLowerCase();
29842
+ loweredCase = true;
29843
+ }
29844
+ }
29845
+ }
29846
+ __name(slowToString, "slowToString");
29847
+ Buffer3.prototype._isBuffer = true;
29848
+ function swap(b, n, m) {
29849
+ var i = b[n];
29850
+ b[n] = b[m];
29851
+ b[m] = i;
29852
+ }
29853
+ __name(swap, "swap");
29854
+ Buffer3.prototype.swap16 = /* @__PURE__ */ __name(function swap16() {
29855
+ var len = this.length;
29856
+ if (len % 2 !== 0) {
29857
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
29858
+ }
29859
+ for (var i = 0; i < len; i += 2) {
29860
+ swap(this, i, i + 1);
29861
+ }
29862
+ return this;
29863
+ }, "swap16");
29864
+ Buffer3.prototype.swap32 = /* @__PURE__ */ __name(function swap32() {
29865
+ var len = this.length;
29866
+ if (len % 4 !== 0) {
29867
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
29868
+ }
29869
+ for (var i = 0; i < len; i += 4) {
29870
+ swap(this, i, i + 3);
29871
+ swap(this, i + 1, i + 2);
29872
+ }
29873
+ return this;
29874
+ }, "swap32");
29875
+ Buffer3.prototype.swap64 = /* @__PURE__ */ __name(function swap64() {
29876
+ var len = this.length;
29877
+ if (len % 8 !== 0) {
29878
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
29879
+ }
29880
+ for (var i = 0; i < len; i += 8) {
29881
+ swap(this, i, i + 7);
29882
+ swap(this, i + 1, i + 6);
29883
+ swap(this, i + 2, i + 5);
29884
+ swap(this, i + 3, i + 4);
29885
+ }
29886
+ return this;
29887
+ }, "swap64");
29888
+ Buffer3.prototype.toString = /* @__PURE__ */ __name(function toString6() {
29889
+ var length2 = this.length;
29890
+ if (length2 === 0)
29891
+ return "";
29892
+ if (arguments.length === 0)
29893
+ return utf8Slice2(this, 0, length2);
29894
+ return slowToString.apply(this, arguments);
29895
+ }, "toString");
29896
+ Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
29897
+ Buffer3.prototype.equals = /* @__PURE__ */ __name(function equals4(b) {
29898
+ if (!Buffer3.isBuffer(b))
29899
+ throw new TypeError("Argument must be a Buffer");
29900
+ if (this === b)
29901
+ return true;
29902
+ return Buffer3.compare(this, b) === 0;
29903
+ }, "equals");
29904
+ Buffer3.prototype.inspect = /* @__PURE__ */ __name(function inspect5() {
29905
+ var str = "";
29906
+ var max = exports.INSPECT_MAX_BYTES;
29907
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
29908
+ if (this.length > max)
29909
+ str += " ... ";
29910
+ return "<Buffer " + str + ">";
29911
+ }, "inspect");
29912
+ if (customInspectSymbol) {
29913
+ Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
29914
+ }
29915
+ Buffer3.prototype.compare = /* @__PURE__ */ __name(function compare4(target, start, end, thisStart, thisEnd) {
29916
+ if (isInstance(target, Uint8Array)) {
29917
+ target = Buffer3.from(target, target.offset, target.byteLength);
29918
+ }
29919
+ if (!Buffer3.isBuffer(target)) {
29920
+ throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target);
29921
+ }
29922
+ if (start === void 0) {
29923
+ start = 0;
29924
+ }
29925
+ if (end === void 0) {
29926
+ end = target ? target.length : 0;
29927
+ }
29928
+ if (thisStart === void 0) {
29929
+ thisStart = 0;
29930
+ }
29931
+ if (thisEnd === void 0) {
29932
+ thisEnd = this.length;
29933
+ }
29934
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
29935
+ throw new RangeError("out of range index");
29936
+ }
29937
+ if (thisStart >= thisEnd && start >= end) {
29938
+ return 0;
29939
+ }
29940
+ if (thisStart >= thisEnd) {
29941
+ return -1;
29942
+ }
29943
+ if (start >= end) {
29944
+ return 1;
29945
+ }
29946
+ start >>>= 0;
29947
+ end >>>= 0;
29948
+ thisStart >>>= 0;
29949
+ thisEnd >>>= 0;
29950
+ if (this === target)
29951
+ return 0;
29952
+ var x = thisEnd - thisStart;
29953
+ var y = end - start;
29954
+ var len = Math.min(x, y);
29955
+ var thisCopy = this.slice(thisStart, thisEnd);
29956
+ var targetCopy = target.slice(start, end);
29957
+ for (var i = 0; i < len; ++i) {
29958
+ if (thisCopy[i] !== targetCopy[i]) {
29959
+ x = thisCopy[i];
29960
+ y = targetCopy[i];
29961
+ break;
29962
+ }
29963
+ }
29964
+ if (x < y)
29965
+ return -1;
29966
+ if (y < x)
29967
+ return 1;
29968
+ return 0;
29969
+ }, "compare");
29970
+ function bidirectionalIndexOf(buffer2, val, byteOffset, encoding, dir) {
29971
+ if (buffer2.length === 0)
29972
+ return -1;
29973
+ if (typeof byteOffset === "string") {
29974
+ encoding = byteOffset;
29975
+ byteOffset = 0;
29976
+ } else if (byteOffset > 2147483647) {
29977
+ byteOffset = 2147483647;
29978
+ } else if (byteOffset < -2147483648) {
29979
+ byteOffset = -2147483648;
29980
+ }
29981
+ byteOffset = +byteOffset;
29982
+ if (numberIsNaN(byteOffset)) {
29983
+ byteOffset = dir ? 0 : buffer2.length - 1;
29984
+ }
29985
+ if (byteOffset < 0)
29986
+ byteOffset = buffer2.length + byteOffset;
29987
+ if (byteOffset >= buffer2.length) {
29988
+ if (dir)
29989
+ return -1;
29990
+ else
29991
+ byteOffset = buffer2.length - 1;
29992
+ } else if (byteOffset < 0) {
29993
+ if (dir)
29994
+ byteOffset = 0;
29995
+ else
29996
+ return -1;
29997
+ }
29998
+ if (typeof val === "string") {
29999
+ val = Buffer3.from(val, encoding);
30000
+ }
30001
+ if (Buffer3.isBuffer(val)) {
30002
+ if (val.length === 0) {
30003
+ return -1;
30004
+ }
30005
+ return arrayIndexOf(buffer2, val, byteOffset, encoding, dir);
30006
+ } else if (typeof val === "number") {
30007
+ val = val & 255;
30008
+ if (typeof Uint8Array.prototype.indexOf === "function") {
30009
+ if (dir) {
30010
+ return Uint8Array.prototype.indexOf.call(buffer2, val, byteOffset);
30011
+ } else {
30012
+ return Uint8Array.prototype.lastIndexOf.call(buffer2, val, byteOffset);
30013
+ }
30014
+ }
30015
+ return arrayIndexOf(buffer2, [val], byteOffset, encoding, dir);
30016
+ }
30017
+ throw new TypeError("val must be string, number or Buffer");
30018
+ }
30019
+ __name(bidirectionalIndexOf, "bidirectionalIndexOf");
30020
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
30021
+ var indexSize = 1;
30022
+ var arrLength = arr.length;
30023
+ var valLength = val.length;
30024
+ if (encoding !== void 0) {
30025
+ encoding = String(encoding).toLowerCase();
30026
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
30027
+ if (arr.length < 2 || val.length < 2) {
30028
+ return -1;
30029
+ }
30030
+ indexSize = 2;
30031
+ arrLength /= 2;
30032
+ valLength /= 2;
30033
+ byteOffset /= 2;
30034
+ }
30035
+ }
30036
+ function read2(buf2, i2) {
30037
+ if (indexSize === 1) {
30038
+ return buf2[i2];
30039
+ } else {
30040
+ return buf2.readUInt16BE(i2 * indexSize);
30041
+ }
30042
+ }
30043
+ __name(read2, "read");
30044
+ var i;
30045
+ if (dir) {
30046
+ var foundIndex = -1;
30047
+ for (i = byteOffset; i < arrLength; i++) {
30048
+ if (read2(arr, i) === read2(val, foundIndex === -1 ? 0 : i - foundIndex)) {
30049
+ if (foundIndex === -1)
30050
+ foundIndex = i;
30051
+ if (i - foundIndex + 1 === valLength)
30052
+ return foundIndex * indexSize;
30053
+ } else {
30054
+ if (foundIndex !== -1)
30055
+ i -= i - foundIndex;
30056
+ foundIndex = -1;
30057
+ }
30058
+ }
30059
+ } else {
30060
+ if (byteOffset + valLength > arrLength)
30061
+ byteOffset = arrLength - valLength;
30062
+ for (i = byteOffset; i >= 0; i--) {
30063
+ var found = true;
30064
+ for (var j = 0; j < valLength; j++) {
30065
+ if (read2(arr, i + j) !== read2(val, j)) {
30066
+ found = false;
30067
+ break;
30068
+ }
30069
+ }
30070
+ if (found)
30071
+ return i;
30072
+ }
30073
+ }
30074
+ return -1;
30075
+ }
30076
+ __name(arrayIndexOf, "arrayIndexOf");
30077
+ Buffer3.prototype.includes = /* @__PURE__ */ __name(function includes(val, byteOffset, encoding) {
30078
+ return this.indexOf(val, byteOffset, encoding) !== -1;
30079
+ }, "includes");
30080
+ Buffer3.prototype.indexOf = /* @__PURE__ */ __name(function indexOf(val, byteOffset, encoding) {
30081
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
30082
+ }, "indexOf");
30083
+ Buffer3.prototype.lastIndexOf = /* @__PURE__ */ __name(function lastIndexOf(val, byteOffset, encoding) {
30084
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
30085
+ }, "lastIndexOf");
30086
+ function hexWrite(buf2, string2, offset, length2) {
30087
+ offset = Number(offset) || 0;
30088
+ var remaining = buf2.length - offset;
30089
+ if (!length2) {
30090
+ length2 = remaining;
30091
+ } else {
30092
+ length2 = Number(length2);
30093
+ if (length2 > remaining) {
30094
+ length2 = remaining;
30095
+ }
30096
+ }
30097
+ var strLen = string2.length;
30098
+ if (length2 > strLen / 2) {
30099
+ length2 = strLen / 2;
30100
+ }
30101
+ for (var i = 0; i < length2; ++i) {
30102
+ var parsed = parseInt(string2.substr(i * 2, 2), 16);
30103
+ if (numberIsNaN(parsed))
30104
+ return i;
30105
+ buf2[offset + i] = parsed;
30106
+ }
30107
+ return i;
30108
+ }
30109
+ __name(hexWrite, "hexWrite");
30110
+ function utf8Write(buf2, string2, offset, length2) {
30111
+ return blitBuffer(utf8ToBytes2(string2, buf2.length - offset), buf2, offset, length2);
30112
+ }
30113
+ __name(utf8Write, "utf8Write");
30114
+ function asciiWrite(buf2, string2, offset, length2) {
30115
+ return blitBuffer(asciiToBytes(string2), buf2, offset, length2);
30116
+ }
30117
+ __name(asciiWrite, "asciiWrite");
30118
+ function base64Write(buf2, string2, offset, length2) {
30119
+ return blitBuffer(base64ToBytes2(string2), buf2, offset, length2);
30120
+ }
30121
+ __name(base64Write, "base64Write");
30122
+ function ucs2Write(buf2, string2, offset, length2) {
30123
+ return blitBuffer(utf16leToBytes(string2, buf2.length - offset), buf2, offset, length2);
30124
+ }
30125
+ __name(ucs2Write, "ucs2Write");
30126
+ Buffer3.prototype.write = /* @__PURE__ */ __name(function write(string2, offset, length2, encoding) {
30127
+ if (offset === void 0) {
30128
+ encoding = "utf8";
30129
+ length2 = this.length;
30130
+ offset = 0;
30131
+ } else if (length2 === void 0 && typeof offset === "string") {
30132
+ encoding = offset;
30133
+ length2 = this.length;
30134
+ offset = 0;
30135
+ } else if (isFinite(offset)) {
30136
+ offset = offset >>> 0;
30137
+ if (isFinite(length2)) {
30138
+ length2 = length2 >>> 0;
30139
+ if (encoding === void 0)
30140
+ encoding = "utf8";
30141
+ } else {
30142
+ encoding = length2;
30143
+ length2 = void 0;
30144
+ }
30145
+ } else {
30146
+ throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
30147
+ }
30148
+ var remaining = this.length - offset;
30149
+ if (length2 === void 0 || length2 > remaining)
30150
+ length2 = remaining;
30151
+ if (string2.length > 0 && (length2 < 0 || offset < 0) || offset > this.length) {
30152
+ throw new RangeError("Attempt to write outside buffer bounds");
30153
+ }
30154
+ if (!encoding)
30155
+ encoding = "utf8";
30156
+ var loweredCase = false;
30157
+ for (; ; ) {
30158
+ switch (encoding) {
30159
+ case "hex":
30160
+ return hexWrite(this, string2, offset, length2);
30161
+ case "utf8":
30162
+ case "utf-8":
30163
+ return utf8Write(this, string2, offset, length2);
30164
+ case "ascii":
30165
+ case "latin1":
30166
+ case "binary":
30167
+ return asciiWrite(this, string2, offset, length2);
30168
+ case "base64":
30169
+ return base64Write(this, string2, offset, length2);
30170
+ case "ucs2":
30171
+ case "ucs-2":
30172
+ case "utf16le":
30173
+ case "utf-16le":
30174
+ return ucs2Write(this, string2, offset, length2);
30175
+ default:
30176
+ if (loweredCase)
30177
+ throw new TypeError("Unknown encoding: " + encoding);
30178
+ encoding = ("" + encoding).toLowerCase();
30179
+ loweredCase = true;
30180
+ }
30181
+ }
30182
+ }, "write");
30183
+ Buffer3.prototype.toJSON = /* @__PURE__ */ __name(function toJSON2() {
30184
+ return {
30185
+ type: "Buffer",
30186
+ data: Array.prototype.slice.call(this._arr || this, 0)
30187
+ };
30188
+ }, "toJSON");
30189
+ function base64Slice(buf2, start, end) {
30190
+ if (start === 0 && end === buf2.length) {
30191
+ return base642.fromByteArray(buf2);
30192
+ } else {
30193
+ return base642.fromByteArray(buf2.slice(start, end));
30194
+ }
30195
+ }
30196
+ __name(base64Slice, "base64Slice");
30197
+ function utf8Slice2(buf2, start, end) {
30198
+ end = Math.min(buf2.length, end);
30199
+ var res = [];
30200
+ var i = start;
30201
+ while (i < end) {
30202
+ var firstByte = buf2[i];
30203
+ var codePoint = null;
30204
+ var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
30205
+ if (i + bytesPerSequence <= end) {
30206
+ var secondByte, thirdByte, fourthByte, tempCodePoint;
30207
+ switch (bytesPerSequence) {
30208
+ case 1:
30209
+ if (firstByte < 128) {
30210
+ codePoint = firstByte;
30211
+ }
30212
+ break;
30213
+ case 2:
30214
+ secondByte = buf2[i + 1];
30215
+ if ((secondByte & 192) === 128) {
30216
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
30217
+ if (tempCodePoint > 127) {
30218
+ codePoint = tempCodePoint;
30219
+ }
30220
+ }
30221
+ break;
30222
+ case 3:
30223
+ secondByte = buf2[i + 1];
30224
+ thirdByte = buf2[i + 2];
30225
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
30226
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
30227
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
30228
+ codePoint = tempCodePoint;
30229
+ }
30230
+ }
30231
+ break;
30232
+ case 4:
30233
+ secondByte = buf2[i + 1];
30234
+ thirdByte = buf2[i + 2];
30235
+ fourthByte = buf2[i + 3];
30236
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
30237
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
30238
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
30239
+ codePoint = tempCodePoint;
30240
+ }
30241
+ }
30242
+ }
30243
+ }
30244
+ if (codePoint === null) {
30245
+ codePoint = 65533;
30246
+ bytesPerSequence = 1;
30247
+ } else if (codePoint > 65535) {
30248
+ codePoint -= 65536;
30249
+ res.push(codePoint >>> 10 & 1023 | 55296);
30250
+ codePoint = 56320 | codePoint & 1023;
30251
+ }
30252
+ res.push(codePoint);
30253
+ i += bytesPerSequence;
30254
+ }
30255
+ return decodeCodePointsArray2(res);
30256
+ }
30257
+ __name(utf8Slice2, "utf8Slice");
30258
+ var MAX_ARGUMENTS_LENGTH2 = 4096;
30259
+ function decodeCodePointsArray2(codePoints) {
30260
+ var len = codePoints.length;
30261
+ if (len <= MAX_ARGUMENTS_LENGTH2) {
30262
+ return String.fromCharCode.apply(String, codePoints);
30263
+ }
30264
+ var res = "";
30265
+ var i = 0;
30266
+ while (i < len) {
30267
+ res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH2));
30268
+ }
30269
+ return res;
30270
+ }
30271
+ __name(decodeCodePointsArray2, "decodeCodePointsArray");
30272
+ function asciiSlice(buf2, start, end) {
30273
+ var ret = "";
30274
+ end = Math.min(buf2.length, end);
30275
+ for (var i = start; i < end; ++i) {
30276
+ ret += String.fromCharCode(buf2[i] & 127);
30277
+ }
30278
+ return ret;
30279
+ }
30280
+ __name(asciiSlice, "asciiSlice");
30281
+ function latin1Slice(buf2, start, end) {
30282
+ var ret = "";
30283
+ end = Math.min(buf2.length, end);
30284
+ for (var i = start; i < end; ++i) {
30285
+ ret += String.fromCharCode(buf2[i]);
30286
+ }
30287
+ return ret;
30288
+ }
30289
+ __name(latin1Slice, "latin1Slice");
30290
+ function hexSlice(buf2, start, end) {
30291
+ var len = buf2.length;
30292
+ if (!start || start < 0)
30293
+ start = 0;
30294
+ if (!end || end < 0 || end > len)
30295
+ end = len;
30296
+ var out = "";
30297
+ for (var i = start; i < end; ++i) {
30298
+ out += hexSliceLookupTable[buf2[i]];
30299
+ }
30300
+ return out;
30301
+ }
30302
+ __name(hexSlice, "hexSlice");
30303
+ function utf16leSlice(buf2, start, end) {
30304
+ var bytes = buf2.slice(start, end);
30305
+ var res = "";
30306
+ for (var i = 0; i < bytes.length - 1; i += 2) {
30307
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
30308
+ }
30309
+ return res;
30310
+ }
30311
+ __name(utf16leSlice, "utf16leSlice");
30312
+ Buffer3.prototype.slice = /* @__PURE__ */ __name(function slice2(start, end) {
30313
+ var len = this.length;
30314
+ start = ~~start;
30315
+ end = end === void 0 ? len : ~~end;
30316
+ if (start < 0) {
30317
+ start += len;
30318
+ if (start < 0)
30319
+ start = 0;
30320
+ } else if (start > len) {
30321
+ start = len;
30322
+ }
30323
+ if (end < 0) {
30324
+ end += len;
30325
+ if (end < 0)
30326
+ end = 0;
30327
+ } else if (end > len) {
30328
+ end = len;
30329
+ }
30330
+ if (end < start)
30331
+ end = start;
30332
+ var newBuf = this.subarray(start, end);
30333
+ Object.setPrototypeOf(newBuf, Buffer3.prototype);
30334
+ return newBuf;
30335
+ }, "slice");
30336
+ function checkOffset(offset, ext, length2) {
30337
+ if (offset % 1 !== 0 || offset < 0)
30338
+ throw new RangeError("offset is not uint");
30339
+ if (offset + ext > length2)
30340
+ throw new RangeError("Trying to access beyond buffer length");
30341
+ }
30342
+ __name(checkOffset, "checkOffset");
30343
+ Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = /* @__PURE__ */ __name(function readUIntLE(offset, byteLength2, noAssert) {
30344
+ offset = offset >>> 0;
30345
+ byteLength2 = byteLength2 >>> 0;
30346
+ if (!noAssert)
30347
+ checkOffset(offset, byteLength2, this.length);
30348
+ var val = this[offset];
30349
+ var mul3 = 1;
30350
+ var i = 0;
30351
+ while (++i < byteLength2 && (mul3 *= 256)) {
30352
+ val += this[offset + i] * mul3;
30353
+ }
30354
+ return val;
30355
+ }, "readUIntLE");
30356
+ Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = /* @__PURE__ */ __name(function readUIntBE(offset, byteLength2, noAssert) {
30357
+ offset = offset >>> 0;
30358
+ byteLength2 = byteLength2 >>> 0;
30359
+ if (!noAssert) {
30360
+ checkOffset(offset, byteLength2, this.length);
30361
+ }
30362
+ var val = this[offset + --byteLength2];
30363
+ var mul3 = 1;
30364
+ while (byteLength2 > 0 && (mul3 *= 256)) {
30365
+ val += this[offset + --byteLength2] * mul3;
30366
+ }
30367
+ return val;
30368
+ }, "readUIntBE");
30369
+ Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = /* @__PURE__ */ __name(function readUInt8(offset, noAssert) {
30370
+ offset = offset >>> 0;
30371
+ if (!noAssert)
30372
+ checkOffset(offset, 1, this.length);
30373
+ return this[offset];
30374
+ }, "readUInt8");
30375
+ Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = /* @__PURE__ */ __name(function readUInt16LE(offset, noAssert) {
30376
+ offset = offset >>> 0;
30377
+ if (!noAssert)
30378
+ checkOffset(offset, 2, this.length);
30379
+ return this[offset] | this[offset + 1] << 8;
30380
+ }, "readUInt16LE");
30381
+ Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = /* @__PURE__ */ __name(function readUInt16BE(offset, noAssert) {
30382
+ offset = offset >>> 0;
30383
+ if (!noAssert)
30384
+ checkOffset(offset, 2, this.length);
30385
+ return this[offset] << 8 | this[offset + 1];
30386
+ }, "readUInt16BE");
30387
+ Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = /* @__PURE__ */ __name(function readUInt32LE(offset, noAssert) {
30388
+ offset = offset >>> 0;
30389
+ if (!noAssert)
30390
+ checkOffset(offset, 4, this.length);
30391
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
30392
+ }, "readUInt32LE");
30393
+ Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = /* @__PURE__ */ __name(function readUInt32BE(offset, noAssert) {
30394
+ offset = offset >>> 0;
30395
+ if (!noAssert)
30396
+ checkOffset(offset, 4, this.length);
30397
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
30398
+ }, "readUInt32BE");
30399
+ Buffer3.prototype.readIntLE = /* @__PURE__ */ __name(function readIntLE(offset, byteLength2, noAssert) {
30400
+ offset = offset >>> 0;
30401
+ byteLength2 = byteLength2 >>> 0;
30402
+ if (!noAssert)
30403
+ checkOffset(offset, byteLength2, this.length);
30404
+ var val = this[offset];
30405
+ var mul3 = 1;
30406
+ var i = 0;
30407
+ while (++i < byteLength2 && (mul3 *= 256)) {
30408
+ val += this[offset + i] * mul3;
30409
+ }
30410
+ mul3 *= 128;
30411
+ if (val >= mul3)
30412
+ val -= Math.pow(2, 8 * byteLength2);
30413
+ return val;
30414
+ }, "readIntLE");
30415
+ Buffer3.prototype.readIntBE = /* @__PURE__ */ __name(function readIntBE(offset, byteLength2, noAssert) {
30416
+ offset = offset >>> 0;
30417
+ byteLength2 = byteLength2 >>> 0;
30418
+ if (!noAssert)
30419
+ checkOffset(offset, byteLength2, this.length);
30420
+ var i = byteLength2;
30421
+ var mul3 = 1;
30422
+ var val = this[offset + --i];
30423
+ while (i > 0 && (mul3 *= 256)) {
30424
+ val += this[offset + --i] * mul3;
30425
+ }
30426
+ mul3 *= 128;
30427
+ if (val >= mul3)
30428
+ val -= Math.pow(2, 8 * byteLength2);
30429
+ return val;
30430
+ }, "readIntBE");
30431
+ Buffer3.prototype.readInt8 = /* @__PURE__ */ __name(function readInt8(offset, noAssert) {
30432
+ offset = offset >>> 0;
30433
+ if (!noAssert)
30434
+ checkOffset(offset, 1, this.length);
30435
+ if (!(this[offset] & 128))
30436
+ return this[offset];
30437
+ return (255 - this[offset] + 1) * -1;
30438
+ }, "readInt8");
30439
+ Buffer3.prototype.readInt16LE = /* @__PURE__ */ __name(function readInt16LE(offset, noAssert) {
30440
+ offset = offset >>> 0;
30441
+ if (!noAssert)
30442
+ checkOffset(offset, 2, this.length);
30443
+ var val = this[offset] | this[offset + 1] << 8;
30444
+ return val & 32768 ? val | 4294901760 : val;
30445
+ }, "readInt16LE");
30446
+ Buffer3.prototype.readInt16BE = /* @__PURE__ */ __name(function readInt16BE(offset, noAssert) {
30447
+ offset = offset >>> 0;
30448
+ if (!noAssert)
30449
+ checkOffset(offset, 2, this.length);
30450
+ var val = this[offset + 1] | this[offset] << 8;
30451
+ return val & 32768 ? val | 4294901760 : val;
30452
+ }, "readInt16BE");
30453
+ Buffer3.prototype.readInt32LE = /* @__PURE__ */ __name(function readInt32LE(offset, noAssert) {
30454
+ offset = offset >>> 0;
30455
+ if (!noAssert)
30456
+ checkOffset(offset, 4, this.length);
30457
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
30458
+ }, "readInt32LE");
30459
+ Buffer3.prototype.readInt32BE = /* @__PURE__ */ __name(function readInt32BE(offset, noAssert) {
30460
+ offset = offset >>> 0;
30461
+ if (!noAssert)
30462
+ checkOffset(offset, 4, this.length);
30463
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
30464
+ }, "readInt32BE");
30465
+ Buffer3.prototype.readFloatLE = /* @__PURE__ */ __name(function readFloatLE(offset, noAssert) {
30466
+ offset = offset >>> 0;
30467
+ if (!noAssert)
30468
+ checkOffset(offset, 4, this.length);
30469
+ return ieee754.read(this, offset, true, 23, 4);
30470
+ }, "readFloatLE");
30471
+ Buffer3.prototype.readFloatBE = /* @__PURE__ */ __name(function readFloatBE(offset, noAssert) {
30472
+ offset = offset >>> 0;
30473
+ if (!noAssert)
30474
+ checkOffset(offset, 4, this.length);
30475
+ return ieee754.read(this, offset, false, 23, 4);
30476
+ }, "readFloatBE");
30477
+ Buffer3.prototype.readDoubleLE = /* @__PURE__ */ __name(function readDoubleLE(offset, noAssert) {
30478
+ offset = offset >>> 0;
30479
+ if (!noAssert)
30480
+ checkOffset(offset, 8, this.length);
30481
+ return ieee754.read(this, offset, true, 52, 8);
30482
+ }, "readDoubleLE");
30483
+ Buffer3.prototype.readDoubleBE = /* @__PURE__ */ __name(function readDoubleBE(offset, noAssert) {
30484
+ offset = offset >>> 0;
30485
+ if (!noAssert)
30486
+ checkOffset(offset, 8, this.length);
30487
+ return ieee754.read(this, offset, false, 52, 8);
30488
+ }, "readDoubleBE");
30489
+ function checkInt(buf2, value, offset, ext, max, min) {
30490
+ if (!Buffer3.isBuffer(buf2))
30491
+ throw new TypeError('"buffer" argument must be a Buffer instance');
30492
+ if (value > max || value < min)
30493
+ throw new RangeError('"value" argument is out of bounds');
30494
+ if (offset + ext > buf2.length)
30495
+ throw new RangeError("Index out of range");
30496
+ }
30497
+ __name(checkInt, "checkInt");
30498
+ Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = /* @__PURE__ */ __name(function writeUIntLE(value, offset, byteLength2, noAssert) {
30499
+ value = +value;
30500
+ offset = offset >>> 0;
30501
+ byteLength2 = byteLength2 >>> 0;
30502
+ if (!noAssert) {
30503
+ var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
30504
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
30505
+ }
30506
+ var mul3 = 1;
30507
+ var i = 0;
30508
+ this[offset] = value & 255;
30509
+ while (++i < byteLength2 && (mul3 *= 256)) {
30510
+ this[offset + i] = value / mul3 & 255;
30511
+ }
30512
+ return offset + byteLength2;
30513
+ }, "writeUIntLE");
30514
+ Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = /* @__PURE__ */ __name(function writeUIntBE(value, offset, byteLength2, noAssert) {
30515
+ value = +value;
30516
+ offset = offset >>> 0;
30517
+ byteLength2 = byteLength2 >>> 0;
30518
+ if (!noAssert) {
30519
+ var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
30520
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
30521
+ }
30522
+ var i = byteLength2 - 1;
30523
+ var mul3 = 1;
30524
+ this[offset + i] = value & 255;
30525
+ while (--i >= 0 && (mul3 *= 256)) {
30526
+ this[offset + i] = value / mul3 & 255;
30527
+ }
30528
+ return offset + byteLength2;
30529
+ }, "writeUIntBE");
30530
+ Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = /* @__PURE__ */ __name(function writeUInt8(value, offset, noAssert) {
30531
+ value = +value;
30532
+ offset = offset >>> 0;
30533
+ if (!noAssert)
30534
+ checkInt(this, value, offset, 1, 255, 0);
30535
+ this[offset] = value & 255;
30536
+ return offset + 1;
30537
+ }, "writeUInt8");
30538
+ Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = /* @__PURE__ */ __name(function writeUInt16LE(value, offset, noAssert) {
30539
+ value = +value;
30540
+ offset = offset >>> 0;
30541
+ if (!noAssert)
30542
+ checkInt(this, value, offset, 2, 65535, 0);
30543
+ this[offset] = value & 255;
30544
+ this[offset + 1] = value >>> 8;
30545
+ return offset + 2;
30546
+ }, "writeUInt16LE");
30547
+ Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = /* @__PURE__ */ __name(function writeUInt16BE(value, offset, noAssert) {
30548
+ value = +value;
30549
+ offset = offset >>> 0;
30550
+ if (!noAssert)
30551
+ checkInt(this, value, offset, 2, 65535, 0);
30552
+ this[offset] = value >>> 8;
30553
+ this[offset + 1] = value & 255;
30554
+ return offset + 2;
30555
+ }, "writeUInt16BE");
30556
+ Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = /* @__PURE__ */ __name(function writeUInt32LE(value, offset, noAssert) {
30557
+ value = +value;
30558
+ offset = offset >>> 0;
30559
+ if (!noAssert)
30560
+ checkInt(this, value, offset, 4, 4294967295, 0);
30561
+ this[offset + 3] = value >>> 24;
30562
+ this[offset + 2] = value >>> 16;
30563
+ this[offset + 1] = value >>> 8;
30564
+ this[offset] = value & 255;
30565
+ return offset + 4;
30566
+ }, "writeUInt32LE");
30567
+ Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = /* @__PURE__ */ __name(function writeUInt32BE(value, offset, noAssert) {
30568
+ value = +value;
30569
+ offset = offset >>> 0;
30570
+ if (!noAssert)
30571
+ checkInt(this, value, offset, 4, 4294967295, 0);
30572
+ this[offset] = value >>> 24;
30573
+ this[offset + 1] = value >>> 16;
30574
+ this[offset + 2] = value >>> 8;
30575
+ this[offset + 3] = value & 255;
30576
+ return offset + 4;
30577
+ }, "writeUInt32BE");
30578
+ Buffer3.prototype.writeIntLE = /* @__PURE__ */ __name(function writeIntLE(value, offset, byteLength2, noAssert) {
30579
+ value = +value;
30580
+ offset = offset >>> 0;
30581
+ if (!noAssert) {
30582
+ var limit = Math.pow(2, 8 * byteLength2 - 1);
30583
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
30584
+ }
30585
+ var i = 0;
30586
+ var mul3 = 1;
30587
+ var sub = 0;
30588
+ this[offset] = value & 255;
30589
+ while (++i < byteLength2 && (mul3 *= 256)) {
30590
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
30591
+ sub = 1;
30592
+ }
30593
+ this[offset + i] = (value / mul3 >> 0) - sub & 255;
30594
+ }
30595
+ return offset + byteLength2;
30596
+ }, "writeIntLE");
30597
+ Buffer3.prototype.writeIntBE = /* @__PURE__ */ __name(function writeIntBE(value, offset, byteLength2, noAssert) {
30598
+ value = +value;
30599
+ offset = offset >>> 0;
30600
+ if (!noAssert) {
30601
+ var limit = Math.pow(2, 8 * byteLength2 - 1);
30602
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
30603
+ }
30604
+ var i = byteLength2 - 1;
30605
+ var mul3 = 1;
30606
+ var sub = 0;
30607
+ this[offset + i] = value & 255;
30608
+ while (--i >= 0 && (mul3 *= 256)) {
30609
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
30610
+ sub = 1;
30611
+ }
30612
+ this[offset + i] = (value / mul3 >> 0) - sub & 255;
30613
+ }
30614
+ return offset + byteLength2;
30615
+ }, "writeIntBE");
30616
+ Buffer3.prototype.writeInt8 = /* @__PURE__ */ __name(function writeInt8(value, offset, noAssert) {
30617
+ value = +value;
30618
+ offset = offset >>> 0;
30619
+ if (!noAssert)
30620
+ checkInt(this, value, offset, 1, 127, -128);
30621
+ if (value < 0)
30622
+ value = 255 + value + 1;
30623
+ this[offset] = value & 255;
30624
+ return offset + 1;
30625
+ }, "writeInt8");
30626
+ Buffer3.prototype.writeInt16LE = /* @__PURE__ */ __name(function writeInt16LE(value, offset, noAssert) {
30627
+ value = +value;
30628
+ offset = offset >>> 0;
30629
+ if (!noAssert)
30630
+ checkInt(this, value, offset, 2, 32767, -32768);
30631
+ this[offset] = value & 255;
30632
+ this[offset + 1] = value >>> 8;
30633
+ return offset + 2;
30634
+ }, "writeInt16LE");
30635
+ Buffer3.prototype.writeInt16BE = /* @__PURE__ */ __name(function writeInt16BE(value, offset, noAssert) {
30636
+ value = +value;
30637
+ offset = offset >>> 0;
30638
+ if (!noAssert)
30639
+ checkInt(this, value, offset, 2, 32767, -32768);
30640
+ this[offset] = value >>> 8;
30641
+ this[offset + 1] = value & 255;
30642
+ return offset + 2;
30643
+ }, "writeInt16BE");
30644
+ Buffer3.prototype.writeInt32LE = /* @__PURE__ */ __name(function writeInt32LE(value, offset, noAssert) {
30645
+ value = +value;
30646
+ offset = offset >>> 0;
30647
+ if (!noAssert)
30648
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
30649
+ this[offset] = value & 255;
30650
+ this[offset + 1] = value >>> 8;
30651
+ this[offset + 2] = value >>> 16;
30652
+ this[offset + 3] = value >>> 24;
30653
+ return offset + 4;
30654
+ }, "writeInt32LE");
30655
+ Buffer3.prototype.writeInt32BE = /* @__PURE__ */ __name(function writeInt32BE(value, offset, noAssert) {
30656
+ value = +value;
30657
+ offset = offset >>> 0;
30658
+ if (!noAssert)
30659
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
30660
+ if (value < 0)
30661
+ value = 4294967295 + value + 1;
30662
+ this[offset] = value >>> 24;
30663
+ this[offset + 1] = value >>> 16;
30664
+ this[offset + 2] = value >>> 8;
30665
+ this[offset + 3] = value & 255;
30666
+ return offset + 4;
30667
+ }, "writeInt32BE");
30668
+ function checkIEEE754(buf2, value, offset, ext, max, min) {
30669
+ if (offset + ext > buf2.length)
30670
+ throw new RangeError("Index out of range");
30671
+ if (offset < 0)
30672
+ throw new RangeError("Index out of range");
30673
+ }
30674
+ __name(checkIEEE754, "checkIEEE754");
30675
+ function writeFloat(buf2, value, offset, littleEndian, noAssert) {
30676
+ value = +value;
30677
+ offset = offset >>> 0;
30678
+ if (!noAssert) {
30679
+ checkIEEE754(buf2, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
30680
+ }
30681
+ ieee754.write(buf2, value, offset, littleEndian, 23, 4);
30682
+ return offset + 4;
30683
+ }
30684
+ __name(writeFloat, "writeFloat");
30685
+ Buffer3.prototype.writeFloatLE = /* @__PURE__ */ __name(function writeFloatLE(value, offset, noAssert) {
30686
+ return writeFloat(this, value, offset, true, noAssert);
30687
+ }, "writeFloatLE");
30688
+ Buffer3.prototype.writeFloatBE = /* @__PURE__ */ __name(function writeFloatBE(value, offset, noAssert) {
30689
+ return writeFloat(this, value, offset, false, noAssert);
30690
+ }, "writeFloatBE");
30691
+ function writeDouble(buf2, value, offset, littleEndian, noAssert) {
30692
+ value = +value;
30693
+ offset = offset >>> 0;
30694
+ if (!noAssert) {
30695
+ checkIEEE754(buf2, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
30696
+ }
30697
+ ieee754.write(buf2, value, offset, littleEndian, 52, 8);
30698
+ return offset + 8;
30699
+ }
30700
+ __name(writeDouble, "writeDouble");
30701
+ Buffer3.prototype.writeDoubleLE = /* @__PURE__ */ __name(function writeDoubleLE(value, offset, noAssert) {
30702
+ return writeDouble(this, value, offset, true, noAssert);
30703
+ }, "writeDoubleLE");
30704
+ Buffer3.prototype.writeDoubleBE = /* @__PURE__ */ __name(function writeDoubleBE(value, offset, noAssert) {
30705
+ return writeDouble(this, value, offset, false, noAssert);
30706
+ }, "writeDoubleBE");
30707
+ Buffer3.prototype.copy = /* @__PURE__ */ __name(function copy(target, targetStart, start, end) {
30708
+ if (!Buffer3.isBuffer(target))
30709
+ throw new TypeError("argument should be a Buffer");
30710
+ if (!start)
30711
+ start = 0;
30712
+ if (!end && end !== 0)
30713
+ end = this.length;
30714
+ if (targetStart >= target.length)
30715
+ targetStart = target.length;
30716
+ if (!targetStart)
30717
+ targetStart = 0;
30718
+ if (end > 0 && end < start)
30719
+ end = start;
30720
+ if (end === start)
30721
+ return 0;
30722
+ if (target.length === 0 || this.length === 0)
30723
+ return 0;
30724
+ if (targetStart < 0) {
30725
+ throw new RangeError("targetStart out of bounds");
30726
+ }
30727
+ if (start < 0 || start >= this.length)
30728
+ throw new RangeError("Index out of range");
30729
+ if (end < 0)
30730
+ throw new RangeError("sourceEnd out of bounds");
30731
+ if (end > this.length)
30732
+ end = this.length;
30733
+ if (target.length - targetStart < end - start) {
30734
+ end = target.length - targetStart + start;
30735
+ }
30736
+ var len = end - start;
30737
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
30738
+ this.copyWithin(targetStart, start, end);
30739
+ } else {
30740
+ Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
30741
+ }
30742
+ return len;
30743
+ }, "copy");
30744
+ Buffer3.prototype.fill = /* @__PURE__ */ __name(function fill(val, start, end, encoding) {
30745
+ if (typeof val === "string") {
30746
+ if (typeof start === "string") {
30747
+ encoding = start;
30748
+ start = 0;
30749
+ end = this.length;
30750
+ } else if (typeof end === "string") {
30751
+ encoding = end;
30752
+ end = this.length;
30753
+ }
30754
+ if (encoding !== void 0 && typeof encoding !== "string") {
30755
+ throw new TypeError("encoding must be a string");
30756
+ }
30757
+ if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
30758
+ throw new TypeError("Unknown encoding: " + encoding);
30759
+ }
30760
+ if (val.length === 1) {
30761
+ var code5 = val.charCodeAt(0);
30762
+ if (encoding === "utf8" && code5 < 128 || encoding === "latin1") {
30763
+ val = code5;
30764
+ }
30765
+ }
30766
+ } else if (typeof val === "number") {
30767
+ val = val & 255;
30768
+ } else if (typeof val === "boolean") {
30769
+ val = Number(val);
30770
+ }
30771
+ if (start < 0 || this.length < start || this.length < end) {
30772
+ throw new RangeError("Out of range index");
30773
+ }
30774
+ if (end <= start) {
30775
+ return this;
30776
+ }
30777
+ start = start >>> 0;
30778
+ end = end === void 0 ? this.length : end >>> 0;
30779
+ if (!val)
30780
+ val = 0;
30781
+ var i;
30782
+ if (typeof val === "number") {
30783
+ for (i = start; i < end; ++i) {
30784
+ this[i] = val;
30785
+ }
30786
+ } else {
30787
+ var bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
30788
+ var len = bytes.length;
30789
+ if (len === 0) {
30790
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
30791
+ }
30792
+ for (i = 0; i < end - start; ++i) {
30793
+ this[i + start] = bytes[i % len];
30794
+ }
30795
+ }
30796
+ return this;
30797
+ }, "fill");
30798
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
30799
+ function base64clean(str) {
30800
+ str = str.split("=")[0];
30801
+ str = str.trim().replace(INVALID_BASE64_RE, "");
30802
+ if (str.length < 2)
30803
+ return "";
30804
+ while (str.length % 4 !== 0) {
30805
+ str = str + "=";
30806
+ }
30807
+ return str;
30808
+ }
30809
+ __name(base64clean, "base64clean");
30810
+ function utf8ToBytes2(string2, units) {
30811
+ units = units || Infinity;
30812
+ var codePoint;
30813
+ var length2 = string2.length;
30814
+ var leadSurrogate = null;
30815
+ var bytes = [];
30816
+ for (var i = 0; i < length2; ++i) {
30817
+ codePoint = string2.charCodeAt(i);
30818
+ if (codePoint > 55295 && codePoint < 57344) {
30819
+ if (!leadSurrogate) {
30820
+ if (codePoint > 56319) {
30821
+ if ((units -= 3) > -1)
30822
+ bytes.push(239, 191, 189);
30823
+ continue;
30824
+ } else if (i + 1 === length2) {
30825
+ if ((units -= 3) > -1)
30826
+ bytes.push(239, 191, 189);
30827
+ continue;
30828
+ }
30829
+ leadSurrogate = codePoint;
30830
+ continue;
30831
+ }
30832
+ if (codePoint < 56320) {
30833
+ if ((units -= 3) > -1)
30834
+ bytes.push(239, 191, 189);
30835
+ leadSurrogate = codePoint;
30836
+ continue;
30837
+ }
30838
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
30839
+ } else if (leadSurrogate) {
30840
+ if ((units -= 3) > -1)
30841
+ bytes.push(239, 191, 189);
30842
+ }
30843
+ leadSurrogate = null;
30844
+ if (codePoint < 128) {
30845
+ if ((units -= 1) < 0)
30846
+ break;
30847
+ bytes.push(codePoint);
30848
+ } else if (codePoint < 2048) {
30849
+ if ((units -= 2) < 0)
30850
+ break;
30851
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
30852
+ } else if (codePoint < 65536) {
30853
+ if ((units -= 3) < 0)
30854
+ break;
30855
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
30856
+ } else if (codePoint < 1114112) {
30857
+ if ((units -= 4) < 0)
30858
+ break;
30859
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
30860
+ } else {
30861
+ throw new Error("Invalid code point");
30862
+ }
30863
+ }
30864
+ return bytes;
30865
+ }
30866
+ __name(utf8ToBytes2, "utf8ToBytes");
30867
+ function asciiToBytes(str) {
30868
+ var byteArray = [];
30869
+ for (var i = 0; i < str.length; ++i) {
30870
+ byteArray.push(str.charCodeAt(i) & 255);
30871
+ }
30872
+ return byteArray;
30873
+ }
30874
+ __name(asciiToBytes, "asciiToBytes");
30875
+ function utf16leToBytes(str, units) {
30876
+ var c, hi, lo;
30877
+ var byteArray = [];
30878
+ for (var i = 0; i < str.length; ++i) {
30879
+ if ((units -= 2) < 0)
30880
+ break;
30881
+ c = str.charCodeAt(i);
30882
+ hi = c >> 8;
30883
+ lo = c % 256;
30884
+ byteArray.push(lo);
30885
+ byteArray.push(hi);
30886
+ }
30887
+ return byteArray;
30888
+ }
30889
+ __name(utf16leToBytes, "utf16leToBytes");
30890
+ function base64ToBytes2(str) {
30891
+ return base642.toByteArray(base64clean(str));
30892
+ }
30893
+ __name(base64ToBytes2, "base64ToBytes");
30894
+ function blitBuffer(src2, dst, offset, length2) {
30895
+ for (var i = 0; i < length2; ++i) {
30896
+ if (i + offset >= dst.length || i >= src2.length)
30897
+ break;
30898
+ dst[i + offset] = src2[i];
30899
+ }
30900
+ return i;
30901
+ }
30902
+ __name(blitBuffer, "blitBuffer");
30903
+ function isInstance(obj, type) {
30904
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
30905
+ }
30906
+ __name(isInstance, "isInstance");
30907
+ function numberIsNaN(obj) {
30908
+ return obj !== obj;
30909
+ }
30910
+ __name(numberIsNaN, "numberIsNaN");
30911
+ var hexSliceLookupTable = function() {
30912
+ var alphabet3 = "0123456789abcdef";
30913
+ var table = new Array(256);
30914
+ for (var i = 0; i < 16; ++i) {
30915
+ var i16 = i * 16;
30916
+ for (var j = 0; j < 16; ++j) {
30917
+ table[i16 + j] = alphabet3[i] + alphabet3[j];
30918
+ }
30919
+ }
30920
+ return table;
30921
+ }();
30922
+ }
30923
+ });
30924
+
29264
30925
  // src/wallet/plugins/EthereumPlugin/erc20.abi.json
29265
30926
  var require_erc20_abi = __commonJS({
29266
30927
  "src/wallet/plugins/EthereumPlugin/erc20.abi.json"(exports, module2) {
@@ -35270,6 +36931,7 @@ __export(src_exports2, {
35270
36931
  ExpirationPlugin: () => ExpirationPlugin,
35271
36932
  emptyWallet: () => emptyWallet,
35272
36933
  generateWallet: () => generateWallet,
36934
+ getCHAPIPlugin: () => getCHAPIPlugin,
35273
36935
  getDidKeyPlugin: () => getDidKeyPlugin,
35274
36936
  getDidKitPlugin: () => getDidKitPlugin,
35275
36937
  getEthereumPlugin: () => getEthereumPlugin,
@@ -35277,8 +36939,7 @@ __export(src_exports2, {
35277
36939
  getVCPlugin: () => getVCPlugin,
35278
36940
  getVpqrPlugin: () => getVpqrPlugin,
35279
36941
  initLearnCard: () => initLearnCard,
35280
- passwordToKey: () => passwordToKey,
35281
- seedToId: () => seedToId,
36942
+ walletFromApiUrl: () => walletFromApiUrl,
35282
36943
  walletFromKey: () => walletFromKey
35283
36944
  });
35284
36945
  module.exports = __toCommonJS(src_exports2);
@@ -35289,34 +36950,6 @@ var import_polyfill = require("abort-controller/polyfill");
35289
36950
  var import_isomorphic_webcrypto = __toESM(require("isomorphic-webcrypto"));
35290
36951
  if (typeof window === "undefined" && !globalThis.crypto)
35291
36952
  globalThis.crypto = import_isomorphic_webcrypto.default;
35292
- var crypto_default = import_isomorphic_webcrypto.default;
35293
-
35294
- // src/wallet/base/functions/passwordToKey.ts
35295
- var passwordToKey = /* @__PURE__ */ __name((password, salt = "salt", iterations = 1e5, digest2 = "SHA-256") => __async(void 0, null, function* () {
35296
- var saltBuffer = Buffer.from(salt);
35297
- var passphraseKey = Buffer.from(password);
35298
- return crypto_default.subtle.importKey("raw", passphraseKey, { name: "PBKDF2" }, false, [
35299
- "deriveBits",
35300
- "deriveKey"
35301
- ]).then(function(key2) {
35302
- return crypto_default.subtle.deriveKey({
35303
- name: "PBKDF2",
35304
- salt: saltBuffer,
35305
- iterations,
35306
- hash: digest2
35307
- }, key2, { name: "AES-CBC", length: 256 }, true, ["encrypt", "decrypt"]);
35308
- }).then((webKey) => {
35309
- return crypto_default.subtle.exportKey("raw", webKey);
35310
- }).then((buffer2) => {
35311
- return new Uint8Array(buffer2);
35312
- });
35313
- }), "passwordToKey");
35314
-
35315
- // src/wallet/base/functions/seedToId.ts
35316
- var seedToId = /* @__PURE__ */ __name((seed) => __async(void 0, null, function* () {
35317
- const buffer2 = yield crypto_default.subtle.digest("SHA-256", seed);
35318
- return `urn:digest:${Buffer.from(new Int8Array(buffer2)).toString("hex")}`;
35319
- }), "seedToId");
35320
36953
 
35321
36954
  // src/wallet/base/wallet.ts
35322
36955
  var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async(void 0, null, function* () {
@@ -36092,20 +37725,20 @@ var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async(void 0, null, fu
36092
37725
  issueCredential: (_wallet, credential, options, keypair) => __async(void 0, null, function* () {
36093
37726
  return JSON.parse(yield issueCredential(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
36094
37727
  }),
36095
- verifyCredential: (_wallet, credential) => __async(void 0, null, function* () {
36096
- return JSON.parse(yield verifyCredential(JSON.stringify(credential), "{}"));
37728
+ verifyCredential: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, options = {}) {
37729
+ return JSON.parse(yield verifyCredential(JSON.stringify(credential), JSON.stringify(options)));
36097
37730
  }),
36098
37731
  issuePresentation: (_wallet, presentation, options, keypair) => __async(void 0, null, function* () {
36099
37732
  return JSON.parse(yield issuePresentation(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair)));
36100
37733
  }),
36101
- verifyPresentation: (_wallet, presentation) => __async(void 0, null, function* () {
36102
- return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), "{}"));
37734
+ verifyPresentation: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, presentation, options = {}) {
37735
+ return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), JSON.stringify(options)));
36103
37736
  }),
36104
37737
  contextLoader: (_wallet, url) => __async(void 0, null, function* () {
36105
37738
  return JSON.parse(yield contextLoader(url));
36106
37739
  }),
36107
- resolveDid: (_wallet, did) => __async(void 0, null, function* () {
36108
- return JSON.parse(yield resolveDID(did, "{}"));
37740
+ resolveDid: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, did, inputMetadata = {}) {
37741
+ return JSON.parse(yield resolveDID(did, JSON.stringify(inputMetadata)));
36109
37742
  })
36110
37743
  }
36111
37744
  };
@@ -36126,8 +37759,1493 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
36126
37759
  }
36127
37760
  }), "ExpirationPlugin");
36128
37761
 
36129
- // src/wallet/helpers/wallet.helpers.ts
36130
- var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
37762
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/utils.js
37763
+ var RPC_ERRORS = {
37764
+ ParseError: {
37765
+ message: "Parse error",
37766
+ code: -32700
37767
+ },
37768
+ InvalidRequest: {
37769
+ message: "Invalid Request",
37770
+ code: -32600
37771
+ },
37772
+ MethodNotFound: {
37773
+ message: "Method not found",
37774
+ code: -32601
37775
+ },
37776
+ InvalidParams: {
37777
+ message: "Invalid params",
37778
+ code: -32602
37779
+ },
37780
+ InternalError: {
37781
+ message: "Internal Error",
37782
+ code: -32603
37783
+ },
37784
+ ServerError: {
37785
+ message: "Server error",
37786
+ code: -32e3
37787
+ }
37788
+ };
37789
+ function parseUrl(url, base4) {
37790
+ if (base4 === void 0) {
37791
+ base4 = window.location.href;
37792
+ }
37793
+ if (typeof URL === "function") {
37794
+ return new URL(url, base4);
37795
+ }
37796
+ if (typeof url !== "string") {
37797
+ throw new TypeError('"url" must be a string.');
37798
+ }
37799
+ if (!url.includes(":")) {
37800
+ if (base4.startsWith("http") && !url.startsWith("/")) {
37801
+ url = base4 + "/" + url;
37802
+ } else {
37803
+ url = base4 + url;
37804
+ }
37805
+ }
37806
+ const parser = document.createElement("a");
37807
+ parser.href = url;
37808
+ let origin = (parser.protocol || window.location.protocol) + "//";
37809
+ if (parser.host) {
37810
+ if (parser.protocol === "http:" && parser.port === "80" || parser.protocol === "https:" && parser.port === "443") {
37811
+ origin += parser.hostname;
37812
+ } else {
37813
+ origin += parser.host;
37814
+ }
37815
+ } else {
37816
+ origin += window.location.host;
37817
+ }
37818
+ let pathname = parser.pathname;
37819
+ if (!pathname.startsWith("/")) {
37820
+ pathname = "/" + pathname;
37821
+ }
37822
+ return {
37823
+ host: parser.host || window.location.host,
37824
+ hostname: parser.hostname,
37825
+ origin,
37826
+ protocol: parser.protocol,
37827
+ pathname
37828
+ };
37829
+ }
37830
+ __name(parseUrl, "parseUrl");
37831
+ function uuidv4(a, b) {
37832
+ for (b = a = ""; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : "-")
37833
+ ;
37834
+ return b;
37835
+ }
37836
+ __name(uuidv4, "uuidv4");
37837
+ function isValidMessage(message) {
37838
+ return message && typeof message === "object" && message.jsonrpc === "2.0" && message.id && typeof message.id === "string";
37839
+ }
37840
+ __name(isValidMessage, "isValidMessage");
37841
+ function isValidRequest(message) {
37842
+ return isValidMessage(message) && Array.isArray(message.params);
37843
+ }
37844
+ __name(isValidRequest, "isValidRequest");
37845
+ function isValidResponse(message) {
37846
+ return isValidMessage(message) && !!("result" in message ^ "error" in message) && (!("error" in message) || isValidError(message.error));
37847
+ }
37848
+ __name(isValidResponse, "isValidResponse");
37849
+ function isValidError(error) {
37850
+ return error && typeof error === "object" && typeof error.code === "number" && typeof error.message === "string";
37851
+ }
37852
+ __name(isValidError, "isValidError");
37853
+ function serializeError(error) {
37854
+ const err = {
37855
+ message: error.message
37856
+ };
37857
+ if (error.constructor.name !== "Error") {
37858
+ err.constructor = error.constructor.name;
37859
+ }
37860
+ if ("name" in error) {
37861
+ err.name = error.name;
37862
+ }
37863
+ if ("code" in error) {
37864
+ err.code = error.code;
37865
+ } else {
37866
+ err.code = RPC_ERRORS.ServerError.code;
37867
+ }
37868
+ if ("details" in error) {
37869
+ err.details = error.details;
37870
+ }
37871
+ return err;
37872
+ }
37873
+ __name(serializeError, "serializeError");
37874
+ function deserializeError(error) {
37875
+ let err;
37876
+ if (error.constructor === "DOMException") {
37877
+ err = new DOMException(error.message, error.name);
37878
+ } else {
37879
+ err = new Error(error.message);
37880
+ if ("code" in error) {
37881
+ err.code = error.code;
37882
+ }
37883
+ }
37884
+ if (error.details) {
37885
+ err.details = error.details;
37886
+ }
37887
+ return err;
37888
+ }
37889
+ __name(deserializeError, "deserializeError");
37890
+ function createMessageListener({ listener: listener2, origin, handle, expectRequest }) {
37891
+ if (isHandlePromise(handle)) {
37892
+ const promise = handle;
37893
+ handle = false;
37894
+ promise.then((h) => handle = h);
37895
+ }
37896
+ return (e) => {
37897
+ if (!(e.source === handle && e.origin === origin && (expectRequest && isValidRequest(e.data) || !expectRequest && isValidResponse(e.data)))) {
37898
+ return;
37899
+ }
37900
+ listener2(e.data, e);
37901
+ };
37902
+ }
37903
+ __name(createMessageListener, "createMessageListener");
37904
+ function destructureMethodName(fqMethodName) {
37905
+ let [name5, ...rest] = fqMethodName.split(".");
37906
+ const method = rest.pop();
37907
+ name5 = [name5, ...rest].join(".");
37908
+ return { name: name5, method };
37909
+ }
37910
+ __name(destructureMethodName, "destructureMethodName");
37911
+ function isHandlePromise(handle) {
37912
+ try {
37913
+ return typeof handle.then === "function";
37914
+ } catch (e) {
37915
+ }
37916
+ return false;
37917
+ }
37918
+ __name(isHandlePromise, "isHandlePromise");
37919
+
37920
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/Client.js
37921
+ var RPC_CLIENT_CALL_TIMEOUT = 3e4;
37922
+ var Client = class {
37923
+ constructor() {
37924
+ this.origin = null;
37925
+ this._handle = null;
37926
+ this._listener = null;
37927
+ this._pending = /* @__PURE__ */ new Map();
37928
+ }
37929
+ connect(origin, options) {
37930
+ return __async(this, null, function* () {
37931
+ if (this._listener) {
37932
+ throw new Error("Already connected.");
37933
+ }
37934
+ options = options || {};
37935
+ const self2 = this;
37936
+ self2.origin = parseUrl(origin).origin;
37937
+ self2._handle = options.handle || window.opener || window.parent;
37938
+ const pending = self2._pending;
37939
+ self2._listener = createMessageListener({
37940
+ origin: self2.origin,
37941
+ handle: self2._handle,
37942
+ expectRequest: false,
37943
+ listener: (message) => {
37944
+ if (!pending.has(message.id)) {
37945
+ return;
37946
+ }
37947
+ const { resolve, reject, cancelTimeout } = pending.get(message.id);
37948
+ cancelTimeout();
37949
+ if ("result" in message) {
37950
+ return resolve(message.result);
37951
+ }
37952
+ reject(deserializeError(message.error));
37953
+ }
37954
+ });
37955
+ window.addEventListener("message", self2._listener);
37956
+ return new Injector(self2);
37957
+ });
37958
+ }
37959
+ send(_0, _1, _2) {
37960
+ return __async(this, arguments, function* (qualifiedMethodName, parameters, {
37961
+ timeout = RPC_CLIENT_CALL_TIMEOUT
37962
+ }) {
37963
+ if (!this._listener) {
37964
+ throw new Error("RPC client not connected.");
37965
+ }
37966
+ const self2 = this;
37967
+ const message = {
37968
+ jsonrpc: "2.0",
37969
+ id: uuidv4(),
37970
+ method: qualifiedMethodName,
37971
+ params: parameters
37972
+ };
37973
+ if (isHandlePromise(self2._handle)) {
37974
+ const handle = yield self2._handle;
37975
+ handle.postMessage(message, self2.origin);
37976
+ } else {
37977
+ self2._handle.postMessage(message, self2.origin);
37978
+ }
37979
+ return new Promise((resolve, reject) => {
37980
+ const pending = self2._pending;
37981
+ let cancelTimeout;
37982
+ if (timeout > 0) {
37983
+ const timeoutId = setTimeout(() => {
37984
+ pending.delete(message.id);
37985
+ reject(new Error("RPC call timed out."));
37986
+ }, timeout);
37987
+ cancelTimeout = /* @__PURE__ */ __name(() => {
37988
+ pending.delete(message.id);
37989
+ clearTimeout(timeoutId);
37990
+ }, "cancelTimeout");
37991
+ } else {
37992
+ cancelTimeout = /* @__PURE__ */ __name(() => {
37993
+ pending.delete(message.id);
37994
+ }, "cancelTimeout");
37995
+ }
37996
+ pending.set(message.id, { resolve, reject, cancelTimeout });
37997
+ });
37998
+ });
37999
+ }
38000
+ close() {
38001
+ if (this._listener) {
38002
+ window.removeEventListener("message", this._listener);
38003
+ this._handle = this.origin = this._listener = null;
38004
+ for (const value of this._pending.values()) {
38005
+ value.reject(new Error("RPC client closed."));
38006
+ }
38007
+ this._pending = /* @__PURE__ */ new Map();
38008
+ }
38009
+ }
38010
+ };
38011
+ __name(Client, "Client");
38012
+ var Injector = class {
38013
+ constructor(client) {
38014
+ this.client = client;
38015
+ this._apis = /* @__PURE__ */ new Map();
38016
+ }
38017
+ define(name5, definition) {
38018
+ if (!(name5 && typeof name5 === "string")) {
38019
+ throw new TypeError("`name` must be a non-empty string.");
38020
+ }
38021
+ if (!(definition && typeof definition === "object" && Array.isArray(definition.functions))) {
38022
+ throw new TypeError("`definition.function` must be an array of function names or function definition objects to be defined.");
38023
+ }
38024
+ const self2 = this;
38025
+ const api = {};
38026
+ definition.functions.forEach((fn) => {
38027
+ if (typeof fn === "string") {
38028
+ fn = { name: fn, options: {} };
38029
+ }
38030
+ api[fn.name] = function() {
38031
+ return __async(this, arguments, function* () {
38032
+ return self2.client.send(name5 + "." + fn.name, [...arguments], fn.options);
38033
+ });
38034
+ };
38035
+ });
38036
+ self2._apis[name5] = api;
38037
+ return api;
38038
+ }
38039
+ get(name5, definition) {
38040
+ const api = this._apis[name5];
38041
+ if (!api) {
38042
+ if (definition) {
38043
+ return this.define(name5, definition);
38044
+ }
38045
+ throw new Error(`API "${name5}" has not been defined.`);
38046
+ }
38047
+ return this._apis[name5];
38048
+ }
38049
+ };
38050
+ __name(Injector, "Injector");
38051
+
38052
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/EventEmitter.js
38053
+ var EventEmitter = class {
38054
+ constructor({ deserialize = /* @__PURE__ */ __name((e) => e, "deserialize"), waitUntil = /* @__PURE__ */ __name(() => __async(this, null, function* () {
38055
+ }), "waitUntil") } = {}) {
38056
+ this._listeners = [];
38057
+ this._deserialize = deserialize;
38058
+ this._waitUntil = waitUntil;
38059
+ }
38060
+ emit(event) {
38061
+ return __async(this, null, function* () {
38062
+ event = this._deserialize(event);
38063
+ (this._listeners[event.type] || []).forEach((l) => l(event));
38064
+ return this._waitUntil(event);
38065
+ });
38066
+ }
38067
+ addEventListener(eventType, fn) {
38068
+ if (!this._listeners[eventType]) {
38069
+ this._listeners[eventType] = [fn];
38070
+ } else {
38071
+ this._listeners[eventType].push(fn);
38072
+ }
38073
+ }
38074
+ removeEventListener(eventType, fn) {
38075
+ const listeners = this._listeners[eventType];
38076
+ if (!listeners) {
38077
+ return;
38078
+ }
38079
+ const idx = listeners.indexOf(fn);
38080
+ if (idx !== -1) {
38081
+ listeners.splice(idx, 1);
38082
+ }
38083
+ }
38084
+ };
38085
+ __name(EventEmitter, "EventEmitter");
38086
+
38087
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/Server.js
38088
+ var Server = class {
38089
+ constructor() {
38090
+ this.origin = null;
38091
+ this._handle = null;
38092
+ this._apis = /* @__PURE__ */ new Map();
38093
+ }
38094
+ define(name5, api) {
38095
+ if (!(name5 && typeof name5 === "string")) {
38096
+ throw new TypeError("`name` must be a non-empty string.");
38097
+ }
38098
+ if (!(api && api !== "object")) {
38099
+ throw new TypeError("`api` must be an object.");
38100
+ }
38101
+ if (name5 in this._apis) {
38102
+ throw new Error(`The "${name5}" API is already defined.`);
38103
+ }
38104
+ this._apis[name5] = api;
38105
+ }
38106
+ listen(origin, options) {
38107
+ return __async(this, null, function* () {
38108
+ if (this._listener) {
38109
+ throw new Error("Already listening.");
38110
+ }
38111
+ options = options || {};
38112
+ const self2 = this;
38113
+ self2.origin = parseUrl(origin).origin;
38114
+ self2._handle = options.handle || window.opener || window.parent;
38115
+ const ignoreUnknownApi = options.ignoreUnknownApi === "true" || false;
38116
+ self2._listener = createMessageListener({
38117
+ origin: self2.origin,
38118
+ handle: self2._handle,
38119
+ expectRequest: true,
38120
+ listener: (message) => {
38121
+ const { name: name5, method } = destructureMethodName(message.method);
38122
+ const api = self2._apis[name5];
38123
+ if (method && method.startsWith("_")) {
38124
+ return sendMethodNotFound(self2._handle, self2.origin, message);
38125
+ }
38126
+ if (!api && ignoreUnknownApi) {
38127
+ return;
38128
+ }
38129
+ if (!api || typeof api[method] !== "function") {
38130
+ return sendMethodNotFound(self2._handle, self2.origin, message);
38131
+ }
38132
+ const fn = api[method];
38133
+ (() => __async(this, null, function* () {
38134
+ const response = {
38135
+ jsonrpc: "2.0",
38136
+ id: message.id
38137
+ };
38138
+ try {
38139
+ response.result = yield fn.apply(api, message.params);
38140
+ } catch (e) {
38141
+ response.error = serializeError(e);
38142
+ }
38143
+ if (self2._handle) {
38144
+ if (isHandlePromise(self2._handle)) {
38145
+ self2._handle.then((h) => h.postMessage(response, self2.origin));
38146
+ } else {
38147
+ self2._handle.postMessage(response, self2.origin);
38148
+ }
38149
+ }
38150
+ }))();
38151
+ }
38152
+ });
38153
+ window.addEventListener("message", self2._listener);
38154
+ });
38155
+ }
38156
+ close() {
38157
+ if (this._listener) {
38158
+ window.removeEventListener("message", this._listener);
38159
+ this._handle = this.origin = this._listener = null;
38160
+ }
38161
+ }
38162
+ };
38163
+ __name(Server, "Server");
38164
+ function sendMethodNotFound(handle, origin, message) {
38165
+ const response = {
38166
+ jsonrpc: "2.0",
38167
+ id: message.id,
38168
+ error: Object.assign({}, RPC_ERRORS.MethodNotFound)
38169
+ };
38170
+ if (isHandlePromise(handle)) {
38171
+ return handle.then((h) => h.postMessage(response, origin));
38172
+ } else {
38173
+ return handle.postMessage(response, origin);
38174
+ }
38175
+ }
38176
+ __name(sendMethodNotFound, "sendMethodNotFound");
38177
+
38178
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebApp.js
38179
+ var WebApp = class {
38180
+ constructor(relyingOrigin) {
38181
+ this.relyingOrigin = parseUrl(relyingOrigin).origin;
38182
+ this.client = null;
38183
+ this.injector = null;
38184
+ this.client = new Client();
38185
+ this.server = new Server();
38186
+ this._control = null;
38187
+ this._connected = false;
38188
+ }
38189
+ connect() {
38190
+ return __async(this, null, function* () {
38191
+ this.injector = yield this.client.connect(this.relyingOrigin);
38192
+ this._connected = true;
38193
+ this._control = this.injector.define("core.control", {
38194
+ functions: ["ready", "show", "hide"]
38195
+ });
38196
+ this.server.listen(this.relyingOrigin);
38197
+ return this.injector;
38198
+ });
38199
+ }
38200
+ ready() {
38201
+ return __async(this, null, function* () {
38202
+ if (!this._connected) {
38203
+ throw new Error('WebApp not connected. Did you call ".connect()"?');
38204
+ }
38205
+ yield this._control.ready();
38206
+ return this;
38207
+ });
38208
+ }
38209
+ close() {
38210
+ if (this._connected) {
38211
+ this.server.close();
38212
+ this.client.close();
38213
+ this._connected = false;
38214
+ }
38215
+ }
38216
+ show() {
38217
+ return __async(this, null, function* () {
38218
+ if (!this._connected) {
38219
+ throw new Error('Cannot "show" yet; not connected. Did you call ".connect()"?');
38220
+ }
38221
+ return this._control.show();
38222
+ });
38223
+ }
38224
+ hide() {
38225
+ return __async(this, null, function* () {
38226
+ if (!this._connected) {
38227
+ throw new Error('Cannot "hide" yet; not connected. Did you call ".connect()?"');
38228
+ }
38229
+ return this._control.hide();
38230
+ });
38231
+ }
38232
+ };
38233
+ __name(WebApp, "WebApp");
38234
+
38235
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowDialog.js
38236
+ var WebAppWindowDialog = class {
38237
+ constructor() {
38238
+ this._closeEventListeners = /* @__PURE__ */ new Set();
38239
+ }
38240
+ addEventListener(name5, listener2) {
38241
+ if (name5 !== "close") {
38242
+ throw new Error(`Unknown event "${name5}".`);
38243
+ }
38244
+ if (typeof listener2 !== "function") {
38245
+ throw new TypeError('"listener" must be a function.');
38246
+ }
38247
+ this._closeEventListeners.add(listener2);
38248
+ }
38249
+ removeEventListener(name5, listener2) {
38250
+ if (name5 !== "close") {
38251
+ throw new Error(`Unknown event "${name5}".`);
38252
+ }
38253
+ if (typeof listener2 !== "function") {
38254
+ throw new TypeError('"listener" must be a function.');
38255
+ }
38256
+ this._closeEventListeners.delete(listener2);
38257
+ }
38258
+ show() {
38259
+ }
38260
+ close() {
38261
+ for (const listener2 of this._closeEventListeners) {
38262
+ listener2({});
38263
+ }
38264
+ }
38265
+ destroy() {
38266
+ this._closeEventListeners.clear();
38267
+ }
38268
+ };
38269
+ __name(WebAppWindowDialog, "WebAppWindowDialog");
38270
+
38271
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowInlineDialog.js
38272
+ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
38273
+ constructor({ url, handle, className }) {
38274
+ super();
38275
+ this.url = url;
38276
+ this.handle = handle;
38277
+ this.dialog = document.createElement("dialog");
38278
+ applyStyle(this.dialog, {
38279
+ position: "fixed",
38280
+ top: 0,
38281
+ left: 0,
38282
+ width: "100%",
38283
+ height: "100%",
38284
+ "max-width": "100%",
38285
+ "max-height": "100%",
38286
+ display: "none",
38287
+ margin: 0,
38288
+ padding: 0,
38289
+ border: "none",
38290
+ background: "transparent",
38291
+ color: "black",
38292
+ "box-sizing": "border-box",
38293
+ overflow: "hidden",
38294
+ "z-index": 1e6
38295
+ });
38296
+ this.dialog.className = "web-app-window";
38297
+ if (typeof className === "string") {
38298
+ this.dialog.className = this.dialog.className + " " + className;
38299
+ }
38300
+ const style = document.createElement("style");
38301
+ style.appendChild(document.createTextNode(`dialog.web-app-window::backdrop {
38302
+ background-color: transparent;
38303
+ }`));
38304
+ this.container = document.createElement("div");
38305
+ applyStyle(this.container, {
38306
+ position: "relative",
38307
+ width: "100%",
38308
+ height: "100%",
38309
+ margin: 0,
38310
+ padding: 0,
38311
+ display: "flex",
38312
+ "flex-direction": "column"
38313
+ });
38314
+ this.container.className = "web-app-window-backdrop";
38315
+ this.iframe = document.createElement("iframe");
38316
+ this.iframe.src = url;
38317
+ this.iframe.scrolling = "auto";
38318
+ applyStyle(this.iframe, {
38319
+ position: "fixed",
38320
+ top: 0,
38321
+ left: 0,
38322
+ width: "100%",
38323
+ height: "100%",
38324
+ border: "none",
38325
+ background: "transparent",
38326
+ overflow: "hidden",
38327
+ margin: 0,
38328
+ padding: 0,
38329
+ "flex-grow": 1
38330
+ });
38331
+ this.dialog.appendChild(style);
38332
+ this.container.appendChild(this.iframe);
38333
+ this.dialog.appendChild(this.container);
38334
+ this.dialog.addEventListener("cancel", (e) => {
38335
+ e.preventDefault();
38336
+ this.hide();
38337
+ });
38338
+ document.body.appendChild(this.dialog);
38339
+ this.handle = this.iframe.contentWindow;
38340
+ }
38341
+ show() {
38342
+ this.dialog.style.display = "block";
38343
+ if (this.dialog.showModal) {
38344
+ this.dialog.showModal();
38345
+ }
38346
+ }
38347
+ close() {
38348
+ this.dialog.style.display = "none";
38349
+ if (this.dialog.close) {
38350
+ try {
38351
+ this.dialog.close();
38352
+ } catch (e) {
38353
+ console.error(e);
38354
+ }
38355
+ }
38356
+ super.close();
38357
+ }
38358
+ destroy() {
38359
+ this.dialog.parentNode.removeChild(this.dialog);
38360
+ super.destroy();
38361
+ }
38362
+ };
38363
+ __name(WebAppWindowInlineDialog, "WebAppWindowInlineDialog");
38364
+ function applyStyle(element, style) {
38365
+ for (const name5 in style) {
38366
+ element.style[name5] = style[name5];
38367
+ }
38368
+ }
38369
+ __name(applyStyle, "applyStyle");
38370
+
38371
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindowPopupDialog.js
38372
+ var WebAppWindowPopupDialog = class extends WebAppWindowDialog {
38373
+ constructor({ url, handle, bounds = { width: 500, height: 400 } }) {
38374
+ super();
38375
+ this.url = url;
38376
+ this.handle = handle;
38377
+ this._locationChanging = false;
38378
+ if (!handle) {
38379
+ this._openWindow({ url, name: "web-app-window", bounds });
38380
+ }
38381
+ this.destroyed = false;
38382
+ this._removeListeners = () => {
38383
+ };
38384
+ }
38385
+ show() {
38386
+ }
38387
+ close() {
38388
+ this.destroy();
38389
+ }
38390
+ destroy() {
38391
+ if (this.handle && !this.destroyed) {
38392
+ this.handle.close();
38393
+ super.close();
38394
+ this.handle = null;
38395
+ this.destroyed = true;
38396
+ this._removeListeners();
38397
+ super.destroy();
38398
+ }
38399
+ }
38400
+ isClosed() {
38401
+ return !this.handle || this.handle.closed;
38402
+ }
38403
+ _openWindow({ url, name: name5, bounds }) {
38404
+ const { x, y } = bounds;
38405
+ let { width = 500, height = 400 } = bounds;
38406
+ width = Math.min(width, window.innerWidth);
38407
+ height = Math.min(height, window.innerHeight);
38408
+ const left = x !== void 0 ? x : window.screenX + (window.innerWidth - width) / 2;
38409
+ const top = y !== void 0 ? y : window.screenY + (window.innerHeight - height) / 2;
38410
+ const features = `popup=yes,menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=${width},height=${height},left=${left},top=${top}`;
38411
+ this._locationChanging = true;
38412
+ this.handle = window.open(url, name5, features);
38413
+ this._addListeners();
38414
+ }
38415
+ setLocation(url) {
38416
+ this.url = url;
38417
+ this._locationChanging = true;
38418
+ this.handle.location.replace(url);
38419
+ }
38420
+ _addListeners() {
38421
+ const destroyDialog = /* @__PURE__ */ __name(() => this.destroy(), "destroyDialog");
38422
+ const loadDialog = /* @__PURE__ */ __name(() => {
38423
+ this._locationChanging = false;
38424
+ }, "loadDialog");
38425
+ const unloadDialog = /* @__PURE__ */ __name(() => {
38426
+ if (this._locationChanging) {
38427
+ return;
38428
+ }
38429
+ this.destroy();
38430
+ }, "unloadDialog");
38431
+ this.handle.addEventListener("unload", unloadDialog);
38432
+ this.handle.addEventListener("load", loadDialog);
38433
+ window.addEventListener("beforeUnload", destroyDialog, { once: true });
38434
+ const intervalId = setInterval(() => {
38435
+ if (this.isClosed()) {
38436
+ this.destroy();
38437
+ clearInterval(intervalId);
38438
+ }
38439
+ }, 250);
38440
+ this._removeListeners = () => {
38441
+ clearInterval(intervalId);
38442
+ this.handle.removeListener("unload", unloadDialog);
38443
+ this.handle.removeListener("load", loadDialog);
38444
+ window.removeEventListener("beforeUnload", destroyDialog);
38445
+ };
38446
+ }
38447
+ };
38448
+ __name(WebAppWindowPopupDialog, "WebAppWindowPopupDialog");
38449
+
38450
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppWindow.js
38451
+ var LOAD_WINDOW_TIMEOUT = 6e4;
38452
+ var WebAppWindow = class {
38453
+ constructor(url, {
38454
+ timeout = LOAD_WINDOW_TIMEOUT,
38455
+ dialog = null,
38456
+ handle,
38457
+ popup = false,
38458
+ className = null,
38459
+ customize = null,
38460
+ bounds
38461
+ } = {}) {
38462
+ this.visible = false;
38463
+ this.dialog = dialog;
38464
+ this.handle = null;
38465
+ this.popup = popup;
38466
+ this.windowControl = null;
38467
+ this._destroyed = false;
38468
+ this._ready = false;
38469
+ this._private = {};
38470
+ this._timeoutId = null;
38471
+ if (handle && handle._dialog) {
38472
+ this.dialog = dialog = handle._dialog;
38473
+ }
38474
+ this._private._readyPromise = new Promise((resolve, reject) => {
38475
+ this._timeoutId = setTimeout(() => reject(new DOMException("Loading Web application window timed out.", "TimeoutError")), timeout);
38476
+ this._private._resolveReady = (value) => {
38477
+ clearTimeout(this.timeoutId);
38478
+ this._timeoutId = null;
38479
+ resolve(value);
38480
+ };
38481
+ this._private._rejectReady = (err) => {
38482
+ clearTimeout(this.timeoutId);
38483
+ this._timeoutId = null;
38484
+ reject(err);
38485
+ };
38486
+ });
38487
+ this._private.isReady = () => __async(this, null, function* () {
38488
+ return this._private._readyPromise;
38489
+ });
38490
+ this._private.destroy = () => {
38491
+ if (this._timeoutId) {
38492
+ this._private._rejectReady(new DOMException("Web application window closed before ready.", "AbortError"));
38493
+ }
38494
+ if (!this._destroyed) {
38495
+ this.dialog.destroy();
38496
+ this.dialog = null;
38497
+ this._destroyed = true;
38498
+ }
38499
+ };
38500
+ if (customize) {
38501
+ if (!typeof customize === "function") {
38502
+ throw new TypeError("`options.customize` must be a function.");
38503
+ }
38504
+ }
38505
+ if (!this.dialog) {
38506
+ if (this.popup) {
38507
+ this.dialog = new WebAppWindowPopupDialog({ url, handle, bounds });
38508
+ } else {
38509
+ this.dialog = new WebAppWindowInlineDialog({ url, handle, className });
38510
+ }
38511
+ } else if (this.popup && bounds) {
38512
+ if (bounds) {
38513
+ const { top: y, left: x, width, height } = bounds;
38514
+ if (x !== void 0 && y !== void 0) {
38515
+ this.dialog.handle.moveTo(x, y);
38516
+ }
38517
+ if (width !== void 0 && height !== void 0) {
38518
+ this.dialog.handle.resizeTo(width, height);
38519
+ }
38520
+ }
38521
+ }
38522
+ this.handle = this.dialog.handle;
38523
+ if (customize) {
38524
+ try {
38525
+ customize({
38526
+ dialog: this.dialog.dialog,
38527
+ container: this.dialog.container,
38528
+ iframe: this.dialog.iframe,
38529
+ webAppWindow: this
38530
+ });
38531
+ } catch (e) {
38532
+ console.error(e);
38533
+ }
38534
+ }
38535
+ }
38536
+ ready() {
38537
+ this._ready = true;
38538
+ this._private._resolveReady(true);
38539
+ }
38540
+ show() {
38541
+ if (!this.visible) {
38542
+ this.visible = true;
38543
+ const body = document.querySelector("body");
38544
+ this._bodyOverflowStyle = body.style.overflow;
38545
+ body.style.overflow = "hidden";
38546
+ if (!this._destroyed) {
38547
+ this.dialog.show();
38548
+ } else if (this.windowControl.show) {
38549
+ this.windowControl.show();
38550
+ }
38551
+ }
38552
+ }
38553
+ hide() {
38554
+ if (this.visible) {
38555
+ this.visible = false;
38556
+ const body = document.querySelector("body");
38557
+ if (this._bodyOverflowStyle) {
38558
+ body.style.overflow = this._bodyOverflowStyle;
38559
+ } else {
38560
+ body.style.overflow = "";
38561
+ }
38562
+ if (!this._destroyed) {
38563
+ this.dialog.close();
38564
+ } else if (this.windowControl.hide) {
38565
+ this.windowControl.hide();
38566
+ }
38567
+ }
38568
+ }
38569
+ };
38570
+ __name(WebAppWindow, "WebAppWindow");
38571
+
38572
+ // ../../node_modules/.pnpm/web-request-rpc@2.0.0/node_modules/web-request-rpc/WebAppContext.js
38573
+ var WEB_APP_CONTEXT_LOAD_TIMEOUT = 1e4;
38574
+ var WebAppContext = class {
38575
+ constructor() {
38576
+ this.client = new Client();
38577
+ this.server = new Server();
38578
+ this.injector = null;
38579
+ this.control = null;
38580
+ this.loaded = false;
38581
+ this.closed = false;
38582
+ }
38583
+ createWindow(_0) {
38584
+ return __async(this, arguments, function* (url, {
38585
+ timeout = WEB_APP_CONTEXT_LOAD_TIMEOUT,
38586
+ iframe,
38587
+ dialog = null,
38588
+ popup = false,
38589
+ handle,
38590
+ windowControl,
38591
+ className,
38592
+ customize,
38593
+ bounds
38594
+ } = {}) {
38595
+ if (this.loaded) {
38596
+ throw new Error("AppContext already loaded.");
38597
+ }
38598
+ this.loaded = true;
38599
+ this.control = new WebAppWindow(url, {
38600
+ timeout,
38601
+ dialog,
38602
+ iframe,
38603
+ popup,
38604
+ handle,
38605
+ windowControl,
38606
+ className,
38607
+ customize,
38608
+ bounds
38609
+ });
38610
+ window.addEventListener("pagehide", () => this.close(), { once: true });
38611
+ this.server.define("core.control", this.control);
38612
+ const origin = parseUrl(url).origin;
38613
+ this.server.listen(origin, {
38614
+ handle: this.control.handle,
38615
+ ignoreUnknownApi: true
38616
+ });
38617
+ yield this.control._private.isReady();
38618
+ this.injector = yield this.client.connect(origin, {
38619
+ handle: this.control.handle
38620
+ });
38621
+ return this.injector;
38622
+ });
38623
+ }
38624
+ close() {
38625
+ if (!this.closed) {
38626
+ this.closed = true;
38627
+ this.control._private.destroy();
38628
+ this.server.close();
38629
+ this.client.close();
38630
+ }
38631
+ }
38632
+ };
38633
+ __name(WebAppContext, "WebAppContext");
38634
+
38635
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialRequestEvent.js
38636
+ var CredentialRequestEvent = class {
38637
+ constructor({
38638
+ credentialHandler,
38639
+ credentialRequestOrigin,
38640
+ credentialRequestOptions,
38641
+ hintKey
38642
+ }) {
38643
+ this.type = "credentialrequest";
38644
+ this._credentialHandler = credentialHandler;
38645
+ this.credentialRequestOrigin = credentialRequestOrigin;
38646
+ this.credentialRequestOptions = credentialRequestOptions;
38647
+ this.hintKey = hintKey;
38648
+ }
38649
+ openWindow(url) {
38650
+ return __async(this, null, function* () {
38651
+ yield this._credentialHandler.show();
38652
+ const appWindow = new WebAppWindow(url, {
38653
+ className: "credential-handler"
38654
+ });
38655
+ appWindow.ready();
38656
+ appWindow.show();
38657
+ appWindow.handle._dialog = appWindow.dialog;
38658
+ return appWindow.handle;
38659
+ });
38660
+ }
38661
+ respondWith(handlerResponse) {
38662
+ this._promise = handlerResponse;
38663
+ }
38664
+ };
38665
+ __name(CredentialRequestEvent, "CredentialRequestEvent");
38666
+
38667
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialStoreEvent.js
38668
+ var CredentialStoreEvent = class {
38669
+ constructor({
38670
+ credentialHandler,
38671
+ credentialRequestOrigin,
38672
+ credential,
38673
+ hintKey
38674
+ }) {
38675
+ this.type = "credentialstore";
38676
+ this._credentialHandler = credentialHandler;
38677
+ this.credentialRequestOrigin = credentialRequestOrigin;
38678
+ this.credential = credential;
38679
+ this.hintKey = hintKey;
38680
+ }
38681
+ openWindow(url) {
38682
+ return __async(this, null, function* () {
38683
+ yield this._credentialHandler.show();
38684
+ const appWindow = new WebAppWindow(url);
38685
+ appWindow.ready();
38686
+ appWindow.show();
38687
+ appWindow.handle._dialog = appWindow.dialog;
38688
+ return appWindow.handle;
38689
+ });
38690
+ }
38691
+ respondWith(handlerResponse) {
38692
+ this._promise = handlerResponse;
38693
+ }
38694
+ };
38695
+ __name(CredentialStoreEvent, "CredentialStoreEvent");
38696
+
38697
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerService.js
38698
+ var CredentialHandlerService = class {
38699
+ constructor(credentialHandler) {
38700
+ this._credentialHandler = credentialHandler;
38701
+ }
38702
+ request(credentialRequestEvent) {
38703
+ return __async(this, null, function* () {
38704
+ return yield this._credentialHandler._emitter.emit(new CredentialRequestEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialRequestEvent)));
38705
+ });
38706
+ }
38707
+ store(credentialStoreEvent) {
38708
+ return __async(this, null, function* () {
38709
+ return yield this._credentialHandler._emitter.emit(new CredentialStoreEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialStoreEvent)));
38710
+ });
38711
+ }
38712
+ };
38713
+ __name(CredentialHandlerService, "CredentialHandlerService");
38714
+
38715
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandler.js
38716
+ var EVENT_TYPES = ["credentialrequest", "credentialstore"];
38717
+ var CredentialHandler = class extends WebApp {
38718
+ constructor(mediatorOrigin, inline = false) {
38719
+ if (typeof mediatorOrigin !== "string") {
38720
+ throw new TypeError('"mediatorOrigin" must be a string.');
38721
+ }
38722
+ super(mediatorOrigin, inline);
38723
+ this._emitter = new EventEmitter({
38724
+ waitUntil(event) {
38725
+ return __async(this, null, function* () {
38726
+ return event._promise || Promise.reject(new DOMException('No "credentialrequest" event handler found.', "NotFoundError"));
38727
+ });
38728
+ }
38729
+ });
38730
+ }
38731
+ connect() {
38732
+ return __async(this, null, function* () {
38733
+ const injector = yield __superGet(CredentialHandler.prototype, this, "connect").call(this);
38734
+ this.server.define("credentialHandler", new CredentialHandlerService(this));
38735
+ yield this.ready();
38736
+ return injector;
38737
+ });
38738
+ }
38739
+ addEventListener(eventType, fn) {
38740
+ if (!EVENT_TYPES.includes(eventType)) {
38741
+ throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
38742
+ }
38743
+ return this._emitter.addEventListener(eventType, fn);
38744
+ }
38745
+ removeEventListener(eventType, fn) {
38746
+ if (!EVENT_TYPES.includes(eventType)) {
38747
+ throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
38748
+ }
38749
+ return this._emitter.removeEventListener(eventType, fn);
38750
+ }
38751
+ };
38752
+ __name(CredentialHandler, "CredentialHandler");
38753
+
38754
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHints.js
38755
+ var CredentialHints = class {
38756
+ constructor(url, injector) {
38757
+ const remote = injector.get("credentialHints", {
38758
+ functions: ["delete", "get", "keys", "has", "set", "clear"]
38759
+ });
38760
+ for (let methodName in remote) {
38761
+ if (methodName !== "set") {
38762
+ const method = remote[methodName].bind(this, url);
38763
+ this[methodName] = function(...args) {
38764
+ this._deprecateNotice();
38765
+ return method(...args);
38766
+ };
38767
+ }
38768
+ }
38769
+ this._remoteSet = remote.set.bind(this, url);
38770
+ }
38771
+ set(hintKey, credentialHint) {
38772
+ return __async(this, null, function* () {
38773
+ this._deprecateNotice();
38774
+ credentialHint.icons = credentialHint.icons || [];
38775
+ const promises = credentialHint.icons.map((icon) => imageToDataUrl(icon.src).then((fetchedImage) => {
38776
+ icon.fetchedImage = fetchedImage;
38777
+ }));
38778
+ yield Promise.all(promises);
38779
+ return this._remoteSet(hintKey, credentialHint);
38780
+ });
38781
+ }
38782
+ _deprecateNotice() {
38783
+ console.warn("Credential hints are deprecated and no longer used.");
38784
+ }
38785
+ };
38786
+ __name(CredentialHints, "CredentialHints");
38787
+ function imageToDataUrl(url) {
38788
+ return new Promise((resolve) => {
38789
+ const img = new Image();
38790
+ img.crossOrigin = "Anonymous";
38791
+ img.onload = () => {
38792
+ let canvas = document.createElement("canvas");
38793
+ const ctx = canvas.getContext("2d");
38794
+ canvas.height = img.height;
38795
+ canvas.width = img.width;
38796
+ ctx.drawImage(img, 0, 0);
38797
+ const dataUrl = canvas.toDataURL();
38798
+ resolve(dataUrl);
38799
+ canvas = null;
38800
+ };
38801
+ img.onerror = () => resolve(null);
38802
+ img.src = url;
38803
+ });
38804
+ }
38805
+ __name(imageToDataUrl, "imageToDataUrl");
38806
+
38807
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialManager.js
38808
+ var CredentialManager = class {
38809
+ constructor(url, injector) {
38810
+ if (!(url && typeof url === "string")) {
38811
+ throw new TypeError('"url" must be a non-empty string.');
38812
+ }
38813
+ this.hints = new CredentialHints(url, injector);
38814
+ }
38815
+ static requestPermission() {
38816
+ return __async(this, null, function* () {
38817
+ const status = yield navigator.credentialsPolyfill.permissions.request({ name: "credentialhandler" });
38818
+ return status.state;
38819
+ });
38820
+ }
38821
+ };
38822
+ __name(CredentialManager, "CredentialManager");
38823
+
38824
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerRegistration.js
38825
+ var CredentialHandlerRegistration = 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.credentialManager = new CredentialManager(url, injector);
38831
+ }
38832
+ };
38833
+ __name(CredentialHandlerRegistration, "CredentialHandlerRegistration");
38834
+
38835
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlers.js
38836
+ var CredentialHandlers = class {
38837
+ constructor(injector) {
38838
+ this._init = (() => __async(this, null, function* () {
38839
+ this._injector = yield injector;
38840
+ this._remote = this._injector.get("credentialHandlers", {
38841
+ functions: [
38842
+ "register",
38843
+ "unregister",
38844
+ "getRegistration",
38845
+ "hasRegistration"
38846
+ ]
38847
+ });
38848
+ }))();
38849
+ }
38850
+ register(url) {
38851
+ return __async(this, null, function* () {
38852
+ this._deprecateNotice();
38853
+ yield this._init;
38854
+ url = yield this._remote.register("credential", url);
38855
+ return new CredentialHandlerRegistration(url, this._injector);
38856
+ });
38857
+ }
38858
+ unregister(url) {
38859
+ return __async(this, null, function* () {
38860
+ this._deprecateNotice();
38861
+ yield this._init;
38862
+ return this._remote.unregister("credential", url);
38863
+ });
38864
+ }
38865
+ getRegistration(url) {
38866
+ return __async(this, null, function* () {
38867
+ this._deprecateNotice();
38868
+ yield this._init;
38869
+ url = yield this._remote.getRegistration("credential", url);
38870
+ if (!url) {
38871
+ return null;
38872
+ }
38873
+ return new CredentialHandlerRegistration(url, this._injector);
38874
+ });
38875
+ }
38876
+ hasRegistration(url) {
38877
+ return __async(this, null, function* () {
38878
+ this._deprecateNotice();
38879
+ yield this._init;
38880
+ return yield this._remote.hasRegistration("credential", url);
38881
+ });
38882
+ }
38883
+ _deprecateNotice() {
38884
+ 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()".');
38885
+ }
38886
+ };
38887
+ __name(CredentialHandlers, "CredentialHandlers");
38888
+
38889
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/WebCredential.js
38890
+ var WebCredential2 = class {
38891
+ constructor(dataType, data, { recommendedHandlerOrigins = [] } = {}) {
38892
+ if (typeof dataType !== "string") {
38893
+ throw new TypeError('"dataType" must be a string.');
38894
+ }
38895
+ this.type = "web";
38896
+ this.dataType = dataType;
38897
+ this.data = data;
38898
+ this.options = { recommendedHandlerOrigins };
38899
+ }
38900
+ };
38901
+ __name(WebCredential2, "WebCredential");
38902
+
38903
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialsContainer.js
38904
+ var CREDENTIAL_GET_TIMEOUT = 0;
38905
+ var CREDENTIAL_STORE_TIMEOUT = 0;
38906
+ var CredentialsContainer = class {
38907
+ constructor(injector) {
38908
+ this._nativeCredentialsContainer = {
38909
+ get: navigator.credentials && navigator.credentials.get && navigator.credentials.get.bind(navigator.credentials),
38910
+ store: navigator.credentials && navigator.credentials.store && navigator.credentials.store.bind(navigator.credentials)
38911
+ };
38912
+ this._init = (() => __async(this, null, function* () {
38913
+ this._remote = (yield injector).get("credentialsContainer", {
38914
+ functions: [
38915
+ { name: "get", options: { timeout: CREDENTIAL_GET_TIMEOUT } },
38916
+ { name: "store", options: { timeout: CREDENTIAL_STORE_TIMEOUT } }
38917
+ ]
38918
+ });
38919
+ }))();
38920
+ }
38921
+ get() {
38922
+ return __async(this, arguments, function* (options = {}) {
38923
+ if (options.web) {
38924
+ yield this._init;
38925
+ const credential = yield this._remote.get(options);
38926
+ if (!credential) {
38927
+ return null;
38928
+ }
38929
+ return new WebCredential2(credential.dataType, credential.data);
38930
+ }
38931
+ if (this._nativeCredentialsContainer.get) {
38932
+ return this._nativeCredentialsContainer.get(options);
38933
+ }
38934
+ throw new DOMException("Not implemented.", "NotSupportedError");
38935
+ });
38936
+ }
38937
+ store(credential) {
38938
+ return __async(this, null, function* () {
38939
+ if (credential instanceof WebCredential2) {
38940
+ yield this._init;
38941
+ const result = yield this._remote.store(credential);
38942
+ if (!result) {
38943
+ return null;
38944
+ }
38945
+ return new WebCredential2(result.dataType, result.data);
38946
+ }
38947
+ if (this._nativeCredentialsContainer.store) {
38948
+ return this._nativeCredentialsContainer.store(credential);
38949
+ }
38950
+ throw new DOMException("Not implemented.", "NotSupportedError");
38951
+ });
38952
+ }
38953
+ };
38954
+ __name(CredentialsContainer, "CredentialsContainer");
38955
+
38956
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/PermissionManager.js
38957
+ var PERMISSION_REQUEST_TIMEOUT = 0;
38958
+ var PermissionManager = class {
38959
+ constructor(injector) {
38960
+ this._init = (() => __async(this, null, function* () {
38961
+ this._remote = (yield injector).get("permissionManager", {
38962
+ functions: [
38963
+ "query",
38964
+ { name: "request", options: { timeout: PERMISSION_REQUEST_TIMEOUT } },
38965
+ "revoke"
38966
+ ]
38967
+ });
38968
+ }))();
38969
+ }
38970
+ query(permissionDesc) {
38971
+ return __async(this, null, function* () {
38972
+ yield this._init;
38973
+ return yield this._remote.query(permissionDesc);
38974
+ });
38975
+ }
38976
+ request(permissionDesc) {
38977
+ return __async(this, null, function* () {
38978
+ yield this._init;
38979
+ return yield this._remote.request(permissionDesc);
38980
+ });
38981
+ }
38982
+ revoke(permissionDesc) {
38983
+ return __async(this, null, function* () {
38984
+ yield this._init;
38985
+ return yield this._remote.revoke(permissionDesc);
38986
+ });
38987
+ }
38988
+ };
38989
+ __name(PermissionManager, "PermissionManager");
38990
+
38991
+ // ../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/index.js
38992
+ var DEFAULT_MEDIATOR_ORIGIN = "https://authn.io";
38993
+ var loaded;
38994
+ function loadOnce(options) {
38995
+ return __async(this, null, function* () {
38996
+ if (loaded) {
38997
+ return loaded;
38998
+ }
38999
+ loaded = true;
39000
+ return load2(options);
39001
+ });
39002
+ }
39003
+ __name(loadOnce, "loadOnce");
39004
+ function load2() {
39005
+ return __async(this, arguments, function* (options = {
39006
+ mediatorOrigin: DEFAULT_MEDIATOR_ORIGIN
39007
+ }) {
39008
+ let mediatorUrl;
39009
+ if (typeof options === "string") {
39010
+ mediatorUrl = options;
39011
+ } else if (options && typeof options === "object" && typeof options.mediatorOrigin === "string") {
39012
+ mediatorUrl = `${options.mediatorOrigin}/mediator`;
39013
+ } else {
39014
+ throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');
39015
+ }
39016
+ const appContext = new WebAppContext();
39017
+ const injector = appContext.createWindow(mediatorUrl, {
39018
+ className: "credential-mediator",
39019
+ timeout: 3e4
39020
+ });
39021
+ const style = document.createElement("style");
39022
+ style.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
39023
+ background-color: rgba(0, 0, 0, 0.25);
39024
+ }`));
39025
+ document.body.appendChild(style);
39026
+ const polyfill = {};
39027
+ polyfill.permissions = new PermissionManager(injector);
39028
+ polyfill.CredentialHandlers = new CredentialHandlers(injector);
39029
+ polyfill.CredentialHandler = CredentialHandler;
39030
+ polyfill.CredentialManager = CredentialManager;
39031
+ polyfill.credentials = new CredentialsContainer(injector);
39032
+ polyfill.WebCredential = WebCredential2;
39033
+ navigator.credentialsPolyfill = polyfill;
39034
+ if ("credentials" in navigator) {
39035
+ navigator.credentials.get = polyfill.credentials.get.bind(polyfill.credentials);
39036
+ navigator.credentials.store = polyfill.credentials.store.bind(polyfill.credentials);
39037
+ } else {
39038
+ navigator.credentials = polyfill.credentials;
39039
+ }
39040
+ window.CredentialManager = CredentialManager;
39041
+ window.WebCredential = WebCredential2;
39042
+ return polyfill;
39043
+ });
39044
+ }
39045
+ __name(load2, "load");
39046
+
39047
+ // ../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/CredentialEventProxy.js
39048
+ var PROXY_EVENT_TIMEOUT = 6e4;
39049
+ var CredentialEventProxy = class extends WebApp {
39050
+ constructor() {
39051
+ super(window.location.origin);
39052
+ }
39053
+ receive() {
39054
+ return __async(this, null, function* () {
39055
+ const self2 = this;
39056
+ yield self2.connect();
39057
+ return new Promise((resolveReceive, rejectReceive) => {
39058
+ const timeoutId = setTimeout(() => {
39059
+ rejectReceive(new Error("Timed out waiting to receive event."));
39060
+ }, PROXY_EVENT_TIMEOUT);
39061
+ self2.server.define("credentialEventProxy", {
39062
+ send(event) {
39063
+ return __async(this, null, function* () {
39064
+ resolveReceive(event);
39065
+ clearTimeout(timeoutId);
39066
+ return new Promise((resolveSend, rejectSend) => {
39067
+ event.respondWith = (promise) => {
39068
+ try {
39069
+ resolveSend(promise);
39070
+ } catch (e) {
39071
+ rejectSend(e);
39072
+ }
39073
+ };
39074
+ });
39075
+ });
39076
+ }
39077
+ });
39078
+ self2.ready();
39079
+ });
39080
+ });
39081
+ }
39082
+ };
39083
+ __name(CredentialEventProxy, "CredentialEventProxy");
39084
+
39085
+ // ../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/index.js
39086
+ var DEFAULT_MEDIATOR = "https://authn.io";
39087
+ function installHandler() {
39088
+ return __async(this, null, function* () {
39089
+ const CredentialManager2 = navigator.credentialsPolyfill.CredentialManager;
39090
+ const result = yield CredentialManager2.requestPermission();
39091
+ if (result !== "granted") {
39092
+ throw new Error("Permission denied.");
39093
+ }
39094
+ });
39095
+ }
39096
+ __name(installHandler, "installHandler");
39097
+ function activateHandler(_0) {
39098
+ return __async(this, arguments, function* ({
39099
+ mediatorOrigin = DEFAULT_MEDIATOR,
39100
+ get: get2,
39101
+ store
39102
+ }) {
39103
+ if (!(get2 || store)) {
39104
+ throw new Error('"get" or "store" function(s) must be specified.');
39105
+ }
39106
+ const CredentialHandler2 = navigator.credentialsPolyfill.CredentialHandler;
39107
+ const self2 = new CredentialHandler2(mediatorOrigin);
39108
+ if (get2) {
39109
+ if (typeof get2 !== "function") {
39110
+ throw new TypeError('"get" must be a function.');
39111
+ }
39112
+ self2.addEventListener("credentialrequest", (event) => listener({ event, get: get2 }));
39113
+ }
39114
+ if (store) {
39115
+ if (typeof store !== "function") {
39116
+ throw new TypeError('"store" must be a function.');
39117
+ }
39118
+ self2.addEventListener("credentialstore", (event) => listener({ event, store }));
39119
+ }
39120
+ yield self2.connect();
39121
+ });
39122
+ }
39123
+ __name(activateHandler, "activateHandler");
39124
+ function receiveCredentialEvent() {
39125
+ return __async(this, null, function* () {
39126
+ const proxy = new CredentialEventProxy();
39127
+ return proxy.receive();
39128
+ });
39129
+ }
39130
+ __name(receiveCredentialEvent, "receiveCredentialEvent");
39131
+ function listener({ event, get: get2, store }) {
39132
+ event.respondWith(createResponse({ event, get: get2, store }));
39133
+ }
39134
+ __name(listener, "listener");
39135
+ function createResponse(_0) {
39136
+ return __async(this, arguments, function* ({ event, get: get2, store }) {
39137
+ const result = yield (get2 || store)({ event });
39138
+ if (!(result && typeof result === "object")) {
39139
+ throw new TypeError('Return value of "get" or "store" hook must be an object.');
39140
+ }
39141
+ if (result.type === "response") {
39142
+ return { dataType: result.dataType, data: result.data };
39143
+ }
39144
+ if (result.type === "redirect") {
39145
+ const appContext = new WebAppContext();
39146
+ const handle = yield event.openWindow(result.url);
39147
+ const windowReady = appContext.createWindow(result.url, {
39148
+ handle,
39149
+ popup: false,
39150
+ timeout: 6e5
39151
+ });
39152
+ const injector = yield windowReady;
39153
+ const proxy = injector.get("credentialEventProxy", {
39154
+ functions: [{ name: "send", options: { timeout: 0 } }]
39155
+ });
39156
+ return proxy.send({
39157
+ type: event.type,
39158
+ credentialRequestOptions: event.credentialRequestOptions,
39159
+ credentialRequestOrigin: event.credentialRequestOrigin,
39160
+ credential: event.credential,
39161
+ hintKey: event.hintKey
39162
+ });
39163
+ }
39164
+ throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".');
39165
+ });
39166
+ }
39167
+ __name(createResponse, "createResponse");
39168
+
39169
+ // src/wallet/plugins/chapi/chapi.ts
39170
+ var getCHAPIPlugin = /* @__PURE__ */ __name(() => __async(void 0, null, function* () {
39171
+ if (typeof window === "undefined") {
39172
+ return {
39173
+ pluginMethods: {
39174
+ installChapiHandler: () => __async(void 0, null, function* () {
39175
+ throw new Error("CHAPI is only available inside of a browser!");
39176
+ }),
39177
+ activateChapiHandler: () => __async(void 0, null, function* () {
39178
+ throw new Error("CHAPI is only available inside of a browser!");
39179
+ }),
39180
+ receiveChapiEvent: () => __async(void 0, null, function* () {
39181
+ throw new Error("CHAPI is only available inside of a browser!");
39182
+ }),
39183
+ storeCredentialViaChapiDidAuth: () => __async(void 0, null, function* () {
39184
+ throw new Error("CHAPI is only available inside of a browser!");
39185
+ }),
39186
+ storePresentationViaChapi: () => __async(void 0, null, function* () {
39187
+ throw new Error("CHAPI is only available inside of a browser!");
39188
+ })
39189
+ }
39190
+ };
39191
+ }
39192
+ yield loadOnce();
39193
+ return {
39194
+ pluginMethods: {
39195
+ installChapiHandler: () => __async(void 0, null, function* () {
39196
+ return installHandler();
39197
+ }),
39198
+ activateChapiHandler: (_0, _1) => __async(void 0, [_0, _1], function* (_wallet, {
39199
+ mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,
39200
+ get: get2,
39201
+ store
39202
+ }) {
39203
+ return activateHandler({ mediatorOrigin, get: get2, store });
39204
+ }),
39205
+ receiveChapiEvent: () => __async(void 0, null, function* () {
39206
+ return receiveCredentialEvent();
39207
+ }),
39208
+ storeCredentialViaChapiDidAuth: (wallet, credential) => __async(void 0, null, function* () {
39209
+ var _a, _b, _c;
39210
+ const challenge = crypto.randomUUID();
39211
+ const domain = window.location.origin;
39212
+ const vpr = {
39213
+ web: {
39214
+ VerifiablePresentation: {
39215
+ query: { type: "DIDAuthentication" },
39216
+ challenge,
39217
+ domain
39218
+ }
39219
+ }
39220
+ };
39221
+ const res = yield navigator.credentials.get(vpr);
39222
+ if (!res)
39223
+ return { success: false, reason: "did not auth" };
39224
+ const verification = yield wallet.pluginMethods.verifyPresentation(res.data, {
39225
+ challenge,
39226
+ domain,
39227
+ proofPurpose: "authentication"
39228
+ });
39229
+ if (verification.warnings.length > 0 || verification.errors.length > 0) {
39230
+ return { success: false, reason: "auth failed verification" };
39231
+ }
39232
+ const subject = (_c = (_b = (_a = res.data) == null ? void 0 : _a.proof) == null ? void 0 : _b.verificationMethod) == null ? void 0 : _c.split("#")[0];
39233
+ if (!Array.isArray(credential.credentialSubject)) {
39234
+ credential.credentialSubject.id = subject;
39235
+ }
39236
+ const vp = yield wallet.pluginMethods.getTestVp(yield wallet.pluginMethods.issueCredential(credential));
39237
+ const success = yield wallet.pluginMethods.storePresentationViaChapi(vp);
39238
+ if (success)
39239
+ return { success: true };
39240
+ return { success: false, reason: "did not store" };
39241
+ }),
39242
+ storePresentationViaChapi: (_wallet, presentation) => __async(void 0, null, function* () {
39243
+ const wc = new WebCredential("VerifiablePresentation", presentation);
39244
+ return window.navigator.credentials.store(wc);
39245
+ })
39246
+ }
39247
+ };
39248
+ }), "getCHAPIPlugin");
36131
39249
 
36132
39250
  // src/wallet/plugins/vc-templates/templates.ts
36133
39251
  var VC_TEMPLATES = {
@@ -36176,9 +39294,9 @@ var VC_TEMPLATES = {
36176
39294
  };
36177
39295
 
36178
39296
  // src/wallet/plugins/vc-templates/vc-templates.ts
36179
- var getVCTemplatesPlugin = /* @__PURE__ */ __name((wallet) => {
39297
+ var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
36180
39298
  return {
36181
- pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
39299
+ pluginMethods: {
36182
39300
  newCredential: (_wallet, args = { type: "basic" }) => {
36183
39301
  var _a, _b;
36184
39302
  const did = args.did || ((_b = (_a = _wallet.pluginMethods).getSubjectDid) == null ? void 0 : _b.call(_a, "key"));
@@ -36206,7 +39324,7 @@ var getVCTemplatesPlugin = /* @__PURE__ */ __name((wallet) => {
36206
39324
  verifiableCredential: credential
36207
39325
  };
36208
39326
  })
36209
- })
39327
+ }
36210
39328
  };
36211
39329
  }, "getVCTemplatesPlugin");
36212
39330
 
@@ -39266,6 +42384,13 @@ var IDXCredentialValidator = mod.object({
39266
42384
  title: mod.string(),
39267
42385
  storageType: StorageTypeValidator.optional()
39268
42386
  });
42387
+ var JWKValidator = mod.object({
42388
+ kty: mod.string(),
42389
+ crv: mod.string(),
42390
+ x: mod.string(),
42391
+ y: mod.string().optional(),
42392
+ d: mod.string()
42393
+ });
39269
42394
 
39270
42395
  // ../../node_modules/.pnpm/date-fns@2.28.0/node_modules/date-fns/esm/_lib/toInteger/index.js
39271
42396
  function toInteger(dirtyNumber) {
@@ -40879,14 +44004,20 @@ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
40879
44004
  var emptyWallet = /* @__PURE__ */ __name((..._0) => __async(void 0, [..._0], function* ({ didkit } = {}) {
40880
44005
  const didkitWallet = yield (yield generateWallet()).addPlugin(yield getDidKitPlugin(didkit));
40881
44006
  const expirationWallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
40882
- const wallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin(expirationWallet));
44007
+ const templatesWallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin());
44008
+ const wallet = yield templatesWallet.addPlugin(yield getCHAPIPlugin());
40883
44009
  return {
40884
44010
  _wallet: wallet,
40885
44011
  newCredential: wallet.pluginMethods.newCredential,
40886
44012
  newPresentation: wallet.pluginMethods.newPresentation,
40887
44013
  verifyCredential: verifyCredential2(wallet),
40888
44014
  verifyPresentation: wallet.pluginMethods.verifyPresentation,
40889
- resolveDid: wallet.pluginMethods.resolveDid
44015
+ resolveDid: wallet.pluginMethods.resolveDid,
44016
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
44017
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
44018
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
44019
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
44020
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
40890
44021
  };
40891
44022
  }), "emptyWallet");
40892
44023
 
@@ -48889,75 +52020,75 @@ var PatchError = function(_super) {
48889
52020
  var JsonPatchError = PatchError;
48890
52021
  var deepClone = _deepClone;
48891
52022
  var objOps = {
48892
- add: function(obj, key2, document) {
52023
+ add: function(obj, key2, document2) {
48893
52024
  obj[key2] = this.value;
48894
- return { newDocument: document };
52025
+ return { newDocument: document2 };
48895
52026
  },
48896
- remove: function(obj, key2, document) {
52027
+ remove: function(obj, key2, document2) {
48897
52028
  var removed = obj[key2];
48898
52029
  delete obj[key2];
48899
- return { newDocument: document, removed };
52030
+ return { newDocument: document2, removed };
48900
52031
  },
48901
- replace: function(obj, key2, document) {
52032
+ replace: function(obj, key2, document2) {
48902
52033
  var removed = obj[key2];
48903
52034
  obj[key2] = this.value;
48904
- return { newDocument: document, removed };
52035
+ return { newDocument: document2, removed };
48905
52036
  },
48906
- move: function(obj, key2, document) {
48907
- var removed = getValueByPointer(document, this.path);
52037
+ move: function(obj, key2, document2) {
52038
+ var removed = getValueByPointer(document2, this.path);
48908
52039
  if (removed) {
48909
52040
  removed = _deepClone(removed);
48910
52041
  }
48911
- var originalValue = applyOperation(document, { op: "remove", path: this.from }).removed;
48912
- applyOperation(document, { op: "add", path: this.path, value: originalValue });
48913
- return { newDocument: document, removed };
52042
+ var originalValue = applyOperation(document2, { op: "remove", path: this.from }).removed;
52043
+ applyOperation(document2, { op: "add", path: this.path, value: originalValue });
52044
+ return { newDocument: document2, removed };
48914
52045
  },
48915
- copy: function(obj, key2, document) {
48916
- var valueToCopy = getValueByPointer(document, this.from);
48917
- applyOperation(document, { op: "add", path: this.path, value: _deepClone(valueToCopy) });
48918
- return { newDocument: document };
52046
+ copy: function(obj, key2, document2) {
52047
+ var valueToCopy = getValueByPointer(document2, this.from);
52048
+ applyOperation(document2, { op: "add", path: this.path, value: _deepClone(valueToCopy) });
52049
+ return { newDocument: document2 };
48919
52050
  },
48920
- test: function(obj, key2, document) {
48921
- return { newDocument: document, test: _areEquals(obj[key2], this.value) };
52051
+ test: function(obj, key2, document2) {
52052
+ return { newDocument: document2, test: _areEquals(obj[key2], this.value) };
48922
52053
  },
48923
- _get: function(obj, key2, document) {
52054
+ _get: function(obj, key2, document2) {
48924
52055
  this.value = obj[key2];
48925
- return { newDocument: document };
52056
+ return { newDocument: document2 };
48926
52057
  }
48927
52058
  };
48928
52059
  var arrOps = {
48929
- add: function(arr, i, document) {
52060
+ add: function(arr, i, document2) {
48930
52061
  if (isInteger2(i)) {
48931
52062
  arr.splice(i, 0, this.value);
48932
52063
  } else {
48933
52064
  arr[i] = this.value;
48934
52065
  }
48935
- return { newDocument: document, index: i };
52066
+ return { newDocument: document2, index: i };
48936
52067
  },
48937
- remove: function(arr, i, document) {
52068
+ remove: function(arr, i, document2) {
48938
52069
  var removedList = arr.splice(i, 1);
48939
- return { newDocument: document, removed: removedList[0] };
52070
+ return { newDocument: document2, removed: removedList[0] };
48940
52071
  },
48941
- replace: function(arr, i, document) {
52072
+ replace: function(arr, i, document2) {
48942
52073
  var removed = arr[i];
48943
52074
  arr[i] = this.value;
48944
- return { newDocument: document, removed };
52075
+ return { newDocument: document2, removed };
48945
52076
  },
48946
52077
  move: objOps.move,
48947
52078
  copy: objOps.copy,
48948
52079
  test: objOps.test,
48949
52080
  _get: objOps._get
48950
52081
  };
48951
- function getValueByPointer(document, pointer) {
52082
+ function getValueByPointer(document2, pointer) {
48952
52083
  if (pointer == "") {
48953
- return document;
52084
+ return document2;
48954
52085
  }
48955
52086
  var getOriginalDestination = { op: "_get", path: pointer };
48956
- applyOperation(document, getOriginalDestination);
52087
+ applyOperation(document2, getOriginalDestination);
48957
52088
  return getOriginalDestination.value;
48958
52089
  }
48959
52090
  __name(getValueByPointer, "getValueByPointer");
48960
- function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
52091
+ function applyOperation(document2, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
48961
52092
  if (validateOperation === void 0) {
48962
52093
  validateOperation = false;
48963
52094
  }
@@ -48972,54 +52103,54 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
48972
52103
  }
48973
52104
  if (validateOperation) {
48974
52105
  if (typeof validateOperation == "function") {
48975
- validateOperation(operation, 0, document, operation.path);
52106
+ validateOperation(operation, 0, document2, operation.path);
48976
52107
  } else {
48977
52108
  validator(operation, 0);
48978
52109
  }
48979
52110
  }
48980
52111
  if (operation.path === "") {
48981
- var returnValue = { newDocument: document };
52112
+ var returnValue = { newDocument: document2 };
48982
52113
  if (operation.op === "add") {
48983
52114
  returnValue.newDocument = operation.value;
48984
52115
  return returnValue;
48985
52116
  } else if (operation.op === "replace") {
48986
52117
  returnValue.newDocument = operation.value;
48987
- returnValue.removed = document;
52118
+ returnValue.removed = document2;
48988
52119
  return returnValue;
48989
52120
  } else if (operation.op === "move" || operation.op === "copy") {
48990
- returnValue.newDocument = getValueByPointer(document, operation.from);
52121
+ returnValue.newDocument = getValueByPointer(document2, operation.from);
48991
52122
  if (operation.op === "move") {
48992
- returnValue.removed = document;
52123
+ returnValue.removed = document2;
48993
52124
  }
48994
52125
  return returnValue;
48995
52126
  } else if (operation.op === "test") {
48996
- returnValue.test = _areEquals(document, operation.value);
52127
+ returnValue.test = _areEquals(document2, operation.value);
48997
52128
  if (returnValue.test === false) {
48998
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52129
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
48999
52130
  }
49000
- returnValue.newDocument = document;
52131
+ returnValue.newDocument = document2;
49001
52132
  return returnValue;
49002
52133
  } else if (operation.op === "remove") {
49003
- returnValue.removed = document;
52134
+ returnValue.removed = document2;
49004
52135
  returnValue.newDocument = null;
49005
52136
  return returnValue;
49006
52137
  } else if (operation.op === "_get") {
49007
- operation.value = document;
52138
+ operation.value = document2;
49008
52139
  return returnValue;
49009
52140
  } else {
49010
52141
  if (validateOperation) {
49011
- throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
52142
+ throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document2);
49012
52143
  } else {
49013
52144
  return returnValue;
49014
52145
  }
49015
52146
  }
49016
52147
  } else {
49017
52148
  if (!mutateDocument) {
49018
- document = _deepClone(document);
52149
+ document2 = _deepClone(document2);
49019
52150
  }
49020
52151
  var path = operation.path || "";
49021
52152
  var keys = path.split("/");
49022
- var obj = document;
52153
+ var obj = document2;
49023
52154
  var t = 1;
49024
52155
  var len = keys.length;
49025
52156
  var existingPathFragment = void 0;
@@ -49046,7 +52177,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
49046
52177
  existingPathFragment = operation.path;
49047
52178
  }
49048
52179
  if (existingPathFragment !== void 0) {
49049
- validateFunction(operation, 0, document, existingPathFragment);
52180
+ validateFunction(operation, 0, document2, existingPathFragment);
49050
52181
  }
49051
52182
  }
49052
52183
  }
@@ -49056,39 +52187,39 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
49056
52187
  key2 = obj.length;
49057
52188
  } else {
49058
52189
  if (validateOperation && !isInteger2(key2)) {
49059
- 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);
52190
+ 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);
49060
52191
  } else if (isInteger2(key2)) {
49061
52192
  key2 = ~~key2;
49062
52193
  }
49063
52194
  }
49064
52195
  if (t >= len) {
49065
52196
  if (validateOperation && operation.op === "add" && key2 > obj.length) {
49066
- 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);
52197
+ 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);
49067
52198
  }
49068
- var returnValue = arrOps[operation.op].call(operation, obj, key2, document);
52199
+ var returnValue = arrOps[operation.op].call(operation, obj, key2, document2);
49069
52200
  if (returnValue.test === false) {
49070
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52201
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49071
52202
  }
49072
52203
  return returnValue;
49073
52204
  }
49074
52205
  } else {
49075
52206
  if (t >= len) {
49076
- var returnValue = objOps[operation.op].call(operation, obj, key2, document);
52207
+ var returnValue = objOps[operation.op].call(operation, obj, key2, document2);
49077
52208
  if (returnValue.test === false) {
49078
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52209
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49079
52210
  }
49080
52211
  return returnValue;
49081
52212
  }
49082
52213
  }
49083
52214
  obj = obj[key2];
49084
52215
  if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
49085
- throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
52216
+ throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document2);
49086
52217
  }
49087
52218
  }
49088
52219
  }
49089
52220
  }
49090
52221
  __name(applyOperation, "applyOperation");
49091
- function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
52222
+ function applyPatch(document2, patch, validateOperation, mutateDocument, banPrototypeModifications) {
49092
52223
  if (mutateDocument === void 0) {
49093
52224
  mutateDocument = true;
49094
52225
  }
@@ -49101,72 +52232,72 @@ function applyPatch(document, patch, validateOperation, mutateDocument, banProto
49101
52232
  }
49102
52233
  }
49103
52234
  if (!mutateDocument) {
49104
- document = _deepClone(document);
52235
+ document2 = _deepClone(document2);
49105
52236
  }
49106
52237
  var results = new Array(patch.length);
49107
52238
  for (var i = 0, length_1 = patch.length; i < length_1; i++) {
49108
- results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
49109
- document = results[i].newDocument;
52239
+ results[i] = applyOperation(document2, patch[i], validateOperation, true, banPrototypeModifications, i);
52240
+ document2 = results[i].newDocument;
49110
52241
  }
49111
- results.newDocument = document;
52242
+ results.newDocument = document2;
49112
52243
  return results;
49113
52244
  }
49114
52245
  __name(applyPatch, "applyPatch");
49115
- function applyReducer(document, operation, index) {
49116
- var operationResult = applyOperation(document, operation);
52246
+ function applyReducer(document2, operation, index) {
52247
+ var operationResult = applyOperation(document2, operation);
49117
52248
  if (operationResult.test === false) {
49118
- throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
52249
+ throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document2);
49119
52250
  }
49120
52251
  return operationResult.newDocument;
49121
52252
  }
49122
52253
  __name(applyReducer, "applyReducer");
49123
- function validator(operation, index, document, existingPathFragment) {
52254
+ function validator(operation, index, document2, existingPathFragment) {
49124
52255
  if (typeof operation !== "object" || operation === null || Array.isArray(operation)) {
49125
- throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document);
52256
+ throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document2);
49126
52257
  } else if (!objOps[operation.op]) {
49127
- throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
52258
+ throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document2);
49128
52259
  } else if (typeof operation.path !== "string") {
49129
- throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document);
52260
+ throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document2);
49130
52261
  } else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) {
49131
- throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document);
52262
+ throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document2);
49132
52263
  } else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") {
49133
- throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document);
52264
+ throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document2);
49134
52265
  } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) {
49135
- throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document);
52266
+ throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document2);
49136
52267
  } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && hasUndefined(operation.value)) {
49137
- throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document);
49138
- } else if (document) {
52268
+ throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document2);
52269
+ } else if (document2) {
49139
52270
  if (operation.op == "add") {
49140
52271
  var pathLen = operation.path.split("/").length;
49141
52272
  var existingPathLen = existingPathFragment.split("/").length;
49142
52273
  if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
49143
- throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document);
52274
+ throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document2);
49144
52275
  }
49145
52276
  } else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") {
49146
52277
  if (operation.path !== existingPathFragment) {
49147
- throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
52278
+ throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document2);
49148
52279
  }
49149
52280
  } else if (operation.op === "move" || operation.op === "copy") {
49150
52281
  var existingValue = { op: "_get", path: operation.from, value: void 0 };
49151
- var error = validate5([existingValue], document);
52282
+ var error = validate5([existingValue], document2);
49152
52283
  if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") {
49153
- throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document);
52284
+ throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document2);
49154
52285
  }
49155
52286
  }
49156
52287
  }
49157
52288
  }
49158
52289
  __name(validator, "validator");
49159
- function validate5(sequence, document, externalValidator) {
52290
+ function validate5(sequence, document2, externalValidator) {
49160
52291
  try {
49161
52292
  if (!Array.isArray(sequence)) {
49162
52293
  throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
49163
52294
  }
49164
- if (document) {
49165
- applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);
52295
+ if (document2) {
52296
+ applyPatch(_deepClone(document2), _deepClone(sequence), externalValidator || true);
49166
52297
  } else {
49167
52298
  externalValidator = externalValidator || validator;
49168
52299
  for (var i = 0; i < sequence.length; i++) {
49169
- externalValidator(sequence[i], i, document, void 0);
52300
+ externalValidator(sequence[i], i, document2, void 0);
49170
52301
  }
49171
52302
  }
49172
52303
  } catch (e) {
@@ -49394,11 +52525,11 @@ var fast_json_patch_default = Object.assign({}, core_exports, duplex_exports, {
49394
52525
  unescapePathComponent
49395
52526
  });
49396
52527
 
49397
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
52528
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
49398
52529
  var import_lodash3 = __toESM(require_lodash(), 1);
49399
52530
  var import_random3 = __toESM(require_random(), 1);
49400
52531
 
49401
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/streamopts.js
52532
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/streamopts.js
49402
52533
  var SyncOptions;
49403
52534
  (function(SyncOptions2) {
49404
52535
  SyncOptions2[SyncOptions2["PREFER_CACHE"] = 0] = "PREFER_CACHE";
@@ -49406,7 +52537,7 @@ var SyncOptions;
49406
52537
  SyncOptions2[SyncOptions2["NEVER_SYNC"] = 2] = "NEVER_SYNC";
49407
52538
  })(SyncOptions || (SyncOptions = {}));
49408
52539
 
49409
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream.js
52540
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream.js
49410
52541
  var import_lodash = __toESM(require_lodash(), 1);
49411
52542
 
49412
52543
  // ../../node_modules/.pnpm/tslib@2.4.0/node_modules/tslib/modules/index.js
@@ -51300,7 +54431,7 @@ function throttle(durationSelector, config2) {
51300
54431
  }
51301
54432
  __name(throttle, "throttle");
51302
54433
 
51303
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream.js
54434
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream.js
51304
54435
  var SignatureStatus;
51305
54436
  (function(SignatureStatus2) {
51306
54437
  SignatureStatus2[SignatureStatus2["GENESIS"] = 0] = "GENESIS";
@@ -51379,10 +54510,10 @@ function StreamStatic() {
51379
54510
  }
51380
54511
  __name(StreamStatic, "StreamStatic");
51381
54512
 
51382
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
54513
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
51383
54514
  var import_cross_fetch = __toESM(require("cross-fetch"), 1);
51384
54515
 
51385
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/abort-signal-utils.js
54516
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/abort-signal-utils.js
51386
54517
  function mergeAbortSignals(signals) {
51387
54518
  const controller = new AbortController();
51388
54519
  if (signals.length === 0) {
@@ -51432,7 +54563,7 @@ function abortable2(original, fn) {
51432
54563
  }
51433
54564
  __name(abortable2, "abortable");
51434
54565
 
51435
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
54566
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/http-utils.js
51436
54567
  var DEFAULT_FETCH_TIMEOUT = 60 * 1e3 * 3;
51437
54568
  function fetchJson(_0) {
51438
54569
  return __async(this, arguments, function* (url, opts = {}) {
@@ -51457,10 +54588,10 @@ function fetchJson(_0) {
51457
54588
  }
51458
54589
  __name(fetchJson, "fetchJson");
51459
54590
 
51460
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
54591
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
51461
54592
  var import_lodash2 = __toESM(require_lodash(), 1);
51462
54593
 
51463
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/cid-utils.js
54594
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/cid-utils.js
51464
54595
  init_cid();
51465
54596
  function toCID(givenCid) {
51466
54597
  const cid = CID.asCID(givenCid);
@@ -51477,7 +54608,7 @@ function toCID(givenCid) {
51477
54608
  }
51478
54609
  __name(toCID, "toCID");
51479
54610
 
51480
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
54611
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/stream-utils.js
51481
54612
  var TILE_TYPE_ID = 0;
51482
54613
  var StreamUtils = class {
51483
54614
  static streamIdFromState(state) {
@@ -51657,7 +54788,7 @@ var StreamUtils = class {
51657
54788
  };
51658
54789
  __name(StreamUtils, "StreamUtils");
51659
54790
 
51660
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/utils/accountid-utils.js
54791
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/utils/accountid-utils.js
51661
54792
  function normalizeAccountId(accountId) {
51662
54793
  if (typeof accountId === "string" && accountId.includes("@")) {
51663
54794
  const [address, chainId] = accountId.split("@");
@@ -51670,7 +54801,7 @@ function normalizeAccountId(accountId) {
51670
54801
  }
51671
54802
  __name(normalizeAccountId, "normalizeAccountId");
51672
54803
 
51673
- // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0/node_modules/@ceramicnetwork/common/lib/stream-state-subject.js
54804
+ // ../../node_modules/.pnpm/@ceramicnetwork+common@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/common/lib/stream-state-subject.js
51674
54805
  var StreamStateSubject = class extends BehaviorSubject {
51675
54806
  next(next) {
51676
54807
  const current = this.value;
@@ -51681,7 +54812,7 @@ var StreamStateSubject = class extends BehaviorSubject {
51681
54812
  };
51682
54813
  __name(StreamStateSubject, "StreamStateSubject");
51683
54814
 
51684
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
54815
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-tile@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-tile/lib/tile-document.js
51685
54816
  var __decorate4 = function(decorators, target, key2, desc) {
51686
54817
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
51687
54818
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -51917,7 +55048,7 @@ TileDocument = TileDocument_1 = __decorate4([
51917
55048
  StreamStatic()
51918
55049
  ], TileDocument);
51919
55050
 
51920
- // ../../node_modules/.pnpm/@glazed+tile-loader@0.2.1/node_modules/@glazed/tile-loader/dist/index.js
55051
+ // ../../node_modules/.pnpm/@glazed+tile-loader@0.2.1_@opentelemetry+api@1.1.0/node_modules/@glazed/tile-loader/dist/index.js
51921
55052
  var import_dataloader = __toESM(require_dataloader(), 1);
51922
55053
  function _checkPrivateRedeclaration2(obj, privateCollection) {
51923
55054
  if (privateCollection.has(obj)) {
@@ -52076,7 +55207,7 @@ var TileLoader = class extends import_dataloader.default {
52076
55207
  };
52077
55208
  __name(TileLoader, "TileLoader");
52078
55209
 
52079
- // ../../node_modules/.pnpm/@glazed+datamodel@0.3.1/node_modules/@glazed/datamodel/dist/index.js
55210
+ // ../../node_modules/.pnpm/@glazed+datamodel@0.3.1_@opentelemetry+api@1.1.0/node_modules/@glazed/datamodel/dist/index.js
52080
55211
  function _checkPrivateRedeclaration3(obj, privateCollection) {
52081
55212
  if (privateCollection.has(obj)) {
52082
55213
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52196,7 +55327,7 @@ var DataModel = class {
52196
55327
  };
52197
55328
  __name(DataModel, "DataModel");
52198
55329
 
52199
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/proxy.js
55330
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/proxy.js
52200
55331
  function _checkPrivateRedeclaration4(obj, privateCollection) {
52201
55332
  if (privateCollection.has(obj)) {
52202
55333
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52342,7 +55473,7 @@ var TileProxy = class {
52342
55473
  };
52343
55474
  __name(TileProxy, "TileProxy");
52344
55475
 
52345
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/utils.js
55476
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/utils.js
52346
55477
  var didRegex = /^did:([A-Za-z0-9]+):([A-Za-z0-9.\-:_]+)$/;
52347
55478
  function isDIDstring(did) {
52348
55479
  return didRegex.test(did);
@@ -52365,7 +55496,7 @@ function getIDXMetadata(did) {
52365
55496
  }
52366
55497
  __name(getIDXMetadata, "getIDXMetadata");
52367
55498
 
52368
- // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2/node_modules/@glazed/did-datastore/dist/index.js
55499
+ // ../../node_modules/.pnpm/@glazed+did-datastore@0.3.2_@opentelemetry+api@1.1.0/node_modules/@glazed/did-datastore/dist/index.js
52369
55500
  function _checkPrivateRedeclaration5(obj, privateCollection) {
52370
55501
  if (privateCollection.has(obj)) {
52371
55502
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -52762,13 +55893,13 @@ var DIDDataStore = class {
52762
55893
  };
52763
55894
  __name(DIDDataStore, "DIDDataStore");
52764
55895
 
52765
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/utils.js
55896
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/utils.js
52766
55897
  function typeStreamID(streamId) {
52767
55898
  return typeof streamId === "string" ? StreamID.fromString(streamId) : streamId;
52768
55899
  }
52769
55900
  __name(typeStreamID, "typeStreamID");
52770
55901
 
52771
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/document.js
55902
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/document.js
52772
55903
  var Document = class extends Observable {
52773
55904
  constructor(initial, _apiUrl, syncInterval) {
52774
55905
  super((subscriber) => {
@@ -52867,7 +55998,7 @@ var Document = class extends Observable {
52867
55998
  };
52868
55999
  __name(Document, "Document");
52869
56000
 
52870
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-caip10-link@2.1.0/node_modules/@ceramicnetwork/stream-caip10-link/lib/caip10-link.js
56001
+ // ../../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
52871
56002
  var import_lodash4 = __toESM(require_lodash(), 1);
52872
56003
  var __decorate5 = function(decorators, target, key2, desc) {
52873
56004
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
@@ -52986,7 +56117,7 @@ Caip10Link = Caip10Link_1 = __decorate5([
52986
56117
  StreamStatic()
52987
56118
  ], Caip10Link);
52988
56119
 
52989
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-model@0.3.0/node_modules/@ceramicnetwork/stream-model/lib/model.js
56120
+ // ../../node_modules/.pnpm/@ceramicnetwork+stream-model@0.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/stream-model/lib/model.js
52990
56121
  var import_random4 = __toESM(require_random(), 1);
52991
56122
  init_cid();
52992
56123
  init_digest();
@@ -53187,7 +56318,7 @@ Model = Model_1 = __decorate6([
53187
56318
  StreamStatic()
53188
56319
  ], Model);
53189
56320
 
53190
- // ../../node_modules/.pnpm/@ceramicnetwork+stream-model-instance@0.3.0/node_modules/@ceramicnetwork/stream-model-instance/lib/model-instance-document.js
56321
+ // ../../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
53191
56322
  var import_random5 = __toESM(require_random(), 1);
53192
56323
  var __decorate7 = function(decorators, target, key2, desc) {
53193
56324
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
@@ -53342,7 +56473,7 @@ ModelInstanceDocument = ModelInstanceDocument_1 = __decorate7([
53342
56473
  StreamStatic()
53343
56474
  ], ModelInstanceDocument);
53344
56475
 
53345
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/remote-pin-api.js
56476
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/remote-pin-api.js
53346
56477
  var RemotePinApi = class {
53347
56478
  constructor(_apiUrl) {
53348
56479
  this._apiUrl = _apiUrl;
@@ -53395,7 +56526,7 @@ var RemotePinApi = class {
53395
56526
  };
53396
56527
  __name(RemotePinApi, "RemotePinApi");
53397
56528
 
53398
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/remote-index-api.js
56529
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/remote-index-api.js
53399
56530
  var RemoteIndexApi = class {
53400
56531
  constructor(apiUrl) {
53401
56532
  this._fetchJson = fetchJson;
@@ -53423,7 +56554,7 @@ var RemoteIndexApi = class {
53423
56554
  };
53424
56555
  __name(RemoteIndexApi, "RemoteIndexApi");
53425
56556
 
53426
- // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js
56557
+ // ../../node_modules/.pnpm/@ceramicnetwork+http-client@2.3.0_@opentelemetry+api@1.1.0/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js
53427
56558
  var API_PATH = "/api/v0/";
53428
56559
  var CERAMIC_HOST = "http://localhost:7007";
53429
56560
  var DEFAULT_CLIENT_CONFIG = {
@@ -53517,14 +56648,14 @@ var CeramicClient = class {
53517
56648
  return __async(this, arguments, function* (streamId, commit, opts = {}) {
53518
56649
  opts = __spreadValues(__spreadValues({}, DEFAULT_APPLY_COMMIT_OPTS), opts);
53519
56650
  const effectiveStreamId = typeStreamID(streamId);
53520
- const document = yield Document.applyCommit(this._apiUrl, effectiveStreamId, commit, opts, this._config.syncInterval);
56651
+ const document2 = yield Document.applyCommit(this._apiUrl, effectiveStreamId, commit, opts, this._config.syncInterval);
53521
56652
  const fromCache = this._streamCache.get(effectiveStreamId.toString());
53522
56653
  if (fromCache) {
53523
- fromCache.next(document.state);
53524
- return this.buildStreamFromDocument(document);
56654
+ fromCache.next(document2.state);
56655
+ return this.buildStreamFromDocument(document2);
53525
56656
  } else {
53526
- this._streamCache.set(effectiveStreamId.toString(), document);
53527
- return this.buildStreamFromDocument(document);
56657
+ this._streamCache.set(effectiveStreamId.toString(), document2);
56658
+ return this.buildStreamFromDocument(document2);
53528
56659
  }
53529
56660
  });
53530
56661
  }
@@ -53691,6 +56822,11 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53691
56822
  };
53692
56823
  }), "getIDXPlugin");
53693
56824
 
56825
+ // ../learn-card-helpers/dist/helpers.esm.js
56826
+ var __defProp2 = Object.defineProperty;
56827
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
56828
+ var isHex = /* @__PURE__ */ __name2((str) => /^[0-9a-f]+$/i.test(str), "isHex");
56829
+
53694
56830
  // src/wallet/plugins/didkey/helpers.ts
53695
56831
  var ED25519_METHODS = ["key", "tz", "pkh:tz", "pkh:tezos", "pkh:sol", "pkh:solana"];
53696
56832
  var SECP256K1_METHODS = [
@@ -53707,7 +56843,6 @@ var SECP256K1_METHODS = [
53707
56843
  "pkh:eip155",
53708
56844
  "pkh:bip122"
53709
56845
  ];
53710
- var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
53711
56846
  var getAlgorithmForDidMethod = /* @__PURE__ */ __name((didMethod) => {
53712
56847
  if (ED25519_METHODS.includes(didMethod))
53713
56848
  return "ed25519";
@@ -53758,50 +56893,50 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async(void 0, n
53758
56893
 
53759
56894
  // src/wallet/plugins/vc/issueCredential.ts
53760
56895
  var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
53761
- return (wallet, credential) => __async(void 0, null, function* () {
56896
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (wallet, credential, signingOptions = {}) {
53762
56897
  const kp = wallet.pluginMethods.getSubjectKeypair();
53763
56898
  if (!kp)
53764
56899
  throw new Error("Cannot issue credential: Could not get subject keypair");
53765
- const options = {
56900
+ const options = __spreadValues({
53766
56901
  verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
53767
56902
  proofPurpose: "assertionMethod"
53768
- };
56903
+ }, signingOptions);
53769
56904
  return initWallet.pluginMethods.issueCredential(credential, options, kp);
53770
56905
  });
53771
56906
  }, "issueCredential");
53772
56907
 
53773
56908
  // src/wallet/plugins/vc/verifyCredential.ts
53774
56909
  var verifyCredential3 = /* @__PURE__ */ __name((initWallet) => {
53775
- return (_wallet, credential) => __async(void 0, null, function* () {
53776
- return initWallet.pluginMethods.verifyCredential(credential);
56910
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, options = {}) {
56911
+ return initWallet.pluginMethods.verifyCredential(credential, options);
53777
56912
  });
53778
56913
  }, "verifyCredential");
53779
56914
 
53780
56915
  // src/wallet/plugins/vc/issuePresentation.ts
53781
56916
  var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
53782
- return (wallet, presentation) => __async(void 0, null, function* () {
56917
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (wallet, presentation, signingOptions = {}) {
53783
56918
  const kp = wallet.pluginMethods.getSubjectKeypair();
53784
56919
  if (!kp)
53785
56920
  throw new Error("Cannot issue credential: Could not get subject keypair");
53786
- const options = {
56921
+ const options = __spreadValues({
53787
56922
  verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
53788
56923
  proofPurpose: "assertionMethod"
53789
- };
56924
+ }, signingOptions);
53790
56925
  return initWallet.pluginMethods.issuePresentation(presentation, options, kp);
53791
56926
  });
53792
56927
  }, "issuePresentation");
53793
56928
 
53794
56929
  // src/wallet/plugins/vc/verifyPresentation.ts
53795
56930
  var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
53796
- return (_wallet, presentation) => __async(void 0, null, function* () {
53797
- return initWallet.pluginMethods.verifyPresentation(presentation);
56931
+ return (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, presentation, options = {}) {
56932
+ return initWallet.pluginMethods.verifyPresentation(presentation, options);
53798
56933
  });
53799
56934
  }, "verifyPresentation");
53800
56935
 
53801
56936
  // src/wallet/plugins/vc/vc.ts
53802
56937
  var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
53803
56938
  return {
53804
- pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
56939
+ pluginMethods: {
53805
56940
  issueCredential: issueCredential2(wallet),
53806
56941
  verifyCredential: verifyCredential3(wallet),
53807
56942
  issuePresentation: issuePresentation2(wallet),
@@ -53827,11 +56962,12 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
53827
56962
  verifiableCredential: credential
53828
56963
  };
53829
56964
  })
53830
- })
56965
+ }
53831
56966
  };
53832
56967
  }, "getVCPlugin");
53833
56968
 
53834
56969
  // src/wallet/plugins/EthereumPlugin/index.ts
56970
+ var import_buffer = __toESM(require_buffer2());
53835
56971
  var import_ethers2 = require("ethers");
53836
56972
 
53837
56973
  // src/wallet/plugins/EthereumPlugin/helpers.ts
@@ -53899,7 +57035,7 @@ var ERC20ABI = require_erc20_abi();
53899
57035
  var getEthereumPlugin = /* @__PURE__ */ __name((initWallet, config2) => {
53900
57036
  let { infuraProjectId, network = "mainnet" } = config2;
53901
57037
  const secpKeypair = initWallet.pluginMethods.getSubjectKeypair("secp256k1");
53902
- const privateKey = Buffer.from(secpKeypair.d, "base64").toString("hex");
57038
+ const privateKey = import_buffer.Buffer.from(secpKeypair.d, "base64").toString("hex");
53903
57039
  let ethersWallet = new import_ethers2.ethers.Wallet(privateKey);
53904
57040
  const publicKey = ethersWallet.address;
53905
57041
  const getProvider = /* @__PURE__ */ __name(() => {
@@ -54638,11 +57774,11 @@ var Transformer = class {
54638
57774
  }
54639
57775
  _getDocument(_0) {
54640
57776
  return __async(this, arguments, function* ({ url }) {
54641
- const { document } = yield this.documentLoader(url);
54642
- if (typeof document === "string") {
54643
- return JSON.parse(document);
57777
+ const { document: document2 } = yield this.documentLoader(url);
57778
+ if (typeof document2 === "string") {
57779
+ return JSON.parse(document2);
54644
57780
  }
54645
- return document;
57781
+ return document2;
54646
57782
  });
54647
57783
  }
54648
57784
  _getTermType({ activeCtx, def }) {
@@ -57181,11 +60317,12 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57181
60317
  const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
57182
60318
  const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
57183
60319
  const didkeyAndVCWallet = yield didkeyWallet.addPlugin(getVCPlugin(didkeyWallet));
57184
- const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin(didkeyAndVCWallet));
60320
+ const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin());
57185
60321
  const idxWallet = yield templateWallet.addPlugin(yield getIDXPlugin(templateWallet, ceramicIdx));
57186
60322
  const expirationWallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
57187
60323
  const ethWallet = yield expirationWallet.addPlugin(getEthereumPlugin(expirationWallet, ethereumConfig));
57188
- const wallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
60324
+ const vpqrWallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
60325
+ const wallet = yield vpqrWallet.addPlugin(yield getCHAPIPlugin());
57189
60326
  return {
57190
60327
  _wallet: wallet,
57191
60328
  did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
@@ -57220,21 +60357,187 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57220
60357
  transferTokens: wallet.pluginMethods.transferTokens,
57221
60358
  getCurrentNetwork: wallet.pluginMethods.getCurrentNetwork,
57222
60359
  changeNetwork: wallet.pluginMethods.changeNetwork,
57223
- addInfuraProjectId: wallet.pluginMethods.addInfuraProjectId
60360
+ addInfuraProjectId: wallet.pluginMethods.addInfuraProjectId,
60361
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
60362
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
60363
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
60364
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
60365
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
57224
60366
  };
57225
60367
  }), "walletFromKey");
57226
60368
 
60369
+ // src/wallet/plugins/vc-api/helpers.ts
60370
+ var post = /* @__PURE__ */ __name((url, data) => __async(void 0, null, function* () {
60371
+ return fetch(url, {
60372
+ method: "POST",
60373
+ headers: { "Content-Type": "application/json" },
60374
+ body: JSON.stringify(data)
60375
+ });
60376
+ }), "post");
60377
+ var isSuccessful = /* @__PURE__ */ __name((status) => status.toString().startsWith("2"), "isSuccessful");
60378
+
60379
+ // src/wallet/plugins/vc-api/index.ts
60380
+ var getVCAPIPlugin = /* @__PURE__ */ __name((_0) => __async(void 0, [_0], function* ({
60381
+ url: _url,
60382
+ did: _did
60383
+ }) {
60384
+ const url = _url.endsWith("/") ? _url.slice(0, -1) : _url;
60385
+ let did = _did;
60386
+ if (!did) {
60387
+ const res = yield fetch(`${url}/did`);
60388
+ if (res.status === 200)
60389
+ did = yield res.text();
60390
+ }
60391
+ if (!did)
60392
+ throw new Error("Could not retrieve did from VC API! Please suppy a did.");
60393
+ return {
60394
+ pluginMethods: {
60395
+ getSubjectDid: () => did,
60396
+ issueCredential: (_wallet, credential, options) => __async(void 0, null, function* () {
60397
+ yield UnsignedVCValidator.parseAsync(credential);
60398
+ const response = yield post(`${url}/credentials/issue`, { credential, options });
60399
+ if (!isSuccessful(response.status)) {
60400
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60401
+ }
60402
+ return VCValidator.parseAsync(yield response.json());
60403
+ }),
60404
+ verifyCredential: (_wallet, verifiableCredential, options) => __async(void 0, null, function* () {
60405
+ yield VCValidator.parseAsync(verifiableCredential);
60406
+ const response = yield post(`${url}/credentials/verify`, {
60407
+ verifiableCredential,
60408
+ options
60409
+ });
60410
+ if (!isSuccessful(response.status)) {
60411
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60412
+ }
60413
+ return VerificationCheckValidator.parseAsync(yield response.json());
60414
+ }),
60415
+ issuePresentation: (_wallet, presentation, options) => __async(void 0, null, function* () {
60416
+ yield UnsignedVPValidator.parseAsync(presentation);
60417
+ const response = yield post(`${url}/presentations/issue`, {
60418
+ presentation,
60419
+ options
60420
+ });
60421
+ if (!isSuccessful(response.status)) {
60422
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60423
+ }
60424
+ return VPValidator.parseAsync(yield response.json());
60425
+ }),
60426
+ verifyPresentation: (_wallet, verifiablePresentation, options) => __async(void 0, null, function* () {
60427
+ yield VPValidator.parseAsync(verifiablePresentation);
60428
+ const response = yield post(`${url}/presentations/verify`, {
60429
+ verifiablePresentation,
60430
+ options
60431
+ });
60432
+ if (!isSuccessful(response.status)) {
60433
+ throw new Error(`API Error: ${response.status} ${response.statusText}`);
60434
+ }
60435
+ return VerificationCheckValidator.parseAsync(yield response.json());
60436
+ }),
60437
+ getTestVc: (_wallet, subject = "did:example:d23dd687a7dc6787646f2eb98d0") => {
60438
+ return {
60439
+ "@context": ["https://www.w3.org/2018/credentials/v1"],
60440
+ id: "http://example.org/credentials/3731",
60441
+ type: ["VerifiableCredential"],
60442
+ issuer: did,
60443
+ issuanceDate: "2020-08-19T21:41:50Z",
60444
+ credentialSubject: { id: subject }
60445
+ };
60446
+ },
60447
+ getTestVp: (_wallet, _credential) => __async(void 0, null, function* () {
60448
+ const credential = _credential || (yield _wallet.pluginMethods.issueCredential(_wallet.pluginMethods.getTestVc()));
60449
+ return {
60450
+ "@context": ["https://www.w3.org/2018/credentials/v1"],
60451
+ type: ["VerifiablePresentation"],
60452
+ holder: did,
60453
+ verifiableCredential: credential
60454
+ };
60455
+ })
60456
+ }
60457
+ };
60458
+ }), "getVCAPIPlugin");
60459
+
60460
+ // src/wallet/initializers/apiWallet.ts
60461
+ var walletFromApiUrl = /* @__PURE__ */ __name((_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (url, did, { defaultContents = [] } = {}) {
60462
+ const apiWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getVCAPIPlugin({ url, did }));
60463
+ const expirationWallet = yield apiWallet.addPlugin(ExpirationPlugin(apiWallet));
60464
+ const templateWallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin());
60465
+ const wallet = yield templateWallet.addPlugin(yield getCHAPIPlugin());
60466
+ return {
60467
+ _wallet: wallet,
60468
+ did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
60469
+ newCredential: wallet.pluginMethods.newCredential,
60470
+ newPresentation: wallet.pluginMethods.newPresentation,
60471
+ issueCredential: wallet.pluginMethods.issueCredential,
60472
+ verifyCredential: verifyCredential2(wallet),
60473
+ issuePresentation: wallet.pluginMethods.issuePresentation,
60474
+ verifyPresentation: wallet.pluginMethods.verifyPresentation,
60475
+ getTestVc: wallet.pluginMethods.getTestVc,
60476
+ getTestVp: wallet.pluginMethods.getTestVp,
60477
+ installChapiHandler: wallet.pluginMethods.installChapiHandler,
60478
+ activateChapiHandler: wallet.pluginMethods.activateChapiHandler,
60479
+ receiveChapiEvent: wallet.pluginMethods.receiveChapiEvent,
60480
+ storePresentationViaChapi: wallet.pluginMethods.storePresentationViaChapi,
60481
+ storeCredentialViaChapiDidAuth: wallet.pluginMethods.storeCredentialViaChapiDidAuth
60482
+ };
60483
+ }), "walletFromApiUrl");
60484
+
57227
60485
  // src/wallet/init.ts
57228
60486
  function initLearnCard() {
57229
60487
  return __async(this, arguments, function* (config2 = {}) {
60488
+ if ("vcApi" in config2) {
60489
+ const _a = config2, { vcApi, did } = _a, apiConfig = __objRest(_a, ["vcApi", "did"]);
60490
+ return walletFromApiUrl(typeof vcApi === "string" ? vcApi : "https://bridge.learncard.com", vcApi === true ? "did:key:z6MkjSz4mYqcn7dePGuktJ5PxecMkXQQHWRg8Lm6okATyFVh" : did, apiConfig);
60491
+ }
57230
60492
  if ("seed" in config2) {
57231
- const _a = config2, { seed } = _a, keyConfig = __objRest(_a, ["seed"]);
60493
+ const _b = config2, { seed } = _b, keyConfig = __objRest(_b, ["seed"]);
57232
60494
  return walletFromKey(seed, keyConfig);
57233
60495
  }
57234
60496
  return emptyWallet(config2);
57235
60497
  });
57236
60498
  }
57237
60499
  __name(initLearnCard, "initLearnCard");
60500
+ /*!
60501
+ * A CredentialHandlerRegistration provides a CredentialManager to enable Web
60502
+ * apps to register Profiles that can be presented to websites.
60503
+ *
60504
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60505
+ */
60506
+ /*!
60507
+ * A CredentialRequestEvent is emitted when a request has been made for
60508
+ * credentials.
60509
+ *
60510
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60511
+ */
60512
+ /*!
60513
+ * A CredentialStoreEvent is emitted when a request has been made to
60514
+ * store a credential.
60515
+ *
60516
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60517
+ */
60518
+ /*!
60519
+ * A WebApp is a remote application that runs in a WebAppContext.
60520
+ *
60521
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60522
+ */
60523
+ /*!
60524
+ * A WebCredential is a Credential that can be retrieved from or stored by a
60525
+ * "credential handler" that runs in a third party Web application.
60526
+ *
60527
+ * Copyright (c) 2017-2021 Digital Bazaar, Inc. All rights reserved.
60528
+ */
60529
+ /*!
60530
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60531
+ */
60532
+ /*!
60533
+ * Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
60534
+ */
60535
+ /*!
60536
+ * Copyright (c) 2017-2022 Digital Bazaar, Inc. All rights reserved.
60537
+ */
60538
+ /*!
60539
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
60540
+ */
57238
60541
  /*!
57239
60542
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
57240
60543
  */
@@ -57247,6 +60550,36 @@ __name(initLearnCard, "initLearnCard");
57247
60550
  /*!
57248
60551
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
57249
60552
  */
60553
+ /*!
60554
+ * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
60555
+ */
60556
+ /*!
60557
+ * JSON-RPC for Web Request Polyfills.
60558
+ *
60559
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60560
+ */
60561
+ /*!
60562
+ * The buffer module from node.js, for the browser.
60563
+ *
60564
+ * @author Feross Aboukhadijeh <https://feross.org>
60565
+ * @license MIT
60566
+ */
60567
+ /*!
60568
+ * The core CredentialHandler class.
60569
+ *
60570
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60571
+ */
60572
+ /*!
60573
+ * Utilities for Web Request RPC.
60574
+ *
60575
+ * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
60576
+ */
60577
+ /*!
60578
+ * Wrapper for native CredentialsContainer that uses remote Credential Mediator
60579
+ * for WebCredential-related operations.
60580
+ *
60581
+ * Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
60582
+ */
57250
60583
  /*!
57251
60584
  * https://github.com/Starcounter-Jack/JSON-Patch
57252
60585
  * (c) 2017-2021 Joachim Wester
@@ -57257,6 +60590,7 @@ __name(initLearnCard, "initLearnCard");
57257
60590
  * (c) 2017-2022 Joachim Wester
57258
60591
  * MIT licensed
57259
60592
  */
60593
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
57260
60594
  /**
57261
60595
  * @module QRCode
57262
60596
  * @package @nuintun/qrcode