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GAAS,CAAC;SAClD;QAED,QACED,QAACC,UAAI,QACHD,sBAAU,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAACL,eAAU,aAAVA,eAAU,uBAAVA,eAAU,CAAE,OAAO,CAAA,EAAE,QAAQ,EAAE,CAAC,EAACA,eAAU,aAAVA,eAAU,uBAAVA,eAAU,CAAE,WAAW,CAAA,IACtH,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAIK,kBAAM,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAS,EAC3F,CAACD,oCAA0B,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,OAAO,EAAEG,OAAK,MACvDF,iBAAK,SAAS,EAAE,OAAO,EAAE,GAAG,EAAEE,OAAK,GAAQ,CAC5C,CAAC,CACO,EACXF,qBAAQ,CACH,EACP;KACH;;;;;;","names":["errorState","onChange","currentFormState","removeNotice","getAdditionalErrorMessages","h","Host","index"],"sources":["src/components/controllers/checkout-form/checkout-form-errors/sc-checkout-form-errors.scss?tag=sc-checkout-form-errors&encapsulation=shadow","src/components/controllers/checkout-form/checkout-form-errors/sc-checkout-form-errors.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\nul {\n margin: 6px 0px;\n padding: 0px;\n list-style: none;\n}\n","/**\n * External dependencies.\n */\nimport { Component, h, Host } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies.\n */\nimport { state as errorState } from '@store/notices';\nimport { getAdditionalErrorMessages } from '@store/notices/getters';\nimport { currentFormState } from '@store/form/getters';\nimport { onChange } from '@store/form';\nimport { removeNotice } from '@store/notices/mutations';\n\n/**\n * This component listens for a confirmed event and redirects to the success url.\n */\n@Component({\n tag: 'sc-checkout-form-errors',\n styleUrl: 'sc-checkout-form-errors.scss',\n shadow: true,\n})\nexport class ScCheckoutFormErrors {\n private removeStateListener = () => {};\n /**\n * Get the alert type.\n * @returns string\n */\n getAlertType() {\n switch (errorState?.type) {\n case 'error':\n return 'danger';\n case 'default':\n return 'primary';\n default:\n return errorState?.type;\n }\n }\n\n componentWillLoad() {\n // remove notice if finalizing or updating.\n this.removeStateListener = onChange('formState', () => {\n if (['finalizing', 'updating'].includes(currentFormState())) {\n removeNotice();\n }\n });\n }\n\n disconnectedCallback() {\n this.removeStateListener();\n }\n\n getTopLevelError() {\n // checkout invalid is not friendly.\n if (errorState?.code === 'checkout.invalid' && getAdditionalErrorMessages()?.length) {\n return '';\n }\n return errorState?.message;\n }\n\n render() {\n // don't show component if no error message or is finalizing or updating.\n if (!errorState?.message || ['finalizing', 'updating'].includes(currentFormState())) {\n return <Host style={{ display: 'none' }}></Host>;\n }\n\n return (\n <Host>\n <sc-alert type={this.getAlertType()} scrollOnOpen={true} open={!!errorState?.message} closable={!!errorState?.dismissible}>\n {!!this.getTopLevelError() && <span slot=\"title\" innerHTML={this.getTopLevelError()}></span>}\n {(getAdditionalErrorMessages() || []).map((message, index) => (\n <div innerHTML={message} key={index}></div>\n ))}\n </sc-alert>\n <slot />\n </Host>\n );\n }\n}\n"],"version":3}