/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";const componentNames=require("./component-names-7808fb62.js"),prop_validators=require("./prop.validators-37d21dea.js"),dev_utils=require("./dev.utils-58fde089.js"),searchFormElement=e=>{for(dev_utils.getExperimentalMode()&&(prop_validators.devHint("↓ Search form element start."),dev_utils.Log.debug(e));e instanceof HTMLElement&&"FORM"!==e.tagName&&e.tagName!==componentNames.KolFormTag.toUpperCase();){try{e=e.parentElement instanceof HTMLElement?e.parentElement:e.parentNode instanceof ShadowRoot?e.parentNode.host:null}catch(e){}dev_utils.getExperimentalMode()&&(dev_utils.Log.debug(e),prop_validators.devHint("↑ Search form element finished."))}return e},propagateResetEventToForm=(e={})=>{var t,o;const r=searchFormElement(e.form);if(r instanceof HTMLElement){const e=new Event("reset",{bubbles:!0,cancelable:!0});if("FORM"===r.tagName)prop_validators.setEventTarget(e,r),r.dispatchEvent(e);else if(r.tagName===componentNames.KolFormTag.toUpperCase()){prop_validators.setEventTarget(e,prop_validators.KoliBriDevHelper.querySelector("form",r));const a=r;"function"==typeof(null===(t=a._on)||void 0===t?void 0:t.onReset)&&(null===(o=a._on)||void 0===o||o.onReset(e))}}},propagateSubmitEventToForm=(e={})=>{const t=searchFormElement(e.form);if(t instanceof HTMLElement){const e=new SubmitEvent("submit",{bubbles:!0,cancelable:!0,submitter:t});if("FORM"===t.tagName)dev_utils.getExperimentalMode()&&!1===t.noValidate&&prop_validators.devHint("If you have not focusable or hidden form fields in your form, you should enable noValidate for your form.",{force:!0}),setTimeout((()=>{"function"==typeof t.requestSubmit?t.requestSubmit():(prop_validators.setEventTarget(e,t),t.dispatchEvent(e))}));else if(t.tagName===componentNames.KolFormTag.toUpperCase()){prop_validators.setEventTarget(e,prop_validators.KoliBriDevHelper.querySelector("form",t));const o=t;setTimeout((()=>{var t,r;"function"==typeof(null===(t=o._on)||void 0===t?void 0:t.onSubmit)&&(null===(r=o._on)||void 0===r||r.onSubmit(e))}))}}};exports.propagateResetEventToForm=propagateResetEventToForm,exports.propagateSubmitEventToForm=propagateSubmitEventToForm;