finform-react-builder
Version:
A powerful, flexible React form builder with dynamic field rendering, custom validation, multi-step forms, Material-UI integration, image component support, toggle/radio buttons, switches, autocomplete, and advanced button positioning
1 lines • 369 kB
JavaScript
"use strict";var Gc=Object.defineProperty;var bs=e=>{throw TypeError(e)};var Qc=(e,t,r)=>t in e?Gc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var pn=(e,t,r)=>Qc(e,typeof t!="symbol"?t+"":t,r),Pi=(e,t,r)=>t.has(e)||bs("Cannot "+r);var O=(e,t,r)=>(Pi(e,t,"read from private field"),r?r.call(e):t.get(e)),me=(e,t,r)=>t.has(e)?bs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),oe=(e,t,r,n)=>(Pi(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),xe=(e,t,r)=>(Pi(e,t,"access private method"),r);var Dn=(e,t,r,n)=>({set _(i){oe(e,t,i,r)},get _(){return O(e,t,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),$=require("react"),g=require("@mui/material"),Zc=require("@emotion/styled"),fr=require("@emotion/react");function Xc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ae=Xc($);var An=e=>e.type==="checkbox",br=e=>e instanceof Date,nt=e=>e==null;const ll=e=>typeof e=="object";var Le=e=>!nt(e)&&!Array.isArray(e)&&ll(e)&&!br(e),cl=e=>Le(e)&&e.target?An(e.target)?e.target.checked:e.target.value:e,Jc=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ul=(e,t)=>e.has(Jc(t)),eu=e=>{const t=e.constructor&&e.constructor.prototype;return Le(t)&&t.hasOwnProperty("isPrototypeOf")},Na=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function $e(e){let t;const r=Array.isArray(e),n=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Na&&(e instanceof Blob||n))&&(r||Le(e)))if(t=r?[]:{},!r&&!eu(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=$e(e[i]));else return e;return t}var vi=e=>/^\w*$/.test(e),Ae=e=>e===void 0,bi=e=>Array.isArray(e)?e.filter(Boolean):[],La=e=>bi(e.replace(/["|']|\]/g,"").split(/\.|\[/)),te=(e,t,r)=>{if(!t||!Le(e))return r;const n=(vi(t)?[t]:La(t)).reduce((i,a)=>nt(i)?i:i[a],e);return Ae(n)||n===e?Ae(e[t])?r:e[t]:n},ft=e=>typeof e=="boolean",we=(e,t,r)=>{let n=-1;const i=vi(t)?[t]:La(t),a=i.length,s=a-1;for(;++n<a;){const o=i[n];let c=r;if(n!==s){const p=e[o];c=Le(p)||Array.isArray(p)?p:isNaN(+i[n+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const Jn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ct={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Bt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},pl=$.createContext(null);pl.displayName="HookFormContext";const wi=()=>$.useContext(pl);var dl=(e,t,r,n=!0)=>{const i={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(i,a,{get:()=>{const s=a;return t._proxyFormState[s]!==Ct.all&&(t._proxyFormState[s]=!n||Ct.all),r&&(r[s]=!0),e[s]}});return i};const Si=typeof window<"u"?ae.useLayoutEffect:ae.useEffect;function tu(e){const t=wi(),{control:r=t.control,disabled:n,name:i,exact:a}=e||{},[s,o]=$.useState(r._formState),c=$.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Si(()=>r._subscribe({name:i,formState:c.current,exact:a,callback:p=>{!n&&o({...r._formState,...p})}}),[i,n,a]),$.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),$.useMemo(()=>dl(s,r,c.current,!1),[s,r])}var zt=e=>typeof e=="string",fl=(e,t,r,n,i)=>zt(e)?(n&&t.watch.add(e),te(r,e,i)):Array.isArray(e)?e.map(a=>(n&&t.watch.add(a),te(r,a))):(n&&(t.watchAll=!0),r);function hl(e){const t=wi(),{control:r=t.control,name:n,defaultValue:i,disabled:a,exact:s}=e||{},o=$.useRef(i),[c,p]=$.useState(r._getWatch(n,o.current));return Si(()=>r._subscribe({name:n,formState:{values:!0},exact:s,callback:d=>!a&&p(fl(n,r._names,d.values||r._formValues,!1,o.current))}),[n,r,a,s]),$.useEffect(()=>r._removeUnmounted()),c}function ru(e){const t=wi(),{name:r,disabled:n,control:i=t.control,shouldUnregister:a}=e,s=ul(i._names.array,r),o=hl({control:i,name:r,defaultValue:te(i._formValues,r,te(i._defaultValues,r,e.defaultValue)),exact:!0}),c=tu({control:i,name:r,exact:!0}),p=$.useRef(e),d=$.useRef(i.register(r,{...e.rules,value:o,...ft(e.disabled)?{disabled:e.disabled}:{}})),f=$.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!te(c.errors,r)},isDirty:{enumerable:!0,get:()=>!!te(c.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!te(c.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!te(c.validatingFields,r)},error:{enumerable:!0,get:()=>te(c.errors,r)}}),[c,r]),u=$.useCallback(S=>d.current.onChange({target:{value:cl(S),name:r},type:Jn.CHANGE}),[r]),x=$.useCallback(()=>d.current.onBlur({target:{value:te(i._formValues,r),name:r},type:Jn.BLUR}),[r,i._formValues]),E=$.useCallback(S=>{const v=te(i._fields,r);v&&S&&(v._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:j=>S.setCustomValidity(j),reportValidity:()=>S.reportValidity()})},[i._fields,r]),m=$.useMemo(()=>({name:r,value:o,...ft(n)||c.disabled?{disabled:c.disabled||n}:{},onChange:u,onBlur:x,ref:E}),[r,n,c.disabled,u,x,E,o]);return $.useEffect(()=>{const S=i._options.shouldUnregister||a;i.register(r,{...p.current.rules,...ft(p.current.disabled)?{disabled:p.current.disabled}:{}});const v=(j,D)=>{const F=te(i._fields,j);F&&F._f&&(F._f.mount=D)};if(v(r,!0),S){const j=$e(te(i._options.defaultValues,r));we(i._defaultValues,r,j),Ae(te(i._formValues,r))&&we(i._formValues,r,j)}return!s&&i.register(r),()=>{(s?S&&!i._state.action:S)?i.unregister(r):v(r,!1)}},[r,i,s,a]),$.useEffect(()=>{i._setDisabledField({disabled:n,name:r})},[n,r,i]),$.useMemo(()=>({field:m,formState:c,fieldState:f}),[m,c,f])}const Re=e=>e.render(ru(e));var ml=(e,t,r,n,i)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:i||!0}}:{},ut=e=>Array.isArray(e)?e:[e],ws=()=>{let e=[];return{get observers(){return e},next:i=>{for(const a of e)a.next&&a.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(a=>a!==i)}}),unsubscribe:()=>{e=[]}}},la=e=>nt(e)||!ll(e);function Jt(e,t){if(la(e)||la(t))return e===t;if(br(e)&&br(t))return e.getTime()===t.getTime();const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const i of r){const a=e[i];if(!n.includes(i))return!1;if(i!=="ref"){const s=t[i];if(br(a)&&br(s)||Le(a)&&Le(s)||Array.isArray(a)&&Array.isArray(s)?!Jt(a,s):a!==s)return!1}}return!0}var rt=e=>Le(e)&&!Object.keys(e).length,qa=e=>e.type==="file",At=e=>typeof e=="function",ei=e=>{if(!Na)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},gl=e=>e.type==="select-multiple",Wa=e=>e.type==="radio",nu=e=>Wa(e)||An(e),Di=e=>ei(e)&&e.isConnected;function iu(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=Ae(e)?n++:e[t[n++]];return e}function au(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ae(e[t]))return!1;return!0}function He(e,t){const r=Array.isArray(t)?t:vi(t)?[t]:La(t),n=r.length===1?e:iu(e,r),i=r.length-1,a=r[i];return n&&delete n[a],i!==0&&(Le(n)&&rt(n)||Array.isArray(n)&&au(n))&&He(e,r.slice(0,-1)),e}var yl=e=>{for(const t in e)if(At(e[t]))return!0;return!1};function ti(e,t={}){const r=Array.isArray(e);if(Le(e)||r)for(const n in e)Array.isArray(e[n])||Le(e[n])&&!yl(e[n])?(t[n]=Array.isArray(e[n])?[]:{},ti(e[n],t[n])):nt(e[n])||(t[n]=!0);return t}function xl(e,t,r){const n=Array.isArray(e);if(Le(e)||n)for(const i in e)Array.isArray(e[i])||Le(e[i])&&!yl(e[i])?Ae(t)||la(r[i])?r[i]=Array.isArray(e[i])?ti(e[i],[]):{...ti(e[i])}:xl(e[i],nt(t)?{}:t[i],r[i]):r[i]=!Jt(e[i],t[i]);return r}var dn=(e,t)=>xl(e,t,ti(t));const Ss={value:!1,isValid:!1},Cs={value:!0,isValid:!0};var vl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ae(e[0].attributes.value)?Ae(e[0].value)||e[0].value===""?Cs:{value:e[0].value,isValid:!0}:Cs:Ss}return Ss},bl=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>Ae(e)?e:t?e===""?NaN:e&&+e:r&&zt(e)?new Date(e):n?n(e):e;const Es={isValid:!1,value:null};var wl=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Es):Es;function ks(e){const t=e.ref;return qa(t)?t.files:Wa(t)?wl(e.refs).value:gl(t)?[...t.selectedOptions].map(({value:r})=>r):An(t)?vl(e.refs).value:bl(Ae(t.value)?e.ref.value:t.value,e)}var su=(e,t,r,n)=>{const i={};for(const a of e){const s=te(t,a);s&&we(i,a,s._f)}return{criteriaMode:r,names:[...e],fields:i,shouldUseNativeValidation:n}},ri=e=>e instanceof RegExp,fn=e=>Ae(e)?e:ri(e)?e.source:Le(e)?ri(e.value)?e.value.source:e.value:e,Ur=e=>({isOnSubmit:!e||e===Ct.onSubmit,isOnBlur:e===Ct.onBlur,isOnChange:e===Ct.onChange,isOnAll:e===Ct.all,isOnTouch:e===Ct.onTouched});const Ts="AsyncFunction";var ou=e=>!!e&&!!e.validate&&!!(At(e.validate)&&e.validate.constructor.name===Ts||Le(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Ts)),lu=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ca=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Kr=(e,t,r,n)=>{for(const i of r||Object.keys(e)){const a=te(e,i);if(a){const{_f:s,...o}=a;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],i)&&!n)return!0;if(s.ref&&t(s.ref,s.name)&&!n)return!0;if(Kr(o,t))break}else if(Le(o)&&Kr(o,t))break}}};function js(e,t,r){const n=te(e,r);if(n||vi(r))return{error:n,name:r};const i=r.split(".");for(;i.length;){const a=i.join("."),s=te(t,a),o=te(e,a);if(s&&!Array.isArray(s)&&r!==a)return{name:r};if(o&&o.type)return{name:a,error:o};if(o&&o.root&&o.root.type)return{name:`${a}.root`,error:o.root};i.pop()}return{name:r}}var cu=(e,t,r,n)=>{r(e);const{name:i,...a}=e;return rt(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(s=>t[s]===(!n||Ct.all))},uu=(e,t,r)=>!e||!t||e===t||ut(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),pu=(e,t,r,n,i)=>i.isOnAll?!1:!r&&i.isOnTouch?!(t||e):(r?n.isOnBlur:i.isOnBlur)?!e:(r?n.isOnChange:i.isOnChange)?e:!0,du=(e,t)=>!bi(te(e,t)).length&&He(e,t),Sl=(e,t,r)=>{const n=ut(te(e,r));return we(n,"root",t[r]),we(e,r,n),e},Hn=e=>zt(e);function Fs(e,t,r="validate"){if(Hn(e)||Array.isArray(e)&&e.every(Hn)||ft(e)&&!e)return{type:r,message:Hn(e)?e:"",ref:t}}var zr=e=>Le(e)&&!ri(e)?e:{value:e,message:""},ua=async(e,t,r,n,i,a)=>{const{ref:s,refs:o,required:c,maxLength:p,minLength:d,min:f,max:u,pattern:x,validate:E,name:m,valueAsNumber:S,mount:v}=e._f,j=te(r,m);if(!v||t.has(m))return{};const D=o?o[0]:s,F=q=>{i&&D.reportValidity&&(D.setCustomValidity(ft(q)?"":q||""),D.reportValidity())},C={},_=Wa(s),I=An(s),R=_||I,Y=(S||qa(s))&&Ae(s.value)&&Ae(j)||ei(s)&&s.value===""||j===""||Array.isArray(j)&&!j.length,h=ml.bind(null,m,n,C),B=(q,Z,L,H=Bt.maxLength,G=Bt.minLength)=>{const ne=q?Z:L;C[m]={type:q?H:G,message:ne,ref:s,...h(q?H:G,ne)}};if(a?!Array.isArray(j)||!j.length:c&&(!R&&(Y||nt(j))||ft(j)&&!j||I&&!vl(o).isValid||_&&!wl(o).isValid)){const{value:q,message:Z}=Hn(c)?{value:!!c,message:c}:zr(c);if(q&&(C[m]={type:Bt.required,message:Z,ref:D,...h(Bt.required,Z)},!n))return F(Z),C}if(!Y&&(!nt(f)||!nt(u))){let q,Z;const L=zr(u),H=zr(f);if(!nt(j)&&!isNaN(j)){const G=s.valueAsNumber||j&&+j;nt(L.value)||(q=G>L.value),nt(H.value)||(Z=G<H.value)}else{const G=s.valueAsDate||new Date(j),ne=U=>new Date(new Date().toDateString()+" "+U),ue=s.type=="time",P=s.type=="week";zt(L.value)&&j&&(q=ue?ne(j)>ne(L.value):P?j>L.value:G>new Date(L.value)),zt(H.value)&&j&&(Z=ue?ne(j)<ne(H.value):P?j<H.value:G<new Date(H.value))}if((q||Z)&&(B(!!q,L.message,H.message,Bt.max,Bt.min),!n))return F(C[m].message),C}if((p||d)&&!Y&&(zt(j)||a&&Array.isArray(j))){const q=zr(p),Z=zr(d),L=!nt(q.value)&&j.length>+q.value,H=!nt(Z.value)&&j.length<+Z.value;if((L||H)&&(B(L,q.message,Z.message),!n))return F(C[m].message),C}if(x&&!Y&&zt(j)){const{value:q,message:Z}=zr(x);if(ri(q)&&!j.match(q)&&(C[m]={type:Bt.pattern,message:Z,ref:s,...h(Bt.pattern,Z)},!n))return F(Z),C}if(E){if(At(E)){const q=await E(j,r),Z=Fs(q,D);if(Z&&(C[m]={...Z,...h(Bt.validate,Z.message)},!n))return F(Z.message),C}else if(Le(E)){let q={};for(const Z in E){if(!rt(q)&&!n)break;const L=Fs(await E[Z](j,r),D,Z);L&&(q={...L,...h(Z,L.message)},F(L.message),n&&(C[m]=q))}if(!rt(q)&&(C[m]={ref:D,...q},!n))return C}}return F(!0),C};const fu={mode:Ct.onSubmit,reValidateMode:Ct.onChange,shouldFocusError:!0};function hu(e={}){let t={...fu,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:At(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1};const n={};let i=Le(t.defaultValues)||Le(t.values)?$e(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:$e(i),s={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,p=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...d};const u={array:ws(),state:ws()},x=t.criteriaMode===Ct.all,E=w=>T=>{clearTimeout(p),p=setTimeout(w,T)},m=async w=>{if(!t.disabled&&(d.isValid||f.isValid||w)){const T=t.resolver?rt((await I()).errors):await Y(n,!0);T!==r.isValid&&u.state.next({isValid:T})}},S=(w,T)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((w||Array.from(o.mount)).forEach(y=>{y&&(T?we(r.validatingFields,y,T):He(r.validatingFields,y))}),u.state.next({validatingFields:r.validatingFields,isValidating:!rt(r.validatingFields)}))},v=(w,T=[],y,M,b=!0,A=!0)=>{if(M&&y&&!t.disabled){if(s.action=!0,A&&Array.isArray(te(n,w))){const V=y(te(n,w),M.argA,M.argB);b&&we(n,w,V)}if(A&&Array.isArray(te(r.errors,w))){const V=y(te(r.errors,w),M.argA,M.argB);b&&we(r.errors,w,V),du(r.errors,w)}if((d.touchedFields||f.touchedFields)&&A&&Array.isArray(te(r.touchedFields,w))){const V=y(te(r.touchedFields,w),M.argA,M.argB);b&&we(r.touchedFields,w,V)}(d.dirtyFields||f.dirtyFields)&&(r.dirtyFields=dn(i,a)),u.state.next({name:w,isDirty:B(w,T),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else we(a,w,T)},j=(w,T)=>{we(r.errors,w,T),u.state.next({errors:r.errors})},D=w=>{r.errors=w,u.state.next({errors:r.errors,isValid:!1})},F=(w,T,y,M)=>{const b=te(n,w);if(b){const A=te(a,w,Ae(y)?te(i,w):y);Ae(A)||M&&M.defaultChecked||T?we(a,w,T?A:ks(b._f)):L(w,A),s.mount&&m()}},C=(w,T,y,M,b)=>{let A=!1,V=!1;const z={name:w};if(!t.disabled){if(!y||M){(d.isDirty||f.isDirty)&&(V=r.isDirty,r.isDirty=z.isDirty=B(),A=V!==z.isDirty);const K=Jt(te(i,w),T);V=!!te(r.dirtyFields,w),K?He(r.dirtyFields,w):we(r.dirtyFields,w,!0),z.dirtyFields=r.dirtyFields,A=A||(d.dirtyFields||f.dirtyFields)&&V!==!K}if(y){const K=te(r.touchedFields,w);K||(we(r.touchedFields,w,y),z.touchedFields=r.touchedFields,A=A||(d.touchedFields||f.touchedFields)&&K!==y)}A&&b&&u.state.next(z)}return A?z:{}},_=(w,T,y,M)=>{const b=te(r.errors,w),A=(d.isValid||f.isValid)&&ft(T)&&r.isValid!==T;if(t.delayError&&y?(c=E(()=>j(w,y)),c(t.delayError)):(clearTimeout(p),c=null,y?we(r.errors,w,y):He(r.errors,w)),(y?!Jt(b,y):b)||!rt(M)||A){const V={...M,...A&&ft(T)?{isValid:T}:{},errors:r.errors,name:w};r={...r,...V},u.state.next(V)}},I=async w=>{S(w,!0);const T=await t.resolver(a,t.context,su(w||o.mount,n,t.criteriaMode,t.shouldUseNativeValidation));return S(w),T},R=async w=>{const{errors:T}=await I(w);if(w)for(const y of w){const M=te(T,y);M?we(r.errors,y,M):He(r.errors,y)}else r.errors=T;return T},Y=async(w,T,y={valid:!0})=>{for(const M in w){const b=w[M];if(b){const{_f:A,...V}=b;if(A){const z=o.array.has(A.name),K=b._f&&ou(b._f);K&&d.validatingFields&&S([M],!0);const fe=await ua(b,o.disabled,a,x,t.shouldUseNativeValidation&&!T,z);if(K&&d.validatingFields&&S([M]),fe[A.name]&&(y.valid=!1,T))break;!T&&(te(fe,A.name)?z?Sl(r.errors,fe,A.name):we(r.errors,A.name,fe[A.name]):He(r.errors,A.name))}!rt(V)&&await Y(V,T,y)}}return y.valid},h=()=>{for(const w of o.unMount){const T=te(n,w);T&&(T._f.refs?T._f.refs.every(y=>!Di(y)):!Di(T._f.ref))&&Q(w)}o.unMount=new Set},B=(w,T)=>!t.disabled&&(w&&T&&we(a,w,T),!Jt(U(),i)),q=(w,T,y)=>fl(w,o,{...s.mount?a:Ae(T)?i:zt(w)?{[w]:T}:T},y,T),Z=w=>bi(te(s.mount?a:i,w,t.shouldUnregister?te(i,w,[]):[])),L=(w,T,y={})=>{const M=te(n,w);let b=T;if(M){const A=M._f;A&&(!A.disabled&&we(a,w,bl(T,A)),b=ei(A.ref)&&nt(T)?"":T,gl(A.ref)?[...A.ref.options].forEach(V=>V.selected=b.includes(V.value)):A.refs?An(A.ref)?A.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(b)?V.checked=!!b.find(z=>z===V.value):V.checked=b===V.value||!!b)}):A.refs.forEach(V=>V.checked=V.value===b):qa(A.ref)?A.ref.value="":(A.ref.value=b,A.ref.type||u.state.next({name:w,values:$e(a)})))}(y.shouldDirty||y.shouldTouch)&&C(w,b,y.shouldTouch,y.shouldDirty,!0),y.shouldValidate&&P(w)},H=(w,T,y)=>{for(const M in T){if(!T.hasOwnProperty(M))return;const b=T[M],A=w+"."+M,V=te(n,A);(o.array.has(w)||Le(b)||V&&!V._f)&&!br(b)?H(A,b,y):L(A,b,y)}},G=(w,T,y={})=>{const M=te(n,w),b=o.array.has(w),A=$e(T);we(a,w,A),b?(u.array.next({name:w,values:$e(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&y.shouldDirty&&u.state.next({name:w,dirtyFields:dn(i,a),isDirty:B(w,A)})):M&&!M._f&&!nt(A)?H(w,A,y):L(w,A,y),ca(w,o)&&u.state.next({...r}),u.state.next({name:s.mount?w:void 0,values:$e(a)})},ne=async w=>{s.mount=!0;const T=w.target;let y=T.name,M=!0;const b=te(n,y),A=K=>{M=Number.isNaN(K)||br(K)&&isNaN(K.getTime())||Jt(K,te(a,y,K))},V=Ur(t.mode),z=Ur(t.reValidateMode);if(b){let K,fe;const ye=T.type?ks(b._f):cl(w),ge=w.type===Jn.BLUR||w.type===Jn.FOCUS_OUT,Ne=!lu(b._f)&&!t.resolver&&!te(r.errors,y)&&!b._f.deps||pu(ge,te(r.touchedFields,y),r.isSubmitted,z,V),Oe=ca(y,o,ge);we(a,y,ye),ge?(b._f.onBlur&&b._f.onBlur(w),c&&c(0)):b._f.onChange&&b._f.onChange(w);const at=C(y,ye,ge),dt=!rt(at)||Oe;if(!ge&&u.state.next({name:y,type:w.type,values:$e(a)}),Ne)return(d.isValid||f.isValid)&&(t.mode==="onBlur"?ge&&m():ge||m()),dt&&u.state.next({name:y,...Oe?{}:at});if(!ge&&Oe&&u.state.next({...r}),t.resolver){const{errors:Me}=await I([y]);if(A(ye),M){const ie=js(r.errors,n,y),Ge=js(Me,n,ie.name||y);K=Ge.error,y=Ge.name,fe=rt(Me)}}else S([y],!0),K=(await ua(b,o.disabled,a,x,t.shouldUseNativeValidation))[y],S([y]),A(ye),M&&(K?fe=!1:(d.isValid||f.isValid)&&(fe=await Y(n,!0)));M&&(b._f.deps&&P(b._f.deps),_(y,fe,K,at))}},ue=(w,T)=>{if(te(r.errors,T)&&w.focus)return w.focus(),1},P=async(w,T={})=>{let y,M;const b=ut(w);if(t.resolver){const A=await R(Ae(w)?w:b);y=rt(A),M=w?!b.some(V=>te(A,V)):y}else w?(M=(await Promise.all(b.map(async A=>{const V=te(n,A);return await Y(V&&V._f?{[A]:V}:V)}))).every(Boolean),!(!M&&!r.isValid)&&m()):M=y=await Y(n);return u.state.next({...!zt(w)||(d.isValid||f.isValid)&&y!==r.isValid?{}:{name:w},...t.resolver||!w?{isValid:y}:{},errors:r.errors}),T.shouldFocus&&!M&&Kr(n,ue,w?b:o.mount),M},U=w=>{const T={...s.mount?a:i};return Ae(w)?T:zt(w)?te(T,w):w.map(y=>te(T,y))},X=(w,T)=>({invalid:!!te((T||r).errors,w),isDirty:!!te((T||r).dirtyFields,w),error:te((T||r).errors,w),isValidating:!!te(r.validatingFields,w),isTouched:!!te((T||r).touchedFields,w)}),pe=w=>{w&&ut(w).forEach(T=>He(r.errors,T)),u.state.next({errors:w?r.errors:{}})},he=(w,T,y)=>{const M=(te(n,w,{_f:{}})._f||{}).ref,b=te(r.errors,w)||{},{ref:A,message:V,type:z,...K}=b;we(r.errors,w,{...K,...T,ref:M}),u.state.next({name:w,errors:r.errors,isValid:!1}),y&&y.shouldFocus&&M&&M.focus&&M.focus()},de=(w,T)=>At(w)?u.state.subscribe({next:y=>w(q(void 0,T),y)}):q(w,T,!0),re=w=>u.state.subscribe({next:T=>{uu(w.name,T.name,w.exact)&&cu(T,w.formState||d,Ye,w.reRenderRoot)&&w.callback({values:{...a},...r,...T})}}).unsubscribe,W=w=>(s.mount=!0,f={...f,...w.formState},re({...w,formState:f})),Q=(w,T={})=>{for(const y of w?ut(w):o.mount)o.mount.delete(y),o.array.delete(y),T.keepValue||(He(n,y),He(a,y)),!T.keepError&&He(r.errors,y),!T.keepDirty&&He(r.dirtyFields,y),!T.keepTouched&&He(r.touchedFields,y),!T.keepIsValidating&&He(r.validatingFields,y),!t.shouldUnregister&&!T.keepDefaultValue&&He(i,y);u.state.next({values:$e(a)}),u.state.next({...r,...T.keepDirty?{isDirty:B()}:{}}),!T.keepIsValid&&m()},se=({disabled:w,name:T})=>{(ft(w)&&s.mount||w||o.disabled.has(T))&&(w?o.disabled.add(T):o.disabled.delete(T))},le=(w,T={})=>{let y=te(n,w);const M=ft(T.disabled)||ft(t.disabled);return we(n,w,{...y||{},_f:{...y&&y._f?y._f:{ref:{name:w}},name:w,mount:!0,...T}}),o.mount.add(w),y?se({disabled:ft(T.disabled)?T.disabled:t.disabled,name:w}):F(w,!0,T.value),{...M?{disabled:T.disabled||t.disabled}:{},...t.progressive?{required:!!T.required,min:fn(T.min),max:fn(T.max),minLength:fn(T.minLength),maxLength:fn(T.maxLength),pattern:fn(T.pattern)}:{},name:w,onChange:ne,onBlur:ne,ref:b=>{if(b){le(w,T),y=te(n,w);const A=Ae(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,V=nu(A),z=y._f.refs||[];if(V?z.find(K=>K===A):A===y._f.ref)return;we(n,w,{_f:{...y._f,...V?{refs:[...z.filter(Di),A,...Array.isArray(te(i,w))?[{}]:[]],ref:{type:A.type,name:w}}:{ref:A}}}),F(w,!1,void 0,A)}else y=te(n,w,{}),y._f&&(y._f.mount=!1),(t.shouldUnregister||T.shouldUnregister)&&!(ul(o.array,w)&&s.action)&&o.unMount.add(w)}}},ce=()=>t.shouldFocusError&&Kr(n,ue,o.mount),be=w=>{ft(w)&&(u.state.next({disabled:w}),Kr(n,(T,y)=>{const M=te(n,y);M&&(T.disabled=M._f.disabled||w,Array.isArray(M._f.refs)&&M._f.refs.forEach(b=>{b.disabled=M._f.disabled||w}))},0,!1))},J=(w,T)=>async y=>{let M;y&&(y.preventDefault&&y.preventDefault(),y.persist&&y.persist());let b=$e(a);if(u.state.next({isSubmitting:!0}),t.resolver){const{errors:A,values:V}=await I();r.errors=A,b=V}else await Y(n);if(o.disabled.size)for(const A of o.disabled)we(b,A,void 0);if(He(r.errors,"root"),rt(r.errors)){u.state.next({errors:{}});try{await w(b,y)}catch(A){M=A}}else T&&await T({...r.errors},y),ce(),setTimeout(ce);if(u.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:rt(r.errors)&&!M,submitCount:r.submitCount+1,errors:r.errors}),M)throw M},Ie=(w,T={})=>{te(n,w)&&(Ae(T.defaultValue)?G(w,$e(te(i,w))):(G(w,T.defaultValue),we(i,w,$e(T.defaultValue))),T.keepTouched||He(r.touchedFields,w),T.keepDirty||(He(r.dirtyFields,w),r.isDirty=T.defaultValue?B(w,$e(te(i,w))):B()),T.keepError||(He(r.errors,w),d.isValid&&m()),u.state.next({...r}))},Ke=(w,T={})=>{const y=w?$e(w):i,M=$e(y),b=rt(w),A=b?i:M;if(T.keepDefaultValues||(i=y),!T.keepValues){if(T.keepDirtyValues){const V=new Set([...o.mount,...Object.keys(dn(i,a))]);for(const z of Array.from(V))te(r.dirtyFields,z)?we(A,z,te(a,z)):G(z,te(A,z))}else{if(Na&&Ae(w))for(const V of o.mount){const z=te(n,V);if(z&&z._f){const K=Array.isArray(z._f.refs)?z._f.refs[0]:z._f.ref;if(ei(K)){const fe=K.closest("form");if(fe){fe.reset();break}}}}for(const V of o.mount)G(V,te(A,V))}a=$e(A),u.array.next({values:{...A}}),u.state.next({values:{...A}})}o={mount:T.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!d.isValid||!!T.keepIsValid||!!T.keepDirtyValues,s.watch=!!t.shouldUnregister,u.state.next({submitCount:T.keepSubmitCount?r.submitCount:0,isDirty:b?!1:T.keepDirty?r.isDirty:!!(T.keepDefaultValues&&!Jt(w,i)),isSubmitted:T.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:b?{}:T.keepDirtyValues?T.keepDefaultValues&&a?dn(i,a):r.dirtyFields:T.keepDefaultValues&&w?dn(i,w):T.keepDirty?r.dirtyFields:{},touchedFields:T.keepTouched?r.touchedFields:{},errors:T.keepErrors?r.errors:{},isSubmitSuccessful:T.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Xe=(w,T)=>Ke(At(w)?w(a):w,T),Tt=(w,T={})=>{const y=te(n,w),M=y&&y._f;if(M){const b=M.refs?M.refs[0]:M.ref;b.focus&&(b.focus(),T.shouldSelect&&At(b.select)&&b.select())}},Ye=w=>{r={...r,...w}},Ue={control:{register:le,unregister:Q,getFieldState:X,handleSubmit:J,setError:he,_subscribe:re,_runSchema:I,_focusError:ce,_getWatch:q,_getDirty:B,_setValid:m,_setFieldArray:v,_setDisabledField:se,_setErrors:D,_getFieldArray:Z,_reset:Ke,_resetDefaultValues:()=>At(t.defaultValues)&&t.defaultValues().then(w=>{Xe(w,t.resetOptions),u.state.next({isLoading:!1})}),_removeUnmounted:h,_disableForm:be,_subjects:u,_proxyFormState:d,get _fields(){return n},get _formValues(){return a},get _state(){return s},set _state(w){s=w},get _defaultValues(){return i},get _names(){return o},set _names(w){o=w},get _formState(){return r},get _options(){return t},set _options(w){t={...t,...w}}},subscribe:W,trigger:P,register:le,handleSubmit:J,watch:de,setValue:G,getValues:U,reset:Xe,resetField:Ie,clearErrors:pe,unregister:Q,setError:he,setFocus:Tt,getFieldState:X};return{...Ue,formControl:Ue}}var Gt=()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();const e=typeof performance>"u"?Date.now():performance.now()*1e3;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(Math.random()*16+e)%16|0;return(t=="x"?r:r&3|8).toString(16)})},Ii=(e,t,r={})=>r.shouldFocus||Ae(r.shouldFocus)?r.focusName||`${e}.${Ae(r.focusIndex)?t:r.focusIndex}.`:"",Mi=(e,t)=>[...e,...ut(t)],zi=e=>Array.isArray(e)?e.map(()=>{}):void 0;function Bi(e,t,r){return[...e.slice(0,t),...ut(r),...e.slice(t)]}var Vi=(e,t,r)=>Array.isArray(e)?(Ae(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],Ni=(e,t)=>[...ut(t),...ut(e)];function mu(e,t){let r=0;const n=[...e];for(const i of t)n.splice(i-r,1),r++;return bi(n).length?n:[]}var Li=(e,t)=>Ae(t)?[]:mu(e,ut(t).sort((r,n)=>r-n)),qi=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},As=(e,t,r)=>(e[t]=r,e);function gu(e){const t=wi(),{control:r=t.control,name:n,keyName:i="id",shouldUnregister:a,rules:s}=e,[o,c]=$.useState(r._getFieldArray(n)),p=$.useRef(r._getFieldArray(n).map(Gt)),d=$.useRef(o),f=$.useRef(n),u=$.useRef(!1);f.current=n,d.current=o,r._names.array.add(n),s&&r.register(n,s),Si(()=>r._subjects.array.subscribe({next:({values:_,name:I})=>{if(I===f.current||!I){const R=te(_,f.current);Array.isArray(R)&&(c(R),p.current=R.map(Gt))}}}).unsubscribe,[r]);const x=$.useCallback(_=>{u.current=!0,r._setFieldArray(n,_)},[r,n]),E=(_,I)=>{const R=ut($e(_)),Y=Mi(r._getFieldArray(n),R);r._names.focus=Ii(n,Y.length-1,I),p.current=Mi(p.current,R.map(Gt)),x(Y),c(Y),r._setFieldArray(n,Y,Mi,{argA:zi(_)})},m=(_,I)=>{const R=ut($e(_)),Y=Ni(r._getFieldArray(n),R);r._names.focus=Ii(n,0,I),p.current=Ni(p.current,R.map(Gt)),x(Y),c(Y),r._setFieldArray(n,Y,Ni,{argA:zi(_)})},S=_=>{const I=Li(r._getFieldArray(n),_);p.current=Li(p.current,_),x(I),c(I),!Array.isArray(te(r._fields,n))&&we(r._fields,n,void 0),r._setFieldArray(n,I,Li,{argA:_})},v=(_,I,R)=>{const Y=ut($e(I)),h=Bi(r._getFieldArray(n),_,Y);r._names.focus=Ii(n,_,R),p.current=Bi(p.current,_,Y.map(Gt)),x(h),c(h),r._setFieldArray(n,h,Bi,{argA:_,argB:zi(I)})},j=(_,I)=>{const R=r._getFieldArray(n);qi(R,_,I),qi(p.current,_,I),x(R),c(R),r._setFieldArray(n,R,qi,{argA:_,argB:I},!1)},D=(_,I)=>{const R=r._getFieldArray(n);Vi(R,_,I),Vi(p.current,_,I),x(R),c(R),r._setFieldArray(n,R,Vi,{argA:_,argB:I},!1)},F=(_,I)=>{const R=$e(I),Y=As(r._getFieldArray(n),_,R);p.current=[...Y].map((h,B)=>!h||B===_?Gt():p.current[B]),x(Y),c([...Y]),r._setFieldArray(n,Y,As,{argA:_,argB:R},!0,!1)},C=_=>{const I=ut($e(_));p.current=I.map(Gt),x([...I]),c([...I]),r._setFieldArray(n,[...I],R=>R,{},!0,!1)};return $.useEffect(()=>{if(r._state.action=!1,ca(n,r._names)&&r._subjects.state.next({...r._formState}),u.current&&(!Ur(r._options.mode).isOnSubmit||r._formState.isSubmitted)&&!Ur(r._options.reValidateMode).isOnSubmit)if(r._options.resolver)r._runSchema([n]).then(_=>{const I=te(_.errors,n),R=te(r._formState.errors,n);(R?!I&&R.type||I&&(R.type!==I.type||R.message!==I.message):I&&I.type)&&(I?we(r._formState.errors,n,I):He(r._formState.errors,n),r._subjects.state.next({errors:r._formState.errors}))});else{const _=te(r._fields,n);_&&_._f&&!(Ur(r._options.reValidateMode).isOnSubmit&&Ur(r._options.mode).isOnSubmit)&&ua(_,r._names.disabled,r._formValues,r._options.criteriaMode===Ct.all,r._options.shouldUseNativeValidation,!0).then(I=>!rt(I)&&r._subjects.state.next({errors:Sl(r._formState.errors,I,n)}))}r._subjects.state.next({name:n,values:$e(r._formValues)}),r._names.focus&&Kr(r._fields,(_,I)=>{if(r._names.focus&&I.startsWith(r._names.focus)&&_.focus)return _.focus(),1}),r._names.focus="",r._setValid(),u.current=!1},[o,n,r]),$.useEffect(()=>(!te(r._formValues,n)&&r._setFieldArray(n),()=>{const _=(I,R)=>{const Y=te(r._fields,I);Y&&Y._f&&(Y._f.mount=R)};r._options.shouldUnregister||a?r.unregister(n):_(n,!1)}),[n,r,i,a]),{swap:$.useCallback(j,[x,n,r]),move:$.useCallback(D,[x,n,r]),prepend:$.useCallback(m,[x,n,r]),append:$.useCallback(E,[x,n,r]),remove:$.useCallback(S,[x,n,r]),insert:$.useCallback(v,[x,n,r]),update:$.useCallback(F,[x,n,r]),replace:$.useCallback(C,[x,n,r]),fields:$.useMemo(()=>o.map((_,I)=>({..._,[i]:p.current[I]||Gt()})),[o,i])}}function yu(e={}){const t=$.useRef(void 0),r=$.useRef(void 0),[n,i]=$.useState({isDirty:!1,isValidating:!1,isLoading:At(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:At(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!At(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:s,...o}=hu(e);t.current={...o,formState:n}}const a=t.current.control;return a._options=e,Si(()=>{const s=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(o=>({...o,isReady:!0})),a._formState.isReady=!0,s},[a]),$.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),$.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),$.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),$.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),$.useEffect(()=>{if(a._proxyFormState.isDirty){const s=a._getDirty();s!==n.isDirty&&a._subjects.state.next({isDirty:s})}},[a,n.isDirty]),$.useEffect(()=>{e.values&&!Jt(e.values,r.current)?(a._reset(e.values,a._options.resetOptions),r.current=e.values,i(s=>({...s}))):a._resetDefaultValues()},[a,e.values]),$.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=dl(n,a),t.current}const Os=(e,t,r)=>{if(e&&"reportValidity"in e){const n=te(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Cl=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?Os(n.ref,r,e):n&&n.refs&&n.refs.forEach(i=>Os(i,r,e))}},xu=(e,t)=>{t.shouldUseNativeValidation&&Cl(e,t);const r={};for(const n in e){const i=te(t.fields,n),a=Object.assign(e[n]||{},{ref:i&&i.ref});if(vu(t.names||Object.keys(e),n)){const s=Object.assign({},te(r,n));we(s,"root",a),we(r,n,s)}else we(r,n,a)}return r},vu=(e,t)=>{const r=_s(t);return e.some(n=>_s(n).match(`^${r}\\.\\d+`))};function _s(e){return e.replace(/\]|\[/g,"")}function bu(e,t,r){return r===void 0&&(r={}),function(n,i,a){try{return Promise.resolve(function(s,o){try{var c=(t!=null&&t.context&&process.env.NODE_ENV==="development"&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e[r.mode==="sync"?"validateSync":"validate"](n,Object.assign({abortEarly:!1},t,{context:i}))).then(function(p){return a.shouldUseNativeValidation&&Cl({},a),{values:r.raw?Object.assign({},n):p,errors:{}}}))}catch(p){return o(p)}return c&&c.then?c.then(void 0,o):c}(0,function(s){if(!s.inner)throw s;return{values:{},errors:xu((o=s,c=!a.shouldUseNativeValidation&&a.criteriaMode==="all",(o.inner||[]).reduce(function(p,d){if(p[d.path]||(p[d.path]={message:d.message,type:d.type}),c){var f=p[d.path].types,u=f&&f[d.type];p[d.path]=ml(d.path,c,p,d.type,u?[].concat(u,d.message):d.message)}return p},{})),a)};var o,c}))}catch(s){return Promise.reject(s)}}}var On=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},$r=typeof window>"u"||"Deno"in globalThis;function lt(){}function wu(e,t){return typeof e=="function"?e(t):e}function pa(e){return typeof e=="number"&&e>=0&&e!==1/0}function El(e,t){return Math.max(e+(t||0)-Date.now(),0)}function cr(e,t){return typeof e=="function"?e(t):e}function bt(e,t){return typeof e=="function"?e(t):e}function Rs(e,t){const{type:r="all",exact:n,fetchStatus:i,predicate:a,queryKey:s,stale:o}=e;if(s){if(n){if(t.queryHash!==Ua(s,t.options))return!1}else if(!Sn(t.queryKey,s))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||a&&!a(t))}function $s(e,t){const{exact:r,status:n,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(wn(t.options.mutationKey)!==wn(a))return!1}else if(!Sn(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function Ua(e,t){return((t==null?void 0:t.queryKeyHashFn)||wn)(e)}function wn(e){return JSON.stringify(e,(t,r)=>ha(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function Sn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Sn(e[r],t[r])):!1}function da(e,t){if(e===t)return e;const r=Ps(e)&&Ps(t);if(r||ha(e)&&ha(t)){const n=r?e:Object.keys(e),i=n.length,a=r?t:Object.keys(t),s=a.length,o=r?[]:{},c=new Set(n);let p=0;for(let d=0;d<s;d++){const f=r?d:a[d];(!r&&c.has(f)||r)&&e[f]===void 0&&t[f]===void 0?(o[f]=void 0,p++):(o[f]=da(e[f],t[f]),o[f]===e[f]&&e[f]!==void 0&&p++)}return i===s&&p===i?e:o}return t}function fa(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Ps(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ha(e){if(!Ds(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Ds(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ds(e){return Object.prototype.toString.call(e)==="[object Object]"}function Su(e){return new Promise(t=>{setTimeout(t,e)})}function ma(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return da(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`),n}return da(e,t)}return t}function Cu(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Eu(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var ni=Symbol();function kl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===ni&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===ni?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ku(e,t){return typeof e=="function"?e(...t):!!e}var Cr,er,Gr,Jo,Tu=(Jo=class extends On{constructor(){super();me(this,Cr);me(this,er);me(this,Gr);oe(this,Gr,t=>{if(!$r&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){O(this,er)||this.setEventListener(O(this,Gr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,er))==null||t.call(this),oe(this,er,void 0))}setEventListener(t){var r;oe(this,Gr,t),(r=O(this,er))==null||r.call(this),oe(this,er,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){O(this,Cr)!==t&&(oe(this,Cr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof O(this,Cr)=="boolean"?O(this,Cr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Cr=new WeakMap,er=new WeakMap,Gr=new WeakMap,Jo),Ha=new Tu,Qr,tr,Zr,el,ju=(el=class extends On{constructor(){super();me(this,Qr,!0);me(this,tr);me(this,Zr);oe(this,Zr,t=>{if(!$r&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){O(this,tr)||this.setEventListener(O(this,Zr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,tr))==null||t.call(this),oe(this,tr,void 0))}setEventListener(t){var r;oe(this,Zr,t),(r=O(this,tr))==null||r.call(this),oe(this,tr,t(this.setOnline.bind(this)))}setOnline(t){O(this,Qr)!==t&&(oe(this,Qr,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return O(this,Qr)}},Qr=new WeakMap,tr=new WeakMap,Zr=new WeakMap,el),ii=new ju;function ga(){let e,t;const r=new Promise((i,a)=>{e=i,t=a});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function Fu(e){return Math.min(1e3*2**e,3e4)}function Tl(e){return(e??"online")==="online"?ii.isOnline():!0}var jl=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Wi(e){return e instanceof jl}function Fl(e){let t=!1,r=0,n=!1,i;const a=ga(),s=m=>{var S;n||(u(new jl(m)),(S=e.abort)==null||S.call(e))},o=()=>{t=!0},c=()=>{t=!1},p=()=>Ha.isFocused()&&(e.networkMode==="always"||ii.isOnline())&&e.canRun(),d=()=>Tl(e.networkMode)&&e.canRun(),f=m=>{var S;n||(n=!0,(S=e.onSuccess)==null||S.call(e,m),i==null||i(),a.resolve(m))},u=m=>{var S;n||(n=!0,(S=e.onError)==null||S.call(e,m),i==null||i(),a.reject(m))},x=()=>new Promise(m=>{var S;i=v=>{(n||p())&&m(v)},(S=e.onPause)==null||S.call(e)}).then(()=>{var m;i=void 0,n||(m=e.onContinue)==null||m.call(e)}),E=()=>{if(n)return;let m;const S=r===0?e.initialPromise:void 0;try{m=S??e.fn()}catch(v){m=Promise.reject(v)}Promise.resolve(m).then(f).catch(v=>{var _;if(n)return;const j=e.retry??($r?0:3),D=e.retryDelay??Fu,F=typeof D=="function"?D(r,v):D,C=j===!0||typeof j=="number"&&r<j||typeof j=="function"&&j(r,v);if(t||!C){u(v);return}r++,(_=e.onFail)==null||_.call(e,r,v),Su(F).then(()=>p()?void 0:x()).then(()=>{t?u(v):E()})})};return{promise:a,cancel:s,continue:()=>(i==null||i(),a),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?E():x().then(E),a)}}var Au=e=>setTimeout(e,0);function Ou(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=Au;const a=o=>{t?e.push(o):i(()=>{r(o)})},s=()=>{const o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(c=>{r(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||s()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var Qe=Ou(),Er,tl,Al=(tl=class{constructor(){me(this,Er)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),pa(this.gcTime)&&oe(this,Er,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($r?1/0:5*60*1e3))}clearGcTimeout(){O(this,Er)&&(clearTimeout(O(this,Er)),oe(this,Er,void 0))}},Er=new WeakMap,tl),Xr,kr,xt,Tr,Je,kn,jr,jt,Wt,rl,_u=(rl=class extends Al{constructor(t){super();me(this,jt);me(this,Xr);me(this,kr);me(this,xt);me(this,Tr);me(this,Je);me(this,kn);me(this,jr);oe(this,jr,!1),oe(this,kn,t.defaultOptions),this.setOptions(t.options),this.observers=[],oe(this,Tr,t.client),oe(this,xt,O(this,Tr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,oe(this,Xr,Ru(this.options)),this.state=t.state??O(this,Xr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,Je))==null?void 0:t.promise}setOptions(t){this.options={...O(this,kn),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,xt).remove(this)}setData(t,r){const n=ma(this.state.data,t,this.options);return xe(this,jt,Wt).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){xe(this,jt,Wt).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n,i;const r=(n=O(this,Je))==null?void 0:n.promise;return(i=O(this,Je))==null||i.cancel(t),r?r.then(lt).catch(lt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,Xr))}isActive(){return this.observers.some(t=>bt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ni||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>cr(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!El(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=O(this,Je))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=O(this,Je))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,xt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(O(this,Je)&&(O(this,jr)?O(this,Je).cancel({revert:!0}):O(this,Je).cancelRetry()),this.scheduleGc()),O(this,xt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||xe(this,jt,Wt).call(this,{type:"invalidate"})}fetch(t,r){var p,d,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(O(this,Je))return O(this,Je).continueRetry(),O(this,Je).promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(x=>x.options.queryFn);u&&this.setOptions(u.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,i=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(oe(this,jr,!0),n.signal)})},a=()=>{const u=kl(this.options,r),E=(()=>{const m={client:O(this,Tr),queryKey:this.queryKey,meta:this.meta};return i(m),m})();return oe(this,jr,!1),this.options.persister?this.options.persister(u,E,this):u(E)},o=(()=>{const u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:O(this,Tr),state:this.state,fetchFn:a};return i(u),u})();(p=this.options.behavior)==null||p.onFetch(o,this),oe(this,kr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&xe(this,jt,Wt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta});const c=u=>{var x,E,m,S;Wi(u)&&u.silent||xe(this,jt,Wt).call(this,{type:"error",error:u}),Wi(u)||((E=(x=O(this,xt).config).onError)==null||E.call(x,u,this),(S=(m=O(this,xt).config).onSettled)==null||S.call(m,this.state.data,u,this)),this.scheduleGc()};return oe(this,Je,Fl({initialPromise:r==null?void 0:r.initialPromise,fn:o.fetchFn,abort:n.abort.bind(n),onSuccess:u=>{var x,E,m,S;if(u===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(u)}catch(v){c(v);return}(E=(x=O(this,xt).config).onSuccess)==null||E.call(x,u,this),(S=(m=O(this,xt).config).onSettled)==null||S.call(m,u,this.state.error,this),this.scheduleGc()},onError:c,onFail:(u,x)=>{xe(this,jt,Wt).call(this,{type:"failed",failureCount:u,error:x})},onPause:()=>{xe(this,jt,Wt).call(this,{type:"pause"})},onContinue:()=>{xe(this,jt,Wt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),O(this,Je).start()}},Xr=new WeakMap,kr=new WeakMap,xt=new WeakMap,Tr=new WeakMap,Je=new WeakMap,kn=new WeakMap,jr=new WeakMap,jt=new WeakSet,Wt=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Ol(n.data,this.options),fetchMeta:t.meta??null};case"success":return oe(this,kr,void 0),{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const i=t.error;return Wi(i)&&i.revert&&O(this,kr)?{...O(this,kr),fetchStatus:"idle"}:{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),Qe.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),O(this,xt).notify({query:this,type:"updated",action:t})})},rl);function Ol(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Tl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ru(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Pt,nl,$u=(nl=class extends On{constructor(t={}){super();me(this,Pt);this.config=t,oe(this,Pt,new Map)}build(t,r,n){const i=r.queryKey,a=r.queryHash??Ua(i,r);let s=this.get(a);return s||(s=new _u({client:t,queryKey:i,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(i)}),this.add(s)),s}add(t){O(this,Pt).has(t.queryHash)||(O(this,Pt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=O(this,Pt).get(t.queryHash);r&&(t.destroy(),r===t&&O(this,Pt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Qe.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Pt).get(t)}getAll(){return[...O(this,Pt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Rs(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Rs(t,n)):r}notify(t){Qe.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Qe.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Qe.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Pt=new WeakMap,nl),Dt,et,Fr,It,Zt,il,Pu=(il=class extends Al{constructor(t){super();me(this,It);me(this,Dt);me(this,et);me(this,Fr);this.mutationId=t.mutationId,oe(this,et,t.mutationCache),oe(this,Dt,[]),this.state=t.state||Du(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){O(this,Dt).includes(t)||(O(this,Dt).push(t),this.clearGcTimeout(),O(this,et).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){oe(this,Dt,O(this,Dt).filter(r=>r!==t)),this.scheduleGc(),O(this,et).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,Dt).length||(this.state.status==="pending"?this.scheduleGc():O(this,et).remove(this))}continue(){var t;return((t=O(this,Fr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,s,o,c,p,d,f,u,x,E,m,S,v,j,D,F,C,_,I,R;const r=()=>{xe(this,It,Zt).call(this,{type:"continue"})};oe(this,Fr,Fl({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(Y,h)=>{xe(this,It,Zt).call(this,{type:"failed",failureCount:Y,error:h})},onPause:()=>{xe(this,It,Zt).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,et).canRun(this)}));const n=this.state.status==="pending",i=!O(this,Fr).canStart();try{if(n)r();else{xe(this,It,Zt).call(this,{type:"pending",variables:t,isPaused:i}),await((s=(a=O(this,et).config).onMutate)==null?void 0:s.call(a,t,this));const h=await((c=(o=this.options).onMutate)==null?void 0:c.call(o,t));h!==this.state.context&&xe(this,It,Zt).call(this,{type:"pending",context:h,variables:t,isPaused:i})}const Y=await O(this,Fr).start();return await((d=(p=O(this,et).config).onSuccess)==null?void 0:d.call(p,Y,t,this.state.context,this)),await((u=(f=this.options).onSuccess)==null?void 0:u.call(f,Y,t,this.state.context)),await((E=(x=O(this,et).config).onSettled)==null?void 0:E.call(x,Y,null