@saasquatch/mint-components 2.3.0-11 → 2.3.0-13

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 (85) hide show
  1. package/dist/cjs/{usePortalRegistrationForm-23ee2d62.js → AsYouType-d15caac8.js} +265 -223
  2. package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +46 -27
  3. package/dist/cjs/sqm-big-stat_47.cjs.entry.js +17 -13
  4. package/dist/cjs/sqm-portal-forgot-password_6.cjs.entry.js +3 -2
  5. package/dist/cjs/sqm-stencilbook.cjs.entry.js +59 -2
  6. package/dist/cjs/{sqm-user-info-form-view-8f7186b8.js → sqm-user-info-form-view-60e09262.js} +1004 -8
  7. package/dist/cjs/subregions-3542b0b8.js +1068 -0
  8. package/dist/cjs/{useIndirectTaxForm-112914a0.js → useIndirectTaxForm-c439eb81.js} +6 -2
  9. package/dist/cjs/usePortalRegistrationForm-8a3a14ac.js +215 -0
  10. package/dist/collection/components/tax-and-cash/TaxForm.stories.js +3 -0
  11. package/dist/collection/components/tax-and-cash/phoneExtensions.js +12 -0
  12. package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form-view.js +8 -0
  13. package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form.js +2 -1
  14. package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +5 -1
  15. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/useTaxAndCash.js +12 -9
  16. package/dist/collection/components/tax-and-cash/sqm-user-info-form/UserInfoFormView.stories.js +52 -0
  17. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +18 -5
  18. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.js +3 -1
  19. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +31 -27
  20. package/dist/collection/components/tax-and-cash/utils.js +30 -27
  21. package/dist/esm/{usePortalRegistrationForm-3a1f36a2.js → AsYouType-2d56519e.js} +248 -223
  22. package/dist/esm/sqm-banking-info-form_10.entry.js +46 -27
  23. package/dist/esm/sqm-big-stat_47.entry.js +16 -12
  24. package/dist/esm/sqm-portal-forgot-password_6.entry.js +2 -1
  25. package/dist/esm/sqm-stencilbook.entry.js +59 -2
  26. package/dist/esm/{sqm-user-info-form-view-599a6922.js → sqm-user-info-form-view-647a2bd5.js} +1002 -6
  27. package/dist/esm/subregions-7c5112e8.js +1055 -0
  28. package/dist/esm/{useIndirectTaxForm-a6ac7e7e.js → useIndirectTaxForm-38cd984e.js} +6 -2
  29. package/dist/esm/usePortalRegistrationForm-78fdfd93.js +213 -0
  30. package/dist/esm-es5/AsYouType-2d56519e.js +1 -0
  31. package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
  32. package/dist/esm-es5/sqm-big-stat_47.entry.js +1 -1
  33. package/dist/esm-es5/sqm-portal-forgot-password_6.entry.js +1 -1
  34. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  35. package/dist/esm-es5/sqm-user-info-form-view-647a2bd5.js +1 -0
  36. package/dist/esm-es5/subregions-7c5112e8.js +1 -0
  37. package/dist/esm-es5/{useIndirectTaxForm-a6ac7e7e.js → useIndirectTaxForm-38cd984e.js} +2 -2
  38. package/dist/esm-es5/usePortalRegistrationForm-78fdfd93.js +1 -0
  39. package/dist/mint-components/mint-components.esm.js +1 -1
  40. package/dist/mint-components/p-1f387c7b.system.js +1 -1
  41. package/dist/mint-components/p-34179541.system.js +1 -0
  42. package/dist/mint-components/p-4065ae93.entry.js +9 -0
  43. package/dist/mint-components/p-5c3bff99.entry.js +1 -0
  44. package/dist/mint-components/p-6fd8981d.system.entry.js +1 -0
  45. package/dist/mint-components/p-769166a5.system.js +1 -0
  46. package/dist/mint-components/p-7c72eeb5.js +1 -0
  47. package/dist/mint-components/p-8d30945a.js +1 -0
  48. package/dist/mint-components/p-8dcd72fe.system.entry.js +1 -0
  49. package/dist/mint-components/p-a08157c4.js +1 -0
  50. package/dist/mint-components/p-a779e577.js +13 -0
  51. package/dist/mint-components/{p-2d4132fb.js → p-aa2c6585.js} +7 -5
  52. package/dist/mint-components/{p-6ef373ed.system.js → p-aab8a207.system.js} +2 -2
  53. package/dist/mint-components/p-af8b8c06.system.entry.js +1 -0
  54. package/dist/mint-components/{p-86231add.entry.js → p-b3f25c0e.entry.js} +8 -8
  55. package/dist/mint-components/p-c31966e3.system.entry.js +1 -0
  56. package/dist/mint-components/p-d463fa82.system.js +1 -0
  57. package/dist/mint-components/{p-339ce676.entry.js → p-dd5c1db9.entry.js} +11 -11
  58. package/dist/mint-components/p-ee91aeac.system.js +1 -0
  59. package/dist/types/components/tax-and-cash/phoneExtensions.d.ts +12 -0
  60. package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form-view.d.ts +1 -0
  61. package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.d.ts +1 -0
  62. package/dist/types/components/tax-and-cash/sqm-user-info-form/UserInfoFormView.stories.d.ts +1 -0
  63. package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.d.ts +2 -0
  64. package/dist/types/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.d.ts +2 -0
  65. package/dist/types/components/tax-and-cash/utils.d.ts +8 -2
  66. package/docs/docs.docx +0 -0
  67. package/grapesjs/grapesjs.js +1 -1
  68. package/package.json +1 -1
  69. package/dist/cjs/subregions-984e30d7.js +0 -1505
  70. package/dist/esm/subregions-7c9778d0.js +0 -1492
  71. package/dist/esm-es5/sqm-user-info-form-view-599a6922.js +0 -1
  72. package/dist/esm-es5/subregions-7c9778d0.js +0 -1
  73. package/dist/esm-es5/usePortalRegistrationForm-3a1f36a2.js +0 -1
  74. package/dist/mint-components/p-26a4ebfd.js +0 -1
  75. package/dist/mint-components/p-335a5736.entry.js +0 -1
  76. package/dist/mint-components/p-3a41b39c.js +0 -13
  77. package/dist/mint-components/p-40894343.entry.js +0 -9
  78. package/dist/mint-components/p-5fdf0286.system.js +0 -1
  79. package/dist/mint-components/p-7f29622d.js +0 -1
  80. package/dist/mint-components/p-81270b9f.system.js +0 -1
  81. package/dist/mint-components/p-b62d8b95.system.entry.js +0 -1
  82. package/dist/mint-components/p-bd03efe0.system.js +0 -1
  83. package/dist/mint-components/p-c9d2ccfc.system.entry.js +0 -1
  84. package/dist/mint-components/p-db6bf7cf.system.entry.js +0 -1
  85. package/dist/mint-components/p-f0ef09a0.system.entry.js +0 -1
