import{r as t,c as i,h as s,g as e}from"./p-1a7a8b00.js";import{e as h,f as n}from"./p-19cd3f24.js";const r=class{constructor(s){t(this,s),this.vinUpdate=i(this,"vinUpdate",7),this.onFocusOut=()=>{this.touched=!0,this.updateErrors(this.pristine,!0,this.value)},this.value=void 0,this.answerId=void 0,this.code=h(8),this.useExternal=!1,this.touched=!1,this.pristine=!0,this.errors=[]}resetState(){this.touched=!1,this.pristine=!0,this.errors=[]}connectedCallback(){this.resetState()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-vehicle-vin-input-container"),customElements.whenDefined("bp-sdk-external-vehicle-vin-input-container").then((()=>{this.useExternal=!0}))}loadFocusEvents(){this.useExternal||this.el.addEventListener("focusout",this.onFocusOut)}unloadFocusEvents(){this.el.removeEventListener("focusout",this.onFocusOut)}componentDidLoad(){this.loadFocusEvents()}disconnectedCallback(){this.unloadFocusEvents()}onValueUpdate(t){var i;this.useExternal||(this.pristine=!1,this.value=(null!==(i=t.detail)&&void 0!==i?i:[])[0],this.updateErrors(!1,this.touched,this.value),0===this.errors.length&&this.vinUpdate.emit({vin:this.value,answerId:this.answerId}))}updateErrors(t,i,s){this.errors=n(t,i,s)?["required"]:[]}onMakeDirty(){this.touched=!0,this.pristine=!1}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return s("bp-sdk-external-vehicle-vin-input-container",null)}renderInternal(){return s("bp-sdk-vehicle-vin-input",{value:this.value,code:this.code,label:"Enter vehicle VIN",touched:this.touched,pristine:this.pristine,errors:this.errors})}get el(){return e(this)}};r.style="";export{r as bp_sdk_vehicle_vin_input_container}