@stryke/prisma-trpc-generator 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -672,165 +672,1960 @@ var require_pluralize = __commonJS({
672
672
  }
673
673
  });
674
674
 
675
- // src/index.ts
676
- init_esm_shims();
677
-
678
- // src/prisma-generator.ts
679
- init_esm_shims();
680
-
681
- // ../fs/src/helpers.ts
682
- init_esm_shims();
683
-
684
- // ../path/src/exists.ts
685
- init_esm_shims();
686
- import { access, constants } from "node:fs/promises";
687
- var exists = /* @__PURE__ */ __name(async (filePath) => {
688
- return access(filePath, constants.F_OK).then(() => true).catch(() => false);
689
- }, "exists");
690
-
691
- // ../fs/src/helpers.ts
692
- import { mkdir, readFile, rm } from "node:fs/promises";
693
- async function createDirectory(path6) {
694
- if (await exists(path6)) {
695
- return;
675
+ // ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
676
+ var require_base64_js = __commonJS({
677
+ "../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports) {
678
+ "use strict";
679
+ init_esm_shims();
680
+ exports.byteLength = byteLength;
681
+ exports.toByteArray = toByteArray;
682
+ exports.fromByteArray = fromByteArray;
683
+ var lookup = [];
684
+ var revLookup = [];
685
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
686
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
687
+ for (i = 0, len = code.length; i < len; ++i) {
688
+ lookup[i] = code[i];
689
+ revLookup[code.charCodeAt(i)] = i;
690
+ }
691
+ var i;
692
+ var len;
693
+ revLookup["-".charCodeAt(0)] = 62;
694
+ revLookup["_".charCodeAt(0)] = 63;
695
+ function getLens(b64) {
696
+ var len2 = b64.length;
697
+ if (len2 % 4 > 0) {
698
+ throw new Error("Invalid string. Length must be a multiple of 4");
699
+ }
700
+ var validLen = b64.indexOf("=");
701
+ if (validLen === -1) validLen = len2;
702
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
703
+ return [
704
+ validLen,
705
+ placeHoldersLen
706
+ ];
707
+ }
708
+ __name(getLens, "getLens");
709
+ function byteLength(b64) {
710
+ var lens = getLens(b64);
711
+ var validLen = lens[0];
712
+ var placeHoldersLen = lens[1];
713
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
714
+ }
715
+ __name(byteLength, "byteLength");
716
+ function _byteLength(b64, validLen, placeHoldersLen) {
717
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
718
+ }
719
+ __name(_byteLength, "_byteLength");
720
+ function toByteArray(b64) {
721
+ var tmp;
722
+ var lens = getLens(b64);
723
+ var validLen = lens[0];
724
+ var placeHoldersLen = lens[1];
725
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
726
+ var curByte = 0;
727
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
728
+ var i2;
729
+ for (i2 = 0; i2 < len2; i2 += 4) {
730
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
731
+ arr[curByte++] = tmp >> 16 & 255;
732
+ arr[curByte++] = tmp >> 8 & 255;
733
+ arr[curByte++] = tmp & 255;
734
+ }
735
+ if (placeHoldersLen === 2) {
736
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
737
+ arr[curByte++] = tmp & 255;
738
+ }
739
+ if (placeHoldersLen === 1) {
740
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
741
+ arr[curByte++] = tmp >> 8 & 255;
742
+ arr[curByte++] = tmp & 255;
743
+ }
744
+ return arr;
745
+ }
746
+ __name(toByteArray, "toByteArray");
747
+ function tripletToBase64(num) {
748
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
749
+ }
750
+ __name(tripletToBase64, "tripletToBase64");
751
+ function encodeChunk(uint8, start, end) {
752
+ var tmp;
753
+ var output = [];
754
+ for (var i2 = start; i2 < end; i2 += 3) {
755
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
756
+ output.push(tripletToBase64(tmp));
757
+ }
758
+ return output.join("");
759
+ }
760
+ __name(encodeChunk, "encodeChunk");
761
+ function fromByteArray(uint8) {
762
+ var tmp;
763
+ var len2 = uint8.length;
764
+ var extraBytes = len2 % 3;
765
+ var parts = [];
766
+ var maxChunkLength = 16383;
767
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
768
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
769
+ }
770
+ if (extraBytes === 1) {
771
+ tmp = uint8[len2 - 1];
772
+ parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
773
+ } else if (extraBytes === 2) {
774
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
775
+ parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
776
+ }
777
+ return parts.join("");
778
+ }
779
+ __name(fromByteArray, "fromByteArray");
696
780
  }
697
- return mkdir(path6, {
698
- recursive: true
699
- });
700
- }
701
- __name(createDirectory, "createDirectory");
781
+ });
702
782
 
703
- // ../path/src/join-paths.ts
704
- init_esm_shims();
705
- var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
706
- function normalizeWindowsPath(input = "") {
707
- if (!input) {
708
- return input;
709
- }
710
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
711
- }
712
- __name(normalizeWindowsPath, "normalizeWindowsPath");
713
- var _UNC_REGEX = /^[/\\]{2}/;
714
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
715
- var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
716
- var isAbsolute = /* @__PURE__ */ __name(function(p) {
717
- return _IS_ABSOLUTE_RE.test(p);
718
- }, "isAbsolute");
719
- var correctPaths = /* @__PURE__ */ __name(function(path6) {
720
- if (!path6 || path6.length === 0) {
721
- return ".";
783
+ // ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
784
+ var require_ieee754 = __commonJS({
785
+ "../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports) {
786
+ "use strict";
787
+ init_esm_shims();
788
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
789
+ var e, m;
790
+ var eLen = nBytes * 8 - mLen - 1;
791
+ var eMax = (1 << eLen) - 1;
792
+ var eBias = eMax >> 1;
793
+ var nBits = -7;
794
+ var i = isLE ? nBytes - 1 : 0;
795
+ var d = isLE ? -1 : 1;
796
+ var s = buffer[offset + i];
797
+ i += d;
798
+ e = s & (1 << -nBits) - 1;
799
+ s >>= -nBits;
800
+ nBits += eLen;
801
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
802
+ }
803
+ m = e & (1 << -nBits) - 1;
804
+ e >>= -nBits;
805
+ nBits += mLen;
806
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
807
+ }
808
+ if (e === 0) {
809
+ e = 1 - eBias;
810
+ } else if (e === eMax) {
811
+ return m ? NaN : (s ? -1 : 1) * Infinity;
812
+ } else {
813
+ m = m + Math.pow(2, mLen);
814
+ e = e - eBias;
815
+ }
816
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
817
+ };
818
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
819
+ var e, m, c;
820
+ var eLen = nBytes * 8 - mLen - 1;
821
+ var eMax = (1 << eLen) - 1;
822
+ var eBias = eMax >> 1;
823
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
824
+ var i = isLE ? 0 : nBytes - 1;
825
+ var d = isLE ? 1 : -1;
826
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
827
+ value = Math.abs(value);
828
+ if (isNaN(value) || value === Infinity) {
829
+ m = isNaN(value) ? 1 : 0;
830
+ e = eMax;
831
+ } else {
832
+ e = Math.floor(Math.log(value) / Math.LN2);
833
+ if (value * (c = Math.pow(2, -e)) < 1) {
834
+ e--;
835
+ c *= 2;
836
+ }
837
+ if (e + eBias >= 1) {
838
+ value += rt / c;
839
+ } else {
840
+ value += rt * Math.pow(2, 1 - eBias);
841
+ }
842
+ if (value * c >= 2) {
843
+ e++;
844
+ c /= 2;
845
+ }
846
+ if (e + eBias >= eMax) {
847
+ m = 0;
848
+ e = eMax;
849
+ } else if (e + eBias >= 1) {
850
+ m = (value * c - 1) * Math.pow(2, mLen);
851
+ e = e + eBias;
852
+ } else {
853
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
854
+ e = 0;
855
+ }
856
+ }
857
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
858
+ }
859
+ e = e << mLen | m;
860
+ eLen += mLen;
861
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
862
+ }
863
+ buffer[offset + i - d] |= s * 128;
864
+ };
722
865
  }
723
- path6 = normalizeWindowsPath(path6);
724
- const isUNCPath = path6.match(_UNC_REGEX);
725
- const isPathAbsolute = isAbsolute(path6);
726
- const trailingSeparator = path6[path6.length - 1] === "/";
727
- path6 = normalizeString(path6, !isPathAbsolute);
728
- if (path6.length === 0) {
729
- if (isPathAbsolute) {
730
- return "/";
866
+ });
867
+
868
+ // ../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
869
+ var require_buffer = __commonJS({
870
+ "../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js"(exports) {
871
+ "use strict";
872
+ init_esm_shims();
873
+ var base64 = require_base64_js();
874
+ var ieee754 = require_ieee754();
875
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
876
+ exports.Buffer = Buffer3;
877
+ exports.SlowBuffer = SlowBuffer;
878
+ exports.INSPECT_MAX_BYTES = 50;
879
+ var K_MAX_LENGTH = 2147483647;
880
+ exports.kMaxLength = K_MAX_LENGTH;
881
+ Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
882
+ if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
883
+ 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.");
884
+ }
885
+ function typedArraySupport() {
886
+ try {
887
+ const arr = new Uint8Array(1);
888
+ const proto = {
889
+ foo: /* @__PURE__ */ __name(function() {
890
+ return 42;
891
+ }, "foo")
892
+ };
893
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
894
+ Object.setPrototypeOf(arr, proto);
895
+ return arr.foo() === 42;
896
+ } catch (e) {
897
+ return false;
898
+ }
731
899
  }
732
- return trailingSeparator ? "./" : ".";
733
- }
734
- if (trailingSeparator) {
735
- path6 += "/";
736
- }
737
- if (_DRIVE_LETTER_RE.test(path6)) {
738
- path6 += "/";
739
- }
740
- if (isUNCPath) {
741
- if (!isPathAbsolute) {
742
- return `//./${path6}`;
900
+ __name(typedArraySupport, "typedArraySupport");
901
+ Object.defineProperty(Buffer3.prototype, "parent", {
902
+ enumerable: true,
903
+ get: /* @__PURE__ */ __name(function() {
904
+ if (!Buffer3.isBuffer(this)) return void 0;
905
+ return this.buffer;
906
+ }, "get")
907
+ });
908
+ Object.defineProperty(Buffer3.prototype, "offset", {
909
+ enumerable: true,
910
+ get: /* @__PURE__ */ __name(function() {
911
+ if (!Buffer3.isBuffer(this)) return void 0;
912
+ return this.byteOffset;
913
+ }, "get")
914
+ });
915
+ function createBuffer(length) {
916
+ if (length > K_MAX_LENGTH) {
917
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
918
+ }
919
+ const buf = new Uint8Array(length);
920
+ Object.setPrototypeOf(buf, Buffer3.prototype);
921
+ return buf;
922
+ }
923
+ __name(createBuffer, "createBuffer");
924
+ function Buffer3(arg, encodingOrOffset, length) {
925
+ if (typeof arg === "number") {
926
+ if (typeof encodingOrOffset === "string") {
927
+ throw new TypeError('The "string" argument must be of type string. Received type number');
928
+ }
929
+ return allocUnsafe(arg);
930
+ }
931
+ return from(arg, encodingOrOffset, length);
743
932
  }
744
- return `//${path6}`;
745
- }
746
- return isPathAbsolute && !isAbsolute(path6) ? `/${path6}` : path6;
747
- }, "correctPaths");
748
- var joinPaths = /* @__PURE__ */ __name(function(...segments) {
749
- let path6 = "";
750
- for (const seg of segments) {
751
- if (!seg) {
752
- continue;
933
+ __name(Buffer3, "Buffer");
934
+ Buffer3.poolSize = 8192;
935
+ function from(value, encodingOrOffset, length) {
936
+ if (typeof value === "string") {
937
+ return fromString(value, encodingOrOffset);
938
+ }
939
+ if (ArrayBuffer.isView(value)) {
940
+ return fromArrayView(value);
941
+ }
942
+ if (value == null) {
943
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
944
+ }
945
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
946
+ return fromArrayBuffer(value, encodingOrOffset, length);
947
+ }
948
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
949
+ return fromArrayBuffer(value, encodingOrOffset, length);
950
+ }
951
+ if (typeof value === "number") {
952
+ throw new TypeError('The "value" argument must not be of type number. Received type number');
953
+ }
954
+ const valueOf = value.valueOf && value.valueOf();
955
+ if (valueOf != null && valueOf !== value) {
956
+ return Buffer3.from(valueOf, encodingOrOffset, length);
957
+ }
958
+ const b = fromObject(value);
959
+ if (b) return b;
960
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
961
+ return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
962
+ }
963
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
753
964
  }
754
- if (path6.length > 0) {
755
- const pathTrailing = path6[path6.length - 1] === "/";
756
- const segLeading = seg[0] === "/";
757
- const both = pathTrailing && segLeading;
758
- if (both) {
759
- path6 += seg.slice(1);
965
+ __name(from, "from");
966
+ Buffer3.from = function(value, encodingOrOffset, length) {
967
+ return from(value, encodingOrOffset, length);
968
+ };
969
+ Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
970
+ Object.setPrototypeOf(Buffer3, Uint8Array);
971
+ function assertSize(size) {
972
+ if (typeof size !== "number") {
973
+ throw new TypeError('"size" argument must be of type number');
974
+ } else if (size < 0) {
975
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
976
+ }
977
+ }
978
+ __name(assertSize, "assertSize");
979
+ function alloc(size, fill, encoding) {
980
+ assertSize(size);
981
+ if (size <= 0) {
982
+ return createBuffer(size);
983
+ }
984
+ if (fill !== void 0) {
985
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
986
+ }
987
+ return createBuffer(size);
988
+ }
989
+ __name(alloc, "alloc");
990
+ Buffer3.alloc = function(size, fill, encoding) {
991
+ return alloc(size, fill, encoding);
992
+ };
993
+ function allocUnsafe(size) {
994
+ assertSize(size);
995
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
996
+ }
997
+ __name(allocUnsafe, "allocUnsafe");
998
+ Buffer3.allocUnsafe = function(size) {
999
+ return allocUnsafe(size);
1000
+ };
1001
+ Buffer3.allocUnsafeSlow = function(size) {
1002
+ return allocUnsafe(size);
1003
+ };
1004
+ function fromString(string, encoding) {
1005
+ if (typeof encoding !== "string" || encoding === "") {
1006
+ encoding = "utf8";
1007
+ }
1008
+ if (!Buffer3.isEncoding(encoding)) {
1009
+ throw new TypeError("Unknown encoding: " + encoding);
1010
+ }
1011
+ const length = byteLength(string, encoding) | 0;
1012
+ let buf = createBuffer(length);
1013
+ const actual = buf.write(string, encoding);
1014
+ if (actual !== length) {
1015
+ buf = buf.slice(0, actual);
1016
+ }
1017
+ return buf;
1018
+ }
1019
+ __name(fromString, "fromString");
1020
+ function fromArrayLike(array) {
1021
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
1022
+ const buf = createBuffer(length);
1023
+ for (let i = 0; i < length; i += 1) {
1024
+ buf[i] = array[i] & 255;
1025
+ }
1026
+ return buf;
1027
+ }
1028
+ __name(fromArrayLike, "fromArrayLike");
1029
+ function fromArrayView(arrayView) {
1030
+ if (isInstance(arrayView, Uint8Array)) {
1031
+ const copy2 = new Uint8Array(arrayView);
1032
+ return fromArrayBuffer(copy2.buffer, copy2.byteOffset, copy2.byteLength);
1033
+ }
1034
+ return fromArrayLike(arrayView);
1035
+ }
1036
+ __name(fromArrayView, "fromArrayView");
1037
+ function fromArrayBuffer(array, byteOffset, length) {
1038
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
1039
+ throw new RangeError('"offset" is outside of buffer bounds');
1040
+ }
1041
+ if (array.byteLength < byteOffset + (length || 0)) {
1042
+ throw new RangeError('"length" is outside of buffer bounds');
1043
+ }
1044
+ let buf;
1045
+ if (byteOffset === void 0 && length === void 0) {
1046
+ buf = new Uint8Array(array);
1047
+ } else if (length === void 0) {
1048
+ buf = new Uint8Array(array, byteOffset);
760
1049
  } else {
761
- path6 += pathTrailing || segLeading ? seg : `/${seg}`;
1050
+ buf = new Uint8Array(array, byteOffset, length);
1051
+ }
1052
+ Object.setPrototypeOf(buf, Buffer3.prototype);
1053
+ return buf;
1054
+ }
1055
+ __name(fromArrayBuffer, "fromArrayBuffer");
1056
+ function fromObject(obj) {
1057
+ if (Buffer3.isBuffer(obj)) {
1058
+ const len = checked(obj.length) | 0;
1059
+ const buf = createBuffer(len);
1060
+ if (buf.length === 0) {
1061
+ return buf;
1062
+ }
1063
+ obj.copy(buf, 0, 0, len);
1064
+ return buf;
1065
+ }
1066
+ if (obj.length !== void 0) {
1067
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
1068
+ return createBuffer(0);
1069
+ }
1070
+ return fromArrayLike(obj);
1071
+ }
1072
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
1073
+ return fromArrayLike(obj.data);
762
1074
  }
763
- } else {
764
- path6 += seg;
765
1075
  }
