sixseconds-modules 1.6.141 → 1.6.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,20 +1,9 @@
1
- (function() {
2
- "use strict";
3
- try {
4
- if (typeof document != "undefined") {
5
- var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode('@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap");\r\n\r\nblockquote,\r\ndl,\r\ndd,\r\nh1,\r\nh2,\r\nh3,\r\nh4,\r\nh5,\r\nh6,\r\nhr,\r\nfigure,\r\np,\r\npre {\r\n font-family: "Inter", serif !important;\r\n}\r\n\r\n/* .MuiDialog-root {\r\n z-index: 999999999 !important;\r\n}\r\n\r\n.MuiModal-root {\r\n z-index: 999999999 !important;\r\n} */\r\n\r\n.main_list_Menu {\r\n display: flex;\r\n}\r\n\r\n.main_list_Menu li {\r\n padding: 0.5rem 0.5rem;\r\n}\r\n\r\n.main_list_Menu li a {\r\n padding: 0 0.25rem;\r\n font-weight: 600;\r\n font-size: 14px;\r\n}\r\n\r\n.main_list_Menu .menu-item {\r\n position: relative;\r\n padding: 15px;\r\n}\r\n\r\n.main_list_Menu .menu-link {\r\n text-decoration: none;\r\n color: #2c2e35;\r\n transition: color 0.3s ease;\r\n}\r\n\r\n.main_list_Menu .menu-link:hover {\r\n color: #2ea3f2;\r\n}\r\n\r\n/* Submenu (Dropdown) */\r\n\r\n.main_list_Menu .submenuData {\r\n position: absolute;\r\n top: 85%;\r\n left: 0;\r\n background: white;\r\n border-top: 3px solid #2ea3f2;\r\n box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);\r\n display: none;\r\n min-width: 200px;\r\n z-index: 10;\r\n}\r\n\r\n.main_list_Menu .submenuData li {\r\n list-style: none;\r\n}\r\n\r\n.main_list_Menu .submenu-link {\r\n display: block;\r\n padding: 1px 15px;\r\n text-decoration: none;\r\n color: rgba(0, 0, 0, 0.7);\r\n font-weight: 600;\r\n}\r\n\r\n.main_list_Menu .submenu-link:hover {\r\n background: #f1f1f1;\r\n}\r\n\r\n/* Show dropdown on hover */\r\n\r\n.main_list_Menu .menu-item:hover .submenuData {\r\n display: block;\r\n}\r\n\r\n.smallDeviceMenu {\r\n display: none;\r\n width: 100%;\r\n left: 0;\r\n top: 72px;\r\n background-color: #fff;\r\n position: fixed;\r\n overflow-y: auto;\r\n height: 95vh;\r\n}\r\n\r\n.smallDeviceMenu a.bg_main_menu {\r\n display: block;\r\n text-decoration: none;\r\n}\r\n\r\n.submenu_child li {\r\n padding: 0.5rem 0;\r\n}\r\n\r\n.submenu_child li a {\r\n text-decoration: none;\r\n}\r\n\r\n.layout_mobile_menu {\r\n padding-bottom: 12px;\r\n padding-inline: 0;\r\n height: 95vh;\r\n overflow-y: auto;\r\n padding-top: 8px;\r\n}\r\n\r\n.smallDeviceMenu a {\r\n background-color: rgba(0, 0, 0, 0.03);\r\n font-size: 15px;\r\n font-weight: 600;\r\n color: #2c2e35;\r\n margin-bottom: 4px;\r\n padding: 12px 8px;\r\n}\r\n\r\n.smallDeviceMenu .submenu_child {\r\n padding-left: 0px;\r\n min-width: 90%;\r\n max-width: 90%;\r\n top: 57px;\r\n margin-top: 8px;\r\n background-color: #fff;\r\n color: #000;\r\n margin-inline: auto;\r\n}\r\n\r\n.smallDeviceMenu ul li .submenu_child_link {\r\n padding: 12px 20px;\r\n}\r\n\r\n.smallDeviceMenu ul li a {\r\n background-color: transparent;\r\n color: #000000b3;\r\n}\r\n\r\n.smallDeviceMenu ul {\r\n padding-left: 15px;\r\n}\r\n\r\n.desktopMenu {\r\n display: flex;\r\n}\r\n\r\n.button_hamburger {\r\n display: none;\r\n position: absolute;\r\n right: 20px;\r\n top: 25px;\r\n z-index: 9;\r\n}\r\n\r\n.tox-editor-header {\r\n background-color: transparent;\r\n}\r\n\r\n.hamburger-icon-btn {\r\n padding: 8px;\r\n color: rgba(0, 0, 0, 0.54);\r\n}\r\n\r\n.desktopMenu .menu-item .menu-link {\r\n font-size: 15px;\r\n}\r\n\r\n.smallDeviceMenu {\r\n padding-inline: 20px;\r\n}\r\n\r\n@media screen and (max-width: 600px) and (min-width: 320px) {\r\n .notification_icon_error .MuiBadge-badge {\r\n font-size: 11px;\r\n padding: 0 3px;\r\n min-width: 16px;\r\n right: 5px;\r\n }\r\n\r\n .submenu nav {\r\n padding: 0 !important;\r\n }\r\n\r\n .MuiPagination-root.MuiPagination-outlined {\r\n /* margin-top: 10px; */\r\n display: flex;\r\n justify-content: center;\r\n margin-left: 0;\r\n }\r\n\r\n .toogle_btn_menu {\r\n position: absolute;\r\n right: 20px;\r\n top: 18px;\r\n z-index: 99;\r\n }\r\n\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .desktopMenu {\r\n display: none;\r\n }\r\n\r\n .smallDeviceMenu {\r\n display: block;\r\n width: 100%;\r\n position: fixed;\r\n left: 0;\r\n background: #fff;\r\n top: 69px;\r\n }\r\n\r\n .main.login_page .loginBody {\r\n width: 400px !important;\r\n }\r\n\r\n .submenu {\r\n width: 100%;\r\n max-width: 100% !important;\r\n }\r\n\r\n .sideBar {\r\n width: 300px !important;\r\n background-color: #fff;\r\n z-index: 99;\r\n }\r\n\r\n .sideMenu {\r\n width: 300px;\r\n background-color: #fff;\r\n }\r\n\r\n .logo_header {\r\n opacity: 1;\r\n }\r\n\r\n .profile .headerMenu {\r\n min-width: 320px;\r\n width: 500px !important;\r\n }\r\n}\r\n\r\n@media screen and (max-width: 1024px) and (min-width: 600px) {\r\n .toogle_btn_menu {\r\n position: absolute;\r\n right: 20px;\r\n top: 18px;\r\n }\r\n\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .desktopMenu {\r\n display: none;\r\n }\r\n\r\n .smallDeviceMenu {\r\n display: block;\r\n }\r\n\r\n .main.login_page .loginBody {\r\n width: 500px !important;\r\n }\r\n\r\n .banner {\r\n margin-left: 0 !important;\r\n }\r\n\r\n .submenu {\r\n width: 100%;\r\n max-width: 100% !important;\r\n }\r\n\r\n .sideBar {\r\n width: 300px !important;\r\n background-color: #fff;\r\n z-index: 99;\r\n }\r\n\r\n .sideMenu {\r\n width: 300px;\r\n background-color: #fff;\r\n }\r\n\r\n .logo_header {\r\n opacity: 1;\r\n }\r\n\r\n .profile .headerMenu {\r\n min-width: 320px;\r\n width: 500px !important;\r\n }\r\n}\r\n\r\n@media screen and (max-width: 1380px) and (min-width: 1024px) {\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .desktopMenu {\r\n display: none;\r\n }\r\n\r\n .smallDeviceMenu {\r\n display: block;\r\n width: 100%;\r\n position: fixed;\r\n left: 0;\r\n background: #fff;\r\n top: 72px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n}'));
7
- document.head.appendChild(elementStyle);
8
- }
9
- } catch (e) {
10
- console.error("vite-plugin-css-injected-by-js", e);
11
- }
12
- })();
13
1
  "use strict";
14
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
15
3
  const jsxRuntime = require("react/jsx-runtime");
16
4
  const material = require("@mui/material");
17
5
  const React = require("react");
6
+ const constants = require("./index.cjs2.js");
18
7
  const axios = require("axios");
19
8
  const Cookies = require("js-cookie");
20
9
  const MenuIcon = require("@mui/icons-material/Menu");
