PageSourceSearch

https://settlrglobal.com/assets/contact-B-J5iJ1O.js

js settlrglobal.com collected 2026-10-04 02:40:17 UTC 74,595 bytes, 1 lines download raw bytes

1import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{n as t,t as n}from"./navbar-Nl1l42aa.js";import{a as r,c as i,f as a,i as o,n as s,r as c,t as l}from"./src-BcaPNpws.js";import{r as u}from"./Navbar-DW33Loce.js";import{a as d,i as f,n as p,r as m,s as h,t as g}from"./content-b8ZUJI-h.js";import{t as _}from"./ServicePageLayout-BkSCiQ2y.js";import{t as v}from"./style-CNeX89z9.js";import{cr as y,lr as b,or as x,sr as S}from"./index-i4gGdaZ9.js";import{t as ee}from"./ContactMap-1kyK4hUf.js";var C=class{constructor(e,t){this.atom=y(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(b(e))}},te=class{constructor(e){this.atom=y(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(b(e))}};function w(e,t){return typeof e==`function`?new te(e):t?new C(e,t):new C(e)}var ne=`/api/contact`;function re(){return`0x4AAAAAAEuveulZRRaFdh5t`}var ie=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function ae(e,t){return new ie(e,t).maybeExecute}var oe=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i
1),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},T=new class extends oe{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function E(e,t){return typeof e==`function`?e(t):e}function D(e,t){return pe(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function O(e,t,n){let r=pe(t);function i(e){if(!r.length)return E(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function se(e,t){let n=pe(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var ce=46,le=91,ue=93,de=48,fe=57;function pe(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===le),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===ce||s===le||s===ue){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==de),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==ue&&!(a===-1&&s===ue)&&!(a===s&&(s===ce||s===le))&&n.push(``);r=o+1,i=!0}else(s<de||s>fe)&&(i=!1);a=s}return n.length||n.push(``),n}function me(e){return!(Array.isArray(e)&&e.length===0)}function k(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function A(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0;break}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var j=e=>!!e&&typeof e==`object`&&`fields`in e;function M(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!M(e[i],t[i]))return!1;return!0}var he=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},N=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function P(e,t){return e==null?t:{...e,...t}}for(var F=256,I=[],L;F--;)I[F]=(F+256).toString(16).substring(1);function ge(){let e=0,t,n=``;if(!L||F+16>256){for(L=Array(256),e=256;e--;)L[e]=256*Math.random()|0;e=0,F=0}for(;e<16;
1e++)t=L[F+e],e===6?n+=I[t&15|64]:e===8?n+=I[t&63|128]:n+=I[t],e&1&&e>1&&e<11&&(n+=`-`);return F++,n}var _e=ae(e=>T.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function R(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=R(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,R(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(R(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=R(e[n]));return t}function z(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var B=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function ve(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);Array.isArray(i)&&!Number.isNaN(o)?a+=`[${o}]`:a+=(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var ye=(e,t)=>{let n=ve(e,t);return{form:n,fields:n}},V={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:ye(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:ye(r.issues,e)}},be=e=>!!e&&`~standard`in e,H={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function U(e){function t(t){let n=e.getFieldMeta(t)??H;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>H;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function xe(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var Se=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{_e(this)}),t=T.on(`request-form-state`,e=>{e.payload.id===this._formId&&T.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=T.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=T.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),T.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return T.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!M(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!M(e.defaultState,t.defaultState)&&!this.state.isTouched;if(!(!n&&!r)){if(S(()=>{this.baseStore.setState(()=>xe(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=U(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}T.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;
1return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=O(t,e.instance.name,e.instance.options.defaultValue))}),xe({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return S(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return S(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=k(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||B}),r=!1,i={};return S(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=W(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=G(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??H,r=a?.[e],{newErrorValue:s,newSource:c}=he({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=H)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=G(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=G(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=A(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||B});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=G(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=W(r);s&&(i=i?{...i,...s}:s);let c=G(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??H,r=i?.[e],{newErrorValue:a,newSource:o}=he({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=H)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>
1{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),S(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),T.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),T.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}S(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),S(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),T.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),T.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>D(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:E(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=H,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;S(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:O(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t.startsWith(`${n}.`)||t.startsWith(`${n}[`)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=se(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),U(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],P(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),U(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),P(r,{dontValidate:!0})),U(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),P(n,{dontValidate:!0})),U(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return O(O(e,`${t}`,i),`${n}`,r)},P(r,{dontValidate:!0}
1)),U(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},P(r,{dontValidate:!0})),U(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],P(t,{dontValidate:!0})),U(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=D(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:H},values:i===void 0?t.values:O(t.values,e,i)}})},this.setErrorMap=e=>{S(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(j(t)){let{formError:e,fieldErrors:r}=W(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>V.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>V.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ge(),this._devtoolsSubmissionOverride=!1;let t=xe({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(!(n===void 0||!j(n)))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=w(t);let n;this.fieldMetaDerived=w(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=D(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!me(u),f=!o.isDirty,p=M(l,this.getFieldInfo(a)?.instance?.options.defaultValue??D(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=w(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!z(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&z(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>
1{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,ee=i.options.canSubmitWhenInvalid??!1,C=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||ee;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===C&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let te={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:C};Object.defineProperty(te,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=te}return r});let r;this.store=w(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&j(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&M(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return be(e.validate)?V[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function W(e){return e?j(e)?{formError:W(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function G(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var Ce=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...H,isTouched:e.fieldMetaBase[this.name]?.isTouched??H.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??H.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??H.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(M(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>
1{this.form.setFieldValue(this.name,e,P(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,P(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,P(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,P(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,P(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,P(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,P(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,P(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=k(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||B}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=k(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||B});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;S(()=>{let e=(e,n)=>{let r=K(n.cause),a=n.validate?we(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=N({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=K(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=A(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||B}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=A(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||B});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));S(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=K(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=we(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=N({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),S(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>
1{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>z(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[K(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[K(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)a.get(t)&&!t.options.asyncAlways||c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>V.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>V.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)z(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=w(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...H,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!M(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return be(e.validate)?V[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function we(e){if(e)return e}function K(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Te(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function Ee(e){return{...H,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var De=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??Te({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(M(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...H,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??Te({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;ke(t)&&(n=t.group,r=t.fields);let i=Oe(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:Te({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>
1{this.form.setFieldValue(this.name,e,P(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof Ce&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&z(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n==null||n===!1||r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=he({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),!(s===c&&o?.errorSourceMap[e]===l)&&this.form.setFieldMeta(n,(t=H)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=k(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||B}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=k(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||B});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;S(()=>{let t=(t,r)=>{let i=q(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&ke(s)&&(c=s.group,l=s.fields);let u=Oe(c),d=n[i],{newErrorValue:f,newSource:p}=N({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=q(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=A(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||B}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=A(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||B});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=q(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&ke(o)&&(l=o.group,u=o.fields);let d=Oe(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=N({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);
1for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return S(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>z(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[q(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>z(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),S(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}S(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),S(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=w(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??Ee(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!M(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(be(e.validate)){let t=V[e.type](e.value,e.validate);return e.type===`validate`?Ae(t):t.then(Ae)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function Oe(e){if(e)return e}function ke(e){return!!e&&typeof e==`object`&&`fields`in e}function Ae(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function q(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function je(e,t){if(!t)return;let n=Object.assign({},e,{state:R(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return S(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}var J=e(t(),1),Y=typeof window<`u`?J.useLayoutEffect:J.useEffect,X=n();function Me(e){let[t,n]=(0,J.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,J.useState)(()=>new Ce({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new Ce({...e}),i(a),n({form:e.form,name:e.name}));let o=x(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=x(a.store,e=>e.meta.isTouched),c=x(a.store,e=>e.meta.isBlurred),l=x(a.store,e=>e.meta.isDirty),u=x(a.store,e=>e.meta.errorMap),d=x(a.store,e=>e.meta.errorSourceMap),f=x(a.store,e=>e.meta.isValidating),p=(0,J.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return Y(a.mount,[a]),Y(()=>{a.update(e)}),p}var Ne=(({children:e,...t})=>{let n=Me(t);return(0,X.jsx)(X.Fragment,{children:(0,J.useMemo)(()=>E(e,n),[e,n])})});function Pe(){return(0,J.useState)(()=>ge())[0]}
1var Fe=J,Ie=`19.3.0`.split(`.`)[0]===`17`?Pe:Fe.useId;function Le(e){let[t,n]=(0,J.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,J.useState)(()=>new De({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new De({...e})),n({form:e.form,name:e.name}));let a=x(r.store,e=>e.value),o=x(r.store,e=>e.meta.isTouched),s=x(r.store,e=>e.meta.isBlurred),c=x(r.store,e=>e.meta.isDirty),l=x(r.store,e=>e.meta.errorMap),u=x(r.store,e=>e.meta.errorSourceMap),d=x(r.store,e=>e.meta.isValidating),f=x(r.store,e=>e.meta.isSubmitting),p=x(r.store,e=>e.meta.isSubmitted),m=x(r.store,e=>e.meta.submissionAttempts),h=x(r.store,e=>e.meta.isSubmitSuccessful),g=x(r.store,e=>e.meta.canSubmit),_=x(r.store,e=>e.meta.isValid),v=x(r.store,e=>e.meta.isFieldsValid),y=x(r.store,e=>e.meta.isFieldsValidating),b=x(r.store,e=>e.meta.isGroupValid),S=(0,J.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return Y(r.mount,[r]),Y(()=>{r.update(e)}),S}var Re=(({children:e,...t})=>{let n=Le(t);return(0,X.jsx)(X.Fragment,{children:(0,J.useMemo)(()=>E(e,n),[e,n])})});function ze({form:e,selector:t=e=>e,children:n}){return(0,X.jsx)(X.Fragment,{children:E(n,x(e.store,t))})}function Be(e){let t=Ie(),[n,r]=(0,J.useState)(e?.formId),[i,a]=(0,J.useState)(()=>new Se({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new Se({...e,formId:n})),r(n)}let o=(0,J.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,X.jsx)(Ne,{...e,form:i})},e.FormGroup=function(e){return(0,X.jsx)(Re,{...e,form:i})},e.Subscribe=function(e){return(0,X.jsx)(ze,{form:i,selector:e.selector,children:e.children})},e},[i]);Y(i.mount,[]),Y(()=>{i.update(e)});let s=(0,J.useRef)(!1);return Y(()=>{s.current&&e?.transform&&je(i,e.transform)},[i,e?.transform]),Y(()=>{s.current=!0}),o}var Ve=[{id:`incorporation`,label:`Incorporation`},{id:`visa`,label:`Visas and work permits`},{id:`payroll`,label:`Payroll`},{id:`eor`,label:`Employee management / EOR`},{id:`accounting`,label:`Accounting and tax`},{id:`cfo`,label:`Fractional CFO`},{id:`legal`,label:`Legal advisory`},{id:`other`,label:`Something else`}],He=new Set(Ve.map(e=>e.id));function Ue(e){return He.has(e)}function We(e){return e.length===0?`Choose topics`:e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function Ge(e){return Ve.filter(t=>e.includes(t.id)).map(e=>e.label)}function Ke(e){return We(Ge(e))}var qe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Je(e){let t=Q(e.name,Z.name.max),n=Q(e.email,Z.email.max).toLowerCase(),r=Ye(e.topics),i=Q(e.message,Z.message.max),a=[];return t.length<Z.name.min&&a.push({field:`name`,message:`Please enter your name.`}),(n.length<Z.email.min||!qe.test(n))&&a.push({field:`email`,message:`Please enter a valid email address.`}),r.length===0&&a.push({field:`topics`,message:`Please choose a topic.`}),i.length<Z.message.min&&a.push({field:`message`,message:`Please add a short message (at least 10 characters).`}),e.consent!==!0&&a.push({field:`consent`,message:`Please agree to the privacy policy.`}),a}var Z={name:{min:2,max:120},email:{min:5,max:254},company:{max:120},phone:{max:40},referralCode:{max:40},message:{min:10,max:4e3}};function Q(e,t){return typeof e==`string`?e.trim().slice(0,t):``}function Ye(e){let t=new Set,n=[];for(let r of e){let e=Q(r,40);!Ue(e)||t.has(e)||(t.add(e),n.push(e))}return n}var Xe={name:``,email:``,company:``,phone:``,topics:[],referralCode:``,message:``,consent:!1,website:``};function Ze(e){let t={};for(let n of Je(e))t[n.field]??=n.message;return t}var Qe=`Unable to send your message. Please try again.`;async function $e(e,t=fetch){try{let n=await t(ne,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)}),r=await n.json().catch(()=>null),i=typeof r==`object`&&r&&`error`in r&&typeof r.error==`string`?r.error:null;return n.ok?{ok:!0}:{ok:!1,error:i??Qe}}catch{return{ok:!1,error:Qe}}}var et=`Thanks. We'll reply within one business day.`;function tt(){let[e,t]=(0,J.useState)(`idle`),[n,r]=(0,J.useState)(),[i,a]=(0,J.useState)({}),[o,s]=(0,J.useState)(``),c=Be({defaultValues:Xe,onSubmit:async({value:e})=>{r(void 0);let n=Ze(e);if(Object.keys(n).length>0){a(n),t(`error`);return}a({}),t(`busy`);let i=await $e({...e,turnstileToken:o});if(!i.ok){r({kind:`error`,copy:i.error}),t(`error`);return}r({kind:`success`,copy:et}),t(`success`)}});return{form:c,panelState:e,status:n,fieldErrors:i,busy:e===`busy`,submitted:e===`
1success`,clearError:e=>{a(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},setTurnstileToken:s,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),c.handleSubmit()}}}function nt({id:e,label:t,className:n,name:i,rows:s=8,required:c,minLength:l,maxLength:u,error:d,nudge:f=!1,value:p,placeholder:m,onBlur:h,onChange:g}){let _=(0,J.useRef)(null),v=`${e}-error`;return(0,J.useLayoutEffect)(()=>{let e=_.current;if(e){if(!f){e.classList.remove(`is-nudge`);return}r(e,`is-nudge`)}},[f,d]),(0,X.jsx)(o,{id:e,label:t,error:d,htmlFor:e,className:n,children:(0,X.jsx)(`textarea`,{ref:_,className:a(`settlr-field__control`,`settlr-field__control--area`),id:e,name:i,rows:s,required:c,minLength:l,maxLength:u,placeholder:m,"aria-describedby":d?v:void 0,"aria-invalid":d?!0:void 0,value:p,onBlur:h,onChange:e=>g(e.target.value)})})}function rt({selected:e,onChange:t,error:n}){return(0,X.jsx)(`div`,{"data-contact-topics":!0,children:(0,X.jsx)(s,{id:`contact-topic`,label:`Topics`,name:`topic`,options:Ve.map(e=>({value:e.id,label:e.label})),value:e,onChange:e=>t(e),placeholder:`Choose topics`,summary:Ke(e),error:n,nudge:!!n})})}function $({id:e,label:t,optional:n=!1,type:r=`text`,autoComplete:i,required:a=!1,maxLength:o,error:s,name:l,value:u,placeholder:d,onBlur:f,onChange:p}){return d?(0,X.jsx)(it,{id:e,label:t,optional:n,type:r,autoComplete:i,required:a,maxLength:o,error:s,name:l,value:u,placeholder:d,onBlur:f,onChange:p}):(0,X.jsx)(c,{id:e,label:t,optional:n,type:r,autoComplete:i,required:a,maxLength:o,error:s,nudge:!!s,name:l,value:u,onBlur:f,onChange:p})}function it({id:e,label:t,optional:n=!1,type:i=`text`,autoComplete:a,required:s=!1,maxLength:c,error:l,name:u,value:d,placeholder:f,onBlur:p,onChange:m}){let h=(0,J.useRef)(null),g=`${e}-error`,_=!!l;return(0,J.useLayoutEffect)(()=>{let e=h.current;if(e){if(!_){e.classList.remove(`is-nudge`);return}r(e,`is-nudge`)}},[_,l]),(0,X.jsx)(o,{id:e,label:t,optional:n,error:l,htmlFor:e,children:(0,X.jsx)(`input`,{ref:h,className:`settlr-field__control`,id:e,type:i,name:u,autoComplete:a,required:s,maxLength:c,placeholder:f,"aria-describedby":l?g:void 0,"aria-invalid":l?!0:void 0,value:d,onBlur:p,onChange:e=>m(e.target.value)})})}function at({form:e,fieldErrors:t,clearError:n}){return(0,X.jsxs)(`div`,{className:`contact-form__grid`,children:[(0,X.jsxs)(`div`,{className:`contact-form__col`,children:[(0,X.jsxs)(`div`,{className:`contact-form__row`,children:[(0,X.jsx)(e.Field,{name:`name`,children:e=>(0,X.jsx)($,{id:`contact-name`,label:`Name`,type:`text`,autoComplete:`name`,required:!0,maxLength:120,error:t.name,name:e.name,value:e.state.value,placeholder:`Enter your name`,onBlur:e.handleBlur,onChange:t=>{n(`name`),e.handleChange(t)}})}),(0,X.jsx)(e.Field,{name:`email`,children:e=>(0,X.jsx)($,{id:`contact-email`,label:`Email`,type:`email`,autoComplete:`email`,required:!0,maxLength:254,error:t.email,name:e.name,value:e.state.value,placeholder:`Enter your email`,onBlur:e.handleBlur,onChange:t=>{n(`email`),e.handleChange(t)}})})]}),(0,X.jsxs)(`div`,{className:`contact-form__row`,children:[(0,X.jsx)(e.Field,{name:`company`,children:e=>(0,X.jsx)($,{id:`contact-company`,label:`Company`,optional:!0,type:`text`,autoComplete:`organization`,maxLength:120,name:e.name,value:e.state.value,placeholder:`Enter your company`,onBlur:e.handleBlur,onChange:t=>e.handleChange(t)})}),(0,X.jsx)(e.Field,{name:`phone`,children:e=>(0,X.jsx)($,{id:`contact-phone`,label:`Phone`,optional:!0,type:`tel`,autoComplete:`tel`,maxLength:40,name:e.name,value:e.state.value,placeholder:`Enter your phone number`,onBlur:e.handleBlur,onChange:t=>e.handleChange(t)})})]}),(0,X.jsx)(e.Field,{name:`topics`,children:e=>(0,X.jsx)(rt,{selected:e.state.value,error:t.topics,onChange:t=>{n(`topics`),e.handleChange(t)}})}),(0,X.jsx)(e.Field,{name:`referralCode`,children:e=>(0,X.jsx)($,{id:`contact-referral-code`,label:`Referral Code`,optional:!0,type:`text`,autoComplete:`off`,maxLength:40,name:e.name,value:e.state.value,placeholder:`Enter your referral code`,onBlur:e.handleBlur,onChange:t=>e.handleChange(t)})})]}),(0,X.jsx)(e.Field,{name:`message`,children:e=>(0,X.jsx)(nt,{id:`contact-message`,label:`Message`,className:`contact-form__field--message`,name:e.name,rows:8,required:!0,minLength:10,maxLength:4e3,error:t.message,nudge:!!t.message,value:e.state.value,placeholder:`Tell us how we 
1can help`,onBlur:e.handleBlur,onChange:t=>{n(`message`),e.handleChange(t)}})})]})}var ot=`cf-turnstile-script`,st=`https://challenges.cloudflare.com/turnstile/v0/api.js`;function ct(){return window.turnstile?Promise.resolve(window.turnstile):new Promise(e=>{let t=document.getElementById(ot),n=()=>e(window.turnstile);if(t){t.addEventListener(`load`,n,{once:!0});return}let r=document.createElement(`script`);r.id=ot,r.src=st,r.async=!0,r.defer=!0,r.addEventListener(`load`,n,{once:!0}),r.addEventListener(`error`,()=>e(void 0),{once:!0}),document.head.appendChild(r)})}function lt(e,t){let n,r=!1;return ct().then(i=>{r||!i||(n=i.render(e,{sitekey:re(),theme:`light`,appearance:`interaction-only`,callback:e=>t(e),"expired-callback":()=>t(``),"error-callback":()=>t(``)}))}),()=>{r=!0,n&&window.turnstile?.remove(n)}}function ut(e){let t=(0,J.useRef)(null),n=(0,J.useRef)(e);return n.current=e,(0,J.useEffect)(()=>{let e=t.current;if(e)return lt(e,e=>n.current(e))},[]),t}function dt({onToken:e}){return(0,X.jsx)(`div`,{className:`cf-turnstile`,ref:ut(e)})}function ft({form:e,fieldErrors:t,busy:n,clearError:r,onTurnstileToken:i}){return(0,X.jsxs)(`div`,{className:`contact-form__footer`,children:[(0,X.jsx)(e.Field,{name:`consent`,children:e=>(0,X.jsxs)(l,{id:`contact-consent`,name:e.name,required:!0,checked:e.state.value,onBlur:e.handleBlur,onChange:t=>{r(`consent`),e.handleChange(t)},error:t.consent,nudge:!!t.consent,children:[m.consentPrefix,` `,(0,X.jsx)(`a`,{href:`/privacy`,children:m.consentLink})]})}),(0,X.jsxs)(`div`,{className:`contact-form__footer-end`,children:[(0,X.jsx)(`div`,{className:`contact-form__verify`,children:(0,X.jsx)(dt,{onToken:i})}),(0,X.jsx)(`div`,{className:`contact-form__actions`,children:(0,X.jsxs)(`button`,{type:`submit`,className:`contact-form__submit`,"data-contact-submit":!0,"data-busy":n,disabled:n,"aria-label":n?m.submitBusy:m.submitIdle,children:[(0,X.jsx)(`span`,{className:`contact-form__submit-visual`,"aria-hidden":`true`,children:(0,X.jsx)(`span`,{className:`contact-form__spinner`})}),(0,X.jsxs)(`span`,{className:`contact-form__submit-copy`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`contact-form__submit-label contact-form__submit-label--idle`,children:m.submitIdle}),(0,X.jsx)(`span`,{className:`contact-form__submit-label contact-form__submit-label--busy`,children:m.submitBusy})]})]})})]})]})}function pt({status:e}){return(0,X.jsxs)(`div`,{className:e?`contact-form__outcome is-in`:`contact-form__outcome`,"data-contact-form-status":!0,"data-kind":e?.kind,role:`status`,"aria-live":`polite`,hidden:!e,children:[(0,X.jsxs)(`span`,{className:`contact-form__outcome-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`svg`,{className:`contact-form__outcome-icon contact-form__outcome-icon--ok`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,X.jsx)(`path`,{d:`M5 13.2 9.6 17.5 19 7.5`})}),(0,X.jsxs)(`svg`,{className:`contact-form__outcome-icon contact-form__outcome-icon--err`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.25`}),(0,X.jsx)(`path`,{d:`M12 8v5`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`16.35`,r:`0.85`,fill:`currentColor`,stroke:`none`})]})]}),(0,X.jsx)(`p`,{className:`contact-form__outcome-copy`,"data-contact-status-copy":!0,children:e?.copy})]})}function mt(){let{form:e,panelState:t,status:n,fieldErrors:r,busy:i,submitted:a,clearError:o,setTurnstileToken:s,onSubmit:c}=tt();return(0,X.jsxs)(`div`,{className:`contact-form-panel`,"data-contact-panel":!0,"data-state":t,children:[(0,X.jsxs)(`form`,{className:a?`contact-form is-exiting`:`contact-form`,"data-contact-form":!0,action:ne,method:`post`,noValidate:!0,hidden:a,"aria-busy":i,onSubmit:c,children:[(0,X.jsx)(`div`,{className:`contact-form__hp`,"aria-hidden":`true`,children:(0,X.jsx)(e.Field,{name:`website`,children:e=>(0,X.jsx)(`input`,{type:`text`,name:e.name,tabIndex:-1,autoComplete:`off`,value:e.state.value,onChange:t=>e.handleChange(t.target.value)})})}),(0,X.jsx)(at,{form:e,fieldErrors:r,clearError:o}),(0,X.jsx)(ft,{form:e,fieldErrors:r,busy:i,clearError:o,onTurnstileToken:s})]}),(0,X.jsx)(pt,{status:n})]})}function ht(){return(0,X.jsxs)(`header`,{className:`contact__intro`,children:[(0,X.jsx)(`p`,{className:`contact__eyebrow contact-rise`,style:v(`--contact-rise-delay: 40ms`),children:f.eyebrow}),(0,X.jsxs)(`h1`,{className:`contact__title contact-rise`,style:v(`--contact-rise-delay: 100ms`),children:[(0,X.jsx)(`span`,{className:`contact__title-line`,children:f.titleLine1}),` `,(0,X.jsx)(`span`,{className:`contact__title-accent`,children:f.titleAccent})]}),(0,X.jsx)(`p`,{className:`contact__lead contact-rise`,style:v(`--contact-rise-delay: 180ms`),children:f.description})]})}function gt(){return(0,X.jsxs)(`div`,{className:`contact__map contact-rise`,style:v(`--contact-rise-delay: 200ms`),children:[(0,X.jsx)(ee,{lat:d.lat,lng:d.lng,zoom:d.mapZoom,label:`Settlr Global`}),(0,X.jsxs)(`div`,{className:`contact__map-card`,children:[(0,X.jsxs)(`div`,{className:`contact__map-card-top`,children:[(0,X.jsx)(`p`,{className:`contact__map-card-kicker`,children:`Bangkok office`}),(0,X.jsx)(`button`,{type:`button`,className:`contact__map-copy`,"data-contact-copy":!0,"data-copy-text":encodeURIComponent(g),"aria-label":`Copy office address`,children:(0,X.jsxs)(`svg`,{className:`contact__map-copy-icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,X.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})})]}),(0,X.jsx)(`p`,{className:`contact__map-card-title`,children:d.company}),(0,X.jsxs)(`p`,{className:`contact__map-card-address`,children:[d.street,(0,X.jsx)(`br`,{}),d.locality,` `,d.postalCode]}),(0,X.jsx)(`p`,{className:`contact__map-card-area`,children:d.neighborhood})]}),(0,X.jsx)(`p`,{className:`contact__map-toast`,"data-contact-copy-toast":!0,role:`status`,"aria-live":`polite`,hidden:!0,children:`Copied to clipboard`}),(0,X.jsx)(`a`,{className:`contact__map-link`,href:d.mapsLink,target:`_blank`,rel:`noopener noreferrer`,children:`Open in Google Maps`})]})}function _t(){return(0,X.jsxs)(`div`,{className:`contact__copy`,children:[(0,X.jsx)(`p`,{className:`contact__visit-eyebrow contact-rise`,style:v(`--contact-rise-delay: 40ms`),children:h.eyebrow}),(0,X.jsxs)(`h2`,{className:`contact__visit-title contact-rise`,style:v(`--contact-rise-delay: 100ms`),children:[h.titleLine1,(0,X.jsx)(`em`,{className:`contact__visit-accent`,children:h.titleAccent})]}),(0,X.jsxs)(`div`,{className:`contact__actions contact-rise`,style:v(`--contact-rise-delay: 260ms`),children:[(0,X.jsx)(i,{className:`contact__btn contact__btn--primary`,variant:`solid`,href:u,children:`Book consultation`}),(0,X.jsx)(i,{className:`contact__btn contact__btn--ghost`,variant:`outline`,href:`mailto:${d.email}`,children:`Email the team`})]}),(0,X.jsx)(`ul`,{className:`contact__channels contact-rise`,style:v(`--contact-rise-delay: 340ms`),children:p.map((e,t)=>(0,X.jsxs)(`li`,{className:`contact__channel`,children:[(0,X.jsx)(`span`,{className:`contact__channel-label`,children:e.label}),(0,X.jsx)(`a`,{className:`contact__channel-value`,href:e.href,...e.external?{target:`_blank`,rel:`noopener noreferrer`}:{},children:e.value}),(0,X.jsx)(`span`,{className:`contact__channel-note`,children:e.note})]},t))}),(0,X.jsx)(`p`,{className:`contact__promise contact-rise`,style:v(`--contact-rise-delay: 420ms`),children:d.responsePromise})]})}function vt(){return(0,X.jsx)(_,{children:(0,X.jsx)(`main`,{className:`contact`,children:(0,X.jsxs)(`section`,{className:`contact__stage`,children:[(0,X.jsx)(ht,{}),(0,X.jsx)(mt,{}),(0,X.jsx)(`hr`,{className:`contact__divider`}),(0,X.jsxs)(`div`,{className:`contact__split`,children:[(0,X.jsx)(_t,{}),(0,X.jsx)(gt,{})]})]})})})}var yt=vt;export{yt as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.