766
- }
767
- return correctPaths(path6);
768
- }, "joinPaths");
769
- function normalizeString(path6, allowAboveRoot) {
770
- let res = "";
771
- let lastSegmentLength = 0;
772
- let lastSlash = -1;
773
- let dots = 0;
774
- let char = null;
775
- for (let index = 0; index <= path6.length; ++index) {
776
- if (index < path6.length) {
777
- char = path6[index];
778
- } else if (char === "/") {
779
- break;
780
- } else {
781
- char = "/";
1076
+ __name(fromObject, "fromObject");
1077
+ function checked(length) {
1078
+ if (length >= K_MAX_LENGTH) {
1079
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
1080
+ }
1081
+ return length | 0;
782
1082
  }
783
- if (char === "/") {
784
- if (lastSlash === index - 1 || dots === 1) {
785
- } else if (dots === 2) {
786
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
787
- if (res.length > 2) {
788
- const lastSlashIndex = res.lastIndexOf("/");
789
- if (lastSlashIndex === -1) {
790
- res = "";
791
- lastSegmentLength = 0;
792
- } else {
793
- res = res.slice(0, lastSlashIndex);
794
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1083
+ __name(checked, "checked");
1084
+ function SlowBuffer(length) {
1085
+ if (+length != length) {
1086
+ length = 0;
1087
+ }
1088
+ return Buffer3.alloc(+length);
1089
+ }
1090
+ __name(SlowBuffer, "SlowBuffer");
1091
+ Buffer3.isBuffer = /* @__PURE__ */ __name(function isBuffer(b) {
1092
+ return b != null && b._isBuffer === true && b !== Buffer3.prototype;
1093
+ }, "isBuffer");
1094
+ Buffer3.compare = /* @__PURE__ */ __name(function compare(a, b) {
1095
+ if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
1096
+ if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
1097
+ if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
1098
+ throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
1099
+ }
1100
+ if (a === b) return 0;
1101
+ let x = a.length;
1102
+ let y = b.length;
1103
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
1104
+ if (a[i] !== b[i]) {
1105
+ x = a[i];
1106
+ y = b[i];
1107
+ break;
1108
+ }
1109
+ }
1110
+ if (x < y) return -1;
1111
+ if (y < x) return 1;
1112
+ return 0;
1113
+ }, "compare");
1114
+ Buffer3.isEncoding = /* @__PURE__ */ __name(function isEncoding(encoding) {
1115
+ switch (String(encoding).toLowerCase()) {
1116
+ case "hex":
1117
+ case "utf8":
1118
+ case "utf-8":
1119
+ case "ascii":
1120
+ case "latin1":
1121
+ case "binary":
1122
+ case "base64":
1123
+ case "ucs2":
1124
+ case "ucs-2":
1125
+ case "utf16le":
1126
+ case "utf-16le":
1127
+ return true;
1128
+ default:
1129
+ return false;
1130
+ }
1131
+ }, "isEncoding");
1132
+ Buffer3.concat = /* @__PURE__ */ __name(function concat(list, length) {
1133
+ if (!Array.isArray(list)) {
1134
+ throw new TypeError('"list" argument must be an Array of Buffers');
1135
+ }
1136
+ if (list.length === 0) {
1137
+ return Buffer3.alloc(0);
1138
+ }
1139
+ let i;
1140
+ if (length === void 0) {
1141
+ length = 0;
1142
+ for (i = 0; i < list.length; ++i) {
1143
+ length += list[i].length;
1144
+ }
1145
+ }
1146
+ const buffer = Buffer3.allocUnsafe(length);
1147
+ let pos = 0;
1148
+ for (i = 0; i < list.length; ++i) {
1149
+ let buf = list[i];
1150
+ if (isInstance(buf, Uint8Array)) {
1151
+ if (pos + buf.length > buffer.length) {
1152
+ if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
1153
+ buf.copy(buffer, pos);
1154
+ } else {
1155
+ Uint8Array.prototype.set.call(buffer, buf, pos);
1156
+ }
1157
+ } else if (!Buffer3.isBuffer(buf)) {
1158
+ throw new TypeError('"list" argument must be an Array of Buffers');
1159
+ } else {
1160
+ buf.copy(buffer, pos);
1161
+ }
1162
+ pos += buf.length;
1163
+ }
1164
+ return buffer;
1165
+ }, "concat");
1166
+ function byteLength(string, encoding) {
1167
+ if (Buffer3.isBuffer(string)) {
1168
+ return string.length;
1169
+ }
1170
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
1171
+ return string.byteLength;
1172
+ }
1173
+ if (typeof string !== "string") {
1174
+ throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string);
1175
+ }
1176
+ const len = string.length;
1177
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
1178
+ if (!mustMatch && len === 0) return 0;
1179
+ let loweredCase = false;
1180
+ for (; ; ) {
1181
+ switch (encoding) {
1182
+ case "ascii":
1183
+ case "latin1":
1184
+ case "binary":
1185
+ return len;
1186
+ case "utf8":
1187
+ case "utf-8":
1188
+ return utf8ToBytes(string).length;
1189
+ case "ucs2":
1190
+ case "ucs-2":
1191
+ case "utf16le":
1192
+ case "utf-16le":
1193
+ return len * 2;
1194
+ case "hex":
1195
+ return len >>> 1;
1196
+ case "base64":
1197
+ return base64ToBytes(string).length;
1198
+ default:
1199
+ if (loweredCase) {
1200
+ return mustMatch ? -1 : utf8ToBytes(string).length;
795
1201
  }
796
- lastSlash = index;
797
- dots = 0;
798
- continue;
799
- } else if (res.length > 0) {
800
- res = "";
801
- lastSegmentLength = 0;
802
- lastSlash = index;
803
- dots = 0;
804
- continue;
1202
+ encoding = ("" + encoding).toLowerCase();
1203
+ loweredCase = true;
1204
+ }
1205
+ }
1206
+ }
1207
+ __name(byteLength, "byteLength");
1208
+ Buffer3.byteLength = byteLength;
1209
+ function slowToString(encoding, start, end) {
1210
+ let loweredCase = false;
1211
+ if (start === void 0 || start < 0) {
1212
+ start = 0;
1213
+ }
1214
+ if (start > this.length) {
1215
+ return "";
1216
+ }
1217
+ if (end === void 0 || end > this.length) {
1218
+ end = this.length;
1219
+ }
1220
+ if (end <= 0) {
1221
+ return "";
1222
+ }
1223
+ end >>>= 0;
1224
+ start >>>= 0;
1225
+ if (end <= start) {
1226
+ return "";
1227
+ }
1228
+ if (!encoding) encoding = "utf8";
1229
+ while (true) {
1230
+ switch (encoding) {
1231
+ case "hex":
1232
+ return hexSlice(this, start, end);
1233
+ case "utf8":
1234
+ case "utf-8":
1235
+ return utf8Slice(this, start, end);
1236
+ case "ascii":
1237
+ return asciiSlice(this, start, end);
1238
+ case "latin1":
1239
+ case "binary":
1240
+ return latin1Slice(this, start, end);
1241
+ case "base64":
1242
+ return base64Slice(this, start, end);
1243
+ case "ucs2":
1244
+ case "ucs-2":
1245
+ case "utf16le":
1246
+ case "utf-16le":
1247
+ return utf16leSlice(this, start, end);
1248
+ default:
1249
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
1250
+ encoding = (encoding + "").toLowerCase();
1251
+ loweredCase = true;
1252
+ }
1253
+ }
1254
+ }
1255
+ __name(slowToString, "slowToString");
1256
+ Buffer3.prototype._isBuffer = true;
1257
+ function swap(b, n, m) {
1258
+ const i = b[n];
1259
+ b[n] = b[m];
1260
+ b[m] = i;
1261
+ }
1262
+ __name(swap, "swap");
1263
+ Buffer3.prototype.swap16 = /* @__PURE__ */ __name(function swap16() {
1264
+ const len = this.length;
1265
+ if (len % 2 !== 0) {
1266
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
1267
+ }
1268
+ for (let i = 0; i < len; i += 2) {
1269
+ swap(this, i, i + 1);
1270
+ }
1271
+ return this;
1272
+ }, "swap16");
1273
+ Buffer3.prototype.swap32 = /* @__PURE__ */ __name(function swap32() {
1274
+ const len = this.length;
1275
+ if (len % 4 !== 0) {
1276
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
1277
+ }
1278
+ for (let i = 0; i < len; i += 4) {
1279
+ swap(this, i, i + 3);
1280
+ swap(this, i + 1, i + 2);
1281
+ }
1282
+ return this;
1283
+ }, "swap32");
1284
+ Buffer3.prototype.swap64 = /* @__PURE__ */ __name(function swap64() {
1285
+ const len = this.length;
1286
+ if (len % 8 !== 0) {
1287
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
1288
+ }
1289
+ for (let i = 0; i < len; i += 8) {
1290
+ swap(this, i, i + 7);
1291
+ swap(this, i + 1, i + 6);
1292
+ swap(this, i + 2, i + 5);
1293
+ swap(this, i + 3, i + 4);
1294
+ }
1295
+ return this;
1296
+ }, "swap64");
1297
+ Buffer3.prototype.toString = /* @__PURE__ */ __name(function toString() {
1298
+ const length = this.length;
1299
+ if (length === 0) return "";
1300
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
1301
+ return slowToString.apply(this, arguments);
1302
+ }, "toString");
1303
+ Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
1304
+ Buffer3.prototype.equals = /* @__PURE__ */ __name(function equals(b) {
1305
+ if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
1306
+ if (this === b) return true;
1307
+ return Buffer3.compare(this, b) === 0;
1308
+ }, "equals");
1309
+ Buffer3.prototype.inspect = /* @__PURE__ */ __name(function inspect() {
1310
+ let str = "";
1311
+ const max = exports.INSPECT_MAX_BYTES;
1312
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
1313
+ if (this.length > max) str += " ... ";
1314
+ return "<Buffer " + str + ">";
1315
+ }, "inspect");
1316
+ if (customInspectSymbol) {
1317
+ Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
1318
+ }
1319
+ Buffer3.prototype.compare = /* @__PURE__ */ __name(function compare(target, start, end, thisStart, thisEnd) {
1320
+ if (isInstance(target, Uint8Array)) {
1321
+ target = Buffer3.from(target, target.offset, target.byteLength);
1322
+ }
1323
+ if (!Buffer3.isBuffer(target)) {
1324
+ throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target);
1325
+ }
1326
+ if (start === void 0) {
1327
+ start = 0;
1328
+ }
1329
+ if (end === void 0) {
1330
+ end = target ? target.length : 0;
1331
+ }
1332
+ if (thisStart === void 0) {
1333
+ thisStart = 0;
1334
+ }
1335
+ if (thisEnd === void 0) {
1336
+ thisEnd = this.length;
1337
+ }
1338
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1339
+ throw new RangeError("out of range index");
1340
+ }
1341
+ if (thisStart >= thisEnd && start >= end) {
1342
+ return 0;
1343
+ }
1344
+ if (thisStart >= thisEnd) {
1345
+ return -1;
1346
+ }
1347
+ if (start >= end) {
1348
+ return 1;
1349
+ }
1350
+ start >>>= 0;
1351
+ end >>>= 0;
1352
+ thisStart >>>= 0;
1353
+ thisEnd >>>= 0;
1354
+ if (this === target) return 0;
1355
+ let x = thisEnd - thisStart;
1356
+ let y = end - start;
1357
+ const len = Math.min(x, y);
1358
+ const thisCopy = this.slice(thisStart, thisEnd);
1359
+ const targetCopy = target.slice(start, end);
1360
+ for (let i = 0; i < len; ++i) {
1361
+ if (thisCopy[i] !== targetCopy[i]) {
1362
+ x = thisCopy[i];
1363
+ y = targetCopy[i];
1364
+ break;
1365
+ }
1366
+ }
1367
+ if (x < y) return -1;
1368
+ if (y < x) return 1;
1369
+ return 0;
1370
+ }, "compare");
1371
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
1372
+ if (buffer.length === 0) return -1;
1373
+ if (typeof byteOffset === "string") {
1374
+ encoding = byteOffset;
1375
+ byteOffset = 0;
1376
+ } else if (byteOffset > 2147483647) {
1377
+ byteOffset = 2147483647;
1378
+ } else if (byteOffset < -2147483648) {
1379
+ byteOffset = -2147483648;
1380
+ }
1381
+ byteOffset = +byteOffset;
1382
+ if (numberIsNaN(byteOffset)) {
1383
+ byteOffset = dir ? 0 : buffer.length - 1;
1384
+ }
1385
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
1386
+ if (byteOffset >= buffer.length) {
1387
+ if (dir) return -1;
1388
+ else byteOffset = buffer.length - 1;
1389
+ } else if (byteOffset < 0) {
1390
+ if (dir) byteOffset = 0;
1391
+ else return -1;
1392
+ }
1393
+ if (typeof val === "string") {
1394
+ val = Buffer3.from(val, encoding);
1395
+ }
1396
+ if (Buffer3.isBuffer(val)) {
1397
+ if (val.length === 0) {
1398
+ return -1;
1399
+ }
1400
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
1401
+ } else if (typeof val === "number") {
1402
+ val = val & 255;
1403
+ if (typeof Uint8Array.prototype.indexOf === "function") {
1404
+ if (dir) {
1405
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
1406
+ } else {
1407
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
805
1408
  }
806
1409
  }
807
- if (allowAboveRoot) {
808
- res += res.length > 0 ? "/.." : "..";
809
- lastSegmentLength = 2;
1410
+ return arrayIndexOf(buffer, [
1411
+ val
1412
+ ], byteOffset, encoding, dir);
1413
+ }
1414
+ throw new TypeError("val must be string, number or Buffer");
1415
+ }
1416
+ __name(bidirectionalIndexOf, "bidirectionalIndexOf");
1417
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
1418
+ let indexSize = 1;
1419
+ let arrLength = arr.length;
1420
+ let valLength = val.length;
1421
+ if (encoding !== void 0) {
1422
+ encoding = String(encoding).toLowerCase();
1423
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
1424
+ if (arr.length < 2 || val.length < 2) {
1425
+ return -1;
1426
+ }
1427
+ indexSize = 2;
1428
+ arrLength /= 2;
1429
+ valLength /= 2;
1430
+ byteOffset /= 2;
1431
+ }
1432
+ }
1433
+ function read(buf, i2) {
1434
+ if (indexSize === 1) {
1435
+ return buf[i2];
1436
+ } else {
1437
+ return buf.readUInt16BE(i2 * indexSize);
1438
+ }
1439
+ }
1440
+ __name(read, "read");
1441
+ let i;
1442
+ if (dir) {
1443
+ let foundIndex = -1;
1444
+ for (i = byteOffset; i < arrLength; i++) {
1445
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1446
+ if (foundIndex === -1) foundIndex = i;
1447
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
1448
+ } else {
1449
+ if (foundIndex !== -1) i -= i - foundIndex;
1450
+ foundIndex = -1;
1451
+ }
810
1452
  }
811
1453
  } else {
812
- if (res.length > 0) {
813
- res += `/${path6.slice(lastSlash + 1, index)}`;
1454
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
1455
+ for (i = byteOffset; i >= 0; i--) {
1456
+ let found = true;
1457
+ for (let j = 0; j < valLength; j++) {
1458
+ if (read(arr, i + j) !== read(val, j)) {
1459
+ found = false;
1460
+ break;
1461
+ }
1462
+ }
1463
+ if (found) return i;
1464
+ }
1465
+ }
1466
+ return -1;
1467
+ }
1468
+ __name(arrayIndexOf, "arrayIndexOf");
1469
+ Buffer3.prototype.includes = /* @__PURE__ */ __name(function includes2(val, byteOffset, encoding) {
1470
+ return this.indexOf(val, byteOffset, encoding) !== -1;
1471
+ }, "includes");
1472
+ Buffer3.prototype.indexOf = /* @__PURE__ */ __name(function indexOf(val, byteOffset, encoding) {
1473
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
1474
+ }, "indexOf");
1475
+ Buffer3.prototype.lastIndexOf = /* @__PURE__ */ __name(function lastIndexOf(val, byteOffset, encoding) {
1476
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
1477
+ }, "lastIndexOf");
1478
+ function hexWrite(buf, string, offset, length) {
1479
+ offset = Number(offset) || 0;
1480
+ const remaining = buf.length - offset;
1481
+ if (!length) {
1482
+ length = remaining;
1483
+ } else {
1484
+ length = Number(length);
1485
+ if (length > remaining) {
1486
+ length = remaining;
1487
+ }
1488
+ }
1489
+ const strLen = string.length;
1490
+ if (length > strLen / 2) {
1491
+ length = strLen / 2;
1492
+ }
1493
+ let i;
1494
+ for (i = 0; i < length; ++i) {
1495
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
1496
+ if (numberIsNaN(parsed)) return i;
1497
+ buf[offset + i] = parsed;
1498
+ }
1499
+ return i;
1500
+ }
1501
+ __name(hexWrite, "hexWrite");
1502
+ function utf8Write(buf, string, offset, length) {
1503
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
1504
+ }
1505
+ __name(utf8Write, "utf8Write");
1506
+ function asciiWrite(buf, string, offset, length) {
1507
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
1508
+ }
1509
+ __name(asciiWrite, "asciiWrite");
1510
+ function base64Write(buf, string, offset, length) {
1511
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
1512
+ }
1513
+ __name(base64Write, "base64Write");
1514
+ function ucs2Write(buf, string, offset, length) {
1515
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
1516
+ }
1517
+ __name(ucs2Write, "ucs2Write");
1518
+ Buffer3.prototype.write = /* @__PURE__ */ __name(function write(string, offset, length, encoding) {
1519
+ if (offset === void 0) {
1520
+ encoding = "utf8";
1521
+ length = this.length;
1522
+ offset = 0;
1523
+ } else if (length === void 0 && typeof offset === "string") {
1524
+ encoding = offset;
1525
+ length = this.length;
1526
+ offset = 0;
1527
+ } else if (isFinite(offset)) {
1528
+ offset = offset >>> 0;
1529
+ if (isFinite(length)) {
1530
+ length = length >>> 0;
1531
+ if (encoding === void 0) encoding = "utf8";
814
1532
  } else {
815
- res = path6.slice(lastSlash + 1, index);
1533
+ encoding = length;
1534
+ length = void 0;
816
1535
  }
817
- lastSegmentLength = index - lastSlash - 1;
1536
+ } else {
1537
+ throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
1538
+ }
1539
+ const remaining = this.length - offset;
1540
+ if (length === void 0 || length > remaining) length = remaining;
1541
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
1542
+ throw new RangeError("Attempt to write outside buffer bounds");
1543
+ }
1544
+ if (!encoding) encoding = "utf8";
1545
+ let loweredCase = false;
1546
+ for (; ; ) {
1547
+ switch (encoding) {
1548
+ case "hex":
1549
+ return hexWrite(this, string, offset, length);
1550
+ case "utf8":
1551
+ case "utf-8":
1552
+ return utf8Write(this, string, offset, length);
1553
+ case "ascii":
1554
+ case "latin1":
1555
+ case "binary":
1556
+ return asciiWrite(this, string, offset, length);
1557
+ case "base64":
1558
+ return base64Write(this, string, offset, length);
1559
+ case "ucs2":
1560
+ case "ucs-2":
1561
+ case "utf16le":
1562
+ case "utf-16le":
1563
+ return ucs2Write(this, string, offset, length);
1564
+ default:
1565
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
1566
+ encoding = ("" + encoding).toLowerCase();
1567
+ loweredCase = true;
1568
+ }
1569
+ }
1570
+ }, "write");
1571
+ Buffer3.prototype.toJSON = /* @__PURE__ */ __name(function toJSON() {
1572
+ return {
1573
+ type: "Buffer",
1574
+ data: Array.prototype.slice.call(this._arr || this, 0)
1575
+ };
1576
+ }, "toJSON");
1577
+ function base64Slice(buf, start, end) {
1578
+ if (start === 0 && end === buf.length) {
1579
+ return base64.fromByteArray(buf);
1580
+ } else {
1581
+ return base64.fromByteArray(buf.slice(start, end));
818
1582
  }
819
- lastSlash = index;
820
- dots = 0;
821
- } else if (char === "." && dots !== -1) {
822
- ++dots;
823
- } else {
824
- dots = -1;
825
1583
  }