@@ -0,0 +1,1055 @@
1
+ import { h } from './index-38ad4957.js';
2
+ import { i as intl } from './global-75e96214.js';
3
+ import { c as createStyleSheet } from './JSS-67b5cff8.js';
4
+ import { m as metadata, c as createExtensionPattern, p as parseDigit, M as Metadata, a as MIN_LENGTH_FOR_NSN, b as MAX_LENGTH_FOR_NSN, P as PhoneNumber, d as matchesEntirely, i as isPossibleNumber, e as parseRFC3966, f as isViablePhoneNumber, g as extractCountryCallingCode, h as getCountryCallingCode, j as extractNationalNumber, k as getCountryByCallingCode, l as PLUS_CHARS, V as VALID_DIGITS, n as isSupportedCountry } from './AsYouType-2d56519e.js';
5
+
6
+ // Importing from `.json.js` a workaround for a bug in web browsers' "native"
7
+
8
+ function withMetadata(func, _arguments) {
9
+ var args = Array.prototype.slice.call(_arguments);
10
+ args.push(metadata);
11
+ return func.apply(this, args)
12
+ }
13
+
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+
16
+ // https://stackoverflow.com/a/46971044/970769
17
+ var ParseError = function ParseError(code) {
18
+ _classCallCheck(this, ParseError);
19
+
20
+ this.name = this.constructor.name;
21
+ this.message = code;
22
+ this.stack = new Error(code).stack;
23
+ };
24
+ ParseError.prototype = Object.create(Error.prototype);
25
+ ParseError.prototype.constructor = ParseError;
26
+
27
+ // 1 or more valid digits, for use when parsing.
28
+
29
+ var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
30
+ // connected, usually indicated with extn, ext, x or similar) from the end of
31
+ // the number, and returns it.
32
+
33
+ function extractExtension(number) {
34
+ var start = number.search(EXTN_PATTERN);
35
+
36
+ if (start < 0) {
37
+ return {};
38
+ } // If we find a potential extension, and the number preceding this is a viable
39
+ // number, we assume it is an extension.
40
+
41
+
42
+ var numberWithoutExtension = number.slice(0, start);
43
+ var matches = number.match(EXTN_PATTERN);
44
+ var i = 1;
45
+
46
+ while (i < matches.length) {
47
+ if (matches[i]) {
48
+ return {
49
+ number: numberWithoutExtension,
50
+ ext: matches[i]
51
+ };
52
+ }
53
+
54
+ i++;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Parses phone number characters from a string.
60
+ * Drops all punctuation leaving only digits and the leading `+` sign (if any).
61
+ * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
62
+ * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
63
+ * @param {string} string
64
+ * @return {string}
65
+ * @example
66
+ * ```js
67
+ * // Outputs '8800555'.
68
+ * parseIncompletePhoneNumber('8 (800) 555')
69
+ * // Outputs '+7800555'.
70
+ * parseIncompletePhoneNumber('+7 800 555')
71
+ * ```
72
+ */
73
+
74
+ function parseIncompletePhoneNumber(string) {
75
+ var result = ''; // Using `.split('')` here instead of normal `for ... of`
76
+ // because the importing application doesn't neccessarily include an ES6 polyfill.
77
+ // The `.split('')` approach discards "exotic" UTF-8 characters
78
+ // (the ones consisting of four bytes) but digits
79
+ // (including non-European ones) don't fall into that range
80
+ // so such "exotic" characters would be discarded anyway.
81
+
82
+ for (var _iterator = string.split(''), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
83
+ var _ref;
84
+
85
+ if (_isArray) {
86
+ if (_i >= _iterator.length) break;
87
+ _ref = _iterator[_i++];
88
+ } else {
89
+ _i = _iterator.next();
90
+ if (_i.done) break;
91
+ _ref = _i.value;
92
+ }
93
+
94
+ var character = _ref;
95
+ result += parsePhoneNumberCharacter(character, result) || '';
96
+ }
97
+
98
+ return result;
99
+ }
100
+ /**
101
+ * Parses next character while parsing phone number digits (including a `+`)
102
+ * from text: discards everything except `+` and digits, and `+` is only allowed
103
+ * at the start of a phone number.
104
+ * For example, is used in `react-phone-number-input` where it uses
105
+ * [`input-format`](https://gitlab.com/catamphetamine/input-format).
106
+ * @param {string} character - Yet another character from raw input string.
107
+ * @param {string?} prevParsedCharacters - Previous parsed characters.
108
+ * @param {object} meta - Optional custom use-case-specific metadata.
109
+ * @return {string?} The parsed character.
110
+ */
111
+
112
+ function parsePhoneNumberCharacter(character, prevParsedCharacters) {
113
+ // Only allow a leading `+`.
114
+ if (character === '+') {
115
+ // If this `+` is not the first parsed character
116
+ // then discard it.
117
+ if (prevParsedCharacters) {
118
+ return;
119
+ }
120
+
121
+ return '+';
122
+ } // Allow digits.
123
+
124
+
125
+ return parseDigit(character);
126
+ }
127
+
128
+ // This is a port of Google Android `libphonenumber`'s
129
+ // This prevents malicious input from consuming CPU.
130
+
131
+ var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
132
+
133
+ var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
134
+ // A trailing `#` is sometimes used when writing phone numbers with extensions in US.
135
+ // Example: "+1 (645) 123 1234-910#" number has extension "910".
136
+
137
+ var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
138
+ //
139
+ // ```js
140
+ // parse('8 (800) 555-35-35', 'RU')
141
+ // parse('8 (800) 555-35-35', 'RU', metadata)
142
+ // parse('8 (800) 555-35-35', { country: { default: 'RU' } })
143
+ // parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
144
+ // parse('+7 800 555 35 35')
145
+ // parse('+7 800 555 35 35', metadata)
146
+ // ```
147
+ //
148
+
149
+ function parse(text, options, metadata) {
150
+ // If assigning the `{}` default value is moved to the arguments above,
151
+ // code coverage would decrease for some weird reason.
152
+ options = options || {};
153
+ metadata = new Metadata(metadata); // Validate `defaultCountry`.
154
+
155
+ if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
156
+ if (options.v2) {
157
+ throw new ParseError('INVALID_COUNTRY');
158
+ }
159
+
160
+ throw new Error("Unknown country: ".concat(options.defaultCountry));
161
+ } // Parse the phone number.
162
+
163
+
164
+ var _parseInput = parseInput(text, options.v2, options.extract),
165
+ formattedPhoneNumber = _parseInput.number,
166
+ ext = _parseInput.ext; // If the phone number is not viable then return nothing.
167
+
168
+
169
+ if (!formattedPhoneNumber) {
170
+ if (options.v2) {
171
+ throw new ParseError('NOT_A_NUMBER');
172
+ }
173
+
174
+ return {};
175
+ }
176
+
177
+ var _parsePhoneNumber = parsePhoneNumber(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
178
+ country = _parsePhoneNumber.country,
179
+ nationalNumber = _parsePhoneNumber.nationalNumber,
180
+ countryCallingCode = _parsePhoneNumber.countryCallingCode,
181
+ carrierCode = _parsePhoneNumber.carrierCode;
182
+
183
+ if (!metadata.hasSelectedNumberingPlan()) {
184
+ if (options.v2) {
185
+ throw new ParseError('INVALID_COUNTRY');
186
+ }
187
+
188
+ return {};
189
+ } // Validate national (significant) number length.
190
+
191
+
192
+ if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
193
+ // Won't throw here because the regexp already demands length > 1.
194
+
195
+ /* istanbul ignore if */
196
+ if (options.v2) {
197
+ throw new ParseError('TOO_SHORT');
198
+ } // Google's demo just throws an error in this case.
199
+
200
+
201
+ return {};
202
+ } // Validate national (significant) number length.
203
+ //
204
+ // A sidenote:
205
+ //
206
+ // They say that sometimes national (significant) numbers
207
+ // can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
208
+ // https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
209
+ // Such numbers will just be discarded.
210
+ //
211
+
212
+
213
+ if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
214
+ if (options.v2) {
215
+ throw new ParseError('TOO_LONG');
216
+ } // Google's demo just throws an error in this case.
217
+
218
+
219
+ return {};
220
+ }
221
+
222
+ if (options.v2) {
223
+ var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
224
+
225
+ if (country) {
226
+ phoneNumber.country = country;
227
+ }
228
+
229
+ if (carrierCode) {
230
+ phoneNumber.carrierCode = carrierCode;
231
+ }
232
+
233
+ if (ext) {
234
+ phoneNumber.ext = ext;
235
+ }
236
+
237
+ return phoneNumber;
238
+ } // Check if national phone number pattern matches the number.
239
+ // National number pattern is different for each country,
240
+ // even for those ones which are part of the "NANPA" group.
241
+
242
+
243
+ var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
244
+
245
+ if (!options.extended) {
246
+ return valid ? result(country, nationalNumber, ext) : {};
247
+ } // isInternational: countryCallingCode !== undefined
248
+
249
+
250
+ return {
251
+ country: country,
252
+ countryCallingCode: countryCallingCode,
253
+ carrierCode: carrierCode,
254
+ valid: valid,
255
+ possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
256
+ phone: nationalNumber,
257
+ ext: ext
258
+ };
259
+ }
260
+ /**
261
+ * Extracts a formatted phone number from text.
262
+ * Doesn't guarantee that the extracted phone number
263
+ * is a valid phone number (for example, doesn't validate its length).
264
+ * @param {string} text
265
+ * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
266
+ * @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.
267
+ * @return {string}
268
+ * @example
269
+ * // Returns "(213) 373-4253".
270
+ * extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
271
+ */
272
+
273
+ function extractFormattedPhoneNumber(text, extract, throwOnError) {
274
+ if (!text) {
275
+ return;
276
+ }
277
+
278
+ if (text.length > MAX_INPUT_STRING_LENGTH) {
279
+ if (throwOnError) {
280
+ throw new ParseError('TOO_LONG');
281
+ }
282
+
283
+ return;
284
+ }
285
+
286
+ if (extract === false) {
287
+ return text;
288
+ } // Attempt to extract a possible number from the string passed in
289
+
290
+
291
+ var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
292
+
293
+ if (startsAt < 0) {
294
+ return;
295
+ }
296
+
297
+ return text // Trim everything to the left of the phone number
298
+ .slice(startsAt) // Remove trailing non-numerical characters
299
+ .replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
300
+ }
301
+ /**
302
+ * @param {string} text - Input.
303
+ * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
304
+ * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
305
+ * @return {object} `{ ?number, ?ext }`.
306
+ */
307
+
308
+
309
+ function parseInput(text, v2, extract) {
310
+ // Parse RFC 3966 phone number URI.
311
+ if (text && text.indexOf('tel:') === 0) {
312
+ return parseRFC3966(text);
313
+ }
314
+
315
+ var number = extractFormattedPhoneNumber(text, extract, v2); // If the phone number is not viable, then abort.
316
+
317
+ if (!number || !isViablePhoneNumber(number)) {
318
+ return {};
319
+ } // Attempt to parse extension first, since it doesn't require region-specific
320
+ // data and we want to have the non-normalised number here.
321
+
322
+
323
+ var withExtensionStripped = extractExtension(number);
324
+
325
+ if (withExtensionStripped.ext) {
326
+ return withExtensionStripped;
327
+ }
328
+
329
+ return {
330
+ number: number
331
+ };
332
+ }
333
+ /**
334
+ * Creates `parse()` result object.
335
+ */
336
+
337
+
338
+ function result(country, nationalNumber, ext) {
339
+ var result = {
340
+ country: country,
341
+ phone: nationalNumber
342
+ };
343
+
344
+ if (ext) {
345
+ result.ext = ext;
346
+ }
347
+
348
+ return result;
349
+ }
350
+ /**
351
+ * Parses a viable phone number.
352
+ * @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
353
+ * @param {string} [defaultCountry]
354
+ * @param {string} [defaultCallingCode]
355
+ * @param {Metadata} metadata
356
+ * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
357
+ */
358
+
359
+
360
+ function parsePhoneNumber(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
361
+ // Extract calling code from phone number.
362
+ var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
363
+ countryCallingCode = _extractCountryCallin.countryCallingCode,
364
+ number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
365
+
366
+
367
+ var country;
368
+
369
+ if (countryCallingCode) {
370
+ metadata.selectNumberingPlan(countryCallingCode);
371
+ } // If `formattedPhoneNumber` is in "national" format
372
+ // then `number` is defined and `countryCallingCode` isn't.
373
+ else if (number && (defaultCountry || defaultCallingCode)) {
374
+ metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
375
+
376
+ if (defaultCountry) {
377
+ country = defaultCountry;
378
+ }
379
+
380
+ countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
381
+ } else return {};
382
+
383
+ if (!number) {
384
+ return {
385
+ countryCallingCode: countryCallingCode
386
+ };
387
+ }
388
+
389
+ var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
390
+ nationalNumber = _extractNationalNumbe.nationalNumber,
391
+ carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
392
+ // corresponding to the same country phone code
393
+ // (e.g. NANPA countries all having `1` country phone code).
394
+ // Therefore, to reliably determine the exact country,
395
+ // national (significant) number should have been parsed first.
396
+ //
397
+ // When `metadata.json` is generated, all "ambiguous" country phone codes
398
+ // get their countries populated with the full set of
399
+ // "phone number type" regular expressions.
400
+ //
401
+
402
+
403
+ var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);
404
+
405
+ if (exactCountry) {
406
+ country = exactCountry;
407
+ /* istanbul ignore if */
408
+
409
+ if (exactCountry === '001') ; else {
410
+ metadata.country(country);
411
+ }
412
+ }
413
+
414
+ return {
415
+ country: country,
416
+ countryCallingCode: countryCallingCode,
417
+ nationalNumber: nationalNumber,
418
+ carrierCode: carrierCode
419
+ };
420
+ }
421
+
422
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
423
+
424
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
425
+ function parsePhoneNumber$1(text, options, metadata) {
426
+ return parse(text, _objectSpread({}, options, {
427
+ v2: true
428
+ }), metadata);
429
+ }
430
+
431
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
432
+
433
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } return target; }
434
+
435
+ function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
436
+
437
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
438
+
439
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
440
+
441
+ function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
442
+
443
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
444
+ function normalizeArguments(args) {
445
+ var _Array$prototype$slic = Array.prototype.slice.call(args),
446
+ _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
447
+ arg_1 = _Array$prototype$slic2[0],
448
+ arg_2 = _Array$prototype$slic2[1],
449
+ arg_3 = _Array$prototype$slic2[2],
450
+ arg_4 = _Array$prototype$slic2[3];
451
+
452
+ var text;
453
+ var options;
454
+ var metadata; // If the phone number is passed as a string.
455
+ // `parsePhoneNumber('88005553535', ...)`.
456
+
457
+ if (typeof arg_1 === 'string') {
458
+ text = arg_1;
459
+ } else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
460
+ // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
461
+
462
+
463
+ if (!arg_2 || typeof arg_2 === 'string') {
464
+ if (arg_4) {
465
+ options = arg_3;
466
+ metadata = arg_4;
467
+ } else {
468
+ options = undefined;
469
+ metadata = arg_3;
470
+ }
471
+
472
+ if (arg_2) {
473
+ options = _objectSpread$1({
474
+ defaultCountry: arg_2
475
+ }, options);
476
+ }
477
+ } // `defaultCountry` is not passed.
478
+ // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
479
+ else if (isObject(arg_2)) {
480
+ if (arg_3) {
481
+ options = arg_2;
482
+ metadata = arg_3;
483
+ } else {
484
+ metadata = arg_2;
485
+ }
486
+ } else throw new Error("Invalid second argument: ".concat(arg_2));
487
+
488
+ return {
489
+ text: text,
490
+ options: options,
491
+ metadata: metadata
492
+ };
493
+ } // Otherwise istanbul would show this as "branch not covered".
494
+
495
+ /* istanbul ignore next */
496
+
497
+ var isObject = function isObject(_) {
498
+ return _typeof(_) === 'object';
499
+ };
500
+
501
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } return target; }
502
+
503
+ function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
504
+ function parsePhoneNumberFromString(text, options, metadata) {
505
+ // Validate `defaultCountry`.
506
+ if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
507
+ options = _objectSpread$2({}, options, {
508
+ defaultCountry: undefined
509
+ });
510
+ } // Parse phone number.
511
+
512
+
513
+ try {
514
+ return parsePhoneNumber$1(text, options, metadata);
515
+ } catch (error) {
516
+ /* istanbul ignore else */
517
+ if (error instanceof ParseError) ; else {
518
+ throw error;
519
+ }
520
+ }
521
+ }
522
+
523
+ function parsePhoneNumberFromString$1() {
524
+ var _normalizeArguments = normalizeArguments(arguments),
525
+ text = _normalizeArguments.text,
526
+ options = _normalizeArguments.options,
527
+ metadata = _normalizeArguments.metadata;
528
+
529
+ return parsePhoneNumberFromString(text, options, metadata);
530
+ }
531
+
532
+ function parsePhoneNumberFromString$2() {
533
+ return withMetadata(parsePhoneNumberFromString$1, arguments)
534
+ }
535
+
536
+ /**
537
+ * Normalize user input to the domestic form Impact stores: digits only,
538
+ * with the country dial code and trunk-zero prefix removed.
539
+ */
540
+ function toDomesticNumber(phoneCountryCode, input) {
541
+ var _a;
542
+ if (!input)
543
+ return "";
544
+ const parsed = parsePhoneNumberFromString$2(input, phoneCountryCode === null || phoneCountryCode === void 0 ? void 0 : phoneCountryCode.toUpperCase());
545
+ return (_a = parsed === null || parsed === void 0 ? void 0 : parsed.nationalNumber) !== null && _a !== void 0 ? _a : input.replace(/\D/g, "");
546
+ }
547
+ /**
548
+ * Validates a phone number against both libphonenumber-js's per-country
549
+ * pattern rules AND Impact's I18nPhoneNumber length rules, applied to the
550
+ * sanitized value we'll submit.
551
+ */
552
+ function isValidI18nPhoneNumber(phoneCountryCode, phoneNumber) {
553
+ if (!phoneCountryCode || !(phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.trim()))
554
+ return false;
555
+ const country = phoneCountryCode.toUpperCase();
556
+ const parsed = parsePhoneNumberFromString$2(phoneNumber, country);
557
+ if (!(parsed === null || parsed === void 0 ? void 0 : parsed.isValid()))
558
+ return false;
559
+ return passesImpactBackendLengthCheck(country, toDomesticNumber(country, phoneNumber));
560
+ }
561
+ /**
562
+ * Mirrors estalea.bucket.phone.I18nPhoneNumber.isValidI18nPhoneNumber()
563
+ * length rules on the already-sanitized (digits-only) submission value.
564
+ */
565
+ function passesImpactBackendLengthCheck(country, digits) {
566
+ if (!digits)
567
+ return false;
568
+ switch (country) {
569
+ case "US":
570
+ case "CA": {
571
+ const n = digits.startsWith("1") ? digits.slice(1) : digits;
572
+ return n.length === 10;
573
+ }
574
+ case "AU":
575
+ return digits.length === 9 || digits.length === 10;
576
+ case "NZ": {
577
+ let n = digits;
578
+ if (n.length > 9) {
579
+ if (n.startsWith("640"))
580
+ n = n.slice(3);
581
+ else if (n.startsWith("0"))
582
+ n = n.slice(1);
583
+ }
584
+ return n.length >= 8 && n.length <= 10;
585
+ }
586
+ default:
587
+ return stripLeadingZero(digits).length >= 6;
588
+ }
589
+ }
590
+ function stripLeadingZero(digits) {
591
+ return digits.startsWith("0") ? digits.slice(1) : digits;
592
+ }
593
+ function validTaxDocument(requiredType) {
594
+ const validTypes = ["W9", "W8BENE", "W8BEN"];
595
+ if (validTypes.includes(requiredType))
596
+ return true;
597
+ return false;
598
+ }
599
+ const objectIsFull = (obj) => {
600
+ return !Object.keys(obj).find((k) => obj[k] == undefined);
601
+ };
602
+ const taxTypeToName = (taxType) => {
603
+ switch (taxType) {
604
+ case "W9":
605
+ return "W-9";
606
+ case "W8BEN":
607
+ case "W8BENE":
608
+ return "W-8";
609
+ default:
610
+ return "";
611
+ }
612
+ };
613
+ function validateBillingField(regex, value) {
614
+ const trimmed = value.trim();
615
+ const idx = trimmed.search(regex);
616
+ return idx > -1;
617
+ }
618
+ const formatErrorMessage = (fieldName, errorMessage) => {
619
+ return intl.formatMessage({
620
+ id: fieldName,
621
+ defaultMessage: errorMessage,
622
+ }, {
623
+ fieldName,
624
+ });
625
+ };
626
+ function getCountryObj({ countryCode, locale, }) {
627
+ // @ts-ignore DisplayNames not in Intl type
628
+ const displayName = new Intl.DisplayNames([locale], {
629
+ type: "region",
630
+ }).of(countryCode);
631
+ return {
632
+ countryCode,
633
+ displayName,
634
+ };
635
+ }
636
+
637
+ const style = {
638
+ Container: {
639
+ display: "flex",
640
+ flexDirection: "column",
641
+ gap: "35px",
642
+ },
643
+ HeaderContainer: {
644
+ display: "flex",
645
+ flexDirection: "column",
646
+ gap: "10px",
647
+ },
648
+ };
649
+ const sheet = createStyleSheet(style);
650
+ const styleString = sheet.toString();
651
+ const LoadingView = () => {
652
+ return (h("div", { class: sheet.classes.Container },
653
+ h("style", { type: "text/css" }, styleString),
654
+ h("sqm-skeleton", { width: "45%", height: "40px !important" }),
655
+ h("div", { class: sheet.classes.HeaderContainer },
656
+ h("sqm-skeleton", { width: "15%" }),
657
+ h("sqm-skeleton", { width: "25%", height: "30px !important" })),
658
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
659
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
660
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
661
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
662
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
663
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
664
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
665
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
666
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
667
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
668
+ h("sqm-skeleton", { width: "75%", height: "35px" }),
669
+ h("sqm-skeleton", { width: "15%" }),
670
+ h("sqm-skeleton", { width: "80px", height: "30px !important" })));
671
+ };
672
+
673
+ const INDIRECT_TAX_PROVINCES = [
674
+ { regionCode: "ALBERTA", taxType: "GST", displayName: "Alberta" },
675
+ {
676
+ regionCode: "BRITISHCOLUMBIA",
677
+ taxType: "HST",
678
+ displayName: "British Columbia",
679
+ },
680
+ { regionCode: "MANITOBA", taxType: "HST", displayName: "Manitoba" },
681
+ {
682
+ regionCode: "NEWBRUNSWICK",
683
+ taxType: "HST",
684
+ displayName: "New Brunswick",
685
+ },
686
+ {
687
+ regionCode: "NEWFOUNDLANDLABRADOR",
688
+ taxType: "HST",
689
+ displayName: "Newfoundland",
690
+ },
691
+ {
692
+ regionCode: "NORTHWESTTERRITORIES",
693
+ taxType: "GST",
694
+ displayName: "North West Territories",
695
+ },
696
+ { regionCode: "NOVASCOTIA", taxType: "HST", displayName: "Nova Scotia" },
697
+ { regionCode: "NUNAVUT", taxType: "HST", displayName: "Nunavut" },
698
+ { regionCode: "ONTARIO", taxType: "HST", displayName: "Ontario" },
699
+ {
700
+ regionCode: "PRINCEEDWARDISLAND",
701
+ taxType: "HST",
702
+ displayName: "Prince Edward Island",
703
+ },
704
+ { regionCode: "QUEBEC", taxType: "GST", displayName: "Quebec" },
705
+ { regionCode: "SASKATCHEWAN", taxType: "HST", displayName: "Saskatchewan" },
706
+ { regionCode: "YUKON", taxType: "GST", displayName: "Yukon" },
707
+ ];
708
+ const INDIRECT_TAX_SPAIN_REGIONS = [
709
+ { regionCode: "SPAINPROPER", taxType: "VAT", displayName: "Spain Proper" },
710
+ {
711
+ regionCode: "CANARYISLANDS",
712
+ taxType: "VAT",
713
+ displayName: "Canary Islands",
714
+ },
715
+ ];
716
+ const ADDRESS_REGIONS = {
717
+ CA: {
718
+ labelEnum: "PROVINCE",
719
+ regions: [
720
+ {
721
+ label: "Alberta",
722
+ value: "ALBERTA",
723
+ },
724
+ {
725
+ label: "British Columbia",
726
+ value: "BRITISHCOLUMBIA",
727
+ },
728
+ {
729
+ label: "Manitoba",
730
+ value: "MANITOBA",
731
+ },
732
+ {
733
+ label: "New Brunswick",
734
+ value: "NEWBRUNSWICK",
735
+ },
736
+ {
737
+ label: "Newfoundland & Labrador",
738
+ value: "NEWFOUNDLANDANDLABRADOR",
739
+ },
740
+ {
741
+ label: "Northwest Territories",
742
+ value: "NORTHWESTTERRITORIES",
743
+ },
744
+ {
745
+ label: "Nova Scotia",
746
+ value: "NOVASCOTIA",
747
+ },
748
+ {
749
+ label: "Nunavut",
750
+ value: "NUNAVUT",
751
+ },
752
+ {
753
+ label: "Ontario",
754
+ value: "ONTARIO",
755
+ },
756
+ {
757
+ label: "Prince Edward Island",
758
+ value: "PRINCEEDWARDISLAND",
759
+ },
760
+ {
761
+ label: "Quebec",
762
+ value: "QUEBEC",
763
+ },
764
+ {
765
+ label: "Saskatchewan",
766
+ value: "SASKATCHEWAN",
767
+ },
768
+ {
769
+ label: "Yukon",
770
+ value: "YUKON",
771
+ },
772
+ ],
773
+ },
774
+ ES: {
775
+ labelEnum: "REGION",
776
+ regions: [
777
+ {
778
+ label: "Canary Islands",
779
+ value: "CANARYISLANDS",
780
+ },
781
+ {
782
+ label: "Spain Proper",
783
+ value: "SPAINPROPER",
784
+ },
785
+ ],
786
+ },
787
+ AU: {
788
+ labelEnum: "STATE",
789
+ regions: [
790
+ {
791
+ label: "Australian Capital Territory",
792
+ value: "CAPITALTERRITORY",
793
+ },
794
+ {
795
+ label: "New South Wales",
796
+ value: "NEWSOUTHWALES",
797
+ },
798
+ {
799
+ label: "Northern Territory",
800
+ value: "NORTHERNTERRITORY",
801
+ },
802
+ {
803
+ label: "Queensland",
804
+ value: "QUEENSLAND",
805
+ },
806
+ {
807
+ label: "South Australia",
808
+ value: "SOUTHAUSTRALIA",
809
+ },
810
+ {
811
+ label: "Tasmania",
812
+ value: "TASMANIA",
813
+ },
814
+ {
815
+ label: "Victoria",
816
+ value: "VICTORIA",
817
+ },
818
+ {
819
+ label: "Western Australia",
820
+ value: "WESTERNAUSTRALIA",
821
+ },
822
+ ],
823
+ },
824
+ US: {
825
+ labelEnum: "STATE",
826
+ regions: [
827
+ {
828
+ label: "Alabama",
829
+ value: "ALABAMA",
830
+ },
831
+ {
832
+ label: "Alaska",
833
+ value: "ALASKA",
834
+ },
835
+ {
836
+ label: "Arizona",
837
+ value: "ARIZONA",
838
+ },
839
+ {
840
+ label: "Arkansas",
841
+ value: "ARKANSAS",
842
+ },
843
+ {
844
+ label: "California",
845
+ value: "CALIFORNIA",
846
+ },
847
+ {
848
+ label: "Colorado",
849
+ value: "COLORADO",
850
+ },
851
+ {
852
+ label: "Connecticut",
853
+ value: "CONNECTICUT",
854
+ },
855
+ {
856
+ label: "Delaware",
857
+ value: "DELAWARE",
858
+ },
859
+ {
860
+ label: "District of Columbia",
861
+ value: "DISTRICTOFCOLUMBIA",
862
+ },
863
+ {
864
+ label: "Florida",
865
+ value: "FLORIDA",
866
+ },
867
+ {
868
+ label: "Georgia",
869
+ value: "GEORGIA",
870
+ },
871
+ {
872
+ label: "Hawaii",
873
+ value: "HAWAII",
874
+ },
875
+ {
876
+ label: "Idaho",
877
+ value: "IDAHO",
878
+ },
879
+ {
880
+ label: "Illinois",
881
+ value: "ILLINOIS",
882
+ },
883
+ {
884
+ label: "Indiana",
885
+ value: "INDIANA",
886
+ },
887
+ {
888
+ label: "Iowa",
889
+ value: "IOWA",
890
+ },
891
+ {
892
+ label: "Kansas",
893
+ value: "KANSAS",
894
+ },
895
+ {
896
+ label: "Kentucky",
897
+ value: "KENTUCKY",
898
+ },
899
+ {
900
+ label: "Louisiana",
901
+ value: "LOUISIANA",
902
+ },
903
+ {
904
+ label: "Maine",
905
+ value: "MAINE",
906
+ },
907
+ {
908
+ label: "Maryland",
909
+ value: "MARYLAND",
910
+ },
911
+ {
912
+ label: "Massachusetts",
913
+ value: "MASSACHUSETTS",
914
+ },
915
+ {
916
+ label: "Michigan",
917
+ value: "MICHIGAN",
918
+ },
919
+ {
920
+ label: "Minnesota",
921
+ value: "MINNESOTA",
922
+ },
923
+ {
924
+ label: "Mississippi",
925
+ value: "MISSISSIPPI",
926
+ },
927
+ {
928
+ label: "Missouri",
929
+ value: "MISSOURI",
930
+ },
931
+ {
932
+ label: "Montana",
933
+ value: "MONTANA",
934
+ },
935
+ {
936
+ label: "Nebraska",
937
+ value: "NEBRASKA",
938
+ },
939
+ {
940
+ label: "Nevada",
941
+ value: "NEVADA",
942
+ },
943
+ {
944
+ label: "New Hampshire",
945
+ value: "NEWHAMPSHIRE",
946
+ },
947
+ {
948
+ label: "New Jersey",
949
+ value: "NEWJERSEY",
950
+ },
951
+ {
952
+ label: "New Mexico",
953
+ value: "NEWMEXICO",
954
+ },
955
+ {
956
+ label: "New York",
957
+ value: "NEWYORK",
958
+ },
959
+ {
960
+ label: "North Carolina",
961
+ value: "NORTHCAROLINA",
962
+ },
963
+ {
964
+ label: "North Dakota",
965
+ value: "NORTHDAKOTA",
966
+ },
967
+ {
968
+ label: "Ohio",
969
+ value: "OHIO",
970
+ },
971
+ {
972
+ label: "Oklahoma",
973
+ value: "OKLAHOMA",
974
+ },
975
+ {
976
+ label: "Oregon",
977
+ value: "OREGON",
978
+ },
979
+ {
980
+ label: "Pennsylvania",
981
+ value: "PENNSYLVANIA",
982
+ },
983
+ {
984
+ label: "Rhode Island",
985
+ value: "RHODEISLAND",
986
+ },
987
+ {
988
+ label: "South Carolina",
989
+ value: "SOUTHCAROLINA",
990
+ },
991
+ {
992
+ label: "South Dakota",
993
+ value: "SOUTHDAKOTA",
994
+ },
995
+ {
996
+ label: "Tennessee",
997
+ value: "TENNESSEE",
998
+ },
999
+ {
1000
+ label: "Texas",
1001
+ value: "TEXAS",
1002
+ },
1003
+ {
1004
+ label: "Utah",
1005
+ value: "UTAH",
1006
+ },
1007
+ {
1008
+ label: "Vermont",
1009
+ value: "VERMONT",
1010
+ },
1011
+ {
1012
+ label: "Virgin Islands",
1013
+ value: "VIRGINISLANDS",
1014
+ },
1015
+ {
1016
+ label: "Virginia",
1017
+ value: "VIRGINIA",
1018
+ },
1019
+ {
1020
+ label: "Washington",
1021
+ value: "WASHINGTON",
1022
+ },
1023
+ {
1024
+ label: "West Virginia",
1025
+ value: "WESTVIRGINIA",
1026
+ },
1027
+ {
1028
+ label: "Wisconsin",
1029
+ value: "WISCONSIN",
1030
+ },
1031
+ {
1032
+ label: "Wyoming",
1033
+ value: "WYOMING",
1034
+ },
1035
+ {
1036
+ label: "Americas Forces",
1037
+ value: "AAMILITARY",
1038
+ },
1039
+ {
1040
+ label: "Europe, Middle East, Canada, Africa and Canada Forces",
1041
+ value: "AEMILITARY",
1042
+ },
1043
+ {
1044
+ label: "Pacific Forces",
1045
+ value: "APMILITARY",
1046
+ },
1047
+ {
1048
+ label: "Other",
1049
+ value: "OTHER",
1050
+ },
1051
+ ],
1052
+ },
1053
+ };
1054
+
1055
+ export { ADDRESS_REGIONS as A, INDIRECT_TAX_SPAIN_REGIONS as I, LoadingView as L, INDIRECT_TAX_PROVINCES as a, validTaxDocument as b, toDomesticNumber as c, formatErrorMessage as f, getCountryObj as g, isValidI18nPhoneNumber as i, objectIsFull as o, taxTypeToName as t, validateBillingField as v };