{ "version": 3, "sources": ["../../assets/scripts/store/features/registration/events.ts"], "sourcesContent": ["// @TODO: AK SA MENI KRAJINA, AJ TU TREBA ZMENIT\r\nexport const defaultCountry = 'sk';\r\nexport const defaultCountryRegex = /^sk$/is;\r\nexport const vatNumberSlovakRegex = /^(SK)+/is;\r\n\r\nexport function isValidForNotVatRegistration(country: string, vatNumber: string | null) {\r\n return (\r\n !defaultCountryRegex.test(country) &&\r\n !!vatNumber &&\r\n vatNumber.length > 2 &&\r\n !vatNumberSlovakRegex.test(vatNumber)\r\n );\r\n}\r\n\r\nexport function addRegistrationFormHandler() {\r\n document.addEventListener('change', ({ target }) => {\r\n if (!(target instanceof HTMLElement)) return;\r\n if (!target.matches('#Form_NotVatRegistered')) return;\r\n\r\n const notVatRegisteredEl = document.getElementById('Form_NotVatRegistered') as HTMLInputElement;\r\n const notVatRegistered = notVatRegisteredEl?.checked ?? false;\r\n\r\n const options = document.querySelectorAll(\r\n 'select[autocomplete=\"country\"] > option'\r\n );\r\n options.forEach(option => {\r\n if (option.value !== defaultCountry) return;\r\n if (notVatRegistered) option.classList.add('hidden');\r\n else option.classList.remove('hidden');\r\n });\r\n });\r\n\r\n document.addEventListener('change', event => {\r\n const target = event.target as HTMLElement;\r\n if (!target.matches('#Form_BillingCountryCode') && !target.matches('#Form_VatNumber')) return;\r\n\r\n const countryEl = document.getElementById('Form_BillingCountryCode');\r\n const vatNumberEl = document.getElementById('Form_VatNumber');\r\n const notVatRegisteredEl = document.getElementById('Form_NotVatRegistered');\r\n\r\n if (\r\n !(countryEl instanceof HTMLSelectElement) ||\r\n !(vatNumberEl instanceof HTMLInputElement) ||\r\n !(notVatRegisteredEl instanceof HTMLInputElement)\r\n )\r\n return;\r\n\r\n if (isValidForNotVatRegistration(countryEl.value, vatNumberEl.value)) {\r\n notVatRegisteredEl.disabled = false;\r\n notVatRegisteredEl.parentElement?.setAttribute('aria-disabled', 'false');\r\n } else {\r\n notVatRegisteredEl.checked = false;\r\n notVatRegisteredEl.disabled = true;\r\n notVatRegisteredEl.parentElement?.setAttribute('aria-disabled', 'true');\r\n }\r\n });\r\n\r\n document.addEventListener('change', event => {\r\n const target = event.target as HTMLInputElement;\r\n if (!target.matches('[data-action=\"toggleAsOrganization\"]')) return;\r\n\r\n const isOrganization = target.checked;\r\n\r\n const organizationFields = document.getElementById('organizationFields');\r\n organizationFields?.classList.toggle('hidden');\r\n\r\n const consentsFieldset = document.getElementById('consentsSection');\r\n const consentsEveryone = document.getElementById('consentsEveryone');\r\n\r\n const consentsCitizen = document.getElementById('consentsCitizen');\r\n consentsCitizen?.classList.toggle('hidden');\r\n\r\n const consentsCompany = document.getElementById('consentsCompany');\r\n consentsCompany?.classList.toggle('hidden');\r\n\r\n if (consentsEveryone) {\r\n consentsFieldset?.classList.remove('hidden');\r\n }\r\n\r\n if (isOrganization && !consentsCompany && !consentsEveryone) {\r\n consentsFieldset?.classList.add('hidden');\r\n } else if (isOrganization) {\r\n consentsFieldset?.classList.remove('hidden');\r\n }\r\n\r\n if (!isOrganization && !consentsCitizen && !consentsEveryone) {\r\n consentsFieldset?.classList.add('hidden');\r\n } else if (!isOrganization) {\r\n consentsFieldset?.classList.remove('hidden');\r\n }\r\n });\r\n}\r\n"], "mappings": ";AACO,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,uBAAuB;AAE7B,SAAS,6BAA6B,SAAiB,WAA0B;AACtF,SACE,CAAC,oBAAoB,KAAK,OAAO,KACjC,CAAC,CAAC,aACF,UAAU,SAAS,KACnB,CAAC,qBAAqB,KAAK,SAAS;AAExC;AAEO,SAAS,6BAA6B;AAC3C,WAAS,iBAAiB,UAAU,CAAC,EAAE,OAAO,MAAM;AAClD,QAAI,EAAE,kBAAkB,aAAc;AACtC,QAAI,CAAC,OAAO,QAAQ,wBAAwB,EAAG;AAE/C,UAAM,qBAAqB,SAAS,eAAe,uBAAuB;AAC1E,UAAM,mBAAmB,oBAAoB,WAAW;AAExD,UAAM,UAAU,SAAS;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