826
- }
1584
+ __name(base64Slice, "base64Slice");
1585
+ function utf8Slice(buf, start, end) {
1586
+ end = Math.min(buf.length, end);
1587
+ const res = [];
1588
+ let i = start;
1589
+ while (i < end) {
1590
+ const firstByte = buf[i];
1591
+ let codePoint = null;
1592
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
1593
+ if (i + bytesPerSequence <= end) {
1594
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
1595
+ switch (bytesPerSequence) {
1596
+ case 1:
1597
+ if (firstByte < 128) {
1598
+ codePoint = firstByte;
1599
+ }
1600
+ break;
1601
+ case 2:
1602
+ secondByte = buf[i + 1];
1603
+ if ((secondByte & 192) === 128) {
1604
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
1605
+ if (tempCodePoint > 127) {
1606
+ codePoint = tempCodePoint;
1607
+ }
1608
+ }
1609
+ break;
1610
+ case 3:
1611
+ secondByte = buf[i + 1];
1612
+ thirdByte = buf[i + 2];
1613
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
1614
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
1615
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
1616
+ codePoint = tempCodePoint;
1617
+ }
1618
+ }
1619
+ break;
1620
+ case 4:
1621
+ secondByte = buf[i + 1];
1622
+ thirdByte = buf[i + 2];
1623
+ fourthByte = buf[i + 3];
1624
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
1625
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
1626
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
1627
+ codePoint = tempCodePoint;
1628
+ }
1629
+ }
1630
+ }
1631
+ }
1632
+ if (codePoint === null) {
1633
+ codePoint = 65533;
1634
+ bytesPerSequence = 1;
1635
+ } else if (codePoint > 65535) {
1636
+ codePoint -= 65536;
1637
+ res.push(codePoint >>> 10 & 1023 | 55296);
1638
+ codePoint = 56320 | codePoint & 1023;
1639
+ }
1640
+ res.push(codePoint);
1641
+ i += bytesPerSequence;
1642
+ }
1643
+ return decodeCodePointsArray(res);
1644
+ }
1645
+ __name(utf8Slice, "utf8Slice");
1646
+ var MAX_ARGUMENTS_LENGTH = 4096;
1647
+ function decodeCodePointsArray(codePoints) {
1648
+ const len = codePoints.length;
1649
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1650
+ return String.fromCharCode.apply(String, codePoints);
1651
+ }
1652
+ let res = "";
1653
+ let i = 0;
1654
+ while (i < len) {
1655
+ res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
1656
+ }
1657
+ return res;
1658
+ }
1659
+ __name(decodeCodePointsArray, "decodeCodePointsArray");
1660
+ function asciiSlice(buf, start, end) {
1661
+ let ret = "";
1662
+ end = Math.min(buf.length, end);
1663
+ for (let i = start; i < end; ++i) {
1664
+ ret += String.fromCharCode(buf[i] & 127);
1665
+ }
1666
+ return ret;
1667
+ }
1668
+ __name(asciiSlice, "asciiSlice");
1669
+ function latin1Slice(buf, start, end) {
1670
+ let ret = "";
1671
+ end = Math.min(buf.length, end);
1672
+ for (let i = start; i < end; ++i) {
1673
+ ret += String.fromCharCode(buf[i]);
1674
+ }
1675
+ return ret;
1676
+ }
1677
+ __name(latin1Slice, "latin1Slice");
1678
+ function hexSlice(buf, start, end) {
1679
+ const len = buf.length;
1680
+ if (!start || start < 0) start = 0;
1681
+ if (!end || end < 0 || end > len) end = len;
1682
+ let out = "";
1683
+ for (let i = start; i < end; ++i) {
1684
+ out += hexSliceLookupTable[buf[i]];
1685
+ }
1686
+ return out;
1687
+ }
1688
+ __name(hexSlice, "hexSlice");
1689
+ function utf16leSlice(buf, start, end) {
1690
+ const bytes = buf.slice(start, end);
1691
+ let res = "";
1692
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1693
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1694
+ }
1695
+ return res;
1696
+ }
1697
+ __name(utf16leSlice, "utf16leSlice");
1698
+ Buffer3.prototype.slice = /* @__PURE__ */ __name(function slice(start, end) {
1699
+ const len = this.length;
1700
+ start = ~~start;
1701
+ end = end === void 0 ? len : ~~end;
1702
+ if (start < 0) {
1703
+ start += len;
1704
+ if (start < 0) start = 0;
1705
+ } else if (start > len) {
1706
+ start = len;
1707
+ }
1708
+ if (end < 0) {
1709
+ end += len;
1710
+ if (end < 0) end = 0;
1711
+ } else if (end > len) {
1712
+ end = len;
1713
+ }
1714
+ if (end < start) end = start;
1715
+ const newBuf = this.subarray(start, end);
1716
+ Object.setPrototypeOf(newBuf, Buffer3.prototype);
1717
+ return newBuf;
1718
+ }, "slice");
1719
+ function checkOffset(offset, ext, length) {
1720
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1721
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1722
+ }
1723
+ __name(checkOffset, "checkOffset");
1724
+ Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = /* @__PURE__ */ __name(function readUIntLE(offset, byteLength2, noAssert) {
1725
+ offset = offset >>> 0;
1726
+ byteLength2 = byteLength2 >>> 0;
1727
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1728
+ let val = this[offset];
1729
+ let mul = 1;
1730
+ let i = 0;
1731
+ while (++i < byteLength2 && (mul *= 256)) {
1732
+ val += this[offset + i] * mul;
1733
+ }
1734
+ return val;
1735
+ }, "readUIntLE");
1736
+ Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = /* @__PURE__ */ __name(function readUIntBE(offset, byteLength2, noAssert) {
1737
+ offset = offset >>> 0;
1738
+ byteLength2 = byteLength2 >>> 0;
1739
+ if (!noAssert) {
1740
+ checkOffset(offset, byteLength2, this.length);
1741
+ }
1742
+ let val = this[offset + --byteLength2];
1743
+ let mul = 1;
1744
+ while (byteLength2 > 0 && (mul *= 256)) {
1745
+ val += this[offset + --byteLength2] * mul;
1746
+ }
1747
+ return val;
1748
+ }, "readUIntBE");
1749
+ Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = /* @__PURE__ */ __name(function readUInt8(offset, noAssert) {
1750
+ offset = offset >>> 0;
1751
+ if (!noAssert) checkOffset(offset, 1, this.length);
1752
+ return this[offset];
1753
+ }, "readUInt8");
1754
+ Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = /* @__PURE__ */ __name(function readUInt16LE(offset, noAssert) {
1755
+ offset = offset >>> 0;
1756
+ if (!noAssert) checkOffset(offset, 2, this.length);
1757
+ return this[offset] | this[offset + 1] << 8;
1758
+ }, "readUInt16LE");
1759
+ Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = /* @__PURE__ */ __name(function readUInt16BE(offset, noAssert) {
1760
+ offset = offset >>> 0;
1761
+ if (!noAssert) checkOffset(offset, 2, this.length);
1762
+ return this[offset] << 8 | this[offset + 1];
1763
+ }, "readUInt16BE");
1764
+ Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = /* @__PURE__ */ __name(function readUInt32LE(offset, noAssert) {
1765
+ offset = offset >>> 0;
1766
+ if (!noAssert) checkOffset(offset, 4, this.length);
1767
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1768
+ }, "readUInt32LE");
1769
+ Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = /* @__PURE__ */ __name(function readUInt32BE(offset, noAssert) {
1770
+ offset = offset >>> 0;
1771
+ if (!noAssert) checkOffset(offset, 4, this.length);
1772
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1773
+ }, "readUInt32BE");
1774
+ Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(/* @__PURE__ */ __name(function readBigUInt64LE(offset) {
1775
+ offset = offset >>> 0;
1776
+ validateNumber(offset, "offset");
1777
+ const first = this[offset];
1778
+ const last = this[offset + 7];
1779
+ if (first === void 0 || last === void 0) {
1780
+ boundsError(offset, this.length - 8);
1781
+ }
1782
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1783
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1784
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1785
+ }, "readBigUInt64LE"));
1786
+ Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(/* @__PURE__ */ __name(function readBigUInt64BE(offset) {
1787
+ offset = offset >>> 0;
1788
+ validateNumber(offset, "offset");
1789
+ const first = this[offset];
1790
+ const last = this[offset + 7];
1791
+ if (first === void 0 || last === void 0) {
1792
+ boundsError(offset, this.length - 8);
1793
+ }
1794
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1795
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1796
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1797
+ }, "readBigUInt64BE"));
1798
+ Buffer3.prototype.readIntLE = /* @__PURE__ */ __name(function readIntLE(offset, byteLength2, noAssert) {
1799
+ offset = offset >>> 0;
1800
+ byteLength2 = byteLength2 >>> 0;
1801
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1802
+ let val = this[offset];
1803
+ let mul = 1;
1804
+ let i = 0;
1805
+ while (++i < byteLength2 && (mul *= 256)) {
1806
+ val += this[offset + i] * mul;
1807
+ }
1808
+ mul *= 128;
1809
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1810
+ return val;
1811
+ }, "readIntLE");
1812
+ Buffer3.prototype.readIntBE = /* @__PURE__ */ __name(function readIntBE(offset, byteLength2, noAssert) {
1813
+ offset = offset >>> 0;
1814
+ byteLength2 = byteLength2 >>> 0;
1815
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1816
+ let i = byteLength2;
1817
+ let mul = 1;
1818
+ let val = this[offset + --i];
1819
+ while (i > 0 && (mul *= 256)) {
1820
+ val += this[offset + --i] * mul;
1821
+ }
1822
+ mul *= 128;
1823
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1824
+ return val;
1825
+ }, "readIntBE");
1826
+ Buffer3.prototype.readInt8 = /* @__PURE__ */ __name(function readInt8(offset, noAssert) {
1827
+ offset = offset >>> 0;
1828
+ if (!noAssert) checkOffset(offset, 1, this.length);
1829
+ if (!(this[offset] & 128)) return this[offset];
1830
+ return (255 - this[offset] + 1) * -1;
1831
+ }, "readInt8");
1832
+ Buffer3.prototype.readInt16LE = /* @__PURE__ */ __name(function readInt16LE(offset, noAssert) {
1833
+ offset = offset >>> 0;
1834
+ if (!noAssert) checkOffset(offset, 2, this.length);
1835
+ const val = this[offset] | this[offset + 1] << 8;
1836
+ return val & 32768 ? val | 4294901760 : val;
1837
+ }, "readInt16LE");
1838
+ Buffer3.prototype.readInt16BE = /* @__PURE__ */ __name(function readInt16BE(offset, noAssert) {
1839
+ offset = offset >>> 0;
1840
+ if (!noAssert) checkOffset(offset, 2, this.length);
1841
+ const val = this[offset + 1] | this[offset] << 8;
1842
+ return val & 32768 ? val | 4294901760 : val;
1843
+ }, "readInt16BE");
1844
+ Buffer3.prototype.readInt32LE = /* @__PURE__ */ __name(function readInt32LE(offset, noAssert) {
1845
+ offset = offset >>> 0;
1846
+ if (!noAssert) checkOffset(offset, 4, this.length);
1847
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1848
+ }, "readInt32LE");
1849
+ Buffer3.prototype.readInt32BE = /* @__PURE__ */ __name(function readInt32BE(offset, noAssert) {
1850
+ offset = offset >>> 0;
1851
+ if (!noAssert) checkOffset(offset, 4, this.length);
1852
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1853
+ }, "readInt32BE");
1854
+ Buffer3.prototype.readBigInt64LE = defineBigIntMethod(/* @__PURE__ */ __name(function readBigInt64LE(offset) {
1855
+ offset = offset >>> 0;
1856
+ validateNumber(offset, "offset");
1857
+ const first = this[offset];
1858
+ const last = this[offset + 7];
1859
+ if (first === void 0 || last === void 0) {
1860
+ boundsError(offset, this.length - 8);
1861
+ }
1862
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1863
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1864
+ }, "readBigInt64LE"));
1865
+ Buffer3.prototype.readBigInt64BE = defineBigIntMethod(/* @__PURE__ */ __name(function readBigInt64BE(offset) {
1866
+ offset = offset >>> 0;
1867
+ validateNumber(offset, "offset");
1868
+ const first = this[offset];
1869
+ const last = this[offset + 7];
1870
+ if (first === void 0 || last === void 0) {
1871
+ boundsError(offset, this.length - 8);
1872
+ }
1873
+ const val = (first << 24) + // Overflow
1874
+ this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1875
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1876
+ }, "readBigInt64BE"));
1877
+ Buffer3.prototype.readFloatLE = /* @__PURE__ */ __name(function readFloatLE(offset, noAssert) {
1878
+ offset = offset >>> 0;
1879
+ if (!noAssert) checkOffset(offset, 4, this.length);
1880
+ return ieee754.read(this, offset, true, 23, 4);
1881
+ }, "readFloatLE");
1882
+ Buffer3.prototype.readFloatBE = /* @__PURE__ */ __name(function readFloatBE(offset, noAssert) {
1883
+ offset = offset >>> 0;
1884
+ if (!noAssert) checkOffset(offset, 4, this.length);
1885
+ return ieee754.read(this, offset, false, 23, 4);
1886
+ }, "readFloatBE");
1887
+ Buffer3.prototype.readDoubleLE = /* @__PURE__ */ __name(function readDoubleLE(offset, noAssert) {
1888
+ offset = offset >>> 0;
1889
+ if (!noAssert) checkOffset(offset, 8, this.length);
1890
+ return ieee754.read(this, offset, true, 52, 8);
1891
+ }, "readDoubleLE");
1892
+ Buffer3.prototype.readDoubleBE = /* @__PURE__ */ __name(function readDoubleBE(offset, noAssert) {
1893
+ offset = offset >>> 0;
1894
+ if (!noAssert) checkOffset(offset, 8, this.length);
1895
+ return ieee754.read(this, offset, false, 52, 8);
1896
+ }, "readDoubleBE");
1897
+ function checkInt(buf, value, offset, ext, max, min) {
1898
+ if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1899
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
1900
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1901
+ }
1902
+ __name(checkInt, "checkInt");
1903
+ Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = /* @__PURE__ */ __name(function writeUIntLE(value, offset, byteLength2, noAssert) {
1904
+ value = +value;
1905
+ offset = offset >>> 0;
1906
+ byteLength2 = byteLength2 >>> 0;
1907
+ if (!noAssert) {
1908
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1909
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1910
+ }
1911
+ let mul = 1;
1912
+ let i = 0;
1913
+ this[offset] = value & 255;
1914
+ while (++i < byteLength2 && (mul *= 256)) {
1915
+ this[offset + i] = value / mul & 255;
1916
+ }
1917
+ return offset + byteLength2;
1918
+ }, "writeUIntLE");
1919
+ Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = /* @__PURE__ */ __name(function writeUIntBE(value, offset, byteLength2, noAssert) {
1920
+ value = +value;
1921
+ offset = offset >>> 0;
1922
+ byteLength2 = byteLength2 >>> 0;
1923
+ if (!noAssert) {
1924
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1925
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1926
+ }
1927
+ let i = byteLength2 - 1;
1928
+ let mul = 1;
1929
+ this[offset + i] = value & 255;
1930
+ while (--i >= 0 && (mul *= 256)) {
1931
+ this[offset + i] = value / mul & 255;
1932
+ }
1933
+ return offset + byteLength2;
1934
+ }, "writeUIntBE");
1935
+ Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = /* @__PURE__ */ __name(function writeUInt8(value, offset, noAssert) {
1936
+ value = +value;
1937
+ offset = offset >>> 0;
1938
+ if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
1939
+ this[offset] = value & 255;
1940
+ return offset + 1;
1941
+ }, "writeUInt8");
1942
+ Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = /* @__PURE__ */ __name(function writeUInt16LE(value, offset, noAssert) {
1943
+ value = +value;
1944
+ offset = offset >>> 0;
1945
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1946
+ this[offset] = value & 255;
1947
+ this[offset + 1] = value >>> 8;
1948
+ return offset + 2;
1949
+ }, "writeUInt16LE");
1950
+ Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = /* @__PURE__ */ __name(function writeUInt16BE(value, offset, noAssert) {
1951
+ value = +value;
1952
+ offset = offset >>> 0;
1953
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1954
+ this[offset] = value >>> 8;
1955
+ this[offset + 1] = value & 255;
1956
+ return offset + 2;
1957
+ }, "writeUInt16BE");
1958
+ Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = /* @__PURE__ */ __name(function writeUInt32LE(value, offset, noAssert) {
1959
+ value = +value;
1960
+ offset = offset >>> 0;
1961
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1962
+ this[offset + 3] = value >>> 24;
1963
+ this[offset + 2] = value >>> 16;
1964
+ this[offset + 1] = value >>> 8;
1965
+ this[offset] = value & 255;
1966
+ return offset + 4;
1967
+ }, "writeUInt32LE");
1968
+ Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = /* @__PURE__ */ __name(function writeUInt32BE(value, offset, noAssert) {
1969
+ value = +value;
1970
+ offset = offset >>> 0;
1971
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1972
+ this[offset] = value >>> 24;
1973
+ this[offset + 1] = value >>> 16;
1974
+ this[offset + 2] = value >>> 8;
1975
+ this[offset + 3] = value & 255;
1976
+ return offset + 4;
1977
+ }, "writeUInt32BE");
1978
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1979
+ checkIntBI(value, min, max, buf, offset, 7);
1980
+ let lo = Number(value & BigInt(4294967295));
1981
+ buf[offset++] = lo;
1982
+ lo = lo >> 8;
1983
+ buf[offset++] = lo;
1984
+ lo = lo >> 8;
1985
+ buf[offset++] = lo;
1986
+ lo = lo >> 8;
1987
+ buf[offset++] = lo;
1988
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1989
+ buf[offset++] = hi;
1990
+ hi = hi >> 8;
1991
+ buf[offset++] = hi;
1992
+ hi = hi >> 8;
1993
+ buf[offset++] = hi;
1994
+ hi = hi >> 8;
1995
+ buf[offset++] = hi;
1996
+ return offset;
1997
+ }
1998
+ __name(wrtBigUInt64LE, "wrtBigUInt64LE");
1999
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
2000
+ checkIntBI(value, min, max, buf, offset, 7);
2001
+ let lo = Number(value & BigInt(4294967295));
2002
+ buf[offset + 7] = lo;
2003
+ lo = lo >> 8;
2004
+ buf[offset + 6] = lo;
2005
+ lo = lo >> 8;
2006
+ buf[offset + 5] = lo;
2007
+ lo = lo >> 8;
2008
+ buf[offset + 4] = lo;
2009
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
2010
+ buf[offset + 3] = hi;
2011
+ hi = hi >> 8;
2012
+ buf[offset + 2] = hi;
2013
+ hi = hi >> 8;
2014
+ buf[offset + 1] = hi;
2015
+ hi = hi >> 8;
2016
+ buf[offset] = hi;
2017
+ return offset + 8;
2018
+ }
2019
+ __name(wrtBigUInt64BE, "wrtBigUInt64BE");
2020
+ Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(/* @__PURE__ */ __name(function writeBigUInt64LE(value, offset = 0) {
2021
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
2022
+ }, "writeBigUInt64LE"));
2023
+ Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(/* @__PURE__ */ __name(function writeBigUInt64BE(value, offset = 0) {
2024
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
2025
+ }, "writeBigUInt64BE"));
2026
+ Buffer3.prototype.writeIntLE = /* @__PURE__ */ __name(function writeIntLE(value, offset, byteLength2, noAssert) {
2027
+ value = +value;
2028
+ offset = offset >>> 0;
2029
+ if (!noAssert) {
2030
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
2031
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
2032
+ }
2033
+ let i = 0;
2034
+ let mul = 1;
2035
+ let sub = 0;
2036
+ this[offset] = value & 255;
2037
+ while (++i < byteLength2 && (mul *= 256)) {
2038
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2039
+ sub = 1;
2040
+ }
2041
+ this[offset + i] = (value / mul >> 0) - sub & 255;
2042
+ }
2043
+ return offset + byteLength2;
2044
+ }, "writeIntLE");
2045
+ Buffer3.prototype.writeIntBE = /* @__PURE__ */ __name(function writeIntBE(value, offset, byteLength2, noAssert) {
2046
+ value = +value;
2047
+ offset = offset >>> 0;
2048
+ if (!noAssert) {
2049
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
2050
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
2051
+ }
2052
+ let i = byteLength2 - 1;
2053
+ let mul = 1;
2054
+ let sub = 0;
2055
+ this[offset + i] = value & 255;
2056
+ while (--i >= 0 && (mul *= 256)) {
2057
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2058
+ sub = 1;
2059
+ }
2060
+ this[offset + i] = (value / mul >> 0) - sub & 255;
2061
+ }
2062
+ return offset + byteLength2;
2063
+ }, "writeIntBE");
2064
+ Buffer3.prototype.writeInt8 = /* @__PURE__ */ __name(function writeInt8(value, offset, noAssert) {
2065
+ value = +value;
2066
+ offset = offset >>> 0;
2067
+ if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
2068
+ if (value < 0) value = 255 + value + 1;
2069
+ this[offset] = value & 255;
2070
+ return offset + 1;
2071
+ }, "writeInt8");
2072
+ Buffer3.prototype.writeInt16LE = /* @__PURE__ */ __name(function writeInt16LE(value, offset, noAssert) {
2073
+ value = +value;
2074
+ offset = offset >>> 0;
2075
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
2076
+ this[offset] = value & 255;
2077
+ this[offset + 1] = value >>> 8;
2078
+ return offset + 2;
2079
+ }, "writeInt16LE");
2080
+ Buffer3.prototype.writeInt16BE = /* @__PURE__ */ __name(function writeInt16BE(value, offset, noAssert) {
2081
+ value = +value;
2082
+ offset = offset >>> 0;
2083
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
2084
+ this[offset] = value >>> 8;
2085
+ this[offset + 1] = value & 255;
2086
+ return offset + 2;
2087
+ }, "writeInt16BE");
2088
+ Buffer3.prototype.writeInt32LE = /* @__PURE__ */ __name(function writeInt32LE(value, offset, noAssert) {
2089
+ value = +value;
2090
+ offset = offset >>> 0;
2091
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
2092
+ this[offset] = value & 255;
2093
+ this[offset + 1] = value >>> 8;
2094
+ this[offset + 2] = value >>> 16;
2095
+ this[offset + 3] = value >>> 24;
2096
+ return offset + 4;
2097
+ }, "writeInt32LE");
2098
+ Buffer3.prototype.writeInt32BE = /* @__PURE__ */ __name(function writeInt32BE(value, offset, noAssert) {
2099
+ value = +value;
2100
+ offset = offset >>> 0;
2101
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
2102
+ if (value < 0) value = 4294967295 + value + 1;
2103
+ this[offset] = value >>> 24;
2104
+ this[offset + 1] = value >>> 16;
2105
+ this[offset + 2] = value >>> 8;
2106
+ this[offset + 3] = value & 255;
2107
+ return offset + 4;
2108
+ }, "writeInt32BE");
2109
+ Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(/* @__PURE__ */ __name(function writeBigInt64LE(value, offset = 0) {
2110
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
2111
+ }, "writeBigInt64LE"));
2112
+ Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(/* @__PURE__ */ __name(function writeBigInt64BE(value, offset = 0) {
2113
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
2114
+ }, "writeBigInt64BE"));
2115
+ function checkIEEE754(buf, value, offset, ext, max, min) {
2116
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
2117
+ if (offset < 0) throw new RangeError("Index out of range");
2118
+ }
2119
+ __name(checkIEEE754, "checkIEEE754");
2120
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
2121
+ value = +value;
2122
+ offset = offset >>> 0;
2123
+ if (!noAssert) {
2124
+ checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
2125
+ }
2126
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
2127
+ return offset + 4;
2128
+ }
2129
+ __name(writeFloat, "writeFloat");
2130
+ Buffer3.prototype.writeFloatLE = /* @__PURE__ */ __name(function writeFloatLE(value, offset, noAssert) {
2131
+ return writeFloat(this, value, offset, true, noAssert);
2132
+ }, "writeFloatLE");
2133
+ Buffer3.prototype.writeFloatBE = /* @__PURE__ */ __name(function writeFloatBE(value, offset, noAssert) {
2134
+ return writeFloat(this, value, offset, false, noAssert);
2135
+ }, "writeFloatBE");
2136
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
2137
+ value = +value;
2138
+ offset = offset >>> 0;
2139
+ if (!noAssert) {
2140
+ checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
2141
+ }
2142
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
2143
+ return offset + 8;
2144
+ }
2145
+ __name(writeDouble, "writeDouble");
2146
+ Buffer3.prototype.writeDoubleLE = /* @__PURE__ */ __name(function writeDoubleLE(value, offset, noAssert) {
2147
+ return writeDouble(this, value, offset, true, noAssert);
2148
+ }, "writeDoubleLE");
2149
+ Buffer3.prototype.writeDoubleBE = /* @__PURE__ */ __name(function writeDoubleBE(value, offset, noAssert) {
2150
+ return writeDouble(this, value, offset, false, noAssert);
2151
+ }, "writeDoubleBE");
2152
+ Buffer3.prototype.copy = /* @__PURE__ */ __name(function copy2(target, targetStart, start, end) {
2153
+ if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
2154
+ if (!start) start = 0;
2155
+ if (!end && end !== 0) end = this.length;
2156
+ if (targetStart >= target.length) targetStart = target.length;
2157
+ if (!targetStart) targetStart = 0;
2158
+ if (end > 0 && end < start) end = start;
2159
+ if (end === start) return 0;
2160
+ if (target.length === 0 || this.length === 0) return 0;
2161
+ if (targetStart < 0) {
2162
+ throw new RangeError("targetStart out of bounds");
2163
+ }
2164
+ if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
2165
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
2166
+ if (end > this.length) end = this.length;
2167
+ if (target.length - targetStart < end - start) {
2168
+ end = target.length - targetStart + start;
2169
+ }
2170
+ const len = end - start;
2171
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
2172
+ this.copyWithin(targetStart, start, end);
2173
+ } else {
2174
+ Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
2175
+ }
2176
+ return len;
2177
+ }, "copy");
2178
+ Buffer3.prototype.fill = /* @__PURE__ */ __name(function fill(val, start, end, encoding) {
2179
+ if (typeof val === "string") {
2180
+ if (typeof start === "string") {
2181
+ encoding = start;
2182
+ start = 0;
2183
+ end = this.length;
2184
+ } else if (typeof end === "string") {
2185
+ encoding = end;
2186
+ end = this.length;
2187
+ }
2188
+ if (encoding !== void 0 && typeof encoding !== "string") {
2189
+ throw new TypeError("encoding must be a string");
2190
+ }
2191
+ if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
2192
+ throw new TypeError("Unknown encoding: " + encoding);
2193
+ }
2194
+ if (val.length === 1) {
2195
+ const code = val.charCodeAt(0);
2196
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
2197
+ val = code;
2198
+ }
2199
+ }
2200
+ } else if (typeof val === "number") {
2201
+ val = val & 255;
2202
+ } else if (typeof val === "boolean") {
2203
+ val = Number(val);
2204
+ }
2205
+ if (start < 0 || this.length < start || this.length < end) {
2206
+ throw new RangeError("Out of range index");
2207
+ }
2208
+ if (end <= start) {
2209
+ return this;
2210
+ }
2211
+ start = start >>> 0;
2212
+ end = end === void 0 ? this.length : end >>> 0;
2213
+ if (!val) val = 0;
2214
+ let i;
2215
+ if (typeof val === "number") {
2216
+ for (i = start; i < end; ++i) {
2217
+ this[i] = val;
2218
+ }
2219
+ } else {
2220
+ const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
2221
+ const len = bytes.length;
2222
+ if (len === 0) {
2223
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
2224
+ }
2225
+ for (i = 0; i < end - start; ++i) {
2226
+ this[i + start] = bytes[i % len];
2227
+ }
2228
+ }
2229
+ return this;
2230
+ }, "fill");
2231
+ var errors = {};
2232
+ function E(sym, getMessage, Base) {
2233
+ errors[sym] = class NodeError extends Base {
2234
+ static {
2235
+ __name(this, "NodeError");
2236
+ }
2237
+ constructor() {
2238
+ super();
2239
+ Object.defineProperty(this, "message", {
2240
+ value: getMessage.apply(this, arguments),
2241
+ writable: true,
2242
+ configurable: true
2243
+ });
2244
+ this.name = `${this.name} [${sym}]`;
2245
+ this.stack;
2246
+ delete this.name;
2247
+ }
2248
+ get code() {
2249
+ return sym;
2250
+ }
2251
+ set code(value) {
2252
+ Object.defineProperty(this, "code", {
2253
+ configurable: true,
2254
+ enumerable: true,
2255
+ value,
2256
+ writable: true
2257
+ });
2258
+ }
2259
+ toString() {
2260
+ return `${this.name} [${sym}]: ${this.message}`;
2261
+ }
2262
+ };
2263
+ }
2264
+ __name(E, "E");
2265
+ E("ERR_BUFFER_OUT_OF_BOUNDS", function(name) {
2266
+ if (name) {
2267
+ return `${name} is outside of buffer bounds`;
2268
+ }
2269
+ return "Attempt to access memory outside buffer bounds";
2270
+ }, RangeError);
2271
+ E("ERR_INVALID_ARG_TYPE", function(name, actual) {
2272
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
2273
+ }, TypeError);
2274
+ E("ERR_OUT_OF_RANGE", function(str, range, input) {
2275
+ let msg = `The value of "${str}" is out of range.`;
2276
+ let received = input;
2277
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
2278
+ received = addNumericalSeparator(String(input));
2279
+ } else if (typeof input === "bigint") {
2280
+ received = String(input);
2281
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
2282
+ received = addNumericalSeparator(received);
2283
+ }
2284
+ received += "n";
2285
+ }
2286
+ msg += ` It must be ${range}. Received ${received}`;
2287
+ return msg;
2288
+ }, RangeError);
2289
+ function addNumericalSeparator(val) {
2290
+ let res = "";
2291
+ let i = val.length;
2292
+ const start = val[0] === "-" ? 1 : 0;
2293
+ for (; i >= start + 4; i -= 3) {
2294
+ res = `_${val.slice(i - 3, i)}${res}`;
2295
+ }
2296
+ return `${val.slice(0, i)}${res}`;
2297
+ }
2298
+ __name(addNumericalSeparator, "addNumericalSeparator");
2299
+ function checkBounds(buf, offset, byteLength2) {
2300
+ validateNumber(offset, "offset");
2301
+ if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
2302
+ boundsError(offset, buf.length - (byteLength2 + 1));
2303
+ }
2304
+ }
2305
+ __name(checkBounds, "checkBounds");
2306
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
2307
+ if (value > max || value < min) {
2308
+ const n = typeof min === "bigint" ? "n" : "";
2309
+ let range;
2310
+ if (byteLength2 > 3) {
2311
+ if (min === 0 || min === BigInt(0)) {
2312
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
2313
+ } else {
2314
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
2315
+ }
2316
+ } else {
2317
+ range = `>= ${min}${n} and <= ${max}${n}`;
2318
+ }
2319
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
2320
+ }
2321
+ checkBounds(buf, offset, byteLength2);
2322
+ }
2323
+ __name(checkIntBI, "checkIntBI");
2324
+ function validateNumber(value, name) {
2325
+ if (typeof value !== "number") {
2326
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
2327
+ }
2328
+ }
2329
+ __name(validateNumber, "validateNumber");
2330
+ function boundsError(value, length, type) {
2331
+ if (Math.floor(value) !== value) {
2332
+ validateNumber(value, type);
2333
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
2334
+ }
2335
+ if (length < 0) {
2336
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
2337
+ }
2338
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value);
2339
+ }
2340
+ __name(boundsError, "boundsError");
2341
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
2342
+ function base64clean(str) {
2343
+ str = str.split("=")[0];
2344
+ str = str.trim().replace(INVALID_BASE64_RE, "");
2345
+ if (str.length < 2) return "";
2346
+ while (str.length % 4 !== 0) {
2347
+ str = str + "=";
2348
+ }
2349
+ return str;
2350
+ }
2351
+ __name(base64clean, "base64clean");
2352
+ function utf8ToBytes(string, units) {
2353
+ units = units || Infinity;
2354
+ let codePoint;
2355
+ const length = string.length;
2356
+ let leadSurrogate = null;
2357
+ const bytes = [];
2358
+ for (let i = 0; i < length; ++i) {
2359
+ codePoint = string.charCodeAt(i);
2360
+ if (codePoint > 55295 && codePoint < 57344) {
2361
+ if (!leadSurrogate) {
2362
+ if (codePoint > 56319) {
2363
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
2364
+ continue;
2365
+ } else if (i + 1 === length) {
2366
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
2367
+ continue;
2368
+ }
2369
+ leadSurrogate = codePoint;
2370
+ continue;
2371
+ }
2372
+ if (codePoint < 56320) {
2373
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
2374
+ leadSurrogate = codePoint;
2375
+ continue;
2376
+ }
2377
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
2378
+ } else if (leadSurrogate) {
2379
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
2380
+ }
2381
+ leadSurrogate = null;
2382
+ if (codePoint < 128) {
2383
+ if ((units -= 1) < 0) break;
2384
+ bytes.push(codePoint);
2385
+ } else if (codePoint < 2048) {
2386
+ if ((units -= 2) < 0) break;
2387
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
2388
+ } else if (codePoint < 65536) {
2389
+ if ((units -= 3) < 0) break;
2390
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
2391
+ } else if (codePoint < 1114112) {
2392
+ if ((units -= 4) < 0) break;
2393
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
2394
+ } else {
2395
+ throw new Error("Invalid code point");
2396
+ }
2397
+ }
2398
+ return bytes;
2399
+ }
2400
+ __name(utf8ToBytes, "utf8ToBytes");
2401
+ function asciiToBytes(str) {
2402
+ const byteArray = [];
2403
+ for (let i = 0; i < str.length; ++i) {
2404
+ byteArray.push(str.charCodeAt(i) & 255);
2405
+ }
2406
+ return byteArray;
2407
+ }
2408
+ __name(asciiToBytes, "asciiToBytes");
2409
+ function utf16leToBytes(str, units) {
2410
+ let c, hi, lo;
2411
+ const byteArray = [];
2412
+ for (let i = 0; i < str.length; ++i) {
2413
+ if ((units -= 2) < 0) break;
2414
+ c = str.charCodeAt(i);
2415
+ hi = c >> 8;
2416
+ lo = c % 256;
2417
+ byteArray.push(lo);
2418
+ byteArray.push(hi);
2419
+ }
2420
+ return byteArray;
2421
+ }
2422
+ __name(utf16leToBytes, "utf16leToBytes");
2423
+ function base64ToBytes(str) {
2424
+ return base64.toByteArray(base64clean(str));
2425
+ }
2426
+ __name(base64ToBytes, "base64ToBytes");
2427
+ function blitBuffer(src, dst, offset, length) {
2428
+ let i;
2429
+ for (i = 0; i < length; ++i) {
2430
+ if (i + offset >= dst.length || i >= src.length) break;
2431
+ dst[i + offset] = src[i];
2432
+ }
2433
+ return i;
2434
+ }
2435
+ __name(blitBuffer, "blitBuffer");
2436
+ function isInstance(obj, type) {
2437
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
2438
+ }
2439
+ __name(isInstance, "isInstance");
2440
+ function numberIsNaN(obj) {
2441
+ return obj !== obj;
2442
+ }
2443
+ __name(numberIsNaN, "numberIsNaN");
2444
+ var hexSliceLookupTable = function() {
2445
+ const alphabet = "0123456789abcdef";
2446
+ const table = new Array(256);
2447
+ for (let i = 0; i < 16; ++i) {
2448
+ const i16 = i * 16;
2449
+ for (let j = 0; j < 16; ++j) {
2450
+ table[i16 + j] = alphabet[i] + alphabet[j];
2451
+ }
2452
+ }
2453
+ return table;
2454
+ }();
2455
+ function defineBigIntMethod(fn) {
2456
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
2457
+ }
2458
+ __name(defineBigIntMethod, "defineBigIntMethod");
2459
+ function BufferBigIntNotDefined() {
2460
+ throw new Error("BigInt not supported");
2461
+ }
2462
+ __name(BufferBigIntNotDefined, "BufferBigIntNotDefined");
2463
+ }
2464
+ });
2465
+
2466
+ // src/index.ts
2467
+ init_esm_shims();
2468
+
2469
+ // src/prisma-generator.ts
2470
+ init_esm_shims();
2471
+
2472
+ // ../fs/src/helpers.ts
2473
+ init_esm_shims();
2474
+
2475
+ // ../path/src/exists.ts
2476
+ init_esm_shims();
2477
+ import { existsSync as existsSyncFs } from "node:fs";
2478
+ import { access, constants } from "node:fs/promises";
2479
+ var existsSync = /* @__PURE__ */ __name((filePath) => {
2480
+ return existsSyncFs(filePath);
2481
+ }, "existsSync");
2482
+ var exists = /* @__PURE__ */ __name(async (filePath) => {
2483
+ return access(filePath, constants.F_OK).then(() => true).catch(() => false);
2484
+ }, "exists");
2485
+
2486
+ // ../fs/src/helpers.ts
2487
+ import { mkdir, readFile, rm } from "node:fs/promises";
2488
+ async function createDirectory(path5) {
2489
+ if (await exists(path5)) {
2490
+ return;
2491
+ }
2492
+ return mkdir(path5, {
2493
+ recursive: true
2494
+ });
2495
+ }
2496
+ __name(createDirectory, "createDirectory");
2497
+
2498
+ // ../path/src/join-paths.ts
2499
+ init_esm_shims();
2500
+ var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
2501
+ function normalizeWindowsPath(input = "") {
2502
+ if (!input) {
2503
+ return input;
2504
+ }
2505
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
2506
+ }
2507
+ __name(normalizeWindowsPath, "normalizeWindowsPath");
2508
+ var _UNC_REGEX = /^[/\\]{2}/;
2509
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
2510
+ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
2511
+ var isAbsolute = /* @__PURE__ */ __name(function(p) {
2512
+ return _IS_ABSOLUTE_RE.test(p);
2513
+ }, "isAbsolute");
2514
+ var correctPaths = /* @__PURE__ */ __name(function(path5) {
2515
+ if (!path5 || path5.length === 0) {
2516
+ return ".";
2517
+ }
2518
+ path5 = normalizeWindowsPath(path5);
2519
+ const isUNCPath = path5.match(_UNC_REGEX);
2520
+ const isPathAbsolute = isAbsolute(path5);
2521
+ const trailingSeparator = path5[path5.length - 1] === "/";
2522
+ path5 = normalizeString(path5, !isPathAbsolute);
2523
+ if (path5.length === 0) {
2524
+ if (isPathAbsolute) {
2525
+ return "/";
2526
+ }
2527
+ return trailingSeparator ? "./" : ".";
2528
+ }
2529
+ if (trailingSeparator) {
2530
+ path5 += "/";
2531
+ }
2532
+ if (_DRIVE_LETTER_RE.test(path5)) {
2533
+ path5 += "/";
2534
+ }
2535
+ if (isUNCPath) {
2536
+ if (!isPathAbsolute) {
2537
+ return `//./${path5}`;
2538
+ }
2539
+ return `//${path5}`;
2540
+ }
2541
+ return isPathAbsolute && !isAbsolute(path5) ? `/${path5}` : path5;
2542
+ }, "correctPaths");
2543
+ var joinPaths = /* @__PURE__ */ __name(function(...segments) {
2544
+ let path5 = "";
2545
+ for (const seg of segments) {
2546
+ if (!seg) {
2547
+ continue;
2548
+ }
2549
+ if (path5.length > 0) {
2550
+ const pathTrailing = path5[path5.length - 1] === "/";
2551
+ const segLeading = seg[0] === "/";
2552
+ const both = pathTrailing && segLeading;
2553
+ if (both) {
2554
+ path5 += seg.slice(1);
2555
+ } else {
2556
+ path5 += pathTrailing || segLeading ? seg : `/${seg}`;
2557
+ }
2558
+ } else {
2559
+ path5 += seg;
2560
+ }
2561
+ }
2562
+ return correctPaths(path5);
2563
+ }, "joinPaths");
2564
+ function normalizeString(path5, allowAboveRoot) {
2565
+ let res = "";
2566
+ let lastSegmentLength = 0;
2567
+ let lastSlash = -1;
2568
+ let dots = 0;
2569
+ let char = null;
2570
+ for (let index = 0; index <= path5.length; ++index) {
2571
+ if (index < path5.length) {
2572
+ char = path5[index];
2573
+ } else if (char === "/") {
2574
+ break;
2575
+ } else {
2576
+ char = "/";
2577
+ }
2578
+ if (char === "/") {
2579
+ if (lastSlash === index - 1 || dots === 1) {
2580
+ } else if (dots === 2) {
2581
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
2582
+ if (res.length > 2) {
2583
+ const lastSlashIndex = res.lastIndexOf("/");
2584
+ if (lastSlashIndex === -1) {
2585
+ res = "";
2586
+ lastSegmentLength = 0;
2587
+ } else {
2588
+ res = res.slice(0, lastSlashIndex);
2589
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
2590
+ }
2591
+ lastSlash = index;
2592
+ dots = 0;
2593
+ continue;
2594
+ } else if (res.length > 0) {
2595
+ res = "";
2596
+ lastSegmentLength = 0;
2597
+ lastSlash = index;
2598
+ dots = 0;
2599
+ continue;
2600
+ }
2601
+ }
2602
+ if (allowAboveRoot) {
2603
+ res += res.length > 0 ? "/.." : "..";
2604
+ lastSegmentLength = 2;
2605
+ }
2606
+ } else {
2607
+ if (res.length > 0) {
2608
+ res += `/${path5.slice(lastSlash + 1, index)}`;
2609
+ } else {
2610
+ res = path5.slice(lastSlash + 1, index);
2611
+ }
2612
+ lastSegmentLength = index - lastSlash - 1;
2613
+ }
2614
+ lastSlash = index;
2615
+ dots = 0;
2616
+ } else if (char === "." && dots !== -1) {
2617
+ ++dots;
2618
+ } else {
2619
+ dots = -1;
2620
+ }
2621
+ }
827
2622
  return res;
