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AI,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAC/B,EACZ;KACH;;;;;;","names":["checkoutState","createOrUpdateCheckout","getValueFromUrl","userState","onChange","h"],"sources":["src/components/controllers/checkout-form/customer-lastname/sc-customer-lastname.css?tag=sc-customer-lastname&encapsulation=shadow","src/components/controllers/checkout-form/customer-lastname/sc-customer-lastname.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Customer, Checkout } from '../../../../types';\nimport { Component, Prop, h, Event, EventEmitter, Method } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport { state as userState } from '@store/user';\nimport { state as checkoutState, onChange } from '@store/checkout';\nimport { getValueFromUrl } from '../../../../functions/util';\nimport { createOrUpdateCheckout } from '../../../../services/session';\n\n@Component({\n tag: 'sc-customer-lastname',\n styleUrl: 'sc-customer-lastname.css',\n shadow: true,\n})\nexport class ScCustomerLastname {\n private input: HTMLScInputElement;\n\n private removeCheckoutListener: () => void;\n\n /** Is the user logged in. */\n @Prop() loggedIn: boolean;\n\n /** The input's size. */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value = null;\n\n /** Draws a pill-style input with rounded edges. */\n @Prop({ reflect: true }) pill = false;\n\n /** The input's label. */\n @Prop() label: string;\n\n /** Should we show the label */\n @Prop() showLabel: boolean = true;\n\n /** The input's help text. */\n @Prop() help: string = '';\n\n /** The input's placeholder text. */\n @Prop() placeholder: string;\n\n /** Disables the input. */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /** Makes the input readonly. */\n @Prop({ reflect: true }) readonly: boolean = false;\n\n /** Makes the input a required field. */\n @Prop({ reflect: true }) required = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity is determined by props such as `type`,\n * `required`, `minlength`, `maxlength`, and `pattern` using the browser's constraint validation API.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The input's autofocus attribute. */\n @Prop() autofocus: boolean;\n\n /** Inputs focus */\n @Prop({ mutable: true, reflect: true }) hasFocus: boolean;\n\n /** Emitted when the control receives input. */\n @Event() scInput: EventEmitter<void>;\n\n /** Emitted when the control gains focus. */\n @Event() scFocus: EventEmitter<void>;\n\n /** Emitted when the control loses focus. */\n @Event() scBlur: EventEmitter<void>;\n\n /** Don't allow a blank space as an input here. */\n @Method()\n async reportValidity() {\n return this.input.reportValidity();\n }\n\n /** Silently update the checkout when the input changes. */\n async handleChange() {\n this.value = this.input.value;\n try {\n checkoutState.checkout = (await createOrUpdateCheckout({ id: checkoutState.checkout.id, data: { last_name: this.input.value } })) as Checkout;\n } catch (error) {\n console.error(error);\n }\n }\n\n /** Sync customer last name with session if it's updated by other means */\n handleSessionChange() {\n // we already have a value.\n if (this.value) return;\n\n const fromUrl = getValueFromUrl('last_name');\n if (!userState.loggedIn && !!fromUrl) {\n this.value = fromUrl;\n return;\n }\n\n if (userState.loggedIn) {\n this.value = (checkoutState?.checkout?.customer as Customer)?.last_name || checkoutState?.checkout?.last_name;\n } else {\n this.value = checkoutState?.checkout?.last_name || (checkoutState?.checkout?.customer as Customer)?.last_name;\n }\n }\n\n /** Listen to checkout. */\n componentWillLoad() {\n this.handleSessionChange();\n this.removeCheckoutListener = onChange('checkout', () => this.handleSessionChange());\n }\n\n /** Remove listener. */\n disconnectedCallback() {\n this.removeCheckoutListener();\n }\n\n render() {\n return (\n <sc-input\n type=\"text\"\n name=\"last_name\"\n ref={el => (this.input = el as HTMLScInputElement)}\n value={this.value}\n label={this.label}\n help={this.help}\n autocomplete=\"last_name\"\n placeholder={this.placeholder}\n readonly={this.readonly}\n required={this.required}\n invalid={this.invalid}\n autofocus={this.autofocus}\n hasFocus={this.hasFocus}\n onScChange={() => this.handleChange()}\n onScInput={() => this.scInput.emit()}\n onScFocus={() => this.scFocus.emit()}\n onScBlur={() => this.scBlur.emit()}\n {...(this.disabled && { disabled: true })}\n ></sc-input>\n );\n }\n}\n"],"version":3}