@@ -1360,7 +1349,7 @@ function requireReactIs_production_min() {
1360
1349
  if (hasRequiredReactIs_production_min) return reactIs_production_min;
1361
1350
  hasRequiredReactIs_production_min = 1;
1362
1351
  var b = "function" === typeof Symbol && Symbol.for, c = b ? Symbol.for("react.element") : 60103, d = b ? Symbol.for("react.portal") : 60106, e = b ? Symbol.for("react.fragment") : 60107, f = b ? Symbol.for("react.strict_mode") : 60108, g = b ? Symbol.for("react.profiler") : 60114, h = b ? Symbol.for("react.provider") : 60109, k = b ? Symbol.for("react.context") : 60110, l = b ? Symbol.for("react.async_mode") : 60111, m = b ? Symbol.for("react.concurrent_mode") : 60111, n = b ? Symbol.for("react.forward_ref") : 60112, p = b ? Symbol.for("react.suspense") : 60113, q = b ? Symbol.for("react.suspense_list") : 60120, r = b ? Symbol.for("react.memo") : 60115, t = b ? Symbol.for("react.lazy") : 60116, v = b ? Symbol.for("react.block") : 60121, w = b ? Symbol.for("react.fundamental") : 60117, x = b ? Symbol.for("react.responder") : 60118, y = b ? Symbol.for("react.scope") : 60119;
1363
- function z2(a) {
1352
+ function z(a) {
1364
1353
  if ("object" === typeof a && null !== a) {
1365
1354
  var u = a.$$typeof;
1366
1355
  switch (u) {
@@ -1391,7 +1380,7 @@ function requireReactIs_production_min() {
1391
1380
  }
1392
1381
  }
1393
1382
  function A(a) {
1394
- return z2(a) === m;
1383
+ return z(a) === m;
1395
1384
  }
1396
1385
  reactIs_production_min.AsyncMode = l;
1397
1386
  reactIs_production_min.ConcurrentMode = m;
@@ -1407,46 +1396,46 @@ function requireReactIs_production_min() {
1407
1396
  reactIs_production_min.StrictMode = f;
1408
1397
  reactIs_production_min.Suspense = p;
1409
1398
  reactIs_production_min.isAsyncMode = function(a) {
1410
- return A(a) || z2(a) === l;
1399
+ return A(a) || z(a) === l;
1411
1400
  };
1412
1401
  reactIs_production_min.isConcurrentMode = A;
1413
1402
  reactIs_production_min.isContextConsumer = function(a) {
1414
- return z2(a) === k;
1403
+ return z(a) === k;
1415
1404
  };
1416
1405
  reactIs_production_min.isContextProvider = function(a) {
1417
- return z2(a) === h;
1406
+ return z(a) === h;
1418
1407
  };
1419
1408
  reactIs_production_min.isElement = function(a) {
1420
1409
  return "object" === typeof a && null !== a && a.$$typeof === c;
1421
1410
  };
1422
1411
  reactIs_production_min.isForwardRef = function(a) {
1423
- return z2(a) === n;
1412
+ return z(a) === n;
1424
1413
  };
1425
1414
  reactIs_production_min.isFragment = function(a) {
1426
- return z2(a) === e;
1415
+ return z(a) === e;
1427
1416
  };
1428
1417
  reactIs_production_min.isLazy = function(a) {
1429
- return z2(a) === t;
1418
+ return z(a) === t;
1430
1419
  };
1431
1420
  reactIs_production_min.isMemo = function(a) {
1432
- return z2(a) === r;
1421
+ return z(a) === r;
1433
1422
  };
1434
1423
  reactIs_production_min.isPortal = function(a) {
1435
- return z2(a) === d;
1424
+ return z(a) === d;
1436
1425
  };
1437
1426
  reactIs_production_min.isProfiler = function(a) {
1438
- return z2(a) === g;
1427
+ return z(a) === g;
1439
1428
  };
1440
1429
  reactIs_production_min.isStrictMode = function(a) {
1441
- return z2(a) === f;
1430
+ return z(a) === f;
1442
1431
  };
1443
1432
  reactIs_production_min.isSuspense = function(a) {
1444
- return z2(a) === p;
1433
+ return z(a) === p;
1445
1434
  };
1446
1435
  reactIs_production_min.isValidElementType = function(a) {
1447
1436
  return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === typeof a && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
1448
1437
  };
1449
- reactIs_production_min.typeOf = z2;
1438
+ reactIs_production_min.typeOf = z;
1450
1439
  return reactIs_production_min;
1451
1440
  }
1452
1441
  var reactIs_development = {};
@@ -2665,4186 +2654,6 @@ const ErrorMessage = ({ fieldName, formik }) => {
2665
2654
  }
2666
2655
  ) : null;
2667
2656
  };
2668
- function createEnv(opts) {
2669
- const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
2670
- const emptyStringAsUndefined = opts.emptyStringAsUndefined ?? false;
2671
- if (emptyStringAsUndefined) {
2672
- for (const [key, value] of Object.entries(runtimeEnv)) if (value === "") delete runtimeEnv[key];
2673
- }
2674
- return runtimeEnv;
2675
- }
2676
- var util;
2677
- (function(util2) {
2678
- util2.assertEqual = (val) => val;
2679
- function assertIs(_arg) {
2680
- }
2681
- util2.assertIs = assertIs;
2682
- function assertNever(_x) {
2683
- throw new Error();
2684
- }
2685
- util2.assertNever = assertNever;
2686
- util2.arrayToEnum = (items) => {
2687
- const obj = {};
2688
- for (const item of items) {
2689
- obj[item] = item;
2690
- }
2691
- return obj;
2692
- };
2693
- util2.getValidEnumValues = (obj) => {
2694
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
2695
- const filtered = {};
2696
- for (const k of validKeys) {
2697
- filtered[k] = obj[k];
2698
- }
2699
- return util2.objectValues(filtered);
2700
- };
2701
- util2.objectValues = (obj) => {
2702
- return util2.objectKeys(obj).map(function(e) {
2703
- return obj[e];
2704
- });
2705
- };
2706
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
2707
- const keys2 = [];
2708
- for (const key in object2) {
2709
- if (Object.prototype.hasOwnProperty.call(object2, key)) {
2710
- keys2.push(key);
2711
- }
2712
- }
2713
- return keys2;
2714
- };
2715
- util2.find = (arr, checker) => {
2716
- for (const item of arr) {
2717
- if (checker(item))
2718
- return item;
2719
- }
2720
- return void 0;
2721
- };
2722
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
2723
- function joinValues(array2, separator = " | ") {
2724
- return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
2725
- }
2726
- util2.joinValues = joinValues;
2727
- util2.jsonStringifyReplacer = (_, value) => {
2728
- if (typeof value === "bigint") {
2729
- return value.toString();
2730
- }
2731
- return value;
2732
- };
2733
- })(util || (util = {}));
2734
- var objectUtil;
2735
- (function(objectUtil2) {
2736
- objectUtil2.mergeShapes = (first, second) => {
2737
- return {
2738
- ...first,
2739
- ...second
2740
- // second overwrites first
2741
- };
2742
- };
2743
- })(objectUtil || (objectUtil = {}));
2744
- const ZodParsedType = util.arrayToEnum([
2745
- "string",
2746
- "nan",
2747
- "number",
2748
- "integer",
2749
- "float",
2750
- "boolean",
2751
- "date",
2752
- "bigint",
2753
- "symbol",
2754
- "function",
2755
- "undefined",
2756
- "null",
2757
- "array",
2758
- "object",
2759
- "unknown",
2760
- "promise",
2761
- "void",
2762
- "never",
2763
- "map",
2764
- "set"
2765
- ]);
2766
- const getParsedType = (data) => {
2767
- const t = typeof data;
2768
- switch (t) {
2769
- case "undefined":
2770
- return ZodParsedType.undefined;
2771
- case "string":
2772
- return ZodParsedType.string;
2773
- case "number":
2774
- return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
2775
- case "boolean":
2776
- return ZodParsedType.boolean;
2777
- case "function":
2778
- return ZodParsedType.function;
2779
- case "bigint":
2780
- return ZodParsedType.bigint;
2781
- case "symbol":
2782
- return ZodParsedType.symbol;
2783
- case "object":
2784
- if (Array.isArray(data)) {
2785
- return ZodParsedType.array;
2786
- }
2787
- if (data === null) {
2788
- return ZodParsedType.null;
2789
- }
2790
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
2791
- return ZodParsedType.promise;
2792
- }
2793
- if (typeof Map !== "undefined" && data instanceof Map) {
2794
- return ZodParsedType.map;
2795
- }
2796
- if (typeof Set !== "undefined" && data instanceof Set) {
2797
- return ZodParsedType.set;
2798
- }
2799
- if (typeof Date !== "undefined" && data instanceof Date) {
2800
- return ZodParsedType.date;
2801
- }
2802
- return ZodParsedType.object;
2803
- default:
2804
- return ZodParsedType.unknown;
2805
- }
2806
- };
2807
- const ZodIssueCode = util.arrayToEnum([
2808
- "invalid_type",
2809
- "invalid_literal",
2810
- "custom",
2811
- "invalid_union",
2812
- "invalid_union_discriminator",
2813
- "invalid_enum_value",
2814
- "unrecognized_keys",
2815
- "invalid_arguments",
2816
- "invalid_return_type",
2817
- "invalid_date",
2818
- "invalid_string",
2819
- "too_small",
2820
- "too_big",
2821
- "invalid_intersection_types",
2822
- "not_multiple_of",
2823
- "not_finite"
2824
- ]);
2825
- const quotelessJson = (obj) => {
2826
- const json = JSON.stringify(obj, null, 2);
2827
- return json.replace(/"([^"]+)":/g, "$1:");
2828
- };
2829
- class ZodError extends Error {
2830
- get errors() {
2831
- return this.issues;
2832
- }
2833
- constructor(issues) {
2834
- super();
2835
- this.issues = [];
2836
- this.addIssue = (sub) => {
2837
- this.issues = [...this.issues, sub];
2838
- };
2839
- this.addIssues = (subs = []) => {
2840
- this.issues = [...this.issues, ...subs];
2841
- };
2842
- const actualProto = new.target.prototype;
2843
- if (Object.setPrototypeOf) {
2844
- Object.setPrototypeOf(this, actualProto);
2845
- } else {
2846
- this.__proto__ = actualProto;
2847
- }
2848
- this.name = "ZodError";
2849
- this.issues = issues;
2850
- }
2851
- format(_mapper) {
2852
- const mapper = _mapper || function(issue) {
2853
- return issue.message;
2854
- };
2855
- const fieldErrors = { _errors: [] };
2856
- const processError = (error) => {
2857
- for (const issue of error.issues) {
2858
- if (issue.code === "invalid_union") {
2859
- issue.unionErrors.map(processError);
2860
- } else if (issue.code === "invalid_return_type") {
2861
- processError(issue.returnTypeError);
2862
- } else if (issue.code === "invalid_arguments") {
2863
- processError(issue.argumentsError);
2864
- } else if (issue.path.length === 0) {
2865
- fieldErrors._errors.push(mapper(issue));
2866
- } else {
2867
- let curr = fieldErrors;
2868
- let i = 0;
2869
- while (i < issue.path.length) {
2870
- const el = issue.path[i];
2871
- const terminal = i === issue.path.length - 1;
2872
- if (!terminal) {
2873
- curr[el] = curr[el] || { _errors: [] };
2874
- } else {
2875
- curr[el] = curr[el] || { _errors: [] };
2876
- curr[el]._errors.push(mapper(issue));
2877
- }
2878
- curr = curr[el];
2879
- i++;
2880
- }
2881
- }
2882
- }
2883
- };
2884
- processError(this);
2885
- return fieldErrors;
2886
- }
2887
- static assert(value) {
2888
- if (!(value instanceof ZodError)) {
2889
- throw new Error(`Not a ZodError: ${value}`);
2890
- }
2891
- }
2892
- toString() {
2893
- return this.message;
2894
- }
2895
- get message() {
2896
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
2897
- }
2898
- get isEmpty() {
2899
- return this.issues.length === 0;
2900
- }
2901
- flatten(mapper = (issue) => issue.message) {
2902
- const fieldErrors = {};
2903
- const formErrors = [];
2904
- for (const sub of this.issues) {
2905
- if (sub.path.length > 0) {
2906
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
2907
- fieldErrors[sub.path[0]].push(mapper(sub));
2908
- } else {
2909
- formErrors.push(mapper(sub));
2910
- }
2911
- }
2912
- return { formErrors, fieldErrors };
2913
- }
2914
- get formErrors() {
2915
- return this.flatten();
2916
- }
2917
- }
2918
- ZodError.create = (issues) => {
2919
- const error = new ZodError(issues);
2920
- return error;
2921
- };
2922
- const errorMap = (issue, _ctx) => {
2923
- let message;
2924
- switch (issue.code) {
2925
- case ZodIssueCode.invalid_type:
2926
- if (issue.received === ZodParsedType.undefined) {
2927
- message = "Required";
2928
- } else {
2929
- message = `Expected ${issue.expected}, received ${issue.received}`;
2930
- }
2931
- break;
2932
- case ZodIssueCode.invalid_literal:
2933
- message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
2934
- break;
2935
- case ZodIssueCode.unrecognized_keys:
2936
- message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
2937
- break;
2938
- case ZodIssueCode.invalid_union:
2939
- message = `Invalid input`;
2940
- break;
2941
- case ZodIssueCode.invalid_union_discriminator:
2942
- message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
2943
- break;
2944
- case ZodIssueCode.invalid_enum_value:
2945
- message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
2946
- break;
2947
- case ZodIssueCode.invalid_arguments:
2948
- message = `Invalid function arguments`;
2949
- break;
2950
- case ZodIssueCode.invalid_return_type:
2951
- message = `Invalid function return type`;
2952
- break;
2953
- case ZodIssueCode.invalid_date:
2954
- message = `Invalid date`;
2955
- break;
2956
- case ZodIssueCode.invalid_string:
2957
- if (typeof issue.validation === "object") {
2958
- if ("includes" in issue.validation) {
2959
- message = `Invalid input: must include "${issue.validation.includes}"`;
2960
- if (typeof issue.validation.position === "number") {
2961
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
2962
- }
2963
- } else if ("startsWith" in issue.validation) {
2964
- message = `Invalid input: must start with "${issue.validation.startsWith}"`;
2965
- } else if ("endsWith" in issue.validation) {
2966
- message = `Invalid input: must end with "${issue.validation.endsWith}"`;
2967
- } else {
2968
- util.assertNever(issue.validation);
2969
- }
2970
- } else if (issue.validation !== "regex") {
2971
- message = `Invalid ${issue.validation}`;
2972
- } else {
2973
- message = "Invalid";
2974
- }
2975
- break;
2976
- case ZodIssueCode.too_small:
2977
- if (issue.type === "array")
2978
- message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
2979
- else if (issue.type === "string")
2980
- message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
2981
- else if (issue.type === "number")
2982
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
2983
- else if (issue.type === "date")
2984
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
2985
- else
2986
- message = "Invalid input";
2987
- break;
2988
- case ZodIssueCode.too_big:
2989
- if (issue.type === "array")
2990
- message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
2991
- else if (issue.type === "string")
2992
- message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
2993
- else if (issue.type === "number")
2994
- message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
2995
- else if (issue.type === "bigint")
2996
- message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
2997
- else if (issue.type === "date")
2998
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
2999
- else
3000
- message = "Invalid input";
3001
- break;
3002
- case ZodIssueCode.custom:
3003
- message = `Invalid input`;
3004
- break;
3005
- case ZodIssueCode.invalid_intersection_types:
3006
- message = `Intersection results could not be merged`;
3007
- break;
3008
- case ZodIssueCode.not_multiple_of:
3009
- message = `Number must be a multiple of ${issue.multipleOf}`;
3010
- break;
3011
- case ZodIssueCode.not_finite:
3012
- message = "Number must be finite";
3013
- break;
3014
- default:
3015
- message = _ctx.defaultError;
3016
- util.assertNever(issue);
3017
- }
3018
- return { message };
3019
- };
3020
- let overrideErrorMap = errorMap;
3021
- function setErrorMap(map2) {
3022
- overrideErrorMap = map2;
3023
- }
3024
- function getErrorMap() {
3025
- return overrideErrorMap;
3026
- }
3027
- const makeIssue = (params) => {
3028
- const { data, path, errorMaps, issueData } = params;
3029
- const fullPath = [...path, ...issueData.path || []];
3030
- const fullIssue = {
3031
- ...issueData,
3032
- path: fullPath
3033
- };
3034
- if (issueData.message !== void 0) {
3035
- return {
3036
- ...issueData,
3037
- path: fullPath,
3038
- message: issueData.message
3039
- };
3040
- }
3041
- let errorMessage = "";
3042
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
3043
- for (const map2 of maps) {
3044
- errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
3045
- }
3046
- return {
3047
- ...issueData,
3048
- path: fullPath,
3049
- message: errorMessage
3050
- };
3051
- };
3052
- const EMPTY_PATH = [];
3053
- function addIssueToContext(ctx, issueData) {
3054
- const overrideMap = getErrorMap();
3055
- const issue = makeIssue({
3056
- issueData,
3057
- data: ctx.data,
3058
- path: ctx.path,
3059
- errorMaps: [
3060
- ctx.common.contextualErrorMap,
3061
- // contextual error map is first priority
3062
- ctx.schemaErrorMap,
3063
- // then schema-bound map if available
3064
- overrideMap,
3065
- // then global override map
3066
- overrideMap === errorMap ? void 0 : errorMap
3067
- // then global default map
3068
- ].filter((x) => !!x)
3069
- });
3070
- ctx.common.issues.push(issue);
3071
- }
3072
- class ParseStatus {
3073
- constructor() {
3074
- this.value = "valid";
3075
- }
3076
- dirty() {
3077
- if (this.value === "valid")
3078
- this.value = "dirty";
3079
- }
3080
- abort() {
3081
- if (this.value !== "aborted")
3082
- this.value = "aborted";
3083
- }
3084
- static mergeArray(status, results) {
3085
- const arrayValue = [];
3086
- for (const s of results) {
3087
- if (s.status === "aborted")
3088
- return INVALID;
3089
- if (s.status === "dirty")
3090
- status.dirty();
3091
- arrayValue.push(s.value);
3092
- }
3093
- return { status: status.value, value: arrayValue };
3094
- }
3095
- static async mergeObjectAsync(status, pairs) {
3096
- const syncPairs = [];
3097
- for (const pair of pairs) {
3098
- const key = await pair.key;
3099
- const value = await pair.value;
3100
- syncPairs.push({
3101
- key,
3102
- value
3103
- });
3104
- }
3105
- return ParseStatus.mergeObjectSync(status, syncPairs);
3106
- }
3107
- static mergeObjectSync(status, pairs) {
3108
- const finalObject = {};
3109
- for (const pair of pairs) {
3110
- const { key, value } = pair;
3111
- if (key.status === "aborted")
3112
- return INVALID;
3113
- if (value.status === "aborted")
3114
- return INVALID;
3115
- if (key.status === "dirty")
3116
- status.dirty();
3117
- if (value.status === "dirty")
3118
- status.dirty();
3119
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
3120
- finalObject[key.value] = value.value;
3121
- }
3122
- }
3123
- return { status: status.value, value: finalObject };
3124
- }
3125
- }
3126
- const INVALID = Object.freeze({
3127
- status: "aborted"
3128
- });
3129
- const DIRTY = (value) => ({ status: "dirty", value });
3130
- const OK = (value) => ({ status: "valid", value });
3131
- const isAborted = (x) => x.status === "aborted";
3132
- const isDirty = (x) => x.status === "dirty";
3133
- const isValid$3 = (x) => x.status === "valid";
3134
- const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
3135
- function __classPrivateFieldGet(receiver, state, kind, f) {
3136
- if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3137
- return state.get(receiver);
3138
- }
3139
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
3140
- if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3141
- return state.set(receiver, value), value;
3142
- }
3143
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
3144
- var e = new Error(message);
3145
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3146
- };
3147
- var errorUtil;
3148
- (function(errorUtil2) {
3149
- errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
3150
- errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
3151
- })(errorUtil || (errorUtil = {}));
3152
- var _ZodEnum_cache, _ZodNativeEnum_cache;
3153
- class ParseInputLazyPath {
3154
- constructor(parent, value, path, key) {
3155
- this._cachedPath = [];
3156
- this.parent = parent;
3157
- this.data = value;
3158
- this._path = path;
3159
- this._key = key;
3160
- }
3161
- get path() {
3162
- if (!this._cachedPath.length) {
3163
- if (this._key instanceof Array) {
3164
- this._cachedPath.push(...this._path, ...this._key);
3165
- } else {
3166
- this._cachedPath.push(...this._path, this._key);
3167
- }
3168
- }
3169
- return this._cachedPath;
3170
- }
3171
- }
3172
- const handleResult = (ctx, result) => {
3173
- if (isValid$3(result)) {
3174
- return { success: true, data: result.value };
3175
- } else {
3176
- if (!ctx.common.issues.length) {
3177
- throw new Error("Validation failed but no issues detected.");
3178
- }
3179
- return {
3180
- success: false,
3181
- get error() {
3182
- if (this._error)
3183
- return this._error;
3184
- const error = new ZodError(ctx.common.issues);
3185
- this._error = error;
3186
- return this._error;
3187
- }
3188
- };
3189
- }
3190
- };
3191
- function processCreateParams(params) {
3192
- if (!params)
3193
- return {};
3194
- const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
3195
- if (errorMap2 && (invalid_type_error || required_error)) {
3196
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
3197
- }
3198
- if (errorMap2)
3199
- return { errorMap: errorMap2, description };
3200
- const customMap = (iss, ctx) => {
3201
- var _a, _b;
3202
- const { message } = params;
3203
- if (iss.code === "invalid_enum_value") {
3204
- return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
3205
- }
3206
- if (typeof ctx.data === "undefined") {
3207
- return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
3208
- }
3209
- if (iss.code !== "invalid_type")
3210
- return { message: ctx.defaultError };
3211
- return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
3212
- };
3213
- return { errorMap: customMap, description };
3214
- }
3215
- class ZodType {
3216
- get description() {
3217
- return this._def.description;
3218
- }
3219
- _getType(input) {
3220
- return getParsedType(input.data);
3221
- }
3222
- _getOrReturnCtx(input, ctx) {
3223
- return ctx || {
3224
- common: input.parent.common,
3225
- data: input.data,
3226
- parsedType: getParsedType(input.data),
3227
- schemaErrorMap: this._def.errorMap,
3228
- path: input.path,
3229
- parent: input.parent
3230
- };
3231
- }
3232
- _processInputParams(input) {
3233
- return {
3234
- status: new ParseStatus(),
3235
- ctx: {
3236
- common: input.parent.common,
3237
- data: input.data,
3238
- parsedType: getParsedType(input.data),
3239
- schemaErrorMap: this._def.errorMap,
3240
- path: input.path,
3241
- parent: input.parent
3242
- }
3243
- };
3244
- }
3245
- _parseSync(input) {
3246
- const result = this._parse(input);
3247
- if (isAsync(result)) {
3248
- throw new Error("Synchronous parse encountered promise.");
3249
- }
3250
- return result;
3251
- }
3252
- _parseAsync(input) {
3253
- const result = this._parse(input);
3254
- return Promise.resolve(result);
3255
- }
3256
- parse(data, params) {
3257
- const result = this.safeParse(data, params);
3258
- if (result.success)
3259
- return result.data;
3260
- throw result.error;
3261
- }
3262
- safeParse(data, params) {
3263
- var _a;
3264
- const ctx = {
3265
- common: {
3266
- issues: [],
3267
- async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
3268
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
3269
- },
3270
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
3271
- schemaErrorMap: this._def.errorMap,
3272
- parent: null,
3273
- data,
3274
- parsedType: getParsedType(data)
3275
- };
3276
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
3277
- return handleResult(ctx, result);
3278
- }
3279
- "~validate"(data) {
3280
- var _a, _b;
3281
- const ctx = {
3282
- common: {
3283
- issues: [],
3284
- async: !!this["~standard"].async
3285
- },
3286
- path: [],
3287
- schemaErrorMap: this._def.errorMap,
3288
- parent: null,
3289
- data,
3290
- parsedType: getParsedType(data)
3291
- };
3292
- if (!this["~standard"].async) {
3293
- try {
3294
- const result = this._parseSync({ data, path: [], parent: ctx });
3295
- return isValid$3(result) ? {
3296
- value: result.value
3297
- } : {
3298
- issues: ctx.common.issues
3299
- };
3300
- } catch (err) {
3301
- if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
3302
- this["~standard"].async = true;
3303
- }
3304
- ctx.common = {
3305
- issues: [],
3306
- async: true
3307
- };
3308
- }
3309
- }
3310
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid$3(result) ? {
3311
- value: result.value
3312
- } : {
3313
- issues: ctx.common.issues
3314
- });
3315
- }
3316
- async parseAsync(data, params) {
3317
- const result = await this.safeParseAsync(data, params);
3318
- if (result.success)
3319
- return result.data;
3320
- throw result.error;
3321
- }
3322
- async safeParseAsync(data, params) {
3323
- const ctx = {
3324
- common: {
3325
- issues: [],
3326
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
3327
- async: true
3328
- },
3329
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
3330
- schemaErrorMap: this._def.errorMap,
3331
- parent: null,
3332
- data,
3333
- parsedType: getParsedType(data)
3334
- };
3335
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
3336
- const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
3337
- return handleResult(ctx, result);
3338
- }
3339
- refine(check, message) {
3340
- const getIssueProperties = (val) => {
3341
- if (typeof message === "string" || typeof message === "undefined") {
3342
- return { message };
3343
- } else if (typeof message === "function") {
3344
- return message(val);
3345
- } else {
3346
- return message;
3347
- }
3348
- };
3349
- return this._refinement((val, ctx) => {
3350
- const result = check(val);
3351
- const setError = () => ctx.addIssue({
3352
- code: ZodIssueCode.custom,
3353
- ...getIssueProperties(val)
3354
- });
3355
- if (typeof Promise !== "undefined" && result instanceof Promise) {
3356
- return result.then((data) => {
3357
- if (!data) {
3358
- setError();
3359
- return false;
3360
- } else {
3361
- return true;
3362
- }
3363
- });
3364
- }
3365
- if (!result) {
3366
- setError();
3367
- return false;
3368
- } else {
3369
- return true;
3370
- }
3371
- });
3372
- }
3373
- refinement(check, refinementData) {
3374
- return this._refinement((val, ctx) => {
3375
- if (!check(val)) {
3376
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
3377
- return false;
3378
- } else {
3379
- return true;
3380
- }
3381
- });
3382
- }
3383
- _refinement(refinement) {
3384
- return new ZodEffects({
3385
- schema: this,
3386
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3387
- effect: { type: "refinement", refinement }
3388
- });
3389
- }
3390
- superRefine(refinement) {
3391
- return this._refinement(refinement);
3392
- }
3393
- constructor(def) {
3394
- this.spa = this.safeParseAsync;
3395
- this._def = def;
3396
- this.parse = this.parse.bind(this);
3397
- this.safeParse = this.safeParse.bind(this);
3398
- this.parseAsync = this.parseAsync.bind(this);
3399
- this.safeParseAsync = this.safeParseAsync.bind(this);
3400
- this.spa = this.spa.bind(this);
3401
- this.refine = this.refine.bind(this);
3402
- this.refinement = this.refinement.bind(this);
3403
- this.superRefine = this.superRefine.bind(this);
3404
- this.optional = this.optional.bind(this);
3405
- this.nullable = this.nullable.bind(this);
3406
- this.nullish = this.nullish.bind(this);
3407
- this.array = this.array.bind(this);
3408
- this.promise = this.promise.bind(this);
3409
- this.or = this.or.bind(this);
3410
- this.and = this.and.bind(this);
3411
- this.transform = this.transform.bind(this);
3412
- this.brand = this.brand.bind(this);
3413
- this.default = this.default.bind(this);
3414
- this.catch = this.catch.bind(this);
3415
- this.describe = this.describe.bind(this);
3416
- this.pipe = this.pipe.bind(this);
3417
- this.readonly = this.readonly.bind(this);
3418
- this.isNullable = this.isNullable.bind(this);
3419
- this.isOptional = this.isOptional.bind(this);
3420
- this["~standard"] = {
3421
- version: 1,
3422
- vendor: "zod",
3423
- validate: (data) => this["~validate"](data)
3424
- };
3425
- }
3426
- optional() {
3427
- return ZodOptional.create(this, this._def);
3428
- }
3429
- nullable() {
3430
- return ZodNullable.create(this, this._def);
3431
- }
3432
- nullish() {
3433
- return this.nullable().optional();
3434
- }
3435
- array() {
3436
- return ZodArray.create(this);
3437
- }
3438
- promise() {
3439
- return ZodPromise.create(this, this._def);
3440
- }
3441
- or(option) {
3442
- return ZodUnion.create([this, option], this._def);
3443
- }
3444
- and(incoming) {
3445
- return ZodIntersection.create(this, incoming, this._def);
3446
- }
3447
- transform(transform) {
3448
- return new ZodEffects({
3449
- ...processCreateParams(this._def),
3450
- schema: this,
3451
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3452
- effect: { type: "transform", transform }
3453
- });
3454
- }
3455
- default(def) {
3456
- const defaultValueFunc = typeof def === "function" ? def : () => def;
3457
- return new ZodDefault({
3458
- ...processCreateParams(this._def),
3459
- innerType: this,
3460
- defaultValue: defaultValueFunc,
3461
- typeName: ZodFirstPartyTypeKind.ZodDefault
3462
- });
3463
- }
3464
- brand() {
3465
- return new ZodBranded({
3466
- typeName: ZodFirstPartyTypeKind.ZodBranded,
3467
- type: this,
3468
- ...processCreateParams(this._def)
3469
- });
3470
- }
3471
- catch(def) {
3472
- const catchValueFunc = typeof def === "function" ? def : () => def;
3473
- return new ZodCatch({
3474
- ...processCreateParams(this._def),
3475
- innerType: this,
3476
- catchValue: catchValueFunc,
3477
- typeName: ZodFirstPartyTypeKind.ZodCatch
3478
- });
3479
- }
3480
- describe(description) {
3481
- const This = this.constructor;
3482
- return new This({
3483
- ...this._def,
3484
- description
3485
- });
3486
- }
3487
- pipe(target) {
3488
- return ZodPipeline.create(this, target);
3489
- }
3490
- readonly() {
3491
- return ZodReadonly.create(this);
3492
- }
3493
- isOptional() {
3494
- return this.safeParse(void 0).success;
3495
- }
3496
- isNullable() {
3497
- return this.safeParse(null).success;
3498
- }
3499
- }
3500
- const cuidRegex = /^c[^\s-]{8,}$/i;
3501
- const cuid2Regex = /^[0-9a-z]+$/;
3502
- const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
3503
- const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
3504
- const nanoidRegex = /^[a-z0-9_-]{21}$/i;
3505
- const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
3506
- const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
3507
- const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
3508
- const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
3509
- let emojiRegex;
3510
- const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
3511
- const ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
3512
- const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
3513
- const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
3514
- const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
3515
- const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
3516
- const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
3517
- const dateRegex = new RegExp(`^${dateRegexSource}$`);
3518
- function timeRegexSource(args) {
3519
- let secondsRegexSource = `[0-5]\\d`;
3520
- if (args.precision) {
3521
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
3522
- } else if (args.precision == null) {
3523
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
3524
- }
3525
- const secondsQuantifier = args.precision ? "+" : "?";
3526
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
3527
- }
3528
- function timeRegex(args) {
3529
- return new RegExp(`^${timeRegexSource(args)}$`);
3530
- }
3531
- function datetimeRegex(args) {
3532
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
3533
- const opts = [];
3534
- opts.push(args.local ? `Z?` : `Z`);
3535
- if (args.offset)
3536
- opts.push(`([+-]\\d{2}:?\\d{2})`);
3537
- regex = `${regex}(${opts.join("|")})`;
3538
- return new RegExp(`^${regex}$`);
3539
- }
3540
- function isValidIP(ip, version) {
3541
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
3542
- return true;
3543
- }
3544
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
3545
- return true;
3546
- }
3547
- return false;
3548
- }
3549
- function isValidJWT(jwt, alg) {
3550
- if (!jwtRegex.test(jwt))
3551
- return false;
3552
- try {
3553
- const [header] = jwt.split(".");
3554
- const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
3555
- const decoded = JSON.parse(atob(base64));
3556
- if (typeof decoded !== "object" || decoded === null)
3557
- return false;
3558
- if (!decoded.typ || !decoded.alg)
3559
- return false;
3560
- if (alg && decoded.alg !== alg)
3561
- return false;
3562
- return true;
3563
- } catch (_a) {
3564
- return false;
3565
- }
3566
- }
3567
- function isValidCidr(ip, version) {
3568
- if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
3569
- return true;
3570
- }
3571
- if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
3572
- return true;
3573
- }
3574
- return false;
3575
- }
3576
- class ZodString extends ZodType {
3577
- _parse(input) {
3578
- if (this._def.coerce) {
3579
- input.data = String(input.data);
3580
- }
3581
- const parsedType = this._getType(input);
3582
- if (parsedType !== ZodParsedType.string) {
3583
- const ctx2 = this._getOrReturnCtx(input);
3584
- addIssueToContext(ctx2, {
3585
- code: ZodIssueCode.invalid_type,
3586
- expected: ZodParsedType.string,
3587
- received: ctx2.parsedType
3588
- });
3589
- return INVALID;
3590
- }
3591
- const status = new ParseStatus();
3592
- let ctx = void 0;
3593
- for (const check of this._def.checks) {
3594
- if (check.kind === "min") {
3595
- if (input.data.length < check.value) {
3596
- ctx = this._getOrReturnCtx(input, ctx);
3597
- addIssueToContext(ctx, {
3598
- code: ZodIssueCode.too_small,
3599
- minimum: check.value,
3600
- type: "string",
3601
- inclusive: true,
3602
- exact: false,
3603
- message: check.message
3604
- });
3605
- status.dirty();
3606
- }
3607
- } else if (check.kind === "max") {
3608
- if (input.data.length > check.value) {
3609
- ctx = this._getOrReturnCtx(input, ctx);
3610
- addIssueToContext(ctx, {
3611
- code: ZodIssueCode.too_big,
3612
- maximum: check.value,
3613
- type: "string",
3614
- inclusive: true,
3615
- exact: false,
3616
- message: check.message
3617
- });
3618
- status.dirty();
3619
- }
3620
- } else if (check.kind === "length") {
3621
- const tooBig = input.data.length > check.value;
3622
- const tooSmall = input.data.length < check.value;
3623
- if (tooBig || tooSmall) {
3624
- ctx = this._getOrReturnCtx(input, ctx);
3625
- if (tooBig) {
3626
- addIssueToContext(ctx, {
3627
- code: ZodIssueCode.too_big,
3628
- maximum: check.value,
3629
- type: "string",
3630
- inclusive: true,
3631
- exact: true,
3632
- message: check.message
3633
- });
3634
- } else if (tooSmall) {
3635
- addIssueToContext(ctx, {
3636
- code: ZodIssueCode.too_small,
3637
- minimum: check.value,
3638
- type: "string",
3639
- inclusive: true,
3640
- exact: true,
3641
- message: check.message
3642
- });
3643
- }
3644
- status.dirty();
3645
- }
3646
- } else if (check.kind === "email") {
3647
- if (!emailRegex.test(input.data)) {
3648
- ctx = this._getOrReturnCtx(input, ctx);
3649
- addIssueToContext(ctx, {
3650
- validation: "email",
3651
- code: ZodIssueCode.invalid_string,
3652
- message: check.message
3653
- });
3654
- status.dirty();
3655
- }
3656
- } else if (check.kind === "emoji") {
3657
- if (!emojiRegex) {
3658
- emojiRegex = new RegExp(_emojiRegex, "u");
3659
- }
3660
- if (!emojiRegex.test(input.data)) {
3661
- ctx = this._getOrReturnCtx(input, ctx);
3662
- addIssueToContext(ctx, {
3663
- validation: "emoji",
3664
- code: ZodIssueCode.invalid_string,
3665
- message: check.message
3666
- });
3667
- status.dirty();
3668
- }
3669
- } else if (check.kind === "uuid") {
3670
- if (!uuidRegex.test(input.data)) {
3671
- ctx = this._getOrReturnCtx(input, ctx);
3672
- addIssueToContext(ctx, {
3673
- validation: "uuid",
3674
- code: ZodIssueCode.invalid_string,
3675
- message: check.message
3676
- });
3677
- status.dirty();
3678
- }
3679
- } else if (check.kind === "nanoid") {
3680
- if (!nanoidRegex.test(input.data)) {
3681
- ctx = this._getOrReturnCtx(input, ctx);
3682
- addIssueToContext(ctx, {
3683
- validation: "nanoid",
3684
- code: ZodIssueCode.invalid_string,
3685
- message: check.message
3686
- });
3687
- status.dirty();
3688
- }
3689
- } else if (check.kind === "cuid") {
3690
- if (!cuidRegex.test(input.data)) {
3691
- ctx = this._getOrReturnCtx(input, ctx);
3692
- addIssueToContext(ctx, {
3693
- validation: "cuid",
3694
- code: ZodIssueCode.invalid_string,
3695
- message: check.message
3696
- });
3697
- status.dirty();
3698
- }
3699
- } else if (check.kind === "cuid2") {
3700
- if (!cuid2Regex.test(input.data)) {
3701
- ctx = this._getOrReturnCtx(input, ctx);
3702
- addIssueToContext(ctx, {
3703
- validation: "cuid2",
3704
- code: ZodIssueCode.invalid_string,
3705
- message: check.message
3706
- });
3707
- status.dirty();
3708
- }
3709
- } else if (check.kind === "ulid") {
3710
- if (!ulidRegex.test(input.data)) {
3711
- ctx = this._getOrReturnCtx(input, ctx);
3712
- addIssueToContext(ctx, {
3713
- validation: "ulid",
3714
- code: ZodIssueCode.invalid_string,
3715
- message: check.message
3716
- });
3717
- status.dirty();
3718
- }
3719
- } else if (check.kind === "url") {
3720
- try {
3721
- new URL(input.data);
3722
- } catch (_a) {
3723
- ctx = this._getOrReturnCtx(input, ctx);
3724
- addIssueToContext(ctx, {
3725
- validation: "url",
3726
- code: ZodIssueCode.invalid_string,
3727
- message: check.message
3728
- });
3729
- status.dirty();
3730
- }
3731
- } else if (check.kind === "regex") {
3732
- check.regex.lastIndex = 0;
3733
- const testResult = check.regex.test(input.data);
3734
- if (!testResult) {
3735
- ctx = this._getOrReturnCtx(input, ctx);
3736
- addIssueToContext(ctx, {
3737
- validation: "regex",
3738
- code: ZodIssueCode.invalid_string,
3739
- message: check.message
3740
- });
3741
- status.dirty();
3742
- }
3743
- } else if (check.kind === "trim") {
3744
- input.data = input.data.trim();
3745
- } else if (check.kind === "includes") {
3746
- if (!input.data.includes(check.value, check.position)) {
3747
- ctx = this._getOrReturnCtx(input, ctx);
3748
- addIssueToContext(ctx, {
3749
- code: ZodIssueCode.invalid_string,
3750
- validation: { includes: check.value, position: check.position },
3751
- message: check.message
3752
- });
3753
- status.dirty();
3754
- }
3755
- } else if (check.kind === "toLowerCase") {
3756
- input.data = input.data.toLowerCase();
3757
- } else if (check.kind === "toUpperCase") {
3758
- input.data = input.data.toUpperCase();
3759
- } else if (check.kind === "startsWith") {
3760
- if (!input.data.startsWith(check.value)) {
3761
- ctx = this._getOrReturnCtx(input, ctx);
3762
- addIssueToContext(ctx, {
3763
- code: ZodIssueCode.invalid_string,
3764
- validation: { startsWith: check.value },
3765
- message: check.message
3766
- });
3767
- status.dirty();
3768
- }
3769
- } else if (check.kind === "endsWith") {
3770
- if (!input.data.endsWith(check.value)) {
3771
- ctx = this._getOrReturnCtx(input, ctx);
3772
- addIssueToContext(ctx, {
3773
- code: ZodIssueCode.invalid_string,
3774
- validation: { endsWith: check.value },
3775
- message: check.message
3776
- });
3777
- status.dirty();
3778
- }
3779
- } else if (check.kind === "datetime") {
3780
- const regex = datetimeRegex(check);
3781
- if (!regex.test(input.data)) {
3782
- ctx = this._getOrReturnCtx(input, ctx);
3783
- addIssueToContext(ctx, {
3784
- code: ZodIssueCode.invalid_string,
3785
- validation: "datetime",
3786
- message: check.message
3787
- });
3788
- status.dirty();
3789
- }
3790
- } else if (check.kind === "date") {
3791
- const regex = dateRegex;
3792
- if (!regex.test(input.data)) {
3793
- ctx = this._getOrReturnCtx(input, ctx);
3794
- addIssueToContext(ctx, {
3795
- code: ZodIssueCode.invalid_string,
3796
- validation: "date",
3797
- message: check.message
3798
- });
3799
- status.dirty();
3800
- }
3801
- } else if (check.kind === "time") {
3802
- const regex = timeRegex(check);
3803
- if (!regex.test(input.data)) {
3804
- ctx = this._getOrReturnCtx(input, ctx);
3805
- addIssueToContext(ctx, {
3806
- code: ZodIssueCode.invalid_string,
3807
- validation: "time",
3808
- message: check.message
3809
- });
3810
- status.dirty();
3811
- }
3812
- } else if (check.kind === "duration") {
3813
- if (!durationRegex.test(input.data)) {
3814
- ctx = this._getOrReturnCtx(input, ctx);
3815
- addIssueToContext(ctx, {
3816
- validation: "duration",
3817
- code: ZodIssueCode.invalid_string,
3818
- message: check.message
3819
- });
3820
- status.dirty();
3821
- }
3822
- } else if (check.kind === "ip") {
3823
- if (!isValidIP(input.data, check.version)) {
3824
- ctx = this._getOrReturnCtx(input, ctx);
3825
- addIssueToContext(ctx, {
3826
- validation: "ip",
3827
- code: ZodIssueCode.invalid_string,
3828
- message: check.message
3829
- });
3830
- status.dirty();
3831
- }
3832
- } else if (check.kind === "jwt") {
3833
- if (!isValidJWT(input.data, check.alg)) {
3834
- ctx = this._getOrReturnCtx(input, ctx);
3835
- addIssueToContext(ctx, {
3836
- validation: "jwt",
3837
- code: ZodIssueCode.invalid_string,
3838
- message: check.message
3839
- });
3840
- status.dirty();
3841
- }
3842
- } else if (check.kind === "cidr") {
3843
- if (!isValidCidr(input.data, check.version)) {
3844
- ctx = this._getOrReturnCtx(input, ctx);
3845
- addIssueToContext(ctx, {
3846
- validation: "cidr",
3847
- code: ZodIssueCode.invalid_string,
3848
- message: check.message
3849
- });
3850
- status.dirty();
3851
- }
3852
- } else if (check.kind === "base64") {
3853
- if (!base64Regex.test(input.data)) {
3854
- ctx = this._getOrReturnCtx(input, ctx);
3855
- addIssueToContext(ctx, {
3856
- validation: "base64",
3857
- code: ZodIssueCode.invalid_string,
3858
- message: check.message
3859
- });
3860
- status.dirty();
3861
- }
3862
- } else if (check.kind === "base64url") {
3863
- if (!base64urlRegex.test(input.data)) {
3864
- ctx = this._getOrReturnCtx(input, ctx);
3865
- addIssueToContext(ctx, {
3866
- validation: "base64url",
3867
- code: ZodIssueCode.invalid_string,
3868
- message: check.message
3869
- });
3870
- status.dirty();
3871
- }
3872
- } else {
3873
- util.assertNever(check);
3874
- }
3875
- }
3876
- return { status: status.value, value: input.data };
3877
- }
3878
- _regex(regex, validation, message) {
3879
- return this.refinement((data) => regex.test(data), {
3880
- validation,
3881
- code: ZodIssueCode.invalid_string,
3882
- ...errorUtil.errToObj(message)
3883
- });
3884
- }
3885
- _addCheck(check) {
3886
- return new ZodString({
3887
- ...this._def,
3888
- checks: [...this._def.checks, check]
3889
- });
3890
- }
3891
- email(message) {
3892
- return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
3893
- }
3894
- url(message) {
3895
- return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
3896
- }
3897
- emoji(message) {
3898
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
3899
- }
3900
- uuid(message) {
3901
- return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
3902
- }
3903
- nanoid(message) {
3904
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
3905
- }
3906
- cuid(message) {
3907
- return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
3908
- }
3909
- cuid2(message) {
3910
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
3911
- }
3912
- ulid(message) {
3913
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
3914
- }
3915
- base64(message) {
3916
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
3917
- }
3918
- base64url(message) {
3919
- return this._addCheck({
3920
- kind: "base64url",
3921
- ...errorUtil.errToObj(message)
3922
- });
3923
- }
3924
- jwt(options) {
3925
- return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
3926
- }
3927
- ip(options) {
3928
- return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
3929
- }
3930
- cidr(options) {
3931
- return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
3932
- }
3933
- datetime(options) {
3934
- var _a, _b;
3935
- if (typeof options === "string") {
3936
- return this._addCheck({
3937
- kind: "datetime",
3938
- precision: null,
3939
- offset: false,
3940
- local: false,
3941
- message: options
3942
- });
3943
- }
3944
- return this._addCheck({
3945
- kind: "datetime",
3946
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
3947
- offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
3948
- local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
3949
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
3950
- });
3951
- }
3952
- date(message) {
3953
- return this._addCheck({ kind: "date", message });
3954
- }
3955
- time(options) {
3956
- if (typeof options === "string") {
3957
- return this._addCheck({
3958
- kind: "time",
3959
- precision: null,
3960
- message: options
3961
- });
3962
- }
3963
- return this._addCheck({
3964
- kind: "time",
3965
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
3966
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
3967
- });
3968
- }
3969
- duration(message) {
3970
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
3971
- }
3972
- regex(regex, message) {
3973
- return this._addCheck({
3974
- kind: "regex",
3975
- regex,
3976
- ...errorUtil.errToObj(message)
3977
- });
3978
- }
3979
- includes(value, options) {
3980
- return this._addCheck({
3981
- kind: "includes",
3982
- value,
3983
- position: options === null || options === void 0 ? void 0 : options.position,
3984
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
3985
- });
3986
- }
3987
- startsWith(value, message) {
3988
- return this._addCheck({
3989
- kind: "startsWith",
3990
- value,
3991
- ...errorUtil.errToObj(message)
3992
- });
3993
- }
3994
- endsWith(value, message) {
3995
- return this._addCheck({
3996
- kind: "endsWith",
3997
- value,
3998
- ...errorUtil.errToObj(message)
3999
- });
4000
- }
4001
- min(minLength, message) {
4002
- return this._addCheck({
4003
- kind: "min",
4004
- value: minLength,
4005
- ...errorUtil.errToObj(message)
4006
- });
4007
- }
4008
- max(maxLength, message) {
4009
- return this._addCheck({
4010
- kind: "max",
4011
- value: maxLength,
4012
- ...errorUtil.errToObj(message)
4013
- });
4014
- }
4015
- length(len, message) {
4016
- return this._addCheck({
4017
- kind: "length",
4018
- value: len,
4019
- ...errorUtil.errToObj(message)
4020
- });
4021
- }
4022
- /**
4023
- * Equivalent to `.min(1)`
4024
- */
4025
- nonempty(message) {
4026
- return this.min(1, errorUtil.errToObj(message));
4027
- }
4028
- trim() {
4029
- return new ZodString({
4030
- ...this._def,
4031
- checks: [...this._def.checks, { kind: "trim" }]
4032
- });
4033
- }
4034
- toLowerCase() {
4035
- return new ZodString({
4036
- ...this._def,
4037
- checks: [...this._def.checks, { kind: "toLowerCase" }]
4038
- });
4039
- }
4040
- toUpperCase() {
4041
- return new ZodString({
4042
- ...this._def,
4043
- checks: [...this._def.checks, { kind: "toUpperCase" }]
4044
- });
4045
- }
4046
- get isDatetime() {
4047
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
4048
- }
4049
- get isDate() {
4050
- return !!this._def.checks.find((ch) => ch.kind === "date");
4051
- }
4052
- get isTime() {
4053
- return !!this._def.checks.find((ch) => ch.kind === "time");
4054
- }
4055
- get isDuration() {
4056
- return !!this._def.checks.find((ch) => ch.kind === "duration");
4057
- }
4058
- get isEmail() {
4059
- return !!this._def.checks.find((ch) => ch.kind === "email");
4060
- }
4061
- get isURL() {
4062
- return !!this._def.checks.find((ch) => ch.kind === "url");
4063
- }
4064
- get isEmoji() {
4065
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
4066
- }
4067
- get isUUID() {
4068
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
4069
- }
4070
- get isNANOID() {
4071
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
4072
- }
4073
- get isCUID() {
4074
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
4075
- }
4076
- get isCUID2() {
4077
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
4078
- }
4079
- get isULID() {
4080
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
4081
- }
4082
- get isIP() {
4083
- return !!this._def.checks.find((ch) => ch.kind === "ip");
4084
- }
4085
- get isCIDR() {
4086
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
4087
- }
4088
- get isBase64() {
4089
- return !!this._def.checks.find((ch) => ch.kind === "base64");
4090
- }
4091
- get isBase64url() {
4092
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
4093
- }
4094
- get minLength() {
4095
- let min2 = null;
4096
- for (const ch of this._def.checks) {
4097
- if (ch.kind === "min") {
4098
- if (min2 === null || ch.value > min2)
4099
- min2 = ch.value;
4100
- }
4101
- }
4102
- return min2;
4103
- }
4104
- get maxLength() {
4105
- let max2 = null;
4106
- for (const ch of this._def.checks) {
4107
- if (ch.kind === "max") {
4108
- if (max2 === null || ch.value < max2)
4109
- max2 = ch.value;
4110
- }
4111
- }
4112
- return max2;
4113
- }
4114
- }
4115
- ZodString.create = (params) => {
4116
- var _a;
4117
- return new ZodString({
4118
- checks: [],
4119
- typeName: ZodFirstPartyTypeKind.ZodString,
4120
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
4121
- ...processCreateParams(params)
4122
- });
4123
- };
4124
- function floatSafeRemainder(val, step) {
4125
- const valDecCount = (val.toString().split(".")[1] || "").length;
4126
- const stepDecCount = (step.toString().split(".")[1] || "").length;
4127
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
4128
- const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
4129
- const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
4130
- return valInt % stepInt / Math.pow(10, decCount);
4131
- }
4132
- class ZodNumber extends ZodType {
4133
- constructor() {
4134
- super(...arguments);
4135
- this.min = this.gte;
4136
- this.max = this.lte;
4137
- this.step = this.multipleOf;
4138
- }
4139
- _parse(input) {
4140
- if (this._def.coerce) {
4141
- input.data = Number(input.data);
4142
- }
4143
- const parsedType = this._getType(input);
4144
- if (parsedType !== ZodParsedType.number) {
4145
- const ctx2 = this._getOrReturnCtx(input);
4146
- addIssueToContext(ctx2, {
4147
- code: ZodIssueCode.invalid_type,
4148
- expected: ZodParsedType.number,
4149
- received: ctx2.parsedType
4150
- });
4151
- return INVALID;
4152
- }
4153
- let ctx = void 0;
4154
- const status = new ParseStatus();
4155
- for (const check of this._def.checks) {
4156
- if (check.kind === "int") {
4157
- if (!util.isInteger(input.data)) {
4158
- ctx = this._getOrReturnCtx(input, ctx);
4159
- addIssueToContext(ctx, {
4160
- code: ZodIssueCode.invalid_type,
4161
- expected: "integer",
4162
- received: "float",
4163
- message: check.message
4164
- });
4165
- status.dirty();
4166
- }
4167
- } else if (check.kind === "min") {
4168
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
4169
- if (tooSmall) {
4170
- ctx = this._getOrReturnCtx(input, ctx);
4171
- addIssueToContext(ctx, {
4172
- code: ZodIssueCode.too_small,
4173
- minimum: check.value,
4174
- type: "number",
4175
- inclusive: check.inclusive,
4176
- exact: false,
4177
- message: check.message
4178
- });
4179
- status.dirty();
4180
- }
4181
- } else if (check.kind === "max") {
4182
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
4183
- if (tooBig) {
4184
- ctx = this._getOrReturnCtx(input, ctx);
4185
- addIssueToContext(ctx, {
4186
- code: ZodIssueCode.too_big,
4187
- maximum: check.value,
4188
- type: "number",
4189
- inclusive: check.inclusive,
4190
- exact: false,
4191
- message: check.message
4192
- });
4193
- status.dirty();
4194
- }
4195
- } else if (check.kind === "multipleOf") {
4196
- if (floatSafeRemainder(input.data, check.value) !== 0) {
4197
- ctx = this._getOrReturnCtx(input, ctx);
4198
- addIssueToContext(ctx, {
4199
- code: ZodIssueCode.not_multiple_of,
4200
- multipleOf: check.value,
4201
- message: check.message
4202
- });
4203
- status.dirty();
4204
- }
4205
- } else if (check.kind === "finite") {
4206
- if (!Number.isFinite(input.data)) {
4207
- ctx = this._getOrReturnCtx(input, ctx);
4208
- addIssueToContext(ctx, {
4209
- code: ZodIssueCode.not_finite,
4210
- message: check.message
4211
- });
4212
- status.dirty();
4213
- }
4214
- } else {
4215
- util.assertNever(check);
4216
- }
4217
- }
4218
- return { status: status.value, value: input.data };
4219
- }
4220
- gte(value, message) {
4221
- return this.setLimit("min", value, true, errorUtil.toString(message));
4222
- }
4223
- gt(value, message) {
4224
- return this.setLimit("min", value, false, errorUtil.toString(message));
4225
- }
4226
- lte(value, message) {
4227
- return this.setLimit("max", value, true, errorUtil.toString(message));
4228
- }
4229
- lt(value, message) {
4230
- return this.setLimit("max", value, false, errorUtil.toString(message));
4231
- }
4232
- setLimit(kind, value, inclusive, message) {
4233
- return new ZodNumber({
4234
- ...this._def,
4235
- checks: [
4236
- ...this._def.checks,
4237
- {
4238
- kind,
4239
- value,
4240
- inclusive,
4241
- message: errorUtil.toString(message)
4242
- }
4243
- ]
4244
- });
4245
- }
4246
- _addCheck(check) {
4247
- return new ZodNumber({
4248
- ...this._def,
4249
- checks: [...this._def.checks, check]
4250
- });
4251
- }
4252
- int(message) {
4253
- return this._addCheck({
4254
- kind: "int",
4255
- message: errorUtil.toString(message)
4256
- });
4257
- }
4258
- positive(message) {
4259
- return this._addCheck({
4260
- kind: "min",
4261
- value: 0,
4262
- inclusive: false,
4263
- message: errorUtil.toString(message)
4264
- });
4265
- }
4266
- negative(message) {
4267
- return this._addCheck({
4268
- kind: "max",
4269
- value: 0,
4270
- inclusive: false,
4271
- message: errorUtil.toString(message)
4272
- });
4273
- }
4274
- nonpositive(message) {
4275
- return this._addCheck({
4276
- kind: "max",
4277
- value: 0,
4278
- inclusive: true,
4279
- message: errorUtil.toString(message)
4280
- });
4281
- }
4282
- nonnegative(message) {
4283
- return this._addCheck({
4284
- kind: "min",
4285
- value: 0,
4286
- inclusive: true,
4287
- message: errorUtil.toString(message)
4288
- });
4289
- }
4290
- multipleOf(value, message) {
4291
- return this._addCheck({
4292
- kind: "multipleOf",
4293
- value,
4294
- message: errorUtil.toString(message)
4295
- });
4296
- }
4297
- finite(message) {
4298
- return this._addCheck({
4299
- kind: "finite",
4300
- message: errorUtil.toString(message)
4301
- });
4302
- }
4303
- safe(message) {
4304
- return this._addCheck({
4305
- kind: "min",
4306
- inclusive: true,
4307
- value: Number.MIN_SAFE_INTEGER,
4308
- message: errorUtil.toString(message)
4309
- })._addCheck({
4310
- kind: "max",
4311
- inclusive: true,
4312
- value: Number.MAX_SAFE_INTEGER,
4313
- message: errorUtil.toString(message)
4314
- });
4315
- }
4316
- get minValue() {
4317
- let min2 = null;
4318
- for (const ch of this._def.checks) {
4319
- if (ch.kind === "min") {
4320
- if (min2 === null || ch.value > min2)
4321
- min2 = ch.value;
4322
- }
4323
- }
4324
- return min2;
4325
- }
4326
- get maxValue() {
4327
- let max2 = null;
4328
- for (const ch of this._def.checks) {
4329
- if (ch.kind === "max") {
4330
- if (max2 === null || ch.value < max2)
4331
- max2 = ch.value;
4332
- }
4333
- }
4334
- return max2;
4335
- }
4336
- get isInt() {
4337
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
4338
- }
4339
- get isFinite() {
4340
- let max2 = null, min2 = null;
4341
- for (const ch of this._def.checks) {
4342
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
4343
- return true;
4344
- } else if (ch.kind === "min") {
4345
- if (min2 === null || ch.value > min2)
4346
- min2 = ch.value;
4347
- } else if (ch.kind === "max") {
4348
- if (max2 === null || ch.value < max2)
4349
- max2 = ch.value;
4350
- }
4351
- }
4352
- return Number.isFinite(min2) && Number.isFinite(max2);
4353
- }
4354
- }
4355
- ZodNumber.create = (params) => {
4356
- return new ZodNumber({
4357
- checks: [],
4358
- typeName: ZodFirstPartyTypeKind.ZodNumber,
4359
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
4360
- ...processCreateParams(params)
4361
- });
4362
- };
4363
- class ZodBigInt extends ZodType {
4364
- constructor() {
4365
- super(...arguments);
4366
- this.min = this.gte;
4367
- this.max = this.lte;
4368
- }
4369
- _parse(input) {
4370
- if (this._def.coerce) {
4371
- try {
4372
- input.data = BigInt(input.data);
4373
- } catch (_a) {
4374
- return this._getInvalidInput(input);
4375
- }
4376
- }
4377
- const parsedType = this._getType(input);
4378
- if (parsedType !== ZodParsedType.bigint) {
4379
- return this._getInvalidInput(input);
4380
- }
4381
- let ctx = void 0;
4382
- const status = new ParseStatus();
4383
- for (const check of this._def.checks) {
4384
- if (check.kind === "min") {
4385
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
4386
- if (tooSmall) {
4387
- ctx = this._getOrReturnCtx(input, ctx);
4388
- addIssueToContext(ctx, {
4389
- code: ZodIssueCode.too_small,
4390
- type: "bigint",
4391
- minimum: check.value,
4392
- inclusive: check.inclusive,
4393
- message: check.message
4394
- });
4395
- status.dirty();
4396
- }
4397
- } else if (check.kind === "max") {
4398
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
4399
- if (tooBig) {
4400
- ctx = this._getOrReturnCtx(input, ctx);
4401
- addIssueToContext(ctx, {
4402
- code: ZodIssueCode.too_big,
4403
- type: "bigint",
4404
- maximum: check.value,
4405
- inclusive: check.inclusive,
4406
- message: check.message
4407
- });
4408
- status.dirty();
4409
- }
4410
- } else if (check.kind === "multipleOf") {
4411
- if (input.data % check.value !== BigInt(0)) {
4412
- ctx = this._getOrReturnCtx(input, ctx);
4413
- addIssueToContext(ctx, {
4414
- code: ZodIssueCode.not_multiple_of,
4415
- multipleOf: check.value,
4416
- message: check.message
4417
- });
4418
- status.dirty();
4419
- }
4420
- } else {
4421
- util.assertNever(check);
4422
- }
4423
- }
4424
- return { status: status.value, value: input.data };
4425
- }
4426
- _getInvalidInput(input) {
4427
- const ctx = this._getOrReturnCtx(input);
4428
- addIssueToContext(ctx, {
4429
- code: ZodIssueCode.invalid_type,
4430
- expected: ZodParsedType.bigint,
4431
- received: ctx.parsedType
4432
- });
4433
- return INVALID;
4434
- }
4435
- gte(value, message) {
4436
- return this.setLimit("min", value, true, errorUtil.toString(message));
4437
- }
4438
- gt(value, message) {
4439
- return this.setLimit("min", value, false, errorUtil.toString(message));
4440
- }
4441
- lte(value, message) {
4442
- return this.setLimit("max", value, true, errorUtil.toString(message));
4443
- }
4444
- lt(value, message) {
4445
- return this.setLimit("max", value, false, errorUtil.toString(message));
4446
- }
4447
- setLimit(kind, value, inclusive, message) {
4448
- return new ZodBigInt({
4449
- ...this._def,
4450
- checks: [
4451
- ...this._def.checks,
4452
- {
4453
- kind,
4454
- value,
4455
- inclusive,
4456
- message: errorUtil.toString(message)
4457
- }
4458
- ]
4459
- });
4460
- }
4461
- _addCheck(check) {
4462
- return new ZodBigInt({
4463
- ...this._def,
4464
- checks: [...this._def.checks, check]
4465
- });
4466
- }
4467
- positive(message) {
4468
- return this._addCheck({
4469
- kind: "min",
4470
- value: BigInt(0),
4471
- inclusive: false,
4472
- message: errorUtil.toString(message)
4473
- });
4474
- }
4475
- negative(message) {
4476
- return this._addCheck({
4477
- kind: "max",
4478
- value: BigInt(0),
4479
- inclusive: false,
4480
- message: errorUtil.toString(message)
4481
- });
4482
- }
4483
- nonpositive(message) {
4484
- return this._addCheck({
4485
- kind: "max",
4486
- value: BigInt(0),
4487
- inclusive: true,
4488
- message: errorUtil.toString(message)
4489
- });
4490
- }
4491
- nonnegative(message) {
4492
- return this._addCheck({
4493
- kind: "min",
4494
- value: BigInt(0),
4495
- inclusive: true,
4496
- message: errorUtil.toString(message)
4497
- });
4498
- }
4499
- multipleOf(value, message) {
4500
- return this._addCheck({
4501
- kind: "multipleOf",
4502
- value,
4503
- message: errorUtil.toString(message)
4504
- });
4505
- }
4506
- get minValue() {
4507
- let min2 = null;
4508
- for (const ch of this._def.checks) {
4509
- if (ch.kind === "min") {
4510
- if (min2 === null || ch.value > min2)
4511
- min2 = ch.value;
4512
- }
4513
- }
4514
- return min2;
4515
- }
4516
- get maxValue() {
4517
- let max2 = null;
4518
- for (const ch of this._def.checks) {
4519
- if (ch.kind === "max") {
4520
- if (max2 === null || ch.value < max2)
4521
- max2 = ch.value;
4522
- }
4523
- }
4524
- return max2;
4525
- }
4526
- }
4527
- ZodBigInt.create = (params) => {
4528
- var _a;
4529
- return new ZodBigInt({
4530
- checks: [],
4531
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
4532
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
4533
- ...processCreateParams(params)
4534
- });
4535
- };
4536
- class ZodBoolean extends ZodType {
4537
- _parse(input) {
4538
- if (this._def.coerce) {
4539
- input.data = Boolean(input.data);
4540
- }
4541
- const parsedType = this._getType(input);
4542
- if (parsedType !== ZodParsedType.boolean) {
4543
- const ctx = this._getOrReturnCtx(input);
4544
- addIssueToContext(ctx, {
4545
- code: ZodIssueCode.invalid_type,
4546
- expected: ZodParsedType.boolean,
4547
- received: ctx.parsedType
4548
- });
4549
- return INVALID;
4550
- }
4551
- return OK(input.data);
4552
- }
4553
- }
4554
- ZodBoolean.create = (params) => {
4555
- return new ZodBoolean({
4556
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
4557
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
4558
- ...processCreateParams(params)
4559
- });
4560
- };
4561
- class ZodDate extends ZodType {
4562
- _parse(input) {
4563
- if (this._def.coerce) {
4564
- input.data = new Date(input.data);
4565
- }
4566
- const parsedType = this._getType(input);
4567
- if (parsedType !== ZodParsedType.date) {
4568
- const ctx2 = this._getOrReturnCtx(input);
4569
- addIssueToContext(ctx2, {
4570
- code: ZodIssueCode.invalid_type,
4571
- expected: ZodParsedType.date,
4572
- received: ctx2.parsedType
4573
- });
4574
- return INVALID;
4575
- }
4576
- if (isNaN(input.data.getTime())) {
4577
- const ctx2 = this._getOrReturnCtx(input);
4578
- addIssueToContext(ctx2, {
4579
- code: ZodIssueCode.invalid_date
4580
- });
4581
- return INVALID;
4582
- }
4583
- const status = new ParseStatus();
4584
- let ctx = void 0;
4585
- for (const check of this._def.checks) {
4586
- if (check.kind === "min") {
4587
- if (input.data.getTime() < check.value) {
4588
- ctx = this._getOrReturnCtx(input, ctx);
4589
- addIssueToContext(ctx, {
4590
- code: ZodIssueCode.too_small,
4591
- message: check.message,
4592
- inclusive: true,
4593
- exact: false,
4594
- minimum: check.value,
4595
- type: "date"
4596
- });
4597
- status.dirty();
4598
- }
4599
- } else if (check.kind === "max") {
4600
- if (input.data.getTime() > check.value) {
4601
- ctx = this._getOrReturnCtx(input, ctx);
4602
- addIssueToContext(ctx, {
4603
- code: ZodIssueCode.too_big,
4604
- message: check.message,
4605
- inclusive: true,
4606
- exact: false,
4607
- maximum: check.value,
4608
- type: "date"
4609
- });
4610
- status.dirty();
4611
- }
4612
- } else {
4613
- util.assertNever(check);
4614
- }
4615
- }
4616
- return {
4617
- status: status.value,
4618
- value: new Date(input.data.getTime())
4619
- };
4620
- }
4621
- _addCheck(check) {
4622
- return new ZodDate({
4623
- ...this._def,
4624
- checks: [...this._def.checks, check]
4625
- });
4626
- }
4627
- min(minDate, message) {
4628
- return this._addCheck({
4629
- kind: "min",
4630
- value: minDate.getTime(),
4631
- message: errorUtil.toString(message)
4632
- });
4633
- }
4634
- max(maxDate, message) {
4635
- return this._addCheck({
4636
- kind: "max",
4637
- value: maxDate.getTime(),
4638
- message: errorUtil.toString(message)
4639
- });
4640
- }
4641
- get minDate() {
4642
- let min2 = null;
4643
- for (const ch of this._def.checks) {
4644
- if (ch.kind === "min") {
4645
- if (min2 === null || ch.value > min2)
4646
- min2 = ch.value;
4647
- }
4648
- }
4649
- return min2 != null ? new Date(min2) : null;
4650
- }
4651
- get maxDate() {
4652
- let max2 = null;
4653
- for (const ch of this._def.checks) {
4654
- if (ch.kind === "max") {
4655
- if (max2 === null || ch.value < max2)
4656
- max2 = ch.value;
4657
- }
4658
- }
4659
- return max2 != null ? new Date(max2) : null;
4660
- }
4661
- }
4662
- ZodDate.create = (params) => {
4663
- return new ZodDate({
4664
- checks: [],
4665
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
4666
- typeName: ZodFirstPartyTypeKind.ZodDate,
4667
- ...processCreateParams(params)
4668
- });
4669
- };
4670
- class ZodSymbol extends ZodType {
4671
- _parse(input) {
4672
- const parsedType = this._getType(input);
4673
- if (parsedType !== ZodParsedType.symbol) {
4674
- const ctx = this._getOrReturnCtx(input);
4675
- addIssueToContext(ctx, {
4676
- code: ZodIssueCode.invalid_type,
4677
- expected: ZodParsedType.symbol,
4678
- received: ctx.parsedType
4679
- });
4680
- return INVALID;
4681
- }
4682
- return OK(input.data);
4683
- }
4684
- }
4685
- ZodSymbol.create = (params) => {
4686
- return new ZodSymbol({
4687
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
4688
- ...processCreateParams(params)
4689
- });
4690
- };
4691
- class ZodUndefined extends ZodType {
4692
- _parse(input) {
4693
- const parsedType = this._getType(input);
4694
- if (parsedType !== ZodParsedType.undefined) {
4695
- const ctx = this._getOrReturnCtx(input);
4696
- addIssueToContext(ctx, {
4697
- code: ZodIssueCode.invalid_type,
4698
- expected: ZodParsedType.undefined,
4699
- received: ctx.parsedType
4700
- });
4701
- return INVALID;
4702
- }
4703
- return OK(input.data);
4704
- }
4705
- }
4706
- ZodUndefined.create = (params) => {
4707
- return new ZodUndefined({
4708
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
4709
- ...processCreateParams(params)
4710
- });
4711
- };
4712
- class ZodNull extends ZodType {
4713
- _parse(input) {
4714
- const parsedType = this._getType(input);
4715
- if (parsedType !== ZodParsedType.null) {
4716
- const ctx = this._getOrReturnCtx(input);
4717
- addIssueToContext(ctx, {
4718
- code: ZodIssueCode.invalid_type,
4719
- expected: ZodParsedType.null,
4720
- received: ctx.parsedType
4721
- });
4722
- return INVALID;
4723
- }
4724
- return OK(input.data);
4725
- }
4726
- }
4727
- ZodNull.create = (params) => {
4728
- return new ZodNull({
4729
- typeName: ZodFirstPartyTypeKind.ZodNull,
4730
- ...processCreateParams(params)
4731
- });
4732
- };
4733
- class ZodAny extends ZodType {
4734
- constructor() {
4735
- super(...arguments);
4736
- this._any = true;
4737
- }
4738
- _parse(input) {
4739
- return OK(input.data);
4740
- }
4741
- }
4742
- ZodAny.create = (params) => {
4743
- return new ZodAny({
4744
- typeName: ZodFirstPartyTypeKind.ZodAny,
4745
- ...processCreateParams(params)
4746
- });
4747
- };
4748
- class ZodUnknown extends ZodType {
4749
- constructor() {
4750
- super(...arguments);
4751
- this._unknown = true;
4752
- }
4753
- _parse(input) {
4754
- return OK(input.data);
4755
- }
4756
- }
4757
- ZodUnknown.create = (params) => {
4758
- return new ZodUnknown({
4759
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
4760
- ...processCreateParams(params)
4761
- });
4762
- };
4763
- class ZodNever extends ZodType {
4764
- _parse(input) {
4765
- const ctx = this._getOrReturnCtx(input);
4766
- addIssueToContext(ctx, {
4767
- code: ZodIssueCode.invalid_type,
4768
- expected: ZodParsedType.never,
4769
- received: ctx.parsedType
4770
- });
4771
- return INVALID;
4772
- }
4773
- }
4774
- ZodNever.create = (params) => {
4775
- return new ZodNever({
4776
- typeName: ZodFirstPartyTypeKind.ZodNever,
4777
- ...processCreateParams(params)
4778
- });
4779
- };
4780
- class ZodVoid extends ZodType {
4781
- _parse(input) {
4782
- const parsedType = this._getType(input);
4783
- if (parsedType !== ZodParsedType.undefined) {
4784
- const ctx = this._getOrReturnCtx(input);
4785
- addIssueToContext(ctx, {
4786
- code: ZodIssueCode.invalid_type,
4787
- expected: ZodParsedType.void,
4788
- received: ctx.parsedType
4789
- });
4790
- return INVALID;
4791
- }
4792
- return OK(input.data);
4793
- }
4794
- }
4795
- ZodVoid.create = (params) => {
4796
- return new ZodVoid({
4797
- typeName: ZodFirstPartyTypeKind.ZodVoid,
4798
- ...processCreateParams(params)
4799
- });
4800
- };
4801
- class ZodArray extends ZodType {
4802
- _parse(input) {
4803
- const { ctx, status } = this._processInputParams(input);
4804
- const def = this._def;
4805
- if (ctx.parsedType !== ZodParsedType.array) {
4806
- addIssueToContext(ctx, {
4807
- code: ZodIssueCode.invalid_type,
4808
- expected: ZodParsedType.array,
4809
- received: ctx.parsedType
4810
- });
4811
- return INVALID;
4812
- }
4813
- if (def.exactLength !== null) {
4814
- const tooBig = ctx.data.length > def.exactLength.value;
4815
- const tooSmall = ctx.data.length < def.exactLength.value;
4816
- if (tooBig || tooSmall) {
4817
- addIssueToContext(ctx, {
4818
- code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
4819
- minimum: tooSmall ? def.exactLength.value : void 0,
4820
- maximum: tooBig ? def.exactLength.value : void 0,
4821
- type: "array",
4822
- inclusive: true,
4823
- exact: true,
4824
- message: def.exactLength.message
4825
- });
4826
- status.dirty();
4827
- }
4828
- }
4829
- if (def.minLength !== null) {
4830
- if (ctx.data.length < def.minLength.value) {
4831
- addIssueToContext(ctx, {
4832
- code: ZodIssueCode.too_small,
4833
- minimum: def.minLength.value,
4834
- type: "array",
4835
- inclusive: true,
4836
- exact: false,
4837
- message: def.minLength.message
4838
- });
4839
- status.dirty();
4840
- }
4841
- }
4842
- if (def.maxLength !== null) {
4843
- if (ctx.data.length > def.maxLength.value) {
4844
- addIssueToContext(ctx, {
4845
- code: ZodIssueCode.too_big,
4846
- maximum: def.maxLength.value,
4847
- type: "array",
4848
- inclusive: true,
4849
- exact: false,
4850
- message: def.maxLength.message
4851
- });
4852
- status.dirty();
4853
- }
4854
- }
4855
- if (ctx.common.async) {
4856
- return Promise.all([...ctx.data].map((item, i) => {
4857
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
4858
- })).then((result2) => {
4859
- return ParseStatus.mergeArray(status, result2);
4860
- });
4861
- }
4862
- const result = [...ctx.data].map((item, i) => {
4863
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
4864
- });
4865
- return ParseStatus.mergeArray(status, result);
4866
- }
4867
- get element() {
4868
- return this._def.type;
4869
- }
4870
- min(minLength, message) {
4871
- return new ZodArray({
4872
- ...this._def,
4873
- minLength: { value: minLength, message: errorUtil.toString(message) }
4874
- });
4875
- }
4876
- max(maxLength, message) {
4877
- return new ZodArray({
4878
- ...this._def,
4879
- maxLength: { value: maxLength, message: errorUtil.toString(message) }
4880
- });
4881
- }
4882
- length(len, message) {
4883
- return new ZodArray({
4884
- ...this._def,
4885
- exactLength: { value: len, message: errorUtil.toString(message) }
4886
- });
4887
- }
4888
- nonempty(message) {
4889
- return this.min(1, message);
4890
- }
4891
- }
4892
- ZodArray.create = (schema, params) => {
4893
- return new ZodArray({
4894
- type: schema,
4895
- minLength: null,
4896
- maxLength: null,
4897
- exactLength: null,
4898
- typeName: ZodFirstPartyTypeKind.ZodArray,
4899
- ...processCreateParams(params)
4900
- });
4901
- };
4902
- function deepPartialify(schema) {
4903
- if (schema instanceof ZodObject) {
4904
- const newShape = {};
4905
- for (const key in schema.shape) {
4906
- const fieldSchema = schema.shape[key];
4907
- newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
4908
- }
4909
- return new ZodObject({
4910
- ...schema._def,
4911
- shape: () => newShape
4912
- });
4913
- } else if (schema instanceof ZodArray) {
4914
- return new ZodArray({
4915
- ...schema._def,
4916
- type: deepPartialify(schema.element)
4917
- });
4918
- } else if (schema instanceof ZodOptional) {
4919
- return ZodOptional.create(deepPartialify(schema.unwrap()));
4920
- } else if (schema instanceof ZodNullable) {
4921
- return ZodNullable.create(deepPartialify(schema.unwrap()));
4922
- } else if (schema instanceof ZodTuple) {
4923
- return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
4924
- } else {
4925
- return schema;
4926
- }
4927
- }
4928
- class ZodObject extends ZodType {
4929
- constructor() {
4930
- super(...arguments);
4931
- this._cached = null;
4932
- this.nonstrict = this.passthrough;
4933
- this.augment = this.extend;
4934
- }
4935
- _getCached() {
4936
- if (this._cached !== null)
4937
- return this._cached;
4938
- const shape = this._def.shape();
4939
- const keys2 = util.objectKeys(shape);
4940
- return this._cached = { shape, keys: keys2 };
4941
- }
4942
- _parse(input) {
4943
- const parsedType = this._getType(input);
4944
- if (parsedType !== ZodParsedType.object) {
4945
- const ctx2 = this._getOrReturnCtx(input);
4946
- addIssueToContext(ctx2, {
4947
- code: ZodIssueCode.invalid_type,
4948
- expected: ZodParsedType.object,
4949
- received: ctx2.parsedType
4950
- });
4951
- return INVALID;
4952
- }
4953
- const { status, ctx } = this._processInputParams(input);
4954
- const { shape, keys: shapeKeys } = this._getCached();
4955
- const extraKeys = [];
4956
- if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
4957
- for (const key in ctx.data) {
4958
- if (!shapeKeys.includes(key)) {
4959
- extraKeys.push(key);
4960
- }
4961
- }
4962
- }
4963
- const pairs = [];
4964
- for (const key of shapeKeys) {
4965
- const keyValidator = shape[key];
4966
- const value = ctx.data[key];
4967
- pairs.push({
4968
- key: { status: "valid", value: key },
4969
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
4970
- alwaysSet: key in ctx.data
4971
- });
4972
- }
4973
- if (this._def.catchall instanceof ZodNever) {
4974
- const unknownKeys = this._def.unknownKeys;
4975
- if (unknownKeys === "passthrough") {
4976
- for (const key of extraKeys) {
4977
- pairs.push({
4978
- key: { status: "valid", value: key },
4979
- value: { status: "valid", value: ctx.data[key] }
4980
- });
4981
- }
4982
- } else if (unknownKeys === "strict") {
4983
- if (extraKeys.length > 0) {
4984
- addIssueToContext(ctx, {
4985
- code: ZodIssueCode.unrecognized_keys,
4986
- keys: extraKeys
4987
- });
4988
- status.dirty();
4989
- }
4990
- } else if (unknownKeys === "strip") ;
4991
- else {
4992
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
4993
- }
4994
- } else {
4995
- const catchall = this._def.catchall;
4996
- for (const key of extraKeys) {
4997
- const value = ctx.data[key];
4998
- pairs.push({
4999
- key: { status: "valid", value: key },
5000
- value: catchall._parse(
5001
- new ParseInputLazyPath(ctx, value, ctx.path, key)
5002
- //, ctx.child(key), value, getParsedType(value)
5003
- ),
5004
- alwaysSet: key in ctx.data
5005
- });
5006
- }
5007
- }
5008
- if (ctx.common.async) {
5009
- return Promise.resolve().then(async () => {
5010
- const syncPairs = [];
5011
- for (const pair of pairs) {
5012
- const key = await pair.key;
5013
- const value = await pair.value;
5014
- syncPairs.push({
5015
- key,
5016
- value,
5017
- alwaysSet: pair.alwaysSet
5018
- });
5019
- }
5020
- return syncPairs;
5021
- }).then((syncPairs) => {
5022
- return ParseStatus.mergeObjectSync(status, syncPairs);
5023
- });
5024
- } else {
5025
- return ParseStatus.mergeObjectSync(status, pairs);
5026
- }
5027
- }
5028
- get shape() {
5029
- return this._def.shape();
5030
- }
5031
- strict(message) {
5032
- errorUtil.errToObj;
5033
- return new ZodObject({
5034
- ...this._def,
5035
- unknownKeys: "strict",
5036
- ...message !== void 0 ? {
5037
- errorMap: (issue, ctx) => {
5038
- var _a, _b, _c, _d;
5039
- const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
5040
- if (issue.code === "unrecognized_keys")
5041
- return {
5042
- message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
5043
- };
5044
- return {
5045
- message: defaultError
5046
- };
5047
- }
5048
- } : {}
5049
- });
5050
- }
5051
- strip() {
5052
- return new ZodObject({
5053
- ...this._def,
5054
- unknownKeys: "strip"
5055
- });
5056
- }
5057
- passthrough() {
5058
- return new ZodObject({
5059
- ...this._def,
5060
- unknownKeys: "passthrough"
5061
- });
5062
- }
5063
- // const AugmentFactory =
5064
- // <Def extends ZodObjectDef>(def: Def) =>
5065
- // <Augmentation extends ZodRawShape>(
5066
- // augmentation: Augmentation
5067
- // ): ZodObject<
5068
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
5069
- // Def["unknownKeys"],
5070
- // Def["catchall"]
5071
- // > => {
5072
- // return new ZodObject({
5073
- // ...def,
5074
- // shape: () => ({
5075
- // ...def.shape(),
5076
- // ...augmentation,
5077
- // }),
5078
- // }) as any;
5079
- // };
5080
- extend(augmentation) {
5081
- return new ZodObject({
5082
- ...this._def,
5083
- shape: () => ({
5084
- ...this._def.shape(),
5085
- ...augmentation
5086
- })
5087
- });
5088
- }
5089
- /**
5090
- * Prior to zod@1.0.12 there was a bug in the
5091
- * inferred type of merged objects. Please
5092
- * upgrade if you are experiencing issues.
5093
- */
5094
- merge(merging) {
5095
- const merged = new ZodObject({
5096
- unknownKeys: merging._def.unknownKeys,
5097
- catchall: merging._def.catchall,
5098
- shape: () => ({
5099
- ...this._def.shape(),
5100
- ...merging._def.shape()
5101
- }),
5102
- typeName: ZodFirstPartyTypeKind.ZodObject
5103
- });
5104
- return merged;
5105
- }
5106
- // merge<
5107
- // Incoming extends AnyZodObject,
5108
- // Augmentation extends Incoming["shape"],
5109
- // NewOutput extends {
5110
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
5111
- // ? Augmentation[k]["_output"]
5112
- // : k extends keyof Output
5113
- // ? Output[k]
5114
- // : never;
5115
- // },
5116
- // NewInput extends {
5117
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
5118
- // ? Augmentation[k]["_input"]
5119
- // : k extends keyof Input
5120
- // ? Input[k]
5121
- // : never;
5122
- // }
5123
- // >(
5124
- // merging: Incoming
5125
- // ): ZodObject<
5126
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
5127
- // Incoming["_def"]["unknownKeys"],
5128
- // Incoming["_def"]["catchall"],
5129
- // NewOutput,
5130
- // NewInput
5131
- // > {
5132
- // const merged: any = new ZodObject({
5133
- // unknownKeys: merging._def.unknownKeys,
5134
- // catchall: merging._def.catchall,
5135
- // shape: () =>
5136
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
5137
- // typeName: ZodFirstPartyTypeKind.ZodObject,
5138
- // }) as any;
5139
- // return merged;
5140
- // }
5141
- setKey(key, schema) {
5142
- return this.augment({ [key]: schema });
5143
- }
5144
- // merge<Incoming extends AnyZodObject>(
5145
- // merging: Incoming
5146
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
5147
- // ZodObject<
5148
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
5149
- // Incoming["_def"]["unknownKeys"],
5150
- // Incoming["_def"]["catchall"]
5151
- // > {
5152
- // // const mergedShape = objectUtil.mergeShapes(
5153
- // // this._def.shape(),
5154
- // // merging._def.shape()
5155
- // // );
5156
- // const merged: any = new ZodObject({
5157
- // unknownKeys: merging._def.unknownKeys,
5158
- // catchall: merging._def.catchall,
5159
- // shape: () =>
5160
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
5161
- // typeName: ZodFirstPartyTypeKind.ZodObject,
5162
- // }) as any;
5163
- // return merged;
5164
- // }
5165
- catchall(index) {
5166
- return new ZodObject({
5167
- ...this._def,
5168
- catchall: index
5169
- });
5170
- }
5171
- pick(mask) {
5172
- const shape = {};
5173
- util.objectKeys(mask).forEach((key) => {
5174
- if (mask[key] && this.shape[key]) {
5175
- shape[key] = this.shape[key];
5176
- }
5177
- });
5178
- return new ZodObject({
5179
- ...this._def,
5180
- shape: () => shape
5181
- });
5182
- }
5183
- omit(mask) {
5184
- const shape = {};
5185
- util.objectKeys(this.shape).forEach((key) => {
5186
- if (!mask[key]) {
5187
- shape[key] = this.shape[key];
5188
- }
5189
- });
5190
- return new ZodObject({
5191
- ...this._def,
5192
- shape: () => shape
5193
- });
5194
- }
5195
- /**
5196
- * @deprecated
5197
- */
5198
- deepPartial() {
5199
- return deepPartialify(this);
5200
- }
5201
- partial(mask) {
5202
- const newShape = {};
5203
- util.objectKeys(this.shape).forEach((key) => {
5204
- const fieldSchema = this.shape[key];
5205
- if (mask && !mask[key]) {
5206
- newShape[key] = fieldSchema;
5207
- } else {
5208
- newShape[key] = fieldSchema.optional();
5209
- }
5210
- });
5211
- return new ZodObject({
5212
- ...this._def,
5213
- shape: () => newShape
5214
- });
5215
- }
5216
- required(mask) {
5217
- const newShape = {};
5218
- util.objectKeys(this.shape).forEach((key) => {
5219
- if (mask && !mask[key]) {
5220
- newShape[key] = this.shape[key];
5221
- } else {
5222
- const fieldSchema = this.shape[key];
5223
- let newField = fieldSchema;
5224
- while (newField instanceof ZodOptional) {
5225
- newField = newField._def.innerType;
5226
- }
5227
- newShape[key] = newField;
5228
- }
5229
- });
5230
- return new ZodObject({
5231
- ...this._def,
5232
- shape: () => newShape
5233
- });
5234
- }
5235
- keyof() {
5236
- return createZodEnum(util.objectKeys(this.shape));
5237
- }
5238
- }
5239
- ZodObject.create = (shape, params) => {
5240
- return new ZodObject({
5241
- shape: () => shape,
5242
- unknownKeys: "strip",
5243
- catchall: ZodNever.create(),
5244
- typeName: ZodFirstPartyTypeKind.ZodObject,
5245
- ...processCreateParams(params)
5246
- });
5247
- };
5248
- ZodObject.strictCreate = (shape, params) => {
5249
- return new ZodObject({
5250
- shape: () => shape,
5251
- unknownKeys: "strict",
5252
- catchall: ZodNever.create(),
5253
- typeName: ZodFirstPartyTypeKind.ZodObject,
5254
- ...processCreateParams(params)
5255
- });
5256
- };
5257
- ZodObject.lazycreate = (shape, params) => {
5258
- return new ZodObject({
5259
- shape,
5260
- unknownKeys: "strip",
5261
- catchall: ZodNever.create(),
5262
- typeName: ZodFirstPartyTypeKind.ZodObject,
5263
- ...processCreateParams(params)
5264
- });
5265
- };
5266
- class ZodUnion extends ZodType {
5267
- _parse(input) {
5268
- const { ctx } = this._processInputParams(input);
5269
- const options = this._def.options;
5270
- function handleResults(results) {
5271
- for (const result of results) {
5272
- if (result.result.status === "valid") {
5273
- return result.result;
5274
- }
5275
- }
5276
- for (const result of results) {
5277
- if (result.result.status === "dirty") {
5278
- ctx.common.issues.push(...result.ctx.common.issues);
5279
- return result.result;
5280
- }
5281
- }
5282
- const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
5283
- addIssueToContext(ctx, {
5284
- code: ZodIssueCode.invalid_union,
5285
- unionErrors
5286
- });
5287
- return INVALID;
5288
- }
5289
- if (ctx.common.async) {
5290
- return Promise.all(options.map(async (option) => {
5291
- const childCtx = {
5292
- ...ctx,
5293
- common: {
5294
- ...ctx.common,
5295
- issues: []
5296
- },
5297
- parent: null
5298
- };
5299
- return {
5300
- result: await option._parseAsync({
5301
- data: ctx.data,
5302
- path: ctx.path,
5303
- parent: childCtx
5304
- }),
5305
- ctx: childCtx
5306
- };
5307
- })).then(handleResults);
5308
- } else {
5309
- let dirty = void 0;
5310
- const issues = [];
5311
- for (const option of options) {
5312
- const childCtx = {
5313
- ...ctx,
5314
- common: {
5315
- ...ctx.common,
5316
- issues: []
5317
- },
5318
- parent: null
5319
- };
5320
- const result = option._parseSync({
5321
- data: ctx.data,
5322
- path: ctx.path,
5323
- parent: childCtx
5324
- });
5325
- if (result.status === "valid") {
5326
- return result;
5327
- } else if (result.status === "dirty" && !dirty) {
5328
- dirty = { result, ctx: childCtx };
5329
- }
5330
- if (childCtx.common.issues.length) {
5331
- issues.push(childCtx.common.issues);
5332
- }
5333
- }
5334
- if (dirty) {
5335
- ctx.common.issues.push(...dirty.ctx.common.issues);
5336
- return dirty.result;
5337
- }
5338
- const unionErrors = issues.map((issues2) => new ZodError(issues2));
5339
- addIssueToContext(ctx, {
5340
- code: ZodIssueCode.invalid_union,
5341
- unionErrors
5342
- });
5343
- return INVALID;
5344
- }
5345
- }
5346
- get options() {
5347
- return this._def.options;
5348
- }
5349
- }
5350
- ZodUnion.create = (types, params) => {
5351
- return new ZodUnion({
5352
- options: types,
5353
- typeName: ZodFirstPartyTypeKind.ZodUnion,
5354
- ...processCreateParams(params)
5355
- });
5356
- };
5357
- const getDiscriminator = (type) => {
5358
- if (type instanceof ZodLazy) {
5359
- return getDiscriminator(type.schema);
5360
- } else if (type instanceof ZodEffects) {
5361
- return getDiscriminator(type.innerType());
5362
- } else if (type instanceof ZodLiteral) {
5363
- return [type.value];
5364
- } else if (type instanceof ZodEnum) {
5365
- return type.options;
5366
- } else if (type instanceof ZodNativeEnum) {
5367
- return util.objectValues(type.enum);
5368
- } else if (type instanceof ZodDefault) {
5369
- return getDiscriminator(type._def.innerType);
5370
- } else if (type instanceof ZodUndefined) {
5371
- return [void 0];
5372
- } else if (type instanceof ZodNull) {
5373
- return [null];
5374
- } else if (type instanceof ZodOptional) {
5375
- return [void 0, ...getDiscriminator(type.unwrap())];
5376
- } else if (type instanceof ZodNullable) {
5377
- return [null, ...getDiscriminator(type.unwrap())];
5378
- } else if (type instanceof ZodBranded) {
5379
- return getDiscriminator(type.unwrap());
5380
- } else if (type instanceof ZodReadonly) {
5381
- return getDiscriminator(type.unwrap());
5382
- } else if (type instanceof ZodCatch) {
5383
- return getDiscriminator(type._def.innerType);
5384
- } else {
5385
- return [];
5386
- }
5387
- };
5388
- class ZodDiscriminatedUnion extends ZodType {
5389
- _parse(input) {
5390
- const { ctx } = this._processInputParams(input);
5391
- if (ctx.parsedType !== ZodParsedType.object) {
5392
- addIssueToContext(ctx, {
5393
- code: ZodIssueCode.invalid_type,
5394
- expected: ZodParsedType.object,
5395
- received: ctx.parsedType
5396
- });
5397
- return INVALID;
5398
- }
5399
- const discriminator = this.discriminator;
5400
- const discriminatorValue = ctx.data[discriminator];
5401
- const option = this.optionsMap.get(discriminatorValue);
5402
- if (!option) {
5403
- addIssueToContext(ctx, {
5404
- code: ZodIssueCode.invalid_union_discriminator,
5405
- options: Array.from(this.optionsMap.keys()),
5406
- path: [discriminator]
5407
- });
5408
- return INVALID;
5409
- }
5410
- if (ctx.common.async) {
5411
- return option._parseAsync({
5412
- data: ctx.data,
5413
- path: ctx.path,
5414
- parent: ctx
5415
- });
5416
- } else {
5417
- return option._parseSync({
5418
- data: ctx.data,
5419
- path: ctx.path,
5420
- parent: ctx
5421
- });
5422
- }
5423
- }
5424
- get discriminator() {
5425
- return this._def.discriminator;
5426
- }
5427
- get options() {
5428
- return this._def.options;
5429
- }
5430
- get optionsMap() {
5431
- return this._def.optionsMap;
5432
- }
5433
- /**
5434
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
5435
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
5436
- * have a different value for each object in the union.
5437
- * @param discriminator the name of the discriminator property
5438
- * @param types an array of object schemas
5439
- * @param params
5440
- */
5441
- static create(discriminator, options, params) {
5442
- const optionsMap = /* @__PURE__ */ new Map();
5443
- for (const type of options) {
5444
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
5445
- if (!discriminatorValues.length) {
5446
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
5447
- }
5448
- for (const value of discriminatorValues) {
5449
- if (optionsMap.has(value)) {
5450
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
5451
- }
5452
- optionsMap.set(value, type);
5453
- }
5454
- }
5455
- return new ZodDiscriminatedUnion({
5456
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
5457
- discriminator,
5458
- options,
5459
- optionsMap,
5460
- ...processCreateParams(params)
5461
- });
5462
- }
5463
- }
5464
- function mergeValues(a, b) {
5465
- const aType = getParsedType(a);
5466
- const bType = getParsedType(b);
5467
- if (a === b) {
5468
- return { valid: true, data: a };
5469
- } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
5470
- const bKeys = util.objectKeys(b);
5471
- const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
5472
- const newObj = { ...a, ...b };
5473
- for (const key of sharedKeys) {
5474
- const sharedValue = mergeValues(a[key], b[key]);
5475
- if (!sharedValue.valid) {
5476
- return { valid: false };
5477
- }
5478
- newObj[key] = sharedValue.data;
5479
- }
5480
- return { valid: true, data: newObj };
5481
- } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
5482
- if (a.length !== b.length) {
5483
- return { valid: false };
5484
- }
5485
- const newArray = [];
5486
- for (let index = 0; index < a.length; index++) {
5487
- const itemA = a[index];
5488
- const itemB = b[index];
5489
- const sharedValue = mergeValues(itemA, itemB);
5490
- if (!sharedValue.valid) {
5491
- return { valid: false };
5492
- }
5493
- newArray.push(sharedValue.data);
5494
- }
5495
- return { valid: true, data: newArray };
5496
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
5497
- return { valid: true, data: a };
5498
- } else {
5499
- return { valid: false };
5500
- }
5501
- }
5502
- class ZodIntersection extends ZodType {
5503
- _parse(input) {
5504
- const { status, ctx } = this._processInputParams(input);
5505
- const handleParsed = (parsedLeft, parsedRight) => {
5506
- if (isAborted(parsedLeft) || isAborted(parsedRight)) {
5507
- return INVALID;
5508
- }
5509
- const merged = mergeValues(parsedLeft.value, parsedRight.value);
5510
- if (!merged.valid) {
5511
- addIssueToContext(ctx, {
5512
- code: ZodIssueCode.invalid_intersection_types
5513
- });
5514
- return INVALID;
5515
- }
5516
- if (isDirty(parsedLeft) || isDirty(parsedRight)) {
5517
- status.dirty();
5518
- }
5519
- return { status: status.value, value: merged.data };
5520
- };
5521
- if (ctx.common.async) {
5522
- return Promise.all([
5523
- this._def.left._parseAsync({
5524
- data: ctx.data,
5525
- path: ctx.path,
5526
- parent: ctx
5527
- }),
5528
- this._def.right._parseAsync({
5529
- data: ctx.data,
5530
- path: ctx.path,
5531
- parent: ctx
5532
- })
5533
- ]).then(([left, right]) => handleParsed(left, right));
5534
- } else {
5535
- return handleParsed(this._def.left._parseSync({
5536
- data: ctx.data,
5537
- path: ctx.path,
5538
- parent: ctx
5539
- }), this._def.right._parseSync({
5540
- data: ctx.data,
5541
- path: ctx.path,
5542
- parent: ctx
5543
- }));
5544
- }
5545
- }
5546
- }
5547
- ZodIntersection.create = (left, right, params) => {
5548
- return new ZodIntersection({
5549
- left,
5550
- right,
5551
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
5552
- ...processCreateParams(params)
5553
- });
5554
- };
5555
- class ZodTuple extends ZodType {
5556
- _parse(input) {
5557
- const { status, ctx } = this._processInputParams(input);
5558
- if (ctx.parsedType !== ZodParsedType.array) {
5559
- addIssueToContext(ctx, {
5560
- code: ZodIssueCode.invalid_type,
5561
- expected: ZodParsedType.array,
5562
- received: ctx.parsedType
5563
- });
5564
- return INVALID;
5565
- }
5566
- if (ctx.data.length < this._def.items.length) {
5567
- addIssueToContext(ctx, {
5568
- code: ZodIssueCode.too_small,
5569
- minimum: this._def.items.length,
5570
- inclusive: true,
5571
- exact: false,
5572
- type: "array"
5573
- });
5574
- return INVALID;
5575
- }
5576
- const rest = this._def.rest;
5577
- if (!rest && ctx.data.length > this._def.items.length) {
5578
- addIssueToContext(ctx, {
5579
- code: ZodIssueCode.too_big,
5580
- maximum: this._def.items.length,
5581
- inclusive: true,
5582
- exact: false,
5583
- type: "array"
5584
- });
5585
- status.dirty();
5586
- }
5587
- const items = [...ctx.data].map((item, itemIndex) => {
5588
- const schema = this._def.items[itemIndex] || this._def.rest;
5589
- if (!schema)
5590
- return null;
5591
- return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
5592
- }).filter((x) => !!x);
5593
- if (ctx.common.async) {
5594
- return Promise.all(items).then((results) => {
5595
- return ParseStatus.mergeArray(status, results);
5596
- });
5597
- } else {
5598
- return ParseStatus.mergeArray(status, items);
5599
- }
5600
- }
5601
- get items() {
5602
- return this._def.items;
5603
- }
5604
- rest(rest) {
5605
- return new ZodTuple({
5606
- ...this._def,
5607
- rest
5608
- });
5609
- }
5610
- }
5611
- ZodTuple.create = (schemas, params) => {
5612
- if (!Array.isArray(schemas)) {
5613
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
5614
- }
5615
- return new ZodTuple({
5616
- items: schemas,
5617
- typeName: ZodFirstPartyTypeKind.ZodTuple,
5618
- rest: null,
5619
- ...processCreateParams(params)
5620
- });
5621
- };
5622
- class ZodRecord extends ZodType {
5623
- get keySchema() {
5624
- return this._def.keyType;
5625
- }
5626
- get valueSchema() {
5627
- return this._def.valueType;
5628
- }
5629
- _parse(input) {
5630
- const { status, ctx } = this._processInputParams(input);
5631
- if (ctx.parsedType !== ZodParsedType.object) {
5632
- addIssueToContext(ctx, {
5633
- code: ZodIssueCode.invalid_type,
5634
- expected: ZodParsedType.object,
5635
- received: ctx.parsedType
5636
- });
5637
- return INVALID;
5638
- }
5639
- const pairs = [];
5640
- const keyType = this._def.keyType;
5641
- const valueType = this._def.valueType;
5642
- for (const key in ctx.data) {
5643
- pairs.push({
5644
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
5645
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
5646
- alwaysSet: key in ctx.data
5647
- });
5648
- }
5649
- if (ctx.common.async) {
5650
- return ParseStatus.mergeObjectAsync(status, pairs);
5651
- } else {
5652
- return ParseStatus.mergeObjectSync(status, pairs);
5653
- }
5654
- }
5655
- get element() {
5656
- return this._def.valueType;
5657
- }
5658
- static create(first, second, third) {
5659
- if (second instanceof ZodType) {
5660
- return new ZodRecord({
5661
- keyType: first,
5662
- valueType: second,
5663
- typeName: ZodFirstPartyTypeKind.ZodRecord,
5664
- ...processCreateParams(third)
5665
- });
5666
- }
5667
- return new ZodRecord({
5668
- keyType: ZodString.create(),
5669
- valueType: first,
5670
- typeName: ZodFirstPartyTypeKind.ZodRecord,
5671
- ...processCreateParams(second)
5672
- });
5673
- }
5674
- }
5675
- class ZodMap extends ZodType {
5676
- get keySchema() {
5677
- return this._def.keyType;
5678
- }
5679
- get valueSchema() {
5680
- return this._def.valueType;
5681
- }
5682
- _parse(input) {
5683
- const { status, ctx } = this._processInputParams(input);
5684
- if (ctx.parsedType !== ZodParsedType.map) {
5685
- addIssueToContext(ctx, {
5686
- code: ZodIssueCode.invalid_type,
5687
- expected: ZodParsedType.map,
5688
- received: ctx.parsedType
5689
- });
5690
- return INVALID;
5691
- }
5692
- const keyType = this._def.keyType;
5693
- const valueType = this._def.valueType;
5694
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
5695
- return {
5696
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
5697
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
5698
- };
5699
- });
5700
- if (ctx.common.async) {
5701
- const finalMap = /* @__PURE__ */ new Map();
5702
- return Promise.resolve().then(async () => {
5703
- for (const pair of pairs) {
5704
- const key = await pair.key;
5705
- const value = await pair.value;
5706
- if (key.status === "aborted" || value.status === "aborted") {
5707
- return INVALID;
5708
- }
5709
- if (key.status === "dirty" || value.status === "dirty") {
5710
- status.dirty();
5711
- }
5712
- finalMap.set(key.value, value.value);
5713
- }
5714
- return { status: status.value, value: finalMap };
5715
- });
5716
- } else {
5717
- const finalMap = /* @__PURE__ */ new Map();
5718
- for (const pair of pairs) {
5719
- const key = pair.key;
5720
- const value = pair.value;
5721
- if (key.status === "aborted" || value.status === "aborted") {
5722
- return INVALID;
5723
- }
5724
- if (key.status === "dirty" || value.status === "dirty") {
5725
- status.dirty();
5726
- }
5727
- finalMap.set(key.value, value.value);
5728
- }
5729
- return { status: status.value, value: finalMap };
5730
- }
5731
- }
5732
- }
5733
- ZodMap.create = (keyType, valueType, params) => {
5734
- return new ZodMap({
5735
- valueType,
5736
- keyType,
5737
- typeName: ZodFirstPartyTypeKind.ZodMap,
5738
- ...processCreateParams(params)
5739
- });
5740
- };
5741
- class ZodSet extends ZodType {
5742
- _parse(input) {
5743
- const { status, ctx } = this._processInputParams(input);
5744
- if (ctx.parsedType !== ZodParsedType.set) {
5745
- addIssueToContext(ctx, {
5746
- code: ZodIssueCode.invalid_type,
5747
- expected: ZodParsedType.set,
5748
- received: ctx.parsedType
5749
- });
5750
- return INVALID;
5751
- }
5752
- const def = this._def;
5753
- if (def.minSize !== null) {
5754
- if (ctx.data.size < def.minSize.value) {
5755
- addIssueToContext(ctx, {
5756
- code: ZodIssueCode.too_small,
5757
- minimum: def.minSize.value,
5758
- type: "set",
5759
- inclusive: true,
5760
- exact: false,
5761
- message: def.minSize.message
5762
- });
5763
- status.dirty();
5764
- }
5765
- }
5766
- if (def.maxSize !== null) {
5767
- if (ctx.data.size > def.maxSize.value) {
5768
- addIssueToContext(ctx, {
5769
- code: ZodIssueCode.too_big,
5770
- maximum: def.maxSize.value,
5771
- type: "set",
5772
- inclusive: true,
5773
- exact: false,
5774
- message: def.maxSize.message
5775
- });
5776
- status.dirty();
5777
- }
5778
- }
5779
- const valueType = this._def.valueType;
5780
- function finalizeSet(elements2) {
5781
- const parsedSet = /* @__PURE__ */ new Set();
5782
- for (const element of elements2) {
5783
- if (element.status === "aborted")
5784
- return INVALID;
5785
- if (element.status === "dirty")
5786
- status.dirty();
5787
- parsedSet.add(element.value);
5788
- }
5789
- return { status: status.value, value: parsedSet };
5790
- }
5791
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
5792
- if (ctx.common.async) {
5793
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
5794
- } else {
5795
- return finalizeSet(elements);
5796
- }
5797
- }
5798
- min(minSize, message) {
5799
- return new ZodSet({
5800
- ...this._def,
5801
- minSize: { value: minSize, message: errorUtil.toString(message) }
5802
- });
5803
- }
5804
- max(maxSize, message) {
5805
- return new ZodSet({
5806
- ...this._def,
5807
- maxSize: { value: maxSize, message: errorUtil.toString(message) }
5808
- });
5809
- }
5810
- size(size, message) {
5811
- return this.min(size, message).max(size, message);
5812
- }
5813
- nonempty(message) {
5814
- return this.min(1, message);
5815
- }
5816
- }
5817
- ZodSet.create = (valueType, params) => {
5818
- return new ZodSet({
5819
- valueType,
5820
- minSize: null,
5821
- maxSize: null,
5822
- typeName: ZodFirstPartyTypeKind.ZodSet,
5823
- ...processCreateParams(params)
5824
- });
5825
- };
5826
- class ZodFunction extends ZodType {
5827
- constructor() {
5828
- super(...arguments);
5829
- this.validate = this.implement;
5830
- }
5831
- _parse(input) {
5832
- const { ctx } = this._processInputParams(input);
5833
- if (ctx.parsedType !== ZodParsedType.function) {
5834
- addIssueToContext(ctx, {
5835
- code: ZodIssueCode.invalid_type,
5836
- expected: ZodParsedType.function,
5837
- received: ctx.parsedType
5838
- });
5839
- return INVALID;
5840
- }
5841
- function makeArgsIssue(args, error) {
5842
- return makeIssue({
5843
- data: args,
5844
- path: ctx.path,
5845
- errorMaps: [
5846
- ctx.common.contextualErrorMap,
5847
- ctx.schemaErrorMap,
5848
- getErrorMap(),
5849
- errorMap
5850
- ].filter((x) => !!x),
5851
- issueData: {
5852
- code: ZodIssueCode.invalid_arguments,
5853
- argumentsError: error
5854
- }
5855
- });
5856
- }
5857
- function makeReturnsIssue(returns, error) {
5858
- return makeIssue({
5859
- data: returns,
5860
- path: ctx.path,
5861
- errorMaps: [
5862
- ctx.common.contextualErrorMap,
5863
- ctx.schemaErrorMap,
5864
- getErrorMap(),
5865
- errorMap
5866
- ].filter((x) => !!x),
5867
- issueData: {
5868
- code: ZodIssueCode.invalid_return_type,
5869
- returnTypeError: error
5870
- }
5871
- });
5872
- }
5873
- const params = { errorMap: ctx.common.contextualErrorMap };
5874
- const fn = ctx.data;
5875
- if (this._def.returns instanceof ZodPromise) {
5876
- const me = this;
5877
- return OK(async function(...args) {
5878
- const error = new ZodError([]);
5879
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
5880
- error.addIssue(makeArgsIssue(args, e));
5881
- throw error;
5882
- });
5883
- const result = await Reflect.apply(fn, this, parsedArgs);
5884
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
5885
- error.addIssue(makeReturnsIssue(result, e));
5886
- throw error;
5887
- });
5888
- return parsedReturns;
5889
- });
5890
- } else {
5891
- const me = this;
5892
- return OK(function(...args) {
5893
- const parsedArgs = me._def.args.safeParse(args, params);
5894
- if (!parsedArgs.success) {
5895
- throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
5896
- }
5897
- const result = Reflect.apply(fn, this, parsedArgs.data);
5898
- const parsedReturns = me._def.returns.safeParse(result, params);
5899
- if (!parsedReturns.success) {
5900
- throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
5901
- }
5902
- return parsedReturns.data;
5903
- });
5904
- }
5905
- }
5906
- parameters() {
5907
- return this._def.args;
5908
- }
5909
- returnType() {
5910
- return this._def.returns;
5911
- }
5912
- args(...items) {
5913
- return new ZodFunction({
5914
- ...this._def,
5915
- args: ZodTuple.create(items).rest(ZodUnknown.create())
5916
- });
5917
- }
5918
- returns(returnType) {
5919
- return new ZodFunction({
5920
- ...this._def,
5921
- returns: returnType
5922
- });
5923
- }
5924
- implement(func) {
5925
- const validatedFunc = this.parse(func);
5926
- return validatedFunc;
5927
- }
5928
- strictImplement(func) {
5929
- const validatedFunc = this.parse(func);
5930
- return validatedFunc;
5931
- }
5932
- static create(args, returns, params) {
5933
- return new ZodFunction({
5934
- args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
5935
- returns: returns || ZodUnknown.create(),
5936
- typeName: ZodFirstPartyTypeKind.ZodFunction,
5937
- ...processCreateParams(params)
5938
- });
5939
- }
5940
- }
5941
- class ZodLazy extends ZodType {
5942
- get schema() {
5943
- return this._def.getter();
5944
- }
5945
- _parse(input) {
5946
- const { ctx } = this._processInputParams(input);
5947
- const lazySchema = this._def.getter();
5948
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
5949
- }
5950
- }
5951
- ZodLazy.create = (getter, params) => {
5952
- return new ZodLazy({
5953
- getter,
5954
- typeName: ZodFirstPartyTypeKind.ZodLazy,
5955
- ...processCreateParams(params)
5956
- });
5957
- };
5958
- class ZodLiteral extends ZodType {
5959
- _parse(input) {
5960
- if (input.data !== this._def.value) {
5961
- const ctx = this._getOrReturnCtx(input);
5962
- addIssueToContext(ctx, {
5963
- received: ctx.data,
5964
- code: ZodIssueCode.invalid_literal,
5965
- expected: this._def.value
5966
- });
5967
- return INVALID;
5968
- }
5969
- return { status: "valid", value: input.data };
5970
- }
5971
- get value() {
5972
- return this._def.value;
5973
- }
5974
- }
5975
- ZodLiteral.create = (value, params) => {
5976
- return new ZodLiteral({
5977
- value,
5978
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
5979
- ...processCreateParams(params)
5980
- });
5981
- };
5982
- function createZodEnum(values, params) {
5983
- return new ZodEnum({
5984
- values,
5985
- typeName: ZodFirstPartyTypeKind.ZodEnum,
5986
- ...processCreateParams(params)
5987
- });
5988
- }
5989
- class ZodEnum extends ZodType {
5990
- constructor() {
5991
- super(...arguments);
5992
- _ZodEnum_cache.set(this, void 0);
5993
- }
5994
- _parse(input) {
5995
- if (typeof input.data !== "string") {
5996
- const ctx = this._getOrReturnCtx(input);
5997
- const expectedValues = this._def.values;
5998
- addIssueToContext(ctx, {
5999
- expected: util.joinValues(expectedValues),
6000
- received: ctx.parsedType,
6001
- code: ZodIssueCode.invalid_type
6002
- });
6003
- return INVALID;
6004
- }
6005
- if (!__classPrivateFieldGet(this, _ZodEnum_cache)) {
6006
- __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values));
6007
- }
6008
- if (!__classPrivateFieldGet(this, _ZodEnum_cache).has(input.data)) {
6009
- const ctx = this._getOrReturnCtx(input);
6010
- const expectedValues = this._def.values;
6011
- addIssueToContext(ctx, {
6012
- received: ctx.data,
6013
- code: ZodIssueCode.invalid_enum_value,
6014
- options: expectedValues
6015
- });
6016
- return INVALID;
6017
- }
6018
- return OK(input.data);
6019
- }
6020
- get options() {
6021
- return this._def.values;
6022
- }
6023
- get enum() {
6024
- const enumValues = {};
6025
- for (const val of this._def.values) {
6026
- enumValues[val] = val;
6027
- }
6028
- return enumValues;
6029
- }
6030
- get Values() {
6031
- const enumValues = {};
6032
- for (const val of this._def.values) {
6033
- enumValues[val] = val;
6034
- }
6035
- return enumValues;
6036
- }
6037
- get Enum() {
6038
- const enumValues = {};
6039
- for (const val of this._def.values) {
6040
- enumValues[val] = val;
6041
- }
6042
- return enumValues;
6043
- }
6044
- extract(values, newDef = this._def) {
6045
- return ZodEnum.create(values, {
6046
- ...this._def,
6047
- ...newDef
6048
- });
6049
- }
6050
- exclude(values, newDef = this._def) {
6051
- return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
6052
- ...this._def,
6053
- ...newDef
6054
- });
6055
- }
6056
- }
6057
- _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
6058
- ZodEnum.create = createZodEnum;
6059
- class ZodNativeEnum extends ZodType {
6060
- constructor() {
6061
- super(...arguments);
6062
- _ZodNativeEnum_cache.set(this, void 0);
6063
- }
6064
- _parse(input) {
6065
- const nativeEnumValues = util.getValidEnumValues(this._def.values);
6066
- const ctx = this._getOrReturnCtx(input);
6067
- if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
6068
- const expectedValues = util.objectValues(nativeEnumValues);
6069
- addIssueToContext(ctx, {
6070
- expected: util.joinValues(expectedValues),
6071
- received: ctx.parsedType,
6072
- code: ZodIssueCode.invalid_type
6073
- });
6074
- return INVALID;
6075
- }
6076
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache)) {
6077
- __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)));
6078
- }
6079
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache).has(input.data)) {
6080
- const expectedValues = util.objectValues(nativeEnumValues);
6081
- addIssueToContext(ctx, {
6082
- received: ctx.data,
6083
- code: ZodIssueCode.invalid_enum_value,
6084
- options: expectedValues
6085
- });
6086
- return INVALID;
6087
- }
6088
- return OK(input.data);
6089
- }
6090
- get enum() {
6091
- return this._def.values;
6092
- }
6093
- }
6094
- _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
6095
- ZodNativeEnum.create = (values, params) => {
6096
- return new ZodNativeEnum({
6097
- values,
6098
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
6099
- ...processCreateParams(params)
6100
- });
6101
- };
6102
- class ZodPromise extends ZodType {
6103
- unwrap() {
6104
- return this._def.type;
6105
- }
6106
- _parse(input) {
6107
- const { ctx } = this._processInputParams(input);
6108
- if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
6109
- addIssueToContext(ctx, {
6110
- code: ZodIssueCode.invalid_type,
6111
- expected: ZodParsedType.promise,
6112
- received: ctx.parsedType
6113
- });
6114
- return INVALID;
6115
- }
6116
- const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
6117
- return OK(promisified.then((data) => {
6118
- return this._def.type.parseAsync(data, {
6119
- path: ctx.path,
6120
- errorMap: ctx.common.contextualErrorMap
6121
- });
6122
- }));
6123
- }
6124
- }
6125
- ZodPromise.create = (schema, params) => {
6126
- return new ZodPromise({
6127
- type: schema,
6128
- typeName: ZodFirstPartyTypeKind.ZodPromise,
6129
- ...processCreateParams(params)
6130
- });
6131
- };
6132
- class ZodEffects extends ZodType {
6133
- innerType() {
6134
- return this._def.schema;
6135
- }
6136
- sourceType() {
6137
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
6138
- }
6139
- _parse(input) {
6140
- const { status, ctx } = this._processInputParams(input);
6141
- const effect = this._def.effect || null;
6142
- const checkCtx = {
6143
- addIssue: (arg) => {
6144
- addIssueToContext(ctx, arg);
6145
- if (arg.fatal) {
6146
- status.abort();
6147
- } else {
6148
- status.dirty();
6149
- }
6150
- },
6151
- get path() {
6152
- return ctx.path;
6153
- }
6154
- };
6155
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
6156
- if (effect.type === "preprocess") {
6157
- const processed = effect.transform(ctx.data, checkCtx);
6158
- if (ctx.common.async) {
6159
- return Promise.resolve(processed).then(async (processed2) => {
6160
- if (status.value === "aborted")
6161
- return INVALID;
6162
- const result = await this._def.schema._parseAsync({
6163
- data: processed2,
6164
- path: ctx.path,
6165
- parent: ctx
6166
- });
6167
- if (result.status === "aborted")
6168
- return INVALID;
6169
- if (result.status === "dirty")
6170
- return DIRTY(result.value);
6171
- if (status.value === "dirty")
6172
- return DIRTY(result.value);
6173
- return result;
6174
- });
6175
- } else {
6176
- if (status.value === "aborted")
6177
- return INVALID;
6178
- const result = this._def.schema._parseSync({
6179
- data: processed,
6180
- path: ctx.path,
6181
- parent: ctx
6182
- });
6183
- if (result.status === "aborted")
6184
- return INVALID;
6185
- if (result.status === "dirty")
6186
- return DIRTY(result.value);
6187
- if (status.value === "dirty")
6188
- return DIRTY(result.value);
6189
- return result;
6190
- }
6191
- }
6192
- if (effect.type === "refinement") {
6193
- const executeRefinement = (acc) => {
6194
- const result = effect.refinement(acc, checkCtx);
6195
- if (ctx.common.async) {
6196
- return Promise.resolve(result);
6197
- }
6198
- if (result instanceof Promise) {
6199
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
6200
- }
6201
- return acc;
6202
- };
6203
- if (ctx.common.async === false) {
6204
- const inner = this._def.schema._parseSync({
6205
- data: ctx.data,
6206
- path: ctx.path,
6207
- parent: ctx
6208
- });
6209
- if (inner.status === "aborted")
6210
- return INVALID;
6211
- if (inner.status === "dirty")
6212
- status.dirty();
6213
- executeRefinement(inner.value);
6214
- return { status: status.value, value: inner.value };
6215
- } else {
6216
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
6217
- if (inner.status === "aborted")
6218
- return INVALID;
6219
- if (inner.status === "dirty")
6220
- status.dirty();
6221
- return executeRefinement(inner.value).then(() => {
6222
- return { status: status.value, value: inner.value };
6223
- });
6224
- });
6225
- }
6226
- }
6227
- if (effect.type === "transform") {
6228
- if (ctx.common.async === false) {
6229
- const base = this._def.schema._parseSync({
6230
- data: ctx.data,
6231
- path: ctx.path,
6232
- parent: ctx
6233
- });
6234
- if (!isValid$3(base))
6235
- return base;
6236
- const result = effect.transform(base.value, checkCtx);
6237
- if (result instanceof Promise) {
6238
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
6239
- }
6240
- return { status: status.value, value: result };
6241
- } else {
6242
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
6243
- if (!isValid$3(base))
6244
- return base;
6245
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
6246
- });
6247
- }
6248
- }
6249
- util.assertNever(effect);
6250
- }
6251
- }
6252
- ZodEffects.create = (schema, effect, params) => {
6253
- return new ZodEffects({
6254
- schema,
6255
- typeName: ZodFirstPartyTypeKind.ZodEffects,
6256
- effect,
6257
- ...processCreateParams(params)
6258
- });
6259
- };
6260
- ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
6261
- return new ZodEffects({
6262
- schema,
6263
- effect: { type: "preprocess", transform: preprocess },
6264
- typeName: ZodFirstPartyTypeKind.ZodEffects,
6265
- ...processCreateParams(params)
6266
- });
6267
- };
6268
- class ZodOptional extends ZodType {
6269
- _parse(input) {
6270
- const parsedType = this._getType(input);
6271
- if (parsedType === ZodParsedType.undefined) {
6272
- return OK(void 0);
6273
- }
6274
- return this._def.innerType._parse(input);
6275
- }
6276
- unwrap() {
6277
- return this._def.innerType;
6278
- }
6279
- }
6280
- ZodOptional.create = (type, params) => {
6281
- return new ZodOptional({
6282
- innerType: type,
6283
- typeName: ZodFirstPartyTypeKind.ZodOptional,
6284
- ...processCreateParams(params)
6285
- });
6286
- };
6287
- class ZodNullable extends ZodType {
6288
- _parse(input) {
6289
- const parsedType = this._getType(input);
6290
- if (parsedType === ZodParsedType.null) {
6291
- return OK(null);
6292
- }
6293
- return this._def.innerType._parse(input);
6294
- }
6295
- unwrap() {
6296
- return this._def.innerType;
6297
- }
6298
- }
6299
- ZodNullable.create = (type, params) => {
6300
- return new ZodNullable({
6301
- innerType: type,
6302
- typeName: ZodFirstPartyTypeKind.ZodNullable,
6303
- ...processCreateParams(params)
6304
- });
6305
- };
6306
- class ZodDefault extends ZodType {
6307
- _parse(input) {
6308
- const { ctx } = this._processInputParams(input);
6309
- let data = ctx.data;
6310
- if (ctx.parsedType === ZodParsedType.undefined) {
6311
- data = this._def.defaultValue();
6312
- }
6313
- return this._def.innerType._parse({
6314
- data,
6315
- path: ctx.path,
6316
- parent: ctx
6317
- });
6318
- }
6319
- removeDefault() {
6320
- return this._def.innerType;
6321
- }
6322
- }
6323
- ZodDefault.create = (type, params) => {
6324
- return new ZodDefault({
6325
- innerType: type,
6326
- typeName: ZodFirstPartyTypeKind.ZodDefault,
6327
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
6328
- ...processCreateParams(params)
6329
- });
6330
- };
6331
- class ZodCatch extends ZodType {
6332
- _parse(input) {
6333
- const { ctx } = this._processInputParams(input);
6334
- const newCtx = {
6335
- ...ctx,
6336
- common: {
6337
- ...ctx.common,
6338
- issues: []
6339
- }
6340
- };
6341
- const result = this._def.innerType._parse({
6342
- data: newCtx.data,
6343
- path: newCtx.path,
6344
- parent: {
6345
- ...newCtx
6346
- }
6347
- });
6348
- if (isAsync(result)) {
6349
- return result.then((result2) => {
6350
- return {
6351
- status: "valid",
6352
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
6353
- get error() {
6354
- return new ZodError(newCtx.common.issues);
6355
- },
6356
- input: newCtx.data
6357
- })
6358
- };
6359
- });
6360
- } else {
6361
- return {
6362
- status: "valid",
6363
- value: result.status === "valid" ? result.value : this._def.catchValue({
6364
- get error() {
6365
- return new ZodError(newCtx.common.issues);
6366
- },
6367
- input: newCtx.data
6368
- })
6369
- };
6370
- }
6371
- }
6372
- removeCatch() {
6373
- return this._def.innerType;
6374
- }
6375
- }
6376
- ZodCatch.create = (type, params) => {
6377
- return new ZodCatch({
6378
- innerType: type,
6379
- typeName: ZodFirstPartyTypeKind.ZodCatch,
6380
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
6381
- ...processCreateParams(params)
6382
- });
6383
- };
6384
- class ZodNaN extends ZodType {
6385
- _parse(input) {
6386
- const parsedType = this._getType(input);
6387
- if (parsedType !== ZodParsedType.nan) {
6388
- const ctx = this._getOrReturnCtx(input);
6389
- addIssueToContext(ctx, {
6390
- code: ZodIssueCode.invalid_type,
6391
- expected: ZodParsedType.nan,
6392
- received: ctx.parsedType
6393
- });
6394
- return INVALID;
6395
- }
6396
- return { status: "valid", value: input.data };
6397
- }
6398
- }
6399
- ZodNaN.create = (params) => {
6400
- return new ZodNaN({
6401
- typeName: ZodFirstPartyTypeKind.ZodNaN,
6402
- ...processCreateParams(params)
6403
- });
6404
- };
6405
- const BRAND = Symbol("zod_brand");
6406
- class ZodBranded extends ZodType {
6407
- _parse(input) {
6408
- const { ctx } = this._processInputParams(input);
6409
- const data = ctx.data;
6410
- return this._def.type._parse({
6411
- data,
6412
- path: ctx.path,
6413
- parent: ctx
6414
- });
6415
- }
6416
- unwrap() {
6417
- return this._def.type;
6418
- }
6419
- }
6420
- class ZodPipeline extends ZodType {
6421
- _parse(input) {
6422
- const { status, ctx } = this._processInputParams(input);
6423
- if (ctx.common.async) {
6424
- const handleAsync = async () => {
6425
- const inResult = await this._def.in._parseAsync({
6426
- data: ctx.data,
6427
- path: ctx.path,
6428
- parent: ctx
6429
- });
6430
- if (inResult.status === "aborted")
6431
- return INVALID;
6432
- if (inResult.status === "dirty") {
6433
- status.dirty();
6434
- return DIRTY(inResult.value);
6435
- } else {
6436
- return this._def.out._parseAsync({
6437
- data: inResult.value,
6438
- path: ctx.path,
6439
- parent: ctx
6440
- });
6441
- }
6442
- };
6443
- return handleAsync();
6444
- } else {
6445
- const inResult = this._def.in._parseSync({
6446
- data: ctx.data,
6447
- path: ctx.path,
6448
- parent: ctx
6449
- });
6450
- if (inResult.status === "aborted")
6451
- return INVALID;
6452
- if (inResult.status === "dirty") {
6453
- status.dirty();
6454
- return {
6455
- status: "dirty",
6456
- value: inResult.value
6457
- };
6458
- } else {
6459
- return this._def.out._parseSync({
6460
- data: inResult.value,
6461
- path: ctx.path,
6462
- parent: ctx
6463
- });
6464
- }
6465
- }
6466
- }
6467
- static create(a, b) {
6468
- return new ZodPipeline({
6469
- in: a,
6470
- out: b,
6471
- typeName: ZodFirstPartyTypeKind.ZodPipeline
6472
- });
6473
- }
6474
- }
6475
- class ZodReadonly extends ZodType {
6476
- _parse(input) {
6477
- const result = this._def.innerType._parse(input);
6478
- const freeze = (data) => {
6479
- if (isValid$3(data)) {
6480
- data.value = Object.freeze(data.value);
6481
- }
6482
- return data;
6483
- };
6484
- return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
6485
- }
6486
- unwrap() {
6487
- return this._def.innerType;
6488
- }
6489
- }
6490
- ZodReadonly.create = (type, params) => {
6491
- return new ZodReadonly({
6492
- innerType: type,
6493
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
6494
- ...processCreateParams(params)
6495
- });
6496
- };
6497
- function cleanParams(params, data) {
6498
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
6499
- const p2 = typeof p === "string" ? { message: p } : p;
6500
- return p2;
6501
- }
6502
- function custom(check, _params = {}, fatal) {
6503
- if (check)
6504
- return ZodAny.create().superRefine((data, ctx) => {
6505
- var _a, _b;
6506
- const r = check(data);
6507
- if (r instanceof Promise) {
6508
- return r.then((r2) => {
6509
- var _a2, _b2;
6510
- if (!r2) {
6511
- const params = cleanParams(_params, data);
6512
- const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
6513
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
6514
- }
6515
- });
6516
- }
6517
- if (!r) {
6518
- const params = cleanParams(_params, data);
6519
- const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
6520
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
6521
- }
6522
- return;
6523
- });
6524
- return ZodAny.create();
6525
- }
6526
- const late = {
6527
- object: ZodObject.lazycreate
6528
- };
6529
- var ZodFirstPartyTypeKind;
6530
- (function(ZodFirstPartyTypeKind2) {
6531
- ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
6532
- ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
6533
- ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
6534
- ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
6535
- ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
6536
- ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
6537
- ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
6538
- ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
6539
- ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
6540
- ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
6541
- ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
6542
- ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
6543
- ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
6544
- ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
6545
- ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
6546
- ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
6547
- ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
6548
- ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
6549
- ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
6550
- ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
6551
- ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
6552
- ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
6553
- ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
6554
- ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
6555
- ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
6556
- ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
6557
- ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
6558
- ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
6559
- ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
6560
- ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
6561
- ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
6562
- ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
6563
- ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
6564
- ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
6565
- ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
6566
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
6567
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
6568
- const instanceOfType = (cls, params = {
6569
- message: `Input not instance of ${cls.name}`
6570
- }) => custom((data) => data instanceof cls, params);
6571
- const stringType = ZodString.create;
6572
- const numberType = ZodNumber.create;
6573
- const nanType = ZodNaN.create;
6574
- const bigIntType = ZodBigInt.create;
6575
- const booleanType = ZodBoolean.create;
6576
- const dateType = ZodDate.create;
6577
- const symbolType = ZodSymbol.create;
6578
- const undefinedType = ZodUndefined.create;
6579
- const nullType = ZodNull.create;
6580
- const anyType = ZodAny.create;
6581
- const unknownType = ZodUnknown.create;
6582
- const neverType = ZodNever.create;
6583
- const voidType = ZodVoid.create;
6584
- const arrayType = ZodArray.create;
6585
- const objectType = ZodObject.create;
6586
- const strictObjectType = ZodObject.strictCreate;
6587
- const unionType = ZodUnion.create;
6588
- const discriminatedUnionType = ZodDiscriminatedUnion.create;
6589
- const intersectionType = ZodIntersection.create;
6590
- const tupleType = ZodTuple.create;
6591
- const recordType = ZodRecord.create;
6592
- const mapType = ZodMap.create;
6593
- const setType = ZodSet.create;
6594
- const functionType = ZodFunction.create;
6595
- const lazyType = ZodLazy.create;
6596
- const literalType = ZodLiteral.create;
6597
- const enumType = ZodEnum.create;
6598
- const nativeEnumType = ZodNativeEnum.create;
6599
- const promiseType = ZodPromise.create;
6600
- const effectsType = ZodEffects.create;
6601
- const optionalType = ZodOptional.create;
6602
- const nullableType = ZodNullable.create;
6603
- const preprocessType = ZodEffects.createWithPreprocess;
6604
- const pipelineType = ZodPipeline.create;
6605
- const ostring = () => stringType().optional();
6606
- const onumber = () => numberType().optional();
6607
- const oboolean = () => booleanType().optional();
6608
- const coerce = {
6609
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
6610
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
6611
- boolean: (arg) => ZodBoolean.create({
6612
- ...arg,
6613
- coerce: true
6614
- }),
6615
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
6616
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
6617
- };
6618
- const NEVER = INVALID;
6619
- var z = /* @__PURE__ */ Object.freeze({
6620
- __proto__: null,
6621
- defaultErrorMap: errorMap,
6622
- setErrorMap,
6623
- getErrorMap,
6624
- makeIssue,
6625
- EMPTY_PATH,
6626
- addIssueToContext,
6627
- ParseStatus,
6628
- INVALID,
6629
- DIRTY,
6630
- OK,
6631
- isAborted,
6632
- isDirty,
6633
- isValid: isValid$3,
6634
- isAsync,
6635
- get util() {
6636
- return util;
6637
- },
6638
- get objectUtil() {
6639
- return objectUtil;
6640
- },
6641
- ZodParsedType,
6642
- getParsedType,
6643
- ZodType,
6644
- datetimeRegex,
6645
- ZodString,
6646
- ZodNumber,
6647
- ZodBigInt,
6648
- ZodBoolean,
6649
- ZodDate,
6650
- ZodSymbol,
6651
- ZodUndefined,
6652
- ZodNull,
6653
- ZodAny,
6654
- ZodUnknown,
6655
- ZodNever,
6656
- ZodVoid,
6657
- ZodArray,
6658
- ZodObject,
6659
- ZodUnion,
6660
- ZodDiscriminatedUnion,
6661
- ZodIntersection,
6662
- ZodTuple,
6663
- ZodRecord,
6664
- ZodMap,
6665
- ZodSet,
6666
- ZodFunction,
6667
- ZodLazy,
6668
- ZodLiteral,
6669
- ZodEnum,
6670
- ZodNativeEnum,
6671
- ZodPromise,
6672
- ZodEffects,
6673
- ZodTransformer: ZodEffects,
6674
- ZodOptional,
6675
- ZodNullable,
6676
- ZodDefault,
6677
- ZodCatch,
6678
- ZodNaN,
6679
- BRAND,
6680
- ZodBranded,
6681
- ZodPipeline,
6682
- ZodReadonly,
6683
- custom,
6684
- Schema: ZodType,
6685
- ZodSchema: ZodType,
6686
- late,
6687
- get ZodFirstPartyTypeKind() {
6688
- return ZodFirstPartyTypeKind;
6689
- },
6690
- coerce,
6691
- any: anyType,
6692
- array: arrayType,
6693
- bigint: bigIntType,
6694
- boolean: booleanType,
6695
- date: dateType,
6696
- discriminatedUnion: discriminatedUnionType,
6697
- effect: effectsType,
6698
- "enum": enumType,
6699
- "function": functionType,
6700
- "instanceof": instanceOfType,
6701
- intersection: intersectionType,
6702
- lazy: lazyType,
6703
- literal: literalType,
6704
- map: mapType,
6705
- nan: nanType,
6706
- nativeEnum: nativeEnumType,
6707
- never: neverType,
6708
- "null": nullType,
6709
- nullable: nullableType,
6710
- number: numberType,
6711
- object: objectType,
6712
- oboolean,
6713
- onumber,
6714
- optional: optionalType,
6715
- ostring,
6716
- pipeline: pipelineType,
6717
- preprocess: preprocessType,
6718
- promise: promiseType,
6719
- record: recordType,
6720
- set: setType,
6721
- strictObject: strictObjectType,
6722
- string: stringType,
6723
- symbol: symbolType,
6724
- transformer: effectsType,
6725
- tuple: tupleType,
6726
- "undefined": undefinedType,
6727
- union: unionType,
6728
- unknown: unknownType,
6729
- "void": voidType,
6730
- NEVER,
6731
- ZodIssueCode,
6732
- quotelessJson,
6733
- ZodError
6734
- });
6735
- const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "development", "PROD": true, "SSR": false, "VITE_MODULES_CARDS_ADMIN_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_CARDS_HOME_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_CERT_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_ENV": "dev", "VITE_MODULES_EVENTS_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_SSO_BACKEND_BASE_URL": "https://dev-ssoapi.6seconds.org", "VITE_MODULES_SSO_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_TOOLS_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org" };
6736
- const env = createEnv({
6737
- client: {
6738
- VITE_MODULES_ENV: z.string()
6739
- },
6740
- runtimeEnv: __vite_import_meta_env__
6741
- });
6742
- process.env.NODE_ENV === "development";
6743
- const SERVER_STATUS = Object.freeze({
6744
- success: "success",
6745
- failure: "failure"
6746
- });
6747
- const APP_NAMES = Object.freeze({
6748
- events: "Events",
6749
- tools: "Tools",
6750
- certHome: "Cert Home",
6751
- cards: "Cards",
6752
- sso: "SSO Admin",
6753
- cardsHome: "Cards Home",
6754
- cardsAdmin: "Cards Admin"
6755
- });
6756
- const ALERT_MESSAGES = Object.freeze({
6757
- // not found
6758
- dataNoFount: "Data not found",
6759
- searchNotFount: "Sorry, there are no matches. Try a new search?",
6760
- // generic
6761
- commonLoadingMessage: "Please wait...",
6762
- submittingSuccessMassage: "Detail Added Successfully",
6763
- allFieldsRequired: "Please fill all required fields",
6764
- NA: "N/A",
6765
- // error
6766
- fallbackError: "Something went wrong, Please try again later!",
6767
- networkError: "Please check your internet connection!",
6768
- timeOutError: "Your connection taking too long to get data!"
6769
- });
6770
- const REGEX = Object.freeze({
6771
- email: /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/i,
6772
- mobile: /^[6-9]\d{9}$/,
6773
- website: /^(https?:\/\/)?(www\.)?[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(\/.*)?$/,
6774
- password: /^(?=.*[A-Z])(?=.*\d)(?=.*[@!$%^&*()_+[\]{};':"\\|,.<>/?#]).*$/
6775
- });
6776
- const NOTIFICATIONS_TYPES = Object.freeze({
6777
- project: "Project",
6778
- credit: "Credit",
6779
- report: "Report",
6780
- group: "Group",
6781
- system: "System"
6782
- });
6783
- const TOOLS_ROUTES = {
6784
- creditList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/credit/regular-credits",
6785
- groupList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/sei/adult/groups",
6786
- projectList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/sei/adult/projects",
6787
- reportList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/sei/adult/reports"
6788
- };
6789
- const SSO_ROUTES = (APP_NAME) => {
6790
- return {
6791
- languages: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/languages?source=${APP_NAME}`,
6792
- translations: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/translations?source=${APP_NAME}`,
6793
- editProfile: `${APP_NAME !== APP_NAMES.sso ? env.VITE_MODULES_SSO_FRONTEND_BASE_URL : "."}/edit-profile?source=${APP_NAME}`,
6794
- emailTemplate: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/email-templates?source=${APP_NAME}`,
6795
- unauthorized: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/unauthorized`
6796
- };
6797
- };
6798
- const ROUTES = {
6799
- home: "/"
6800
- };
6801
- const STORAGE_VALUES = Object.freeze({
6802
- // mainToken: env.NEXT_PUBLIC_TOKEN_NAME,
6803
- previousLoginBanner: "previousLoginDetails-" + env.VITE_MODULES_ENV
6804
- });
6805
- const MAIN_DATE_FORMAT = "MM/DD/YYYY";
6806
- const FILTER_DATE_FORMAT = "YYYY-MM-DD";
6807
- const MAIN_TIME_FORMAT = "h:mm a";
6808
- const TRANSLATION_PREFIX = Object.freeze({
6809
- // elements
6810
- tooltip: "tooltip_",
6811
- validation: "validation_",
6812
- toast: "toast_"
6813
- });
6814
- const COMMON_VALIDATION_MASSAGE = Object.freeze({
6815
- // Requires
6816
- password: TRANSLATION_PREFIX.validation + "password_is_required!",
6817
- email: TRANSLATION_PREFIX.validation + "Email_is_required!",
6818
- oldPassword: TRANSLATION_PREFIX.validation + "old_password_is_required!",
6819
- gender: TRANSLATION_PREFIX.validation + "gender_is_required!",
6820
- projectType: TRANSLATION_PREFIX.validation + "project_type_is_required!",
6821
- name: TRANSLATION_PREFIX.validation + "name_is_required!",
6822
- surname: TRANSLATION_PREFIX.validation + "surname_is_required!",
6823
- language: TRANSLATION_PREFIX.validation + "language_is_required!",
6824
- pricing: TRANSLATION_PREFIX.validation + "pricing scheme_is_required!",
6825
- coach: TRANSLATION_PREFIX.validation + "coach_is_required!",
6826
- amount: TRANSLATION_PREFIX.validation + "amount_is_required!",
6827
- credit: TRANSLATION_PREFIX.validation + "credits_is_required!",
6828
- report: TRANSLATION_PREFIX.validation + "report_language_is_required!",
6829
- reportNorm: TRANSLATION_PREFIX.validation + "report_norm_is_required!",
6830
- date: TRANSLATION_PREFIX.validation + "date_is_required!",
6831
- parentDistributor: TRANSLATION_PREFIX.validation + "parent_distributor_is_required!",
6832
- belongTo: TRANSLATION_PREFIX.validation + "belong_to_is_required!",
6833
- notes: TRANSLATION_PREFIX.validation + "notes_is_required!",
6834
- company: TRANSLATION_PREFIX.validation + "company_is_required!",
6835
- orgLogo: TRANSLATION_PREFIX.validation + "organization_logo_is_required",
6836
- url: TRANSLATION_PREFIX.validation + "url_is_Required!",
6837
- description: TRANSLATION_PREFIX.validation + "description_is_Required!",
6838
- // length
6839
- maxVal: TRANSLATION_PREFIX.validation + "too_long!",
6840
- minVal: TRANSLATION_PREFIX.validation + "too_short!",
6841
- // validation
6842
- emailValidation: TRANSLATION_PREFIX.validation + "email_is_not_valid!",
6843
- urlValidation: TRANSLATION_PREFIX.validation + "url_must_be_a_valid!",
6844
- // general
6845
- certifications: TRANSLATION_PREFIX.validation + "Please select at least one certification!",
6846
- questions: TRANSLATION_PREFIX.toast + "Please answer all questions!"
6847
- });
6848
2657
  const truncateValUtil = (val, maxTruncateVal = 15) => {
6849
2658
  return val.length > maxTruncateVal ? val.substring(0, maxTruncateVal) + "..." : val;
6850
2659
  };
@@ -6890,25 +2699,25 @@ const getIcons = (val, defaultIcon) => {
6890
2699
  }
6891
2700
  };
6892
2701
  const handleRedirection = (type, source) => {
6893
- if (source === APP_NAMES.tools) {
2702
+ if (source === constants.APP_NAMES.tools) {
6894
2703
  switch (type) {
6895
- case NOTIFICATIONS_TYPES.project:
6896
- window.open(TOOLS_ROUTES.projectList);
2704
+ case constants.NOTIFICATIONS_TYPES.project:
2705
+ window.open(constants.TOOLS_ROUTES.projectList);
6897
2706
  break;
6898
- case NOTIFICATIONS_TYPES.credit:
6899
- window.open(TOOLS_ROUTES.creditList);
2707
+ case constants.NOTIFICATIONS_TYPES.credit:
2708
+ window.open(constants.TOOLS_ROUTES.creditList);
6900
2709
  break;
6901
- case NOTIFICATIONS_TYPES.group:
6902
- window.open(TOOLS_ROUTES.groupList);
2710
+ case constants.NOTIFICATIONS_TYPES.group:
2711
+ window.open(constants.TOOLS_ROUTES.groupList);
6903
2712
  break;
6904
- case NOTIFICATIONS_TYPES.report:
6905
- window.open(TOOLS_ROUTES.reportList);
2713
+ case constants.NOTIFICATIONS_TYPES.report:
2714
+ window.open(constants.TOOLS_ROUTES.reportList);
6906
2715
  break;
6907
- case NOTIFICATIONS_TYPES.system:
6908
- window.open(TOOLS_ROUTES.projectList);
2716
+ case constants.NOTIFICATIONS_TYPES.system:
2717
+ window.open(constants.TOOLS_ROUTES.projectList);
6909
2718
  break;
6910
2719
  default:
6911
- window.open(TOOLS_ROUTES.projectList);
2720
+ window.open(constants.TOOLS_ROUTES.projectList);
6912
2721
  }
6913
2722
  }
6914
2723
  };
@@ -10924,9 +6733,9 @@ hooks.HTML5_FMT = {
10924
6733
  MONTH: "YYYY-MM"
10925
6734
  // <input type="month" />
10926
6735
  };
10927
- function formatDateUtil(dateString, flag, formatDate = MAIN_DATE_FORMAT) {
6736
+ function formatDateUtil(dateString, flag, formatDate = constants.MAIN_DATE_FORMAT) {
10928
6737
  const dateTime = hooks.utc(dateString).local();
10929
- return dateString ? formatTwoValues(dateTime.format(formatDate), dateTime.format(MAIN_TIME_FORMAT)) : "";
6738
+ return dateString ? formatTwoValues(dateTime.format(formatDate), dateTime.format(constants.MAIN_TIME_FORMAT)) : "";
10930
6739
  }
10931
6740
  var propertyExpr;
10932
6741
  var hasRequiredPropertyExpr;
@@ -11477,7 +7286,7 @@ function createValidation(config) {
11477
7286
  originalValue,
11478
7287
  schema
11479
7288
  };
11480
- const handleResult2 = (validOrError) => {
7289
+ const handleResult = (validOrError) => {
11481
7290
  if (ValidationError.isError(validOrError)) invalid(validOrError);
11482
7291
  else if (!validOrError) invalid(createError());
11483
7292
  else next(null);
@@ -11488,7 +7297,7 @@ function createValidation(config) {
11488
7297
  };
11489
7298
  const shouldSkip = skipAbsent && isAbsent(value);
11490
7299
  if (shouldSkip) {
11491
- return handleResult2(true);
7300
+ return handleResult(true);
11492
7301
  }
11493
7302
  let result;
11494
7303
  try {
@@ -11498,13 +7307,13 @@ function createValidation(config) {
11498
7307
  if (options.sync) {
11499
7308
  throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
11500
7309
  }
11501
- return Promise.resolve(result).then(handleResult2, handleError);
7310
+ return Promise.resolve(result).then(handleResult, handleError);
11502
7311
  }
11503
7312
  } catch (err) {
11504
7313
  handleError(err);
11505
7314
  return;
11506
7315
  }
11507
- handleResult2(result);
7316
+ handleResult(result);
11508
7317
  }
11509
7318
  validate.OPTIONS = config;
11510
7319
  return validate;
@@ -12998,32 +8807,32 @@ const commonVal = {
12998
8807
  };
12999
8808
  const commonUtil = (t) => {
13000
8809
  return {
13001
- email: create$6().matches(REGEX.email, t(COMMON_VALIDATION_MASSAGE.emailValidation)).trim(),
13002
- name: create$6().min(commonVal.min, t(COMMON_VALIDATION_MASSAGE.minVal)).max(commonVal.max, t(COMMON_VALIDATION_MASSAGE.maxVal)),
13003
- url: create$6().matches(REGEX.website, t(COMMON_VALIDATION_MASSAGE.urlValidation)).trim(),
8810
+ email: create$6().matches(constants.REGEX.email, t(constants.COMMON_VALIDATION_MASSAGE.emailValidation)).trim(),
8811
+ name: create$6().min(commonVal.min, t(constants.COMMON_VALIDATION_MASSAGE.minVal)).max(commonVal.max, t(constants.COMMON_VALIDATION_MASSAGE.maxVal)),
8812
+ url: create$6().matches(constants.REGEX.website, t(constants.COMMON_VALIDATION_MASSAGE.urlValidation)).trim(),
13004
8813
  password: create$6().matches(
13005
- REGEX.password,
8814
+ constants.REGEX.password,
13006
8815
  t(
13007
- `${TRANSLATION_PREFIX.validation}password must contain at least one uppercase letter, one number, and one special character`
8816
+ `${constants.TRANSLATION_PREFIX.validation}password must contain at least one uppercase letter, one number, and one special character`
13008
8817
  )
13009
8818
  ).min(8).trim(),
13010
8819
  date: create$6().required("Date is required").test(
13011
8820
  "is-valid-format",
13012
- `${TRANSLATION_PREFIX.validation}invalid_date_format`,
13013
- (value) => hooks(value, MAIN_DATE_FORMAT, true).isValid()
13014
- ).test("is-future-date", `${TRANSLATION_PREFIX.validation}date_cannot_be_in_the_past`, (value) => {
8821
+ `${constants.TRANSLATION_PREFIX.validation}invalid_date_format`,
8822
+ (value) => hooks(value, constants.MAIN_DATE_FORMAT, true).isValid()
8823
+ ).test("is-future-date", `${constants.TRANSLATION_PREFIX.validation}date_cannot_be_in_the_past`, (value) => {
13015
8824
  const today = hooks().startOf("day");
13016
- const selectedDate = hooks(value, MAIN_DATE_FORMAT, true);
8825
+ const selectedDate = hooks(value, constants.MAIN_DATE_FORMAT, true);
13017
8826
  return selectedDate.isSameOrAfter(today);
13018
8827
  }),
13019
8828
  positiveNumber: create$5().positive().integer(),
13020
- confirmPass: create$6().test("passwords-match", t(`${TRANSLATION_PREFIX.validation}passwords_must_match`), function(value) {
8829
+ confirmPass: create$6().test("passwords-match", t(`${constants.TRANSLATION_PREFIX.validation}passwords_must_match`), function(value) {
13021
8830
  return value === this.parent.newPassword;
13022
8831
  }).trim(),
13023
8832
  cvsFile: create$3().shape({
13024
- file: create$8().required(t(`${TRANSLATION_PREFIX.validation}file_is_required`)).test("fileSize", t(`${TRANSLATION_PREFIX.validation}file_is_required`), function(val) {
8833
+ file: create$8().required(t(`${constants.TRANSLATION_PREFIX.validation}file_is_required`)).test("fileSize", t(`${constants.TRANSLATION_PREFIX.validation}file_is_required`), function(val) {
13025
8834
  return val && val.length > 0;
13026
- }).test("fileType", t(`${TRANSLATION_PREFIX.validation}unsupported_file_type`), function(val) {
8835
+ }).test("fileType", t(`${constants.TRANSLATION_PREFIX.validation}unsupported_file_type`), function(val) {
13027
8836
  return val && ["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].includes(
13028
8837
  val[0]?.type
13029
8838
  );
@@ -13032,7 +8841,7 @@ const commonUtil = (t) => {
13032
8841
  };
13033
8842
  };
13034
8843
  const ResetPasswordValidationUtil = (t) => create$3().shape({
13035
- newPassword: commonUtil(t).password.required(t(COMMON_VALIDATION_MASSAGE.password)),
8844
+ newPassword: commonUtil(t).password.required(t(constants.COMMON_VALIDATION_MASSAGE.password)),
13036
8845
  passwordConfirmation: commonUtil(t).confirmPass
13037
8846
  });
13038
8847
  function Logo({ sx }) {
@@ -13046,10 +8855,10 @@ function Logo({ sx }) {
13046
8855
  alignItems: "center",
13047
8856
  ...sx
13048
8857
  },
13049
- onClick: () => url(ROUTES.home),
8858
+ onClick: () => url(constants.ROUTES.home),
13050
8859
  children: [
13051
- /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: { xs: "none", md: "block", height: "100%", width: "200px" } }, children: env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("dev") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.DevIcon, {}) : env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("qa") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.QaIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(SVG.Logo, {}) }),
13052
- /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: { xs: "block", md: "none" } }, children: env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("dev") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.SmallLogoDev, {}) : env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("qa") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.SmallLogoQa, {}) : /* @__PURE__ */ jsxRuntime.jsx(SVG.SmallLogo, {}) })
8860
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: { xs: "none", md: "block", height: "100%", width: "200px" } }, children: constants.env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("dev") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.DevIcon, {}) : constants.env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("qa") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.QaIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(SVG.Logo, {}) }),
8861
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: { xs: "block", md: "none" } }, children: constants.env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("dev") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.SmallLogoDev, {}) : constants.env.VITE_MODULES_SSO_FRONTEND_BASE_URL?.includes("qa") ? /* @__PURE__ */ jsxRuntime.jsx(SVG.SmallLogoQa, {}) : /* @__PURE__ */ jsxRuntime.jsx(SVG.SmallLogo, {}) })
13053
8862
  ]
