/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as t,h as e,H as i}from"./index-b2c61df0.js";import{t as o}from"./i18n-112381e9.js";import{j as s,k as r,h as a}from"./component-names-068dc2ae.js";import{w as n,b as d,i as l}from"./prop.validators-db70e3c4.js";import"./i18n-66b52d13.js";import"./reuse-b66836de.js";import"./index-db4aa6e4.js";import"./dev.utils-1ca991a2.js";const f=(e,t)=>{n(e,"errorList",(e=>"object"==typeof e),new Set(["Object"]),t)},c=class{constructor(e){t(this,e),this.onSubmit=e=>{var t,i;e.preventDefault(),e.stopPropagation(),"function"==typeof(null===(t=this.state._on)||void 0===t?void 0:t.onSubmit)&&(null===(i=this.state._on)||void 0===i||i.onSubmit(e))},this.onReset=e=>{var t,i;e.preventDefault(),e.stopPropagation(),"function"==typeof(null===(t=this.state._on)||void 0===t?void 0:t.onReset)&&(null===(i=this.state._on)||void 0===i||i.onReset(e))},this.handleLinkClick=e=>{var t;const i=null===(t=e.target)||void 0===t?void 0:t.href;if(i){const e=new URL(i),t=document.querySelector(e.hash);t&&"function"==typeof t.focus&&(t.scrollIntoView({behavior:"smooth"}),t.focus())}},this._on=void 0,this._requiredText=!0,this._errorList=void 0,this.state={}}render(){return e(i,{key:"005270f9d4c739b5f2b399546d91dc8559bb45db",class:"kol-form"},this._errorList&&this._errorList.length>0&&e(r,{key:"7acdf57b3f0954ee26df575334f7521d1898a597",_type:"error"},o("kol-error-list-message"),e("nav",{key:"f16799bcbb7f60baec798674acb9f38c28424ce0","aria-label":o("kol-error-list")},e("ul",{key:"8c86a5fa750031073142d383d1806bcae7a9eec6"},this._errorList.map(((t,i)=>e("li",{key:i},e(a,{_href:t.selector,_label:t.message,_on:{onClick:this.handleLinkClick},ref:e=>{0===i&&(this.errorListElement=e)}}))))))),e("form",{key:"a626ea1dc80b465abfc4153b4c2217a462e3faf0",method:"post",onSubmit:this.onSubmit,onReset:this.onReset,autoComplete:"off",noValidate:!0},!0===this.state._requiredText?e("p",null,e(s,null,o("kol-form-description"))):"string"==typeof this.state._requiredText&&this.state._requiredText.length>0?e("p",null,e(s,null,this.state._requiredText)):null,e("slot",{key:"05b129e368edc5151a8e3b19bc696b749be3db2a"})))}async focusErrorList(){return setTimeout((()=>{var e;this._errorList&&this._errorList.length>0&&(null===(e=this.errorListElement)||void 0===e||e.focus())}),300),Promise.resolve()}validateOn(e){"object"==typeof e&&null!==e&&(this.state=Object.assign(Object.assign({},this.state),{_on:e}))}validateRequiredText(e){"boolean"==typeof e?d(this,"_requiredText",e):l(this,"_requiredText",e)}validateErrorList(e){f(this,e)}componentWillLoad(){this.validateOn(this._on),this.validateRequiredText(this._requiredText),this.validateErrorList(this._errorList)}static get watchers(){return{_on:["validateOn"],_requiredText:["validateRequiredText"],_errorList:["validateErrorList"]}}};export{c as kol_form};