@instockng/storefront-ui 1.0.17 → 1.0.19

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.
Files changed (292) hide show
  1. package/dist/components/OrderConfirmation.d.ts +1 -1
  2. package/dist/components/OrderConfirmation.d.ts.map +1 -1
  3. package/dist/components/ShoppingCart.d.ts.map +1 -1
  4. package/dist/contexts/CartContext.d.ts +2 -2
  5. package/dist/contexts/CartContext.d.ts.map +1 -1
  6. package/dist/fetchers.d.ts +19 -0
  7. package/dist/fetchers.d.ts.map +1 -0
  8. package/dist/hooks/usePageTracking.d.ts +40 -0
  9. package/dist/hooks/usePageTracking.d.ts.map +1 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.mjs +101 -92
  13. package/dist/index10.mjs +149 -624
  14. package/dist/index100.mjs +22 -33
  15. package/dist/index101.mjs +22 -30
  16. package/dist/index102.mjs +32 -27
  17. package/dist/index103.mjs +152 -57
  18. package/dist/index104.mjs +20 -3
  19. package/dist/index105.mjs +31 -2
  20. package/dist/index106.mjs +84 -2
  21. package/dist/index107.mjs +37 -16
  22. package/dist/index108.mjs +144 -12
  23. package/dist/index109.mjs +55 -6
  24. package/dist/index11.mjs +94 -56
  25. package/dist/index110.mjs +23 -30
  26. package/dist/index111.mjs +30 -0
  27. package/dist/index112.mjs +26 -0
  28. package/dist/index113.mjs +28 -0
  29. package/dist/index114.mjs +24 -0
  30. package/dist/index115.mjs +25 -0
  31. package/dist/index116.mjs +24 -0
  32. package/dist/index117.mjs +68 -0
  33. package/dist/index118.mjs +21 -0
  34. package/dist/index119.mjs +42 -0
  35. package/dist/index12.mjs +645 -62
  36. package/dist/index120.mjs +27 -0
  37. package/dist/index121.mjs +37 -0
  38. package/dist/index122.mjs +30 -0
  39. package/dist/index123.mjs +22 -0
  40. package/dist/index124.mjs +24 -0
  41. package/dist/index125.mjs +50 -0
  42. package/dist/index126.mjs +26 -0
  43. package/dist/index127.mjs +271 -0
  44. package/dist/index128.mjs +73 -0
  45. package/dist/index129.mjs +11 -0
  46. package/dist/index13.mjs +50 -14
  47. package/dist/index130.mjs +5 -0
  48. package/dist/index131.mjs +5 -0
  49. package/dist/index132.mjs +36 -0
  50. package/dist/index133.mjs +5 -0
  51. package/dist/index134.mjs +24 -0
  52. package/dist/index135.mjs +59 -0
  53. package/dist/index136.mjs +32 -0
  54. package/dist/index137.mjs +10 -0
  55. package/dist/index138.mjs +55 -0
  56. package/dist/index139.mjs +9 -0
  57. package/dist/index14.mjs +62 -115
  58. package/dist/index140.mjs +15 -0
  59. package/dist/index141.mjs +10 -0
  60. package/dist/index142.mjs +31 -0
  61. package/dist/index143.mjs +5 -0
  62. package/dist/index144.mjs +73 -0
  63. package/dist/index145.mjs +170 -0
  64. package/dist/index146.mjs +5 -0
  65. package/dist/index147.mjs +5 -0
  66. package/dist/index148.mjs +5 -0
  67. package/dist/index149.mjs +21 -0
  68. package/dist/index15.mjs +23 -41
  69. package/dist/index150.mjs +35 -0
  70. package/dist/index151.mjs +41 -0
  71. package/dist/index152.mjs +21 -0
  72. package/dist/index153.mjs +21 -0
  73. package/dist/index154.mjs +5 -0
  74. package/dist/index155.mjs +23 -0
  75. package/dist/index156.mjs +49 -0
  76. package/dist/index157.mjs +5 -0
  77. package/dist/index158.mjs +33 -0
  78. package/dist/index159.mjs +21 -0
  79. package/dist/index16.mjs +115 -42
  80. package/dist/index160.mjs +5 -0
  81. package/dist/index161.mjs +5 -0
  82. package/dist/index162.mjs +5 -0
  83. package/dist/index163.mjs +5 -0
  84. package/dist/index164.mjs +75 -0
  85. package/dist/index165.mjs +5 -0
  86. package/dist/index166.mjs +56 -0
  87. package/dist/index167.mjs +5 -0
  88. package/dist/index168.mjs +39 -0
  89. package/dist/index169.mjs +155 -0
  90. package/dist/index17.mjs +42 -42
  91. package/dist/index170.mjs +5 -0
  92. package/dist/index171.mjs +5 -0
  93. package/dist/index172.mjs +22 -0
  94. package/dist/index173.mjs +5 -0
  95. package/dist/index174.mjs +5 -0
  96. package/dist/index175.mjs +29 -0
  97. package/dist/index176.mjs +5 -0
  98. package/dist/index177.mjs +5 -0
  99. package/dist/index178.mjs +27 -0
  100. package/dist/index179.mjs +26 -0
  101. package/dist/index18.mjs +41 -31
  102. package/dist/index180.mjs +5 -0
  103. package/dist/index181.mjs +5 -0
  104. package/dist/index182.mjs +5 -0
  105. package/dist/index183.mjs +26 -0
  106. package/dist/index184.mjs +5 -0
  107. package/dist/index185.mjs +26 -0
  108. package/dist/index186.mjs +5 -0
  109. package/dist/index187.mjs +5 -0
  110. package/dist/index188.mjs +5 -0
  111. package/dist/index189.mjs +26 -0
  112. package/dist/index19.mjs +40 -7
  113. package/dist/index190.mjs +5 -0
  114. package/dist/index191.mjs +26 -0
  115. package/dist/index192.mjs +5 -0
  116. package/dist/index193.mjs +5 -0
  117. package/dist/index194.mjs +5 -0
  118. package/dist/index195.mjs +5 -0
  119. package/dist/index196.mjs +5 -0
  120. package/dist/index197.mjs +5 -0
  121. package/dist/index198.mjs +5 -0
  122. package/dist/index199.mjs +5 -0
  123. package/dist/index2.mjs +31 -12
  124. package/dist/index20.mjs +27 -17
  125. package/dist/index200.mjs +130 -0
  126. package/dist/index201.mjs +5 -0
  127. package/dist/index202.mjs +77 -0
  128. package/dist/index203.mjs +77 -0
  129. package/dist/index204.mjs +5 -0
  130. package/dist/index205.mjs +5 -0
  131. package/dist/index206.mjs +111 -0
  132. package/dist/index207.mjs +5 -0
  133. package/dist/index208.mjs +5 -0
  134. package/dist/index209.mjs +5 -0
  135. package/dist/index21.mjs +6 -29
  136. package/dist/index210.mjs +5 -0
  137. package/dist/index211.mjs +5 -0
  138. package/dist/index212.mjs +5 -0
  139. package/dist/index213.mjs +5 -0
  140. package/dist/index214.mjs +5 -0
  141. package/dist/index215.mjs +5 -0
  142. package/dist/index216.mjs +40 -0
  143. package/dist/index217.mjs +5 -0
  144. package/dist/index218.mjs +5 -0
  145. package/dist/index219.mjs +5 -0
  146. package/dist/index22.mjs +20 -18
  147. package/dist/index220.mjs +247 -0
  148. package/dist/index221.mjs +5 -0
  149. package/dist/index222.mjs +36 -0
  150. package/dist/index223.mjs +68 -0
  151. package/dist/index224.mjs +28 -0
  152. package/dist/index225.mjs +5 -0
  153. package/dist/index226.mjs +5 -0
  154. package/dist/index227.mjs +5 -0
  155. package/dist/index228.mjs +5 -0
  156. package/dist/index229.mjs +5 -0
  157. package/dist/index23.mjs +32 -87
  158. package/dist/index230.mjs +5 -0
  159. package/dist/index231.mjs +5 -0
  160. package/dist/index232.mjs +5 -0
  161. package/dist/index233.mjs +7 -0
  162. package/dist/index234.mjs +5 -0
  163. package/dist/index235.mjs +5 -0
  164. package/dist/index236.mjs +34 -0
  165. package/dist/index237.mjs +14 -0
  166. package/dist/index238.mjs +7 -0
  167. package/dist/index239.mjs +7 -0
  168. package/dist/index24.mjs +12 -12
  169. package/dist/index240.mjs +16 -0
  170. package/dist/index241.mjs +10 -0
  171. package/dist/index242.mjs +15 -0
  172. package/dist/index243.mjs +8 -0
  173. package/dist/index244.mjs +36 -0
  174. package/dist/index245.mjs +34 -0
  175. package/dist/index246.mjs +31 -0
  176. package/dist/index247.mjs +64 -0
  177. package/dist/index248.mjs +5 -0
  178. package/dist/index249.mjs +5 -0
  179. package/dist/index25.mjs +85 -8
  180. package/dist/index250.mjs +21 -0
  181. package/dist/index251.mjs +50 -0
  182. package/dist/index252.mjs +5 -0
  183. package/dist/index253.mjs +5 -0
  184. package/dist/index254.mjs +5 -0
  185. package/dist/index255.mjs +5 -0
  186. package/dist/index256.mjs +94 -0
  187. package/dist/index257.mjs +5 -0
  188. package/dist/index258.mjs +6 -0
  189. package/dist/index259.mjs +5 -0
  190. package/dist/index26.mjs +20 -97
  191. package/dist/index260.mjs +5 -0
  192. package/dist/index261.mjs +20 -0
  193. package/dist/index262.mjs +16 -0
  194. package/dist/index263.mjs +9 -0
  195. package/dist/index264.mjs +33 -0
  196. package/dist/index265.mjs +5 -0
  197. package/dist/index266.mjs +5 -0
  198. package/dist/index267.mjs +5 -0
  199. package/dist/index27.mjs +11 -18
  200. package/dist/index28.mjs +11 -65
  201. package/dist/index29.mjs +94 -89
  202. package/dist/index3.mjs +117 -97
  203. package/dist/index30.mjs +20 -19
  204. package/dist/index31.mjs +65 -19
  205. package/dist/index32.mjs +93 -8
  206. package/dist/index33.mjs +18 -1432
  207. package/dist/index34.mjs +19 -2
  208. package/dist/index35.mjs +10 -56
  209. package/dist/index36.mjs +9 -49
  210. package/dist/index37.mjs +103 -33
  211. package/dist/index38.mjs +24 -14
  212. package/dist/index39.mjs +1411 -2241
  213. package/dist/index4.mjs +82 -197
  214. package/dist/index40.mjs +2 -36
  215. package/dist/index41.mjs +56 -43
  216. package/dist/index42.mjs +50 -98
  217. package/dist/index43.mjs +33 -97
  218. package/dist/index44.mjs +13 -79
  219. package/dist/index45.mjs +2255 -69
  220. package/dist/index46.mjs +36 -95
  221. package/dist/index47.mjs +43 -80
  222. package/dist/index48.mjs +99 -79
  223. package/dist/index49.mjs +93 -15
  224. package/dist/index5.mjs +15 -108
  225. package/dist/index50.mjs +77 -14
  226. package/dist/index51.mjs +58 -44
  227. package/dist/index52.mjs +63 -93
  228. package/dist/index53.mjs +51 -99
  229. package/dist/index54.mjs +78 -4
  230. package/dist/index55.mjs +18 -22
  231. package/dist/index56.mjs +17 -74
  232. package/dist/index57.mjs +63 -15
  233. package/dist/index58.mjs +121 -59
  234. package/dist/index59.mjs +122 -228
  235. package/dist/index6.mjs +190 -73
  236. package/dist/index60.mjs +23 -5
  237. package/dist/index61.mjs +145 -126
  238. package/dist/index62.mjs +2 -68
  239. package/dist/index63.mjs +22 -86
  240. package/dist/index64.mjs +73 -27
  241. package/dist/index65.mjs +15 -9
  242. package/dist/index66.mjs +58 -70
  243. package/dist/index67.mjs +4 -3
  244. package/dist/index68.mjs +2 -2
  245. package/dist/index69.mjs +5 -82
  246. package/dist/index7.mjs +97 -85
  247. package/dist/index70.mjs +1133 -53
  248. package/dist/index71.mjs +19 -5
  249. package/dist/index72.mjs +54 -4
  250. package/dist/index73.mjs +28 -174
  251. package/dist/index74.mjs +2 -53
  252. package/dist/index75.mjs +2 -69
  253. package/dist/index76.mjs +231 -30
  254. package/dist/index77.mjs +5 -42
  255. package/dist/index78.mjs +133 -3
  256. package/dist/index79.mjs +68 -2
  257. package/dist/index8.mjs +78 -162
  258. package/dist/index80.mjs +85 -19
  259. package/dist/index81.mjs +26 -53
  260. package/dist/index82.mjs +8 -28
  261. package/dist/index83.mjs +74 -6
  262. package/dist/index84.mjs +3 -51
  263. package/dist/index85.mjs +2 -6
  264. package/dist/index86.mjs +81 -10
  265. package/dist/index87.mjs +53 -6
  266. package/dist/index88.mjs +5 -27
  267. package/dist/index89.mjs +5 -2
  268. package/dist/index9.mjs +90 -90
  269. package/dist/index90.mjs +175 -66
  270. package/dist/index91.mjs +49 -163
  271. package/dist/index92.mjs +68 -30
  272. package/dist/index93.mjs +34 -11
  273. package/dist/index94.mjs +42 -3
  274. package/dist/index95.mjs +2 -4
  275. package/dist/index96.mjs +28 -13
  276. package/dist/index97.mjs +18 -7
  277. package/dist/index98.mjs +214 -11
  278. package/dist/index99.mjs +179 -4
  279. package/dist/providers/MetaPixelProvider.d.ts +98 -0
  280. package/dist/providers/MetaPixelProvider.d.ts.map +1 -0
  281. package/dist/providers/StorefrontProvider.d.ts +1 -0
  282. package/dist/providers/StorefrontProvider.d.ts.map +1 -1
  283. package/dist/styles.css +1 -1
  284. package/package.json +8 -3
  285. package/src/components/OrderConfirmation.tsx +0 -2
  286. package/src/components/ShoppingCart.tsx +12 -1
  287. package/src/contexts/CartContext.tsx +30 -5
  288. package/src/fetchers.ts +33 -0
  289. package/src/hooks/usePageTracking.ts +72 -0
  290. package/src/index.ts +5 -0
  291. package/src/providers/MetaPixelProvider.tsx +236 -0
  292. package/src/providers/StorefrontProvider.tsx +29 -3