13054
8863
  }
13055
8864
  );
@@ -13090,8 +8899,8 @@ function requireDist() {
13090
8899
  dist.default = urlcat2;
13091
8900
  function urlcatImpl(pathTemplate, params, baseUrl) {
13092
8901
  var _a = path(pathTemplate, params), renderedPath = _a.renderedPath, remainingParams = _a.remainingParams;
13093
- var cleanParams2 = removeNullOrUndef(remainingParams);
13094
- var renderedQuery = query(cleanParams2);
8902
+ var cleanParams = removeNullOrUndef(remainingParams);
8903
+ var renderedQuery = query(cleanParams);
13095
8904
  var pathAndQuery = join(renderedPath, "?", renderedQuery);
13096
8905
  return baseUrl ? join(baseUrl, "/", pathAndQuery) : pathAndQuery;
13097
8906
  }
@@ -13147,7 +8956,7 @@ function requireDist() {
13147
8956
  }
13148
8957
  var distExports = requireDist();
13149
8958
  const urlcat = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
13150
- if (env.VITE_MODULES_SSO_BACKEND_BASE_URL === void 0) {
8959
+ if (constants.env.VITE_MODULES_SSO_BACKEND_BASE_URL === void 0) {
13151
8960
  throw new Error("env is not set");
13152
8961
  }
13153
8962
  function createAxiosInstance(baseUrl) {
@@ -13160,23 +8969,23 @@ function createAxiosInstance(baseUrl) {
13160
8969
  });
13161
8970
  }
13162
8971
  async function req(config) {
13163
- const baseUrl = env.VITE_MODULES_SSO_BACKEND_BASE_URL;
8972
+ const baseUrl = constants.env.VITE_MODULES_SSO_BACKEND_BASE_URL;
13164
8973
  const axiosInstance = createAxiosInstance(baseUrl);
13165
8974
  try {
13166
8975
  const response = await axiosInstance.request({ ...config });
13167
8976
  return {
13168
- remote: SERVER_STATUS.success,
8977
+ remote: constants.SERVER_STATUS.success,
13169
8978
  data: response?.data?.data
13170
8979
  };
13171
8980
  } catch (error) {
13172
8981
  if (error.response) {
13173
8982
  const axiosError = error;
13174
- const errorMessage = axiosError.response?.data?.message || ALERT_MESSAGES.fallbackError;
8983
+ const errorMessage = axiosError.response?.data?.message || constants.ALERT_MESSAGES.fallbackError;
13175
8984
  const errorCode = axiosError.response?.status;
13176
8985
  const errorData = axiosError.response?.data?.data || null;
13177
8986
  return {
13178
8987
  status: errorCode,
13179
- remote: SERVER_STATUS.failure,
8988
+ remote: constants.SERVER_STATUS.failure,
13180
8989
  error: {
13181
8990
  message: errorMessage,
13182
8991
  data: errorData
@@ -13211,9 +9020,9 @@ async function getDropDownMenuApi(params) {
13211
9020
  url: urlcat("menu/menus", params),
13212
9021
  method: "GET"
13213
9022
  });
13214
- if (res.remote === SERVER_STATUS.success) {
9023
+ if (res.remote === constants.SERVER_STATUS.success) {
13215
9024
  return {
13216
- remote: SERVER_STATUS.success,
9025
+ remote: constants.SERVER_STATUS.success,
13217
9026
  data: res?.data?.map(transformMenuBuilderData)
13218
9027
  };
13219
9028
  }
@@ -13224,9 +9033,9 @@ async function notificationApi(data) {
13224
9033
  url: urlcat("/notification/index", data),
13225
9034
  method: "GET"
13226
9035
  });
13227
- if (res.remote === SERVER_STATUS.success) {
9036
+ if (res.remote === constants.SERVER_STATUS.success) {
13228
9037
  return {
13229
- remote: SERVER_STATUS.success,
9038
+ remote: constants.SERVER_STATUS.success,
13230
9039
  data: res?.data?.pager
13231
9040
  };
13232
9041
  }
@@ -13238,9 +9047,9 @@ async function changeUserPasswordApi(payload) {
13238
9047
  method: "POST",
13239
9048
  data: payload
13240
9049
  });
13241
- if (res.remote === SERVER_STATUS.success) {
9050
+ if (res.remote === constants.SERVER_STATUS.success) {
13242
9051
  return {
13243
- remote: SERVER_STATUS.success,
9052
+ remote: constants.SERVER_STATUS.success,
13244
9053
  data: res?.data?.pager
13245
9054
  };
13246
9055
  }
@@ -13334,7 +9143,7 @@ const DangerDialog = ({
13334
9143
  fontSize: "14px",
13335
9144
  "&:hover": { background: "#EC5962" }
13336
9145
  },
13337
- children: isLoading ? ALERT_MESSAGES.commonLoadingMessage : buttonTitle
9146
+ children: isLoading ? constants.ALERT_MESSAGES.commonLoadingMessage : buttonTitle
13338
9147
  }
13339
9148
  )
13340
9149
  ] })
@@ -13900,11 +9709,11 @@ function ChangePasswordDialog({ isOpen, email, t: t2, setInitialState }) {
13900
9709
  };
13901
9710
  const res = await changeUserPasswordApi(payload);
13902
9711
  if (res.remote === "success") {
13903
- toast.success(t2(TRANSLATION_PREFIX.toast + "Password changed successfully."));
9712
+ toast.success(t2(constants.TRANSLATION_PREFIX.toast + "Password changed successfully."));
13904
9713
  handleCloseUtil(setInitialState);
13905
9714
  }
13906
9715
  } catch (err) {
13907
- toast.error(err.message || t2(ALERT_MESSAGES.fallbackError));
9716
+ toast.error(err.message || t2(constants.ALERT_MESSAGES.fallbackError));
13908
9717
  }
13909
9718
  }