828
2623
  }
829
2624
  __name(normalizeString, "normalizeString");
830
2625
 
831
2626
  // src/prisma-generator.ts
832
2627
  var import_pluralize = __toESM(require_pluralize(), 1);
833
- import path5 from "node:path";
2628
+ import path4 from "node:path";
834
2629
 
835
2630
  // src/config.ts
836
2631
  init_esm_shims();
@@ -1197,8 +2992,8 @@ function getErrorMap() {
1197
2992
  }
1198
2993
  __name(getErrorMap, "getErrorMap");
1199
2994
  var makeIssue = /* @__PURE__ */ __name((params) => {
1200
- const { data, path: path6, errorMaps, issueData } = params;
1201
- const fullPath = [...path6, ...issueData.path || []];
2995
+ const { data, path: path5, errorMaps, issueData } = params;
2996
+ const fullPath = [...path5, ...issueData.path || []];
1202
2997
  const fullIssue = {
1203
2998
  ...issueData,
1204
2999
  path: fullPath
@@ -1332,11 +3127,11 @@ var ParseInputLazyPath = class {
1332
3127
  static {
1333
3128
  __name(this, "ParseInputLazyPath");
1334
3129
  }
1335
- constructor(parent, value, path6, key) {
3130
+ constructor(parent, value, path5, key) {
1336
3131
  this._cachedPath = [];
1337
3132
  this.parent = parent;
1338
3133
  this.data = value;
1339
- this._path = path6;
3134
+ this._path = path5;
1340
3135
  this._key = key;
1341
3136
  }
1342
3137
  get path() {
@@ -5321,34 +7116,34 @@ __name2(normalizeWindowsPath2, "normalizeWindowsPath");
5321
7116
  var _UNC_REGEX2 = /^[/\\]{2}/;
5322
7117
  var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
5323
7118
  var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
5324
- var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
5325
- if (!path6 || path6.length === 0) {
7119
+ var correctPaths2 = /* @__PURE__ */ __name2(function(path5) {
7120
+ if (!path5 || path5.length === 0) {
5326
7121
  return ".";
5327
7122
  }
5328
- path6 = normalizeWindowsPath2(path6);
5329
- const isUNCPath = path6.match(_UNC_REGEX2);
5330
- const isPathAbsolute = isAbsolute2(path6);
5331
- const trailingSeparator = path6[path6.length - 1] === "/";
5332
- path6 = normalizeString2(path6, !isPathAbsolute);
5333
- if (path6.length === 0) {
7123
+ path5 = normalizeWindowsPath2(path5);
7124
+ const isUNCPath = path5.match(_UNC_REGEX2);
7125
+ const isPathAbsolute = isAbsolute2(path5);
7126
+ const trailingSeparator = path5[path5.length - 1] === "/";
7127
+ path5 = normalizeString2(path5, !isPathAbsolute);
7128
+ if (path5.length === 0) {
5334
7129
  if (isPathAbsolute) {
5335
7130
  return "/";
5336
7131
  }
5337
7132
  return trailingSeparator ? "./" : ".";
5338
7133
  }
5339
7134
  if (trailingSeparator) {
5340
- path6 += "/";
7135
+ path5 += "/";
5341
7136
  }
5342
- if (_DRIVE_LETTER_RE2.test(path6)) {
5343
- path6 += "/";
7137
+ if (_DRIVE_LETTER_RE2.test(path5)) {
7138
+ path5 += "/";
5344
7139
  }
5345
7140
  if (isUNCPath) {
5346
7141
  if (!isPathAbsolute) {
5347
- return `//./${path6}`;
7142
+ return `//./${path5}`;
5348
7143
  }
5349
- return `//${path6}`;
7144
+ return `//${path5}`;
5350
7145
  }
5351
- return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
7146
+ return isPathAbsolute && !isAbsolute2(path5) ? `/${path5}` : path5;
5352
7147
  }, "correctPaths");
5353
7148
  function cwd() {
5354
7149
  if (typeof process !== "undefined" && typeof process.cwd === "function") {
@@ -5358,15 +7153,15 @@ function cwd() {
5358
7153
  }
5359
7154
  __name(cwd, "cwd");
5360
7155
  __name2(cwd, "cwd");
5361
- function normalizeString2(path6, allowAboveRoot) {
7156
+ function normalizeString2(path5, allowAboveRoot) {
5362
7157
  let res = "";
5363
7158
  let lastSegmentLength = 0;
5364
7159
  let lastSlash = -1;
5365
7160
  let dots = 0;
5366
7161
  let char = null;
5367
- for (let index = 0; index <= path6.length; ++index) {
5368
- if (index < path6.length) {
5369
- char = path6[index];
7162
+ for (let index = 0; index <= path5.length; ++index) {
7163
+ if (index < path5.length) {
7164
+ char = path5[index];
5370
7165
  } else if (char === "/") {
5371
7166
  break;
5372
7167
  } else {
@@ -5402,9 +7197,9 @@ function normalizeString2(path6, allowAboveRoot) {
5402
7197
  }
5403
7198
  } else {
5404
7199
  if (res.length > 0) {
5405
- res += `/${path6.slice(lastSlash + 1, index)}`;
7200
+ res += `/${path5.slice(lastSlash + 1, index)}`;
5406
7201
  } else {
5407
- res = path6.slice(lastSlash + 1, index);
7202
+ res = path5.slice(lastSlash + 1, index);
5408
7203
  }
5409
7204
  lastSegmentLength = index - lastSlash - 1;
5410
7205
  }
@@ -5495,6 +7290,7 @@ init_esm_shims();
5495
7290
 
5496
7291
  // ../types/src/base.ts
5497
7292
  init_esm_shims();
7293
+ var EMPTY_STRING = "";
5498
7294
  var $NestedValue = Symbol("NestedValue");
5499
7295
 
5500
7296
  // ../path/src/correct-path.ts
@@ -5503,20 +7299,20 @@ init_esm_shims();
5503
7299
  // ../path/src/is-file.ts
5504
7300
  init_esm_shims();
5505
7301
  import { lstatSync, statSync } from "node:fs";
5506
- function isFile(path6, additionalPath) {
5507
- return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path6) : path6, {
7302
+ function isFile(path5, additionalPath) {
7303
+ return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path5) : path5, {
5508
7304
  throwIfNoEntry: false
5509
7305
  })?.isFile());
5510
7306
  }
5511
7307
  __name(isFile, "isFile");
5512
- function isDirectory(path6, additionalPath) {
5513
- return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path6) : path6, {
7308
+ function isDirectory(path5, additionalPath) {
7309
+ return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path5) : path5, {
5514
7310
  throwIfNoEntry: false
5515
7311
  })?.isDirectory());
5516
7312
  }
5517
7313
  __name(isDirectory, "isDirectory");
5518
- function isAbsolutePath(path6) {
5519
- return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
7314
+ function isAbsolutePath(path5) {
7315
+ return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path5);
5520
7316
  }
5521
7317
  __name(isAbsolutePath, "isAbsolutePath");
5522
7318
 
@@ -5529,15 +7325,47 @@ function normalizeWindowsPath3(input = "") {
5529
7325
  return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE3, (r) => r.toUpperCase());
5530
7326
  }
5531
7327
  __name(normalizeWindowsPath3, "normalizeWindowsPath");
5532
- function normalizeString3(path6, allowAboveRoot) {
7328
+ var _UNC_REGEX3 = /^[/\\]{2}/;
7329
+ var _DRIVE_LETTER_RE3 = /^[A-Z]:$/i;
7330
+ function correctPath(path5) {
7331
+ if (!path5 || path5.length === 0) {
7332
+ return ".";
7333
+ }
7334
+ path5 = normalizeWindowsPath3(path5);
7335
+ const isUNCPath = path5.match(_UNC_REGEX3);
7336
+ const isPathAbsolute = isAbsolutePath(path5);
7337
+ const trailingSeparator = path5[path5.length - 1] === "/";
7338
+ path5 = normalizeString3(path5, !isPathAbsolute);
7339
+ if (path5.length === 0) {
7340
+ if (isPathAbsolute) {
7341
+ return "/";
7342
+ }
7343
+ return trailingSeparator ? "./" : ".";
7344
+ }
7345
+ if (trailingSeparator) {
7346
+ path5 += "/";
7347
+ }
7348
+ if (_DRIVE_LETTER_RE3.test(path5)) {
7349
+ path5 += "/";
7350
+ }
7351
+ if (isUNCPath) {
7352
+ if (!isPathAbsolute) {
7353
+ return `//./${path5}`;
7354
+ }
7355
+ return `//${path5}`;
7356
+ }
7357
+ return isPathAbsolute && !isAbsolutePath(path5) ? `/${path5}` : path5;
7358
+ }
7359
+ __name(correctPath, "correctPath");
7360
+ function normalizeString3(path5, allowAboveRoot) {
5533
7361
  let res = "";
5534
7362
  let lastSegmentLength = 0;
5535
7363
  let lastSlash = -1;
5536
7364
  let dots = 0;
5537
7365
  let char = null;
5538
- for (let index = 0; index <= path6.length; ++index) {
5539
- if (index < path6.length) {
5540
- char = path6[index];
7366
+ for (let index = 0; index <= path5.length; ++index) {
7367
+ if (index < path5.length) {
7368
+ char = path5[index];
5541
7369
  } else if (char === "/") {
5542
7370
  break;
5543
7371
  } else {
@@ -5573,9 +7401,9 @@ function normalizeString3(path6, allowAboveRoot) {
5573
7401
  }
5574
7402
  } else {
5575
7403
  if (res.length > 0) {
5576
- res += `/${path6.slice(lastSlash + 1, index)}`;
7404
+ res += `/${path5.slice(lastSlash + 1, index)}`;
5577
7405
  } else {
5578
- res = path6.slice(lastSlash + 1, index);
7406
+ res = path5.slice(lastSlash + 1, index);
5579
7407
  }
5580
7408
  lastSegmentLength = index - lastSlash - 1;
5581
7409
  }
@@ -5592,17 +7420,35 @@ function normalizeString3(path6, allowAboveRoot) {
5592
7420
  __name(normalizeString3, "normalizeString");
5593
7421
 
5594
7422
  // ../path/src/file-path-fns.ts
5595
- function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
5596
- const paths = normalizeWindowsPath3(path6).split("/");
7423
+ function findFileName(filePath, { requireExtension, withExtension } = {}) {
7424
+ const result = normalizeWindowsPath3(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
7425
+ if (requireExtension === true && !result.includes(".")) {
7426
+ return EMPTY_STRING;
7427
+ }
7428
+ if (withExtension === false && result.includes(".")) {
7429
+ return result.split(".").slice(-1).join(".") || EMPTY_STRING;
7430
+ }
7431
+ return result;
7432
+ }
7433
+ __name(findFileName, "findFileName");
7434
+ function findFilePath(filePath) {
7435
+ const normalizedPath = normalizeWindowsPath3(filePath);
7436
+ return normalizedPath.replace(findFileName(normalizedPath, {
7437
+ requireExtension: true
7438
+ }), "");
7439
+ }
7440
+ __name(findFilePath, "findFilePath");
7441
+ function resolvePath(path5, cwd2 = getWorkspaceRoot()) {
7442
+ const paths = normalizeWindowsPath3(path5).split("/");
5597
7443
  let resolvedPath = "";
5598
7444
  let resolvedAbsolute = false;
5599
7445
  for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
5600
- const path7 = index >= 0 ? paths[index] : cwd2;
5601
- if (!path7 || path7.length === 0) {
7446
+ const path6 = index >= 0 ? paths[index] : cwd2;
7447
+ if (!path6 || path6.length === 0) {
5602
7448
  continue;
5603
7449
  }
5604
- resolvedPath = joinPaths(path7, resolvedPath);
5605
- resolvedAbsolute = isAbsolutePath(path7);
7450
+ resolvedPath = joinPaths(path6, resolvedPath);
7451
+ resolvedAbsolute = isAbsolutePath(path6);
5606
7452
  }
5607
7453
  resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
5608
7454
  if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
@@ -5612,13 +7458,13 @@ function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
5612
7458
  }
5613
7459
  __name(resolvePath, "resolvePath");
5614
7460
  function resolvePaths(...paths) {
5615
- return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath3(path6))));
7461
+ return resolvePath(joinPaths(...paths.map((path5) => normalizeWindowsPath3(path5))));
5616
7462
  }
5617
7463
  __name(resolvePaths, "resolvePaths");
5618
7464
 
5619
7465
  // ../path/src/get-parent-path.ts
5620
- var resolveParentPath = /* @__PURE__ */ __name((path6) => {
5621
- return resolvePaths(path6, "..");
7466
+ var resolveParentPath = /* @__PURE__ */ __name((path5) => {
7467
+ return resolvePaths(path5, "..");
5622
7468
  }, "resolveParentPath");
5623
7469
  var getParentPath = /* @__PURE__ */ __name((name, cwd2, options) => {
5624
7470
  const ignoreCase = options?.ignoreCase ?? true;
@@ -6001,142 +7847,2411 @@ var getProcedureTypeByOpName = /* @__PURE__ */ __name((opName) => {
6001
7847
  opName
6002
7848
  });
6003
7849
  }
6004
- return procType;
6005
- }, "getProcedureTypeByOpName");
6006
- function resolveModelsComments(models, hiddenModels) {
6007
- const modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
6008
- const attributeNameRegex = /\.+[A-Z]+\(+/i;
6009
- const attributeArgsRegex = /\(+[A-Z]+:.+\)/i;
6010
- for (const model of models) {
6011
- if (model.documentation) {
6012
- const attribute = model.documentation?.match(modelAttributeRegex)?.[0];
6013
- const attributeName = attribute?.match(attributeNameRegex)?.[0]?.slice(1, -1);
6014
- if (attributeName !== "model") continue;
6015
- const rawAttributeArgs = attribute?.match(attributeArgsRegex)?.[0]?.slice(1, -1);
6016
- const parsedAttributeArgs = {};
6017
- if (rawAttributeArgs) {
6018
- const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
6019
- for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
6020
- const key = rawAttributeArgsParts[i];
6021
- const value = rawAttributeArgsParts[i + 1];
6022
- parsedAttributeArgs[key] = JSON.parse(value);
7850
+ return procType;
7851
+ }, "getProcedureTypeByOpName");
7852
+ function resolveModelsComments(models, hiddenModels) {
7853
+ const modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
7854
+ const attributeNameRegex = /\.+[A-Z]+\(+/i;
7855
+ const attributeArgsRegex = /\(+[A-Z]+:.+\)/i;
7856
+ for (const model of models) {
7857
+ if (model.documentation) {
7858
+ const attribute = model.documentation?.match(modelAttributeRegex)?.[0];
7859
+ const attributeName = attribute?.match(attributeNameRegex)?.[0]?.slice(1, -1);
7860
+ if (attributeName !== "model") continue;
7861
+ const rawAttributeArgs = attribute?.match(attributeArgsRegex)?.[0]?.slice(1, -1);
7862
+ const parsedAttributeArgs = {};
7863
+ if (rawAttributeArgs) {
7864
+ const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
7865
+ for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
7866
+ const key = rawAttributeArgsParts[i];
7867
+ const value = rawAttributeArgsParts[i + 1];
7868
+ parsedAttributeArgs[key] = JSON.parse(value);
7869
+ }
7870
+ }
7871
+ if (parsedAttributeArgs.hide) {
7872
+ hiddenModels.push(model.name);
7873
+ }
7874
+ }
7875
+ }
7876
+ }
7877
+ __name(resolveModelsComments, "resolveModelsComments");
7878
+ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7879
+ let statement = "";
7880
+ if (type === "trpc") {
7881
+ statement = "import * as trpc from '@trpc/server';\n";
7882
+ } else if (type === "trpc-shield") {
7883
+ statement = "import { shield, allow } from 'trpc-shield';\n";
7884
+ } else if (type === "context") {
7885
+ statement = `import { Context } from '${newPath}';
7886
+ `;
7887
+ }
7888
+ return statement;
7889
+ }, "getImports");
7890
+ var wrapWithObject = /* @__PURE__ */ __name(({ shieldItemLines }) => {
7891
+ let wrapped = "{";
7892
+ wrapped += "\n";
7893
+ wrapped += Array.isArray(shieldItemLines) ? ` ${shieldItemLines.join(",\r\n")}` : ` ${shieldItemLines}`;
7894
+ wrapped += "\n";
7895
+ wrapped += "}";
7896
+ return wrapped;
7897
+ }, "wrapWithObject");
7898
+ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }) => {
7899
+ let wrapped = "shield<Context>(";
7900
+ wrapped += "\n";
7901
+ wrapped += ` ${shieldObjectTextWrapped}`;
7902
+ wrapped += "\n";
7903
+ wrapped += ")";
7904
+ return wrapped;
7905
+ }, "wrapWithTrpcShieldCall");
7906
+ var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7907
+ return `export const permissions = ${shieldObjectText};`;
7908
+ }, "wrapWithExport");
7909
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options) => {
7910
+ if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7911
+ return "";
7912
+ }
7913
+ let rootItems = "";
7914
+ if (queries.length > 0) {
7915
+ const queryLinesWrapped = `query: ${wrapWithObject({
7916
+ shieldItemLines: queries.map((query) => `${query}: allow`)
7917
+ })},`;
7918
+ rootItems += queryLinesWrapped;
7919
+ }
7920
+ if (mutations.length > 0) {
7921
+ const mutationLinesWrapped = `mutation: ${wrapWithObject({
7922
+ shieldItemLines: mutations.map((mutation) => `${mutation}: allow`)
7923
+ })},`;
7924
+ rootItems += mutationLinesWrapped;
7925
+ }
7926
+ if (subscriptions.length > 0) {
7927
+ const subscriptionLinesWrapped = `subscription: ${wrapWithObject({
7928
+ shieldItemLines: subscriptions.map((subscription) => `${subscription}: allow`)
7929
+ })},`;
7930
+ rootItems += subscriptionLinesWrapped;
7931
+ }
7932
+ if (rootItems.length === 0) return "";
7933
+ let shieldText = getImports("trpc-shield");
7934
+ const internals = await getPrismaInternals();
7935
+ const outputDir = internals.parseEnvValue(options.generator.output);
7936
+ shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
7937
+ shieldText += "\n\n";
7938
+ shieldText += wrapWithExport({
7939
+ shieldObjectText: wrapWithTrpcShieldCall({
7940
+ shieldObjectTextWrapped: wrapWithObject({
7941
+ shieldItemLines: rootItems
7942
+ })
7943
+ })
7944
+ });
7945
+ return shieldText;
7946
+ }, "constructShield");
7947
+
7948
+ // src/project.ts
7949
+ init_esm_shims();
7950
+ import { ModuleKind, Project, ScriptTarget } from "ts-morph";
7951
+ var compilerOptions = {
7952
+ target: ScriptTarget.ESNext,
7953
+ module: ModuleKind.ESNext,
7954
+ emitDecoratorMetadata: true,
7955
+ experimentalDecorators: true,
7956
+ esModuleInterop: true
7957
+ };
7958
+ var project = new Project({
7959
+ compilerOptions: {
7960
+ ...compilerOptions
7961
+ }
7962
+ });
7963
+
7964
+ // src/utils/remove-dir.ts
7965
+ init_esm_shims();
7966
+ import { promises as fs } from "node:fs";
7967
+ import path3 from "node:path";
7968
+ async function removeDir(dirPath, onlyContent) {
7969
+ const dirEntries = await fs.readdir(dirPath, {
7970
+ withFileTypes: true
7971
+ });
7972
+ await Promise.all(dirEntries.map(async (dirEntry) => {
7973
+ const fullPath = path3.join(dirPath, dirEntry.name);
7974
+ return dirEntry.isDirectory() ? removeDir(fullPath, false) : fs.unlink(fullPath);
7975
+ }));
7976
+ if (!onlyContent) {
7977
+ await fs.rmdir(dirPath);
7978
+ }
7979
+ }
7980
+ __name(removeDir, "removeDir");
7981
+
7982
+ // src/utils/write-file-safely.ts
7983
+ init_esm_shims();
7984
+
7985
+ // ../fs/src/write-file.ts
7986
+ init_esm_shims();
7987
+
7988
+ // ../json/src/storm-json.ts
7989
+ init_esm_shims();
7990
+
7991
+ // ../type-checks/src/is-object.ts
7992
+ init_esm_shims();
7993
+
7994
+ // ../type-checks/src/is-plain-object.ts
7995
+ init_esm_shims();
7996
+
7997
+ // ../type-checks/src/get-object-tag.ts
7998
+ init_esm_shims();
7999
+ var getObjectTag = /* @__PURE__ */ __name((value) => {
8000
+ if (value == null) {
8001
+ return value === void 0 ? "[object Undefined]" : "[object Null]";
8002
+ }
8003
+ return Object.prototype.toString.call(value);
8004
+ }, "getObjectTag");
8005
+
8006
+ // ../type-checks/src/is-plain-object.ts
8007
+ var isObjectLike = /* @__PURE__ */ __name((obj) => {
8008
+ return typeof obj === "object" && obj !== null;
8009
+ }, "isObjectLike");
8010
+ var isPlainObject = /* @__PURE__ */ __name((obj) => {
8011
+ if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") {
8012
+ return false;
8013
+ }
8014
+ if (Object.getPrototypeOf(obj) === null) {
8015
+ return true;
8016
+ }
8017
+ let proto = obj;
8018
+ while (Object.getPrototypeOf(proto) !== null) {
8019
+ proto = Object.getPrototypeOf(proto);
8020
+ }
8021
+ return Object.getPrototypeOf(obj) === proto;
8022
+ }, "isPlainObject");
8023
+
8024
+ // ../type-checks/src/is-object.ts
8025
+ var isObject = /* @__PURE__ */ __name((value) => {
8026
+ try {
8027
+ return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
8028
+ } catch {
8029
+ return false;
8030
+ }
8031
+ }, "isObject");
8032
+
8033
+ // ../json/src/storm-json.ts
8034
+ var import_buffer = __toESM(require_buffer(), 1);
8035
+
8036
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
8037
+ init_esm_shims();
8038
+
8039
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
8040
+ init_esm_shims();
8041
+
8042
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
8043
+ init_esm_shims();
8044
+ function createScanner(text, ignoreTrivia = false) {
8045
+ const len = text.length;
8046
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
8047
+ function scanHexDigits(count, exact) {
8048
+ let digits = 0;
8049
+ let value2 = 0;
8050
+ while (digits < count || !exact) {
8051
+ let ch = text.charCodeAt(pos);
8052
+ if (ch >= 48 && ch <= 57) {
8053
+ value2 = value2 * 16 + ch - 48;
8054
+ } else if (ch >= 65 && ch <= 70) {
8055
+ value2 = value2 * 16 + ch - 65 + 10;
8056
+ } else if (ch >= 97 && ch <= 102) {
8057
+ value2 = value2 * 16 + ch - 97 + 10;
8058
+ } else {
8059
+ break;
8060
+ }
8061
+ pos++;
8062
+ digits++;
8063
+ }
8064
+ if (digits < count) {
8065
+ value2 = -1;
8066
+ }
8067
+ return value2;
8068
+ }
8069
+ __name(scanHexDigits, "scanHexDigits");
8070
+ function setPosition(newPosition) {
8071
+ pos = newPosition;
8072
+ value = "";
8073
+ tokenOffset = 0;
8074
+ token = 16;
8075
+ scanError = 0;
8076
+ }
8077
+ __name(setPosition, "setPosition");
8078
+ function scanNumber() {
8079
+ let start = pos;
8080
+ if (text.charCodeAt(pos) === 48) {
8081
+ pos++;
8082
+ } else {
8083
+ pos++;
8084
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
8085
+ pos++;
8086
+ }
8087
+ }
8088
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
8089
+ pos++;
8090
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
8091
+ pos++;
8092
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
8093
+ pos++;
8094
+ }
8095
+ } else {
8096
+ scanError = 3;
8097
+ return text.substring(start, pos);
8098
+ }
8099
+ }
8100
+ let end = pos;
8101
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
8102
+ pos++;
8103
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
8104
+ pos++;
8105
+ }
8106
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
8107
+ pos++;
8108
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
8109
+ pos++;
8110
+ }
8111
+ end = pos;
8112
+ } else {
8113
+ scanError = 3;
8114
+ }
8115
+ }
8116
+ return text.substring(start, end);
8117
+ }
8118
+ __name(scanNumber, "scanNumber");
8119
+ function scanString() {
8120
+ let result = "", start = pos;
8121
+ while (true) {
8122
+ if (pos >= len) {
8123
+ result += text.substring(start, pos);
8124
+ scanError = 2;
8125
+ break;
8126
+ }
8127
+ const ch = text.charCodeAt(pos);
8128
+ if (ch === 34) {
8129
+ result += text.substring(start, pos);
8130
+ pos++;
8131
+ break;
8132
+ }
8133
+ if (ch === 92) {
8134
+ result += text.substring(start, pos);
8135
+ pos++;
8136
+ if (pos >= len) {
8137
+ scanError = 2;
8138
+ break;
8139
+ }
8140
+ const ch2 = text.charCodeAt(pos++);
8141
+ switch (ch2) {
8142
+ case 34:
8143
+ result += '"';
8144
+ break;
8145
+ case 92:
8146
+ result += "\\";
8147
+ break;
8148
+ case 47:
8149
+ result += "/";
8150
+ break;
8151
+ case 98:
8152
+ result += "\b";
8153
+ break;
8154
+ case 102:
8155
+ result += "\f";
8156
+ break;
8157
+ case 110:
8158
+ result += "\n";
8159
+ break;
8160
+ case 114:
8161
+ result += "\r";
8162
+ break;
8163
+ case 116:
8164
+ result += " ";
8165
+ break;
8166
+ case 117:
8167
+ const ch3 = scanHexDigits(4, true);
8168
+ if (ch3 >= 0) {
8169
+ result += String.fromCharCode(ch3);
8170
+ } else {
8171
+ scanError = 4;
8172
+ }
8173
+ break;
8174
+ default:
8175
+ scanError = 5;
8176
+ }
8177
+ start = pos;
8178
+ continue;
8179
+ }
8180
+ if (ch >= 0 && ch <= 31) {
8181
+ if (isLineBreak(ch)) {
8182
+ result += text.substring(start, pos);
8183
+ scanError = 2;
8184
+ break;
8185
+ } else {
8186
+ scanError = 6;
8187
+ }
8188
+ }
8189
+ pos++;
8190
+ }
8191
+ return result;
8192
+ }
8193
+ __name(scanString, "scanString");
8194
+ function scanNext() {
8195
+ value = "";
8196
+ scanError = 0;
8197
+ tokenOffset = pos;
8198
+ lineStartOffset = lineNumber;
8199
+ prevTokenLineStartOffset = tokenLineStartOffset;
8200
+ if (pos >= len) {
8201
+ tokenOffset = len;
8202
+ return token = 17;
8203
+ }
8204
+ let code = text.charCodeAt(pos);
8205
+ if (isWhiteSpace(code)) {
8206
+ do {
8207
+ pos++;
8208
+ value += String.fromCharCode(code);
8209
+ code = text.charCodeAt(pos);
8210
+ } while (isWhiteSpace(code));
8211
+ return token = 15;
8212
+ }
8213
+ if (isLineBreak(code)) {
8214
+ pos++;
8215
+ value += String.fromCharCode(code);
8216
+ if (code === 13 && text.charCodeAt(pos) === 10) {
8217
+ pos++;
8218
+ value += "\n";
8219
+ }
8220
+ lineNumber++;
8221
+ tokenLineStartOffset = pos;
8222
+ return token = 14;
8223
+ }
8224
+ switch (code) {
8225
+ // tokens: []{}:,
8226
+ case 123:
8227
+ pos++;
8228
+ return token = 1;
8229
+ case 125:
8230
+ pos++;
8231
+ return token = 2;
8232
+ case 91:
8233
+ pos++;
8234
+ return token = 3;
8235
+ case 93:
8236
+ pos++;
8237
+ return token = 4;
8238
+ case 58:
8239
+ pos++;
8240
+ return token = 6;
8241
+ case 44:
8242
+ pos++;
8243
+ return token = 5;
8244
+ // strings
8245
+ case 34:
8246
+ pos++;
8247
+ value = scanString();
8248
+ return token = 10;
8249
+ // comments
8250
+ case 47:
8251
+ const start = pos - 1;
8252
+ if (text.charCodeAt(pos + 1) === 47) {
8253
+ pos += 2;
8254
+ while (pos < len) {
8255
+ if (isLineBreak(text.charCodeAt(pos))) {
8256
+ break;
8257
+ }
8258
+ pos++;
8259
+ }
8260
+ value = text.substring(start, pos);
8261
+ return token = 12;
8262
+ }
8263
+ if (text.charCodeAt(pos + 1) === 42) {
8264
+ pos += 2;
8265
+ const safeLength = len - 1;
8266
+ let commentClosed = false;
8267
+ while (pos < safeLength) {
8268
+ const ch = text.charCodeAt(pos);
8269
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
8270
+ pos += 2;
8271
+ commentClosed = true;
8272
+ break;
8273
+ }
8274
+ pos++;
8275
+ if (isLineBreak(ch)) {
8276
+ if (ch === 13 && text.charCodeAt(pos) === 10) {
8277
+ pos++;
8278
+ }
8279
+ lineNumber++;
8280
+ tokenLineStartOffset = pos;
8281
+ }
8282
+ }
8283
+ if (!commentClosed) {
8284
+ pos++;
8285
+ scanError = 1;
8286
+ }
8287
+ value = text.substring(start, pos);
8288
+ return token = 13;
8289
+ }
8290
+ value += String.fromCharCode(code);
8291
+ pos++;
8292
+ return token = 16;
8293
+ // numbers
8294
+ case 45:
8295
+ value += String.fromCharCode(code);
8296
+ pos++;
8297
+ if (pos === len || !isDigit(text.charCodeAt(pos))) {
8298
+ return token = 16;
8299
+ }
8300
+ // found a minus, followed by a number so
8301
+ // we fall through to proceed with scanning
8302
+ // numbers
8303
+ case 48:
8304
+ case 49:
8305
+ case 50:
8306
+ case 51:
8307
+ case 52:
8308
+ case 53:
8309
+ case 54:
8310
+ case 55:
8311
+ case 56:
8312
+ case 57:
8313
+ value += scanNumber();
8314
+ return token = 11;
8315
+ // literals and unknown symbols
8316
+ default:
8317
+ while (pos < len && isUnknownContentCharacter(code)) {
8318
+ pos++;
8319
+ code = text.charCodeAt(pos);
8320
+ }
8321
+ if (tokenOffset !== pos) {
8322
+ value = text.substring(tokenOffset, pos);
8323
+ switch (value) {
8324
+ case "true":
8325
+ return token = 8;
8326
+ case "false":
8327
+ return token = 9;
8328
+ case "null":
8329
+ return token = 7;
8330
+ }
8331
+ return token = 16;
8332
+ }
8333
+ value += String.fromCharCode(code);
8334
+ pos++;
8335
+ return token = 16;
8336
+ }
8337
+ }
8338
+ __name(scanNext, "scanNext");
8339
+ function isUnknownContentCharacter(code) {
8340
+ if (isWhiteSpace(code) || isLineBreak(code)) {
8341
+ return false;
8342
+ }
8343
+ switch (code) {
8344
+ case 125:
8345
+ case 93:
8346
+ case 123:
8347
+ case 91:
8348
+ case 34:
8349
+ case 58:
8350
+ case 44:
8351
+ case 47:
8352
+ return false;
8353
+ }
8354
+ return true;
8355
+ }
8356
+ __name(isUnknownContentCharacter, "isUnknownContentCharacter");
8357
+ function scanNextNonTrivia() {
8358
+ let result;
8359
+ do {
8360
+ result = scanNext();
8361
+ } while (result >= 12 && result <= 15);
8362
+ return result;
8363
+ }
8364
+ __name(scanNextNonTrivia, "scanNextNonTrivia");
8365
+ return {
8366
+ setPosition,
8367
+ getPosition: /* @__PURE__ */ __name(() => pos, "getPosition"),
8368
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
8369
+ getToken: /* @__PURE__ */ __name(() => token, "getToken"),
8370
+ getTokenValue: /* @__PURE__ */ __name(() => value, "getTokenValue"),
8371
+ getTokenOffset: /* @__PURE__ */ __name(() => tokenOffset, "getTokenOffset"),
8372
+ getTokenLength: /* @__PURE__ */ __name(() => pos - tokenOffset, "getTokenLength"),
8373
+ getTokenStartLine: /* @__PURE__ */ __name(() => lineStartOffset, "getTokenStartLine"),
8374
+ getTokenStartCharacter: /* @__PURE__ */ __name(() => tokenOffset - prevTokenLineStartOffset, "getTokenStartCharacter"),
8375
+ getTokenError: /* @__PURE__ */ __name(() => scanError, "getTokenError")
8376
+ };
8377
+ }
8378
+ __name(createScanner, "createScanner");
8379
+ function isWhiteSpace(ch) {
8380
+ return ch === 32 || ch === 9;
8381
+ }
8382
+ __name(isWhiteSpace, "isWhiteSpace");
8383
+ function isLineBreak(ch) {
8384
+ return ch === 10 || ch === 13;
8385
+ }
8386
+ __name(isLineBreak, "isLineBreak");
8387
+ function isDigit(ch) {
8388
+ return ch >= 48 && ch <= 57;
8389
+ }
8390
+ __name(isDigit, "isDigit");
8391
+ var CharacterCodes;
8392
+ (function(CharacterCodes2) {
8393
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
8394
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
8395
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
8396
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
8397
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
8398
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
8399
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
8400
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
8401
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
8402
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
8403
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
8404
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
8405
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
8406
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
8407
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
8408
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
8409
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
8410
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
8411
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
8412
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
8413
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
8414
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
8415
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
8416
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
8417
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
8418
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
8419
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
8420
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
8421
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
8422
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
8423
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
8424
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
8425
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
8426
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
8427
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
8428
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
8429
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
8430
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
8431
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
8432
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
8433
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
8434
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
8435
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
8436
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
8437
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
8438
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
8439
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
8440
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
8441
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
8442
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
8443
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
8444
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
8445
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
8446
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
8447
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
8448
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
8449
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
8450
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
8451
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
8452
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
8453
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
8454
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
8455
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
8456
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
8457
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
8458
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
8459
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
8460
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
8461
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
8462
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
8463
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
8464
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
8465
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
8466
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
8467
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
8468
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
8469
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
8470
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
8471
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
8472
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
8473
+ })(CharacterCodes || (CharacterCodes = {}));
8474
+
8475
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
8476
+ init_esm_shims();
8477
+ var cachedSpaces = new Array(20).fill(0).map((_, index) => {
8478
+ return " ".repeat(index);
8479
+ });
8480
+ var maxCachedValues = 200;
8481
+ var cachedBreakLinesWithSpaces = {
8482
+ " ": {
8483
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
8484
+ return "\n" + " ".repeat(index);
8485
+ }),
8486
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
8487
+ return "\r" + " ".repeat(index);
8488
+ }),
8489
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
8490
+ return "\r\n" + " ".repeat(index);
8491
+ })
8492
+ },
8493
+ " ": {
8494
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
8495
+ return "\n" + " ".repeat(index);
8496
+ }),
8497
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
8498
+ return "\r" + " ".repeat(index);
8499
+ }),
8500
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
8501
+ return "\r\n" + " ".repeat(index);
8502
+ })
8503
+ }
8504
+ };
8505
+
8506
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
8507
+ init_esm_shims();
8508
+
8509
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
8510
+ init_esm_shims();
8511
+ var ParseOptions;
8512
+ (function(ParseOptions2) {
8513
+ ParseOptions2.DEFAULT = {
8514
+ allowTrailingComma: false
8515
+ };
8516
+ })(ParseOptions || (ParseOptions = {}));
8517
+ function parse(text, errors = [], options = ParseOptions.DEFAULT) {
8518
+ let currentProperty = null;
8519
+ let currentParent = [];
8520
+ const previousParents = [];
8521
+ function onValue(value) {
8522
+ if (Array.isArray(currentParent)) {
8523
+ currentParent.push(value);
8524
+ } else if (currentProperty !== null) {
8525
+ currentParent[currentProperty] = value;
8526
+ }
8527
+ }
8528
+ __name(onValue, "onValue");
8529
+ const visitor = {
8530
+ onObjectBegin: /* @__PURE__ */ __name(() => {
8531
+ const object = {};
8532
+ onValue(object);
8533
+ previousParents.push(currentParent);
8534
+ currentParent = object;
8535
+ currentProperty = null;
8536
+ }, "onObjectBegin"),
8537
+ onObjectProperty: /* @__PURE__ */ __name((name) => {
8538
+ currentProperty = name;
8539
+ }, "onObjectProperty"),
8540
+ onObjectEnd: /* @__PURE__ */ __name(() => {
8541
+ currentParent = previousParents.pop();
8542
+ }, "onObjectEnd"),
8543
+ onArrayBegin: /* @__PURE__ */ __name(() => {
8544
+ const array = [];
8545
+ onValue(array);
8546
+ previousParents.push(currentParent);
8547
+ currentParent = array;
8548
+ currentProperty = null;
8549
+ }, "onArrayBegin"),
8550
+ onArrayEnd: /* @__PURE__ */ __name(() => {
8551
+ currentParent = previousParents.pop();
8552
+ }, "onArrayEnd"),
8553
+ onLiteralValue: onValue,
8554
+ onError: /* @__PURE__ */ __name((error, offset, length) => {
8555
+ errors.push({
8556
+ error,
8557
+ offset,
8558
+ length
8559
+ });
8560
+ }, "onError")
8561
+ };
8562
+ visit(text, visitor, options);
8563
+ return currentParent[0];
8564
+ }
8565
+ __name(parse, "parse");
8566
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
8567
+ const _scanner = createScanner(text, false);
8568
+ const _jsonPath = [];
8569
+ let suppressedCallbacks = 0;
8570
+ function toNoArgVisit(visitFunction) {
8571
+ return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
8572
+ }
8573
+ __name(toNoArgVisit, "toNoArgVisit");
8574
+ function toOneArgVisit(visitFunction) {
8575
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
8576
+ }
8577
+ __name(toOneArgVisit, "toOneArgVisit");
8578
+ function toOneArgVisitWithPath(visitFunction) {
8579
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
8580
+ }
8581
+ __name(toOneArgVisitWithPath, "toOneArgVisitWithPath");
8582
+ function toBeginVisit(visitFunction) {
8583
+ return visitFunction ? () => {
8584
+ if (suppressedCallbacks > 0) {
8585
+ suppressedCallbacks++;
8586
+ } else {
8587
+ let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
8588
+ if (cbReturn === false) {
8589
+ suppressedCallbacks = 1;
8590
+ }
8591
+ }
8592
+ } : () => true;
8593
+ }
8594
+ __name(toBeginVisit, "toBeginVisit");
8595
+ function toEndVisit(visitFunction) {
8596
+ return visitFunction ? () => {
8597
+ if (suppressedCallbacks > 0) {
8598
+ suppressedCallbacks--;
8599
+ }
8600
+ if (suppressedCallbacks === 0) {
8601
+ visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
8602
+ }
8603
+ } : () => true;
8604
+ }
8605
+ __name(toEndVisit, "toEndVisit");
8606
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
8607
+ const disallowComments = options && options.disallowComments;
8608
+ const allowTrailingComma = options && options.allowTrailingComma;
8609
+ function scanNext() {
8610
+ while (true) {
8611
+ const token = _scanner.scan();
8612
+ switch (_scanner.getTokenError()) {
8613
+ case 4:
8614
+ handleError(
8615
+ 14
8616
+ /* ParseErrorCode.InvalidUnicode */
8617
+ );
8618
+ break;
8619
+ case 5:
8620
+ handleError(
8621
+ 15
8622
+ /* ParseErrorCode.InvalidEscapeCharacter */
8623
+ );
8624
+ break;
8625
+ case 3:
8626
+ handleError(
8627
+ 13
8628
+ /* ParseErrorCode.UnexpectedEndOfNumber */
8629
+ );
8630
+ break;
8631
+ case 1:
8632
+ if (!disallowComments) {
8633
+ handleError(
8634
+ 11
8635
+ /* ParseErrorCode.UnexpectedEndOfComment */
8636
+ );
8637
+ }
8638
+ break;
8639
+ case 2:
8640
+ handleError(
8641
+ 12
8642
+ /* ParseErrorCode.UnexpectedEndOfString */
8643
+ );
8644
+ break;
8645
+ case 6:
8646
+ handleError(
8647
+ 16
8648
+ /* ParseErrorCode.InvalidCharacter */
8649
+ );
8650
+ break;
8651
+ }
8652
+ switch (token) {
8653
+ case 12:
8654
+ case 13:
8655
+ if (disallowComments) {
8656
+ handleError(
8657
+ 10
8658
+ /* ParseErrorCode.InvalidCommentToken */
8659
+ );
8660
+ } else {
8661
+ onComment();
8662
+ }
8663
+ break;
8664
+ case 16:
8665
+ handleError(
8666
+ 1
8667
+ /* ParseErrorCode.InvalidSymbol */
8668
+ );
8669
+ break;
8670
+ case 15:
8671
+ case 14:
8672
+ break;
8673
+ default:
8674
+ return token;
8675
+ }
8676
+ }
8677
+ }
8678
+ __name(scanNext, "scanNext");
8679
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
8680
+ onError(error);
8681
+ if (skipUntilAfter.length + skipUntil.length > 0) {
8682
+ let token = _scanner.getToken();
8683
+ while (token !== 17) {
8684
+ if (skipUntilAfter.indexOf(token) !== -1) {
8685
+ scanNext();
8686
+ break;
8687
+ } else if (skipUntil.indexOf(token) !== -1) {
8688
+ break;
8689
+ }
8690
+ token = scanNext();
8691
+ }
8692
+ }
8693
+ }
8694
+ __name(handleError, "handleError");
8695
+ function parseString(isValue) {
8696
+ const value = _scanner.getTokenValue();
8697
+ if (isValue) {
8698
+ onLiteralValue(value);
8699
+ } else {
8700
+ onObjectProperty(value);
8701
+ _jsonPath.push(value);
8702
+ }
8703
+ scanNext();
8704
+ return true;
8705
+ }
8706
+ __name(parseString, "parseString");
8707
+ function parseLiteral() {
8708
+ switch (_scanner.getToken()) {
8709
+ case 11:
8710
+ const tokenValue = _scanner.getTokenValue();
8711
+ let value = Number(tokenValue);
8712
+ if (isNaN(value)) {
8713
+ handleError(
8714
+ 2
8715
+ /* ParseErrorCode.InvalidNumberFormat */
8716
+ );
8717
+ value = 0;
8718
+ }
8719
+ onLiteralValue(value);
8720
+ break;
8721
+ case 7:
8722
+ onLiteralValue(null);
8723
+ break;
8724
+ case 8:
8725
+ onLiteralValue(true);
8726
+ break;
8727
+ case 9:
8728
+ onLiteralValue(false);
8729
+ break;
8730
+ default:
8731
+ return false;
8732
+ }
8733
+ scanNext();
8734
+ return true;
8735
+ }
8736
+ __name(parseLiteral, "parseLiteral");
8737
+ function parseProperty() {
8738
+ if (_scanner.getToken() !== 10) {
8739
+ handleError(3, [], [
8740
+ 2,
8741
+ 5
8742
+ /* SyntaxKind.CommaToken */
8743
+ ]);
8744
+ return false;
8745
+ }
8746
+ parseString(false);
8747
+ if (_scanner.getToken() === 6) {
8748
+ onSeparator(":");
8749
+ scanNext();
8750
+ if (!parseValue()) {
8751
+ handleError(4, [], [
8752
+ 2,
8753
+ 5
8754
+ /* SyntaxKind.CommaToken */
8755
+ ]);
8756
+ }
8757
+ } else {
8758
+ handleError(5, [], [
8759
+ 2,
8760
+ 5
8761
+ /* SyntaxKind.CommaToken */
8762
+ ]);
8763
+ }
8764
+ _jsonPath.pop();
8765
+ return true;
8766
+ }
8767
+ __name(parseProperty, "parseProperty");
8768
+ function parseObject() {
8769
+ onObjectBegin();
8770
+ scanNext();
8771
+ let needsComma = false;
8772
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
8773
+ if (_scanner.getToken() === 5) {
8774
+ if (!needsComma) {
8775
+ handleError(4, [], []);
8776
+ }
8777
+ onSeparator(",");
8778
+ scanNext();
8779
+ if (_scanner.getToken() === 2 && allowTrailingComma) {
8780
+ break;
8781
+ }
8782
+ } else if (needsComma) {
8783
+ handleError(6, [], []);
8784
+ }
8785
+ if (!parseProperty()) {
8786
+ handleError(4, [], [
8787
+ 2,
8788
+ 5
8789
+ /* SyntaxKind.CommaToken */
8790
+ ]);
8791
+ }
8792
+ needsComma = true;
8793
+ }
8794
+ onObjectEnd();
8795
+ if (_scanner.getToken() !== 2) {
8796
+ handleError(7, [
8797
+ 2
8798
+ /* SyntaxKind.CloseBraceToken */
8799
+ ], []);
8800
+ } else {
8801
+ scanNext();
8802
+ }
8803
+ return true;
8804
+ }
8805
+ __name(parseObject, "parseObject");
8806
+ function parseArray() {
8807
+ onArrayBegin();
8808
+ scanNext();
8809
+ let isFirstElement = true;
8810
+ let needsComma = false;
8811
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
8812
+ if (_scanner.getToken() === 5) {
8813
+ if (!needsComma) {
8814
+ handleError(4, [], []);
8815
+ }
8816
+ onSeparator(",");
8817
+ scanNext();
8818
+ if (_scanner.getToken() === 4 && allowTrailingComma) {
8819
+ break;
8820
+ }
8821
+ } else if (needsComma) {
8822
+ handleError(6, [], []);
8823
+ }
8824
+ if (isFirstElement) {
8825
+ _jsonPath.push(0);
8826
+ isFirstElement = false;
8827
+ } else {
8828
+ _jsonPath[_jsonPath.length - 1]++;
8829
+ }
8830
+ if (!parseValue()) {
8831
+ handleError(4, [], [
8832
+ 4,
8833
+ 5
8834
+ /* SyntaxKind.CommaToken */
8835
+ ]);
8836
+ }
8837
+ needsComma = true;
8838
+ }
8839
+ onArrayEnd();
8840
+ if (!isFirstElement) {
8841
+ _jsonPath.pop();
8842
+ }
8843
+ if (_scanner.getToken() !== 4) {
8844
+ handleError(8, [
8845
+ 4
8846
+ /* SyntaxKind.CloseBracketToken */
8847
+ ], []);
8848
+ } else {
8849
+ scanNext();
8850
+ }
8851
+ return true;
8852
+ }
8853
+ __name(parseArray, "parseArray");
8854
+ function parseValue() {
8855
+ switch (_scanner.getToken()) {
8856
+ case 3:
8857
+ return parseArray();
8858
+ case 1:
8859
+ return parseObject();
8860
+ case 10:
8861
+ return parseString(true);
8862
+ default:
8863
+ return parseLiteral();
8864
+ }
8865
+ }
8866
+ __name(parseValue, "parseValue");
8867
+ scanNext();
8868
+ if (_scanner.getToken() === 17) {
8869
+ if (options.allowEmptyContent) {
8870
+ return true;
8871
+ }
8872
+ handleError(4, [], []);
8873
+ return false;
8874
+ }
8875
+ if (!parseValue()) {
8876
+ handleError(4, [], []);
8877
+ return false;
8878
+ }
8879
+ if (_scanner.getToken() !== 17) {
8880
+ handleError(9, [], []);
8881
+ }
8882
+ return true;
8883
+ }
8884
+ __name(visit, "visit");
8885
+
8886
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
8887
+ var ScanError;
8888
+ (function(ScanError2) {
8889
+ ScanError2[ScanError2["None"] = 0] = "None";
8890
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
8891
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
8892
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
8893
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
8894
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
8895
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
8896
+ })(ScanError || (ScanError = {}));
8897
+ var SyntaxKind;
8898
+ (function(SyntaxKind2) {
8899
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
8900
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
8901
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
8902
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
8903
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
8904
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
8905
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
8906
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
8907
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
8908
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
8909
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
8910
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
8911
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
8912
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
8913
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
8914
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
8915
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
8916
+ })(SyntaxKind || (SyntaxKind = {}));
8917
+ var parse2 = parse;
8918
+ var ParseErrorCode;
8919
+ (function(ParseErrorCode2) {
8920
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
8921
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
8922
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
8923
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
8924
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
8925
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
8926
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
8927
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
8928
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
8929
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
8930
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
8931
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
8932
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
8933
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
8934
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
8935
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
8936
+ })(ParseErrorCode || (ParseErrorCode = {}));
8937
+ function printParseErrorCode(code) {
8938
+ switch (code) {
8939
+ case 1:
8940
+ return "InvalidSymbol";
8941
+ case 2:
8942
+ return "InvalidNumberFormat";
8943
+ case 3:
8944
+ return "PropertyNameExpected";
8945
+ case 4:
8946
+ return "ValueExpected";
8947
+ case 5:
8948
+ return "ColonExpected";
8949
+ case 6:
8950
+ return "CommaExpected";
8951
+ case 7:
8952
+ return "CloseBraceExpected";
8953
+ case 8:
8954
+ return "CloseBracketExpected";
8955
+ case 9:
8956
+ return "EndOfFileExpected";
8957
+ case 10:
8958
+ return "InvalidCommentToken";
8959
+ case 11:
8960
+ return "UnexpectedEndOfComment";
8961
+ case 12:
8962
+ return "UnexpectedEndOfString";
8963
+ case 13:
8964
+ return "UnexpectedEndOfNumber";
8965
+ case 14:
8966
+ return "InvalidUnicode";
8967
+ case 15:
8968
+ return "InvalidEscapeCharacter";
8969
+ case 16:
8970
+ return "InvalidCharacter";
8971
+ }
8972
+ return "<unknown ParseErrorCode>";
8973
+ }
8974
+ __name(printParseErrorCode, "printParseErrorCode");
8975
+
8976
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.js
8977
+ init_esm_shims();
8978
+
8979
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.js
8980
+ init_esm_shims();
8981
+
8982
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.js
8983
+ init_esm_shims();
8984
+
8985
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.js
8986
+ init_esm_shims();
8987
+ var DoubleIndexedKV = class {
8988
+ static {
8989
+ __name(this, "DoubleIndexedKV");
8990
+ }
8991
+ constructor() {
8992
+ this.keyToValue = /* @__PURE__ */ new Map();
8993
+ this.valueToKey = /* @__PURE__ */ new Map();
8994
+ }
8995
+ set(key, value) {
8996
+ this.keyToValue.set(key, value);
8997
+ this.valueToKey.set(value, key);
8998
+ }
8999
+ getByKey(key) {
9000
+ return this.keyToValue.get(key);
9001
+ }
9002
+ getByValue(value) {
9003
+ return this.valueToKey.get(value);
9004
+ }
9005
+ clear() {
9006
+ this.keyToValue.clear();
9007
+ this.valueToKey.clear();
9008
+ }
9009
+ };
9010
+
9011
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.js
9012
+ var Registry = class {
9013
+ static {
9014
+ __name(this, "Registry");
9015
+ }
9016
+ constructor(generateIdentifier) {
9017
+ this.generateIdentifier = generateIdentifier;
9018
+ this.kv = new DoubleIndexedKV();
9019
+ }
9020
+ register(value, identifier) {
9021
+ if (this.kv.getByValue(value)) {
9022
+ return;
9023
+ }
9024
+ if (!identifier) {
9025
+ identifier = this.generateIdentifier(value);
9026
+ }
9027
+ this.kv.set(identifier, value);
9028
+ }
9029
+ clear() {
9030
+ this.kv.clear();
9031
+ }
9032
+ getIdentifier(value) {
9033
+ return this.kv.getByValue(value);
9034
+ }
9035
+ getValue(identifier) {
9036
+ return this.kv.getByKey(identifier);
9037
+ }
9038
+ };
9039
+
9040
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.js
9041
+ var ClassRegistry = class extends Registry {
9042
+ static {
9043
+ __name(this, "ClassRegistry");
9044
+ }
9045
+ constructor() {
9046
+ super((c) => c.name);
9047
+ this.classToAllowedProps = /* @__PURE__ */ new Map();
9048
+ }
9049
+ register(value, options) {
9050
+ if (typeof options === "object") {
9051
+ if (options.allowProps) {
9052
+ this.classToAllowedProps.set(value, options.allowProps);
9053
+ }
9054
+ super.register(value, options.identifier);
9055
+ } else {
9056
+ super.register(value, options);
9057
+ }
9058
+ }
9059
+ getAllowedProps(value) {
9060
+ return this.classToAllowedProps.get(value);
9061
+ }
9062
+ };
9063
+
9064
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.js
9065
+ init_esm_shims();
9066
+
9067
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.js
9068
+ init_esm_shims();
9069
+ function valuesOfObj(record) {
9070
+ if ("values" in Object) {
9071
+ return Object.values(record);
9072
+ }
9073
+ const values = [];
9074
+ for (const key in record) {
9075
+ if (record.hasOwnProperty(key)) {
9076
+ values.push(record[key]);
9077
+ }
9078
+ }
9079
+ return values;
9080
+ }
9081
+ __name(valuesOfObj, "valuesOfObj");
9082
+ function find(record, predicate) {
9083
+ const values = valuesOfObj(record);
9084
+ if ("find" in values) {
9085
+ return values.find(predicate);
9086
+ }
9087
+ const valuesNotNever = values;
9088
+ for (let i = 0; i < valuesNotNever.length; i++) {
9089
+ const value = valuesNotNever[i];
9090
+ if (predicate(value)) {
9091
+ return value;
9092
+ }
9093
+ }
9094
+ return void 0;
9095
+ }
9096
+ __name(find, "find");
9097
+ function forEach(record, run) {
9098
+ Object.entries(record).forEach(([key, value]) => run(value, key));
9099
+ }
9100
+ __name(forEach, "forEach");
9101
+ function includes(arr, value) {
9102
+ return arr.indexOf(value) !== -1;
9103
+ }
9104
+ __name(includes, "includes");
9105
+ function findArr(record, predicate) {
9106
+ for (let i = 0; i < record.length; i++) {
9107
+ const value = record[i];
9108
+ if (predicate(value)) {
9109
+ return value;
9110
+ }
9111
+ }
9112
+ return void 0;
9113
+ }
9114
+ __name(findArr, "findArr");
9115
+
9116
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.js
9117
+ var CustomTransformerRegistry = class {
9118
+ static {
9119
+ __name(this, "CustomTransformerRegistry");
9120
+ }
9121
+ constructor() {
9122
+ this.transfomers = {};
9123
+ }
9124
+ register(transformer) {
9125
+ this.transfomers[transformer.name] = transformer;
9126
+ }
9127
+ findApplicable(v) {
9128
+ return find(this.transfomers, (transformer) => transformer.isApplicable(v));
9129
+ }
9130
+ findByName(name) {
9131
+ return this.transfomers[name];
9132
+ }
9133
+ };
9134
+
9135
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.js
9136
+ init_esm_shims();
9137
+
9138
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.js
9139
+ init_esm_shims();
9140
+ var getType = /* @__PURE__ */ __name((payload) => Object.prototype.toString.call(payload).slice(8, -1), "getType");
9141
+ var isUndefined = /* @__PURE__ */ __name((payload) => typeof payload === "undefined", "isUndefined");
9142
+ var isNull = /* @__PURE__ */ __name((payload) => payload === null, "isNull");
9143
+ var isPlainObject2 = /* @__PURE__ */ __name((payload) => {
9144
+ if (typeof payload !== "object" || payload === null) return false;
9145
+ if (payload === Object.prototype) return false;
9146
+ if (Object.getPrototypeOf(payload) === null) return true;
9147
+ return Object.getPrototypeOf(payload) === Object.prototype;
9148
+ }, "isPlainObject");
9149
+ var isEmptyObject = /* @__PURE__ */ __name((payload) => isPlainObject2(payload) && Object.keys(payload).length === 0, "isEmptyObject");
9150
+ var isArray = /* @__PURE__ */ __name((payload) => Array.isArray(payload), "isArray");
9151
+ var isString2 = /* @__PURE__ */ __name((payload) => typeof payload === "string", "isString");
9152
+ var isNumber = /* @__PURE__ */ __name((payload) => typeof payload === "number" && !isNaN(payload), "isNumber");
9153
+ var isBoolean = /* @__PURE__ */ __name((payload) => typeof payload === "boolean", "isBoolean");
9154
+ var isRegExp = /* @__PURE__ */ __name((payload) => payload instanceof RegExp, "isRegExp");
9155
+ var isMap = /* @__PURE__ */ __name((payload) => payload instanceof Map, "isMap");
9156
+ var isSet = /* @__PURE__ */ __name((payload) => payload instanceof Set, "isSet");
9157
+ var isSymbol = /* @__PURE__ */ __name((payload) => getType(payload) === "Symbol", "isSymbol");
9158
+ var isDate = /* @__PURE__ */ __name((payload) => payload instanceof Date && !isNaN(payload.valueOf()), "isDate");
9159
+ var isError = /* @__PURE__ */ __name((payload) => payload instanceof Error, "isError");
9160
+ var isNaNValue = /* @__PURE__ */ __name((payload) => typeof payload === "number" && isNaN(payload), "isNaNValue");
9161
+ var isPrimitive = /* @__PURE__ */ __name((payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString2(payload) || isSymbol(payload), "isPrimitive");
9162
+ var isBigint = /* @__PURE__ */ __name((payload) => typeof payload === "bigint", "isBigint");
9163
+ var isInfinite = /* @__PURE__ */ __name((payload) => payload === Infinity || payload === -Infinity, "isInfinite");
9164
+ var isTypedArray = /* @__PURE__ */ __name((payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView), "isTypedArray");
9165
+ var isURL = /* @__PURE__ */ __name((payload) => payload instanceof URL, "isURL");
9166
+
9167
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
9168
+ init_esm_shims();
9169
+ var escapeKey = /* @__PURE__ */ __name((key) => key.replace(/\./g, "\\."), "escapeKey");
9170
+ var stringifyPath = /* @__PURE__ */ __name((path5) => path5.map(String).map(escapeKey).join("."), "stringifyPath");
9171
+ var parsePath = /* @__PURE__ */ __name((string) => {
9172
+ const result = [];
9173
+ let segment = "";
9174
+ for (let i = 0; i < string.length; i++) {
9175
+ let char = string.charAt(i);
9176
+ const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
9177
+ if (isEscapedDot) {
9178
+ segment += ".";
9179
+ i++;
9180
+ continue;
9181
+ }
9182
+ const isEndOfSegment = char === ".";
9183
+ if (isEndOfSegment) {
9184
+ result.push(segment);
9185
+ segment = "";
9186
+ continue;
9187
+ }
9188
+ segment += char;
9189
+ }
9190
+ const lastSegment = segment;
9191
+ result.push(lastSegment);
9192
+ return result;
9193
+ }, "parsePath");
9194
+
9195
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.js
9196
+ init_esm_shims();
9197
+ function simpleTransformation(isApplicable, annotation, transform, untransform) {
9198
+ return {
9199
+ isApplicable,
9200
+ annotation,
9201
+ transform,
9202
+ untransform
9203
+ };
9204
+ }
9205
+ __name(simpleTransformation, "simpleTransformation");
9206
+ var simpleRules = [
9207
+ simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
9208
+ simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
9209
+ if (typeof BigInt !== "undefined") {
9210
+ return BigInt(v);
9211
+ }
9212
+ console.error("Please add a BigInt polyfill.");
9213
+ return v;
9214
+ }),
9215
+ simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
9216
+ simpleTransformation(isError, "Error", (v, superJson) => {
9217
+ const baseError = {
9218
+ name: v.name,
9219
+ message: v.message
9220
+ };
9221
+ superJson.allowedErrorProps.forEach((prop) => {
9222
+ baseError[prop] = v[prop];
9223
+ });
9224
+ return baseError;
9225
+ }, (v, superJson) => {
9226
+ const e = new Error(v.message);
9227
+ e.name = v.name;
9228
+ e.stack = v.stack;
9229
+ superJson.allowedErrorProps.forEach((prop) => {
9230
+ e[prop] = v[prop];
9231
+ });
9232
+ return e;
9233
+ }),
9234
+ simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
9235
+ const body = regex.slice(1, regex.lastIndexOf("/"));
9236
+ const flags = regex.slice(regex.lastIndexOf("/") + 1);
9237
+ return new RegExp(body, flags);
9238
+ }),
9239
+ simpleTransformation(
9240
+ isSet,
9241
+ "set",
9242
+ // (sets only exist in es6+)
9243
+ // eslint-disable-next-line es5/no-es6-methods
9244
+ (v) => [
9245
+ ...v.values()
9246
+ ],
9247
+ (v) => new Set(v)
9248
+ ),
9249
+ simpleTransformation(isMap, "map", (v) => [
9250
+ ...v.entries()
9251
+ ], (v) => new Map(v)),
9252
+ simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
9253
+ if (isNaNValue(v)) {
9254
+ return "NaN";
9255
+ }
9256
+ if (v > 0) {
9257
+ return "Infinity";
9258
+ } else {
9259
+ return "-Infinity";
9260
+ }
9261
+ }, Number),
9262
+ simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
9263
+ return "-0";
9264
+ }, Number),
9265
+ simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
9266
+ ];
9267
+ function compositeTransformation(isApplicable, annotation, transform, untransform) {
9268
+ return {
9269
+ isApplicable,
9270
+ annotation,
9271
+ transform,
9272
+ untransform
9273
+ };
9274
+ }
9275
+ __name(compositeTransformation, "compositeTransformation");
9276
+ var symbolRule = compositeTransformation((s, superJson) => {
9277
+ if (isSymbol(s)) {
9278
+ const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
9279
+ return isRegistered;
9280
+ }
9281
+ return false;
9282
+ }, (s, superJson) => {
9283
+ const identifier = superJson.symbolRegistry.getIdentifier(s);
9284
+ return [
9285
+ "symbol",
9286
+ identifier
9287
+ ];
9288
+ }, (v) => v.description, (_, a, superJson) => {
9289
+ const value = superJson.symbolRegistry.getValue(a[1]);
9290
+ if (!value) {
9291
+ throw new Error("Trying to deserialize unknown symbol");
9292
+ }
9293
+ return value;
9294
+ });
9295
+ var constructorToName = [
9296
+ Int8Array,
9297
+ Uint8Array,
9298
+ Int16Array,
9299
+ Uint16Array,
9300
+ Int32Array,
9301
+ Uint32Array,
9302
+ Float32Array,
9303
+ Float64Array,
9304
+ Uint8ClampedArray
9305
+ ].reduce((obj, ctor) => {
9306
+ obj[ctor.name] = ctor;
9307
+ return obj;
9308
+ }, {});
9309
+ var typedArrayRule = compositeTransformation(isTypedArray, (v) => [
9310
+ "typed-array",
9311
+ v.constructor.name
9312
+ ], (v) => [
9313
+ ...v
9314
+ ], (v, a) => {
9315
+ const ctor = constructorToName[a[1]];
9316
+ if (!ctor) {
9317
+ throw new Error("Trying to deserialize unknown typed array");
9318
+ }
9319
+ return new ctor(v);
9320
+ });
9321
+ function isInstanceOfRegisteredClass(potentialClass, superJson) {
9322
+ if (potentialClass?.constructor) {
9323
+ const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
9324
+ return isRegistered;
9325
+ }
9326
+ return false;
9327
+ }
9328
+ __name(isInstanceOfRegisteredClass, "isInstanceOfRegisteredClass");
9329
+ var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
9330
+ const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
9331
+ return [
9332
+ "class",
9333
+ identifier
9334
+ ];
9335
+ }, (clazz, superJson) => {
9336
+ const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
9337
+ if (!allowedProps) {
9338
+ return {
9339
+ ...clazz
9340
+ };
9341
+ }
9342
+ const result = {};
9343
+ allowedProps.forEach((prop) => {
9344
+ result[prop] = clazz[prop];
9345
+ });
9346
+ return result;
9347
+ }, (v, a, superJson) => {
9348
+ const clazz = superJson.classRegistry.getValue(a[1]);
9349
+ if (!clazz) {
9350
+ throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
9351
+ }
9352
+ return Object.assign(Object.create(clazz.prototype), v);
9353
+ });
9354
+ var customRule = compositeTransformation((value, superJson) => {
9355
+ return !!superJson.customTransformerRegistry.findApplicable(value);
9356
+ }, (value, superJson) => {
9357
+ const transformer = superJson.customTransformerRegistry.findApplicable(value);
9358
+ return [
9359
+ "custom",
9360
+ transformer.name
9361
+ ];
9362
+ }, (value, superJson) => {
9363
+ const transformer = superJson.customTransformerRegistry.findApplicable(value);
9364
+ return transformer.serialize(value);
9365
+ }, (v, a, superJson) => {
9366
+ const transformer = superJson.customTransformerRegistry.findByName(a[1]);
9367
+ if (!transformer) {
9368
+ throw new Error("Trying to deserialize unknown custom value");
9369
+ }
9370
+ return transformer.deserialize(v);
9371
+ });
9372
+ var compositeRules = [
9373
+ classRule,
9374
+ symbolRule,
9375
+ customRule,
9376
+ typedArrayRule
9377
+ ];
9378
+ var transformValue = /* @__PURE__ */ __name((value, superJson) => {
9379
+ const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
9380
+ if (applicableCompositeRule) {
9381
+ return {
9382
+ value: applicableCompositeRule.transform(value, superJson),
9383
+ type: applicableCompositeRule.annotation(value, superJson)
9384
+ };
9385
+ }
9386
+ const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
9387
+ if (applicableSimpleRule) {
9388
+ return {
9389
+ value: applicableSimpleRule.transform(value, superJson),
9390
+ type: applicableSimpleRule.annotation
9391
+ };
9392
+ }
9393
+ return void 0;
9394
+ }, "transformValue");
9395
+ var simpleRulesByAnnotation = {};
9396
+ simpleRules.forEach((rule) => {
9397
+ simpleRulesByAnnotation[rule.annotation] = rule;
9398
+ });
9399
+ var untransformValue = /* @__PURE__ */ __name((json, type, superJson) => {
9400
+ if (isArray(type)) {
9401
+ switch (type[0]) {
9402
+ case "symbol":
9403
+ return symbolRule.untransform(json, type, superJson);
9404
+ case "class":
9405
+ return classRule.untransform(json, type, superJson);
9406
+ case "custom":
9407
+ return customRule.untransform(json, type, superJson);
9408
+ case "typed-array":
9409
+ return typedArrayRule.untransform(json, type, superJson);
9410
+ default:
9411
+ throw new Error("Unknown transformation: " + type);
9412
+ }
9413
+ } else {
9414
+ const transformation = simpleRulesByAnnotation[type];
9415
+ if (!transformation) {
9416
+ throw new Error("Unknown transformation: " + type);
9417
+ }
9418
+ return transformation.untransform(json, superJson);
9419
+ }
9420
+ }, "untransformValue");
9421
+
9422
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.js
9423
+ init_esm_shims();
9424
+ var getNthKey = /* @__PURE__ */ __name((value, n) => {
9425
+ if (n > value.size) throw new Error("index out of bounds");
9426
+ const keys = value.keys();
9427
+ while (n > 0) {
9428
+ keys.next();
9429
+ n--;
9430
+ }
9431
+ return keys.next().value;
9432
+ }, "getNthKey");
9433
+ function validatePath(path5) {
9434
+ if (includes(path5, "__proto__")) {
9435
+ throw new Error("__proto__ is not allowed as a property");
9436
+ }
9437
+ if (includes(path5, "prototype")) {
9438
+ throw new Error("prototype is not allowed as a property");
9439
+ }
9440
+ if (includes(path5, "constructor")) {
9441
+ throw new Error("constructor is not allowed as a property");
9442
+ }
9443
+ }
9444
+ __name(validatePath, "validatePath");
9445
+ var getDeep = /* @__PURE__ */ __name((object, path5) => {
9446
+ validatePath(path5);
9447
+ for (let i = 0; i < path5.length; i++) {
9448
+ const key = path5[i];
9449
+ if (isSet(object)) {
9450
+ object = getNthKey(object, +key);
9451
+ } else if (isMap(object)) {
9452
+ const row = +key;
9453
+ const type = +path5[++i] === 0 ? "key" : "value";
9454
+ const keyOfRow = getNthKey(object, row);
9455
+ switch (type) {
9456
+ case "key":
9457
+ object = keyOfRow;
9458
+ break;
9459
+ case "value":
9460
+ object = object.get(keyOfRow);
9461
+ break;
9462
+ }
9463
+ } else {
9464
+ object = object[key];
9465
+ }
9466
+ }
9467
+ return object;
9468
+ }, "getDeep");
9469
+ var setDeep = /* @__PURE__ */ __name((object, path5, mapper) => {
9470
+ validatePath(path5);
9471
+ if (path5.length === 0) {
9472
+ return mapper(object);
9473
+ }
9474
+ let parent = object;
9475
+ for (let i = 0; i < path5.length - 1; i++) {
9476
+ const key = path5[i];
9477
+ if (isArray(parent)) {
9478
+ const index = +key;
9479
+ parent = parent[index];
9480
+ } else if (isPlainObject2(parent)) {
9481
+ parent = parent[key];
9482
+ } else if (isSet(parent)) {
9483
+ const row = +key;
9484
+ parent = getNthKey(parent, row);
9485
+ } else if (isMap(parent)) {
9486
+ const isEnd = i === path5.length - 2;
9487
+ if (isEnd) {
9488
+ break;
9489
+ }
9490
+ const row = +key;
9491
+ const type = +path5[++i] === 0 ? "key" : "value";
9492
+ const keyOfRow = getNthKey(parent, row);
9493
+ switch (type) {
9494
+ case "key":
9495
+ parent = keyOfRow;
9496
+ break;
9497
+ case "value":
9498
+ parent = parent.get(keyOfRow);
9499
+ break;
9500
+ }
9501
+ }
9502
+ }
9503
+ const lastKey = path5[path5.length - 1];
9504
+ if (isArray(parent)) {
9505
+ parent[+lastKey] = mapper(parent[+lastKey]);
9506
+ } else if (isPlainObject2(parent)) {
9507
+ parent[lastKey] = mapper(parent[lastKey]);
9508
+ }
9509
+ if (isSet(parent)) {
9510
+ const oldValue = getNthKey(parent, +lastKey);
9511
+ const newValue = mapper(oldValue);
9512
+ if (oldValue !== newValue) {
9513
+ parent.delete(oldValue);
9514
+ parent.add(newValue);
9515
+ }
9516
+ }
9517
+ if (isMap(parent)) {
9518
+ const row = +path5[path5.length - 2];
9519
+ const keyToRow = getNthKey(parent, row);
9520
+ const type = +lastKey === 0 ? "key" : "value";
9521
+ switch (type) {
9522
+ case "key": {
9523
+ const newKey = mapper(keyToRow);
9524
+ parent.set(newKey, parent.get(keyToRow));
9525
+ if (newKey !== keyToRow) {
9526
+ parent.delete(keyToRow);
9527
+ }
9528
+ break;
9529
+ }
9530
+ case "value": {
9531
+ parent.set(keyToRow, mapper(parent.get(keyToRow)));
9532
+ break;
9533
+ }
9534
+ }
9535
+ }
9536
+ return object;
9537
+ }, "setDeep");
9538
+
9539
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.js
9540
+ function traverse(tree, walker2, origin = []) {
9541
+ if (!tree) {
9542
+ return;
9543
+ }
9544
+ if (!isArray(tree)) {
9545
+ forEach(tree, (subtree, key) => traverse(subtree, walker2, [
9546
+ ...origin,
9547
+ ...parsePath(key)
9548
+ ]));
9549
+ return;
9550
+ }
9551
+ const [nodeValue, children] = tree;
9552
+ if (children) {
9553
+ forEach(children, (child, key) => {
9554
+ traverse(child, walker2, [
9555
+ ...origin,
9556
+ ...parsePath(key)
9557
+ ]);
9558
+ });
9559
+ }
9560
+ walker2(nodeValue, origin);
9561
+ }
9562
+ __name(traverse, "traverse");
9563
+ function applyValueAnnotations(plain, annotations, superJson) {
9564
+ traverse(annotations, (type, path5) => {
9565
+ plain = setDeep(plain, path5, (v) => untransformValue(v, type, superJson));
9566
+ });
9567
+ return plain;
9568
+ }
9569
+ __name(applyValueAnnotations, "applyValueAnnotations");
9570
+ function applyReferentialEqualityAnnotations(plain, annotations) {
9571
+ function apply(identicalPaths, path5) {
9572
+ const object = getDeep(plain, parsePath(path5));
9573
+ identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
9574
+ plain = setDeep(plain, identicalObjectPath, () => object);
9575
+ });
9576
+ }
9577
+ __name(apply, "apply");
9578
+ if (isArray(annotations)) {
9579
+ const [root, other] = annotations;
9580
+ root.forEach((identicalPath) => {
9581
+ plain = setDeep(plain, parsePath(identicalPath), () => plain);
9582
+ });
9583
+ if (other) {
9584
+ forEach(other, apply);
9585
+ }
9586
+ } else {
9587
+ forEach(annotations, apply);
9588
+ }
9589
+ return plain;
9590
+ }
9591
+ __name(applyReferentialEqualityAnnotations, "applyReferentialEqualityAnnotations");
9592
+ var isDeep = /* @__PURE__ */ __name((object, superJson) => isPlainObject2(object) || isArray(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson), "isDeep");
9593
+ function addIdentity(object, path5, identities) {
9594
+ const existingSet = identities.get(object);
9595
+ if (existingSet) {
9596
+ existingSet.push(path5);
9597
+ } else {
9598
+ identities.set(object, [
9599
+ path5
9600
+ ]);
9601
+ }
9602
+ }
9603
+ __name(addIdentity, "addIdentity");
9604
+ function generateReferentialEqualityAnnotations(identitites, dedupe) {
9605
+ const result = {};
9606
+ let rootEqualityPaths = void 0;
9607
+ identitites.forEach((paths) => {
9608
+ if (paths.length <= 1) {
9609
+ return;
9610
+ }
9611
+ if (!dedupe) {
9612
+ paths = paths.map((path5) => path5.map(String)).sort((a, b) => a.length - b.length);
9613
+ }
9614
+ const [representativePath, ...identicalPaths] = paths;
9615
+ if (representativePath.length === 0) {
9616
+ rootEqualityPaths = identicalPaths.map(stringifyPath);
9617
+ } else {
9618
+ result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
9619
+ }
9620
+ });
9621
+ if (rootEqualityPaths) {
9622
+ if (isEmptyObject(result)) {
9623
+ return [
9624
+ rootEqualityPaths
9625
+ ];
9626
+ } else {
9627
+ return [
9628
+ rootEqualityPaths,
9629
+ result
9630
+ ];
9631
+ }
9632
+ } else {
9633
+ return isEmptyObject(result) ? void 0 : result;
9634
+ }
9635
+ }
9636
+ __name(generateReferentialEqualityAnnotations, "generateReferentialEqualityAnnotations");
9637
+ var walker = /* @__PURE__ */ __name((object, identities, superJson, dedupe, path5 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
9638
+ const primitive = isPrimitive(object);
9639
+ if (!primitive) {
9640
+ addIdentity(object, path5, identities);
9641
+ const seen = seenObjects.get(object);
9642
+ if (seen) {
9643
+ return dedupe ? {
9644
+ transformedValue: null
9645
+ } : seen;
9646
+ }
9647
+ }
9648
+ if (!isDeep(object, superJson)) {
9649
+ const transformed2 = transformValue(object, superJson);
9650
+ const result2 = transformed2 ? {
9651
+ transformedValue: transformed2.value,
9652
+ annotations: [
9653
+ transformed2.type
9654
+ ]
9655
+ } : {
9656
+ transformedValue: object
9657
+ };
9658
+ if (!primitive) {
9659
+ seenObjects.set(object, result2);
9660
+ }
9661
+ return result2;
9662
+ }
9663
+ if (includes(objectsInThisPath, object)) {
9664
+ return {
9665
+ transformedValue: null
9666
+ };
9667
+ }
9668
+ const transformationResult = transformValue(object, superJson);
9669
+ const transformed = transformationResult?.value ?? object;
9670
+ const transformedValue = isArray(transformed) ? [] : {};
9671
+ const innerAnnotations = {};
9672
+ forEach(transformed, (value, index) => {
9673
+ if (index === "__proto__" || index === "constructor" || index === "prototype") {
9674
+ throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
9675
+ }
9676
+ const recursiveResult = walker(value, identities, superJson, dedupe, [
9677
+ ...path5,
9678
+ index
9679
+ ], [
9680
+ ...objectsInThisPath,
9681
+ object
9682
+ ], seenObjects);
9683
+ transformedValue[index] = recursiveResult.transformedValue;
9684
+ if (isArray(recursiveResult.annotations)) {
9685
+ innerAnnotations[index] = recursiveResult.annotations;
9686
+ } else if (isPlainObject2(recursiveResult.annotations)) {
9687
+ forEach(recursiveResult.annotations, (tree, key) => {
9688
+ innerAnnotations[escapeKey(index) + "." + key] = tree;
9689
+ });
9690
+ }
9691
+ });
9692
+ const result = isEmptyObject(innerAnnotations) ? {
9693
+ transformedValue,
9694
+ annotations: !!transformationResult ? [
9695
+ transformationResult.type
9696
+ ] : void 0
9697
+ } : {
9698
+ transformedValue,
9699
+ annotations: !!transformationResult ? [
9700
+ transformationResult.type,
9701
+ innerAnnotations
9702
+ ] : innerAnnotations
9703
+ };
9704
+ if (!primitive) {
9705
+ seenObjects.set(object, result);
9706
+ }
9707
+ return result;
9708
+ }, "walker");
9709
+
9710
+ // ../../node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.js
9711
+ init_esm_shims();
9712
+
9713
+ // ../../node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.js
9714
+ init_esm_shims();
9715
+ function getType2(payload) {
9716
+ return Object.prototype.toString.call(payload).slice(8, -1);
9717
+ }
9718
+ __name(getType2, "getType");
9719
+ function isArray2(payload) {
9720
+ return getType2(payload) === "Array";
9721
+ }
9722
+ __name(isArray2, "isArray");
9723
+ function isPlainObject3(payload) {
9724
+ if (getType2(payload) !== "Object") return false;
9725
+ const prototype = Object.getPrototypeOf(payload);
9726
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
9727
+ }
9728
+ __name(isPlainObject3, "isPlainObject");
9729
+ function isNull2(payload) {
9730
+ return getType2(payload) === "Null";
9731
+ }
9732
+ __name(isNull2, "isNull");
9733
+ function isOneOf(a, b, c, d, e) {
9734
+ return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
9735
+ }
9736
+ __name(isOneOf, "isOneOf");
9737
+ function isUndefined2(payload) {
9738
+ return getType2(payload) === "Undefined";
9739
+ }
9740
+ __name(isUndefined2, "isUndefined");
9741
+ var isNullOrUndefined = isOneOf(isNull2, isUndefined2);
9742
+
9743
+ // ../../node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.js
9744
+ function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
9745
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
9746
+ if (propType === "enumerable") carry[key] = newVal;
9747
+ if (includeNonenumerable && propType === "nonenumerable") {
9748
+ Object.defineProperty(carry, key, {
9749
+ value: newVal,
9750
+ enumerable: false,
9751
+ writable: true,
9752
+ configurable: true
9753
+ });
9754
+ }
9755
+ }
9756
+ __name(assignProp, "assignProp");
9757
+ function copy(target, options = {}) {
9758
+ if (isArray2(target)) {
9759
+ return target.map((item) => copy(item, options));
9760
+ }
9761
+ if (!isPlainObject3(target)) {
9762
+ return target;
9763
+ }
9764
+ const props = Object.getOwnPropertyNames(target);
9765
+ const symbols = Object.getOwnPropertySymbols(target);
9766
+ return [
9767
+ ...props,
9768
+ ...symbols
9769
+ ].reduce((carry, key) => {
9770
+ if (isArray2(options.props) && !options.props.includes(key)) {
9771
+ return carry;
9772
+ }
9773
+ const val = target[key];
9774
+ const newVal = copy(val, options);
9775
+ assignProp(carry, key, newVal, target, options.nonenumerable);
9776
+ return carry;
9777
+ }, {});
9778
+ }
9779
+ __name(copy, "copy");
9780
+
9781
+ // ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.js
9782
+ var SuperJSON = class {
9783
+ static {
9784
+ __name(this, "SuperJSON");
9785
+ }
9786
+ /**
9787
+ * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
9788
+ */
9789
+ constructor({ dedupe = false } = {}) {
9790
+ this.classRegistry = new ClassRegistry();
9791
+ this.symbolRegistry = new Registry((s) => s.description ?? "");
9792
+ this.customTransformerRegistry = new CustomTransformerRegistry();
9793
+ this.allowedErrorProps = [];
9794
+ this.dedupe = dedupe;
9795
+ }
9796
+ serialize(object) {
9797
+ const identities = /* @__PURE__ */ new Map();
9798
+ const output = walker(object, identities, this, this.dedupe);
9799
+ const res = {
9800
+ json: output.transformedValue
9801
+ };
9802
+ if (output.annotations) {
9803
+ res.meta = {
9804
+ ...res.meta,
9805
+ values: output.annotations
9806
+ };
9807
+ }
9808
+ const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
9809
+ if (equalityAnnotations) {
9810
+ res.meta = {
9811
+ ...res.meta,
9812
+ referentialEqualities: equalityAnnotations
9813
+ };
9814
+ }
9815
+ return res;
9816
+ }
9817
+ deserialize(payload) {
9818
+ const { json, meta } = payload;
9819
+ let result = copy(json);
9820
+ if (meta?.values) {
9821
+ result = applyValueAnnotations(result, meta.values, this);
9822
+ }
9823
+ if (meta?.referentialEqualities) {
9824
+ result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
9825
+ }
9826
+ return result;
9827
+ }
9828
+ stringify(object) {
9829
+ return JSON.stringify(this.serialize(object));
9830
+ }
9831
+ parse(string) {
9832
+ return this.deserialize(JSON.parse(string));
9833
+ }
9834
+ registerClass(v, options) {
9835
+ this.classRegistry.register(v, options);
9836
+ }
9837
+ registerSymbol(v, identifier) {
9838
+ this.symbolRegistry.register(v, identifier);
9839
+ }
9840
+ registerCustom(transformer, name) {
9841
+ this.customTransformerRegistry.register({
9842
+ name,
9843
+ ...transformer
9844
+ });
9845
+ }
9846
+ allowErrorProps(...props) {
9847
+ this.allowedErrorProps.push(...props);
9848
+ }
9849
+ };
9850
+ SuperJSON.defaultInstance = new SuperJSON();
9851
+ SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
9852
+ SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
9853
+ SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
9854
+ SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
9855
+ SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
9856
+ SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
9857
+ SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
9858
+ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
9859
+ var serialize = SuperJSON.serialize;
9860
+ var deserialize = SuperJSON.deserialize;
9861
+ var stringify = SuperJSON.stringify;
9862
+ var parse3 = SuperJSON.parse;
9863
+ var registerClass = SuperJSON.registerClass;
9864
+ var registerCustom = SuperJSON.registerCustom;
9865
+ var registerSymbol = SuperJSON.registerSymbol;
9866
+ var allowErrorProps = SuperJSON.allowErrorProps;
9867
+
9868
+ // ../json/src/utils/parse-error.ts
9869
+ init_esm_shims();
9870
+
9871
+ // ../../node_modules/.pnpm/lines-and-columns@2.0.4/node_modules/lines-and-columns/build/index.mjs
9872
+ init_esm_shims();
9873
+ var LF = "\n";
9874
+ var CR = "\r";
9875
+ var LinesAndColumns = (
9876
+ /** @class */
9877
+ function() {
9878
+ function LinesAndColumns2(string) {
9879
+ this.length = string.length;
9880
+ var offsets = [0];
9881
+ for (var offset = 0; offset < string.length; ) {
9882
+ switch (string[offset]) {
9883
+ case LF:
9884
+ offset += LF.length;
9885
+ offsets.push(offset);
9886
+ break;
9887
+ case CR:
9888
+ offset += CR.length;
9889
+ if (string[offset] === LF) {
9890
+ offset += LF.length;
9891
+ }
9892
+ offsets.push(offset);
9893
+ break;
9894
+ default:
9895
+ offset++;
9896
+ break;
6023
9897
  }
6024
9898
  }
6025
- if (parsedAttributeArgs.hide) {
6026
- hiddenModels.push(model.name);
9899
+ this.offsets = offsets;
9900
+ }
9901
+ __name(LinesAndColumns2, "LinesAndColumns");
9902
+ LinesAndColumns2.prototype.locationForIndex = function(index) {
9903
+ if (index < 0 || index > this.length) {
9904
+ return null;
9905
+ }
9906
+ var line = 0;
9907
+ var offsets = this.offsets;
9908
+ while (offsets[line + 1] <= index) {
9909
+ line++;
9910
+ }
9911
+ var column = index - offsets[line];
9912
+ return { line, column };
9913
+ };
9914
+ LinesAndColumns2.prototype.indexForLocation = function(location) {
9915
+ var line = location.line, column = location.column;
9916
+ if (line < 0 || line >= this.offsets.length) {
9917
+ return null;
9918
+ }
9919
+ if (column < 0 || column > this.lengthOfLine(line)) {
9920
+ return null;
9921
+ }
9922
+ return this.offsets[line] + column;
9923
+ };
9924
+ LinesAndColumns2.prototype.lengthOfLine = function(line) {
9925
+ var offset = this.offsets[line];
9926
+ var nextOffset = line === this.offsets.length - 1 ? this.length : this.offsets[line + 1];
9927
+ return nextOffset - offset;
9928
+ };
9929
+ return LinesAndColumns2;
9930
+ }()
9931
+ );
9932
+
9933
+ // ../json/src/utils/code-frames.ts
9934
+ init_esm_shims();
9935
+ var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
9936
+ function getMarkerLines(loc, source, opts = {}) {
9937
+ const startLoc = {
9938
+ column: 0,
9939
+ line: -1,
9940
+ ...loc.start
9941
+ };
9942
+ const endLoc = {
9943
+ ...startLoc,
9944
+ ...loc.end
9945
+ };
9946
+ const { linesAbove = 2, linesBelow = 3 } = opts || {};
9947
+ const startLine = startLoc.line;
9948
+ const startColumn = startLoc.column;
9949
+ const endLine = endLoc.line;
9950
+ const endColumn = endLoc.column;
9951
+ let start = Math.max(startLine - (linesAbove + 1), 0);
9952
+ let end = Math.min(source.length, endLine + linesBelow);
9953
+ if (startLine === -1) {
9954
+ start = 0;
9955
+ }
9956
+ if (endLine === -1) {
9957
+ end = source.length;
9958
+ }
9959
+ const lineDiff = endLine - startLine;
9960
+ const markerLines = {};
9961
+ if (lineDiff) {
9962
+ for (let i = 0; i <= lineDiff; i++) {
9963
+ const lineNumber = i + startLine;
9964
+ if (!startColumn) {
9965
+ markerLines[lineNumber] = true;
9966
+ } else if (i === 0) {
9967
+ const sourceLength = source[lineNumber - 1]?.length ?? 0;
9968
+ markerLines[lineNumber] = [
9969
+ startColumn,
9970
+ sourceLength - startColumn + 1
9971
+ ];
9972
+ } else if (i === lineDiff) {
9973
+ markerLines[lineNumber] = [
9974
+ 0,
9975
+ endColumn
9976
+ ];
9977
+ } else {
9978
+ const sourceLength = source[lineNumber - i]?.length ?? 0;
9979
+ markerLines[lineNumber] = [
9980
+ 0,
9981
+ sourceLength
9982
+ ];
6027
9983
  }
6028
9984
  }
9985
+ } else if (startColumn === endColumn) {
9986
+ markerLines[startLine] = startColumn ? [
9987
+ startColumn,
9988
+ 0
9989
+ ] : true;
9990
+ } else {
9991
+ markerLines[startLine] = [
9992
+ startColumn,
9993
+ endColumn - startColumn
9994
+ ];
6029
9995
  }
9996
+ return {
9997
+ start,
9998
+ end,
9999
+ markerLines
10000
+ };
6030
10001
  }
6031
- __name(resolveModelsComments, "resolveModelsComments");
6032
- var getImports = /* @__PURE__ */ __name((type, newPath) => {
6033
- let statement = "";
6034
- if (type === "trpc") {
6035
- statement = "import * as trpc from '@trpc/server';\n";
6036
- } else if (type === "trpc-shield") {
6037
- statement = "import { shield, allow } from 'trpc-shield';\n";
6038
- } else if (type === "context") {
6039
- statement = `import { Context } from '${newPath}';
10002
+ __name(getMarkerLines, "getMarkerLines");
10003
+ function codeFrameColumns(rawLines, loc, opts = {}) {
10004
+ const lines = rawLines.split(NEWLINE);
10005
+ const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
10006
+ const numberMaxWidth = String(end).length;
10007
+ const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;
10008
+ const frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
10009
+ const number = start + 1 + index;
10010
+ const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
10011
+ const gutter = ` ${paddedNumber} | `;
10012
+ const hasMarker = Boolean(markerLines[number] ?? false);
10013
+ if (hasMarker) {
10014
+ let markerLine = "";
10015
+ if (Array.isArray(hasMarker)) {
10016
+ const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
10017
+ const numberOfMarkers = hasMarker[1] || 1;
10018
+ markerLine = [
10019
+ "\n ",
10020
+ gutter.replace(/\d/g, " "),
10021
+ markerSpacing,
10022
+ "^".repeat(numberOfMarkers)
10023
+ ].join("");
10024
+ }
10025
+ return [
10026
+ ">",
10027
+ gutter,
10028
+ line,
10029
+ markerLine
10030
+ ].join("");
10031
+ }
10032
+ return ` ${gutter}${line}`;
10033
+ }).join("\n");
10034
+ return frame;
10035
+ }
10036
+ __name(codeFrameColumns, "codeFrameColumns");
10037
+
10038
+ // ../json/src/utils/parse-error.ts
10039
+ function formatParseError(input, parseError) {
10040
+ const { error, offset, length } = parseError;
10041
+ const result = new LinesAndColumns(input).locationForIndex(offset);
10042
+ let line = result?.line ?? 0;
10043
+ let column = result?.column ?? 0;
10044
+ line++;
10045
+ column++;
10046
+ return `${printParseErrorCode(error)} in JSON at ${line}:${column}
10047
+ ${codeFrameColumns(input, {
10048
+ start: {
10049
+ line,
10050
+ column
10051
+ },
10052
+ end: {
10053
+ line,
10054
+ column: column + length
10055
+ }
10056
+ })}
6040
10057
  `;
10058
+ }
10059
+ __name(formatParseError, "formatParseError");
10060
+
10061
+ // ../json/src/utils/stringify.ts
10062
+ init_esm_shims();
10063
+
10064
+ // ../type-checks/src/is-number.ts
10065
+ init_esm_shims();
10066
+ var isNumber2 = /* @__PURE__ */ __name((value) => {
10067
+ try {
10068
+ return value instanceof Number || typeof value === "number" || Number(value) === value;
10069
+ } catch {
10070
+ return false;
6041
10071
  }
6042
- return statement;
6043
- }, "getImports");
6044
- var wrapWithObject = /* @__PURE__ */ __name(({ shieldItemLines }) => {
6045
- let wrapped = "{";
6046
- wrapped += "\n";
6047
- wrapped += Array.isArray(shieldItemLines) ? ` ${shieldItemLines.join(",\r\n")}` : ` ${shieldItemLines}`;
6048
- wrapped += "\n";
6049
- wrapped += "}";
6050
- return wrapped;
6051
- }, "wrapWithObject");
6052
- var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }) => {
6053
- let wrapped = "shield<Context>(";
6054
- wrapped += "\n";
6055
- wrapped += ` ${shieldObjectTextWrapped}`;
6056
- wrapped += "\n";
6057
- wrapped += ")";
6058
- return wrapped;
6059
- }, "wrapWithTrpcShieldCall");
6060
- var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
6061
- return `export const permissions = ${shieldObjectText};`;
6062
- }, "wrapWithExport");
6063
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options) => {
6064
- if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
6065
- return "";
10072
+ }, "isNumber");
10073
+
10074
+ // ../json/src/utils/stringify.ts
10075
+ var stringify2 = /* @__PURE__ */ __name((value, spacing = 2) => {
10076
+ const space = isNumber2(spacing) ? " ".repeat(spacing) : spacing;
10077
+ switch (value) {
10078
+ case null: {
10079
+ return "null";
10080
+ }
10081
+ case void 0: {
10082
+ return "undefined";
10083
+ }
10084
+ case true: {
10085
+ return "true";
10086
+ }
10087
+ case false: {
10088
+ return "false";
10089
+ }
6066
10090
  }
6067
- let rootItems = "";
6068
- if (queries.length > 0) {
6069
- const queryLinesWrapped = `query: ${wrapWithObject({
6070
- shieldItemLines: queries.map((query) => `${query}: allow`)
6071
- })},`;
6072
- rootItems += queryLinesWrapped;
10091
+ if (Array.isArray(value)) {
10092
+ return `[${space}${value.map((v) => stringify2(v, space)).join(`,${space}`)}${space}]`;
6073
10093
  }
6074
- if (mutations.length > 0) {
6075
- const mutationLinesWrapped = `mutation: ${wrapWithObject({
6076
- shieldItemLines: mutations.map((mutation) => `${mutation}: allow`)
6077
- })},`;
6078
- rootItems += mutationLinesWrapped;
10094
+ if (value instanceof Uint8Array) {
10095
+ return value.toString();
6079
10096
  }
6080
- if (subscriptions.length > 0) {
6081
- const subscriptionLinesWrapped = `subscription: ${wrapWithObject({
6082
- shieldItemLines: subscriptions.map((subscription) => `${subscription}: allow`)
6083
- })},`;
6084
- rootItems += subscriptionLinesWrapped;
10097
+ switch (typeof value) {
10098
+ case "number": {
10099
+ return `${value}`;
10100
+ }
10101
+ case "string": {
10102
+ return JSON.stringify(value);
10103
+ }
10104
+ case "object": {
10105
+ const keys = Object.keys(value);
10106
+ return `{${space}${keys.map((k) => `${k}: ${space}${stringify2(value[k], space)}`).join(`,${space}`)}${space}}`;
10107
+ }
10108
+ default:
10109
+ return "null";
6085
10110
  }
6086
- if (rootItems.length === 0) return "";
6087
- let shieldText = getImports("trpc-shield");
6088
- const internals = await getPrismaInternals();
6089
- const outputDir = internals.parseEnvValue(options.generator.output);
6090
- shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
6091
- shieldText += "\n\n";
6092
- shieldText += wrapWithExport({
6093
- shieldObjectText: wrapWithTrpcShieldCall({
6094
- shieldObjectTextWrapped: wrapWithObject({
6095
- shieldItemLines: rootItems
6096
- })
6097
- })
6098
- });
6099
- return shieldText;
6100
- }, "constructShield");
10111
+ }, "stringify");
6101
10112
 
6102
- // src/project.ts
6103
- init_esm_shims();
6104
- import { ModuleKind, Project, ScriptTarget } from "ts-morph";
6105
- var compilerOptions = {
6106
- target: ScriptTarget.ESNext,
6107
- module: ModuleKind.ESNext,
6108
- emitDecoratorMetadata: true,
6109
- experimentalDecorators: true,
6110
- esModuleInterop: true
6111
- };
6112
- var project = new Project({
6113
- compilerOptions: {
6114
- ...compilerOptions
10113
+ // ../json/src/storm-json.ts
10114
+ var StormJSON = class _StormJSON extends SuperJSON {
10115
+ static {
10116
+ __name(this, "StormJSON");
6115
10117
  }
6116
- });
6117
-
6118
- // src/utils/remove-dir.ts
6119
- init_esm_shims();
6120
- import { promises as fs } from "node:fs";
6121
- import path3 from "node:path";
6122
- async function removeDir(dirPath, onlyContent) {
6123
- const dirEntries = await fs.readdir(dirPath, {
6124
- withFileTypes: true
6125
- });
6126
- await Promise.all(dirEntries.map(async (dirEntry) => {
6127
- const fullPath = path3.join(dirPath, dirEntry.name);
6128
- return dirEntry.isDirectory() ? removeDir(fullPath, false) : fs.unlink(fullPath);
6129
- }));
6130
- if (!onlyContent) {
6131
- await fs.rmdir(dirPath);
10118
+ static #instance;
10119
+ static get instance() {
10120
+ if (!_StormJSON.#instance) {
10121
+ _StormJSON.#instance = new _StormJSON();
10122
+ }
10123
+ return _StormJSON.#instance;
6132
10124
  }
6133
- }
6134
- __name(removeDir, "removeDir");
10125
+ /**
10126
+ * Deserialize the given value with superjson using the given metadata
10127
+ */
10128
+ static deserialize(payload) {
10129
+ return _StormJSON.instance.deserialize(payload);
10130
+ }
10131
+ /**
10132
+ * Serialize the given value with superjson
10133
+ *
10134
+ *
10135
+ */
10136
+ static serialize(object) {
10137
+ return _StormJSON.instance.serialize(object);
10138
+ }
10139
+ /**
10140
+ * Parse the given string value with superjson using the given metadata
10141
+ *
10142
+ * @param value - The string value to parse
10143
+ * @returns The parsed data
10144
+ */
10145
+ static parse(value) {
10146
+ return _StormJSON.instance.parse(value);
10147
+ }
10148
+ /**
10149
+ * Serializes the given data to a JSON string.
10150
+ * By default the JSON string is formatted with a 2 space indentation to be easy readable.
10151
+ *
10152
+ * @param value - Object which should be serialized to JSON
10153
+ * @param options - JSON serialize options
10154
+ * @returns the formatted JSON representation of the object
10155
+ */
10156
+ static stringify(value, options) {
10157
+ const customTransformer = _StormJSON.instance.customTransformerRegistry.findApplicable(value);
10158
+ let result = value;
10159
+ if (customTransformer) {
10160
+ result = customTransformer.serialize(result);
10161
+ }
10162
+ return stringify2(result?.json ? result?.json : result, options?.spaces);
10163
+ }
10164
+ /**
10165
+ * Stringify the given value with superjson
10166
+ *
10167
+ * @param obj - The object to stringify
10168
+ * @returns The stringified object
10169
+ */
10170
+ static stringifyBase(obj) {
10171
+ return _StormJSON.instance.stringify(obj);
10172
+ }
10173
+ /**
10174
+ * Parses the given JSON string and returns the object the JSON content represents.
10175
+ * By default javascript-style comments and trailing commas are allowed.
10176
+ *
10177
+ * @param strData - JSON content as string
10178
+ * @param options - JSON parse options
10179
+ * @returns Object the JSON content represents
10180
+ */
10181
+ static parseJson(strData, options) {
10182
+ try {
10183
+ if (options?.expectComments === false) {
10184
+ return _StormJSON.instance.parse(strData);
10185
+ }
10186
+ } catch {
10187
+ }
10188
+ const errors = [];
10189
+ const opts = {
10190
+ allowTrailingComma: true,
10191
+ ...options
10192
+ };
10193
+ const result = parse2(strData, errors, opts);
10194
+ if (errors.length > 0 && errors[0]) {
10195
+ throw new Error(formatParseError(strData, errors[0]));
10196
+ }
10197
+ return result;
10198
+ }
10199
+ /**
10200
+ * Register a custom schema with superjson
10201
+ *
10202
+ * @param name - The name of the schema
10203
+ * @param serialize - The function to serialize the schema
10204
+ * @param deserialize - The function to deserialize the schema
10205
+ * @param isApplicable - The function to check if the schema is applicable
10206
+ */
10207
+ static register(name, serialize2, deserialize2, isApplicable) {
10208
+ _StormJSON.instance.registerCustom({
10209
+ isApplicable,
10210
+ serialize: serialize2,
10211
+ deserialize: deserialize2
10212
+ }, name);
10213
+ }
10214
+ /**
10215
+ * Register a class with superjson
10216
+ *
10217
+ * @param classConstructor - The class constructor to register
10218
+ */
10219
+ static registerClass(classConstructor, options) {
10220
+ _StormJSON.instance.registerClass(classConstructor, {
10221
+ identifier: isString(options) ? options : options?.identifier || classConstructor.name,
10222
+ allowProps: options && isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : [
10223
+ "__typename"
10224
+ ]
10225
+ });
10226
+ }
10227
+ constructor() {
10228
+ super({
10229
+ dedupe: true
10230
+ });
10231
+ }
10232
+ };
10233
+ StormJSON.instance.registerCustom({
10234
+ isApplicable: /* @__PURE__ */ __name((v) => import_buffer.Buffer.isBuffer(v), "isApplicable"),
10235
+ serialize: /* @__PURE__ */ __name((v) => v.toString("base64"), "serialize"),
10236
+ deserialize: /* @__PURE__ */ __name((v) => import_buffer.Buffer.from(v, "base64"), "deserialize")
10237
+ }, "Bytes");
6135
10238
 
6136
- // src/utils/write-file-safely.ts
6137
- init_esm_shims();
6138
- import fs2 from "node:fs";
6139
- import path4 from "node:path";
10239
+ // ../fs/src/write-file.ts
10240
+ import { writeFile as writeFileFs } from "node:fs/promises";
10241
+ var writeFile = /* @__PURE__ */ __name(async (filePath, content, options) => {
10242
+ if (!filePath) {
10243
+ throw new Error("No file path provided to read data");
10244
+ }
10245
+ const directory = findFilePath(correctPath(filePath));
10246
+ if (!existsSync(directory)) {
10247
+ if (options?.createDirectory !== false) {
10248
+ await createDirectory(directory);
10249
+ } else {
10250
+ throw new Error(`Directory ${directory} does not exist`);
10251
+ }
10252
+ }
10253
+ return writeFileFs(filePath, content || "", options);
10254
+ }, "writeFile");
6140
10255
 
6141
10256
  // src/utils/format-file.ts
6142
10257
  init_esm_shims();
@@ -6165,10 +10280,11 @@ __name(formatFile, "formatFile");
6165
10280
 
6166
10281
  // src/utils/write-file-safely.ts
6167
10282
  var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content) => {
6168
- fs2.mkdirSync(path4.dirname(writeLocation), {
6169
- recursive: true
6170
- });
6171
- fs2.writeFileSync(writeLocation, await formatFile(content));
10283
+ const [fileContent] = await Promise.all([
10284
+ formatFile(content),
10285
+ createDirectory(findFilePath(writeLocation))
10286
+ ]);
10287
+ await writeFile(writeLocation, fileContent);
6172
10288
  }, "writeFileSafely");
6173
10289
 
6174
10290
  // src/prisma-generator.ts
@@ -6248,7 +10364,7 @@ async function generate(options) {
6248
10364
  mutations.sort();
6249
10365
  subscriptions.sort();
6250
10366
  consoleLog("Constructing tRPC Shield source file");
6251
- const shieldText = constructShield({
10367
+ const shieldText = await constructShield({
6252
10368
  queries,
6253
10369
  mutations,
6254
10370
  subscriptions
@@ -6274,7 +10390,7 @@ async function generate(options) {
6274
10390
  }
6275
10391
  consoleLog(`Generating tRPC source code for ${models.length} models`);
6276
10392
  resolveModelsComments(models, hiddenModels);
6277
- const createRouter = project.createSourceFile(path5.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
10393
+ const createRouter = project.createSourceFile(path4.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
6278
10394
  overwrite: true
6279
10395
  });
6280
10396
  consoleLog("Generating tRPC imports");
@@ -6287,7 +10403,7 @@ async function generate(options) {
6287
10403
  createRouter.formatText({
6288
10404
  indentSize: 2
6289
10405
  });
6290
- const appRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `index.ts`), void 0, {
10406
+ const appRouter = project.createSourceFile(path4.resolve(outputDir, "routers", `index.ts`), void 0, {
6291
10407
  overwrite: true
6292
10408
  });
6293
10409
  consoleLog("Generating tRPC router imports");
@@ -6309,7 +10425,7 @@ async function generate(options) {
6309
10425
  const plural = (0, import_pluralize.default)(model.toLowerCase());
6310
10426
  consoleLog(`Generating tRPC router for model ${model}`);
6311
10427
  generateRouterImport(appRouter, plural, model);
6312
- const modelRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
10428
+ const modelRouter = project.createSourceFile(path4.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
6313
10429
  overwrite: true
6314
10430
  });
6315
10431
  generateCreateRouterImport({
@@ -6376,3 +10492,16 @@ getPrismaGeneratorHelper().then((helpers) => {
6376
10492
  }).catch((reason) => {
6377
10493
  console.error(`An error occured while generating prisma tRPC source code: ${reason}`);
6378
10494
  });
10495
+ /*! Bundled license information:
10496
+
10497
+ ieee754/index.js:
10498
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
10499
+
10500
+ buffer/index.js:
10501
+ (*!
10502
+ * The buffer module from node.js, for the browser.
10503
+ *
10504
+ * @author Feross Aboukhadijeh <https://feross.org>
10505
+ * @license MIT
10506
+ *)
10507
+ */