import*as t from"lit";import*as e from"lit/decorators.js";import*as r from"lit/directives/if-defined.js";var i,o,s={9147(t,e,r){r.d(e,{l:()=>i});var i,o=r(7704),s=r(2927),n=r(8899),a=r(3517),p=function(t,e,r,i){var o,s=arguments.length,n=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n};!function(t){let e=class extends((0,o.TS)(s.LitElement)){constructor(){super(...arguments),this.rel="",this.name="",this.action="",this.label="",this.method="get",this.target="_self",this.enctype="application/x-www-form-urlencoded",this.novalidate=!1,this.charset="UTF-8",this.isvalid=!1,this.token="on",this.allowRedirect=!1,this.autofillname="input-name",this.formElement=[],this.handleSubmit=t=>{t.preventDefault(),this.validated()&&this.submitForm()},this.handleFormSubmit=t=>{this.allowRedirect||t.preventDefault(),this.dispatchEvent(new CustomEvent("form-submitted",{composed:!0,bubbles:!0}))}}get formMethod(){return"GET"===this.method?"get":"POST"===this.method?"post":this.method}isSubmittable(t){return t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement}isDisabled(t){return t.hasAttribute("disabled")||"true"===t.getAttribute("aria-disabled")}findSubmittable(t,e){const r=Array.from(t.children);for(const t of r)if(!this.isDisabled(t))if(this.isSubmittable(t)&&e.add(t),t.shadowRoot)this.findSubmittable(t.shadowRoot,e);else if("SLOT"===t.tagName){const r=t.assignedElements();if(r.length){const{parentElement:t}=r[0];t&&this.findSubmittable(t,e)}}else this.findSubmittable(t,e);return[...e]}validated(){return!!this.novalidate||this.isvalid}submitForm(){const{form:t}=this;t.requestSubmit?t.requestSubmit():t.submit()}get submitButton(){return this.querySelector("button[type='submit']")||this.querySelector("input[type='submit']")||this.querySelector("md-button[type='submit']")}disconnectedCallback(){super.disconnectedCallback(),this.cleanupWrappedForms(),this.teardownEvents()}deleteWrappedForm(t){t.removeEventListener("submit",this.handleFormSubmit)}cleanupWrappedForms(){const{formElement:t}=this;if(t.length)for(const e of t)this.deleteWrappedForm(e);this.formElement=[]}createWrappedForm(t){const e=document.createElement("form");e.addEventListener("submit",this.handleFormSubmit);const{parentNode:r}=t;t.autocomplete=this.token,t.id||(t.id=this.autofillname),t.name||(t.name=this.autofillname),r&&(this.formElement.push(e),r.insertBefore(e,t),e.append(t))}teardownEvents(){this.submitButton&&this.submitButton.removeEventListener("click",this.handleSubmit)}setupEvents(){this.submitButton&&this.submitButton.addEventListener("click",this.handleSubmit)}setupSubmittable(){const t=this.findSubmittable(this.form,new Set);if(t.length)for(const e of t)this.createWrappedForm(e)}slottedChanged(){this.setupSubmittable(),this.setupEvents()}render(){return s.html`
        <form
          class="md-form"
          role="form"
          name=${(0,a.ifDefined)(this.name||void 0)}
          rel=${(0,a.ifDefined)(this.rel||void 0)}
          action=${(0,a.ifDefined)(this.action||void 0)}
          accept-charset=${this.charset}
          enctype=${this.enctype}
          aria-label=${(0,a.ifDefined)(this.label||void 0)}
          ?novalidate=${this.novalidate}
          method=${this.formMethod}
          target=${this.target}
          part="form"
          @submit=${this.handleFormSubmit}
        >
          <slot></slot>
        </form>
      `}};p([(0,n.property)({type:String})],e.prototype,"rel",void 0),p([(0,n.property)({type:String})],e.prototype,"name",void 0),p([(0,n.property)({type:String})],e.prototype,"action",void 0),p([(0,n.property)({type:String})],e.prototype,"label",void 0),p([(0,n.property)({type:String})],e.prototype,"method",void 0),p([(0,n.property)({type:String})],e.prototype,"target",void 0),p([(0,n.property)({type:String})],e.prototype,"enctype",void 0),p([(0,n.property)({type:Boolean,reflect:!0,attribute:"no-validate"})],e.prototype,"novalidate",void 0),p([(0,n.property)({type:String,reflect:!0,attribute:"accept-charset"})],e.prototype,"charset",void 0),p([(0,n.property)({type:Boolean,reflect:!0,attribute:"is-valid"})],e.prototype,"isvalid",void 0),p([(0,n.property)({type:String,attribute:"autofill-token"})],e.prototype,"token",void 0),p([(0,n.property)({type:Boolean,attribute:"allow-redirect"})],e.prototype,"allowRedirect",void 0),p([(0,n.property)({type:String,attribute:"autofill-name"})],e.prototype,"autofillname",void 0),p([(0,n.query)(".md-form")],e.prototype,"form",void 0),e=p([(0,o.wW)("md-form")],e),t.ELEMENT=e}(i||(i={}))},2927(e,r,i){var o,s;e.exports=(o={LitElement:()=>t.LitElement,html:()=>t.html},s={},i.d(s,o),s)},8899(t,r,i){var o,s;t.exports=(o={property:()=>e.property,query:()=>e.query},s={},i.d(s,o),s)},3517(t,e,i){var o,s;t.exports=(o={ifDefined:()=>r.ifDefined},s={},i.d(s,o),s)}},n={};function a(t){var e=n[t];if(void 0!==e)return e.exports;var r=n[t]={exports:{}};return s[t](r,r.exports,a),r.exports}a.m=s,i=[],a.O=(t,e,r,o)=>{if(!e){var s=1/0;for(m=0;m<i.length;m++){for(var[e,r,o]=i[m],n=!0,p=0;p<e.length;p++)(!1&o||s>=o)&&Object.keys(a.O).every(t=>a.O[t](e[p]))?e.splice(p--,1):(n=!1,o<s&&(s=o));if(n){i.splice(m--,1);var l=r();void 0!==l&&(t=l)}}return t}o=o||0;for(var m=i.length;m>0&&i[m-1][2]>o;m--)i[m]=i[m-1];i[m]=[e,r,o]},a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{a as __webpack_require__};o={6060:0,6494:0},a.C=t=>{var e,r,{__webpack_esm_ids__:i,__webpack_esm_modules__:s,__webpack_esm_runtime__:n}=t,p=0;for(e in s)a.o(s,e)&&(a.m[e]=s[e]);for(n&&n(a);p<i.length;p++)r=i[p],a.o(o,r)&&o[r]&&o[r][0](),o[i[p]]=0;a.O()},a.O.j=t=>0===o[t];import*as p from"../9609.js";a.C(p);import*as l from"../2364.js";a.C(l);import*as m from"../9938.js";a.C(m);import*as d from"../4781.js";a.C(d);import*as h from"../5201.js";a.C(h);import*as u from"../608.js";a.C(u);import*as f from"../3203.js";a.C(f);import*as c from"../5757.js";a.C(c);import*as b from"../8180.js";a.C(b);var v=a.O(void 0,[9609,2364,9938,4781,5201,608,3203,5757,8180],()=>a(9147));const y=(v=a.O(v)).l;export{y as Form};