13910
9719
  });
@@ -13974,7 +9783,7 @@ function ChangePasswordDialog({ isOpen, email, t: t2, setInitialState }) {
13974
9783
  }
13975
9784
  const AppMenus = ({ menuItems, setInitialState, t: t2, appName, router }) => {
13976
9785
  const handleRedirection2 = (appName2, url2, type) => {
13977
- if (router && appName2 === APP_NAMES.sso && type === "tab") {
9786
+ if (router && appName2 === constants.APP_NAMES.sso && type === "tab") {
13978
9787
  router.push(url2);
13979
9788
  } else {
13980
9789
  if (type === "app") {
@@ -14596,11 +10405,11 @@ const Notification = ({ setInitialState, notificationAccessApps, initialState, t
14596
10405
  alignItems: "center",
14597
10406
  pT: 1
14598
10407
  },
14599
- children: /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { color: "#000", children: t2(ALERT_MESSAGES.commonLoadingMessage) })
10408
+ children: /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { color: "#000", children: t2(constants.ALERT_MESSAGES.commonLoadingMessage) })
14600
10409
  }
14601
10410
  ),
14602
10411
  scrollableTarget: "scrollableDiv",
14603
- children: !notifications.length && !hasMore ? /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { display: "flex", justifyContent: "center", color: "#000", children: t2(ALERT_MESSAGES.dataNoFount) }) : notifications.map((itm) => /* @__PURE__ */ jsxRuntime.jsxs(material.MenuItem, { sx: { bgcolor: "#fff", p: 2 }, children: [
10412
+ children: !notifications.length && !hasMore ? /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { display: "flex", justifyContent: "center", color: "#000", children: t2(constants.ALERT_MESSAGES.dataNoFount) }) : notifications.map((itm) => /* @__PURE__ */ jsxRuntime.jsxs(material.MenuItem, { sx: { bgcolor: "#fff", p: 2 }, children: [
14604
10413
  /* @__PURE__ */ jsxRuntime.jsx(material.Avatar, { sx: { bgcolor: "#ccc", mr: 1, color: "#000" }, children: getIcons(itm.type, itm?.source[0]) }),
14605
10414
  /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { flex: 1 }, children: [
14606
10415
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -14724,7 +10533,7 @@ const SubHeaderStyled = material.styled(material.AppBar)(() => ({
14724
10533
  const UserProfile = ({ t: t2, userData, setInitialState, extraMenuOptions, router }) => {
14725
10534
  const [state, setState] = React.useState({ toggles: { userProfile: false } });
14726
10535
  const handleRedirection2 = (appName, url2) => {
14727
- if (router && appName === APP_NAMES.sso) {
10536
+ if (router && appName === constants.APP_NAMES.sso) {
14728
10537
  router.push(url2);
14729
10538
  } else {
14730
10539
  window.open(url2, "_blank");
@@ -14823,7 +10632,7 @@ const UserProfile = ({ t: t2, userData, setInitialState, extraMenuOptions, route
14823
10632
  direction: "row",
14824
10633
  gap: 1,
14825
10634
  alignItems: "center",
14826
- onClick: () => handleRedirection2(userData?.appName, SSO_ROUTES(userData?.appName).editProfile),
10635
+ onClick: () => handleRedirection2(userData?.appName, constants.SSO_ROUTES(userData?.appName).editProfile),
14827
10636
  sx: { color: "#1A1919", textDecoration: "none" },
14828
10637
  children: [
14829
10638
  /* @__PURE__ */ jsxRuntime.jsx(SVG.UserEdit, { style: { width: "20px", height: "23px" } }),
@@ -14938,11 +10747,11 @@ const Header = ({
14938
10747
  });
14939
10748
  const handleLogout = async () => {
14940
10749
  setState((p) => ({ ...p, isLoading: true }));
14941
- CookiesUtil.remove(STORAGE_VALUES.previousLoginBanner);
10750
+ CookiesUtil.remove(constants.STORAGE_VALUES.previousLoginBanner);
14942
10751
  logoutHandler();
14943
10752
  };
14944
10753
  const getDropDownMenuData = async () => {
14945
- const res = await getDropDownMenuApi({ source: APP_NAMES.events, language_id: selectedInterFaceLang?.id });
10754
+ const res = await getDropDownMenuApi({ source: constants.APP_NAMES.events, language_id: selectedInterFaceLang?.id });
14946
10755
  if (res.remote === "success") {
14947
10756
  setState((p) => ({ ...p, menuData: res.data, isMenuIconsShow: res?.data?.length > 0 }));
14948
10757
  }
@@ -15458,26 +11267,26 @@ const ButtonStyled = material.styled("div")(() => ({
15458
11267
  }
15459
11268
  }));
15460
11269
  function Button({ isLoading = false, btnTitle, className, disabled = false, ...rest }) {
15461
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(ButtonStyled, { children: /* @__PURE__ */ jsxRuntime.jsx(material.Button, { disabled, className: `btn ${className}`, ...rest, size: "small", children: isLoading ? ALERT_MESSAGES.commonLoadingMessage : btnTitle }) }) });
11270
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(ButtonStyled, { children: /* @__PURE__ */ jsxRuntime.jsx(material.Button, { disabled, className: `btn ${className}`, ...rest, size: "small", children: isLoading ? constants.ALERT_MESSAGES.commonLoadingMessage : btnTitle }) }) });
15462
11271
  }
15463
11272
  const PreviousLoginBanner = ({ t: t2, router, sx }) => {
15464
- const previousLoginDetails = CookiesUtil.get(STORAGE_VALUES.previousLoginBanner) || {};
15465
- CookiesUtil.set(STORAGE_VALUES.previousLoginBanner, previousLoginDetails);
11273
+ const previousLoginDetails = CookiesUtil.get(constants.STORAGE_VALUES.previousLoginBanner) || {};
11274
+ CookiesUtil.set(constants.STORAGE_VALUES.previousLoginBanner, previousLoginDetails);
15466
11275
  const handleAutoLogin = async () => {
15467
11276
  try {
15468
11277
  const res = await autoLoginApi(previousLoginDetails?.id);
15469
11278
  if (res.remote === "success") {
15470
- CookiesUtil.remove(STORAGE_VALUES.previousLoginBanner);
11279
+ CookiesUtil.remove(constants.STORAGE_VALUES.previousLoginBanner);
15471
11280
  if (router) {
15472
11281
  router.reload();
15473
- router.replace(ROUTES.home);
11282
+ router.replace(constants.ROUTES.home);
15474
11283
  } else {
15475
11284
  window.location.reload();
15476
- window.location.href = ROUTES.home;
11285
+ window.location.href = constants.ROUTES.home;
15477
11286
  }
15478
11287
  }
15479
11288
  } catch (err) {
15480
- toast.error(t2(ALERT_MESSAGES.fallbackError));
11289
+ toast.error(t2(constants.ALERT_MESSAGES.fallbackError));
15481
11290
  }
15482
11291
  };
15483
11292
  return previousLoginDetails.id && previousLoginDetails.isAllowToAccess && /* @__PURE__ */ jsxRuntime.jsx(
@@ -15535,7 +11344,7 @@ const App = () => {
15535
11344
  company: "",
15536
11345
  certBio: "",
15537
11346
  certOfferToHelp: "",
15538
- appName: APP_NAMES.sso,
11347
+ appName: constants.APP_NAMES.sso,
15539
11348
  appAccess: [
15540
11349
  {
15541
11350
  name: "Tools",
@@ -15659,17 +11468,17 @@ const App = () => {
15659
11468
  /* @__PURE__ */ jsxRuntime.jsx(PreviousLoginBanner, { t: (s) => s })
15660
11469
  ] });
15661
11470
  };
11471
+ exports.FILTER_DATE_FORMAT = constants.FILTER_DATE_FORMAT;
11472
+ exports.MAIN_DATE_FORMAT = constants.MAIN_DATE_FORMAT;
11473
+ exports.MAIN_TIME_FORMAT = constants.MAIN_TIME_FORMAT;
11474
+ exports.SSO_ROUTES = constants.SSO_ROUTES;
11475
+ exports.STORAGE_VALUES = constants.STORAGE_VALUES;
15662
11476
  exports.CookiesUtil = CookiesUtil;
15663
11477
  exports.DangerDialog = DangerDialog;
15664
- exports.FILTER_DATE_FORMAT = FILTER_DATE_FORMAT;
15665
11478
  exports.Header = Header;
15666
11479
  exports.IMAGES = IMAGES;
15667
11480
  exports.Logo = Logo;
15668
- exports.MAIN_DATE_FORMAT = MAIN_DATE_FORMAT;
15669
- exports.MAIN_TIME_FORMAT = MAIN_TIME_FORMAT;
15670
11481
  exports.PreviousLoginBanner = PreviousLoginBanner;
15671
- exports.SSO_ROUTES = SSO_ROUTES;
15672
- exports.STORAGE_VALUES = STORAGE_VALUES;
15673
11482
  exports.SVG = SVG;
15674
11483
  exports.Warning = Warning;
15675
11484
  exports.default = App;