@justifi/webcomponents 4.23.1 → 5.0.0-rc-2

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 (965) hide show
  1. package/dist/cjs/{Business-aa799fec.js → Business-cfd6a2dd.js} +5 -0
  2. package/dist/cjs/Dispute-eb6bad54.js +59 -0
  3. package/dist/cjs/{Payment-87b47c43.js → Payment-d074b246.js} +7 -9
  4. package/dist/cjs/additional-questions-details_5.cjs.entry.js +9 -28
  5. package/dist/cjs/bank-account-form_9.cjs.entry.js +493 -0
  6. package/dist/cjs/{business-additional-questions-schema-f5591026.js → business-additional-questions-schema-caa23e95.js} +2 -2
  7. package/dist/cjs/business-details-core.cjs.entry.js +26 -4
  8. package/dist/cjs/{business-form-options-5db0bd5e.js → business-form-options-4bcb8943.js} +1 -1
  9. package/dist/cjs/{business-identity-schema-804a4bd7.js → business-identity-schema-0c537067.js} +2 -2
  10. package/dist/cjs/{business.service-7faffa0b.js → business.service-285f6f26.js} +1 -1
  11. package/dist/cjs/button-94bdc1f0.js +20 -0
  12. package/dist/cjs/{Analytics-7ab90cae.js → check-pkg-version-18426209.js} +23 -3
  13. package/dist/cjs/{checkout.service-aae1996c.js → checkout.service-671fab62.js} +2 -2
  14. package/dist/cjs/checkouts-list-core.cjs.entry.js +37 -30
  15. package/dist/cjs/checkouts-list-params-state-418c75a3.js +14 -0
  16. package/dist/cjs/checkouts-table-17648e93.js +48 -0
  17. package/dist/cjs/{config-05767cba.js → config-b190e93e.js} +1 -1
  18. package/dist/cjs/{custom-popper_4.cjs.entry.js → custom-popper.cjs.entry.js} +3 -107
  19. package/dist/cjs/dispute.service-c362a953.js +29 -0
  20. package/dist/cjs/event-types-180a85a9.js +23 -0
  21. package/dist/cjs/{table-ec9ce9f7.js → event-types-4df47396.js} +16 -8
  22. package/dist/cjs/event-types-8edaabbb.js +22 -0
  23. package/dist/cjs/form-alert_5.cjs.entry.js +9 -8
  24. package/dist/cjs/form-control-checkbox.cjs.entry.js +57 -0
  25. package/dist/cjs/form-control-date.cjs.entry.js +21 -2
  26. package/dist/cjs/form-control-error-text-a2fd5fc1.js +14 -0
  27. package/dist/cjs/form-control-file-v2_2.cjs.entry.js +90 -0
  28. package/dist/cjs/form-control-file.cjs.entry.js +21 -2
  29. package/dist/cjs/form-control-help-text-b6f7ae6e.js +14 -0
  30. package/dist/cjs/form-control-help-text.cjs.entry.js +1 -1
  31. package/dist/cjs/form-control-monetary.cjs.entry.js +22 -2
  32. package/dist/cjs/form-control-number-masked_2.cjs.entry.js +21 -3
  33. package/dist/cjs/form-control-number.cjs.entry.js +21 -2
  34. package/dist/cjs/form-control-radio.cjs.entry.js +25 -17
  35. package/dist/cjs/form-control-select_3.cjs.entry.js +145 -0
  36. package/dist/cjs/{get-payout-csv-1eed32ee.js → get-payout-csv-d2aed52c.js} +2 -2
  37. package/dist/cjs/{get-subaccounts-1d2fb201.js → get-subaccounts-9aa22224.js} +2 -2
  38. package/dist/cjs/gross-payment-chart-core.cjs.entry.js +6 -8
  39. package/dist/cjs/header-1-cb7af794.js +10 -0
  40. package/dist/cjs/header-3-75e50713.js +10 -0
  41. package/dist/cjs/iframe-input-styles-state-d0de0b24.js +26 -0
  42. package/dist/cjs/{justifi-billing-form_2.cjs.entry.js → iframe-input.cjs.entry.js} +73 -180
  43. package/dist/cjs/{index-fb499e95.js → index-5b9a3b5f.js} +1 -93
  44. package/dist/cjs/{insurance-state-80e24caf.js → index-d2d0b181.js} +2 -24
  45. package/dist/cjs/{index.esm-97cf6825.js → index.esm-a397536a.js} +1 -1
  46. package/dist/cjs/insurance-state-001cfe12.js +34 -0
  47. package/dist/cjs/justifi-additional-questions-form-step-core_8.cjs.entry.js +591 -0
  48. package/dist/cjs/justifi-additional-questions-form-step_10.cjs.entry.js +43 -43
  49. package/dist/cjs/justifi-additional-statement_8.cjs.entry.js +413 -0
  50. package/dist/cjs/justifi-business-details.cjs.entry.js +9 -9
  51. package/dist/cjs/justifi-business-form.cjs.entry.js +25 -32
  52. package/dist/cjs/justifi-business-representative-form-inputs.cjs.entry.js +3 -2
  53. package/dist/cjs/justifi-checkout-core.cjs.entry.js +16 -20
  54. package/dist/cjs/justifi-checkout.cjs.entry.js +10 -10
  55. package/dist/cjs/justifi-checkouts-list-filters.cjs.entry.js +38 -0
  56. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +14 -14
  57. package/dist/cjs/justifi-details.cjs.entry.js +4 -4
  58. package/dist/cjs/justifi-dispute-management-core.cjs.entry.js +50 -11
  59. package/dist/cjs/justifi-dispute-management.cjs.entry.js +87 -2
  60. package/dist/cjs/justifi-dispute-notification_3.cjs.entry.js +378 -0
  61. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +7 -7
  62. package/dist/cjs/justifi-owner-form_3.cjs.entry.js +18 -28
  63. package/dist/cjs/justifi-payment-details.cjs.entry.js +10 -9
  64. package/dist/cjs/justifi-payment-provisioning-core.cjs.entry.js +13 -8
  65. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +7 -8
  66. package/dist/cjs/justifi-payments-list-filters.cjs.entry.js +43 -0
  67. package/dist/cjs/justifi-payments-list.cjs.entry.js +13 -13
  68. package/dist/cjs/justifi-payout-details.cjs.entry.js +10 -9
  69. package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +27 -0
  70. package/dist/cjs/justifi-payouts-list.cjs.entry.js +20 -14
  71. package/dist/cjs/justifi-refund-form.cjs.entry.js +7 -10
  72. package/dist/cjs/justifi-season-interruption-insurance-core.cjs.entry.js +17 -18
  73. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +8 -8
  74. package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +35 -0
  75. package/dist/cjs/justifi-terminals-list.cjs.entry.js +12 -12
  76. package/dist/cjs/justifi-tokenize-payment-method.cjs.entry.js +11 -15
  77. package/dist/cjs/loader.cjs.js +2 -2
  78. package/dist/cjs/{package-6d1daab8.js → package-d6ef89ed.js} +1 -1
  79. package/dist/cjs/pagination-menu.cjs.entry.js +26 -0
  80. package/dist/cjs/parts-811ddb9c.js +119 -0
  81. package/dist/cjs/payment-details-core.cjs.entry.js +13 -11
  82. package/dist/cjs/{payment.service-86871f43.js → payment.service-9a5336f1.js} +2 -2
  83. package/dist/cjs/payments-list-core.cjs.entry.js +34 -27
  84. package/dist/cjs/payments-list-params-state-0ff968a7.js +14 -0
  85. package/dist/cjs/payments-table-cf5d1c33.js +32 -0
  86. package/dist/cjs/payout-details-core.cjs.entry.js +8 -5
  87. package/dist/cjs/payouts-list-core.cjs.entry.js +37 -30
  88. package/dist/cjs/payouts-list-params-state-16348184.js +14 -0
  89. package/dist/cjs/payouts-table-58881d95.js +38 -0
  90. package/dist/cjs/{schema-validations-f0363047.js → schema-validations-0be8068a.js} +2 -2
  91. package/dist/cjs/skeleton-5ca03840.js +13 -0
  92. package/dist/cjs/spinner-c11fcb44.js +12 -0
  93. package/dist/cjs/styled-host-94309bab.js +14 -0
  94. package/dist/cjs/table-filters-menu.cjs.entry.js +45 -0
  95. package/dist/cjs/terminals-list-core.cjs.entry.js +36 -29
  96. package/dist/cjs/terminals-list-params-state-95ff6a64.js +14 -0
  97. package/dist/cjs/terminals-table-91985249.js +33 -0
  98. package/dist/cjs/{utils-e88fbc94.js → utils-a21b7453.js} +31 -28
  99. package/dist/cjs/utils-fc17191b.js +29 -0
  100. package/dist/cjs/webcomponents.cjs.js +2 -2
  101. package/dist/collection/api/Analytics.js +1 -1
  102. package/dist/collection/api/Business.js +5 -0
  103. package/dist/collection/api/Dispute.js +55 -0
  104. package/dist/collection/api/DisputeEvidenceDocument.js +44 -0
  105. package/dist/collection/api/Payment.js +6 -9
  106. package/dist/collection/api/services/dispute.service.js +20 -0
  107. package/dist/collection/collection-manifest.json +16 -17
  108. package/dist/collection/components/billing-form/billing-form.js +2 -19
  109. package/dist/collection/components/business-details/additional-questions-details/additional-questions-details.js +1 -19
  110. package/dist/collection/components/business-details/business-details-core.js +8 -7
  111. package/dist/collection/components/business-details/business-details-loading.js +6 -0
  112. package/dist/collection/components/business-details/business-details.js +5 -13
  113. package/dist/collection/components/business-details/generic-info-details/generic-info-details.js +1 -11
  114. package/dist/collection/components/business-details/legal-address-details/legal-address-details.js +1 -11
  115. package/dist/collection/components/business-details/owner-details/owner-details.js +1 -11
  116. package/dist/collection/components/business-details/representative-details/representative-details.js +1 -19
  117. package/dist/collection/components/business-forms/business-form/additional-questions/additional-questions.js +2 -6
  118. package/dist/collection/components/business-forms/business-form/business-core-info/business-core-info.js +2 -4
  119. package/dist/collection/components/business-forms/business-form/business-form.js +18 -59
  120. package/dist/collection/components/business-forms/business-form/business-representative/business-representative.js +2 -1
  121. package/dist/collection/components/business-forms/business-form/legal-address-form/legal-address-form.js +2 -6
  122. package/dist/collection/components/business-forms/owner-form/identity-address/identity-address-form.js +1 -1
  123. package/dist/collection/components/business-forms/owner-form/owner-form-core.js +22 -52
  124. package/dist/collection/components/business-forms/owner-form/owner-form-inputs.js +1 -1
  125. package/dist/collection/components/business-forms/owner-form/owner-form.js +6 -6
  126. package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step-core.js +18 -40
  127. package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step.js +6 -11
  128. package/dist/collection/components/business-forms/payment-provisioning/bank-account/business-bank-account-form-step.js +19 -44
  129. package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step-core.js +18 -40
  130. package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step.js +6 -11
  131. package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step-core.js +26 -47
  132. package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step.js +6 -11
  133. package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-inputs.js +2 -1
  134. package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-step-core.js +17 -39
  135. package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-step.js +6 -6
  136. package/dist/collection/components/business-forms/payment-provisioning/document-uploads/business-document-upload-form-step.js +21 -42
  137. package/dist/collection/components/business-forms/payment-provisioning/document-uploads/business-document-upload-input-group.js +1 -1
  138. package/dist/collection/components/business-forms/payment-provisioning/document-uploads/business-documents-on-file.js +4 -3
  139. package/dist/collection/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step-core.js +18 -39
  140. package/dist/collection/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step.js +6 -11
  141. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-core.js +32 -23
  142. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-form-buttons.js +2 -2
  143. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-form-steps.js +2 -20
  144. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning.js +7 -11
  145. package/dist/collection/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-form-step.js +30 -31
  146. package/dist/collection/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-text.js +2 -11
  147. package/dist/collection/components/business-forms/utils/event-types.js +21 -0
  148. package/dist/collection/components/business-forms/utils/index.js +4 -0
  149. package/dist/collection/components/checkout/bank-account-form/bank-account-form.js +65 -0
  150. package/dist/collection/components/checkout/card-form/card-form.js +67 -0
  151. package/dist/collection/components/checkout/checkout-core.js +19 -28
  152. package/dist/collection/components/checkout/checkout.js +7 -7
  153. package/dist/collection/components/checkout/message-event-types.js +4 -0
  154. package/dist/collection/components/checkout/new-payment-method.js +23 -15
  155. package/dist/collection/components/checkout/payment-method-options.js +1 -11
  156. package/dist/collection/components/checkout/save-new-payment-method.js +3 -4
  157. package/dist/collection/components/checkout/saved-payment-method.js +6 -5
  158. package/dist/collection/components/checkout/sezzle-payment-method.js +6 -4
  159. package/dist/collection/components/checkouts-list/checkouts-list-core.js +43 -36
  160. package/dist/collection/components/checkouts-list/checkouts-list-filters.js +8 -61
  161. package/dist/collection/components/checkouts-list/checkouts-list-params-state.js +8 -0
  162. package/dist/collection/components/checkouts-list/checkouts-list.js +7 -29
  163. package/dist/collection/components/checkouts-list/checkouts-table.js +13 -12
  164. package/dist/collection/components/dispute-management/dispute-actions.js +31 -0
  165. package/dist/collection/components/dispute-management/dispute-management-core.js +131 -17
  166. package/dist/collection/components/dispute-management/dispute-management.js +143 -2
  167. package/dist/collection/components/dispute-management/dispute-notification.js +135 -15
  168. package/dist/collection/components/dispute-management/dispute-response/additional-statement.js +110 -0
  169. package/dist/collection/components/dispute-management/dispute-response/cancellation-policy.js +106 -0
  170. package/dist/collection/components/dispute-management/dispute-response/customer-details.js +106 -0
  171. package/dist/collection/components/dispute-management/dispute-response/dispute-response-actions.js +117 -0
  172. package/dist/collection/components/dispute-management/dispute-response/dispute-response-core.js +362 -0
  173. package/dist/collection/components/dispute-management/dispute-response/dispute-response-form-types.js +12 -0
  174. package/dist/collection/components/dispute-management/dispute-response/dispute-response.js +186 -0
  175. package/dist/collection/components/dispute-management/dispute-response/duplicate-charge.js +106 -0
  176. package/dist/collection/components/dispute-management/dispute-response/electronic-evidence.js +106 -0
  177. package/dist/collection/components/dispute-management/dispute-response/product-or-service.js +106 -0
  178. package/dist/collection/components/dispute-management/dispute-response/refund-policy.js +106 -0
  179. package/dist/collection/components/dispute-management/dispute-response/schemas/additional-statement-schema.js +5 -0
  180. package/dist/collection/components/dispute-management/dispute-response/schemas/cancellation-policy-schema.js +6 -0
  181. package/dist/collection/components/dispute-management/dispute-response/schemas/customer-details-schema.js +7 -0
  182. package/dist/collection/components/dispute-management/dispute-response/schemas/dispute-reason-schema.js +5 -0
  183. package/dist/collection/components/dispute-management/dispute-response/schemas/duplicate-charge-schema.js +6 -0
  184. package/dist/collection/components/dispute-management/dispute-response/schemas/electronic-evidence-schema.js +5 -0
  185. package/dist/collection/components/dispute-management/dispute-response/schemas/product-or-service-schema.js +6 -0
  186. package/dist/collection/components/dispute-management/dispute-response/schemas/refund-policy-schema.js +6 -0
  187. package/dist/collection/components/dispute-management/dispute-response/schemas/shipping-details-schema.js +8 -0
  188. package/dist/collection/components/dispute-management/dispute-response/shipping-details.js +106 -0
  189. package/dist/collection/components/dispute-management/event-types.js +20 -0
  190. package/dist/collection/components/gross-payment-chart/gross-payment-chart-core.js +8 -17
  191. package/dist/collection/components/gross-payment-chart/gross-payment-chart.js +5 -5
  192. package/dist/collection/components/insurance/season-interruption/season-interruption-insurance-core.js +19 -22
  193. package/dist/collection/components/insurance/season-interruption/season-interruption-insurance.js +6 -6
  194. package/dist/collection/components/pagination-menu/pagination-menu.js +5 -4
  195. package/dist/collection/components/payment-details/payment-details-core.js +15 -13
  196. package/dist/collection/components/payment-details/payment-details.js +5 -28
  197. package/dist/collection/components/payments-list/payments-list-core.js +40 -33
  198. package/dist/collection/components/payments-list/payments-list-filters.js +8 -61
  199. package/dist/collection/components/payments-list/payments-list-params-state.js +8 -0
  200. package/dist/collection/components/payments-list/payments-list.js +7 -29
  201. package/dist/collection/components/payments-list/payments-table.js +15 -14
  202. package/dist/collection/components/payout-details/payout-details-core.js +10 -8
  203. package/dist/collection/components/payout-details/payout-details.js +5 -5
  204. package/dist/collection/components/payouts-list/payouts-list-core.js +43 -36
  205. package/dist/collection/components/payouts-list/payouts-list-filters.js +8 -60
  206. package/dist/collection/components/payouts-list/payouts-list-params-state.js +8 -0
  207. package/dist/collection/components/payouts-list/payouts-list.js +6 -28
  208. package/dist/collection/components/payouts-list/payouts-table.js +19 -18
  209. package/dist/collection/components/refund-form/refund-form.js +1 -11
  210. package/dist/collection/components/refund-form/refund-form.stories.js +1 -60
  211. package/dist/collection/components/terminals-list/terminals-list-core.js +43 -36
  212. package/dist/collection/components/terminals-list/terminals-list-filters.js +8 -61
  213. package/dist/collection/components/terminals-list/terminals-list-params-state.js +8 -0
  214. package/dist/collection/components/terminals-list/terminals-list.js +7 -29
  215. package/dist/collection/components/terminals-list/terminals-table.js +9 -8
  216. package/dist/collection/components/tokenize-payment-method/tokenize-payment-method.js +20 -24
  217. package/dist/collection/styles/parts.js +74 -0
  218. package/dist/collection/ui-components/button.js +6 -12
  219. package/dist/collection/ui-components/custom-popper/custom-popper.js +2 -2
  220. package/dist/collection/ui-components/details/details.js +2 -4
  221. package/dist/collection/ui-components/details/utils.js +7 -10
  222. package/dist/collection/ui-components/filters/table-filters-menu.js +5 -1
  223. package/dist/collection/ui-components/form/form-control-checkbox.js +31 -16
  224. package/dist/collection/ui-components/form/form-control-date.js +25 -1
  225. package/dist/collection/ui-components/form/form-control-file-v2.js +177 -0
  226. package/dist/collection/ui-components/form/form-control-file.js +22 -2
  227. package/dist/collection/ui-components/form/form-control-monetary.js +25 -1
  228. package/dist/collection/ui-components/form/form-control-number-masked.js +24 -1
  229. package/dist/collection/ui-components/form/form-control-number.js +24 -1
  230. package/dist/collection/ui-components/form/form-control-radio.js +50 -40
  231. package/dist/collection/ui-components/form/form-control-select.js +25 -1
  232. package/dist/collection/ui-components/form/form-control-text.js +24 -1
  233. package/dist/collection/ui-components/form/form-control-textarea.js +27 -2
  234. package/dist/collection/ui-components/form/form-helpers/form-alert/form-alert.js +2 -1
  235. package/dist/collection/ui-components/form/form-helpers/form-control-error-text.js +9 -0
  236. package/dist/collection/ui-components/form/form-helpers/form-control-help-text.js +9 -0
  237. package/dist/collection/ui-components/form/form-helpers/form-control-tooltip/form-control-tooltip.js +2 -1
  238. package/dist/collection/ui-components/form/form.js +1 -1
  239. package/dist/collection/ui-components/form/hidden-input.js +85 -0
  240. package/dist/collection/ui-components/form/iframe-input-styles-state.js +21 -0
  241. package/dist/collection/ui-components/form/iframe-input.js +215 -0
  242. package/dist/collection/ui-components/headers/header-1.js +5 -0
  243. package/dist/collection/ui-components/headers/header-2.js +5 -0
  244. package/dist/collection/ui-components/headers/header-3.js +5 -0
  245. package/dist/collection/ui-components/index.js +6 -0
  246. package/dist/collection/ui-components/skeleton.js +4 -34
  247. package/dist/collection/ui-components/spinner.js +6 -0
  248. package/dist/collection/ui-components/table/event-types.js +6 -0
  249. package/dist/collection/ui-components/table-empty-state.js +2 -1
  250. package/dist/collection/ui-components/table-error-state.js +2 -1
  251. package/dist/collection/ui-components/table-loading-state.js +3 -1
  252. package/dist/collection/utils/table.js +2 -2
  253. package/dist/collection/utils/utils.js +27 -26
  254. package/dist/docs.json +3573 -4721
  255. package/dist/esm/{Business-b73d5055.js → Business-29c69f22.js} +6 -1
  256. package/dist/esm/Dispute-5fd28ec9.js +57 -0
  257. package/dist/esm/{Payment-2a868d0c.js → Payment-4f72d277.js} +7 -9
  258. package/dist/esm/additional-questions-details_5.entry.js +9 -28
  259. package/dist/esm/bank-account-form_9.entry.js +481 -0
  260. package/dist/esm/{business-additional-questions-schema-d94f8975.js → business-additional-questions-schema-48e93928.js} +2 -2
  261. package/dist/esm/business-details-core.entry.js +26 -4
  262. package/dist/esm/{business-form-options-d790973e.js → business-form-options-018f62a5.js} +1 -1
  263. package/dist/esm/{business-identity-schema-2756dbc6.js → business-identity-schema-75126188.js} +2 -2
  264. package/dist/esm/{business.service-97a3da69.js → business.service-182aea6f.js} +1 -1
  265. package/dist/esm/button-1886a33d.js +18 -0
  266. package/dist/esm/{Analytics-77dc80f3.js → check-pkg-version-157854b7.js} +23 -4
  267. package/dist/esm/{checkout.service-c1e44e0c.js → checkout.service-32a6ebe8.js} +2 -2
  268. package/dist/esm/checkouts-list-core.entry.js +36 -29
  269. package/dist/esm/checkouts-list-params-state-1d968971.js +10 -0
  270. package/dist/esm/checkouts-table-8b116232.js +44 -0
  271. package/dist/esm/{config-27764a9d.js → config-187b3ae1.js} +1 -1
  272. package/dist/esm/{custom-popper_4.entry.js → custom-popper.entry.js} +4 -105
  273. package/dist/esm/dispute.service-4e5059aa.js +27 -0
  274. package/dist/esm/{table-44e3d1e7.js → event-types-01dcdcbd.js} +17 -9
  275. package/dist/esm/event-types-07cdb9a0.js +22 -0
  276. package/dist/esm/event-types-5c87de02.js +23 -0
  277. package/dist/esm/form-alert_5.entry.js +9 -8
  278. package/dist/esm/form-control-checkbox.entry.js +53 -0
  279. package/dist/esm/form-control-date.entry.js +21 -2
  280. package/dist/esm/form-control-error-text-3b2553b5.js +12 -0
  281. package/dist/esm/form-control-file-v2_2.entry.js +85 -0
  282. package/dist/esm/form-control-file.entry.js +21 -2
  283. package/dist/esm/form-control-help-text-a2fc3617.js +12 -0
  284. package/dist/esm/form-control-help-text.entry.js +1 -1
  285. package/dist/esm/form-control-monetary.entry.js +22 -2
  286. package/dist/esm/form-control-number-masked_2.entry.js +21 -3
  287. package/dist/esm/form-control-number.entry.js +21 -2
  288. package/dist/esm/form-control-radio.entry.js +25 -17
  289. package/dist/esm/form-control-select_3.entry.js +139 -0
  290. package/dist/esm/{get-payout-csv-3b83b088.js → get-payout-csv-e6058aa7.js} +2 -2
  291. package/dist/esm/{get-subaccounts-dd20cfa4.js → get-subaccounts-0b8af245.js} +2 -2
  292. package/dist/esm/gross-payment-chart-core.entry.js +6 -8
  293. package/dist/esm/header-1-c6a00a22.js +8 -0
  294. package/dist/esm/header-3-a1c6d475.js +8 -0
  295. package/dist/esm/iframe-input-styles-state-ff730fe5.js +23 -0
  296. package/dist/esm/{justifi-billing-form_2.entry.js → iframe-input.entry.js} +73 -179
  297. package/dist/esm/{index-57431c24.js → index-29fcfdf5.js} +1 -93
  298. package/dist/esm/{insurance-state-8ce01e59.js → index-a47fdc7f.js} +2 -21
  299. package/dist/esm/{index.esm-ed37201b.js → index.esm-0b6849c2.js} +1 -1
  300. package/dist/esm/insurance-state-8fc9376f.js +28 -0
  301. package/dist/esm/justifi-additional-questions-form-step-core_8.entry.js +580 -0
  302. package/dist/esm/justifi-additional-questions-form-step_10.entry.js +43 -43
  303. package/dist/esm/justifi-additional-statement_8.entry.js +402 -0
  304. package/dist/esm/justifi-business-details.entry.js +8 -8
  305. package/dist/esm/justifi-business-form.entry.js +21 -28
  306. package/dist/esm/justifi-business-representative-form-inputs.entry.js +3 -2
  307. package/dist/esm/justifi-checkout-core.entry.js +16 -20
  308. package/dist/esm/justifi-checkout.entry.js +9 -9
  309. package/dist/esm/justifi-checkouts-list-filters.entry.js +34 -0
  310. package/dist/esm/justifi-checkouts-list.entry.js +13 -13
  311. package/dist/esm/justifi-details.entry.js +4 -4
  312. package/dist/esm/justifi-dispute-management-core.entry.js +50 -11
  313. package/dist/esm/justifi-dispute-management.entry.js +87 -2
  314. package/dist/esm/justifi-dispute-notification_3.entry.js +372 -0
  315. package/dist/esm/justifi-gross-payment-chart.entry.js +6 -6
  316. package/dist/esm/justifi-owner-form_3.entry.js +16 -26
  317. package/dist/esm/justifi-payment-details.entry.js +9 -8
  318. package/dist/esm/justifi-payment-provisioning-core.entry.js +12 -7
  319. package/dist/esm/justifi-payment-provisioning.entry.js +6 -7
  320. package/dist/esm/justifi-payments-list-filters.entry.js +39 -0
  321. package/dist/esm/justifi-payments-list.entry.js +12 -12
  322. package/dist/esm/justifi-payout-details.entry.js +9 -8
  323. package/dist/esm/justifi-payouts-list-filters.entry.js +23 -0
  324. package/dist/esm/justifi-payouts-list.entry.js +19 -13
  325. package/dist/esm/justifi-refund-form.entry.js +7 -10
  326. package/dist/esm/justifi-season-interruption-insurance-core.entry.js +17 -18
  327. package/dist/esm/justifi-season-interruption-insurance.entry.js +7 -7
  328. package/dist/esm/justifi-terminals-list-filters.entry.js +31 -0
  329. package/dist/esm/justifi-terminals-list.entry.js +11 -11
  330. package/dist/esm/justifi-tokenize-payment-method.entry.js +10 -14
  331. package/dist/esm/loader.js +3 -3
  332. package/dist/esm/{package-627f73c1.js → package-9e3b7f9e.js} +1 -1
  333. package/dist/esm/pagination-menu.entry.js +22 -0
  334. package/dist/esm/parts-186d437f.js +72 -0
  335. package/dist/esm/payment-details-core.entry.js +13 -11
  336. package/dist/esm/{payment.service-ca6b5bc5.js → payment.service-45f90e06.js} +2 -2
  337. package/dist/esm/payments-list-core.entry.js +33 -26
  338. package/dist/esm/payments-list-params-state-b3dab8bc.js +10 -0
  339. package/dist/esm/payments-table-d6fbab5b.js +28 -0
  340. package/dist/esm/payout-details-core.entry.js +8 -5
  341. package/dist/esm/payouts-list-core.entry.js +36 -29
  342. package/dist/esm/payouts-list-params-state-49618e7a.js +10 -0
  343. package/dist/esm/payouts-table-2e61a116.js +34 -0
  344. package/dist/esm/{schema-validations-93a9d504.js → schema-validations-c7d4f9df.js} +2 -2
  345. package/dist/esm/skeleton-8f71cdf7.js +11 -0
  346. package/dist/esm/spinner-879489b3.js +10 -0
  347. package/dist/esm/styled-host-32228b45.js +12 -0
  348. package/dist/esm/table-filters-menu.entry.js +41 -0
  349. package/dist/esm/terminals-list-core.entry.js +35 -28
  350. package/dist/esm/terminals-list-params-state-2c48d35f.js +10 -0
  351. package/dist/esm/terminals-table-8e42977c.js +29 -0
  352. package/dist/esm/{utils-1df1e55a.js → utils-54543523.js} +31 -30
  353. package/dist/esm/utils-d7633e66.js +22 -0
  354. package/dist/esm/webcomponents.js +3 -3
  355. package/dist/module/Business.js +6 -1
  356. package/dist/module/Payment.js +62 -10
  357. package/dist/module/additional-questions-details2.js +1 -5
  358. package/dist/module/additional-questions.js +4 -15
  359. package/dist/module/additional-statement.js +52 -13
  360. package/dist/module/{justifi-card-form.d.ts → bank-account-form.d.ts} +4 -4
  361. package/dist/module/bank-account-form.js +6 -0
  362. package/dist/module/bank-account-form2.js +44 -0
  363. package/dist/module/billing-form.js +6 -18
  364. package/dist/module/business-additional-questions-form-step-core.js +8 -21
  365. package/dist/module/business-additional-questions-form-step.js +3 -15
  366. package/dist/module/business-bank-account-form-step.js +11 -18
  367. package/dist/module/business-core-info-form-step-core.js +11 -18
  368. package/dist/module/business-core-info-form-step.js +5 -11
  369. package/dist/module/business-core-info.js +6 -11
  370. package/dist/module/business-details-core2.js +25 -3
  371. package/dist/module/business-document-upload-form-step.js +12 -18
  372. package/dist/module/business-document-upload-input-group.js +3 -9
  373. package/dist/module/business-documents-on-file.js +4 -3
  374. package/dist/module/business-owners-form-step-core.js +12 -18
  375. package/dist/module/business-owners-form-step.js +5 -11
  376. package/dist/module/business-representative-form-inputs.js +6 -11
  377. package/dist/module/business-representative-form-step-core.js +9 -17
  378. package/dist/module/business-representative-form-step.js +5 -11
  379. package/dist/module/business-representative.js +6 -11
  380. package/dist/module/business-terms-conditions-form-step.js +16 -22
  381. package/dist/module/business-terms-conditions-text.js +2 -5
  382. package/dist/module/button.js +6 -12
  383. package/dist/module/cancellation-policy.js +49 -13
  384. package/dist/module/{justifi-payment-form.d.ts → card-form.d.ts} +4 -4
  385. package/dist/module/card-form.js +6 -0
  386. package/dist/module/card-form2.js +46 -0
  387. package/dist/module/check-pkg-version.js +76 -1
  388. package/dist/module/checkout-core.js +55 -30
  389. package/dist/module/checkouts-list-core2.js +47 -77
  390. package/dist/module/checkouts-list-params-state.js +10 -0
  391. package/dist/module/config.js +1 -1
  392. package/dist/module/custom-popper2.js +2 -2
  393. package/dist/module/customer-details.js +50 -13
  394. package/dist/module/details.js +3 -5
  395. package/dist/module/dispute-management-core.js +74 -39
  396. package/dist/module/dispute-notification.js +41 -8
  397. package/dist/module/dispute-response-actions.js +117 -0
  398. package/dist/module/dispute-response-core.js +280 -0
  399. package/dist/module/dispute-response-form-types.js +59 -0
  400. package/dist/module/dispute-response.js +198 -0
  401. package/dist/module/duplicate-charge.js +49 -13
  402. package/dist/module/electronic-evidence.js +49 -20
  403. package/dist/module/{table.js → event-types.js} +16 -8
  404. package/dist/module/event-types2.js +23 -0
  405. package/dist/module/event-types3.js +22 -0
  406. package/dist/module/form-alert2.js +2 -1
  407. package/dist/module/form-control-checkbox2.js +29 -27
  408. package/dist/module/form-control-date2.js +25 -10
  409. package/dist/module/form-control-error-text.js +10 -4
  410. package/dist/module/{payouts-list-filters.d.ts → form-control-file-v2.d.ts} +4 -4
  411. package/dist/module/form-control-file-v2.js +6 -0
  412. package/dist/module/form-control-file-v22.js +59 -0
  413. package/dist/module/form-control-file2.js +25 -10
  414. package/dist/module/form-control-help-text.js +1 -1
  415. package/dist/module/form-control-help-text2.js +9 -32
  416. package/dist/module/form-control-help-text3.js +35 -0
  417. package/dist/module/form-control-monetary2.js +26 -16
  418. package/dist/module/form-control-number-masked2.js +25 -11
  419. package/dist/module/form-control-number.js +24 -15
  420. package/dist/module/form-control-radio2.js +31 -30
  421. package/dist/module/form-control-select2.js +25 -10
  422. package/dist/module/form-control-text2.js +24 -10
  423. package/dist/module/form-control-textarea2.js +26 -11
  424. package/dist/module/form-control-tooltip2.js +2 -1
  425. package/dist/module/form.js +1 -1
  426. package/dist/module/generic-info-details2.js +1 -5
  427. package/dist/module/get-payout-csv.js +1 -1
  428. package/dist/module/get-subaccounts.js +1 -1
  429. package/dist/module/gross-payment-chart-core2.js +3 -6
  430. package/dist/module/header-1.js +8 -0
  431. package/dist/module/{payments-list-filters.d.ts → hidden-input.d.ts} +4 -4
  432. package/dist/module/hidden-input.js +6 -0
  433. package/dist/module/hidden-input2.js +100 -0
  434. package/dist/module/identity-address-form.js +4 -10
  435. package/dist/module/iframe-input-styles-state.js +23 -0
  436. package/dist/module/iframe-input.d.ts +11 -0
  437. package/dist/module/iframe-input.js +6 -0
  438. package/dist/module/{payment-method-form.js → iframe-input2.js} +83 -131
  439. package/dist/module/index2.js +167 -3572
  440. package/dist/module/index3.js +3599 -0
  441. package/dist/module/insurance-state.js +6 -191
  442. package/dist/module/justifi-business-details.js +2 -3
  443. package/dist/module/justifi-business-form.js +16 -36
  444. package/dist/module/justifi-checkout.js +52 -23
  445. package/dist/module/justifi-checkouts-list-filters.d.ts +11 -0
  446. package/dist/module/justifi-checkouts-list-filters.js +77 -0
  447. package/dist/module/justifi-checkouts-list.js +8 -45
  448. package/dist/module/justifi-dispute-management.js +109 -34
  449. package/dist/module/justifi-dispute-response-core.d.ts +11 -0
  450. package/dist/module/justifi-dispute-response-core.js +6 -0
  451. package/dist/module/justifi-dispute-response.d.ts +11 -0
  452. package/dist/module/justifi-dispute-response.js +6 -0
  453. package/dist/module/justifi-gross-payment-chart.js +2 -3
  454. package/dist/module/justifi-payment-details.js +3 -4
  455. package/dist/module/justifi-payment-provisioning.js +12 -24
  456. package/dist/module/justifi-payments-list-filters.d.ts +11 -0
  457. package/dist/module/justifi-payments-list-filters.js +94 -0
  458. package/dist/module/justifi-payments-list.js +9 -58
  459. package/dist/module/justifi-payout-details.js +2 -3
  460. package/dist/module/justifi-payouts-list-filters.d.ts +11 -0
  461. package/dist/module/justifi-payouts-list-filters.js +66 -0
  462. package/dist/module/justifi-payouts-list.js +14 -45
  463. package/dist/module/justifi-refund-form.js +4 -19
  464. package/dist/module/justifi-season-interruption-insurance.js +16 -5
  465. package/dist/module/justifi-terminals-list-filters.d.ts +11 -0
  466. package/dist/module/{terminals-list-filters2.js → justifi-terminals-list-filters.js} +25 -28
  467. package/dist/module/justifi-terminals-list.js +8 -51
  468. package/dist/module/justifi-tokenize-payment-method.js +51 -25
  469. package/dist/module/legal-address-details2.js +1 -5
  470. package/dist/module/legal-address-form-step-core.js +10 -17
  471. package/dist/module/legal-address-form-step.js +3 -9
  472. package/dist/module/legal-address-form.js +5 -10
  473. package/dist/module/new-payment-method.js +72 -30
  474. package/dist/module/owner-details2.js +1 -5
  475. package/dist/module/owner-form-core2.js +10 -25
  476. package/dist/module/owner-form-inputs2.js +5 -11
  477. package/dist/module/owner-form.js +5 -11
  478. package/dist/module/package.js +1 -1
  479. package/dist/module/pagination-menu2.js +4 -3
  480. package/dist/module/parts.js +72 -0
  481. package/dist/module/payment-details-core2.js +11 -9
  482. package/dist/module/payment-method-options.js +47 -24
  483. package/dist/module/payment-provisioning-actions.js +1 -1
  484. package/dist/module/payment-provisioning-core.js +21 -28
  485. package/dist/module/payment-provisioning-form-buttons.js +4 -2
  486. package/dist/module/payment-provisioning-form-steps.js +11 -24
  487. package/dist/module/payments-list-core2.js +46 -88
  488. package/dist/module/payments-list-params-state.js +10 -0
  489. package/dist/module/payout-details-core2.js +6 -3
  490. package/dist/module/payouts-list-core2.js +53 -83
  491. package/dist/module/payouts-list-params-state.js +10 -0
  492. package/dist/module/product-or-service.js +46 -13
  493. package/dist/module/refund-policy.js +49 -13
  494. package/dist/module/representative-details2.js +1 -5
  495. package/dist/module/save-new-payment-method.js +10 -5
  496. package/dist/module/saved-payment-method.js +19 -6
  497. package/dist/module/season-interruption-insurance-core.js +29 -19
  498. package/dist/module/sezzle-payment-method.js +19 -5
  499. package/dist/module/shipping-details.js +53 -19
  500. package/dist/module/skeleton.js +4 -34
  501. package/dist/module/spinner.js +10 -0
  502. package/dist/module/styled-host.js +1 -1
  503. package/dist/module/table-filters-menu2.js +12 -2
  504. package/dist/module/terminals-list-core2.js +43 -79
  505. package/dist/module/terminals-list-params-state.js +10 -0
  506. package/dist/module/utils.js +14 -19
  507. package/dist/module/utils2.js +31 -30
  508. package/dist/module/utils3.js +25 -30
  509. package/dist/module/utils4.js +23 -24
  510. package/dist/types/api/Business.d.ts +4 -0
  511. package/dist/types/api/Checkout.d.ts +1 -3
  512. package/dist/types/api/ComponentError.d.ts +0 -6
  513. package/dist/types/api/ComponentEvents.d.ts +23 -0
  514. package/dist/types/api/Dispute.d.ts +76 -0
  515. package/dist/types/api/DisputeEvidenceDocument.d.ts +23 -0
  516. package/dist/types/api/Payment.d.ts +6 -11
  517. package/dist/types/api/Payout.d.ts +1 -3
  518. package/dist/types/api/Terminal.d.ts +1 -4
  519. package/dist/types/api/services/dispute.service.d.ts +14 -0
  520. package/dist/types/components/billing-form/billing-form.d.ts +0 -5
  521. package/dist/types/components/business-details/additional-questions-details/additional-questions-details.d.ts +0 -8
  522. package/dist/types/components/business-details/business-details-core.d.ts +2 -2
  523. package/dist/types/components/business-details/business-details-loading.d.ts +1 -0
  524. package/dist/types/components/business-details/business-details.d.ts +2 -10
  525. package/dist/types/components/business-details/representative-details/representative-details.d.ts +0 -8
  526. package/dist/types/components/business-forms/business-form/additional-questions/additional-questions.d.ts +0 -5
  527. package/dist/types/components/business-forms/business-form/business-core-info/business-core-info.d.ts +0 -3
  528. package/dist/types/components/business-forms/business-form/business-form.d.ts +4 -11
  529. package/dist/types/components/business-forms/business-form/legal-address-form/legal-address-form.d.ts +0 -5
  530. package/dist/types/components/business-forms/owner-form/owner-form-core.d.ts +4 -6
  531. package/dist/types/components/business-forms/owner-form/owner-form.d.ts +2 -2
  532. package/dist/types/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step-core.d.ts +3 -5
  533. package/dist/types/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step.d.ts +2 -7
  534. package/dist/types/components/business-forms/payment-provisioning/bank-account/business-bank-account-form-step.d.ts +3 -8
  535. package/dist/types/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step-core.d.ts +3 -5
  536. package/dist/types/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step.d.ts +2 -7
  537. package/dist/types/components/business-forms/payment-provisioning/business-owners/business-owners-form-step-core.d.ts +4 -6
  538. package/dist/types/components/business-forms/payment-provisioning/business-owners/business-owners-form-step.d.ts +2 -7
  539. package/dist/types/components/business-forms/payment-provisioning/business-representative/business-representative-form-step-core.d.ts +3 -5
  540. package/dist/types/components/business-forms/payment-provisioning/business-representative/business-representative-form-step.d.ts +2 -2
  541. package/dist/types/components/business-forms/payment-provisioning/document-uploads/business-document-upload-form-step.d.ts +3 -5
  542. package/dist/types/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step-core.d.ts +3 -5
  543. package/dist/types/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step.d.ts +2 -7
  544. package/dist/types/components/business-forms/payment-provisioning/payment-provisioning-core.d.ts +5 -5
  545. package/dist/types/components/business-forms/payment-provisioning/payment-provisioning-form-steps.d.ts +0 -2
  546. package/dist/types/components/business-forms/payment-provisioning/payment-provisioning.d.ts +2 -7
  547. package/dist/types/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-form-step.d.ts +5 -5
  548. package/dist/types/components/business-forms/utils/event-types.d.ts +19 -0
  549. package/dist/types/components/business-forms/utils/index.d.ts +4 -0
  550. package/dist/types/components/checkout/bank-account-form/bank-account-form.d.ts +7 -0
  551. package/dist/types/components/checkout/card-form/card-form.d.ts +9 -0
  552. package/dist/types/components/checkout/checkout-core.d.ts +5 -4
  553. package/dist/types/components/checkout/checkout.d.ts +2 -2
  554. package/dist/types/components/checkout/message-event-types.d.ts +4 -0
  555. package/dist/types/components/checkout/new-payment-method.d.ts +3 -3
  556. package/dist/types/components/checkout/save-new-payment-method.d.ts +1 -1
  557. package/dist/types/components/checkout/saved-payment-method.d.ts +1 -1
  558. package/dist/types/components/checkout/sezzle-payment-method.d.ts +1 -1
  559. package/dist/types/components/checkouts-list/checkouts-list-core.d.ts +7 -8
  560. package/dist/types/components/checkouts-list/checkouts-list-filters.d.ts +1 -3
  561. package/dist/types/components/checkouts-list/checkouts-list-params-state.d.ts +5 -0
  562. package/dist/types/components/checkouts-list/checkouts-list.d.ts +2 -24
  563. package/dist/types/components/checkouts-list/checkouts-table.d.ts +6 -6
  564. package/dist/types/components/dispute-management/dispute-actions.d.ts +9 -0
  565. package/dist/types/components/dispute-management/dispute-management-core.d.ts +14 -3
  566. package/dist/types/components/dispute-management/dispute-management.d.ts +15 -0
  567. package/dist/types/components/dispute-management/dispute-notification.d.ts +9 -3
  568. package/dist/types/components/dispute-management/dispute-response/additional-statement.d.ts +17 -0
  569. package/dist/types/components/dispute-management/dispute-response/cancellation-policy.d.ts +15 -0
  570. package/dist/types/components/dispute-management/dispute-response/customer-details.d.ts +15 -0
  571. package/dist/types/components/dispute-management/dispute-response/dispute-response-actions.d.ts +40 -0
  572. package/dist/types/components/dispute-management/dispute-response/dispute-response-core.d.ts +46 -0
  573. package/dist/types/components/dispute-management/dispute-response/dispute-response-form-types.d.ts +20 -0
  574. package/dist/types/components/dispute-management/dispute-response/dispute-response.d.ts +35 -0
  575. package/dist/types/components/dispute-management/dispute-response/duplicate-charge.d.ts +15 -0
  576. package/dist/types/components/dispute-management/dispute-response/electronic-evidence.d.ts +15 -0
  577. package/dist/types/components/dispute-management/dispute-response/product-or-service.d.ts +15 -0
  578. package/dist/types/components/dispute-management/dispute-response/refund-policy.d.ts +15 -0
  579. package/dist/types/components/dispute-management/dispute-response/schemas/additional-statement-schema.d.ts +6 -0
  580. package/dist/types/components/dispute-management/dispute-response/schemas/cancellation-policy-schema.d.ts +8 -0
  581. package/dist/types/components/dispute-management/dispute-response/schemas/customer-details-schema.d.ts +10 -0
  582. package/dist/types/components/dispute-management/dispute-response/schemas/dispute-reason-schema.d.ts +6 -0
  583. package/dist/types/components/dispute-management/dispute-response/schemas/duplicate-charge-schema.d.ts +8 -0
  584. package/dist/types/components/dispute-management/dispute-response/schemas/electronic-evidence-schema.d.ts +6 -0
  585. package/dist/types/components/dispute-management/dispute-response/schemas/product-or-service-schema.d.ts +8 -0
  586. package/dist/types/components/dispute-management/dispute-response/schemas/refund-policy-schema.d.ts +8 -0
  587. package/dist/types/components/dispute-management/dispute-response/schemas/shipping-details-schema.d.ts +12 -0
  588. package/dist/types/components/dispute-management/dispute-response/shipping-details.d.ts +15 -0
  589. package/dist/types/components/dispute-management/event-types.d.ts +18 -0
  590. package/dist/types/components/gross-payment-chart/gross-payment-chart-core.d.ts +2 -2
  591. package/dist/types/components/gross-payment-chart/gross-payment-chart.d.ts +3 -3
  592. package/dist/types/components/insurance/season-interruption/season-interruption-insurance-core.d.ts +4 -4
  593. package/dist/types/components/insurance/season-interruption/season-interruption-insurance.d.ts +2 -2
  594. package/dist/types/components/payment-details/payment-details-core.d.ts +2 -2
  595. package/dist/types/components/payment-details/payment-details.d.ts +2 -25
  596. package/dist/types/components/payments-list/payments-list-core.d.ts +6 -7
  597. package/dist/types/components/payments-list/payments-list-filters.d.ts +1 -4
  598. package/dist/types/components/payments-list/payments-list-params-state.d.ts +5 -0
  599. package/dist/types/components/payments-list/payments-list.d.ts +2 -24
  600. package/dist/types/components/payments-list/payments-table.d.ts +7 -7
  601. package/dist/types/components/payout-details/payout-details-core.d.ts +2 -2
  602. package/dist/types/components/payout-details/payout-details.d.ts +3 -3
  603. package/dist/types/components/payouts-list/payouts-list-core.d.ts +7 -8
  604. package/dist/types/components/payouts-list/payouts-list-filters.d.ts +0 -3
  605. package/dist/types/components/payouts-list/payouts-list-params-state.d.ts +5 -0
  606. package/dist/types/components/payouts-list/payouts-list.d.ts +2 -24
  607. package/dist/types/components/payouts-list/payouts-table.d.ts +9 -9
  608. package/dist/types/components/terminals-list/terminals-list-core.d.ts +7 -8
  609. package/dist/types/components/terminals-list/terminals-list-filters.d.ts +1 -4
  610. package/dist/types/components/terminals-list/terminals-list-params-state.d.ts +5 -0
  611. package/dist/types/components/terminals-list/terminals-list.d.ts +2 -24
  612. package/dist/types/components/terminals-list/terminals-table.d.ts +4 -4
  613. package/dist/types/components/tokenize-payment-method/tokenize-payment-method.d.ts +4 -5
  614. package/dist/types/components.d.ts +465 -1338
  615. package/dist/types/styles/parts.d.ts +58 -0
  616. package/dist/types/ui-components/details/utils.d.ts +0 -1
  617. package/dist/types/ui-components/filters/table-filters-menu.d.ts +1 -0
  618. package/dist/types/ui-components/form/form-control-checkbox.d.ts +3 -3
  619. package/dist/types/ui-components/form/form-control-date.d.ts +2 -0
  620. package/dist/types/ui-components/form/form-control-file-v2.d.ts +15 -0
  621. package/dist/types/ui-components/form/form-control-file.d.ts +2 -0
  622. package/dist/types/ui-components/form/form-control-monetary.d.ts +2 -0
  623. package/dist/types/ui-components/form/form-control-number-masked.d.ts +2 -0
  624. package/dist/types/ui-components/form/form-control-number.d.ts +2 -0
  625. package/dist/types/ui-components/form/form-control-radio.d.ts +6 -7
  626. package/dist/types/ui-components/form/form-control-select.d.ts +2 -0
  627. package/dist/types/ui-components/form/form-control-text.d.ts +2 -0
  628. package/dist/types/ui-components/form/form-control-textarea.d.ts +2 -0
  629. package/dist/types/ui-components/form/form-helpers/form-control-error-text.d.ts +4 -0
  630. package/dist/types/ui-components/form/form-helpers/form-control-help-text.d.ts +4 -0
  631. package/dist/types/ui-components/form/form.d.ts +1 -1
  632. package/dist/types/ui-components/form/hidden-input.d.ts +11 -0
  633. package/dist/types/ui-components/form/iframe-input-styles-state.d.ts +3 -0
  634. package/dist/types/ui-components/form/iframe-input.d.ts +21 -0
  635. package/dist/types/ui-components/headers/header-1.d.ts +6 -0
  636. package/dist/types/ui-components/headers/header-2.d.ts +6 -0
  637. package/dist/types/ui-components/headers/header-3.d.ts +6 -0
  638. package/dist/types/ui-components/index.d.ts +6 -0
  639. package/dist/types/ui-components/skeleton.d.ts +1 -2
  640. package/dist/types/ui-components/spinner.d.ts +2 -0
  641. package/dist/types/ui-components/table/event-types.d.ts +5 -0
  642. package/dist/types/utils/utils.d.ts +3 -2
  643. package/dist/webcomponents/p-0201ec6c.entry.js +1 -0
  644. package/dist/webcomponents/p-08b8d1f0.entry.js +1 -0
  645. package/dist/webcomponents/p-0aa63869.entry.js +1 -0
  646. package/dist/webcomponents/p-0cc6c539.js +1 -0
  647. package/dist/webcomponents/p-0ccbc022.entry.js +1 -0
  648. package/dist/webcomponents/{p-1815a43b.js → p-0ea387a2.js} +1 -1
  649. package/dist/webcomponents/p-0eb86b3f.entry.js +1 -0
  650. package/dist/webcomponents/{p-5a62fca2.js → p-0f23ff58.js} +1 -1
  651. package/dist/webcomponents/p-110cae83.entry.js +1 -0
  652. package/dist/webcomponents/p-16ba9bea.js +1 -0
  653. package/dist/webcomponents/p-1ce22da6.entry.js +1 -0
  654. package/dist/webcomponents/p-1dbae48b.entry.js +1 -0
  655. package/dist/webcomponents/p-275f2154.js +1 -0
  656. package/dist/webcomponents/p-2783e363.js +2 -0
  657. package/dist/webcomponents/p-28029272.entry.js +1 -0
  658. package/dist/webcomponents/p-323ba4df.entry.js +1 -0
  659. package/dist/webcomponents/p-32a5bf4e.js +1 -0
  660. package/dist/webcomponents/p-34c14f59.js +1 -0
  661. package/dist/webcomponents/p-438df53f.entry.js +1 -0
  662. package/dist/webcomponents/p-441c1cf8.js +1 -0
  663. package/dist/webcomponents/p-4972d608.entry.js +1 -0
  664. package/dist/webcomponents/p-4a576796.js +1 -0
  665. package/dist/webcomponents/p-4cc3c7f9.js +1 -0
  666. package/dist/webcomponents/p-4d916b2d.js +1 -0
  667. package/dist/webcomponents/p-4eb3dcfa.entry.js +1 -0
  668. package/dist/webcomponents/p-5456a794.js +1 -0
  669. package/dist/webcomponents/p-5844a0f0.js +1 -0
  670. package/dist/webcomponents/p-597bd1e1.entry.js +1 -0
  671. package/dist/webcomponents/p-5bbe1133.entry.js +1 -0
  672. package/dist/webcomponents/p-5c6d08a6.entry.js +1 -0
  673. package/dist/webcomponents/p-5cb947bc.entry.js +1 -0
  674. package/dist/webcomponents/p-5d3f81c0.entry.js +1 -0
  675. package/dist/webcomponents/p-663a00cd.entry.js +1 -0
  676. package/dist/webcomponents/p-6677c60d.entry.js +1 -0
  677. package/dist/webcomponents/p-667ebd79.js +1 -0
  678. package/dist/webcomponents/p-68694a17.entry.js +1 -0
  679. package/dist/webcomponents/p-6ab77b89.js +1 -0
  680. package/dist/webcomponents/p-6b840696.entry.js +1 -0
  681. package/dist/webcomponents/p-6f4bfdff.entry.js +1 -0
  682. package/dist/webcomponents/p-6fbd6abb.js +1 -0
  683. package/dist/webcomponents/p-6feeb9f2.js +1 -0
  684. package/dist/webcomponents/p-7216ef00.entry.js +1 -0
  685. package/dist/webcomponents/p-73a18b5a.entry.js +1 -0
  686. package/dist/webcomponents/p-73f9be7c.js +1 -0
  687. package/dist/webcomponents/p-7693ed02.entry.js +1 -0
  688. package/dist/webcomponents/{p-4cf7f4ae.js → p-79b7c30d.js} +1 -1
  689. package/dist/webcomponents/p-7a975a3c.js +1 -0
  690. package/dist/webcomponents/p-7b9f21cd.entry.js +1 -0
  691. package/dist/webcomponents/p-7f796066.entry.js +1 -0
  692. package/dist/webcomponents/p-808bb677.entry.js +1 -0
  693. package/dist/webcomponents/p-83584c56.entry.js +1 -0
  694. package/dist/webcomponents/p-88acfa7c.entry.js +1 -0
  695. package/dist/webcomponents/p-8a94d2c8.js +1 -0
  696. package/dist/webcomponents/p-8c7a81c1.js +1 -0
  697. package/dist/webcomponents/p-8da3667c.js +1 -0
  698. package/dist/webcomponents/p-90dc2f2c.js +1 -0
  699. package/dist/webcomponents/p-9c2e00cc.js +1 -0
  700. package/dist/webcomponents/p-9ef9a625.entry.js +1 -0
  701. package/dist/webcomponents/p-9f773228.js +1 -0
  702. package/dist/webcomponents/p-a07b1816.js +1 -0
  703. package/dist/webcomponents/p-a3949f32.js +1 -0
  704. package/dist/webcomponents/p-abdbcd8e.js +1 -0
  705. package/dist/webcomponents/p-ac147eef.entry.js +1 -0
  706. package/dist/webcomponents/{p-b0311e88.js → p-af834eb8.js} +1 -1
  707. package/dist/webcomponents/p-b056034f.entry.js +1 -0
  708. package/dist/webcomponents/p-b1d4e520.entry.js +1 -0
  709. package/dist/webcomponents/p-b392ec21.js +1 -0
  710. package/dist/webcomponents/p-b867dd5d.entry.js +1 -0
  711. package/dist/webcomponents/{p-544a4e7a.js → p-bb0f8b70.js} +1 -1
  712. package/dist/webcomponents/p-bb61c6e0.js +1 -0
  713. package/dist/webcomponents/p-bbcaa29b.entry.js +1 -0
  714. package/dist/webcomponents/p-bfe9748b.js +1 -0
  715. package/dist/webcomponents/p-c092cbb2.js +1 -0
  716. package/dist/webcomponents/p-c2a2b9fe.entry.js +1 -0
  717. package/dist/webcomponents/p-c9670f3c.entry.js +1 -0
  718. package/dist/webcomponents/p-cc977850.js +1 -0
  719. package/dist/webcomponents/p-cefd50f8.entry.js +1 -0
  720. package/dist/webcomponents/p-d53c5ea5.entry.js +1 -0
  721. package/dist/webcomponents/p-d75b52c8.entry.js +1 -0
  722. package/dist/webcomponents/p-d960db89.entry.js +1 -0
  723. package/dist/webcomponents/p-db8c12ee.js +1 -0
  724. package/dist/webcomponents/p-e1ee92f5.entry.js +1 -0
  725. package/dist/webcomponents/p-e396506c.entry.js +1 -0
  726. package/dist/webcomponents/p-e723bc30.entry.js +1 -0
  727. package/dist/webcomponents/p-ec60d318.entry.js +1 -0
  728. package/dist/webcomponents/p-ed8918d1.entry.js +1 -0
  729. package/dist/webcomponents/{p-f6f8dabc.js → p-edb57087.js} +1 -1
  730. package/dist/webcomponents/p-ee4a2aac.entry.js +1 -0
  731. package/dist/webcomponents/p-ef4c49b9.js +1 -0
  732. package/dist/webcomponents/p-f20b6ce1.js +1 -0
  733. package/dist/webcomponents/{p-c13a7d10.js → p-f4722957.js} +1 -1
  734. package/dist/webcomponents/p-f88d5c0d.entry.js +1 -0
  735. package/dist/webcomponents/p-f8a3b942.entry.js +1 -0
  736. package/dist/webcomponents/p-f99e8150.entry.js +1 -0
  737. package/dist/webcomponents/{p-628693c1.entry.js → p-f9fdcc1a.entry.js} +4 -4
  738. package/dist/webcomponents/p-fa2e3dc7.entry.js +1 -0
  739. package/dist/webcomponents/{p-ccbff4fa.entry.js → p-faa35b47.entry.js} +1 -1
  740. package/dist/webcomponents/p-fc3daedd.js +1 -0
  741. package/dist/webcomponents/webcomponents.esm.js +1 -1
  742. package/package.json +1 -1
  743. package/dist/cjs/business-form-types-719b7f52.js +0 -50
  744. package/dist/cjs/button-3f400a66.js +0 -26
  745. package/dist/cjs/check-pkg-version-fe8c72a9.js +0 -24
  746. package/dist/cjs/checkouts-list-filters.cjs.entry.js +0 -35
  747. package/dist/cjs/checkouts-table-00b6482f.js +0 -47
  748. package/dist/cjs/dispute-30c806f6.js +0 -10
  749. package/dist/cjs/exported-parts-a994d693.js +0 -9
  750. package/dist/cjs/form-control-checkbox_9.cjs.entry.js +0 -641
  751. package/dist/cjs/form-control-error-text.cjs.entry.js +0 -21
  752. package/dist/cjs/form-control-textarea.cjs.entry.js +0 -49
  753. package/dist/cjs/justifi-additional-statement_11.cjs.entry.js +0 -173
  754. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +0 -79
  755. package/dist/cjs/justifi-card-form.cjs.entry.js +0 -80
  756. package/dist/cjs/justifi-new-payment-method_5.cjs.entry.js +0 -320
  757. package/dist/cjs/justifi-payment-form.cjs.entry.js +0 -141
  758. package/dist/cjs/justifi-payment-method-selector.cjs.entry.js +0 -34
  759. package/dist/cjs/pagination-menu_2.cjs.entry.js +0 -54
  760. package/dist/cjs/payments-list-filters.cjs.entry.js +0 -40
  761. package/dist/cjs/payments-table-7087e771.js +0 -31
  762. package/dist/cjs/payouts-list-filters.cjs.entry.js +0 -24
  763. package/dist/cjs/payouts-table-4858eb84.js +0 -37
  764. package/dist/cjs/skeleton-748c5dde.js +0 -43
  765. package/dist/cjs/styled-host-1adf46c3.js +0 -14
  766. package/dist/cjs/terminals-list-filters.cjs.entry.js +0 -32
  767. package/dist/cjs/terminals-table-12410159.js +0 -32
  768. package/dist/cjs/utils-189dc30d.js +0 -35
  769. package/dist/cjs/utils-ba79e868.js +0 -37
  770. package/dist/collection/components/bank-account-form/bank-account-form.js +0 -281
  771. package/dist/collection/components/billing-form/billing-form.css +0 -51
  772. package/dist/collection/components/business-details/shared-business-details.css +0 -3
  773. package/dist/collection/components/business-forms/business-form/business-form.css +0 -121
  774. package/dist/collection/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-text.css +0 -18
  775. package/dist/collection/components/business-forms/utils/business-form-types.js +0 -48
  776. package/dist/collection/components/card-form/card-form.js +0 -300
  777. package/dist/collection/components/checkout/checkout-core.css +0 -110
  778. package/dist/collection/components/checkout/form-check-input.css +0 -20
  779. package/dist/collection/components/checkout/header.css +0 -4
  780. package/dist/collection/components/checkout/payment-method-options.css +0 -15
  781. package/dist/collection/components/dispute-management/counter-dispute/additional-statement.js +0 -8
  782. package/dist/collection/components/dispute-management/counter-dispute/cancellation-policy.js +0 -8
  783. package/dist/collection/components/dispute-management/counter-dispute/counter-dispute.js +0 -90
  784. package/dist/collection/components/dispute-management/counter-dispute/customer-details.js +0 -8
  785. package/dist/collection/components/dispute-management/counter-dispute/dispute-reason.js +0 -8
  786. package/dist/collection/components/dispute-management/counter-dispute/duplicate-charge.js +0 -8
  787. package/dist/collection/components/dispute-management/counter-dispute/electronic-evidence.js +0 -8
  788. package/dist/collection/components/dispute-management/counter-dispute/product-or-service.js +0 -16
  789. package/dist/collection/components/dispute-management/counter-dispute/refund-policy.js +0 -8
  790. package/dist/collection/components/dispute-management/counter-dispute/shipping-details.js +0 -12
  791. package/dist/collection/components/dispute-management/dispute.js +0 -8
  792. package/dist/collection/components/gross-payment-chart/gross-payment-chart.css +0 -3
  793. package/dist/collection/components/insurance/season-interruption/season-interruption-insurance-core.css +0 -11
  794. package/dist/collection/components/payment-form/payment-form.css +0 -97
  795. package/dist/collection/components/payment-form/payment-form.js +0 -372
  796. package/dist/collection/components/payment-form/payment-method-selector.css +0 -39
  797. package/dist/collection/components/payment-form/payment-method-selector.js +0 -74
  798. package/dist/collection/components/payment-method-form/message-event-types.js +0 -16
  799. package/dist/collection/components/payment-method-form/payment-method-form.css +0 -13
  800. package/dist/collection/components/payment-method-form/payment-method-form.js +0 -298
  801. package/dist/collection/components/refund-form/refund-form.css +0 -59
  802. package/dist/collection/components/tokenize-payment-method/tokenize-payment-method.css +0 -9
  803. package/dist/collection/ui-components/form/form-helpers/form-control-error-text/form-control-error-text.js +0 -52
  804. package/dist/collection/utils/get-computed-theme.js +0 -50
  805. package/dist/esm/business-form-types-8fd61b0e.js +0 -50
  806. package/dist/esm/button-34e75e0f.js +0 -24
  807. package/dist/esm/check-pkg-version-fbf01ce7.js +0 -22
  808. package/dist/esm/checkouts-list-filters.entry.js +0 -31
  809. package/dist/esm/checkouts-table-cd33b57c.js +0 -43
  810. package/dist/esm/dispute-4d2e0a04.js +0 -10
  811. package/dist/esm/exported-parts-70e7a12b.js +0 -7
  812. package/dist/esm/form-control-checkbox_9.entry.js +0 -629
  813. package/dist/esm/form-control-error-text.entry.js +0 -17
  814. package/dist/esm/form-control-textarea.entry.js +0 -45
  815. package/dist/esm/justifi-additional-statement_11.entry.js +0 -159
  816. package/dist/esm/justifi-bank-account-form.entry.js +0 -75
  817. package/dist/esm/justifi-card-form.entry.js +0 -76
  818. package/dist/esm/justifi-new-payment-method_5.entry.js +0 -312
  819. package/dist/esm/justifi-payment-form.entry.js +0 -137
  820. package/dist/esm/justifi-payment-method-selector.entry.js +0 -30
  821. package/dist/esm/pagination-menu_2.entry.js +0 -49
  822. package/dist/esm/payments-list-filters.entry.js +0 -36
  823. package/dist/esm/payments-table-bba91324.js +0 -27
  824. package/dist/esm/payouts-list-filters.entry.js +0 -20
  825. package/dist/esm/payouts-table-edff9bbe.js +0 -33
  826. package/dist/esm/skeleton-145a80d4.js +0 -41
  827. package/dist/esm/styled-host-e0ddb759.js +0 -12
  828. package/dist/esm/terminals-list-filters.entry.js +0 -28
  829. package/dist/esm/terminals-table-dc787616.js +0 -28
  830. package/dist/esm/utils-218275b7.js +0 -27
  831. package/dist/esm/utils-4006c425.js +0 -33
  832. package/dist/module/Analytics.js +0 -78
  833. package/dist/module/business-form-types.js +0 -50
  834. package/dist/module/checkouts-list-filters.d.ts +0 -11
  835. package/dist/module/checkouts-list-filters.js +0 -6
  836. package/dist/module/checkouts-list-filters2.js +0 -80
  837. package/dist/module/counter-dispute.js +0 -189
  838. package/dist/module/dispute-reason.js +0 -45
  839. package/dist/module/exported-parts.js +0 -7
  840. package/dist/module/form-control-error-text.d.ts +0 -11
  841. package/dist/module/form-control-error-text2.js +0 -35
  842. package/dist/module/justifi-bank-account-form.d.ts +0 -11
  843. package/dist/module/justifi-bank-account-form.js +0 -104
  844. package/dist/module/justifi-card-form.js +0 -106
  845. package/dist/module/justifi-counter-dispute.d.ts +0 -11
  846. package/dist/module/justifi-counter-dispute.js +0 -6
  847. package/dist/module/justifi-dispute-reason.d.ts +0 -11
  848. package/dist/module/justifi-dispute-reason.js +0 -6
  849. package/dist/module/justifi-payment-form.js +0 -216
  850. package/dist/module/justifi-payment-method-form.d.ts +0 -11
  851. package/dist/module/justifi-payment-method-form.js +0 -6
  852. package/dist/module/justifi-payment-method-selector.d.ts +0 -11
  853. package/dist/module/justifi-payment-method-selector.js +0 -6
  854. package/dist/module/payment-method-selector.js +0 -47
  855. package/dist/module/payments-list-filters.js +0 -6
  856. package/dist/module/payments-list-filters2.js +0 -97
  857. package/dist/module/payouts-list-filters.js +0 -6
  858. package/dist/module/payouts-list-filters2.js +0 -69
  859. package/dist/module/terminals-list-filters.d.ts +0 -11
  860. package/dist/module/terminals-list-filters.js +0 -6
  861. package/dist/module/utils5.js +0 -27
  862. package/dist/types/components/bank-account-form/bank-account-form.d.ts +0 -62
  863. package/dist/types/components/business-forms/utils/business-form-types.d.ts +0 -76
  864. package/dist/types/components/card-form/card-form.d.ts +0 -72
  865. package/dist/types/components/dispute-management/counter-dispute/additional-statement.d.ts +0 -3
  866. package/dist/types/components/dispute-management/counter-dispute/cancellation-policy.d.ts +0 -3
  867. package/dist/types/components/dispute-management/counter-dispute/counter-dispute.d.ts +0 -14
  868. package/dist/types/components/dispute-management/counter-dispute/customer-details.d.ts +0 -3
  869. package/dist/types/components/dispute-management/counter-dispute/dispute-reason.d.ts +0 -3
  870. package/dist/types/components/dispute-management/counter-dispute/duplicate-charge.d.ts +0 -3
  871. package/dist/types/components/dispute-management/counter-dispute/electronic-evidence.d.ts +0 -3
  872. package/dist/types/components/dispute-management/counter-dispute/product-or-service.d.ts +0 -4
  873. package/dist/types/components/dispute-management/counter-dispute/refund-policy.d.ts +0 -3
  874. package/dist/types/components/dispute-management/counter-dispute/shipping-details.d.ts +0 -3
  875. package/dist/types/components/dispute-management/dispute.d.ts +0 -7
  876. package/dist/types/components/payment-form/payment-form.d.ts +0 -36
  877. package/dist/types/components/payment-form/payment-method-selector.d.ts +0 -10
  878. package/dist/types/components/payment-form/tokenize.d.ts +0 -5
  879. package/dist/types/components/payment-method-form/message-event-types.d.ts +0 -16
  880. package/dist/types/components/payment-method-form/payment-method-form.d.ts +0 -25
  881. package/dist/types/ui-components/form/form-helpers/form-control-error-text/form-control-error-text.d.ts +0 -5
  882. package/dist/types/utils/get-computed-theme.d.ts +0 -3
  883. package/dist/webcomponents/p-08b0fb31.js +0 -1
  884. package/dist/webcomponents/p-0a963f7e.entry.js +0 -1
  885. package/dist/webcomponents/p-0d6ddff2.js +0 -1
  886. package/dist/webcomponents/p-0fbab710.entry.js +0 -1
  887. package/dist/webcomponents/p-2338affa.js +0 -1
  888. package/dist/webcomponents/p-25d2ed4c.js +0 -1
  889. package/dist/webcomponents/p-286b87ab.js +0 -1
  890. package/dist/webcomponents/p-28bd6dcd.js +0 -1
  891. package/dist/webcomponents/p-297faf3d.js +0 -1
  892. package/dist/webcomponents/p-29c8fa3d.entry.js +0 -1
  893. package/dist/webcomponents/p-2f422aad.entry.js +0 -1
  894. package/dist/webcomponents/p-3186d1fb.entry.js +0 -1
  895. package/dist/webcomponents/p-3bfb4f80.entry.js +0 -1
  896. package/dist/webcomponents/p-3c654c07.js +0 -1
  897. package/dist/webcomponents/p-3ed7fc42.entry.js +0 -1
  898. package/dist/webcomponents/p-404a847c.entry.js +0 -1
  899. package/dist/webcomponents/p-41c1c1f7.entry.js +0 -1
  900. package/dist/webcomponents/p-41c7ee13.entry.js +0 -1
  901. package/dist/webcomponents/p-420adedb.entry.js +0 -1
  902. package/dist/webcomponents/p-431d7a9e.entry.js +0 -1
  903. package/dist/webcomponents/p-448826a7.entry.js +0 -1
  904. package/dist/webcomponents/p-469804a9.entry.js +0 -1
  905. package/dist/webcomponents/p-486da67e.entry.js +0 -1
  906. package/dist/webcomponents/p-4a5e5574.entry.js +0 -1
  907. package/dist/webcomponents/p-52f9d8a0.entry.js +0 -1
  908. package/dist/webcomponents/p-54145a37.entry.js +0 -1
  909. package/dist/webcomponents/p-56d84fb3.entry.js +0 -1
  910. package/dist/webcomponents/p-57125bd1.js +0 -1
  911. package/dist/webcomponents/p-5e7c60d8.js +0 -1
  912. package/dist/webcomponents/p-5ec82df8.entry.js +0 -1
  913. package/dist/webcomponents/p-673cf8c4.js +0 -1
  914. package/dist/webcomponents/p-69527219.entry.js +0 -1
  915. package/dist/webcomponents/p-6cc30da2.js +0 -1
  916. package/dist/webcomponents/p-6d51aed8.entry.js +0 -1
  917. package/dist/webcomponents/p-72819173.entry.js +0 -1
  918. package/dist/webcomponents/p-74da98da.js +0 -1
  919. package/dist/webcomponents/p-8037704c.js +0 -1
  920. package/dist/webcomponents/p-89f6691e.js +0 -1
  921. package/dist/webcomponents/p-91de21cc.js +0 -1
  922. package/dist/webcomponents/p-942be28b.entry.js +0 -1
  923. package/dist/webcomponents/p-95ec39f6.entry.js +0 -1
  924. package/dist/webcomponents/p-9690eca9.entry.js +0 -1
  925. package/dist/webcomponents/p-9c9c7dac.js +0 -1
  926. package/dist/webcomponents/p-a76ece26.js +0 -1
  927. package/dist/webcomponents/p-a7830e98.entry.js +0 -1
  928. package/dist/webcomponents/p-a8b4f429.js +0 -1
  929. package/dist/webcomponents/p-abe513e6.entry.js +0 -1
  930. package/dist/webcomponents/p-ada9ac19.entry.js +0 -1
  931. package/dist/webcomponents/p-b0dc68b3.entry.js +0 -1
  932. package/dist/webcomponents/p-b3cac576.entry.js +0 -1
  933. package/dist/webcomponents/p-b97233cc.entry.js +0 -1
  934. package/dist/webcomponents/p-bc1984ec.entry.js +0 -1
  935. package/dist/webcomponents/p-bc8205ec.js +0 -1
  936. package/dist/webcomponents/p-bfb990fc.entry.js +0 -1
  937. package/dist/webcomponents/p-c1bf9285.entry.js +0 -1
  938. package/dist/webcomponents/p-c3fb5d3a.entry.js +0 -1
  939. package/dist/webcomponents/p-c420cb7d.entry.js +0 -1
  940. package/dist/webcomponents/p-c8243721.js +0 -1
  941. package/dist/webcomponents/p-cd19c597.entry.js +0 -1
  942. package/dist/webcomponents/p-d1f75fa6.js +0 -1
  943. package/dist/webcomponents/p-d291dc4c.entry.js +0 -1
  944. package/dist/webcomponents/p-d2eb61e6.entry.js +0 -1
  945. package/dist/webcomponents/p-d516e700.js +0 -1
  946. package/dist/webcomponents/p-da176d01.entry.js +0 -1
  947. package/dist/webcomponents/p-dcb288a3.entry.js +0 -1
  948. package/dist/webcomponents/p-df3ca87f.entry.js +0 -1
  949. package/dist/webcomponents/p-df5a1202.entry.js +0 -1
  950. package/dist/webcomponents/p-e2ce097c.js +0 -1
  951. package/dist/webcomponents/p-e5790011.entry.js +0 -1
  952. package/dist/webcomponents/p-e69b2ff8.entry.js +0 -1
  953. package/dist/webcomponents/p-e8be1b55.entry.js +0 -1
  954. package/dist/webcomponents/p-e99957ff.entry.js +0 -1
  955. package/dist/webcomponents/p-eb9ba917.entry.js +0 -1
  956. package/dist/webcomponents/p-ed95feec.entry.js +0 -1
  957. package/dist/webcomponents/p-f28a4c03.entry.js +0 -1
  958. package/dist/webcomponents/p-f698d6d9.entry.js +0 -1
  959. package/dist/webcomponents/p-fad19d75.js +0 -2
  960. package/dist/webcomponents/p-fc6f697d.entry.js +0 -1
  961. package/dist/webcomponents/p-ffe27126.entry.js +0 -1
  962. package/dist/webcomponents/webcomponents.css +0 -6
  963. /package/dist/collection/{components/payment-form/tokenize.js → api/ComponentEvents.js} +0 -0
  964. /package/dist/collection/components/{payment-method-form → checkout}/payment-method-responses.js +0 -0
  965. /package/dist/types/components/{payment-method-form → checkout}/payment-method-responses.d.ts +0 -0
