@globalpayments/vega 2.27.0 → 2.28.0

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 (171) hide show
  1. package/dist/cjs/{app-globals-190595cc.js → app-globals-512d84f4.js} +1 -1
  2. package/dist/cjs/{form-field-controller-slimmer-ee984eb2.js → form-field-controller-slimmer-223f8ee3.js} +1 -1
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +3 -3
  5. package/dist/cjs/{sub-state-observer-slimmer-832a4215.js → sub-state-observer-slimmer-36660092.js} +2 -2
  6. package/dist/cjs/{translation-slimmer-8ebf126d.js → translation-slimmer-83577cfd.js} +1 -1
  7. package/dist/cjs/vega-app-header-button.cjs.entry.js +1 -1
  8. package/dist/cjs/vega-button-circle.cjs.entry.js +1 -1
  9. package/dist/cjs/vega-button-group_2.cjs.entry.js +3 -3
  10. package/dist/cjs/vega-button.cjs.entry.js +1 -1
  11. package/dist/cjs/vega-calendar_3.cjs.entry.js +937 -838
  12. package/dist/cjs/vega-checkbox_2.cjs.entry.js +2 -2
  13. package/dist/cjs/vega-chip.cjs.entry.js +1 -1
  14. package/dist/cjs/vega-color-picker.cjs.entry.js +2 -2
  15. package/dist/cjs/vega-combo-box.cjs.entry.js +2 -2
  16. package/dist/cjs/vega-date-picker_2.cjs.entry.js +3 -3
  17. package/dist/cjs/vega-dropdown_5.cjs.entry.js +3 -3
  18. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  19. package/dist/cjs/vega-file-uploader.cjs.entry.js +3 -3
  20. package/dist/cjs/vega-form.cjs.entry.js +2 -2
  21. package/dist/cjs/vega-image-uploader.cjs.entry.js +3 -3
  22. package/dist/cjs/vega-input-credit-card.cjs.entry.js +2 -2
  23. package/dist/cjs/vega-input-phone-number.cjs.entry.js +2 -2
  24. package/dist/cjs/vega-input-range.cjs.entry.js +3 -3
  25. package/dist/cjs/vega-input-select.cjs.entry.js +3 -3
  26. package/dist/cjs/vega-input.cjs.entry.js +46 -13
  27. package/dist/cjs/vega-pagination.cjs.entry.js +2 -2
  28. package/dist/cjs/vega-radio_2.cjs.entry.js +2 -2
  29. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +3 -3
  30. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +3 -3
  31. package/dist/cjs/vega-signature-capture.cjs.entry.js +3 -3
  32. package/dist/cjs/vega-stepper.cjs.entry.js +2 -2
  33. package/dist/cjs/vega-table_8.cjs.entry.js +3 -3
  34. package/dist/cjs/vega-textarea.cjs.entry.js +2 -2
  35. package/dist/cjs/vega-time-picker_2.cjs.entry.js +3 -3
  36. package/dist/cjs/vega-toggle-switch.cjs.entry.js +2 -2
  37. package/dist/cjs/vega.cjs.js +3 -3
  38. package/dist/collection/components/vega-app-header-button/vega-app-header-button.css +7 -1
  39. package/dist/collection/components/vega-button/vega-button.css +1 -0
  40. package/dist/collection/components/vega-button-circle/vega-button-circle.css +4 -0
  41. package/dist/collection/components/vega-button-group/vega-button-group-item/vega-button-group-item.css +10 -0
  42. package/dist/collection/components/vega-button-group/vega-button-group.css +13 -0
  43. package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-current-period-controller.js +17 -3
  44. package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-event-responsive-controller.js +1 -1
  45. package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-view-controller.js +3 -0
  46. package/dist/collection/components/vega-calendar/slimmers/common/layout/full-day-event-layout-generator.js +1 -1
  47. package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.js +4 -3
  48. package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-view-renderer.js +4 -1
  49. package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/timed-event/vega-calendar-day-event-layout-renderer.js +1 -1
  50. package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/vega-calendar-time-line-renderer.js +1 -1
  51. package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/vega-calendar-view-with-time-renderer.js +0 -3
  52. package/dist/collection/components/vega-calendar/slimmers/month-view/renderers/vega-calendar-month-event-renderer.js +3 -1
  53. package/dist/collection/components/vega-calendar/slimmers/month-view/renderers/vega-calendar-month-view-renderer.js +0 -3
  54. package/dist/collection/components/vega-calendar/utils/index.js +24 -0
  55. package/dist/collection/components/vega-calendar/vega-calendar-event/slimmers/renderers/vega-calendar-event-renderer.js +3 -2
  56. package/dist/collection/components/vega-calendar/vega-calendar.css +10 -6
  57. package/dist/collection/components/vega-calendar/vega-calendar.js +36 -0
  58. package/dist/collection/components/vega-chip/vega-chip.css +4 -0
  59. package/dist/collection/helpers/calendar/calendar-period/calendar-period.abstract.js +8 -0
  60. package/dist/collection/helpers/calendar/calendar-period/day-period.js +27 -4
  61. package/dist/collection/helpers/calendar/calendar-period/month-period.js +4 -2
  62. package/dist/collection/helpers/calendar/calendar-period/week-period.js +4 -2
  63. package/dist/collection/helpers/calendar/calendar-view-generator/month-view-generator.js +8 -2
  64. package/dist/collection/helpers/calendar/calendar-view-generator/week-view-generator.js +8 -1
  65. package/dist/collection/helpers/calendar/test/calendar-period/day-period.test.js +16 -0
  66. package/dist/collection/helpers/calendar/test/calendar-view-generator/month-view-generator.test.js +50 -0
  67. package/dist/collection/helpers/calendar/test/calendar-view-generator/week-view-generator.test.js +15 -0
  68. package/dist/collection/helpers/formatter/string-formatter/number-mask-strategy.js +36 -4
  69. package/dist/collection/helpers/formatter/string-formatter/number-thousand-comma-strategy.js +9 -7
  70. package/dist/collection/helpers/formatter/test/string-formatter/number-mask-strategy.test.js +11 -2
  71. package/dist/collection/helpers/formatter/test/string-formatter/number-thousand-comma-mask-strategy.test.js +2 -0
  72. package/dist/collection/helpers/slimmers/sub-state/sub-state-observer-slimmer.js +2 -2
  73. package/dist/collection/helpers/slimmers/test/string-input-formatter-slimmer.test.js +20 -0
  74. package/dist/esm/{app-globals-d0b86358.js → app-globals-41797af8.js} +1 -1
  75. package/dist/esm/{form-field-controller-slimmer-2f9c871b.js → form-field-controller-slimmer-edbaaf7c.js} +1 -1
  76. package/dist/esm/index.js +1 -1
  77. package/dist/esm/loader.js +3 -3
  78. package/dist/esm/{sub-state-observer-slimmer-af28076b.js → sub-state-observer-slimmer-8eff5559.js} +2 -2
  79. package/dist/esm/{translation-slimmer-c740a5f3.js → translation-slimmer-79f9a9c9.js} +1 -1
  80. package/dist/esm/vega-app-header-button.entry.js +1 -1
  81. package/dist/esm/vega-button-circle.entry.js +1 -1
  82. package/dist/esm/vega-button-group_2.entry.js +3 -3
  83. package/dist/esm/vega-button.entry.js +1 -1
  84. package/dist/esm/vega-calendar_3.entry.js +937 -838
  85. package/dist/esm/vega-checkbox_2.entry.js +2 -2
  86. package/dist/esm/vega-chip.entry.js +1 -1
  87. package/dist/esm/vega-color-picker.entry.js +2 -2
  88. package/dist/esm/vega-combo-box.entry.js +2 -2
  89. package/dist/esm/vega-date-picker_2.entry.js +3 -3
  90. package/dist/esm/vega-dropdown_5.entry.js +3 -3
  91. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  92. package/dist/esm/vega-file-uploader.entry.js +3 -3
  93. package/dist/esm/vega-form.entry.js +2 -2
  94. package/dist/esm/vega-image-uploader.entry.js +3 -3
  95. package/dist/esm/vega-input-credit-card.entry.js +2 -2
  96. package/dist/esm/vega-input-phone-number.entry.js +2 -2
  97. package/dist/esm/vega-input-range.entry.js +3 -3
  98. package/dist/esm/vega-input-select.entry.js +3 -3
  99. package/dist/esm/vega-input.entry.js +46 -13
  100. package/dist/esm/vega-pagination.entry.js +2 -2
  101. package/dist/esm/vega-radio_2.entry.js +2 -2
  102. package/dist/esm/vega-selection-chip_2.entry.js +3 -3
  103. package/dist/esm/vega-selection-tile_2.entry.js +3 -3
  104. package/dist/esm/vega-signature-capture.entry.js +3 -3
  105. package/dist/esm/vega-stepper.entry.js +2 -2
  106. package/dist/esm/vega-table_8.entry.js +3 -3
  107. package/dist/esm/vega-textarea.entry.js +2 -2
  108. package/dist/esm/vega-time-picker_2.entry.js +3 -3
  109. package/dist/esm/vega-toggle-switch.entry.js +2 -2
  110. package/dist/esm/vega.js +3 -3
  111. package/dist/types/components/vega-calendar/slimmers/common/controllers/vega-calendar-current-period-controller.d.ts +5 -0
  112. package/dist/types/components/vega-calendar/slimmers/common/controllers/vega-calendar-view-controller.d.ts +1 -0
  113. package/dist/types/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.d.ts +1 -1
  114. package/dist/types/components/vega-calendar/slimmers/common/renderers/vega-calendar-view-renderer.d.ts +1 -0
  115. package/dist/types/components/vega-calendar/slimmers/day-view/renderers/vega-calendar-view-with-time-renderer.d.ts +0 -1
  116. package/dist/types/components/vega-calendar/slimmers/month-view/renderers/vega-calendar-month-view-renderer.d.ts +0 -1
  117. package/dist/types/components/vega-calendar/utils/index.d.ts +13 -0
  118. package/dist/types/components/vega-calendar/vega-calendar.d.ts +10 -0
  119. package/dist/types/components.d.ts +10 -0
  120. package/dist/types/helpers/calendar/calendar-period/calendar-period.abstract.d.ts +7 -0
  121. package/dist/types/helpers/calendar/calendar-period/day-period.d.ts +8 -1
  122. package/dist/types/helpers/calendar/calendar-period/month-period.d.ts +2 -1
  123. package/dist/types/helpers/calendar/calendar-period/week-period.d.ts +2 -1
  124. package/dist/types/helpers/formatter/string-formatter/number-mask-strategy.d.ts +20 -0
  125. package/dist/types/helpers/slimmers/sub-state/sub-state-observer-slimmer.d.ts +1 -1
  126. package/dist/vega/index.esm.js +1 -1
  127. package/dist/vega/{p-f57454a6.js → p-0120ce7a.js} +1 -1
  128. package/dist/vega/{p-1dc80394.entry.js → p-0395e791.entry.js} +1 -1
  129. package/dist/vega/{p-8a1d8b99.entry.js → p-048a97d1.entry.js} +1 -1
  130. package/dist/vega/{p-963e8c45.entry.js → p-0dd750b0.entry.js} +1 -1
  131. package/dist/vega/{p-c31002d0.entry.js → p-1b901368.entry.js} +1 -1
  132. package/dist/vega/p-1f38eef6.entry.js +1 -0
  133. package/dist/vega/{p-8912d5c9.entry.js → p-1fc5373a.entry.js} +1 -1
  134. package/dist/vega/{p-7f8db003.entry.js → p-22a85055.entry.js} +1 -1
  135. package/dist/vega/{p-351a0ea1.entry.js → p-34545d2d.entry.js} +1 -1
  136. package/dist/vega/{p-f37e6adf.entry.js → p-40f6add9.entry.js} +1 -1
  137. package/dist/vega/p-41784db1.js +1 -0
  138. package/dist/vega/{p-c9e3413b.entry.js → p-4bc042ec.entry.js} +1 -1
  139. package/dist/vega/{p-a7666db3.entry.js → p-5d231a82.entry.js} +1 -1
  140. package/dist/vega/p-5f377954.js +1 -1
  141. package/dist/vega/{p-ded47af0.entry.js → p-657df167.entry.js} +1 -1
  142. package/dist/vega/{p-28f6ead3.entry.js → p-6d015656.entry.js} +1 -1
  143. package/dist/vega/{p-8c2852c4.entry.js → p-6e3cc7f0.entry.js} +1 -1
  144. package/dist/vega/{p-09352107.entry.js → p-8c72aa56.entry.js} +1 -1
  145. package/dist/vega/{p-ba3db23b.entry.js → p-8f60c3ee.entry.js} +1 -1
  146. package/dist/vega/{p-bffaa859.entry.js → p-9a4ffc2c.entry.js} +1 -1
  147. package/dist/vega/p-9e6934fb.js +1 -0
  148. package/dist/vega/p-a19ae233.entry.js +1 -0
  149. package/dist/vega/{p-e7e19350.entry.js → p-a454acc4.entry.js} +1 -1
  150. package/dist/vega/{p-27b73500.entry.js → p-a8b1f19c.entry.js} +1 -1
  151. package/dist/vega/{p-14c0b4ea.js → p-bccacf42.js} +1 -1
  152. package/dist/vega/{p-8eadc60b.entry.js → p-d0a83562.entry.js} +1 -1
  153. package/dist/vega/{p-288b47f0.entry.js → p-d4fb2264.entry.js} +1 -1
  154. package/dist/vega/{p-fa78f87f.entry.js → p-d550fc66.entry.js} +1 -1
  155. package/dist/vega/p-d686dd96.entry.js +1 -0
  156. package/dist/vega/p-e0410974.entry.js +1 -0
  157. package/dist/vega/{p-0afaa0f3.entry.js → p-ead9a2b9.entry.js} +1 -1
  158. package/dist/vega/{p-54f5c773.entry.js → p-f0ad06bd.entry.js} +1 -1
  159. package/dist/vega/{p-8aaa9233.entry.js → p-f2019f70.entry.js} +1 -1
  160. package/dist/vega/{p-af71fe84.entry.js → p-fc746bae.entry.js} +1 -1
  161. package/dist/vega/vega.esm.js +1 -1
  162. package/package.json +1 -1
  163. package/dist/vega/p-15452727.js +0 -1
  164. package/dist/vega/p-38e3d50e.entry.js +0 -1
  165. package/dist/vega/p-8a646846.entry.js +0 -1
  166. package/dist/vega/p-bf557666.entry.js +0 -1
  167. package/dist/vega/p-d7bd2be5.entry.js +0 -1
  168. package/dist/vega/p-dee487f9.js +0 -1
  169. /package/dist/cjs/{translation-77e9ccce.js → translation-0dd74433.js} +0 -0
  170. /package/dist/esm/{translation-3b437b6d.js → translation-0fa7cf77.js} +0 -0
  171. /package/dist/vega/{p-05ebf5a3.js → p-be784f53.js} +0 -0
