import{r as s,h as e}from"./p-1a7a8b00.js";import{M as t,r}from"./p-487241b6.js";const i=class{constructor(e){s(this,e),this.answerId=void 0,this.questionId=void 0,this.min=void 0,this.minDate=void 0,this.max=void 0,this.maxDate=void 0,this.fieldType=void 0,this.pattern=void 0,this.errors=[],this.errorText=void 0,this.errorMessages=void 0,this.useExternal=!1}transformError(s){switch(s){case t.MaximumValue:case t.MinimumValue:return r.includes(this.fieldType)?this.errorMessages.value(this.min,this.max):this.errorMessages.length(this.min,this.max);case t.MinimumDate:case t.MaximumDate:return this.errorMessages.date(this.minDate,this.maxDate);case t.Required:return this.errorMessages.required();case t.Pattern:return this.errorMessages.pattern()}return s}resetState(){}connectedCallback(){this.resetState()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-errors"),customElements.whenDefined("bp-sdk-external-errors").then((()=>{this.useExternal=!0}))}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return e("bp-sdk-external-errors",{answerId:this.answerId,errorMessages:this.errorMessages,errors:this.errors,errorText:this.errorText,fieldType:this.fieldType,maxDate:this.maxDate,max:this.max,minDate:this.minDate,min:this.min,pattern:this.pattern,questionId:this.questionId})}renderInternal(){return e("div",{class:"bp-sdk-errors__container"},this.errorText&&e("span",{"aria-live":"polite",id:`bp-sdk-error-${this.answerId}-text`,class:`bp-sdk-errors-text bp-sdk-errors-text-${this.answerId}`},this.errorText),!this.errorText&&e("ul",{class:"bp-sdk-errors__list"},this.errors.map((s=>e("li",{"aria-live":"polite",id:`bp-sdk-errors__${this.answerId}-${s}`,class:`bp-sdk-errors__list-item bp-sdk-errors__list-item-${this.answerId}`},this.transformError(s))))))}};i.style="";const a=class{constructor(e){s(this,e),this.answerId=void 0,this.questionId=void 0,this.min=void 0,this.minDate=void 0,this.max=void 0,this.maxDate=void 0,this.fieldType=void 0,this.pattern=void 0,this.errors=[],this.errorText=void 0,this.errorMessages=a.DEFAULT_ERROR_MESSAGES,this.useExternal=!1}resetState(){}connectedCallback(){this.resetState()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-errors-container"),customElements.whenDefined("bp-sdk-external-errors-container").then((()=>{this.useExternal=!0}))}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return e("bp-sdk-external-errors-container",{answerId:this.answerId,errorText:this.errorText,errorMessages:this.errorMessages,errors:this.errors,fieldType:this.fieldType,maxDate:this.maxDate,max:this.max,minDate:this.minDate,min:this.min,pattern:this.pattern,questionId:this.questionId})}renderInternal(){return e("bp-sdk-errors",{answerId:this.answerId,questionId:this.questionId,fieldType:this.fieldType,min:this.min,max:this.max,minDate:this.minDate,maxDate:this.maxDate,pattern:this.pattern,errorMessages:this.errorMessages,errors:this.errors,errorText:this.errorText})}};a.DEFAULT_ERROR_MESSAGES={value:(s,e)=>null!=s&&null!=e?`Please select a value in range of ${s} to ${e}.`:null!=s?`Please select a value of ${s} or larger.`:`Please select a value of ${s} or smaller.`,length:(s,e)=>null!=s&&s===e?`Please rephrase your answer in ${s} characters.`:null!=s&&null!=e?`Please rephrase your answer in ${s}-${e} characters.`:null!=s?`Please rephrase your answer in more than ${s} characters.`:`Please rephrase your answer in less than ${e} characters.`,date:(s,e)=>null!=s&&null!=e?`Please select a date ${s===e?`of ${s}`:`between ${s} and ${e}`}.`:null!=s?`Please select a date after ${s}.`:`Please select a date before ${e}.`,required:()=>"An answer is required for this question.",pattern:()=>"Input does not look correct"},a.style="";export{i as bp_sdk_errors,a as bp_sdk_errors_container}