import{r as s,c as i,h as t}from"./p-e97fde0a.js";import{s as o}from"./p-894c7006.js";import{s as e,o as a}from"./p-53e7f7d7.js";import{a as h}from"./p-93127aa7.js";import{c as n}from"./p-75e76c8c.js";import"./p-03631502.js";import"./p-9dbc54d6.js";import"./p-d3366af3.js";import"./p-401e165e.js";import"./p-830ab1a3.js";import"./p-ec182234.js";import"./p-3f6362a4.js";import"./p-95325ec5.js";import"./p-4df6e0c5.js";import"./p-dd3464cd.js";const d=":host{display:block}";const l=d;const c=class{constructor(t){s(this,t);this.scInput=i(this,"scInput",7);this.scFocus=i(this,"scFocus",7);this.scBlur=i(this,"scBlur",7);this.loggedIn=undefined;this.size="medium";this.value=null;this.pill=false;this.label=undefined;this.showLabel=true;this.help="";this.placeholder=undefined;this.disabled=false;this.readonly=false;this.required=false;this.invalid=false;this.autofocus=undefined;this.hasFocus=undefined}async reportValidity(){return this.input.reportValidity()}async handleChange(){this.value=this.input.value;try{e.checkout=await n({id:e.checkout.id,data:{last_name:this.input.value}})}catch(s){console.error(s)}}handleSessionChange(){var s,i,t,a,n,d;if(this.value)return;const l=h("last_name");if(!o.loggedIn&&!!l){this.value=l;return}if(o.loggedIn){this.value=((i=(s=e===null||e===void 0?void 0:e.checkout)===null||s===void 0?void 0:s.customer)===null||i===void 0?void 0:i.last_name)||((t=e===null||e===void 0?void 0:e.checkout)===null||t===void 0?void 0:t.last_name)}else{this.value=((a=e===null||e===void 0?void 0:e.checkout)===null||a===void 0?void 0:a.last_name)||((d=(n=e===null||e===void 0?void 0:e.checkout)===null||n===void 0?void 0:n.customer)===null||d===void 0?void 0:d.last_name)}}componentWillLoad(){this.handleSessionChange();this.removeCheckoutListener=a("checkout",(()=>this.handleSessionChange()))}disconnectedCallback(){this.removeCheckoutListener()}render(){return t("sc-input",{key:"a823ba41f05201d19d051c703978c0c7fb245010",type:"text",name:"last_name",ref:s=>this.input=s,value:this.value,label:this.label,help:this.help,autocomplete:"last_name",placeholder:this.placeholder,readonly:this.readonly,required:this.required,invalid:this.invalid,autofocus:this.autofocus,hasFocus:this.hasFocus,onScChange:()=>this.handleChange(),onScInput:()=>this.scInput.emit(),onScFocus:()=>this.scFocus.emit(),onScBlur:()=>this.scBlur.emit(),...this.disabled&&{disabled:true}})}};c.style=l;export{c as sc_customer_lastname};
//# sourceMappingURL=p-37b3c4b7.entry.js.map