PageSourceSearch

https://www.clinique.com/cdn/shop/t/104/assets/footer-opt-in-form.3l7jgswA.min.js

js clinique.com collected 2026-10-01 10:32:46 UTC 9,178 bytes, 1 lines download raw bytes

1import{B as t}from"./BaseElement.wji90fuE.min.js";import{r as e}from"./report.LMKEGfPy.min.js";import{e as n,t as s}from"./vendor-lit.2u3dzq2T.min.js";var i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=(t,e,n,s)=>{for(var r,a=s>1?void 0:s?o(e,n):e,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(s?r(e,n,a):r(a))||a);return s&&a&&i(e,n,a),a};const a="footer-opt-in-sms-pending";let l=class extends t{constructor(){super(...arguments),this.submitting=!1,this.allowNativeSubmit=!1}get dialCode(){var t;return(null==(t=this.dialCodeSelect)?void 0:t.value)||this.getAttribute("dial-code")||"+1"}get emailConsentRequired(){return"true"===this.getAttribute("email-consent-required")}get smsCopyVersion(){return this.getAttribute("sms-copy-version")||""}get proxyBase(){return window.__T1_PROXY_BASE__||"/apps/talonone-proxy/api/public"}connectedCallback(){var t,e,n,s,i,o,r,a,l,h;super.connectedCallback(),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleEmailFocus=this.handleEmailFocus.bind(this),this.handlePhoneFocus=this.handlePhoneFocus.bind(this),this.handlePhoneInput=this.handlePhoneInput.bind(this),this.handleFieldEdit=this.handleFieldEdit.bind(this),this.handleDialCodeChange=this.handleDialCodeChange.bind(this),null==(t=this.form)||t.addEventListener("submit",this.handleFormSubmit),null==(e=this.submitButton)||e.addEventListener("click",this.handleFormSubmit),null==(n=this.emailInput)||n.addEventListener("focus",this.handleEmailFocus),null==(s=this.emailInput)||s.addEventListener("input",this.handleFieldEdit),null==(i=this.phoneInput)||i.addEventListener("focus",this.handlePhoneFocus),null==(o=this.phoneInput)||o.addEventListener("input",this.handlePhoneInput),null==(r=this.phoneInput)||r.addEventListener("input",this.handleFieldEdit),null==(a=this.emailConsentInput)||a.addEventListener("change",this.handleFieldEdit),null==(l=this.smsConsentInput)||l.addEventListener("change",this.handleFieldEdit),null==(h=this.dialCodeSelect)||h.addEventListener("change",this.handleDialCodeChange),this.bootstrapFromRedirect()}disconnectedCallback(){var t,e,n,s,i,o,r,a,l,h;super.disconnectedCallback(),null==(t=this.form)||t.removeEventListener("submit",this.handleFormSubmit),null==(e=this.submitButton)||e.removeEventListener("click",this.handleFormSubmit),null==(n=this.emailInput)||n.removeEventListener("focus",this.handleEmailFocus),null==(s=this.emailInput)||s.removeEventListener("input",this.handleFieldEdit),null==(i=this.phoneInput)||i.removeEventListener("focus",this.handlePhoneFocus),null==(o=this.phoneInput)||o.removeEventListener("input",this.handlePhoneInput),null==(r=this.phoneInput)||r.removeEventListener("input",this.handleFieldEdit),null==(a=this.emailConsentInput)||a.removeEventListener("change",this.handleFieldEdit),null==(l=this.smsConsentInput)||l.removeEventListener("change",this.handleFieldEdit),null==(h=this.dialCodeSelect)||h.removeEventListener("change",this.handleDialCodeChange)}bootstrapFromRedirect(){const t=this.resultMarker;t&&("true"===t.dataset.postedSuccessfully?(this.showSuccess(),this.submitPendingSmsConsent(),this.stripPostedFlagFromUrl()):"true"===t.dataset.hasErrors&&this.setState("error-server"))}stripPostedFlagFromUrl(){const t=new URL(window.location.href);t.searchParams.has("customer_posted")&&(t.searchParams.delete("customer_posted"),window.history.replaceState(window.history.state,"",t))}async submitPendingSmsConsent(){var t;let n,s=null;try{s=sessionStorage.getItem(a),sessionStorage.removeItem(a)}catch{return}if(s){try{n=JSON.parse(s)}catch{return}(null==n?void 0:n.phone)&&!(await(async(t,n,s={})=>{const i=`${t}/marketing-consent/sms`;try{const t=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n),signal:s.timeoutMs?AbortSignal.timeout(s.timeoutMs):void 0});return!!t.ok||(e("talon-one","marketing-consent/sms returned an error",{context:{url:i,status:t.status,statusText:t.statusText}}),!1)}catch(o){return e("talon-one","marketing-consent/sms request failed",{cause:o,context:{url:i,timeoutMs:s.timeoutMs}}),!1}})(this.proxyBase,n))&&this.isConnected&&(this.setState("error-api-sms-partial"),null==(t=this.smsPartialErrorBanner)||t.focu
1s())}}handleEmailFocus(){var t;null==(t=this.emailConsentWrap)||t.removeAttribute("hidden")}handlePhoneFocus(){var t;null==(t=this.smsConsentWrap)||t.removeAttribute("hidden")}handlePhoneInput(){var t;this.nationalPhoneDigits().length>0&&(null==(t=this.smsConsentWrap)||t.removeAttribute("hidden"))}handleDialCodeChange(){this.handlePhoneInput(),"error-validation-phone"===this.dataset.state&&(this.clearFieldErrors(),this.resetMessage())}handleFieldEdit(){var t;(null==(t=this.dataset.state)?void 0:t.startsWith("error-validation"))&&(this.clearFieldErrors(),this.resetMessage())}phoneValue(){var t;return String((null==(t=this.phoneInput)?void 0:t.value)??"").trim()}nationalPhoneDigits(){return this.phoneValue().replace(/\D/g,"")}isValidEmail(t){return this.emailInput?(this.emailInput.value=t,this.emailInput.checkValidity()):/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}isValidPhone(t,e){if(!t)return!0;if(!/^[\d\s()+.-]+$/.test(t)||!e)return!1;const n=this.dialCode;if("+44"===n){const t=e.startsWith("0")?e.slice(1):e;return/^7\d{9}$/.test(t)}if("+1"===n)return/^[2-9]\d{2}[2-9]\d{6}$/.test(e);const s=n.replace(/\D/g,"").length;return e.length>=4&&e.length<=15-s}toE164(t){const e=this.dialCode.replace(/\D/g,"");let n=t;return"1"!==e&&n.startsWith("0")&&(n=n.slice(1)),`+${e}${n}`}fieldControl(t){return null==t?void 0:t.closest(".relative")}setFieldError(t,e){const n=this.fieldControl(t);n&&(e?(n.setAttribute("error",""),(t instanceof HTMLInputElement||t instanceof HTMLSelectElement)&&t.setAttribute("aria-invalid","true")):(n.removeAttribute("error"),(t instanceof HTMLInputElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid")))}setConsentError(t,e,n){t&&t.toggleAttribute("data-invalid",n),e&&(n?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"))}clearFieldErrors(){this.setFieldError(this.emailInput,!1),this.setFieldError(this.phoneInput,!1),this.setConsentError(this.emailConsentWrap,this.emailConsentInput,!1),this.setConsentError(this.smsConsentWrap,this.smsConsentInput,!1)}handleFormSubmit(t){var e,n,s,i,o,r,l,h,u;if(this.allowNativeSubmit)return;if(t.preventDefault(),this.submitting)return;this.clearFieldErrors(),this.resetMessage();const d=new FormData(this.form),m=String(d.get("contact[email]")??"").trim(),p=this.phoneValue(),c=this.nationalPhoneDigits(),v=p.length>0;if(!m)return this.setFieldError(this.emailInput,!0),this.setState("error-validation-email-required"),void(null==(e=this.emailInput)||e.focus());if(!this.isValidEmail(m))return this.setFieldError(this.emailInput,!0),this.setState("error-validation-email"),void(null==(n=this.emailInput)||n.focus());if(this.emailConsentRequired&&!(null==(s=this.emailConsentInput)?void 0:s.checked))return null==(i=this.emailConsentWrap)||i.removeAttribute("hidden"),this.setConsentError(this.emailConsentWrap,this.emailConsentInput,!0),this.setState("error-validation-email-consent"),void(null==(o=this.emailConsentInput)||o.focus());if(v){if(!this.isValidPhone(p,c))return this.setFieldError(this.phoneInput,!0),this.setState("error-validation-phone"),void(null==(r=this.phoneInput)||r.focus());if(this.smsConsentInput&&!this.smsConsentInput.checked)return null==(l=this.smsConsentWrap)||l.removeAttribute("hidden"),this.setConsentError(this.smsConsentWrap,this.smsConsentInput,!0),this.setState("error-validation-sms-consent"),void(null==(h=this.smsConsentInput)||h.focus())}const E=v&&!!(null==(u=this.smsConsentInput)?void 0:u.checked);this.contactPhoneInput&&(v&&this.isValidPhone(p,c)?this.contactPhoneInput.value=this.toE164(c):this.contactPhoneInput.value="");try{v&&E?sessionStorage.setItem(a,JSON.stringify({phone:this.toE164(c),consentGiven:!0,copyVersion:this.smsCopyVersion})):sessionStorage.removeItem(a)}catch{}this.submitting=!0,this.setState("loading"),this.submitButton.disabled=!0,this.allowNativeSubmit=!0,this.form.requestSubmit()}showSuccess(){var t;this.setState("success"),null==(t=this.querySelector(".js-footer-opt-in-success"))||t.focus()}setState(t){this.dataset.state=t}resetMessage(){this.dataset.state=""}};r([n("form")],l.prototype,"form",2),r([n(".js-footer-opt-in-submit")],l.prototype,"submitButton",2),r([n('input[type="email"][name="contact[email]"]')],l.prototype,"emailInput",2),r([n('input[type="tel"][name="phone_national"]')],l.prototype,"phoneInput",2),r([n('input[name="contact[phone]"]')],l.prototype,"contactPhoneInput",2),r([n('select[name="country_dial_code"]')],l.prototype,"dialCodeSelect",2),r([n('input[type="checkbox"][name="email_consent"]')],l.prototype,"emailConsentInput",2),r([n('input[type="checkbox"][name="sms_consent"]')],l.prototype,"smsConsentInput",2),r([n("[data-email-consent]")],l.prototype,"emailConsentWrap",2),r([n("[data-sms-consent]")],l.prototype,"smsConsentWrap",2),r([n(".js-footer-opt-in-result")],l.prototype,"resultMarker",2),r([n(".js-footer-opt-in-sms-partial-error")],l.prototype,"smsPartialErrorBanner",2),l=r([s("footer-opt-in-form")],l);export{l as FooterOptInForm};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.