"use strict";(self.webpackChunk_surecart_blocks_next=self.webpackChunk_surecart_blocks_next||[]).push([[5510],{5510:function(t,e,s){s.r(e),s.d(e,{sc_form:function(){return i}});var o=s(6892);function r(t){const e=new FormData(t),s={};return e.forEach(((t,e)=>{s[e]=t})),s}const i=class{constructor(t){(0,o.r)(this,t),this.scSubmit=(0,o.c)(this,"scSubmit",7),this.scFormSubmit=(0,o.c)(this,"scFormSubmit",7),this.scFormChange=(0,o.c)(this,"scFormChange",7),this.novalidate=!1}async getFormData(){return new FormData(this.formElement)}async getFormJson(){return r(this.formElement)}async handleChange(){this.scFormChange.emit(r(this.formElement))}async submit(){return this.submitForm()}getFormControls(){return[...this.form.querySelectorAll("*")]}async validate(){const t=this.getFormControls().filter((t=>"function"==typeof t.reportValidity));if(!this.novalidate)for(const e of t)if((e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&!await e.reportValidity())return!1;return!0}submitForm(){const t=document.createElement("button");this.formElement&&(t.type="submit",t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.clip="rect(0 0 0 0)",t.style.clipPath="inset(50%)",t.style.overflow="hidden",t.style.whiteSpace="nowrap",this.formElement.append(t),t.click(),t.remove())}render(){return(0,o.h)("div",{key:"afbedd7cc354e641c4b615628c8dbb813729624c",part:"base",class:"form",role:"form"},(0,o.h)("form",{key:"a9b5b52081af16eb861563374927591112f893ce",part:"form",ref:t=>this.formElement=t,class:"test",onSubmit:async t=>{if(t.preventDefault(),!await this.validate())return!1;this.scSubmit.emit(),this.scFormSubmit.emit()},novalidate:this.novalidate},(0,o.h)("slot",{key:"8bdf63e445592e71155c9a7d3db57a88eb0374c3"})))}get form(){return(0,o.a)(this)}};i.style=":host{display:block}::slotted(*:not(:last-child)){margin-bottom:var(--sc-form-row-spacing, 0.75em)}::slotted(*:not(:last-child)).wp-block-spacer{margin-bottom:0}::slotted(*:focus-within),::slotted(*:active){position:relative;z-index:var(--sc-form-focus-within-z-index, auto);}"}}]);