@@ -0,0 +1,3599 @@
1
+ /** Checks if value is string */
2
+ function isString(str) {
3
+ return typeof str === 'string' || str instanceof String;
4
+ }
5
+
6
+ /** Checks if value is object */
7
+ function isObject(obj) {
8
+ var _obj$constructor;
9
+ return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
10
+ }
11
+ function pick(obj, keys) {
12
+ if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
13
+ return Object.entries(obj).reduce((acc, _ref) => {
14
+ let [k, v] = _ref;
15
+ if (keys(v, k)) acc[k] = v;
16
+ return acc;
17
+ }, {});
18
+ }
19
+
20
+ /** Direction */
21
+ const DIRECTION = {
22
+ NONE: 'NONE',
23
+ LEFT: 'LEFT',
24
+ FORCE_LEFT: 'FORCE_LEFT',
25
+ RIGHT: 'RIGHT',
26
+ FORCE_RIGHT: 'FORCE_RIGHT'
27
+ };
28
+
29
+ /** Direction */
30
+
31
+ function forceDirection(direction) {
32
+ switch (direction) {
33
+ case DIRECTION.LEFT:
34
+ return DIRECTION.FORCE_LEFT;
35
+ case DIRECTION.RIGHT:
36
+ return DIRECTION.FORCE_RIGHT;
37
+ default:
38
+ return direction;
39
+ }
40
+ }
41
+
42
+ /** Escapes regular expression control chars */
43
+ function escapeRegExp(str) {
44
+ return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
45
+ }
46
+
47
+ // cloned from https://github.com/epoberezkin/fast-deep-equal with small changes
48
+ function objectIncludes(b, a) {
49
+ if (a === b) return true;
50
+ const arrA = Array.isArray(a),
51
+ arrB = Array.isArray(b);
52
+ let i;
53
+ if (arrA && arrB) {
54
+ if (a.length != b.length) return false;
55
+ for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false;
56
+ return true;
57
+ }
58
+ if (arrA != arrB) return false;
59
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
60
+ const dateA = a instanceof Date,
61
+ dateB = b instanceof Date;
62
+ if (dateA && dateB) return a.getTime() == b.getTime();
63
+ if (dateA != dateB) return false;
64
+ const regexpA = a instanceof RegExp,
65
+ regexpB = b instanceof RegExp;
66
+ if (regexpA && regexpB) return a.toString() == b.toString();
67
+ if (regexpA != regexpB) return false;
68
+ const keys = Object.keys(a);
69
+ // if (keys.length !== Object.keys(b).length) return false;
70
+
71
+ for (i = 0; i < keys.length; i++) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
72
+ for (i = 0; i < keys.length; i++) if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
73
+ return true;
74
+ } else if (a && b && typeof a === 'function' && typeof b === 'function') {
75
+ return a.toString() === b.toString();
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /** Provides details of changing input */
81
+ class ActionDetails {
82
+ /** Current input value */
83
+
84
+ /** Current cursor position */
85
+
86
+ /** Old input value */
87
+
88
+ /** Old selection */
89
+
90
+ constructor(opts) {
91
+ Object.assign(this, opts);
92
+
93
+ // double check if left part was changed (autofilling, other non-standard input triggers)
94
+ while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
95
+ --this.oldSelection.start;
96
+ }
97
+ if (this.insertedCount) {
98
+ // double check right part
99
+ while (this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end)) {
100
+ if (this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end) ++this.oldSelection.end;else ++this.cursorPos;
101
+ }
102
+ }
103
+ }
104
+
105
+ /** Start changing position */
106
+ get startChangePos() {
107
+ return Math.min(this.cursorPos, this.oldSelection.start);
108
+ }
109
+
110
+ /** Inserted symbols count */
111
+ get insertedCount() {
112
+ return this.cursorPos - this.startChangePos;
113
+ }
114
+
115
+ /** Inserted symbols */
116
+ get inserted() {
117
+ return this.value.substr(this.startChangePos, this.insertedCount);
118
+ }
119
+
120
+ /** Removed symbols count */
121
+ get removedCount() {
122
+ // Math.max for opposite operation
123
+ return Math.max(this.oldSelection.end - this.startChangePos ||
124
+ // for Delete
125
+ this.oldValue.length - this.value.length, 0);
126
+ }
127
+
128
+ /** Removed symbols */
129
+ get removed() {
130
+ return this.oldValue.substr(this.startChangePos, this.removedCount);
131
+ }
132
+
133
+ /** Unchanged head symbols */
134
+ get head() {
135
+ return this.value.substring(0, this.startChangePos);
136
+ }
137
+
138
+ /** Unchanged tail symbols */
139
+ get tail() {
140
+ return this.value.substring(this.startChangePos + this.insertedCount);
141
+ }
142
+
143
+ /** Remove direction */
144
+ get removeDirection() {
145
+ if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
146
+
147
+ // align right if delete at right
148
+ return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
149
+ // if not range removed (event with backspace)
150
+ this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
151
+ }
152
+ }
153
+
154
+ /** Applies mask on element */
155
+ function IMask(el, opts) {
156
+ // currently available only for input-like elements
157
+ return new IMask.InputMask(el, opts);
158
+ }
159
+
160
+ // TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754
161
+ // export function maskedClass(mask: string): typeof MaskedPattern;
162
+ // export function maskedClass(mask: DateConstructor): typeof MaskedDate;
163
+ // export function maskedClass(mask: NumberConstructor): typeof MaskedNumber;
164
+ // export function maskedClass(mask: Array<any> | ArrayConstructor): typeof MaskedDynamic;
165
+ // export function maskedClass(mask: MaskedDate): typeof MaskedDate;
166
+ // export function maskedClass(mask: MaskedNumber): typeof MaskedNumber;
167
+ // export function maskedClass(mask: MaskedEnum): typeof MaskedEnum;
168
+ // export function maskedClass(mask: MaskedRange): typeof MaskedRange;
169
+ // export function maskedClass(mask: MaskedRegExp): typeof MaskedRegExp;
170
+ // export function maskedClass(mask: MaskedFunction): typeof MaskedFunction;
171
+ // export function maskedClass(mask: MaskedPattern): typeof MaskedPattern;
172
+ // export function maskedClass(mask: MaskedDynamic): typeof MaskedDynamic;
173
+ // export function maskedClass(mask: Masked): typeof Masked;
174
+ // export function maskedClass(mask: typeof Masked): typeof Masked;
175
+ // export function maskedClass(mask: typeof MaskedDate): typeof MaskedDate;
176
+ // export function maskedClass(mask: typeof MaskedNumber): typeof MaskedNumber;
177
+ // export function maskedClass(mask: typeof MaskedEnum): typeof MaskedEnum;
178
+ // export function maskedClass(mask: typeof MaskedRange): typeof MaskedRange;
179
+ // export function maskedClass(mask: typeof MaskedRegExp): typeof MaskedRegExp;
180
+ // export function maskedClass(mask: typeof MaskedFunction): typeof MaskedFunction;
181
+ // export function maskedClass(mask: typeof MaskedPattern): typeof MaskedPattern;
182
+ // export function maskedClass(mask: typeof MaskedDynamic): typeof MaskedDynamic;
183
+ // export function maskedClass<Mask extends typeof Masked> (mask: Mask): Mask;
184
+ // export function maskedClass(mask: RegExp): typeof MaskedRegExp;
185
+ // export function maskedClass(mask: (value: string, ...args: any[]) => boolean): typeof MaskedFunction;
186
+
187
+ /** Get Masked class by mask type */
188
+ function maskedClass(mask) /* TODO */{
189
+ if (mask == null) throw new Error('mask property should be defined');
190
+ if (mask instanceof RegExp) return IMask.MaskedRegExp;
191
+ if (isString(mask)) return IMask.MaskedPattern;
192
+ if (mask === Date) return IMask.MaskedDate;
193
+ if (mask === Number) return IMask.MaskedNumber;
194
+ if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
195
+ if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
196
+ if (IMask.Masked && mask instanceof IMask.Masked) return mask.constructor;
197
+ if (mask instanceof Function) return IMask.MaskedFunction;
198
+ console.warn('Mask not found for mask', mask); // eslint-disable-line no-console
199
+ return IMask.Masked;
200
+ }
201
+ function normalizeOpts(opts) {
202
+ if (!opts) throw new Error('Options in not defined');
203
+ if (IMask.Masked) {
204
+ if (opts.prototype instanceof IMask.Masked) return {
205
+ mask: opts
206
+ };
207
+
208
+ /*
209
+ handle cases like:
210
+ 1) opts = Masked
211
+ 2) opts = { mask: Masked, ...instanceOpts }
212
+ */
213
+ const {
214
+ mask = undefined,
215
+ ...instanceOpts
216
+ } = opts instanceof IMask.Masked ? {
217
+ mask: opts
218
+ } : isObject(opts) && opts.mask instanceof IMask.Masked ? opts : {};
219
+ if (mask) {
220
+ const _mask = mask.mask;
221
+ return {
222
+ ...pick(mask, (_, k) => !k.startsWith('_')),
223
+ mask: mask.constructor,
224
+ _mask,
225
+ ...instanceOpts
226
+ };
227
+ }
228
+ }
229
+ if (!isObject(opts)) return {
230
+ mask: opts
231
+ };
232
+ return {
233
+ ...opts
234
+ };
235
+ }
236
+
237
+ // TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754
238
+
239
+ // From masked
240
+ // export default function createMask<Opts extends Masked, ReturnMasked=Opts> (opts: Opts): ReturnMasked;
241
+ // // From masked class
242
+ // export default function createMask<Opts extends MaskedOptions<typeof Masked>, ReturnMasked extends Masked=InstanceType<Opts['mask']>> (opts: Opts): ReturnMasked;
243
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedDate>, ReturnMasked extends MaskedDate=MaskedDate<Opts['parent']>> (opts: Opts): ReturnMasked;
244
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedNumber>, ReturnMasked extends MaskedNumber=MaskedNumber<Opts['parent']>> (opts: Opts): ReturnMasked;
245
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedEnum>, ReturnMasked extends MaskedEnum=MaskedEnum<Opts['parent']>> (opts: Opts): ReturnMasked;
246
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedRange>, ReturnMasked extends MaskedRange=MaskedRange<Opts['parent']>> (opts: Opts): ReturnMasked;
247
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedRegExp>, ReturnMasked extends MaskedRegExp=MaskedRegExp<Opts['parent']>> (opts: Opts): ReturnMasked;
248
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedFunction>, ReturnMasked extends MaskedFunction=MaskedFunction<Opts['parent']>> (opts: Opts): ReturnMasked;
249
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedPattern>, ReturnMasked extends MaskedPattern=MaskedPattern<Opts['parent']>> (opts: Opts): ReturnMasked;
250
+ // export default function createMask<Opts extends MaskedOptions<typeof MaskedDynamic>, ReturnMasked extends MaskedDynamic=MaskedDynamic<Opts['parent']>> (opts: Opts): ReturnMasked;
251
+ // // From mask opts
252
+ // export default function createMask<Opts extends MaskedOptions<Masked>, ReturnMasked=Opts extends MaskedOptions<infer M> ? M : never> (opts: Opts): ReturnMasked;
253
+ // export default function createMask<Opts extends MaskedNumberOptions, ReturnMasked extends MaskedNumber=MaskedNumber<Opts['parent']>> (opts: Opts): ReturnMasked;
254
+ // export default function createMask<Opts extends MaskedDateFactoryOptions, ReturnMasked extends MaskedDate=MaskedDate<Opts['parent']>> (opts: Opts): ReturnMasked;
255
+ // export default function createMask<Opts extends MaskedEnumOptions, ReturnMasked extends MaskedEnum=MaskedEnum<Opts['parent']>> (opts: Opts): ReturnMasked;
256
+ // export default function createMask<Opts extends MaskedRangeOptions, ReturnMasked extends MaskedRange=MaskedRange<Opts['parent']>> (opts: Opts): ReturnMasked;
257
+ // export default function createMask<Opts extends MaskedPatternOptions, ReturnMasked extends MaskedPattern=MaskedPattern<Opts['parent']>> (opts: Opts): ReturnMasked;
258
+ // export default function createMask<Opts extends MaskedDynamicOptions, ReturnMasked extends MaskedDynamic=MaskedDynamic<Opts['parent']>> (opts: Opts): ReturnMasked;
259
+ // export default function createMask<Opts extends MaskedOptions<RegExp>, ReturnMasked extends MaskedRegExp=MaskedRegExp<Opts['parent']>> (opts: Opts): ReturnMasked;
260
+ // export default function createMask<Opts extends MaskedOptions<Function>, ReturnMasked extends MaskedFunction=MaskedFunction<Opts['parent']>> (opts: Opts): ReturnMasked;
261
+
262
+ /** Creates new {@link Masked} depending on mask type */
263
+ function createMask(opts) {
264
+ if (IMask.Masked && opts instanceof IMask.Masked) return opts;
265
+ const nOpts = normalizeOpts(opts);
266
+ const MaskedClass = maskedClass(nOpts.mask);
267
+ if (!MaskedClass) throw new Error("Masked class is not found for provided mask " + nOpts.mask + ", appropriate module needs to be imported manually before creating mask.");
268
+ if (nOpts.mask === MaskedClass) delete nOpts.mask;
269
+ if (nOpts._mask) {
270
+ nOpts.mask = nOpts._mask;
271
+ delete nOpts._mask;
272
+ }
273
+ return new MaskedClass(nOpts);
274
+ }
275
+ IMask.createMask = createMask;
276
+
277
+ /** Generic element API to use with mask */
278
+ class MaskElement {
279
+ /** */
280
+
281
+ /** */
282
+
283
+ /** */
284
+
285
+ /** Safely returns selection start */
286
+ get selectionStart() {
287
+ let start;
288
+ try {
289
+ start = this._unsafeSelectionStart;
290
+ } catch {}
291
+ return start != null ? start : this.value.length;
292
+ }
293
+
294
+ /** Safely returns selection end */
295
+ get selectionEnd() {
296
+ let end;
297
+ try {
298
+ end = this._unsafeSelectionEnd;
299
+ } catch {}
300
+ return end != null ? end : this.value.length;
301
+ }
302
+
303
+ /** Safely sets element selection */
304
+ select(start, end) {
305
+ if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
306
+ try {
307
+ this._unsafeSelect(start, end);
308
+ } catch {}
309
+ }
310
+
311
+ /** */
312
+ get isActive() {
313
+ return false;
314
+ }
315
+ /** */
316
+
317
+ /** */
318
+
319
+ /** */
320
+ }
321
+ IMask.MaskElement = MaskElement;
322
+
323
+ const KEY_Z = 90;
324
+ const KEY_Y = 89;
325
+
326
+ /** Bridge between HTMLElement and {@link Masked} */
327
+ class HTMLMaskElement extends MaskElement {
328
+ /** HTMLElement to use mask on */
329
+
330
+ constructor(input) {
331
+ super();
332
+ this.input = input;
333
+ this._onKeydown = this._onKeydown.bind(this);
334
+ this._onInput = this._onInput.bind(this);
335
+ this._onBeforeinput = this._onBeforeinput.bind(this);
336
+ this._onCompositionEnd = this._onCompositionEnd.bind(this);
337
+ }
338
+ get rootElement() {
339
+ var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
340
+ return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) == null ? void 0 : _this$input$getRootNo2.call(_this$input)) != null ? _this$input$getRootNo : document;
341
+ }
342
+
343
+ /** Is element in focus */
344
+ get isActive() {
345
+ return this.input === this.rootElement.activeElement;
346
+ }
347
+
348
+ /** Binds HTMLElement events to mask internal events */
349
+ bindEvents(handlers) {
350
+ this.input.addEventListener('keydown', this._onKeydown);
351
+ this.input.addEventListener('input', this._onInput);
352
+ this.input.addEventListener('beforeinput', this._onBeforeinput);
353
+ this.input.addEventListener('compositionend', this._onCompositionEnd);
354
+ this.input.addEventListener('drop', handlers.drop);
355
+ this.input.addEventListener('click', handlers.click);
356
+ this.input.addEventListener('focus', handlers.focus);
357
+ this.input.addEventListener('blur', handlers.commit);
358
+ this._handlers = handlers;
359
+ }
360
+ _onKeydown(e) {
361
+ if (this._handlers.redo && (e.keyCode === KEY_Z && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === KEY_Y && e.ctrlKey)) {
362
+ e.preventDefault();
363
+ return this._handlers.redo(e);
364
+ }
365
+ if (this._handlers.undo && e.keyCode === KEY_Z && (e.metaKey || e.ctrlKey)) {
366
+ e.preventDefault();
367
+ return this._handlers.undo(e);
368
+ }
369
+ if (!e.isComposing) this._handlers.selectionChange(e);
370
+ }
371
+ _onBeforeinput(e) {
372
+ if (e.inputType === 'historyUndo' && this._handlers.undo) {
373
+ e.preventDefault();
374
+ return this._handlers.undo(e);
375
+ }
376
+ if (e.inputType === 'historyRedo' && this._handlers.redo) {
377
+ e.preventDefault();
378
+ return this._handlers.redo(e);
379
+ }
380
+ }
381
+ _onCompositionEnd(e) {
382
+ this._handlers.input(e);
383
+ }
384
+ _onInput(e) {
385
+ if (!e.isComposing) this._handlers.input(e);
386
+ }
387
+
388
+ /** Unbinds HTMLElement events to mask internal events */
389
+ unbindEvents() {
390
+ this.input.removeEventListener('keydown', this._onKeydown);
391
+ this.input.removeEventListener('input', this._onInput);
392
+ this.input.removeEventListener('beforeinput', this._onBeforeinput);
393
+ this.input.removeEventListener('compositionend', this._onCompositionEnd);
394
+ this.input.removeEventListener('drop', this._handlers.drop);
395
+ this.input.removeEventListener('click', this._handlers.click);
396
+ this.input.removeEventListener('focus', this._handlers.focus);
397
+ this.input.removeEventListener('blur', this._handlers.commit);
398
+ this._handlers = {};
399
+ }
400
+ }
401
+ IMask.HTMLMaskElement = HTMLMaskElement;
402
+
403
+ /** Bridge between InputElement and {@link Masked} */
404
+ class HTMLInputMaskElement extends HTMLMaskElement {
405
+ /** InputElement to use mask on */
406
+
407
+ constructor(input) {
408
+ super(input);
409
+ this.input = input;
410
+ }
411
+
412
+ /** Returns InputElement selection start */
413
+ get _unsafeSelectionStart() {
414
+ return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
415
+ }
416
+
417
+ /** Returns InputElement selection end */
418
+ get _unsafeSelectionEnd() {
419
+ return this.input.selectionEnd;
420
+ }
421
+
422
+ /** Sets InputElement selection */
423
+ _unsafeSelect(start, end) {
424
+ this.input.setSelectionRange(start, end);
425
+ }
426
+ get value() {
427
+ return this.input.value;
428
+ }
429
+ set value(value) {
430
+ this.input.value = value;
431
+ }
432
+ }
433
+ IMask.HTMLMaskElement = HTMLMaskElement;
434
+
435
+ class HTMLContenteditableMaskElement extends HTMLMaskElement {
436
+ /** Returns HTMLElement selection start */
437
+ get _unsafeSelectionStart() {
438
+ const root = this.rootElement;
439
+ const selection = root.getSelection && root.getSelection();
440
+ const anchorOffset = selection && selection.anchorOffset;
441
+ const focusOffset = selection && selection.focusOffset;
442
+ if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
443
+ return anchorOffset;
444
+ }
445
+ return focusOffset;
446
+ }
447
+
448
+ /** Returns HTMLElement selection end */
449
+ get _unsafeSelectionEnd() {
450
+ const root = this.rootElement;
451
+ const selection = root.getSelection && root.getSelection();
452
+ const anchorOffset = selection && selection.anchorOffset;
453
+ const focusOffset = selection && selection.focusOffset;
454
+ if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
455
+ return anchorOffset;
456
+ }
457
+ return focusOffset;
458
+ }
459
+
460
+ /** Sets HTMLElement selection */
461
+ _unsafeSelect(start, end) {
462
+ if (!this.rootElement.createRange) return;
463
+ const range = this.rootElement.createRange();
464
+ range.setStart(this.input.firstChild || this.input, start);
465
+ range.setEnd(this.input.lastChild || this.input, end);
466
+ const root = this.rootElement;
467
+ const selection = root.getSelection && root.getSelection();
468
+ if (selection) {
469
+ selection.removeAllRanges();
470
+ selection.addRange(range);
471
+ }
472
+ }
473
+
474
+ /** HTMLElement value */
475
+ get value() {
476
+ return this.input.textContent || '';
477
+ }
478
+ set value(value) {
479
+ this.input.textContent = value;
480
+ }
481
+ }
482
+ IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
483
+
484
+ class InputHistory {
485
+ constructor() {
486
+ this.states = [];
487
+ this.currentIndex = 0;
488
+ }
489
+ get currentState() {
490
+ return this.states[this.currentIndex];
491
+ }
492
+ get isEmpty() {
493
+ return this.states.length === 0;
494
+ }
495
+ push(state) {
496
+ // if current index points before the last element then remove the future
497
+ if (this.currentIndex < this.states.length - 1) this.states.length = this.currentIndex + 1;
498
+ this.states.push(state);
499
+ if (this.states.length > InputHistory.MAX_LENGTH) this.states.shift();
500
+ this.currentIndex = this.states.length - 1;
501
+ }
502
+ go(steps) {
503
+ this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);
504
+ return this.currentState;
505
+ }
506
+ undo() {
507
+ return this.go(-1);
508
+ }
509
+ redo() {
510
+ return this.go(+1);
511
+ }
512
+ clear() {
513
+ this.states.length = 0;
514
+ this.currentIndex = 0;
515
+ }
516
+ }
517
+ InputHistory.MAX_LENGTH = 100;
518
+
519
+ /** Listens to element events and controls changes between element and {@link Masked} */
520
+ class InputMask {
521
+ /**
522
+ View element
523
+ */
524
+
525
+ /** Internal {@link Masked} model */
526
+
527
+ constructor(el, opts) {
528
+ this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLInputMaskElement(el);
529
+ this.masked = createMask(opts);
530
+ this._listeners = {};
531
+ this._value = '';
532
+ this._unmaskedValue = '';
533
+ this._rawInputValue = '';
534
+ this.history = new InputHistory();
535
+ this._saveSelection = this._saveSelection.bind(this);
536
+ this._onInput = this._onInput.bind(this);
537
+ this._onChange = this._onChange.bind(this);
538
+ this._onDrop = this._onDrop.bind(this);
539
+ this._onFocus = this._onFocus.bind(this);
540
+ this._onClick = this._onClick.bind(this);
541
+ this._onUndo = this._onUndo.bind(this);
542
+ this._onRedo = this._onRedo.bind(this);
543
+ this.alignCursor = this.alignCursor.bind(this);
544
+ this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
545
+ this._bindEvents();
546
+
547
+ // refresh
548
+ this.updateValue();
549
+ this._onChange();
550
+ }
551
+ maskEquals(mask) {
552
+ var _this$masked;
553
+ return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
554
+ }
555
+
556
+ /** Masked */
557
+ get mask() {
558
+ return this.masked.mask;
559
+ }
560
+ set mask(mask) {
561
+ if (this.maskEquals(mask)) return;
562
+ if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
563
+ // TODO "any" no idea
564
+ this.masked.updateOptions({
565
+ mask
566
+ });
567
+ return;
568
+ }
569
+ const masked = mask instanceof IMask.Masked ? mask : createMask({
570
+ mask
571
+ });
572
+ masked.unmaskedValue = this.masked.unmaskedValue;
573
+ this.masked = masked;
574
+ }
575
+
576
+ /** Raw value */
577
+ get value() {
578
+ return this._value;
579
+ }
580
+ set value(str) {
581
+ if (this.value === str) return;
582
+ this.masked.value = str;
583
+ this.updateControl('auto');
584
+ }
585
+
586
+ /** Unmasked value */
587
+ get unmaskedValue() {
588
+ return this._unmaskedValue;
589
+ }
590
+ set unmaskedValue(str) {
591
+ if (this.unmaskedValue === str) return;
592
+ this.masked.unmaskedValue = str;
593
+ this.updateControl('auto');
594
+ }
595
+
596
+ /** Raw input value */
597
+ get rawInputValue() {
598
+ return this._rawInputValue;
599
+ }
600
+ set rawInputValue(str) {
601
+ if (this.rawInputValue === str) return;
602
+ this.masked.rawInputValue = str;
603
+ this.updateControl();
604
+ this.alignCursor();
605
+ }
606
+
607
+ /** Typed unmasked value */
608
+ get typedValue() {
609
+ return this.masked.typedValue;
610
+ }
611
+ set typedValue(val) {
612
+ if (this.masked.typedValueEquals(val)) return;
613
+ this.masked.typedValue = val;
614
+ this.updateControl('auto');
615
+ }
616
+
617
+ /** Display value */
618
+ get displayValue() {
619
+ return this.masked.displayValue;
620
+ }
621
+
622
+ /** Starts listening to element events */
623
+ _bindEvents() {
624
+ this.el.bindEvents({
625
+ selectionChange: this._saveSelection,
626
+ input: this._onInput,
627
+ drop: this._onDrop,
628
+ click: this._onClick,
629
+ focus: this._onFocus,
630
+ commit: this._onChange,
631
+ undo: this._onUndo,
632
+ redo: this._onRedo
633
+ });
634
+ }
635
+
636
+ /** Stops listening to element events */
637
+ _unbindEvents() {
638
+ if (this.el) this.el.unbindEvents();
639
+ }
640
+
641
+ /** Fires custom event */
642
+ _fireEvent(ev, e) {
643
+ const listeners = this._listeners[ev];
644
+ if (!listeners) return;
645
+ listeners.forEach(l => l(e));
646
+ }
647
+
648
+ /** Current selection start */
649
+ get selectionStart() {
650
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
651
+ }
652
+
653
+ /** Current cursor position */
654
+ get cursorPos() {
655
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
656
+ }
657
+ set cursorPos(pos) {
658
+ if (!this.el || !this.el.isActive) return;
659
+ this.el.select(pos, pos);
660
+ this._saveSelection();
661
+ }
662
+
663
+ /** Stores current selection */
664
+ _saveSelection( /* ev */
665
+ ) {
666
+ if (this.displayValue !== this.el.value) {
667
+ console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console
668
+ }
669
+ this._selection = {
670
+ start: this.selectionStart,
671
+ end: this.cursorPos
672
+ };
673
+ }
674
+
675
+ /** Syncronizes model value from view */
676
+ updateValue() {
677
+ this.masked.value = this.el.value;
678
+ this._value = this.masked.value;
679
+ this._unmaskedValue = this.masked.unmaskedValue;
680
+ this._rawInputValue = this.masked.rawInputValue;
681
+ }
682
+
683
+ /** Syncronizes view from model value, fires change events */
684
+ updateControl(cursorPos) {
685
+ const newUnmaskedValue = this.masked.unmaskedValue;
686
+ const newValue = this.masked.value;
687
+ const newRawInputValue = this.masked.rawInputValue;
688
+ const newDisplayValue = this.displayValue;
689
+ const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue || this._rawInputValue !== newRawInputValue;
690
+ this._unmaskedValue = newUnmaskedValue;
691
+ this._value = newValue;
692
+ this._rawInputValue = newRawInputValue;
693
+ if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
694
+ if (cursorPos === 'auto') this.alignCursor();else if (cursorPos != null) this.cursorPos = cursorPos;
695
+ if (isChanged) this._fireChangeEvents();
696
+ if (!this._historyChanging && (isChanged || this.history.isEmpty)) this.history.push({
697
+ unmaskedValue: newUnmaskedValue,
698
+ selection: {
699
+ start: this.selectionStart,
700
+ end: this.cursorPos
701
+ }
702
+ });
703
+ }
704
+
705
+ /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
706
+ updateOptions(opts) {
707
+ const {
708
+ mask,
709
+ ...restOpts
710
+ } = opts; // TODO types, yes, mask is optional
711
+
712
+ const updateMask = !this.maskEquals(mask);
713
+ const updateOpts = this.masked.optionsIsChanged(restOpts);
714
+ if (updateMask) this.mask = mask;
715
+ if (updateOpts) this.masked.updateOptions(restOpts); // TODO
716
+
717
+ if (updateMask || updateOpts) this.updateControl();
718
+ }
719
+
720
+ /** Updates cursor */
721
+ updateCursor(cursorPos) {
722
+ if (cursorPos == null) return;
723
+ this.cursorPos = cursorPos;
724
+
725
+ // also queue change cursor for mobile browsers
726
+ this._delayUpdateCursor(cursorPos);
727
+ }
728
+
729
+ /** Delays cursor update to support mobile browsers */
730
+ _delayUpdateCursor(cursorPos) {
731
+ this._abortUpdateCursor();
732
+ this._changingCursorPos = cursorPos;
733
+ this._cursorChanging = setTimeout(() => {
734
+ if (!this.el) return; // if was destroyed
735
+ this.cursorPos = this._changingCursorPos;
736
+ this._abortUpdateCursor();
737
+ }, 10);
738
+ }
739
+
740
+ /** Fires custom events */
741
+ _fireChangeEvents() {
742
+ this._fireEvent('accept', this._inputEvent);
743
+ if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
744
+ }
745
+
746
+ /** Aborts delayed cursor update */
747
+ _abortUpdateCursor() {
748
+ if (this._cursorChanging) {
749
+ clearTimeout(this._cursorChanging);
750
+ delete this._cursorChanging;
751
+ }
752
+ }
753
+
754
+ /** Aligns cursor to nearest available position */
755
+ alignCursor() {
756
+ this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
757
+ }
758
+
759
+ /** Aligns cursor only if selection is empty */
760
+ alignCursorFriendly() {
761
+ if (this.selectionStart !== this.cursorPos) return; // skip if range is selected
762
+ this.alignCursor();
763
+ }
764
+
765
+ /** Adds listener on custom event */
766
+ on(ev, handler) {
767
+ if (!this._listeners[ev]) this._listeners[ev] = [];
768
+ this._listeners[ev].push(handler);
769
+ return this;
770
+ }
771
+
772
+ /** Removes custom event listener */
773
+ off(ev, handler) {
774
+ if (!this._listeners[ev]) return this;
775
+ if (!handler) {
776
+ delete this._listeners[ev];
777
+ return this;
778
+ }
779
+ const hIndex = this._listeners[ev].indexOf(handler);
780
+ if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
781
+ return this;
782
+ }
783
+
784
+ /** Handles view input event */
785
+ _onInput(e) {
786
+ this._inputEvent = e;
787
+ this._abortUpdateCursor();
788
+ const details = new ActionDetails({
789
+ // new state
790
+ value: this.el.value,
791
+ cursorPos: this.cursorPos,
792
+ // old state
793
+ oldValue: this.displayValue,
794
+ oldSelection: this._selection
795
+ });
796
+ const oldRawValue = this.masked.rawInputValue;
797
+ const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
798
+ input: true,
799
+ raw: true
800
+ }).offset;
801
+
802
+ // force align in remove direction only if no input chars were removed
803
+ // otherwise we still need to align with NONE (to get out from fixed symbols for instance)
804
+ const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
805
+ let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
806
+ if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
807
+ this.updateControl(cursorPos);
808
+ delete this._inputEvent;
809
+ }
810
+
811
+ /** Handles view change event and commits model value */
812
+ _onChange() {
813
+ if (this.displayValue !== this.el.value) this.updateValue();
814
+ this.masked.doCommit();
815
+ this.updateControl();
816
+ this._saveSelection();
817
+ }
818
+
819
+ /** Handles view drop event, prevents by default */
820
+ _onDrop(ev) {
821
+ ev.preventDefault();
822
+ ev.stopPropagation();
823
+ }
824
+
825
+ /** Restore last selection on focus */
826
+ _onFocus(ev) {
827
+ this.alignCursorFriendly();
828
+ }
829
+
830
+ /** Restore last selection on focus */
831
+ _onClick(ev) {
832
+ this.alignCursorFriendly();
833
+ }
834
+ _onUndo() {
835
+ this._applyHistoryState(this.history.undo());
836
+ }
837
+ _onRedo() {
838
+ this._applyHistoryState(this.history.redo());
839
+ }
840
+ _applyHistoryState(state) {
841
+ if (!state) return;
842
+ this._historyChanging = true;
843
+ this.unmaskedValue = state.unmaskedValue;
844
+ this.el.select(state.selection.start, state.selection.end);
845
+ this._saveSelection();
846
+ this._historyChanging = false;
847
+ }
848
+
849
+ /** Unbind view events and removes element reference */
850
+ destroy() {
851
+ this._unbindEvents();
852
+ this._listeners.length = 0;
853
+ delete this.el;
854
+ }
855
+ }
856
+ IMask.InputMask = InputMask;
857
+
858
+ /** Provides details of changing model value */
859
+ class ChangeDetails {
860
+ /** Inserted symbols */
861
+
862
+ /** Additional offset if any changes occurred before tail */
863
+
864
+ /** Raw inserted is used by dynamic mask */
865
+
866
+ /** Can skip chars */
867
+
868
+ static normalize(prep) {
869
+ return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
870
+ }
871
+ constructor(details) {
872
+ Object.assign(this, {
873
+ inserted: '',
874
+ rawInserted: '',
875
+ tailShift: 0,
876
+ skip: false
877
+ }, details);
878
+ }
879
+
880
+ /** Aggregate changes */
881
+ aggregate(details) {
882
+ this.inserted += details.inserted;
883
+ this.rawInserted += details.rawInserted;
884
+ this.tailShift += details.tailShift;
885
+ this.skip = this.skip || details.skip;
886
+ return this;
887
+ }
888
+
889
+ /** Total offset considering all changes */
890
+ get offset() {
891
+ return this.tailShift + this.inserted.length;
892
+ }
893
+ get consumed() {
894
+ return Boolean(this.rawInserted) || this.skip;
895
+ }
896
+ equals(details) {
897
+ return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
898
+ }
899
+ }
900
+ IMask.ChangeDetails = ChangeDetails;
901
+
902
+ /** Provides details of continuous extracted tail */
903
+ class ContinuousTailDetails {
904
+ /** Tail value as string */
905
+
906
+ /** Tail start position */
907
+
908
+ /** Start position */
909
+
910
+ constructor(value, from, stop) {
911
+ if (value === void 0) {
912
+ value = '';
913
+ }
914
+ if (from === void 0) {
915
+ from = 0;
916
+ }
917
+ this.value = value;
918
+ this.from = from;
919
+ this.stop = stop;
920
+ }
921
+ toString() {
922
+ return this.value;
923
+ }
924
+ extend(tail) {
925
+ this.value += String(tail);
926
+ }
927
+ appendTo(masked) {
928
+ return masked.append(this.toString(), {
929
+ tail: true
930
+ }).aggregate(masked._appendPlaceholder());
931
+ }
932
+ get state() {
933
+ return {
934
+ value: this.value,
935
+ from: this.from,
936
+ stop: this.stop
937
+ };
938
+ }
939
+ set state(state) {
940
+ Object.assign(this, state);
941
+ }
942
+ unshift(beforePos) {
943
+ if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
944
+ const shiftChar = this.value[0];
945
+ this.value = this.value.slice(1);
946
+ return shiftChar;
947
+ }
948
+ shift() {
949
+ if (!this.value.length) return '';
950
+ const shiftChar = this.value[this.value.length - 1];
951
+ this.value = this.value.slice(0, -1);
952
+ return shiftChar;
953
+ }
954
+ }
955
+
956
+ /** Append flags */
957
+
958
+ /** Extract flags */
959
+
960
+ // see https://github.com/microsoft/TypeScript/issues/6223
961
+
962
+ /** Provides common masking stuff */
963
+ class Masked {
964
+ /** */
965
+
966
+ /** */
967
+
968
+ /** Transforms value before mask processing */
969
+
970
+ /** Transforms each char before mask processing */
971
+
972
+ /** Validates if value is acceptable */
973
+
974
+ /** Does additional processing at the end of editing */
975
+
976
+ /** Format typed value to string */
977
+
978
+ /** Parse string to get typed value */
979
+
980
+ /** Enable characters overwriting */
981
+
982
+ /** */
983
+
984
+ /** */
985
+
986
+ /** */
987
+
988
+ /** */
989
+
990
+ constructor(opts) {
991
+ this._value = '';
992
+ this._update({
993
+ ...Masked.DEFAULTS,
994
+ ...opts
995
+ });
996
+ this._initialized = true;
997
+ }
998
+
999
+ /** Sets and applies new options */
1000
+ updateOptions(opts) {
1001
+ if (!this.optionsIsChanged(opts)) return;
1002
+ this.withValueRefresh(this._update.bind(this, opts));
1003
+ }
1004
+
1005
+ /** Sets new options */
1006
+ _update(opts) {
1007
+ Object.assign(this, opts);
1008
+ }
1009
+
1010
+ /** Mask state */
1011
+ get state() {
1012
+ return {
1013
+ _value: this.value,
1014
+ _rawInputValue: this.rawInputValue
1015
+ };
1016
+ }
1017
+ set state(state) {
1018
+ this._value = state._value;
1019
+ }
1020
+
1021
+ /** Resets value */
1022
+ reset() {
1023
+ this._value = '';
1024
+ }
1025
+ get value() {
1026
+ return this._value;
1027
+ }
1028
+ set value(value) {
1029
+ this.resolve(value, {
1030
+ input: true
1031
+ });
1032
+ }
1033
+
1034
+ /** Resolve new value */
1035
+ resolve(value, flags) {
1036
+ if (flags === void 0) {
1037
+ flags = {
1038
+ input: true
1039
+ };
1040
+ }
1041
+ this.reset();
1042
+ this.append(value, flags, '');
1043
+ this.doCommit();
1044
+ }
1045
+ get unmaskedValue() {
1046
+ return this.value;
1047
+ }
1048
+ set unmaskedValue(value) {
1049
+ this.resolve(value, {});
1050
+ }
1051
+ get typedValue() {
1052
+ return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
1053
+ }
1054
+ set typedValue(value) {
1055
+ if (this.format) {
1056
+ this.value = this.format(value, this);
1057
+ } else {
1058
+ this.unmaskedValue = String(value);
1059
+ }
1060
+ }
1061
+
1062
+ /** Value that includes raw user input */
1063
+ get rawInputValue() {
1064
+ return this.extractInput(0, this.displayValue.length, {
1065
+ raw: true
1066
+ });
1067
+ }
1068
+ set rawInputValue(value) {
1069
+ this.resolve(value, {
1070
+ raw: true
1071
+ });
1072
+ }
1073
+ get displayValue() {
1074
+ return this.value;
1075
+ }
1076
+ get isComplete() {
1077
+ return true;
1078
+ }
1079
+ get isFilled() {
1080
+ return this.isComplete;
1081
+ }
1082
+
1083
+ /** Finds nearest input position in direction */
1084
+ nearestInputPos(cursorPos, direction) {
1085
+ return cursorPos;
1086
+ }
1087
+ totalInputPositions(fromPos, toPos) {
1088
+ if (fromPos === void 0) {
1089
+ fromPos = 0;
1090
+ }
1091
+ if (toPos === void 0) {
1092
+ toPos = this.displayValue.length;
1093
+ }
1094
+ return Math.min(this.displayValue.length, toPos - fromPos);
1095
+ }
1096
+
1097
+ /** Extracts value in range considering flags */
1098
+ extractInput(fromPos, toPos, flags) {
1099
+ if (fromPos === void 0) {
1100
+ fromPos = 0;
1101
+ }
1102
+ if (toPos === void 0) {
1103
+ toPos = this.displayValue.length;
1104
+ }
1105
+ return this.displayValue.slice(fromPos, toPos);
1106
+ }
1107
+
1108
+ /** Extracts tail in range */
1109
+ extractTail(fromPos, toPos) {
1110
+ if (fromPos === void 0) {
1111
+ fromPos = 0;
1112
+ }
1113
+ if (toPos === void 0) {
1114
+ toPos = this.displayValue.length;
1115
+ }
1116
+ return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
1117
+ }
1118
+
1119
+ /** Appends tail */
1120
+ appendTail(tail) {
1121
+ if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
1122
+ return tail.appendTo(this);
1123
+ }
1124
+
1125
+ /** Appends char */
1126
+ _appendCharRaw(ch, flags) {
1127
+ if (!ch) return new ChangeDetails();
1128
+ this._value += ch;
1129
+ return new ChangeDetails({
1130
+ inserted: ch,
1131
+ rawInserted: ch
1132
+ });
1133
+ }
1134
+
1135
+ /** Appends char */
1136
+ _appendChar(ch, flags, checkTail) {
1137
+ if (flags === void 0) {
1138
+ flags = {};
1139
+ }
1140
+ const consistentState = this.state;
1141
+ let details;
1142
+ [ch, details] = this.doPrepareChar(ch, flags);
1143
+ if (ch) {
1144
+ details = details.aggregate(this._appendCharRaw(ch, flags));
1145
+
1146
+ // TODO handle `skip`?
1147
+
1148
+ // try `autofix` lookahead
1149
+ if (!details.rawInserted && this.autofix === 'pad') {
1150
+ const noFixState = this.state;
1151
+ this.state = consistentState;
1152
+ let fixDetails = this.pad(flags);
1153
+ const chDetails = this._appendCharRaw(ch, flags);
1154
+ fixDetails = fixDetails.aggregate(chDetails);
1155
+
1156
+ // if fix was applied or
1157
+ // if details are equal use skip restoring state optimization
1158
+ if (chDetails.rawInserted || fixDetails.equals(details)) {
1159
+ details = fixDetails;
1160
+ } else {
1161
+ this.state = noFixState;
1162
+ }
1163
+ }
1164
+ }
1165
+ if (details.inserted) {
1166
+ let consistentTail;
1167
+ let appended = this.doValidate(flags) !== false;
1168
+ if (appended && checkTail != null) {
1169
+ // validation ok, check tail
1170
+ const beforeTailState = this.state;
1171
+ if (this.overwrite === true) {
1172
+ consistentTail = checkTail.state;
1173
+ for (let i = 0; i < details.rawInserted.length; ++i) {
1174
+ checkTail.unshift(this.displayValue.length - details.tailShift);
1175
+ }
1176
+ }
1177
+ let tailDetails = this.appendTail(checkTail);
1178
+ appended = tailDetails.rawInserted.length === checkTail.toString().length;
1179
+
1180
+ // not ok, try shift
1181
+ if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
1182
+ this.state = beforeTailState;
1183
+ consistentTail = checkTail.state;
1184
+ for (let i = 0; i < details.rawInserted.length; ++i) {
1185
+ checkTail.shift();
1186
+ }
1187
+ tailDetails = this.appendTail(checkTail);
1188
+ appended = tailDetails.rawInserted.length === checkTail.toString().length;
1189
+ }
1190
+
1191
+ // if ok, rollback state after tail
1192
+ if (appended && tailDetails.inserted) this.state = beforeTailState;
1193
+ }
1194
+
1195
+ // revert all if something went wrong
1196
+ if (!appended) {
1197
+ details = new ChangeDetails();
1198
+ this.state = consistentState;
1199
+ if (checkTail && consistentTail) checkTail.state = consistentTail;
1200
+ }
1201
+ }
1202
+ return details;
1203
+ }
1204
+
1205
+ /** Appends optional placeholder at the end */
1206
+ _appendPlaceholder() {
1207
+ return new ChangeDetails();
1208
+ }
1209
+
1210
+ /** Appends optional eager placeholder at the end */
1211
+ _appendEager() {
1212
+ return new ChangeDetails();
1213
+ }
1214
+
1215
+ /** Appends symbols considering flags */
1216
+ append(str, flags, tail) {
1217
+ if (!isString(str)) throw new Error('value should be string');
1218
+ const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
1219
+ if (flags != null && flags.tail) flags._beforeTailState = this.state;
1220
+ let details;
1221
+ [str, details] = this.doPrepare(str, flags);
1222
+ for (let ci = 0; ci < str.length; ++ci) {
1223
+ const d = this._appendChar(str[ci], flags, checkTail);
1224
+ if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
1225
+ details.aggregate(d);
1226
+ }
1227
+ if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
1228
+ details.aggregate(this._appendEager());
1229
+ }
1230
+
1231
+ // append tail but aggregate only tailShift
1232
+ if (checkTail != null) {
1233
+ details.tailShift += this.appendTail(checkTail).tailShift;
1234
+ // TODO it's a good idea to clear state after appending ends
1235
+ // but it causes bugs when one append calls another (when dynamic dispatch set rawInputValue)
1236
+ // this._resetBeforeTailState();
1237
+ }
1238
+ return details;
1239
+ }
1240
+ remove(fromPos, toPos) {
1241
+ if (fromPos === void 0) {
1242
+ fromPos = 0;
1243
+ }
1244
+ if (toPos === void 0) {
1245
+ toPos = this.displayValue.length;
1246
+ }
1247
+ this._value = this.displayValue.slice(0, fromPos) + this.displayValue.slice(toPos);
1248
+ return new ChangeDetails();
1249
+ }
1250
+
1251
+ /** Calls function and reapplies current value */
1252
+ withValueRefresh(fn) {
1253
+ if (this._refreshing || !this._initialized) return fn();
1254
+ this._refreshing = true;
1255
+ const rawInput = this.rawInputValue;
1256
+ const value = this.value;
1257
+ const ret = fn();
1258
+ this.rawInputValue = rawInput;
1259
+ // append lost trailing chars at the end
1260
+ if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
1261
+ this.append(value.slice(this.displayValue.length), {}, '');
1262
+ this.doCommit();
1263
+ }
1264
+ delete this._refreshing;
1265
+ return ret;
1266
+ }
1267
+ runIsolated(fn) {
1268
+ if (this._isolated || !this._initialized) return fn(this);
1269
+ this._isolated = true;
1270
+ const state = this.state;
1271
+ const ret = fn(this);
1272
+ this.state = state;
1273
+ delete this._isolated;
1274
+ return ret;
1275
+ }
1276
+ doSkipInvalid(ch, flags, checkTail) {
1277
+ return Boolean(this.skipInvalid);
1278
+ }
1279
+
1280
+ /** Prepares string before mask processing */
1281
+ doPrepare(str, flags) {
1282
+ if (flags === void 0) {
1283
+ flags = {};
1284
+ }
1285
+ return ChangeDetails.normalize(this.prepare ? this.prepare(str, this, flags) : str);
1286
+ }
1287
+
1288
+ /** Prepares each char before mask processing */
1289
+ doPrepareChar(str, flags) {
1290
+ if (flags === void 0) {
1291
+ flags = {};
1292
+ }
1293
+ return ChangeDetails.normalize(this.prepareChar ? this.prepareChar(str, this, flags) : str);
1294
+ }
1295
+
1296
+ /** Validates if value is acceptable */
1297
+ doValidate(flags) {
1298
+ return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
1299
+ }
1300
+
1301
+ /** Does additional processing at the end of editing */
1302
+ doCommit() {
1303
+ if (this.commit) this.commit(this.value, this);
1304
+ }
1305
+ splice(start, deleteCount, inserted, removeDirection, flags) {
1306
+ if (inserted === void 0) {
1307
+ inserted = '';
1308
+ }
1309
+ if (removeDirection === void 0) {
1310
+ removeDirection = DIRECTION.NONE;
1311
+ }
1312
+ if (flags === void 0) {
1313
+ flags = {
1314
+ input: true
1315
+ };
1316
+ }
1317
+ const tailPos = start + deleteCount;
1318
+ const tail = this.extractTail(tailPos);
1319
+ const eagerRemove = this.eager === true || this.eager === 'remove';
1320
+ let oldRawValue;
1321
+ if (eagerRemove) {
1322
+ removeDirection = forceDirection(removeDirection);
1323
+ oldRawValue = this.extractInput(0, tailPos, {
1324
+ raw: true
1325
+ });
1326
+ }
1327
+ let startChangePos = start;
1328
+ const details = new ChangeDetails();
1329
+
1330
+ // if it is just deletion without insertion
1331
+ if (removeDirection !== DIRECTION.NONE) {
1332
+ startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !eagerRemove ? DIRECTION.NONE : removeDirection);
1333
+
1334
+ // adjust tailShift if start was aligned
1335
+ details.tailShift = startChangePos - start;
1336
+ }
1337
+ details.aggregate(this.remove(startChangePos));
1338
+ if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
1339
+ if (removeDirection === DIRECTION.FORCE_LEFT) {
1340
+ let valLength;
1341
+ while (oldRawValue === this.rawInputValue && (valLength = this.displayValue.length)) {
1342
+ details.aggregate(new ChangeDetails({
1343
+ tailShift: -1
1344
+ })).aggregate(this.remove(valLength - 1));
1345
+ }
1346
+ } else if (removeDirection === DIRECTION.FORCE_RIGHT) {
1347
+ tail.unshift();
1348
+ }
1349
+ }
1350
+ return details.aggregate(this.append(inserted, flags, tail));
1351
+ }
1352
+ maskEquals(mask) {
1353
+ return this.mask === mask;
1354
+ }
1355
+ optionsIsChanged(opts) {
1356
+ return !objectIncludes(this, opts);
1357
+ }
1358
+ typedValueEquals(value) {
1359
+ const tval = this.typedValue;
1360
+ return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || (this.format ? this.format(value, this) === this.format(this.typedValue, this) : false);
1361
+ }
1362
+ pad(flags) {
1363
+ return new ChangeDetails();
1364
+ }
1365
+ }
1366
+ Masked.DEFAULTS = {
1367
+ skipInvalid: true
1368
+ };
1369
+ Masked.EMPTY_VALUES = [undefined, null, ''];
1370
+ IMask.Masked = Masked;
1371
+
1372
+ class ChunksTailDetails {
1373
+ /** */
1374
+
1375
+ constructor(chunks, from) {
1376
+ if (chunks === void 0) {
1377
+ chunks = [];
1378
+ }
1379
+ if (from === void 0) {
1380
+ from = 0;
1381
+ }
1382
+ this.chunks = chunks;
1383
+ this.from = from;
1384
+ }
1385
+ toString() {
1386
+ return this.chunks.map(String).join('');
1387
+ }
1388
+ extend(tailChunk) {
1389
+ if (!String(tailChunk)) return;
1390
+ tailChunk = isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk;
1391
+ const lastChunk = this.chunks[this.chunks.length - 1];
1392
+ const extendLast = lastChunk && (
1393
+ // if stops are same or tail has no stop
1394
+ lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
1395
+ // if tail chunk goes just after last chunk
1396
+ tailChunk.from === lastChunk.from + lastChunk.toString().length;
1397
+ if (tailChunk instanceof ContinuousTailDetails) {
1398
+ // check the ability to extend previous chunk
1399
+ if (extendLast) {
1400
+ // extend previous chunk
1401
+ lastChunk.extend(tailChunk.toString());
1402
+ } else {
1403
+ // append new chunk
1404
+ this.chunks.push(tailChunk);
1405
+ }
1406
+ } else if (tailChunk instanceof ChunksTailDetails) {
1407
+ if (tailChunk.stop == null) {
1408
+ // unwrap floating chunks to parent, keeping `from` pos
1409
+ let firstTailChunk;
1410
+ while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
1411
+ firstTailChunk = tailChunk.chunks.shift(); // not possible to be `undefined` because length was checked above
1412
+ firstTailChunk.from += tailChunk.from;
1413
+ this.extend(firstTailChunk);
1414
+ }
1415
+ }
1416
+
1417
+ // if tail chunk still has value
1418
+ if (tailChunk.toString()) {
1419
+ // if chunks contains stops, then popup stop to container
1420
+ tailChunk.stop = tailChunk.blockIndex;
1421
+ this.chunks.push(tailChunk);
1422
+ }
1423
+ }
1424
+ }
1425
+ appendTo(masked) {
1426
+ if (!(masked instanceof IMask.MaskedPattern)) {
1427
+ const tail = new ContinuousTailDetails(this.toString());
1428
+ return tail.appendTo(masked);
1429
+ }
1430
+ const details = new ChangeDetails();
1431
+ for (let ci = 0; ci < this.chunks.length; ++ci) {
1432
+ const chunk = this.chunks[ci];
1433
+ const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
1434
+ const stop = chunk.stop;
1435
+ let chunkBlock;
1436
+ if (stop != null && (
1437
+ // if block not found or stop is behind lastBlock
1438
+ !lastBlockIter || lastBlockIter.index <= stop)) {
1439
+ if (chunk instanceof ChunksTailDetails ||
1440
+ // for continuous block also check if stop is exist
1441
+ masked._stops.indexOf(stop) >= 0) {
1442
+ details.aggregate(masked._appendPlaceholder(stop));
1443
+ }
1444
+ chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
1445
+ }
1446
+ if (chunkBlock) {
1447
+ const tailDetails = chunkBlock.appendTail(chunk);
1448
+ details.aggregate(tailDetails);
1449
+
1450
+ // get not inserted chars
1451
+ const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
1452
+ if (remainChars) details.aggregate(masked.append(remainChars, {
1453
+ tail: true
1454
+ }));
1455
+ } else {
1456
+ details.aggregate(masked.append(chunk.toString(), {
1457
+ tail: true
1458
+ }));
1459
+ }
1460
+ }
1461
+ return details;
1462
+ }
1463
+ get state() {
1464
+ return {
1465
+ chunks: this.chunks.map(c => c.state),
1466
+ from: this.from,
1467
+ stop: this.stop,
1468
+ blockIndex: this.blockIndex
1469
+ };
1470
+ }
1471
+ set state(state) {
1472
+ const {
1473
+ chunks,
1474
+ ...props
1475
+ } = state;
1476
+ Object.assign(this, props);
1477
+ this.chunks = chunks.map(cstate => {
1478
+ const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
1479
+ chunk.state = cstate;
1480
+ return chunk;
1481
+ });
1482
+ }
1483
+ unshift(beforePos) {
1484
+ if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
1485
+ const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
1486
+ let ci = 0;
1487
+ while (ci < this.chunks.length) {
1488
+ const chunk = this.chunks[ci];
1489
+ const shiftChar = chunk.unshift(chunkShiftPos);
1490
+ if (chunk.toString()) {
1491
+ // chunk still contains value
1492
+ // but not shifted - means no more available chars to shift
1493
+ if (!shiftChar) break;
1494
+ ++ci;
1495
+ } else {
1496
+ // clean if chunk has no value
1497
+ this.chunks.splice(ci, 1);
1498
+ }
1499
+ if (shiftChar) return shiftChar;
1500
+ }
1501
+ return '';
1502
+ }
1503
+ shift() {
1504
+ if (!this.chunks.length) return '';
1505
+ let ci = this.chunks.length - 1;
1506
+ while (0 <= ci) {
1507
+ const chunk = this.chunks[ci];
1508
+ const shiftChar = chunk.shift();
1509
+ if (chunk.toString()) {
1510
+ // chunk still contains value
1511
+ // but not shifted - means no more available chars to shift
1512
+ if (!shiftChar) break;
1513
+ --ci;
1514
+ } else {
1515
+ // clean if chunk has no value
1516
+ this.chunks.splice(ci, 1);
1517
+ }
1518
+ if (shiftChar) return shiftChar;
1519
+ }
1520
+ return '';
1521
+ }
1522
+ }
1523
+
1524
+ class PatternCursor {
1525
+ constructor(masked, pos) {
1526
+ this.masked = masked;
1527
+ this._log = [];
1528
+ const {
1529
+ offset,
1530
+ index
1531
+ } = masked._mapPosToBlock(pos) || (pos < 0 ?
1532
+ // first
1533
+ {
1534
+ index: 0,
1535
+ offset: 0
1536
+ } :
1537
+ // last
1538
+ {
1539
+ index: this.masked._blocks.length,
1540
+ offset: 0
1541
+ });
1542
+ this.offset = offset;
1543
+ this.index = index;
1544
+ this.ok = false;
1545
+ }
1546
+ get block() {
1547
+ return this.masked._blocks[this.index];
1548
+ }
1549
+ get pos() {
1550
+ return this.masked._blockStartPos(this.index) + this.offset;
1551
+ }
1552
+ get state() {
1553
+ return {
1554
+ index: this.index,
1555
+ offset: this.offset,
1556
+ ok: this.ok
1557
+ };
1558
+ }
1559
+ set state(s) {
1560
+ Object.assign(this, s);
1561
+ }
1562
+ pushState() {
1563
+ this._log.push(this.state);
1564
+ }
1565
+ popState() {
1566
+ const s = this._log.pop();
1567
+ if (s) this.state = s;
1568
+ return s;
1569
+ }
1570
+ bindBlock() {
1571
+ if (this.block) return;
1572
+ if (this.index < 0) {
1573
+ this.index = 0;
1574
+ this.offset = 0;
1575
+ }
1576
+ if (this.index >= this.masked._blocks.length) {
1577
+ this.index = this.masked._blocks.length - 1;
1578
+ this.offset = this.block.displayValue.length; // TODO this is stupid type error, `block` depends on index that was changed above
1579
+ }
1580
+ }
1581
+ _pushLeft(fn) {
1582
+ this.pushState();
1583
+ for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
1584
+ var _this$block;
1585
+ if (fn()) return this.ok = true;
1586
+ }
1587
+ return this.ok = false;
1588
+ }
1589
+ _pushRight(fn) {
1590
+ this.pushState();
1591
+ for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
1592
+ if (fn()) return this.ok = true;
1593
+ }
1594
+ return this.ok = false;
1595
+ }
1596
+ pushLeftBeforeFilled() {
1597
+ return this._pushLeft(() => {
1598
+ if (this.block.isFixed || !this.block.value) return;
1599
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);
1600
+ if (this.offset !== 0) return true;
1601
+ });
1602
+ }
1603
+ pushLeftBeforeInput() {
1604
+ // cases:
1605
+ // filled input: 00|
1606
+ // optional empty input: 00[]|
1607
+ // nested block: XX<[]>|
1608
+ return this._pushLeft(() => {
1609
+ if (this.block.isFixed) return;
1610
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
1611
+ return true;
1612
+ });
1613
+ }
1614
+ pushLeftBeforeRequired() {
1615
+ return this._pushLeft(() => {
1616
+ if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
1617
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
1618
+ return true;
1619
+ });
1620
+ }
1621
+ pushRightBeforeFilled() {
1622
+ return this._pushRight(() => {
1623
+ if (this.block.isFixed || !this.block.value) return;
1624
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);
1625
+ if (this.offset !== this.block.value.length) return true;
1626
+ });
1627
+ }
1628
+ pushRightBeforeInput() {
1629
+ return this._pushRight(() => {
1630
+ if (this.block.isFixed) return;
1631
+
1632
+ // const o = this.offset;
1633
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
1634
+ // HACK cases like (STILL DOES NOT WORK FOR NESTED)
1635
+ // aa|X
1636
+ // aa<X|[]>X_ - this will not work
1637
+ // if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;
1638
+ return true;
1639
+ });
1640
+ }
1641
+ pushRightBeforeRequired() {
1642
+ return this._pushRight(() => {
1643
+ if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
1644
+
1645
+ // TODO check |[*]XX_
1646
+ this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
1647
+ return true;
1648
+ });
1649
+ }
1650
+ }
1651
+
1652
+ class PatternFixedDefinition {
1653
+ /** */
1654
+
1655
+ /** */
1656
+
1657
+ /** */
1658
+
1659
+ /** */
1660
+
1661
+ /** */
1662
+
1663
+ /** */
1664
+
1665
+ constructor(opts) {
1666
+ Object.assign(this, opts);
1667
+ this._value = '';
1668
+ this.isFixed = true;
1669
+ }
1670
+ get value() {
1671
+ return this._value;
1672
+ }
1673
+ get unmaskedValue() {
1674
+ return this.isUnmasking ? this.value : '';
1675
+ }
1676
+ get rawInputValue() {
1677
+ return this._isRawInput ? this.value : '';
1678
+ }
1679
+ get displayValue() {
1680
+ return this.value;
1681
+ }
1682
+ reset() {
1683
+ this._isRawInput = false;
1684
+ this._value = '';
1685
+ }
1686
+ remove(fromPos, toPos) {
1687
+ if (fromPos === void 0) {
1688
+ fromPos = 0;
1689
+ }
1690
+ if (toPos === void 0) {
1691
+ toPos = this._value.length;
1692
+ }
1693
+ this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
1694
+ if (!this._value) this._isRawInput = false;
1695
+ return new ChangeDetails();
1696
+ }
1697
+ nearestInputPos(cursorPos, direction) {
1698
+ if (direction === void 0) {
1699
+ direction = DIRECTION.NONE;
1700
+ }
1701
+ const minPos = 0;
1702
+ const maxPos = this._value.length;
1703
+ switch (direction) {
1704
+ case DIRECTION.LEFT:
1705
+ case DIRECTION.FORCE_LEFT:
1706
+ return minPos;
1707
+ case DIRECTION.NONE:
1708
+ case DIRECTION.RIGHT:
1709
+ case DIRECTION.FORCE_RIGHT:
1710
+ default:
1711
+ return maxPos;
1712
+ }
1713
+ }
1714
+ totalInputPositions(fromPos, toPos) {
1715
+ if (fromPos === void 0) {
1716
+ fromPos = 0;
1717
+ }
1718
+ if (toPos === void 0) {
1719
+ toPos = this._value.length;
1720
+ }
1721
+ return this._isRawInput ? toPos - fromPos : 0;
1722
+ }
1723
+ extractInput(fromPos, toPos, flags) {
1724
+ if (fromPos === void 0) {
1725
+ fromPos = 0;
1726
+ }
1727
+ if (toPos === void 0) {
1728
+ toPos = this._value.length;
1729
+ }
1730
+ if (flags === void 0) {
1731
+ flags = {};
1732
+ }
1733
+ return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
1734
+ }
1735
+ get isComplete() {
1736
+ return true;
1737
+ }
1738
+ get isFilled() {
1739
+ return Boolean(this._value);
1740
+ }
1741
+ _appendChar(ch, flags) {
1742
+ if (flags === void 0) {
1743
+ flags = {};
1744
+ }
1745
+ if (this.isFilled) return new ChangeDetails();
1746
+ const appendEager = this.eager === true || this.eager === 'append';
1747
+ const appended = this.char === ch;
1748
+ const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
1749
+ const details = new ChangeDetails({
1750
+ inserted: this.char,
1751
+ rawInserted: isResolved ? this.char : ''
1752
+ });
1753
+ this._value = this.char;
1754
+ this._isRawInput = isResolved && (flags.raw || flags.input);
1755
+ return details;
1756
+ }
1757
+ _appendEager() {
1758
+ return this._appendChar(this.char, {
1759
+ tail: true
1760
+ });
1761
+ }
1762
+ _appendPlaceholder() {
1763
+ const details = new ChangeDetails();
1764
+ if (this.isFilled) return details;
1765
+ this._value = details.inserted = this.char;
1766
+ return details;
1767
+ }
1768
+ extractTail() {
1769
+ return new ContinuousTailDetails('');
1770
+ }
1771
+ appendTail(tail) {
1772
+ if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
1773
+ return tail.appendTo(this);
1774
+ }
1775
+ append(str, flags, tail) {
1776
+ const details = this._appendChar(str[0], flags);
1777
+ if (tail != null) {
1778
+ details.tailShift += this.appendTail(tail).tailShift;
1779
+ }
1780
+ return details;
1781
+ }
1782
+ doCommit() {}
1783
+ get state() {
1784
+ return {
1785
+ _value: this._value,
1786
+ _rawInputValue: this.rawInputValue
1787
+ };
1788
+ }
1789
+ set state(state) {
1790
+ this._value = state._value;
1791
+ this._isRawInput = Boolean(state._rawInputValue);
1792
+ }
1793
+ pad(flags) {
1794
+ return this._appendPlaceholder();
1795
+ }
1796
+ }
1797
+
1798
+ class PatternInputDefinition {
1799
+ /** */
1800
+
1801
+ /** */
1802
+
1803
+ /** */
1804
+
1805
+ /** */
1806
+
1807
+ /** */
1808
+
1809
+ /** */
1810
+
1811
+ /** */
1812
+
1813
+ /** */
1814
+
1815
+ constructor(opts) {
1816
+ const {
1817
+ parent,
1818
+ isOptional,
1819
+ placeholderChar,
1820
+ displayChar,
1821
+ lazy,
1822
+ eager,
1823
+ ...maskOpts
1824
+ } = opts;
1825
+ this.masked = createMask(maskOpts);
1826
+ Object.assign(this, {
1827
+ parent,
1828
+ isOptional,
1829
+ placeholderChar,
1830
+ displayChar,
1831
+ lazy,
1832
+ eager
1833
+ });
1834
+ }
1835
+ reset() {
1836
+ this.isFilled = false;
1837
+ this.masked.reset();
1838
+ }
1839
+ remove(fromPos, toPos) {
1840
+ if (fromPos === void 0) {
1841
+ fromPos = 0;
1842
+ }
1843
+ if (toPos === void 0) {
1844
+ toPos = this.value.length;
1845
+ }
1846
+ if (fromPos === 0 && toPos >= 1) {
1847
+ this.isFilled = false;
1848
+ return this.masked.remove(fromPos, toPos);
1849
+ }
1850
+ return new ChangeDetails();
1851
+ }
1852
+ get value() {
1853
+ return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
1854
+ }
1855
+ get unmaskedValue() {
1856
+ return this.masked.unmaskedValue;
1857
+ }
1858
+ get rawInputValue() {
1859
+ return this.masked.rawInputValue;
1860
+ }
1861
+ get displayValue() {
1862
+ return this.masked.value && this.displayChar || this.value;
1863
+ }
1864
+ get isComplete() {
1865
+ return Boolean(this.masked.value) || this.isOptional;
1866
+ }
1867
+ _appendChar(ch, flags) {
1868
+ if (flags === void 0) {
1869
+ flags = {};
1870
+ }
1871
+ if (this.isFilled) return new ChangeDetails();
1872
+ const state = this.masked.state;
1873
+ // simulate input
1874
+ let details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
1875
+ if (details.inserted && this.doValidate(flags) === false) {
1876
+ details = new ChangeDetails();
1877
+ this.masked.state = state;
1878
+ }
1879
+ if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
1880
+ details.inserted = this.placeholderChar;
1881
+ }
1882
+ details.skip = !details.inserted && !this.isOptional;
1883
+ this.isFilled = Boolean(details.inserted);
1884
+ return details;
1885
+ }
1886
+ append(str, flags, tail) {
1887
+ // TODO probably should be done via _appendChar
1888
+ return this.masked.append(str, this.currentMaskFlags(flags), tail);
1889
+ }
1890
+ _appendPlaceholder() {
1891
+ if (this.isFilled || this.isOptional) return new ChangeDetails();
1892
+ this.isFilled = true;
1893
+ return new ChangeDetails({
1894
+ inserted: this.placeholderChar
1895
+ });
1896
+ }
1897
+ _appendEager() {
1898
+ return new ChangeDetails();
1899
+ }
1900
+ extractTail(fromPos, toPos) {
1901
+ return this.masked.extractTail(fromPos, toPos);
1902
+ }
1903
+ appendTail(tail) {
1904
+ return this.masked.appendTail(tail);
1905
+ }
1906
+ extractInput(fromPos, toPos, flags) {
1907
+ if (fromPos === void 0) {
1908
+ fromPos = 0;
1909
+ }
1910
+ if (toPos === void 0) {
1911
+ toPos = this.value.length;
1912
+ }
1913
+ return this.masked.extractInput(fromPos, toPos, flags);
1914
+ }
1915
+ nearestInputPos(cursorPos, direction) {
1916
+ if (direction === void 0) {
1917
+ direction = DIRECTION.NONE;
1918
+ }
1919
+ const minPos = 0;
1920
+ const maxPos = this.value.length;
1921
+ const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
1922
+ switch (direction) {
1923
+ case DIRECTION.LEFT:
1924
+ case DIRECTION.FORCE_LEFT:
1925
+ return this.isComplete ? boundPos : minPos;
1926
+ case DIRECTION.RIGHT:
1927
+ case DIRECTION.FORCE_RIGHT:
1928
+ return this.isComplete ? boundPos : maxPos;
1929
+ case DIRECTION.NONE:
1930
+ default:
1931
+ return boundPos;
1932
+ }
1933
+ }
1934
+ totalInputPositions(fromPos, toPos) {
1935
+ if (fromPos === void 0) {
1936
+ fromPos = 0;
1937
+ }
1938
+ if (toPos === void 0) {
1939
+ toPos = this.value.length;
1940
+ }
1941
+ return this.value.slice(fromPos, toPos).length;
1942
+ }
1943
+ doValidate(flags) {
1944
+ return this.masked.doValidate(this.currentMaskFlags(flags)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));
1945
+ }
1946
+ doCommit() {
1947
+ this.masked.doCommit();
1948
+ }
1949
+ get state() {
1950
+ return {
1951
+ _value: this.value,
1952
+ _rawInputValue: this.rawInputValue,
1953
+ masked: this.masked.state,
1954
+ isFilled: this.isFilled
1955
+ };
1956
+ }
1957
+ set state(state) {
1958
+ this.masked.state = state.masked;
1959
+ this.isFilled = state.isFilled;
1960
+ }
1961
+ currentMaskFlags(flags) {
1962
+ var _flags$_beforeTailSta;
1963
+ return {
1964
+ ...flags,
1965
+ _beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
1966
+ };
1967
+ }
1968
+ pad(flags) {
1969
+ return new ChangeDetails();
1970
+ }
1971
+ }
1972
+ PatternInputDefinition.DEFAULT_DEFINITIONS = {
1973
+ '0': /\d/,
1974
+ 'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
1975
+ // http://stackoverflow.com/a/22075070
1976
+ '*': /./
1977
+ };
1978
+
1979
+ /** Masking by RegExp */
1980
+ class MaskedRegExp extends Masked {
1981
+ /** */
1982
+
1983
+ /** Enable characters overwriting */
1984
+
1985
+ /** */
1986
+
1987
+ /** */
1988
+
1989
+ /** */
1990
+
1991
+ updateOptions(opts) {
1992
+ super.updateOptions(opts);
1993
+ }
1994
+ _update(opts) {
1995
+ const mask = opts.mask;
1996
+ if (mask) opts.validate = value => value.search(mask) >= 0;
1997
+ super._update(opts);
1998
+ }
1999
+ }
2000
+ IMask.MaskedRegExp = MaskedRegExp;
2001
+
2002
+ /** Pattern mask */
2003
+ class MaskedPattern extends Masked {
2004
+ /** */
2005
+
2006
+ /** */
2007
+
2008
+ /** Single char for empty input */
2009
+
2010
+ /** Single char for filled input */
2011
+
2012
+ /** Show placeholder only when needed */
2013
+
2014
+ /** Enable characters overwriting */
2015
+
2016
+ /** */
2017
+
2018
+ /** */
2019
+
2020
+ /** */
2021
+
2022
+ constructor(opts) {
2023
+ super({
2024
+ ...MaskedPattern.DEFAULTS,
2025
+ ...opts,
2026
+ definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
2027
+ });
2028
+ }
2029
+ updateOptions(opts) {
2030
+ super.updateOptions(opts);
2031
+ }
2032
+ _update(opts) {
2033
+ opts.definitions = Object.assign({}, this.definitions, opts.definitions);
2034
+ super._update(opts);
2035
+ this._rebuildMask();
2036
+ }
2037
+ _rebuildMask() {
2038
+ const defs = this.definitions;
2039
+ this._blocks = [];
2040
+ this.exposeBlock = undefined;
2041
+ this._stops = [];
2042
+ this._maskedBlocks = {};
2043
+ const pattern = this.mask;
2044
+ if (!pattern || !defs) return;
2045
+ let unmaskingBlock = false;
2046
+ let optionalBlock = false;
2047
+ for (let i = 0; i < pattern.length; ++i) {
2048
+ if (this.blocks) {
2049
+ const p = pattern.slice(i);
2050
+ const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
2051
+ // order by key length
2052
+ bNames.sort((a, b) => b.length - a.length);
2053
+ // use block name with max length
2054
+ const bName = bNames[0];
2055
+ if (bName) {
2056
+ const {
2057
+ expose,
2058
+ repeat,
2059
+ ...bOpts
2060
+ } = normalizeOpts(this.blocks[bName]); // TODO type Opts<Arg & Extra>
2061
+ const blockOpts = {
2062
+ lazy: this.lazy,
2063
+ eager: this.eager,
2064
+ placeholderChar: this.placeholderChar,
2065
+ displayChar: this.displayChar,
2066
+ overwrite: this.overwrite,
2067
+ autofix: this.autofix,
2068
+ ...bOpts,
2069
+ repeat,
2070
+ parent: this
2071
+ };
2072
+ const maskedBlock = repeat != null ? new IMask.RepeatBlock(blockOpts /* TODO */) : createMask(blockOpts);
2073
+ if (maskedBlock) {
2074
+ this._blocks.push(maskedBlock);
2075
+ if (expose) this.exposeBlock = maskedBlock;
2076
+
2077
+ // store block index
2078
+ if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
2079
+ this._maskedBlocks[bName].push(this._blocks.length - 1);
2080
+ }
2081
+ i += bName.length - 1;
2082
+ continue;
2083
+ }
2084
+ }
2085
+ let char = pattern[i];
2086
+ let isInput = (char in defs);
2087
+ if (char === MaskedPattern.STOP_CHAR) {
2088
+ this._stops.push(this._blocks.length);
2089
+ continue;
2090
+ }
2091
+ if (char === '{' || char === '}') {
2092
+ unmaskingBlock = !unmaskingBlock;
2093
+ continue;
2094
+ }
2095
+ if (char === '[' || char === ']') {
2096
+ optionalBlock = !optionalBlock;
2097
+ continue;
2098
+ }
2099
+ if (char === MaskedPattern.ESCAPE_CHAR) {
2100
+ ++i;
2101
+ char = pattern[i];
2102
+ if (!char) break;
2103
+ isInput = false;
2104
+ }
2105
+ const def = isInput ? new PatternInputDefinition({
2106
+ isOptional: optionalBlock,
2107
+ lazy: this.lazy,
2108
+ eager: this.eager,
2109
+ placeholderChar: this.placeholderChar,
2110
+ displayChar: this.displayChar,
2111
+ ...normalizeOpts(defs[char]),
2112
+ parent: this
2113
+ }) : new PatternFixedDefinition({
2114
+ char,
2115
+ eager: this.eager,
2116
+ isUnmasking: unmaskingBlock
2117
+ });
2118
+ this._blocks.push(def);
2119
+ }
2120
+ }
2121
+ get state() {
2122
+ return {
2123
+ ...super.state,
2124
+ _blocks: this._blocks.map(b => b.state)
2125
+ };
2126
+ }
2127
+ set state(state) {
2128
+ if (!state) {
2129
+ this.reset();
2130
+ return;
2131
+ }
2132
+ const {
2133
+ _blocks,
2134
+ ...maskedState
2135
+ } = state;
2136
+ this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
2137
+ super.state = maskedState;
2138
+ }
2139
+ reset() {
2140
+ super.reset();
2141
+ this._blocks.forEach(b => b.reset());
2142
+ }
2143
+ get isComplete() {
2144
+ return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every(b => b.isComplete);
2145
+ }
2146
+ get isFilled() {
2147
+ return this._blocks.every(b => b.isFilled);
2148
+ }
2149
+ get isFixed() {
2150
+ return this._blocks.every(b => b.isFixed);
2151
+ }
2152
+ get isOptional() {
2153
+ return this._blocks.every(b => b.isOptional);
2154
+ }
2155
+ doCommit() {
2156
+ this._blocks.forEach(b => b.doCommit());
2157
+ super.doCommit();
2158
+ }
2159
+ get unmaskedValue() {
2160
+ return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
2161
+ }
2162
+ set unmaskedValue(unmaskedValue) {
2163
+ if (this.exposeBlock) {
2164
+ const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
2165
+ this.exposeBlock.unmaskedValue = unmaskedValue;
2166
+ this.appendTail(tail);
2167
+ this.doCommit();
2168
+ } else super.unmaskedValue = unmaskedValue;
2169
+ }
2170
+ get value() {
2171
+ return this.exposeBlock ? this.exposeBlock.value :
2172
+ // TODO return _value when not in change?
2173
+ this._blocks.reduce((str, b) => str += b.value, '');
2174
+ }
2175
+ set value(value) {
2176
+ if (this.exposeBlock) {
2177
+ const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
2178
+ this.exposeBlock.value = value;
2179
+ this.appendTail(tail);
2180
+ this.doCommit();
2181
+ } else super.value = value;
2182
+ }
2183
+ get typedValue() {
2184
+ return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
2185
+ }
2186
+ set typedValue(value) {
2187
+ if (this.exposeBlock) {
2188
+ const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
2189
+ this.exposeBlock.typedValue = value;
2190
+ this.appendTail(tail);
2191
+ this.doCommit();
2192
+ } else super.typedValue = value;
2193
+ }
2194
+ get displayValue() {
2195
+ return this._blocks.reduce((str, b) => str += b.displayValue, '');
2196
+ }
2197
+ appendTail(tail) {
2198
+ return super.appendTail(tail).aggregate(this._appendPlaceholder());
2199
+ }
2200
+ _appendEager() {
2201
+ var _this$_mapPosToBlock;
2202
+ const details = new ChangeDetails();
2203
+ let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
2204
+ if (startBlockIndex == null) return details;
2205
+
2206
+ // TODO test if it works for nested pattern masks
2207
+ if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
2208
+ for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
2209
+ const d = this._blocks[bi]._appendEager();
2210
+ if (!d.inserted) break;
2211
+ details.aggregate(d);
2212
+ }
2213
+ return details;
2214
+ }
2215
+ _appendCharRaw(ch, flags) {
2216
+ if (flags === void 0) {
2217
+ flags = {};
2218
+ }
2219
+ const blockIter = this._mapPosToBlock(this.displayValue.length);
2220
+ const details = new ChangeDetails();
2221
+ if (!blockIter) return details;
2222
+ for (let bi = blockIter.index, block; block = this._blocks[bi]; ++bi) {
2223
+ var _flags$_beforeTailSta;
2224
+ const blockDetails = block._appendChar(ch, {
2225
+ ...flags,
2226
+ _beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
2227
+ });
2228
+ details.aggregate(blockDetails);
2229
+ if (blockDetails.consumed) break; // go next char
2230
+ }
2231
+ return details;
2232
+ }
2233
+ extractTail(fromPos, toPos) {
2234
+ if (fromPos === void 0) {
2235
+ fromPos = 0;
2236
+ }
2237
+ if (toPos === void 0) {
2238
+ toPos = this.displayValue.length;
2239
+ }
2240
+ const chunkTail = new ChunksTailDetails();
2241
+ if (fromPos === toPos) return chunkTail;
2242
+ this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
2243
+ const blockChunk = b.extractTail(bFromPos, bToPos);
2244
+ blockChunk.stop = this._findStopBefore(bi);
2245
+ blockChunk.from = this._blockStartPos(bi);
2246
+ if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
2247
+ chunkTail.extend(blockChunk);
2248
+ });
2249
+ return chunkTail;
2250
+ }
2251
+ extractInput(fromPos, toPos, flags) {
2252
+ if (fromPos === void 0) {
2253
+ fromPos = 0;
2254
+ }
2255
+ if (toPos === void 0) {
2256
+ toPos = this.displayValue.length;
2257
+ }
2258
+ if (flags === void 0) {
2259
+ flags = {};
2260
+ }
2261
+ if (fromPos === toPos) return '';
2262
+ let input = '';
2263
+ this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
2264
+ input += b.extractInput(fromPos, toPos, flags);
2265
+ });
2266
+ return input;
2267
+ }
2268
+ _findStopBefore(blockIndex) {
2269
+ let stopBefore;
2270
+ for (let si = 0; si < this._stops.length; ++si) {
2271
+ const stop = this._stops[si];
2272
+ if (stop <= blockIndex) stopBefore = stop;else break;
2273
+ }
2274
+ return stopBefore;
2275
+ }
2276
+
2277
+ /** Appends placeholder depending on laziness */
2278
+ _appendPlaceholder(toBlockIndex) {
2279
+ const details = new ChangeDetails();
2280
+ if (this.lazy && toBlockIndex == null) return details;
2281
+ const startBlockIter = this._mapPosToBlock(this.displayValue.length);
2282
+ if (!startBlockIter) return details;
2283
+ const startBlockIndex = startBlockIter.index;
2284
+ const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
2285
+ this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
2286
+ if (!b.lazy || toBlockIndex != null) {
2287
+ var _blocks2;
2288
+ details.aggregate(b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length));
2289
+ }
2290
+ });
2291
+ return details;
2292
+ }
2293
+
2294
+ /** Finds block in pos */
2295
+ _mapPosToBlock(pos) {
2296
+ let accVal = '';
2297
+ for (let bi = 0; bi < this._blocks.length; ++bi) {
2298
+ const block = this._blocks[bi];
2299
+ const blockStartPos = accVal.length;
2300
+ accVal += block.displayValue;
2301
+ if (pos <= accVal.length) {
2302
+ return {
2303
+ index: bi,
2304
+ offset: pos - blockStartPos
2305
+ };
2306
+ }
2307
+ }
2308
+ }
2309
+ _blockStartPos(blockIndex) {
2310
+ return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.displayValue.length, 0);
2311
+ }
2312
+ _forEachBlocksInRange(fromPos, toPos, fn) {
2313
+ if (toPos === void 0) {
2314
+ toPos = this.displayValue.length;
2315
+ }
2316
+ const fromBlockIter = this._mapPosToBlock(fromPos);
2317
+ if (fromBlockIter) {
2318
+ const toBlockIter = this._mapPosToBlock(toPos);
2319
+ // process first block
2320
+ const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
2321
+ const fromBlockStartPos = fromBlockIter.offset;
2322
+ const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].displayValue.length;
2323
+ fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
2324
+ if (toBlockIter && !isSameBlock) {
2325
+ // process intermediate blocks
2326
+ for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
2327
+ fn(this._blocks[bi], bi, 0, this._blocks[bi].displayValue.length);
2328
+ }
2329
+
2330
+ // process last block
2331
+ fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
2332
+ }
2333
+ }
2334
+ }
2335
+ remove(fromPos, toPos) {
2336
+ if (fromPos === void 0) {
2337
+ fromPos = 0;
2338
+ }
2339
+ if (toPos === void 0) {
2340
+ toPos = this.displayValue.length;
2341
+ }
2342
+ const removeDetails = super.remove(fromPos, toPos);
2343
+ this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
2344
+ removeDetails.aggregate(b.remove(bFromPos, bToPos));
2345
+ });
2346
+ return removeDetails;
2347
+ }
2348
+ nearestInputPos(cursorPos, direction) {
2349
+ if (direction === void 0) {
2350
+ direction = DIRECTION.NONE;
2351
+ }
2352
+ if (!this._blocks.length) return 0;
2353
+ const cursor = new PatternCursor(this, cursorPos);
2354
+ if (direction === DIRECTION.NONE) {
2355
+ // -------------------------------------------------
2356
+ // NONE should only go out from fixed to the right!
2357
+ // -------------------------------------------------
2358
+ if (cursor.pushRightBeforeInput()) return cursor.pos;
2359
+ cursor.popState();
2360
+ if (cursor.pushLeftBeforeInput()) return cursor.pos;
2361
+ return this.displayValue.length;
2362
+ }
2363
+
2364
+ // FORCE is only about a|* otherwise is 0
2365
+ if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
2366
+ // try to break fast when *|a
2367
+ if (direction === DIRECTION.LEFT) {
2368
+ cursor.pushRightBeforeFilled();
2369
+ if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
2370
+ cursor.popState();
2371
+ }
2372
+
2373
+ // forward flow
2374
+ cursor.pushLeftBeforeInput();
2375
+ cursor.pushLeftBeforeRequired();
2376
+ cursor.pushLeftBeforeFilled();
2377
+
2378
+ // backward flow
2379
+ if (direction === DIRECTION.LEFT) {
2380
+ cursor.pushRightBeforeInput();
2381
+ cursor.pushRightBeforeRequired();
2382
+ if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
2383
+ cursor.popState();
2384
+ if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
2385
+ cursor.popState();
2386
+ }
2387
+ if (cursor.ok) return cursor.pos;
2388
+ if (direction === DIRECTION.FORCE_LEFT) return 0;
2389
+ cursor.popState();
2390
+ if (cursor.ok) return cursor.pos;
2391
+ cursor.popState();
2392
+ if (cursor.ok) return cursor.pos;
2393
+ return 0;
2394
+ }
2395
+ if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
2396
+ // forward flow
2397
+ cursor.pushRightBeforeInput();
2398
+ cursor.pushRightBeforeRequired();
2399
+ if (cursor.pushRightBeforeFilled()) return cursor.pos;
2400
+ if (direction === DIRECTION.FORCE_RIGHT) return this.displayValue.length;
2401
+
2402
+ // backward flow
2403
+ cursor.popState();
2404
+ if (cursor.ok) return cursor.pos;
2405
+ cursor.popState();
2406
+ if (cursor.ok) return cursor.pos;
2407
+ return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
2408
+ }
2409
+ return cursorPos;
2410
+ }
2411
+ totalInputPositions(fromPos, toPos) {
2412
+ if (fromPos === void 0) {
2413
+ fromPos = 0;
2414
+ }
2415
+ if (toPos === void 0) {
2416
+ toPos = this.displayValue.length;
2417
+ }
2418
+ let total = 0;
2419
+ this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
2420
+ total += b.totalInputPositions(bFromPos, bToPos);
2421
+ });
2422
+ return total;
2423
+ }
2424
+
2425
+ /** Get block by name */
2426
+ maskedBlock(name) {
2427
+ return this.maskedBlocks(name)[0];
2428
+ }
2429
+
2430
+ /** Get all blocks by name */
2431
+ maskedBlocks(name) {
2432
+ const indices = this._maskedBlocks[name];
2433
+ if (!indices) return [];
2434
+ return indices.map(gi => this._blocks[gi]);
2435
+ }
2436
+ pad(flags) {
2437
+ const details = new ChangeDetails();
2438
+ this._forEachBlocksInRange(0, this.displayValue.length, b => details.aggregate(b.pad(flags)));
2439
+ return details;
2440
+ }
2441
+ }
2442
+ MaskedPattern.DEFAULTS = {
2443
+ ...Masked.DEFAULTS,
2444
+ lazy: true,
2445
+ placeholderChar: '_'
2446
+ };
2447
+ MaskedPattern.STOP_CHAR = '`';
2448
+ MaskedPattern.ESCAPE_CHAR = '\\';
2449
+ MaskedPattern.InputDefinition = PatternInputDefinition;
2450
+ MaskedPattern.FixedDefinition = PatternFixedDefinition;
2451
+ IMask.MaskedPattern = MaskedPattern;
2452
+
2453
+ /** Pattern which accepts ranges */
2454
+ class MaskedRange extends MaskedPattern {
2455
+ /**
2456
+ Optionally sets max length of pattern.
2457
+ Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
2458
+ */
2459
+
2460
+ /** Min bound */
2461
+
2462
+ /** Max bound */
2463
+
2464
+ get _matchFrom() {
2465
+ return this.maxLength - String(this.from).length;
2466
+ }
2467
+ constructor(opts) {
2468
+ super(opts); // mask will be created in _update
2469
+ }
2470
+ updateOptions(opts) {
2471
+ super.updateOptions(opts);
2472
+ }
2473
+ _update(opts) {
2474
+ const {
2475
+ to = this.to || 0,
2476
+ from = this.from || 0,
2477
+ maxLength = this.maxLength || 0,
2478
+ autofix = this.autofix,
2479
+ ...patternOpts
2480
+ } = opts;
2481
+ this.to = to;
2482
+ this.from = from;
2483
+ this.maxLength = Math.max(String(to).length, maxLength);
2484
+ this.autofix = autofix;
2485
+ const fromStr = String(this.from).padStart(this.maxLength, '0');
2486
+ const toStr = String(this.to).padStart(this.maxLength, '0');
2487
+ let sameCharsCount = 0;
2488
+ while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
2489
+ patternOpts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(this.maxLength - sameCharsCount);
2490
+ super._update(patternOpts);
2491
+ }
2492
+ get isComplete() {
2493
+ return super.isComplete && Boolean(this.value);
2494
+ }
2495
+ boundaries(str) {
2496
+ let minstr = '';
2497
+ let maxstr = '';
2498
+ const [, placeholder, num] = str.match(/^(\D*)(\d*)(\D*)/) || [];
2499
+ if (num) {
2500
+ minstr = '0'.repeat(placeholder.length) + num;
2501
+ maxstr = '9'.repeat(placeholder.length) + num;
2502
+ }
2503
+ minstr = minstr.padEnd(this.maxLength, '0');
2504
+ maxstr = maxstr.padEnd(this.maxLength, '9');
2505
+ return [minstr, maxstr];
2506
+ }
2507
+ doPrepareChar(ch, flags) {
2508
+ if (flags === void 0) {
2509
+ flags = {};
2510
+ }
2511
+ let details;
2512
+ [ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
2513
+ if (!ch) details.skip = !this.isComplete;
2514
+ return [ch, details];
2515
+ }
2516
+ _appendCharRaw(ch, flags) {
2517
+ if (flags === void 0) {
2518
+ flags = {};
2519
+ }
2520
+ if (!this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(ch, flags);
2521
+ const fromStr = String(this.from).padStart(this.maxLength, '0');
2522
+ const toStr = String(this.to).padStart(this.maxLength, '0');
2523
+ const [minstr, maxstr] = this.boundaries(this.value + ch);
2524
+ if (Number(maxstr) < this.from) return super._appendCharRaw(fromStr[this.value.length], flags);
2525
+ if (Number(minstr) > this.to) {
2526
+ if (!flags.tail && this.autofix === 'pad' && this.value.length + 1 < this.maxLength) {
2527
+ return super._appendCharRaw(fromStr[this.value.length], flags).aggregate(this._appendCharRaw(ch, flags));
2528
+ }
2529
+ return super._appendCharRaw(toStr[this.value.length], flags);
2530
+ }
2531
+ return super._appendCharRaw(ch, flags);
2532
+ }
2533
+ doValidate(flags) {
2534
+ const str = this.value;
2535
+ const firstNonZero = str.search(/[^0]/);
2536
+ if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
2537
+ const [minstr, maxstr] = this.boundaries(str);
2538
+ return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
2539
+ }
2540
+ pad(flags) {
2541
+ const details = new ChangeDetails();
2542
+ if (this.value.length === this.maxLength) return details;
2543
+ const value = this.value;
2544
+ const padLength = this.maxLength - this.value.length;
2545
+ if (padLength) {
2546
+ this.reset();
2547
+ for (let i = 0; i < padLength; ++i) {
2548
+ details.aggregate(super._appendCharRaw('0', flags));
2549
+ }
2550
+
2551
+ // append tail
2552
+ value.split('').forEach(ch => this._appendCharRaw(ch));
2553
+ }
2554
+ return details;
2555
+ }
2556
+ }
2557
+ IMask.MaskedRange = MaskedRange;
2558
+
2559
+ const DefaultPattern = 'd{.}`m{.}`Y';
2560
+
2561
+ // Make format and parse required when pattern is provided
2562
+
2563
+ /** Date mask */
2564
+ class MaskedDate extends MaskedPattern {
2565
+ static extractPatternOptions(opts) {
2566
+ const {
2567
+ mask,
2568
+ pattern,
2569
+ ...patternOpts
2570
+ } = opts;
2571
+ return {
2572
+ ...patternOpts,
2573
+ mask: isString(mask) ? mask : pattern
2574
+ };
2575
+ }
2576
+
2577
+ /** Pattern mask for date according to {@link MaskedDate#format} */
2578
+
2579
+ /** Start date */
2580
+
2581
+ /** End date */
2582
+
2583
+ /** Format typed value to string */
2584
+
2585
+ /** Parse string to get typed value */
2586
+
2587
+ constructor(opts) {
2588
+ super(MaskedDate.extractPatternOptions({
2589
+ ...MaskedDate.DEFAULTS,
2590
+ ...opts
2591
+ }));
2592
+ }
2593
+ updateOptions(opts) {
2594
+ super.updateOptions(opts);
2595
+ }
2596
+ _update(opts) {
2597
+ const {
2598
+ mask,
2599
+ pattern,
2600
+ blocks,
2601
+ ...patternOpts
2602
+ } = {
2603
+ ...MaskedDate.DEFAULTS,
2604
+ ...opts
2605
+ };
2606
+ const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
2607
+ // adjust year block
2608
+ if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();
2609
+ if (opts.max) patternBlocks.Y.to = opts.max.getFullYear();
2610
+ if (opts.min && opts.max && patternBlocks.Y.from === patternBlocks.Y.to) {
2611
+ patternBlocks.m.from = opts.min.getMonth() + 1;
2612
+ patternBlocks.m.to = opts.max.getMonth() + 1;
2613
+ if (patternBlocks.m.from === patternBlocks.m.to) {
2614
+ patternBlocks.d.from = opts.min.getDate();
2615
+ patternBlocks.d.to = opts.max.getDate();
2616
+ }
2617
+ }
2618
+ Object.assign(patternBlocks, this.blocks, blocks);
2619
+ super._update({
2620
+ ...patternOpts,
2621
+ mask: isString(mask) ? mask : pattern,
2622
+ blocks: patternBlocks
2623
+ });
2624
+ }
2625
+ doValidate(flags) {
2626
+ const date = this.date;
2627
+ return super.doValidate(flags) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
2628
+ }
2629
+
2630
+ /** Checks if date is exists */
2631
+ isDateExist(str) {
2632
+ return this.format(this.parse(str, this), this).indexOf(str) >= 0;
2633
+ }
2634
+
2635
+ /** Parsed Date */
2636
+ get date() {
2637
+ return this.typedValue;
2638
+ }
2639
+ set date(date) {
2640
+ this.typedValue = date;
2641
+ }
2642
+ get typedValue() {
2643
+ return this.isComplete ? super.typedValue : null;
2644
+ }
2645
+ set typedValue(value) {
2646
+ super.typedValue = value;
2647
+ }
2648
+ maskEquals(mask) {
2649
+ return mask === Date || super.maskEquals(mask);
2650
+ }
2651
+ optionsIsChanged(opts) {
2652
+ return super.optionsIsChanged(MaskedDate.extractPatternOptions(opts));
2653
+ }
2654
+ }
2655
+ MaskedDate.GET_DEFAULT_BLOCKS = () => ({
2656
+ d: {
2657
+ mask: MaskedRange,
2658
+ from: 1,
2659
+ to: 31,
2660
+ maxLength: 2
2661
+ },
2662
+ m: {
2663
+ mask: MaskedRange,
2664
+ from: 1,
2665
+ to: 12,
2666
+ maxLength: 2
2667
+ },
2668
+ Y: {
2669
+ mask: MaskedRange,
2670
+ from: 1900,
2671
+ to: 9999
2672
+ }
2673
+ });
2674
+ MaskedDate.DEFAULTS = {
2675
+ ...MaskedPattern.DEFAULTS,
2676
+ mask: Date,
2677
+ pattern: DefaultPattern,
2678
+ format: (date, masked) => {
2679
+ if (!date) return '';
2680
+ const day = String(date.getDate()).padStart(2, '0');
2681
+ const month = String(date.getMonth() + 1).padStart(2, '0');
2682
+ const year = date.getFullYear();
2683
+ return [day, month, year].join('.');
2684
+ },
2685
+ parse: (str, masked) => {
2686
+ const [day, month, year] = str.split('.').map(Number);
2687
+ return new Date(year, month - 1, day);
2688
+ }
2689
+ };
2690
+ IMask.MaskedDate = MaskedDate;
2691
+
2692
+ /** Dynamic mask for choosing appropriate mask in run-time */
2693
+ class MaskedDynamic extends Masked {
2694
+ constructor(opts) {
2695
+ super({
2696
+ ...MaskedDynamic.DEFAULTS,
2697
+ ...opts
2698
+ });
2699
+ this.currentMask = undefined;
2700
+ }
2701
+ updateOptions(opts) {
2702
+ super.updateOptions(opts);
2703
+ }
2704
+ _update(opts) {
2705
+ super._update(opts);
2706
+ if ('mask' in opts) {
2707
+ this.exposeMask = undefined;
2708
+ // mask could be totally dynamic with only `dispatch` option
2709
+ this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => {
2710
+ const {
2711
+ expose,
2712
+ ...maskOpts
2713
+ } = normalizeOpts(m);
2714
+ const masked = createMask({
2715
+ overwrite: this._overwrite,
2716
+ eager: this._eager,
2717
+ skipInvalid: this._skipInvalid,
2718
+ ...maskOpts
2719
+ });
2720
+ if (expose) this.exposeMask = masked;
2721
+ return masked;
2722
+ }) : [];
2723
+
2724
+ // this.currentMask = this.doDispatch(''); // probably not needed but lets see
2725
+ }
2726
+ }
2727
+ _appendCharRaw(ch, flags) {
2728
+ if (flags === void 0) {
2729
+ flags = {};
2730
+ }
2731
+ const details = this._applyDispatch(ch, flags);
2732
+ if (this.currentMask) {
2733
+ details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
2734
+ }
2735
+ return details;
2736
+ }
2737
+ _applyDispatch(appended, flags, tail) {
2738
+ if (appended === void 0) {
2739
+ appended = '';
2740
+ }
2741
+ if (flags === void 0) {
2742
+ flags = {};
2743
+ }
2744
+ if (tail === void 0) {
2745
+ tail = '';
2746
+ }
2747
+ const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
2748
+ const inputValue = this.rawInputValue;
2749
+ const insertValue = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._rawInputValue : inputValue;
2750
+ const tailValue = inputValue.slice(insertValue.length);
2751
+ const prevMask = this.currentMask;
2752
+ const details = new ChangeDetails();
2753
+ const prevMaskState = prevMask == null ? void 0 : prevMask.state;
2754
+
2755
+ // clone flags to prevent overwriting `_beforeTailState`
2756
+ this.currentMask = this.doDispatch(appended, {
2757
+ ...flags
2758
+ }, tail);
2759
+
2760
+ // restore state after dispatch
2761
+ if (this.currentMask) {
2762
+ if (this.currentMask !== prevMask) {
2763
+ // if mask changed reapply input
2764
+ this.currentMask.reset();
2765
+ if (insertValue) {
2766
+ this.currentMask.append(insertValue, {
2767
+ raw: true
2768
+ });
2769
+ details.tailShift = this.currentMask.value.length - prevValueBeforeTail.length;
2770
+ }
2771
+ if (tailValue) {
2772
+ details.tailShift += this.currentMask.append(tailValue, {
2773
+ raw: true,
2774
+ tail: true
2775
+ }).tailShift;
2776
+ }
2777
+ } else if (prevMaskState) {
2778
+ // Dispatch can do something bad with state, so
2779
+ // restore prev mask state
2780
+ this.currentMask.state = prevMaskState;
2781
+ }
2782
+ }
2783
+ return details;
2784
+ }
2785
+ _appendPlaceholder() {
2786
+ const details = this._applyDispatch();
2787
+ if (this.currentMask) {
2788
+ details.aggregate(this.currentMask._appendPlaceholder());
2789
+ }
2790
+ return details;
2791
+ }
2792
+ _appendEager() {
2793
+ const details = this._applyDispatch();
2794
+ if (this.currentMask) {
2795
+ details.aggregate(this.currentMask._appendEager());
2796
+ }
2797
+ return details;
2798
+ }
2799
+ appendTail(tail) {
2800
+ const details = new ChangeDetails();
2801
+ if (tail) details.aggregate(this._applyDispatch('', {}, tail));
2802
+ return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
2803
+ }
2804
+ currentMaskFlags(flags) {
2805
+ var _flags$_beforeTailSta, _flags$_beforeTailSta2;
2806
+ return {
2807
+ ...flags,
2808
+ _beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
2809
+ };
2810
+ }
2811
+ doDispatch(appended, flags, tail) {
2812
+ if (flags === void 0) {
2813
+ flags = {};
2814
+ }
2815
+ if (tail === void 0) {
2816
+ tail = '';
2817
+ }
2818
+ return this.dispatch(appended, this, flags, tail);
2819
+ }
2820
+ doValidate(flags) {
2821
+ return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
2822
+ }
2823
+ doPrepare(str, flags) {
2824
+ if (flags === void 0) {
2825
+ flags = {};
2826
+ }
2827
+ let [s, details] = super.doPrepare(str, flags);
2828
+ if (this.currentMask) {
2829
+ let currentDetails;
2830
+ [s, currentDetails] = super.doPrepare(s, this.currentMaskFlags(flags));
2831
+ details = details.aggregate(currentDetails);
2832
+ }
2833
+ return [s, details];
2834
+ }
2835
+ doPrepareChar(str, flags) {
2836
+ if (flags === void 0) {
2837
+ flags = {};
2838
+ }
2839
+ let [s, details] = super.doPrepareChar(str, flags);
2840
+ if (this.currentMask) {
2841
+ let currentDetails;
2842
+ [s, currentDetails] = super.doPrepareChar(s, this.currentMaskFlags(flags));
2843
+ details = details.aggregate(currentDetails);
2844
+ }
2845
+ return [s, details];
2846
+ }
2847
+ reset() {
2848
+ var _this$currentMask;
2849
+ (_this$currentMask = this.currentMask) == null || _this$currentMask.reset();
2850
+ this.compiledMasks.forEach(m => m.reset());
2851
+ }
2852
+ get value() {
2853
+ return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : '';
2854
+ }
2855
+ set value(value) {
2856
+ if (this.exposeMask) {
2857
+ this.exposeMask.value = value;
2858
+ this.currentMask = this.exposeMask;
2859
+ this._applyDispatch();
2860
+ } else super.value = value;
2861
+ }
2862
+ get unmaskedValue() {
2863
+ return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : '';
2864
+ }
2865
+ set unmaskedValue(unmaskedValue) {
2866
+ if (this.exposeMask) {
2867
+ this.exposeMask.unmaskedValue = unmaskedValue;
2868
+ this.currentMask = this.exposeMask;
2869
+ this._applyDispatch();
2870
+ } else super.unmaskedValue = unmaskedValue;
2871
+ }
2872
+ get typedValue() {
2873
+ return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : '';
2874
+ }
2875
+ set typedValue(typedValue) {
2876
+ if (this.exposeMask) {
2877
+ this.exposeMask.typedValue = typedValue;
2878
+ this.currentMask = this.exposeMask;
2879
+ this._applyDispatch();
2880
+ return;
2881
+ }
2882
+ let unmaskedValue = String(typedValue);
2883
+
2884
+ // double check it
2885
+ if (this.currentMask) {
2886
+ this.currentMask.typedValue = typedValue;
2887
+ unmaskedValue = this.currentMask.unmaskedValue;
2888
+ }
2889
+ this.unmaskedValue = unmaskedValue;
2890
+ }
2891
+ get displayValue() {
2892
+ return this.currentMask ? this.currentMask.displayValue : '';
2893
+ }
2894
+ get isComplete() {
2895
+ var _this$currentMask2;
2896
+ return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
2897
+ }
2898
+ get isFilled() {
2899
+ var _this$currentMask3;
2900
+ return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
2901
+ }
2902
+ remove(fromPos, toPos) {
2903
+ const details = new ChangeDetails();
2904
+ if (this.currentMask) {
2905
+ details.aggregate(this.currentMask.remove(fromPos, toPos))
2906
+ // update with dispatch
2907
+ .aggregate(this._applyDispatch());
2908
+ }
2909
+ return details;
2910
+ }
2911
+ get state() {
2912
+ var _this$currentMask4;
2913
+ return {
2914
+ ...super.state,
2915
+ _rawInputValue: this.rawInputValue,
2916
+ compiledMasks: this.compiledMasks.map(m => m.state),
2917
+ currentMaskRef: this.currentMask,
2918
+ currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
2919
+ };
2920
+ }
2921
+ set state(state) {
2922
+ const {
2923
+ compiledMasks,
2924
+ currentMaskRef,
2925
+ currentMask,
2926
+ ...maskedState
2927
+ } = state;
2928
+ if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
2929
+ if (currentMaskRef != null) {
2930
+ this.currentMask = currentMaskRef;
2931
+ this.currentMask.state = currentMask;
2932
+ }
2933
+ super.state = maskedState;
2934
+ }
2935
+ extractInput(fromPos, toPos, flags) {
2936
+ return this.currentMask ? this.currentMask.extractInput(fromPos, toPos, flags) : '';
2937
+ }
2938
+ extractTail(fromPos, toPos) {
2939
+ return this.currentMask ? this.currentMask.extractTail(fromPos, toPos) : super.extractTail(fromPos, toPos);
2940
+ }
2941
+ doCommit() {
2942
+ if (this.currentMask) this.currentMask.doCommit();
2943
+ super.doCommit();
2944
+ }
2945
+ nearestInputPos(cursorPos, direction) {
2946
+ return this.currentMask ? this.currentMask.nearestInputPos(cursorPos, direction) : super.nearestInputPos(cursorPos, direction);
2947
+ }
2948
+ get overwrite() {
2949
+ return this.currentMask ? this.currentMask.overwrite : this._overwrite;
2950
+ }
2951
+ set overwrite(overwrite) {
2952
+ this._overwrite = overwrite;
2953
+ }
2954
+ get eager() {
2955
+ return this.currentMask ? this.currentMask.eager : this._eager;
2956
+ }
2957
+ set eager(eager) {
2958
+ this._eager = eager;
2959
+ }
2960
+ get skipInvalid() {
2961
+ return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
2962
+ }
2963
+ set skipInvalid(skipInvalid) {
2964
+ this._skipInvalid = skipInvalid;
2965
+ }
2966
+ get autofix() {
2967
+ return this.currentMask ? this.currentMask.autofix : this._autofix;
2968
+ }
2969
+ set autofix(autofix) {
2970
+ this._autofix = autofix;
2971
+ }
2972
+ maskEquals(mask) {
2973
+ return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
2974
+ if (!mask[mi]) return;
2975
+ const {
2976
+ mask: oldMask,
2977
+ ...restOpts
2978
+ } = mask[mi];
2979
+ return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
2980
+ }) : super.maskEquals(mask);
2981
+ }
2982
+ typedValueEquals(value) {
2983
+ var _this$currentMask5;
2984
+ return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
2985
+ }
2986
+ }
2987
+ /** Currently chosen mask */
2988
+ /** Currently chosen mask */
2989
+ /** Compliled {@link Masked} options */
2990
+ /** Chooses {@link Masked} depending on input value */
2991
+ MaskedDynamic.DEFAULTS = {
2992
+ ...Masked.DEFAULTS,
2993
+ dispatch: (appended, masked, flags, tail) => {
2994
+ if (!masked.compiledMasks.length) return;
2995
+ const inputValue = masked.rawInputValue;
2996
+
2997
+ // simulate input
2998
+ const inputs = masked.compiledMasks.map((m, index) => {
2999
+ const isCurrent = masked.currentMask === m;
3000
+ const startInputPos = isCurrent ? m.displayValue.length : m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT);
3001
+ if (m.rawInputValue !== inputValue) {
3002
+ m.reset();
3003
+ m.append(inputValue, {
3004
+ raw: true
3005
+ });
3006
+ } else if (!isCurrent) {
3007
+ m.remove(startInputPos);
3008
+ }
3009
+ m.append(appended, masked.currentMaskFlags(flags));
3010
+ m.appendTail(tail);
3011
+ return {
3012
+ index,
3013
+ weight: m.rawInputValue.length,
3014
+ totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT)))
3015
+ };
3016
+ });
3017
+
3018
+ // pop masks with longer values first
3019
+ inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
3020
+ return masked.compiledMasks[inputs[0].index];
3021
+ }
3022
+ };
3023
+ IMask.MaskedDynamic = MaskedDynamic;
3024
+
3025
+ /** Pattern which validates enum values */
3026
+ class MaskedEnum extends MaskedPattern {
3027
+ constructor(opts) {
3028
+ super({
3029
+ ...MaskedEnum.DEFAULTS,
3030
+ ...opts
3031
+ }); // mask will be created in _update
3032
+ }
3033
+ updateOptions(opts) {
3034
+ super.updateOptions(opts);
3035
+ }
3036
+ _update(opts) {
3037
+ const {
3038
+ enum: enum_,
3039
+ ...eopts
3040
+ } = opts;
3041
+ if (enum_) {
3042
+ const lengths = enum_.map(e => e.length);
3043
+ const requiredLength = Math.min(...lengths);
3044
+ const optionalLength = Math.max(...lengths) - requiredLength;
3045
+ eopts.mask = '*'.repeat(requiredLength);
3046
+ if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
3047
+ this.enum = enum_;
3048
+ }
3049
+ super._update(eopts);
3050
+ }
3051
+ _appendCharRaw(ch, flags) {
3052
+ if (flags === void 0) {
3053
+ flags = {};
3054
+ }
3055
+ const matchFrom = Math.min(this.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
3056
+ const matches = this.enum.filter(e => this.matchValue(e, this.unmaskedValue + ch, matchFrom));
3057
+ if (matches.length) {
3058
+ if (matches.length === 1) {
3059
+ this._forEachBlocksInRange(0, this.value.length, (b, bi) => {
3060
+ const mch = matches[0][bi];
3061
+ if (bi >= this.value.length || mch === b.value) return;
3062
+ b.reset();
3063
+ b._appendChar(mch, flags);
3064
+ });
3065
+ }
3066
+ const d = super._appendCharRaw(matches[0][this.value.length], flags);
3067
+ if (matches.length === 1) {
3068
+ matches[0].slice(this.unmaskedValue.length).split('').forEach(mch => d.aggregate(super._appendCharRaw(mch)));
3069
+ }
3070
+ return d;
3071
+ }
3072
+ return new ChangeDetails({
3073
+ skip: !this.isComplete
3074
+ });
3075
+ }
3076
+ extractTail(fromPos, toPos) {
3077
+ if (fromPos === void 0) {
3078
+ fromPos = 0;
3079
+ }
3080
+ // just drop tail
3081
+ return new ContinuousTailDetails('', fromPos);
3082
+ }
3083
+ remove(fromPos, toPos) {
3084
+ if (fromPos === void 0) {
3085
+ fromPos = 0;
3086
+ }
3087
+ if (toPos === void 0) {
3088
+ toPos = this.displayValue.length;
3089
+ }
3090
+ if (fromPos === toPos) return new ChangeDetails();
3091
+ const matchFrom = Math.min(super.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
3092
+ let pos;
3093
+ for (pos = fromPos; pos >= 0; --pos) {
3094
+ const matches = this.enum.filter(e => this.matchValue(e, this.value.slice(matchFrom, pos), matchFrom));
3095
+ if (matches.length > 1) break;
3096
+ }
3097
+ const details = super.remove(pos, toPos);
3098
+ details.tailShift += pos - fromPos;
3099
+ return details;
3100
+ }
3101
+ get isComplete() {
3102
+ return this.enum.indexOf(this.value) >= 0;
3103
+ }
3104
+ }
3105
+ /** Match enum value */
3106
+ MaskedEnum.DEFAULTS = {
3107
+ ...MaskedPattern.DEFAULTS,
3108
+ matchValue: (estr, istr, matchFrom) => estr.indexOf(istr, matchFrom) === matchFrom
3109
+ };
3110
+ IMask.MaskedEnum = MaskedEnum;
3111
+
3112
+ /** Masking by custom Function */
3113
+ class MaskedFunction extends Masked {
3114
+ /** */
3115
+
3116
+ /** Enable characters overwriting */
3117
+
3118
+ /** */
3119
+
3120
+ /** */
3121
+
3122
+ /** */
3123
+
3124
+ updateOptions(opts) {
3125
+ super.updateOptions(opts);
3126
+ }
3127
+ _update(opts) {
3128
+ super._update({
3129
+ ...opts,
3130
+ validate: opts.mask
3131
+ });
3132
+ }
3133
+ }
3134
+ IMask.MaskedFunction = MaskedFunction;
3135
+
3136
+ var _MaskedNumber;
3137
+ /** Number mask */
3138
+ class MaskedNumber extends Masked {
3139
+ /** Single char */
3140
+
3141
+ /** Single char */
3142
+
3143
+ /** Array of single chars */
3144
+
3145
+ /** */
3146
+
3147
+ /** */
3148
+
3149
+ /** Digits after point */
3150
+
3151
+ /** Flag to remove leading and trailing zeros in the end of editing */
3152
+
3153
+ /** Flag to pad trailing zeros after point in the end of editing */
3154
+
3155
+ /** Enable characters overwriting */
3156
+
3157
+ /** */
3158
+
3159
+ /** */
3160
+
3161
+ /** */
3162
+
3163
+ /** Format typed value to string */
3164
+
3165
+ /** Parse string to get typed value */
3166
+
3167
+ constructor(opts) {
3168
+ super({
3169
+ ...MaskedNumber.DEFAULTS,
3170
+ ...opts
3171
+ });
3172
+ }
3173
+ updateOptions(opts) {
3174
+ super.updateOptions(opts);
3175
+ }
3176
+ _update(opts) {
3177
+ super._update(opts);
3178
+ this._updateRegExps();
3179
+ }
3180
+ _updateRegExps() {
3181
+ const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
3182
+ const mid = '\\d*';
3183
+ const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
3184
+ this._numberRegExp = new RegExp(start + mid + end);
3185
+ this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
3186
+ this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
3187
+ }
3188
+ _removeThousandsSeparators(value) {
3189
+ return value.replace(this._thousandsSeparatorRegExp, '');
3190
+ }
3191
+ _insertThousandsSeparators(value) {
3192
+ // https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
3193
+ const parts = value.split(this.radix);
3194
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
3195
+ return parts.join(this.radix);
3196
+ }
3197
+ doPrepareChar(ch, flags) {
3198
+ if (flags === void 0) {
3199
+ flags = {};
3200
+ }
3201
+ const [prepCh, details] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
3202
+ /*
3203
+ radix should be mapped when
3204
+ 1) input is done from keyboard = flags.input && flags.raw
3205
+ 2) unmasked value is set = !flags.input && !flags.raw
3206
+ and should not be mapped when
3207
+ 1) value is set = flags.input && !flags.raw
3208
+ 2) raw value is set = !flags.input && flags.raw
3209
+ */
3210
+ flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch), flags);
3211
+ if (ch && !prepCh) details.skip = true;
3212
+ if (prepCh && !this.allowPositive && !this.value && prepCh !== '-') details.aggregate(this._appendChar('-'));
3213
+ return [prepCh, details];
3214
+ }
3215
+ _separatorsCount(to, extendOnSeparators) {
3216
+ if (extendOnSeparators === void 0) {
3217
+ extendOnSeparators = false;
3218
+ }
3219
+ let count = 0;
3220
+ for (let pos = 0; pos < to; ++pos) {
3221
+ if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
3222
+ ++count;
3223
+ if (extendOnSeparators) to += this.thousandsSeparator.length;
3224
+ }
3225
+ }
3226
+ return count;
3227
+ }
3228
+ _separatorsCountFromSlice(slice) {
3229
+ if (slice === void 0) {
3230
+ slice = this._value;
3231
+ }
3232
+ return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
3233
+ }
3234
+ extractInput(fromPos, toPos, flags) {
3235
+ if (fromPos === void 0) {
3236
+ fromPos = 0;
3237
+ }
3238
+ if (toPos === void 0) {
3239
+ toPos = this.displayValue.length;
3240
+ }
3241
+ [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
3242
+ return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
3243
+ }
3244
+ _appendCharRaw(ch, flags) {
3245
+ if (flags === void 0) {
3246
+ flags = {};
3247
+ }
3248
+ const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
3249
+ const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
3250
+ this._value = this._removeThousandsSeparators(this.value);
3251
+ const oldValue = this._value;
3252
+ this._value += ch;
3253
+ const num = this.number;
3254
+ let accepted = !isNaN(num);
3255
+ let skip = false;
3256
+ if (accepted) {
3257
+ let fixedNum;
3258
+ if (this.min != null && this.min < 0 && this.number < this.min) fixedNum = this.min;
3259
+ if (this.max != null && this.max > 0 && this.number > this.max) fixedNum = this.max;
3260
+ if (fixedNum != null) {
3261
+ if (this.autofix) {
3262
+ this._value = this.format(fixedNum, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
3263
+ skip || (skip = oldValue === this._value && !flags.tail); // if not changed on tail it's still ok to proceed
3264
+ } else {
3265
+ accepted = false;
3266
+ }
3267
+ }
3268
+ accepted && (accepted = Boolean(this._value.match(this._numberRegExp)));
3269
+ }
3270
+ let appendDetails;
3271
+ if (!accepted) {
3272
+ this._value = oldValue;
3273
+ appendDetails = new ChangeDetails();
3274
+ } else {
3275
+ appendDetails = new ChangeDetails({
3276
+ inserted: this._value.slice(oldValue.length),
3277
+ rawInserted: skip ? '' : ch,
3278
+ skip
3279
+ });
3280
+ }
3281
+ this._value = this._insertThousandsSeparators(this._value);
3282
+ const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
3283
+ const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
3284
+ appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
3285
+ return appendDetails;
3286
+ }
3287
+ _findSeparatorAround(pos) {
3288
+ if (this.thousandsSeparator) {
3289
+ const searchFrom = pos - this.thousandsSeparator.length + 1;
3290
+ const separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
3291
+ if (separatorPos <= pos) return separatorPos;
3292
+ }
3293
+ return -1;
3294
+ }
3295
+ _adjustRangeWithSeparators(from, to) {
3296
+ const separatorAroundFromPos = this._findSeparatorAround(from);
3297
+ if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
3298
+ const separatorAroundToPos = this._findSeparatorAround(to);
3299
+ if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
3300
+ return [from, to];
3301
+ }
3302
+ remove(fromPos, toPos) {
3303
+ if (fromPos === void 0) {
3304
+ fromPos = 0;
3305
+ }
3306
+ if (toPos === void 0) {
3307
+ toPos = this.displayValue.length;
3308
+ }
3309
+ [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
3310
+ const valueBeforePos = this.value.slice(0, fromPos);
3311
+ const valueAfterPos = this.value.slice(toPos);
3312
+ const prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
3313
+ this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
3314
+ const beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
3315
+ return new ChangeDetails({
3316
+ tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
3317
+ });
3318
+ }
3319
+ nearestInputPos(cursorPos, direction) {
3320
+ if (!this.thousandsSeparator) return cursorPos;
3321
+ switch (direction) {
3322
+ case DIRECTION.NONE:
3323
+ case DIRECTION.LEFT:
3324
+ case DIRECTION.FORCE_LEFT:
3325
+ {
3326
+ const separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
3327
+ if (separatorAtLeftPos >= 0) {
3328
+ const separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
3329
+ if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
3330
+ return separatorAtLeftPos;
3331
+ }
3332
+ }
3333
+ break;
3334
+ }
3335
+ case DIRECTION.RIGHT:
3336
+ case DIRECTION.FORCE_RIGHT:
3337
+ {
3338
+ const separatorAtRightPos = this._findSeparatorAround(cursorPos);
3339
+ if (separatorAtRightPos >= 0) {
3340
+ return separatorAtRightPos + this.thousandsSeparator.length;
3341
+ }
3342
+ }
3343
+ }
3344
+ return cursorPos;
3345
+ }
3346
+ doCommit() {
3347
+ if (this.value) {
3348
+ const number = this.number;
3349
+ let validnum = number;
3350
+
3351
+ // check bounds
3352
+ if (this.min != null) validnum = Math.max(validnum, this.min);
3353
+ if (this.max != null) validnum = Math.min(validnum, this.max);
3354
+ if (validnum !== number) this.unmaskedValue = this.format(validnum, this);
3355
+ let formatted = this.value;
3356
+ if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
3357
+ if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
3358
+ this._value = formatted;
3359
+ }
3360
+ super.doCommit();
3361
+ }
3362
+ _normalizeZeros(value) {
3363
+ const parts = this._removeThousandsSeparators(value).split(this.radix);
3364
+
3365
+ // remove leading zeros
3366
+ parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, (match, sign, zeros, num) => sign + num);
3367
+ // add leading zero
3368
+ if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
3369
+ if (parts.length > 1) {
3370
+ parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros
3371
+ if (!parts[1].length) parts.length = 1; // remove fractional
3372
+ }
3373
+ return this._insertThousandsSeparators(parts.join(this.radix));
3374
+ }
3375
+ _padFractionalZeros(value) {
3376
+ if (!value) return value;
3377
+ const parts = value.split(this.radix);
3378
+ if (parts.length < 2) parts.push('');
3379
+ parts[1] = parts[1].padEnd(this.scale, '0');
3380
+ return parts.join(this.radix);
3381
+ }
3382
+ doSkipInvalid(ch, flags, checkTail) {
3383
+ if (flags === void 0) {
3384
+ flags = {};
3385
+ }
3386
+ const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
3387
+ return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
3388
+ }
3389
+ get unmaskedValue() {
3390
+ return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, MaskedNumber.UNMASKED_RADIX);
3391
+ }
3392
+ set unmaskedValue(unmaskedValue) {
3393
+ super.unmaskedValue = unmaskedValue;
3394
+ }
3395
+ get typedValue() {
3396
+ return this.parse(this.unmaskedValue, this);
3397
+ }
3398
+ set typedValue(n) {
3399
+ this.rawInputValue = this.format(n, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
3400
+ }
3401
+
3402
+ /** Parsed Number */
3403
+ get number() {
3404
+ return this.typedValue;
3405
+ }
3406
+ set number(number) {
3407
+ this.typedValue = number;
3408
+ }
3409
+ get allowNegative() {
3410
+ return this.min != null && this.min < 0 || this.max != null && this.max < 0;
3411
+ }
3412
+ get allowPositive() {
3413
+ return this.min != null && this.min > 0 || this.max != null && this.max > 0;
3414
+ }
3415
+ typedValueEquals(value) {
3416
+ // handle 0 -> '' case (typed = 0 even if value = '')
3417
+ // for details see https://github.com/uNmAnNeR/imaskjs/issues/134
3418
+ return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
3419
+ }
3420
+ }
3421
+ _MaskedNumber = MaskedNumber;
3422
+ MaskedNumber.UNMASKED_RADIX = '.';
3423
+ MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
3424
+ MaskedNumber.DEFAULTS = {
3425
+ ...Masked.DEFAULTS,
3426
+ mask: Number,
3427
+ radix: ',',
3428
+ thousandsSeparator: '',
3429
+ mapToRadix: [_MaskedNumber.UNMASKED_RADIX],
3430
+ min: Number.MIN_SAFE_INTEGER,
3431
+ max: Number.MAX_SAFE_INTEGER,
3432
+ scale: 2,
3433
+ normalizeZeros: true,
3434
+ padFractionalZeros: false,
3435
+ parse: Number,
3436
+ format: n => n.toLocaleString('en-US', {
3437
+ useGrouping: false,
3438
+ maximumFractionDigits: 20
3439
+ })
3440
+ };
3441
+ IMask.MaskedNumber = MaskedNumber;
3442
+
3443
+ /** Mask pipe source and destination types */
3444
+ const PIPE_TYPE = {
3445
+ MASKED: 'value',
3446
+ UNMASKED: 'unmaskedValue',
3447
+ TYPED: 'typedValue'
3448
+ };
3449
+ /** Creates new pipe function depending on mask type, source and destination options */
3450
+ function createPipe(arg, from, to) {
3451
+ if (from === void 0) {
3452
+ from = PIPE_TYPE.MASKED;
3453
+ }
3454
+ if (to === void 0) {
3455
+ to = PIPE_TYPE.MASKED;
3456
+ }
3457
+ const masked = createMask(arg);
3458
+ return value => masked.runIsolated(m => {
3459
+ m[from] = value;
3460
+ return m[to];
3461
+ });
3462
+ }
3463
+
3464
+ /** Pipes value through mask depending on mask type, source and destination options */
3465
+ function pipe(value, mask, from, to) {
3466
+ return createPipe(mask, from, to)(value);
3467
+ }
3468
+ IMask.PIPE_TYPE = PIPE_TYPE;
3469
+ IMask.createPipe = createPipe;
3470
+ IMask.pipe = pipe;
3471
+
3472
+ /** Pattern mask */
3473
+ class RepeatBlock extends MaskedPattern {
3474
+ get repeatFrom() {
3475
+ var _ref;
3476
+ return (_ref = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === Infinity ? 0 : this.repeat) != null ? _ref : 0;
3477
+ }
3478
+ get repeatTo() {
3479
+ var _ref2;
3480
+ return (_ref2 = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? _ref2 : Infinity;
3481
+ }
3482
+ constructor(opts) {
3483
+ super(opts);
3484
+ }
3485
+ updateOptions(opts) {
3486
+ super.updateOptions(opts);
3487
+ }
3488
+ _update(opts) {
3489
+ var _ref3, _ref4, _this$_blocks;
3490
+ const {
3491
+ repeat,
3492
+ ...blockOpts
3493
+ } = normalizeOpts(opts); // TODO type
3494
+ this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
3495
+ const block = createMask(this._blockOpts);
3496
+ this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity; // TODO type
3497
+
3498
+ super._update({
3499
+ mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
3500
+ blocks: {
3501
+ m: block
3502
+ },
3503
+ eager: block.eager,
3504
+ overwrite: block.overwrite,
3505
+ skipInvalid: block.skipInvalid,
3506
+ lazy: block.lazy,
3507
+ placeholderChar: block.placeholderChar,
3508
+ displayChar: block.displayChar
3509
+ });
3510
+ }
3511
+ _allocateBlock(bi) {
3512
+ if (bi < this._blocks.length) return this._blocks[bi];
3513
+ if (this.repeatTo === Infinity || this._blocks.length < this.repeatTo) {
3514
+ this._blocks.push(createMask(this._blockOpts));
3515
+ this.mask += 'm';
3516
+ return this._blocks[this._blocks.length - 1];
3517
+ }
3518
+ }
3519
+ _appendCharRaw(ch, flags) {
3520
+ if (flags === void 0) {
3521
+ flags = {};
3522
+ }
3523
+ const details = new ChangeDetails();
3524
+ for (let bi = (_this$_mapPosToBlock$ = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index) != null ? _this$_mapPosToBlock$ : Math.max(this._blocks.length - 1, 0), block, allocated;
3525
+ // try to get a block or
3526
+ // try to allocate a new block if not allocated already
3527
+ block = (_this$_blocks$bi = this._blocks[bi]) != null ? _this$_blocks$bi : allocated = !allocated && this._allocateBlock(bi); ++bi) {
3528
+ var _this$_mapPosToBlock$, _this$_mapPosToBlock, _this$_blocks$bi, _flags$_beforeTailSta;
3529
+ const blockDetails = block._appendChar(ch, {
3530
+ ...flags,
3531
+ _beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
3532
+ });
3533
+ if (blockDetails.skip && allocated) {
3534
+ // remove the last allocated block and break
3535
+ this._blocks.pop();
3536
+ this.mask = this.mask.slice(1);
3537
+ break;
3538
+ }
3539
+ details.aggregate(blockDetails);
3540
+ if (blockDetails.consumed) break; // go next char
3541
+ }
3542
+ return details;
3543
+ }
3544
+ _trimEmptyTail(fromPos, toPos) {
3545
+ var _this$_mapPosToBlock2, _this$_mapPosToBlock3;
3546
+ if (fromPos === void 0) {
3547
+ fromPos = 0;
3548
+ }
3549
+ const firstBlockIndex = Math.max(((_this$_mapPosToBlock2 = this._mapPosToBlock(fromPos)) == null ? void 0 : _this$_mapPosToBlock2.index) || 0, this.repeatFrom, 0);
3550
+ let lastBlockIndex;
3551
+ if (toPos != null) lastBlockIndex = (_this$_mapPosToBlock3 = this._mapPosToBlock(toPos)) == null ? void 0 : _this$_mapPosToBlock3.index;
3552
+ if (lastBlockIndex == null) lastBlockIndex = this._blocks.length - 1;
3553
+ let removeCount = 0;
3554
+ for (let blockIndex = lastBlockIndex; firstBlockIndex <= blockIndex; --blockIndex, ++removeCount) {
3555
+ if (this._blocks[blockIndex].unmaskedValue) break;
3556
+ }
3557
+ if (removeCount) {
3558
+ this._blocks.splice(lastBlockIndex - removeCount + 1, removeCount);
3559
+ this.mask = this.mask.slice(removeCount);
3560
+ }
3561
+ }
3562
+ reset() {
3563
+ super.reset();
3564
+ this._trimEmptyTail();
3565
+ }
3566
+ remove(fromPos, toPos) {
3567
+ if (fromPos === void 0) {
3568
+ fromPos = 0;
3569
+ }
3570
+ if (toPos === void 0) {
3571
+ toPos = this.displayValue.length;
3572
+ }
3573
+ const removeDetails = super.remove(fromPos, toPos);
3574
+ this._trimEmptyTail(fromPos, toPos);
3575
+ return removeDetails;
3576
+ }
3577
+ totalInputPositions(fromPos, toPos) {
3578
+ if (fromPos === void 0) {
3579
+ fromPos = 0;
3580
+ }
3581
+ if (toPos == null && this.repeatTo === Infinity) return Infinity;
3582
+ return super.totalInputPositions(fromPos, toPos);
3583
+ }
3584
+ get state() {
3585
+ return super.state;
3586
+ }
3587
+ set state(state) {
3588
+ this._blocks.length = state._blocks.length;
3589
+ this.mask = this.mask.slice(0, this._blocks.length);
3590
+ super.state = state;
3591
+ }
3592
+ }
3593
+ IMask.RepeatBlock = RepeatBlock;
3594
+
3595
+ try {
3596
+ globalThis.IMask = IMask;
3597
+ } catch {}
3598
+
3599
+ export { IMask as I };