(()=>{"use strict";var e={338(e,t,r){var n=r(795);t.H=n.createRoot,n.hydrateRoot},795(e){e.exports=window.ReactDOM}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const n=window.React;var s=r(338);const o=(0,n.createContext)(null),a={didCatch:!1,error:null};class i extends n.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=a}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){const{error:t}=this.state;null!==t&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(a))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){const{didCatch:r}=this.state,{resetKeys:n}=this.props;r&&null!==t.error&&function(e=[],t=[]){return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)&&(this.props.onReset?.({next:n,prev:e.resetKeys,reason:"keys"}),this.setState(a))}render(){const{children:e,fallbackRender:t,FallbackComponent:r,fallback:s}=this.props,{didCatch:a,error:i}=this.state;let l=e;if(a){const e={error:i,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)l=t(e);else if(r)l=(0,n.createElement)(r,e);else{if(void 0===s)throw i;l=s}}return(0,n.createElement)(o.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}const l=window.wp.i18n,d=window.ReactJSXRuntime,c=new Map,u=class{fallbackRender({error:e}){return(0,d.jsx)("div",{role:"alert",className:"hulk-error-boundary",children:(0,d.jsxs)("pre",{style:{color:"red"},children:[(0,l.__)("Something went wrong:","advanced-fields-for-elementor-forms"),(0,d.jsx)("br",{}),e.message]})})}handleField(e){const t=e.getAttribute("data-key"),r=document.getElementById(t),n=JSON.parse(r.textContent);c.has(e)||c.set(e,(0,s.H)(e));const o=this.fieldComponent(n);c.get(e)?.render((0,d.jsx)(i,{fallbackRender:this.fallbackRender.bind(this),children:o}))}handleWidget(){document.querySelectorAll(".elementor-form").forEach(e=>{e.querySelectorAll(`.${this.name}_wrap`).forEach(e=>this.handleField(e))})}onInit(){document.querySelectorAll(".elementor-form").length>0?this.handleWidget.bind(this)():elementorFrontend.hooks.addAction("frontend/element_ready/form.default",this.handleWidget.bind(this))}constructor(e){this.name=e,window.addEventListener("elementor/frontend/init",this.onInit.bind(this))}},h=window.jQuery;var m=r.n(h);const f=e=>{const t=(0,n.useMemo)(()=>function(e){const t={};for(let[r,n]of Object.entries(e)){let e=n;Array.isArray(n)&&(e=n.join(" ")),"class"===r&&(r="className"),t[r]=String(e)}return t}(e.attrs),[e.attrs]),r=(0,n.useMemo)(()=>{const t=Number(e.attrs.max),r=Number(e.attrs.min);return t<r?r:r+(t-r)/2},[e.attrs.max,e.attrs.min]),s=(0,n.useMemo)(()=>t.value?.trim()||r.toString(),[t.value,r]),o=(0,n.useRef)(null),[a,i]=(0,n.useState)(s);return function(e,t,r){(0,n.useEffect)(()=>{if(!e.current)return;const r=m()(e.current).closest(".elementor-form");return r.on("submit_success.hulk_affef",t),()=>{r.off("submit_success.hulk_affef",t)}},r)}(o,()=>{i(s)},[s]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"hulk-range-input-wrap",children:(0,d.jsx)("input",{ref:o,...t,type:"range",value:a,onChange:function(e){i(e.target.value)}})}),e.showInput&&(0,d.jsx)("div",{className:"hulk-show-input-wrap",children:(0,d.jsx)("input",{type:"number",className:"elementor-field elementor-field-textual hulk-show-input",value:a,onChange:function(e){i(e.target.value)},min:t.min,max:t.max,step:t.step})})]})};new class extends u{fieldComponent(e){return(0,d.jsx)(f,{...e})}}("hulk_affef_native_range")})();