@pkgverse/prismock 2.0.5-beta.0 → 2.0.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/v6/index.mjs CHANGED
@@ -16,6 +16,16 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  return to;
17
17
  };
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
19
29
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
30
 
21
31
  // node_modules/@noble/hashes/_u64.js
@@ -627,6 +637,2646 @@ var require_src = __commonJS((exports, module) => {
627
637
  exports.isCuid = isCuid;
628
638
  });
629
639
 
640
+ // node_modules/@prisma/client-runtime-utils/dist/index.mjs
641
+ var exports_dist = {};
642
+ __export(exports_dist, {
643
+ sql: () => sql,
644
+ raw: () => raw,
645
+ join: () => join,
646
+ isJsonNull: () => isJsonNull,
647
+ isDbNull: () => isDbNull,
648
+ isAnyNull: () => isAnyNull,
649
+ hasBatchIndex: () => hasBatchIndex,
650
+ empty: () => empty,
651
+ Sql: () => Sql,
652
+ PrismaClientValidationError: () => PrismaClientValidationError,
653
+ PrismaClientUnknownRequestError: () => PrismaClientUnknownRequestError,
654
+ PrismaClientRustPanicError: () => PrismaClientRustPanicError,
655
+ PrismaClientRustError: () => PrismaClientRustError,
656
+ PrismaClientKnownRequestError: () => PrismaClientKnownRequestError,
657
+ PrismaClientInitializationError: () => PrismaClientInitializationError,
658
+ ObjectEnumValue: () => ObjectEnumValue,
659
+ NullTypes: () => NullTypes,
660
+ JsonNullClass: () => JsonNullClass,
661
+ JsonNull: () => JsonNull,
662
+ Decimal: () => Decimal,
663
+ DbNullClass: () => DbNullClass,
664
+ DbNull: () => DbNull,
665
+ AnyNullClass: () => AnyNullClass,
666
+ AnyNull: () => AnyNull
667
+ });
668
+ function hasBatchIndex(value) {
669
+ return typeof value["batchRequestIdx"] === "number";
670
+ }
671
+ function setClassName(classObject, name) {
672
+ Object.defineProperty(classObject, "name", {
673
+ value: name,
674
+ configurable: true
675
+ });
676
+ }
677
+ function getBacktrace(log3) {
678
+ if (log3.fields?.message) {
679
+ let str = log3.fields?.message;
680
+ if (log3.fields?.file) {
681
+ str += ` in ${log3.fields.file}`;
682
+ if (log3.fields?.line) {
683
+ str += `:${log3.fields.line}`;
684
+ }
685
+ if (log3.fields?.column) {
686
+ str += `:${log3.fields.column}`;
687
+ }
688
+ }
689
+ if (log3.fields?.reason) {
690
+ str += `
691
+ ${log3.fields?.reason}`;
692
+ }
693
+ return str;
694
+ }
695
+ return "Unknown error";
696
+ }
697
+ function isPanic(err) {
698
+ return err.fields?.message === "PANIC";
699
+ }
700
+ function setClassName2(classObject, name) {
701
+ Object.defineProperty(classObject, "name", {
702
+ value: name,
703
+ configurable: true
704
+ });
705
+ }
706
+ function isDbNull(value) {
707
+ return value === DbNull;
708
+ }
709
+ function isJsonNull(value) {
710
+ return value === JsonNull;
711
+ }
712
+ function isAnyNull(value) {
713
+ return value === AnyNull;
714
+ }
715
+ function digitsToString(d) {
716
+ var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
717
+ if (indexOfLastWord > 0) {
718
+ str += w;
719
+ for (i = 1;i < indexOfLastWord; i++) {
720
+ ws = d[i] + "";
721
+ k = LOG_BASE - ws.length;
722
+ if (k)
723
+ str += getZeroString(k);
724
+ str += ws;
725
+ }
726
+ w = d[i];
727
+ ws = w + "";
728
+ k = LOG_BASE - ws.length;
729
+ if (k)
730
+ str += getZeroString(k);
731
+ } else if (w === 0) {
732
+ return "0";
733
+ }
734
+ for (;w % 10 === 0; )
735
+ w /= 10;
736
+ return str + w;
737
+ }
738
+ function checkInt32(i, min2, max2) {
739
+ if (i !== ~~i || i < min2 || i > max2) {
740
+ throw Error(invalidArgument + i);
741
+ }
742
+ }
743
+ function checkRoundingDigits(d, i, rm, repeating) {
744
+ var di, k, r, rd;
745
+ for (k = d[0];k >= 10; k /= 10)
746
+ --i;
747
+ if (--i < 0) {
748
+ i += LOG_BASE;
749
+ di = 0;
750
+ } else {
751
+ di = Math.ceil((i + 1) / LOG_BASE);
752
+ i %= LOG_BASE;
753
+ }
754
+ k = mathpow(10, LOG_BASE - i);
755
+ rd = d[di] % k | 0;
756
+ if (repeating == null) {
757
+ if (i < 3) {
758
+ if (i == 0)
759
+ rd = rd / 100 | 0;
760
+ else if (i == 1)
761
+ rd = rd / 10 | 0;
762
+ r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
763
+ } else {
764
+ r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
765
+ }
766
+ } else {
767
+ if (i < 4) {
768
+ if (i == 0)
769
+ rd = rd / 1000 | 0;
770
+ else if (i == 1)
771
+ rd = rd / 100 | 0;
772
+ else if (i == 2)
773
+ rd = rd / 10 | 0;
774
+ r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
775
+ } else {
776
+ r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
777
+ }
778
+ }
779
+ return r;
780
+ }
781
+ function convertBase(str, baseIn, baseOut) {
782
+ var j, arr = [0], arrL, i = 0, strL = str.length;
783
+ for (;i < strL; ) {
784
+ for (arrL = arr.length;arrL--; )
785
+ arr[arrL] *= baseIn;
786
+ arr[0] += NUMERALS.indexOf(str.charAt(i++));
787
+ for (j = 0;j < arr.length; j++) {
788
+ if (arr[j] > baseOut - 1) {
789
+ if (arr[j + 1] === undefined)
790
+ arr[j + 1] = 0;
791
+ arr[j + 1] += arr[j] / baseOut | 0;
792
+ arr[j] %= baseOut;
793
+ }
794
+ }
795
+ }
796
+ return arr.reverse();
797
+ }
798
+ function cosine(Ctor, x) {
799
+ var k, len, y;
800
+ if (x.isZero())
801
+ return x;
802
+ len = x.d.length;
803
+ if (len < 32) {
804
+ k = Math.ceil(len / 3);
805
+ y = (1 / tinyPow(4, k)).toString();
806
+ } else {
807
+ k = 16;
808
+ y = "2.3283064365386962890625e-10";
809
+ }
810
+ Ctor.precision += k;
811
+ x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
812
+ for (var i = k;i--; ) {
813
+ var cos2x = x.times(x);
814
+ x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
815
+ }
816
+ Ctor.precision -= k;
817
+ return x;
818
+ }
819
+ function finalise(x, sd, rm, isTruncated) {
820
+ var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
821
+ out:
822
+ if (sd != null) {
823
+ xd = x.d;
824
+ if (!xd)
825
+ return x;
826
+ for (digits = 1, k = xd[0];k >= 10; k /= 10)
827
+ digits++;
828
+ i = sd - digits;
829
+ if (i < 0) {
830
+ i += LOG_BASE;
831
+ j = sd;
832
+ w = xd[xdi = 0];
833
+ rd = w / mathpow(10, digits - j - 1) % 10 | 0;
834
+ } else {
835
+ xdi = Math.ceil((i + 1) / LOG_BASE);
836
+ k = xd.length;
837
+ if (xdi >= k) {
838
+ if (isTruncated) {
839
+ for (;k++ <= xdi; )
840
+ xd.push(0);
841
+ w = rd = 0;
842
+ digits = 1;
843
+ i %= LOG_BASE;
844
+ j = i - LOG_BASE + 1;
845
+ } else {
846
+ break out;
847
+ }
848
+ } else {
849
+ w = k = xd[xdi];
850
+ for (digits = 1;k >= 10; k /= 10)
851
+ digits++;
852
+ i %= LOG_BASE;
853
+ j = i - LOG_BASE + digits;
854
+ rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
855
+ }
856
+ }
857
+ isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== undefined || (j < 0 ? w : w % mathpow(10, digits - j - 1));
858
+ roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
859
+ if (sd < 1 || !xd[0]) {
860
+ xd.length = 0;
861
+ if (roundUp) {
862
+ sd -= x.e + 1;
863
+ xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
864
+ x.e = -sd || 0;
865
+ } else {
866
+ xd[0] = x.e = 0;
867
+ }
868
+ return x;
869
+ }
870
+ if (i == 0) {
871
+ xd.length = xdi;
872
+ k = 1;
873
+ xdi--;
874
+ } else {
875
+ xd.length = xdi + 1;
876
+ k = mathpow(10, LOG_BASE - i);
877
+ xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
878
+ }
879
+ if (roundUp) {
880
+ for (;; ) {
881
+ if (xdi == 0) {
882
+ for (i = 1, j = xd[0];j >= 10; j /= 10)
883
+ i++;
884
+ j = xd[0] += k;
885
+ for (k = 1;j >= 10; j /= 10)
886
+ k++;
887
+ if (i != k) {
888
+ x.e++;
889
+ if (xd[0] == BASE)
890
+ xd[0] = 1;
891
+ }
892
+ break;
893
+ } else {
894
+ xd[xdi] += k;
895
+ if (xd[xdi] != BASE)
896
+ break;
897
+ xd[xdi--] = 0;
898
+ k = 1;
899
+ }
900
+ }
901
+ }
902
+ for (i = xd.length;xd[--i] === 0; )
903
+ xd.pop();
904
+ }
905
+ if (external) {
906
+ if (x.e > Ctor.maxE) {
907
+ x.d = null;
908
+ x.e = NaN;
909
+ } else if (x.e < Ctor.minE) {
910
+ x.e = 0;
911
+ x.d = [0];
912
+ }
913
+ }
914
+ return x;
915
+ }
916
+ function finiteToString(x, isExp, sd) {
917
+ if (!x.isFinite())
918
+ return nonFiniteToString(x);
919
+ var k, e = x.e, str = digitsToString(x.d), len = str.length;
920
+ if (isExp) {
921
+ if (sd && (k = sd - len) > 0) {
922
+ str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
923
+ } else if (len > 1) {
924
+ str = str.charAt(0) + "." + str.slice(1);
925
+ }
926
+ str = str + (x.e < 0 ? "e" : "e+") + x.e;
927
+ } else if (e < 0) {
928
+ str = "0." + getZeroString(-e - 1) + str;
929
+ if (sd && (k = sd - len) > 0)
930
+ str += getZeroString(k);
931
+ } else if (e >= len) {
932
+ str += getZeroString(e + 1 - len);
933
+ if (sd && (k = sd - e - 1) > 0)
934
+ str = str + "." + getZeroString(k);
935
+ } else {
936
+ if ((k = e + 1) < len)
937
+ str = str.slice(0, k) + "." + str.slice(k);
938
+ if (sd && (k = sd - len) > 0) {
939
+ if (e + 1 === len)
940
+ str += ".";
941
+ str += getZeroString(k);
942
+ }
943
+ }
944
+ return str;
945
+ }
946
+ function getBase10Exponent(digits, e) {
947
+ var w = digits[0];
948
+ for (e *= LOG_BASE;w >= 10; w /= 10)
949
+ e++;
950
+ return e;
951
+ }
952
+ function getLn10(Ctor, sd, pr) {
953
+ if (sd > LN10_PRECISION) {
954
+ external = true;
955
+ if (pr)
956
+ Ctor.precision = pr;
957
+ throw Error(precisionLimitExceeded);
958
+ }
959
+ return finalise(new Ctor(LN10), sd, 1, true);
960
+ }
961
+ function getPi(Ctor, sd, rm) {
962
+ if (sd > PI_PRECISION)
963
+ throw Error(precisionLimitExceeded);
964
+ return finalise(new Ctor(PI), sd, rm, true);
965
+ }
966
+ function getPrecision(digits) {
967
+ var w = digits.length - 1, len = w * LOG_BASE + 1;
968
+ w = digits[w];
969
+ if (w) {
970
+ for (;w % 10 == 0; w /= 10)
971
+ len--;
972
+ for (w = digits[0];w >= 10; w /= 10)
973
+ len++;
974
+ }
975
+ return len;
976
+ }
977
+ function getZeroString(k) {
978
+ var zs = "";
979
+ for (;k--; )
980
+ zs += "0";
981
+ return zs;
982
+ }
983
+ function intPow(Ctor, x, n, pr) {
984
+ var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
985
+ external = false;
986
+ for (;; ) {
987
+ if (n % 2) {
988
+ r = r.times(x);
989
+ if (truncate(r.d, k))
990
+ isTruncated = true;
991
+ }
992
+ n = mathfloor(n / 2);
993
+ if (n === 0) {
994
+ n = r.d.length - 1;
995
+ if (isTruncated && r.d[n] === 0)
996
+ ++r.d[n];
997
+ break;
998
+ }
999
+ x = x.times(x);
1000
+ truncate(x.d, k);
1001
+ }
1002
+ external = true;
1003
+ return r;
1004
+ }
1005
+ function isOdd(n) {
1006
+ return n.d[n.d.length - 1] & 1;
1007
+ }
1008
+ function maxOrMin(Ctor, args, n) {
1009
+ var k, y, x = new Ctor(args[0]), i = 0;
1010
+ for (;++i < args.length; ) {
1011
+ y = new Ctor(args[i]);
1012
+ if (!y.s) {
1013
+ x = y;
1014
+ break;
1015
+ }
1016
+ k = x.cmp(y);
1017
+ if (k === n || k === 0 && x.s === n) {
1018
+ x = y;
1019
+ }
1020
+ }
1021
+ return x;
1022
+ }
1023
+ function naturalExponential(x, sd) {
1024
+ var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1025
+ if (!x.d || !x.d[0] || x.e > 17) {
1026
+ return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
1027
+ }
1028
+ if (sd == null) {
1029
+ external = false;
1030
+ wpr = pr;
1031
+ } else {
1032
+ wpr = sd;
1033
+ }
1034
+ t = new Ctor(0.03125);
1035
+ while (x.e > -2) {
1036
+ x = x.times(t);
1037
+ k += 5;
1038
+ }
1039
+ guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
1040
+ wpr += guard;
1041
+ denominator = pow2 = sum2 = new Ctor(1);
1042
+ Ctor.precision = wpr;
1043
+ for (;; ) {
1044
+ pow2 = finalise(pow2.times(x), wpr, 1);
1045
+ denominator = denominator.times(++i);
1046
+ t = sum2.plus(divide(pow2, denominator, wpr, 1));
1047
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1048
+ j = k;
1049
+ while (j--)
1050
+ sum2 = finalise(sum2.times(sum2), wpr, 1);
1051
+ if (sd == null) {
1052
+ if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1053
+ Ctor.precision = wpr += 10;
1054
+ denominator = pow2 = t = new Ctor(1);
1055
+ i = 0;
1056
+ rep++;
1057
+ } else {
1058
+ return finalise(sum2, Ctor.precision = pr, rm, external = true);
1059
+ }
1060
+ } else {
1061
+ Ctor.precision = pr;
1062
+ return sum2;
1063
+ }
1064
+ }
1065
+ sum2 = t;
1066
+ }
1067
+ }
1068
+ function naturalLogarithm(y, sd) {
1069
+ var c, c0, denominator, e, numerator, rep, sum2, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1070
+ if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
1071
+ return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
1072
+ }
1073
+ if (sd == null) {
1074
+ external = false;
1075
+ wpr = pr;
1076
+ } else {
1077
+ wpr = sd;
1078
+ }
1079
+ Ctor.precision = wpr += guard;
1080
+ c = digitsToString(xd);
1081
+ c0 = c.charAt(0);
1082
+ if (Math.abs(e = x.e) < 1500000000000000) {
1083
+ while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
1084
+ x = x.times(y);
1085
+ c = digitsToString(x.d);
1086
+ c0 = c.charAt(0);
1087
+ n++;
1088
+ }
1089
+ e = x.e;
1090
+ if (c0 > 1) {
1091
+ x = new Ctor("0." + c);
1092
+ e++;
1093
+ } else {
1094
+ x = new Ctor(c0 + "." + c.slice(1));
1095
+ }
1096
+ } else {
1097
+ t = getLn10(Ctor, wpr + 2, pr).times(e + "");
1098
+ x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
1099
+ Ctor.precision = pr;
1100
+ return sd == null ? finalise(x, pr, rm, external = true) : x;
1101
+ }
1102
+ x1 = x;
1103
+ sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
1104
+ x2 = finalise(x.times(x), wpr, 1);
1105
+ denominator = 3;
1106
+ for (;; ) {
1107
+ numerator = finalise(numerator.times(x2), wpr, 1);
1108
+ t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
1109
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1110
+ sum2 = sum2.times(2);
1111
+ if (e !== 0)
1112
+ sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
1113
+ sum2 = divide(sum2, new Ctor(n), wpr, 1);
1114
+ if (sd == null) {
1115
+ if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1116
+ Ctor.precision = wpr += guard;
1117
+ t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
1118
+ x2 = finalise(x.times(x), wpr, 1);
1119
+ denominator = rep = 1;
1120
+ } else {
1121
+ return finalise(sum2, Ctor.precision = pr, rm, external = true);
1122
+ }
1123
+ } else {
1124
+ Ctor.precision = pr;
1125
+ return sum2;
1126
+ }
1127
+ }
1128
+ sum2 = t;
1129
+ denominator += 2;
1130
+ }
1131
+ }
1132
+ function nonFiniteToString(x) {
1133
+ return String(x.s * x.s / 0);
1134
+ }
1135
+ function parseDecimal(x, str) {
1136
+ var e, i, len;
1137
+ if ((e = str.indexOf(".")) > -1)
1138
+ str = str.replace(".", "");
1139
+ if ((i = str.search(/e/i)) > 0) {
1140
+ if (e < 0)
1141
+ e = i;
1142
+ e += +str.slice(i + 1);
1143
+ str = str.substring(0, i);
1144
+ } else if (e < 0) {
1145
+ e = str.length;
1146
+ }
1147
+ for (i = 0;str.charCodeAt(i) === 48; i++)
1148
+ ;
1149
+ for (len = str.length;str.charCodeAt(len - 1) === 48; --len)
1150
+ ;
1151
+ str = str.slice(i, len);
1152
+ if (str) {
1153
+ len -= i;
1154
+ x.e = e = e - i - 1;
1155
+ x.d = [];
1156
+ i = (e + 1) % LOG_BASE;
1157
+ if (e < 0)
1158
+ i += LOG_BASE;
1159
+ if (i < len) {
1160
+ if (i)
1161
+ x.d.push(+str.slice(0, i));
1162
+ for (len -= LOG_BASE;i < len; )
1163
+ x.d.push(+str.slice(i, i += LOG_BASE));
1164
+ str = str.slice(i);
1165
+ i = LOG_BASE - str.length;
1166
+ } else {
1167
+ i -= len;
1168
+ }
1169
+ for (;i--; )
1170
+ str += "0";
1171
+ x.d.push(+str);
1172
+ if (external) {
1173
+ if (x.e > x.constructor.maxE) {
1174
+ x.d = null;
1175
+ x.e = NaN;
1176
+ } else if (x.e < x.constructor.minE) {
1177
+ x.e = 0;
1178
+ x.d = [0];
1179
+ }
1180
+ }
1181
+ } else {
1182
+ x.e = 0;
1183
+ x.d = [0];
1184
+ }
1185
+ return x;
1186
+ }
1187
+ function parseOther(x, str) {
1188
+ var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
1189
+ if (str.indexOf("_") > -1) {
1190
+ str = str.replace(/(\d)_(?=\d)/g, "$1");
1191
+ if (isDecimal.test(str))
1192
+ return parseDecimal(x, str);
1193
+ } else if (str === "Infinity" || str === "NaN") {
1194
+ if (!+str)
1195
+ x.s = NaN;
1196
+ x.e = NaN;
1197
+ x.d = null;
1198
+ return x;
1199
+ }
1200
+ if (isHex.test(str)) {
1201
+ base = 16;
1202
+ str = str.toLowerCase();
1203
+ } else if (isBinary.test(str)) {
1204
+ base = 2;
1205
+ } else if (isOctal.test(str)) {
1206
+ base = 8;
1207
+ } else {
1208
+ throw Error(invalidArgument + str);
1209
+ }
1210
+ i = str.search(/p/i);
1211
+ if (i > 0) {
1212
+ p = +str.slice(i + 1);
1213
+ str = str.substring(2, i);
1214
+ } else {
1215
+ str = str.slice(2);
1216
+ }
1217
+ i = str.indexOf(".");
1218
+ isFloat = i >= 0;
1219
+ Ctor = x.constructor;
1220
+ if (isFloat) {
1221
+ str = str.replace(".", "");
1222
+ len = str.length;
1223
+ i = len - i;
1224
+ divisor = intPow(Ctor, new Ctor(base), i, i * 2);
1225
+ }
1226
+ xd = convertBase(str, base, BASE);
1227
+ xe = xd.length - 1;
1228
+ for (i = xe;xd[i] === 0; --i)
1229
+ xd.pop();
1230
+ if (i < 0)
1231
+ return new Ctor(x.s * 0);
1232
+ x.e = getBase10Exponent(xd, xe);
1233
+ x.d = xd;
1234
+ external = false;
1235
+ if (isFloat)
1236
+ x = divide(x, divisor, len * 4);
1237
+ if (p)
1238
+ x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
1239
+ external = true;
1240
+ return x;
1241
+ }
1242
+ function sine(Ctor, x) {
1243
+ var k, len = x.d.length;
1244
+ if (len < 3) {
1245
+ return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
1246
+ }
1247
+ k = 1.4 * Math.sqrt(len);
1248
+ k = k > 16 ? 16 : k | 0;
1249
+ x = x.times(1 / tinyPow(5, k));
1250
+ x = taylorSeries(Ctor, 2, x, x);
1251
+ var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
1252
+ for (;k--; ) {
1253
+ sin2_x = x.times(x);
1254
+ x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
1255
+ }
1256
+ return x;
1257
+ }
1258
+ function taylorSeries(Ctor, n, x, y, isHyperbolic) {
1259
+ var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
1260
+ external = false;
1261
+ x2 = x.times(x);
1262
+ u = new Ctor(y);
1263
+ for (;; ) {
1264
+ t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
1265
+ u = isHyperbolic ? y.plus(t) : y.minus(t);
1266
+ y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
1267
+ t = u.plus(y);
1268
+ if (t.d[k] !== undefined) {
1269
+ for (j = k;t.d[j] === u.d[j] && j--; )
1270
+ ;
1271
+ if (j == -1)
1272
+ break;
1273
+ }
1274
+ j = u;
1275
+ u = y;
1276
+ y = t;
1277
+ t = j;
1278
+ i++;
1279
+ }
1280
+ external = true;
1281
+ t.d.length = k + 1;
1282
+ return t;
1283
+ }
1284
+ function tinyPow(b, e) {
1285
+ var n = b;
1286
+ while (--e)
1287
+ n *= b;
1288
+ return n;
1289
+ }
1290
+ function toLessThanHalfPi(Ctor, x) {
1291
+ var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
1292
+ x = x.abs();
1293
+ if (x.lte(halfPi)) {
1294
+ quadrant = isNeg ? 4 : 1;
1295
+ return x;
1296
+ }
1297
+ t = x.divToInt(pi);
1298
+ if (t.isZero()) {
1299
+ quadrant = isNeg ? 3 : 2;
1300
+ } else {
1301
+ x = x.minus(t.times(pi));
1302
+ if (x.lte(halfPi)) {
1303
+ quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
1304
+ return x;
1305
+ }
1306
+ quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
1307
+ }
1308
+ return x.minus(pi).abs();
1309
+ }
1310
+ function toStringBinary(x, baseOut, sd, rm) {
1311
+ var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== undefined;
1312
+ if (isExp) {
1313
+ checkInt32(sd, 1, MAX_DIGITS2);
1314
+ if (rm === undefined)
1315
+ rm = Ctor.rounding;
1316
+ else
1317
+ checkInt32(rm, 0, 8);
1318
+ } else {
1319
+ sd = Ctor.precision;
1320
+ rm = Ctor.rounding;
1321
+ }
1322
+ if (!x.isFinite()) {
1323
+ str = nonFiniteToString(x);
1324
+ } else {
1325
+ str = finiteToString(x);
1326
+ i = str.indexOf(".");
1327
+ if (isExp) {
1328
+ base = 2;
1329
+ if (baseOut == 16) {
1330
+ sd = sd * 4 - 3;
1331
+ } else if (baseOut == 8) {
1332
+ sd = sd * 3 - 2;
1333
+ }
1334
+ } else {
1335
+ base = baseOut;
1336
+ }
1337
+ if (i >= 0) {
1338
+ str = str.replace(".", "");
1339
+ y = new Ctor(1);
1340
+ y.e = str.length - i;
1341
+ y.d = convertBase(finiteToString(y), 10, base);
1342
+ y.e = y.d.length;
1343
+ }
1344
+ xd = convertBase(str, 10, base);
1345
+ e = len = xd.length;
1346
+ for (;xd[--len] == 0; )
1347
+ xd.pop();
1348
+ if (!xd[0]) {
1349
+ str = isExp ? "0p+0" : "0";
1350
+ } else {
1351
+ if (i < 0) {
1352
+ e--;
1353
+ } else {
1354
+ x = new Ctor(x);
1355
+ x.d = xd;
1356
+ x.e = e;
1357
+ x = divide(x, y, sd, rm, 0, base);
1358
+ xd = x.d;
1359
+ e = x.e;
1360
+ roundUp = inexact;
1361
+ }
1362
+ i = xd[sd];
1363
+ k = base / 2;
1364
+ roundUp = roundUp || xd[sd + 1] !== undefined;
1365
+ roundUp = rm < 4 ? (i !== undefined || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
1366
+ xd.length = sd;
1367
+ if (roundUp) {
1368
+ for (;++xd[--sd] > base - 1; ) {
1369
+ xd[sd] = 0;
1370
+ if (!sd) {
1371
+ ++e;
1372
+ xd.unshift(1);
1373
+ }
1374
+ }
1375
+ }
1376
+ for (len = xd.length;!xd[len - 1]; --len)
1377
+ ;
1378
+ for (i = 0, str = "";i < len; i++)
1379
+ str += NUMERALS.charAt(xd[i]);
1380
+ if (isExp) {
1381
+ if (len > 1) {
1382
+ if (baseOut == 16 || baseOut == 8) {
1383
+ i = baseOut == 16 ? 4 : 3;
1384
+ for (--len;len % i; len++)
1385
+ str += "0";
1386
+ xd = convertBase(str, base, baseOut);
1387
+ for (len = xd.length;!xd[len - 1]; --len)
1388
+ ;
1389
+ for (i = 1, str = "1.";i < len; i++)
1390
+ str += NUMERALS.charAt(xd[i]);
1391
+ } else {
1392
+ str = str.charAt(0) + "." + str.slice(1);
1393
+ }
1394
+ }
1395
+ str = str + (e < 0 ? "p" : "p+") + e;
1396
+ } else if (e < 0) {
1397
+ for (;++e; )
1398
+ str = "0" + str;
1399
+ str = "0." + str;
1400
+ } else {
1401
+ if (++e > len)
1402
+ for (e -= len;e--; )
1403
+ str += "0";
1404
+ else if (e < len)
1405
+ str = str.slice(0, e) + "." + str.slice(e);
1406
+ }
1407
+ }
1408
+ str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
1409
+ }
1410
+ return x.s < 0 ? "-" + str : str;
1411
+ }
1412
+ function truncate(arr, len) {
1413
+ if (arr.length > len) {
1414
+ arr.length = len;
1415
+ return true;
1416
+ }
1417
+ }
1418
+ function abs(x) {
1419
+ return new this(x).abs();
1420
+ }
1421
+ function acos(x) {
1422
+ return new this(x).acos();
1423
+ }
1424
+ function acosh(x) {
1425
+ return new this(x).acosh();
1426
+ }
1427
+ function add(x, y) {
1428
+ return new this(x).plus(y);
1429
+ }
1430
+ function asin(x) {
1431
+ return new this(x).asin();
1432
+ }
1433
+ function asinh(x) {
1434
+ return new this(x).asinh();
1435
+ }
1436
+ function atan(x) {
1437
+ return new this(x).atan();
1438
+ }
1439
+ function atanh(x) {
1440
+ return new this(x).atanh();
1441
+ }
1442
+ function atan2(y, x) {
1443
+ y = new this(y);
1444
+ x = new this(x);
1445
+ var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
1446
+ if (!y.s || !x.s) {
1447
+ r = new this(NaN);
1448
+ } else if (!y.d && !x.d) {
1449
+ r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
1450
+ r.s = y.s;
1451
+ } else if (!x.d || y.isZero()) {
1452
+ r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
1453
+ r.s = y.s;
1454
+ } else if (!y.d || x.isZero()) {
1455
+ r = getPi(this, wpr, 1).times(0.5);
1456
+ r.s = y.s;
1457
+ } else if (x.s < 0) {
1458
+ this.precision = wpr;
1459
+ this.rounding = 1;
1460
+ r = this.atan(divide(y, x, wpr, 1));
1461
+ x = getPi(this, wpr, 1);
1462
+ this.precision = pr;
1463
+ this.rounding = rm;
1464
+ r = y.s < 0 ? r.minus(x) : r.plus(x);
1465
+ } else {
1466
+ r = this.atan(divide(y, x, wpr, 1));
1467
+ }
1468
+ return r;
1469
+ }
1470
+ function cbrt(x) {
1471
+ return new this(x).cbrt();
1472
+ }
1473
+ function ceil(x) {
1474
+ return finalise(x = new this(x), x.e + 1, 2);
1475
+ }
1476
+ function clamp(x, min2, max2) {
1477
+ return new this(x).clamp(min2, max2);
1478
+ }
1479
+ function config(obj) {
1480
+ if (!obj || typeof obj !== "object")
1481
+ throw Error(decimalError + "Object expected");
1482
+ var i, p, v, useDefaults = obj.defaults === true, ps = [
1483
+ "precision",
1484
+ 1,
1485
+ MAX_DIGITS2,
1486
+ "rounding",
1487
+ 0,
1488
+ 8,
1489
+ "toExpNeg",
1490
+ -EXP_LIMIT,
1491
+ 0,
1492
+ "toExpPos",
1493
+ 0,
1494
+ EXP_LIMIT,
1495
+ "maxE",
1496
+ 0,
1497
+ EXP_LIMIT,
1498
+ "minE",
1499
+ -EXP_LIMIT,
1500
+ 0,
1501
+ "modulo",
1502
+ 0,
1503
+ 9
1504
+ ];
1505
+ for (i = 0;i < ps.length; i += 3) {
1506
+ if (p = ps[i], useDefaults)
1507
+ this[p] = DEFAULTS[p];
1508
+ if ((v = obj[p]) !== undefined) {
1509
+ if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
1510
+ this[p] = v;
1511
+ else
1512
+ throw Error(invalidArgument + p + ": " + v);
1513
+ }
1514
+ }
1515
+ if (p = "crypto", useDefaults)
1516
+ this[p] = DEFAULTS[p];
1517
+ if ((v = obj[p]) !== undefined) {
1518
+ if (v === true || v === false || v === 0 || v === 1) {
1519
+ if (v) {
1520
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
1521
+ this[p] = true;
1522
+ } else {
1523
+ throw Error(cryptoUnavailable);
1524
+ }
1525
+ } else {
1526
+ this[p] = false;
1527
+ }
1528
+ } else {
1529
+ throw Error(invalidArgument + p + ": " + v);
1530
+ }
1531
+ }
1532
+ return this;
1533
+ }
1534
+ function cos(x) {
1535
+ return new this(x).cos();
1536
+ }
1537
+ function cosh(x) {
1538
+ return new this(x).cosh();
1539
+ }
1540
+ function clone(obj) {
1541
+ var i, p, ps;
1542
+ function Decimal2(v) {
1543
+ var e, i2, t, x = this;
1544
+ if (!(x instanceof Decimal2))
1545
+ return new Decimal2(v);
1546
+ x.constructor = Decimal2;
1547
+ if (isDecimalInstance(v)) {
1548
+ x.s = v.s;
1549
+ if (external) {
1550
+ if (!v.d || v.e > Decimal2.maxE) {
1551
+ x.e = NaN;
1552
+ x.d = null;
1553
+ } else if (v.e < Decimal2.minE) {
1554
+ x.e = 0;
1555
+ x.d = [0];
1556
+ } else {
1557
+ x.e = v.e;
1558
+ x.d = v.d.slice();
1559
+ }
1560
+ } else {
1561
+ x.e = v.e;
1562
+ x.d = v.d ? v.d.slice() : v.d;
1563
+ }
1564
+ return;
1565
+ }
1566
+ t = typeof v;
1567
+ if (t === "number") {
1568
+ if (v === 0) {
1569
+ x.s = 1 / v < 0 ? -1 : 1;
1570
+ x.e = 0;
1571
+ x.d = [0];
1572
+ return;
1573
+ }
1574
+ if (v < 0) {
1575
+ v = -v;
1576
+ x.s = -1;
1577
+ } else {
1578
+ x.s = 1;
1579
+ }
1580
+ if (v === ~~v && v < 1e7) {
1581
+ for (e = 0, i2 = v;i2 >= 10; i2 /= 10)
1582
+ e++;
1583
+ if (external) {
1584
+ if (e > Decimal2.maxE) {
1585
+ x.e = NaN;
1586
+ x.d = null;
1587
+ } else if (e < Decimal2.minE) {
1588
+ x.e = 0;
1589
+ x.d = [0];
1590
+ } else {
1591
+ x.e = e;
1592
+ x.d = [v];
1593
+ }
1594
+ } else {
1595
+ x.e = e;
1596
+ x.d = [v];
1597
+ }
1598
+ return;
1599
+ }
1600
+ if (v * 0 !== 0) {
1601
+ if (!v)
1602
+ x.s = NaN;
1603
+ x.e = NaN;
1604
+ x.d = null;
1605
+ return;
1606
+ }
1607
+ return parseDecimal(x, v.toString());
1608
+ }
1609
+ if (t === "string") {
1610
+ if ((i2 = v.charCodeAt(0)) === 45) {
1611
+ v = v.slice(1);
1612
+ x.s = -1;
1613
+ } else {
1614
+ if (i2 === 43)
1615
+ v = v.slice(1);
1616
+ x.s = 1;
1617
+ }
1618
+ return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
1619
+ }
1620
+ if (t === "bigint") {
1621
+ if (v < 0) {
1622
+ v = -v;
1623
+ x.s = -1;
1624
+ } else {
1625
+ x.s = 1;
1626
+ }
1627
+ return parseDecimal(x, v.toString());
1628
+ }
1629
+ throw Error(invalidArgument + v);
1630
+ }
1631
+ Decimal2.prototype = P;
1632
+ Decimal2.ROUND_UP = 0;
1633
+ Decimal2.ROUND_DOWN = 1;
1634
+ Decimal2.ROUND_CEIL = 2;
1635
+ Decimal2.ROUND_FLOOR = 3;
1636
+ Decimal2.ROUND_HALF_UP = 4;
1637
+ Decimal2.ROUND_HALF_DOWN = 5;
1638
+ Decimal2.ROUND_HALF_EVEN = 6;
1639
+ Decimal2.ROUND_HALF_CEIL = 7;
1640
+ Decimal2.ROUND_HALF_FLOOR = 8;
1641
+ Decimal2.EUCLID = 9;
1642
+ Decimal2.config = Decimal2.set = config;
1643
+ Decimal2.clone = clone;
1644
+ Decimal2.isDecimal = isDecimalInstance;
1645
+ Decimal2.abs = abs;
1646
+ Decimal2.acos = acos;
1647
+ Decimal2.acosh = acosh;
1648
+ Decimal2.add = add;
1649
+ Decimal2.asin = asin;
1650
+ Decimal2.asinh = asinh;
1651
+ Decimal2.atan = atan;
1652
+ Decimal2.atanh = atanh;
1653
+ Decimal2.atan2 = atan2;
1654
+ Decimal2.cbrt = cbrt;
1655
+ Decimal2.ceil = ceil;
1656
+ Decimal2.clamp = clamp;
1657
+ Decimal2.cos = cos;
1658
+ Decimal2.cosh = cosh;
1659
+ Decimal2.div = div;
1660
+ Decimal2.exp = exp;
1661
+ Decimal2.floor = floor;
1662
+ Decimal2.hypot = hypot;
1663
+ Decimal2.ln = ln;
1664
+ Decimal2.log = log;
1665
+ Decimal2.log10 = log10;
1666
+ Decimal2.log2 = log2;
1667
+ Decimal2.max = max;
1668
+ Decimal2.min = min;
1669
+ Decimal2.mod = mod;
1670
+ Decimal2.mul = mul;
1671
+ Decimal2.pow = pow;
1672
+ Decimal2.random = random;
1673
+ Decimal2.round = round;
1674
+ Decimal2.sign = sign;
1675
+ Decimal2.sin = sin;
1676
+ Decimal2.sinh = sinh;
1677
+ Decimal2.sqrt = sqrt;
1678
+ Decimal2.sub = sub;
1679
+ Decimal2.sum = sum;
1680
+ Decimal2.tan = tan;
1681
+ Decimal2.tanh = tanh;
1682
+ Decimal2.trunc = trunc;
1683
+ if (obj === undefined)
1684
+ obj = {};
1685
+ if (obj) {
1686
+ if (obj.defaults !== true) {
1687
+ ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
1688
+ for (i = 0;i < ps.length; )
1689
+ if (!obj.hasOwnProperty(p = ps[i++]))
1690
+ obj[p] = this[p];
1691
+ }
1692
+ }
1693
+ Decimal2.config(obj);
1694
+ return Decimal2;
1695
+ }
1696
+ function div(x, y) {
1697
+ return new this(x).div(y);
1698
+ }
1699
+ function exp(x) {
1700
+ return new this(x).exp();
1701
+ }
1702
+ function floor(x) {
1703
+ return finalise(x = new this(x), x.e + 1, 3);
1704
+ }
1705
+ function hypot() {
1706
+ var i, n, t = new this(0);
1707
+ external = false;
1708
+ for (i = 0;i < arguments.length; ) {
1709
+ n = new this(arguments[i++]);
1710
+ if (!n.d) {
1711
+ if (n.s) {
1712
+ external = true;
1713
+ return new this(1 / 0);
1714
+ }
1715
+ t = n;
1716
+ } else if (t.d) {
1717
+ t = t.plus(n.times(n));
1718
+ }
1719
+ }
1720
+ external = true;
1721
+ return t.sqrt();
1722
+ }
1723
+ function isDecimalInstance(obj) {
1724
+ return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
1725
+ }
1726
+ function ln(x) {
1727
+ return new this(x).ln();
1728
+ }
1729
+ function log(x, y) {
1730
+ return new this(x).log(y);
1731
+ }
1732
+ function log2(x) {
1733
+ return new this(x).log(2);
1734
+ }
1735
+ function log10(x) {
1736
+ return new this(x).log(10);
1737
+ }
1738
+ function max() {
1739
+ return maxOrMin(this, arguments, -1);
1740
+ }
1741
+ function min() {
1742
+ return maxOrMin(this, arguments, 1);
1743
+ }
1744
+ function mod(x, y) {
1745
+ return new this(x).mod(y);
1746
+ }
1747
+ function mul(x, y) {
1748
+ return new this(x).mul(y);
1749
+ }
1750
+ function pow(x, y) {
1751
+ return new this(x).pow(y);
1752
+ }
1753
+ function random(sd) {
1754
+ var d, e, k, n, i = 0, r = new this(1), rd = [];
1755
+ if (sd === undefined)
1756
+ sd = this.precision;
1757
+ else
1758
+ checkInt32(sd, 1, MAX_DIGITS2);
1759
+ k = Math.ceil(sd / LOG_BASE);
1760
+ if (!this.crypto) {
1761
+ for (;i < k; )
1762
+ rd[i++] = Math.random() * 1e7 | 0;
1763
+ } else if (crypto.getRandomValues) {
1764
+ d = crypto.getRandomValues(new Uint32Array(k));
1765
+ for (;i < k; ) {
1766
+ n = d[i];
1767
+ if (n >= 4290000000) {
1768
+ d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
1769
+ } else {
1770
+ rd[i++] = n % 1e7;
1771
+ }
1772
+ }
1773
+ } else if (crypto.randomBytes) {
1774
+ d = crypto.randomBytes(k *= 4);
1775
+ for (;i < k; ) {
1776
+ n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
1777
+ if (n >= 2140000000) {
1778
+ crypto.randomBytes(4).copy(d, i);
1779
+ } else {
1780
+ rd.push(n % 1e7);
1781
+ i += 4;
1782
+ }
1783
+ }
1784
+ i = k / 4;
1785
+ } else {
1786
+ throw Error(cryptoUnavailable);
1787
+ }
1788
+ k = rd[--i];
1789
+ sd %= LOG_BASE;
1790
+ if (k && sd) {
1791
+ n = mathpow(10, LOG_BASE - sd);
1792
+ rd[i] = (k / n | 0) * n;
1793
+ }
1794
+ for (;rd[i] === 0; i--)
1795
+ rd.pop();
1796
+ if (i < 0) {
1797
+ e = 0;
1798
+ rd = [0];
1799
+ } else {
1800
+ e = -1;
1801
+ for (;rd[0] === 0; e -= LOG_BASE)
1802
+ rd.shift();
1803
+ for (k = 1, n = rd[0];n >= 10; n /= 10)
1804
+ k++;
1805
+ if (k < LOG_BASE)
1806
+ e -= LOG_BASE - k;
1807
+ }
1808
+ r.e = e;
1809
+ r.d = rd;
1810
+ return r;
1811
+ }
1812
+ function round(x) {
1813
+ return finalise(x = new this(x), x.e + 1, this.rounding);
1814
+ }
1815
+ function sign(x) {
1816
+ x = new this(x);
1817
+ return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
1818
+ }
1819
+ function sin(x) {
1820
+ return new this(x).sin();
1821
+ }
1822
+ function sinh(x) {
1823
+ return new this(x).sinh();
1824
+ }
1825
+ function sqrt(x) {
1826
+ return new this(x).sqrt();
1827
+ }
1828
+ function sub(x, y) {
1829
+ return new this(x).sub(y);
1830
+ }
1831
+ function sum() {
1832
+ var i = 0, args = arguments, x = new this(args[i]);
1833
+ external = false;
1834
+ for (;x.s && ++i < args.length; )
1835
+ x = x.plus(args[i]);
1836
+ external = true;
1837
+ return finalise(x, this.precision, this.rounding);
1838
+ }
1839
+ function tan(x) {
1840
+ return new this(x).tan();
1841
+ }
1842
+ function tanh(x) {
1843
+ return new this(x).tanh();
1844
+ }
1845
+ function trunc(x) {
1846
+ return finalise(x = new this(x), x.e + 1, 1);
1847
+ }
1848
+ function join(values, separator = ",", prefix = "", suffix = "") {
1849
+ if (values.length === 0) {
1850
+ throw new TypeError("Expected `join([])` to be called with an array of multiple elements, but got an empty array");
1851
+ }
1852
+ return new Sql([prefix, ...Array(values.length - 1).fill(separator), suffix], values);
1853
+ }
1854
+ function raw(value) {
1855
+ return new Sql([value], []);
1856
+ }
1857
+ function sql(strings, ...values) {
1858
+ return new Sql(strings, values);
1859
+ }
1860
+ var PrismaClientInitializationError, PrismaClientKnownRequestError, PrismaClientRustError, PrismaClientRustPanicError, PrismaClientUnknownRequestError, PrismaClientValidationError, secret, representations, ObjectEnumValue = class {
1861
+ constructor(arg) {
1862
+ if (arg === secret) {
1863
+ representations.set(this, `Prisma.${this._getName()}`);
1864
+ } else {
1865
+ representations.set(this, `new Prisma.${this._getNamespace()}.${this._getName()}()`);
1866
+ }
1867
+ }
1868
+ _getName() {
1869
+ return this.constructor.name;
1870
+ }
1871
+ toString() {
1872
+ return representations.get(this);
1873
+ }
1874
+ }, NullTypesEnumValue, DbNullClass, JsonNullClass, AnyNullClass, NullTypes, DbNull, JsonNull, AnyNull, EXP_LIMIT = 9000000000000000, MAX_DIGITS2 = 1e9, NUMERALS = "0123456789abcdef", LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", DEFAULTS, inexact, quadrant, external = true, decimalError = "[DecimalError] ", invalidArgument, precisionLimitExceeded, cryptoUnavailable, tag = "[object Decimal]", mathfloor, mathpow, isBinary, isHex, isOctal, isDecimal, BASE = 1e7, LOG_BASE = 7, MAX_SAFE_INTEGER = 9007199254740991, LN10_PRECISION, PI_PRECISION, P, divide, Decimal, Sql = class _Sql {
1875
+ constructor(rawStrings, rawValues) {
1876
+ if (rawStrings.length - 1 !== rawValues.length) {
1877
+ if (rawStrings.length === 0) {
1878
+ throw new TypeError("Expected at least 1 string");
1879
+ }
1880
+ throw new TypeError(`Expected ${rawStrings.length} strings to have ${rawStrings.length - 1} values`);
1881
+ }
1882
+ const valuesLength = rawValues.reduce((len, value) => len + (value instanceof _Sql ? value.values.length : 1), 0);
1883
+ this.values = new Array(valuesLength);
1884
+ this.strings = new Array(valuesLength + 1);
1885
+ this.strings[0] = rawStrings[0];
1886
+ let i = 0, pos = 0;
1887
+ while (i < rawValues.length) {
1888
+ const child = rawValues[i++];
1889
+ const rawString = rawStrings[i];
1890
+ if (child instanceof _Sql) {
1891
+ this.strings[pos] += child.strings[0];
1892
+ let childIndex = 0;
1893
+ while (childIndex < child.values.length) {
1894
+ this.values[pos++] = child.values[childIndex++];
1895
+ this.strings[pos] = child.strings[childIndex];
1896
+ }
1897
+ this.strings[pos] += rawString;
1898
+ } else {
1899
+ this.values[pos++] = child;
1900
+ this.strings[pos] = rawString;
1901
+ }
1902
+ }
1903
+ }
1904
+ get sql() {
1905
+ const len = this.strings.length;
1906
+ let i = 1;
1907
+ let value = this.strings[0];
1908
+ while (i < len)
1909
+ value += `?${this.strings[i++]}`;
1910
+ return value;
1911
+ }
1912
+ get statement() {
1913
+ const len = this.strings.length;
1914
+ let i = 1;
1915
+ let value = this.strings[0];
1916
+ while (i < len)
1917
+ value += `:${i}${this.strings[i++]}`;
1918
+ return value;
1919
+ }
1920
+ get text() {
1921
+ const len = this.strings.length;
1922
+ let i = 1;
1923
+ let value = this.strings[0];
1924
+ while (i < len)
1925
+ value += `$${i}${this.strings[i++]}`;
1926
+ return value;
1927
+ }
1928
+ inspect() {
1929
+ return {
1930
+ sql: this.sql,
1931
+ statement: this.statement,
1932
+ text: this.text,
1933
+ values: this.values
1934
+ };
1935
+ }
1936
+ }, empty;
1937
+ var init_dist = __esm(() => {
1938
+ PrismaClientInitializationError = class _PrismaClientInitializationError extends Error {
1939
+ clientVersion;
1940
+ errorCode;
1941
+ retryable;
1942
+ constructor(message, clientVersion, errorCode) {
1943
+ super(message);
1944
+ this.name = "PrismaClientInitializationError";
1945
+ this.clientVersion = clientVersion;
1946
+ this.errorCode = errorCode;
1947
+ Error.captureStackTrace(_PrismaClientInitializationError);
1948
+ }
1949
+ get [Symbol.toStringTag]() {
1950
+ return "PrismaClientInitializationError";
1951
+ }
1952
+ };
1953
+ setClassName(PrismaClientInitializationError, "PrismaClientInitializationError");
1954
+ PrismaClientKnownRequestError = class extends Error {
1955
+ code;
1956
+ meta;
1957
+ clientVersion;
1958
+ batchRequestIdx;
1959
+ constructor(message, { code, clientVersion, meta, batchRequestIdx }) {
1960
+ super(message);
1961
+ this.name = "PrismaClientKnownRequestError";
1962
+ this.code = code;
1963
+ this.clientVersion = clientVersion;
1964
+ this.meta = meta;
1965
+ Object.defineProperty(this, "batchRequestIdx", {
1966
+ value: batchRequestIdx,
1967
+ enumerable: false,
1968
+ writable: true
1969
+ });
1970
+ }
1971
+ get [Symbol.toStringTag]() {
1972
+ return "PrismaClientKnownRequestError";
1973
+ }
1974
+ };
1975
+ setClassName(PrismaClientKnownRequestError, "PrismaClientKnownRequestError");
1976
+ PrismaClientRustError = class extends Error {
1977
+ clientVersion;
1978
+ _isPanic;
1979
+ constructor({ clientVersion, error }) {
1980
+ const backtrace = getBacktrace(error);
1981
+ super(backtrace ?? "Unknown error");
1982
+ this._isPanic = isPanic(error);
1983
+ this.clientVersion = clientVersion;
1984
+ }
1985
+ get [Symbol.toStringTag]() {
1986
+ return "PrismaClientRustError";
1987
+ }
1988
+ isPanic() {
1989
+ return this._isPanic;
1990
+ }
1991
+ };
1992
+ setClassName(PrismaClientRustError, "PrismaClientRustError");
1993
+ PrismaClientRustPanicError = class extends Error {
1994
+ clientVersion;
1995
+ constructor(message, clientVersion) {
1996
+ super(message);
1997
+ this.name = "PrismaClientRustPanicError";
1998
+ this.clientVersion = clientVersion;
1999
+ }
2000
+ get [Symbol.toStringTag]() {
2001
+ return "PrismaClientRustPanicError";
2002
+ }
2003
+ };
2004
+ setClassName(PrismaClientRustPanicError, "PrismaClientRustPanicError");
2005
+ PrismaClientUnknownRequestError = class extends Error {
2006
+ clientVersion;
2007
+ batchRequestIdx;
2008
+ constructor(message, { clientVersion, batchRequestIdx }) {
2009
+ super(message);
2010
+ this.name = "PrismaClientUnknownRequestError";
2011
+ this.clientVersion = clientVersion;
2012
+ Object.defineProperty(this, "batchRequestIdx", {
2013
+ value: batchRequestIdx,
2014
+ writable: true,
2015
+ enumerable: false
2016
+ });
2017
+ }
2018
+ get [Symbol.toStringTag]() {
2019
+ return "PrismaClientUnknownRequestError";
2020
+ }
2021
+ };
2022
+ setClassName(PrismaClientUnknownRequestError, "PrismaClientUnknownRequestError");
2023
+ PrismaClientValidationError = class extends Error {
2024
+ name = "PrismaClientValidationError";
2025
+ clientVersion;
2026
+ constructor(message, { clientVersion }) {
2027
+ super(message);
2028
+ this.clientVersion = clientVersion;
2029
+ }
2030
+ get [Symbol.toStringTag]() {
2031
+ return "PrismaClientValidationError";
2032
+ }
2033
+ };
2034
+ setClassName(PrismaClientValidationError, "PrismaClientValidationError");
2035
+ secret = Symbol();
2036
+ representations = /* @__PURE__ */ new WeakMap;
2037
+ NullTypesEnumValue = class extends ObjectEnumValue {
2038
+ _getNamespace() {
2039
+ return "NullTypes";
2040
+ }
2041
+ };
2042
+ DbNullClass = class extends NullTypesEnumValue {
2043
+ #_brand_DbNull;
2044
+ };
2045
+ setClassName2(DbNullClass, "DbNull");
2046
+ JsonNullClass = class extends NullTypesEnumValue {
2047
+ #_brand_JsonNull;
2048
+ };
2049
+ setClassName2(JsonNullClass, "JsonNull");
2050
+ AnyNullClass = class extends NullTypesEnumValue {
2051
+ #_brand_AnyNull;
2052
+ };
2053
+ setClassName2(AnyNullClass, "AnyNull");
2054
+ NullTypes = {
2055
+ DbNull: DbNullClass,
2056
+ JsonNull: JsonNullClass,
2057
+ AnyNull: AnyNullClass
2058
+ };
2059
+ DbNull = new DbNullClass(secret);
2060
+ JsonNull = new JsonNullClass(secret);
2061
+ AnyNull = new AnyNullClass(secret);
2062
+ DEFAULTS = {
2063
+ precision: 20,
2064
+ rounding: 4,
2065
+ modulo: 1,
2066
+ toExpNeg: -7,
2067
+ toExpPos: 21,
2068
+ minE: -EXP_LIMIT,
2069
+ maxE: EXP_LIMIT,
2070
+ crypto: false
2071
+ };
2072
+ invalidArgument = decimalError + "Invalid argument: ";
2073
+ precisionLimitExceeded = decimalError + "Precision limit exceeded";
2074
+ cryptoUnavailable = decimalError + "crypto unavailable";
2075
+ mathfloor = Math.floor;
2076
+ mathpow = Math.pow;
2077
+ isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
2078
+ isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
2079
+ isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
2080
+ isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
2081
+ LN10_PRECISION = LN10.length - 1;
2082
+ PI_PRECISION = PI.length - 1;
2083
+ P = { toStringTag: tag };
2084
+ P.absoluteValue = P.abs = function() {
2085
+ var x = new this.constructor(this);
2086
+ if (x.s < 0)
2087
+ x.s = 1;
2088
+ return finalise(x);
2089
+ };
2090
+ P.ceil = function() {
2091
+ return finalise(new this.constructor(this), this.e + 1, 2);
2092
+ };
2093
+ P.clampedTo = P.clamp = function(min2, max2) {
2094
+ var k, x = this, Ctor = x.constructor;
2095
+ min2 = new Ctor(min2);
2096
+ max2 = new Ctor(max2);
2097
+ if (!min2.s || !max2.s)
2098
+ return new Ctor(NaN);
2099
+ if (min2.gt(max2))
2100
+ throw Error(invalidArgument + max2);
2101
+ k = x.cmp(min2);
2102
+ return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
2103
+ };
2104
+ P.comparedTo = P.cmp = function(y) {
2105
+ var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
2106
+ if (!xd || !yd) {
2107
+ return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
2108
+ }
2109
+ if (!xd[0] || !yd[0])
2110
+ return xd[0] ? xs : yd[0] ? -ys : 0;
2111
+ if (xs !== ys)
2112
+ return xs;
2113
+ if (x.e !== y.e)
2114
+ return x.e > y.e ^ xs < 0 ? 1 : -1;
2115
+ xdL = xd.length;
2116
+ ydL = yd.length;
2117
+ for (i = 0, j = xdL < ydL ? xdL : ydL;i < j; ++i) {
2118
+ if (xd[i] !== yd[i])
2119
+ return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
2120
+ }
2121
+ return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
2122
+ };
2123
+ P.cosine = P.cos = function() {
2124
+ var pr, rm, x = this, Ctor = x.constructor;
2125
+ if (!x.d)
2126
+ return new Ctor(NaN);
2127
+ if (!x.d[0])
2128
+ return new Ctor(1);
2129
+ pr = Ctor.precision;
2130
+ rm = Ctor.rounding;
2131
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
2132
+ Ctor.rounding = 1;
2133
+ x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
2134
+ Ctor.precision = pr;
2135
+ Ctor.rounding = rm;
2136
+ return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
2137
+ };
2138
+ P.cubeRoot = P.cbrt = function() {
2139
+ var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
2140
+ if (!x.isFinite() || x.isZero())
2141
+ return new Ctor(x);
2142
+ external = false;
2143
+ s = x.s * mathpow(x.s * x, 1 / 3);
2144
+ if (!s || Math.abs(s) == 1 / 0) {
2145
+ n = digitsToString(x.d);
2146
+ e = x.e;
2147
+ if (s = (e - n.length + 1) % 3)
2148
+ n += s == 1 || s == -2 ? "0" : "00";
2149
+ s = mathpow(n, 1 / 3);
2150
+ e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
2151
+ if (s == 1 / 0) {
2152
+ n = "5e" + e;
2153
+ } else {
2154
+ n = s.toExponential();
2155
+ n = n.slice(0, n.indexOf("e") + 1) + e;
2156
+ }
2157
+ r = new Ctor(n);
2158
+ r.s = x.s;
2159
+ } else {
2160
+ r = new Ctor(s.toString());
2161
+ }
2162
+ sd = (e = Ctor.precision) + 3;
2163
+ for (;; ) {
2164
+ t = r;
2165
+ t3 = t.times(t).times(t);
2166
+ t3plusx = t3.plus(x);
2167
+ r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
2168
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
2169
+ n = n.slice(sd - 3, sd + 1);
2170
+ if (n == "9999" || !rep && n == "4999") {
2171
+ if (!rep) {
2172
+ finalise(t, e + 1, 0);
2173
+ if (t.times(t).times(t).eq(x)) {
2174
+ r = t;
2175
+ break;
2176
+ }
2177
+ }
2178
+ sd += 4;
2179
+ rep = 1;
2180
+ } else {
2181
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
2182
+ finalise(r, e + 1, 1);
2183
+ m = !r.times(r).times(r).eq(x);
2184
+ }
2185
+ break;
2186
+ }
2187
+ }
2188
+ }
2189
+ external = true;
2190
+ return finalise(r, e, Ctor.rounding, m);
2191
+ };
2192
+ P.decimalPlaces = P.dp = function() {
2193
+ var w, d = this.d, n = NaN;
2194
+ if (d) {
2195
+ w = d.length - 1;
2196
+ n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
2197
+ w = d[w];
2198
+ if (w)
2199
+ for (;w % 10 == 0; w /= 10)
2200
+ n--;
2201
+ if (n < 0)
2202
+ n = 0;
2203
+ }
2204
+ return n;
2205
+ };
2206
+ P.dividedBy = P.div = function(y) {
2207
+ return divide(this, new this.constructor(y));
2208
+ };
2209
+ P.dividedToIntegerBy = P.divToInt = function(y) {
2210
+ var x = this, Ctor = x.constructor;
2211
+ return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
2212
+ };
2213
+ P.equals = P.eq = function(y) {
2214
+ return this.cmp(y) === 0;
2215
+ };
2216
+ P.floor = function() {
2217
+ return finalise(new this.constructor(this), this.e + 1, 3);
2218
+ };
2219
+ P.greaterThan = P.gt = function(y) {
2220
+ return this.cmp(y) > 0;
2221
+ };
2222
+ P.greaterThanOrEqualTo = P.gte = function(y) {
2223
+ var k = this.cmp(y);
2224
+ return k == 1 || k === 0;
2225
+ };
2226
+ P.hyperbolicCosine = P.cosh = function() {
2227
+ var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
2228
+ if (!x.isFinite())
2229
+ return new Ctor(x.s ? 1 / 0 : NaN);
2230
+ if (x.isZero())
2231
+ return one;
2232
+ pr = Ctor.precision;
2233
+ rm = Ctor.rounding;
2234
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
2235
+ Ctor.rounding = 1;
2236
+ len = x.d.length;
2237
+ if (len < 32) {
2238
+ k = Math.ceil(len / 3);
2239
+ n = (1 / tinyPow(4, k)).toString();
2240
+ } else {
2241
+ k = 16;
2242
+ n = "2.3283064365386962890625e-10";
2243
+ }
2244
+ x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
2245
+ var cosh2_x, i = k, d8 = new Ctor(8);
2246
+ for (;i--; ) {
2247
+ cosh2_x = x.times(x);
2248
+ x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
2249
+ }
2250
+ return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
2251
+ };
2252
+ P.hyperbolicSine = P.sinh = function() {
2253
+ var k, pr, rm, len, x = this, Ctor = x.constructor;
2254
+ if (!x.isFinite() || x.isZero())
2255
+ return new Ctor(x);
2256
+ pr = Ctor.precision;
2257
+ rm = Ctor.rounding;
2258
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
2259
+ Ctor.rounding = 1;
2260
+ len = x.d.length;
2261
+ if (len < 3) {
2262
+ x = taylorSeries(Ctor, 2, x, x, true);
2263
+ } else {
2264
+ k = 1.4 * Math.sqrt(len);
2265
+ k = k > 16 ? 16 : k | 0;
2266
+ x = x.times(1 / tinyPow(5, k));
2267
+ x = taylorSeries(Ctor, 2, x, x, true);
2268
+ var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
2269
+ for (;k--; ) {
2270
+ sinh2_x = x.times(x);
2271
+ x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
2272
+ }
2273
+ }
2274
+ Ctor.precision = pr;
2275
+ Ctor.rounding = rm;
2276
+ return finalise(x, pr, rm, true);
2277
+ };
2278
+ P.hyperbolicTangent = P.tanh = function() {
2279
+ var pr, rm, x = this, Ctor = x.constructor;
2280
+ if (!x.isFinite())
2281
+ return new Ctor(x.s);
2282
+ if (x.isZero())
2283
+ return new Ctor(x);
2284
+ pr = Ctor.precision;
2285
+ rm = Ctor.rounding;
2286
+ Ctor.precision = pr + 7;
2287
+ Ctor.rounding = 1;
2288
+ return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
2289
+ };
2290
+ P.inverseCosine = P.acos = function() {
2291
+ var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
2292
+ if (k !== -1) {
2293
+ return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
2294
+ }
2295
+ if (x.isZero())
2296
+ return getPi(Ctor, pr + 4, rm).times(0.5);
2297
+ Ctor.precision = pr + 6;
2298
+ Ctor.rounding = 1;
2299
+ x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
2300
+ Ctor.precision = pr;
2301
+ Ctor.rounding = rm;
2302
+ return x.times(2);
2303
+ };
2304
+ P.inverseHyperbolicCosine = P.acosh = function() {
2305
+ var pr, rm, x = this, Ctor = x.constructor;
2306
+ if (x.lte(1))
2307
+ return new Ctor(x.eq(1) ? 0 : NaN);
2308
+ if (!x.isFinite())
2309
+ return new Ctor(x);
2310
+ pr = Ctor.precision;
2311
+ rm = Ctor.rounding;
2312
+ Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
2313
+ Ctor.rounding = 1;
2314
+ external = false;
2315
+ x = x.times(x).minus(1).sqrt().plus(x);
2316
+ external = true;
2317
+ Ctor.precision = pr;
2318
+ Ctor.rounding = rm;
2319
+ return x.ln();
2320
+ };
2321
+ P.inverseHyperbolicSine = P.asinh = function() {
2322
+ var pr, rm, x = this, Ctor = x.constructor;
2323
+ if (!x.isFinite() || x.isZero())
2324
+ return new Ctor(x);
2325
+ pr = Ctor.precision;
2326
+ rm = Ctor.rounding;
2327
+ Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
2328
+ Ctor.rounding = 1;
2329
+ external = false;
2330
+ x = x.times(x).plus(1).sqrt().plus(x);
2331
+ external = true;
2332
+ Ctor.precision = pr;
2333
+ Ctor.rounding = rm;
2334
+ return x.ln();
2335
+ };
2336
+ P.inverseHyperbolicTangent = P.atanh = function() {
2337
+ var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
2338
+ if (!x.isFinite())
2339
+ return new Ctor(NaN);
2340
+ if (x.e >= 0)
2341
+ return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
2342
+ pr = Ctor.precision;
2343
+ rm = Ctor.rounding;
2344
+ xsd = x.sd();
2345
+ if (Math.max(xsd, pr) < 2 * -x.e - 1)
2346
+ return finalise(new Ctor(x), pr, rm, true);
2347
+ Ctor.precision = wpr = xsd - x.e;
2348
+ x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
2349
+ Ctor.precision = pr + 4;
2350
+ Ctor.rounding = 1;
2351
+ x = x.ln();
2352
+ Ctor.precision = pr;
2353
+ Ctor.rounding = rm;
2354
+ return x.times(0.5);
2355
+ };
2356
+ P.inverseSine = P.asin = function() {
2357
+ var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
2358
+ if (x.isZero())
2359
+ return new Ctor(x);
2360
+ k = x.abs().cmp(1);
2361
+ pr = Ctor.precision;
2362
+ rm = Ctor.rounding;
2363
+ if (k !== -1) {
2364
+ if (k === 0) {
2365
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
2366
+ halfPi.s = x.s;
2367
+ return halfPi;
2368
+ }
2369
+ return new Ctor(NaN);
2370
+ }
2371
+ Ctor.precision = pr + 6;
2372
+ Ctor.rounding = 1;
2373
+ x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
2374
+ Ctor.precision = pr;
2375
+ Ctor.rounding = rm;
2376
+ return x.times(2);
2377
+ };
2378
+ P.inverseTangent = P.atan = function() {
2379
+ var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
2380
+ if (!x.isFinite()) {
2381
+ if (!x.s)
2382
+ return new Ctor(NaN);
2383
+ if (pr + 4 <= PI_PRECISION) {
2384
+ r = getPi(Ctor, pr + 4, rm).times(0.5);
2385
+ r.s = x.s;
2386
+ return r;
2387
+ }
2388
+ } else if (x.isZero()) {
2389
+ return new Ctor(x);
2390
+ } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
2391
+ r = getPi(Ctor, pr + 4, rm).times(0.25);
2392
+ r.s = x.s;
2393
+ return r;
2394
+ }
2395
+ Ctor.precision = wpr = pr + 10;
2396
+ Ctor.rounding = 1;
2397
+ k = Math.min(28, wpr / LOG_BASE + 2 | 0);
2398
+ for (i = k;i; --i)
2399
+ x = x.div(x.times(x).plus(1).sqrt().plus(1));
2400
+ external = false;
2401
+ j = Math.ceil(wpr / LOG_BASE);
2402
+ n = 1;
2403
+ x2 = x.times(x);
2404
+ r = new Ctor(x);
2405
+ px = x;
2406
+ for (;i !== -1; ) {
2407
+ px = px.times(x2);
2408
+ t = r.minus(px.div(n += 2));
2409
+ px = px.times(x2);
2410
+ r = t.plus(px.div(n += 2));
2411
+ if (r.d[j] !== undefined)
2412
+ for (i = j;r.d[i] === t.d[i] && i--; )
2413
+ ;
2414
+ }
2415
+ if (k)
2416
+ r = r.times(2 << k - 1);
2417
+ external = true;
2418
+ return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
2419
+ };
2420
+ P.isFinite = function() {
2421
+ return !!this.d;
2422
+ };
2423
+ P.isInteger = P.isInt = function() {
2424
+ return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
2425
+ };
2426
+ P.isNaN = function() {
2427
+ return !this.s;
2428
+ };
2429
+ P.isNegative = P.isNeg = function() {
2430
+ return this.s < 0;
2431
+ };
2432
+ P.isPositive = P.isPos = function() {
2433
+ return this.s > 0;
2434
+ };
2435
+ P.isZero = function() {
2436
+ return !!this.d && this.d[0] === 0;
2437
+ };
2438
+ P.lessThan = P.lt = function(y) {
2439
+ return this.cmp(y) < 0;
2440
+ };
2441
+ P.lessThanOrEqualTo = P.lte = function(y) {
2442
+ return this.cmp(y) < 1;
2443
+ };
2444
+ P.logarithm = P.log = function(base) {
2445
+ var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
2446
+ if (base == null) {
2447
+ base = new Ctor(10);
2448
+ isBase10 = true;
2449
+ } else {
2450
+ base = new Ctor(base);
2451
+ d = base.d;
2452
+ if (base.s < 0 || !d || !d[0] || base.eq(1))
2453
+ return new Ctor(NaN);
2454
+ isBase10 = base.eq(10);
2455
+ }
2456
+ d = arg.d;
2457
+ if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
2458
+ return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
2459
+ }
2460
+ if (isBase10) {
2461
+ if (d.length > 1) {
2462
+ inf = true;
2463
+ } else {
2464
+ for (k = d[0];k % 10 === 0; )
2465
+ k /= 10;
2466
+ inf = k !== 1;
2467
+ }
2468
+ }
2469
+ external = false;
2470
+ sd = pr + guard;
2471
+ num = naturalLogarithm(arg, sd);
2472
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
2473
+ r = divide(num, denominator, sd, 1);
2474
+ if (checkRoundingDigits(r.d, k = pr, rm)) {
2475
+ do {
2476
+ sd += 10;
2477
+ num = naturalLogarithm(arg, sd);
2478
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
2479
+ r = divide(num, denominator, sd, 1);
2480
+ if (!inf) {
2481
+ if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 100000000000000) {
2482
+ r = finalise(r, pr + 1, 0);
2483
+ }
2484
+ break;
2485
+ }
2486
+ } while (checkRoundingDigits(r.d, k += 10, rm));
2487
+ }
2488
+ external = true;
2489
+ return finalise(r, pr, rm);
2490
+ };
2491
+ P.minus = P.sub = function(y) {
2492
+ var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
2493
+ y = new Ctor(y);
2494
+ if (!x.d || !y.d) {
2495
+ if (!x.s || !y.s)
2496
+ y = new Ctor(NaN);
2497
+ else if (x.d)
2498
+ y.s = -y.s;
2499
+ else
2500
+ y = new Ctor(y.d || x.s !== y.s ? x : NaN);
2501
+ return y;
2502
+ }
2503
+ if (x.s != y.s) {
2504
+ y.s = -y.s;
2505
+ return x.plus(y);
2506
+ }
2507
+ xd = x.d;
2508
+ yd = y.d;
2509
+ pr = Ctor.precision;
2510
+ rm = Ctor.rounding;
2511
+ if (!xd[0] || !yd[0]) {
2512
+ if (yd[0])
2513
+ y.s = -y.s;
2514
+ else if (xd[0])
2515
+ y = new Ctor(x);
2516
+ else
2517
+ return new Ctor(rm === 3 ? -0 : 0);
2518
+ return external ? finalise(y, pr, rm) : y;
2519
+ }
2520
+ e = mathfloor(y.e / LOG_BASE);
2521
+ xe = mathfloor(x.e / LOG_BASE);
2522
+ xd = xd.slice();
2523
+ k = xe - e;
2524
+ if (k) {
2525
+ xLTy = k < 0;
2526
+ if (xLTy) {
2527
+ d = xd;
2528
+ k = -k;
2529
+ len = yd.length;
2530
+ } else {
2531
+ d = yd;
2532
+ e = xe;
2533
+ len = xd.length;
2534
+ }
2535
+ i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
2536
+ if (k > i) {
2537
+ k = i;
2538
+ d.length = 1;
2539
+ }
2540
+ d.reverse();
2541
+ for (i = k;i--; )
2542
+ d.push(0);
2543
+ d.reverse();
2544
+ } else {
2545
+ i = xd.length;
2546
+ len = yd.length;
2547
+ xLTy = i < len;
2548
+ if (xLTy)
2549
+ len = i;
2550
+ for (i = 0;i < len; i++) {
2551
+ if (xd[i] != yd[i]) {
2552
+ xLTy = xd[i] < yd[i];
2553
+ break;
2554
+ }
2555
+ }
2556
+ k = 0;
2557
+ }
2558
+ if (xLTy) {
2559
+ d = xd;
2560
+ xd = yd;
2561
+ yd = d;
2562
+ y.s = -y.s;
2563
+ }
2564
+ len = xd.length;
2565
+ for (i = yd.length - len;i > 0; --i)
2566
+ xd[len++] = 0;
2567
+ for (i = yd.length;i > k; ) {
2568
+ if (xd[--i] < yd[i]) {
2569
+ for (j = i;j && xd[--j] === 0; )
2570
+ xd[j] = BASE - 1;
2571
+ --xd[j];
2572
+ xd[i] += BASE;
2573
+ }
2574
+ xd[i] -= yd[i];
2575
+ }
2576
+ for (;xd[--len] === 0; )
2577
+ xd.pop();
2578
+ for (;xd[0] === 0; xd.shift())
2579
+ --e;
2580
+ if (!xd[0])
2581
+ return new Ctor(rm === 3 ? -0 : 0);
2582
+ y.d = xd;
2583
+ y.e = getBase10Exponent(xd, e);
2584
+ return external ? finalise(y, pr, rm) : y;
2585
+ };
2586
+ P.modulo = P.mod = function(y) {
2587
+ var q, x = this, Ctor = x.constructor;
2588
+ y = new Ctor(y);
2589
+ if (!x.d || !y.s || y.d && !y.d[0])
2590
+ return new Ctor(NaN);
2591
+ if (!y.d || x.d && !x.d[0]) {
2592
+ return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
2593
+ }
2594
+ external = false;
2595
+ if (Ctor.modulo == 9) {
2596
+ q = divide(x, y.abs(), 0, 3, 1);
2597
+ q.s *= y.s;
2598
+ } else {
2599
+ q = divide(x, y, 0, Ctor.modulo, 1);
2600
+ }
2601
+ q = q.times(y);
2602
+ external = true;
2603
+ return x.minus(q);
2604
+ };
2605
+ P.naturalExponential = P.exp = function() {
2606
+ return naturalExponential(this);
2607
+ };
2608
+ P.naturalLogarithm = P.ln = function() {
2609
+ return naturalLogarithm(this);
2610
+ };
2611
+ P.negated = P.neg = function() {
2612
+ var x = new this.constructor(this);
2613
+ x.s = -x.s;
2614
+ return finalise(x);
2615
+ };
2616
+ P.plus = P.add = function(y) {
2617
+ var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
2618
+ y = new Ctor(y);
2619
+ if (!x.d || !y.d) {
2620
+ if (!x.s || !y.s)
2621
+ y = new Ctor(NaN);
2622
+ else if (!x.d)
2623
+ y = new Ctor(y.d || x.s === y.s ? x : NaN);
2624
+ return y;
2625
+ }
2626
+ if (x.s != y.s) {
2627
+ y.s = -y.s;
2628
+ return x.minus(y);
2629
+ }
2630
+ xd = x.d;
2631
+ yd = y.d;
2632
+ pr = Ctor.precision;
2633
+ rm = Ctor.rounding;
2634
+ if (!xd[0] || !yd[0]) {
2635
+ if (!yd[0])
2636
+ y = new Ctor(x);
2637
+ return external ? finalise(y, pr, rm) : y;
2638
+ }
2639
+ k = mathfloor(x.e / LOG_BASE);
2640
+ e = mathfloor(y.e / LOG_BASE);
2641
+ xd = xd.slice();
2642
+ i = k - e;
2643
+ if (i) {
2644
+ if (i < 0) {
2645
+ d = xd;
2646
+ i = -i;
2647
+ len = yd.length;
2648
+ } else {
2649
+ d = yd;
2650
+ e = k;
2651
+ len = xd.length;
2652
+ }
2653
+ k = Math.ceil(pr / LOG_BASE);
2654
+ len = k > len ? k + 1 : len + 1;
2655
+ if (i > len) {
2656
+ i = len;
2657
+ d.length = 1;
2658
+ }
2659
+ d.reverse();
2660
+ for (;i--; )
2661
+ d.push(0);
2662
+ d.reverse();
2663
+ }
2664
+ len = xd.length;
2665
+ i = yd.length;
2666
+ if (len - i < 0) {
2667
+ i = len;
2668
+ d = yd;
2669
+ yd = xd;
2670
+ xd = d;
2671
+ }
2672
+ for (carry = 0;i; ) {
2673
+ carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
2674
+ xd[i] %= BASE;
2675
+ }
2676
+ if (carry) {
2677
+ xd.unshift(carry);
2678
+ ++e;
2679
+ }
2680
+ for (len = xd.length;xd[--len] == 0; )
2681
+ xd.pop();
2682
+ y.d = xd;
2683
+ y.e = getBase10Exponent(xd, e);
2684
+ return external ? finalise(y, pr, rm) : y;
2685
+ };
2686
+ P.precision = P.sd = function(z) {
2687
+ var k, x = this;
2688
+ if (z !== undefined && z !== !!z && z !== 1 && z !== 0)
2689
+ throw Error(invalidArgument + z);
2690
+ if (x.d) {
2691
+ k = getPrecision(x.d);
2692
+ if (z && x.e + 1 > k)
2693
+ k = x.e + 1;
2694
+ } else {
2695
+ k = NaN;
2696
+ }
2697
+ return k;
2698
+ };
2699
+ P.round = function() {
2700
+ var x = this, Ctor = x.constructor;
2701
+ return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
2702
+ };
2703
+ P.sine = P.sin = function() {
2704
+ var pr, rm, x = this, Ctor = x.constructor;
2705
+ if (!x.isFinite())
2706
+ return new Ctor(NaN);
2707
+ if (x.isZero())
2708
+ return new Ctor(x);
2709
+ pr = Ctor.precision;
2710
+ rm = Ctor.rounding;
2711
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
2712
+ Ctor.rounding = 1;
2713
+ x = sine(Ctor, toLessThanHalfPi(Ctor, x));
2714
+ Ctor.precision = pr;
2715
+ Ctor.rounding = rm;
2716
+ return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
2717
+ };
2718
+ P.squareRoot = P.sqrt = function() {
2719
+ var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
2720
+ if (s !== 1 || !d || !d[0]) {
2721
+ return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
2722
+ }
2723
+ external = false;
2724
+ s = Math.sqrt(+x);
2725
+ if (s == 0 || s == 1 / 0) {
2726
+ n = digitsToString(d);
2727
+ if ((n.length + e) % 2 == 0)
2728
+ n += "0";
2729
+ s = Math.sqrt(n);
2730
+ e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
2731
+ if (s == 1 / 0) {
2732
+ n = "5e" + e;
2733
+ } else {
2734
+ n = s.toExponential();
2735
+ n = n.slice(0, n.indexOf("e") + 1) + e;
2736
+ }
2737
+ r = new Ctor(n);
2738
+ } else {
2739
+ r = new Ctor(s.toString());
2740
+ }
2741
+ sd = (e = Ctor.precision) + 3;
2742
+ for (;; ) {
2743
+ t = r;
2744
+ r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
2745
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
2746
+ n = n.slice(sd - 3, sd + 1);
2747
+ if (n == "9999" || !rep && n == "4999") {
2748
+ if (!rep) {
2749
+ finalise(t, e + 1, 0);
2750
+ if (t.times(t).eq(x)) {
2751
+ r = t;
2752
+ break;
2753
+ }
2754
+ }
2755
+ sd += 4;
2756
+ rep = 1;
2757
+ } else {
2758
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
2759
+ finalise(r, e + 1, 1);
2760
+ m = !r.times(r).eq(x);
2761
+ }
2762
+ break;
2763
+ }
2764
+ }
2765
+ }
2766
+ external = true;
2767
+ return finalise(r, e, Ctor.rounding, m);
2768
+ };
2769
+ P.tangent = P.tan = function() {
2770
+ var pr, rm, x = this, Ctor = x.constructor;
2771
+ if (!x.isFinite())
2772
+ return new Ctor(NaN);
2773
+ if (x.isZero())
2774
+ return new Ctor(x);
2775
+ pr = Ctor.precision;
2776
+ rm = Ctor.rounding;
2777
+ Ctor.precision = pr + 10;
2778
+ Ctor.rounding = 1;
2779
+ x = x.sin();
2780
+ x.s = 1;
2781
+ x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
2782
+ Ctor.precision = pr;
2783
+ Ctor.rounding = rm;
2784
+ return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
2785
+ };
2786
+ P.times = P.mul = function(y) {
2787
+ var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
2788
+ y.s *= x.s;
2789
+ if (!xd || !xd[0] || !yd || !yd[0]) {
2790
+ return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
2791
+ }
2792
+ e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
2793
+ xdL = xd.length;
2794
+ ydL = yd.length;
2795
+ if (xdL < ydL) {
2796
+ r = xd;
2797
+ xd = yd;
2798
+ yd = r;
2799
+ rL = xdL;
2800
+ xdL = ydL;
2801
+ ydL = rL;
2802
+ }
2803
+ r = [];
2804
+ rL = xdL + ydL;
2805
+ for (i = rL;i--; )
2806
+ r.push(0);
2807
+ for (i = ydL;--i >= 0; ) {
2808
+ carry = 0;
2809
+ for (k = xdL + i;k > i; ) {
2810
+ t = r[k] + yd[i] * xd[k - i - 1] + carry;
2811
+ r[k--] = t % BASE | 0;
2812
+ carry = t / BASE | 0;
2813
+ }
2814
+ r[k] = (r[k] + carry) % BASE | 0;
2815
+ }
2816
+ for (;!r[--rL]; )
2817
+ r.pop();
2818
+ if (carry)
2819
+ ++e;
2820
+ else
2821
+ r.shift();
2822
+ y.d = r;
2823
+ y.e = getBase10Exponent(r, e);
2824
+ return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
2825
+ };
2826
+ P.toBinary = function(sd, rm) {
2827
+ return toStringBinary(this, 2, sd, rm);
2828
+ };
2829
+ P.toDecimalPlaces = P.toDP = function(dp, rm) {
2830
+ var x = this, Ctor = x.constructor;
2831
+ x = new Ctor(x);
2832
+ if (dp === undefined)
2833
+ return x;
2834
+ checkInt32(dp, 0, MAX_DIGITS2);
2835
+ if (rm === undefined)
2836
+ rm = Ctor.rounding;
2837
+ else
2838
+ checkInt32(rm, 0, 8);
2839
+ return finalise(x, dp + x.e + 1, rm);
2840
+ };
2841
+ P.toExponential = function(dp, rm) {
2842
+ var str, x = this, Ctor = x.constructor;
2843
+ if (dp === undefined) {
2844
+ str = finiteToString(x, true);
2845
+ } else {
2846
+ checkInt32(dp, 0, MAX_DIGITS2);
2847
+ if (rm === undefined)
2848
+ rm = Ctor.rounding;
2849
+ else
2850
+ checkInt32(rm, 0, 8);
2851
+ x = finalise(new Ctor(x), dp + 1, rm);
2852
+ str = finiteToString(x, true, dp + 1);
2853
+ }
2854
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
2855
+ };
2856
+ P.toFixed = function(dp, rm) {
2857
+ var str, y, x = this, Ctor = x.constructor;
2858
+ if (dp === undefined) {
2859
+ str = finiteToString(x);
2860
+ } else {
2861
+ checkInt32(dp, 0, MAX_DIGITS2);
2862
+ if (rm === undefined)
2863
+ rm = Ctor.rounding;
2864
+ else
2865
+ checkInt32(rm, 0, 8);
2866
+ y = finalise(new Ctor(x), dp + x.e + 1, rm);
2867
+ str = finiteToString(y, false, dp + y.e + 1);
2868
+ }
2869
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
2870
+ };
2871
+ P.toFraction = function(maxD) {
2872
+ var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
2873
+ if (!xd)
2874
+ return new Ctor(x);
2875
+ n1 = d0 = new Ctor(1);
2876
+ d1 = n0 = new Ctor(0);
2877
+ d = new Ctor(d1);
2878
+ e = d.e = getPrecision(xd) - x.e - 1;
2879
+ k = e % LOG_BASE;
2880
+ d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
2881
+ if (maxD == null) {
2882
+ maxD = e > 0 ? d : n1;
2883
+ } else {
2884
+ n = new Ctor(maxD);
2885
+ if (!n.isInt() || n.lt(n1))
2886
+ throw Error(invalidArgument + n);
2887
+ maxD = n.gt(d) ? e > 0 ? d : n1 : n;
2888
+ }
2889
+ external = false;
2890
+ n = new Ctor(digitsToString(xd));
2891
+ pr = Ctor.precision;
2892
+ Ctor.precision = e = xd.length * LOG_BASE * 2;
2893
+ for (;; ) {
2894
+ q = divide(n, d, 0, 1, 1);
2895
+ d2 = d0.plus(q.times(d1));
2896
+ if (d2.cmp(maxD) == 1)
2897
+ break;
2898
+ d0 = d1;
2899
+ d1 = d2;
2900
+ d2 = n1;
2901
+ n1 = n0.plus(q.times(d2));
2902
+ n0 = d2;
2903
+ d2 = d;
2904
+ d = n.minus(q.times(d2));
2905
+ n = d2;
2906
+ }
2907
+ d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
2908
+ n0 = n0.plus(d2.times(n1));
2909
+ d0 = d0.plus(d2.times(d1));
2910
+ n0.s = n1.s = x.s;
2911
+ r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
2912
+ Ctor.precision = pr;
2913
+ external = true;
2914
+ return r;
2915
+ };
2916
+ P.toHexadecimal = P.toHex = function(sd, rm) {
2917
+ return toStringBinary(this, 16, sd, rm);
2918
+ };
2919
+ P.toNearest = function(y, rm) {
2920
+ var x = this, Ctor = x.constructor;
2921
+ x = new Ctor(x);
2922
+ if (y == null) {
2923
+ if (!x.d)
2924
+ return x;
2925
+ y = new Ctor(1);
2926
+ rm = Ctor.rounding;
2927
+ } else {
2928
+ y = new Ctor(y);
2929
+ if (rm === undefined) {
2930
+ rm = Ctor.rounding;
2931
+ } else {
2932
+ checkInt32(rm, 0, 8);
2933
+ }
2934
+ if (!x.d)
2935
+ return y.s ? x : y;
2936
+ if (!y.d) {
2937
+ if (y.s)
2938
+ y.s = x.s;
2939
+ return y;
2940
+ }
2941
+ }
2942
+ if (y.d[0]) {
2943
+ external = false;
2944
+ x = divide(x, y, 0, rm, 1).times(y);
2945
+ external = true;
2946
+ finalise(x);
2947
+ } else {
2948
+ y.s = x.s;
2949
+ x = y;
2950
+ }
2951
+ return x;
2952
+ };
2953
+ P.toNumber = function() {
2954
+ return +this;
2955
+ };
2956
+ P.toOctal = function(sd, rm) {
2957
+ return toStringBinary(this, 8, sd, rm);
2958
+ };
2959
+ P.toPower = P.pow = function(y) {
2960
+ var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
2961
+ if (!x.d || !y.d || !x.d[0] || !y.d[0])
2962
+ return new Ctor(mathpow(+x, yn));
2963
+ x = new Ctor(x);
2964
+ if (x.eq(1))
2965
+ return x;
2966
+ pr = Ctor.precision;
2967
+ rm = Ctor.rounding;
2968
+ if (y.eq(1))
2969
+ return finalise(x, pr, rm);
2970
+ e = mathfloor(y.e / LOG_BASE);
2971
+ if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
2972
+ r = intPow(Ctor, x, k, pr);
2973
+ return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
2974
+ }
2975
+ s = x.s;
2976
+ if (s < 0) {
2977
+ if (e < y.d.length - 1)
2978
+ return new Ctor(NaN);
2979
+ if ((y.d[e] & 1) == 0)
2980
+ s = 1;
2981
+ if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
2982
+ x.s = s;
2983
+ return x;
2984
+ }
2985
+ }
2986
+ k = mathpow(+x, yn);
2987
+ e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
2988
+ if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
2989
+ return new Ctor(e > 0 ? s / 0 : 0);
2990
+ external = false;
2991
+ Ctor.rounding = x.s = 1;
2992
+ k = Math.min(12, (e + "").length);
2993
+ r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
2994
+ if (r.d) {
2995
+ r = finalise(r, pr + 5, 1);
2996
+ if (checkRoundingDigits(r.d, pr, rm)) {
2997
+ e = pr + 10;
2998
+ r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
2999
+ if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 100000000000000) {
3000
+ r = finalise(r, pr + 1, 0);
3001
+ }
3002
+ }
3003
+ }
3004
+ r.s = s;
3005
+ external = true;
3006
+ Ctor.rounding = rm;
3007
+ return finalise(r, pr, rm);
3008
+ };
3009
+ P.toPrecision = function(sd, rm) {
3010
+ var str, x = this, Ctor = x.constructor;
3011
+ if (sd === undefined) {
3012
+ str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
3013
+ } else {
3014
+ checkInt32(sd, 1, MAX_DIGITS2);
3015
+ if (rm === undefined)
3016
+ rm = Ctor.rounding;
3017
+ else
3018
+ checkInt32(rm, 0, 8);
3019
+ x = finalise(new Ctor(x), sd, rm);
3020
+ str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
3021
+ }
3022
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
3023
+ };
3024
+ P.toSignificantDigits = P.toSD = function(sd, rm) {
3025
+ var x = this, Ctor = x.constructor;
3026
+ if (sd === undefined) {
3027
+ sd = Ctor.precision;
3028
+ rm = Ctor.rounding;
3029
+ } else {
3030
+ checkInt32(sd, 1, MAX_DIGITS2);
3031
+ if (rm === undefined)
3032
+ rm = Ctor.rounding;
3033
+ else
3034
+ checkInt32(rm, 0, 8);
3035
+ }
3036
+ return finalise(new Ctor(x), sd, rm);
3037
+ };
3038
+ P.toString = function() {
3039
+ var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
3040
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
3041
+ };
3042
+ P.truncated = P.trunc = function() {
3043
+ return finalise(new this.constructor(this), this.e + 1, 1);
3044
+ };
3045
+ P.valueOf = P.toJSON = function() {
3046
+ var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
3047
+ return x.isNeg() ? "-" + str : str;
3048
+ };
3049
+ divide = /* @__PURE__ */ function() {
3050
+ function multiplyInteger(x, k, base) {
3051
+ var temp, carry = 0, i = x.length;
3052
+ for (x = x.slice();i--; ) {
3053
+ temp = x[i] * k + carry;
3054
+ x[i] = temp % base | 0;
3055
+ carry = temp / base | 0;
3056
+ }
3057
+ if (carry)
3058
+ x.unshift(carry);
3059
+ return x;
3060
+ }
3061
+ function compare(a, b, aL, bL) {
3062
+ var i, r;
3063
+ if (aL != bL) {
3064
+ r = aL > bL ? 1 : -1;
3065
+ } else {
3066
+ for (i = r = 0;i < aL; i++) {
3067
+ if (a[i] != b[i]) {
3068
+ r = a[i] > b[i] ? 1 : -1;
3069
+ break;
3070
+ }
3071
+ }
3072
+ }
3073
+ return r;
3074
+ }
3075
+ function subtract(a, b, aL, base) {
3076
+ var i = 0;
3077
+ for (;aL--; ) {
3078
+ a[aL] -= i;
3079
+ i = a[aL] < b[aL] ? 1 : 0;
3080
+ a[aL] = i * base + a[aL] - b[aL];
3081
+ }
3082
+ for (;!a[0] && a.length > 1; )
3083
+ a.shift();
3084
+ }
3085
+ return function(x, y, pr, rm, dp, base) {
3086
+ var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
3087
+ if (!xd || !xd[0] || !yd || !yd[0]) {
3088
+ return new Ctor(!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0);
3089
+ }
3090
+ if (base) {
3091
+ logBase = 1;
3092
+ e = x.e - y.e;
3093
+ } else {
3094
+ base = BASE;
3095
+ logBase = LOG_BASE;
3096
+ e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
3097
+ }
3098
+ yL = yd.length;
3099
+ xL = xd.length;
3100
+ q = new Ctor(sign2);
3101
+ qd = q.d = [];
3102
+ for (i = 0;yd[i] == (xd[i] || 0); i++)
3103
+ ;
3104
+ if (yd[i] > (xd[i] || 0))
3105
+ e--;
3106
+ if (pr == null) {
3107
+ sd = pr = Ctor.precision;
3108
+ rm = Ctor.rounding;
3109
+ } else if (dp) {
3110
+ sd = pr + (x.e - y.e) + 1;
3111
+ } else {
3112
+ sd = pr;
3113
+ }
3114
+ if (sd < 0) {
3115
+ qd.push(1);
3116
+ more = true;
3117
+ } else {
3118
+ sd = sd / logBase + 2 | 0;
3119
+ i = 0;
3120
+ if (yL == 1) {
3121
+ k = 0;
3122
+ yd = yd[0];
3123
+ sd++;
3124
+ for (;(i < xL || k) && sd--; i++) {
3125
+ t = k * base + (xd[i] || 0);
3126
+ qd[i] = t / yd | 0;
3127
+ k = t % yd | 0;
3128
+ }
3129
+ more = k || i < xL;
3130
+ } else {
3131
+ k = base / (yd[0] + 1) | 0;
3132
+ if (k > 1) {
3133
+ yd = multiplyInteger(yd, k, base);
3134
+ xd = multiplyInteger(xd, k, base);
3135
+ yL = yd.length;
3136
+ xL = xd.length;
3137
+ }
3138
+ xi = yL;
3139
+ rem = xd.slice(0, yL);
3140
+ remL = rem.length;
3141
+ for (;remL < yL; )
3142
+ rem[remL++] = 0;
3143
+ yz = yd.slice();
3144
+ yz.unshift(0);
3145
+ yd0 = yd[0];
3146
+ if (yd[1] >= base / 2)
3147
+ ++yd0;
3148
+ do {
3149
+ k = 0;
3150
+ cmp = compare(yd, rem, yL, remL);
3151
+ if (cmp < 0) {
3152
+ rem0 = rem[0];
3153
+ if (yL != remL)
3154
+ rem0 = rem0 * base + (rem[1] || 0);
3155
+ k = rem0 / yd0 | 0;
3156
+ if (k > 1) {
3157
+ if (k >= base)
3158
+ k = base - 1;
3159
+ prod = multiplyInteger(yd, k, base);
3160
+ prodL = prod.length;
3161
+ remL = rem.length;
3162
+ cmp = compare(prod, rem, prodL, remL);
3163
+ if (cmp == 1) {
3164
+ k--;
3165
+ subtract(prod, yL < prodL ? yz : yd, prodL, base);
3166
+ }
3167
+ } else {
3168
+ if (k == 0)
3169
+ cmp = k = 1;
3170
+ prod = yd.slice();
3171
+ }
3172
+ prodL = prod.length;
3173
+ if (prodL < remL)
3174
+ prod.unshift(0);
3175
+ subtract(rem, prod, remL, base);
3176
+ if (cmp == -1) {
3177
+ remL = rem.length;
3178
+ cmp = compare(yd, rem, yL, remL);
3179
+ if (cmp < 1) {
3180
+ k++;
3181
+ subtract(rem, yL < remL ? yz : yd, remL, base);
3182
+ }
3183
+ }
3184
+ remL = rem.length;
3185
+ } else if (cmp === 0) {
3186
+ k++;
3187
+ rem = [0];
3188
+ }
3189
+ qd[i++] = k;
3190
+ if (cmp && rem[0]) {
3191
+ rem[remL++] = xd[xi] || 0;
3192
+ } else {
3193
+ rem = [xd[xi]];
3194
+ remL = 1;
3195
+ }
3196
+ } while ((xi++ < xL || rem[0] !== undefined) && sd--);
3197
+ more = rem[0] !== undefined;
3198
+ }
3199
+ if (!qd[0])
3200
+ qd.shift();
3201
+ }
3202
+ if (logBase == 1) {
3203
+ q.e = e;
3204
+ inexact = more;
3205
+ } else {
3206
+ for (i = 1, k = qd[0];k >= 10; k /= 10)
3207
+ i++;
3208
+ q.e = i + e * logBase - 1;
3209
+ finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
3210
+ }
3211
+ return q;
3212
+ };
3213
+ }();
3214
+ P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
3215
+ P[Symbol.toStringTag] = "Decimal";
3216
+ Decimal = P.constructor = clone(DEFAULTS);
3217
+ LN10 = new Decimal(LN10);
3218
+ PI = new Decimal(PI);
3219
+ empty = raw("");
3220
+ /*! Bundled license information:
3221
+
3222
+ decimal.js/decimal.mjs:
3223
+ (*!
3224
+ * decimal.js v10.5.0
3225
+ * An arbitrary-precision Decimal type for JavaScript.
3226
+ * https://github.com/MikeMcl/decimal.js
3227
+ * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
3228
+ * MIT Licence
3229
+ *)
3230
+ */
3231
+ });
3232
+
3233
+ // node_modules/@prisma/dmmf-v6/dist/convert.mjs
3234
+ function datamodelEnumToSchemaEnum(datamodelEnum) {
3235
+ return {
3236
+ name: datamodelEnum.name,
3237
+ values: datamodelEnum.values.map((v) => v.name)
3238
+ };
3239
+ }
3240
+ var init_convert = () => {};
3241
+
3242
+ // node_modules/@prisma/dmmf-v6/dist/dmmf.mjs
3243
+ var ModelAction;
3244
+ var init_dmmf = __esm(() => {
3245
+ ModelAction = /* @__PURE__ */ ((ModelAction2) => {
3246
+ ModelAction2["findUnique"] = "findUnique";
3247
+ ModelAction2["findUniqueOrThrow"] = "findUniqueOrThrow";
3248
+ ModelAction2["findFirst"] = "findFirst";
3249
+ ModelAction2["findFirstOrThrow"] = "findFirstOrThrow";
3250
+ ModelAction2["findMany"] = "findMany";
3251
+ ModelAction2["create"] = "create";
3252
+ ModelAction2["createMany"] = "createMany";
3253
+ ModelAction2["createManyAndReturn"] = "createManyAndReturn";
3254
+ ModelAction2["update"] = "update";
3255
+ ModelAction2["updateMany"] = "updateMany";
3256
+ ModelAction2["updateManyAndReturn"] = "updateManyAndReturn";
3257
+ ModelAction2["upsert"] = "upsert";
3258
+ ModelAction2["delete"] = "delete";
3259
+ ModelAction2["deleteMany"] = "deleteMany";
3260
+ ModelAction2["groupBy"] = "groupBy";
3261
+ ModelAction2["count"] = "count";
3262
+ ModelAction2["aggregate"] = "aggregate";
3263
+ ModelAction2["findRaw"] = "findRaw";
3264
+ ModelAction2["aggregateRaw"] = "aggregateRaw";
3265
+ return ModelAction2;
3266
+ })(ModelAction || {});
3267
+ });
3268
+
3269
+ // node_modules/@prisma/dmmf-v6/dist/index.mjs
3270
+ var exports_dist2 = {};
3271
+ __export(exports_dist2, {
3272
+ datamodelEnumToSchemaEnum: () => datamodelEnumToSchemaEnum,
3273
+ ModelAction: () => ModelAction
3274
+ });
3275
+ var init_dist2 = __esm(() => {
3276
+ init_convert();
3277
+ init_dmmf();
3278
+ });
3279
+
630
3280
  // src/lib/client.ts