package/dist/index33.mjs CHANGED
@@ -1,1436 +1,22 @@
1
1
  'use client';
2
- import { p as S } from "./index56.mjs";
3
- import { t as U } from "./index57.mjs";
4
- import he from "./index58.mjs";
5
- const fe = Object.prototype.toString, de = Error.prototype.toString, pe = RegExp.prototype.toString, me = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", ye = /^Symbol\((.*)\)(.*)$/;
6
- function ge(n) {
7
- return n != +n ? "NaN" : n === 0 && 1 / n < 0 ? "-0" : "" + n;
2
+ import { useMutation as t } from "@tanstack/react-query";
3
+ import { useQueryUnwrapped as u } from "./index67.mjs";
4
+ import { queryKeys as n } from "./index29.mjs";
5
+ import { confirmOrder as i, fetchOrder as m } from "./index26.mjs";
6
+ function y(e, r, o) {
7
+ return u({
8
+ queryKey: n.public.orders.detail(e, r),
9
+ queryFn: () => m(e, r),
10
+ ...o
11
+ });
12
+ }
13
+ function c(e) {
14
+ return t({
15
+ mutationFn: (r) => i(r.orderId, r.token),
16
+ ...e
17
+ });
8
18
  }
9
- function H(n, t = !1) {
10
- if (n == null || n === !0 || n === !1) return "" + n;
11
- const e = typeof n;
12
- if (e === "number") return ge(n);
13
- if (e === "string") return t ? `"${n}"` : n;
14
- if (e === "function") return "[Function " + (n.name || "anonymous") + "]";
15
- if (e === "symbol") return me.call(n).replace(ye, "Symbol($1)");
16
- const r = fe.call(n).slice(8, -1);
17
- return r === "Date" ? isNaN(n.getTime()) ? "" + n : n.toISOString(n) : r === "Error" || n instanceof Error ? "[" + de.call(n) + "]" : r === "RegExp" ? pe.call(n) : null;
18
- }
19
- function x(n, t) {
20
- let e = H(n, t);
21
- return e !== null ? e : JSON.stringify(n, function(r, s) {
22
- let i = H(this[r], t);
23
- return i !== null ? i : s;
24
- }, 2);
25
- }
26
- function te(n) {
27
- return n == null ? [] : [].concat(n);
28
- }
29
- let re, se, ne, be = /\$\{\s*(\w+)\s*\}/g;
30
- re = Symbol.toStringTag;
31
- class Q {
32
- constructor(t, e, r, s) {
33
- this.name = void 0, this.message = void 0, this.value = void 0, this.path = void 0, this.type = void 0, this.params = void 0, this.errors = void 0, this.inner = void 0, this[re] = "Error", this.name = "ValidationError", this.value = e, this.path = r, this.type = s, this.errors = [], this.inner = [], te(t).forEach((i) => {
34
- if (p.isError(i)) {
35
- this.errors.push(...i.errors);
36
- const a = i.inner.length ? i.inner : [i];
37
- this.inner.push(...a);
38
- } else
39
- this.errors.push(i);
40
- }), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
41
- }
42
- }
43
- se = Symbol.hasInstance;
44
- ne = Symbol.toStringTag;
45
- class p extends Error {
46
- static formatError(t, e) {
47
- const r = e.label || e.path || "this";
48
- return e = Object.assign({}, e, {
49
- path: r,
50
- originalPath: e.path
51
- }), typeof t == "string" ? t.replace(be, (s, i) => x(e[i])) : typeof t == "function" ? t(e) : t;
52
- }
53
- static isError(t) {
54
- return t && t.name === "ValidationError";
55
- }
56
- constructor(t, e, r, s, i) {
57
- const a = new Q(t, e, r, s);
58
- if (i)
59
- return a;
60
- super(), this.value = void 0, this.path = void 0, this.type = void 0, this.params = void 0, this.errors = [], this.inner = [], this[ne] = "Error", this.name = a.name, this.message = a.message, this.type = a.type, this.value = a.value, this.path = a.path, this.errors = a.errors, this.inner = a.inner, Error.captureStackTrace && Error.captureStackTrace(this, p);
61
- }
62
- static [se](t) {
63
- return Q[Symbol.hasInstance](t) || super[Symbol.hasInstance](t);
64
- }
65
- }
66
- let F = {
67
- default: "${path} is invalid",
68
- required: "${path} is a required field",
69
- defined: "${path} must be defined",
70
- notNull: "${path} cannot be null",
71
- oneOf: "${path} must be one of the following values: ${values}",
72
- notOneOf: "${path} must not be one of the following values: ${values}",
73
- notType: ({
74
- path: n,
75
- type: t,
76
- value: e,
77
- originalValue: r
78
- }) => {
79
- const s = r != null && r !== e ? ` (cast from the value \`${x(r, !0)}\`).` : ".";
80
- return t !== "mixed" ? `${n} must be a \`${t}\` type, but the final value was: \`${x(e, !0)}\`` + s : `${n} must match the configured type. The validated value was: \`${x(e, !0)}\`` + s;
81
- }
82
- }, m = {
83
- length: "${path} must be exactly ${length} characters",
84
- min: "${path} must be at least ${min} characters",
85
- max: "${path} must be at most ${max} characters",
86
- matches: '${path} must match the following: "${regex}"',
87
- email: "${path} must be a valid email",
88
- url: "${path} must be a valid URL",
89
- uuid: "${path} must be a valid UUID",
90
- datetime: "${path} must be a valid ISO date-time",
91
- datetime_precision: "${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",
92
- datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
93
- trim: "${path} must be a trimmed string",
94
- lowercase: "${path} must be a lowercase string",
95
- uppercase: "${path} must be a upper case string"
96
- }, Fe = {
97
- min: "${path} must be greater than or equal to ${min}",
98
- max: "${path} must be less than or equal to ${max}",
99
- lessThan: "${path} must be less than ${less}",
100
- moreThan: "${path} must be greater than ${more}",
101
- positive: "${path} must be a positive number",
102
- negative: "${path} must be a negative number",
103
- integer: "${path} must be an integer"
104
- }, q = {
105
- min: "${path} field must be later than ${min}",
106
- max: "${path} field must be at earlier than ${max}"
107
- }, $e = {
108
- isValue: "${path} field must be ${value}"
109
- }, C = {
110
- noUnknown: "${path} field has unspecified keys: ${unknown}",
111
- exact: "${path} object contains unknown properties: ${properties}"
112
- }, Oe = {
113
- min: "${path} field must have at least ${min} items",
114
- max: "${path} field must have less than or equal to ${max} items",
115
- length: "${path} must have ${length} items"
116
- }, we = {
117
- notType: (n) => {
118
- const {
119
- path: t,
120
- value: e,
121
- spec: r
122
- } = n, s = r.types.length;
123
- if (Array.isArray(e)) {
124
- if (e.length < s) return `${t} tuple value has too few items, expected a length of ${s} but got ${e.length} for value: \`${x(e, !0)}\``;
125
- if (e.length > s) return `${t} tuple value has too many items, expected a length of ${s} but got ${e.length} for value: \`${x(e, !0)}\``;
126
- }
127
- return p.formatError(F.notType, n);
128
- }
129
- };
130
- Object.assign(/* @__PURE__ */ Object.create(null), {
131
- mixed: F,
132
- string: m,
133
- number: Fe,
134
- date: q,
135
- object: C,
136
- array: Oe,
137
- boolean: $e,
138
- tuple: we
139
- });
140
- const L = (n) => n && n.__isYupSchema__;
141
- class R {
142
- static fromOptions(t, e) {
143
- if (!e.then && !e.otherwise) throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
144
- let {
145
- is: r,
146
- then: s,
147
- otherwise: i
148
- } = e, a = typeof r == "function" ? r : (...l) => l.every((u) => u === r);
149
- return new R(t, (l, u) => {
150
- var o;
151
- let c = a(...l) ? s : i;
152
- return (o = c == null ? void 0 : c(u)) != null ? o : u;
153
- });
154
- }
155
- constructor(t, e) {
156
- this.fn = void 0, this.refs = t, this.refs = t, this.fn = e;
157
- }
158
- resolve(t, e) {
159
- let r = this.refs.map((i) => (
160
- // TODO: ? operator here?
161
- i.getValue(e == null ? void 0 : e.value, e == null ? void 0 : e.parent, e == null ? void 0 : e.context)
162
- )), s = this.fn(r, t, e);
163
- if (s === void 0 || // @ts-ignore this can be base
164
- s === t)
165
- return t;
166
- if (!L(s)) throw new TypeError("conditions must return a schema object");
167
- return s.resolve(e);
168
- }
169
- }
170
- const N = {
171
- context: "$",
172
- value: "."
173
- };
174
- class E {
175
- constructor(t, e = {}) {
176
- if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof t != "string") throw new TypeError("ref must be a string, got: " + t);
177
- if (this.key = t.trim(), t === "") throw new TypeError("ref must be a non-empty string");
178
- this.isContext = this.key[0] === N.context, this.isValue = this.key[0] === N.value, this.isSibling = !this.isContext && !this.isValue;
179
- let r = this.isContext ? N.context : this.isValue ? N.value : "";
180
- this.path = this.key.slice(r.length), this.getter = this.path && S.getter(this.path, !0), this.map = e.map;
181
- }
182
- getValue(t, e, r) {
183
- let s = this.isContext ? r : this.isValue ? t : e;
184
- return this.getter && (s = this.getter(s || {})), this.map && (s = this.map(s)), s;
185
- }
186
- /**
187
- *
188
- * @param {*} value
189
- * @param {Object} options
190
- * @param {Object=} options.context
191
- * @param {Object=} options.parent
192
- */
193
- cast(t, e) {
194
- return this.getValue(t, e == null ? void 0 : e.parent, e == null ? void 0 : e.context);
195
- }
196
- resolve() {
197
- return this;
198
- }
199
- describe() {
200
- return {
201
- type: "ref",
202
- key: this.key
203
- };
204
- }
205
- toString() {
206
- return `Ref(${this.key})`;
207
- }
208
- static isRef(t) {
209
- return t && t.__isYupRef;
210
- }
211
- }
212
- E.prototype.__isYupRef = !0;
213
- const v = (n) => n == null;
214
- function k(n) {
215
- function t({
216
- value: e,
217
- path: r = "",
218
- options: s,
219
- originalValue: i,
220
- schema: a
221
- }, l, u) {
222
- const {
223
- name: o,
224
- test: c,
225
- params: h,
226
- message: f,
227
- skipAbsent: g
228
- } = n;
229
- let {
230
- parent: b,
231
- context: y,
232
- abortEarly: w = a.spec.abortEarly,
233
- disableStackTrace: D = a.spec.disableStackTrace
234
- } = s;
235
- const _ = {
236
- value: e,
237
- parent: b,
238
- context: y
239
- };
240
- function K(d = {}) {
241
- const A = ie(Object.assign({
242
- value: e,
243
- originalValue: i,
244
- label: a.spec.label,
245
- path: d.path || r,
246
- spec: a.spec,
247
- disableStackTrace: d.disableStackTrace || D
248
- }, h, d.params), _), G = new p(p.formatError(d.message || f, A), e, A.path, d.type || o, A.disableStackTrace);
249
- return G.params = A, G;
250
- }
251
- const M = w ? l : u;
252
- let z = {
253
- path: r,
254
- parent: b,
255
- type: o,
256
- from: s.from,
257
- createError: K,
258
- resolve(d) {
259
- return ae(d, _);
260
- },
261
- options: s,
262
- originalValue: i,
263
- schema: a
264
- };
265
- const V = (d) => {
266
- p.isError(d) ? M(d) : d ? u(null) : M(K());
267
- }, B = (d) => {
268
- p.isError(d) ? M(d) : l(d);
269
- };
270
- if (g && v(e))
271
- return V(!0);
272
- let j;
273
- try {
274
- var J;
275
- if (j = c.call(z, e, z), typeof ((J = j) == null ? void 0 : J.then) == "function") {
276
- if (s.sync)
277
- throw new Error(`Validation test of type: "${z.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
278
- return Promise.resolve(j).then(V, B);
279
- }
280
- } catch (d) {
281
- B(d);
282
- return;
283
- }
284
- V(j);
285
- }
286
- return t.OPTIONS = n, t;
287
- }
288
- function ie(n, t) {
289
- if (!n) return n;
290
- for (const e of Object.keys(n))
291
- n[e] = ae(n[e], t);
292
- return n;
293
- }
294
- function ae(n, t) {
295
- return E.isRef(n) ? n.getValue(t.value, t.parent, t.context) : n;
296
- }
297
- function xe(n, t, e, r = e) {
298
- let s, i, a;
299
- return t ? (S.forEach(t, (l, u, o) => {
300
- let c = u ? l.slice(1, l.length - 1) : l;
301
- n = n.resolve({
302
- context: r,
303
- parent: s,
304
- value: e
305
- });
306
- let h = n.type === "tuple", f = o ? parseInt(c, 10) : 0;
307
- if (n.innerType || h) {
308
- if (h && !o) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);
309
- if (e && f >= e.length)
310
- throw new Error(`Yup.reach cannot resolve an array item at index: ${l}, in the path: ${t}. because there is no value at that index. `);
311
- s = e, e = e && e[f], n = h ? n.spec.types[f] : n.innerType;
312
- }
313
- if (!o) {
314
- if (!n.fields || !n.fields[c]) throw new Error(`The schema does not contain the path: ${t}. (failed at: ${a} which is a type: "${n.type}")`);
315
- s = e, e = e && e[c], n = n.fields[c];
316
- }
317
- i = c, a = u ? "[" + l + "]" : "." + l;
318
- }), {
319
- schema: n,
320
- parent: s,
321
- parentPath: i
322
- }) : {
323
- parent: s,
324
- parentPath: t,
325
- schema: n
326
- };
327
- }
328
- class P extends Set {
329
- describe() {
330
- const t = [];
331
- for (const e of this.values())
332
- t.push(E.isRef(e) ? e.describe() : e);
333
- return t;
334
- }
335
- resolveAll(t) {
336
- let e = [];
337
- for (const r of this.values())
338
- e.push(t(r));
339
- return e;
340
- }
341
- clone() {
342
- return new P(this.values());
343
- }
344
- merge(t, e) {
345
- const r = this.clone();
346
- return t.forEach((s) => r.add(s)), e.forEach((s) => r.delete(s)), r;
347
- }
348
- }
349
- function T(n, t = /* @__PURE__ */ new Map()) {
350
- if (L(n) || !n || typeof n != "object") return n;
351
- if (t.has(n)) return t.get(n);
352
- let e;
353
- if (n instanceof Date)
354
- e = new Date(n.getTime()), t.set(n, e);
355
- else if (n instanceof RegExp)
356
- e = new RegExp(n), t.set(n, e);
357
- else if (Array.isArray(n)) {
358
- e = new Array(n.length), t.set(n, e);
359
- for (let r = 0; r < n.length; r++) e[r] = T(n[r], t);
360
- } else if (n instanceof Map) {
361
- e = /* @__PURE__ */ new Map(), t.set(n, e);
362
- for (const [r, s] of n.entries()) e.set(r, T(s, t));
363
- } else if (n instanceof Set) {
364
- e = /* @__PURE__ */ new Set(), t.set(n, e);
365
- for (const r of n) e.add(T(r, t));
366
- } else if (n instanceof Object) {
367
- e = {}, t.set(n, e);
368
- for (const [r, s] of Object.entries(n)) e[r] = T(s, t);
369
- } else
370
- throw Error(`Unable to clone ${n}`);
371
- return e;
372
- }
373
- function _e(n) {
374
- if (!(n != null && n.length))
375
- return;
376
- const t = [];
377
- let e = "", r = !1, s = !1;
378
- for (let i = 0; i < n.length; i++) {
379
- const a = n[i];
380
- if (a === "[" && !s) {
381
- e && (t.push(...e.split(".").filter(Boolean)), e = ""), r = !0;
382
- continue;
383
- }
384
- if (a === "]" && !s) {
385
- e && (/^\d+$/.test(e) ? t.push(e) : t.push(e.replace(/^"|"$/g, "")), e = ""), r = !1;
386
- continue;
387
- }
388
- if (a === '"') {
389
- s = !s;
390
- continue;
391
- }
392
- if (a === "." && !r && !s) {
393
- e && (t.push(e), e = "");
394
- continue;
395
- }
396
- e += a;
397
- }
398
- return e && t.push(...e.split(".").filter(Boolean)), t;
399
- }
400
- function ve(n, t) {
401
- const e = t ? `${t}.${n.path}` : n.path;
402
- return n.errors.map((r) => ({
403
- message: r,
404
- path: _e(e)
405
- }));
406
- }
407
- function le(n, t) {
408
- var e;
409
- if (!((e = n.inner) != null && e.length) && n.errors.length)
410
- return ve(n, t);
411
- const r = t ? `${t}.${n.path}` : n.path;
412
- return n.inner.flatMap((s) => le(s, r));
413
- }
414
- class $ {
415
- constructor(t) {
416
- this.type = void 0, this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this.internalTests = {}, this._whitelist = new P(), this._blacklist = new P(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this._typeCheck = void 0, this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
417
- this.typeError(F.notType);
418
- }), this.type = t.type, this._typeCheck = t.check, this.spec = Object.assign({
419
- strip: !1,
420
- strict: !1,
421
- abortEarly: !0,
422
- recursive: !0,
423
- disableStackTrace: !1,
424
- nullable: !1,
425
- optional: !0,
426
- coerce: !0
427
- }, t == null ? void 0 : t.spec), this.withMutation((e) => {
428
- e.nonNullable();
429
- });
430
- }
431
- // TODO: remove
432
- get _type() {
433
- return this.type;
434
- }
435
- clone(t) {
436
- if (this._mutate)
437
- return t && Object.assign(this.spec, t), this;
438
- const e = Object.create(Object.getPrototypeOf(this));
439
- return e.type = this.type, e._typeCheck = this._typeCheck, e._whitelist = this._whitelist.clone(), e._blacklist = this._blacklist.clone(), e.internalTests = Object.assign({}, this.internalTests), e.exclusiveTests = Object.assign({}, this.exclusiveTests), e.deps = [...this.deps], e.conditions = [...this.conditions], e.tests = [...this.tests], e.transforms = [...this.transforms], e.spec = T(Object.assign({}, this.spec, t)), e;
440
- }
441
- label(t) {
442
- let e = this.clone();
443
- return e.spec.label = t, e;
444
- }
445
- meta(...t) {
446
- if (t.length === 0) return this.spec.meta;
447
- let e = this.clone();
448
- return e.spec.meta = Object.assign(e.spec.meta || {}, t[0]), e;
449
- }
450
- withMutation(t) {
451
- let e = this._mutate;
452
- this._mutate = !0;
453
- let r = t(this);
454
- return this._mutate = e, r;
455
- }
456
- concat(t) {
457
- if (!t || t === this) return this;
458
- if (t.type !== this.type && this.type !== "mixed") throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);
459
- let e = this, r = t.clone();
460
- const s = Object.assign({}, e.spec, r.spec);
461
- return r.spec = s, r.internalTests = Object.assign({}, e.internalTests, r.internalTests), r._whitelist = e._whitelist.merge(t._whitelist, t._blacklist), r._blacklist = e._blacklist.merge(t._blacklist, t._whitelist), r.tests = e.tests, r.exclusiveTests = e.exclusiveTests, r.withMutation((i) => {
462
- t.tests.forEach((a) => {
463
- i.test(a.OPTIONS);
464
- });
465
- }), r.transforms = [...e.transforms, ...r.transforms], r;
466
- }
467
- isType(t) {
468
- return t == null ? !!(this.spec.nullable && t === null || this.spec.optional && t === void 0) : this._typeCheck(t);
469
- }
470
- resolve(t) {
471
- let e = this;
472
- if (e.conditions.length) {
473
- let r = e.conditions;
474
- e = e.clone(), e.conditions = [], e = r.reduce((s, i) => i.resolve(s, t), e), e = e.resolve(t);
475
- }
476
- return e;
477
- }
478
- resolveOptions(t) {
479
- var e, r, s, i;
480
- return Object.assign({}, t, {
481
- from: t.from || [],
482
- strict: (e = t.strict) != null ? e : this.spec.strict,
483
- abortEarly: (r = t.abortEarly) != null ? r : this.spec.abortEarly,
484
- recursive: (s = t.recursive) != null ? s : this.spec.recursive,
485
- disableStackTrace: (i = t.disableStackTrace) != null ? i : this.spec.disableStackTrace
486
- });
487
- }
488
- /**
489
- * Run the configured transform pipeline over an input value.
490
- */
491
- cast(t, e = {}) {
492
- let r = this.resolve(Object.assign({}, e, {
493
- value: t
494
- // parent: options.parent,
495
- // context: options.context,
496
- })), s = e.assert === "ignore-optionality", i = r._cast(t, e);
497
- if (e.assert !== !1 && !r.isType(i)) {
498
- if (s && v(i))
499
- return i;
500
- let a = x(t), l = x(i);
501
- throw new TypeError(`The value of ${e.path || "field"} could not be cast to a value that satisfies the schema type: "${r.type}".
502
-
503
- attempted value: ${a}
504
- ` + (l !== a ? `result of cast: ${l}` : ""));
505
- }
506
- return i;
507
- }
508
- _cast(t, e) {
509
- let r = t === void 0 ? t : this.transforms.reduce((s, i) => i.call(this, s, t, this, e), t);
510
- return r === void 0 && (r = this.getDefault(e)), r;
511
- }
512
- _validate(t, e = {}, r, s) {
513
- let {
514
- path: i,
515
- originalValue: a = t,
516
- strict: l = this.spec.strict
517
- } = e, u = t;
518
- l || (u = this._cast(u, Object.assign({
519
- assert: !1
520
- }, e)));
521
- let o = [];
522
- for (let c of Object.values(this.internalTests))
523
- c && o.push(c);
524
- this.runTests({
525
- path: i,
526
- value: u,
527
- originalValue: a,
528
- options: e,
529
- tests: o
530
- }, r, (c) => {
531
- if (c.length)
532
- return s(c, u);
533
- this.runTests({
534
- path: i,
535
- value: u,
536
- originalValue: a,
537
- options: e,
538
- tests: this.tests
539
- }, r, s);
540
- });
541
- }
542
- /**
543
- * Executes a set of validations, either schema, produced Tests or a nested
544
- * schema validate result.
545
- */
546
- runTests(t, e, r) {
547
- let s = !1, {
548
- tests: i,
549
- value: a,
550
- originalValue: l,
551
- path: u,
552
- options: o
553
- } = t, c = (y) => {
554
- s || (s = !0, e(y, a));
555
- }, h = (y) => {
556
- s || (s = !0, r(y, a));
557
- }, f = i.length, g = [];
558
- if (!f) return h([]);
559
- let b = {
560
- value: a,
561
- originalValue: l,
562
- path: u,
563
- options: o,
564
- schema: this
565
- };
566
- for (let y = 0; y < i.length; y++) {
567
- const w = i[y];
568
- w(b, c, function(_) {
569
- _ && (Array.isArray(_) ? g.push(..._) : g.push(_)), --f <= 0 && h(g);
570
- });
571
- }
572
- }
573
- asNestedTest({
574
- key: t,
575
- index: e,
576
- parent: r,
577
- parentPath: s,
578
- originalParent: i,
579
- options: a
580
- }) {
581
- const l = t ?? e;
582
- if (l == null)
583
- throw TypeError("Must include `key` or `index` for nested validations");
584
- const u = typeof l == "number";
585
- let o = r[l];
586
- const c = Object.assign({}, a, {
587
- // Nested validations fields are always strict:
588
- // 1. parent isn't strict so the casting will also have cast inner values
589
- // 2. parent is strict in which case the nested values weren't cast either
590
- strict: !0,
591
- parent: r,
592
- value: o,
593
- originalValue: i[l],
594
- // FIXME: tests depend on `index` being passed around deeply,
595
- // we should not let the options.key/index bleed through
596
- key: void 0,
597
- // index: undefined,
598
- [u ? "index" : "key"]: l,
599
- path: u || l.includes(".") ? `${s || ""}[${u ? l : `"${l}"`}]` : (s ? `${s}.` : "") + t
600
- });
601
- return (h, f, g) => this.resolve(c)._validate(o, c, f, g);
602
- }
603
- validate(t, e) {
604
- var r;
605
- let s = this.resolve(Object.assign({}, e, {
606
- value: t
607
- })), i = (r = e == null ? void 0 : e.disableStackTrace) != null ? r : s.spec.disableStackTrace;
608
- return new Promise((a, l) => s._validate(t, e, (u, o) => {
609
- p.isError(u) && (u.value = o), l(u);
610
- }, (u, o) => {
611
- u.length ? l(new p(u, o, void 0, void 0, i)) : a(o);
612
- }));
613
- }
614
- validateSync(t, e) {
615
- var r;
616
- let s = this.resolve(Object.assign({}, e, {
617
- value: t
618
- })), i, a = (r = e == null ? void 0 : e.disableStackTrace) != null ? r : s.spec.disableStackTrace;
619
- return s._validate(t, Object.assign({}, e, {
620
- sync: !0
621
- }), (l, u) => {
622
- throw p.isError(l) && (l.value = u), l;
623
- }, (l, u) => {
624
- if (l.length) throw new p(l, t, void 0, void 0, a);
625
- i = u;
626
- }), i;
627
- }
628
- isValid(t, e) {
629
- return this.validate(t, e).then(() => !0, (r) => {
630
- if (p.isError(r)) return !1;
631
- throw r;
632
- });
633
- }
634
- isValidSync(t, e) {
635
- try {
636
- return this.validateSync(t, e), !0;
637
- } catch (r) {
638
- if (p.isError(r)) return !1;
639
- throw r;
640
- }
641
- }
642
- _getDefault(t) {
643
- let e = this.spec.default;
644
- return e == null ? e : typeof e == "function" ? e.call(this, t) : T(e);
645
- }
646
- getDefault(t) {
647
- return this.resolve(t || {})._getDefault(t);
648
- }
649
- default(t) {
650
- return arguments.length === 0 ? this._getDefault() : this.clone({
651
- default: t
652
- });
653
- }
654
- strict(t = !0) {
655
- return this.clone({
656
- strict: t
657
- });
658
- }
659
- nullability(t, e) {
660
- const r = this.clone({
661
- nullable: t
662
- });
663
- return r.internalTests.nullable = k({
664
- message: e,
665
- name: "nullable",
666
- test(s) {
667
- return s === null ? this.schema.spec.nullable : !0;
668
- }
669
- }), r;
670
- }
671
- optionality(t, e) {
672
- const r = this.clone({
673
- optional: t
674
- });
675
- return r.internalTests.optionality = k({
676
- message: e,
677
- name: "optionality",
678
- test(s) {
679
- return s === void 0 ? this.schema.spec.optional : !0;
680
- }
681
- }), r;
682
- }
683
- optional() {
684
- return this.optionality(!0);
685
- }
686
- defined(t = F.defined) {
687
- return this.optionality(!1, t);
688
- }
689
- nullable() {
690
- return this.nullability(!0);
691
- }
692
- nonNullable(t = F.notNull) {
693
- return this.nullability(!1, t);
694
- }
695
- required(t = F.required) {
696
- return this.clone().withMutation((e) => e.nonNullable(t).defined(t));
697
- }
698
- notRequired() {
699
- return this.clone().withMutation((t) => t.nullable().optional());
700
- }
701
- transform(t) {
702
- let e = this.clone();
703
- return e.transforms.push(t), e;
704
- }
705
- /**
706
- * Adds a test function to the schema's queue of tests.
707
- * tests can be exclusive or non-exclusive.
708
- *
709
- * - exclusive tests, will replace any existing tests of the same name.
710
- * - non-exclusive: can be stacked
711
- *
712
- * If a non-exclusive test is added to a schema with an exclusive test of the same name
713
- * the exclusive test is removed and further tests of the same name will be stacked.
714
- *
715
- * If an exclusive test is added to a schema with non-exclusive tests of the same name
716
- * the previous tests are removed and further tests of the same name will replace each other.
717
- */
718
- test(...t) {
719
- let e;
720
- if (t.length === 1 ? typeof t[0] == "function" ? e = {
721
- test: t[0]
722
- } : e = t[0] : t.length === 2 ? e = {
723
- name: t[0],
724
- test: t[1]
725
- } : e = {
726
- name: t[0],
727
- message: t[1],
728
- test: t[2]
729
- }, e.message === void 0 && (e.message = F.default), typeof e.test != "function") throw new TypeError("`test` is a required parameters");
730
- let r = this.clone(), s = k(e), i = e.exclusive || e.name && r.exclusiveTests[e.name] === !0;
731
- if (e.exclusive && !e.name)
732
- throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
733
- return e.name && (r.exclusiveTests[e.name] = !!e.exclusive), r.tests = r.tests.filter((a) => !(a.OPTIONS.name === e.name && (i || a.OPTIONS.test === s.OPTIONS.test))), r.tests.push(s), r;
734
- }
735
- when(t, e) {
736
- !Array.isArray(t) && typeof t != "string" && (e = t, t = ".");
737
- let r = this.clone(), s = te(t).map((i) => new E(i));
738
- return s.forEach((i) => {
739
- i.isSibling && r.deps.push(i.key);
740
- }), r.conditions.push(typeof e == "function" ? new R(s, e) : R.fromOptions(s, e)), r;
741
- }
742
- typeError(t) {
743
- let e = this.clone();
744
- return e.internalTests.typeError = k({
745
- message: t,
746
- name: "typeError",
747
- skipAbsent: !0,
748
- test(r) {
749
- return this.schema._typeCheck(r) ? !0 : this.createError({
750
- params: {
751
- type: this.schema.type
752
- }
753
- });
754
- }
755
- }), e;
756
- }
757
- oneOf(t, e = F.oneOf) {
758
- let r = this.clone();
759
- return t.forEach((s) => {
760
- r._whitelist.add(s), r._blacklist.delete(s);
761
- }), r.internalTests.whiteList = k({
762
- message: e,
763
- name: "oneOf",
764
- skipAbsent: !0,
765
- test(s) {
766
- let i = this.schema._whitelist, a = i.resolveAll(this.resolve);
767
- return a.includes(s) ? !0 : this.createError({
768
- params: {
769
- values: Array.from(i).join(", "),
770
- resolved: a
771
- }
772
- });
773
- }
774
- }), r;
775
- }
776
- notOneOf(t, e = F.notOneOf) {
777
- let r = this.clone();
778
- return t.forEach((s) => {
779
- r._blacklist.add(s), r._whitelist.delete(s);
780
- }), r.internalTests.blacklist = k({
781
- message: e,
782
- name: "notOneOf",
783
- test(s) {
784
- let i = this.schema._blacklist, a = i.resolveAll(this.resolve);
785
- return a.includes(s) ? this.createError({
786
- params: {
787
- values: Array.from(i).join(", "),
788
- resolved: a
789
- }
790
- }) : !0;
791
- }
792
- }), r;
793
- }
794
- strip(t = !0) {
795
- let e = this.clone();
796
- return e.spec.strip = t, e;
797
- }
798
- /**
799
- * Return a serialized description of the schema including validations, flags, types etc.
800
- *
801
- * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
802
- */
803
- describe(t) {
804
- const e = (t ? this.resolve(t) : this).clone(), {
805
- label: r,
806
- meta: s,
807
- optional: i,
808
- nullable: a
809
- } = e.spec;
810
- return {
811
- meta: s,
812
- label: r,
813
- optional: i,
814
- nullable: a,
815
- default: e.getDefault(t),
816
- type: e.type,
817
- oneOf: e._whitelist.describe(),
818
- notOneOf: e._blacklist.describe(),
819
- tests: e.tests.filter((u, o, c) => c.findIndex((h) => h.OPTIONS.name === u.OPTIONS.name) === o).map((u) => {
820
- const o = u.OPTIONS.params && t ? ie(Object.assign({}, u.OPTIONS.params), t) : u.OPTIONS.params;
821
- return {
822
- name: u.OPTIONS.name,
823
- params: o
824
- };
825
- })
826
- };
827
- }
828
- get "~standard"() {
829
- const t = this;
830
- return {
831
- version: 1,
832
- vendor: "yup",
833
- async validate(r) {
834
- try {
835
- return {
836
- value: await t.validate(r, {
837
- abortEarly: !1
838
- })
839
- };
840
- } catch (s) {
841
- if (s instanceof p)
842
- return {
843
- issues: le(s)
844
- };
845
- throw s;
846
- }
847
- }
848
- };
849
- }
850
- }
851
- $.prototype.__isYupSchema__ = !0;
852
- for (const n of ["validate", "validateSync"]) $.prototype[`${n}At`] = function(t, e, r = {}) {
853
- const {
854
- parent: s,
855
- parentPath: i,
856
- schema: a
857
- } = xe(this, t, e, r.context);
858
- return a[n](s && s[i], Object.assign({}, r, {
859
- parent: s,
860
- path: t
861
- }));
862
- };
863
- for (const n of ["equals", "is"]) $.prototype[n] = $.prototype.oneOf;
864
- for (const n of ["not", "nope"]) $.prototype[n] = $.prototype.notOneOf;
865
- const Se = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
866
- function Ee(n) {
867
- const t = Z(n);
868
- if (!t) return Date.parse ? Date.parse(n) : Number.NaN;
869
- if (t.z === void 0 && t.plusMinus === void 0)
870
- return new Date(t.year, t.month, t.day, t.hour, t.minute, t.second, t.millisecond).valueOf();
871
- let e = 0;
872
- return t.z !== "Z" && t.plusMinus !== void 0 && (e = t.hourOffset * 60 + t.minuteOffset, t.plusMinus === "+" && (e = 0 - e)), Date.UTC(t.year, t.month, t.day, t.hour, t.minute + e, t.second, t.millisecond);
873
- }
874
- function Z(n) {
875
- var t, e;
876
- const r = Se.exec(n);
877
- return r ? {
878
- year: O(r[1]),
879
- month: O(r[2], 1) - 1,
880
- day: O(r[3], 1),
881
- hour: O(r[4]),
882
- minute: O(r[5]),
883
- second: O(r[6]),
884
- millisecond: r[7] ? (
885
- // allow arbitrary sub-second precision beyond milliseconds
886
- O(r[7].substring(0, 3))
887
- ) : 0,
888
- precision: (t = (e = r[7]) == null ? void 0 : e.length) != null ? t : void 0,
889
- z: r[8] || void 0,
890
- plusMinus: r[9] || void 0,
891
- hourOffset: O(r[10]),
892
- minuteOffset: O(r[11])
893
- } : null;
894
- }
895
- function O(n, t = 0) {
896
- return Number(n) || t;
897
- }
898
- let ke = (
899
- // eslint-disable-next-line
900
- /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
901
- ), Te = (
902
- // eslint-disable-next-line
903
- /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
904
- ), De = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, je = "^\\d{4}-\\d{2}-\\d{2}", Ae = "\\d{2}:\\d{2}:\\d{2}", Ne = "(([+-]\\d{2}(:?\\d{2})?)|Z)", Ce = new RegExp(`${je}T${Ae}(\\.\\d+)?${Ne}$`), Ie = (n) => v(n) || n === n.trim(), Re = {}.toString();
905
- function Pe() {
906
- return new ue();
907
- }
908
- class ue extends $ {
909
- constructor() {
910
- super({
911
- type: "string",
912
- check(t) {
913
- return t instanceof String && (t = t.valueOf()), typeof t == "string";
914
- }
915
- }), this.withMutation(() => {
916
- this.transform((t, e) => {
917
- if (!this.spec.coerce || this.isType(t) || Array.isArray(t)) return t;
918
- const r = t != null && t.toString ? t.toString() : t;
919
- return r === Re ? t : r;
920
- });
921
- });
922
- }
923
- required(t) {
924
- return super.required(t).withMutation((e) => e.test({
925
- message: t || F.required,
926
- name: "required",
927
- skipAbsent: !0,
928
- test: (r) => !!r.length
929
- }));
930
- }
931
- notRequired() {
932
- return super.notRequired().withMutation((t) => (t.tests = t.tests.filter((e) => e.OPTIONS.name !== "required"), t));
933
- }
934
- length(t, e = m.length) {
935
- return this.test({
936
- message: e,
937
- name: "length",
938
- exclusive: !0,
939
- params: {
940
- length: t
941
- },
942
- skipAbsent: !0,
943
- test(r) {
944
- return r.length === this.resolve(t);
945
- }
946
- });
947
- }
948
- min(t, e = m.min) {
949
- return this.test({
950
- message: e,
951
- name: "min",
952
- exclusive: !0,
953
- params: {
954
- min: t
955
- },
956
- skipAbsent: !0,
957
- test(r) {
958
- return r.length >= this.resolve(t);
959
- }
960
- });
961
- }
962
- max(t, e = m.max) {
963
- return this.test({
964
- name: "max",
965
- exclusive: !0,
966
- message: e,
967
- params: {
968
- max: t
969
- },
970
- skipAbsent: !0,
971
- test(r) {
972
- return r.length <= this.resolve(t);
973
- }
974
- });
975
- }
976
- matches(t, e) {
977
- let r = !1, s, i;
978
- return e && (typeof e == "object" ? {
979
- excludeEmptyString: r = !1,
980
- message: s,
981
- name: i
982
- } = e : s = e), this.test({
983
- name: i || "matches",
984
- message: s || m.matches,
985
- params: {
986
- regex: t
987
- },
988
- skipAbsent: !0,
989
- test: (a) => a === "" && r || a.search(t) !== -1
990
- });
991
- }
992
- email(t = m.email) {
993
- return this.matches(ke, {
994
- name: "email",
995
- message: t,
996
- excludeEmptyString: !0
997
- });
998
- }
999
- url(t = m.url) {
1000
- return this.matches(Te, {
1001
- name: "url",
1002
- message: t,
1003
- excludeEmptyString: !0
1004
- });
1005
- }
1006
- uuid(t = m.uuid) {
1007
- return this.matches(De, {
1008
- name: "uuid",
1009
- message: t,
1010
- excludeEmptyString: !1
1011
- });
1012
- }
1013
- datetime(t) {
1014
- let e = "", r, s;
1015
- return t && (typeof t == "object" ? {
1016
- message: e = "",
1017
- allowOffset: r = !1,
1018
- precision: s = void 0
1019
- } = t : e = t), this.matches(Ce, {
1020
- name: "datetime",
1021
- message: e || m.datetime,
1022
- excludeEmptyString: !0
1023
- }).test({
1024
- name: "datetime_offset",
1025
- message: e || m.datetime_offset,
1026
- params: {
1027
- allowOffset: r
1028
- },
1029
- skipAbsent: !0,
1030
- test: (i) => {
1031
- if (!i || r) return !0;
1032
- const a = Z(i);
1033
- return a ? !!a.z : !1;
1034
- }
1035
- }).test({
1036
- name: "datetime_precision",
1037
- message: e || m.datetime_precision,
1038
- params: {
1039
- precision: s
1040
- },
1041
- skipAbsent: !0,
1042
- test: (i) => {
1043
- if (!i || s == null) return !0;
1044
- const a = Z(i);
1045
- return a ? a.precision === s : !1;
1046
- }
1047
- });
1048
- }
1049
- //-- transforms --
1050
- ensure() {
1051
- return this.default("").transform((t) => t === null ? "" : t);
1052
- }
1053
- trim(t = m.trim) {
1054
- return this.transform((e) => e != null ? e.trim() : e).test({
1055
- message: t,
1056
- name: "trim",
1057
- test: Ie
1058
- });
1059
- }
1060
- lowercase(t = m.lowercase) {
1061
- return this.transform((e) => v(e) ? e : e.toLowerCase()).test({
1062
- message: t,
1063
- name: "string_case",
1064
- exclusive: !0,
1065
- skipAbsent: !0,
1066
- test: (e) => v(e) || e === e.toLowerCase()
1067
- });
1068
- }
1069
- uppercase(t = m.uppercase) {
1070
- return this.transform((e) => v(e) ? e : e.toUpperCase()).test({
1071
- message: t,
1072
- name: "string_case",
1073
- exclusive: !0,
1074
- skipAbsent: !0,
1075
- test: (e) => v(e) || e === e.toUpperCase()
1076
- });
1077
- }
1078
- }
1079
- Pe.prototype = ue.prototype;
1080
- let Me = /* @__PURE__ */ new Date(""), ze = (n) => Object.prototype.toString.call(n) === "[object Date]";
1081
- class Y extends $ {
1082
- constructor() {
1083
- super({
1084
- type: "date",
1085
- check(t) {
1086
- return ze(t) && !isNaN(t.getTime());
1087
- }
1088
- }), this.withMutation(() => {
1089
- this.transform((t, e) => !this.spec.coerce || this.isType(t) || t === null ? t : (t = Ee(t), isNaN(t) ? Y.INVALID_DATE : new Date(t)));
1090
- });
1091
- }
1092
- prepareParam(t, e) {
1093
- let r;
1094
- if (E.isRef(t))
1095
- r = t;
1096
- else {
1097
- let s = this.cast(t);
1098
- if (!this._typeCheck(s)) throw new TypeError(`\`${e}\` must be a Date or a value that can be \`cast()\` to a Date`);
1099
- r = s;
1100
- }
1101
- return r;
1102
- }
1103
- min(t, e = q.min) {
1104
- let r = this.prepareParam(t, "min");
1105
- return this.test({
1106
- message: e,
1107
- name: "min",
1108
- exclusive: !0,
1109
- params: {
1110
- min: t
1111
- },
1112
- skipAbsent: !0,
1113
- test(s) {
1114
- return s >= this.resolve(r);
1115
- }
1116
- });
1117
- }
1118
- max(t, e = q.max) {
1119
- let r = this.prepareParam(t, "max");
1120
- return this.test({
1121
- message: e,
1122
- name: "max",
1123
- exclusive: !0,
1124
- params: {
1125
- max: t
1126
- },
1127
- skipAbsent: !0,
1128
- test(s) {
1129
- return s <= this.resolve(r);
1130
- }
1131
- });
1132
- }
1133
- }
1134
- Y.INVALID_DATE = Me;
1135
- function Ve(n, t = []) {
1136
- let e = [], r = /* @__PURE__ */ new Set(), s = new Set(t.map(([a, l]) => `${a}-${l}`));
1137
- function i(a, l) {
1138
- let u = S.split(a)[0];
1139
- r.add(u), s.has(`${l}-${u}`) || e.push([l, u]);
1140
- }
1141
- for (const a of Object.keys(n)) {
1142
- let l = n[a];
1143
- r.add(a), E.isRef(l) && l.isSibling ? i(l.path, a) : L(l) && "deps" in l && l.deps.forEach((u) => i(u, a));
1144
- }
1145
- return he.array(Array.from(r), e).reverse();
1146
- }
1147
- function X(n, t) {
1148
- let e = 1 / 0;
1149
- return n.some((r, s) => {
1150
- var i;
1151
- if ((i = t.path) != null && i.includes(r))
1152
- return e = s, !0;
1153
- }), e;
1154
- }
1155
- function oe(n) {
1156
- return (t, e) => X(n, t) - X(n, e);
1157
- }
1158
- const Ue = (n, t, e) => {
1159
- if (typeof n != "string")
1160
- return n;
1161
- let r = n;
1162
- try {
1163
- r = JSON.parse(n);
1164
- } catch {
1165
- }
1166
- return e.isType(r) ? r : n;
1167
- };
1168
- function I(n) {
1169
- if ("fields" in n) {
1170
- const t = {};
1171
- for (const [e, r] of Object.entries(n.fields))
1172
- t[e] = I(r);
1173
- return n.setFields(t);
1174
- }
1175
- if (n.type === "array") {
1176
- const t = n.optional();
1177
- return t.innerType && (t.innerType = I(t.innerType)), t;
1178
- }
1179
- return n.type === "tuple" ? n.optional().clone({
1180
- types: n.spec.types.map(I)
1181
- }) : "optional" in n ? n.optional() : n;
1182
- }
1183
- const qe = (n, t) => {
1184
- const e = [...S.normalizePath(t)];
1185
- if (e.length === 1) return e[0] in n;
1186
- let r = e.pop(), s = S.getter(S.join(e), !0)(n);
1187
- return !!(s && r in s);
1188
- };
1189
- let W = (n) => Object.prototype.toString.call(n) === "[object Object]";
1190
- function ee(n, t) {
1191
- let e = Object.keys(n.fields);
1192
- return Object.keys(t).filter((r) => e.indexOf(r) === -1);
1193
- }
1194
- const Ze = oe([]);
1195
- function Le(n) {
1196
- return new ce(n);
1197
- }
1198
- class ce extends $ {
1199
- constructor(t) {
1200
- super({
1201
- type: "object",
1202
- check(e) {
1203
- return W(e) || typeof e == "function";
1204
- }
1205
- }), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = Ze, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
1206
- t && this.shape(t);
1207
- });
1208
- }
1209
- _cast(t, e = {}) {
1210
- var r;
1211
- let s = super._cast(t, e);
1212
- if (s === void 0) return this.getDefault(e);
1213
- if (!this._typeCheck(s)) return s;
1214
- let i = this.fields, a = (r = e.stripUnknown) != null ? r : this.spec.noUnknown, l = [].concat(this._nodes, Object.keys(s).filter((h) => !this._nodes.includes(h))), u = {}, o = Object.assign({}, e, {
1215
- parent: u,
1216
- __validating: e.__validating || !1
1217
- }), c = !1;
1218
- for (const h of l) {
1219
- let f = i[h], g = h in s, b = s[h];
1220
- if (f) {
1221
- let y;
1222
- o.path = (e.path ? `${e.path}.` : "") + h, f = f.resolve({
1223
- value: b,
1224
- context: e.context,
1225
- parent: u
1226
- });
1227
- let w = f instanceof $ ? f.spec : void 0, D = w == null ? void 0 : w.strict;
1228
- if (w != null && w.strip) {
1229
- c = c || h in s;
1230
- continue;
1231
- }
1232
- y = !e.__validating || !D ? f.cast(b, o) : b, y !== void 0 && (u[h] = y);
1233
- } else g && !a && (u[h] = b);
1234
- (g !== h in u || u[h] !== b) && (c = !0);
1235
- }
1236
- return c ? u : s;
1237
- }
1238
- _validate(t, e = {}, r, s) {
1239
- let {
1240
- from: i = [],
1241
- originalValue: a = t,
1242
- recursive: l = this.spec.recursive
1243
- } = e;
1244
- e.from = [{
1245
- schema: this,
1246
- value: a
1247
- }, ...i], e.__validating = !0, e.originalValue = a, super._validate(t, e, r, (u, o) => {
1248
- if (!l || !W(o)) {
1249
- s(u, o);
1250
- return;
1251
- }
1252
- a = a || o;
1253
- let c = [];
1254
- for (let h of this._nodes) {
1255
- let f = this.fields[h];
1256
- !f || E.isRef(f) || c.push(f.asNestedTest({
1257
- options: e,
1258
- key: h,
1259
- parent: o,
1260
- parentPath: e.path,
1261
- originalParent: a
1262
- }));
1263
- }
1264
- this.runTests({
1265
- tests: c,
1266
- value: o,
1267
- originalValue: a,
1268
- options: e
1269
- }, r, (h) => {
1270
- s(h.sort(this._sortErrors).concat(u), o);
1271
- });
1272
- });
1273
- }
1274
- clone(t) {
1275
- const e = super.clone(t);
1276
- return e.fields = Object.assign({}, this.fields), e._nodes = this._nodes, e._excludedEdges = this._excludedEdges, e._sortErrors = this._sortErrors, e;
1277
- }
1278
- concat(t) {
1279
- let e = super.concat(t), r = e.fields;
1280
- for (let [s, i] of Object.entries(this.fields)) {
1281
- const a = r[s];
1282
- r[s] = a === void 0 ? i : a;
1283
- }
1284
- return e.withMutation((s) => (
1285
- // XXX: excludes here is wrong
1286
- s.setFields(r, [...this._excludedEdges, ...t._excludedEdges])
1287
- ));
1288
- }
1289
- _getDefault(t) {
1290
- if ("default" in this.spec)
1291
- return super._getDefault(t);
1292
- if (!this._nodes.length)
1293
- return;
1294
- let e = {};
1295
- return this._nodes.forEach((r) => {
1296
- var s;
1297
- const i = this.fields[r];
1298
- let a = t;
1299
- (s = a) != null && s.value && (a = Object.assign({}, a, {
1300
- parent: a.value,
1301
- value: a.value[r]
1302
- })), e[r] = i && "getDefault" in i ? i.getDefault(a) : void 0;
1303
- }), e;
1304
- }
1305
- setFields(t, e) {
1306
- let r = this.clone();
1307
- return r.fields = t, r._nodes = Ve(t, e), r._sortErrors = oe(Object.keys(t)), e && (r._excludedEdges = e), r;
1308
- }
1309
- shape(t, e = []) {
1310
- return this.clone().withMutation((r) => {
1311
- let s = r._excludedEdges;
1312
- return e.length && (Array.isArray(e[0]) || (e = [e]), s = [...r._excludedEdges, ...e]), r.setFields(Object.assign(r.fields, t), s);
1313
- });
1314
- }
1315
- partial() {
1316
- const t = {};
1317
- for (const [e, r] of Object.entries(this.fields))
1318
- t[e] = "optional" in r && r.optional instanceof Function ? r.optional() : r;
1319
- return this.setFields(t);
1320
- }
1321
- deepPartial() {
1322
- return I(this);
1323
- }
1324
- pick(t) {
1325
- const e = {};
1326
- for (const r of t)
1327
- this.fields[r] && (e[r] = this.fields[r]);
1328
- return this.setFields(e, this._excludedEdges.filter(([r, s]) => t.includes(r) && t.includes(s)));
1329
- }
1330
- omit(t) {
1331
- const e = [];
1332
- for (const r of Object.keys(this.fields))
1333
- t.includes(r) || e.push(r);
1334
- return this.pick(e);
1335
- }
1336
- from(t, e, r) {
1337
- let s = S.getter(t, !0);
1338
- return this.transform((i) => {
1339
- if (!i) return i;
1340
- let a = i;
1341
- return qe(i, t) && (a = Object.assign({}, i), r || delete a[t], a[e] = s(i)), a;
1342
- });
1343
- }
1344
- /** Parse an input JSON string to an object */
1345
- json() {
1346
- return this.transform(Ue);
1347
- }
1348
- /**
1349
- * Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys
1350
- */
1351
- exact(t) {
1352
- return this.test({
1353
- name: "exact",
1354
- exclusive: !0,
1355
- message: t || C.exact,
1356
- test(e) {
1357
- if (e == null) return !0;
1358
- const r = ee(this.schema, e);
1359
- return r.length === 0 || this.createError({
1360
- params: {
1361
- properties: r.join(", ")
1362
- }
1363
- });
1364
- }
1365
- });
1366
- }
1367
- stripUnknown() {
1368
- return this.clone({
1369
- noUnknown: !0
1370
- });
1371
- }
1372
- noUnknown(t = !0, e = C.noUnknown) {
1373
- typeof t != "boolean" && (e = t, t = !0);
1374
- let r = this.test({
1375
- name: "noUnknown",
1376
- exclusive: !0,
1377
- message: e,
1378
- test(s) {
1379
- if (s == null) return !0;
1380
- const i = ee(this.schema, s);
1381
- return !t || i.length === 0 || this.createError({
1382
- params: {
1383
- unknown: i.join(", ")
1384
- }
1385
- });
1386
- }
1387
- });
1388
- return r.spec.noUnknown = t, r;
1389
- }
1390
- unknown(t = !0, e = C.noUnknown) {
1391
- return this.noUnknown(!t, e);
1392
- }
1393
- transformKeys(t) {
1394
- return this.transform((e) => {
1395
- if (!e) return e;
1396
- const r = {};
1397
- for (const s of Object.keys(e)) r[t(s)] = e[s];
1398
- return r;
1399
- });
1400
- }
1401
- camelCase() {
1402
- return this.transformKeys(U.camelCase);
1403
- }
1404
- snakeCase() {
1405
- return this.transformKeys(U.snakeCase);
1406
- }
1407
- constantCase() {
1408
- return this.transformKeys((t) => U.snakeCase(t).toUpperCase());
1409
- }
1410
- describe(t) {
1411
- const e = (t ? this.resolve(t) : this).clone(), r = super.describe(t);
1412
- r.fields = {};
1413
- for (const [i, a] of Object.entries(e.fields)) {
1414
- var s;
1415
- let l = t;
1416
- (s = l) != null && s.value && (l = Object.assign({}, l, {
1417
- parent: l.value,
1418
- value: l.value[i]
1419
- })), r.fields[i] = a.describe(l);
1420
- }
1421
- return r;
1422
- }
1423
- }
1424
- Le.prototype = ce.prototype;
1425
19
  export {
1426
- Y as DateSchema,
1427
- ce as ObjectSchema,
1428
- $ as Schema,
1429
- ue as StringSchema,
1430
- p as ValidationError,
1431
- xe as getIn,
1432
- L as isSchema,
1433
- Le as object,
1434
- x as printValue,
1435
- Pe as string
20
+ c as useConfirmOrder,
21
+ y as useGetOrder
1436
22
  };