@@ -1 +1 @@
1
- import{c as t,V as s,I as e,M as i}from"./p-6e1ab235.js";import{c as r}from"./p-0bb29d98.js";import{C as o}from"./p-2d0d575f.js";import{O as n}from"./p-331a62d5.js";import{U as h,c as a,d as l,b as c,e as d,F as u,f,g as m}from"./p-da86ba01.js";import{f as p,c as v}from"./p-4163c2c2.js";import{i as b,g}from"./p-fb6c90d6.js";import{c as R}from"./p-6a334573.js";import{d as y,D as j}from"./p-6c6d86da.js";import{V as w,a as O}from"./p-6168c1e7.js";import{V as E}from"./p-05ebf5a3.js";import{P as F}from"./p-47c87634.js";import{M as I}from"./p-987fbbd0.js";import{A as V}from"./p-38d81bde.js";import{i as C}from"./p-ee68920f.js";class k{constructor(t){this.rule=t}getStatus(t,s,e){return{canEvaluate:this.rule.canEvaluate(t,s,e),isAsync:b(this.rule.evaluate)}}shouldShowError(t,s){try{return this.rule.shouldShowError?this.rule.shouldShowError(t,s):this.defaultShouldShowError(t)}catch(t){return!1}}handle(t){try{return this.rule.evaluate(t)}catch(t){return{isValid:!0,message:""}}}defaultShouldShowError(t){return!t.disabled&&t.visible&&(t.touched||t.modified)}}class A{constructor(){this.handlers=[],this.processId=""}checkIncludesAsyncRuleHandler(t,s,e){return!!this.handlers.find((i=>{const r=i.getStatus(t,s,e);return r.canEvaluate&&r.isAsync}))}setHandlersByRules(t){this.handlers=t&&t.length?t.map((t=>new k(t))):[]}async process(t,s,e,i,r){const o=this.preProcess();let n;for(const i of this.handlers){if(o!==this.processId)break;const r=i.getStatus(t,s,e);if(!r.canEvaluate)continue;let h;if(r.isAsync)try{h=await i.handle(t)}catch(t){}else h=i.handle(t);if(h&&!h.isValid){const t=i.shouldShowError(s,e);n=Object.assign(Object.assign({},h),{shouldShowError:t});break}}return this.postProcess(o,i,n,r),!n}preProcess(){const t=g();return this.processId=t,t}postProcess(t,s,e,i){this.processId===t&&i(s,e)}}class S{run(t){const s=t.nextElementSibling;return s&&s.querySelector(".vega-error")?s.querySelector(".vega-error"):null}}class T{run(t){let s=t.nextElementSibling;return s&&!s.classList.contains("vega-error")&&(s=document.createElement("label"),s.classList.add("vega-error"),s.setAttribute("part","field-error-message"),t.after(s)),s}}class L{run(t){let s=t.nextElementSibling;return s||(s=document.createElement("label"),s.classList.add("vega-error"),s.setAttribute("part","field-error-message"),t.after(s)),s}}var M=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class U extends s{constructor(){super(),this.fieldErrorUiControllerStrategies=[new S,new T,new L],this.initTranslationObserver()}applyInputInvalidUI(t){this.errorMessage=t;const s=this.getInputElementContainer();if(t&&s){const e=this.getErrorContainer(s);e.innerHTML=this.getTranslatedMessage(t),e.classList.remove("vega-hidden"),s.classList.add("error"),o.notify(y.getSubject(this.host,w),{host:this.host,showError:!0})}}resetInputInvalidUI(){this.errorMessage="";const t=this.getInputElementContainer();t&&(this.getErrorContainer(t).classList.add("vega-hidden"),t.classList.remove("error"),o.notify(y.getSubject(this.host,w),{host:this.host,showError:!1}))}getInputElementContainer(){return this.options&&this.options.inputContainerGetter?this.options.inputContainerGetter():null}getErrorContainer(t){for(const s of this.fieldErrorUiControllerStrategies){const e=s.run(t);if(e)return e}}getTranslatedMessage(t){return"string"==typeof t?E.t(t):E.t(t.key,...t.args||[])}initTranslationObserver(){const t=new n(this.isAcceptableTranslationObserver.bind(this),(()=>{if(!this.errorMessage)return;const t=this.getInputElementContainer();if(t){const s=this.getErrorContainer(t);s&&(s.innerHTML=this.getTranslatedMessage(this.errorMessage))}}));o.register(h,t)}isAcceptableTranslationObserver(){return!0}}M([t()],U.prototype,"host",void 0),M([t()],U.prototype,"options",void 0);var D=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class B{constructor(t,s,e,i){var r,n;this.fieldErrorUIController=new U,this.resizeObserverSlimmer=R(B,F,[],[{mapFrom:"connectResizeObserver",mapTo:"connectResizeObserver"}],[{callback:t=>{const s=this.isVisible,e=t[0].contentRect.height>0;this.isVisible=e,this.isAutoValidationEnabled()&&p(this.host,"vega-form")&&s!==e&&this.valid(["visible"])},target:()=>this.host}]),this.defaultRules=[],this.additionalRules=[],this.listeners=[],this.isTouched=!1,this.isModified=!1,this.isVisible=!1,this.formFieldValidationRuleHandlerChain=new A,this.hostChildAddedBlurEventMap=new WeakMap,this.handleValidationResult=(t,s)=>{let e=!0;return s?("rule"===t?s.shouldShowError?this.fieldErrorUIController.applyInputInvalidUI(s.message):this.fieldErrorUIController.resetInputInvalidUI():t?this.fieldErrorUIController.applyInputInvalidUI(s.message):this.fieldErrorUIController.resetInputInvalidUI(),e=!1):this.fieldErrorUIController.resetInputInvalidUI(),this.invokeListeners(e),o.notify(a,{host:this.host,detail:e}),e},this.setupTouchedListener=()=>{this.getTouchableAreaElements().filter((t=>!0!==this.hostChildAddedBlurEventMap.get(t))).forEach((t=>{t.addEventListener("blur",(()=>{this.updateIsTouched(!0)})),this.hostChildAddedBlurEventMap.set(t,!0)}))},this.defaultRules=t||[],this.host=s,this.defaultValue=e,this.options=i,this.initDisabledAttrObserver(),this.connectResizeObserver(),this.initFormResetObserver(),null===(n=(r=this.host).componentOnReady)||void 0===n||n.call(r).then((()=>{this.didRender()})),this.setupModifiedListener(),this.listenHostElementKeydown(),this.updateValidationHandlers()}async validate(t){return await this.valid([],t)}addListener(t){this.listeners.push(t)}getRules(){return[...this.defaultRules,...this.additionalRules]}setDefaultRules(t){this.defaultRules=t,this.updateValidationHandlers()}setAdditionalRules(t){this.additionalRules=t,this.updateValidationHandlers()}destroy(){o.notify(l,{host:this.host}),this.unregisterFormResetObserver(),o.unregister(c,this.hostValueChangeObserver),this.hostChildrenObserver&&this.hostChildrenObserver.disconnect()}connectResizeObserver(){}updateValidationHandlers(){this.formFieldValidationRuleHandlerChain.setHandlersByRules(this.getRules())}async valid(t,s="rule"){const e=this.getStatus(),i=this.host.value;return this.formFieldValidationRuleHandlerChain.checkIncludesAsyncRuleHandler(i,e,t)&&o.notify(a,{host:this.host,detail:null}),await this.formFieldValidationRuleHandlerChain.process(i,e,t,s,this.handleValidationResult)}invokeListeners(t){this.listeners.forEach((s=>s.callback(t)))}getStatus(){return{touched:this.isTouched,modified:this.isModified,disabled:this.host.disabled,visible:this.isVisible}}updateIsTouched(t){const s=this.isTouched;this.isTouched=t,this.isAutoValidationEnabled()&&this.valid(s===t?[]:["touched"])}updateIsModified(t){const s=this.isModified;this.isModified=t,this.isAutoValidationEnabled()&&this.valid(s===t?[]:["modified"])}initDisabledAttrObserver(){this.disabledAttrObserver=new MutationObserver((()=>{this.isAutoValidationEnabled()&&this.valid(["disabled"])})),this.disabledAttrObserver.observe(this.host,{attributes:!0,attributeFilter:["disabled"]})}canAcceptFormResetOperation(t){return p(this.host,"vega-form")===t.host}unregisterFormResetObserver(){o.unregister(d,this.formResetTriggeredObserver)}monitorTouchedListener(){const t=this.getInputContainerElements();t&&(this.hostChildrenObserver=new MutationObserver((()=>{this.setupTouchedListener()})),this.hostChildrenObserver.observe(t,{childList:!0,subtree:!0})),this.setupTouchedListener()}getTouchableAreaElements(){return this.options&&this.options.touchableAreaGetter?this.options.touchableAreaGetter():[]}getInputContainerElements(){return this.options&&this.options.inputContainerGetter?this.options.inputContainerGetter():null}setupModifiedListener(){this.hostValueChangeObserver=new n(this.isCurrentTarget.bind(this),(()=>this.updateIsModified(!0))),o.register(c,this.hostValueChangeObserver)}isCurrentTarget(t){return this.host===t.host}async reset(t){var s,e;if(this.shouldVisitElement(this.host,null===(s=t.option)||void 0===s?void 0:s.skipDisabled,null===(e=t.option)||void 0===e?void 0:e.skipInvisible)){const s=t.defaultValueMap,e=this.host.dataset.vegaForm,i=null==s[e]?this.getDefaultValue():s[e];"function"==typeof this.host.setValue?await this.host.setValue(i):this.host.value=i,this.isTouched=!1,this.isModified=!1,this.fieldErrorUIController.resetInputInvalidUI()}}getDefaultValue(){return this.defaultValue instanceof Function?this.defaultValue(this.host):this.defaultValue}didRender(){this.monitorTouchedListener()}initFormResetObserver(){this.formResetTriggeredObserver=new n(this.canAcceptFormResetOperation.bind(this),this.reset.bind(this)),o.register(d,this.formResetTriggeredObserver)}isAutoValidationEnabled(){return!1!==this.host.autoValidation}shouldVisitElement(t,s,e){return!(!t.dataset.vegaForm||s&&t.disabled||e&&!v(t))}listenHostElementKeydown(){this.host.addEventListener("keydown",(t=>{this.canSubmitFormByEvent(t)&&o.notify(u,{host:this.host})}))}canSubmitFormByEvent(t){const s="Enter"===t.key||13===t.keyCode,e=s&&t.shiftKey;switch(this.host.tagName){case"VEGA-TEXTAREA":case"VEGA-DATE-PICKER":case"VEGA-TIME-PICKER":return e&&t.preventDefault(),e;default:return s}}}D([e()],B.prototype,"fieldErrorUIController",void 0),D([e()],B.prototype,"resizeObserverSlimmer",void 0);var H=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class P extends s{constructor(){super(...arguments),this.fieldErrorUIController=new U,this.handleFieldErrorMessageUpdate=t=>{const{message:s}=t;s?this.fieldErrorUIController.applyInputInvalidUI(s):this.fieldErrorUIController.resetInputInvalidUI()}}handleComponentWillLoadByFieldErrorSlimmer(){this.fieldErrorMessageChangeObserver=new n(this.canAcceptFieldErrorMessageUpdate.bind(this),this.handleFieldErrorMessageUpdate),o.register(f,this.fieldErrorMessageChangeObserver)}handleUnregisterObserver(){o.unregister(f,this.fieldErrorMessageChangeObserver)}canAcceptFieldErrorMessageUpdate(t){const{host:s}=t,e=this.host.parentElement;return!(!e||e!==s)}}H([t()],P.prototype,"host",void 0),H([t()],P.prototype,"options",void 0),H([e()],P.prototype,"fieldErrorUIController",void 0),H([i("setInjectFormFieldHelper")],P.prototype,"handleComponentWillLoadByFieldErrorSlimmer",null),H([i("disconnectedCallback")],P.prototype,"handleUnregisterObserver",null);var x=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class z extends s{constructor(){super(...arguments),this.handleValidInvocation=async t=>{if(this.validator){void 0!==t.timerId&&clearTimeout(t.timerId);const s=await this.validator.validate(t.message);"function"==typeof t.promiseResolve&&t.promiseResolve(s)}}}registerValidInvocationObserver(){j.addUniqueObserverToNode(this.host,O,this.handleValidInvocation)}handleUnregisterObserver(){j.removeUniqueObserverFromNode(this.host,O)}}x([t()],z.prototype,"host",void 0),x([t()],z.prototype,"validator",void 0),x([i("setInjectFormFieldHelper")],z.prototype,"registerValidInvocationObserver",null),x([i("disconnectedCallback")],z.prototype,"handleUnregisterObserver",null);var G=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class W extends s{constructor(t){super(),this.fieldErrorSlimmer=new P,this.formFieldValidInvokeSlimmer=new z,this.mutationObserverCallBack=()=>{this.validator&&(this.setDefaultRules(),this.internalValidate())},this.options=t,this.setMutationObserverSlimmer()}connectedCallback(){null===this.validator&&this.setInjectFormFieldHelper()}disconnectedCallback(){this.validator&&(this.validator.destroy(),this.validator=null)}componentDidLoad(){}static isValidFormField(t){return t&&Boolean(t.getAttribute("data-vega-form"))}watchValidationRulesByFormControllerSlimmer(t,s){C(t,s)||(this.setAdditionalRules(),this.internalValidate())}setInjectFormFieldHelper(){if(W.isValidFormField(this.host)){const{defaultValue:t}=this.options,s=new B(this.getPropertyRules(),this.host,t,this.options);s.addListener({callback:t=>{this.isValid!=t&&(this.isValid=t,o.notify(m,{host:this.host,detail:t}))}}),this.validator=s,this.setAdditionalRules()}}setAdditionalRules(){this.options.validationRulesName&&"validationRules"===this.options.validationRulesName&&this.validator&&this.validator.setAdditionalRules(this.validationRules||[])}setDefaultRules(){this.validator&&this.validator.setDefaultRules(this.getPropertyRules())}getPropertyRules(){const{propertyRules:t,attributeGetter:s}=this.options;return t.map((t=>{const e=t.dependence&&"string"==typeof t.dependence?[s(t.dependence)]:Array.isArray(t.dependence)?t.dependence.map((t=>s(t))):[null];return t.ruleFactory(s(t.propertyName),...e)})).filter(Boolean)}internalValidate(){!this.disabled&&this.validator&&this.validator.validate()}setMutationObserverSlimmer(){this.mutationObserverSlimmer=new I({options:{attributeFilter:this.options.propertyRules.map((t=>r(t.propertyName))),attributeOldValue:!0},mutationFilter:V(),callback:this.mutationObserverCallBack})}}G([t()],W.prototype,"host",void 0),G([t({writable:!0})],W.prototype,"validationRules",void 0),G([t()],W.prototype,"disabled",void 0),G([t()],W.prototype,"autoValidation",void 0),G([t({writable:!0})],W.prototype,"isValid",void 0),G([e()],W.prototype,"fieldErrorSlimmer",void 0),G([e()],W.prototype,"formFieldValidInvokeSlimmer",void 0),G([e()],W.prototype,"mutationObserverSlimmer",void 0),G([i("connectedCallback")],W.prototype,"connectedCallback",null),G([i("disconnectedCallback")],W.prototype,"disconnectedCallback",null),G([i("componentDidLoad")],W.prototype,"componentDidLoad",null),G([i("watchValidationRules")],W.prototype,"watchValidationRulesByFormControllerSlimmer",null),G([i("componentWillLoad")],W.prototype,"setInjectFormFieldHelper",null);export{W as F}
1
+ import{c as t,V as s,I as e,M as i}from"./p-6e1ab235.js";import{c as r}from"./p-0bb29d98.js";import{C as o}from"./p-2d0d575f.js";import{O as n}from"./p-331a62d5.js";import{U as h,c as a,d as l,b as c,e as d,F as u,f,g as m}from"./p-da86ba01.js";import{f as p,c as v}from"./p-4163c2c2.js";import{i as b,g}from"./p-fb6c90d6.js";import{c as R}from"./p-6a334573.js";import{d as y,D as j}from"./p-6c6d86da.js";import{V as w,a as O}from"./p-6168c1e7.js";import{V as E}from"./p-be784f53.js";import{P as F}from"./p-47c87634.js";import{M as I}from"./p-987fbbd0.js";import{A as V}from"./p-38d81bde.js";import{i as C}from"./p-ee68920f.js";class k{constructor(t){this.rule=t}getStatus(t,s,e){return{canEvaluate:this.rule.canEvaluate(t,s,e),isAsync:b(this.rule.evaluate)}}shouldShowError(t,s){try{return this.rule.shouldShowError?this.rule.shouldShowError(t,s):this.defaultShouldShowError(t)}catch(t){return!1}}handle(t){try{return this.rule.evaluate(t)}catch(t){return{isValid:!0,message:""}}}defaultShouldShowError(t){return!t.disabled&&t.visible&&(t.touched||t.modified)}}class A{constructor(){this.handlers=[],this.processId=""}checkIncludesAsyncRuleHandler(t,s,e){return!!this.handlers.find((i=>{const r=i.getStatus(t,s,e);return r.canEvaluate&&r.isAsync}))}setHandlersByRules(t){this.handlers=t&&t.length?t.map((t=>new k(t))):[]}async process(t,s,e,i,r){const o=this.preProcess();let n;for(const i of this.handlers){if(o!==this.processId)break;const r=i.getStatus(t,s,e);if(!r.canEvaluate)continue;let h;if(r.isAsync)try{h=await i.handle(t)}catch(t){}else h=i.handle(t);if(h&&!h.isValid){const t=i.shouldShowError(s,e);n=Object.assign(Object.assign({},h),{shouldShowError:t});break}}return this.postProcess(o,i,n,r),!n}preProcess(){const t=g();return this.processId=t,t}postProcess(t,s,e,i){this.processId===t&&i(s,e)}}class S{run(t){const s=t.nextElementSibling;return s&&s.querySelector(".vega-error")?s.querySelector(".vega-error"):null}}class T{run(t){let s=t.nextElementSibling;return s&&!s.classList.contains("vega-error")&&(s=document.createElement("label"),s.classList.add("vega-error"),s.setAttribute("part","field-error-message"),t.after(s)),s}}class L{run(t){let s=t.nextElementSibling;return s||(s=document.createElement("label"),s.classList.add("vega-error"),s.setAttribute("part","field-error-message"),t.after(s)),s}}var M=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class U extends s{constructor(){super(),this.fieldErrorUiControllerStrategies=[new S,new T,new L],this.initTranslationObserver()}applyInputInvalidUI(t){this.errorMessage=t;const s=this.getInputElementContainer();if(t&&s){const e=this.getErrorContainer(s);e.innerHTML=this.getTranslatedMessage(t),e.classList.remove("vega-hidden"),s.classList.add("error"),o.notify(y.getSubject(this.host,w),{host:this.host,showError:!0})}}resetInputInvalidUI(){this.errorMessage="";const t=this.getInputElementContainer();t&&(this.getErrorContainer(t).classList.add("vega-hidden"),t.classList.remove("error"),o.notify(y.getSubject(this.host,w),{host:this.host,showError:!1}))}getInputElementContainer(){return this.options&&this.options.inputContainerGetter?this.options.inputContainerGetter():null}getErrorContainer(t){for(const s of this.fieldErrorUiControllerStrategies){const e=s.run(t);if(e)return e}}getTranslatedMessage(t){return"string"==typeof t?E.t(t):E.t(t.key,...t.args||[])}initTranslationObserver(){const t=new n(this.isAcceptableTranslationObserver.bind(this),(()=>{if(!this.errorMessage)return;const t=this.getInputElementContainer();if(t){const s=this.getErrorContainer(t);s&&(s.innerHTML=this.getTranslatedMessage(this.errorMessage))}}));o.register(h,t)}isAcceptableTranslationObserver(){return!0}}M([t()],U.prototype,"host",void 0),M([t()],U.prototype,"options",void 0);var D=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class B{constructor(t,s,e,i){var r,n;this.fieldErrorUIController=new U,this.resizeObserverSlimmer=R(B,F,[],[{mapFrom:"connectResizeObserver",mapTo:"connectResizeObserver"}],[{callback:t=>{const s=this.isVisible,e=t[0].contentRect.height>0;this.isVisible=e,this.isAutoValidationEnabled()&&p(this.host,"vega-form")&&s!==e&&this.valid(["visible"])},target:()=>this.host}]),this.defaultRules=[],this.additionalRules=[],this.listeners=[],this.isTouched=!1,this.isModified=!1,this.isVisible=!1,this.formFieldValidationRuleHandlerChain=new A,this.hostChildAddedBlurEventMap=new WeakMap,this.handleValidationResult=(t,s)=>{let e=!0;return s?("rule"===t?s.shouldShowError?this.fieldErrorUIController.applyInputInvalidUI(s.message):this.fieldErrorUIController.resetInputInvalidUI():t?this.fieldErrorUIController.applyInputInvalidUI(s.message):this.fieldErrorUIController.resetInputInvalidUI(),e=!1):this.fieldErrorUIController.resetInputInvalidUI(),this.invokeListeners(e),o.notify(a,{host:this.host,detail:e}),e},this.setupTouchedListener=()=>{this.getTouchableAreaElements().filter((t=>!0!==this.hostChildAddedBlurEventMap.get(t))).forEach((t=>{t.addEventListener("blur",(()=>{this.updateIsTouched(!0)})),this.hostChildAddedBlurEventMap.set(t,!0)}))},this.defaultRules=t||[],this.host=s,this.defaultValue=e,this.options=i,this.initDisabledAttrObserver(),this.connectResizeObserver(),this.initFormResetObserver(),null===(n=(r=this.host).componentOnReady)||void 0===n||n.call(r).then((()=>{this.didRender()})),this.setupModifiedListener(),this.listenHostElementKeydown(),this.updateValidationHandlers()}async validate(t){return await this.valid([],t)}addListener(t){this.listeners.push(t)}getRules(){return[...this.defaultRules,...this.additionalRules]}setDefaultRules(t){this.defaultRules=t,this.updateValidationHandlers()}setAdditionalRules(t){this.additionalRules=t,this.updateValidationHandlers()}destroy(){o.notify(l,{host:this.host}),this.unregisterFormResetObserver(),o.unregister(c,this.hostValueChangeObserver),this.hostChildrenObserver&&this.hostChildrenObserver.disconnect()}connectResizeObserver(){}updateValidationHandlers(){this.formFieldValidationRuleHandlerChain.setHandlersByRules(this.getRules())}async valid(t,s="rule"){const e=this.getStatus(),i=this.host.value;return this.formFieldValidationRuleHandlerChain.checkIncludesAsyncRuleHandler(i,e,t)&&o.notify(a,{host:this.host,detail:null}),await this.formFieldValidationRuleHandlerChain.process(i,e,t,s,this.handleValidationResult)}invokeListeners(t){this.listeners.forEach((s=>s.callback(t)))}getStatus(){return{touched:this.isTouched,modified:this.isModified,disabled:this.host.disabled,visible:this.isVisible}}updateIsTouched(t){const s=this.isTouched;this.isTouched=t,this.isAutoValidationEnabled()&&this.valid(s===t?[]:["touched"])}updateIsModified(t){const s=this.isModified;this.isModified=t,this.isAutoValidationEnabled()&&this.valid(s===t?[]:["modified"])}initDisabledAttrObserver(){this.disabledAttrObserver=new MutationObserver((()=>{this.isAutoValidationEnabled()&&this.valid(["disabled"])})),this.disabledAttrObserver.observe(this.host,{attributes:!0,attributeFilter:["disabled"]})}canAcceptFormResetOperation(t){return p(this.host,"vega-form")===t.host}unregisterFormResetObserver(){o.unregister(d,this.formResetTriggeredObserver)}monitorTouchedListener(){const t=this.getInputContainerElements();t&&(this.hostChildrenObserver=new MutationObserver((()=>{this.setupTouchedListener()})),this.hostChildrenObserver.observe(t,{childList:!0,subtree:!0})),this.setupTouchedListener()}getTouchableAreaElements(){return this.options&&this.options.touchableAreaGetter?this.options.touchableAreaGetter():[]}getInputContainerElements(){return this.options&&this.options.inputContainerGetter?this.options.inputContainerGetter():null}setupModifiedListener(){this.hostValueChangeObserver=new n(this.isCurrentTarget.bind(this),(()=>this.updateIsModified(!0))),o.register(c,this.hostValueChangeObserver)}isCurrentTarget(t){return this.host===t.host}async reset(t){var s,e;if(this.shouldVisitElement(this.host,null===(s=t.option)||void 0===s?void 0:s.skipDisabled,null===(e=t.option)||void 0===e?void 0:e.skipInvisible)){const s=t.defaultValueMap,e=this.host.dataset.vegaForm,i=null==s[e]?this.getDefaultValue():s[e];"function"==typeof this.host.setValue?await this.host.setValue(i):this.host.value=i,this.isTouched=!1,this.isModified=!1,this.fieldErrorUIController.resetInputInvalidUI()}}getDefaultValue(){return this.defaultValue instanceof Function?this.defaultValue(this.host):this.defaultValue}didRender(){this.monitorTouchedListener()}initFormResetObserver(){this.formResetTriggeredObserver=new n(this.canAcceptFormResetOperation.bind(this),this.reset.bind(this)),o.register(d,this.formResetTriggeredObserver)}isAutoValidationEnabled(){return!1!==this.host.autoValidation}shouldVisitElement(t,s,e){return!(!t.dataset.vegaForm||s&&t.disabled||e&&!v(t))}listenHostElementKeydown(){this.host.addEventListener("keydown",(t=>{this.canSubmitFormByEvent(t)&&o.notify(u,{host:this.host})}))}canSubmitFormByEvent(t){const s="Enter"===t.key||13===t.keyCode,e=s&&t.shiftKey;switch(this.host.tagName){case"VEGA-TEXTAREA":case"VEGA-DATE-PICKER":case"VEGA-TIME-PICKER":return e&&t.preventDefault(),e;default:return s}}}D([e()],B.prototype,"fieldErrorUIController",void 0),D([e()],B.prototype,"resizeObserverSlimmer",void 0);var H=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class P extends s{constructor(){super(...arguments),this.fieldErrorUIController=new U,this.handleFieldErrorMessageUpdate=t=>{const{message:s}=t;s?this.fieldErrorUIController.applyInputInvalidUI(s):this.fieldErrorUIController.resetInputInvalidUI()}}handleComponentWillLoadByFieldErrorSlimmer(){this.fieldErrorMessageChangeObserver=new n(this.canAcceptFieldErrorMessageUpdate.bind(this),this.handleFieldErrorMessageUpdate),o.register(f,this.fieldErrorMessageChangeObserver)}handleUnregisterObserver(){o.unregister(f,this.fieldErrorMessageChangeObserver)}canAcceptFieldErrorMessageUpdate(t){const{host:s}=t,e=this.host.parentElement;return!(!e||e!==s)}}H([t()],P.prototype,"host",void 0),H([t()],P.prototype,"options",void 0),H([e()],P.prototype,"fieldErrorUIController",void 0),H([i("setInjectFormFieldHelper")],P.prototype,"handleComponentWillLoadByFieldErrorSlimmer",null),H([i("disconnectedCallback")],P.prototype,"handleUnregisterObserver",null);var x=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class z extends s{constructor(){super(...arguments),this.handleValidInvocation=async t=>{if(this.validator){void 0!==t.timerId&&clearTimeout(t.timerId);const s=await this.validator.validate(t.message);"function"==typeof t.promiseResolve&&t.promiseResolve(s)}}}registerValidInvocationObserver(){j.addUniqueObserverToNode(this.host,O,this.handleValidInvocation)}handleUnregisterObserver(){j.removeUniqueObserverFromNode(this.host,O)}}x([t()],z.prototype,"host",void 0),x([t()],z.prototype,"validator",void 0),x([i("setInjectFormFieldHelper")],z.prototype,"registerValidInvocationObserver",null),x([i("disconnectedCallback")],z.prototype,"handleUnregisterObserver",null);var G=function(t,s,e,i){var r,o=arguments.length,n=o<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,s,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(o<3?r(n):o>3?r(s,e,n):r(s,e))||n);return o>3&&n&&Object.defineProperty(s,e,n),n};class W extends s{constructor(t){super(),this.fieldErrorSlimmer=new P,this.formFieldValidInvokeSlimmer=new z,this.mutationObserverCallBack=()=>{this.validator&&(this.setDefaultRules(),this.internalValidate())},this.options=t,this.setMutationObserverSlimmer()}connectedCallback(){null===this.validator&&this.setInjectFormFieldHelper()}disconnectedCallback(){this.validator&&(this.validator.destroy(),this.validator=null)}componentDidLoad(){}static isValidFormField(t){return t&&Boolean(t.getAttribute("data-vega-form"))}watchValidationRulesByFormControllerSlimmer(t,s){C(t,s)||(this.setAdditionalRules(),this.internalValidate())}setInjectFormFieldHelper(){if(W.isValidFormField(this.host)){const{defaultValue:t}=this.options,s=new B(this.getPropertyRules(),this.host,t,this.options);s.addListener({callback:t=>{this.isValid!=t&&(this.isValid=t,o.notify(m,{host:this.host,detail:t}))}}),this.validator=s,this.setAdditionalRules()}}setAdditionalRules(){this.options.validationRulesName&&"validationRules"===this.options.validationRulesName&&this.validator&&this.validator.setAdditionalRules(this.validationRules||[])}setDefaultRules(){this.validator&&this.validator.setDefaultRules(this.getPropertyRules())}getPropertyRules(){const{propertyRules:t,attributeGetter:s}=this.options;return t.map((t=>{const e=t.dependence&&"string"==typeof t.dependence?[s(t.dependence)]:Array.isArray(t.dependence)?t.dependence.map((t=>s(t))):[null];return t.ruleFactory(s(t.propertyName),...e)})).filter(Boolean)}internalValidate(){!this.disabled&&this.validator&&this.validator.validate()}setMutationObserverSlimmer(){this.mutationObserverSlimmer=new I({options:{attributeFilter:this.options.propertyRules.map((t=>r(t.propertyName))),attributeOldValue:!0},mutationFilter:V(),callback:this.mutationObserverCallBack})}}G([t()],W.prototype,"host",void 0),G([t({writable:!0})],W.prototype,"validationRules",void 0),G([t()],W.prototype,"disabled",void 0),G([t()],W.prototype,"autoValidation",void 0),G([t({writable:!0})],W.prototype,"isValid",void 0),G([e()],W.prototype,"fieldErrorSlimmer",void 0),G([e()],W.prototype,"formFieldValidInvokeSlimmer",void 0),G([e()],W.prototype,"mutationObserverSlimmer",void 0),G([i("connectedCallback")],W.prototype,"connectedCallback",null),G([i("disconnectedCallback")],W.prototype,"disconnectedCallback",null),G([i("componentDidLoad")],W.prototype,"componentDidLoad",null),G([i("watchValidationRules")],W.prototype,"watchValidationRulesByFormControllerSlimmer",null),G([i("componentWillLoad")],W.prototype,"setInjectFormFieldHelper",null);export{W as F}
@@ -1 +1 @@
1
- import{r as t,c as i,h as e,H as h,g as s}from"./p-1c298d5a.js";import{F as a}from"./p-319efe6c.js";import{V as l,M as r,A as o,D as c}from"./p-3a0a4d15.js";import{R as p}from"./p-e2acbc60.js";import{V as d}from"./p-7b40ac07.js";import{s as n}from"./p-9b797118.js";import{I as v}from"./p-6e1ab235.js";import{V as m,I as f}from"./p-61f6167c.js";import{F as u}from"./p-14c0b4ea.js";import{b as g}from"./p-da86ba01.js";import{C as _}from"./p-2d0d575f.js";import{c as A}from"./p-83af8ed7.js";import{C as M}from"./p-5dc98104.js";import{D as E}from"./p-6c6d86da.js";import{e as w,y as Z,x as I}from"./p-3f5e44c1.js";import{V as b}from"./p-ac0ab38b.js";import"./p-f404aa83.js";import"./p-344ee7cb.js";import"./p-0bb29d98.js";import"./p-331a62d5.js";import"./p-4163c2c2.js";import"./p-fb6c90d6.js";import"./p-6a334573.js";import"./p-6168c1e7.js";import"./p-05ebf5a3.js";import"./p-47c87634.js";import"./p-f46c930f.js";import"./p-74168615.js";import"./p-987fbbd0.js";import"./p-38d81bde.js";import"./p-ee68920f.js";import"./p-ead1a647.js";import"./p-5f377954.js";import"./p-1ea57951.js";const D=[{type:"visa",iconName:"visa",pattern:l,maskConfig:{type:"custom",options:{mask:"9999 9999 9999 9999 999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}},{type:"mastercard",iconName:"mastercard",pattern:r,maskConfig:{type:"custom",options:{mask:"9999 9999 9999 9999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}},{type:"amex",iconName:"amex",pattern:o,maskConfig:{type:"custom",options:{mask:"9999 999999 99999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}},{type:"discover",iconName:"discover",pattern:c,maskConfig:{type:"custom",options:{mask:"9999 9999 9999 9999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}}],j=[{payloadKey:"AUTO_VALIDATION_IS_TRUE",payloadDescription:"Determines whether the user's input in the credit card field should be automatically validated",payloadValue:t=>!0===t.autoValidation},{payloadKey:"AUTO_VALIDATION_IS_FALSE",payloadDescription:"Determines whether the user's input in the credit card field should be automatically validated",payloadValue:t=>!1===t.autoValidation}];var R=function(t,i,e,h){var s,a=arguments.length,l=a<3?i:null===h?h=Object.getOwnPropertyDescriptor(i,e):h;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,i,e,h);else for(var r=t.length-1;r>=0;r--)(s=t[r])&&(l=(a<3?s(l):a>3?s(i,e,l):s(i,e))||l);return a>3&&l&&Object.defineProperty(i,e,l),l};const y=class{constructor(h){t(this,h),this.vegaChange=i(this,"vegaChange",7),this.change=i(this,"change",7),this.vegaBlur=i(this,"vegaBlur",7),this.blur=i(this,"blur",7),this.vegaFocus=i(this,"vegaFocus",7),this.focus=i(this,"focus",7),this.globalSlimmers={},this.formFieldController=new u({propertyRules:[{propertyName:"required",ruleFactory:t=>t?new p:null},{propertyName:"",ruleFactory:()=>new d}],validationRulesName:"validationRules",defaultValue:"",attributeGetter:t=>this[t],inputContainerGetter:()=>this.inputContainerGetter(),touchableAreaGetter:()=>this.touchableAreaGetter()}),this.changeEventEmitter=A(y,w),this.blurEventEmitter=A(y,Z),this.focusEventEmitter=A(y,I),this.inputCreditCardEventPrevent=new M([w,I,Z],(()=>this.host),!0),this.vegaComponentUsageRuntimeMetricsSlimmer=new m(j),this.maskConfig={type:"custom",options:{mask:"",slot:"9",accept:/[\d\s]/,insertMode:!1,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")},trigger:"blur"},this.required=!1,this.disabled=!1,this.label="",this.hint="",this.size="default",this.placeholder="",this.hideCardNumberOnBlur=!0,this.autoValidation=!0,this.validationRules=[],this.isValid=null,this.value="",this.renderInputContainer=()=>{var t;const i=(null===(t=this.getCreditCardType(this.value))||void 0===t?void 0:t.iconName)||"regular-credit-card";return e("vega-input",{label:this.label,type:"number",prefixIcon:b.getIconKey(i),maskConfig:this.getMaskConfig(),placeholder:this.placeholder,disabled:this.disabled,size:this.size,value:this.value,hint:this.hint,required:this.required,showClearIcon:!1,ref:t=>{this.inputRef=t,E.addUniqueObserverToNode(t,w,(t=>{this.handleVegaChange(t)})),E.addUniqueObserverToNode(t,Z,(()=>{this.handleVegaBlur()})),E.addUniqueObserverToNode(t,I,(()=>{this.handleVegaFocus()}))}})},this.handleVegaChange=t=>{this.value=t.detail},this.handleVegaBlur=()=>{this.blurEventEmitter.emit()},this.handleVegaFocus=()=>{this.focusEventEmitter.emit()},this.inputContainerGetter=()=>this.inputRef.shadowRoot.querySelector(".vega-input-container"),this.touchableAreaGetter=()=>Array.from(this.inputRef.shadowRoot.querySelectorAll("input"))}watchValidationRules(){}watchValue(t){this.changeEventEmitter.emit(t),_.notify(g,{host:this.host,detail:t})}componentDidLoad(){a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")&&this.hideCardNumberOnBlur&&this.inputRef.value&&this.value!==this.inputRef.value&&(this.value=this.inputRef.value)}render(){return n(e(h,null,this.renderInputContainer()),this.host)}getCreditCardType(t){return D.filter((i=>i.pattern.test(t)))[0]}getMaskConfig(){const t=[],i=this.getCreditCardType(this.value);return i&&(t.push(i.maskConfig),this.hideCardNumberOnBlur&&this.value.trim().includes(" ")&&(this.maskConfig.options.mask=this.generateDynamicMask(),t.push(this.maskConfig))),t}generateDynamicMask(){const t=this.value.trim().split(" ");return this.maskCardNumber(t).join(" ")}maskCardNumber(t){return t.map(((i,e)=>(e===t.length-1?"9":"X").repeat(i.length)))}get host(){return s(this)}static get watchers(){return{validationRules:["watchValidationRules"],value:["watchValue"]}}};b.register({visa:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" fill="#00579F" rx="2"/><path fill="#fff" d="M15.474 15.792h-1.979l1.238-7.653h1.979l-1.238 7.653ZM22.647 8.326A4.877 4.877 0 0 0 20.872 8c-1.954 0-3.33 1.042-3.339 2.532-.016 1.1.986 1.71 1.735 2.076.765.375 1.026.62 1.026.953-.008.513-.619.75-1.189.75-.79 0-1.213-.123-1.857-.408l-.26-.122-.277 1.718c.464.211 1.32.4 2.207.407 2.076 0 3.428-1.026 3.444-2.613.008-.872-.52-1.54-1.66-2.085-.693-.35-1.117-.586-1.117-.944.008-.326.359-.66 1.14-.66a3.362 3.362 0 0 1 1.474.293l.18.082.268-1.653ZM25.279 13.08l.79-2.14c-.008.016.162-.448.26-.733l.138.66s.375 1.831.457 2.214h-1.645ZM27.72 8.14h-1.53c-.472 0-.831.138-1.035.635l-2.94 7.018h2.077l.416-1.148h2.54c.057.269.237 1.148.237 1.148h1.832L27.72 8.14ZM11.842 8.139l-1.938 5.219-.212-1.059c-.358-1.221-1.482-2.548-2.736-3.208l1.775 6.693h2.093l3.11-7.645h-2.092Z"/><path fill="#FAA61A" d="M8.104 8.139H4.92l-.032.154c2.483.635 4.128 2.166 4.804 4.007L9 8.782c-.114-.489-.464-.627-.896-.643Z"/></svg>',autoSize:!0},mastercard:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" fill="#000" rx="2"/><path fill="#ED0006" fill-rule="evenodd" d="M18.25 17.157a6.75 6.75 0 0 1-4.426 1.649c-3.769 0-6.824-3.09-6.824-6.903C7 8.091 10.055 5 13.824 5a6.75 6.75 0 0 1 4.426 1.649A6.75 6.75 0 0 1 22.676 5c3.769 0 6.824 3.09 6.824 6.903 0 3.812-3.055 6.903-6.824 6.903a6.75 6.75 0 0 1-4.426-1.65Z" clip-rule="evenodd"/><path fill="#F9A000" fill-rule="evenodd" d="M18.25 17.157a6.92 6.92 0 0 0 2.398-5.254 6.92 6.92 0 0 0-2.398-5.254A6.75 6.75 0 0 1 22.676 5c3.769 0 6.824 3.09 6.824 6.903 0 3.812-3.055 6.903-6.824 6.903a6.75 6.75 0 0 1-4.426-1.65Z" clip-rule="evenodd"/><path fill="#FF5E00" fill-rule="evenodd" d="M18.25 6.65a6.92 6.92 0 0 1 2.398 5.253 6.92 6.92 0 0 1-2.398 5.254 6.92 6.92 0 0 1-2.398-5.254A6.92 6.92 0 0 1 18.25 6.65Z" clip-rule="evenodd"/></svg>',autoSize:!0},amex:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><g clip-path="url(#a)"><rect width="36" height="24" fill="#016FD0" rx="2"/><path fill="#fff" d="M6.99 18.549v-5.654h5.986l.643.838.663-.838h21.729v5.264s-.569.384-1.226.39H22.754l-.724-.891v.891h-2.373v-1.521s-.325.212-1.025.212h-.808v1.309h-3.593l-.641-.855-.651.855H6.99ZM0 8.634l1.35-3.147h2.334l.767 1.763V5.487h2.902l.456 1.274.442-1.274h13.027v.64s.685-.64 1.81-.64l4.227.015.753 1.74V5.487h2.428l.669 1v-1h2.45v5.654h-2.45l-.64-1.003v1.003h-3.569l-.359-.892h-.959l-.353.892h-2.42c-.968 0-1.587-.628-1.587-.628v.628H17.63l-.725-.892v.892H3.34l-.359-.892h-.956l-.356.892H0V8.634Z"/><path fill="#016FD0" d="M1.827 6.184.006 10.417h1.185l.336-.847H3.48l.335.847h1.211L3.207 6.184h-1.38Zm.673.985.596 1.482H1.903L2.5 7.169ZM5.151 10.416V6.183l1.685.006.98 2.73.956-2.736h1.671v4.233H9.385v-3.12l-1.122 3.12h-.928L6.21 7.296v3.12H5.15ZM11.168 10.416V6.183h3.454v.947h-2.384v.724h2.328v.891h-2.328v.752h2.384v.92h-3.454ZM15.233 6.184v4.233h1.059V8.913h.445l1.27 1.504H19.3l-1.393-1.56a1.29 1.29 0 0 0 1.161-1.3c0-.89-.7-1.373-1.48-1.373h-2.355Zm1.059.947h1.21c.29 0 .5.227.5.446 0 .28-.273.445-.485.445h-1.225v-.891ZM20.582 10.416h-1.08V6.183h1.08v4.233ZM23.144 10.416h-.233c-1.129 0-1.814-.889-1.814-2.1 0-1.24.678-2.133 2.103-2.133h1.17v1.003h-1.213c-.578 0-.988.451-.988 1.141 0 .82.468 1.165 1.142 1.165h.279l-.446.924ZM25.448 6.184l-1.82 4.233h1.185l.336-.847h1.953l.334.847h1.211l-1.819-4.233h-1.38Zm.674.985.595 1.482h-1.192l.597-1.482ZM28.77 10.416V6.183h1.345l1.718 2.66v-2.66h1.059v4.233H31.59l-1.762-2.73v2.73H28.77ZM7.715 17.825v-4.233h3.453v.947H8.784v.724h2.329v.89H8.784v.753h2.384v.919H7.715ZM24.636 17.825v-4.233h3.454v.947h-2.384v.724h2.317v.89h-2.317v.753h2.384v.919h-3.454ZM11.303 17.825l1.681-2.09-1.721-2.143h1.333l1.025 1.324 1.029-1.324h1.281l-1.699 2.116 1.685 2.117h-1.333l-.996-1.304-.971 1.304h-1.314ZM16.041 13.592v4.233h1.086v-1.337h1.114c.943 0 1.658-.5 1.658-1.472 0-.806-.56-1.424-1.52-1.424H16.04Zm1.086.957h1.174c.304 0 .522.187.522.488 0 .282-.217.487-.526.487h-1.17v-.975ZM20.359 13.592v4.233h1.058V16.32h.446l1.269 1.504h1.293l-1.393-1.56a1.29 1.29 0 0 0 1.162-1.3c0-.89-.7-1.373-1.48-1.373h-2.355Zm1.058.947h1.21c.29 0 .501.226.501.445 0 .281-.273.446-.486.446h-1.225v-.891ZM28.58 17.825v-.92H30.7c.313 0 .449-.169.449-.354 0-.178-.136-.358-.45-.358h-.957c-.831 0-1.295-.507-1.295-1.268 0-.679.424-1.333 1.66-1.333h2.062l-.446.952H29.94c-.341 0-.446.179-.446.35 0 .175.13.369.39.369h1.003c.927 0 1.33.526 1.33 1.215 0 .74-.449 1.347-1.38 1.347H28.58ZM32.464 17.825v-.92h2.118c.313 0 .45-.169.45-.354 0-.178-.136-.358-.45-.358h-.957c-.832 0-1.295-.507-1.295-1.268 0-.679.424-1.333 1.66-1.333h2.02l-.404.952h-1.783c-.34 0-.446.179-.446.35 0 .175.13.369.39.369h1.003c.927 0 1.33.526 1.33 1.215 0 .74-.449 1.347-1.38 1.347h-2.256Z"/></g><defs><clipPath id="a"><rect width="36" height="24" fill="#fff" rx="2"/></clipPath></defs></svg>',autoSize:!0},discover:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" fill="#232342" rx="2"/><path fill="#fff" fill-rule="evenodd" d="M30.686 9.61c1.086 0 1.684.484 1.684 1.398a1.307 1.307 0 0 1-1.087 1.397l1.467 1.988h-1.14l-1.25-1.935h-.109v1.935h-.924V9.61h1.359Zm-.435 2.204h.272c.597 0 .869-.269.869-.752 0-.43-.272-.699-.87-.699h-.27v1.45Zm-4.129 2.579h2.608v-.806h-1.684v-1.29h1.63v-.806h-1.63v-1.074h1.684V9.61h-2.608v4.781Zm-2.716-1.559-1.25-3.223h-.978l2.01 4.889h.49l2.01-4.89h-.978l-1.304 3.225Zm-11.029-.805c0 1.343 1.087 2.471 2.445 2.471.435 0 .815-.107 1.195-.269v-1.074c-.271.322-.652.537-1.086.537-.87 0-1.576-.645-1.576-1.504v-.108c-.054-.86.652-1.612 1.521-1.665.435 0 .87.215 1.141.537V9.879c-.326-.214-.76-.268-1.14-.268-1.413-.108-2.5 1.02-2.5 2.418Zm-1.684-.591c-.543-.215-.706-.323-.706-.591.054-.323.326-.591.652-.538.271 0 .543.162.76.376l.49-.644c-.381-.323-.87-.538-1.359-.538-.76-.053-1.412.538-1.467 1.29v.054c0 .644.272 1.02 1.141 1.289.217.054.435.161.652.269a.563.563 0 0 1 .272.483c0 .376-.326.699-.652.699h-.055c-.434 0-.814-.269-.977-.645l-.598.59c.326.592.978.914 1.63.914.869.054 1.575-.59 1.63-1.45v-.162c-.055-.644-.326-.967-1.413-1.396Zm-3.15 2.954h.923V9.611h-.924v4.781ZM3.25 9.611H4.88c1.304.054 2.336 1.128 2.282 2.418 0 .698-.326 1.343-.87 1.826-.488.376-1.086.591-1.684.538H3.25V9.61Zm1.195 3.976c.435.053.924-.108 1.25-.376.326-.323.489-.753.489-1.236 0-.43-.163-.86-.49-1.182-.325-.269-.814-.43-1.249-.376h-.271v3.17h.271Z" clip-rule="evenodd"/><path fill="#FD6020" fill-rule="evenodd" d="M18.788 9.5c-1.358 0-2.499 1.075-2.499 2.471 0 1.344 1.087 2.472 2.5 2.526 1.412.053 2.498-1.075 2.553-2.472C21.287 10.628 20.2 9.5 18.788 9.5Z" clip-rule="evenodd"/></svg>',autoSize:!0},"regular-credit-card":{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" rx="2" style=\'fill: rgba(var(--v-regular-credit-card-bg, 205, 209, 211, 1))\'/><g clip-path="url(#a)"><path style="fill: rgba(var(--v-regular-credit-card-top, 252, 252, 252, 1))" d="M11 5c-1.103 0-2 .897-2 2v1h18V7c0-1.103-.897-2-2-2H11Zm16 6H9v6c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-6Zm-14.5 4h2c.275 0 .5.225.5.5s-.225.5-.5.5h-2a.501.501 0 0 1-.5-.5c0-.275.225-.5.5-.5Zm3.5.5c0-.275.225-.5.5-.5h4c.275 0 .5.225.5.5s-.225.5-.5.5h-4a.501.501 0 0 1-.5-.5Z"/></g><defs><clipPath id="a"><path d="M9 4h18v16H9z" style=\'fill: rgba(var(--v-regular-credit-card-bottom, 255, 255, 255, 1))\'/></clipPath></defs></svg>',autoSize:!0}}),R([f()],y.prototype,"globalSlimmers",void 0),R([v()],y.prototype,"formFieldController",void 0),R([v()],y.prototype,"changeEventEmitter",void 0),R([v()],y.prototype,"blurEventEmitter",void 0),R([v()],y.prototype,"focusEventEmitter",void 0),R([v()],y.prototype,"inputCreditCardEventPrevent",void 0),R([v()],y.prototype,"vegaComponentUsageRuntimeMetricsSlimmer",void 0),y.style=":host{display:inline-block;width:100%;text-align:left;line-height:normal}";export{y as vega_input_credit_card}
1
+ import{r as t,c as i,h as e,H as h,g as s}from"./p-1c298d5a.js";import{F as a}from"./p-319efe6c.js";import{V as l,M as r,A as o,D as c}from"./p-3a0a4d15.js";import{R as p}from"./p-e2acbc60.js";import{V as d}from"./p-7b40ac07.js";import{s as n}from"./p-9b797118.js";import{I as v}from"./p-6e1ab235.js";import{V as m,I as f}from"./p-61f6167c.js";import{F as u}from"./p-bccacf42.js";import{b as g}from"./p-da86ba01.js";import{C as _}from"./p-2d0d575f.js";import{c as A}from"./p-83af8ed7.js";import{C as M}from"./p-5dc98104.js";import{D as E}from"./p-6c6d86da.js";import{e as w,y as Z,x as I}from"./p-3f5e44c1.js";import{V as b}from"./p-ac0ab38b.js";import"./p-f404aa83.js";import"./p-344ee7cb.js";import"./p-0bb29d98.js";import"./p-331a62d5.js";import"./p-4163c2c2.js";import"./p-fb6c90d6.js";import"./p-6a334573.js";import"./p-6168c1e7.js";import"./p-be784f53.js";import"./p-47c87634.js";import"./p-f46c930f.js";import"./p-74168615.js";import"./p-987fbbd0.js";import"./p-38d81bde.js";import"./p-ee68920f.js";import"./p-ead1a647.js";import"./p-5f377954.js";import"./p-1ea57951.js";const D=[{type:"visa",iconName:"visa",pattern:l,maskConfig:{type:"custom",options:{mask:"9999 9999 9999 9999 999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}},{type:"mastercard",iconName:"mastercard",pattern:r,maskConfig:{type:"custom",options:{mask:"9999 9999 9999 9999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}},{type:"amex",iconName:"amex",pattern:o,maskConfig:{type:"custom",options:{mask:"9999 999999 99999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}},{type:"discover",iconName:"discover",pattern:c,maskConfig:{type:"custom",options:{mask:"9999 9999 9999 9999",slot:"9",accept:/\d/,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")}}}],j=[{payloadKey:"AUTO_VALIDATION_IS_TRUE",payloadDescription:"Determines whether the user's input in the credit card field should be automatically validated",payloadValue:t=>!0===t.autoValidation},{payloadKey:"AUTO_VALIDATION_IS_FALSE",payloadDescription:"Determines whether the user's input in the credit card field should be automatically validated",payloadValue:t=>!1===t.autoValidation}];var R=function(t,i,e,h){var s,a=arguments.length,l=a<3?i:null===h?h=Object.getOwnPropertyDescriptor(i,e):h;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,i,e,h);else for(var r=t.length-1;r>=0;r--)(s=t[r])&&(l=(a<3?s(l):a>3?s(i,e,l):s(i,e))||l);return a>3&&l&&Object.defineProperty(i,e,l),l};const y=class{constructor(h){t(this,h),this.vegaChange=i(this,"vegaChange",7),this.change=i(this,"change",7),this.vegaBlur=i(this,"vegaBlur",7),this.blur=i(this,"blur",7),this.vegaFocus=i(this,"vegaFocus",7),this.focus=i(this,"focus",7),this.globalSlimmers={},this.formFieldController=new u({propertyRules:[{propertyName:"required",ruleFactory:t=>t?new p:null},{propertyName:"",ruleFactory:()=>new d}],validationRulesName:"validationRules",defaultValue:"",attributeGetter:t=>this[t],inputContainerGetter:()=>this.inputContainerGetter(),touchableAreaGetter:()=>this.touchableAreaGetter()}),this.changeEventEmitter=A(y,w),this.blurEventEmitter=A(y,Z),this.focusEventEmitter=A(y,I),this.inputCreditCardEventPrevent=new M([w,I,Z],(()=>this.host),!0),this.vegaComponentUsageRuntimeMetricsSlimmer=new m(j),this.maskConfig={type:"custom",options:{mask:"",slot:"9",accept:/[\d\s]/,insertMode:!1,triggerAtInit:a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")},trigger:"blur"},this.required=!1,this.disabled=!1,this.label="",this.hint="",this.size="default",this.placeholder="",this.hideCardNumberOnBlur=!0,this.autoValidation=!0,this.validationRules=[],this.isValid=null,this.value="",this.renderInputContainer=()=>{var t;const i=(null===(t=this.getCreditCardType(this.value))||void 0===t?void 0:t.iconName)||"regular-credit-card";return e("vega-input",{label:this.label,type:"number",prefixIcon:b.getIconKey(i),maskConfig:this.getMaskConfig(),placeholder:this.placeholder,disabled:this.disabled,size:this.size,value:this.value,hint:this.hint,required:this.required,showClearIcon:!1,ref:t=>{this.inputRef=t,E.addUniqueObserverToNode(t,w,(t=>{this.handleVegaChange(t)})),E.addUniqueObserverToNode(t,Z,(()=>{this.handleVegaBlur()})),E.addUniqueObserverToNode(t,I,(()=>{this.handleVegaFocus()}))}})},this.handleVegaChange=t=>{this.value=t.detail},this.handleVegaBlur=()=>{this.blurEventEmitter.emit()},this.handleVegaFocus=()=>{this.focusEventEmitter.emit()},this.inputContainerGetter=()=>this.inputRef.shadowRoot.querySelector(".vega-input-container"),this.touchableAreaGetter=()=>Array.from(this.inputRef.shadowRoot.querySelectorAll("input"))}watchValidationRules(){}watchValue(t){this.changeEventEmitter.emit(t),_.notify(g,{host:this.host,detail:t})}componentDidLoad(){a.isEnabled("VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD")&&this.hideCardNumberOnBlur&&this.inputRef.value&&this.value!==this.inputRef.value&&(this.value=this.inputRef.value)}render(){return n(e(h,null,this.renderInputContainer()),this.host)}getCreditCardType(t){return D.filter((i=>i.pattern.test(t)))[0]}getMaskConfig(){const t=[],i=this.getCreditCardType(this.value);return i&&(t.push(i.maskConfig),this.hideCardNumberOnBlur&&this.value.trim().includes(" ")&&(this.maskConfig.options.mask=this.generateDynamicMask(),t.push(this.maskConfig))),t}generateDynamicMask(){const t=this.value.trim().split(" ");return this.maskCardNumber(t).join(" ")}maskCardNumber(t){return t.map(((i,e)=>(e===t.length-1?"9":"X").repeat(i.length)))}get host(){return s(this)}static get watchers(){return{validationRules:["watchValidationRules"],value:["watchValue"]}}};b.register({visa:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" fill="#00579F" rx="2"/><path fill="#fff" d="M15.474 15.792h-1.979l1.238-7.653h1.979l-1.238 7.653ZM22.647 8.326A4.877 4.877 0 0 0 20.872 8c-1.954 0-3.33 1.042-3.339 2.532-.016 1.1.986 1.71 1.735 2.076.765.375 1.026.62 1.026.953-.008.513-.619.75-1.189.75-.79 0-1.213-.123-1.857-.408l-.26-.122-.277 1.718c.464.211 1.32.4 2.207.407 2.076 0 3.428-1.026 3.444-2.613.008-.872-.52-1.54-1.66-2.085-.693-.35-1.117-.586-1.117-.944.008-.326.359-.66 1.14-.66a3.362 3.362 0 0 1 1.474.293l.18.082.268-1.653ZM25.279 13.08l.79-2.14c-.008.016.162-.448.26-.733l.138.66s.375 1.831.457 2.214h-1.645ZM27.72 8.14h-1.53c-.472 0-.831.138-1.035.635l-2.94 7.018h2.077l.416-1.148h2.54c.057.269.237 1.148.237 1.148h1.832L27.72 8.14ZM11.842 8.139l-1.938 5.219-.212-1.059c-.358-1.221-1.482-2.548-2.736-3.208l1.775 6.693h2.093l3.11-7.645h-2.092Z"/><path fill="#FAA61A" d="M8.104 8.139H4.92l-.032.154c2.483.635 4.128 2.166 4.804 4.007L9 8.782c-.114-.489-.464-.627-.896-.643Z"/></svg>',autoSize:!0},mastercard:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" fill="#000" rx="2"/><path fill="#ED0006" fill-rule="evenodd" d="M18.25 17.157a6.75 6.75 0 0 1-4.426 1.649c-3.769 0-6.824-3.09-6.824-6.903C7 8.091 10.055 5 13.824 5a6.75 6.75 0 0 1 4.426 1.649A6.75 6.75 0 0 1 22.676 5c3.769 0 6.824 3.09 6.824 6.903 0 3.812-3.055 6.903-6.824 6.903a6.75 6.75 0 0 1-4.426-1.65Z" clip-rule="evenodd"/><path fill="#F9A000" fill-rule="evenodd" d="M18.25 17.157a6.92 6.92 0 0 0 2.398-5.254 6.92 6.92 0 0 0-2.398-5.254A6.75 6.75 0 0 1 22.676 5c3.769 0 6.824 3.09 6.824 6.903 0 3.812-3.055 6.903-6.824 6.903a6.75 6.75 0 0 1-4.426-1.65Z" clip-rule="evenodd"/><path fill="#FF5E00" fill-rule="evenodd" d="M18.25 6.65a6.92 6.92 0 0 1 2.398 5.253 6.92 6.92 0 0 1-2.398 5.254 6.92 6.92 0 0 1-2.398-5.254A6.92 6.92 0 0 1 18.25 6.65Z" clip-rule="evenodd"/></svg>',autoSize:!0},amex:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><g clip-path="url(#a)"><rect width="36" height="24" fill="#016FD0" rx="2"/><path fill="#fff" d="M6.99 18.549v-5.654h5.986l.643.838.663-.838h21.729v5.264s-.569.384-1.226.39H22.754l-.724-.891v.891h-2.373v-1.521s-.325.212-1.025.212h-.808v1.309h-3.593l-.641-.855-.651.855H6.99ZM0 8.634l1.35-3.147h2.334l.767 1.763V5.487h2.902l.456 1.274.442-1.274h13.027v.64s.685-.64 1.81-.64l4.227.015.753 1.74V5.487h2.428l.669 1v-1h2.45v5.654h-2.45l-.64-1.003v1.003h-3.569l-.359-.892h-.959l-.353.892h-2.42c-.968 0-1.587-.628-1.587-.628v.628H17.63l-.725-.892v.892H3.34l-.359-.892h-.956l-.356.892H0V8.634Z"/><path fill="#016FD0" d="M1.827 6.184.006 10.417h1.185l.336-.847H3.48l.335.847h1.211L3.207 6.184h-1.38Zm.673.985.596 1.482H1.903L2.5 7.169ZM5.151 10.416V6.183l1.685.006.98 2.73.956-2.736h1.671v4.233H9.385v-3.12l-1.122 3.12h-.928L6.21 7.296v3.12H5.15ZM11.168 10.416V6.183h3.454v.947h-2.384v.724h2.328v.891h-2.328v.752h2.384v.92h-3.454ZM15.233 6.184v4.233h1.059V8.913h.445l1.27 1.504H19.3l-1.393-1.56a1.29 1.29 0 0 0 1.161-1.3c0-.89-.7-1.373-1.48-1.373h-2.355Zm1.059.947h1.21c.29 0 .5.227.5.446 0 .28-.273.445-.485.445h-1.225v-.891ZM20.582 10.416h-1.08V6.183h1.08v4.233ZM23.144 10.416h-.233c-1.129 0-1.814-.889-1.814-2.1 0-1.24.678-2.133 2.103-2.133h1.17v1.003h-1.213c-.578 0-.988.451-.988 1.141 0 .82.468 1.165 1.142 1.165h.279l-.446.924ZM25.448 6.184l-1.82 4.233h1.185l.336-.847h1.953l.334.847h1.211l-1.819-4.233h-1.38Zm.674.985.595 1.482h-1.192l.597-1.482ZM28.77 10.416V6.183h1.345l1.718 2.66v-2.66h1.059v4.233H31.59l-1.762-2.73v2.73H28.77ZM7.715 17.825v-4.233h3.453v.947H8.784v.724h2.329v.89H8.784v.753h2.384v.919H7.715ZM24.636 17.825v-4.233h3.454v.947h-2.384v.724h2.317v.89h-2.317v.753h2.384v.919h-3.454ZM11.303 17.825l1.681-2.09-1.721-2.143h1.333l1.025 1.324 1.029-1.324h1.281l-1.699 2.116 1.685 2.117h-1.333l-.996-1.304-.971 1.304h-1.314ZM16.041 13.592v4.233h1.086v-1.337h1.114c.943 0 1.658-.5 1.658-1.472 0-.806-.56-1.424-1.52-1.424H16.04Zm1.086.957h1.174c.304 0 .522.187.522.488 0 .282-.217.487-.526.487h-1.17v-.975ZM20.359 13.592v4.233h1.058V16.32h.446l1.269 1.504h1.293l-1.393-1.56a1.29 1.29 0 0 0 1.162-1.3c0-.89-.7-1.373-1.48-1.373h-2.355Zm1.058.947h1.21c.29 0 .501.226.501.445 0 .281-.273.446-.486.446h-1.225v-.891ZM28.58 17.825v-.92H30.7c.313 0 .449-.169.449-.354 0-.178-.136-.358-.45-.358h-.957c-.831 0-1.295-.507-1.295-1.268 0-.679.424-1.333 1.66-1.333h2.062l-.446.952H29.94c-.341 0-.446.179-.446.35 0 .175.13.369.39.369h1.003c.927 0 1.33.526 1.33 1.215 0 .74-.449 1.347-1.38 1.347H28.58ZM32.464 17.825v-.92h2.118c.313 0 .45-.169.45-.354 0-.178-.136-.358-.45-.358h-.957c-.832 0-1.295-.507-1.295-1.268 0-.679.424-1.333 1.66-1.333h2.02l-.404.952h-1.783c-.34 0-.446.179-.446.35 0 .175.13.369.39.369h1.003c.927 0 1.33.526 1.33 1.215 0 .74-.449 1.347-1.38 1.347h-2.256Z"/></g><defs><clipPath id="a"><rect width="36" height="24" fill="#fff" rx="2"/></clipPath></defs></svg>',autoSize:!0},discover:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" fill="#232342" rx="2"/><path fill="#fff" fill-rule="evenodd" d="M30.686 9.61c1.086 0 1.684.484 1.684 1.398a1.307 1.307 0 0 1-1.087 1.397l1.467 1.988h-1.14l-1.25-1.935h-.109v1.935h-.924V9.61h1.359Zm-.435 2.204h.272c.597 0 .869-.269.869-.752 0-.43-.272-.699-.87-.699h-.27v1.45Zm-4.129 2.579h2.608v-.806h-1.684v-1.29h1.63v-.806h-1.63v-1.074h1.684V9.61h-2.608v4.781Zm-2.716-1.559-1.25-3.223h-.978l2.01 4.889h.49l2.01-4.89h-.978l-1.304 3.225Zm-11.029-.805c0 1.343 1.087 2.471 2.445 2.471.435 0 .815-.107 1.195-.269v-1.074c-.271.322-.652.537-1.086.537-.87 0-1.576-.645-1.576-1.504v-.108c-.054-.86.652-1.612 1.521-1.665.435 0 .87.215 1.141.537V9.879c-.326-.214-.76-.268-1.14-.268-1.413-.108-2.5 1.02-2.5 2.418Zm-1.684-.591c-.543-.215-.706-.323-.706-.591.054-.323.326-.591.652-.538.271 0 .543.162.76.376l.49-.644c-.381-.323-.87-.538-1.359-.538-.76-.053-1.412.538-1.467 1.29v.054c0 .644.272 1.02 1.141 1.289.217.054.435.161.652.269a.563.563 0 0 1 .272.483c0 .376-.326.699-.652.699h-.055c-.434 0-.814-.269-.977-.645l-.598.59c.326.592.978.914 1.63.914.869.054 1.575-.59 1.63-1.45v-.162c-.055-.644-.326-.967-1.413-1.396Zm-3.15 2.954h.923V9.611h-.924v4.781ZM3.25 9.611H4.88c1.304.054 2.336 1.128 2.282 2.418 0 .698-.326 1.343-.87 1.826-.488.376-1.086.591-1.684.538H3.25V9.61Zm1.195 3.976c.435.053.924-.108 1.25-.376.326-.323.489-.753.489-1.236 0-.43-.163-.86-.49-1.182-.325-.269-.814-.43-1.249-.376h-.271v3.17h.271Z" clip-rule="evenodd"/><path fill="#FD6020" fill-rule="evenodd" d="M18.788 9.5c-1.358 0-2.499 1.075-2.499 2.471 0 1.344 1.087 2.472 2.5 2.526 1.412.053 2.498-1.075 2.553-2.472C21.287 10.628 20.2 9.5 18.788 9.5Z" clip-rule="evenodd"/></svg>',autoSize:!0},"regular-credit-card":{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" fill="none"><rect width="36" height="24" rx="2" style=\'fill: rgba(var(--v-regular-credit-card-bg, 205, 209, 211, 1))\'/><g clip-path="url(#a)"><path style="fill: rgba(var(--v-regular-credit-card-top, 252, 252, 252, 1))" d="M11 5c-1.103 0-2 .897-2 2v1h18V7c0-1.103-.897-2-2-2H11Zm16 6H9v6c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-6Zm-14.5 4h2c.275 0 .5.225.5.5s-.225.5-.5.5h-2a.501.501 0 0 1-.5-.5c0-.275.225-.5.5-.5Zm3.5.5c0-.275.225-.5.5-.5h4c.275 0 .5.225.5.5s-.225.5-.5.5h-4a.501.501 0 0 1-.5-.5Z"/></g><defs><clipPath id="a"><path d="M9 4h18v16H9z" style=\'fill: rgba(var(--v-regular-credit-card-bottom, 255, 255, 255, 1))\'/></clipPath></defs></svg>',autoSize:!0}}),R([f()],y.prototype,"globalSlimmers",void 0),R([v()],y.prototype,"formFieldController",void 0),R([v()],y.prototype,"changeEventEmitter",void 0),R([v()],y.prototype,"blurEventEmitter",void 0),R([v()],y.prototype,"focusEventEmitter",void 0),R([v()],y.prototype,"inputCreditCardEventPrevent",void 0),R([v()],y.prototype,"vegaComponentUsageRuntimeMetricsSlimmer",void 0),y.style=":host{display:inline-block;width:100%;text-align:left;line-height:normal}";export{y as vega_input_credit_card}