631
3281
  import * as path2 from "path";
632
3282
  import * as fs from "fs";
@@ -1247,9 +3897,6 @@ function mergeAggregateArg(aggregation, aggregate2, value) {
1247
3897
  [aggregation]: Object.fromEntries(Object.keys(valueToProcess).map((k) => [k, true]))
1248
3898
  };
1249
3899
  }
1250
- // src/lib/operations/create.ts
1251
- import { Decimal } from "@prisma/client/runtime/library";
1252
-
1253
3900
  // node_modules/bson/lib/bson.node.mjs
1254
3901
  import { randomBytes } from "crypto";
1255
3902
  var TypedArrayPrototypeGetSymbolToStringTag = (() => {
@@ -1507,10 +4154,10 @@ function webMathRandomBytes(byteLength) {
1507
4154
  return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
1508
4155
  }
1509
4156
  var webRandomBytes = (() => {
1510
- const { crypto } = globalThis;
1511
- if (crypto != null && typeof crypto.getRandomValues === "function") {
4157
+ const { crypto: crypto2 } = globalThis;
4158
+ if (crypto2 != null && typeof crypto2.getRandomValues === "function") {
1512
4159
  return (byteLength) => {
1513
- return crypto.getRandomValues(webByteUtils.allocate(byteLength));
4160
+ return crypto2.getRandomValues(webByteUtils.allocate(byteLength));
1514
4161
  };
1515
4162
  } else {
1516
4163
  if (isReactNative()) {
@@ -4376,6 +7023,7 @@ var { createId, init, getConstants, isCuid } = require_src();
4376
7023
  var $createId = createId;
4377
7024
 
4378
7025
  // src/lib/operations/create.ts
7026
+ init_dist();
4379
7027
  var isAutoIncrement = (field) => {
4380
7028
  return field.default?.name === "autoincrement";
4381
7029
  };
@@ -4762,15 +7410,29 @@ function updateMany(args, current, delegates, onChange) {
4762
7410
  // node_modules/@prisma/client/package.json
4763
7411
  var version = "6.12.0";
4764
7412
 
7413
+ // src/lib/globals.ts
7414
+ async function getGlobals() {
7415
+ const { PrismaClientKnownRequestError: PrismaClientKnownRequestError2, Decimal: Decimal2 } = await Promise.resolve().then(() => (init_dist(), exports_dist));
7416
+ const DMMF = await (async () => {
7417
+ if (false) {}
7418
+ return await Promise.resolve().then(() => (init_dist2(), exports_dist2));
7419
+ })();
7420
+ return {
7421
+ PrismaClientKnownRequestError: PrismaClientKnownRequestError2,
7422
+ Decimal: Decimal2,
7423
+ DMMF
7424
+ };
7425
+ }
7426
+
4765
7427
  // src/lib/delegate.ts
4766
- import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
4767
- function generateDelegate(model, data, name, properties, delegates, onChange) {
7428
+ async function generateDelegate(model, data, name, properties, delegates, onChange) {
7429
+ const { PrismaClientKnownRequestError: PrismaClientKnownRequestError2 } = await getGlobals();
4768
7430
  const delegate = {};
4769
7431
  Object.assign(delegate, {
4770
7432
  delete: (args = {}) => {
4771
7433
  const deleted = deleteMany(args, delegate, delegates, onChange);
4772
7434
  if (deleted.length === 0)
4773
- return Promise.reject(new PrismaClientKnownRequestError(`No record was found for a delete on ${delegate.model.name}`, {
7435
+ return Promise.reject(new PrismaClientKnownRequestError2(`No record was found for a delete on ${delegate.model.name}`, {
4774
7436
  code: "P2025",
4775
7437
  clientVersion: version,
4776
7438
  meta: {
@@ -4787,7 +7449,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
4787
7449
  update: (args) => {
4788
7450
  const updated = updateMany(args, delegate, delegates, onChange);
4789
7451
  const [update3] = updated;
4790
- return update3 ? Promise.resolve(update3) : Promise.reject(new PrismaClientKnownRequestError(`No record was found for an update on ${delegate.model.name}`, {
7452
+ return update3 ? Promise.resolve(update3) : Promise.reject(new PrismaClientKnownRequestError2(`No record was found for an update on ${delegate.model.name}`, {
4791
7453
  code: "P2025",
4792
7454
  clientVersion: version,
4793
7455
  meta: {
@@ -4833,7 +7495,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
4833
7495
  findUniqueOrThrow: (args = {}) => {
4834
7496
  const found = findOne(args, delegate, delegates);
4835
7497
  if (!found)
4836
- return Promise.reject(new PrismaClientKnownRequestError(`No record was found for a query on ${delegate.model.name}`, {
7498
+ return Promise.reject(new PrismaClientKnownRequestError2(`No record was found for a query on ${delegate.model.name}`, {
4837
7499
  code: "P2025",
4838
7500
  clientVersion: version
4839
7501
  }));
@@ -4842,7 +7504,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
4842
7504
  findFirstOrThrow: (args = {}) => {
4843
7505
  const found = findOne(args, delegate, delegates);
4844
7506
  if (!found)
4845
- return Promise.reject(new PrismaClientKnownRequestError(`No record was found for a query on ${delegate.model.name}`, {
7507
+ return Promise.reject(new PrismaClientKnownRequestError2(`No record was found for a query on ${delegate.model.name}`, {
4846
7508
  code: "P2025",
4847
7509
  clientVersion: version
4848
7510
  }));
@@ -4894,7 +7556,7 @@ async function generateDMMF(schemaPath) {
4894
7556
  }
4895
7557
 
4896
7558
  // src/lib/prismock.ts
4897
- function generateDelegates(options) {
7559
+ async function generateDelegates(options) {
4898
7560
  const models = options.models ?? [];
4899
7561
  const data = {};
4900
7562
  const properties = {};
@@ -4920,18 +7582,19 @@ function generateDelegates(options) {
4920
7582
  };
4921
7583
  }, {}));
4922
7584
  }
4923
- models.forEach((model) => {
7585
+ await Promise.all(models.map(async (model) => {
4924
7586
  const name = camelize(model.name);
4925
7587
  data[name] = [];
4926
7588
  properties[name] = {
4927
7589
  increment: {}
4928
7590
  };
7591
+ const delegate = await generateDelegate(model, data, name, properties, delegates, (items) => {
7592
+ Object.assign(data, { [name]: items });
7593
+ });
4929
7594
  Object.assign(delegates, {
4930
- [name]: generateDelegate(model, data, name, properties, delegates, (items) => {
4931
- Object.assign(data, { [name]: items });
4932
- })
7595
+ [name]: delegate
4933
7596
  });
4934
- }, {});
7597
+ }, {}));
4935
7598
  const clientDelegates = Object.entries(delegates).reduce((accumulator, [delegateKey, delegateValue]) => {
4936
7599
  return {
4937
7600
  ...accumulator,
@@ -5079,25 +7742,23 @@ function applyQueryExtensions(client, extensions) {
5079
7742
  }
5080
7743
 
5081
7744
  // src/lib/extensions/result.ts
5082
- import { Prisma } from "@prisma/client";
5083
- import { DMMF } from "@prisma/client/runtime/library";
5084
- function buildResultExtendedModel(client, proxiedModels, modelExtensions, modelName) {
7745
+ function buildResultExtendedModel(client, proxiedModels, modelExtensions, modelName, PrismaDMMF) {
5085
7746
  const model = proxiedModels[modelName] ?? client[modelName];
5086
7747
  if (Object.keys(modelExtensions).length === 0) {
5087
7748
  return model;
5088
7749
  }
5089
7750
  const singleResultActions = [
5090
- DMMF.ModelAction.findFirst,
5091
- DMMF.ModelAction.findFirstOrThrow,
5092
- DMMF.ModelAction.findUnique,
5093
- DMMF.ModelAction.findUniqueOrThrow,
5094
- DMMF.ModelAction.create,
5095
- DMMF.ModelAction.update,
5096
- DMMF.ModelAction.upsert
7751
+ PrismaDMMF.ModelAction.findFirst,
7752
+ PrismaDMMF.ModelAction.findFirstOrThrow,
7753
+ PrismaDMMF.ModelAction.findUnique,
7754
+ PrismaDMMF.ModelAction.findUniqueOrThrow,
7755
+ PrismaDMMF.ModelAction.create,
7756
+ PrismaDMMF.ModelAction.update,
7757
+ PrismaDMMF.ModelAction.upsert
5097
7758
  ];
5098
7759
  const multipleResultActions = [
5099
- DMMF.ModelAction.findMany,
5100
- DMMF.ModelAction.createManyAndReturn
7760
+ PrismaDMMF.ModelAction.findMany,
7761
+ PrismaDMMF.ModelAction.createManyAndReturn
5101
7762
  ];
5102
7763
  const allResultActions = [...singleResultActions, ...multipleResultActions];
5103
7764
  const proxyMethod = (actionName) => {
@@ -5172,7 +7833,7 @@ function buildResultExtendedModel(client, proxiedModels, modelExtensions, modelN
5172
7833
  });
5173
7834
  return proxiedModel;
5174
7835
  }
5175
- function applyResultExtensions(client, extensions) {
7836
+ function applyResultExtensions(client, extensions, datamodel, PrismaDMMF) {
5176
7837
  if (typeof extensions === "function") {
5177
7838
  const extendedClient = extensions(client);
5178
7839
  return extendedClient;
@@ -5186,7 +7847,7 @@ function applyResultExtensions(client, extensions) {
5186
7847
  if (!originalModel) {
5187
7848
  return;
5188
7849
  }
5189
- const proxiedModel = buildResultExtendedModel(client, proxiedModels, resultExtendedModelMap[modelName], modelName);
7850
+ const proxiedModel = buildResultExtendedModel(client, proxiedModels, resultExtendedModelMap[modelName], modelName, PrismaDMMF);
5190
7851
  proxiedModels[modelName] = proxiedModel;
5191
7852
  return proxiedModel;
5192
7853
  }
@@ -5200,12 +7861,12 @@ function applyResultExtensions(client, extensions) {
5200
7861
  proxyModel(modelName);
5201
7862
  }
5202
7863
  if (hasAllModelsExtension && resultExtendedModelMap["$allModels"]) {
5203
- for (const model of Prisma.dmmf.datamodel.models) {
7864
+ for (const model of datamodel.datamodel.models) {
5204
7865
  const modelName = model.name;
5205
7866
  if (!(modelName in client)) {
5206
7867
  continue;
5207
7868
  }
5208
- const proxiedModel = buildResultExtendedModel(client, proxiedModels, resultExtendedModelMap["$allModels"], modelName);
7869
+ const proxiedModel = buildResultExtendedModel(client, proxiedModels, resultExtendedModelMap["$allModels"], modelName, PrismaDMMF);
5209
7870
  proxiedModels[modelName] = proxiedModel;
5210
7871
  }
5211
7872
  }
@@ -5220,8 +7881,8 @@ function applyResultExtensions(client, extensions) {
5220
7881
  }
5221
7882
 
5222
7883
  // src/lib/extensions/index.ts
5223
- function applyExtensions(client, extensions) {
5224
- const resultExtended = applyResultExtensions(client, extensions);
7884
+ function applyExtensions(client, extensions, datamodel, PrismaDMMF) {
7885
+ const resultExtended = applyResultExtensions(client, extensions, datamodel, PrismaDMMF);
5225
7886
  const queryExtended = applyQueryExtensions(resultExtended, extensions);
5226
7887
  const modelExtended = applyModelExtensions(queryExtended, extensions);
5227
7888
  return modelExtended;
@@ -5230,19 +7891,29 @@ function applyExtensions(client, extensions) {
5230
7891
  // src/lib/client.ts
5231
7892
  class Prismock {
5232
7893
  schemaPath;
7894
+ datamodel;
7895
+ PrismaDMMF;
5233
7896
  genPromise;
5234
7897
  constructor(schemaPath) {
5235
7898
  this.schemaPath = schemaPath;
5236
- this.genPromise = this.generate();
7899
+ this.genPromise = this.generate().then(({ datamodel, PrismaDMMF }) => {
7900
+ this.datamodel = datamodel;
7901
+ this.PrismaDMMF = PrismaDMMF;
7902
+ return { datamodel, PrismaDMMF };
7903
+ });
5237
7904
  }
5238
7905
  static async create(schemaPath) {
5239
7906
  const p = new Prismock(schemaPath);
5240
- await p.genPromise;
7907
+ const { datamodel, PrismaDMMF } = await p.genPromise;
7908
+ p.datamodel = datamodel;
7909
+ p.PrismaDMMF = PrismaDMMF;
5241
7910
  return p;
5242
7911
  }
5243
7912
  static async createDefault(schemaPath) {
5244
7913
  const p = new Prismock(schemaPath);
5245
- await p.genPromise;
7914
+ const { datamodel, PrismaDMMF } = await p.genPromise;
7915
+ p.datamodel = datamodel;
7916
+ p.PrismaDMMF = PrismaDMMF;
5246
7917
  return p;
5247
7918
  }
5248
7919
  async reset() {
@@ -5250,7 +7921,7 @@ class Prismock {
5250
7921
  }
5251
7922
  async generate() {
5252
7923
  const datamodel = await generateDMMF(this.schemaPath);
5253
- const { delegates, setData, getData } = generateDelegates({
7924
+ const { delegates, setData, getData } = await generateDelegates({
5254
7925
  models: [
5255
7926
  ...datamodel.datamodel.models
5256
7927
  ]
@@ -5261,6 +7932,8 @@ class Prismock {
5261
7932
  else
5262
7933
  Object.assign(this, { [key]: value });
5263
7934
  });
7935
+ const { DMMF: PrismaDMMF } = await getGlobals();
7936
+ return { datamodel, PrismaDMMF };
5264
7937
  }
5265
7938
  async $connect() {
5266
7939
  await this.genPromise;
@@ -5286,7 +7959,13 @@ class Prismock {
5286
7959
  return Promise.resolve([]);
5287
7960
  }
5288
7961
  $extends(extensionDefs) {
5289
- return applyExtensions(this, extensionDefs);
7962
+ if (!this.datamodel) {
7963
+ throw new Error("Datamodel not loaded");
7964
+ }
7965
+ if (!this.PrismaDMMF) {
7966
+ throw new Error("PrismaDMMF not loaded");
7967
+ }
7968
+ return applyExtensions(this, extensionDefs, this.datamodel, this.PrismaDMMF);
5290
7969
  }
5291
7970
  async $transaction(args) {
5292
7971
  if (Array.isArray(args)) {