@npm-zenwork/tax-remittance-ui 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Mu=Object.defineProperty;var Qi=e=>{throw TypeError(e)};var Vu=(e,t,r)=>t in e?Mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Zn=(e,t,r)=>Vu(e,typeof t!="symbol"?t+"":t,r),Zs=(e,t,r)=>t.has(e)||Qi("Cannot "+r);var v=(e,t,r)=>(Zs(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>t.has(e)?Qi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),V=(e,t,r,n)=>(Zs(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),re=(e,t,r)=>(Zs(e,t,"access private method"),r);var Wn=(e,t,r,n)=>({set _(a){V(e,t,a,r)},get _(){return v(e,t,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),w=require("react"),ks=require("react-dom");function qu(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 A=qu(w);/**
1
+ "use strict";var Mu=Object.defineProperty;var Qi=e=>{throw TypeError(e)};var Vu=(e,t,r)=>t in e?Mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Zn=(e,t,r)=>Vu(e,typeof t!="symbol"?t+"":t,r),Zs=(e,t,r)=>t.has(e)||Qi("Cannot "+r);var v=(e,t,r)=>(Zs(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>t.has(e)?Qi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),V=(e,t,r,n)=>(Zs(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),re=(e,t,r)=>(Zs(e,t,"access private method"),r);var Wn=(e,t,r,n)=>({set _(a){V(e,t,a,r)},get _(){return v(e,t,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),N=require("react"),ks=require("react-dom");function qu(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 A=qu(N);/**
2
2
  * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
@@ -7,11 +7,11 @@
7
7
  * LICENSE.md file in the root directory of this source tree.
8
8
  *
9
9
  * @license MIT
10
- */var Ya=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Bu=/^[\\/]{2}/;function Uu(e,t){return t+e.replace(/\\/g,"/")}function Ji(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Zu(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:n=!1}=e,a;a=t.map((f,y)=>d(f,typeof f=="string"?null:f.state,y===0?"default":void 0,typeof f=="string"?void 0:f.mask));let i=c(r??a.length-1),o="POP",l=null;function c(f){return Math.min(Math.max(f,0),a.length-1)}function u(){return a[i]}function d(f,y=null,p,x){let b=Yu(a?u().pathname:"/",f,y,p,x);return Xe(b.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),b}function m(f){return typeof f=="string"?f:us(f)}return{get index(){return i},get action(){return o},get location(){return u()},createHref:m,createURL(f){return new URL(m(f),"http://localhost")},encodeLocation(f){let y=typeof f=="string"?Or(f):f;return{pathname:y.pathname||"",search:y.search||"",hash:y.hash||""}},push(f,y){o="PUSH";let p=Ji(f)?f:d(f,y);i+=1,a.splice(i,a.length,p),n&&l&&l({action:o,location:p,delta:1})},replace(f,y){o="REPLACE";let p=Ji(f)?f:d(f,y);a[i]=p,n&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let y=c(i+f),p=a[y];i=y,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function ve(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Xe(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Wu(){return Math.random().toString(36).substring(2,10)}function Yu(e,t,r=null,n,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Or(t):t,state:r,key:t&&t.key||n||Wu(),mask:a}}function us({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Or(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function wl(e,t,r="/"){return Hu(e,t,r,!1)}function Hu(e,t,r,n,a){let i=typeof t=="string"?Or(t):t,o=Vt(i.pathname||"/",r);if(o==null)return null;let l=Ku(e),c=null,u=id(o);for(let d=0;c==null&&d<l.length;++d)c=ad(l[d],u,n);return c}function Ku(e){let t=Nl(e);return Qu(t),t}function Nl(e,t=[],r=[],n="",a=!1){let i=(o,l,c=a,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(n)&&c)return;ve(d.relativePath.startsWith(n),`Absolute route path "${d.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(n.length)}let m=mt([n,d.relativePath]),h=r.concat(d);o.children&&o.children.length>0&&(ve(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Nl(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:nd(m,o.index),routesMeta:h.map((f,y)=>{let[p,x]=Cl(f.relativePath,f.caseSensitive,y===h.length-1);return{...f,matcher:p,compiledParams:x}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of Sl(o.path))i(o,l,!0,u)}),t}function Sl(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let o=Sl(n.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Qu(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:sd(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var Ju=/^:[\w-]+$/,Gu=3,Xu=2,ed=1,td=10,rd=-2,Gi=e=>e==="*";function nd(e,t){let r=e.split("/"),n=r.length;return r.some(Gi)&&(n+=rd),t&&(n+=Xu),r.filter(a=>!Gi(a)).reduce((a,i)=>a+(Ju.test(i)?Gu:i===""?ed:td),n)}function sd(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function ad(e,t,r=!1){let{routesMeta:n}=e,a={},i="/",o=[];for(let l=0;l<n.length;++l){let c=n[l],u=l===n.length-1,d=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h=c.matcher&&c.compiledParams?kl(m,d,c.matcher,c.compiledParams):ds(m,d),f=c.route;if(!h&&u&&r&&!n[n.length-1].route.index&&(h=ds({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:mt([i,h.pathname]),pathnameBase:cd(mt([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=mt([i,h.pathnameBase]))}return o}function ds(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=Cl(e.path,e.caseSensitive,e.end);return kl(e,t,r,n)}function kl(e,t,r,n){let a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce((u,{paramName:d,isOptional:m},h)=>{if(d==="*"){let y=l[h]||"";o=i.slice(0,i.length-y.length).replace(/(.)\/+$/,"$1")}const f=l[h];return m&&!f?u[d]=void 0:u[d]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function Cl(e,t=!1,r=!0){Xe(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(n.push({paramName:l,isOptional:c!=null}),c){let m=d.charAt(u+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function id(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Xe(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Vt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function od(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Or(e):e,i;return r?(r=Al(r),r.startsWith("/")?i=Xi(r.substring(1),"/"):i=Xi(r,t)):i=t,{pathname:i,search:ud(n),hash:dd(a)}}function Xi(e,t){let r=ms(t).split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Ws(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ld(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Ha(e){let t=ld(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function Cs(e,t,r,n=!1){let a;typeof e=="string"?a=Or(e):(a={...e},ve(!a.pathname||!a.pathname.includes("?"),Ws("?","pathname","search",a)),ve(!a.pathname||!a.pathname.includes("#"),Ws("#","pathname","hash",a)),ve(!a.search||!a.search.includes("#"),Ws("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let m=t.length-1;if(!n&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=od(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Al=e=>e.replace(/[\\/]{2,}/g,"/"),mt=e=>Al(e.join("/")),ms=e=>e.replace(/\/+$/,""),cd=e=>ms(e).replace(/^\/*/,"/"),ud=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,dd=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,md=class{constructor(e,t,r,n=!1){this.status=e,this.statusText=t||"",this.internal=n,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function hd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function fd(e){let t=e.map(r=>r.route.path).filter(Boolean);return mt(t)||"/"}var Pl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function _l(e,t){let r=e;if(typeof r!="string"||!Ya.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let n=r,a=!1;if(Pl)try{let i=new URL(window.location.href),o=Bu.test(r)?new URL(Uu(r,i.protocol)):new URL(r),l=Vt(o.pathname,t);o.origin===i.origin&&l!=null?r=l+o.search+o.hash:a=!0}catch{Xe(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:a,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var El=["POST","PUT","PATCH","DELETE"];new Set(El);var pd=["GET",...El];new Set(pd);var xd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function gd(e){try{return xd.includes(new URL(e).protocol)}catch{return!1}}var mn=A.createContext(null);mn.displayName="DataRouter";var As=A.createContext(null);As.displayName="DataRouterState";var Tl=A.createContext(!1);function yd(){return A.useContext(Tl)}var Il=A.createContext({isTransitioning:!1});Il.displayName="ViewTransition";var bd=A.createContext(new Map);bd.displayName="Fetchers";var vd=A.createContext(null);vd.displayName="Await";var tt=A.createContext(null);tt.displayName="Navigation";var $n=A.createContext(null);$n.displayName="Location";var nt=A.createContext({outlet:null,matches:[],isDataRoute:!1});nt.displayName="Route";var Ka=A.createContext(null);Ka.displayName="RouteError";var Fl="REACT_ROUTER_ERROR",jd="REDIRECT",wd="ROUTE_ERROR_RESPONSE";function Nd(e){if(e.startsWith(`${Fl}:${jd}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Sd(e){if(e.startsWith(`${Fl}:${wd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new md(t.status,t.statusText,t.data)}catch{}}function kd(e,{relative:t}={}){ve(hn(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:n}=A.useContext(tt),{hash:a,pathname:i,search:o}=Ln(e,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:mt([r,i])),n.createHref({pathname:l,search:o,hash:a})}function hn(){return A.useContext($n)!=null}function ge(){return ve(hn(),"useLocation() may be used only in the context of a <Router> component."),A.useContext($n).location}var Dl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Rl(e){A.useContext(tt).static||A.useLayoutEffect(e)}function Se(){let{isDataRoute:e}=A.useContext(nt);return e?Md():Cd()}function Cd(){ve(hn(),"useNavigate() may be used only in the context of a <Router> component.");let e=A.useContext(mn),{basename:t,navigator:r}=A.useContext(tt),{matches:n}=A.useContext(nt),{pathname:a}=ge(),i=JSON.stringify(Ha(n)),o=A.useRef(!1);return Rl(()=>{o.current=!0}),A.useCallback((c,u={})=>{if(Xe(o.current,Dl),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=Cs(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:mt([t,d.pathname])),(u.replace?r.replace:r.push)(d,u.state,u)},[t,r,i,a,e])}var Ol=A.createContext(null);function ft(){return A.useContext(Ol)}function Ad(e){let t=A.useContext(nt).outlet;return A.useMemo(()=>t&&A.createElement(Ol.Provider,{value:e},t),[t,e])}function Pd(){let{matches:e}=A.useContext(nt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Ln(e,{relative:t}={}){let{matches:r}=A.useContext(nt),{pathname:n}=ge(),a=JSON.stringify(Ha(r));return A.useMemo(()=>Cs(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function _d(e,t){return $l(e,t)}function $l(e,t,r){var x;ve(hn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=A.useContext(tt),{matches:a}=A.useContext(nt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let b=u&&u.path||"";zl(l,!u||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${b}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
10
+ */var Ya=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Bu=/^[\\/]{2}/;function Uu(e,t){return t+e.replace(/\\/g,"/")}function Ji(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Zu(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:n=!1}=e,a;a=t.map((f,y)=>d(f,typeof f=="string"?null:f.state,y===0?"default":void 0,typeof f=="string"?void 0:f.mask));let i=c(r??a.length-1),o="POP",l=null;function c(f){return Math.min(Math.max(f,0),a.length-1)}function u(){return a[i]}function d(f,y=null,p,x){let b=Yu(a?u().pathname:"/",f,y,p,x);return Xe(b.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),b}function m(f){return typeof f=="string"?f:us(f)}return{get index(){return i},get action(){return o},get location(){return u()},createHref:m,createURL(f){return new URL(m(f),"http://localhost")},encodeLocation(f){let y=typeof f=="string"?Or(f):f;return{pathname:y.pathname||"",search:y.search||"",hash:y.hash||""}},push(f,y){o="PUSH";let p=Ji(f)?f:d(f,y);i+=1,a.splice(i,a.length,p),n&&l&&l({action:o,location:p,delta:1})},replace(f,y){o="REPLACE";let p=Ji(f)?f:d(f,y);a[i]=p,n&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let y=c(i+f),p=a[y];i=y,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function ve(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Xe(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Wu(){return Math.random().toString(36).substring(2,10)}function Yu(e,t,r=null,n,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Or(t):t,state:r,key:t&&t.key||n||Wu(),mask:a}}function us({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Or(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function Nl(e,t,r="/"){return Hu(e,t,r,!1)}function Hu(e,t,r,n,a){let i=typeof t=="string"?Or(t):t,o=Vt(i.pathname||"/",r);if(o==null)return null;let l=Ku(e),c=null,u=id(o);for(let d=0;c==null&&d<l.length;++d)c=ad(l[d],u,n);return c}function Ku(e){let t=wl(e);return Qu(t),t}function wl(e,t=[],r=[],n="",a=!1){let i=(o,l,c=a,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(n)&&c)return;ve(d.relativePath.startsWith(n),`Absolute route path "${d.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(n.length)}let m=mt([n,d.relativePath]),h=r.concat(d);o.children&&o.children.length>0&&(ve(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),wl(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:nd(m,o.index),routesMeta:h.map((f,y)=>{let[p,x]=Cl(f.relativePath,f.caseSensitive,y===h.length-1);return{...f,matcher:p,compiledParams:x}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of Sl(o.path))i(o,l,!0,u)}),t}function Sl(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let o=Sl(n.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Qu(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:sd(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var Ju=/^:[\w-]+$/,Gu=3,Xu=2,ed=1,td=10,rd=-2,Gi=e=>e==="*";function nd(e,t){let r=e.split("/"),n=r.length;return r.some(Gi)&&(n+=rd),t&&(n+=Xu),r.filter(a=>!Gi(a)).reduce((a,i)=>a+(Ju.test(i)?Gu:i===""?ed:td),n)}function sd(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function ad(e,t,r=!1){let{routesMeta:n}=e,a={},i="/",o=[];for(let l=0;l<n.length;++l){let c=n[l],u=l===n.length-1,d=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h=c.matcher&&c.compiledParams?kl(m,d,c.matcher,c.compiledParams):ds(m,d),f=c.route;if(!h&&u&&r&&!n[n.length-1].route.index&&(h=ds({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:mt([i,h.pathname]),pathnameBase:cd(mt([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=mt([i,h.pathnameBase]))}return o}function ds(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=Cl(e.path,e.caseSensitive,e.end);return kl(e,t,r,n)}function kl(e,t,r,n){let a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce((u,{paramName:d,isOptional:m},h)=>{if(d==="*"){let y=l[h]||"";o=i.slice(0,i.length-y.length).replace(/(.)\/+$/,"$1")}const f=l[h];return m&&!f?u[d]=void 0:u[d]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function Cl(e,t=!1,r=!0){Xe(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(n.push({paramName:l,isOptional:c!=null}),c){let m=d.charAt(u+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function id(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Xe(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Vt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function od(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Or(e):e,i;return r?(r=Al(r),r.startsWith("/")?i=Xi(r.substring(1),"/"):i=Xi(r,t)):i=t,{pathname:i,search:ud(n),hash:dd(a)}}function Xi(e,t){let r=ms(t).split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Ws(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ld(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Ha(e){let t=ld(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function Cs(e,t,r,n=!1){let a;typeof e=="string"?a=Or(e):(a={...e},ve(!a.pathname||!a.pathname.includes("?"),Ws("?","pathname","search",a)),ve(!a.pathname||!a.pathname.includes("#"),Ws("#","pathname","hash",a)),ve(!a.search||!a.search.includes("#"),Ws("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let m=t.length-1;if(!n&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=od(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Al=e=>e.replace(/[\\/]{2,}/g,"/"),mt=e=>Al(e.join("/")),ms=e=>e.replace(/\/+$/,""),cd=e=>ms(e).replace(/^\/*/,"/"),ud=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,dd=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,md=class{constructor(e,t,r,n=!1){this.status=e,this.statusText=t||"",this.internal=n,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function hd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function fd(e){let t=e.map(r=>r.route.path).filter(Boolean);return mt(t)||"/"}var Pl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function _l(e,t){let r=e;if(typeof r!="string"||!Ya.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let n=r,a=!1;if(Pl)try{let i=new URL(window.location.href),o=Bu.test(r)?new URL(Uu(r,i.protocol)):new URL(r),l=Vt(o.pathname,t);o.origin===i.origin&&l!=null?r=l+o.search+o.hash:a=!0}catch{Xe(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:a,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var El=["POST","PUT","PATCH","DELETE"];new Set(El);var pd=["GET",...El];new Set(pd);var xd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function gd(e){try{return xd.includes(new URL(e).protocol)}catch{return!1}}var mn=A.createContext(null);mn.displayName="DataRouter";var As=A.createContext(null);As.displayName="DataRouterState";var Tl=A.createContext(!1);function yd(){return A.useContext(Tl)}var Il=A.createContext({isTransitioning:!1});Il.displayName="ViewTransition";var bd=A.createContext(new Map);bd.displayName="Fetchers";var vd=A.createContext(null);vd.displayName="Await";var tt=A.createContext(null);tt.displayName="Navigation";var $n=A.createContext(null);$n.displayName="Location";var nt=A.createContext({outlet:null,matches:[],isDataRoute:!1});nt.displayName="Route";var Ka=A.createContext(null);Ka.displayName="RouteError";var Fl="REACT_ROUTER_ERROR",jd="REDIRECT",Nd="ROUTE_ERROR_RESPONSE";function wd(e){if(e.startsWith(`${Fl}:${jd}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Sd(e){if(e.startsWith(`${Fl}:${Nd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new md(t.status,t.statusText,t.data)}catch{}}function kd(e,{relative:t}={}){ve(hn(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:n}=A.useContext(tt),{hash:a,pathname:i,search:o}=Ln(e,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:mt([r,i])),n.createHref({pathname:l,search:o,hash:a})}function hn(){return A.useContext($n)!=null}function ge(){return ve(hn(),"useLocation() may be used only in the context of a <Router> component."),A.useContext($n).location}var Dl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Rl(e){A.useContext(tt).static||A.useLayoutEffect(e)}function Se(){let{isDataRoute:e}=A.useContext(nt);return e?Md():Cd()}function Cd(){ve(hn(),"useNavigate() may be used only in the context of a <Router> component.");let e=A.useContext(mn),{basename:t,navigator:r}=A.useContext(tt),{matches:n}=A.useContext(nt),{pathname:a}=ge(),i=JSON.stringify(Ha(n)),o=A.useRef(!1);return Rl(()=>{o.current=!0}),A.useCallback((c,u={})=>{if(Xe(o.current,Dl),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=Cs(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:mt([t,d.pathname])),(u.replace?r.replace:r.push)(d,u.state,u)},[t,r,i,a,e])}var Ol=A.createContext(null);function ft(){return A.useContext(Ol)}function Ad(e){let t=A.useContext(nt).outlet;return A.useMemo(()=>t&&A.createElement(Ol.Provider,{value:e},t),[t,e])}function Pd(){let{matches:e}=A.useContext(nt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Ln(e,{relative:t}={}){let{matches:r}=A.useContext(nt),{pathname:n}=ge(),a=JSON.stringify(Ha(r));return A.useMemo(()=>Cs(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function _d(e,t){return $l(e,t)}function $l(e,t,r){var x;ve(hn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=A.useContext(tt),{matches:a}=A.useContext(nt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let b=u&&u.path||"";zl(l,!u||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${b}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
11
11
 
12
- Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let d=ge(),m;if(t){let b=typeof t=="string"?Or(t):t;ve(c==="/"||((x=b.pathname)==null?void 0:x.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${b.pathname}" was given in the \`location\` prop.`),m=b}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let b=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(b.length).join("/")}let y=r&&r.state.matches.length?r.state.matches.map(b=>Object.assign(b,{route:r.manifest[b.route.id]||b.route})):wl(e,{pathname:f});Xe(u||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Xe(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let p=Dd(y&&y.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:mt([c,n.encodeLocation?n.encodeLocation(b.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:mt([c,n.encodeLocation?n.encodeLocation(b.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),a,r);return t&&p?A.createElement($n.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function Ed(){let e=zd(),t=hd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=A.createElement(A.Fragment,null,A.createElement("p",null,"💿 Hey developer 👋"),A.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",A.createElement("code",{style:i},"ErrorBoundary")," or"," ",A.createElement("code",{style:i},"errorElement")," prop on your route.")),A.createElement(A.Fragment,null,A.createElement("h2",null,"Unexpected Application Error!"),A.createElement("h3",{style:{fontStyle:"italic"}},t),r?A.createElement("pre",{style:a},r):null,o)}var Td=A.createElement(Ed,null),Ll=class extends A.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const r=Sd(e.digest);r&&(e=r)}let t=e!==void 0?A.createElement(nt.Provider,{value:this.props.routeContext},A.createElement(Ka.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?A.createElement(Id,{error:e},t):t}};Ll.contextType=Tl;var Ys=new WeakMap;function Id({children:e,error:t}){let{basename:r}=A.useContext(tt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let n=Nd(t.digest);if(n){let a=Ys.get(t);if(a)throw a;let i=_l(n.location,r),o=i.absoluteURL||i.to;if(gd(o))throw new Error("Invalid redirect location");if(Pl&&!Ys.get(t))if(i.isExternal||n.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:n.replace}));throw Ys.set(t,l),l}return A.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Fd({routeContext:e,match:t,children:r}){let n=A.useContext(mn);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(nt.Provider,{value:e},r)}function Dd(e,t=[],r){let n=r==null?void 0:r.state;if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let d=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);ve(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,l=-1;if(r&&n){o=n.renderFallback;for(let d=0;d<a.length;d++){let m=a[d];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=d),m.route.id){let{loaderData:h,errors:f}=n,y=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||y){r.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=r==null?void 0:r.onError,u=n&&c?(d,m)=>{var h,f;c(d,{location:n.location,params:((f=(h=n.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:fd(n.matches),errorInfo:m})}:void 0;return a.reduceRight((d,m,h)=>{let f,y=!1,p=null,x=null;n&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Td,o&&(l<0&&h===0?(zl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,x=null):l===h&&(y=!0,x=m.route.hydrateFallbackElement||null)));let b=t.concat(a.slice(0,h+1)),j=()=>{let N;return f?N=p:y?N=x:m.route.Component?N=A.createElement(m.route.Component,null):m.route.element?N=m.route.element:N=d,A.createElement(Fd,{match:m,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:N})};return n&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?A.createElement(Ll,{location:n.location,revalidation:n.revalidation,component:p,error:f,children:j(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):j()},null)}function Qa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Rd(e){let t=A.useContext(mn);return ve(t,Qa(e)),t}function Od(e){let t=A.useContext(As);return ve(t,Qa(e)),t}function $d(e){let t=A.useContext(nt);return ve(t,Qa(e)),t}function Ja(e){let t=$d(e),r=t.matches[t.matches.length-1];return ve(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Ld(){return Ja("useRouteId")}function zd(){var n;let e=A.useContext(Ka),t=Od("useRouteError"),r=Ja("useRouteError");return e!==void 0?e:(n=t.errors)==null?void 0:n[r]}function Md(){let{router:e}=Rd("useNavigate"),t=Ja("useNavigate"),r=A.useRef(!1);return Rl(()=>{r.current=!0}),A.useCallback(async(a,i={})=>{Xe(r.current,Dl),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var eo={};function zl(e,t,r){!t&&!eo[e]&&(eo[e]=!0,Xe(!1,r))}A.memo(Vd);function Vd({routes:e,manifest:t,future:r,state:n,isStatic:a,onError:i}){return $l(e,void 0,{manifest:t,state:n,isStatic:a,onError:i})}function qd({basename:e,children:t,initialEntries:r,initialIndex:n,useTransitions:a}){let i=A.useRef();i.current==null&&(i.current=Zu({initialEntries:r,initialIndex:n,v5Compat:!0}));let o=i.current,[l,c]=A.useState({action:o.action,location:o.location}),u=A.useCallback(d=>{a===!1?c(d):A.startTransition(()=>c(d))},[a]);return A.useLayoutEffect(()=>o.listen(u),[o,u]),A.createElement(Ud,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function ht({to:e,replace:t,state:r,relative:n}){ve(hn(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=A.useContext(tt);Xe(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:i}=A.useContext(nt),{pathname:o}=ge(),l=Se(),c=Cs(e,Ha(i),o,n==="path"),u=JSON.stringify(c);return A.useEffect(()=>{l(JSON.parse(u),{replace:t,state:r,relative:n})},[l,u,n,t,r]),null}function Bd(e){return Ad(e.context)}function ee(e){ve(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ud({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:i=!1,useTransitions:o}){ve(!hn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=A.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof r=="string"&&(r=Or(r));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:y}=r,p=A.useMemo(()=>{let x=Vt(u,l);return x==null?null:{location:{pathname:x,search:d,hash:m,state:h,key:f,mask:y},navigationType:n}},[l,u,d,m,h,f,n,y]);return Xe(p!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${m}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:A.createElement(tt.Provider,{value:c},A.createElement($n.Provider,{children:t,value:p}))}function Ga({children:e,location:t}){return _d(ca(e),t)}function ca(e,t=[]){let r=[];return A.Children.forEach(e,(n,a)=>{if(!A.isValidElement(n))return;let i=[...t,a];if(n.type===A.Fragment){r.push.apply(r,ca(n.props.children,i));return}ve(n.type===ee,`[${typeof n.type=="string"?n.type:n.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ve(!n.props.index||!n.props.children,"An index route cannot have child routes.");let o={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,middleware:n.props.middleware,loader:n.props.loader,action:n.props.action,hydrateFallbackElement:n.props.hydrateFallbackElement,HydrateFallback:n.props.HydrateFallback,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.hasErrorBoundary===!0||n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=ca(n.props.children,i)),r.push(o)}),r}var is="get",os="application/x-www-form-urlencoded";function Ps(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Zd(e){return Ps(e)&&e.tagName.toLowerCase()==="button"}function Wd(e){return Ps(e)&&e.tagName.toLowerCase()==="form"}function Yd(e){return Ps(e)&&e.tagName.toLowerCase()==="input"}function Hd(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Kd(e,t){return e.button===0&&(!t||t==="_self")&&!Hd(e)}function ua(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function Qd(e,t){let r=ua(e);return t&&t.forEach((n,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}var Yn=null;function Jd(){if(Yn===null)try{new FormData(document.createElement("form"),0),Yn=!1}catch{Yn=!0}return Yn}var Gd=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Hs(e){return e!=null&&!Gd.has(e)?(Xe(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${os}"`),null):e}function Xd(e,t){let r,n,a,i,o;if(Wd(e)){let l=e.getAttribute("action");n=l?Vt(l,t):null,r=e.getAttribute("method")||is,a=Hs(e.getAttribute("enctype"))||os,i=new FormData(e)}else if(Zd(e)||Yd(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(n=c?Vt(c,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||is,a=Hs(e.getAttribute("formenctype"))||Hs(l.getAttribute("enctype"))||os,i=new FormData(l,e),!Jd()){let{name:u,type:d,value:m}=e;if(d==="image"){let h=u?`${u}.`:"";i.append(`${h}x`,"0"),i.append(`${h}y`,"0")}else u&&i.append(u,m)}}else{if(Ps(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=is,n=null,a=os,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xa(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ml(e,t,r,n){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${n}`:a.pathname=`${a.pathname}.${n}`:a.pathname==="/"?a.pathname=`_root.${n}`:t&&Vt(a.pathname,t)==="/"?a.pathname=`${ms(t)}/_root.${n}`:a.pathname=`${ms(a.pathname)}.${n}`,a}async function em(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(r){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function tm(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function rm(e,t,r){let n=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await em(i,r);return o.links?o.links():[]}return[]}));return im(n.flat(1).filter(tm).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function to(e,t,r,n,a,i){let o=(c,u)=>r[u]?c.route.id!==r[u].route.id:!0,l=(c,u)=>{var d;return r[u].pathname!==c.pathname||((d=r[u].route.path)==null?void 0:d.endsWith("*"))&&r[u].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,u)=>o(c,u)||l(c,u)):i==="data"?t.filter((c,u)=>{var m;let d=n.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=r[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function nm(e,t,{includeHydrateFallback:r}={}){return sm(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),r&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function sm(e){return[...new Set(e)]}function am(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function im(e,t){let r=new Set;return new Set(t),e.reduce((n,a)=>{let i=JSON.stringify(am(a));return r.has(i)||(r.add(i),n.push({key:i,link:a})),n},[])}function ei(){let e=A.useContext(mn);return Xa(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function om(){let e=A.useContext(As);return Xa(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ti=A.createContext(void 0);ti.displayName="FrameworkContext";function _s(){let e=A.useContext(ti);return Xa(e,"You must render this element inside a <HydratedRouter> element"),e}function lm(e,t){let r=A.useContext(ti),[n,a]=A.useState(!1),[i,o]=A.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:m}=t,h=A.useRef(null);A.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let p=b=>{b.forEach(j=>{o(j.isIntersecting)})},x=new IntersectionObserver(p,{threshold:.5});return h.current&&x.observe(h.current),()=>{x.disconnect()}}},[e]),A.useEffect(()=>{if(n){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[n]);let f=()=>{a(!0)},y=()=>{a(!1),o(!1)};return r?e!=="intent"?[i,h,{}]:[i,h,{onFocus:bn(l,f),onBlur:bn(c,y),onMouseEnter:bn(u,f),onMouseLeave:bn(d,y),onTouchStart:bn(m,f)}]:[!1,h,{}]}function bn(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function cm({page:e,...t}){let r=yd(),{nonce:n}=_s(),{router:a}=ei(),i=A.useMemo(()=>wl(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&n&&(t={...t,nonce:n}),r?A.createElement(dm,{page:e,matches:i,...t}):A.createElement(mm,{page:e,matches:i,...t})):null}function um(e){let{manifest:t,routeModules:r}=_s(),[n,a]=A.useState([]);return A.useEffect(()=>{let i=!1;return rm(e,t,r).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,r]),n}function dm({page:e,matches:t,...r}){let n=ge(),{future:a}=_s(),{basename:i}=ei(),o=A.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let l=Ml(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,u=[];for(let d of t)typeof d.route.shouldRevalidate=="function"?c=!0:u.push(d.route.id);return c&&u.length>0&&l.searchParams.set("_routes",u.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,n,t]);return A.createElement(A.Fragment,null,o.map(l=>A.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...r})))}function mm({page:e,matches:t,...r}){let n=ge(),{future:a,manifest:i,routeModules:o}=_s(),{basename:l}=ei(),{loaderData:c,matches:u}=om(),d=A.useMemo(()=>to(e,t,u,i,n,"data"),[e,t,u,i,n]),m=A.useMemo(()=>to(e,t,u,i,n,"assets"),[e,t,u,i,n]),h=A.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,x=!1;if(t.forEach(j=>{var k;let N=i.routes[j.route.id];!N||!N.hasLoader||(!d.some(E=>E.route.id===j.route.id)&&j.route.id in c&&((k=o[j.route.id])!=null&&k.shouldRevalidate)||N.hasClientLoader?x=!0:p.add(j.route.id))}),p.size===0)return[];let b=Ml(e,l,a.v8_trailingSlashAwareDataRequests,"data");return x&&p.size>0&&b.searchParams.set("_routes",t.filter(j=>p.has(j.route.id)).map(j=>j.route.id).join(",")),[b.pathname+b.search]},[l,a.v8_trailingSlashAwareDataRequests,c,n,i,d,t,e,o]),f=A.useMemo(()=>nm(m,i),[m,i]),y=um(m);return A.createElement(A.Fragment,null,h.map(p=>A.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...r})),f.map(p=>A.createElement("link",{key:p,rel:"modulepreload",href:p,...r})),y.map(({key:p,link:x})=>A.createElement("link",{key:p,nonce:r.nonce,...x,crossOrigin:x.crossOrigin??r.crossOrigin})))}function hm(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var fm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{fm&&(window.__reactRouterVersion="7.18.1")}catch{}var Vl=A.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...y},p){let{basename:x,navigator:b,useTransitions:j}=A.useContext(tt),N=typeof d=="string"&&Ya.test(d),k=_l(d,x);d=k.to;let E=kd(d,{relative:a}),P=ge(),_=null;if(l){let W=Cs(l,[],P.mask?P.mask.pathname:"/",!0);x!=="/"&&(W.pathname=W.pathname==="/"?x:mt([x,W.pathname])),_=b.createHref(W)}let[F,Y,M]=lm(n,y),se=ym(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:j});function q(W){t&&t(W),W.defaultPrevented||se(W)}let K=!(k.isExternal||i),te=A.createElement("a",{...y,...M,href:(K?_:void 0)||k.absoluteURL||E,onClick:K?q:t,ref:hm(p,Y),target:u,"data-discover":!N&&r==="render"?"true":void 0});return F&&!N?A.createElement(A.Fragment,null,te,A.createElement(cm,{page:E})):te});Vl.displayName="Link";var pm=A.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let m=Ln(o,{relative:u.relative}),h=ge(),f=A.useContext(As),{navigator:y,basename:p}=A.useContext(tt),x=f!=null&&Sm(m)&&l===!0,b=y.encodeLocation?y.encodeLocation(m).pathname:m.pathname,j=h.pathname,N=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;r||(j=j.toLowerCase(),N=N?N.toLowerCase():null,b=b.toLowerCase()),N&&p&&(N=Vt(N,p)||N);const k=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let E=j===b||!a&&j.startsWith(b)&&j.charAt(k)==="/",P=N!=null&&(N===b||!a&&N.startsWith(b)&&N.charAt(b.length)==="/"),_={isActive:E,isPending:P,isTransitioning:x},F=E?t:void 0,Y;typeof n=="function"?Y=n(_):Y=[n,E?"active":null,P?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let M=typeof i=="function"?i(_):i;return A.createElement(Vl,{...u,"aria-current":F,className:Y,ref:d,style:M,to:o,viewTransition:l},typeof c=="function"?c(_):c)});pm.displayName="NavLink";var xm=A.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:n,replace:a,state:i,method:o=is,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},y)=>{let{useTransitions:p}=A.useContext(tt),x=wm(),b=Nm(l,{relative:u}),j=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&Ya.test(l),k=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let P=E.nativeEvent.submitter,_=(P==null?void 0:P.getAttribute("formmethod"))||o,F=()=>x(P||E.currentTarget,{fetcherKey:t,method:_,navigate:r,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&r!==!1?A.startTransition(()=>F()):F()};return A.createElement("form",{ref:y,method:j,action:b,onSubmit:n?c:k,...f,"data-discover":!N&&e==="render"?"true":void 0})});xm.displayName="Form";function gm(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ql(e){let t=A.useContext(mn);return ve(t,gm(e)),t}function ym(e,{target:t,replace:r,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=Se(),m=ge(),h=Ln(e,{relative:o});return A.useCallback(f=>{if(Kd(f,t)){f.preventDefault();let y=r!==void 0?r:us(m)===us(h),p=()=>d(e,{replace:y,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?A.startTransition(()=>p()):p()}},[m,d,h,r,n,a,t,e,i,o,l,c,u])}function bm(e){Xe(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=A.useRef(ua(e)),r=A.useRef(!1),n=ge(),a=A.useMemo(()=>Qd(n.search,r.current?null:t.current),[n.search]),i=Se(),o=A.useCallback((l,c)=>{const u=ua(typeof l=="function"?l(new URLSearchParams(a)):l);r.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var vm=0,jm=()=>`__${String(++vm)}__`;function wm(){let{router:e}=ql("useSubmit"),{basename:t}=A.useContext(tt),r=Ld(),n=e.fetch,a=e.navigate;return A.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:m}=Xd(i,t);if(o.navigate===!1){let h=o.fetcherKey||jm();await n(h,r,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:r,flushSync:o.flushSync,viewTransition:o.viewTransition})},[n,a,t,r])}function Nm(e,{relative:t}={}){let{basename:r}=A.useContext(tt),n=A.useContext(nt);ve(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),i={...Ln(e||".",{relative:t})},o=ge();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let d=l.toString();i.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(i.pathname=i.pathname==="/"?r:mt([r,i.pathname])),us(i)}function Sm(e,{relative:t}={}){let r=A.useContext(Il);ve(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=ql("useViewTransitionState"),a=Ln(e,{relative:t});if(!r.isTransitioning)return!1;let i=Vt(r.currentLocation.pathname,n)||r.currentLocation.pathname,o=Vt(r.nextLocation.pathname,n)||r.nextLocation.pathname;return ds(a.pathname,o)!=null||ds(a.pathname,i)!=null}var fn=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(){}},jr,Jt,Hr,dl,km=(dl=class extends fn{constructor(){super();Q(this,jr);Q(this,Jt);Q(this,Hr);V(this,Hr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){v(this,Jt)||this.setEventListener(v(this,Hr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Jt))==null||t.call(this),V(this,Jt,void 0))}setEventListener(t){var r;V(this,Hr,t),(r=v(this,Jt))==null||r.call(this),V(this,Jt,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){v(this,jr)!==t&&(V(this,jr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof v(this,jr)=="boolean"?v(this,jr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},jr=new WeakMap,Jt=new WeakMap,Hr=new WeakMap,dl),ri=new km,Cm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},gt,wr,ml,Am=(ml=class{constructor(){Q(this,gt,Cm);Q(this,wr,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&v(this,wr)&&e!==v(this,gt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:v(this,gt),provider:e}),V(this,gt,e),process.env.NODE_ENV!=="production"&&V(this,wr,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&V(this,wr,!0),v(this,gt).setTimeout(e,t)}clearTimeout(e){v(this,gt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&V(this,wr,!0),v(this,gt).setInterval(e,t)}clearInterval(e){v(this,gt).clearInterval(e)}},gt=new WeakMap,wr=new WeakMap,ml),br=new Am;function Pm(e){setTimeout(e,0)}var _m=typeof window>"u"||"Deno"in globalThis;function Ze(){}function Em(e,t){return typeof e=="function"?e(t):e}function da(e){return typeof e=="number"&&e>=0&&e!==1/0}function Bl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function or(e,t){return typeof e=="function"?e(t):e}function Qe(e,t){return typeof e=="function"?e(t):e}function ro(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(n){if(t.queryHash!==ni(o,t.options))return!1}else if(!Pn(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function no(e,t){const{exact:r,status:n,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Tr(t.options.mutationKey)!==Tr(i))return!1}else if(!Pn(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function ni(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tr)(e)}function Tr(e){return JSON.stringify(e,(t,r)=>ha(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function Pn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Pn(e[r],t[r])):!1}var Tm=Object.prototype.hasOwnProperty;function ma(e,t,r=0){if(e===t)return e;if(r>500)return t;const n=so(e)&&so(t);if(!n&&!(ha(e)&&ha(t)))return t;const i=(n?e:Object.keys(e)).length,o=n?t:Object.keys(t),l=o.length,c=n?new Array(l):{};let u=0;for(let d=0;d<l;d++){const m=n?d:o[d],h=e[m],f=t[m];if(h===f){c[m]=h,(n?d<i:Tm.call(e,m))&&u++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const y=ma(h,f,r+1);c[m]=y,y===h&&u++}return i===l&&u===i?e:c}function hs(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 so(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ha(e){if(!ao(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!ao(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ao(e){return Object.prototype.toString.call(e)==="[object Object]"}function Im(e){return new Promise(t=>{br.setTimeout(t,e)})}function fa(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 ma(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 ma(e,t)}return t}function Fm(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Dm(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var fs=Symbol();function Ul(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===fs&&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===fs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function si(e,t){return typeof e=="function"?e(...t):!!e}function Rm(e,t,r){let n=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),n||(n=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),e}var _n=(()=>{let e=()=>_m;return{isServer(){return e()},setIsServer(t){e=t}}})();function pa(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),t(a)},r}var Om=Pm;function $m(){let e=[],t=0,r=l=>{l()},n=l=>{l()},a=Om;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var _e=$m(),Kr,Gt,Qr,hl,Lm=(hl=class extends fn{constructor(){super();Q(this,Kr,!0);Q(this,Gt);Q(this,Qr);V(this,Qr,t=>{if(typeof window<"u"&&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(){v(this,Gt)||this.setEventListener(v(this,Qr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Gt))==null||t.call(this),V(this,Gt,void 0))}setEventListener(t){var r;V(this,Qr,t),(r=v(this,Gt))==null||r.call(this),V(this,Gt,t(this.setOnline.bind(this)))}setOnline(t){v(this,Kr)!==t&&(V(this,Kr,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return v(this,Kr)}},Kr=new WeakMap,Gt=new WeakMap,Qr=new WeakMap,hl),ps=new Lm;function zm(e){return Math.min(1e3*2**e,3e4)}function Zl(e){return(e??"online")==="online"?ps.isOnline():!0}var xa=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Wl(e){let t=!1,r=0,n;const a=pa(),i=()=>a.status!=="pending",o=p=>{var x;if(!i()){const b=new xa(p);h(b),(x=e.onCancel)==null||x.call(e,b)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>ri.isFocused()&&(e.networkMode==="always"||ps.isOnline())&&e.canRun(),d=()=>Zl(e.networkMode)&&e.canRun(),m=p=>{i()||(n==null||n(),a.resolve(p))},h=p=>{i()||(n==null||n(),a.reject(p))},f=()=>new Promise(p=>{var x;n=b=>{(i()||u())&&p(b)},(x=e.onPause)==null||x.call(e)}).then(()=>{var p;n=void 0,i()||(p=e.onContinue)==null||p.call(e)}),y=()=>{if(i())return;let p;const x=r===0?e.initialPromise:void 0;try{p=x??e.fn()}catch(b){p=Promise.reject(b)}Promise.resolve(p).then(m).catch(b=>{var P;if(i())return;const j=e.retry??(_n.isServer()?0:3),N=e.retryDelay??zm,k=typeof N=="function"?N(r,b):N,E=j===!0||typeof j=="number"&&r<j||typeof j=="function"&&j(r,b);if(t||!E){h(b);return}r++,(P=e.onFail)==null||P.call(e,r,b),Im(k).then(()=>u()?void 0:f()).then(()=>{t?h(b):y()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?y():f().then(y),a)}}var Nr,fl,Yl=(fl=class{constructor(){Q(this,Nr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),da(this.gcTime)&&V(this,Nr,br.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(_n.isServer()?1/0:300*1e3))}clearGcTimeout(){v(this,Nr)!==void 0&&(br.clearTimeout(v(this,Nr)),V(this,Nr,void 0))}},Nr=new WeakMap,fl);function Mm(e){return{onFetch:(t,r)=>{var d,m,h,f,y;const n=t.options,a=(h=(m=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const x=N=>{Rm(N,()=>t.signal,()=>p=!0)},b=Ul(t.options,t.fetchOptions),j=async(N,k,E)=>{if(p)return Promise.reject(t.signal.reason);if(k==null&&N.pages.length)return Promise.resolve(N);const _=(()=>{const se={client:t.client,queryKey:t.queryKey,pageParam:k,direction:E?"backward":"forward",meta:t.options.meta};return x(se),se})(),F=await b(_),{maxPages:Y}=t.options,M=E?Dm:Fm;return{pages:M(N.pages,F,Y),pageParams:M(N.pageParams,k,Y)}};if(a&&i.length){const N=a==="backward",k=N?Vm:io,E={pages:i,pageParams:o},P=k(n,E);l=await j(E,P,N)}else{const N=e??i.length;do{const k=c===0?o[0]??n.initialPageParam:io(n,l);if(c>0&&k==null)break;l=await j(l,k),c++}while(c<N)}return l};t.options.persister?t.fetchFn=()=>{var p,x;return(x=(p=t.options).persister)==null?void 0:x.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function io(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Vm(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Jr,Sr,Gr,rt,kr,Fe,In,Cr,Ke,Hl,Rt,pl,qm=(pl=class extends Yl{constructor(t){super();Q(this,Ke);Q(this,Jr);Q(this,Sr);Q(this,Gr);Q(this,rt);Q(this,kr);Q(this,Fe);Q(this,In);Q(this,Cr);V(this,Cr,!1),V(this,In,t.defaultOptions),this.setOptions(t.options),this.observers=[],V(this,kr,t.client),V(this,rt,v(this,kr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,V(this,Sr,lo(this.options)),this.state=t.state??v(this,Sr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return v(this,Jr)}get promise(){var t;return(t=v(this,Fe))==null?void 0:t.promise}setOptions(t){if(this.options={...v(this,In),...t},t!=null&&t._type&&V(this,Jr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=lo(this.options);r.data!==void 0&&(this.setState(oo(r.data,r.dataUpdatedAt)),V(this,Sr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,rt).remove(this)}setData(t,r){const n=fa(this.state.data,t,this.options);return re(this,Ke,Rt).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t){re(this,Ke,Rt).call(this,{type:"setState",state:t})}cancel(t){var n,a;const r=(n=v(this,Fe))==null?void 0:n.promise;return(a=v(this,Fe))==null||a.cancel(t),r?r.then(Ze).catch(Ze):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return v(this,Sr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Qe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===fs||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>or(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:!Bl(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,Fe))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,Fe))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),v(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(v(this,Fe)&&(v(this,Cr)||re(this,Ke,Hl).call(this)?v(this,Fe).cancel({revert:!0}):v(this,Fe).cancelRetry()),this.scheduleGc()),v(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||re(this,Ke,Rt).call(this,{type:"invalidate"})}async fetch(t,r){var u,d,m,h,f,y,p,x,b,j,N;if(this.state.fetchStatus!=="idle"&&((u=v(this,Fe))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(v(this,Fe))return v(this,Fe).continueRetry(),v(this,Fe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const k=this.observers.find(E=>E.options.queryFn);k&&this.setOptions(k.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,a=k=>{Object.defineProperty(k,"signal",{enumerable:!0,get:()=>(V(this,Cr,!0),n.signal)})},i=()=>{const k=Ul(this.options,r),P=(()=>{const _={client:v(this,kr),queryKey:this.queryKey,meta:this.meta};return a(_),_})();return V(this,Cr,!1),this.options.persister?this.options.persister(k,P,this):k(P)},l=(()=>{const k={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:v(this,kr),state:this.state,fetchFn:i};return a(k),k})(),c=v(this,Jr)==="infinite"?Mm(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),V(this,Gr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&re(this,Ke,Rt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),V(this,Fe,Wl({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:k=>{k instanceof xa&&k.revert&&this.setState({...v(this,Gr),fetchStatus:"idle"}),n.abort()},onFail:(k,E)=>{re(this,Ke,Rt).call(this,{type:"failed",failureCount:k,error:E})},onPause:()=>{re(this,Ke,Rt).call(this,{type:"pause"})},onContinue:()=>{re(this,Ke,Rt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const k=await v(this,Fe).start();if(k===void 0)throw 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}`),new Error(`${this.queryHash} data is undefined`);return this.setData(k),(f=(h=v(this,rt).config).onSuccess)==null||f.call(h,k,this),(p=(y=v(this,rt).config).onSettled)==null||p.call(y,k,this.state.error,this),k}catch(k){if(k instanceof xa){if(k.silent)return v(this,Fe).promise;if(k.revert){if(this.state.data===void 0)throw k;return this.state.data}}throw re(this,Ke,Rt).call(this,{type:"error",error:k}),(b=(x=v(this,rt).config).onError)==null||b.call(x,k,this),(N=(j=v(this,rt).config).onSettled)==null||N.call(j,this.state.data,k,this),k}finally{this.scheduleGc()}}},Jr=new WeakMap,Sr=new WeakMap,Gr=new WeakMap,rt=new WeakMap,kr=new WeakMap,Fe=new WeakMap,In=new WeakMap,Cr=new WeakMap,Ke=new WeakSet,Hl=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Rt=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,...Kl(n.data,this.options),fetchMeta:t.meta??null};case"success":const a={...n,...oo(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return V(this,Gr,t.manual?a:void 0),a;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),_e.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),v(this,rt).notify({query:this,type:"updated",action:t})})},pl);function Kl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function oo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function lo(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 We,ie,Fn,Ue,Ar,Xr,Ot,Xt,Dn,en,tn,Pr,_r,er,rn,ue,Sn,ga,ya,ba,va,ja,wa,Na,Ql,xl,Bm=(xl=class extends fn{constructor(t,r){super();Q(this,ue);Q(this,We);Q(this,ie);Q(this,Fn);Q(this,Ue);Q(this,Ar);Q(this,Xr);Q(this,Ot);Q(this,Xt);Q(this,Dn);Q(this,en);Q(this,tn);Q(this,Pr);Q(this,_r);Q(this,er);Q(this,rn,new Set);this.options=r,V(this,We,t),V(this,Xt,null),V(this,Ot,pa()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,ie).addObserver(this),co(v(this,ie),this.options)?re(this,ue,Sn).call(this):this.updateResult(),re(this,ue,va).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Sa(v(this,ie),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Sa(v(this,ie),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,re(this,ue,ja).call(this),re(this,ue,wa).call(this),v(this,ie).removeObserver(this)}setOptions(t){const r=this.options,n=v(this,ie);if(this.options=v(this,We).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Qe(this.options.enabled,v(this,ie))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");re(this,ue,Na).call(this),v(this,ie).setOptions(this.options),r._defaulted&&!hs(this.options,r)&&v(this,We).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,ie),observer:this});const a=this.hasListeners();a&&uo(v(this,ie),n,this.options,r)&&re(this,ue,Sn).call(this),this.updateResult(),a&&(v(this,ie)!==n||Qe(this.options.enabled,v(this,ie))!==Qe(r.enabled,v(this,ie))||or(this.options.staleTime,v(this,ie))!==or(r.staleTime,v(this,ie)))&&re(this,ue,ga).call(this);const i=re(this,ue,ya).call(this);a&&(v(this,ie)!==n||Qe(this.options.enabled,v(this,ie))!==Qe(r.enabled,v(this,ie))||i!==v(this,er))&&re(this,ue,ba).call(this,i)}getOptimisticResult(t){const r=v(this,We).getQueryCache().build(v(this,We),t),n=this.createResult(r,t);return Zm(this,n)&&(V(this,Ue,n),V(this,Xr,this.options),V(this,Ar,v(this,ie).state)),n}getCurrentResult(){return v(this,Ue)}trackResult(t,r){return new Proxy(t,{get:(n,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&v(this,Ot).status==="pending"&&v(this,Ot).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,a))})}trackProp(t){v(this,rn).add(t)}getCurrentQuery(){return v(this,ie)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=v(this,We).defaultQueryOptions(t),n=v(this,We).getQueryCache().build(v(this,We),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return re(this,ue,Sn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,Ue)))}createResult(t,r){var Y;const n=v(this,ie),a=this.options,i=v(this,Ue),o=v(this,Ar),l=v(this,Xr),u=t!==n?t.state:v(this,Fn),{state:d}=t;let m={...d},h=!1,f;if(r._optimisticResults){const M=this.hasListeners(),se=!M&&co(t,r),q=M&&uo(t,n,r,a);(se||q)&&(m={...m,...Kl(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:y,errorUpdatedAt:p,status:x}=m;f=m.data;let b=!1;if(r.placeholderData!==void 0&&f===void 0&&x==="pending"){let M;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(M=i.data,b=!0):M=typeof r.placeholderData=="function"?r.placeholderData((Y=v(this,tn))==null?void 0:Y.state.data,v(this,tn)):r.placeholderData,M!==void 0&&(x="success",f=fa(i==null?void 0:i.data,M,r),h=!0)}if(r.select&&f!==void 0&&!b)if(i&&f===(o==null?void 0:o.data)&&r.select===v(this,Dn))f=v(this,en);else try{V(this,Dn,r.select),f=r.select(f),f=fa(i==null?void 0:i.data,f,r),V(this,en,f),V(this,Xt,null)}catch(M){V(this,Xt,M)}v(this,Xt)&&(y=v(this,Xt),f=v(this,en),p=Date.now(),x="error");const j=m.fetchStatus==="fetching",N=x==="pending",k=x==="error",E=N&&j,P=f!==void 0,F={status:x,fetchStatus:m.fetchStatus,isPending:N,isSuccess:x==="success",isError:k,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:y,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:j,isRefetching:j&&!N,isLoadingError:k&&!P,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:k&&P,isStale:ai(t,r),refetch:this.refetch,promise:v(this,Ot),isEnabled:Qe(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const M=F.data!==void 0,se=F.status==="error"&&!M,q=W=>{se?W.reject(F.error):M&&W.resolve(F.data)},K=()=>{const W=V(this,Ot,F.promise=pa());q(W)},te=v(this,Ot);switch(te.status){case"pending":t.queryHash===n.queryHash&&q(te);break;case"fulfilled":(se||F.data!==te.value)&&K();break;case"rejected":(!se||F.error!==te.reason)&&K();break}}return F}updateResult(){const t=v(this,Ue),r=this.createResult(v(this,ie),this.options);if(V(this,Ar,v(this,ie).state),V(this,Xr,this.options),v(this,Ar).data!==void 0&&V(this,tn,v(this,ie)),hs(r,t))return;V(this,Ue,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!v(this,rn).size)return!0;const o=new Set(i??v(this,rn));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,Ue)).some(l=>{const c=l;return v(this,Ue)[c]!==t[c]&&o.has(c)})};re(this,ue,Ql).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&re(this,ue,va).call(this)}},We=new WeakMap,ie=new WeakMap,Fn=new WeakMap,Ue=new WeakMap,Ar=new WeakMap,Xr=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,Dn=new WeakMap,en=new WeakMap,tn=new WeakMap,Pr=new WeakMap,_r=new WeakMap,er=new WeakMap,rn=new WeakMap,ue=new WeakSet,Sn=function(t){re(this,ue,Na).call(this);let r=v(this,ie).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Ze)),r},ga=function(){re(this,ue,ja).call(this);const t=or(this.options.staleTime,v(this,ie));if(_n.isServer()||v(this,Ue).isStale||!da(t))return;const n=Bl(v(this,Ue).dataUpdatedAt,t)+1;V(this,Pr,br.setTimeout(()=>{v(this,Ue).isStale||this.updateResult()},n))},ya=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,ie)):this.options.refetchInterval)??!1},ba=function(t){re(this,ue,wa).call(this),V(this,er,t),!(_n.isServer()||Qe(this.options.enabled,v(this,ie))===!1||!da(v(this,er))||v(this,er)===0)&&V(this,_r,br.setInterval(()=>{(this.options.refetchIntervalInBackground||ri.isFocused())&&re(this,ue,Sn).call(this)},v(this,er)))},va=function(){re(this,ue,ga).call(this),re(this,ue,ba).call(this,re(this,ue,ya).call(this))},ja=function(){v(this,Pr)!==void 0&&(br.clearTimeout(v(this,Pr)),V(this,Pr,void 0))},wa=function(){v(this,_r)!==void 0&&(br.clearInterval(v(this,_r)),V(this,_r,void 0))},Na=function(){const t=v(this,We).getQueryCache().build(v(this,We),this.options);if(t===v(this,ie))return;const r=v(this,ie);V(this,ie,t),V(this,Fn,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},Ql=function(t){_e.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(v(this,Ue))}),v(this,We).getQueryCache().notify({query:v(this,ie),type:"observerResultsUpdated"})})},xl);function Um(e,t){return Qe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Qe(t.retryOnMount,e)===!1)}function co(e,t){return Um(e,t)||e.state.data!==void 0&&Sa(e,t,t.refetchOnMount)}function Sa(e,t,r){if(Qe(t.enabled,e)!==!1&&or(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&ai(e,t)}return!1}function uo(e,t,r,n){return(e!==t||Qe(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&ai(e,r)}function ai(e,t){return Qe(t.enabled,e)!==!1&&e.isStaleByTime(or(t.staleTime,e))}function Zm(e,t){return!hs(e.getCurrentResult(),t)}var Rn,yt,Me,Er,bt,Ht,gl,Wm=(gl=class extends Yl{constructor(t){super();Q(this,bt);Q(this,Rn);Q(this,yt);Q(this,Me);Q(this,Er);V(this,Rn,t.client),this.mutationId=t.mutationId,V(this,Me,t.mutationCache),V(this,yt,[]),this.state=t.state||Jl(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){v(this,yt).includes(t)||(v(this,yt).push(t),this.clearGcTimeout(),v(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){V(this,yt,v(this,yt).filter(r=>r!==t)),this.scheduleGc(),v(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){v(this,yt).length||(this.state.status==="pending"?this.scheduleGc():v(this,Me).remove(this))}continue(){var t;return((t=v(this,Er))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,y,p,x,b,j,N,k,E,P,_;const r=()=>{re(this,bt,Ht).call(this,{type:"continue"})},n={client:v(this,Rn),meta:this.options.meta,mutationKey:this.options.mutationKey};V(this,Er,Wl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(F,Y)=>{re(this,bt,Ht).call(this,{type:"failed",failureCount:F,error:Y})},onPause:()=>{re(this,bt,Ht).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,Me).canRun(this)}));const a=this.state.status==="pending",i=!v(this,Er).canStart();try{if(a)r();else{re(this,bt,Ht).call(this,{type:"pending",variables:t,isPaused:i}),v(this,Me).config.onMutate&&await v(this,Me).config.onMutate(t,this,n);const Y=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,n));Y!==this.state.context&&re(this,bt,Ht).call(this,{type:"pending",context:Y,variables:t,isPaused:i})}const F=await v(this,Er).start();return await((u=(c=v(this,Me).config).onSuccess)==null?void 0:u.call(c,F,t,this.state.context,this,n)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,F,t,this.state.context,n)),await((f=(h=v(this,Me).config).onSettled)==null?void 0:f.call(h,F,null,this.state.variables,this.state.context,this,n)),await((p=(y=this.options).onSettled)==null?void 0:p.call(y,F,null,t,this.state.context,n)),re(this,bt,Ht).call(this,{type:"success",data:F}),F}catch(F){try{await((b=(x=v(this,Me).config).onError)==null?void 0:b.call(x,F,t,this.state.context,this,n))}catch(Y){Promise.reject(Y)}try{await((N=(j=this.options).onError)==null?void 0:N.call(j,F,t,this.state.context,n))}catch(Y){Promise.reject(Y)}try{await((E=(k=v(this,Me).config).onSettled)==null?void 0:E.call(k,void 0,F,this.state.variables,this.state.context,this,n))}catch(Y){Promise.reject(Y)}try{await((_=(P=this.options).onSettled)==null?void 0:_.call(P,void 0,F,t,this.state.context,n))}catch(Y){Promise.reject(Y)}throw re(this,bt,Ht).call(this,{type:"error",error:F}),F}finally{v(this,Me).runNext(this)}}},Rn=new WeakMap,yt=new WeakMap,Me=new WeakMap,Er=new WeakMap,bt=new WeakSet,Ht=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),_e.batch(()=>{v(this,yt).forEach(n=>{n.onMutationUpdate(t)}),v(this,Me).notify({mutation:this,type:"updated",action:t})})},gl);function Jl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $t,ut,On,yl,Ym=(yl=class extends fn{constructor(t={}){super();Q(this,$t);Q(this,ut);Q(this,On);this.config=t,V(this,$t,new Set),V(this,ut,new Map),V(this,On,0)}build(t,r,n){const a=new Wm({client:t,mutationCache:this,mutationId:++Wn(this,On)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){v(this,$t).add(t);const r=Hn(t);if(typeof r=="string"){const n=v(this,ut).get(r);n?n.push(t):v(this,ut).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(v(this,$t).delete(t)){const r=Hn(t);if(typeof r=="string"){const n=v(this,ut).get(r);if(n)if(n.length>1){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}else n[0]===t&&v(this,ut).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Hn(t);if(typeof r=="string"){const n=v(this,ut).get(r),a=n==null?void 0:n.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var n;const r=Hn(t);if(typeof r=="string"){const a=(n=v(this,ut).get(r))==null?void 0:n.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){_e.batch(()=>{v(this,$t).forEach(t=>{this.notify({type:"removed",mutation:t})}),v(this,$t).clear(),v(this,ut).clear()})}getAll(){return Array.from(v(this,$t))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>no(r,n))}findAll(t={}){return this.getAll().filter(r=>no(t,r))}notify(t){_e.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return _e.batch(()=>Promise.all(t.map(r=>r.continue().catch(Ze))))}},$t=new WeakMap,ut=new WeakMap,On=new WeakMap,yl);function Hn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Lt,tr,Ye,zt,Mt,ls,ka,bl,Hm=(bl=class extends fn{constructor(t,r){super();Q(this,Mt);Q(this,Lt);Q(this,tr);Q(this,Ye);Q(this,zt);V(this,Lt,t),this.setOptions(r),this.bindMethods(),re(this,Mt,ls).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=v(this,Lt).defaultMutationOptions(t),hs(this.options,r)||v(this,Lt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:v(this,Ye),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Tr(r.mutationKey)!==Tr(this.options.mutationKey)?this.reset():((n=v(this,Ye))==null?void 0:n.state.status)==="pending"&&v(this,Ye).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=v(this,Ye))==null||t.removeObserver(this)}onMutationUpdate(t){re(this,Mt,ls).call(this),re(this,Mt,ka).call(this,t)}getCurrentResult(){return v(this,tr)}reset(){var t;(t=v(this,Ye))==null||t.removeObserver(this),V(this,Ye,void 0),re(this,Mt,ls).call(this),re(this,Mt,ka).call(this)}mutate(t,r){var n;return V(this,zt,r),(n=v(this,Ye))==null||n.removeObserver(this),V(this,Ye,v(this,Lt).getMutationCache().build(v(this,Lt),this.options)),v(this,Ye).addObserver(this),v(this,Ye).execute(t)}},Lt=new WeakMap,tr=new WeakMap,Ye=new WeakMap,zt=new WeakMap,Mt=new WeakSet,ls=function(){var r;const t=((r=v(this,Ye))==null?void 0:r.state)??Jl();V(this,tr,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},ka=function(t){_e.batch(()=>{var r,n,a,i,o,l,c,u;if(v(this,zt)&&this.hasListeners()){const d=v(this,tr).variables,m=v(this,tr).context,h={client:v(this,Lt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(n=(r=v(this,zt)).onSuccess)==null||n.call(r,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=v(this,zt)).onSettled)==null||i.call(a,t.data,null,d,m,h)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=v(this,zt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=v(this,zt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(v(this,tr))})})},bl),vt,vl,Km=(vl=class extends fn{constructor(t={}){super();Q(this,vt);this.config=t,V(this,vt,new Map)}build(t,r,n){const a=r.queryKey,i=r.queryHash??ni(a,r);let o=this.get(i);return o||(o=new qm({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){v(this,vt).has(t.queryHash)||(v(this,vt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=v(this,vt).get(t.queryHash);r&&(t.destroy(),r===t&&v(this,vt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){_e.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return v(this,vt).get(t)}getAll(){return[...v(this,vt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>ro(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>ro(t,n)):r}notify(t){_e.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){_e.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){_e.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},vt=new WeakMap,vl),Ne,rr,nr,nn,sn,sr,an,on,jl,Qm=(jl=class{constructor(e={}){Q(this,Ne);Q(this,rr);Q(this,nr);Q(this,nn);Q(this,sn);Q(this,sr);Q(this,an);Q(this,on);V(this,Ne,e.queryCache||new Km),V(this,rr,e.mutationCache||new Ym),V(this,nr,e.defaultOptions||{}),V(this,nn,new Map),V(this,sn,new Map),V(this,sr,0)}mount(){Wn(this,sr)._++,v(this,sr)===1&&(V(this,an,ri.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,Ne).onFocus())})),V(this,on,ps.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,Ne).onOnline())})))}unmount(){var e,t;Wn(this,sr)._--,v(this,sr)===0&&((e=v(this,an))==null||e.call(this),V(this,an,void 0),(t=v(this,on))==null||t.call(this),V(this,on,void 0))}isFetching(e){return v(this,Ne).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return v(this,rr).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,Ne).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=v(this,Ne).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(or(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return v(this,Ne).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=v(this,Ne).get(n.queryHash),i=a==null?void 0:a.state.data,o=Em(t,i);if(o!==void 0)return v(this,Ne).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return _e.batch(()=>v(this,Ne).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,Ne).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=v(this,Ne);_e.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=v(this,Ne);return _e.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=_e.batch(()=>v(this,Ne).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Ze).catch(Ze)}invalidateQueries(e,t={}){return _e.batch(()=>(v(this,Ne).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=_e.batch(()=>v(this,Ne).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(Ze)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Ze)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=v(this,Ne).build(this,t);return r.isStaleByTime(or(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ze).catch(Ze)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ze).catch(Ze)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return ps.isOnline()?v(this,rr).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,Ne)}getMutationCache(){return v(this,rr)}getDefaultOptions(){return v(this,nr)}setDefaultOptions(e){V(this,nr,e)}setQueryDefaults(e,t){v(this,nn).set(Tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...v(this,nn).values()],r={};return t.forEach(n=>{Pn(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){v(this,sn).set(Tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...v(this,sn).values()],r={};return t.forEach(n=>{Pn(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...v(this,nr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ni(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===fs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...v(this,nr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){v(this,Ne).clear(),v(this,rr).clear()}},Ne=new WeakMap,rr=new WeakMap,nr=new WeakMap,nn=new WeakMap,sn=new WeakMap,sr=new WeakMap,an=new WeakMap,on=new WeakMap,jl),Gl=A.createContext(void 0),st=e=>{const t=A.useContext(Gl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Jm=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Gl.Provider,{value:e,children:t})),Xl=A.createContext(!1),Gm=()=>A.useContext(Xl);Xl.Provider;function Xm(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var eh=A.createContext(Xm()),th=()=>A.useContext(eh),rh=(e,t,r)=>{const n=r!=null&&r.state.error&&typeof e.throwOnError=="function"?si(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},nh=e=>{A.useEffect(()=>{e.clearReset()},[e])},sh=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||si(r,[e.error,n])),ah=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...a)=>r(n(...a)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ih=(e,t)=>e.isLoading&&e.isFetching&&!t,oh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,mo=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function lh(e,t,r){var f,y,p,x;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=Gm(),a=th(),i=st(),o=i.defaultQueryOptions(e);(y=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||y.call(f,o);const l=i.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`));const c=e.subscribed!==!1;o._optimisticResults=n?"isRestoring":c?"optimistic":void 0,ah(o),rh(o,a,l),nh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=A.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!n&&c;if(A.useSyncExternalStore(A.useCallback(b=>{const j=h?d.subscribe(_e.batchCalls(b)):Ze;return d.updateResult(),j},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),A.useEffect(()=>{d.setOptions(o)},[o,d]),oh(o,m))throw mo(o,d,a);if(sh({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((x=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||x.call(p,o,m),o.experimental_prefetchInRender&&!_n.isServer()&&ih(m,n)){const b=u?mo(o,d,a):l==null?void 0:l.promise;b==null||b.catch(Ze).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function Ee(e,t){return lh(e,Bm)}function ch(e,t){const r=st(),[n]=A.useState(()=>new Hm(r,e));A.useEffect(()=>{n.setOptions(e)},[n,e]);const a=A.useSyncExternalStore(A.useCallback(o=>n.subscribe(_e.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=A.useCallback((o,l)=>{n.mutate(o,l).catch(Ze)},[n]);if(a.error&&si(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function ec(e){return e.trim().replace(/\/+$/,"")}let Ca=null;function tc(e){Ca=ec(e)}let rc=null;function uh(e){rc=e}function dh(){return rc}let nc=null;function mh(e){nc=e.trim()}function hh(){return nc}function fh(){return Ca!==null?Ca:ec("")}const ho={get apiBaseUrl(){return fh()},apiVersion:"v1"};function ph(e){const t=e.startsWith("/")?e:`/${e}`;return`${ho.apiBaseUrl}/api/${ho.apiVersion}${t}`}const Aa="auth:session-expired";function xh(){window.dispatchEvent(new CustomEvent(Aa))}const gh=w.createContext(null);function yh({accessToken:e,onSessionExpired:t,children:r}){return uh(e),w.useEffect(()=>{if(!t)return;const n=()=>t();return window.addEventListener(Aa,n),()=>window.removeEventListener(Aa,n)},[t]),s.jsx(gh.Provider,{value:{accessToken:e},children:r})}class zn extends Error{constructor(r,n,a,i){super(a??n);Zn(this,"status");Zn(this,"title");Zn(this,"details");this.name="ApiError",this.status=r,this.title=n,this.details=i}}const sc="tax-remittance.auth";function bh(){var t;const e=localStorage.getItem(sc);if(!e)return null;try{const r=JSON.parse(e);return!r.accessToken||!((t=r.user)!=null&&t.userId)?null:new Date(r.user.expiresAt)<=new Date?(Pa(),null):r}catch{return Pa(),null}}function Pa(){localStorage.removeItem(sc)}function vh(){var e;return((e=bh())==null?void 0:e.accessToken)??null}async function jh(e){let t=null;try{t=await e.json()}catch{}return new zn(e.status,(t==null?void 0:t.title)??"Request failed",t==null?void 0:t.detail,t==null?void 0:t.errors)}async function wh(e,t={}){const{body:r,auth:n=!0,headers:a,...i}=t,o=new Headers(a);if(o.set("Accept","application/json"),r!==void 0&&o.set("Content-Type","application/json"),n){const u=dh()??vh();u&&o.set("Authorization",`Bearer ${u}`)}const l=hh();l&&o.set("X-Client-ID",l);const c=await fetch(ph(e),{...i,headers:o,body:r!==void 0?JSON.stringify(r):void 0});if(!c.ok){const u=await jh(c);throw n&&u.status===401&&(Pa(),xh()),u}if(c.status!==204)return await c.json()}async function he(e,t={}){return(await wh(e,t)).data}function ac(){return he("/portal/entities/mine")}function Nh(e){return he("/portal/entities",{method:"POST",body:e})}function Sh(e,t){return he(`/portal/entities/${e}`,{method:"PATCH",body:t})}const ic=w.createContext(null);function kh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],children:r}){var y;const[n,a]=w.useState(null),{data:i=[],isLoading:o,isError:l,refetch:c}=Ee({queryKey:["entities","mine"],queryFn:ac}),u=w.useRef(new Set),d=w.useRef(!1);w.useEffect(()=>{if(o)return;if(!d.current){i.forEach(x=>u.current.add(x.entityId)),d.current=!0;return}i.filter(x=>!u.current.has(x.entityId)).forEach(x=>{u.current.add(x.entityId),e==null||e(x)})},[i,o,e]);const m=n!==null&&i.some(p=>p.entityId===n)?n:((y=i[0])==null?void 0:y.entityId)??null,h=i.find(p=>p.entityId===m)??null,f=async()=>{await c()};return s.jsx(ic.Provider,{value:{entities:i,isLoading:o,isError:l,selectedEntity:h,setSelectedEntityId:a,refetchEntities:f,enabledPayments:t},children:r})}function pn(){const e=w.useContext(ic);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}function Ch({theme:e,children:t}){const r={},n=r,a=(e==null?void 0:e.primaryColor)??"#2563eb";n["--embedded-primary"]=a,n["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,n["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";n["--embedded-secondary"]=i,n["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,n["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return n["--embedded-tertiary"]=o,n["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,n["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(n["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(r.fontFamily=e.fontFamily),n.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:r,children:t})}const oc=w.createContext(null),Ah=6e3;function Ph(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function _h({toast:e,onDismiss:t}){const r=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${r?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[s.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),s.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>t(e.id),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border transition hover:opacity-80 ${r?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(Eh,{})})]}),s.jsx("div",{className:`mx-5 border-t ${r?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function Eh(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function Th({children:e}){const[t,r]=w.useState([]),n=w.useCallback(o=>{r(l=>l.filter(c=>c.id!==o))},[]),a=w.useCallback((o,l,c)=>{const u=Ph();r(d=>[...d,{id:u,variant:o,title:l,message:c}]),window.setTimeout(()=>{n(u)},Ah)},[n]),i=w.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(oc.Provider,{value:i,children:[e,ks.createPortal(s.jsx("div",{className:"pointer-events-none fixed right-4 top-4 z-[200] flex w-[min(100vw-2rem,28rem)] flex-col gap-3",children:t.map(o=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(_h,{toast:o,onDismiss:n})},o.id))}),document.body)]})}function Es(){const e=w.useContext(oc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class Ih extends w.Component{constructor(t){super(t),this.state={hasError:!1,message:""}}static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:"Unexpected error"}}render(){return this.state.hasError?s.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),s.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),s.jsx("button",{type:"button",className:"rounded-md bg-slate-100 px-4 py-2 text-sm text-slate-600 hover:bg-slate-200",onClick:()=>this.setState({hasError:!1,message:""}),children:"Try again"})]}):this.props.children}}function Fh(e){return e.startsWith("/dashboard")?"dashboard":e.startsWith("/payments")?"payments":e.startsWith("/tax-forms")?"tax-forms":e.startsWith("/settings")?"settings":e.startsWith("/create-entity/form")?"create-entity-form":e.startsWith("/create-entity")?"create-entity":"other"}function Dh({navigateFnRef:e,onNavigate:t}){const r=Se(),n=ge();return w.useEffect(()=>(e.current=r,()=>{e.current=null}),[r,e]),w.useEffect(()=>{t==null||t(Fh(n.pathname),n.pathname)},[n.pathname,t]),null}function Rh({selectEntityFnRef:e}){const{setSelectedEntityId:t}=pn();return w.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function ii({appKey:e,accessToken:t,apiBaseUrl:r,theme:n,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,navigateFnRef:l,selectEntityFnRef:c,enabledPayments:u,children:d}){tc(r),mh(e);const[m]=w.useState(()=>new Qm({defaultOptions:{queries:{retry:1,staleTime:300*1e3,refetchOnWindowFocus:!1}}}));return s.jsx(Ch,{theme:n,children:s.jsx(Jm,{client:m,children:s.jsx(Th,{children:s.jsx(yh,{accessToken:t,onSessionExpired:a,children:s.jsx(qd,{children:s.jsxs(kh,{onOrganizationCreated:i,enabledPayments:u,children:[s.jsx(Dh,{navigateFnRef:l,onNavigate:o}),s.jsx(Rh,{selectEntityFnRef:c}),s.jsx(Ih,{children:d})]})})})})})})}function oi(){const{entities:e,isLoading:t,isError:r,refetchEntities:n}=pn(),a=Se();return w.useEffect(()=>{t||r||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,r,e,a]),t?s.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600"})}):r?s.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:s.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),s.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),s.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),s.jsx("button",{type:"button",onClick:n,className:"mt-1 rounded-md bg-slate-100 px-4 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-200",children:"Retry"})]}):null}function li(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=pn(),n=Se(),i=ge().pathname.split("/").filter(Boolean).length>1;return s.jsxs("div",{className:"flex min-h-full flex-col bg-slate-50",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3",children:[i&&s.jsxs("button",{type:"button",onClick:()=>n(-1),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-slate-500 transition hover:bg-slate-100 hover:text-slate-700",children:[s.jsx(Oh,{}),"Back"]}),s.jsx("div",{className:"flex-1"}),t&&s.jsxs("button",{type:"button",onClick:()=>n("/entities"),className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-sm text-slate-700 transition hover:border-slate-300 hover:bg-slate-50",title:"Switch organization",children:[s.jsx("span",{className:"truncate font-medium",children:t.tradeName||t.firstName}),e.length>1&&s.jsx($h,{})]})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(Bd,{context:{entities:e,selectedEntity:t,setSelectedEntityId:r}})})]})}function Oh(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function $h(){return s.jsx("svg",{className:"h-3.5 w-3.5 shrink-0 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}const Lh=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function zh({onCreateClick:e}){return s.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[s.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-[#f3f4f6] bg-white shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)] sm:rounded-[24px]",children:[s.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-white/20 sm:h-16 sm:w-16",children:s.jsx(fo,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),s.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Create Your Entity"}),s.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),s.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[s.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:Lh.map(t=>s.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[s.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:s.jsx(Kn,{})}),t]},t))}),s.jsxs("button",{type:"button",onClick:e,className:"mt-5 flex h-12 w-full items-center justify-center gap-2 rounded-2xl bg-[#156bd5] text-sm font-black text-white transition hover:bg-[#125bb8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5] focus-visible:ring-offset-2 sm:mt-6 sm:h-14 sm:text-base",children:[s.jsx(fo,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",s.jsx(Mh,{})]})]})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 text-xs text-[#99a1af] sm:mt-5 sm:gap-x-4",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Kn,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Kn,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Kn,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function fo({className:e="h-5 w-5"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Kn({className:e="h-3 w-3"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 16 16",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.5 8.5l3 3 6-6"})})}function Mh(){return s.jsx("svg",{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})}function ci(){const e=Se(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return s.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:s.jsx(zh,{onCreateClick:t})})}var Mn=e=>e.type==="checkbox",ar=e=>e instanceof Date,$e=e=>e==null;const ui=e=>typeof e=="object";var be=e=>!$e(e)&&!Array.isArray(e)&&ui(e)&&!ar(e),_a=e=>be(e)&&e.target?Mn(e.target)?e.target.checked:e.target.value:e,lc=(e,t)=>t.split(".").some((r,n,a)=>!isNaN(Number(r))&&e.has(a.slice(0,n).join("."))),cc=e=>{const t=e.constructor&&e.constructor.prototype;return be(t)&&t.hasOwnProperty("isPrototypeOf")},Ts=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function we(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Ts&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(be(e)&&cc(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=we(e[a]));return n}const Kt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},dt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ct={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},uc="root",di=["__proto__","constructor","prototype"],Vh=/^\w*$/;var Vn=e=>Vh.test(e),fe=e=>e===void 0;const qh=/[.[\]'"]/;var Is=e=>e.split(qh).filter(Boolean),L=(e,t,r)=>{if(!t||!be(e))return r;const n=Vn(t)?[t]:Is(t);if(n.some(i=>di.includes(i)))return r;const a=n.reduce((i,o)=>$e(i)?void 0:i[o],e);return fe(a)||a===e?fe(e[t])?r:e[t]:a},Je=e=>typeof e=="boolean",Ve=e=>typeof e=="function",ce=(e,t,r)=>{let n=-1;const a=Vn(t)?[t]:Is(t),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=r;if(n!==o){const u=e[l];c=be(u)||Array.isArray(u)?u:isNaN(+a[n+1])?{}:[]}if(di.includes(l))return;e[l]=c,e=e[l]}};const dc=w.createContext(null);dc.displayName="HookFormControlContext";const mi=()=>w.useContext(dc);var mc=(e,t,r,n=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==dt.all&&(t._proxyFormState[o]=!n||dt.all),r&&(r[o]=!0),e[o]}});return a};const hi=Ts?w.useLayoutEffect:w.useEffect;function Bh(e){const t=mi(),{control:r=t,disabled:n,name:a,exact:i}=e||{},[o,l]=w.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=w.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return hi(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!n&&l({...r._formState,...u,defaultValues:r._defaultValues})}}),[a,n,i]),w.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),w.useMemo(()=>mc(o,r,c.current,!1),[o,r])}var qe=e=>typeof e=="string",Ea=(e,t,r,n,a)=>qe(e)?(n&&t.watch.add(e),L(r,e,a)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),L(r,i))):(n&&(t.watchAll=!0),r),Ta=e=>$e(e)||!ui(e);const po=(e,t)=>t.length===0&&!Array.isArray(e)&&!cc(e);function Ge(e,t,r=new WeakMap){if(e===t)return!0;if(Ta(e)||Ta(t))return Object.is(e,t);if(ar(e)&&ar(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(po(e,n)||po(t,a))return Object.is(e,t);if(!n.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=r.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),r.set(e,o)}for(const o of n){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(ar(l)&&ar(c)||(be(l)||Array.isArray(l))&&(be(c)||Array.isArray(c))?!Ge(l,c,r):!Object.is(l,c))return!1}}return!0}function Uh(e){const t=mi(),{control:r=t,name:n,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=w.useRef(a),u=w.useRef(l),d=w.useRef(void 0),m=w.useRef(r),h=w.useRef(n);u.current=l;const[f,y]=w.useState(()=>{const k=r._getWatch(n,c.current);return u.current?u.current(k):k}),p=w.useCallback(k=>{const E=Ea(n,r._names,k||r._formValues,!1,c.current);return u.current?u.current(E):E},[r._formValues,r._names,n]),x=w.useCallback(k=>{if(!i){const E=Ea(n,r._names,k||r._formValues,!1,c.current);if(u.current){const P=u.current(E);Ge(P,d.current)||(y(P),d.current=P)}else y(E)}},[r._formValues,r._names,i,n]);hi(()=>((m.current!==r||!Ge(h.current,n))&&(m.current=r,h.current=n,x()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:k=>{x(k.values)}})),[r,o,n,x]),w.useEffect(()=>r._removeUnmounted());const b=m.current!==r,j=h.current,N=w.useMemo(()=>{if(i)return null;const k=!b&&!Ge(j,n);return b||k?p():null},[i,b,n,j,p]);return N!==null?N:f}function Zh(e){const t=mi(),{name:r,disabled:n,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=lc(a._names.array,r),u=w.useMemo(()=>L(a._formValues,r,L(a._defaultValues,r,o)),[a,r,o]),d=Uh({control:a,name:r,defaultValue:u,exact:l}),m=Bh({control:a,name:r,exact:l}),h=w.useRef(e),f=w.useRef(null),y=w.useRef(a.register(r,{...e.rules,value:d,...Je(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=w.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!L(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!L(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!L(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!L(m.validatingFields,r)},error:{enumerable:!0,get:()=>L(m.errors,r)}}),[m,r]),x=w.useCallback(k=>{const E=_a(k);return L(a._fields,r)||(y.current=a.register(r,{...h.current.rules,value:E})),y.current.onChange({target:{value:_a(k),name:r},type:Kt.CHANGE})},[r,a]),b=w.useCallback(()=>y.current.onBlur({target:{value:L(a._formValues,r),name:r},type:Kt.BLUR}),[r,a._formValues]),j=w.useCallback(k=>{k&&(f.current={focus:()=>Ve(k.focus)&&k.focus(),select:()=>Ve(k.select)&&k.select(),setCustomValidity:P=>Ve(k.setCustomValidity)&&k.setCustomValidity(P),reportValidity:()=>Ve(k.reportValidity)&&k.reportValidity()});const E=L(a._fields,r);E&&E._f&&k&&(E._f.ref=f.current)},[a._fields,r]),N=w.useMemo(()=>({name:r,value:d,...Je(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:x,onBlur:b,ref:j}),[r,n,m.disabled,x,b,j,d]);return w.useEffect(()=>{const k=a._options.shouldUnregister||i;a.register(r,{...h.current.rules,...Je(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(P,_)=>{const F=L(a._fields,P);F&&F._f&&(F._f.mount=_)};if(E(r,!0),k){const P=we(L(i?a._defaultValues:a._options.values||a._defaultValues,r,L(a._options.defaultValues,r,h.current.defaultValue)));ce(a._defaultValues,r,P),fe(L(a._formValues,r))&&ce(a._formValues,r,P)}if(!c&&a.register(r),f.current){const P=L(a._fields,r);P&&P._f&&(P._f.ref=f.current)}return()=>{(c?k&&!a._state.action:k)?a.unregister(r):E(r,!1)}},[r,a,c,i]),w.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),w.useMemo(()=>({field:N,formState:m,fieldState:p}),[N,m,p])}const De=e=>e.render(Zh(e)),hc=e=>{const t={};for(const r of Object.keys(e))if(ui(e[r])&&e[r]!==null&&!ar(e[r])){const n=hc(e[r]);for(const a of Object.keys(n))t[`${r}.${a}`]=n[a]}else t[r]=e[r];return t},Wh=w.createContext(null);Wh.displayName="HookFormContext";var fi=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},fc=e=>Array.isArray(e)?e.filter(Boolean):[],cs=e=>Array.isArray(e)?e:[e],xo=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function pc(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],i=t[n];if(a&&be(a)&&i){const o=pc(a,i);be(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var Oe=e=>be(e)&&!Object.keys(e).length,pi=e=>e.type==="file",xs=e=>{if(!Ts)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},xc=e=>e.type==="select-multiple",xi=e=>e.type==="radio",Yh=e=>xi(e)||Mn(e),Ks=e=>xs(e)&&e.isConnected;function Hh(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;){if($e(e)){e=void 0;break}e=e[t[n]],n++}return e}function Kh(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function Ae(e,t){if(qe(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:Vn(t)?[t]:Is(t);if(r.some(o=>di.includes(String(o))))return e;const n=r.length===1?e:Hh(e,r),a=r.length-1,i=r[a];return n&&delete n[i],a!==0&&(be(n)&&Oe(n)||Array.isArray(n)&&Kh(n))&&Ae(e,r.slice(0,-1)),e}var Qh=e=>{for(const t in e)if(Ve(e[t]))return!0;return!1};function gc(e){return Array.isArray(e)||be(e)&&!Qh(e)}function Ia(e,t={}){for(const r in e){const n=e[r];gc(n)?(t[r]=Array.isArray(n)?[]:{},Ia(n,t[r])):fe(n)||(t[r]=!0)}return t}function Fa(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>Fa(r));return t.some(r=>r!==void 0)?t:void 0}if(be(e)){const t={};for(const r in e){const n=Fa(e[r]);fe(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function yr(e,t,r){r||(r=Ia(t));for(const n in e){const a=e[n];if(gc(a))fe(t)||Ta(r[n])?r[n]=Ia(a,Array.isArray(a)?[]:{}):yr(a,$e(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!Ge(a,i)}}return Fa(r)||{}}const go={value:!1,isValid:!1},yo={value:!0,isValid:!0};var yc=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&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?yo:{value:e[0].value,isValid:!0}:yo:go}return go},bc=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>fe(e)?e:t?e===""?NaN:e&&+e:r&&qe(e)?new Date(e):n?n(e):e;const bo={isValid:!1,value:null};var vc=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,bo):bo;function vo(e){const t=e.ref;return pi(t)?t.files:xi(t)?vc(e.refs).value:xc(t)?[...t.selectedOptions].map(({value:r})=>r):Mn(t)?yc(e.refs).value:bc(fe(t.value)?e.ref.value:t.value,e)}var Jh=(e,t,r,n)=>{const a={};for(const i of e){const o=L(t,i);o&&ce(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},gs=e=>e instanceof RegExp,vn=e=>fe(e)?e:gs(e)?e.source:be(e)?gs(e.value)?e.value.source:e.value:e,Qn=e=>({isOnSubmit:!e||e===dt.onSubmit,isOnBlur:e===dt.onBlur,isOnChange:e===dt.onChange,isOnAll:e===dt.all,isOnTouch:e===dt.onTouched});const jo="AsyncFunction";var Gh=e=>{if(!e||!e.validate)return!1;if(Ve(e.validate))return e.validate.constructor.name===jo;if(be(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===jo)return!0}return!1},Xh=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Qs=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const n of t.watch)if(e.startsWith(n)&&e.charAt(n.length)===".")return!0;return!1};const Cn=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const i=L(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(Cn(l,t))break}else if(be(l)&&Cn(l,t))break}}};function wo(e,t,r){const n=L(e,r);if(n||Vn(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=L(t,i),l=L(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:r}}var ef=(e,t,r,n)=>{r(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||n&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!n||dt.all))},tf=(e,t,r)=>!e||!t||e===t||cs(e).some(n=>n&&(r?n===t||n.startsWith(t+"."):n.startsWith(t)||t.startsWith(n))),rf=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,nf=(e,t)=>!fc(L(e,t)).length&&Ae(e,t),No=(e,t,r)=>{const n=L(e,r),a=Array.isArray(n)?n:[];return ce(a,uc,t[r]),ce(e,r,a),e};function So(e,t,r="validate"){if(qe(e)||Array.isArray(e)&&e.every(qe)||Je(e)&&!e)return{type:r,message:qe(e)?e:"",ref:t}}var Mr=e=>be(e)&&!gs(e)?e:{value:e,message:""},ko=async(e,t,r,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:m,max:h,pattern:f,validate:y,name:p,valueAsNumber:x,mount:b}=e._f,j=L(r,p);if(!b||t.has(p))return{};const N=l?l[0]:o,k=q=>{if(a&&N.reportValidity){const K=Je(q)?"":q||"";l?l.forEach(te=>te.setCustomValidity(K)):N.setCustomValidity(K),N.reportValidity()}},E={},P=xi(o),_=Mn(o),F=P||_,Y=(x||pi(o))&&fe(o.value)&&fe(j)||xs(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,M=fi.bind(null,p,n,E),se=(q,K,te,W=ct.maxLength,ne=ct.minLength)=>{const xe=q?K:te;E[p]={type:q?W:ne,message:xe,ref:o,...M(q?W:ne,xe)}};if(i?!Array.isArray(j)||!j.length:c&&(!F&&(Y||$e(j))||Je(j)&&!j||_&&!yc(l).isValid||P&&!vc(l).isValid)){const{value:q,message:K}=qe(c)?{value:!!c,message:c}:Mr(c);if(q&&(E[p]={type:ct.required,message:K,ref:N,...M(ct.required,K)},!n))return k(K),E}if(!Y&&(!$e(m)||!$e(h))){let q,K;const te=Mr(h),W=Mr(m);if(!$e(j)&&!isNaN(j)){const ne=o.valueAsNumber||j&&+j;$e(te.value)||(q=ne>te.value),$e(W.value)||(K=ne<W.value)}else{const ne=o.valueAsDate||new Date(j),xe=Pe=>new Date(new Date().toDateString()+" "+Pe),pe=o.type=="time",H=o.type=="week";qe(te.value)&&j&&(q=pe?xe(j)>xe(te.value):H?j>te.value:ne>new Date(te.value)),qe(W.value)&&j&&(K=pe?xe(j)<xe(W.value):H?j<W.value:ne<new Date(W.value))}if((q||K)&&(se(!!q,te.message,W.message,ct.max,ct.min),!n))return k(E[p].message),E}if((u||d)&&!Y&&(qe(j)||i&&Array.isArray(j))){const q=Mr(u),K=Mr(d),te=!$e(q.value)&&j.length>+q.value,W=!$e(K.value)&&j.length<+K.value;if((te||W)&&(se(te,q.message,K.message),!n))return k(E[p].message),E}if(f&&!Y&&qe(j)){const{value:q,message:K}=Mr(f);if(gs(q)&&!j.match(q)&&(E[p]={type:ct.pattern,message:K,ref:o,...M(ct.pattern,K)},!n))return k(K),E}if(y){if(Ve(y)){const q=await y(j,r),K=So(q,N);if(K&&(E[p]={...K,...M(ct.validate,K.message)},!n))return k(K.message),E}else if(be(y)){let q={};for(const K in y){if(!Oe(q)&&!n)break;const te=So(await y[K](j,r),N,K);te&&(q={...te,...M(K,te.message)},k(te.message),n&&(E[p]=q))}if(!Oe(q)&&(E[p]={ref:N,...q},!n))return E}}return k(!0),E};const sf={mode:dt.onSubmit,reValidateMode:dt.onChange,shouldFocusError:!0},Js="form",jc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function af(e={}){let t={...sf,...e},r={...we(jc),isLoading:Ve(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},a=be(t.defaultValues)||be(t.values)?we(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:we(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0,d=0,m=Qn(t.mode),h=Qn(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},y={...f};let p={...y};const x={array:xo(),state:xo()},b=t.criteriaMode===dt.all,j=g=>S=>{clearTimeout(u),u=setTimeout(g,S)},N=async g=>{if(!o.keepIsValid&&!t.disabled&&(y.isValid||p.isValid||g)){let S;t.resolver?(S=Oe((await K()).errors),k()):S=await ne({fields:n,onlyCheckValid:!0,eventType:Kt.VALID}),S!==r.isValid&&x.state.next({isValid:S})}},k=(g,S)=>{!t.disabled&&(y.isValidating||y.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(l.mount)).forEach(C=>{C&&(S?ce(r.validatingFields,C,S):Ae(r.validatingFields,C))}),x.state.next({validatingFields:r.validatingFields,isValidating:!Oe(r.validatingFields)}))},E=()=>{r.dirtyFields=yr(a,i)},P=(g,S=[],C,D,R=!0,B=!0)=>{if(D&&C&&!t.disabled){if(o.action=!0,B&&Array.isArray(L(n,g))){const O=C(L(n,g),D.argA,D.argB);R&&ce(n,g,O)}if(B&&Array.isArray(L(r.errors,g))){const O=C(L(r.errors,g),D.argA,D.argB);R&&ce(r.errors,g,O),nf(r.errors,g)}if((y.touchedFields||p.touchedFields)&&B&&Array.isArray(L(r.touchedFields,g))){const O=C(L(r.touchedFields,g),D.argA,D.argB);R&&ce(r.touchedFields,g,O)}(y.dirtyFields||p.dirtyFields)&&E(),x.state.next({name:g,isDirty:pe(g,S),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ce(i,g,S)},_=(g,S)=>{ce(r.errors,g,S),r.errors={...r.errors},x.state.next({errors:r.errors})},F=g=>{r.errors=g,x.state.next({errors:r.errors,isValid:!1})},Y=g=>{const S=Vn(g)?[g]:Is(g);let C=i,D=a;for(let R=0;R<S.length-1;R++){const B=S[R];if(C=$e(C)?C:C[B],D=$e(D)?D:D[B],C===null&&D!==null)return!0}return!1},M=(g,S,C,D)=>{const R=L(n,g);if(R){if(Y(g))return;const B=fe(L(i,g)),O=L(i,g,fe(C)?L(a,g):C);fe(O)||D&&D.defaultChecked||S?ce(i,g,S?O:vo(R._f)):pt(g,O),o.mount&&!o.action&&(N(),B&&r.isDirty&&(y.isDirty||p.isDirty)&&(pe()||(r.isDirty=!1,x.state.next({...r}))),e.shouldUnregister&&B&&!fe(L(i,g))&&Qs(g,l)&&(o.watch=!0))}},se=(g,S,C,D,R)=>{let B=!1,O=!1;const U={name:g};if(!t.disabled){if(!C||D){const $=Ge(L(a,g),S);(y.isDirty||p.isDirty)&&(O=r.isDirty,r.isDirty=U.isDirty=!$||pe(),B=O!==U.isDirty),O=!!L(r.dirtyFields,g),$!==r.isDirty?r.dirtyFields=yr(a,i):$?Ae(r.dirtyFields,g):ce(r.dirtyFields,g,!0),U.dirtyFields=r.dirtyFields,B=B||(y.dirtyFields||p.dirtyFields)&&O!==!$}if(C){const $=L(r.touchedFields,g);$||(ce(r.touchedFields,g,C),U.touchedFields=r.touchedFields,B=B||(y.touchedFields||p.touchedFields)&&$!==C)}B&&R&&x.state.next(U)}return B?U:{}},q=(g,S,C,D)=>{const R=L(r.errors,g),B=(y.isValid||p.isValid)&&Je(S)&&r.isValid!==S;if(t.delayError&&C?(c=j(()=>_(g,C)),c(t.delayError)):(clearTimeout(u),c=null,C?ce(r.errors,g,C):Ae(r.errors,g),r.errors={...r.errors}),(C?!Ge(R,C):R)||!Oe(D)||B){const O={...D,...B&&Je(S)?{isValid:S}:{},errors:r.errors,name:g};r={...r,...O},x.state.next(O)}},K=async g=>(k(g,!0),await t.resolver(i,t.context,Jh(g||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),te=async g=>{const{errors:S}=await K(g);if(k(g),g){for(const C of g){const D=L(S,C);D?l.array.has(C)&&be(D)&&!Object.keys(D).some(R=>!Number.isNaN(Number(R)))?No(r.errors,{[C]:D},C):ce(r.errors,C,D):Ae(r.errors,C)}r.errors={...r.errors}}else r.errors=S;return S},W=async({name:g,eventType:S})=>{if(e.validate){const C=await e.validate({formValues:i,formState:r,name:g,eventType:S});if(be(C))for(const D in C){const R=C[D];R&&lt(`${Js}.${D}`,{message:qe(R.message)?R.message:"",type:R.type||ct.validate})}else qe(C)||!C?lt(Js,{message:C||"",type:ct.validate}):Te(Js);return C}return!0},ne=async({fields:g,onlyCheckValid:S,name:C,eventType:D,context:R={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(R.runRootValidation=!0,!await W({name:C,eventType:D})&&(R.valid=!1,S)))return R.valid;for(const B in g){const O=g[B];if(O){const{_f:U,...$}=O;if(U){const X=l.array.has(U.name),Ie=O._f&&Gh(O._f),Ft=y.validatingFields||y.isValidating||p.validatingFields||p.isValidating;Ie&&Ft&&k([U.name],!0);const Dt=await ko(O,l.disabled,i,b,t.shouldUseNativeValidation&&!S,X);if(Ie&&Ft&&k([U.name]),Dt[U.name]&&(R.valid=!1,S)||(!S&&(L(Dt,U.name)?X?No(r.errors,Dt,U.name):ce(r.errors,U.name,Dt[U.name]):Ae(r.errors,U.name)),e.shouldUseNativeValidation&&Dt[U.name]))break}!Oe($)&&await ne({context:R,onlyCheckValid:S,fields:$,name:B,eventType:D})}}return R.valid},xe=()=>{for(const g of l.unMount){const S=L(n,g);S&&(S._f.refs?S._f.refs.every(C=>!Ks(C)):!Ks(S._f.ref))&&Et(g)}l.unMount=new Set},pe=(g,S)=>!t.disabled&&(g&&S&&ce(i,g,S),!Ge(o.mount?i:a,a)),H=(g,S,C)=>Ea(g,l,{...o.mount?i:fe(S)?a:qe(g)?{[g]:S}:S},C,S),Pe=g=>fc(L(o.mount?i:a,g,t.shouldUnregister?L(a,g,[]):[])),pt=(g,S,C={},D=!1,R=!1)=>{const B=L(n,g);let O=S;if(B){const U=B._f;U&&(!U.disabled&&ce(i,g,bc(S,U)),O=xs(U.ref)&&$e(S)?"":S,xc(U.ref)?[...U.ref.options].forEach($=>$.selected=O.includes($.value)):U.refs?Mn(U.ref)?U.refs.forEach($=>{(!$.defaultChecked||!$.disabled)&&(Array.isArray(O)?$.checked=!!O.find(X=>X===$.value):$.checked=O===$.value||!!O)}):U.refs.forEach($=>$.checked=$.value===O):pi(U.ref)?U.ref.value="":(U.ref.value=O,!U.ref.type&&!R&&x.state.next({name:g,values:D?i:we(i)})))}(C.shouldDirty||C.shouldTouch)&&se(g,O,C.shouldTouch,C.shouldDirty,!R),C.shouldValidate&&ot(g)},le=(g,S,C,D=!1,R=!1)=>{for(const B in S){if(!S.hasOwnProperty(B))return;const O=S[B],U=g+"."+B,$=L(n,U);(l.array.has(g)||be(O)||$&&!$._f)&&!ar(O)?le(U,O,C,D,R):pt(U,O,C,D,R)}},Re=(g,S,C,D,R=!1)=>{const B=L(n,g),O=l.array.has(g),U=D?S:we(S),$=L(i,g),X=Ge($,U);if(X||ce(i,g,U),O)x.array.next({name:g,values:D?i:we(i)}),(y.isDirty||y.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&(E(),R||x.state.next({name:g,dirtyFields:r.dirtyFields,isDirty:pe(g,U)}));else{const Ie=Array.isArray(U)&&!U.length||Oe(U);!B||B._f||$e(U)||Ie?pt(g,U,C,D,R):le(g,U,C,D,R)}if(!X&&!R){const Ie=Qs(g,l),Ft=D?i:we(i);x.state.next({...Ie&&r,name:o.mount||Ie?g:void 0,values:Ft})}},ze=(g,S,C={})=>Re(g,S,C,!1),He=(g,S={})=>{const C=Ve(g)?g(i):g;if(!Ge(i,C)){i={...i,...C};const D=hc(C);for(const R of l.mount)R in D&&Re(R,D[R],S,!0,!0);x.state.next({...r,name:void 0,type:void 0,...d?{values:i}:{}}),S.shouldValidate&&N()}},At=async g=>{o.mount=!0;const S=g.target;let C=S.name,D=!0;const R=L(n,C),B=O=>{D=Number.isNaN(O)||ar(O)&&isNaN(O.getTime())||Ge(O,L(i,C,O))};if(R){let O,U;const $=S.type?vo(R._f):_a(g),X=g.type===Kt.BLUR||g.type===Kt.FOCUS_OUT,Ie=!Xh(R._f)&&!e.validate&&!t.resolver&&!L(r.errors,C)&&!R._f.deps,Ft=Ie||rf(X,L(r.touchedFields,C),r.isSubmitted,h,m),Dt=Qs(C,l,X);ce(i,C,$),X?(!S||!S.readOnly)&&(R._f.onBlur&&R._f.onBlur(g),c&&c(0)):R._f.onChange&&R._f.onChange(g);const yn=se(C,$,X),Lu=!Oe(yn)||Dt;if(!X&&x.state.next({name:C,type:g.type,...d?{values:we(i)}:{}}),Ft)return(!Ie||!r.isValid)&&(y.isValid||p.isValid)&&(t.mode==="onBlur"?X&&N():X||N()),Lu&&x.state.next({name:C,...Dt?{}:yn});if(!t.resolver&&e.validate&&await W({name:C,eventType:g.type}),!X&&Dt&&x.state.next({...r}),t.resolver){const{errors:Hi}=await K([C]);if(k([C]),B($),!D){!Oe(yn)&&x.state.next(yn);return}const zu=wo(r.errors,n,C),Ki=wo(Hi,n,zu.name||C);O=Ki.error,C=Ki.name,U=Oe(Hi)}else k([C],!0),O=(await ko(R,l.disabled,i,b,t.shouldUseNativeValidation))[C],k([C]),B($),D&&(O?U=!1:(y.isValid||p.isValid)&&(U=await ne({fields:n,onlyCheckValid:!0,name:C,eventType:g.type})));D&&(R._f.deps&&(!Array.isArray(R._f.deps)||R._f.deps.length>0)&&ot(R._f.deps),q(C,U,O,yn))}},it=(g,S)=>{if(L(r.errors,S)&&g.focus)return g.focus(),1},ot=async(g,S={})=>{let C,D;const R=cs(g);if(t.resolver){const B=await te(fe(g)?g:R);C=Oe(B),D=g?!R.some(O=>L(B,O)):C}else g?(D=(await Promise.all(R.map(async B=>{const O=L(n,B);return await ne({fields:O&&O._f?{[B]:O}:O,eventType:Kt.TRIGGER})}))).every(Boolean),!(!D&&!r.isValid)&&N()):D=C=await ne({fields:n,name:g,eventType:Kt.TRIGGER});return x.state.next({...!qe(g)||(y.isValid||p.isValid)&&C!==r.isValid?{}:{name:g},...t.resolver||!g?{isValid:C}:{},errors:r.errors}),S.shouldFocus&&!D&&Cn(n,it,g?R:l.mount),D},Pt=(g,S)=>{let C={...o.mount?i:a};return S&&(C=pc(S.dirtyFields?r.dirtyFields:r.touchedFields,C)),fe(g)?C:qe(g)?L(C,g):g.map(D=>L(C,D))},oe=(g,S)=>({invalid:!!L((S||r).errors,g),isDirty:!!L((S||r).dirtyFields,g),error:L((S||r).errors,g),isValidating:!!L(r.validatingFields,g),isTouched:!!L((S||r).touchedFields,g)}),Te=g=>{const S=g?cs(g):void 0;S==null||S.forEach(C=>Ae(r.errors,C)),S?S.forEach(C=>{x.state.next({name:C,errors:r.errors})}):x.state.next({errors:{}})},lt=(g,S,C)=>{const D=(L(n,g,{_f:{}})._f||{}).ref,R=L(r.errors,g)||{},{ref:B,message:O,type:U,...$}=R;ce(r.errors,g,{...$,...S,ref:D}),x.state.next({name:g,errors:r.errors,isValid:!1}),C&&C.shouldFocus&&D&&D.focus&&D.focus()},_t=(g,S)=>{if(Ve(g)){d++;const{unsubscribe:C}=x.state.subscribe({next:R=>"values"in R&&g(R.values||H(void 0,S),R)});let D=!1;return{unsubscribe:()=>{D||(D=!0,d--,C())}}}return H(g,S,!0)},xt=g=>{var S;const C=!!(!((S=g.formState)===null||S===void 0)&&S.values);C&&d++;const{unsubscribe:D}=x.state.subscribe({next:B=>{if(tf(g.name,B.name,g.exact)&&ef(B,g.formState||y,xr,g.reRenderRoot)){const O={...i};g.callback({values:O,...r,...B,defaultValues:a})}}});if(!C)return D;let R=!1;return()=>{R||(R=!0,d--,D())}},mr=g=>(o.mount=!0,p={...p,...g.formState},xt({...g,formState:{...f,...g.formState}})),Et=(g,S={})=>{for(const C of g?cs(g):l.mount)l.mount.delete(C),l.array.delete(C),S.keepValue||(Ae(n,C),Ae(i,C)),!S.keepError&&Ae(r.errors,C),!S.keepDirty&&Ae(r.dirtyFields,C),!S.keepTouched&&Ae(r.touchedFields,C),!S.keepIsValidating&&Ae(r.validatingFields,C),!t.shouldUnregister&&!S.keepDefaultValue&&Ae(a,C);x.state.next({values:we(i)}),x.state.next({...r,...S.keepDirty?{isDirty:pe()}:{}}),!S.keepIsValid&&N()},Ut=({disabled:g,name:S})=>{if(Je(g)&&o.mount||g||l.disabled.has(S)){const R=l.disabled.has(S)!==!!g;g?l.disabled.add(S):l.disabled.delete(S),R&&o.mount&&!o.action&&N()}},Tt=(g,S={})=>{let C=L(n,g);const D=Je(S.disabled)||Je(t.disabled),R=!l.registerName.has(g)&&C&&C._f&&!C._f.mount;return ce(n,g,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:g}},name:g,mount:!0,...S}}),l.mount.add(g),C&&!R?Ut({disabled:Je(S.disabled)?S.disabled:t.disabled,name:g}):M(g,!0,S.value),{...D?{disabled:S.disabled||t.disabled}:{},...t.progressive?{required:!!S.required,min:vn(S.min),max:vn(S.max),minLength:vn(S.minLength),maxLength:vn(S.maxLength),pattern:vn(S.pattern)}:{},name:g,onChange:At,onBlur:At,ref:B=>{if(B){l.registerName.add(g),Tt(g,S),l.registerName.delete(g),C=L(n,g);const O=fe(B.value)&&B.querySelectorAll&&B.querySelectorAll("input,select,textarea")[0]||B,U=Yh(O),$=C._f.refs||[];if(U?$.find(X=>X===O):O===C._f.ref)return;ce(n,g,{_f:{...C._f,...U?{refs:[...$.filter(Ks),O,...Array.isArray(L(a,g))?[{}]:[]],ref:{type:O.type,name:g}}:{ref:O}}}),M(g,!1,void 0,O)}else C=L(n,g,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||S.shouldUnregister)&&!(lc(l.array,g)&&o.action)&&l.unMount.add(g)}}},It=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Cn(n,it,l.mount),hr=g=>{Je(g)&&(x.state.next({disabled:g}),Cn(n,(S,C)=>{const D=L(n,C);D&&(S.disabled=D._f.disabled||g,Array.isArray(D._f.refs)&&D._f.refs.forEach(R=>{R.disabled=D._f.disabled||g}))},0,!1))},Zt=(g,S)=>async C=>{let D;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let R=we(i);if(x.state.next({isSubmitting:!0}),t.resolver){const{errors:B,values:O}=await K();k(),r.errors=B,R=we(O)}else await ne({fields:n,eventType:Kt.SUBMIT});if(l.disabled.size)for(const B of l.disabled)Ae(R,B);if(Ae(r.errors,uc),Oe(r.errors)){x.state.next({errors:{}});try{await g(R,C)}catch(B){D=B}}else S&&await S({...r.errors},C),It(),setTimeout(It);if(x.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Oe(r.errors)&&!D,submitCount:r.submitCount+1,errors:r.errors}),D)throw D},fr=(g,S={})=>{L(n,g)&&(fe(S.defaultValue)?ze(g,we(L(a,g))):(ze(g,S.defaultValue),ce(a,g,we(S.defaultValue))),S.keepTouched||Ae(r.touchedFields,g),S.keepDirty||(Ae(r.dirtyFields,g),r.isDirty=S.defaultValue?pe(g,we(L(a,g))):pe()),S.keepError||(Ae(r.errors,g),y.isValid&&N()),x.state.next({...r}))},Wt=(g,S={})=>{const C=g?we(g):a,D=we(C),R=Oe(g),B=D;if(S.keepDefaultValues||(a=C),!S.keepValues){if(S.keepDirtyValues){const O=new Set([...l.mount,...Object.keys(yr(a,i))]);for(const U of Array.from(O)){const $=L(r.dirtyFields,U),X=L(i,U),Ie=L(B,U);$&&!fe(X)?ce(B,U,X):!$&&!fe(Ie)&&ze(U,Ie)}}else{if(Ts&&fe(g))for(const O of l.mount){const U=L(n,O);if(U&&U._f){const $=Array.isArray(U._f.refs)?U._f.refs[0]:U._f.ref;if(xs($)){const X=$.closest("form");if(X){X.reset();break}}}}if(S.keepFieldsRef)for(const O of l.mount)ze(O,L(B,O));else n={}}if(t.shouldUnregister){if(i=S.keepDefaultValues?we(a):{},S.keepFieldsRef)for(const O of l.mount)ce(i,O,L(B,O))}else i=we(B);x.array.next({values:{...B}}),x.state.next({name:void 0,type:void 0,values:{...B}})}l={mount:S.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!y.isValid||!!S.keepIsValid||!!S.keepDirtyValues||!t.shouldUnregister&&!Oe(B),o.watch=!!t.shouldUnregister,o.keepIsValid=!!S.keepIsValid,o.action=!1,S.keepErrors||(r.errors={}),x.state.next({submitCount:S.keepSubmitCount?r.submitCount:0,isDirty:R?!1:S.keepDirty?r.isDirty:S.keepValues?pe():!!(S.keepDefaultValues&&!Ge(g,a)),isSubmitted:S.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:R?{}:S.keepDirtyValues?S.keepDefaultValues&&i?yr(a,i):r.dirtyFields:S.keepDefaultValues&&g?yr(a,g):S.keepDirty?r.dirtyFields:{},touchedFields:S.keepTouched?r.touchedFields:{},errors:S.keepErrors?r.errors:{},isSubmitSuccessful:S.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Yt=(g,S)=>Wt(Ve(g)?g(i):g,{...t.resetOptions,...S}),pr=(g,S={})=>{const C=L(n,g),D=C&&C._f;if(D){const R=D.refs?D.refs[0]:D.ref;R.focus&&setTimeout(()=>{R.focus(),S.shouldSelect&&Ve(R.select)&&R.select()})}},xr=g=>{const{name:S,type:C,values:D,...R}=g;r={...r,...R}},ae={control:{register:Tt,unregister:Et,getFieldState:oe,handleSubmit:Zt,setError:lt,_subscribe:xt,_runSchema:K,_updateIsValidating:k,_focusError:It,_getWatch:H,_getDirty:pe,_setValid:N,_setFieldArray:P,_setDisabledField:Ut,_setErrors:F,_getFieldArray:Pe,_reset:Wt,_resetDefaultValues:()=>Ve(t.defaultValues)&&t.defaultValues().then(g=>{Yt(g,t.resetOptions),x.state.next({isLoading:!1})}),_removeUnmounted:xe,_disableForm:hr,_subjects:x,_proxyFormState:y,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(g){o=g},get _defaultValues(){return a},get _names(){return l},set _names(g){l=g},get _formState(){return r},get _options(){return t},set _options(g){t={...t,...g},m=Qn(t.mode),h=Qn(t.reValidateMode)}},subscribe:mr,trigger:ot,register:Tt,handleSubmit:Zt,watch:_t,setValue:ze,setValues:He,getValues:Pt,reset:Yt,resetField:fr,resetDefaultValues:(g,S={})=>{if(a=we(g),!S.keepDirty){const C=yr(a,i);r.dirtyFields=C,r.isDirty=!Oe(C)}S.keepIsValid||N(),x.state.next({...r,defaultValues:a})},clearErrors:Te,unregister:Et,setError:lt,setFocus:pr,getFieldState:oe};return{...ae,formControl:ae}}function Nt(e={}){const t=w.useRef(void 0),r=w.useRef(void 0),n=w.useRef(e.formControl),[a,i]=w.useState(()=>({...we(jc),isLoading:Ve(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ve(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Ve(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=af(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,hi(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,l},[o]),w.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),w.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),w.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),w.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),w.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),w.useEffect(()=>{var l;e.values&&!Ge(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),w.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=w.useMemo(()=>mc(a,o),[o,a]),t.current}const Co=(e,t,r)=>{if(e&&"reportValidity"in e){const n=L(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Da=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?Co(n.ref,r,e):n&&n.refs&&n.refs.forEach(a=>Co(a,r,e))}},Ao=(e,t)=>{t.shouldUseNativeValidation&&Da(e,t);const r={};for(const n in e){const a=L(t.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(of(t.names||Object.keys(e),n)){const o=Object.assign({},L(r,n));ce(o,"root",i),ce(r,n,o)}else ce(r,n,i)}return r},of=(e,t)=>{const r=Po(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(n=>Po(n).match(`^${r}\\.\\d+`))};function Po(e){return e.replace(/[\[\]]/g,"")}var _o;function I(e,t,r){function n(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=o.prototype,d=Object.keys(u);for(let m=0;m<d.length;m++){const h=d[m];h in l||(l[h]=u[h].bind(l))}}const a=(r==null?void 0:r.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const u=r!=null&&r.Parent?new i:this;n(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,u;return r!=null&&r.Parent&&l instanceof r.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class wc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(_o=globalThis).__zod_globalConfig??(_o.__zod_globalConfig={});const gi=globalThis.__zod_globalConfig;function Ir(e){return gi}function Nc(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function Ra(e,t){return typeof t=="bigint"?t.toString():t}function yi(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function bi(e){return e==null}function vi(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const Eo=Symbol("evaluating");function me(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Eo)return n===void 0&&(n=Eo,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function $r(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function cr(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function To(e){return JSON.stringify(e)}function lf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Sc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ys(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cf=yi(()=>{var e;if(gi.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function En(e){if(ys(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ys(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function kc(e){return En(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const uf=new Set(["string","number","symbol"]);function ln(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ur(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function G(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function df(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function mf(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=cr(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=r.shape[l])}return $r(this,"shape",o),o},checks:[]});return ur(e,i)}function hf(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=cr(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return $r(this,"shape",o),o},checks:[]});return ur(e,i)}function ff(e,t){if(!En(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=cr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return $r(this,"shape",i),i}});return ur(e,a)}function pf(e,t){if(!En(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=cr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return $r(this,"shape",n),n}});return ur(e,r)}function xf(e,t){var n;if((n=e._zod.def.checks)!=null&&n.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r=cr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return $r(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ur(e,r)}function gf(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=cr(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(r)for(const u in r){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return $r(this,"shape",c),c},checks:[]});return ur(t,o)}function yf(e,t,r){const n=cr(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return $r(this,"shape",i),i}});return ur(t,n)}function qr(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)!==!0)return!0;return!1}function bf(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)===!1)return!0;return!1}function Cc(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Jn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Fr(e,t,r){var c,u,d,m,h,f;const n=e.message?e.message:Jn((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??Jn((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??Jn((h=r.customError)==null?void 0:h.call(r,e))??Jn((f=r.localeError)==null?void 0:f.call(r,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=n,t!=null&&t.reportInput&&(l.input=o),l}function ji(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Tn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Ac=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ra,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wi=I("$ZodError",Ac),Fs=I("$ZodError",Ac,{Parent:Error});function vf(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function jf(e,t=r=>r.message){const r={_errors:[]},n=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>n({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")n({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")n({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)r._errors.push(t(o));else{let c=r,u=0;for(;u<l.length;){const d=l[u];u===l.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return n(e),r}const Ds=e=>(t,r,n,a)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Ur;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Sc(l,a==null?void 0:a.callee),l}return o.value},wf=Ds(Fs),Rs=e=>async(t,r,n,a)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Sc(l,a==null?void 0:a.callee),l}return o.value},Nf=Rs(Fs),Os=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Ur;return i.issues.length?{success:!1,error:new(e??wi)(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},Sf=Os(Fs),$s=e=>async(t,r,n)=>{const a=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},kf=$s(Fs),Cf=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Ds(e)(t,r,a)},Af=e=>(t,r,n)=>Ds(e)(t,r,n),Pf=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Rs(e)(t,r,a)},_f=e=>async(t,r,n)=>Rs(e)(t,r,n),Ef=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Os(e)(t,r,a)},Tf=e=>(t,r,n)=>Os(e)(t,r,n),If=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return $s(e)(t,r,a)},Ff=e=>async(t,r,n)=>$s(e)(t,r,n),Df=/^[cC][0-9a-z]{6,}$/,Rf=/^[0-9a-z]+$/,Of=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$f=/^[0-9a-vA-V]{20}$/,Lf=/^[A-Za-z0-9]{27}$/,zf=/^[a-zA-Z0-9_-]{21}$/,Mf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Vf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Io=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qf=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Bf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Uf(){return new RegExp(Bf,"u")}const Zf=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Yf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Hf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Kf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pc=/^[A-Za-z0-9_-]*$/,Qf=/^https?$/,Jf=/^\+[1-9]\d{6,14}$/,_c="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Gf=new RegExp(`^${_c}$`);function Ec(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Xf(e){return new RegExp(`^${Ec(e)}$`)}function ep(e){const t=Ec({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${_c}T(?:${n})$`)}const tp=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},rp=/^(?:true|false)$/i,np=/^[^A-Z]*$/,sp=/^[^a-z]*$/,St=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),ap=I("$ZodCheckMaxLength",(e,t)=>{var r;St.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!bi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const o=ji(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),ip=I("$ZodCheckMinLength",(e,t)=>{var r;St.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!bi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const o=ji(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),op=I("$ZodCheckLengthEquals",(e,t)=>{var r;St.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!bi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,i=a.length;if(i===t.length)return;const o=ji(a),l=i>t.length;n.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ls=I("$ZodCheckStringFormat",(e,t)=>{var r,n;St.init(e,t),e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),lp=I("$ZodCheckRegex",(e,t)=>{Ls.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),cp=I("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=np),Ls.init(e,t)}),up=I("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=sp),Ls.init(e,t)}),dp=I("$ZodCheckIncludes",(e,t)=>{St.init(e,t);const r=ln(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),mp=I("$ZodCheckStartsWith",(e,t)=>{St.init(e,t);const r=new RegExp(`^${ln(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),hp=I("$ZodCheckEndsWith",(e,t)=>{St.init(e,t);const r=new RegExp(`.*${ln(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),fp=I("$ZodCheckOverwrite",(e,t)=>{St.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class pp{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
12
+ Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let d=ge(),m;if(t){let b=typeof t=="string"?Or(t):t;ve(c==="/"||((x=b.pathname)==null?void 0:x.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${b.pathname}" was given in the \`location\` prop.`),m=b}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let b=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(b.length).join("/")}let y=r&&r.state.matches.length?r.state.matches.map(b=>Object.assign(b,{route:r.manifest[b.route.id]||b.route})):Nl(e,{pathname:f});Xe(u||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Xe(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let p=Dd(y&&y.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:mt([c,n.encodeLocation?n.encodeLocation(b.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:mt([c,n.encodeLocation?n.encodeLocation(b.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),a,r);return t&&p?A.createElement($n.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function Ed(){let e=zd(),t=hd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=A.createElement(A.Fragment,null,A.createElement("p",null,"💿 Hey developer 👋"),A.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",A.createElement("code",{style:i},"ErrorBoundary")," or"," ",A.createElement("code",{style:i},"errorElement")," prop on your route.")),A.createElement(A.Fragment,null,A.createElement("h2",null,"Unexpected Application Error!"),A.createElement("h3",{style:{fontStyle:"italic"}},t),r?A.createElement("pre",{style:a},r):null,o)}var Td=A.createElement(Ed,null),Ll=class extends A.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const r=Sd(e.digest);r&&(e=r)}let t=e!==void 0?A.createElement(nt.Provider,{value:this.props.routeContext},A.createElement(Ka.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?A.createElement(Id,{error:e},t):t}};Ll.contextType=Tl;var Ys=new WeakMap;function Id({children:e,error:t}){let{basename:r}=A.useContext(tt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let n=wd(t.digest);if(n){let a=Ys.get(t);if(a)throw a;let i=_l(n.location,r),o=i.absoluteURL||i.to;if(gd(o))throw new Error("Invalid redirect location");if(Pl&&!Ys.get(t))if(i.isExternal||n.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:n.replace}));throw Ys.set(t,l),l}return A.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Fd({routeContext:e,match:t,children:r}){let n=A.useContext(mn);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(nt.Provider,{value:e},r)}function Dd(e,t=[],r){let n=r==null?void 0:r.state;if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let d=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);ve(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,l=-1;if(r&&n){o=n.renderFallback;for(let d=0;d<a.length;d++){let m=a[d];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=d),m.route.id){let{loaderData:h,errors:f}=n,y=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||y){r.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=r==null?void 0:r.onError,u=n&&c?(d,m)=>{var h,f;c(d,{location:n.location,params:((f=(h=n.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:fd(n.matches),errorInfo:m})}:void 0;return a.reduceRight((d,m,h)=>{let f,y=!1,p=null,x=null;n&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Td,o&&(l<0&&h===0?(zl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,x=null):l===h&&(y=!0,x=m.route.hydrateFallbackElement||null)));let b=t.concat(a.slice(0,h+1)),j=()=>{let w;return f?w=p:y?w=x:m.route.Component?w=A.createElement(m.route.Component,null):m.route.element?w=m.route.element:w=d,A.createElement(Fd,{match:m,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:w})};return n&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?A.createElement(Ll,{location:n.location,revalidation:n.revalidation,component:p,error:f,children:j(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):j()},null)}function Qa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Rd(e){let t=A.useContext(mn);return ve(t,Qa(e)),t}function Od(e){let t=A.useContext(As);return ve(t,Qa(e)),t}function $d(e){let t=A.useContext(nt);return ve(t,Qa(e)),t}function Ja(e){let t=$d(e),r=t.matches[t.matches.length-1];return ve(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Ld(){return Ja("useRouteId")}function zd(){var n;let e=A.useContext(Ka),t=Od("useRouteError"),r=Ja("useRouteError");return e!==void 0?e:(n=t.errors)==null?void 0:n[r]}function Md(){let{router:e}=Rd("useNavigate"),t=Ja("useNavigate"),r=A.useRef(!1);return Rl(()=>{r.current=!0}),A.useCallback(async(a,i={})=>{Xe(r.current,Dl),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var eo={};function zl(e,t,r){!t&&!eo[e]&&(eo[e]=!0,Xe(!1,r))}A.memo(Vd);function Vd({routes:e,manifest:t,future:r,state:n,isStatic:a,onError:i}){return $l(e,void 0,{manifest:t,state:n,isStatic:a,onError:i})}function qd({basename:e,children:t,initialEntries:r,initialIndex:n,useTransitions:a}){let i=A.useRef();i.current==null&&(i.current=Zu({initialEntries:r,initialIndex:n,v5Compat:!0}));let o=i.current,[l,c]=A.useState({action:o.action,location:o.location}),u=A.useCallback(d=>{a===!1?c(d):A.startTransition(()=>c(d))},[a]);return A.useLayoutEffect(()=>o.listen(u),[o,u]),A.createElement(Ud,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function ht({to:e,replace:t,state:r,relative:n}){ve(hn(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=A.useContext(tt);Xe(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:i}=A.useContext(nt),{pathname:o}=ge(),l=Se(),c=Cs(e,Ha(i),o,n==="path"),u=JSON.stringify(c);return A.useEffect(()=>{l(JSON.parse(u),{replace:t,state:r,relative:n})},[l,u,n,t,r]),null}function Bd(e){return Ad(e.context)}function ee(e){ve(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ud({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:i=!1,useTransitions:o}){ve(!hn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=A.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof r=="string"&&(r=Or(r));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:y}=r,p=A.useMemo(()=>{let x=Vt(u,l);return x==null?null:{location:{pathname:x,search:d,hash:m,state:h,key:f,mask:y},navigationType:n}},[l,u,d,m,h,f,n,y]);return Xe(p!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${m}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:A.createElement(tt.Provider,{value:c},A.createElement($n.Provider,{children:t,value:p}))}function Ga({children:e,location:t}){return _d(ca(e),t)}function ca(e,t=[]){let r=[];return A.Children.forEach(e,(n,a)=>{if(!A.isValidElement(n))return;let i=[...t,a];if(n.type===A.Fragment){r.push.apply(r,ca(n.props.children,i));return}ve(n.type===ee,`[${typeof n.type=="string"?n.type:n.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ve(!n.props.index||!n.props.children,"An index route cannot have child routes.");let o={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,middleware:n.props.middleware,loader:n.props.loader,action:n.props.action,hydrateFallbackElement:n.props.hydrateFallbackElement,HydrateFallback:n.props.HydrateFallback,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.hasErrorBoundary===!0||n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=ca(n.props.children,i)),r.push(o)}),r}var is="get",os="application/x-www-form-urlencoded";function Ps(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Zd(e){return Ps(e)&&e.tagName.toLowerCase()==="button"}function Wd(e){return Ps(e)&&e.tagName.toLowerCase()==="form"}function Yd(e){return Ps(e)&&e.tagName.toLowerCase()==="input"}function Hd(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Kd(e,t){return e.button===0&&(!t||t==="_self")&&!Hd(e)}function ua(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function Qd(e,t){let r=ua(e);return t&&t.forEach((n,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}var Yn=null;function Jd(){if(Yn===null)try{new FormData(document.createElement("form"),0),Yn=!1}catch{Yn=!0}return Yn}var Gd=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Hs(e){return e!=null&&!Gd.has(e)?(Xe(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${os}"`),null):e}function Xd(e,t){let r,n,a,i,o;if(Wd(e)){let l=e.getAttribute("action");n=l?Vt(l,t):null,r=e.getAttribute("method")||is,a=Hs(e.getAttribute("enctype"))||os,i=new FormData(e)}else if(Zd(e)||Yd(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(n=c?Vt(c,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||is,a=Hs(e.getAttribute("formenctype"))||Hs(l.getAttribute("enctype"))||os,i=new FormData(l,e),!Jd()){let{name:u,type:d,value:m}=e;if(d==="image"){let h=u?`${u}.`:"";i.append(`${h}x`,"0"),i.append(`${h}y`,"0")}else u&&i.append(u,m)}}else{if(Ps(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=is,n=null,a=os,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xa(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ml(e,t,r,n){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${n}`:a.pathname=`${a.pathname}.${n}`:a.pathname==="/"?a.pathname=`_root.${n}`:t&&Vt(a.pathname,t)==="/"?a.pathname=`${ms(t)}/_root.${n}`:a.pathname=`${ms(a.pathname)}.${n}`,a}async function em(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(r){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function tm(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function rm(e,t,r){let n=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await em(i,r);return o.links?o.links():[]}return[]}));return im(n.flat(1).filter(tm).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function to(e,t,r,n,a,i){let o=(c,u)=>r[u]?c.route.id!==r[u].route.id:!0,l=(c,u)=>{var d;return r[u].pathname!==c.pathname||((d=r[u].route.path)==null?void 0:d.endsWith("*"))&&r[u].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,u)=>o(c,u)||l(c,u)):i==="data"?t.filter((c,u)=>{var m;let d=n.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=r[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function nm(e,t,{includeHydrateFallback:r}={}){return sm(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),r&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function sm(e){return[...new Set(e)]}function am(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function im(e,t){let r=new Set;return new Set(t),e.reduce((n,a)=>{let i=JSON.stringify(am(a));return r.has(i)||(r.add(i),n.push({key:i,link:a})),n},[])}function ei(){let e=A.useContext(mn);return Xa(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function om(){let e=A.useContext(As);return Xa(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ti=A.createContext(void 0);ti.displayName="FrameworkContext";function _s(){let e=A.useContext(ti);return Xa(e,"You must render this element inside a <HydratedRouter> element"),e}function lm(e,t){let r=A.useContext(ti),[n,a]=A.useState(!1),[i,o]=A.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:m}=t,h=A.useRef(null);A.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let p=b=>{b.forEach(j=>{o(j.isIntersecting)})},x=new IntersectionObserver(p,{threshold:.5});return h.current&&x.observe(h.current),()=>{x.disconnect()}}},[e]),A.useEffect(()=>{if(n){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[n]);let f=()=>{a(!0)},y=()=>{a(!1),o(!1)};return r?e!=="intent"?[i,h,{}]:[i,h,{onFocus:bn(l,f),onBlur:bn(c,y),onMouseEnter:bn(u,f),onMouseLeave:bn(d,y),onTouchStart:bn(m,f)}]:[!1,h,{}]}function bn(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function cm({page:e,...t}){let r=yd(),{nonce:n}=_s(),{router:a}=ei(),i=A.useMemo(()=>Nl(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&n&&(t={...t,nonce:n}),r?A.createElement(dm,{page:e,matches:i,...t}):A.createElement(mm,{page:e,matches:i,...t})):null}function um(e){let{manifest:t,routeModules:r}=_s(),[n,a]=A.useState([]);return A.useEffect(()=>{let i=!1;return rm(e,t,r).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,r]),n}function dm({page:e,matches:t,...r}){let n=ge(),{future:a}=_s(),{basename:i}=ei(),o=A.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let l=Ml(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,u=[];for(let d of t)typeof d.route.shouldRevalidate=="function"?c=!0:u.push(d.route.id);return c&&u.length>0&&l.searchParams.set("_routes",u.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,n,t]);return A.createElement(A.Fragment,null,o.map(l=>A.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...r})))}function mm({page:e,matches:t,...r}){let n=ge(),{future:a,manifest:i,routeModules:o}=_s(),{basename:l}=ei(),{loaderData:c,matches:u}=om(),d=A.useMemo(()=>to(e,t,u,i,n,"data"),[e,t,u,i,n]),m=A.useMemo(()=>to(e,t,u,i,n,"assets"),[e,t,u,i,n]),h=A.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,x=!1;if(t.forEach(j=>{var k;let w=i.routes[j.route.id];!w||!w.hasLoader||(!d.some(E=>E.route.id===j.route.id)&&j.route.id in c&&((k=o[j.route.id])!=null&&k.shouldRevalidate)||w.hasClientLoader?x=!0:p.add(j.route.id))}),p.size===0)return[];let b=Ml(e,l,a.v8_trailingSlashAwareDataRequests,"data");return x&&p.size>0&&b.searchParams.set("_routes",t.filter(j=>p.has(j.route.id)).map(j=>j.route.id).join(",")),[b.pathname+b.search]},[l,a.v8_trailingSlashAwareDataRequests,c,n,i,d,t,e,o]),f=A.useMemo(()=>nm(m,i),[m,i]),y=um(m);return A.createElement(A.Fragment,null,h.map(p=>A.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...r})),f.map(p=>A.createElement("link",{key:p,rel:"modulepreload",href:p,...r})),y.map(({key:p,link:x})=>A.createElement("link",{key:p,nonce:r.nonce,...x,crossOrigin:x.crossOrigin??r.crossOrigin})))}function hm(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var fm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{fm&&(window.__reactRouterVersion="7.18.1")}catch{}var Vl=A.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...y},p){let{basename:x,navigator:b,useTransitions:j}=A.useContext(tt),w=typeof d=="string"&&Ya.test(d),k=_l(d,x);d=k.to;let E=kd(d,{relative:a}),P=ge(),_=null;if(l){let W=Cs(l,[],P.mask?P.mask.pathname:"/",!0);x!=="/"&&(W.pathname=W.pathname==="/"?x:mt([x,W.pathname])),_=b.createHref(W)}let[F,Y,M]=lm(n,y),se=ym(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:j});function q(W){t&&t(W),W.defaultPrevented||se(W)}let K=!(k.isExternal||i),te=A.createElement("a",{...y,...M,href:(K?_:void 0)||k.absoluteURL||E,onClick:K?q:t,ref:hm(p,Y),target:u,"data-discover":!w&&r==="render"?"true":void 0});return F&&!w?A.createElement(A.Fragment,null,te,A.createElement(cm,{page:E})):te});Vl.displayName="Link";var pm=A.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let m=Ln(o,{relative:u.relative}),h=ge(),f=A.useContext(As),{navigator:y,basename:p}=A.useContext(tt),x=f!=null&&Sm(m)&&l===!0,b=y.encodeLocation?y.encodeLocation(m).pathname:m.pathname,j=h.pathname,w=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;r||(j=j.toLowerCase(),w=w?w.toLowerCase():null,b=b.toLowerCase()),w&&p&&(w=Vt(w,p)||w);const k=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let E=j===b||!a&&j.startsWith(b)&&j.charAt(k)==="/",P=w!=null&&(w===b||!a&&w.startsWith(b)&&w.charAt(b.length)==="/"),_={isActive:E,isPending:P,isTransitioning:x},F=E?t:void 0,Y;typeof n=="function"?Y=n(_):Y=[n,E?"active":null,P?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let M=typeof i=="function"?i(_):i;return A.createElement(Vl,{...u,"aria-current":F,className:Y,ref:d,style:M,to:o,viewTransition:l},typeof c=="function"?c(_):c)});pm.displayName="NavLink";var xm=A.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:n,replace:a,state:i,method:o=is,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},y)=>{let{useTransitions:p}=A.useContext(tt),x=Nm(),b=wm(l,{relative:u}),j=o.toLowerCase()==="get"?"get":"post",w=typeof l=="string"&&Ya.test(l),k=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let P=E.nativeEvent.submitter,_=(P==null?void 0:P.getAttribute("formmethod"))||o,F=()=>x(P||E.currentTarget,{fetcherKey:t,method:_,navigate:r,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&r!==!1?A.startTransition(()=>F()):F()};return A.createElement("form",{ref:y,method:j,action:b,onSubmit:n?c:k,...f,"data-discover":!w&&e==="render"?"true":void 0})});xm.displayName="Form";function gm(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ql(e){let t=A.useContext(mn);return ve(t,gm(e)),t}function ym(e,{target:t,replace:r,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=Se(),m=ge(),h=Ln(e,{relative:o});return A.useCallback(f=>{if(Kd(f,t)){f.preventDefault();let y=r!==void 0?r:us(m)===us(h),p=()=>d(e,{replace:y,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?A.startTransition(()=>p()):p()}},[m,d,h,r,n,a,t,e,i,o,l,c,u])}function bm(e){Xe(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=A.useRef(ua(e)),r=A.useRef(!1),n=ge(),a=A.useMemo(()=>Qd(n.search,r.current?null:t.current),[n.search]),i=Se(),o=A.useCallback((l,c)=>{const u=ua(typeof l=="function"?l(new URLSearchParams(a)):l);r.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var vm=0,jm=()=>`__${String(++vm)}__`;function Nm(){let{router:e}=ql("useSubmit"),{basename:t}=A.useContext(tt),r=Ld(),n=e.fetch,a=e.navigate;return A.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:m}=Xd(i,t);if(o.navigate===!1){let h=o.fetcherKey||jm();await n(h,r,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:r,flushSync:o.flushSync,viewTransition:o.viewTransition})},[n,a,t,r])}function wm(e,{relative:t}={}){let{basename:r}=A.useContext(tt),n=A.useContext(nt);ve(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),i={...Ln(e||".",{relative:t})},o=ge();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let d=l.toString();i.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(i.pathname=i.pathname==="/"?r:mt([r,i.pathname])),us(i)}function Sm(e,{relative:t}={}){let r=A.useContext(Il);ve(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=ql("useViewTransitionState"),a=Ln(e,{relative:t});if(!r.isTransitioning)return!1;let i=Vt(r.currentLocation.pathname,n)||r.currentLocation.pathname,o=Vt(r.nextLocation.pathname,n)||r.nextLocation.pathname;return ds(a.pathname,o)!=null||ds(a.pathname,i)!=null}var fn=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(){}},jr,Jt,Hr,dl,km=(dl=class extends fn{constructor(){super();Q(this,jr);Q(this,Jt);Q(this,Hr);V(this,Hr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){v(this,Jt)||this.setEventListener(v(this,Hr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Jt))==null||t.call(this),V(this,Jt,void 0))}setEventListener(t){var r;V(this,Hr,t),(r=v(this,Jt))==null||r.call(this),V(this,Jt,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){v(this,jr)!==t&&(V(this,jr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof v(this,jr)=="boolean"?v(this,jr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},jr=new WeakMap,Jt=new WeakMap,Hr=new WeakMap,dl),ri=new km,Cm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},gt,Nr,ml,Am=(ml=class{constructor(){Q(this,gt,Cm);Q(this,Nr,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&v(this,Nr)&&e!==v(this,gt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:v(this,gt),provider:e}),V(this,gt,e),process.env.NODE_ENV!=="production"&&V(this,Nr,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&V(this,Nr,!0),v(this,gt).setTimeout(e,t)}clearTimeout(e){v(this,gt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&V(this,Nr,!0),v(this,gt).setInterval(e,t)}clearInterval(e){v(this,gt).clearInterval(e)}},gt=new WeakMap,Nr=new WeakMap,ml),br=new Am;function Pm(e){setTimeout(e,0)}var _m=typeof window>"u"||"Deno"in globalThis;function Ze(){}function Em(e,t){return typeof e=="function"?e(t):e}function da(e){return typeof e=="number"&&e>=0&&e!==1/0}function Bl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function or(e,t){return typeof e=="function"?e(t):e}function Qe(e,t){return typeof e=="function"?e(t):e}function ro(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(n){if(t.queryHash!==ni(o,t.options))return!1}else if(!Pn(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function no(e,t){const{exact:r,status:n,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Tr(t.options.mutationKey)!==Tr(i))return!1}else if(!Pn(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function ni(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tr)(e)}function Tr(e){return JSON.stringify(e,(t,r)=>ha(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function Pn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Pn(e[r],t[r])):!1}var Tm=Object.prototype.hasOwnProperty;function ma(e,t,r=0){if(e===t)return e;if(r>500)return t;const n=so(e)&&so(t);if(!n&&!(ha(e)&&ha(t)))return t;const i=(n?e:Object.keys(e)).length,o=n?t:Object.keys(t),l=o.length,c=n?new Array(l):{};let u=0;for(let d=0;d<l;d++){const m=n?d:o[d],h=e[m],f=t[m];if(h===f){c[m]=h,(n?d<i:Tm.call(e,m))&&u++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const y=ma(h,f,r+1);c[m]=y,y===h&&u++}return i===l&&u===i?e:c}function hs(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 so(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ha(e){if(!ao(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!ao(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ao(e){return Object.prototype.toString.call(e)==="[object Object]"}function Im(e){return new Promise(t=>{br.setTimeout(t,e)})}function fa(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 ma(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 ma(e,t)}return t}function Fm(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Dm(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var fs=Symbol();function Ul(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===fs&&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===fs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function si(e,t){return typeof e=="function"?e(...t):!!e}function Rm(e,t,r){let n=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),n||(n=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),e}var _n=(()=>{let e=()=>_m;return{isServer(){return e()},setIsServer(t){e=t}}})();function pa(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),t(a)},r}var Om=Pm;function $m(){let e=[],t=0,r=l=>{l()},n=l=>{l()},a=Om;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var _e=$m(),Kr,Gt,Qr,hl,Lm=(hl=class extends fn{constructor(){super();Q(this,Kr,!0);Q(this,Gt);Q(this,Qr);V(this,Qr,t=>{if(typeof window<"u"&&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(){v(this,Gt)||this.setEventListener(v(this,Qr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Gt))==null||t.call(this),V(this,Gt,void 0))}setEventListener(t){var r;V(this,Qr,t),(r=v(this,Gt))==null||r.call(this),V(this,Gt,t(this.setOnline.bind(this)))}setOnline(t){v(this,Kr)!==t&&(V(this,Kr,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return v(this,Kr)}},Kr=new WeakMap,Gt=new WeakMap,Qr=new WeakMap,hl),ps=new Lm;function zm(e){return Math.min(1e3*2**e,3e4)}function Zl(e){return(e??"online")==="online"?ps.isOnline():!0}var xa=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Wl(e){let t=!1,r=0,n;const a=pa(),i=()=>a.status!=="pending",o=p=>{var x;if(!i()){const b=new xa(p);h(b),(x=e.onCancel)==null||x.call(e,b)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>ri.isFocused()&&(e.networkMode==="always"||ps.isOnline())&&e.canRun(),d=()=>Zl(e.networkMode)&&e.canRun(),m=p=>{i()||(n==null||n(),a.resolve(p))},h=p=>{i()||(n==null||n(),a.reject(p))},f=()=>new Promise(p=>{var x;n=b=>{(i()||u())&&p(b)},(x=e.onPause)==null||x.call(e)}).then(()=>{var p;n=void 0,i()||(p=e.onContinue)==null||p.call(e)}),y=()=>{if(i())return;let p;const x=r===0?e.initialPromise:void 0;try{p=x??e.fn()}catch(b){p=Promise.reject(b)}Promise.resolve(p).then(m).catch(b=>{var P;if(i())return;const j=e.retry??(_n.isServer()?0:3),w=e.retryDelay??zm,k=typeof w=="function"?w(r,b):w,E=j===!0||typeof j=="number"&&r<j||typeof j=="function"&&j(r,b);if(t||!E){h(b);return}r++,(P=e.onFail)==null||P.call(e,r,b),Im(k).then(()=>u()?void 0:f()).then(()=>{t?h(b):y()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?y():f().then(y),a)}}var wr,fl,Yl=(fl=class{constructor(){Q(this,wr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),da(this.gcTime)&&V(this,wr,br.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(_n.isServer()?1/0:300*1e3))}clearGcTimeout(){v(this,wr)!==void 0&&(br.clearTimeout(v(this,wr)),V(this,wr,void 0))}},wr=new WeakMap,fl);function Mm(e){return{onFetch:(t,r)=>{var d,m,h,f,y;const n=t.options,a=(h=(m=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const x=w=>{Rm(w,()=>t.signal,()=>p=!0)},b=Ul(t.options,t.fetchOptions),j=async(w,k,E)=>{if(p)return Promise.reject(t.signal.reason);if(k==null&&w.pages.length)return Promise.resolve(w);const _=(()=>{const se={client:t.client,queryKey:t.queryKey,pageParam:k,direction:E?"backward":"forward",meta:t.options.meta};return x(se),se})(),F=await b(_),{maxPages:Y}=t.options,M=E?Dm:Fm;return{pages:M(w.pages,F,Y),pageParams:M(w.pageParams,k,Y)}};if(a&&i.length){const w=a==="backward",k=w?Vm:io,E={pages:i,pageParams:o},P=k(n,E);l=await j(E,P,w)}else{const w=e??i.length;do{const k=c===0?o[0]??n.initialPageParam:io(n,l);if(c>0&&k==null)break;l=await j(l,k),c++}while(c<w)}return l};t.options.persister?t.fetchFn=()=>{var p,x;return(x=(p=t.options).persister)==null?void 0:x.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function io(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Vm(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Jr,Sr,Gr,rt,kr,Fe,In,Cr,Ke,Hl,Rt,pl,qm=(pl=class extends Yl{constructor(t){super();Q(this,Ke);Q(this,Jr);Q(this,Sr);Q(this,Gr);Q(this,rt);Q(this,kr);Q(this,Fe);Q(this,In);Q(this,Cr);V(this,Cr,!1),V(this,In,t.defaultOptions),this.setOptions(t.options),this.observers=[],V(this,kr,t.client),V(this,rt,v(this,kr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,V(this,Sr,lo(this.options)),this.state=t.state??v(this,Sr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return v(this,Jr)}get promise(){var t;return(t=v(this,Fe))==null?void 0:t.promise}setOptions(t){if(this.options={...v(this,In),...t},t!=null&&t._type&&V(this,Jr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=lo(this.options);r.data!==void 0&&(this.setState(oo(r.data,r.dataUpdatedAt)),V(this,Sr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,rt).remove(this)}setData(t,r){const n=fa(this.state.data,t,this.options);return re(this,Ke,Rt).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t){re(this,Ke,Rt).call(this,{type:"setState",state:t})}cancel(t){var n,a;const r=(n=v(this,Fe))==null?void 0:n.promise;return(a=v(this,Fe))==null||a.cancel(t),r?r.then(Ze).catch(Ze):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return v(this,Sr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Qe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===fs||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>or(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:!Bl(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,Fe))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,Fe))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),v(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(v(this,Fe)&&(v(this,Cr)||re(this,Ke,Hl).call(this)?v(this,Fe).cancel({revert:!0}):v(this,Fe).cancelRetry()),this.scheduleGc()),v(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||re(this,Ke,Rt).call(this,{type:"invalidate"})}async fetch(t,r){var u,d,m,h,f,y,p,x,b,j,w;if(this.state.fetchStatus!=="idle"&&((u=v(this,Fe))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(v(this,Fe))return v(this,Fe).continueRetry(),v(this,Fe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const k=this.observers.find(E=>E.options.queryFn);k&&this.setOptions(k.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,a=k=>{Object.defineProperty(k,"signal",{enumerable:!0,get:()=>(V(this,Cr,!0),n.signal)})},i=()=>{const k=Ul(this.options,r),P=(()=>{const _={client:v(this,kr),queryKey:this.queryKey,meta:this.meta};return a(_),_})();return V(this,Cr,!1),this.options.persister?this.options.persister(k,P,this):k(P)},l=(()=>{const k={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:v(this,kr),state:this.state,fetchFn:i};return a(k),k})(),c=v(this,Jr)==="infinite"?Mm(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),V(this,Gr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&re(this,Ke,Rt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),V(this,Fe,Wl({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:k=>{k instanceof xa&&k.revert&&this.setState({...v(this,Gr),fetchStatus:"idle"}),n.abort()},onFail:(k,E)=>{re(this,Ke,Rt).call(this,{type:"failed",failureCount:k,error:E})},onPause:()=>{re(this,Ke,Rt).call(this,{type:"pause"})},onContinue:()=>{re(this,Ke,Rt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const k=await v(this,Fe).start();if(k===void 0)throw 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}`),new Error(`${this.queryHash} data is undefined`);return this.setData(k),(f=(h=v(this,rt).config).onSuccess)==null||f.call(h,k,this),(p=(y=v(this,rt).config).onSettled)==null||p.call(y,k,this.state.error,this),k}catch(k){if(k instanceof xa){if(k.silent)return v(this,Fe).promise;if(k.revert){if(this.state.data===void 0)throw k;return this.state.data}}throw re(this,Ke,Rt).call(this,{type:"error",error:k}),(b=(x=v(this,rt).config).onError)==null||b.call(x,k,this),(w=(j=v(this,rt).config).onSettled)==null||w.call(j,this.state.data,k,this),k}finally{this.scheduleGc()}}},Jr=new WeakMap,Sr=new WeakMap,Gr=new WeakMap,rt=new WeakMap,kr=new WeakMap,Fe=new WeakMap,In=new WeakMap,Cr=new WeakMap,Ke=new WeakSet,Hl=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Rt=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,...Kl(n.data,this.options),fetchMeta:t.meta??null};case"success":const a={...n,...oo(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return V(this,Gr,t.manual?a:void 0),a;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),_e.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),v(this,rt).notify({query:this,type:"updated",action:t})})},pl);function Kl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function oo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function lo(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 We,ie,Fn,Ue,Ar,Xr,Ot,Xt,Dn,en,tn,Pr,_r,er,rn,ue,Sn,ga,ya,ba,va,ja,Na,wa,Ql,xl,Bm=(xl=class extends fn{constructor(t,r){super();Q(this,ue);Q(this,We);Q(this,ie);Q(this,Fn);Q(this,Ue);Q(this,Ar);Q(this,Xr);Q(this,Ot);Q(this,Xt);Q(this,Dn);Q(this,en);Q(this,tn);Q(this,Pr);Q(this,_r);Q(this,er);Q(this,rn,new Set);this.options=r,V(this,We,t),V(this,Xt,null),V(this,Ot,pa()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,ie).addObserver(this),co(v(this,ie),this.options)?re(this,ue,Sn).call(this):this.updateResult(),re(this,ue,va).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Sa(v(this,ie),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Sa(v(this,ie),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,re(this,ue,ja).call(this),re(this,ue,Na).call(this),v(this,ie).removeObserver(this)}setOptions(t){const r=this.options,n=v(this,ie);if(this.options=v(this,We).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Qe(this.options.enabled,v(this,ie))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");re(this,ue,wa).call(this),v(this,ie).setOptions(this.options),r._defaulted&&!hs(this.options,r)&&v(this,We).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,ie),observer:this});const a=this.hasListeners();a&&uo(v(this,ie),n,this.options,r)&&re(this,ue,Sn).call(this),this.updateResult(),a&&(v(this,ie)!==n||Qe(this.options.enabled,v(this,ie))!==Qe(r.enabled,v(this,ie))||or(this.options.staleTime,v(this,ie))!==or(r.staleTime,v(this,ie)))&&re(this,ue,ga).call(this);const i=re(this,ue,ya).call(this);a&&(v(this,ie)!==n||Qe(this.options.enabled,v(this,ie))!==Qe(r.enabled,v(this,ie))||i!==v(this,er))&&re(this,ue,ba).call(this,i)}getOptimisticResult(t){const r=v(this,We).getQueryCache().build(v(this,We),t),n=this.createResult(r,t);return Zm(this,n)&&(V(this,Ue,n),V(this,Xr,this.options),V(this,Ar,v(this,ie).state)),n}getCurrentResult(){return v(this,Ue)}trackResult(t,r){return new Proxy(t,{get:(n,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&v(this,Ot).status==="pending"&&v(this,Ot).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,a))})}trackProp(t){v(this,rn).add(t)}getCurrentQuery(){return v(this,ie)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=v(this,We).defaultQueryOptions(t),n=v(this,We).getQueryCache().build(v(this,We),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return re(this,ue,Sn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,Ue)))}createResult(t,r){var Y;const n=v(this,ie),a=this.options,i=v(this,Ue),o=v(this,Ar),l=v(this,Xr),u=t!==n?t.state:v(this,Fn),{state:d}=t;let m={...d},h=!1,f;if(r._optimisticResults){const M=this.hasListeners(),se=!M&&co(t,r),q=M&&uo(t,n,r,a);(se||q)&&(m={...m,...Kl(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:y,errorUpdatedAt:p,status:x}=m;f=m.data;let b=!1;if(r.placeholderData!==void 0&&f===void 0&&x==="pending"){let M;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(M=i.data,b=!0):M=typeof r.placeholderData=="function"?r.placeholderData((Y=v(this,tn))==null?void 0:Y.state.data,v(this,tn)):r.placeholderData,M!==void 0&&(x="success",f=fa(i==null?void 0:i.data,M,r),h=!0)}if(r.select&&f!==void 0&&!b)if(i&&f===(o==null?void 0:o.data)&&r.select===v(this,Dn))f=v(this,en);else try{V(this,Dn,r.select),f=r.select(f),f=fa(i==null?void 0:i.data,f,r),V(this,en,f),V(this,Xt,null)}catch(M){V(this,Xt,M)}v(this,Xt)&&(y=v(this,Xt),f=v(this,en),p=Date.now(),x="error");const j=m.fetchStatus==="fetching",w=x==="pending",k=x==="error",E=w&&j,P=f!==void 0,F={status:x,fetchStatus:m.fetchStatus,isPending:w,isSuccess:x==="success",isError:k,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:y,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:j,isRefetching:j&&!w,isLoadingError:k&&!P,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:k&&P,isStale:ai(t,r),refetch:this.refetch,promise:v(this,Ot),isEnabled:Qe(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const M=F.data!==void 0,se=F.status==="error"&&!M,q=W=>{se?W.reject(F.error):M&&W.resolve(F.data)},K=()=>{const W=V(this,Ot,F.promise=pa());q(W)},te=v(this,Ot);switch(te.status){case"pending":t.queryHash===n.queryHash&&q(te);break;case"fulfilled":(se||F.data!==te.value)&&K();break;case"rejected":(!se||F.error!==te.reason)&&K();break}}return F}updateResult(){const t=v(this,Ue),r=this.createResult(v(this,ie),this.options);if(V(this,Ar,v(this,ie).state),V(this,Xr,this.options),v(this,Ar).data!==void 0&&V(this,tn,v(this,ie)),hs(r,t))return;V(this,Ue,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!v(this,rn).size)return!0;const o=new Set(i??v(this,rn));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,Ue)).some(l=>{const c=l;return v(this,Ue)[c]!==t[c]&&o.has(c)})};re(this,ue,Ql).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&re(this,ue,va).call(this)}},We=new WeakMap,ie=new WeakMap,Fn=new WeakMap,Ue=new WeakMap,Ar=new WeakMap,Xr=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,Dn=new WeakMap,en=new WeakMap,tn=new WeakMap,Pr=new WeakMap,_r=new WeakMap,er=new WeakMap,rn=new WeakMap,ue=new WeakSet,Sn=function(t){re(this,ue,wa).call(this);let r=v(this,ie).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Ze)),r},ga=function(){re(this,ue,ja).call(this);const t=or(this.options.staleTime,v(this,ie));if(_n.isServer()||v(this,Ue).isStale||!da(t))return;const n=Bl(v(this,Ue).dataUpdatedAt,t)+1;V(this,Pr,br.setTimeout(()=>{v(this,Ue).isStale||this.updateResult()},n))},ya=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,ie)):this.options.refetchInterval)??!1},ba=function(t){re(this,ue,Na).call(this),V(this,er,t),!(_n.isServer()||Qe(this.options.enabled,v(this,ie))===!1||!da(v(this,er))||v(this,er)===0)&&V(this,_r,br.setInterval(()=>{(this.options.refetchIntervalInBackground||ri.isFocused())&&re(this,ue,Sn).call(this)},v(this,er)))},va=function(){re(this,ue,ga).call(this),re(this,ue,ba).call(this,re(this,ue,ya).call(this))},ja=function(){v(this,Pr)!==void 0&&(br.clearTimeout(v(this,Pr)),V(this,Pr,void 0))},Na=function(){v(this,_r)!==void 0&&(br.clearInterval(v(this,_r)),V(this,_r,void 0))},wa=function(){const t=v(this,We).getQueryCache().build(v(this,We),this.options);if(t===v(this,ie))return;const r=v(this,ie);V(this,ie,t),V(this,Fn,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},Ql=function(t){_e.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(v(this,Ue))}),v(this,We).getQueryCache().notify({query:v(this,ie),type:"observerResultsUpdated"})})},xl);function Um(e,t){return Qe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Qe(t.retryOnMount,e)===!1)}function co(e,t){return Um(e,t)||e.state.data!==void 0&&Sa(e,t,t.refetchOnMount)}function Sa(e,t,r){if(Qe(t.enabled,e)!==!1&&or(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&ai(e,t)}return!1}function uo(e,t,r,n){return(e!==t||Qe(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&ai(e,r)}function ai(e,t){return Qe(t.enabled,e)!==!1&&e.isStaleByTime(or(t.staleTime,e))}function Zm(e,t){return!hs(e.getCurrentResult(),t)}var Rn,yt,Me,Er,bt,Ht,gl,Wm=(gl=class extends Yl{constructor(t){super();Q(this,bt);Q(this,Rn);Q(this,yt);Q(this,Me);Q(this,Er);V(this,Rn,t.client),this.mutationId=t.mutationId,V(this,Me,t.mutationCache),V(this,yt,[]),this.state=t.state||Jl(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){v(this,yt).includes(t)||(v(this,yt).push(t),this.clearGcTimeout(),v(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){V(this,yt,v(this,yt).filter(r=>r!==t)),this.scheduleGc(),v(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){v(this,yt).length||(this.state.status==="pending"?this.scheduleGc():v(this,Me).remove(this))}continue(){var t;return((t=v(this,Er))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,y,p,x,b,j,w,k,E,P,_;const r=()=>{re(this,bt,Ht).call(this,{type:"continue"})},n={client:v(this,Rn),meta:this.options.meta,mutationKey:this.options.mutationKey};V(this,Er,Wl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(F,Y)=>{re(this,bt,Ht).call(this,{type:"failed",failureCount:F,error:Y})},onPause:()=>{re(this,bt,Ht).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,Me).canRun(this)}));const a=this.state.status==="pending",i=!v(this,Er).canStart();try{if(a)r();else{re(this,bt,Ht).call(this,{type:"pending",variables:t,isPaused:i}),v(this,Me).config.onMutate&&await v(this,Me).config.onMutate(t,this,n);const Y=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,n));Y!==this.state.context&&re(this,bt,Ht).call(this,{type:"pending",context:Y,variables:t,isPaused:i})}const F=await v(this,Er).start();return await((u=(c=v(this,Me).config).onSuccess)==null?void 0:u.call(c,F,t,this.state.context,this,n)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,F,t,this.state.context,n)),await((f=(h=v(this,Me).config).onSettled)==null?void 0:f.call(h,F,null,this.state.variables,this.state.context,this,n)),await((p=(y=this.options).onSettled)==null?void 0:p.call(y,F,null,t,this.state.context,n)),re(this,bt,Ht).call(this,{type:"success",data:F}),F}catch(F){try{await((b=(x=v(this,Me).config).onError)==null?void 0:b.call(x,F,t,this.state.context,this,n))}catch(Y){Promise.reject(Y)}try{await((w=(j=this.options).onError)==null?void 0:w.call(j,F,t,this.state.context,n))}catch(Y){Promise.reject(Y)}try{await((E=(k=v(this,Me).config).onSettled)==null?void 0:E.call(k,void 0,F,this.state.variables,this.state.context,this,n))}catch(Y){Promise.reject(Y)}try{await((_=(P=this.options).onSettled)==null?void 0:_.call(P,void 0,F,t,this.state.context,n))}catch(Y){Promise.reject(Y)}throw re(this,bt,Ht).call(this,{type:"error",error:F}),F}finally{v(this,Me).runNext(this)}}},Rn=new WeakMap,yt=new WeakMap,Me=new WeakMap,Er=new WeakMap,bt=new WeakSet,Ht=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),_e.batch(()=>{v(this,yt).forEach(n=>{n.onMutationUpdate(t)}),v(this,Me).notify({mutation:this,type:"updated",action:t})})},gl);function Jl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $t,ut,On,yl,Ym=(yl=class extends fn{constructor(t={}){super();Q(this,$t);Q(this,ut);Q(this,On);this.config=t,V(this,$t,new Set),V(this,ut,new Map),V(this,On,0)}build(t,r,n){const a=new Wm({client:t,mutationCache:this,mutationId:++Wn(this,On)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){v(this,$t).add(t);const r=Hn(t);if(typeof r=="string"){const n=v(this,ut).get(r);n?n.push(t):v(this,ut).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(v(this,$t).delete(t)){const r=Hn(t);if(typeof r=="string"){const n=v(this,ut).get(r);if(n)if(n.length>1){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}else n[0]===t&&v(this,ut).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Hn(t);if(typeof r=="string"){const n=v(this,ut).get(r),a=n==null?void 0:n.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var n;const r=Hn(t);if(typeof r=="string"){const a=(n=v(this,ut).get(r))==null?void 0:n.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){_e.batch(()=>{v(this,$t).forEach(t=>{this.notify({type:"removed",mutation:t})}),v(this,$t).clear(),v(this,ut).clear()})}getAll(){return Array.from(v(this,$t))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>no(r,n))}findAll(t={}){return this.getAll().filter(r=>no(t,r))}notify(t){_e.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return _e.batch(()=>Promise.all(t.map(r=>r.continue().catch(Ze))))}},$t=new WeakMap,ut=new WeakMap,On=new WeakMap,yl);function Hn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Lt,tr,Ye,zt,Mt,ls,ka,bl,Hm=(bl=class extends fn{constructor(t,r){super();Q(this,Mt);Q(this,Lt);Q(this,tr);Q(this,Ye);Q(this,zt);V(this,Lt,t),this.setOptions(r),this.bindMethods(),re(this,Mt,ls).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=v(this,Lt).defaultMutationOptions(t),hs(this.options,r)||v(this,Lt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:v(this,Ye),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Tr(r.mutationKey)!==Tr(this.options.mutationKey)?this.reset():((n=v(this,Ye))==null?void 0:n.state.status)==="pending"&&v(this,Ye).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=v(this,Ye))==null||t.removeObserver(this)}onMutationUpdate(t){re(this,Mt,ls).call(this),re(this,Mt,ka).call(this,t)}getCurrentResult(){return v(this,tr)}reset(){var t;(t=v(this,Ye))==null||t.removeObserver(this),V(this,Ye,void 0),re(this,Mt,ls).call(this),re(this,Mt,ka).call(this)}mutate(t,r){var n;return V(this,zt,r),(n=v(this,Ye))==null||n.removeObserver(this),V(this,Ye,v(this,Lt).getMutationCache().build(v(this,Lt),this.options)),v(this,Ye).addObserver(this),v(this,Ye).execute(t)}},Lt=new WeakMap,tr=new WeakMap,Ye=new WeakMap,zt=new WeakMap,Mt=new WeakSet,ls=function(){var r;const t=((r=v(this,Ye))==null?void 0:r.state)??Jl();V(this,tr,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},ka=function(t){_e.batch(()=>{var r,n,a,i,o,l,c,u;if(v(this,zt)&&this.hasListeners()){const d=v(this,tr).variables,m=v(this,tr).context,h={client:v(this,Lt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(n=(r=v(this,zt)).onSuccess)==null||n.call(r,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=v(this,zt)).onSettled)==null||i.call(a,t.data,null,d,m,h)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=v(this,zt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=v(this,zt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(v(this,tr))})})},bl),vt,vl,Km=(vl=class extends fn{constructor(t={}){super();Q(this,vt);this.config=t,V(this,vt,new Map)}build(t,r,n){const a=r.queryKey,i=r.queryHash??ni(a,r);let o=this.get(i);return o||(o=new qm({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){v(this,vt).has(t.queryHash)||(v(this,vt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=v(this,vt).get(t.queryHash);r&&(t.destroy(),r===t&&v(this,vt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){_e.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return v(this,vt).get(t)}getAll(){return[...v(this,vt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>ro(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>ro(t,n)):r}notify(t){_e.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){_e.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){_e.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},vt=new WeakMap,vl),we,rr,nr,nn,sn,sr,an,on,jl,Qm=(jl=class{constructor(e={}){Q(this,we);Q(this,rr);Q(this,nr);Q(this,nn);Q(this,sn);Q(this,sr);Q(this,an);Q(this,on);V(this,we,e.queryCache||new Km),V(this,rr,e.mutationCache||new Ym),V(this,nr,e.defaultOptions||{}),V(this,nn,new Map),V(this,sn,new Map),V(this,sr,0)}mount(){Wn(this,sr)._++,v(this,sr)===1&&(V(this,an,ri.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,we).onFocus())})),V(this,on,ps.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,we).onOnline())})))}unmount(){var e,t;Wn(this,sr)._--,v(this,sr)===0&&((e=v(this,an))==null||e.call(this),V(this,an,void 0),(t=v(this,on))==null||t.call(this),V(this,on,void 0))}isFetching(e){return v(this,we).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return v(this,rr).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,we).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=v(this,we).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(or(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return v(this,we).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=v(this,we).get(n.queryHash),i=a==null?void 0:a.state.data,o=Em(t,i);if(o!==void 0)return v(this,we).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return _e.batch(()=>v(this,we).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,we).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=v(this,we);_e.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=v(this,we);return _e.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=_e.batch(()=>v(this,we).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Ze).catch(Ze)}invalidateQueries(e,t={}){return _e.batch(()=>(v(this,we).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=_e.batch(()=>v(this,we).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(Ze)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Ze)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=v(this,we).build(this,t);return r.isStaleByTime(or(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ze).catch(Ze)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ze).catch(Ze)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return ps.isOnline()?v(this,rr).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,we)}getMutationCache(){return v(this,rr)}getDefaultOptions(){return v(this,nr)}setDefaultOptions(e){V(this,nr,e)}setQueryDefaults(e,t){v(this,nn).set(Tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...v(this,nn).values()],r={};return t.forEach(n=>{Pn(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){v(this,sn).set(Tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...v(this,sn).values()],r={};return t.forEach(n=>{Pn(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...v(this,nr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ni(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===fs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...v(this,nr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){v(this,we).clear(),v(this,rr).clear()}},we=new WeakMap,rr=new WeakMap,nr=new WeakMap,nn=new WeakMap,sn=new WeakMap,sr=new WeakMap,an=new WeakMap,on=new WeakMap,jl),Gl=A.createContext(void 0),st=e=>{const t=A.useContext(Gl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Jm=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Gl.Provider,{value:e,children:t})),Xl=A.createContext(!1),Gm=()=>A.useContext(Xl);Xl.Provider;function Xm(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var eh=A.createContext(Xm()),th=()=>A.useContext(eh),rh=(e,t,r)=>{const n=r!=null&&r.state.error&&typeof e.throwOnError=="function"?si(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},nh=e=>{A.useEffect(()=>{e.clearReset()},[e])},sh=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||si(r,[e.error,n])),ah=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...a)=>r(n(...a)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ih=(e,t)=>e.isLoading&&e.isFetching&&!t,oh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,mo=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function lh(e,t,r){var f,y,p,x;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=Gm(),a=th(),i=st(),o=i.defaultQueryOptions(e);(y=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||y.call(f,o);const l=i.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`));const c=e.subscribed!==!1;o._optimisticResults=n?"isRestoring":c?"optimistic":void 0,ah(o),rh(o,a,l),nh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=A.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!n&&c;if(A.useSyncExternalStore(A.useCallback(b=>{const j=h?d.subscribe(_e.batchCalls(b)):Ze;return d.updateResult(),j},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),A.useEffect(()=>{d.setOptions(o)},[o,d]),oh(o,m))throw mo(o,d,a);if(sh({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((x=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||x.call(p,o,m),o.experimental_prefetchInRender&&!_n.isServer()&&ih(m,n)){const b=u?mo(o,d,a):l==null?void 0:l.promise;b==null||b.catch(Ze).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function Ee(e,t){return lh(e,Bm)}function ch(e,t){const r=st(),[n]=A.useState(()=>new Hm(r,e));A.useEffect(()=>{n.setOptions(e)},[n,e]);const a=A.useSyncExternalStore(A.useCallback(o=>n.subscribe(_e.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=A.useCallback((o,l)=>{n.mutate(o,l).catch(Ze)},[n]);if(a.error&&si(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function ec(e){return e.trim().replace(/\/+$/,"")}let Ca=null;function tc(e){Ca=ec(e)}let rc=null;function uh(e){rc=e}function dh(){return rc}let nc=null;function mh(e){nc=e.trim()}function hh(){return nc}function fh(){return Ca!==null?Ca:ec("")}const ho={get apiBaseUrl(){return fh()},apiVersion:"v1"};function ph(e){const t=e.startsWith("/")?e:`/${e}`;return`${ho.apiBaseUrl}/api/${ho.apiVersion}${t}`}const Aa="auth:session-expired";function xh(){window.dispatchEvent(new CustomEvent(Aa))}const gh=N.createContext(null);function yh({accessToken:e,onSessionExpired:t,children:r}){return uh(e),N.useEffect(()=>{if(!t)return;const n=()=>t();return window.addEventListener(Aa,n),()=>window.removeEventListener(Aa,n)},[t]),s.jsx(gh.Provider,{value:{accessToken:e},children:r})}class zn extends Error{constructor(r,n,a,i){super(a??n);Zn(this,"status");Zn(this,"title");Zn(this,"details");this.name="ApiError",this.status=r,this.title=n,this.details=i}}const sc="tax-remittance.auth";function bh(){var t;const e=localStorage.getItem(sc);if(!e)return null;try{const r=JSON.parse(e);return!r.accessToken||!((t=r.user)!=null&&t.userId)?null:new Date(r.user.expiresAt)<=new Date?(Pa(),null):r}catch{return Pa(),null}}function Pa(){localStorage.removeItem(sc)}function vh(){var e;return((e=bh())==null?void 0:e.accessToken)??null}async function jh(e){let t=null;try{t=await e.json()}catch{}return new zn(e.status,(t==null?void 0:t.title)??"Request failed",t==null?void 0:t.detail,t==null?void 0:t.errors)}async function Nh(e,t={}){const{body:r,auth:n=!0,headers:a,...i}=t,o=new Headers(a);if(o.set("Accept","application/json"),r!==void 0&&o.set("Content-Type","application/json"),n){const u=dh()??vh();u&&o.set("Authorization",`Bearer ${u}`)}const l=hh();l&&o.set("X-Client-ID",l);const c=await fetch(ph(e),{...i,headers:o,body:r!==void 0?JSON.stringify(r):void 0});if(!c.ok){const u=await jh(c);throw n&&u.status===401&&(Pa(),xh()),u}if(c.status!==204)return await c.json()}async function he(e,t={}){return(await Nh(e,t)).data}function ac(){return he("/portal/entities/mine")}function wh(e){return he("/portal/entities",{method:"POST",body:e})}function Sh(e,t){return he(`/portal/entities/${e}`,{method:"PATCH",body:t})}const ic=N.createContext(null);function kh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],children:r}){var y;const[n,a]=N.useState(null),{data:i=[],isLoading:o,isError:l,refetch:c}=Ee({queryKey:["entities","mine"],queryFn:ac}),u=N.useRef(new Set),d=N.useRef(!1);N.useEffect(()=>{if(o)return;if(!d.current){i.forEach(x=>u.current.add(x.entityId)),d.current=!0;return}i.filter(x=>!u.current.has(x.entityId)).forEach(x=>{u.current.add(x.entityId),e==null||e(x)})},[i,o,e]);const m=n!==null&&i.some(p=>p.entityId===n)?n:((y=i[0])==null?void 0:y.entityId)??null,h=i.find(p=>p.entityId===m)??null,f=async()=>{await c()};return s.jsx(ic.Provider,{value:{entities:i,isLoading:o,isError:l,selectedEntity:h,setSelectedEntityId:a,refetchEntities:f,enabledPayments:t},children:r})}function pn(){const e=N.useContext(ic);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}function Ch({theme:e,children:t}){const r={},n=r,a=(e==null?void 0:e.primaryColor)??"#2563eb";n["--embedded-primary"]=a,n["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,n["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";n["--embedded-secondary"]=i,n["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,n["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return n["--embedded-tertiary"]=o,n["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,n["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(n["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(r.fontFamily=e.fontFamily),n.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:r,children:t})}const oc=N.createContext(null),Ah=6e3;function Ph(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function _h({toast:e,onDismiss:t}){const r=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${r?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[s.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),s.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>t(e.id),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border transition hover:opacity-80 ${r?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(Eh,{})})]}),s.jsx("div",{className:`mx-5 border-t ${r?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function Eh(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function Th({children:e}){const[t,r]=N.useState([]),n=N.useCallback(o=>{r(l=>l.filter(c=>c.id!==o))},[]),a=N.useCallback((o,l,c)=>{const u=Ph();r(d=>[...d,{id:u,variant:o,title:l,message:c}]),window.setTimeout(()=>{n(u)},Ah)},[n]),i=N.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(oc.Provider,{value:i,children:[e,ks.createPortal(s.jsx("div",{className:"pointer-events-none fixed right-4 top-4 z-[200] flex w-[min(100vw-2rem,28rem)] flex-col gap-3",children:t.map(o=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(_h,{toast:o,onDismiss:n})},o.id))}),document.body)]})}function Es(){const e=N.useContext(oc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class Ih extends N.Component{constructor(t){super(t),this.state={hasError:!1,message:""}}static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:"Unexpected error"}}render(){return this.state.hasError?s.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),s.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),s.jsx("button",{type:"button",className:"rounded-md bg-slate-100 px-4 py-2 text-sm text-slate-600 hover:bg-slate-200",onClick:()=>this.setState({hasError:!1,message:""}),children:"Try again"})]}):this.props.children}}function Fh(e){return e.startsWith("/dashboard")?"dashboard":e.startsWith("/payments")?"payments":e.startsWith("/tax-forms")?"tax-forms":e.startsWith("/settings")?"settings":e.startsWith("/create-entity/form")?"create-entity-form":e.startsWith("/create-entity")?"create-entity":"other"}function Dh({navigateFnRef:e,onNavigate:t}){const r=Se(),n=ge();return N.useEffect(()=>(e.current=r,()=>{e.current=null}),[r,e]),N.useEffect(()=>{t==null||t(Fh(n.pathname),n.pathname)},[n.pathname,t]),null}function Rh({selectEntityFnRef:e}){const{setSelectedEntityId:t}=pn();return N.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function ii({appKey:e,accessToken:t,apiBaseUrl:r,theme:n,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,navigateFnRef:l,selectEntityFnRef:c,enabledPayments:u,children:d}){tc(r),mh(e);const[m]=N.useState(()=>new Qm({defaultOptions:{queries:{retry:1,staleTime:300*1e3,refetchOnWindowFocus:!1}}}));return s.jsx(Ch,{theme:n,children:s.jsx(Jm,{client:m,children:s.jsx(Th,{children:s.jsx(yh,{accessToken:t,onSessionExpired:a,children:s.jsx(qd,{children:s.jsxs(kh,{onOrganizationCreated:i,enabledPayments:u,children:[s.jsx(Dh,{navigateFnRef:l,onNavigate:o}),s.jsx(Rh,{selectEntityFnRef:c}),s.jsx(Ih,{children:d})]})})})})})})}function oi(){const{entities:e,isLoading:t,isError:r,refetchEntities:n}=pn(),a=Se();return N.useEffect(()=>{t||r||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,r,e,a]),t?s.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600"})}):r?s.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:s.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),s.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),s.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),s.jsx("button",{type:"button",onClick:n,className:"mt-1 rounded-md bg-slate-100 px-4 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-200",children:"Retry"})]}):null}function li(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=pn(),n=Se(),i=ge().pathname.split("/").filter(Boolean).length>1;return s.jsxs("div",{className:"flex min-h-full flex-col bg-slate-50",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3",children:[i&&s.jsxs("button",{type:"button",onClick:()=>n(-1),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-slate-500 transition hover:bg-slate-100 hover:text-slate-700",children:[s.jsx(Oh,{}),"Back"]}),s.jsx("div",{className:"flex-1"})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(Bd,{context:{entities:e,selectedEntity:t,setSelectedEntityId:r}})})]})}function Oh(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}const $h=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function Lh({onCreateClick:e}){return s.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[s.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-[#f3f4f6] bg-white shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)] sm:rounded-[24px]",children:[s.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-white/20 sm:h-16 sm:w-16",children:s.jsx(fo,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),s.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Create Your Entity"}),s.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),s.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[s.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:$h.map(t=>s.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[s.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:s.jsx(Kn,{})}),t]},t))}),s.jsxs("button",{type:"button",onClick:e,className:"mt-5 flex h-12 w-full items-center justify-center gap-2 rounded-2xl bg-[#156bd5] text-sm font-black text-white transition hover:bg-[#125bb8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5] focus-visible:ring-offset-2 sm:mt-6 sm:h-14 sm:text-base",children:[s.jsx(fo,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",s.jsx(zh,{})]})]})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 text-xs text-[#99a1af] sm:mt-5 sm:gap-x-4",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Kn,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Kn,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Kn,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function fo({className:e="h-5 w-5"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Kn({className:e="h-3 w-3"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 16 16",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.5 8.5l3 3 6-6"})})}function zh(){return s.jsx("svg",{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})}function ci(){const e=Se(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return s.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:s.jsx(Lh,{onCreateClick:t})})}var Mn=e=>e.type==="checkbox",ar=e=>e instanceof Date,$e=e=>e==null;const ui=e=>typeof e=="object";var be=e=>!$e(e)&&!Array.isArray(e)&&ui(e)&&!ar(e),_a=e=>be(e)&&e.target?Mn(e.target)?e.target.checked:e.target.value:e,lc=(e,t)=>t.split(".").some((r,n,a)=>!isNaN(Number(r))&&e.has(a.slice(0,n).join("."))),cc=e=>{const t=e.constructor&&e.constructor.prototype;return be(t)&&t.hasOwnProperty("isPrototypeOf")},Ts=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Ne(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Ts&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(be(e)&&cc(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Ne(e[a]));return n}const Kt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},dt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ct={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},uc="root",di=["__proto__","constructor","prototype"],Mh=/^\w*$/;var Vn=e=>Mh.test(e),fe=e=>e===void 0;const Vh=/[.[\]'"]/;var Is=e=>e.split(Vh).filter(Boolean),L=(e,t,r)=>{if(!t||!be(e))return r;const n=Vn(t)?[t]:Is(t);if(n.some(i=>di.includes(i)))return r;const a=n.reduce((i,o)=>$e(i)?void 0:i[o],e);return fe(a)||a===e?fe(e[t])?r:e[t]:a},Je=e=>typeof e=="boolean",Ve=e=>typeof e=="function",ce=(e,t,r)=>{let n=-1;const a=Vn(t)?[t]:Is(t),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=r;if(n!==o){const u=e[l];c=be(u)||Array.isArray(u)?u:isNaN(+a[n+1])?{}:[]}if(di.includes(l))return;e[l]=c,e=e[l]}};const dc=N.createContext(null);dc.displayName="HookFormControlContext";const mi=()=>N.useContext(dc);var mc=(e,t,r,n=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==dt.all&&(t._proxyFormState[o]=!n||dt.all),r&&(r[o]=!0),e[o]}});return a};const hi=Ts?N.useLayoutEffect:N.useEffect;function qh(e){const t=mi(),{control:r=t,disabled:n,name:a,exact:i}=e||{},[o,l]=N.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=N.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return hi(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!n&&l({...r._formState,...u,defaultValues:r._defaultValues})}}),[a,n,i]),N.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),N.useMemo(()=>mc(o,r,c.current,!1),[o,r])}var qe=e=>typeof e=="string",Ea=(e,t,r,n,a)=>qe(e)?(n&&t.watch.add(e),L(r,e,a)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),L(r,i))):(n&&(t.watchAll=!0),r),Ta=e=>$e(e)||!ui(e);const po=(e,t)=>t.length===0&&!Array.isArray(e)&&!cc(e);function Ge(e,t,r=new WeakMap){if(e===t)return!0;if(Ta(e)||Ta(t))return Object.is(e,t);if(ar(e)&&ar(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(po(e,n)||po(t,a))return Object.is(e,t);if(!n.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=r.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),r.set(e,o)}for(const o of n){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(ar(l)&&ar(c)||(be(l)||Array.isArray(l))&&(be(c)||Array.isArray(c))?!Ge(l,c,r):!Object.is(l,c))return!1}}return!0}function Bh(e){const t=mi(),{control:r=t,name:n,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=N.useRef(a),u=N.useRef(l),d=N.useRef(void 0),m=N.useRef(r),h=N.useRef(n);u.current=l;const[f,y]=N.useState(()=>{const k=r._getWatch(n,c.current);return u.current?u.current(k):k}),p=N.useCallback(k=>{const E=Ea(n,r._names,k||r._formValues,!1,c.current);return u.current?u.current(E):E},[r._formValues,r._names,n]),x=N.useCallback(k=>{if(!i){const E=Ea(n,r._names,k||r._formValues,!1,c.current);if(u.current){const P=u.current(E);Ge(P,d.current)||(y(P),d.current=P)}else y(E)}},[r._formValues,r._names,i,n]);hi(()=>((m.current!==r||!Ge(h.current,n))&&(m.current=r,h.current=n,x()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:k=>{x(k.values)}})),[r,o,n,x]),N.useEffect(()=>r._removeUnmounted());const b=m.current!==r,j=h.current,w=N.useMemo(()=>{if(i)return null;const k=!b&&!Ge(j,n);return b||k?p():null},[i,b,n,j,p]);return w!==null?w:f}function Uh(e){const t=mi(),{name:r,disabled:n,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=lc(a._names.array,r),u=N.useMemo(()=>L(a._formValues,r,L(a._defaultValues,r,o)),[a,r,o]),d=Bh({control:a,name:r,defaultValue:u,exact:l}),m=qh({control:a,name:r,exact:l}),h=N.useRef(e),f=N.useRef(null),y=N.useRef(a.register(r,{...e.rules,value:d,...Je(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=N.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!L(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!L(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!L(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!L(m.validatingFields,r)},error:{enumerable:!0,get:()=>L(m.errors,r)}}),[m,r]),x=N.useCallback(k=>{const E=_a(k);return L(a._fields,r)||(y.current=a.register(r,{...h.current.rules,value:E})),y.current.onChange({target:{value:_a(k),name:r},type:Kt.CHANGE})},[r,a]),b=N.useCallback(()=>y.current.onBlur({target:{value:L(a._formValues,r),name:r},type:Kt.BLUR}),[r,a._formValues]),j=N.useCallback(k=>{k&&(f.current={focus:()=>Ve(k.focus)&&k.focus(),select:()=>Ve(k.select)&&k.select(),setCustomValidity:P=>Ve(k.setCustomValidity)&&k.setCustomValidity(P),reportValidity:()=>Ve(k.reportValidity)&&k.reportValidity()});const E=L(a._fields,r);E&&E._f&&k&&(E._f.ref=f.current)},[a._fields,r]),w=N.useMemo(()=>({name:r,value:d,...Je(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:x,onBlur:b,ref:j}),[r,n,m.disabled,x,b,j,d]);return N.useEffect(()=>{const k=a._options.shouldUnregister||i;a.register(r,{...h.current.rules,...Je(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(P,_)=>{const F=L(a._fields,P);F&&F._f&&(F._f.mount=_)};if(E(r,!0),k){const P=Ne(L(i?a._defaultValues:a._options.values||a._defaultValues,r,L(a._options.defaultValues,r,h.current.defaultValue)));ce(a._defaultValues,r,P),fe(L(a._formValues,r))&&ce(a._formValues,r,P)}if(!c&&a.register(r),f.current){const P=L(a._fields,r);P&&P._f&&(P._f.ref=f.current)}return()=>{(c?k&&!a._state.action:k)?a.unregister(r):E(r,!1)}},[r,a,c,i]),N.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),N.useMemo(()=>({field:w,formState:m,fieldState:p}),[w,m,p])}const De=e=>e.render(Uh(e)),hc=e=>{const t={};for(const r of Object.keys(e))if(ui(e[r])&&e[r]!==null&&!ar(e[r])){const n=hc(e[r]);for(const a of Object.keys(n))t[`${r}.${a}`]=n[a]}else t[r]=e[r];return t},Zh=N.createContext(null);Zh.displayName="HookFormContext";var fi=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},fc=e=>Array.isArray(e)?e.filter(Boolean):[],cs=e=>Array.isArray(e)?e:[e],xo=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function pc(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],i=t[n];if(a&&be(a)&&i){const o=pc(a,i);be(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var Oe=e=>be(e)&&!Object.keys(e).length,pi=e=>e.type==="file",xs=e=>{if(!Ts)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},xc=e=>e.type==="select-multiple",xi=e=>e.type==="radio",Wh=e=>xi(e)||Mn(e),Ks=e=>xs(e)&&e.isConnected;function Yh(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;){if($e(e)){e=void 0;break}e=e[t[n]],n++}return e}function Hh(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function Ae(e,t){if(qe(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:Vn(t)?[t]:Is(t);if(r.some(o=>di.includes(String(o))))return e;const n=r.length===1?e:Yh(e,r),a=r.length-1,i=r[a];return n&&delete n[i],a!==0&&(be(n)&&Oe(n)||Array.isArray(n)&&Hh(n))&&Ae(e,r.slice(0,-1)),e}var Kh=e=>{for(const t in e)if(Ve(e[t]))return!0;return!1};function gc(e){return Array.isArray(e)||be(e)&&!Kh(e)}function Ia(e,t={}){for(const r in e){const n=e[r];gc(n)?(t[r]=Array.isArray(n)?[]:{},Ia(n,t[r])):fe(n)||(t[r]=!0)}return t}function Fa(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>Fa(r));return t.some(r=>r!==void 0)?t:void 0}if(be(e)){const t={};for(const r in e){const n=Fa(e[r]);fe(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function yr(e,t,r){r||(r=Ia(t));for(const n in e){const a=e[n];if(gc(a))fe(t)||Ta(r[n])?r[n]=Ia(a,Array.isArray(a)?[]:{}):yr(a,$e(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!Ge(a,i)}}return Fa(r)||{}}const go={value:!1,isValid:!1},yo={value:!0,isValid:!0};var yc=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&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?yo:{value:e[0].value,isValid:!0}:yo:go}return go},bc=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>fe(e)?e:t?e===""?NaN:e&&+e:r&&qe(e)?new Date(e):n?n(e):e;const bo={isValid:!1,value:null};var vc=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,bo):bo;function vo(e){const t=e.ref;return pi(t)?t.files:xi(t)?vc(e.refs).value:xc(t)?[...t.selectedOptions].map(({value:r})=>r):Mn(t)?yc(e.refs).value:bc(fe(t.value)?e.ref.value:t.value,e)}var Qh=(e,t,r,n)=>{const a={};for(const i of e){const o=L(t,i);o&&ce(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},gs=e=>e instanceof RegExp,vn=e=>fe(e)?e:gs(e)?e.source:be(e)?gs(e.value)?e.value.source:e.value:e,Qn=e=>({isOnSubmit:!e||e===dt.onSubmit,isOnBlur:e===dt.onBlur,isOnChange:e===dt.onChange,isOnAll:e===dt.all,isOnTouch:e===dt.onTouched});const jo="AsyncFunction";var Jh=e=>{if(!e||!e.validate)return!1;if(Ve(e.validate))return e.validate.constructor.name===jo;if(be(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===jo)return!0}return!1},Gh=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Qs=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const n of t.watch)if(e.startsWith(n)&&e.charAt(n.length)===".")return!0;return!1};const Cn=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const i=L(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(Cn(l,t))break}else if(be(l)&&Cn(l,t))break}}};function No(e,t,r){const n=L(e,r);if(n||Vn(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=L(t,i),l=L(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:r}}var Xh=(e,t,r,n)=>{r(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||n&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!n||dt.all))},ef=(e,t,r)=>!e||!t||e===t||cs(e).some(n=>n&&(r?n===t||n.startsWith(t+"."):n.startsWith(t)||t.startsWith(n))),tf=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,rf=(e,t)=>!fc(L(e,t)).length&&Ae(e,t),wo=(e,t,r)=>{const n=L(e,r),a=Array.isArray(n)?n:[];return ce(a,uc,t[r]),ce(e,r,a),e};function So(e,t,r="validate"){if(qe(e)||Array.isArray(e)&&e.every(qe)||Je(e)&&!e)return{type:r,message:qe(e)?e:"",ref:t}}var Mr=e=>be(e)&&!gs(e)?e:{value:e,message:""},ko=async(e,t,r,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:m,max:h,pattern:f,validate:y,name:p,valueAsNumber:x,mount:b}=e._f,j=L(r,p);if(!b||t.has(p))return{};const w=l?l[0]:o,k=q=>{if(a&&w.reportValidity){const K=Je(q)?"":q||"";l?l.forEach(te=>te.setCustomValidity(K)):w.setCustomValidity(K),w.reportValidity()}},E={},P=xi(o),_=Mn(o),F=P||_,Y=(x||pi(o))&&fe(o.value)&&fe(j)||xs(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,M=fi.bind(null,p,n,E),se=(q,K,te,W=ct.maxLength,ne=ct.minLength)=>{const xe=q?K:te;E[p]={type:q?W:ne,message:xe,ref:o,...M(q?W:ne,xe)}};if(i?!Array.isArray(j)||!j.length:c&&(!F&&(Y||$e(j))||Je(j)&&!j||_&&!yc(l).isValid||P&&!vc(l).isValid)){const{value:q,message:K}=qe(c)?{value:!!c,message:c}:Mr(c);if(q&&(E[p]={type:ct.required,message:K,ref:w,...M(ct.required,K)},!n))return k(K),E}if(!Y&&(!$e(m)||!$e(h))){let q,K;const te=Mr(h),W=Mr(m);if(!$e(j)&&!isNaN(j)){const ne=o.valueAsNumber||j&&+j;$e(te.value)||(q=ne>te.value),$e(W.value)||(K=ne<W.value)}else{const ne=o.valueAsDate||new Date(j),xe=Pe=>new Date(new Date().toDateString()+" "+Pe),pe=o.type=="time",H=o.type=="week";qe(te.value)&&j&&(q=pe?xe(j)>xe(te.value):H?j>te.value:ne>new Date(te.value)),qe(W.value)&&j&&(K=pe?xe(j)<xe(W.value):H?j<W.value:ne<new Date(W.value))}if((q||K)&&(se(!!q,te.message,W.message,ct.max,ct.min),!n))return k(E[p].message),E}if((u||d)&&!Y&&(qe(j)||i&&Array.isArray(j))){const q=Mr(u),K=Mr(d),te=!$e(q.value)&&j.length>+q.value,W=!$e(K.value)&&j.length<+K.value;if((te||W)&&(se(te,q.message,K.message),!n))return k(E[p].message),E}if(f&&!Y&&qe(j)){const{value:q,message:K}=Mr(f);if(gs(q)&&!j.match(q)&&(E[p]={type:ct.pattern,message:K,ref:o,...M(ct.pattern,K)},!n))return k(K),E}if(y){if(Ve(y)){const q=await y(j,r),K=So(q,w);if(K&&(E[p]={...K,...M(ct.validate,K.message)},!n))return k(K.message),E}else if(be(y)){let q={};for(const K in y){if(!Oe(q)&&!n)break;const te=So(await y[K](j,r),w,K);te&&(q={...te,...M(K,te.message)},k(te.message),n&&(E[p]=q))}if(!Oe(q)&&(E[p]={ref:w,...q},!n))return E}}return k(!0),E};const nf={mode:dt.onSubmit,reValidateMode:dt.onChange,shouldFocusError:!0},Js="form",jc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function sf(e={}){let t={...nf,...e},r={...Ne(jc),isLoading:Ve(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},a=be(t.defaultValues)||be(t.values)?Ne(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:Ne(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0,d=0,m=Qn(t.mode),h=Qn(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},y={...f};let p={...y};const x={array:xo(),state:xo()},b=t.criteriaMode===dt.all,j=g=>S=>{clearTimeout(u),u=setTimeout(g,S)},w=async g=>{if(!o.keepIsValid&&!t.disabled&&(y.isValid||p.isValid||g)){let S;t.resolver?(S=Oe((await K()).errors),k()):S=await ne({fields:n,onlyCheckValid:!0,eventType:Kt.VALID}),S!==r.isValid&&x.state.next({isValid:S})}},k=(g,S)=>{!t.disabled&&(y.isValidating||y.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(l.mount)).forEach(C=>{C&&(S?ce(r.validatingFields,C,S):Ae(r.validatingFields,C))}),x.state.next({validatingFields:r.validatingFields,isValidating:!Oe(r.validatingFields)}))},E=()=>{r.dirtyFields=yr(a,i)},P=(g,S=[],C,D,R=!0,B=!0)=>{if(D&&C&&!t.disabled){if(o.action=!0,B&&Array.isArray(L(n,g))){const O=C(L(n,g),D.argA,D.argB);R&&ce(n,g,O)}if(B&&Array.isArray(L(r.errors,g))){const O=C(L(r.errors,g),D.argA,D.argB);R&&ce(r.errors,g,O),rf(r.errors,g)}if((y.touchedFields||p.touchedFields)&&B&&Array.isArray(L(r.touchedFields,g))){const O=C(L(r.touchedFields,g),D.argA,D.argB);R&&ce(r.touchedFields,g,O)}(y.dirtyFields||p.dirtyFields)&&E(),x.state.next({name:g,isDirty:pe(g,S),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ce(i,g,S)},_=(g,S)=>{ce(r.errors,g,S),r.errors={...r.errors},x.state.next({errors:r.errors})},F=g=>{r.errors=g,x.state.next({errors:r.errors,isValid:!1})},Y=g=>{const S=Vn(g)?[g]:Is(g);let C=i,D=a;for(let R=0;R<S.length-1;R++){const B=S[R];if(C=$e(C)?C:C[B],D=$e(D)?D:D[B],C===null&&D!==null)return!0}return!1},M=(g,S,C,D)=>{const R=L(n,g);if(R){if(Y(g))return;const B=fe(L(i,g)),O=L(i,g,fe(C)?L(a,g):C);fe(O)||D&&D.defaultChecked||S?ce(i,g,S?O:vo(R._f)):pt(g,O),o.mount&&!o.action&&(w(),B&&r.isDirty&&(y.isDirty||p.isDirty)&&(pe()||(r.isDirty=!1,x.state.next({...r}))),e.shouldUnregister&&B&&!fe(L(i,g))&&Qs(g,l)&&(o.watch=!0))}},se=(g,S,C,D,R)=>{let B=!1,O=!1;const U={name:g};if(!t.disabled){if(!C||D){const $=Ge(L(a,g),S);(y.isDirty||p.isDirty)&&(O=r.isDirty,r.isDirty=U.isDirty=!$||pe(),B=O!==U.isDirty),O=!!L(r.dirtyFields,g),$!==r.isDirty?r.dirtyFields=yr(a,i):$?Ae(r.dirtyFields,g):ce(r.dirtyFields,g,!0),U.dirtyFields=r.dirtyFields,B=B||(y.dirtyFields||p.dirtyFields)&&O!==!$}if(C){const $=L(r.touchedFields,g);$||(ce(r.touchedFields,g,C),U.touchedFields=r.touchedFields,B=B||(y.touchedFields||p.touchedFields)&&$!==C)}B&&R&&x.state.next(U)}return B?U:{}},q=(g,S,C,D)=>{const R=L(r.errors,g),B=(y.isValid||p.isValid)&&Je(S)&&r.isValid!==S;if(t.delayError&&C?(c=j(()=>_(g,C)),c(t.delayError)):(clearTimeout(u),c=null,C?ce(r.errors,g,C):Ae(r.errors,g),r.errors={...r.errors}),(C?!Ge(R,C):R)||!Oe(D)||B){const O={...D,...B&&Je(S)?{isValid:S}:{},errors:r.errors,name:g};r={...r,...O},x.state.next(O)}},K=async g=>(k(g,!0),await t.resolver(i,t.context,Qh(g||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),te=async g=>{const{errors:S}=await K(g);if(k(g),g){for(const C of g){const D=L(S,C);D?l.array.has(C)&&be(D)&&!Object.keys(D).some(R=>!Number.isNaN(Number(R)))?wo(r.errors,{[C]:D},C):ce(r.errors,C,D):Ae(r.errors,C)}r.errors={...r.errors}}else r.errors=S;return S},W=async({name:g,eventType:S})=>{if(e.validate){const C=await e.validate({formValues:i,formState:r,name:g,eventType:S});if(be(C))for(const D in C){const R=C[D];R&&lt(`${Js}.${D}`,{message:qe(R.message)?R.message:"",type:R.type||ct.validate})}else qe(C)||!C?lt(Js,{message:C||"",type:ct.validate}):Te(Js);return C}return!0},ne=async({fields:g,onlyCheckValid:S,name:C,eventType:D,context:R={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(R.runRootValidation=!0,!await W({name:C,eventType:D})&&(R.valid=!1,S)))return R.valid;for(const B in g){const O=g[B];if(O){const{_f:U,...$}=O;if(U){const X=l.array.has(U.name),Ie=O._f&&Jh(O._f),Ft=y.validatingFields||y.isValidating||p.validatingFields||p.isValidating;Ie&&Ft&&k([U.name],!0);const Dt=await ko(O,l.disabled,i,b,t.shouldUseNativeValidation&&!S,X);if(Ie&&Ft&&k([U.name]),Dt[U.name]&&(R.valid=!1,S)||(!S&&(L(Dt,U.name)?X?wo(r.errors,Dt,U.name):ce(r.errors,U.name,Dt[U.name]):Ae(r.errors,U.name)),e.shouldUseNativeValidation&&Dt[U.name]))break}!Oe($)&&await ne({context:R,onlyCheckValid:S,fields:$,name:B,eventType:D})}}return R.valid},xe=()=>{for(const g of l.unMount){const S=L(n,g);S&&(S._f.refs?S._f.refs.every(C=>!Ks(C)):!Ks(S._f.ref))&&Et(g)}l.unMount=new Set},pe=(g,S)=>!t.disabled&&(g&&S&&ce(i,g,S),!Ge(o.mount?i:a,a)),H=(g,S,C)=>Ea(g,l,{...o.mount?i:fe(S)?a:qe(g)?{[g]:S}:S},C,S),Pe=g=>fc(L(o.mount?i:a,g,t.shouldUnregister?L(a,g,[]):[])),pt=(g,S,C={},D=!1,R=!1)=>{const B=L(n,g);let O=S;if(B){const U=B._f;U&&(!U.disabled&&ce(i,g,bc(S,U)),O=xs(U.ref)&&$e(S)?"":S,xc(U.ref)?[...U.ref.options].forEach($=>$.selected=O.includes($.value)):U.refs?Mn(U.ref)?U.refs.forEach($=>{(!$.defaultChecked||!$.disabled)&&(Array.isArray(O)?$.checked=!!O.find(X=>X===$.value):$.checked=O===$.value||!!O)}):U.refs.forEach($=>$.checked=$.value===O):pi(U.ref)?U.ref.value="":(U.ref.value=O,!U.ref.type&&!R&&x.state.next({name:g,values:D?i:Ne(i)})))}(C.shouldDirty||C.shouldTouch)&&se(g,O,C.shouldTouch,C.shouldDirty,!R),C.shouldValidate&&ot(g)},le=(g,S,C,D=!1,R=!1)=>{for(const B in S){if(!S.hasOwnProperty(B))return;const O=S[B],U=g+"."+B,$=L(n,U);(l.array.has(g)||be(O)||$&&!$._f)&&!ar(O)?le(U,O,C,D,R):pt(U,O,C,D,R)}},Re=(g,S,C,D,R=!1)=>{const B=L(n,g),O=l.array.has(g),U=D?S:Ne(S),$=L(i,g),X=Ge($,U);if(X||ce(i,g,U),O)x.array.next({name:g,values:D?i:Ne(i)}),(y.isDirty||y.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&(E(),R||x.state.next({name:g,dirtyFields:r.dirtyFields,isDirty:pe(g,U)}));else{const Ie=Array.isArray(U)&&!U.length||Oe(U);!B||B._f||$e(U)||Ie?pt(g,U,C,D,R):le(g,U,C,D,R)}if(!X&&!R){const Ie=Qs(g,l),Ft=D?i:Ne(i);x.state.next({...Ie&&r,name:o.mount||Ie?g:void 0,values:Ft})}},ze=(g,S,C={})=>Re(g,S,C,!1),He=(g,S={})=>{const C=Ve(g)?g(i):g;if(!Ge(i,C)){i={...i,...C};const D=hc(C);for(const R of l.mount)R in D&&Re(R,D[R],S,!0,!0);x.state.next({...r,name:void 0,type:void 0,...d?{values:i}:{}}),S.shouldValidate&&w()}},At=async g=>{o.mount=!0;const S=g.target;let C=S.name,D=!0;const R=L(n,C),B=O=>{D=Number.isNaN(O)||ar(O)&&isNaN(O.getTime())||Ge(O,L(i,C,O))};if(R){let O,U;const $=S.type?vo(R._f):_a(g),X=g.type===Kt.BLUR||g.type===Kt.FOCUS_OUT,Ie=!Gh(R._f)&&!e.validate&&!t.resolver&&!L(r.errors,C)&&!R._f.deps,Ft=Ie||tf(X,L(r.touchedFields,C),r.isSubmitted,h,m),Dt=Qs(C,l,X);ce(i,C,$),X?(!S||!S.readOnly)&&(R._f.onBlur&&R._f.onBlur(g),c&&c(0)):R._f.onChange&&R._f.onChange(g);const yn=se(C,$,X),Lu=!Oe(yn)||Dt;if(!X&&x.state.next({name:C,type:g.type,...d?{values:Ne(i)}:{}}),Ft)return(!Ie||!r.isValid)&&(y.isValid||p.isValid)&&(t.mode==="onBlur"?X&&w():X||w()),Lu&&x.state.next({name:C,...Dt?{}:yn});if(!t.resolver&&e.validate&&await W({name:C,eventType:g.type}),!X&&Dt&&x.state.next({...r}),t.resolver){const{errors:Hi}=await K([C]);if(k([C]),B($),!D){!Oe(yn)&&x.state.next(yn);return}const zu=No(r.errors,n,C),Ki=No(Hi,n,zu.name||C);O=Ki.error,C=Ki.name,U=Oe(Hi)}else k([C],!0),O=(await ko(R,l.disabled,i,b,t.shouldUseNativeValidation))[C],k([C]),B($),D&&(O?U=!1:(y.isValid||p.isValid)&&(U=await ne({fields:n,onlyCheckValid:!0,name:C,eventType:g.type})));D&&(R._f.deps&&(!Array.isArray(R._f.deps)||R._f.deps.length>0)&&ot(R._f.deps),q(C,U,O,yn))}},it=(g,S)=>{if(L(r.errors,S)&&g.focus)return g.focus(),1},ot=async(g,S={})=>{let C,D;const R=cs(g);if(t.resolver){const B=await te(fe(g)?g:R);C=Oe(B),D=g?!R.some(O=>L(B,O)):C}else g?(D=(await Promise.all(R.map(async B=>{const O=L(n,B);return await ne({fields:O&&O._f?{[B]:O}:O,eventType:Kt.TRIGGER})}))).every(Boolean),!(!D&&!r.isValid)&&w()):D=C=await ne({fields:n,name:g,eventType:Kt.TRIGGER});return x.state.next({...!qe(g)||(y.isValid||p.isValid)&&C!==r.isValid?{}:{name:g},...t.resolver||!g?{isValid:C}:{},errors:r.errors}),S.shouldFocus&&!D&&Cn(n,it,g?R:l.mount),D},Pt=(g,S)=>{let C={...o.mount?i:a};return S&&(C=pc(S.dirtyFields?r.dirtyFields:r.touchedFields,C)),fe(g)?C:qe(g)?L(C,g):g.map(D=>L(C,D))},oe=(g,S)=>({invalid:!!L((S||r).errors,g),isDirty:!!L((S||r).dirtyFields,g),error:L((S||r).errors,g),isValidating:!!L(r.validatingFields,g),isTouched:!!L((S||r).touchedFields,g)}),Te=g=>{const S=g?cs(g):void 0;S==null||S.forEach(C=>Ae(r.errors,C)),S?S.forEach(C=>{x.state.next({name:C,errors:r.errors})}):x.state.next({errors:{}})},lt=(g,S,C)=>{const D=(L(n,g,{_f:{}})._f||{}).ref,R=L(r.errors,g)||{},{ref:B,message:O,type:U,...$}=R;ce(r.errors,g,{...$,...S,ref:D}),x.state.next({name:g,errors:r.errors,isValid:!1}),C&&C.shouldFocus&&D&&D.focus&&D.focus()},_t=(g,S)=>{if(Ve(g)){d++;const{unsubscribe:C}=x.state.subscribe({next:R=>"values"in R&&g(R.values||H(void 0,S),R)});let D=!1;return{unsubscribe:()=>{D||(D=!0,d--,C())}}}return H(g,S,!0)},xt=g=>{var S;const C=!!(!((S=g.formState)===null||S===void 0)&&S.values);C&&d++;const{unsubscribe:D}=x.state.subscribe({next:B=>{if(ef(g.name,B.name,g.exact)&&Xh(B,g.formState||y,xr,g.reRenderRoot)){const O={...i};g.callback({values:O,...r,...B,defaultValues:a})}}});if(!C)return D;let R=!1;return()=>{R||(R=!0,d--,D())}},mr=g=>(o.mount=!0,p={...p,...g.formState},xt({...g,formState:{...f,...g.formState}})),Et=(g,S={})=>{for(const C of g?cs(g):l.mount)l.mount.delete(C),l.array.delete(C),S.keepValue||(Ae(n,C),Ae(i,C)),!S.keepError&&Ae(r.errors,C),!S.keepDirty&&Ae(r.dirtyFields,C),!S.keepTouched&&Ae(r.touchedFields,C),!S.keepIsValidating&&Ae(r.validatingFields,C),!t.shouldUnregister&&!S.keepDefaultValue&&Ae(a,C);x.state.next({values:Ne(i)}),x.state.next({...r,...S.keepDirty?{isDirty:pe()}:{}}),!S.keepIsValid&&w()},Ut=({disabled:g,name:S})=>{if(Je(g)&&o.mount||g||l.disabled.has(S)){const R=l.disabled.has(S)!==!!g;g?l.disabled.add(S):l.disabled.delete(S),R&&o.mount&&!o.action&&w()}},Tt=(g,S={})=>{let C=L(n,g);const D=Je(S.disabled)||Je(t.disabled),R=!l.registerName.has(g)&&C&&C._f&&!C._f.mount;return ce(n,g,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:g}},name:g,mount:!0,...S}}),l.mount.add(g),C&&!R?Ut({disabled:Je(S.disabled)?S.disabled:t.disabled,name:g}):M(g,!0,S.value),{...D?{disabled:S.disabled||t.disabled}:{},...t.progressive?{required:!!S.required,min:vn(S.min),max:vn(S.max),minLength:vn(S.minLength),maxLength:vn(S.maxLength),pattern:vn(S.pattern)}:{},name:g,onChange:At,onBlur:At,ref:B=>{if(B){l.registerName.add(g),Tt(g,S),l.registerName.delete(g),C=L(n,g);const O=fe(B.value)&&B.querySelectorAll&&B.querySelectorAll("input,select,textarea")[0]||B,U=Wh(O),$=C._f.refs||[];if(U?$.find(X=>X===O):O===C._f.ref)return;ce(n,g,{_f:{...C._f,...U?{refs:[...$.filter(Ks),O,...Array.isArray(L(a,g))?[{}]:[]],ref:{type:O.type,name:g}}:{ref:O}}}),M(g,!1,void 0,O)}else C=L(n,g,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||S.shouldUnregister)&&!(lc(l.array,g)&&o.action)&&l.unMount.add(g)}}},It=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Cn(n,it,l.mount),hr=g=>{Je(g)&&(x.state.next({disabled:g}),Cn(n,(S,C)=>{const D=L(n,C);D&&(S.disabled=D._f.disabled||g,Array.isArray(D._f.refs)&&D._f.refs.forEach(R=>{R.disabled=D._f.disabled||g}))},0,!1))},Zt=(g,S)=>async C=>{let D;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let R=Ne(i);if(x.state.next({isSubmitting:!0}),t.resolver){const{errors:B,values:O}=await K();k(),r.errors=B,R=Ne(O)}else await ne({fields:n,eventType:Kt.SUBMIT});if(l.disabled.size)for(const B of l.disabled)Ae(R,B);if(Ae(r.errors,uc),Oe(r.errors)){x.state.next({errors:{}});try{await g(R,C)}catch(B){D=B}}else S&&await S({...r.errors},C),It(),setTimeout(It);if(x.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Oe(r.errors)&&!D,submitCount:r.submitCount+1,errors:r.errors}),D)throw D},fr=(g,S={})=>{L(n,g)&&(fe(S.defaultValue)?ze(g,Ne(L(a,g))):(ze(g,S.defaultValue),ce(a,g,Ne(S.defaultValue))),S.keepTouched||Ae(r.touchedFields,g),S.keepDirty||(Ae(r.dirtyFields,g),r.isDirty=S.defaultValue?pe(g,Ne(L(a,g))):pe()),S.keepError||(Ae(r.errors,g),y.isValid&&w()),x.state.next({...r}))},Wt=(g,S={})=>{const C=g?Ne(g):a,D=Ne(C),R=Oe(g),B=D;if(S.keepDefaultValues||(a=C),!S.keepValues){if(S.keepDirtyValues){const O=new Set([...l.mount,...Object.keys(yr(a,i))]);for(const U of Array.from(O)){const $=L(r.dirtyFields,U),X=L(i,U),Ie=L(B,U);$&&!fe(X)?ce(B,U,X):!$&&!fe(Ie)&&ze(U,Ie)}}else{if(Ts&&fe(g))for(const O of l.mount){const U=L(n,O);if(U&&U._f){const $=Array.isArray(U._f.refs)?U._f.refs[0]:U._f.ref;if(xs($)){const X=$.closest("form");if(X){X.reset();break}}}}if(S.keepFieldsRef)for(const O of l.mount)ze(O,L(B,O));else n={}}if(t.shouldUnregister){if(i=S.keepDefaultValues?Ne(a):{},S.keepFieldsRef)for(const O of l.mount)ce(i,O,L(B,O))}else i=Ne(B);x.array.next({values:{...B}}),x.state.next({name:void 0,type:void 0,values:{...B}})}l={mount:S.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!y.isValid||!!S.keepIsValid||!!S.keepDirtyValues||!t.shouldUnregister&&!Oe(B),o.watch=!!t.shouldUnregister,o.keepIsValid=!!S.keepIsValid,o.action=!1,S.keepErrors||(r.errors={}),x.state.next({submitCount:S.keepSubmitCount?r.submitCount:0,isDirty:R?!1:S.keepDirty?r.isDirty:S.keepValues?pe():!!(S.keepDefaultValues&&!Ge(g,a)),isSubmitted:S.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:R?{}:S.keepDirtyValues?S.keepDefaultValues&&i?yr(a,i):r.dirtyFields:S.keepDefaultValues&&g?yr(a,g):S.keepDirty?r.dirtyFields:{},touchedFields:S.keepTouched?r.touchedFields:{},errors:S.keepErrors?r.errors:{},isSubmitSuccessful:S.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Yt=(g,S)=>Wt(Ve(g)?g(i):g,{...t.resetOptions,...S}),pr=(g,S={})=>{const C=L(n,g),D=C&&C._f;if(D){const R=D.refs?D.refs[0]:D.ref;R.focus&&setTimeout(()=>{R.focus(),S.shouldSelect&&Ve(R.select)&&R.select()})}},xr=g=>{const{name:S,type:C,values:D,...R}=g;r={...r,...R}},ae={control:{register:Tt,unregister:Et,getFieldState:oe,handleSubmit:Zt,setError:lt,_subscribe:xt,_runSchema:K,_updateIsValidating:k,_focusError:It,_getWatch:H,_getDirty:pe,_setValid:w,_setFieldArray:P,_setDisabledField:Ut,_setErrors:F,_getFieldArray:Pe,_reset:Wt,_resetDefaultValues:()=>Ve(t.defaultValues)&&t.defaultValues().then(g=>{Yt(g,t.resetOptions),x.state.next({isLoading:!1})}),_removeUnmounted:xe,_disableForm:hr,_subjects:x,_proxyFormState:y,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(g){o=g},get _defaultValues(){return a},get _names(){return l},set _names(g){l=g},get _formState(){return r},get _options(){return t},set _options(g){t={...t,...g},m=Qn(t.mode),h=Qn(t.reValidateMode)}},subscribe:mr,trigger:ot,register:Tt,handleSubmit:Zt,watch:_t,setValue:ze,setValues:He,getValues:Pt,reset:Yt,resetField:fr,resetDefaultValues:(g,S={})=>{if(a=Ne(g),!S.keepDirty){const C=yr(a,i);r.dirtyFields=C,r.isDirty=!Oe(C)}S.keepIsValid||w(),x.state.next({...r,defaultValues:a})},clearErrors:Te,unregister:Et,setError:lt,setFocus:pr,getFieldState:oe};return{...ae,formControl:ae}}function wt(e={}){const t=N.useRef(void 0),r=N.useRef(void 0),n=N.useRef(e.formControl),[a,i]=N.useState(()=>({...Ne(jc),isLoading:Ve(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ve(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Ve(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=sf(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,hi(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,l},[o]),N.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),N.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),N.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),N.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),N.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),N.useEffect(()=>{var l;e.values&&!Ge(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),N.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=N.useMemo(()=>mc(a,o),[o,a]),t.current}const Co=(e,t,r)=>{if(e&&"reportValidity"in e){const n=L(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Da=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?Co(n.ref,r,e):n&&n.refs&&n.refs.forEach(a=>Co(a,r,e))}},Ao=(e,t)=>{t.shouldUseNativeValidation&&Da(e,t);const r={};for(const n in e){const a=L(t.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(af(t.names||Object.keys(e),n)){const o=Object.assign({},L(r,n));ce(o,"root",i),ce(r,n,o)}else ce(r,n,i)}return r},af=(e,t)=>{const r=Po(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(n=>Po(n).match(`^${r}\\.\\d+`))};function Po(e){return e.replace(/[\[\]]/g,"")}var _o;function I(e,t,r){function n(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=o.prototype,d=Object.keys(u);for(let m=0;m<d.length;m++){const h=d[m];h in l||(l[h]=u[h].bind(l))}}const a=(r==null?void 0:r.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const u=r!=null&&r.Parent?new i:this;n(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,u;return r!=null&&r.Parent&&l instanceof r.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Nc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(_o=globalThis).__zod_globalConfig??(_o.__zod_globalConfig={});const gi=globalThis.__zod_globalConfig;function Ir(e){return gi}function wc(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function Ra(e,t){return typeof t=="bigint"?t.toString():t}function yi(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function bi(e){return e==null}function vi(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const Eo=Symbol("evaluating");function me(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Eo)return n===void 0&&(n=Eo,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function $r(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function cr(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function To(e){return JSON.stringify(e)}function of(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Sc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ys(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const lf=yi(()=>{var e;if(gi.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function En(e){if(ys(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ys(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function kc(e){return En(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const cf=new Set(["string","number","symbol"]);function ln(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ur(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function G(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function uf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function df(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=cr(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=r.shape[l])}return $r(this,"shape",o),o},checks:[]});return ur(e,i)}function mf(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=cr(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return $r(this,"shape",o),o},checks:[]});return ur(e,i)}function hf(e,t){if(!En(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=cr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return $r(this,"shape",i),i}});return ur(e,a)}function ff(e,t){if(!En(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=cr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return $r(this,"shape",n),n}});return ur(e,r)}function pf(e,t){var n;if((n=e._zod.def.checks)!=null&&n.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r=cr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return $r(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ur(e,r)}function xf(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=cr(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(r)for(const u in r){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return $r(this,"shape",c),c},checks:[]});return ur(t,o)}function gf(e,t,r){const n=cr(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return $r(this,"shape",i),i}});return ur(t,n)}function qr(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)!==!0)return!0;return!1}function yf(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)===!1)return!0;return!1}function Cc(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Jn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Fr(e,t,r){var c,u,d,m,h,f;const n=e.message?e.message:Jn((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??Jn((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??Jn((h=r.customError)==null?void 0:h.call(r,e))??Jn((f=r.localeError)==null?void 0:f.call(r,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=n,t!=null&&t.reportInput&&(l.input=o),l}function ji(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Tn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Ac=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ra,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ni=I("$ZodError",Ac),Fs=I("$ZodError",Ac,{Parent:Error});function bf(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function vf(e,t=r=>r.message){const r={_errors:[]},n=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>n({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")n({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")n({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)r._errors.push(t(o));else{let c=r,u=0;for(;u<l.length;){const d=l[u];u===l.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return n(e),r}const Ds=e=>(t,r,n,a)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Ur;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Sc(l,a==null?void 0:a.callee),l}return o.value},jf=Ds(Fs),Rs=e=>async(t,r,n,a)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Sc(l,a==null?void 0:a.callee),l}return o.value},Nf=Rs(Fs),Os=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Ur;return i.issues.length?{success:!1,error:new(e??Ni)(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},wf=Os(Fs),$s=e=>async(t,r,n)=>{const a=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},Sf=$s(Fs),kf=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Ds(e)(t,r,a)},Cf=e=>(t,r,n)=>Ds(e)(t,r,n),Af=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Rs(e)(t,r,a)},Pf=e=>async(t,r,n)=>Rs(e)(t,r,n),_f=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Os(e)(t,r,a)},Ef=e=>(t,r,n)=>Os(e)(t,r,n),Tf=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return $s(e)(t,r,a)},If=e=>async(t,r,n)=>$s(e)(t,r,n),Ff=/^[cC][0-9a-z]{6,}$/,Df=/^[0-9a-z]+$/,Rf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Of=/^[0-9a-vA-V]{20}$/,$f=/^[A-Za-z0-9]{27}$/,Lf=/^[a-zA-Z0-9_-]{21}$/,zf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Io=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Vf=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Bf(){return new RegExp(qf,"u")}const Uf=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Zf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Wf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Yf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Hf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pc=/^[A-Za-z0-9_-]*$/,Kf=/^https?$/,Qf=/^\+[1-9]\d{6,14}$/,_c="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Jf=new RegExp(`^${_c}$`);function Ec(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Gf(e){return new RegExp(`^${Ec(e)}$`)}function Xf(e){const t=Ec({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${_c}T(?:${n})$`)}const ep=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},tp=/^(?:true|false)$/i,rp=/^[^A-Z]*$/,np=/^[^a-z]*$/,St=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),sp=I("$ZodCheckMaxLength",(e,t)=>{var r;St.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!bi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const o=ji(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),ap=I("$ZodCheckMinLength",(e,t)=>{var r;St.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!bi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const o=ji(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),ip=I("$ZodCheckLengthEquals",(e,t)=>{var r;St.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!bi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,i=a.length;if(i===t.length)return;const o=ji(a),l=i>t.length;n.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ls=I("$ZodCheckStringFormat",(e,t)=>{var r,n;St.init(e,t),e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),op=I("$ZodCheckRegex",(e,t)=>{Ls.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),lp=I("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=rp),Ls.init(e,t)}),cp=I("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=np),Ls.init(e,t)}),up=I("$ZodCheckIncludes",(e,t)=>{St.init(e,t);const r=ln(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),dp=I("$ZodCheckStartsWith",(e,t)=>{St.init(e,t);const r=new RegExp(`^${ln(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),mp=I("$ZodCheckEndsWith",(e,t)=>{St.init(e,t);const r=new RegExp(`.*${ln(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),hp=I("$ZodCheckOverwrite",(e,t)=>{St.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class fp{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
13
13
  `).filter(o=>o),a=Math.min(...n.map(o=>o.length-o.trimStart().length)),i=n.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,r=this==null?void 0:this.args,a=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...r,a.join(`
14
- `))}}const xp={major:4,minor:4,patch:3},ke=I("$ZodType",(e,t)=>{var a;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=xp;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const i of n)for(const o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,u)=>{let d=qr(l),m;for(const h of c){if(h._zod.def.when){if(bf(l)||!h._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,y=h._zod.check(l);if(y instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ur;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,l.issues.length!==f&&(d||(d=qr(l,f)))});else{if(l.issues.length===f)continue;d||(d=qr(l,f))}}return m?m.then(()=>l):l},o=(l,c,u)=>{if(qr(l))return l.aborted=!0,l;const d=i(c,n,u);if(d instanceof Promise){if(u.async===!1)throw new Ur;return d.then(m=>e._zod.parse(m,u))}return e._zod.parse(d,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const d=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(m=>o(m,l,c)):o(d,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new Ur;return u.then(d=>i(d,n,c))}return i(u,n,c)}}me(e,"~standard",()=>({validate:i=>{var o;try{const l=Sf(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return kf(e,i).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),Ni=I("$ZodString",(e,t)=>{var r;ke.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??tp(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),ye=I("$ZodStringFormat",(e,t)=>{Ls.init(e,t),Ni.init(e,t)}),gp=I("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Vf),ye.init(e,t)}),yp=I("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Io(n))}else t.pattern??(t.pattern=Io());ye.init(e,t)}),bp=I("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=qf),ye.init(e,t)}),vp=I("$ZodURL",(e,t)=>{ye.init(e,t),e._zod.check=r=>{var n;try{const a=r.value.trim();if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===Qf.source&&!/^https?:\/\//i.test(a)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=a;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),jp=I("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Uf()),ye.init(e,t)}),wp=I("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=zf),ye.init(e,t)}),Np=I("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Df),ye.init(e,t)}),Sp=I("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Rf),ye.init(e,t)}),kp=I("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Of),ye.init(e,t)}),Cp=I("$ZodXID",(e,t)=>{t.pattern??(t.pattern=$f),ye.init(e,t)}),Ap=I("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Lf),ye.init(e,t)}),Pp=I("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ep(t)),ye.init(e,t)}),_p=I("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Gf),ye.init(e,t)}),Ep=I("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Xf(t)),ye.init(e,t)}),Tp=I("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Mf),ye.init(e,t)}),Ip=I("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Zf),ye.init(e,t),e._zod.bag.format="ipv4"}),Fp=I("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wf),ye.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Dp=I("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Yf),ye.init(e,t)}),Rp=I("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Hf),ye.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Tc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Op=I("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Kf),ye.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Tc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function $p(e){if(!Pc.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Tc(r)}const Lp=I("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Pc),ye.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{$p(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),zp=I("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jf),ye.init(e,t)});function Mp(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const a=JSON.parse(atob(n));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const Vp=I("$ZodJWT",(e,t)=>{ye.init(e,t),e._zod.check=r=>{Mp(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),qp=I("$ZodBoolean",(e,t)=>{ke.init(e,t),e._zod.pattern=rp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const a=r.value;return typeof a=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),r}}),Bp=I("$ZodUnknown",(e,t)=>{ke.init(e,t),e._zod.parse=r=>r}),Up=I("$ZodNever",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Fo(e,t,r){e.issues.length&&t.issues.push(...Cc(r,e.issues)),t.value[r]=e.value}const Zp=I("$ZodArray",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=Array(a.length);const i=[];for(let o=0;o<a.length;o++){const l=a[o],c=t.element._zod.run({value:l,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Fo(u,r,o))):Fo(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function bs(e,t,r,n,a,i){const o=r in n;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Cc(r,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function Ic(e){var n,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(n=e.shape)==null?void 0:n[l])==null?void 0:a._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const r=df(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Fc(e,t,r,n,a,i){const o=[],l=a.keySet,c=a.catchall._zod,u=c.def.type,d=c.optin==="optional",m=c.optout==="optional";for(const h in t){if(h==="__proto__"||l.has(h))continue;if(u==="never"){o.push(h);continue}const f=c.run({value:t[h],issues:[]},n);f instanceof Promise?e.push(f.then(y=>bs(y,r,h,t,d,m))):bs(f,r,h,t,d,m)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const Wp=I("$ZodObject",(e,t)=>{ke.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!(r!=null&&r.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=yi(()=>Ic(t));me(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const d=l[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const m of d.values)c[u].add(m)}}return c});const a=ys,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=n.value);const u=l.value;if(!a(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const d=[],m=o.shape;for(const h of o.keys){const f=m[h],y=f._zod.optin==="optional",p=f._zod.optout==="optional",x=f._zod.run({value:u[h],issues:[]},c);x instanceof Promise?d.push(x.then(b=>bs(b,l,h,u,y,p))):bs(x,l,h,u,y,p)}return i?Fc(d,u,l,c,n.value,e):d.length?Promise.all(d).then(()=>l):l}}),Yp=I("$ZodObjectJIT",(e,t)=>{Wp.init(e,t);const r=e._zod.parse,n=yi(()=>Ic(t)),a=h=>{var N,k;const f=new pp(["shape","payload","ctx"]),y=n.value,p=E=>{const P=To(E);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};f.write("const input = payload.value;");const x=Object.create(null);let b=0;for(const E of y.keys)x[E]=`key_${b++}`;f.write("const newResult = {};");for(const E of y.keys){const P=x[E],_=To(E),F=h[E],Y=((N=F==null?void 0:F._zod)==null?void 0:N.optin)==="optional",M=((k=F==null?void 0:F._zod)==null?void 0:k.optout)==="optional";f.write(`const ${P} = ${p(E)};`),Y&&M?f.write(`
14
+ `))}}const pp={major:4,minor:4,patch:3},ke=I("$ZodType",(e,t)=>{var a;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pp;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const i of n)for(const o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,u)=>{let d=qr(l),m;for(const h of c){if(h._zod.def.when){if(yf(l)||!h._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,y=h._zod.check(l);if(y instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ur;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,l.issues.length!==f&&(d||(d=qr(l,f)))});else{if(l.issues.length===f)continue;d||(d=qr(l,f))}}return m?m.then(()=>l):l},o=(l,c,u)=>{if(qr(l))return l.aborted=!0,l;const d=i(c,n,u);if(d instanceof Promise){if(u.async===!1)throw new Ur;return d.then(m=>e._zod.parse(m,u))}return e._zod.parse(d,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const d=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(m=>o(m,l,c)):o(d,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new Ur;return u.then(d=>i(d,n,c))}return i(u,n,c)}}me(e,"~standard",()=>({validate:i=>{var o;try{const l=wf(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return Sf(e,i).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),wi=I("$ZodString",(e,t)=>{var r;ke.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??ep(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),ye=I("$ZodStringFormat",(e,t)=>{Ls.init(e,t),wi.init(e,t)}),xp=I("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Mf),ye.init(e,t)}),gp=I("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Io(n))}else t.pattern??(t.pattern=Io());ye.init(e,t)}),yp=I("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Vf),ye.init(e,t)}),bp=I("$ZodURL",(e,t)=>{ye.init(e,t),e._zod.check=r=>{var n;try{const a=r.value.trim();if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===Kf.source&&!/^https?:\/\//i.test(a)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=a;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),vp=I("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Bf()),ye.init(e,t)}),jp=I("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Lf),ye.init(e,t)}),Np=I("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ff),ye.init(e,t)}),wp=I("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Df),ye.init(e,t)}),Sp=I("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Rf),ye.init(e,t)}),kp=I("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Of),ye.init(e,t)}),Cp=I("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=$f),ye.init(e,t)}),Ap=I("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Xf(t)),ye.init(e,t)}),Pp=I("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Jf),ye.init(e,t)}),_p=I("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Gf(t)),ye.init(e,t)}),Ep=I("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=zf),ye.init(e,t)}),Tp=I("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Uf),ye.init(e,t),e._zod.bag.format="ipv4"}),Ip=I("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Zf),ye.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Fp=I("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Wf),ye.init(e,t)}),Dp=I("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Yf),ye.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Tc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Rp=I("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Hf),ye.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Tc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Op(e){if(!Pc.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Tc(r)}const $p=I("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Pc),ye.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Op(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Lp=I("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Qf),ye.init(e,t)});function zp(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const a=JSON.parse(atob(n));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const Mp=I("$ZodJWT",(e,t)=>{ye.init(e,t),e._zod.check=r=>{zp(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Vp=I("$ZodBoolean",(e,t)=>{ke.init(e,t),e._zod.pattern=tp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const a=r.value;return typeof a=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),r}}),qp=I("$ZodUnknown",(e,t)=>{ke.init(e,t),e._zod.parse=r=>r}),Bp=I("$ZodNever",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Fo(e,t,r){e.issues.length&&t.issues.push(...Cc(r,e.issues)),t.value[r]=e.value}const Up=I("$ZodArray",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=Array(a.length);const i=[];for(let o=0;o<a.length;o++){const l=a[o],c=t.element._zod.run({value:l,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Fo(u,r,o))):Fo(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function bs(e,t,r,n,a,i){const o=r in n;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Cc(r,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function Ic(e){var n,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(n=e.shape)==null?void 0:n[l])==null?void 0:a._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const r=uf(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Fc(e,t,r,n,a,i){const o=[],l=a.keySet,c=a.catchall._zod,u=c.def.type,d=c.optin==="optional",m=c.optout==="optional";for(const h in t){if(h==="__proto__"||l.has(h))continue;if(u==="never"){o.push(h);continue}const f=c.run({value:t[h],issues:[]},n);f instanceof Promise?e.push(f.then(y=>bs(y,r,h,t,d,m))):bs(f,r,h,t,d,m)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const Zp=I("$ZodObject",(e,t)=>{ke.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!(r!=null&&r.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=yi(()=>Ic(t));me(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const d=l[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const m of d.values)c[u].add(m)}}return c});const a=ys,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=n.value);const u=l.value;if(!a(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const d=[],m=o.shape;for(const h of o.keys){const f=m[h],y=f._zod.optin==="optional",p=f._zod.optout==="optional",x=f._zod.run({value:u[h],issues:[]},c);x instanceof Promise?d.push(x.then(b=>bs(b,l,h,u,y,p))):bs(x,l,h,u,y,p)}return i?Fc(d,u,l,c,n.value,e):d.length?Promise.all(d).then(()=>l):l}}),Wp=I("$ZodObjectJIT",(e,t)=>{Zp.init(e,t);const r=e._zod.parse,n=yi(()=>Ic(t)),a=h=>{var w,k;const f=new fp(["shape","payload","ctx"]),y=n.value,p=E=>{const P=To(E);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};f.write("const input = payload.value;");const x=Object.create(null);let b=0;for(const E of y.keys)x[E]=`key_${b++}`;f.write("const newResult = {};");for(const E of y.keys){const P=x[E],_=To(E),F=h[E],Y=((w=F==null?void 0:F._zod)==null?void 0:w.optin)==="optional",M=((k=F==null?void 0:F._zod)==null?void 0:k.optout)==="optional";f.write(`const ${P} = ${p(E)};`),Y&&M?f.write(`
15
15
  if (${P}.issues.length) {
16
16
  if (${_} in input) {
17
17
  payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
@@ -70,7 +70,7 @@ Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}
70
70
  }
71
71
  }
72
72
 
73
- `)}f.write("payload.value = newResult;"),f.write("return payload;");const j=f.compile();return(E,P)=>j(h,E,P)};let i;const o=ys,l=!gi.jitless,u=l&&cf.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=n.value);const y=h.value;return o(y)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?Fc([],y,h,f,m,e):h):r(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h)}});function Do(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!qr(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>Fr(o,n,Ir())))}),t)}const Hp=I("$ZodUnion",(e,t)=>{ke.init(e,t),me(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),me(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),me(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),me(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${n.map(a=>vi(a.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,a)=>{if(r)return r(n,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:n.value,issues:[]},a);if(c instanceof Promise)o.push(c),i=!0;else{if(c.issues.length===0)return c;o.push(c)}}return i?Promise.all(o).then(l=>Do(l,n,e,a)):Do(o,n,e,a)}}),Kp=I("$ZodIntersection",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{const a=r.value,i=t.left._zod.run({value:a,issues:[]},n),o=t.right._zod.run({value:a,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Ro(r,c,u)):Ro(r,i,o)}});function Oa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(En(e)&&En(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of n){const o=Oa(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};a[i]=o.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const a=e[n],i=t[n],o=Oa(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Ro(e,t,r){const n=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(l);for(const l of r.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(l);const i=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),qr(e))return e;const o=Oa(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Qp=I("$ZodEnum",(e,t)=>{ke.init(e,t);const r=Nc(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(a=>uf.has(typeof a)).map(a=>typeof a=="string"?ln(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:r,input:o,inst:e}),a}}),Jp=I("$ZodLiteral",(e,t)=>{if(ke.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ln(n):n?ln(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,a)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),Gp=I("$ZodTransform",(e,t)=>{ke.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new wc(e.constructor.name);const a=t.transform(r.value,r);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(r.value=o,r.fallback=!0,r));if(a instanceof Promise)throw new Ur;return r.value=a,r.fallback=!0,r}});function Oo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Dc=I("$ZodOptional",(e,t)=>{ke.init(e,t),e._zod.optin="optional",e._zod.optout="optional",me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),me(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vi(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const a=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Oo(o,a)):Oo(i,a)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Xp=I("$ZodExactOptional",(e,t)=>{Dc.init(e,t),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),ex=I("$ZodNullable",(e,t)=>{ke.init(e,t),me(e._zod,"optin",()=>t.innerType._zod.optin),me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vi(r.source)}|null)$`):void 0}),me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),tx=I("$ZodDefault",(e,t)=>{ke.init(e,t),e._zod.optin="optional",me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>$o(i,t)):$o(a,t)}});function $o(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const rx=I("$ZodPrefault",(e,t)=>{ke.init(e,t),e._zod.optin="optional",me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),nx=I("$ZodNonOptional",(e,t)=>{ke.init(e,t),me(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>Lo(i,e)):Lo(a,e)}});function Lo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const sx=I("$ZodCatch",(e,t)=>{ke.init(e,t),e._zod.optin="optional",me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>Fr(o,n,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(i=>Fr(i,n,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),ax=I("$ZodPipe",(e,t)=>{ke.init(e,t),me(e._zod,"values",()=>t.in._zod.values),me(e._zod,"optin",()=>t.in._zod.optin),me(e._zod,"optout",()=>t.out._zod.optout),me(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Gn(o,t.in,n)):Gn(i,t.in,n)}const a=t.in._zod.run(r,n);return a instanceof Promise?a.then(i=>Gn(i,t.out,n)):Gn(a,t.out,n)}});function Gn(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}const ix=I("$ZodReadonly",(e,t)=>{ke.init(e,t),me(e._zod,"propValues",()=>t.innerType._zod.propValues),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"optin",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),me(e._zod,"optout",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optout}),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(zo):zo(a)}});function zo(e){return e.value=Object.freeze(e.value),e}const ox=I("$ZodCustom",(e,t)=>{St.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,a=t.fn(n);if(a instanceof Promise)return a.then(i=>Mo(i,r,n,e));Mo(a,r,n,e)}});function Mo(e,t,r,n){if(!e){const a={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(a.params=n._zod.def.params),t.issues.push(Tn(a))}}var Vo;class lx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const a={...n,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function cx(){return new lx}(Vo=globalThis).__zod_globalRegistry??(Vo.__zod_globalRegistry=cx());const kn=globalThis.__zod_globalRegistry;function ux(e,t){return new e({type:"string",...G(t)})}function Rc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function qo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function dx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}function mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}function hx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}function fx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}function px(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function xx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}function gx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}function yx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}function bx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}function vx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}function jx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}function wx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}function Nx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}function Sx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}function kx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}function Cx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}function Ax(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}function Px(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}function _x(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}function Ex(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}function Tx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}function Ix(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}function Fx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}function Dx(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}function Rx(e,t){return new e({type:"boolean",...G(t)})}function Ox(e){return new e({type:"unknown"})}function $x(e,t){return new e({type:"never",...G(t)})}function Oc(e,t){return new ap({check:"max_length",...G(t),maximum:e})}function vs(e,t){return new ip({check:"min_length",...G(t),minimum:e})}function $c(e,t){return new op({check:"length_equals",...G(t),length:e})}function Lx(e,t){return new lp({check:"string_format",format:"regex",...G(t),pattern:e})}function zx(e){return new cp({check:"string_format",format:"lowercase",...G(e)})}function Mx(e){return new up({check:"string_format",format:"uppercase",...G(e)})}function Vx(e,t){return new dp({check:"string_format",format:"includes",...G(t),includes:e})}function qx(e,t){return new mp({check:"string_format",format:"starts_with",...G(t),prefix:e})}function Bx(e,t){return new hp({check:"string_format",format:"ends_with",...G(t),suffix:e})}function xn(e){return new fp({check:"overwrite",tx:e})}function Ux(e){return xn(t=>t.normalize(e))}function Zx(){return xn(e=>e.trim())}function Wx(){return xn(e=>e.toLowerCase())}function Yx(){return xn(e=>e.toUpperCase())}function Hx(){return xn(e=>lf(e))}function Kx(e,t,r){return new e({type:"array",element:t,...G(r)})}function Qx(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}function Jx(e,t){const r=Gx(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Tn(a,n.value,r._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(Tn(i))}},e(n.value,n)),t);return r}function Gx(e,t){const r=new St({check:"custom",...G(t)});return r._zod.check=e,r}function Lc(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??kn,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Le(e,t,r={path:[],schemaPath:[]}){var d,m;var n;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const l=(m=(d=e._zod).toJSONSchema)==null?void 0:m.call(d);if(l)o.schema=l;else{const h={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const y=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,y,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),Le(f,t,h),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Be(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function zc(e,t){var o,l,c,u;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const d of e.seen.entries()){const m=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(m){const h=n.get(m);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(m,d[0])}}const a=d=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=(p=e.external.registry.get(d[0]))==null?void 0:p.id,b=e.external.uri??(N=>N);if(x)return{ref:b(x)};const j=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=j,{defId:j,ref:`${b("__shared")}#/${m}/${j}`}}if(d[1]===r)return{ref:"#"};const f=`#/${m}/`,y=d[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:f+y}},i=d=>{if(d[1].schema.$ref)return;const m=d[1],{ref:h,defId:f}=a(d);m.def={...m.schema},f&&(m.defId=f);const y=m.schema;for(const p in y)delete y[p];y.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const m=d[1];if(m.cycle)throw new Error(`Cycle detected: #/${(l=m.cycle)==null?void 0:l.join("/")}/<root>
73
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");const j=f.compile();return(E,P)=>j(h,E,P)};let i;const o=ys,l=!gi.jitless,u=l&&lf.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=n.value);const y=h.value;return o(y)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?Fc([],y,h,f,m,e):h):r(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h)}});function Do(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!qr(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>Fr(o,n,Ir())))}),t)}const Yp=I("$ZodUnion",(e,t)=>{ke.init(e,t),me(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),me(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),me(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),me(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${n.map(a=>vi(a.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,a)=>{if(r)return r(n,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:n.value,issues:[]},a);if(c instanceof Promise)o.push(c),i=!0;else{if(c.issues.length===0)return c;o.push(c)}}return i?Promise.all(o).then(l=>Do(l,n,e,a)):Do(o,n,e,a)}}),Hp=I("$ZodIntersection",(e,t)=>{ke.init(e,t),e._zod.parse=(r,n)=>{const a=r.value,i=t.left._zod.run({value:a,issues:[]},n),o=t.right._zod.run({value:a,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Ro(r,c,u)):Ro(r,i,o)}});function Oa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(En(e)&&En(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of n){const o=Oa(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};a[i]=o.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const a=e[n],i=t[n],o=Oa(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Ro(e,t,r){const n=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(l);for(const l of r.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(l);const i=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),qr(e))return e;const o=Oa(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Kp=I("$ZodEnum",(e,t)=>{ke.init(e,t);const r=wc(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(a=>cf.has(typeof a)).map(a=>typeof a=="string"?ln(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:r,input:o,inst:e}),a}}),Qp=I("$ZodLiteral",(e,t)=>{if(ke.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ln(n):n?ln(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,a)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),Jp=I("$ZodTransform",(e,t)=>{ke.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Nc(e.constructor.name);const a=t.transform(r.value,r);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(r.value=o,r.fallback=!0,r));if(a instanceof Promise)throw new Ur;return r.value=a,r.fallback=!0,r}});function Oo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Dc=I("$ZodOptional",(e,t)=>{ke.init(e,t),e._zod.optin="optional",e._zod.optout="optional",me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),me(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vi(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const a=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Oo(o,a)):Oo(i,a)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Gp=I("$ZodExactOptional",(e,t)=>{Dc.init(e,t),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Xp=I("$ZodNullable",(e,t)=>{ke.init(e,t),me(e._zod,"optin",()=>t.innerType._zod.optin),me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vi(r.source)}|null)$`):void 0}),me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),ex=I("$ZodDefault",(e,t)=>{ke.init(e,t),e._zod.optin="optional",me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>$o(i,t)):$o(a,t)}});function $o(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const tx=I("$ZodPrefault",(e,t)=>{ke.init(e,t),e._zod.optin="optional",me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),rx=I("$ZodNonOptional",(e,t)=>{ke.init(e,t),me(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>Lo(i,e)):Lo(a,e)}});function Lo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const nx=I("$ZodCatch",(e,t)=>{ke.init(e,t),e._zod.optin="optional",me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>Fr(o,n,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(i=>Fr(i,n,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),sx=I("$ZodPipe",(e,t)=>{ke.init(e,t),me(e._zod,"values",()=>t.in._zod.values),me(e._zod,"optin",()=>t.in._zod.optin),me(e._zod,"optout",()=>t.out._zod.optout),me(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Gn(o,t.in,n)):Gn(i,t.in,n)}const a=t.in._zod.run(r,n);return a instanceof Promise?a.then(i=>Gn(i,t.out,n)):Gn(a,t.out,n)}});function Gn(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}const ax=I("$ZodReadonly",(e,t)=>{ke.init(e,t),me(e._zod,"propValues",()=>t.innerType._zod.propValues),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"optin",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),me(e._zod,"optout",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optout}),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(zo):zo(a)}});function zo(e){return e.value=Object.freeze(e.value),e}const ix=I("$ZodCustom",(e,t)=>{St.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,a=t.fn(n);if(a instanceof Promise)return a.then(i=>Mo(i,r,n,e));Mo(a,r,n,e)}});function Mo(e,t,r,n){if(!e){const a={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(a.params=n._zod.def.params),t.issues.push(Tn(a))}}var Vo;class ox{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const a={...n,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function lx(){return new ox}(Vo=globalThis).__zod_globalRegistry??(Vo.__zod_globalRegistry=lx());const kn=globalThis.__zod_globalRegistry;function cx(e,t){return new e({type:"string",...G(t)})}function Rc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function qo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function ux(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}function dx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}function mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}function hx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}function fx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function px(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}function xx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}function gx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}function yx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}function bx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}function vx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}function jx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}function Nx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}function wx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}function Sx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}function kx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}function Cx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}function Ax(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}function Px(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}function _x(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}function Ex(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}function Tx(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}function Ix(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}function Fx(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}function Dx(e,t){return new e({type:"boolean",...G(t)})}function Rx(e){return new e({type:"unknown"})}function Ox(e,t){return new e({type:"never",...G(t)})}function Oc(e,t){return new sp({check:"max_length",...G(t),maximum:e})}function vs(e,t){return new ap({check:"min_length",...G(t),minimum:e})}function $c(e,t){return new ip({check:"length_equals",...G(t),length:e})}function $x(e,t){return new op({check:"string_format",format:"regex",...G(t),pattern:e})}function Lx(e){return new lp({check:"string_format",format:"lowercase",...G(e)})}function zx(e){return new cp({check:"string_format",format:"uppercase",...G(e)})}function Mx(e,t){return new up({check:"string_format",format:"includes",...G(t),includes:e})}function Vx(e,t){return new dp({check:"string_format",format:"starts_with",...G(t),prefix:e})}function qx(e,t){return new mp({check:"string_format",format:"ends_with",...G(t),suffix:e})}function xn(e){return new hp({check:"overwrite",tx:e})}function Bx(e){return xn(t=>t.normalize(e))}function Ux(){return xn(e=>e.trim())}function Zx(){return xn(e=>e.toLowerCase())}function Wx(){return xn(e=>e.toUpperCase())}function Yx(){return xn(e=>of(e))}function Hx(e,t,r){return new e({type:"array",element:t,...G(r)})}function Kx(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}function Qx(e,t){const r=Jx(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Tn(a,n.value,r._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(Tn(i))}},e(n.value,n)),t);return r}function Jx(e,t){const r=new St({check:"custom",...G(t)});return r._zod.check=e,r}function Lc(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??kn,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Le(e,t,r={path:[],schemaPath:[]}){var d,m;var n;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const l=(m=(d=e._zod).toJSONSchema)==null?void 0:m.call(d);if(l)o.schema=l;else{const h={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const y=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,y,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),Le(f,t,h),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Be(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function zc(e,t){var o,l,c,u;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const d of e.seen.entries()){const m=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(m){const h=n.get(m);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(m,d[0])}}const a=d=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=(p=e.external.registry.get(d[0]))==null?void 0:p.id,b=e.external.uri??(w=>w);if(x)return{ref:b(x)};const j=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=j,{defId:j,ref:`${b("__shared")}#/${m}/${j}`}}if(d[1]===r)return{ref:"#"};const f=`#/${m}/`,y=d[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:f+y}},i=d=>{if(d[1].schema.$ref)return;const m=d[1],{ref:h,defId:f}=a(d);m.def={...m.schema},f&&(m.defId=f);const y=m.schema;for(const p in y)delete y[p];y.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const m=d[1];if(m.cycle)throw new Error(`Cycle detected: #/${(l=m.cycle)==null?void 0:l.join("/")}/<root>
74
74
 
75
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const m=d[1];if(t===d[0]){i(d);continue}if(e.external){const f=(c=e.external.registry.get(d[0]))==null?void 0:c.id;if(t!==d[0]&&f){i(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){i(d);continue}if(m.cycle){i(d);continue}if(m.count>1&&e.reused==="ref"){i(d);continue}}}function Mc(e,t){var l,c,u,d;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,y={...f},p=h.ref;if(h.ref=null,p){n(p);const b=e.seen.get(p),j=b.schema;if(j.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(j)):Object.assign(f,j),Object.assign(f,y),m._zod.parent===p)for(const k in f)k==="$ref"||k==="allOf"||k in y||delete f[k];if(j.$ref&&b.def)for(const k in f)k==="$ref"||k==="allOf"||k in b.def&&JSON.stringify(f[k])===JSON.stringify(b.def[k])&&delete f[k]}const x=m._zod.parent;if(x&&x!==p){n(x);const b=e.seen.get(x);if(b!=null&&b.schema.$ref&&(f.$ref=b.schema.$ref,b.def))for(const j in f)j==="$ref"||j==="allOf"||j in b.def&&JSON.stringify(f[j])===JSON.stringify(b.def[j])&&delete f[j]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())n(m[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,r.def??r.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&a.id===i&&delete a.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const m of e.seen.entries()){const h=m[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const m=JSON.parse(JSON.stringify(a));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:js(t,"input",e.processors),output:js(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Be(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Be(n.element,r);if(n.type==="set")return Be(n.valueType,r);if(n.type==="lazy")return Be(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Be(n.innerType,r);if(n.type==="intersection")return Be(n.left,r)||Be(n.right,r);if(n.type==="record"||n.type==="map")return Be(n.keyType,r)||Be(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Be(n.in,r)||Be(n.out,r);if(n.type==="object"){for(const a in n.shape)if(Be(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(Be(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(Be(a,r))return!0;return!!(n.rest&&Be(n.rest,r))}return!1}const Xx=(e,t={})=>r=>{const n=Lc({...r,processors:t});return Le(e,n),zc(n,e),Mc(n,e)},js=(e,t,r={})=>n=>{const{libraryOptions:a,target:i}=n??{},o=Lc({...a??{},target:i,io:t,processors:r});return Le(e,o),zc(o,e),Mc(o,e)},eg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tg=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=eg[l]??l,a.format===""&&delete a.format,l==="time"&&delete a.format),u&&(a.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?a.pattern=d[0].source:d.length>1&&(a.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},rg=(e,t,r,n)=>{r.type="boolean"},ng=(e,t,r,n)=>{r.not={}},sg=(e,t,r,n)=>{},ag=(e,t,r,n)=>{const a=e._zod.def,i=Nc(a.entries);i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},ig=(e,t,r,n)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),i.every(o=>typeof o=="boolean")&&(r.type="boolean"),i.every(o=>o===null)&&(r.type="null"),r.enum=i},og=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},lg=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},cg=(e,t,r,n)=>{const a=r,i=e._zod.def,{minimum:o,maximum:l}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof l=="number"&&(a.maxItems=l),a.type="array",a.items=Le(i.element,t,{...n,path:[...n.path,"items"]})},ug=(e,t,r,n)=>{var u;const a=r,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const d in o)a.properties[d]=Le(o[d],t,{...n,path:[...n.path,"properties",d]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(d=>{const m=i.shape[d]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=Le(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},dg=(e,t,r,n)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>Le(l,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=o:r.anyOf=o},mg=(e,t,r,n)=>{const a=e._zod.def,i=Le(a.left,t,{...n,path:[...n.path,"allOf",0]}),o=Le(a.right,t,{...n,path:[...n.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];r.allOf=c},hg=(e,t,r,n)=>{const a=e._zod.def,i=Le(a.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},fg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType},pg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},xg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},gg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},yg=(e,t,r,n)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;Le(o,t,n);const l=t.seen.get(e);l.ref=o},bg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.readOnly=!0},Vc=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType};function $a(){return $a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$a.apply(null,arguments)}function Bo(e,t){try{var r=e()}catch(n){return t(n)}return r&&r.then?r.then(void 0,t):r}function vg(e,t){for(var r={};e.length;){var n=e[0],a=n.code,i=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var l=n.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(d){return d.errors.forEach(function(m){return e.push(m)})}),t){var c=r[o].types,u=c&&c[n.code];r[o]=fi(o,t,r,a,u?[].concat(u,n.message):n.message)}e.shift()}return r}function jg(e,t){for(var r={},n=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!r[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];r[l]={message:c.message,type:c.code}}else r[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push($a({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=r[l].types,d=u&&u[a.code];r[l]=fi(l,t,r,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)n();return r}function kt(e,t,r){if(r===void 0&&(r={}),(function(n){return"_def"in n&&typeof n._def=="object"&&"typeName"in n._def})(e))return function(n,a,i){try{return Promise.resolve(Bo(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(o){return i.shouldUseNativeValidation&&Da({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Ao(vg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(n){return"_zod"in n&&typeof n._zod=="object"})(e))return function(n,a,i){try{return Promise.resolve(Bo(function(){return Promise.resolve((r.mode==="sync"?wf:Nf)(e,n,t)).then(function(o){return i.shouldUseNativeValidation&&Da({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return l instanceof wi})(o))return{values:{},errors:Ao(jg(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function cn({label:e,required:t=!1,htmlFor:r}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})}const de=w.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",...o},l){const c=a??o.name;return s.jsxs("div",{children:[s.jsx(cn,{label:t,required:r,htmlFor:c}),s.jsx("input",{ref:l,id:c,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...o}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}),wt=w.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",children:o,...l},c){const u=a??l.name;return s.jsxs("div",{children:[s.jsx(cn,{label:t,required:r,htmlFor:u}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:u,className:`block w-full appearance-none rounded-lg border bg-white px-3 py-2.5 pr-10 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(wg,{})]}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})});function lr({step:e,title:t,muted:r=!1,children:n}){return s.jsxs("section",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[e?s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:e}):null,s.jsx("h3",{className:`text-sm font-semibold tracking-wide ${r?"text-slate-400":"text-gov-700"}`,children:t})]}),n]})}function wg(){return s.jsx("svg",{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function qt({variant:e="error",title:t,message:r}){const n=e==="error"?"border-red-200 bg-red-50 text-red-800":"border-slate-200 bg-white text-slate-700";return s.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${n}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:r})]})}function et(e,t){var r;if(e instanceof zn){if(e.details){const n=(r=Object.values(e.details)[0])==null?void 0:r[0];if(n)return n}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Ng=I("ZodISODateTime",(e,t)=>{Pp.init(e,t),je.init(e,t)});function Sg(e){return Tx(Ng,e)}const kg=I("ZodISODate",(e,t)=>{_p.init(e,t),je.init(e,t)});function Cg(e){return Ix(kg,e)}const Ag=I("ZodISOTime",(e,t)=>{Ep.init(e,t),je.init(e,t)});function Pg(e){return Fx(Ag,e)}const _g=I("ZodISODuration",(e,t)=>{Tp.init(e,t),je.init(e,t)});function Eg(e){return Dx(_g,e)}const Tg=(e,t)=>{wi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>jf(e,r)},flatten:{value:r=>vf(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Ra,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Ra,2)}},isEmpty:{get(){return e.issues.length===0}}})},at=I("ZodError",Tg,{Parent:Error}),Ig=Ds(at),Fg=Rs(at),Dg=Os(at),Rg=$s(at),Og=Cf(at),$g=Af(at),Lg=Pf(at),zg=_f(at),Mg=Ef(at),Vg=Tf(at),qg=If(at),Bg=Ff(at),Uo=new WeakMap;function zs(e,t,r){const n=Object.getPrototypeOf(e);let a=Uo.get(n);if(a||(a=new Set,Uo.set(n,a)),!a.has(t)){a.add(t);for(const i in r){const o=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const Ce=I("ZodType",(e,t)=>(ke.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:js(e,"input"),output:js(e,"output")}}),e.toJSONSchema=Xx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Ig(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Dg(e,r,n),e.parseAsync=async(r,n)=>Fg(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Rg(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Og(e,r,n),e.decode=(r,n)=>$g(e,r,n),e.encodeAsync=async(r,n)=>Lg(e,r,n),e.decodeAsync=async(r,n)=>zg(e,r,n),e.safeEncode=(r,n)=>Mg(e,r,n),e.safeDecode=(r,n)=>Vg(e,r,n),e.safeEncodeAsync=async(r,n)=>qg(e,r,n),e.safeDecodeAsync=async(r,n)=>Bg(e,r,n),zs(e,"ZodType",{check(...r){const n=this.def;return this.clone(cr(n,{checks:[...n.checks??[],...r.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ur(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Ry(r,n))},superRefine(r,n){return this.check(Oy(r,n))},overwrite(r){return this.check(xn(r))},optional(){return Yo(this)},exactOptional(){return wy(this)},nullable(){return Ho(this)},nullish(){return Yo(Ho(this))},nonoptional(r){return Py(this,r)},array(){return hy(this)},or(r){return Uc([this,r])},and(r){return gy(this,r)},transform(r){return Ko(this,vy(r))},default(r){return ky(this,r)},prefault(r){return Ay(this,r)},catch(r){return Ey(this,r)},pipe(r){return Ko(this,r)},readonly(){return Fy(this)},describe(r){const n=this.clone();return kn.add(n,{description:r}),n},meta(...r){if(r.length===0)return kn.get(this);const n=this.clone();return kn.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){var r;return(r=kn.get(e))==null?void 0:r.description},configurable:!0}),e)),qc=I("_ZodString",(e,t)=>{Ni.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(n,a,i)=>tg(e,n,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,zs(e,"_ZodString",{regex(...n){return this.check(Lx(...n))},includes(...n){return this.check(Vx(...n))},startsWith(...n){return this.check(qx(...n))},endsWith(...n){return this.check(Bx(...n))},min(...n){return this.check(vs(...n))},max(...n){return this.check(Oc(...n))},length(...n){return this.check($c(...n))},nonempty(...n){return this.check(vs(1,...n))},lowercase(n){return this.check(zx(n))},uppercase(n){return this.check(Mx(n))},trim(){return this.check(Zx())},normalize(...n){return this.check(Ux(...n))},toLowerCase(){return this.check(Wx())},toUpperCase(){return this.check(Yx())},slugify(){return this.check(Hx())}})}),Ug=I("ZodString",(e,t)=>{Ni.init(e,t),qc.init(e,t),e.email=r=>e.check(Rc(Bc,r)),e.url=r=>e.check(px(Wg,r)),e.jwt=r=>e.check(Ex(oy,r)),e.emoji=r=>e.check(xx(Yg,r)),e.guid=r=>e.check(qo(Zo,r)),e.uuid=r=>e.check(dx(Xn,r)),e.uuidv4=r=>e.check(mx(Xn,r)),e.uuidv6=r=>e.check(hx(Xn,r)),e.uuidv7=r=>e.check(fx(Xn,r)),e.nanoid=r=>e.check(gx(Hg,r)),e.guid=r=>e.check(qo(Zo,r)),e.cuid=r=>e.check(yx(Kg,r)),e.cuid2=r=>e.check(bx(Qg,r)),e.ulid=r=>e.check(vx(Jg,r)),e.base64=r=>e.check(Ax(sy,r)),e.base64url=r=>e.check(Px(ay,r)),e.xid=r=>e.check(jx(Gg,r)),e.ksuid=r=>e.check(wx(Xg,r)),e.ipv4=r=>e.check(Nx(ey,r)),e.ipv6=r=>e.check(Sx(ty,r)),e.cidrv4=r=>e.check(kx(ry,r)),e.cidrv6=r=>e.check(Cx(ny,r)),e.e164=r=>e.check(_x(iy,r)),e.datetime=r=>e.check(Sg(r)),e.date=r=>e.check(Cg(r)),e.time=r=>e.check(Pg(r)),e.duration=r=>e.check(Eg(r))});function T(e){return ux(Ug,e)}const je=I("ZodStringFormat",(e,t)=>{ye.init(e,t),qc.init(e,t)}),Bc=I("ZodEmail",(e,t)=>{bp.init(e,t),je.init(e,t)});function Zg(e){return Rc(Bc,e)}const Zo=I("ZodGUID",(e,t)=>{gp.init(e,t),je.init(e,t)}),Xn=I("ZodUUID",(e,t)=>{yp.init(e,t),je.init(e,t)}),Wg=I("ZodURL",(e,t)=>{vp.init(e,t),je.init(e,t)}),Yg=I("ZodEmoji",(e,t)=>{jp.init(e,t),je.init(e,t)}),Hg=I("ZodNanoID",(e,t)=>{wp.init(e,t),je.init(e,t)}),Kg=I("ZodCUID",(e,t)=>{Np.init(e,t),je.init(e,t)}),Qg=I("ZodCUID2",(e,t)=>{Sp.init(e,t),je.init(e,t)}),Jg=I("ZodULID",(e,t)=>{kp.init(e,t),je.init(e,t)}),Gg=I("ZodXID",(e,t)=>{Cp.init(e,t),je.init(e,t)}),Xg=I("ZodKSUID",(e,t)=>{Ap.init(e,t),je.init(e,t)}),ey=I("ZodIPv4",(e,t)=>{Ip.init(e,t),je.init(e,t)}),ty=I("ZodIPv6",(e,t)=>{Fp.init(e,t),je.init(e,t)}),ry=I("ZodCIDRv4",(e,t)=>{Dp.init(e,t),je.init(e,t)}),ny=I("ZodCIDRv6",(e,t)=>{Rp.init(e,t),je.init(e,t)}),sy=I("ZodBase64",(e,t)=>{Op.init(e,t),je.init(e,t)}),ay=I("ZodBase64URL",(e,t)=>{Lp.init(e,t),je.init(e,t)}),iy=I("ZodE164",(e,t)=>{zp.init(e,t),je.init(e,t)}),oy=I("ZodJWT",(e,t)=>{Vp.init(e,t),je.init(e,t)}),ly=I("ZodBoolean",(e,t)=>{qp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>rg(e,r,n)});function Zr(e){return Rx(ly,e)}const cy=I("ZodUnknown",(e,t)=>{Bp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>sg()});function Wo(){return Ox(cy)}const uy=I("ZodNever",(e,t)=>{Up.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ng(e,r,n)});function dy(e){return $x(uy,e)}const my=I("ZodArray",(e,t)=>{Zp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>cg(e,r,n,a),e.element=t.element,zs(e,"ZodArray",{min(r,n){return this.check(vs(r,n))},nonempty(r){return this.check(vs(1,r))},max(r,n){return this.check(Oc(r,n))},length(r,n){return this.check($c(r,n))},unwrap(){return this.element}})});function hy(e,t){return Kx(my,e,t)}const fy=I("ZodObject",(e,t)=>{Yp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ug(e,r,n,a),me(e,"shape",()=>t.shape),zs(e,"ZodObject",{keyof(){return Ms(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Wo()})},loose(){return this.clone({...this._zod.def,catchall:Wo()})},strict(){return this.clone({...this._zod.def,catchall:dy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return ff(this,r)},safeExtend(r){return pf(this,r)},merge(r){return xf(this,r)},pick(r){return mf(this,r)},omit(r){return hf(this,r)},partial(...r){return gf(Zc,this,r[0])},required(...r){return yf(Wc,this,r[0])}})});function Bt(e,t){const r={type:"object",shape:e??{},...G(t)};return new fy(r)}const py=I("ZodUnion",(e,t)=>{Hp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dg(e,r,n,a),e.options=t.options});function Uc(e,t){return new py({type:"union",options:e,...G(t)})}const xy=I("ZodIntersection",(e,t)=>{Kp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>mg(e,r,n,a)});function gy(e,t){return new xy({type:"intersection",left:e,right:t})}const La=I("ZodEnum",(e,t)=>{Qp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(n,a,i)=>ag(e,n,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,a)=>{const i={};for(const o of n)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new La({...t,checks:[],...G(a),entries:i})},e.exclude=(n,a)=>{const i={...t.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new La({...t,checks:[],...G(a),entries:i})}});function Ms(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new La({type:"enum",entries:r,...G(t)})}const yy=I("ZodLiteral",(e,t)=>{Jp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ig(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Gs(e,t){return new yy({type:"literal",values:Array.isArray(e)?e:[e],...G(t)})}const by=I("ZodTransform",(e,t)=>{Gp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>lg(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new wc(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Tn(i,r.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(Tn(o))}};const a=t.transform(r.value,r);return a instanceof Promise?a.then(i=>(r.value=i,r.fallback=!0,r)):(r.value=a,r.fallback=!0,r)}});function vy(e){return new by({type:"transform",transform:e})}const Zc=I("ZodOptional",(e,t)=>{Dc.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Yo(e){return new Zc({type:"optional",innerType:e})}const jy=I("ZodExactOptional",(e,t)=>{Xp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function wy(e){return new jy({type:"optional",innerType:e})}const Ny=I("ZodNullable",(e,t)=>{ex.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>hg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Ho(e){return new Ny({type:"nullable",innerType:e})}const Sy=I("ZodDefault",(e,t)=>{tx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>pg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ky(e,t){return new Sy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():kc(t)}})}const Cy=I("ZodPrefault",(e,t)=>{rx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>xg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Ay(e,t){return new Cy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():kc(t)}})}const Wc=I("ZodNonOptional",(e,t)=>{nx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>fg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Py(e,t){return new Wc({type:"nonoptional",innerType:e,...G(t)})}const _y=I("ZodCatch",(e,t)=>{sx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>gg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ey(e,t){return new _y({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ty=I("ZodPipe",(e,t)=>{ax.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>yg(e,r,n,a),e.in=t.in,e.out=t.out});function Ko(e,t){return new Ty({type:"pipe",in:e,out:t})}const Iy=I("ZodReadonly",(e,t)=>{ix.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>bg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Fy(e){return new Iy({type:"readonly",innerType:e})}const Dy=I("ZodCustom",(e,t)=>{ox.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>og(e,r)});function Ry(e,t={}){return Qx(Dy,e,t)}function Oy(e,t){return Jx(e,t)}const Vr={custom:"custom"};function Si(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[t.length-1][0]}`.toUpperCase()}function Ct(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?e.firstName:`${e.firstName} ${e.lastName}`.trim()}function dr(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function Dr(e){const t=e.replace(/\D/g,""),r=t.length===11&&t.startsWith("1")?t.slice(1):t;return r.length!==10?e:`+1 (${r.slice(0,3)}) ${r.slice(3,6)}-${r.slice(6)}`}function $y(e,t){const r=t.trim().toLowerCase();if(!r)return!0;const n=Ct(e).toLowerCase(),a=e.email.toLowerCase(),i=e.idNumber.replace(/\D/g,"");return n.includes(r)||a.includes(r)||i.includes(r.replace(/\D/g,""))||dr(e.idNumber).toLowerCase().includes(r)}const Yc=["LLP","LLC","Corporation","S-Corp","Partnership"],Hc=["Sole Proprietorship"],ki=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"],za=10,Kc=Bt({accountType:Ms(["Business","Individual"]),businessName:T().min(1,"Business name is required"),tradeName:T(),ein:T().min(1,"EIN is required").refine(e=>e.replace(/\D/g,"").length===9,"EIN must be 9 digits"),entityType:T().min(1,"Entity type is required"),email:Zg("Enter a valid email"),countryCode:T().min(1),phoneNumber:T().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===za,`Phone number must be ${za} digits`),address1:T().min(1,"Address is required"),address2:T(),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required")});function Ly(e){const t=e.replace(/\D/g,"");return t.length===12&&t.startsWith("91")?{countryCode:"+91",national:t.slice(2)}:t.length===11&&t.startsWith("1")?{countryCode:"+1",national:t.slice(1)}:t.length===10?{countryCode:"+1",national:t}:{countryCode:"+1",national:t.slice(-za)}}function Qo(e){const{countryCode:t,national:r}=Ly(e.phoneNumber),n=e.accountType==="Individual"?`${e.firstName} ${e.lastName}`.trim():e.firstName;return{accountType:e.accountType==="Individual"?"Individual":"Business",businessName:n,tradeName:e.tradeName??"",ein:dr(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:r,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function zy(e){const t=e.businessName.trim().split(/\s+/),r=t[0]??e.businessName,n=e.accountType==="Individual"?t.slice(1).join(" ")||r:e.businessName.trim();return{firstName:r,lastName:n}}function Qc(e){const{firstName:t,lastName:r}=zy(e);return{accountType:e.accountType,firstName:t,lastName:r,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName,phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function My(e){const{idNumber:t,...r}=Qc(e);return r}function Lr(e,t){const r=e==null?void 0:e.from;return r&&r.startsWith("/")&&!r.startsWith("//")?r:t}function Vy(){var E,P,_,F,Y,M,se,q,K,te,W;const e=Se(),t=ge(),r=st(),{data:n=[]}=Ee({queryKey:["entities","mine"],queryFn:ac}),[a,i]=w.useState(null),[o,l]=w.useState(!1),c=n.length===0,u=c?"/create-entity":"/dashboard",d=Lr(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:y,setValue:p,formState:{errors:x}}=Nt({resolver:kt(Kc),defaultValues:{accountType:"Individual",businessName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),b=y("accountType"),j=y("entityType"),N=b==="Individual"?Hc:Yc;w.useEffect(()=>{N.includes(j)||p("entityType",b==="Individual"?"Sole Proprietorship":"LLP")},[b,j,N,p]);const k=f(async ne=>{i(null),l(!0);try{await Nh(Qc(ne)),await r.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(xe){i(et(xe,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:k,noValidate:!0,className:"space-y-8",children:[a?s.jsx(qt,{message:a}):null,s.jsx(lr,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(cn,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:b==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(E=x.businessName)==null?void 0:E.message,...h("businessName")}),s.jsx(de,{label:"Trade Name, if any",placeholder:"Enter",error:(P=x.tradeName)==null?void 0:P.message,...h("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"EIN",required:!0,placeholder:"**-*******",maxLength:10,error:(_=x.ein)==null?void 0:_.message,...h("ein")}),s.jsx(wt,{label:"Entity Type",required:!0,error:(F=x.entityType)==null?void 0:F.message,...h("entityType"),children:N.map(ne=>s.jsx("option",{value:ne,children:ne},ne))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(Y=x.email)==null?void 0:Y.message,...h("email")}),s.jsxs("div",{children:[s.jsx(cn,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...h("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${x.phoneNumber?"border-red-300":"border-slate-200"}`,...h("phoneNumber")})]}),x.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(de,{label:"Address Line 1",required:!0,error:(M=x.address1)==null?void 0:M.message,...h("address1")}),s.jsx(de,{label:"Address Line 2",error:(se=x.address2)==null?void 0:se.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"City",required:!0,error:(q=x.city)==null?void 0:q.message,...h("city")}),s.jsxs(wt,{label:"State",required:!0,error:(K=x.state)==null?void 0:K.message,...h("state"),children:[s.jsx("option",{value:"",children:"Select"}),ki.map(ne=>s.jsx("option",{value:ne,children:ne},ne))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"ZIP Code",required:!0,error:(te=x.zipCode)==null?void 0:te.message,...h("zipCode")}),s.jsxs(wt,{label:"Country",required:!0,error:(W=x.country)==null?void 0:W.message,...h("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})}),s.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:m,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save"})]})]})}function Ci(){const e=Se(),t=ge(),r=Lr(t.state,"/create-entity");return s.jsxs("div",{className:"relative min-h-full bg-slate-100/80 px-4 py-8 sm:px-6 sm:py-10",children:[s.jsxs("button",{type:"button",onClick:()=>e(r),className:"absolute left-4 top-4 inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white/80 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 sm:left-6 sm:top-6",children:[s.jsx(qy,{}),"Back"]}),s.jsx("div",{className:"mx-auto mt-8 max-w-3xl rounded-2xl border border-slate-200/80 bg-white p-6 shadow-sm sm:mt-4 sm:p-8",children:s.jsx(Vy,{})})]})}function qy(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function By(e,t){const r=new URLSearchParams({entityId:String(e)});return t!==void 0&&r.set("taxYear",String(t)),he(`/portal/dashboard?${r}`)}function Uy(e,t,r){const n=new URLSearchParams({entityId:String(e),category:t,taxYear:String(r)});return he(`/portal/dashboard/summary?${n}`)}function Zy(e,t,r){const n=new URLSearchParams({entityId:String(e),month:String(t)});return r!==void 0&&n.set("year",String(r)),he(`/portal/dashboard/monthly-overview?${n}`)}function Wy({entityId:e,search:t,taxYear:r,status:n,page:a=1,pageSize:i=20}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),r&&o.set("taxYear",r),n&&n!=="all"&&o.set("status",n),he(`/portal/dashboard/payments?${o}`)}function Jo({entityCount:e}){const t=Se(),{enabledPayments:r}=pn();return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(Xs,{}),"Add Federal Payments"]}),r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(Xs,{}),"Add State Payment"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(Xs,{}),"Add Local Payment",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-2 rounded-lg border border-dashed border-emerald-400 bg-white px-4 py-2.5 text-sm font-medium text-slate-700 shadow-sm transition hover:bg-emerald-50/50",children:[s.jsx(Yy,{}),"Add Entity ",e>0?`(${e})`:""]})})]})}function Xs(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Yy(){return s.jsx("svg",{className:"h-4 w-4 text-emerald-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.356 0-4.564-.64-6.374-1.766z"})})}function Hy({title:e,description:t,buttonLabel:r,onAdd:n,comingSoon:a=!1}){return s.jsxs("article",{className:"flex flex-col rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"mx-auto mt-4 max-w-xs text-sm leading-relaxed text-slate-500",children:t}),a?s.jsx("span",{className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-5 py-2.5 text-sm font-semibold text-slate-500",children:"Coming Soon"}):s.jsxs("button",{type:"button",onClick:n,className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg bg-gov-600 px-5 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(Ky,{}),r]})]})}function Ky(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Ai({label:e="Loading…"}){return s.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-[inherit] bg-white/75","aria-live":"polite","aria-busy":"true",children:s.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-slate-500",children:[s.jsx(Qy,{}),s.jsx("span",{children:e})]})})}function Qy(){return s.jsxs("svg",{className:"h-5 w-5 animate-spin text-gov-600",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}const Jy={Draft:"Draft"};function Jc(e){switch((e??Jy.Draft).trim().toLowerCase()){case"draft":case"pending":return"drafts";case"scheduled":return"scheduled";case"processing":return"submitted";case"rejected":return"rejected";case"accepted":return"paid";default:return"drafts"}}function Vs(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function Gy(e){const t=e.submitted+e.paid+e.scheduled+e.failed;return t<=0?[{color:"bg-emerald-400",width:0},{color:"bg-orange-400",width:0},{color:"bg-amber-400",width:0},{color:"bg-red-400",width:0}]:[{color:"bg-emerald-400",width:e.paid/t*100},{color:"bg-orange-400",width:e.submitted/t*100},{color:"bg-amber-400",width:e.scheduled/t*100},{color:"bg-red-400",width:e.failed/t*100}]}const Gc="drafts";function jt(){return Pi(Gc)}function Pi(e){return`/payments?tab=${e}`}function Xy(e){return e==="failed"?"rejected":e}const eb=["January","February","March","April","May","June","July","August","September","October","November","December"];function tb({entityId:e,initialOverview:t,isDashboardLoading:r=!1}){const n=Se(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=w.useState(null);w.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=Ee({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>Zy(e,i,a),enabled:e!==null&&i!==null,placeholderData:p=>p}),m={submitted:0,paid:0,scheduled:0,failed:0},h=c?t??m:u??m,f=r||d&&!c,y=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:nb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:sb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:ab,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Failed",amount:h.failed,icon:ib,iconClassName:"rounded-full bg-red-50 text-red-500",amountClassName:"text-red-500"}];return s.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?s.jsx(Ai,{}):null,s.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-4",children:[s.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-slate-500",children:"Overview of Month"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:l,onChange:p=>o(Number(p.target.value)),disabled:f,className:"appearance-none rounded-full border border-gov-600 bg-white py-1.5 pl-4 pr-8 text-sm font-medium text-gov-600 focus:border-gov-600 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:eb.map((p,x)=>s.jsx("option",{value:x+1,children:p},p))}),s.jsx(rb,{className:"pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gov-600"})]})]}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-4",children:y.map(p=>{const x=p.icon;return s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center ${p.iconClassName}`,children:s.jsx(x,{})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs leading-4 text-slate-500",children:p.label}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("p",{className:`text-xl font-bold leading-7 ${p.amountClassName}`,children:Vs(p.amount)}),s.jsx("button",{type:"button",onClick:()=>n(Pi(Xy(p.key))),className:"text-sm font-medium text-gov-600 underline decoration-gov-600 underline-offset-2 hover:text-gov-700",children:"View Details"})]})]})]},p.key)})})]})}function rb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function nb(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 14.25v-1.5M11.25 13.5h1.5"})]})}function sb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function ab(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})}function ib(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}function Go(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function ob(e){return{id:e.id,jurisdiction:e.jurisdiction,period:e.period,amount:e.amount,paymentDate:e.paymentDate,status:e.status,statusLabel:e.statusLabel,formType:e.formType,category:e.category}}function Xo(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const lb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],el={total:0,items:[]};function cb({label:e,status:t}){const r={scheduled:"bg-amber-50 text-amber-700",paid:"bg-emerald-50 text-emerald-700",submitted:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-600"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r[t]}`,children:e})}function ub({entityId:e,initialPayments:t,isDashboardLoading:r=!1}){const[n,a]=w.useState(""),[i,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState("all");w.useEffect(()=>{const j=window.setTimeout(()=>o(n),300);return()=>window.clearTimeout(j)},[n]);const m=!!i||!!l||u!=="all",{data:h,isFetching:f}=Ee({queryKey:["dashboard","payments",e,i,l,u],queryFn:()=>Wy({entityId:e,search:i||void 0,taxYear:l||void 0,status:u}),enabled:e!==null&&m,placeholderData:j=>j}),y=m?h??t??el:t??el,p=w.useMemo(()=>y.items.map(ob),[y.items]),x=w.useMemo(()=>{const j=new Date().getFullYear();return[j,j-1,j-2].map(String)},[]),b=r||m&&f;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[b?s.jsx(Ai,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(mb,{})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-bold text-slate-900",children:"My Payments"}),s.jsxs("p",{className:"text-xs text-slate-500",children:[y.total," total payments"]})]})]})}),s.jsx("div",{className:"border-b border-slate-200 p-6",children:s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"payment-search",className:"mb-1.5 block text-sm text-slate-600",children:"Search by State/Form Type"}),s.jsxs("div",{className:"relative",children:[s.jsx(db,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),s.jsx("input",{id:"payment-search",type:"text",value:n,onChange:j=>a(j.target.value),placeholder:"All",disabled:r,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"tax-period-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Tax Period"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{id:"tax-period-filter",value:l,onChange:j=>c(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[s.jsx("option",{value:"",children:"Select Year"}),x.map(j=>s.jsx("option",{value:j,children:j},j))]}),s.jsx(tl,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{id:"status-filter",value:u,onChange:j=>d(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:lb.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))}),s.jsx(tl,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"ID"}),s.jsx("th",{className:"px-6 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-6 py-3",children:"Period"}),s.jsx("th",{className:"px-6 py-3",children:"Amount"}),s.jsx("th",{className:"px-6 py-3",children:"Payment"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Form Type"}),s.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),s.jsx("tbody",{children:!b&&p.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:m?"No payments match your filters.":"No payments yet."})}):p.map((j,N)=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsxs("td",{className:"px-6 py-4 font-medium text-slate-900",children:["#",N+1]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Vs(j.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(cb,{label:j.statusLabel,status:j.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"})]})})]},`${j.category}-${j.id}`))})]})})]})}function db({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})})}function tl({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function mb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function ea({entityId:e,category:t,title:r,subtitlePrefix:n,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:u=!1}){const[d,m]=w.useState(a);if(w.useEffect(()=>{m(a)},[e,a]),u)return s.jsxs("article",{className:"flex min-h-[220px] flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:n})]}),s.jsx("div",{className:"flex flex-1 items-center justify-center",children:s.jsx("span",{className:"rounded-full border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-500",children:"Coming Soon"})})]});const h=d===a,{data:f,isFetching:y}=Ee({queryKey:["dashboard","summary",e,t,d],queryFn:()=>Uy(e,t,d),enabled:e!==null&&!h,placeholderData:j=>j}),p=h?o?Go(o):Xo():f?Go(f):Xo(),x=Gy(p),b=l||y&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[b?s.jsx(Ai,{}):null,s.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[n," (",p.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:d,onChange:j=>m(Number(j.target.value)),disabled:b,className:"appearance-none rounded-lg border border-slate-200 bg-white py-1.5 pl-3 pr-8 text-xs font-medium text-slate-700 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(j=>s.jsxs("option",{value:j,children:["TY ",j]},j))}),s.jsx(hb,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"})]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:c.map(j=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${j.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:j.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Vs(p[j.key])})]},j.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:x.map((j,N)=>j.width>0?s.jsx("span",{className:`${j.color} h-full`,style:{width:`${j.width}%`}},N):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function hb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const fb={federal:"Schedule federal tax deposits directly to the IRS — EFTPS payments, 941, 940, and more.",state:"Submit state tax remittances to the relevant state authority on time, every time.",local:"Local tax payment support is coming soon. Stay tuned for updates."},pb=[{key:"federal",title:"Add Your First Federal Payment",buttonLabel:"Add Federal Payment"},{key:"state",title:"Add Your First State Payment",buttonLabel:"Add State Payment"},{key:"local",title:"Add Your First Local Payment",buttonLabel:"Add Local Payments"}],Qt=new Date().getFullYear(),ta=[Qt,Qt-1,Qt-2],xb=[{label:"Submitted to IRS",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],gb=[{label:"Submitted to State",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],yb=[{label:"Submitted",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}];function _i(){const e=Se(),{entities:t,selectedEntity:r,enabledPayments:n}=pn(),a=(r==null?void 0:r.entityId)??null,{data:i,isLoading:o}=Ee({queryKey:["dashboard",a,Qt],queryFn:()=>By(a,Qt),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(Jo,{entityCount:t.length}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:pb.filter(l=>l.key==="local"||n.includes(l.key)).map(l=>s.jsx(Hy,{title:l.title,description:fb[l.key],buttonLabel:l.buttonLabel,onAdd:l.key==="federal"?()=>e("/payments/federal/new",{state:{from:"/dashboard"}}):l.key==="state"?()=>e("/payments/state/new",{state:{from:"/dashboard",resetDraft:!0}}):void 0,comingSoon:l.key==="local"},l.key))})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(Jo,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[n.includes("federal")&&s.jsx(ea,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:Qt,taxYearOptions:ta,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:xb}),n.includes("state")&&s.jsx(ea,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:Qt,taxYearOptions:ta,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:gb}),s.jsx(ea,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:Qt,taxYearOptions:ta,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:yb,comingSoon:!0})]}),s.jsx(tb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(ub,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}function Ei(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=pn(),n=Se(),[a,i]=w.useState(""),o=e.filter(c=>$y(c,a)),l=c=>{r(c.entityId),n("/dashboard",{replace:!0})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("h2",{className:"text-base font-semibold text-slate-800",children:["Organizations (",e.length,")"]}),s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex items-center gap-1.5 rounded-lg border border-dashed border-emerald-400 bg-white px-3 py-2 text-sm font-medium text-slate-700 shadow-sm transition hover:bg-emerald-50/50",children:[s.jsx(vb,{}),"Add Organization"]})]}),e.length>4&&s.jsxs("div",{className:"relative",children:[s.jsx(jb,{}),s.jsx("input",{type:"search",value:a,onChange:c=>i(c.target.value),placeholder:"Search by name, email, or EIN…",className:"w-full rounded-lg border border-slate-200 bg-white py-2 pl-9 pr-4 text-sm text-slate-700 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),o.length===0?s.jsx("p",{className:"py-8 text-center text-sm text-slate-400",children:"No organizations match your search."}):s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:o.map(c=>s.jsx(bb,{entity:c,isSelected:c.entityId===(t==null?void 0:t.entityId),onSelect:()=>l(c)},c.entityId))})]})}function bb({entity:e,isSelected:t,onSelect:r}){const n=Ct(e),a=Si(n);return s.jsxs("button",{type:"button",onClick:r,className:["flex w-full items-center gap-3 rounded-xl border bg-white p-4 text-left shadow-sm transition hover:shadow-md",t?"border-gov-400 ring-1 ring-gov-400":"border-slate-200 hover:border-slate-300"].join(" "),children:[s.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-gov-100 text-sm font-semibold text-gov-700",children:a}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-semibold text-slate-800",children:n}),s.jsx("p",{className:"truncate text-xs text-slate-500",children:e.entityType}),s.jsx("p",{className:"truncate text-xs text-slate-400",children:dr(e.idNumber)})]}),t&&s.jsx(wb,{})]})}function vb(){return s.jsx("svg",{className:"h-4 w-4 text-emerald-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function jb(){return s.jsx("svg",{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-4.35-4.35m0 0A7.5 7.5 0 1116.65 16.65z"})})}function wb(){return s.jsx("svg",{className:"h-4 w-4 shrink-0 text-gov-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function Nb(e){return he(`/portal/federal-payments?entityId=${e}`)}function Ti(e){return he(`/portal/federal-payments/${e}`)}function Sb(e){return he(`/portal/federal-payments/form-types?entityId=${e}`)}function kb(e){const t=new URLSearchParams({formType:e});return he(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Ii(e){return he("/portal/federal-payments",{method:"POST",body:e})}function Fi(e,t){return he(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function Cb(e){return he(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function Ab(e){return he(`/portal/state-payments?entityId=${e}`)}function Pb(e){return he("/portal/state-payments",{method:"POST",body:e})}function _b(e,t){return he(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function Xc(e){return he(`/portal/state-payments/${e}/submit`,{method:"POST"})}function Eb({actionType:e,onView:t,onEdit:r,onSubmit:n,isSubmitting:a=!1}){return e==="draft-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",onClick:r,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"}),s.jsx("button",{type:"button",onClick:n,disabled:a,className:"rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:opacity-60",children:a?"Submitting…":"Submit"})]}):e==="view-pdf"?s.jsx("button",{type:"button",className:"rounded-lg border border-gov-200 bg-gov-50 px-4 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100",children:"View PDF"}):e==="rejected-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-semibold text-red-600 hover:bg-red-100",children:"Re-Submit"})]}):s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})}function eu(e){const t=/^(\d{4})-Q([1-4])$/.exec(e);if(t)return`Q${t[2]} ${t[1]}`;if(e.length!==6)return e;const r=e.slice(0,4),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(n)||n<1||n>12?e:`Q${Math.ceil(n/3)} ${r}`}function Tb(e){return{id:e.federalPaymentId,category:"federal",referenceNo:`FED-${e.federalPaymentId}`,jurisdiction:"IRS - Federal",period:eu(e.taxPeriod),amount:e.paymentAmount,paymentDate:e.settlementDate,status:e.status,reason:e.reason,tab:Jc(e.status)}}function Ib(e){return{id:e.statePaymentDetailId,category:"state",referenceNo:`ST-${e.statePaymentDetailId}`,jurisdiction:`${e.state} (State)`,period:eu(e.taxPeriod),amount:e.taxAmount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Jc(e.status)}}function Fb(e,t,r){return e.filter(n=>n.tab!==t?!1:r==="all"?!0:n.category===r)}function Db(e){return e.reduce((t,r)=>(t[r.tab]+=1,t),{drafts:0,scheduled:0,submitted:0,rejected:0,paid:0})}function Rb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsx("path",{d:"M9.375 1.25H3.75C3.41848 1.25 3.10054 1.3817 2.86612 1.61612C2.6317 1.85054 2.5 2.16848 2.5 2.5V12.5C2.5 12.8315 2.6317 13.1495 2.86612 13.3839C3.10054 13.6183 3.41848 13.75 3.75 13.75H11.25C11.5815 13.75 11.8995 13.6183 12.1339 13.3839C12.3683 13.1495 12.5 12.8315 12.5 12.5V4.375L9.375 1.25Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M8.75 1.25V3.75C8.75 4.08152 8.8817 4.39946 9.11612 4.63388C9.35054 4.8683 9.66848 5 10 5H12.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.25 5.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 8.125H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 10.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ob({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#scheduled-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 3.75V7.5L10 8.75",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"scheduled-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function $b({className:e,...t}){return s.jsx("svg",{width:"12",height:"10",viewBox:"0 0 12 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:s.jsx("path",{d:"M0 10V0L11.875 5L0 10ZM1.25 8.125L8.65625 5L1.25 1.875V4.0625L5 5L1.25 5.9375V8.125Z",fill:"currentColor"})})}function Lb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#rejected-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 5V7.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 10H7.50625",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"rejected-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function zb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#paid-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.625 7.5L6.875 8.75L9.375 6.25",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"paid-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}const tu=[{key:"drafts",label:"DRAFTS",Icon:Rb,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:Ob,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:$b,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:Lb,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:zb,iconClassName:"text-green-500"}],Mb={drafts:{columns:["ID","Jurisdiction / Type","Period","Amount","Payment Date","Actions"],emptyMessage:"No draft payments to display yet.",actionType:"draft-actions"},scheduled:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Scheduled Date","Actions"],emptyMessage:"No scheduled payments to display yet.",actionType:"view-pdf"},submitted:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Submitted Date","Actions"],emptyMessage:"No submitted to fed/state payments to display yet.",actionType:"view-link"},rejected:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Failed Date","Reason","Actions"],emptyMessage:"No rejected payments to display yet.",actionType:"rejected-actions"},paid:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Actions"],emptyMessage:"No paid payments to display yet.",actionType:"view-link"}};function rl(e){return e!==null&&tu.some(t=>t.key===e)}function Di({paymentsMode:e="all"}){const t=Se(),r=st(),[n]=bm(),{selectedEntity:a}=ft(),i=(a==null?void 0:a.entityId)??null,o=n.get("tab"),[l,c]=w.useState(rl(o)?o:Gc),[u,d]=w.useState(e==="all"?"all":e),[m,h]=w.useState(null);w.useEffect(()=>{rl(o)&&c(o)},[o]);const f=Mb[l],{data:y=[],isLoading:p}=Ee({queryKey:["remittance-payments",i,e],queryFn:async()=>{const[P,_]=await Promise.all([e!=="state"?Nb(i):Promise.resolve([]),e!=="federal"?Ab(i):Promise.resolve([])]);return[...P.map(Tb),..._.map(Ib)]},enabled:i!==null}),x=w.useMemo(()=>Db(y),[y]),b=w.useMemo(()=>Fb(y,l,u),[y,l,u]),j=ch({mutationFn:async P=>{if(P.category==="federal"){await Cb(P.id);return}await Xc(P.id)},onSuccess:async()=>{await r.invalidateQueries({queryKey:["remittance-payments"]}),await r.invalidateQueries({queryKey:["dashboard"]}),await r.invalidateQueries({queryKey:["federal-payments"]}),await r.invalidateQueries({queryKey:["state-payments"]})},onError:()=>h(null),onSettled:()=>h(null)}),N=P=>{h(`${P.category}-${P.id}`),j.mutate(P)},k=P=>{t(`/payments/federal/${P.id}/view`)},E=P=>{t(`/payments/federal/${P.id}/edit`)};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=="state"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/payments"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(ra,{}),"Add Federal Payment"]}),e!=="federal"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/payments",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(ra,{}),"Add State Payment"]}),e==="all"&&s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(ra,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:tu.map(P=>{const _=l===P.key,F=P.Icon;return s.jsxs("button",{type:"button",onClick:()=>{c(P.key),t(Pi(P.key),{replace:!0})},className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${_?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(F,{className:`shrink-0 ${P.iconClassName}`}),P.label," (",x[P.key],")"]},P.key)})}),s.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[s.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),s.jsxs("select",{value:u,onChange:P=>d(P.target.value),className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",children:[s.jsx("option",{value:"all",children:"All"}),s.jsx("option",{value:"federal",children:"Federal"}),s.jsx("option",{value:"state",children:"State"}),s.jsx("option",{value:"local",disabled:!0,children:"Local (Coming Soon)"})]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:f.columns.map(P=>s.jsx("th",{className:"px-6 py-3",children:P},P))})}),s.jsx("tbody",{children:p?s.jsx("tr",{children:s.jsx("td",{colSpan:f.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):b.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:f.columns.length,className:"px-6 py-12 text-center text-slate-500",children:f.emptyMessage})}):b.map(P=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:l==="drafts"?`#${P.id}`:P.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Vs(P.amount)}),l!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.paymentDate}):null,l==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(Eb,{actionType:f.actionType,onView:()=>{P.category==="federal"&&k(P)},onEdit:()=>{P.category==="federal"&&E(P)},onSubmit:()=>N(P),isSubmitting:m===`${P.category}-${P.id}`})})]},`${P.category}-${P.id}`))})]})})]})]})}function ra(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function qn(e){return he(`/portal/bank-accounts?entityId=${e}`)}function Vb(e){return he("/portal/bank-accounts",{method:"POST",body:e})}function ru(e,t){return he(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function vr({title:e,children:t,isFirst:r=!1,headerAction:n}){return s.jsxs("section",{className:r?"":"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),n]}),t]})}const un=17,nu=9;function Wr(e,t){return e.replace(/\D/g,"").slice(0,t)}const su=["Checking","Savings"],qb=Bt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${un} digits`),confirmAccountNumber:T().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${un} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ms(su,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")}).refine(e=>e.accountNumber===e.confirmAccountNumber,{message:"Account numbers do not match",path:["confirmAccountNumber"]});function Bb({entityId:e,onCancel:t,onSuccess:r}){const n=st(),{showSuccess:a,showError:i}=Es(),[o,l]=w.useState(null),[c,u]=w.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=Nt({resolver:kt(qb),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async y=>{l(null),u(!0);try{const p=await Vb({entityId:e,bankName:y.bankName.trim(),accountNumber:y.accountNumber,routingNumber:y.routingNumber,accountType:y.accountType});await n.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),r(p.bankAccountDetailId)}catch(p){const x=et(p,"Unable to save bank account.");l(x),i("Action Not Completed",x)}finally{u(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:y=>{y.preventDefault(),y.stopPropagation(),f(y)},className:"space-y-6",children:[s.jsxs(lr,{step:2,title:"Add Bank Account Manually",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Bank Account"}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(De,{name:"accountNumber",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:x=>y.onChange(Wr(x.target.value,un)),onBlur:y.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),s.jsx(De,{name:"confirmAccountNumber",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:x=>y.onChange(Wr(x.target.value,un)),onBlur:y.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),s.jsx(De,{name:"routingNumber",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:x=>y.onChange(Wr(x.target.value,nu)),onBlur:y.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),s.jsx(De,{name:"accountType",control:d,render:({field:y})=>{var p;return s.jsx(wt,{label:"Account Type",required:!0,value:y.value,onChange:y.onChange,onBlur:y.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:su.map(x=>s.jsx("option",{value:x,children:x},x))})}})]}),s.jsx(De,{name:"bankName",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:y.value,onChange:y.onChange,onBlur:y.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?s.jsx(qt,{message:o}):null,s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx("button",{type:"button",onClick:t,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"button",disabled:c,onClick:()=>void f(),className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:c?"Saving…":"Save"})]})]})}function au({open:e,entityId:t,onClose:r,onAccountAdded:n}){const[a,i]=w.useState("choose");if(w.useEffect(()=>{e||i("choose")},[e]),w.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,r]),!e)return null;const o=a==="manual";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"add-bank-account-title",className:`relative w-full rounded-3xl bg-white p-8 shadow-xl ${o?"max-w-2xl":"max-w-[420px]"}`,children:o&&t?s.jsx(Bb,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{n==null||n(l),r()}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:"1"}),s.jsx("h2",{id:"add-bank-account-title",className:"text-sm font-medium uppercase tracking-[0.2em] text-slate-400",children:"Add Bank Account"})]}),s.jsx("div",{className:"my-6 h-px bg-slate-200"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("button",{type:"button",onClick:()=>i("manual"),disabled:!t,className:"flex w-full items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gov-600 text-white",children:s.jsx(Ub,{className:"h-5 w-5"})}),s.jsx("span",{className:"text-base font-semibold text-slate-900",children:"Add Manually"})]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"flex w-full cursor-not-allowed items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-slate-200 bg-white",children:s.jsx(Zb,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function Ub({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 7.5h10.5M6.75 12h10.5m-10.5 4.5h10.5M3.75 6.75A2.25 2.25 0 016 3.75h12A2.25 2.25 0 0120.25 6.75v10.5A2.25 2.25 0 0118 21H6A2.25 2.25 0 013.75 18.75V6.75z"})})}function Zb({className:e}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",fill:"#111827",opacity:"0.35"})]})}const Wb=12,Yb=["January","February","March","April","May","June","July","August","September","October","November","December"];function ir(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function ws(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const r=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(r,n,a);return i.getFullYear()!==r||i.getMonth()!==n||i.getDate()!==a?null:i}function qs(e=new Date){const t=new Date(e);return e.getHours()>=Wb&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),ir(t)}function iu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),ir(t)}function Hb(e=18,t=new Date){const r=new Date(t);return r.setFullYear(r.getFullYear()-e),r.setHours(0,0,0,0),ir(r)}function Kb(e,t,r=new Date){const n=ws(e);if(!n)return!1;const a=new Date(r);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),n.setHours(0,0,0,0),n<=a}function Qb(e){const t=e.getDay();return t!==0&&t!==6}function Ma(e,t=new Date){if(!Qb(e))return!1;const r=ir(e);return r>=qs(t)&&r<=iu(t)}function ou(e,t=new Date){const r=ws(e);return r?Ma(r,t):!1}function Jb(e,t){return`${Yb[t]} ${e}`}function Gb(e,t){const r=new Date(e,t,1),n=new Date(e,t+1,0).getDate(),a=r.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=n;o+=1)i.push(new Date(e,t,o));return i}function nl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Bn(e){const t=Number.parseFloat(e);return!e||Number.isNaN(t)?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(t)}function lu({label:e,required:t=!1,htmlFor:r,info:n}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 flex items-center gap-1.5 text-sm text-slate-600",children:[s.jsxs("span",{children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}),n?s.jsx("span",{title:n,className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-slate-300 text-[10px] font-semibold leading-none text-slate-400","aria-label":n,children:"i"}):null]})}function Z({label:e,required:t,error:r,info:n,children:a}){return s.jsxs("div",{children:[s.jsx(lu,{label:e,required:t,info:n}),a,r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}const cu=e=>`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${e?"border-red-300":"border-slate-200"}`;function J(e,t=!1){return t?`block w-full cursor-default rounded-lg border bg-[#F9FAFB] px-3 py-2.5 text-sm text-slate-700 focus:outline-none ${e?"border-red-300":"border-[#E5E7EB]"}`:cu(e)}function Yr(e){return`${cu(e)} appearance-none`}function Br({className:e}){return s.jsx("svg",{className:e??"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function An({children:e}){return s.jsx("div",{className:"relative",children:e})}function uu({value:e,onChange:t,entityId:r,entityType:n="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[u,d]=w.useState(!1),[m,h]=w.useState(!1),f=w.useRef(null),y=a.find(x=>String(x.bankAccountDetailId)===e);w.useEffect(()=>{if(!u)return;const x=b=>{var j;(j=f.current)!=null&&j.contains(b.target)||d(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[u]);const p=x=>{t(String(x)),h(!1),d(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,className:"relative",children:[s.jsx(lu,{label:c,required:!0}),s.jsxs("button",{type:"button",disabled:o||!r,onClick:()=>d(x=>!x),className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${l?"border-red-300":"border-slate-200"}`,children:[s.jsx("span",{className:y?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":y?nl(y.accountNumber):"Bank account number"}),s.jsx(e0,{className:`shrink-0 text-slate-400 transition ${u?"rotate-180":""}`})]}),l?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,u?s.jsxs("div",{className:"absolute left-0 right-0 z-20 mt-2 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"p-3",children:s.jsxs("button",{type:"button",onClick:()=>{d(!1),h(!0)},className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(Xb,{}),"Add Bank Account"]})}),s.jsx("div",{className:"border-t border-slate-200 px-4 py-2",children:s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"List of Bank Accounts"})}),s.jsx("div",{className:"max-h-64 overflow-y-auto pb-2",children:a.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):a.map(x=>{const b=String(x.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(x.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${b?"bg-gov-50":""}`,children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:Si(x.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:x.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[nl(x.accountNumber),n?` · ${n}`:` · ${x.accountType}`]})]})]},x.bankAccountDetailId)})})]}):null]}),s.jsx(au,{open:m,entityId:r,onClose:()=>h(!1),onAccountAdded:p})]})}function Xb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function e0({className:e=""}){return s.jsx("svg",{className:`h-4 w-4 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function t0(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Un({entity:e,remittanceAmount:t="—",className:r=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No entity selected."})]});const n=Ct(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsxs("dl",{className:"space-y-4 p-5 text-sm",children:[s.jsx(jn,{label:"Entity Name",value:n}),s.jsx(jn,{label:"Tax ID",value:dr(e.idNumber)}),s.jsx(jn,{label:"Email ID",value:e.email}),s.jsx(jn,{label:"Phone Number",value:Dr(e.phoneNumber)}),s.jsx(jn,{label:"Address",value:t0(e)})]}),s.jsxs("div",{className:"border-t border-slate-100 px-5 py-4",children:[s.jsx("p",{className:"text-sm font-medium text-[#99A1AF]",children:"Remittance Amount"}),s.jsx("p",{className:"mt-1.5 text-xl font-bold text-gov-600",children:t})]})]})}function jn({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm font-medium text-slate-500",children:e}),s.jsx("dd",{className:"mt-0.5 text-sm leading-relaxed text-slate-800",children:t})]})}const r0=[0,1,3,4,6,7,9,10],n0=[0,1,2,3,4,5,6,7,8,9,10],s0=[0,1,2,3,4,5,6,8,9,10,11],a0=[0,1,2,3,4,5,6,7,9,10,11],i0=["720","941"],o0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],l0=["7200D"],c0=["8963"];function du(e){return i0.includes(e)?r0:o0.includes(e)?n0:l0.includes(e)?s0:c0.includes(e)?a0:[]}function u0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Ns(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(r)||r<1||r>12?null:{year:t,month:r-1}}function d0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function mu(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Ss={941:"94105",944:"94405","CT-1":"10005"},wn={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Va={regex:/^(?!0+(?:\.0+)?$)(?:100000000(?:\.00?)?|(?:\d{1,8}|\d{1,7}\d)(?:\.\d{1,2})?)$/,errorMessage:"Payment amount must be a number greater than 0, can include up to 2 decimal places, and must not exceed 100,000,000 (one hundred million)."};function Ri(e,t){return!e||!t?!1:Ss[e]===t}function Bs(e,t){return e==="CT-1"&&t===Ss["CT-1"]}function m0(e,t){return e==="941"&&t===Ss[941]||e==="944"&&t===Ss[944]}function h0(e){return e==="CT-1"?{code1:wn.tier1,code2:wn.tier2,code3:""}:{code1:wn.socialSecurity,code2:wn.medicare,code3:wn.withheld}}function qa(e){return Va.regex.test(e)}const f0=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,es=1e8;function p0(e){if(!e)return"";let t="",r=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!r&&(t+=c,r=!0);const n=t.indexOf(".");let a=n===-1?t:t.slice(0,n);const i=n===-1?"":t.slice(n+1,n+3),o=n!==-1&&t.endsWith(".");if(a.length>9&&(a=a.slice(0,9)),a.length===9&&a!=="100000000"&&(a=a.slice(0,8)),a.length>0&&!o&&i===""){const c=Number.parseInt(a,10);!Number.isNaN(c)&&c>es&&(a=String(es))}let l=n===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),f0.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>es)return String(es)}return l}return""}function hu(e){return qa(e)?Number.parseFloat(e):null}function x0(e,t,r,n){const a=[e,t];return n&&a.push(r),a.reduce((i,o)=>{const l=hu(o);return l===null?i:i+l},0)}function g0(e,t){return Math.abs(e-t)<.005}function y0(e,t,r,n,a){if(!Ri(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=Bs(e,t);return{subcategoryCode1:r.trim()?"1":null,subcategoryCode2:n.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const b0=["Su","Mo","Tu","We","Th","Fr","Sa"];function v0(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function j0({value:e,onChange:t,disabled:r=!1,hasError:n=!1}){const a=ws(e),i=qs(),o=iu(),[l,c]=w.useState(!1),[u,d]=w.useState(()=>a??ws(i)??new Date),m=w.useRef(null),h=w.useId();w.useEffect(()=>{a&&d(a)},[e]),w.useEffect(()=>{if(!l)return;const b=j=>{var N;(N=m.current)!=null&&N.contains(j.target)||c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);const f=w.useMemo(()=>Gb(u.getFullYear(),u.getMonth()),[u]),y=w.useMemo(()=>{const b=new Date(u.getFullYear(),u.getMonth()-1,1),j=new Date(b.getFullYear(),b.getMonth()+1,0);return ir(j)>=i},[u,i]),p=w.useMemo(()=>{const b=new Date(u.getFullYear(),u.getMonth()+1,1);return ir(b)<=o},[u,o]),x=b=>{Ma(b)&&(t(ir(b)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:r,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!r&&c(b=>!b),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>c(b=>!b),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open settlement date picker",children:s.jsx(v0,{})})]}),l?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[300px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!y,onClick:()=>d(b=>new Date(b.getFullYear(),b.getMonth()-1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:Jb(u.getFullYear(),u.getMonth())}),s.jsx("button",{type:"button",disabled:!p,onClick:()=>d(b=>new Date(b.getFullYear(),b.getMonth()+1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pt-2 text-center text-xs font-medium text-slate-500",children:b0.map(b=>s.jsx("div",{className:"py-1",children:b},b))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((b,j)=>{if(!b)return s.jsx("div",{},`empty-${j}`);const N=ir(b),k=e===N,E=!Ma(b);return s.jsx("button",{type:"button","aria-disabled":E,onClick:()=>x(b),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":k?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:b.getDate()},N)})})]}):null]})}function ts({value:e,onChange:t,onBlur:r,name:n,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:n,value:e,disabled:a,readOnly:i,placeholder:o,className:J(l,i),onChange:c=>t(p0(c.target.value)),onBlur:r})}const w0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function N0(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function S0({value:e,onChange:t,disabled:r=!1,hasError:n=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=mu(),l=Ns(e),[c,u]=w.useState(!1),[d,m]=w.useState((l==null?void 0:l.year)??o),h=w.useRef(null),f=w.useId();w.useEffect(()=>{l&&m(l.year)},[e]),w.useEffect(()=>{if(!c)return;const N=k=>{var E;(E=h.current)!=null&&E.contains(k.target)||u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[c]);const y=u0(e),p=N=>!!a.includes(N),x=N=>{p(N)||(t(d0(d,N)),u(!1))},b=d>i,j=d<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:f,type:"text",readOnly:!0,disabled:r,value:y,placeholder:"YYYY-MM",onClick:()=>!r&&u(N=>!N),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>u(N=>!N),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open tax period picker",children:s.jsx(N0,{})})]}),c?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[280px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!b,onClick:()=>m(N=>N-1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous year",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:d}),s.jsx("button",{type:"button",disabled:!j,onClick:()=>m(N=>N+1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next year",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-3 gap-1 p-3",children:w0.map((N,k)=>{const E=(l==null?void 0:l.year)===d&&l.month===k&&e.length===6,P=p(k);return s.jsx("button",{type:"button","aria-disabled":P,onClick:()=>x(k),className:`rounded-lg px-2 py-2.5 text-sm transition ${P?"cursor-not-allowed text-slate-300 hover:bg-sky-50":E?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:N},N)})})]}):null]})}const fu="Active",k0="Inactive";function gn(e){return(e.status??fu).trim().toLowerCase()==="active"}function C0(e){return gn(e)?k0:fu}function A0(e){return gn(e)?"Deactivate":"Activate"}function Oi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function P0(e){return Oi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function pu(e){const t=y0(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),r=Bs(e.taxFormType,e.taxTypeCode);return{subcategoryCode1:t.subcategoryCode1,subcategoryAmount1:e.subcategoryAmount1?Number.parseFloat(e.subcategoryAmount1):null,subcategoryCode2:t.subcategoryCode2,subcategoryAmount2:e.subcategoryAmount2?Number.parseFloat(e.subcategoryAmount2):null,subcategoryCode3:t.subcategoryCode3,subcategoryAmount3:!r&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function $i(e,t){return{entityId:e,taxpayerPin:t.taxpayerPin||null,secondaryTin:t.secondaryTin||null,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10),taxFormType:t.taxFormType,taxTypeCode:t.taxTypeCode,taxPeriod:t.taxPeriod,settlementDate:t.settlementDate,paymentAmount:Number.parseFloat(t.paymentAmount),...pu(t)}}function Li(e){return{taxpayerPin:e.taxpayerPin||null,secondaryTin:e.secondaryTin||null,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10),taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:Number.parseFloat(e.paymentAmount),...pu(e)}}const zi="federal-payment-draft";function Mi(e){sessionStorage.setItem(zi,JSON.stringify(e))}function Us(){const e=sessionStorage.getItem(zi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Vi(){sessionStorage.removeItem(zi)}function _0(e,t={}){return{federalPaymentId:e.federalPaymentId,enrollmentId:e.enrollmentId,taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId?String(e.bankAccountDetailId):"",routingNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:t.accountType??"",bankName:t.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:String(e.paymentAmount),subcategoryAmount1:e.subcategoryAmount1!=null?String(e.subcategoryAmount1):"",subcategoryAmount2:e.subcategoryAmount2!=null?String(e.subcategoryAmount2):"",subcategoryAmount3:e.subcategoryAmount3!=null?String(e.subcategoryAmount3):""}}const E0=Bt({taxpayerPin:T().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:T().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional(),taxFormType:T().min(1,"Tax form type is required"),taxTypeCode:T().min(1,"Payment type is required"),taxPeriod:T().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=Ns(e);if(!t)return!1;const{minYear:r,maxYear:n}=mu();return t.year>=r&&t.year<=n},"Tax period must be within the last 3 years"),settlementDate:T().min(1,"This field is required").refine(e=>ou(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:T().min(1,"This field is required").refine(e=>qa(e),Va.errorMessage),subcategoryCode1:T().optional(),subcategoryAmount1:T().optional(),subcategoryCode2:T().optional(),subcategoryAmount2:T().optional(),subcategoryCode3:T().optional(),subcategoryAmount3:T().optional()}).superRefine((e,t)=>{var l;if(e.taxPeriod&&e.taxFormType){const c=Ns(e.taxPeriod);c&&du(e.taxFormType).includes(c.month)&&t.addIssue({code:Vr.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Ri(e.taxFormType,e.taxTypeCode))return;const r=Bs(e.taxFormType,e.taxTypeCode),n=m0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:Vr.custom,message:"This field is required",path:[u]});return}qa(c)||t.addIssue({code:Vr.custom,message:Va.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",n);const i=hu(e.paymentAmount),o=x0(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",n);i!==null&&!g0(i,o)&&t.addIssue({code:Vr.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),r&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Vr.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),rs="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function na(e){return{taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:e.paymentAmount,subcategoryCode1:e.subcategoryCode1??"",subcategoryAmount1:e.subcategoryAmount1??"",subcategoryCode2:e.subcategoryCode2??"",subcategoryAmount2:e.subcategoryAmount2??"",subcategoryCode3:e.subcategoryCode3??"",subcategoryAmount3:e.subcategoryAmount3??""}}const T0={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function I0(e,t){if(e)return na(e);if(t!=null&&t.paymentDraft)return na(t.paymentDraft);const r=Us();return r?na(r):T0}function xu({entity:e,initialDraft:t,readonly:r=!1,onCancel:n}){var mr,Et,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,zr;const a=Se(),i=ge(),o=st(),l=Lr(i.state,jt()),c=i.state,u=w.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Us()??null,[t,c==null?void 0:c.paymentDraft]),d=w.useRef(u==null?void 0:u.federalPaymentId),m=w.useRef(u==null?void 0:u.enrollmentId),[h,f]=w.useState(null),[y,p]=w.useState(!1),x=w.useMemo(()=>I0(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);w.useEffect(()=>{u!=null&&u.federalPaymentId&&(d.current=u.federalPaymentId),u!=null&&u.enrollmentId&&(m.current=u.enrollmentId)},[u==null?void 0:u.federalPaymentId,u==null?void 0:u.enrollmentId]);const{data:b=[],isLoading:j}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>qn(e.entityId),enabled:e!==null}),N=w.useMemo(()=>b.filter(gn),[b]),{data:k=[],isLoading:E}=Ee({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>Sb(e.entityId),enabled:e!==null}),{register:P,control:_,handleSubmit:F,watch:Y,setValue:M,trigger:se,formState:{errors:q}}=Nt({resolver:kt(E0),defaultValues:x}),K=Y("bankAccountDetailId"),te=Y("paymentAmount"),W=Y("taxFormType"),ne=Y("taxTypeCode"),xe=Y("taxPeriod"),pe=Y("settlementDate"),H=Y("subcategoryAmount1"),Pe=Y("subcategoryAmount2"),pt=Y("subcategoryAmount3"),le=w.useRef(W),Re=w.useMemo(()=>W?du(W):[],[W]),ze=w.useMemo(()=>Ri(W,ne),[W,ne]),He=w.useMemo(()=>Bs(W,ne),[W,ne]),{data:At=[],isLoading:it}=Ee({queryKey:["federal-tax-type-codes",W],queryFn:()=>kb(W),enabled:!!W});w.useEffect(()=>{le.current&&le.current!==W&&M("taxTypeCode",""),le.current=W},[W,M]),w.useEffect(()=>{if(!xe||!W)return;const z=Ns(xe);z&&Re.includes(z.month)&&M("taxPeriod","")},[W,xe,Re,M]),w.useEffect(()=>{pe&&(ou(pe)||M("settlementDate",""))},[pe,M]),w.useEffect(()=>{if(!ze){M("subcategoryCode1",""),M("subcategoryCode2",""),M("subcategoryCode3",""),M("subcategoryAmount1",""),M("subcategoryAmount2",""),M("subcategoryAmount3","");return}const z=h0(W);M("subcategoryCode1",z.code1),M("subcategoryCode2",z.code2),M("subcategoryCode3",He?"":z.code3),He&&M("subcategoryAmount3","")},[ze,W,He,M]),w.useEffect(()=>{ze&&(se("paymentAmount"),se("subcategoryAmount1"),se("subcategoryAmount2"),se("subcategoryAmount3"))},[H,Pe,pt,ze,se]),w.useEffect(()=>{const z=N.find(ae=>String(ae.bankAccountDetailId)===K);if(!z){K&&(M("bankAccountDetailId",""),M("routingNumber",""),M("accountType",""),M("bankName",""));return}M("routingNumber",z.routingNumber),M("accountType",z.accountType),M("bankName",z.bankName)},[N,K,M]);const ot=z=>{const ae=N.find(g=>String(g.bankAccountDetailId)===z.bankAccountDetailId);return{federalPaymentId:d.current,enrollmentId:m.current??(u==null?void 0:u.enrollmentId),form8655AuthorizationId:u==null?void 0:u.form8655AuthorizationId,form9783EnrollmentId:u==null?void 0:u.form9783EnrollmentId,taxpayerPin:z.taxpayerPin??"",secondaryTin:z.secondaryTin??"",bankAccountDetailId:z.bankAccountDetailId,routingNumber:z.routingNumber??(ae==null?void 0:ae.routingNumber)??"",accountNumber:(ae==null?void 0:ae.accountNumber)??"",accountType:z.accountType??(ae==null?void 0:ae.accountType)??"",bankName:z.bankName??(ae==null?void 0:ae.bankName)??"",taxFormType:z.taxFormType,taxTypeCode:z.taxTypeCode,taxPeriod:z.taxPeriod,settlementDate:z.settlementDate,paymentAmount:z.paymentAmount,subcategoryCode1:z.subcategoryCode1,subcategoryAmount1:z.subcategoryAmount1,subcategoryCode2:z.subcategoryCode2,subcategoryAmount2:z.subcategoryAmount2,subcategoryCode3:z.subcategoryCode3,subcategoryAmount3:z.subcategoryAmount3}},Pt=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},oe=async z=>{if(!e)return null;if(z.federalPaymentId){const g=await Fi(z.federalPaymentId,Li(z));return d.current=g.federalPaymentId,m.current=g.enrollmentId,g}const ae=await Ii($i(e.entityId,z));return d.current=ae.federalPaymentId,m.current=ae.enrollmentId,ae},Te=F(async z=>{if(!(r||!e)){f(null),p(!0);try{const ae=ot(z),g=await oe(ae);if(!g)return;const S={...ae,federalPaymentId:g.federalPaymentId,enrollmentId:g.enrollmentId};await Pt(),Mi(S),a(P0(e),{state:{from:l,paymentDraft:S}})}catch(ae){f(et(ae,"Failed to save payment details."))}finally{p(!1)}}}),lt=F(async z=>{if(!(!e||r)){f(null),p(!0);try{const ae=ot(z);await oe(ae),await Pt(),Vi(),a(jt())}catch(ae){f(et(ae,"Failed to save draft."))}finally{p(!1)}}}),_t=()=>{if(n){n();return}a(l)},xt=e?Ct(e):"Entity";return s.jsxs("form",{onSubmit:Te,noValidate:!0,className:"w-full space-y-6",children:[h?s.jsx(qt,{message:h}):null,s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:xt}),s.jsx(Un,{entity:e,remittanceAmount:Bn(te),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:[s.jsx(vr,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Taxpayer PIN",required:!0,error:(mr=q.taxpayerPin)==null?void 0:mr.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:J(!!q.taxpayerPin),maxLength:4,disabled:r,...P("taxpayerPin")})}),s.jsx(Z,{label:"Secondary TIN",error:(Et=q.secondaryTin)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:J(!!q.secondaryTin),maxLength:9,disabled:r,...P("secondaryTin")})}),s.jsx(De,{name:"bankAccountDetailId",control:_,render:({field:z})=>{var ae;return s.jsx(uu,{value:z.value,onChange:z.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:N,isLoading:j,disabled:!e||r,error:(ae=q.bankAccountDetailId)==null?void 0:ae.message})}}),s.jsx(Z,{label:"Routing Number",required:!0,error:(Ut=q.routingNumber)==null?void 0:Ut.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:J(!!q.routingNumber,!0),...P("routingNumber")})}),s.jsx(Z,{label:"Account Type",required:!0,error:(Tt=q.accountType)==null?void 0:Tt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:J(!!q.accountType,!0),...P("accountType")})}),s.jsx(Z,{label:"Bank Name",required:!0,error:(It=q.bankName)==null?void 0:It.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:J(!!q.bankName,!0),...P("bankName")})})]})}),s.jsx(vr,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Tax Form Type",required:!0,error:(hr=q.taxFormType)==null?void 0:hr.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!q.taxFormType),disabled:E||!e||r,...P("taxFormType"),children:[s.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),k.map(z=>s.jsx("option",{value:z.value,children:z.value},z.value))]}),s.jsx(Br,{})]})}),s.jsx(Z,{label:"Payment Type",required:!0,error:(Zt=q.taxTypeCode)==null?void 0:Zt.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!q.taxTypeCode),disabled:!W||it||r,...P("taxTypeCode"),children:[s.jsx("option",{value:"",children:W?it?"Loading payment types…":"Select payment type":"Select tax form first"}),At.map(z=>s.jsxs("option",{value:z.code,children:[z.code," - ",z.codeName]},z.code))]}),s.jsx(Br,{})]})}),s.jsx(Z,{label:"Tax Period",required:!0,error:(fr=q.taxPeriod)==null?void 0:fr.message,children:s.jsx(De,{name:"taxPeriod",control:_,render:({field:z})=>s.jsx(S0,{value:z.value,onChange:z.onChange,hasError:!!q.taxPeriod,disabled:!W||r,disabledMonths:Re})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(Z,{label:"Settlement Date",required:!0,error:(Wt=q.settlementDate)==null?void 0:Wt.message,children:s.jsx(De,{name:"settlementDate",control:_,render:({field:z})=>s.jsx(j0,{value:z.value,onChange:z.onChange,hasError:!!q.settlementDate,disabled:r})})}),s.jsx(Z,{label:"Payment Amount",required:!0,error:(Yt=q.paymentAmount)==null?void 0:Yt.message,children:s.jsx(De,{name:"paymentAmount",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value,onChange:z.onChange,onBlur:z.onBlur,disabled:r,hasError:!!q.paymentAmount})})})]}),ze?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Subcategory Code 1",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...P("subcategoryCode1")})}),s.jsx(Z,{label:"Subcategory Code 2",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...P("subcategoryCode2")})}),He?null:s.jsx(Z,{label:"Subcategory Code 3",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...P("subcategoryCode3")})})]}),s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Subcategory Amount 1",required:!0,error:(pr=q.subcategoryAmount1)==null?void 0:pr.message,children:s.jsx(De,{name:"subcategoryAmount1",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!q.subcategoryAmount1})})}),s.jsx(Z,{label:"Subcategory Amount 2",required:!0,error:(xr=q.subcategoryAmount2)==null?void 0:xr.message,children:s.jsx(De,{name:"subcategoryAmount2",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!q.subcategoryAmount2})})}),He?null:s.jsx(Z,{label:"Subcategory Amount 3",required:!0,error:(zr=q.subcategoryAmount3)==null?void 0:zr.message,children:s.jsx(De,{name:"subcategoryAmount3",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!q.subcategoryAmount3})})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:_t,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:r?"Back":"Cancel"}),r?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:lt,disabled:!e||y,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:y?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||y,className:"inline-flex h-11 min-w-[160px] items-center justify-center rounded-lg bg-gov-600 px-10 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:y?"Saving…":"Next"})]})]})]},i.key)}function gu(){const{selectedEntity:e}=ft();return s.jsx(xu,{entity:e})}function yu({mode:e}){var m;const t=Se(),{federalPaymentId:r}=Pd(),{selectedEntity:n}=ft(),a=Number.parseInt(r??"",10),{data:i,isLoading:o,isError:l}=Ee({queryKey:["federal-payment",a],queryFn:()=>Ti(a),enabled:Number.isFinite(a)}),{data:c=[]}=Ee({queryKey:["bank-accounts",n==null?void 0:n.entityId],queryFn:()=>qn(n.entityId),enabled:n!==null&&i!==void 0}),u=w.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return _0(i,{routingNumber:h==null?void 0:h.routingNumber,accountNumber:h==null?void 0:h.accountNumber,accountType:h==null?void 0:h.accountType,bankName:h==null?void 0:h.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(ht,{to:jt(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!u)return s.jsx(ht,{to:jt(),replace:!0});if(!n||i.entityId!==n.entityId)return s.jsx(ht,{to:jt(),replace:!0});const d=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(xu,{entity:n,initialDraft:u,readonly:d,onCancel:()=>t(jt())})}function bu(){return ft(),s.jsx(yu,{mode:"edit"})}function vu(){return ft(),s.jsx(yu,{mode:"view"})}const F0=["Withholding Tax","Estimated Tax","Income Tax"],sl=[{code:"VA",name:"Virginia"}],D0=[{value:"Q1",label:"Q1"},{value:"Q2",label:"Q2"},{value:"Q3",label:"Q3"},{value:"Q4",label:"Q4"}];function R0(){const e=new Date().getFullYear();return[e,e-1,e-2]}const qi="state-payment-draft";function Ba(e){sessionStorage.setItem(qi,JSON.stringify(e))}function ju(){const e=sessionStorage.getItem(qi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ua(){sessionStorage.removeItem(qi)}function wu(e,t){return`${e}-${t}`}function O0(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:wu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function $0(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:wu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}const L0=Bt({state:T().min(1,"State is required"),reasonForPayment:T().min(1,"Reason for payment is required"),stateAccountId:T().min(1,"State ID is required"),accountId:T().min(1,"Account ID is required"),letterId:T().optional(),taxYear:T().min(1,"Tax year is required"),taxPeriod:T().min(1,"Tax period is required"),taxAmount:T().min(1,"Tax amount is required").refine(e=>Number.parseFloat(e)>0,"Tax amount must be greater than 0"),paymentDate:T().min(1,"Payment date is required").refine(e=>e>=qs(),"Payment date must be a future date"),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional()}),sa="grid gap-x-6 gap-y-5 sm:grid-cols-3",al="grid gap-x-6 gap-y-5 sm:grid-cols-2",il="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ol={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function z0({entity:e}){var se,q,K,te,W,ne,xe,pe;const t=Se(),r=ge(),n=Lr(r.state,"/payments"),a=r.state,i=w.useMemo(()=>a!=null&&a.paymentDraft?a.paymentDraft:a!=null&&a.resetDraft?(Ua(),ol):ju()??ol,[a==null?void 0:a.paymentDraft,a==null?void 0:a.resetDraft,r.key]),o=w.useMemo(()=>R0(),[]),l=qs(),{data:c=[],isLoading:u}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>qn(e.entityId),enabled:e!==null}),d=w.useMemo(()=>c.filter(gn),[c]),{register:m,control:h,handleSubmit:f,watch:y,setValue:p,formState:{errors:x}}=Nt({resolver:kt(L0),defaultValues:i}),b=y("state"),j=y("reasonForPayment"),N=y("taxAmount"),k=y("bankAccountDetailId"),E=!!(b&&j),[P,_]=w.useState(!1),F=(se=sl.find(H=>H.code===b))==null?void 0:se.name;w.useEffect(()=>{const H=d.find(Pe=>String(Pe.bankAccountDetailId)===k);if(!H){k&&(p("bankAccountDetailId",""),p("routingNumber",""),p("accountType",""),p("bankName",""));return}p("routingNumber",H.routingNumber),p("accountType",H.accountType),p("bankName",H.bankName)},[d,k,p]);const Y=f(H=>{const Pe={state:H.state,reasonForPayment:H.reasonForPayment,stateAccountId:H.stateAccountId,accountId:H.accountId,letterId:H.letterId,taxYear:H.taxYear,taxPeriod:H.taxPeriod,taxAmount:H.taxAmount,paymentDate:H.paymentDate,bankAccountDetailId:H.bankAccountDetailId,routingNumber:H.routingNumber,accountType:H.accountType,bankName:H.bankName};Ba(Pe),t("/payments/state/authorization",{state:{from:n,paymentDraft:Pe}})}),M=e?Ct(e):"Entity";return s.jsx("form",{onSubmit:Y,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:M}),s.jsx(Un,{entity:e,remittanceAmount:Bn(N),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"lg:mr-[324px]",children:s.jsxs("div",{className:"mx-auto w-full max-w-[720px] space-y-5",children:[s.jsxs("section",{className:il,children:[s.jsx(ll,{step:1,title:"Choose a State"}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>_(H=>!H),className:"flex w-full items-center justify-between rounded-xl border border-slate-200 bg-slate-50/80 px-4 py-4 text-left transition hover:border-gov-300 hover:bg-gov-50/40",children:[s.jsxs("span",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:s.jsx(M0,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:F??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Br,{className:`h-4 w-4 text-slate-400 transition ${P?"rotate-180":""}`})]}),P?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-2 max-h-64 overflow-y-auto rounded-xl border border-slate-200 bg-white shadow-lg",children:sl.map(H=>s.jsxs("button",{type:"button",onClick:()=>{p("state",H.code,{shouldValidate:!0}),_(!1)},className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${b===H.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:H.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:H.code})]},H.code))}):null,x.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.state.message}):null]}),s.jsx(Z,{label:"Reason for Payment",required:!0,error:(q=x.reasonForPayment)==null?void 0:q.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!x.reasonForPayment),...m("reasonForPayment"),children:[s.jsx("option",{value:"",children:"Select reason"}),F0.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsx(Br,{})]})})]})]}),s.jsxs("section",{className:`${il} transition ${E?"":"opacity-60"}`,children:[s.jsx(ll,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!E,className:"min-w-0 border-0 p-0",children:[s.jsx(aa,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:sa,children:[s.jsx(Z,{label:"State ID",required:!0,error:(K=x.stateAccountId)==null?void 0:K.message,children:s.jsx("input",{placeholder:"Enter ID",className:J(!!x.stateAccountId),...m("stateAccountId")})}),s.jsx(Z,{label:"Account ID",required:!0,error:(te=x.accountId)==null?void 0:te.message,children:s.jsx("input",{placeholder:"123456789-WHW",className:J(!!x.accountId),...m("accountId")})}),s.jsx(Z,{label:"Letter ID",children:s.jsx("input",{placeholder:"123456789-WHW",className:J(),...m("letterId")})})]}),s.jsxs("div",{className:al,children:[s.jsx(Z,{label:"Tax Year",required:!0,error:(W=x.taxYear)==null?void 0:W.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!x.taxYear),...m("taxYear"),children:[s.jsx("option",{value:"",children:"Select TY"}),o.map(H=>s.jsxs("option",{value:String(H),children:["TY ",H]},H))]}),s.jsx(Br,{})]})}),s.jsx(Z,{label:"Tax Period",required:!0,error:(ne=x.taxPeriod)==null?void 0:ne.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!x.taxPeriod),...m("taxPeriod"),children:[s.jsx("option",{value:"",children:"Select"}),D0.map(H=>s.jsx("option",{value:H.value,children:H.label},H.value))]}),s.jsx(Br,{})]})})]})]})}),s.jsx(aa,{title:"Amount Info",children:s.jsxs("div",{className:al,children:[s.jsx(Z,{label:"Tax Amount",required:!0,error:(xe=x.taxAmount)==null?void 0:xe.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",className:J(!!x.taxAmount),...m("taxAmount")})}),s.jsx(Z,{label:"Payment Date",required:!0,error:(pe=x.paymentDate)==null?void 0:pe.message,children:s.jsx("input",{type:"date",min:l,className:J(!!x.paymentDate),...m("paymentDate")})})]})}),s.jsx(aa,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:sa,children:[s.jsx(De,{name:"bankAccountDetailId",control:h,render:({field:H})=>{var Pe;return s.jsx(uu,{value:H.value,onChange:H.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:d,isLoading:u,disabled:!e||!E,error:(Pe=x.bankAccountDetailId)==null?void 0:Pe.message,label:"Account Number"})}}),s.jsx(Z,{label:"Routing Number",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:J(!1,!0),...m("routingNumber")})}),s.jsx(Z,{label:"Account Type",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:J(!1,!0),...m("accountType")})})]}),s.jsx("div",{className:sa,children:s.jsx(Z,{label:"Bank Name",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:J(!1,!0),...m("bankName")})})})]})})]}),E?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:"Select a state and reason for payment to continue."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>t(n),className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:!e||!E,className:"inline-flex h-11 min-w-[120px] items-center justify-center gap-2 rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:["Next",s.jsx(V0,{})]})]})]})})]})},r.key)}function ll({step:e,title:t,className:r=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:e}),s.jsx("h3",{className:"text-sm font-bold uppercase tracking-wide text-slate-900",children:t})]})}function aa({title:e,children:t}){return s.jsxs("div",{className:"mt-6 first:mt-0",children:[s.jsx("h4",{className:"mb-4 text-xs font-semibold uppercase tracking-wide text-slate-400",children:e}),t]})}function M0(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]})}function V0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})}function Nu(){const{selectedEntity:e}=ft();return s.jsx(z0,{entity:e})}const q0="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",B0="I have reviewed the details and authorize this payment.",Su=/^[a-zA-Z\s]+$/;function ku(e){return e.replace(/[^a-zA-Z\s]/g,"")}const Bi=T().min(1,"Signature is required").regex(Su,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),U0=T().optional().refine(e=>!e||!e.trim()||Su.test(e),{message:"Signature must contain only letters"}),Z0=Bt({agreementDate:T().min(1,"Date is required"),agreementAccepted:Zr().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:T().min(1,"Name of authorization person is required"),signature:Bi,title:T().min(1,"Title is required")}),W0="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ns="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Y0(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function H0(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function K0({entity:e,paymentDraft:t}){const r=Se(),n=ge(),a=st(),i=Lr(n.state,"/payments"),[o,l]=w.useState(null),[c,u]=w.useState(!1),d=w.useMemo(()=>H0(),[]),m=Bn(t.taxAmount),{register:h,handleSubmit:f,watch:y,formState:{errors:p}}=Nt({resolver:kt(Z0),defaultValues:d}),x=y("agreementDate"),b=y("signature"),j=!!(b!=null&&b.trim()),N=h("signature"),k=async()=>{await a.invalidateQueries({queryKey:["dashboard"]}),await a.invalidateQueries({queryKey:["state-payments"]}),await a.invalidateQueries({queryKey:["remittance-payments"]})},E=async()=>{if(!e)return null;if(t.statePaymentDetailId){const Y=await _b(t.statePaymentDetailId,$0(t));return await k(),Y}const F=await Pb(O0(e.entityId,t));return Ba({...t,statePaymentDetailId:F.statePaymentDetailId}),await k(),F},P=f(async()=>{if(e){l(null),u(!0);try{const F=await E();if(!F)return;await Xc(F.statePaymentDetailId),await k(),Ua(),r(i)}catch(F){l(et(F,"Failed to submit state payment."))}finally{u(!1)}}}),_=f(async()=>{if(e){l(null),u(!0);try{await E(),Ua(),r(i)}catch(F){l(et(F,"Failed to save draft."))}finally{u(!1)}}});return s.jsx("form",{onSubmit:P,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),s.jsx(Un,{entity:e,remittanceAmount:m,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"lg:mr-[324px]",children:[s.jsxs("section",{className:W0,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-slate-200 pb-5",children:[s.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:`${ns} min-w-[128px] py-2.5`,children:[s.jsx("p",{className:"text-[11px] font-medium text-slate-500",children:"Date"}),s.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-800",children:Y0(x)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:q0}),s.jsxs("label",{className:"mt-5 flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...h("agreementAccepted")}),s.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:B0})]}),p.agreementAccepted?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.agreementAccepted.message}):null,s.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("p",{className:"mb-4 text-sm font-medium text-gov-600",children:["Taxpayer's Signature",s.jsx("span",{className:"text-red-500",children:" *"})]}),s.jsxs("div",{className:"grid gap-5 md:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_minmax(0,1fr)] md:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:`${ns} py-7`,children:[s.jsx("input",{placeholder:"Enter name",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("authorizationPersonName")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[180px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Name of Authorization Person"})]}),p.authorizationPersonName?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.authorizationPersonName.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${ns} py-5`,children:[s.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${j?"min-h-[52px] text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:j?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,name:N.name,ref:N.ref,onBlur:N.onBlur,onChange:F=>{const Y=ku(F.target.value);F.target.value=Y,N.onChange(F)}}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[220px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Signature of Tax Payer"})]}),p.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.signature.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${ns} py-7`,children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("title")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[140px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Title"})]}),p.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.title.message}):null]})]})]})]}),o?s.jsx("div",{className:"mt-5",children:s.jsx(qt,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{Ba(t),r("/payments/state/new",{state:{from:i,paymentDraft:t}})},disabled:c,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:_,disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-gov-300 bg-gov-50 px-6 text-sm font-semibold text-gov-600 transition hover:bg-gov-100 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Submit Now"})]})]})]})})}function Cu(){const{selectedEntity:e}=ft(),t=ge(),{paymentDraft:r}=t.state??{},n=r??ju();return n?s.jsx(K0,{entity:e,paymentDraft:n}):s.jsx(ht,{to:"/payments/state/new",replace:!0})}const Ui="/portal/federal-payments/form-8655-authorizations";function Q0(e){return he(Ui,{method:"POST",body:e})}function J0(e){return he(`${Ui}/by-enrolment/${e}`)}function G0(e,t){return he(`${Ui}/${e}`,{method:"PATCH",body:t})}async function Au(e){try{return await J0(e)}catch(t){if(t instanceof zn&&t.status===404)return null;throw t}}const Za=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function X0(e){const t=e.trim();return Za.includes(t)?t:"Other"}const ev="I understand that this agreement does not relieve me, as the taxpayer, of the responsibility to ensure that all tax returns are filed and that all deposits and payments are made and that I may enroll in the Electronic Federal Tax Payment System (EFTPS) to view deposits and payments made on my behalf.",tv="I further understand that this agreement does not authorize the reporting agent to sign any tax returns, to otherwise act as a legal representative of the taxpayer, or to represent the taxpayer before the IRS. I also understand that the reporting agent is not responsible for any penalties or interest that may be assessed against the taxpayer. I authorize the reporting agent to complete Form 8655, Reporting Agent Authorization, and to make deposits and payments on my behalf for the tax return(s) indicated above. I also authorize the reporting agent to receive confidential information and to perform acts as specified on Form 2848, Power of Attorney and Declaration of Representative, or Form 8821, Tax Information Authorization, as applicable.";function rv(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function Wa({label:e,required:t=!1,signature:r,title:n,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:u="Signature of taxpayer"}){const d=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:f,ref:y}=r;return s.jsxs("div",{children:[e?s.jsxs("p",{className:"mb-3 text-sm font-medium text-gov-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}):null,s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-6",children:[s.jsx("input",{ref:y,name:f,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${d?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:d?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:p=>{const x=ku(p.target.value);p.target.value=x,m(p)}}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:u})]}),c!=null&&c.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.signature}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...n}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Title"})]}),c!=null&&c.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-center text-sm text-slate-700",children:rv(o)}),s.jsx("input",{type:"hidden",...a})]}):s.jsx("input",{type:"date",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 focus:outline-none",...a}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Date"})]}),c!=null&&c.date?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function nv(e){return e.replace(/\D/g,"")}function Pu(e,t){var r,n;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:nv(t.ein),address:t.address.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),isSeasonalEmployer:t.isSeasonalEmployer,otherIdentificationNumber:((r=t.otherIdentificationNumber)==null?void 0:r.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((n=t.authorizationMonth)==null?void 0:n.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function sv(e){const{enrollmentId:t,...r}=Pu(0,e);return r}function av(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:dr(e.ein),address:e.address,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,isSeasonalEmployer:e.isSeasonalEmployer,otherIdentificationNumber:e.otherIdentificationNumber??"",contactPerson:e.contactPerson,daytimePhone:Dr(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const iv=Bt({taxpayerName:T().min(1,"Taxpayer name is required"),tradeName:T().min(1,"Trade name is required"),ein:T().min(1,"EIN is required"),address:T().min(1,"Address is required"),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required"),isSeasonalEmployer:Zr(),otherIdentificationNumber:T().optional(),contactPerson:T().min(1,"Contact person is required"),daytimePhone:T().min(1,"Daytime telephone number is required"),faxNumber:T().default(""),authorizedTaxForm:T().min(1,"Select a tax form"),authorizationMonth:T().optional(),agreementAccepted:Zr().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:Bi,title:T().min(1,"Title is required"),signatureDate:T().min(1,"Date is required")}),ia="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function ov(e,t){const r=new Date().toISOString().slice(0,10);return{taxpayerName:e?Ct(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.firstName)||"",ein:e?dr(e.idNumber):"",address:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",isSeasonalEmployer:!1,otherIdentificationNumber:"",contactPerson:e?`${e.firstName} ${e.lastName}`.trim():"",daytimePhone:e?Dr(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:X0(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:r}}function lv({entity:e,paymentDraft:t,initialAuthorization:r=null,readonly:n=!1}){var ne,xe,pe,H,Pe,pt,le,Re,ze,He,At,it,ot,Pt;const a=Se(),i=ge(),o=st(),l=Lr(i.state,jt()),c=Bn(t.paymentAmount),[u,d]=w.useState(null),[m,h]=w.useState(!1),f=w.useMemo(()=>r?av(r):ov(e,t),[e,r,t]),{register:y,handleSubmit:p,watch:x,setValue:b,reset:j,formState:{errors:N}}=Nt({resolver:kt(iv),defaultValues:f});w.useEffect(()=>{j(f)},[f,j]);const k=x("authorizedTaxForm"),E=x("signature"),P=x("signatureDate"),_=e?Ct(e):"Entity",F=!0,Y=!0,M=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},se=async()=>{if(!e)return null;if(t.federalPaymentId){const Te=await Fi(t.federalPaymentId,Li(t));return await M(),Te}const oe=await Ii($i(e.entityId,t));return Mi({...t,federalPaymentId:oe.federalPaymentId,enrollmentId:oe.enrollmentId}),await M(),oe},q=async(oe,Te)=>{var xt;const lt=t.form8655AuthorizationId??((xt=await Au(oe))==null?void 0:xt.form8655AuthorizationId),_t=Te;return lt?G0(lt,sv(_t)):Q0(Pu(oe,_t))},K=async oe=>{if(!e)return;const Te=await se();Te&&(await q(Te.enrollmentId,oe),await o.invalidateQueries({queryKey:["form-8655",Te.enrollmentId]}),Vi(),a(jt()))},te=p(async oe=>{if(!(!e||n)){d(null),h(!0);try{await K(oe)}catch(Te){d(et(Te,"Failed to save federal payment draft."))}finally{h(!1)}}}),W=p(async oe=>{if(!(!e||n)){d(null),h(!0);try{await K(oe)}catch(Te){d(et(Te,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:te,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:_}),s.jsx(Un,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:ia,children:[s.jsx(Z,{label:"1. a) Name of the Taxpayer",required:!0,error:(ne=N.taxpayerName)==null?void 0:ne.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!N.taxpayerName,F),...y("taxpayerName")})}),s.jsx(Z,{label:"1. b) Trade Name, if any",required:!0,error:(xe=N.tradeName)==null?void 0:xe.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!N.tradeName,F),...y("tradeName")})}),s.jsx(Z,{label:"2. Employer Identification Number (EIN)",required:!0,error:(pe=N.ein)==null?void 0:pe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:F,className:J(!!N.ein,F),...y("ein")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Z,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(H=N.address)==null?void 0:H.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!N.address,F),...y("address")})})}),s.jsx(Z,{label:"3. b) City or Town",required:!0,error:(Pe=N.city)==null?void 0:Pe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!N.city,F),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${ia}`,children:[s.jsx(Z,{label:"3. c) State",required:!0,error:(pt=N.state)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!N.state,F),...y("state")})}),s.jsx(Z,{label:"3. d) ZIP Code",required:!0,error:(le=N.zipCode)==null?void 0:le.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!N.zipCode,F),...y("zipCode")})}),s.jsx(Z,{label:"3. e) Country",required:!0,error:(Re=N.country)==null?void 0:Re.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!N.country,F),...y("country")})})]}),s.jsxs("div",{className:`mt-5 ${ia}`,children:[s.jsx("div",{className:"flex items-end pb-2",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(Z,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!1,F),...y("otherIdentificationNumber")})}),s.jsx(Z,{label:"6. Contact Person",required:!0,error:(ze=N.contactPerson)==null?void 0:ze.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!N.contactPerson,F),...y("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(Z,{label:"7. Daytime Telephone Number",required:!0,error:(He=N.daytimePhone)==null?void 0:He.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:F,className:J(!!N.daytimePhone,F),...y("daytimePhone")})}),s.jsx(Z,{label:"8. Fax Number",error:(At=N.faxNumber)==null?void 0:At.message,children:s.jsx("input",{placeholder:"Enter number",className:J(!!N.faxNumber),...y("faxNumber")})})]})]}),s.jsxs(vr,{title:"Authorization of Reporting Agent To Make and Deposits and Payments (Caution: See Authorization Agreement.)",children:[s.jsx("p",{className:"mb-5 text-sm leading-6 text-slate-600",children:"Indicate the tax return(s) for which the reporting agent is authorized to make deposits or payments. Use the 'YYYY/MM' format to enter the month in which the authorization begins (for example, '2024/8' for August 2024)"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Za.slice(0,6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:k===oe,disabled:Y,onChange:()=>b("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Za.slice(6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:k===oe,disabled:Y,onChange:()=>b("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))})]}),N.authorizedTaxForm?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:N.authorizedTaxForm.message}):null]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:"border-t border-slate-200 pt-5",children:[s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:ev})," ",tv]})]}),N.agreementAccepted?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:N.agreementAccepted.message}):null]})]}),s.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:s.jsx(Wa,{label:"Taxpayer's Signature",required:!0,signature:y("signature"),title:y("title"),date:y("signatureDate"),signatureValue:E,dateValue:P,errors:{signature:(it=N.signature)==null?void 0:it.message,title:(ot=N.title)==null?void 0:ot.message,date:(Pt=N.signatureDate)==null?void 0:Pt.message}})})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(qt,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:m,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:W,disabled:m||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:m||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function _u(){const{selectedEntity:e}=ft(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Us(),{data:a,isLoading:i}=Ee({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>Ti(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=Ee({queryKey:["form-8655",o],queryFn:()=>Au(o),enabled:o!=null}),u=w.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form8655AuthorizationId:n.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[n,o,l]);return n?Oi(e)?s.jsx(ht,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(lv,{entity:e,paymentDraft:u??n,initialAuthorization:l}):s.jsx(ht,{to:"/payments/federal/new",replace:!0})}const Zi="/portal/federal-payments/form-9783-enrollments";function cv(e){return he(Zi,{method:"POST",body:e})}function uv(e){return he(`${Zi}/by-enrolment/${e}`)}function dv(e,t){return he(`${Zi}/${e}`,{method:"PATCH",body:t})}async function Eu(e){try{return await uv(e)}catch(t){if(t instanceof zn&&t.status===404)return null;throw t}}const mv="I hereby authorize the contact person listed in item 5 on this form, and the financial institution(s) listed in items 9-11 on this form, to process EFTPS payments and to receive confidential information for enrollment purposes, to answer inquiries regarding my account, and to resolve any issues that may arise. This authorization includes passwords, payment instructions, taxpayer names, and identifying numbers.",hv="By completing the financial institution information in items 9-11 on this form, I authorize the designated Financial Agents of the U.S. Treasury to initiate EFTPS debit entries to my financial institution account for federal tax payments. All debits will be made in accordance with U.S. Treasury regulations. This authorization remains in effect until written notification of termination is received and the Financial Agent has had a reasonable opportunity to act on it.",fv="Under penalties of perjury, I certify that I have the authority to sign this authorization on behalf of the taxpayer. If I am a corporate officer, partner, guardian, executor, receiver, administrator, trustee, or other party, I certify that I have the authority to execute this authorization on behalf of the taxpayer. If I am a tax practitioner, I certify that Form 2848 or Form 8655 is on file with the IRS.",oa=new Date().getFullYear(),pv=[String(oa-1),String(oa-2),String(oa-3)];function ss(e){return e.replace(/\D/g,"")}function Tu(e,t){var r,n,a,i;return{enrollmentId:e,primarySsn:ss(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ss(t.jointFilerSsn):null,taxpayerNames:t.taxpayerNames.trim(),primaryAddress:t.primaryAddress.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),internationalAddress:((r=t.internationalAddress)==null?void 0:r.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((n=t.contactInternationalAddress)==null?void 0:n.trim())||null,primaryTaxpayerPin:t.primaryTaxpayerPin.trim()||null,dateOfBirth:t.dateOfBirth||null,priorYearAgi:t.priorYearAgi.trim()?Number(t.priorYearAgi):null,agiTaxYear:t.agiTaxYear.trim()||null,financialPrimarySsn:ss(t.financialPrimarySsn),routingTransitNumber:ss(t.routingTransitNumber),accountNumber:t.accountNumber.trim(),accountType:t.accountType,disclosureAgreementOne:t.disclosureAgreementOne,disclosureAgreementTwo:t.disclosureAgreementTwo,authorityAgreement:t.authorityAgreement,taxpayerSignature:t.taxpayerSignature.trim()||null,taxpayerTitle:t.taxpayerTitle.trim(),taxpayerSignatureDate:t.taxpayerSignatureDate,jointFilerSignature:((a=t.jointFilerSignature)==null?void 0:a.trim())||null,jointFilerTitle:((i=t.jointFilerTitle)==null?void 0:i.trim())||null,jointFilerSignatureDate:t.jointFilerSignatureDate||null}}function xv(e){const{enrollmentId:t,...r}=Tu(0,e);return r}function gv(e){var r;const t=((r=e.accountType)==null?void 0:r.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:Dr(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Dr(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",financialPrimarySsn:e.financialPrimarySsn,routingTransitNumber:e.routingTransitNumber,accountNumber:e.accountNumber,accountType:t,disclosureAgreementOne:e.disclosureAgreementOne,disclosureAgreementTwo:e.disclosureAgreementTwo,authorityAgreement:e.authorityAgreement,taxpayerSignature:e.taxpayerSignature??"",taxpayerTitle:e.taxpayerTitle,taxpayerSignatureDate:e.taxpayerSignatureDate,jointFilerSignature:e.jointFilerSignature??"",jointFilerTitle:e.jointFilerTitle??"",jointFilerSignatureDate:e.jointFilerSignatureDate??""}}const yv=Bt({primarySsn:T().min(1,"Primary SSN is required"),jointFilerSsn:T().optional(),taxpayerNames:T().min(1,"Taxpayer name is required"),primaryAddress:T().min(1,"Primary address is required"),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required"),internationalAddress:T().optional(),primaryPhone:T().min(1,"Primary phone number is required"),primaryContactName:T().min(1,"Primary contact name is required"),primaryContactAddress:T().min(1,"Primary contact address is required"),contactCity:T().min(1,"Contact city is required"),contactState:T().min(1,"Contact state is required"),contactZipCode:T().min(1,"Contact ZIP code is required"),contactCountry:T().min(1,"Contact country is required"),contactPhone:T().min(1,"Contact phone number is required"),contactInternationalAddress:T().optional(),primaryTaxpayerPin:T().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:T().min(1,"Date of birth is required").refine(e=>Kb(e,Iu),{message:"You must be at least 18 years old"}),priorYearAgi:T().min(1,"Prior year adjusted gross income is required").refine(e=>!Number.isNaN(Number(e))&&Number(e)>=0,{message:"Enter a valid amount"}),agiTaxYear:T().min(1,"Prior tax year is required"),financialPrimarySsn:T().min(1,"Primary SSN is required"),routingTransitNumber:T().min(1,"Routing transit number is required"),accountNumber:T().min(1,"Account number is required"),accountType:Uc([Gs("Checking"),Gs("Savings"),Gs("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Zr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Zr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Zr().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:Bi,taxpayerTitle:T().min(1,"Title is required"),taxpayerSignatureDate:T().min(1,"Date is required"),jointFilerSignature:U0,jointFilerTitle:T().optional(),jointFilerSignatureDate:T().optional()}),gr="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",bv="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",vv=5,Iu=18;function Fu(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function Du(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:Fu(t.accountType)}}function jv(e,t){const r=new Date().toISOString().slice(0,10),n=e?Ct(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:n,primaryAddress:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"US",internationalAddress:"",primaryPhone:e?Dr(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...Du(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:r,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:r}}function wv({entity:e,paymentDraft:t,initialEnrollment:r=null,readonly:n=!1}){var _t,xt,mr,Et,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,zr,z,ae,g,S,C,D,R,B,O,U;const a=Se(),i=ge(),o=st(),l=Lr(i.state,jt()),c=Bn(t.paymentAmount),[u,d]=w.useState(null),[m,h]=w.useState(!1),[f,y]=w.useState(!1),{data:p=[]}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>qn(e.entityId),enabled:(e==null?void 0:e.entityId)!=null}),x=w.useMemo(()=>{if(r)return gv(r);const $=p.find(Ie=>String(Ie.bankAccountDetailId)===t.bankAccountDetailId),X=Du(e,t);return{...jv(e,t),financialPrimarySsn:X.financialPrimarySsn,routingTransitNumber:X.routingTransitNumber||($==null?void 0:$.routingNumber)||"",accountNumber:X.accountNumber||($==null?void 0:$.accountNumber)||"",accountType:Fu(t.accountType||($==null?void 0:$.accountType))}},[e,r,t,p]),{register:b,handleSubmit:j,watch:N,setValue:k,reset:E,control:P,formState:{errors:_}}=Nt({resolver:kt(yv),defaultValues:x});w.useEffect(()=>{E(x)},[x,E]);const F=N("taxpayerSignature"),Y=N("jointFilerSignature"),M=N("taxpayerSignatureDate"),se=N("jointFilerSignatureDate"),q=N("accountType"),K=N("taxpayerNames"),te=N("primaryAddress"),W=N("city"),ne=N("state"),xe=N("zipCode"),pe=N("country"),H=N("primaryPhone"),Pe=N("internationalAddress"),pt=e?Ct(e):"Entity",le=!0,Re=!0,ze=w.useMemo(()=>Hb(Iu),[]),He=()=>{k("primaryContactName",K,{shouldValidate:!0}),k("primaryContactAddress",te,{shouldValidate:!0}),k("contactCity",W,{shouldValidate:!0}),k("contactState",ne,{shouldValidate:!0}),k("contactZipCode",xe,{shouldValidate:!0}),k("contactCountry",pe,{shouldValidate:!0}),k("contactPhone",H,{shouldValidate:!0}),k("contactInternationalAddress",Pe??"",{shouldValidate:!0})},At=()=>{k("primaryContactName","",{shouldValidate:!0}),k("primaryContactAddress","",{shouldValidate:!0}),k("contactCity","",{shouldValidate:!0}),k("contactState","",{shouldValidate:!0}),k("contactZipCode","",{shouldValidate:!0}),k("contactCountry","",{shouldValidate:!0}),k("contactPhone","",{shouldValidate:!0}),k("contactInternationalAddress","",{shouldValidate:!0})};w.useEffect(()=>{f&&He()},[f,K,te,W,ne,xe,pe,H,Pe]);const it=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ot=async()=>{if(!e)return null;if(t.federalPaymentId){const X=await Fi(t.federalPaymentId,Li(t));return await it(),X}const $=await Ii($i(e.entityId,t));return Mi({...t,federalPaymentId:$.federalPaymentId,enrollmentId:$.enrollmentId}),await it(),$},Pt=async($,X)=>{var Ft;const Ie=t.form9783EnrollmentId??((Ft=await Eu($))==null?void 0:Ft.form9783EnrollmentId);return Ie?dv(Ie,xv(X)):cv(Tu($,X))},oe=async $=>{if(!e)return;const X=await ot();X&&(await Pt(X.enrollmentId,$),await o.invalidateQueries({queryKey:["form-9783",X.enrollmentId]}),Vi(),a(jt()))},Te=j(async $=>{if(!(!e||n)){d(null),h(!0);try{await oe($)}catch(X){d(et(X,"Failed to save federal payment draft."))}finally{h(!1)}}}),lt=j(async $=>{if(!(!e||n)){d(null),h(!0);try{await oe($)}catch(X){d(et(X,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:Te,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:pt}),s.jsx(Un,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs(vr,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:gr,children:[s.jsx(Z,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(_t=_.primarySsn)==null?void 0:_t.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:le,className:J(!!_.primarySsn,le),...b("primarySsn")})}),s.jsx(Z,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:le,className:J(!1,le),...b("jointFilerSsn")})}),s.jsx(Z,{label:"2. Taxpayer(S) name(S)",required:!0,error:(xt=_.taxpayerNames)==null?void 0:xt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:le,className:J(!!_.taxpayerNames,le),...b("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(Z,{label:"3. a) Primary taxpayer address",required:!0,error:(mr=_.primaryAddress)==null?void 0:mr.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.primaryAddress,le),...b("primaryAddress")})})}),s.jsx(Z,{label:"3. b) City or Town",required:!0,error:(Et=_.city)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.city,le),...b("city")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx(Z,{label:"3. c) State",required:!0,error:(Ut=_.state)==null?void 0:Ut.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:le,className:J(!!_.state,le),...b("state")})}),s.jsx(Z,{label:"3. d) ZIP code",required:!0,error:(Tt=_.zipCode)==null?void 0:Tt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.zipCode,le),...b("zipCode")})}),s.jsx(Z,{label:"3. e) Country",required:!0,error:(It=_.country)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.country,le),...b("country")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(Z,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:le,className:J(!1,le),...b("internationalAddress")})})}),s.jsx(Z,{label:"4. Primary taxpayer phone number",required:!0,error:(hr=_.primaryPhone)==null?void 0:hr.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:le,className:J(!!_.primaryPhone,le),...b("primaryPhone")})})]})]}),s.jsxs(vr,{title:"2. Contact Information",headerAction:s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",checked:f,disabled:n,onChange:$=>{const X=$.target.checked;y(X),X?He():At()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[s.jsxs("div",{className:gr,children:[s.jsx(Z,{label:"5. Primary contact name",required:!0,error:(Zt=_.primaryContactName)==null?void 0:Zt.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:f,className:J(!!_.primaryContactName,f),...b("primaryContactName")})}),s.jsx(Z,{label:"6. a) Primary contact address",required:!0,error:(fr=_.primaryContactAddress)==null?void 0:fr.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:f,className:J(!!_.primaryContactAddress,f),...b("primaryContactAddress")})}),s.jsx(Z,{label:"6. b) City or Town",required:!0,error:(Wt=_.contactCity)==null?void 0:Wt.message,children:s.jsx("input",{placeholder:"City",readOnly:f,className:J(!!_.contactCity,f),...b("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx(Z,{label:"6. c) State",required:!0,error:(Yt=_.contactState)==null?void 0:Yt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:f,className:J(!!_.contactState,f),...b("contactState")})}),s.jsx(Z,{label:"6. d) ZIP code",required:!0,error:(pr=_.contactZipCode)==null?void 0:pr.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:f,className:J(!!_.contactZipCode,f),...b("contactZipCode")})}),s.jsx(Z,{label:"6. f) Country",required:!0,error:(xr=_.contactCountry)==null?void 0:xr.message,children:s.jsx("input",{placeholder:"Country",readOnly:f,className:J(!!_.contactCountry,f),...b("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(Z,{label:"7. Primary taxpayer phone number",required:!0,error:(zr=_.contactPhone)==null?void 0:zr.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:J(!!_.contactPhone,f),...b("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Z,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:J(!1,f),...b("contactInternationalAddress")})})})]})]}),s.jsx(vr,{title:"Taxpayer Details *",children:s.jsxs("div",{className:bv,children:[s.jsx(Z,{label:"1. Primary Taxpayer Pin",required:!0,error:(z=_.primaryTaxpayerPin)==null?void 0:z.message,children:s.jsx(De,{name:"primaryTaxpayerPin",control:P,render:({field:$})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:J(!!_.primaryTaxpayerPin),value:$.value,onChange:X=>$.onChange(Wr(X.target.value,vv)),onBlur:$.onBlur})})}),s.jsx(Z,{label:"2. Date of Birth",required:!0,error:(ae=_.dateOfBirth)==null?void 0:ae.message,children:s.jsx("input",{type:"date",max:ze,className:J(!!_.dateOfBirth),...b("dateOfBirth")})}),s.jsx(Z,{label:"3. Prior year adjusted gross income",required:!0,error:(g=_.priorYearAgi)==null?void 0:g.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:J(!!_.priorYearAgi),...b("priorYearAgi")})}),s.jsx(Z,{label:"4. Prior Tax Year",required:!0,error:(S=_.agiTaxYear)==null?void 0:S.message,children:s.jsxs("select",{className:Yr(!!_.agiTaxYear),...b("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),pv.map($=>s.jsx("option",{value:$,children:$},$))]})})]})}),s.jsxs(vr,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:gr,children:[s.jsx(Z,{label:"9. Primary SSN",required:!0,error:(C=_.financialPrimarySsn)==null?void 0:C.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:Re,className:J(!!_.financialPrimarySsn,Re),...b("financialPrimarySsn")})}),s.jsx(Z,{label:"10. Routing Transit Number (RTN)",required:!0,error:(D=_.routingTransitNumber)==null?void 0:D.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:Re,className:J(!!_.routingTransitNumber,Re),...b("routingTransitNumber")})}),s.jsx(Z,{label:"11. Account Number",required:!0,error:(R=_.accountNumber)==null?void 0:R.message,children:s.jsx("input",{placeholder:"Enter",readOnly:Re,className:J(!!_.accountNumber,Re),...b("accountNumber")})})]}),s.jsxs("div",{className:"mt-5",children:[s.jsx("p",{className:"mb-3 text-sm text-slate-600",children:"12. Type of Account"}),s.jsx("div",{className:"flex flex-wrap gap-6",children:["Checking","Savings"].map($=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:$,checked:q===$,disabled:Re,onChange:()=>k("accountType",$,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),$]},$))}),_.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.accountType.message}):null]})]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsx("p",{className:"mb-5 text-sm text-slate-600",children:"Read the following authorization agreements"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:mv})]}),_.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.disclosureAgreementOne.message}):null]}),s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:hv})]}),_.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.disclosureAgreementTwo.message}):null]}),s.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Authority to Execute an Authorization"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:fv})]}),_.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(Wa,{label:"Taxpayer's Signature",required:!0,signature:b("taxpayerSignature"),title:b("taxpayerTitle"),date:b("taxpayerSignatureDate"),signatureValue:F,dateValue:M,errors:{signature:(B=_.taxpayerSignature)==null?void 0:B.message,title:(O=_.taxpayerTitle)==null?void 0:O.message,date:(U=_.taxpayerSignatureDate)==null?void 0:U.message}}),s.jsx(Wa,{label:"Joint filer(s) Signature (Optional)",signature:b("jointFilerSignature"),title:b("jointFilerTitle"),date:b("jointFilerSignatureDate"),signatureValue:Y??"",dateValue:se??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(qt,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:m,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:lt,disabled:m||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:m||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function Ru(){const{selectedEntity:e}=ft(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Us(),{data:a,isLoading:i}=Ee({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>Ti(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=Ee({queryKey:["form-9783",o],queryFn:()=>Eu(o),enabled:o!=null}),u=w.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form9783EnrollmentId:n.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[n,o,l]);return n?e&&!Oi(e)?s.jsx(ht,{to:"/payments/federal/authorization",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(wv,{entity:e,paymentDraft:u??n,initialEnrollment:l}):s.jsx(ht,{to:"/payments/federal/new",replace:!0})}function Nv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Sv({type:e}){return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:e})}function kv({status:e}){const t=e.toLowerCase();let r="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?r="bg-orange-50 text-orange-700":t.includes("irs accepted")?r="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?r="bg-red-50 text-red-600":t.includes("pending")&&(r="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r}`,children:e})}function Cv({forms:e=[],isLoading:t=!1,isError:r=!1}){return s.jsx("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"File Name"}),s.jsx("th",{className:"px-6 py-3",children:"Type"}),s.jsx("th",{className:"px-6 py-3",children:"Client"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Date"}),s.jsx("th",{className:"px-6 py-3",children:"Action"})]})}),s.jsx("tbody",{children:t?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Loading tax forms…"})}):r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Unable to load tax forms."})}):e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"No tax forms to display yet."})}):e.map(n=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3 font-medium text-slate-900",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gov-50 text-gov-600",children:s.jsx(Av,{className:"h-4 w-4"})}),n.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Sv,{type:n.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:n.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(kv,{status:n.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:Nv(n.date)}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("button",{type:"button",className:"rounded-full border border-gov-200 bg-gov-50 px-4 py-1.5 text-xs font-semibold text-gov-600 transition hover:bg-gov-100",children:"View PDF"}),n.canSubmit?s.jsx("button",{type:"button",className:"rounded-full bg-gov-600 px-4 py-1.5 text-xs font-semibold text-white transition hover:bg-gov-700",children:"Submit"}):null]})})]},n.taxFormId))})]})})})}function Av({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V6A2.25 2.25 0 014.5 3.75h4.379a2.25 2.25 0 011.59.659l1.122 1.122A2.25 2.25 0 0013.128 6H19.5a2.25 2.25 0 012.25 2.25v10.5A2.25 2.25 0 0119.5 21H4.5a2.25 2.25 0 01-2.25-2.25v-6.75z"})})}function Pv(){return s.jsx(Cv,{})}const cl=160,_v=88,as=8;function Ev({account:e,entityId:t,onEdit:r}){const n=st(),{showSuccess:a,showError:i}=Es(),o=w.useRef(null),l=w.useRef(null),[c,u]=w.useState(!1),[d,m]=w.useState(!1),[h,f]=w.useState({}),y=()=>{var E;const x=o.current;if(!x)return;const b=x.getBoundingClientRect(),j=((E=l.current)==null?void 0:E.offsetHeight)??_v,k=window.innerHeight-b.bottom<j+as;f({position:"fixed",top:k?b.top-j-as:b.bottom+as,left:Math.max(as,b.right-cl),width:cl,zIndex:50})};w.useLayoutEffect(()=>{c&&(y(),requestAnimationFrame(y))},[c]),w.useEffect(()=>{if(!c)return;const x=j=>{var k,E;const N=j.target;(k=o.current)!=null&&k.contains(N)||(E=l.current)!=null&&E.contains(N)||u(!1)},b=()=>y();return document.addEventListener("mousedown",x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[c]);const p=async()=>{const x=gn(e);m(!0);try{await ru(e.bankAccountDetailId,{status:C0(e)}),await n.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),x?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(b){i("Action Not Completed",et(b,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:o,type:"button",disabled:d,onClick:()=>u(x=>!x),className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:["Actions",s.jsx(Tv,{})]}),c?ks.createPortal(s.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[s.jsx("button",{type:"button",onClick:()=>{u(!1),r(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"}),s.jsx("button",{type:"button",disabled:d,onClick:()=>void p(),className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-60",children:A0(e)})]}),document.body):null]})}function Tv(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}const Ou=["Checking","Savings"],Iv=Bt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${un} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ms(Ou,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")});function Fv({open:e,account:t,onClose:r}){const n=st(),{showSuccess:a,showError:i}=Es(),[o,l]=w.useState(null),[c,u]=w.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=Nt({resolver:kt(Iv),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});w.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),w.useEffect(()=>{if(!e)return;const p=x=>{x.key==="Escape"&&r()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,r]);const y=m(async p=>{if(t){l(null),u(!0);try{await ru(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await n.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),r()}catch(x){const b=et(x,"Unable to update bank account.");l(b),i("Action Not Completed",b)}finally{u(!1)}}});return!e||!t?null:ks.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-bank-account-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),s.jsxs("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),y(p)},className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?s.jsx("div",{className:"mb-5",children:s.jsx(qt,{message:o})}):null,s.jsxs(lr,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(De,{name:"accountNumber",control:d,render:({field:p})=>{var x;return s.jsx(de,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:b=>p.onChange(Wr(b.target.value,un)),onBlur:p.onBlur,error:(x=f.accountNumber)==null?void 0:x.message})}}),s.jsx(De,{name:"routingNumber",control:d,render:({field:p})=>{var x;return s.jsx(de,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:b=>p.onChange(Wr(b.target.value,nu)),onBlur:p.onBlur,error:(x=f.routingNumber)==null?void 0:x.message})}}),s.jsx(De,{name:"accountType",control:d,render:({field:p})=>{var x;return s.jsx(wt,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(x=f.accountType)==null?void 0:x.message,children:Ou.map(b=>s.jsx("option",{value:b,children:b},b))})}})]}),s.jsx(De,{name:"bankName",control:d,render:({field:p})=>{var x;return s.jsx(de,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(x=f.bankName)==null?void 0:x.message})}})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:r,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:c?"Saving…":"Save Changes"})]})]})]})]}),document.body)}const Rr=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Dv},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:Rv},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Ov},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:$v}];function Dv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 002.25-2.25V6.75A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25v10.5A2.25 2.25 0 004.5 19.5z"})})}function Rv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Ov({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function $v({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})})}function dn({title:e,subtitle:t,icon:r,action:n}){return s.jsxs("div",{className:"mb-6 flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(r,{className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"text-sm text-slate-500",children:t})]})]}),n]})}function Lv(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function zv({status:e}){const t=gn({status:e});return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:t?"Active":"In-active"})}function Mv({entityId:e}){const[t,r]=w.useState(!1),[n,a]=w.useState(null),i=Rr.find(d=>d.id==="bank-accounts"),o=i.icon,{data:l=[],isLoading:c,isError:u}=Ee({queryKey:["bank-accounts",e],queryFn:()=>qn(e),enabled:e!==null});return s.jsxs("div",{children:[s.jsx(dn,{title:i.title,subtitle:i.subtitle,icon:o,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>r(!0),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(Vv,{}),"Add Bank Account"]})}),s.jsx(au,{open:t,entityId:e,onClose:()=>r(!1)}),s.jsx(Fv,{open:n!==null,account:n,onClose:()=>a(null)}),s.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[700px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Bank"}),s.jsx("th",{className:"px-5 py-3",children:"Account"}),s.jsx("th",{className:"px-5 py-3",children:"Routing"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"}),s.jsx("th",{className:"px-5 py-3"})]})}),s.jsx("tbody",{children:c?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):u?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load bank accounts."})}):e?l.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No bank accounts connected yet."})}):l.map(d=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:d.bankName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Lv(d.accountNumber)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.routingNumber}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.accountType}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(zv,{status:d.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx(Ev,{account:d,entityId:e,onEdit:a})})]},d.bankAccountDetailId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage bank accounts."})})})]})})]})}function Vv(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function qv({open:e,entity:t,onClose:r}){var x,b,j,N,k,E,P,_,F,Y;const n=st(),[a,i]=w.useState(null),[o,l]=w.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,formState:{errors:h}}=Nt({resolver:kt(Kc),defaultValues:Qo(t)});w.useEffect(()=>{e&&(m(Qo(t)),i(null))},[t,e,m]),w.useEffect(()=>{if(!e)return;const M=se=>{se.key==="Escape"&&r()};return document.addEventListener("keydown",M),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",M),document.body.style.overflow=""}},[e,r]);const f=d("accountType"),y=f==="Individual"?Hc:Yc,p=u(async M=>{i(null),l(!0);try{await Sh(t.entityId,My(M)),await n.invalidateQueries({queryKey:["entities","mine"]}),r()}catch(se){i(et(se,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?ks.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-entity-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),s.jsxs("form",{onSubmit:p,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?s.jsx("div",{className:"mb-5",children:s.jsx(qt,{message:a})}):null,s.jsxs("div",{className:"space-y-8",children:[s.jsx("input",{type:"hidden",...c("ein")}),s.jsx(lr,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(cn,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:f==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(x=h.businessName)==null?void 0:x.message,...c("businessName")}),s.jsx(de,{label:"Trade Name, if any",placeholder:"Enter",error:(b=h.tradeName)==null?void 0:b.message,...c("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"EIN",readOnly:!0,value:dr(t.idNumber),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(wt,{label:"Entity Type",required:!0,error:(j=h.entityType)==null?void 0:j.message,...c("entityType"),children:y.map(M=>s.jsx("option",{value:M,children:M},M))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(N=h.email)==null?void 0:N.message,...c("email")}),s.jsxs("div",{children:[s.jsx(cn,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...c("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${h.phoneNumber?"border-red-300":"border-slate-200"}`,...c("phoneNumber")})]}),h.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:h.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(de,{label:"Address Line 1",required:!0,error:(k=h.address1)==null?void 0:k.message,...c("address1")}),s.jsx(de,{label:"Address Line 2",error:(E=h.address2)==null?void 0:E.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"City",required:!0,error:(P=h.city)==null?void 0:P.message,...c("city")}),s.jsxs(wt,{label:"State",required:!0,error:(_=h.state)==null?void 0:_.message,...c("state"),children:[s.jsx("option",{value:"",children:"Select"}),ki.map(M=>s.jsx("option",{value:M,children:M},M))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"ZIP Code",required:!0,error:(F=h.zipCode)==null?void 0:F.message,...c("zipCode")}),s.jsxs(wt,{label:"Country",required:!0,error:(Y=h.country)==null?void 0:Y.message,...c("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:r,disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save Changes"})]})]})]})]}),document.body):null}function Bv({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})}):e==="account"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})}):s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})}function Nn({label:e,value:t,icon:r}){return s.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:s.jsx(Bv,{icon:r})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs text-slate-500",children:e}),s.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function Uv(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function Zv({entity:e}){const[t,r]=w.useState(!1),n=Rr.find(c=>c.id==="entity-details"),a=n.icon;if(!e)return s.jsxs("div",{children:[s.jsx(dn,{title:n.title,subtitle:n.subtitle,icon:a}),s.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=Ct(e),o=`${e.firstName} ${e.lastName}`.trim()||i,l=Si(o);return s.jsxs("div",{children:[s.jsx(dn,{title:n.title,subtitle:n.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),s.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[s.jsx("span",{className:"flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xl font-semibold text-white",children:l}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(Nn,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(Nn,{label:"Tax ID",value:dr(e.idNumber),icon:"tax"}),s.jsx(Nn,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(Nn,{label:"Phone Number",value:Dr(e.phoneNumber),icon:"phone"}),s.jsx(Nn,{label:"Account Type",value:Uv(e.accountType),icon:"account"})]}),s.jsx(qv,{open:t,entity:e,onClose:()=>r(!1)})]})}function $u({activeSection:e,onSectionChange:t,items:r}){return s.jsx("nav",{className:"space-y-2",children:r.map(n=>{const a=e===n.id,i=n.icon;return s.jsxs("button",{type:"button",onClick:()=>t(n.id),className:`flex w-full items-center gap-3 rounded-xl border px-4 py-3.5 text-left transition ${a?"border-gov-200 bg-gov-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300 hover:bg-slate-50"}`,children:[s.jsx("span",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${a?"bg-gov-600 text-white":"bg-slate-100 text-slate-500"}`,children:s.jsx(i,{className:"h-5 w-5"})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:`block text-sm font-semibold ${a?"text-slate-900":"text-slate-700"}`,children:n.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:n.subtitle})]}),s.jsx(Wv,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},n.id)})})}function Wv({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function Yv(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function Hv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Kv({type:e}){const t={Federal:"bg-gov-50 text-gov-700",State:"bg-sky-50 text-sky-700",Local:"bg-indigo-50 text-indigo-700"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]}`,children:e})}function Qv({entityId:e,transactions:t=[],isLoading:r=!1,isError:n=!1}){const a=Rr.find(l=>l.id==="payment-history"),i=a.icon,o=e!==null&&t.length>0;return s.jsxs("div",{children:[s.jsx(dn,{title:a.title,subtitle:a.subtitle,icon:i,action:s.jsxs("button",{type:"button",disabled:!o,className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(Jv,{}),"Export to Excel"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Date"}),s.jsx("th",{className:"px-5 py-3",children:"Amount"}),s.jsx("th",{className:"px-5 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Reference"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load payment history."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No payment transactions to display yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Hv(l.date)}),s.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:Yv(l.amount)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.jurisdiction}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Kv,{type:l.type})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.reference})]},l.paymentHistoryId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to view payment history."})})})]})})]})}function Jv(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"})})}function Gv({count:e}){const t=e===1?"1 Payment":`${e} Payments`;return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:t})}function Xv({status:e}){const r=(e??"Active").toLowerCase()==="active";return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:r?"Active":"In-active"})}function ej(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function tj({entityId:e,accounts:t=[],isLoading:r=!1,isError:n=!1}){const a=Se(),i=Rr.find(l=>l.id==="tax-accounts"),o=i.icon;return s.jsxs("div",{children:[s.jsx(dn,{title:i.title,subtitle:i.subtitle,icon:o,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>a("/settings/tax-accounts/new"),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(rj,{}),"Add Tax Account"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Federal/State ID"}),s.jsx("th",{className:"px-5 py-3",children:"Payments"}),s.jsx("th",{className:"px-5 py-3",children:"Form Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load tax accounts."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"No tax accounts connected yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.federalStateId}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Gv,{count:l.paymentCount})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:ej(l.formTypes)}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Xv,{status:l.status})})]},l.taxAccountId)):s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage tax accounts."})})})]})})]})}function rj(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const ul="rounded-2xl border border-slate-200 bg-white shadow-sm";function nj(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function Wi(){const{selectedEntity:e}=ft(),r=ge().state,[n,a]=w.useState(nj(r==null?void 0:r.section)?r.section:"bank-accounts");return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${ul} p-3`,children:s.jsx($u,{items:Rr,activeSection:n,onSectionChange:a})}),s.jsx("div",{className:`${ul} p-6 lg:p-8`,children:n==="bank-accounts"?s.jsx(Mv,{entityId:(e==null?void 0:e.entityId)??null}):n==="tax-accounts"?s.jsx(tj,{entityId:(e==null?void 0:e.entityId)??null}):n==="payment-history"?s.jsx(Qv,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(Zv,{entity:e})})]})}const sj=["Alexandria","Arlington","Chesapeake","Hampton","Lynchburg","Newport News","Norfolk","Richmond","Roanoke","Virginia Beach"],aj=ki.map(e=>({code:e,name:e==="VA"?"Virginia":e})),ij=[{name:"virginiaTaxAccountId",label:"Virginia Tax Account ID",required:!0},{name:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID",required:!0},{name:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID",required:!0},{name:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number",required:!0},{name:"businessLocationCode",label:"Business Location Code",required:!0},{name:"franchiseTaxAccount",label:"Franchise Tax Account",required:!0},{name:"transientOccupancyTaxAccountId",label:"Transient Occupancy Tax Account ID",required:!1},{name:"certificateOfAuthorityNumber",label:"Certificate of Authority Number (Foreign Entities)",required:!1}],oj=[{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1}],lj=Bt({state:T().min(1,"State is required"),city:T().min(1,"City is required"),zipCode:T().min(1,"ZIP code is required"),address1:T().min(1,"Address Line 1 is required"),address2:T().optional(),virginiaTaxAccountId:T().optional(),virginiaWithholdingAccountingId:T().optional(),unemploymentTaxAccountId:T().optional(),virginiaDepartmentOfTaxationClientNumber:T().optional(),businessLocationCode:T().optional(),franchiseTaxAccount:T().optional(),transientOccupancyTaxAccountId:T().optional(),certificateOfAuthorityNumber:T().optional(),licensedProfessionalEmployerEntityNumber:T().optional()}),cj=lj.superRefine((e,t)=>{if(e.state!=="VA")return;const r=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const n of r){const a=e[n.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:Vr.custom,message:`${n.label} is required`,path:[n.key]})}}),uj={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function dj({onCancel:e,onSuccess:t}){var b,j,N,k,E,P;const{showSuccess:r}=Es(),[n,a]=w.useState(null),[i,o]=w.useState(!1),{register:l,handleSubmit:c,watch:u,setValue:d,formState:{errors:m}}=Nt({resolver:kt(cj),defaultValues:uj}),h=u("state"),f=u("city"),y=h==="VA",p=w.useMemo(()=>h==="VA"?[...sj]:[],[h]);w.useEffect(()=>{if(p.length===0){f&&d("city","");return}f&&!p.includes(f)&&d("city","")},[p,f,d]);const x=c(async _=>{a(null),o(!0);try{await Promise.resolve(),r("Tax Account Ready","Tax account details captured. API save will be enabled soon."),t==null||t(_)}catch{a("Unable to save tax account. Please try again.")}finally{o(!1)}});return s.jsxs("form",{onSubmit:x,noValidate:!0,className:"space-y-8",children:[n?s.jsx(qt,{message:n}):null,s.jsx(lr,{step:1,title:"TAX ACCOUNT DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsxs(wt,{label:"Select State",required:!0,error:(b=m.state)==null?void 0:b.message,...l("state"),children:[s.jsx("option",{value:"",children:"Select"}),aj.map(_=>s.jsx("option",{value:_.code,children:_.name},_.code))]}),p.length>0?s.jsxs(wt,{label:"City",required:!0,error:(j=m.city)==null?void 0:j.message,...l("city"),children:[s.jsx("option",{value:"",children:"Select"}),p.map(_=>s.jsx("option",{value:_,children:_},_))]}):s.jsx(de,{label:"City",required:!0,placeholder:"Enter",error:(N=m.city)==null?void 0:N.message,...l("city")})]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:s.jsx(de,{label:"Zip Code",required:!0,placeholder:"Enter",error:(k=m.zipCode)==null?void 0:k.message,...l("zipCode")})}),s.jsx(de,{label:"Address Line 1",required:!0,placeholder:"Enter",error:(E=m.address1)==null?void 0:E.message,...l("address1")}),s.jsx(de,{label:"Address Line 2",placeholder:"Enter",error:(P=m.address2)==null?void 0:P.message,...l("address2")})]})}),y?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-slate-200"}),s.jsxs(lr,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:ij.map(_=>{var F;return s.jsx(de,{label:_.label,required:_.required,placeholder:"Enter",error:(F=m[_.name])==null?void 0:F.message,...l(_.name)},_.name)})}),s.jsx("div",{className:"mt-5 space-y-5",children:oj.map(_=>{var F;return s.jsx(de,{label:_.label,required:_.required,placeholder:"Enter",error:(F=m[_.name])==null?void 0:F.message,...l(_.name)},_.name)})})]})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:e,disabled:i,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:i,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:i?"Saving…":"Save"})]})]})}const la="rounded-2xl border border-slate-200 bg-white shadow-sm";function Yi(){const e=Se(),{selectedEntity:t}=ft(),r=Rr.find(i=>i.id==="tax-accounts"),n=r.icon,a=(i="tax-accounts")=>{e("/settings",{state:{section:i}})};return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${la} p-3`,children:s.jsx($u,{items:Rr,activeSection:"tax-accounts",onSectionChange:a})}),s.jsxs("div",{className:`${la} p-6 lg:p-8`,children:[s.jsx(dn,{title:r.title,subtitle:r.subtitle,icon:n}),s.jsx(dj,{onCancel:()=>a("tax-accounts"),onSuccess:()=>a("tax-accounts")})]})]}):s.jsx("div",{className:la+" p-6 lg:p-8",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function mj({paymentsMode:e="all"}){return s.jsxs(Ga,{children:[s.jsx(ee,{index:!0,element:s.jsx(oi,{})}),s.jsx(ee,{path:"create-entity",element:s.jsx(ci,{})}),s.jsx(ee,{path:"create-entity/form",element:s.jsx(Ci,{})}),s.jsxs(ee,{element:s.jsx(li,{}),children:[s.jsx(ee,{path:"entities",element:s.jsx(Ei,{})}),s.jsx(ee,{path:"dashboard",element:s.jsx(_i,{})}),s.jsx(ee,{path:"payments",element:s.jsx(Di,{paymentsMode:e})}),s.jsx(ee,{path:"payments/federal/new",element:s.jsx(gu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(bu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(vu,{})}),s.jsx(ee,{path:"payments/state/new",element:s.jsx(Nu,{})}),s.jsx(ee,{path:"payments/state/authorization",element:s.jsx(Cu,{})}),s.jsx(ee,{path:"payments/federal/authorization",element:s.jsx(_u,{})}),s.jsx(ee,{path:"payments/federal/individual-enrollment",element:s.jsx(Ru,{})}),s.jsx(ee,{path:"tax-forms",element:s.jsx(Pv,{})}),s.jsx(ee,{path:"settings",element:s.jsx(Wi,{})}),s.jsx(ee,{path:"settings/tax-accounts/new",element:s.jsx(Yi,{})})]}),s.jsx(ee,{path:"*",element:s.jsx(ht,{to:"/",replace:!0})})]})}const hj=w.forwardRef(function(t,r){const n=w.useRef(null),a=w.useRef(null);return w.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)}})),s.jsx(ii,{...t,navigateFnRef:n,selectEntityFnRef:a,children:s.jsx(mj,{paymentsMode:"all"})})}),fj=w.forwardRef(function(t,r){const n=w.useRef(null),a=w.useRef(null);return w.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)}})),s.jsx(ii,{...t,navigateFnRef:n,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(Ga,{children:[s.jsx(ee,{index:!0,element:s.jsx(oi,{})}),s.jsx(ee,{path:"create-entity",element:s.jsx(ci,{})}),s.jsx(ee,{path:"create-entity/form",element:s.jsx(Ci,{})}),s.jsxs(ee,{element:s.jsx(li,{}),children:[s.jsx(ee,{path:"entities",element:s.jsx(Ei,{})}),s.jsx(ee,{path:"dashboard",element:s.jsx(_i,{})}),s.jsx(ee,{path:"payments",element:s.jsx(Di,{paymentsMode:"federal"})}),s.jsx(ee,{path:"payments/federal/new",element:s.jsx(gu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(bu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(vu,{})}),s.jsx(ee,{path:"payments/federal/authorization",element:s.jsx(_u,{})}),s.jsx(ee,{path:"payments/federal/individual-enrollment",element:s.jsx(Ru,{})}),s.jsx(ee,{path:"settings",element:s.jsx(Wi,{})}),s.jsx(ee,{path:"settings/tax-accounts/new",element:s.jsx(Yi,{})})]}),s.jsx(ee,{path:"*",element:s.jsx(ht,{to:"/",replace:!0})})]})})}),pj=w.forwardRef(function(t,r){const n=w.useRef(null),a=w.useRef(null);return w.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)}})),s.jsx(ii,{...t,navigateFnRef:n,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(Ga,{children:[s.jsx(ee,{index:!0,element:s.jsx(oi,{})}),s.jsx(ee,{path:"create-entity",element:s.jsx(ci,{})}),s.jsx(ee,{path:"create-entity/form",element:s.jsx(Ci,{})}),s.jsxs(ee,{element:s.jsx(li,{}),children:[s.jsx(ee,{path:"entities",element:s.jsx(Ei,{})}),s.jsx(ee,{path:"dashboard",element:s.jsx(_i,{})}),s.jsx(ee,{path:"payments",element:s.jsx(Di,{paymentsMode:"state"})}),s.jsx(ee,{path:"payments/state/new",element:s.jsx(Nu,{})}),s.jsx(ee,{path:"payments/state/authorization",element:s.jsx(Cu,{})}),s.jsx(ee,{path:"settings",element:s.jsx(Wi,{})}),s.jsx(ee,{path:"settings/tax-accounts/new",element:s.jsx(Yi,{})})]}),s.jsx(ee,{path:"*",element:s.jsx(ht,{to:"/",replace:!0})})]})})});exports.ApiError=zn;exports.FederalPaymentWidget=fj;exports.StatePaymentWidget=pj;exports.TaxRemittanceEmbedded=hj;exports.setRuntimeApiBaseUrl=tc;
75
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const m=d[1];if(t===d[0]){i(d);continue}if(e.external){const f=(c=e.external.registry.get(d[0]))==null?void 0:c.id;if(t!==d[0]&&f){i(d);continue}}if((u=e.metadataRegistry.get(d[0]))==null?void 0:u.id){i(d);continue}if(m.cycle){i(d);continue}if(m.count>1&&e.reused==="ref"){i(d);continue}}}function Mc(e,t){var l,c,u,d;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,y={...f},p=h.ref;if(h.ref=null,p){n(p);const b=e.seen.get(p),j=b.schema;if(j.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(j)):Object.assign(f,j),Object.assign(f,y),m._zod.parent===p)for(const k in f)k==="$ref"||k==="allOf"||k in y||delete f[k];if(j.$ref&&b.def)for(const k in f)k==="$ref"||k==="allOf"||k in b.def&&JSON.stringify(f[k])===JSON.stringify(b.def[k])&&delete f[k]}const x=m._zod.parent;if(x&&x!==p){n(x);const b=e.seen.get(x);if(b!=null&&b.schema.$ref&&(f.$ref=b.schema.$ref,b.def))for(const j in f)j==="$ref"||j==="allOf"||j in b.def&&JSON.stringify(f[j])===JSON.stringify(b.def[j])&&delete f[j]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())n(m[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,r.def??r.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&a.id===i&&delete a.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const m of e.seen.entries()){const h=m[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const m=JSON.parse(JSON.stringify(a));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:js(t,"input",e.processors),output:js(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Be(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Be(n.element,r);if(n.type==="set")return Be(n.valueType,r);if(n.type==="lazy")return Be(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Be(n.innerType,r);if(n.type==="intersection")return Be(n.left,r)||Be(n.right,r);if(n.type==="record"||n.type==="map")return Be(n.keyType,r)||Be(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Be(n.in,r)||Be(n.out,r);if(n.type==="object"){for(const a in n.shape)if(Be(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(Be(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(Be(a,r))return!0;return!!(n.rest&&Be(n.rest,r))}return!1}const Gx=(e,t={})=>r=>{const n=Lc({...r,processors:t});return Le(e,n),zc(n,e),Mc(n,e)},js=(e,t,r={})=>n=>{const{libraryOptions:a,target:i}=n??{},o=Lc({...a??{},target:i,io:t,processors:r});return Le(e,o),zc(o,e),Mc(o,e)},Xx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},eg=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=Xx[l]??l,a.format===""&&delete a.format,l==="time"&&delete a.format),u&&(a.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?a.pattern=d[0].source:d.length>1&&(a.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},tg=(e,t,r,n)=>{r.type="boolean"},rg=(e,t,r,n)=>{r.not={}},ng=(e,t,r,n)=>{},sg=(e,t,r,n)=>{const a=e._zod.def,i=wc(a.entries);i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},ag=(e,t,r,n)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),i.every(o=>typeof o=="boolean")&&(r.type="boolean"),i.every(o=>o===null)&&(r.type="null"),r.enum=i},ig=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},og=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},lg=(e,t,r,n)=>{const a=r,i=e._zod.def,{minimum:o,maximum:l}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof l=="number"&&(a.maxItems=l),a.type="array",a.items=Le(i.element,t,{...n,path:[...n.path,"items"]})},cg=(e,t,r,n)=>{var u;const a=r,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const d in o)a.properties[d]=Le(o[d],t,{...n,path:[...n.path,"properties",d]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(d=>{const m=i.shape[d]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=Le(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},ug=(e,t,r,n)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>Le(l,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=o:r.anyOf=o},dg=(e,t,r,n)=>{const a=e._zod.def,i=Le(a.left,t,{...n,path:[...n.path,"allOf",0]}),o=Le(a.right,t,{...n,path:[...n.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];r.allOf=c},mg=(e,t,r,n)=>{const a=e._zod.def,i=Le(a.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},hg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType},fg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},pg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},xg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},gg=(e,t,r,n)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;Le(o,t,n);const l=t.seen.get(e);l.ref=o},yg=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.readOnly=!0},Vc=(e,t,r,n)=>{const a=e._zod.def;Le(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType};function $a(){return $a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$a.apply(null,arguments)}function Bo(e,t){try{var r=e()}catch(n){return t(n)}return r&&r.then?r.then(void 0,t):r}function bg(e,t){for(var r={};e.length;){var n=e[0],a=n.code,i=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var l=n.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(d){return d.errors.forEach(function(m){return e.push(m)})}),t){var c=r[o].types,u=c&&c[n.code];r[o]=fi(o,t,r,a,u?[].concat(u,n.message):n.message)}e.shift()}return r}function vg(e,t){for(var r={},n=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!r[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];r[l]={message:c.message,type:c.code}}else r[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push($a({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=r[l].types,d=u&&u[a.code];r[l]=fi(l,t,r,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)n();return r}function kt(e,t,r){if(r===void 0&&(r={}),(function(n){return"_def"in n&&typeof n._def=="object"&&"typeName"in n._def})(e))return function(n,a,i){try{return Promise.resolve(Bo(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(o){return i.shouldUseNativeValidation&&Da({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Ao(bg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(n){return"_zod"in n&&typeof n._zod=="object"})(e))return function(n,a,i){try{return Promise.resolve(Bo(function(){return Promise.resolve((r.mode==="sync"?jf:Nf)(e,n,t)).then(function(o){return i.shouldUseNativeValidation&&Da({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return l instanceof Ni})(o))return{values:{},errors:Ao(vg(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function cn({label:e,required:t=!1,htmlFor:r}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})}const de=N.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",...o},l){const c=a??o.name;return s.jsxs("div",{children:[s.jsx(cn,{label:t,required:r,htmlFor:c}),s.jsx("input",{ref:l,id:c,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...o}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}),Nt=N.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",children:o,...l},c){const u=a??l.name;return s.jsxs("div",{children:[s.jsx(cn,{label:t,required:r,htmlFor:u}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:u,className:`block w-full appearance-none rounded-lg border bg-white px-3 py-2.5 pr-10 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(jg,{})]}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})});function lr({step:e,title:t,muted:r=!1,children:n}){return s.jsxs("section",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[e?s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:e}):null,s.jsx("h3",{className:`text-sm font-semibold tracking-wide ${r?"text-slate-400":"text-gov-700"}`,children:t})]}),n]})}function jg(){return s.jsx("svg",{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function qt({variant:e="error",title:t,message:r}){const n=e==="error"?"border-red-200 bg-red-50 text-red-800":"border-slate-200 bg-white text-slate-700";return s.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${n}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:r})]})}function et(e,t){var r;if(e instanceof zn){if(e.details){const n=(r=Object.values(e.details)[0])==null?void 0:r[0];if(n)return n}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Ng=I("ZodISODateTime",(e,t)=>{Ap.init(e,t),je.init(e,t)});function wg(e){return Ex(Ng,e)}const Sg=I("ZodISODate",(e,t)=>{Pp.init(e,t),je.init(e,t)});function kg(e){return Tx(Sg,e)}const Cg=I("ZodISOTime",(e,t)=>{_p.init(e,t),je.init(e,t)});function Ag(e){return Ix(Cg,e)}const Pg=I("ZodISODuration",(e,t)=>{Ep.init(e,t),je.init(e,t)});function _g(e){return Fx(Pg,e)}const Eg=(e,t)=>{Ni.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>vf(e,r)},flatten:{value:r=>bf(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Ra,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Ra,2)}},isEmpty:{get(){return e.issues.length===0}}})},at=I("ZodError",Eg,{Parent:Error}),Tg=Ds(at),Ig=Rs(at),Fg=Os(at),Dg=$s(at),Rg=kf(at),Og=Cf(at),$g=Af(at),Lg=Pf(at),zg=_f(at),Mg=Ef(at),Vg=Tf(at),qg=If(at),Uo=new WeakMap;function zs(e,t,r){const n=Object.getPrototypeOf(e);let a=Uo.get(n);if(a||(a=new Set,Uo.set(n,a)),!a.has(t)){a.add(t);for(const i in r){const o=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const Ce=I("ZodType",(e,t)=>(ke.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:js(e,"input"),output:js(e,"output")}}),e.toJSONSchema=Gx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Tg(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Fg(e,r,n),e.parseAsync=async(r,n)=>Ig(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Dg(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Rg(e,r,n),e.decode=(r,n)=>Og(e,r,n),e.encodeAsync=async(r,n)=>$g(e,r,n),e.decodeAsync=async(r,n)=>Lg(e,r,n),e.safeEncode=(r,n)=>zg(e,r,n),e.safeDecode=(r,n)=>Mg(e,r,n),e.safeEncodeAsync=async(r,n)=>Vg(e,r,n),e.safeDecodeAsync=async(r,n)=>qg(e,r,n),zs(e,"ZodType",{check(...r){const n=this.def;return this.clone(cr(n,{checks:[...n.checks??[],...r.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ur(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Dy(r,n))},superRefine(r,n){return this.check(Ry(r,n))},overwrite(r){return this.check(xn(r))},optional(){return Yo(this)},exactOptional(){return jy(this)},nullable(){return Ho(this)},nullish(){return Yo(Ho(this))},nonoptional(r){return Ay(this,r)},array(){return my(this)},or(r){return Uc([this,r])},and(r){return xy(this,r)},transform(r){return Ko(this,by(r))},default(r){return Sy(this,r)},prefault(r){return Cy(this,r)},catch(r){return _y(this,r)},pipe(r){return Ko(this,r)},readonly(){return Iy(this)},describe(r){const n=this.clone();return kn.add(n,{description:r}),n},meta(...r){if(r.length===0)return kn.get(this);const n=this.clone();return kn.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){var r;return(r=kn.get(e))==null?void 0:r.description},configurable:!0}),e)),qc=I("_ZodString",(e,t)=>{wi.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(n,a,i)=>eg(e,n,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,zs(e,"_ZodString",{regex(...n){return this.check($x(...n))},includes(...n){return this.check(Mx(...n))},startsWith(...n){return this.check(Vx(...n))},endsWith(...n){return this.check(qx(...n))},min(...n){return this.check(vs(...n))},max(...n){return this.check(Oc(...n))},length(...n){return this.check($c(...n))},nonempty(...n){return this.check(vs(1,...n))},lowercase(n){return this.check(Lx(n))},uppercase(n){return this.check(zx(n))},trim(){return this.check(Ux())},normalize(...n){return this.check(Bx(...n))},toLowerCase(){return this.check(Zx())},toUpperCase(){return this.check(Wx())},slugify(){return this.check(Yx())}})}),Bg=I("ZodString",(e,t)=>{wi.init(e,t),qc.init(e,t),e.email=r=>e.check(Rc(Bc,r)),e.url=r=>e.check(fx(Zg,r)),e.jwt=r=>e.check(_x(iy,r)),e.emoji=r=>e.check(px(Wg,r)),e.guid=r=>e.check(qo(Zo,r)),e.uuid=r=>e.check(ux(Xn,r)),e.uuidv4=r=>e.check(dx(Xn,r)),e.uuidv6=r=>e.check(mx(Xn,r)),e.uuidv7=r=>e.check(hx(Xn,r)),e.nanoid=r=>e.check(xx(Yg,r)),e.guid=r=>e.check(qo(Zo,r)),e.cuid=r=>e.check(gx(Hg,r)),e.cuid2=r=>e.check(yx(Kg,r)),e.ulid=r=>e.check(bx(Qg,r)),e.base64=r=>e.check(Cx(ny,r)),e.base64url=r=>e.check(Ax(sy,r)),e.xid=r=>e.check(vx(Jg,r)),e.ksuid=r=>e.check(jx(Gg,r)),e.ipv4=r=>e.check(Nx(Xg,r)),e.ipv6=r=>e.check(wx(ey,r)),e.cidrv4=r=>e.check(Sx(ty,r)),e.cidrv6=r=>e.check(kx(ry,r)),e.e164=r=>e.check(Px(ay,r)),e.datetime=r=>e.check(wg(r)),e.date=r=>e.check(kg(r)),e.time=r=>e.check(Ag(r)),e.duration=r=>e.check(_g(r))});function T(e){return cx(Bg,e)}const je=I("ZodStringFormat",(e,t)=>{ye.init(e,t),qc.init(e,t)}),Bc=I("ZodEmail",(e,t)=>{yp.init(e,t),je.init(e,t)});function Ug(e){return Rc(Bc,e)}const Zo=I("ZodGUID",(e,t)=>{xp.init(e,t),je.init(e,t)}),Xn=I("ZodUUID",(e,t)=>{gp.init(e,t),je.init(e,t)}),Zg=I("ZodURL",(e,t)=>{bp.init(e,t),je.init(e,t)}),Wg=I("ZodEmoji",(e,t)=>{vp.init(e,t),je.init(e,t)}),Yg=I("ZodNanoID",(e,t)=>{jp.init(e,t),je.init(e,t)}),Hg=I("ZodCUID",(e,t)=>{Np.init(e,t),je.init(e,t)}),Kg=I("ZodCUID2",(e,t)=>{wp.init(e,t),je.init(e,t)}),Qg=I("ZodULID",(e,t)=>{Sp.init(e,t),je.init(e,t)}),Jg=I("ZodXID",(e,t)=>{kp.init(e,t),je.init(e,t)}),Gg=I("ZodKSUID",(e,t)=>{Cp.init(e,t),je.init(e,t)}),Xg=I("ZodIPv4",(e,t)=>{Tp.init(e,t),je.init(e,t)}),ey=I("ZodIPv6",(e,t)=>{Ip.init(e,t),je.init(e,t)}),ty=I("ZodCIDRv4",(e,t)=>{Fp.init(e,t),je.init(e,t)}),ry=I("ZodCIDRv6",(e,t)=>{Dp.init(e,t),je.init(e,t)}),ny=I("ZodBase64",(e,t)=>{Rp.init(e,t),je.init(e,t)}),sy=I("ZodBase64URL",(e,t)=>{$p.init(e,t),je.init(e,t)}),ay=I("ZodE164",(e,t)=>{Lp.init(e,t),je.init(e,t)}),iy=I("ZodJWT",(e,t)=>{Mp.init(e,t),je.init(e,t)}),oy=I("ZodBoolean",(e,t)=>{Vp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>tg(e,r,n)});function Zr(e){return Dx(oy,e)}const ly=I("ZodUnknown",(e,t)=>{qp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ng()});function Wo(){return Rx(ly)}const cy=I("ZodNever",(e,t)=>{Bp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>rg(e,r,n)});function uy(e){return Ox(cy,e)}const dy=I("ZodArray",(e,t)=>{Up.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>lg(e,r,n,a),e.element=t.element,zs(e,"ZodArray",{min(r,n){return this.check(vs(r,n))},nonempty(r){return this.check(vs(1,r))},max(r,n){return this.check(Oc(r,n))},length(r,n){return this.check($c(r,n))},unwrap(){return this.element}})});function my(e,t){return Hx(dy,e,t)}const hy=I("ZodObject",(e,t)=>{Wp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>cg(e,r,n,a),me(e,"shape",()=>t.shape),zs(e,"ZodObject",{keyof(){return Ms(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Wo()})},loose(){return this.clone({...this._zod.def,catchall:Wo()})},strict(){return this.clone({...this._zod.def,catchall:uy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return hf(this,r)},safeExtend(r){return ff(this,r)},merge(r){return pf(this,r)},pick(r){return df(this,r)},omit(r){return mf(this,r)},partial(...r){return xf(Zc,this,r[0])},required(...r){return gf(Wc,this,r[0])}})});function Bt(e,t){const r={type:"object",shape:e??{},...G(t)};return new hy(r)}const fy=I("ZodUnion",(e,t)=>{Yp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ug(e,r,n,a),e.options=t.options});function Uc(e,t){return new fy({type:"union",options:e,...G(t)})}const py=I("ZodIntersection",(e,t)=>{Hp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>dg(e,r,n,a)});function xy(e,t){return new py({type:"intersection",left:e,right:t})}const La=I("ZodEnum",(e,t)=>{Kp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(n,a,i)=>sg(e,n,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,a)=>{const i={};for(const o of n)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new La({...t,checks:[],...G(a),entries:i})},e.exclude=(n,a)=>{const i={...t.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new La({...t,checks:[],...G(a),entries:i})}});function Ms(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new La({type:"enum",entries:r,...G(t)})}const gy=I("ZodLiteral",(e,t)=>{Qp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ag(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Gs(e,t){return new gy({type:"literal",values:Array.isArray(e)?e:[e],...G(t)})}const yy=I("ZodTransform",(e,t)=>{Jp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>og(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Nc(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Tn(i,r.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(Tn(o))}};const a=t.transform(r.value,r);return a instanceof Promise?a.then(i=>(r.value=i,r.fallback=!0,r)):(r.value=a,r.fallback=!0,r)}});function by(e){return new yy({type:"transform",transform:e})}const Zc=I("ZodOptional",(e,t)=>{Dc.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Yo(e){return new Zc({type:"optional",innerType:e})}const vy=I("ZodExactOptional",(e,t)=>{Gp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Vc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function jy(e){return new vy({type:"optional",innerType:e})}const Ny=I("ZodNullable",(e,t)=>{Xp.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>mg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Ho(e){return new Ny({type:"nullable",innerType:e})}const wy=I("ZodDefault",(e,t)=>{ex.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>fg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sy(e,t){return new wy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():kc(t)}})}const ky=I("ZodPrefault",(e,t)=>{tx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>pg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Cy(e,t){return new ky({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():kc(t)}})}const Wc=I("ZodNonOptional",(e,t)=>{rx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>hg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Ay(e,t){return new Wc({type:"nonoptional",innerType:e,...G(t)})}const Py=I("ZodCatch",(e,t)=>{nx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>xg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _y(e,t){return new Py({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ey=I("ZodPipe",(e,t)=>{sx.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>gg(e,r,n,a),e.in=t.in,e.out=t.out});function Ko(e,t){return new Ey({type:"pipe",in:e,out:t})}const Ty=I("ZodReadonly",(e,t)=>{ax.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>yg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Iy(e){return new Ty({type:"readonly",innerType:e})}const Fy=I("ZodCustom",(e,t)=>{ix.init(e,t),Ce.init(e,t),e._zod.processJSONSchema=(r,n,a)=>ig(e,r)});function Dy(e,t={}){return Kx(Fy,e,t)}function Ry(e,t){return Qx(e,t)}const Vr={custom:"custom"};function Si(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[t.length-1][0]}`.toUpperCase()}function Ct(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?e.firstName:`${e.firstName} ${e.lastName}`.trim()}function dr(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function Dr(e){const t=e.replace(/\D/g,""),r=t.length===11&&t.startsWith("1")?t.slice(1):t;return r.length!==10?e:`+1 (${r.slice(0,3)}) ${r.slice(3,6)}-${r.slice(6)}`}function Oy(e,t){const r=t.trim().toLowerCase();if(!r)return!0;const n=Ct(e).toLowerCase(),a=e.email.toLowerCase(),i=e.idNumber.replace(/\D/g,"");return n.includes(r)||a.includes(r)||i.includes(r.replace(/\D/g,""))||dr(e.idNumber).toLowerCase().includes(r)}const Yc=["LLP","LLC","Corporation","S-Corp","Partnership"],Hc=["Sole Proprietorship"],ki=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"],za=10,Kc=Bt({accountType:Ms(["Business","Individual"]),businessName:T().min(1,"Business name is required"),tradeName:T(),ein:T().min(1,"EIN is required").refine(e=>e.replace(/\D/g,"").length===9,"EIN must be 9 digits"),entityType:T().min(1,"Entity type is required"),email:Ug("Enter a valid email"),countryCode:T().min(1),phoneNumber:T().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===za,`Phone number must be ${za} digits`),address1:T().min(1,"Address is required"),address2:T(),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required")});function $y(e){const t=e.replace(/\D/g,"");return t.length===12&&t.startsWith("91")?{countryCode:"+91",national:t.slice(2)}:t.length===11&&t.startsWith("1")?{countryCode:"+1",national:t.slice(1)}:t.length===10?{countryCode:"+1",national:t}:{countryCode:"+1",national:t.slice(-za)}}function Qo(e){const{countryCode:t,national:r}=$y(e.phoneNumber),n=e.accountType==="Individual"?`${e.firstName} ${e.lastName}`.trim():e.firstName;return{accountType:e.accountType==="Individual"?"Individual":"Business",businessName:n,tradeName:e.tradeName??"",ein:dr(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:r,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function Ly(e){const t=e.businessName.trim().split(/\s+/),r=t[0]??e.businessName,n=e.accountType==="Individual"?t.slice(1).join(" ")||r:e.businessName.trim();return{firstName:r,lastName:n}}function Qc(e){const{firstName:t,lastName:r}=Ly(e);return{accountType:e.accountType,firstName:t,lastName:r,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName,phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function zy(e){const{idNumber:t,...r}=Qc(e);return r}function Lr(e,t){const r=e==null?void 0:e.from;return r&&r.startsWith("/")&&!r.startsWith("//")?r:t}function My(){var E,P,_,F,Y,M,se,q,K,te,W;const e=Se(),t=ge(),r=st(),{data:n=[]}=Ee({queryKey:["entities","mine"],queryFn:ac}),[a,i]=N.useState(null),[o,l]=N.useState(!1),c=n.length===0,u=c?"/create-entity":"/dashboard",d=Lr(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:y,setValue:p,formState:{errors:x}}=wt({resolver:kt(Kc),defaultValues:{accountType:"Individual",businessName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),b=y("accountType"),j=y("entityType"),w=b==="Individual"?Hc:Yc;N.useEffect(()=>{w.includes(j)||p("entityType",b==="Individual"?"Sole Proprietorship":"LLP")},[b,j,w,p]);const k=f(async ne=>{i(null),l(!0);try{await wh(Qc(ne)),await r.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(xe){i(et(xe,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:k,noValidate:!0,className:"space-y-8",children:[a?s.jsx(qt,{message:a}):null,s.jsx(lr,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(cn,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:b==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(E=x.businessName)==null?void 0:E.message,...h("businessName")}),s.jsx(de,{label:"Trade Name, if any",placeholder:"Enter",error:(P=x.tradeName)==null?void 0:P.message,...h("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"EIN",required:!0,placeholder:"**-*******",maxLength:10,error:(_=x.ein)==null?void 0:_.message,...h("ein")}),s.jsx(Nt,{label:"Entity Type",required:!0,error:(F=x.entityType)==null?void 0:F.message,...h("entityType"),children:w.map(ne=>s.jsx("option",{value:ne,children:ne},ne))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(Y=x.email)==null?void 0:Y.message,...h("email")}),s.jsxs("div",{children:[s.jsx(cn,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...h("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${x.phoneNumber?"border-red-300":"border-slate-200"}`,...h("phoneNumber")})]}),x.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(de,{label:"Address Line 1",required:!0,error:(M=x.address1)==null?void 0:M.message,...h("address1")}),s.jsx(de,{label:"Address Line 2",error:(se=x.address2)==null?void 0:se.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"City",required:!0,error:(q=x.city)==null?void 0:q.message,...h("city")}),s.jsxs(Nt,{label:"State",required:!0,error:(K=x.state)==null?void 0:K.message,...h("state"),children:[s.jsx("option",{value:"",children:"Select"}),ki.map(ne=>s.jsx("option",{value:ne,children:ne},ne))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"ZIP Code",required:!0,error:(te=x.zipCode)==null?void 0:te.message,...h("zipCode")}),s.jsxs(Nt,{label:"Country",required:!0,error:(W=x.country)==null?void 0:W.message,...h("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})}),s.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:m,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save"})]})]})}function Ci(){const e=Se(),t=ge(),r=Lr(t.state,"/create-entity");return s.jsxs("div",{className:"relative min-h-full bg-slate-100/80 px-4 py-8 sm:px-6 sm:py-10",children:[s.jsxs("button",{type:"button",onClick:()=>e(r),className:"absolute left-4 top-4 inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white/80 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 sm:left-6 sm:top-6",children:[s.jsx(Vy,{}),"Back"]}),s.jsx("div",{className:"mx-auto mt-8 max-w-3xl rounded-2xl border border-slate-200/80 bg-white p-6 shadow-sm sm:mt-4 sm:p-8",children:s.jsx(My,{})})]})}function Vy(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function qy(e,t){const r=new URLSearchParams({entityId:String(e)});return t!==void 0&&r.set("taxYear",String(t)),he(`/portal/dashboard?${r}`)}function By(e,t,r){const n=new URLSearchParams({entityId:String(e),category:t,taxYear:String(r)});return he(`/portal/dashboard/summary?${n}`)}function Uy(e,t,r){const n=new URLSearchParams({entityId:String(e),month:String(t)});return r!==void 0&&n.set("year",String(r)),he(`/portal/dashboard/monthly-overview?${n}`)}function Zy({entityId:e,search:t,taxYear:r,status:n,page:a=1,pageSize:i=20}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),r&&o.set("taxYear",r),n&&n!=="all"&&o.set("status",n),he(`/portal/dashboard/payments?${o}`)}function Jo({entityCount:e}){const t=Se(),{enabledPayments:r,selectedEntity:n,entities:a}=pn();return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(Xs,{}),"Add Federal Payments"]}),r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(Xs,{}),"Add State Payment"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(Xs,{}),"Add Local Payment",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n&&s.jsxs("button",{type:"button",onClick:()=>t("/entities"),className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 transition hover:border-slate-300 hover:bg-slate-50",title:"Switch organization",children:[s.jsx("span",{className:"truncate font-medium",children:n.tradeName||n.firstName}),a.length>1&&s.jsx(Yy,{})]}),s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-2 rounded-lg border border-dashed border-emerald-400 bg-white px-4 py-2.5 text-sm font-medium text-slate-700 shadow-sm transition hover:bg-emerald-50/50",children:[s.jsx(Wy,{}),"Add Entity ",e>0?`(${e})`:""]})]})]})}function Xs(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Wy(){return s.jsx("svg",{className:"h-4 w-4 text-emerald-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.356 0-4.564-.64-6.374-1.766z"})})}function Yy(){return s.jsx("svg",{className:"h-3.5 w-3.5 shrink-0 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}function Hy({title:e,description:t,buttonLabel:r,onAdd:n,comingSoon:a=!1}){return s.jsxs("article",{className:"flex flex-col rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"mx-auto mt-4 max-w-xs text-sm leading-relaxed text-slate-500",children:t}),a?s.jsx("span",{className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-5 py-2.5 text-sm font-semibold text-slate-500",children:"Coming Soon"}):s.jsxs("button",{type:"button",onClick:n,className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg bg-gov-600 px-5 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(Ky,{}),r]})]})}function Ky(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Ai({label:e="Loading…"}){return s.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-[inherit] bg-white/75","aria-live":"polite","aria-busy":"true",children:s.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-slate-500",children:[s.jsx(Qy,{}),s.jsx("span",{children:e})]})})}function Qy(){return s.jsxs("svg",{className:"h-5 w-5 animate-spin text-gov-600",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}const Jy={Draft:"Draft"};function Jc(e){switch((e??Jy.Draft).trim().toLowerCase()){case"draft":case"pending":return"drafts";case"scheduled":return"scheduled";case"processing":return"submitted";case"rejected":return"rejected";case"accepted":return"paid";default:return"drafts"}}function Vs(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function Gy(e){const t=e.submitted+e.paid+e.scheduled+e.failed;return t<=0?[{color:"bg-emerald-400",width:0},{color:"bg-orange-400",width:0},{color:"bg-amber-400",width:0},{color:"bg-red-400",width:0}]:[{color:"bg-emerald-400",width:e.paid/t*100},{color:"bg-orange-400",width:e.submitted/t*100},{color:"bg-amber-400",width:e.scheduled/t*100},{color:"bg-red-400",width:e.failed/t*100}]}const Gc="drafts";function jt(){return Pi(Gc)}function Pi(e){return`/payments?tab=${e}`}function Xy(e){return e==="failed"?"rejected":e}const eb=["January","February","March","April","May","June","July","August","September","October","November","December"];function tb({entityId:e,initialOverview:t,isDashboardLoading:r=!1}){const n=Se(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=N.useState(null);N.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=Ee({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>Uy(e,i,a),enabled:e!==null&&i!==null,placeholderData:p=>p}),m={submitted:0,paid:0,scheduled:0,failed:0},h=c?t??m:u??m,f=r||d&&!c,y=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:nb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:sb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:ab,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Failed",amount:h.failed,icon:ib,iconClassName:"rounded-full bg-red-50 text-red-500",amountClassName:"text-red-500"}];return s.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?s.jsx(Ai,{}):null,s.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-4",children:[s.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-slate-500",children:"Overview of Month"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:l,onChange:p=>o(Number(p.target.value)),disabled:f,className:"appearance-none rounded-full border border-gov-600 bg-white py-1.5 pl-4 pr-8 text-sm font-medium text-gov-600 focus:border-gov-600 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:eb.map((p,x)=>s.jsx("option",{value:x+1,children:p},p))}),s.jsx(rb,{className:"pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gov-600"})]})]}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-4",children:y.map(p=>{const x=p.icon;return s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center ${p.iconClassName}`,children:s.jsx(x,{})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs leading-4 text-slate-500",children:p.label}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("p",{className:`text-xl font-bold leading-7 ${p.amountClassName}`,children:Vs(p.amount)}),s.jsx("button",{type:"button",onClick:()=>n(Pi(Xy(p.key))),className:"text-sm font-medium text-gov-600 underline decoration-gov-600 underline-offset-2 hover:text-gov-700",children:"View Details"})]})]})]},p.key)})})]})}function rb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function nb(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 14.25v-1.5M11.25 13.5h1.5"})]})}function sb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function ab(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})}function ib(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}function Go(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function ob(e){return{id:e.id,jurisdiction:e.jurisdiction,period:e.period,amount:e.amount,paymentDate:e.paymentDate,status:e.status,statusLabel:e.statusLabel,formType:e.formType,category:e.category}}function Xo(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const lb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],el={total:0,items:[]};function cb({label:e,status:t}){const r={scheduled:"bg-amber-50 text-amber-700",paid:"bg-emerald-50 text-emerald-700",submitted:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-600"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r[t]}`,children:e})}function ub({entityId:e,initialPayments:t,isDashboardLoading:r=!1}){const[n,a]=N.useState(""),[i,o]=N.useState(""),[l,c]=N.useState(""),[u,d]=N.useState("all");N.useEffect(()=>{const j=window.setTimeout(()=>o(n),300);return()=>window.clearTimeout(j)},[n]);const m=!!i||!!l||u!=="all",{data:h,isFetching:f}=Ee({queryKey:["dashboard","payments",e,i,l,u],queryFn:()=>Zy({entityId:e,search:i||void 0,taxYear:l||void 0,status:u}),enabled:e!==null&&m,placeholderData:j=>j}),y=m?h??t??el:t??el,p=N.useMemo(()=>y.items.map(ob),[y.items]),x=N.useMemo(()=>{const j=new Date().getFullYear();return[j,j-1,j-2].map(String)},[]),b=r||m&&f;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[b?s.jsx(Ai,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(mb,{})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-bold text-slate-900",children:"My Payments"}),s.jsxs("p",{className:"text-xs text-slate-500",children:[y.total," total payments"]})]})]})}),s.jsx("div",{className:"border-b border-slate-200 p-6",children:s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"payment-search",className:"mb-1.5 block text-sm text-slate-600",children:"Search by State/Form Type"}),s.jsxs("div",{className:"relative",children:[s.jsx(db,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),s.jsx("input",{id:"payment-search",type:"text",value:n,onChange:j=>a(j.target.value),placeholder:"All",disabled:r,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"tax-period-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Tax Period"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{id:"tax-period-filter",value:l,onChange:j=>c(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[s.jsx("option",{value:"",children:"Select Year"}),x.map(j=>s.jsx("option",{value:j,children:j},j))]}),s.jsx(tl,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{id:"status-filter",value:u,onChange:j=>d(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:lb.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))}),s.jsx(tl,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"ID"}),s.jsx("th",{className:"px-6 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-6 py-3",children:"Period"}),s.jsx("th",{className:"px-6 py-3",children:"Amount"}),s.jsx("th",{className:"px-6 py-3",children:"Payment"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Form Type"}),s.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),s.jsx("tbody",{children:!b&&p.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:m?"No payments match your filters.":"No payments yet."})}):p.map((j,w)=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsxs("td",{className:"px-6 py-4 font-medium text-slate-900",children:["#",w+1]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Vs(j.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(cb,{label:j.statusLabel,status:j.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"})]})})]},`${j.category}-${j.id}`))})]})})]})}function db({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})})}function tl({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function mb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function ea({entityId:e,category:t,title:r,subtitlePrefix:n,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:u=!1}){const[d,m]=N.useState(a);if(N.useEffect(()=>{m(a)},[e,a]),u)return s.jsxs("article",{className:"flex min-h-[220px] flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:n})]}),s.jsx("div",{className:"flex flex-1 items-center justify-center",children:s.jsx("span",{className:"rounded-full border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-500",children:"Coming Soon"})})]});const h=d===a,{data:f,isFetching:y}=Ee({queryKey:["dashboard","summary",e,t,d],queryFn:()=>By(e,t,d),enabled:e!==null&&!h,placeholderData:j=>j}),p=h?o?Go(o):Xo():f?Go(f):Xo(),x=Gy(p),b=l||y&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[b?s.jsx(Ai,{}):null,s.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[n," (",p.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:d,onChange:j=>m(Number(j.target.value)),disabled:b,className:"appearance-none rounded-lg border border-slate-200 bg-white py-1.5 pl-3 pr-8 text-xs font-medium text-slate-700 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(j=>s.jsxs("option",{value:j,children:["TY ",j]},j))}),s.jsx(hb,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"})]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:c.map(j=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${j.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:j.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Vs(p[j.key])})]},j.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:x.map((j,w)=>j.width>0?s.jsx("span",{className:`${j.color} h-full`,style:{width:`${j.width}%`}},w):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function hb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const fb={federal:"Schedule federal tax deposits directly to the IRS — EFTPS payments, 941, 940, and more.",state:"Submit state tax remittances to the relevant state authority on time, every time.",local:"Local tax payment support is coming soon. Stay tuned for updates."},pb=[{key:"federal",title:"Add Your First Federal Payment",buttonLabel:"Add Federal Payment"},{key:"state",title:"Add Your First State Payment",buttonLabel:"Add State Payment"},{key:"local",title:"Add Your First Local Payment",buttonLabel:"Add Local Payments"}],Qt=new Date().getFullYear(),ta=[Qt,Qt-1,Qt-2],xb=[{label:"Submitted to IRS",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],gb=[{label:"Submitted to State",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],yb=[{label:"Submitted",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}];function _i(){const e=Se(),{entities:t,selectedEntity:r,enabledPayments:n}=pn(),a=(r==null?void 0:r.entityId)??null,{data:i,isLoading:o}=Ee({queryKey:["dashboard",a,Qt],queryFn:()=>qy(a,Qt),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(Jo,{entityCount:t.length}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:pb.filter(l=>l.key==="local"||n.includes(l.key)).map(l=>s.jsx(Hy,{title:l.title,description:fb[l.key],buttonLabel:l.buttonLabel,onAdd:l.key==="federal"?()=>e("/payments/federal/new",{state:{from:"/dashboard"}}):l.key==="state"?()=>e("/payments/state/new",{state:{from:"/dashboard",resetDraft:!0}}):void 0,comingSoon:l.key==="local"},l.key))})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(Jo,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[n.includes("federal")&&s.jsx(ea,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:Qt,taxYearOptions:ta,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:xb}),n.includes("state")&&s.jsx(ea,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:Qt,taxYearOptions:ta,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:gb}),s.jsx(ea,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:Qt,taxYearOptions:ta,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:yb,comingSoon:!0})]}),s.jsx(tb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(ub,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}function Ei(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=pn(),n=Se(),[a,i]=N.useState(""),o=e.filter(c=>Oy(c,a)),l=c=>{r(c.entityId),n("/dashboard",{replace:!0})};return s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex shrink-0 items-center gap-2 rounded-[14px] bg-[#156bd5] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1260be]",children:[s.jsx(vb,{}),"Add Entity"]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-[11px] font-semibold text-[#6a7282]",children:"Search by Entity Name/Email/EIN"}),s.jsx("input",{type:"search",value:a,onChange:c=>i(c.target.value),placeholder:"All",className:"h-[38px] w-[220px] rounded-lg border-2 border-[#e5e7eb] bg-[#f9fafb] px-3 text-sm text-slate-700 placeholder-[#99a1af] focus:border-[#156bd5] focus:outline-none"})]})]}),s.jsx("div",{className:"overflow-x-auto rounded-xl border border-black/[0.12] bg-white",children:s.jsxs("table",{className:"min-w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#f8f9fb]",children:[s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Client Name"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"EIN Number"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Email"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Phone"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Business Type"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Status"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Joined Date"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Action"})]})}),s.jsx("tbody",{children:o.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"No organizations match your search."})}):o.map(c=>s.jsx(bb,{entity:c,isSelected:c.entityId===(t==null?void 0:t.entityId),onSelect:()=>l(c)},c.entityId))})]})})]})}function bb({entity:e,isSelected:t,onSelect:r}){var l;const n=Ct(e),a=Si(n),i=((l=e.status)==null?void 0:l.toLowerCase())==="active",o=e.createdAt?new Date(e.createdAt).toISOString().slice(0,10):"—";return s.jsxs("tr",{className:["border-b border-[#e0e0e0] last:border-b-0 transition-colors",t?"bg-[#f0f7ff]":"hover:bg-slate-50"].join(" "),children:[s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] bg-[#156bd5] text-[11px] font-bold text-white",children:a}),s.jsx("span",{className:"font-semibold text-[#1e2939] text-[13px]",children:n})]})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:dr(e.idNumber)})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.email||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.phoneNumber||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.entityType||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:["inline-flex items-center rounded-full px-2 py-0.5 text-[11px]",i?"bg-[#e1f6da] text-[#010d1d]":"bg-[#feeceb] text-[#010d1d]"].join(" "),children:i?"Active":"In-active"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:o})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 rounded-full bg-[#dcebfd] px-2.5 py-0.5 text-[11px] font-semibold text-[#156bd5] transition hover:bg-[#c5ddfb]",children:t?"Selected":"Select"})})]})}function vb(){return s.jsx("svg",{className:"h-[15px] w-[15px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function jb(e){return he(`/portal/federal-payments?entityId=${e}`)}function Ti(e){return he(`/portal/federal-payments/${e}`)}function Nb(e){return he(`/portal/federal-payments/form-types?entityId=${e}`)}function wb(e){const t=new URLSearchParams({formType:e});return he(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Ii(e){return he("/portal/federal-payments",{method:"POST",body:e})}function Fi(e,t){return he(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function Sb(e){return he(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function kb(e){return he(`/portal/state-payments?entityId=${e}`)}function Cb(e){return he("/portal/state-payments",{method:"POST",body:e})}function Ab(e,t){return he(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function Xc(e){return he(`/portal/state-payments/${e}/submit`,{method:"POST"})}function Pb({actionType:e,onView:t,onEdit:r,onSubmit:n,isSubmitting:a=!1}){return e==="draft-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",onClick:r,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"}),s.jsx("button",{type:"button",onClick:n,disabled:a,className:"rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:opacity-60",children:a?"Submitting…":"Submit"})]}):e==="view-pdf"?s.jsx("button",{type:"button",className:"rounded-lg border border-gov-200 bg-gov-50 px-4 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100",children:"View PDF"}):e==="rejected-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-semibold text-red-600 hover:bg-red-100",children:"Re-Submit"})]}):s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})}function eu(e){const t=/^(\d{4})-Q([1-4])$/.exec(e);if(t)return`Q${t[2]} ${t[1]}`;if(e.length!==6)return e;const r=e.slice(0,4),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(n)||n<1||n>12?e:`Q${Math.ceil(n/3)} ${r}`}function _b(e){return{id:e.federalPaymentId,category:"federal",referenceNo:`FED-${e.federalPaymentId}`,jurisdiction:"IRS - Federal",period:eu(e.taxPeriod),amount:e.paymentAmount,paymentDate:e.settlementDate,status:e.status,reason:e.reason,tab:Jc(e.status)}}function Eb(e){return{id:e.statePaymentDetailId,category:"state",referenceNo:`ST-${e.statePaymentDetailId}`,jurisdiction:`${e.state} (State)`,period:eu(e.taxPeriod),amount:e.taxAmount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Jc(e.status)}}function Tb(e,t,r){return e.filter(n=>n.tab!==t?!1:r==="all"?!0:n.category===r)}function Ib(e){return e.reduce((t,r)=>(t[r.tab]+=1,t),{drafts:0,scheduled:0,submitted:0,rejected:0,paid:0})}function Fb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsx("path",{d:"M9.375 1.25H3.75C3.41848 1.25 3.10054 1.3817 2.86612 1.61612C2.6317 1.85054 2.5 2.16848 2.5 2.5V12.5C2.5 12.8315 2.6317 13.1495 2.86612 13.3839C3.10054 13.6183 3.41848 13.75 3.75 13.75H11.25C11.5815 13.75 11.8995 13.6183 12.1339 13.3839C12.3683 13.1495 12.5 12.8315 12.5 12.5V4.375L9.375 1.25Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M8.75 1.25V3.75C8.75 4.08152 8.8817 4.39946 9.11612 4.63388C9.35054 4.8683 9.66848 5 10 5H12.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.25 5.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 8.125H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 10.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Db({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#scheduled-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 3.75V7.5L10 8.75",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"scheduled-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function Rb({className:e,...t}){return s.jsx("svg",{width:"12",height:"10",viewBox:"0 0 12 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:s.jsx("path",{d:"M0 10V0L11.875 5L0 10ZM1.25 8.125L8.65625 5L1.25 1.875V4.0625L5 5L1.25 5.9375V8.125Z",fill:"currentColor"})})}function Ob({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#rejected-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 5V7.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 10H7.50625",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"rejected-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function $b({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#paid-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.625 7.5L6.875 8.75L9.375 6.25",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"paid-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}const tu=[{key:"drafts",label:"DRAFTS",Icon:Fb,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:Db,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:Rb,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:Ob,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:$b,iconClassName:"text-green-500"}],Lb={drafts:{columns:["ID","Jurisdiction / Type","Period","Amount","Payment Date","Actions"],emptyMessage:"No draft payments to display yet.",actionType:"draft-actions"},scheduled:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Scheduled Date","Actions"],emptyMessage:"No scheduled payments to display yet.",actionType:"view-pdf"},submitted:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Submitted Date","Actions"],emptyMessage:"No submitted to fed/state payments to display yet.",actionType:"view-link"},rejected:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Failed Date","Reason","Actions"],emptyMessage:"No rejected payments to display yet.",actionType:"rejected-actions"},paid:{columns:["Reference No","Jurisdiction / Type","Period","Amount","Actions"],emptyMessage:"No paid payments to display yet.",actionType:"view-link"}};function rl(e){return e!==null&&tu.some(t=>t.key===e)}function Di({paymentsMode:e="all"}){const t=Se(),r=st(),[n]=bm(),{selectedEntity:a}=ft(),i=(a==null?void 0:a.entityId)??null,o=n.get("tab"),[l,c]=N.useState(rl(o)?o:Gc),[u,d]=N.useState(e==="all"?"all":e),[m,h]=N.useState(null);N.useEffect(()=>{rl(o)&&c(o)},[o]);const f=Lb[l],{data:y=[],isLoading:p}=Ee({queryKey:["remittance-payments",i,e],queryFn:async()=>{const[P,_]=await Promise.all([e!=="state"?jb(i):Promise.resolve([]),e!=="federal"?kb(i):Promise.resolve([])]);return[...P.map(_b),..._.map(Eb)]},enabled:i!==null}),x=N.useMemo(()=>Ib(y),[y]),b=N.useMemo(()=>Tb(y,l,u),[y,l,u]),j=ch({mutationFn:async P=>{if(P.category==="federal"){await Sb(P.id);return}await Xc(P.id)},onSuccess:async()=>{await r.invalidateQueries({queryKey:["remittance-payments"]}),await r.invalidateQueries({queryKey:["dashboard"]}),await r.invalidateQueries({queryKey:["federal-payments"]}),await r.invalidateQueries({queryKey:["state-payments"]})},onError:()=>h(null),onSettled:()=>h(null)}),w=P=>{h(`${P.category}-${P.id}`),j.mutate(P)},k=P=>{t(`/payments/federal/${P.id}/view`)},E=P=>{t(`/payments/federal/${P.id}/edit`)};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=="state"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/payments"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(ra,{}),"Add Federal Payment"]}),e!=="federal"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/payments",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(ra,{}),"Add State Payment"]}),e==="all"&&s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(ra,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:tu.map(P=>{const _=l===P.key,F=P.Icon;return s.jsxs("button",{type:"button",onClick:()=>{c(P.key),t(Pi(P.key),{replace:!0})},className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${_?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(F,{className:`shrink-0 ${P.iconClassName}`}),P.label," (",x[P.key],")"]},P.key)})}),s.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[s.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),s.jsxs("select",{value:u,onChange:P=>d(P.target.value),className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",children:[s.jsx("option",{value:"all",children:"All"}),s.jsx("option",{value:"federal",children:"Federal"}),s.jsx("option",{value:"state",children:"State"}),s.jsx("option",{value:"local",disabled:!0,children:"Local (Coming Soon)"})]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:f.columns.map(P=>s.jsx("th",{className:"px-6 py-3",children:P},P))})}),s.jsx("tbody",{children:p?s.jsx("tr",{children:s.jsx("td",{colSpan:f.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):b.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:f.columns.length,className:"px-6 py-12 text-center text-slate-500",children:f.emptyMessage})}):b.map(P=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:l==="drafts"?`#${P.id}`:P.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Vs(P.amount)}),l!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.paymentDate}):null,l==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(Pb,{actionType:f.actionType,onView:()=>{P.category==="federal"&&k(P)},onEdit:()=>{P.category==="federal"&&E(P)},onSubmit:()=>w(P),isSubmitting:m===`${P.category}-${P.id}`})})]},`${P.category}-${P.id}`))})]})})]})]})}function ra(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function qn(e){return he(`/portal/bank-accounts?entityId=${e}`)}function zb(e){return he("/portal/bank-accounts",{method:"POST",body:e})}function ru(e,t){return he(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function vr({title:e,children:t,isFirst:r=!1,headerAction:n}){return s.jsxs("section",{className:r?"":"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),n]}),t]})}const un=17,nu=9;function Wr(e,t){return e.replace(/\D/g,"").slice(0,t)}const su=["Checking","Savings"],Mb=Bt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${un} digits`),confirmAccountNumber:T().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${un} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ms(su,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")}).refine(e=>e.accountNumber===e.confirmAccountNumber,{message:"Account numbers do not match",path:["confirmAccountNumber"]});function Vb({entityId:e,onCancel:t,onSuccess:r}){const n=st(),{showSuccess:a,showError:i}=Es(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=wt({resolver:kt(Mb),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async y=>{l(null),u(!0);try{const p=await zb({entityId:e,bankName:y.bankName.trim(),accountNumber:y.accountNumber,routingNumber:y.routingNumber,accountType:y.accountType});await n.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),r(p.bankAccountDetailId)}catch(p){const x=et(p,"Unable to save bank account.");l(x),i("Action Not Completed",x)}finally{u(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:y=>{y.preventDefault(),y.stopPropagation(),f(y)},className:"space-y-6",children:[s.jsxs(lr,{step:2,title:"Add Bank Account Manually",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Bank Account"}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(De,{name:"accountNumber",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:x=>y.onChange(Wr(x.target.value,un)),onBlur:y.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),s.jsx(De,{name:"confirmAccountNumber",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:x=>y.onChange(Wr(x.target.value,un)),onBlur:y.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),s.jsx(De,{name:"routingNumber",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:y.value,onChange:x=>y.onChange(Wr(x.target.value,nu)),onBlur:y.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),s.jsx(De,{name:"accountType",control:d,render:({field:y})=>{var p;return s.jsx(Nt,{label:"Account Type",required:!0,value:y.value,onChange:y.onChange,onBlur:y.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:su.map(x=>s.jsx("option",{value:x,children:x},x))})}})]}),s.jsx(De,{name:"bankName",control:d,render:({field:y})=>{var p;return s.jsx(de,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:y.value,onChange:y.onChange,onBlur:y.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?s.jsx(qt,{message:o}):null,s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx("button",{type:"button",onClick:t,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"button",disabled:c,onClick:()=>void f(),className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:c?"Saving…":"Save"})]})]})}function au({open:e,entityId:t,onClose:r,onAccountAdded:n}){const[a,i]=N.useState("choose");if(N.useEffect(()=>{e||i("choose")},[e]),N.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,r]),!e)return null;const o=a==="manual";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"add-bank-account-title",className:`relative w-full rounded-3xl bg-white p-8 shadow-xl ${o?"max-w-2xl":"max-w-[420px]"}`,children:o&&t?s.jsx(Vb,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{n==null||n(l),r()}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:"1"}),s.jsx("h2",{id:"add-bank-account-title",className:"text-sm font-medium uppercase tracking-[0.2em] text-slate-400",children:"Add Bank Account"})]}),s.jsx("div",{className:"my-6 h-px bg-slate-200"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("button",{type:"button",onClick:()=>i("manual"),disabled:!t,className:"flex w-full items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gov-600 text-white",children:s.jsx(qb,{className:"h-5 w-5"})}),s.jsx("span",{className:"text-base font-semibold text-slate-900",children:"Add Manually"})]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"flex w-full cursor-not-allowed items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-slate-200 bg-white",children:s.jsx(Bb,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function qb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 7.5h10.5M6.75 12h10.5m-10.5 4.5h10.5M3.75 6.75A2.25 2.25 0 016 3.75h12A2.25 2.25 0 0120.25 6.75v10.5A2.25 2.25 0 0118 21H6A2.25 2.25 0 013.75 18.75V6.75z"})})}function Bb({className:e}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",fill:"#111827",opacity:"0.35"})]})}const Ub=12,Zb=["January","February","March","April","May","June","July","August","September","October","November","December"];function ir(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function Ns(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const r=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(r,n,a);return i.getFullYear()!==r||i.getMonth()!==n||i.getDate()!==a?null:i}function qs(e=new Date){const t=new Date(e);return e.getHours()>=Ub&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),ir(t)}function iu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),ir(t)}function Wb(e=18,t=new Date){const r=new Date(t);return r.setFullYear(r.getFullYear()-e),r.setHours(0,0,0,0),ir(r)}function Yb(e,t,r=new Date){const n=Ns(e);if(!n)return!1;const a=new Date(r);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),n.setHours(0,0,0,0),n<=a}function Hb(e){const t=e.getDay();return t!==0&&t!==6}function Ma(e,t=new Date){if(!Hb(e))return!1;const r=ir(e);return r>=qs(t)&&r<=iu(t)}function ou(e,t=new Date){const r=Ns(e);return r?Ma(r,t):!1}function Kb(e,t){return`${Zb[t]} ${e}`}function Qb(e,t){const r=new Date(e,t,1),n=new Date(e,t+1,0).getDate(),a=r.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=n;o+=1)i.push(new Date(e,t,o));return i}function nl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Bn(e){const t=Number.parseFloat(e);return!e||Number.isNaN(t)?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(t)}function lu({label:e,required:t=!1,htmlFor:r,info:n}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 flex items-center gap-1.5 text-sm text-slate-600",children:[s.jsxs("span",{children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}),n?s.jsx("span",{title:n,className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-slate-300 text-[10px] font-semibold leading-none text-slate-400","aria-label":n,children:"i"}):null]})}function Z({label:e,required:t,error:r,info:n,children:a}){return s.jsxs("div",{children:[s.jsx(lu,{label:e,required:t,info:n}),a,r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}const cu=e=>`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${e?"border-red-300":"border-slate-200"}`;function J(e,t=!1){return t?`block w-full cursor-default rounded-lg border bg-[#F9FAFB] px-3 py-2.5 text-sm text-slate-700 focus:outline-none ${e?"border-red-300":"border-[#E5E7EB]"}`:cu(e)}function Yr(e){return`${cu(e)} appearance-none`}function Br({className:e}){return s.jsx("svg",{className:e??"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function An({children:e}){return s.jsx("div",{className:"relative",children:e})}function uu({value:e,onChange:t,entityId:r,entityType:n="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[u,d]=N.useState(!1),[m,h]=N.useState(!1),f=N.useRef(null),y=a.find(x=>String(x.bankAccountDetailId)===e);N.useEffect(()=>{if(!u)return;const x=b=>{var j;(j=f.current)!=null&&j.contains(b.target)||d(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[u]);const p=x=>{t(String(x)),h(!1),d(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,className:"relative",children:[s.jsx(lu,{label:c,required:!0}),s.jsxs("button",{type:"button",disabled:o||!r,onClick:()=>d(x=>!x),className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${l?"border-red-300":"border-slate-200"}`,children:[s.jsx("span",{className:y?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":y?nl(y.accountNumber):"Bank account number"}),s.jsx(Gb,{className:`shrink-0 text-slate-400 transition ${u?"rotate-180":""}`})]}),l?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,u?s.jsxs("div",{className:"absolute left-0 right-0 z-20 mt-2 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"p-3",children:s.jsxs("button",{type:"button",onClick:()=>{d(!1),h(!0)},className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(Jb,{}),"Add Bank Account"]})}),s.jsx("div",{className:"border-t border-slate-200 px-4 py-2",children:s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"List of Bank Accounts"})}),s.jsx("div",{className:"max-h-64 overflow-y-auto pb-2",children:a.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):a.map(x=>{const b=String(x.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(x.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${b?"bg-gov-50":""}`,children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:Si(x.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:x.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[nl(x.accountNumber),n?` · ${n}`:` · ${x.accountType}`]})]})]},x.bankAccountDetailId)})})]}):null]}),s.jsx(au,{open:m,entityId:r,onClose:()=>h(!1),onAccountAdded:p})]})}function Jb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Gb({className:e=""}){return s.jsx("svg",{className:`h-4 w-4 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Xb(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Un({entity:e,remittanceAmount:t="—",className:r=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No entity selected."})]});const n=Ct(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsxs("dl",{className:"space-y-4 p-5 text-sm",children:[s.jsx(jn,{label:"Entity Name",value:n}),s.jsx(jn,{label:"Tax ID",value:dr(e.idNumber)}),s.jsx(jn,{label:"Email ID",value:e.email}),s.jsx(jn,{label:"Phone Number",value:Dr(e.phoneNumber)}),s.jsx(jn,{label:"Address",value:Xb(e)})]}),s.jsxs("div",{className:"border-t border-slate-100 px-5 py-4",children:[s.jsx("p",{className:"text-sm font-medium text-[#99A1AF]",children:"Remittance Amount"}),s.jsx("p",{className:"mt-1.5 text-xl font-bold text-gov-600",children:t})]})]})}function jn({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm font-medium text-slate-500",children:e}),s.jsx("dd",{className:"mt-0.5 text-sm leading-relaxed text-slate-800",children:t})]})}const e0=[0,1,3,4,6,7,9,10],t0=[0,1,2,3,4,5,6,7,8,9,10],r0=[0,1,2,3,4,5,6,8,9,10,11],n0=[0,1,2,3,4,5,6,7,9,10,11],s0=["720","941"],a0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],i0=["7200D"],o0=["8963"];function du(e){return s0.includes(e)?e0:a0.includes(e)?t0:i0.includes(e)?r0:o0.includes(e)?n0:[]}function l0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function ws(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(r)||r<1||r>12?null:{year:t,month:r-1}}function c0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function mu(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Ss={941:"94105",944:"94405","CT-1":"10005"},Nn={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Va={regex:/^(?!0+(?:\.0+)?$)(?:100000000(?:\.00?)?|(?:\d{1,8}|\d{1,7}\d)(?:\.\d{1,2})?)$/,errorMessage:"Payment amount must be a number greater than 0, can include up to 2 decimal places, and must not exceed 100,000,000 (one hundred million)."};function Ri(e,t){return!e||!t?!1:Ss[e]===t}function Bs(e,t){return e==="CT-1"&&t===Ss["CT-1"]}function u0(e,t){return e==="941"&&t===Ss[941]||e==="944"&&t===Ss[944]}function d0(e){return e==="CT-1"?{code1:Nn.tier1,code2:Nn.tier2,code3:""}:{code1:Nn.socialSecurity,code2:Nn.medicare,code3:Nn.withheld}}function qa(e){return Va.regex.test(e)}const m0=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,es=1e8;function h0(e){if(!e)return"";let t="",r=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!r&&(t+=c,r=!0);const n=t.indexOf(".");let a=n===-1?t:t.slice(0,n);const i=n===-1?"":t.slice(n+1,n+3),o=n!==-1&&t.endsWith(".");if(a.length>9&&(a=a.slice(0,9)),a.length===9&&a!=="100000000"&&(a=a.slice(0,8)),a.length>0&&!o&&i===""){const c=Number.parseInt(a,10);!Number.isNaN(c)&&c>es&&(a=String(es))}let l=n===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),m0.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>es)return String(es)}return l}return""}function hu(e){return qa(e)?Number.parseFloat(e):null}function f0(e,t,r,n){const a=[e,t];return n&&a.push(r),a.reduce((i,o)=>{const l=hu(o);return l===null?i:i+l},0)}function p0(e,t){return Math.abs(e-t)<.005}function x0(e,t,r,n,a){if(!Ri(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=Bs(e,t);return{subcategoryCode1:r.trim()?"1":null,subcategoryCode2:n.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const g0=["Su","Mo","Tu","We","Th","Fr","Sa"];function y0(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function b0({value:e,onChange:t,disabled:r=!1,hasError:n=!1}){const a=Ns(e),i=qs(),o=iu(),[l,c]=N.useState(!1),[u,d]=N.useState(()=>a??Ns(i)??new Date),m=N.useRef(null),h=N.useId();N.useEffect(()=>{a&&d(a)},[e]),N.useEffect(()=>{if(!l)return;const b=j=>{var w;(w=m.current)!=null&&w.contains(j.target)||c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);const f=N.useMemo(()=>Qb(u.getFullYear(),u.getMonth()),[u]),y=N.useMemo(()=>{const b=new Date(u.getFullYear(),u.getMonth()-1,1),j=new Date(b.getFullYear(),b.getMonth()+1,0);return ir(j)>=i},[u,i]),p=N.useMemo(()=>{const b=new Date(u.getFullYear(),u.getMonth()+1,1);return ir(b)<=o},[u,o]),x=b=>{Ma(b)&&(t(ir(b)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:r,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!r&&c(b=>!b),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>c(b=>!b),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open settlement date picker",children:s.jsx(y0,{})})]}),l?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[300px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!y,onClick:()=>d(b=>new Date(b.getFullYear(),b.getMonth()-1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:Kb(u.getFullYear(),u.getMonth())}),s.jsx("button",{type:"button",disabled:!p,onClick:()=>d(b=>new Date(b.getFullYear(),b.getMonth()+1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pt-2 text-center text-xs font-medium text-slate-500",children:g0.map(b=>s.jsx("div",{className:"py-1",children:b},b))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((b,j)=>{if(!b)return s.jsx("div",{},`empty-${j}`);const w=ir(b),k=e===w,E=!Ma(b);return s.jsx("button",{type:"button","aria-disabled":E,onClick:()=>x(b),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":k?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:b.getDate()},w)})})]}):null]})}function ts({value:e,onChange:t,onBlur:r,name:n,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:n,value:e,disabled:a,readOnly:i,placeholder:o,className:J(l,i),onChange:c=>t(h0(c.target.value)),onBlur:r})}const v0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function j0(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function N0({value:e,onChange:t,disabled:r=!1,hasError:n=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=mu(),l=ws(e),[c,u]=N.useState(!1),[d,m]=N.useState((l==null?void 0:l.year)??o),h=N.useRef(null),f=N.useId();N.useEffect(()=>{l&&m(l.year)},[e]),N.useEffect(()=>{if(!c)return;const w=k=>{var E;(E=h.current)!=null&&E.contains(k.target)||u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]);const y=l0(e),p=w=>!!a.includes(w),x=w=>{p(w)||(t(c0(d,w)),u(!1))},b=d>i,j=d<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:f,type:"text",readOnly:!0,disabled:r,value:y,placeholder:"YYYY-MM",onClick:()=>!r&&u(w=>!w),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>u(w=>!w),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open tax period picker",children:s.jsx(j0,{})})]}),c?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[280px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!b,onClick:()=>m(w=>w-1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous year",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:d}),s.jsx("button",{type:"button",disabled:!j,onClick:()=>m(w=>w+1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next year",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-3 gap-1 p-3",children:v0.map((w,k)=>{const E=(l==null?void 0:l.year)===d&&l.month===k&&e.length===6,P=p(k);return s.jsx("button",{type:"button","aria-disabled":P,onClick:()=>x(k),className:`rounded-lg px-2 py-2.5 text-sm transition ${P?"cursor-not-allowed text-slate-300 hover:bg-sky-50":E?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:w},w)})})]}):null]})}const fu="Active",w0="Inactive";function gn(e){return(e.status??fu).trim().toLowerCase()==="active"}function S0(e){return gn(e)?w0:fu}function k0(e){return gn(e)?"Deactivate":"Activate"}function Oi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function C0(e){return Oi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function pu(e){const t=x0(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),r=Bs(e.taxFormType,e.taxTypeCode);return{subcategoryCode1:t.subcategoryCode1,subcategoryAmount1:e.subcategoryAmount1?Number.parseFloat(e.subcategoryAmount1):null,subcategoryCode2:t.subcategoryCode2,subcategoryAmount2:e.subcategoryAmount2?Number.parseFloat(e.subcategoryAmount2):null,subcategoryCode3:t.subcategoryCode3,subcategoryAmount3:!r&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function $i(e,t){return{entityId:e,taxpayerPin:t.taxpayerPin||null,secondaryTin:t.secondaryTin||null,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10),taxFormType:t.taxFormType,taxTypeCode:t.taxTypeCode,taxPeriod:t.taxPeriod,settlementDate:t.settlementDate,paymentAmount:Number.parseFloat(t.paymentAmount),...pu(t)}}function Li(e){return{taxpayerPin:e.taxpayerPin||null,secondaryTin:e.secondaryTin||null,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10),taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:Number.parseFloat(e.paymentAmount),...pu(e)}}const zi="federal-payment-draft";function Mi(e){sessionStorage.setItem(zi,JSON.stringify(e))}function Us(){const e=sessionStorage.getItem(zi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Vi(){sessionStorage.removeItem(zi)}function A0(e,t={}){return{federalPaymentId:e.federalPaymentId,enrollmentId:e.enrollmentId,taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId?String(e.bankAccountDetailId):"",routingNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:t.accountType??"",bankName:t.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:String(e.paymentAmount),subcategoryAmount1:e.subcategoryAmount1!=null?String(e.subcategoryAmount1):"",subcategoryAmount2:e.subcategoryAmount2!=null?String(e.subcategoryAmount2):"",subcategoryAmount3:e.subcategoryAmount3!=null?String(e.subcategoryAmount3):""}}const P0=Bt({taxpayerPin:T().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:T().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional(),taxFormType:T().min(1,"Tax form type is required"),taxTypeCode:T().min(1,"Payment type is required"),taxPeriod:T().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=ws(e);if(!t)return!1;const{minYear:r,maxYear:n}=mu();return t.year>=r&&t.year<=n},"Tax period must be within the last 3 years"),settlementDate:T().min(1,"This field is required").refine(e=>ou(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:T().min(1,"This field is required").refine(e=>qa(e),Va.errorMessage),subcategoryCode1:T().optional(),subcategoryAmount1:T().optional(),subcategoryCode2:T().optional(),subcategoryAmount2:T().optional(),subcategoryCode3:T().optional(),subcategoryAmount3:T().optional()}).superRefine((e,t)=>{var l;if(e.taxPeriod&&e.taxFormType){const c=ws(e.taxPeriod);c&&du(e.taxFormType).includes(c.month)&&t.addIssue({code:Vr.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Ri(e.taxFormType,e.taxTypeCode))return;const r=Bs(e.taxFormType,e.taxTypeCode),n=u0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:Vr.custom,message:"This field is required",path:[u]});return}qa(c)||t.addIssue({code:Vr.custom,message:Va.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",n);const i=hu(e.paymentAmount),o=f0(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",n);i!==null&&!p0(i,o)&&t.addIssue({code:Vr.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),r&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Vr.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),rs="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function na(e){return{taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:e.paymentAmount,subcategoryCode1:e.subcategoryCode1??"",subcategoryAmount1:e.subcategoryAmount1??"",subcategoryCode2:e.subcategoryCode2??"",subcategoryAmount2:e.subcategoryAmount2??"",subcategoryCode3:e.subcategoryCode3??"",subcategoryAmount3:e.subcategoryAmount3??""}}const _0={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function E0(e,t){if(e)return na(e);if(t!=null&&t.paymentDraft)return na(t.paymentDraft);const r=Us();return r?na(r):_0}function xu({entity:e,initialDraft:t,readonly:r=!1,onCancel:n}){var mr,Et,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,zr;const a=Se(),i=ge(),o=st(),l=Lr(i.state,jt()),c=i.state,u=N.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Us()??null,[t,c==null?void 0:c.paymentDraft]),d=N.useRef(u==null?void 0:u.federalPaymentId),m=N.useRef(u==null?void 0:u.enrollmentId),[h,f]=N.useState(null),[y,p]=N.useState(!1),x=N.useMemo(()=>E0(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);N.useEffect(()=>{u!=null&&u.federalPaymentId&&(d.current=u.federalPaymentId),u!=null&&u.enrollmentId&&(m.current=u.enrollmentId)},[u==null?void 0:u.federalPaymentId,u==null?void 0:u.enrollmentId]);const{data:b=[],isLoading:j}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>qn(e.entityId),enabled:e!==null}),w=N.useMemo(()=>b.filter(gn),[b]),{data:k=[],isLoading:E}=Ee({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>Nb(e.entityId),enabled:e!==null}),{register:P,control:_,handleSubmit:F,watch:Y,setValue:M,trigger:se,formState:{errors:q}}=wt({resolver:kt(P0),defaultValues:x}),K=Y("bankAccountDetailId"),te=Y("paymentAmount"),W=Y("taxFormType"),ne=Y("taxTypeCode"),xe=Y("taxPeriod"),pe=Y("settlementDate"),H=Y("subcategoryAmount1"),Pe=Y("subcategoryAmount2"),pt=Y("subcategoryAmount3"),le=N.useRef(W),Re=N.useMemo(()=>W?du(W):[],[W]),ze=N.useMemo(()=>Ri(W,ne),[W,ne]),He=N.useMemo(()=>Bs(W,ne),[W,ne]),{data:At=[],isLoading:it}=Ee({queryKey:["federal-tax-type-codes",W],queryFn:()=>wb(W),enabled:!!W});N.useEffect(()=>{le.current&&le.current!==W&&M("taxTypeCode",""),le.current=W},[W,M]),N.useEffect(()=>{if(!xe||!W)return;const z=ws(xe);z&&Re.includes(z.month)&&M("taxPeriod","")},[W,xe,Re,M]),N.useEffect(()=>{pe&&(ou(pe)||M("settlementDate",""))},[pe,M]),N.useEffect(()=>{if(!ze){M("subcategoryCode1",""),M("subcategoryCode2",""),M("subcategoryCode3",""),M("subcategoryAmount1",""),M("subcategoryAmount2",""),M("subcategoryAmount3","");return}const z=d0(W);M("subcategoryCode1",z.code1),M("subcategoryCode2",z.code2),M("subcategoryCode3",He?"":z.code3),He&&M("subcategoryAmount3","")},[ze,W,He,M]),N.useEffect(()=>{ze&&(se("paymentAmount"),se("subcategoryAmount1"),se("subcategoryAmount2"),se("subcategoryAmount3"))},[H,Pe,pt,ze,se]),N.useEffect(()=>{const z=w.find(ae=>String(ae.bankAccountDetailId)===K);if(!z){K&&(M("bankAccountDetailId",""),M("routingNumber",""),M("accountType",""),M("bankName",""));return}M("routingNumber",z.routingNumber),M("accountType",z.accountType),M("bankName",z.bankName)},[w,K,M]);const ot=z=>{const ae=w.find(g=>String(g.bankAccountDetailId)===z.bankAccountDetailId);return{federalPaymentId:d.current,enrollmentId:m.current??(u==null?void 0:u.enrollmentId),form8655AuthorizationId:u==null?void 0:u.form8655AuthorizationId,form9783EnrollmentId:u==null?void 0:u.form9783EnrollmentId,taxpayerPin:z.taxpayerPin??"",secondaryTin:z.secondaryTin??"",bankAccountDetailId:z.bankAccountDetailId,routingNumber:z.routingNumber??(ae==null?void 0:ae.routingNumber)??"",accountNumber:(ae==null?void 0:ae.accountNumber)??"",accountType:z.accountType??(ae==null?void 0:ae.accountType)??"",bankName:z.bankName??(ae==null?void 0:ae.bankName)??"",taxFormType:z.taxFormType,taxTypeCode:z.taxTypeCode,taxPeriod:z.taxPeriod,settlementDate:z.settlementDate,paymentAmount:z.paymentAmount,subcategoryCode1:z.subcategoryCode1,subcategoryAmount1:z.subcategoryAmount1,subcategoryCode2:z.subcategoryCode2,subcategoryAmount2:z.subcategoryAmount2,subcategoryCode3:z.subcategoryCode3,subcategoryAmount3:z.subcategoryAmount3}},Pt=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},oe=async z=>{if(!e)return null;if(z.federalPaymentId){const g=await Fi(z.federalPaymentId,Li(z));return d.current=g.federalPaymentId,m.current=g.enrollmentId,g}const ae=await Ii($i(e.entityId,z));return d.current=ae.federalPaymentId,m.current=ae.enrollmentId,ae},Te=F(async z=>{if(!(r||!e)){f(null),p(!0);try{const ae=ot(z),g=await oe(ae);if(!g)return;const S={...ae,federalPaymentId:g.federalPaymentId,enrollmentId:g.enrollmentId};await Pt(),Mi(S),a(C0(e),{state:{from:l,paymentDraft:S}})}catch(ae){f(et(ae,"Failed to save payment details."))}finally{p(!1)}}}),lt=F(async z=>{if(!(!e||r)){f(null),p(!0);try{const ae=ot(z);await oe(ae),await Pt(),Vi(),a(jt())}catch(ae){f(et(ae,"Failed to save draft."))}finally{p(!1)}}}),_t=()=>{if(n){n();return}a(l)},xt=e?Ct(e):"Entity";return s.jsxs("form",{onSubmit:Te,noValidate:!0,className:"w-full space-y-6",children:[h?s.jsx(qt,{message:h}):null,s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:xt}),s.jsx(Un,{entity:e,remittanceAmount:Bn(te),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:[s.jsx(vr,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Taxpayer PIN",required:!0,error:(mr=q.taxpayerPin)==null?void 0:mr.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:J(!!q.taxpayerPin),maxLength:4,disabled:r,...P("taxpayerPin")})}),s.jsx(Z,{label:"Secondary TIN",error:(Et=q.secondaryTin)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:J(!!q.secondaryTin),maxLength:9,disabled:r,...P("secondaryTin")})}),s.jsx(De,{name:"bankAccountDetailId",control:_,render:({field:z})=>{var ae;return s.jsx(uu,{value:z.value,onChange:z.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:w,isLoading:j,disabled:!e||r,error:(ae=q.bankAccountDetailId)==null?void 0:ae.message})}}),s.jsx(Z,{label:"Routing Number",required:!0,error:(Ut=q.routingNumber)==null?void 0:Ut.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:J(!!q.routingNumber,!0),...P("routingNumber")})}),s.jsx(Z,{label:"Account Type",required:!0,error:(Tt=q.accountType)==null?void 0:Tt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:J(!!q.accountType,!0),...P("accountType")})}),s.jsx(Z,{label:"Bank Name",required:!0,error:(It=q.bankName)==null?void 0:It.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:J(!!q.bankName,!0),...P("bankName")})})]})}),s.jsx(vr,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Tax Form Type",required:!0,error:(hr=q.taxFormType)==null?void 0:hr.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!q.taxFormType),disabled:E||!e||r,...P("taxFormType"),children:[s.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),k.map(z=>s.jsx("option",{value:z.value,children:z.value},z.value))]}),s.jsx(Br,{})]})}),s.jsx(Z,{label:"Payment Type",required:!0,error:(Zt=q.taxTypeCode)==null?void 0:Zt.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!q.taxTypeCode),disabled:!W||it||r,...P("taxTypeCode"),children:[s.jsx("option",{value:"",children:W?it?"Loading payment types…":"Select payment type":"Select tax form first"}),At.map(z=>s.jsxs("option",{value:z.code,children:[z.code," - ",z.codeName]},z.code))]}),s.jsx(Br,{})]})}),s.jsx(Z,{label:"Tax Period",required:!0,error:(fr=q.taxPeriod)==null?void 0:fr.message,children:s.jsx(De,{name:"taxPeriod",control:_,render:({field:z})=>s.jsx(N0,{value:z.value,onChange:z.onChange,hasError:!!q.taxPeriod,disabled:!W||r,disabledMonths:Re})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(Z,{label:"Settlement Date",required:!0,error:(Wt=q.settlementDate)==null?void 0:Wt.message,children:s.jsx(De,{name:"settlementDate",control:_,render:({field:z})=>s.jsx(b0,{value:z.value,onChange:z.onChange,hasError:!!q.settlementDate,disabled:r})})}),s.jsx(Z,{label:"Payment Amount",required:!0,error:(Yt=q.paymentAmount)==null?void 0:Yt.message,children:s.jsx(De,{name:"paymentAmount",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value,onChange:z.onChange,onBlur:z.onBlur,disabled:r,hasError:!!q.paymentAmount})})})]}),ze?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Subcategory Code 1",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...P("subcategoryCode1")})}),s.jsx(Z,{label:"Subcategory Code 2",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...P("subcategoryCode2")})}),He?null:s.jsx(Z,{label:"Subcategory Code 3",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...P("subcategoryCode3")})})]}),s.jsxs("div",{className:rs,children:[s.jsx(Z,{label:"Subcategory Amount 1",required:!0,error:(pr=q.subcategoryAmount1)==null?void 0:pr.message,children:s.jsx(De,{name:"subcategoryAmount1",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!q.subcategoryAmount1})})}),s.jsx(Z,{label:"Subcategory Amount 2",required:!0,error:(xr=q.subcategoryAmount2)==null?void 0:xr.message,children:s.jsx(De,{name:"subcategoryAmount2",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!q.subcategoryAmount2})})}),He?null:s.jsx(Z,{label:"Subcategory Amount 3",required:!0,error:(zr=q.subcategoryAmount3)==null?void 0:zr.message,children:s.jsx(De,{name:"subcategoryAmount3",control:_,render:({field:z})=>s.jsx(ts,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!q.subcategoryAmount3})})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:_t,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:r?"Back":"Cancel"}),r?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:lt,disabled:!e||y,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:y?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||y,className:"inline-flex h-11 min-w-[160px] items-center justify-center rounded-lg bg-gov-600 px-10 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:y?"Saving…":"Next"})]})]})]},i.key)}function gu(){const{selectedEntity:e}=ft();return s.jsx(xu,{entity:e})}function yu({mode:e}){var m;const t=Se(),{federalPaymentId:r}=Pd(),{selectedEntity:n}=ft(),a=Number.parseInt(r??"",10),{data:i,isLoading:o,isError:l}=Ee({queryKey:["federal-payment",a],queryFn:()=>Ti(a),enabled:Number.isFinite(a)}),{data:c=[]}=Ee({queryKey:["bank-accounts",n==null?void 0:n.entityId],queryFn:()=>qn(n.entityId),enabled:n!==null&&i!==void 0}),u=N.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return A0(i,{routingNumber:h==null?void 0:h.routingNumber,accountNumber:h==null?void 0:h.accountNumber,accountType:h==null?void 0:h.accountType,bankName:h==null?void 0:h.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(ht,{to:jt(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!u)return s.jsx(ht,{to:jt(),replace:!0});if(!n||i.entityId!==n.entityId)return s.jsx(ht,{to:jt(),replace:!0});const d=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(xu,{entity:n,initialDraft:u,readonly:d,onCancel:()=>t(jt())})}function bu(){return ft(),s.jsx(yu,{mode:"edit"})}function vu(){return ft(),s.jsx(yu,{mode:"view"})}const T0=["Withholding Tax","Estimated Tax","Income Tax"],sl=[{code:"VA",name:"Virginia"}],I0=[{value:"Q1",label:"Q1"},{value:"Q2",label:"Q2"},{value:"Q3",label:"Q3"},{value:"Q4",label:"Q4"}];function F0(){const e=new Date().getFullYear();return[e,e-1,e-2]}const qi="state-payment-draft";function Ba(e){sessionStorage.setItem(qi,JSON.stringify(e))}function ju(){const e=sessionStorage.getItem(qi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ua(){sessionStorage.removeItem(qi)}function Nu(e,t){return`${e}-${t}`}function D0(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Nu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function R0(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Nu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}const O0=Bt({state:T().min(1,"State is required"),reasonForPayment:T().min(1,"Reason for payment is required"),stateAccountId:T().min(1,"State ID is required"),accountId:T().min(1,"Account ID is required"),letterId:T().optional(),taxYear:T().min(1,"Tax year is required"),taxPeriod:T().min(1,"Tax period is required"),taxAmount:T().min(1,"Tax amount is required").refine(e=>Number.parseFloat(e)>0,"Tax amount must be greater than 0"),paymentDate:T().min(1,"Payment date is required").refine(e=>e>=qs(),"Payment date must be a future date"),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional()}),sa="grid gap-x-6 gap-y-5 sm:grid-cols-3",al="grid gap-x-6 gap-y-5 sm:grid-cols-2",il="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ol={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function $0({entity:e}){var se,q,K,te,W,ne,xe,pe;const t=Se(),r=ge(),n=Lr(r.state,"/payments"),a=r.state,i=N.useMemo(()=>a!=null&&a.paymentDraft?a.paymentDraft:a!=null&&a.resetDraft?(Ua(),ol):ju()??ol,[a==null?void 0:a.paymentDraft,a==null?void 0:a.resetDraft,r.key]),o=N.useMemo(()=>F0(),[]),l=qs(),{data:c=[],isLoading:u}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>qn(e.entityId),enabled:e!==null}),d=N.useMemo(()=>c.filter(gn),[c]),{register:m,control:h,handleSubmit:f,watch:y,setValue:p,formState:{errors:x}}=wt({resolver:kt(O0),defaultValues:i}),b=y("state"),j=y("reasonForPayment"),w=y("taxAmount"),k=y("bankAccountDetailId"),E=!!(b&&j),[P,_]=N.useState(!1),F=(se=sl.find(H=>H.code===b))==null?void 0:se.name;N.useEffect(()=>{const H=d.find(Pe=>String(Pe.bankAccountDetailId)===k);if(!H){k&&(p("bankAccountDetailId",""),p("routingNumber",""),p("accountType",""),p("bankName",""));return}p("routingNumber",H.routingNumber),p("accountType",H.accountType),p("bankName",H.bankName)},[d,k,p]);const Y=f(H=>{const Pe={state:H.state,reasonForPayment:H.reasonForPayment,stateAccountId:H.stateAccountId,accountId:H.accountId,letterId:H.letterId,taxYear:H.taxYear,taxPeriod:H.taxPeriod,taxAmount:H.taxAmount,paymentDate:H.paymentDate,bankAccountDetailId:H.bankAccountDetailId,routingNumber:H.routingNumber,accountType:H.accountType,bankName:H.bankName};Ba(Pe),t("/payments/state/authorization",{state:{from:n,paymentDraft:Pe}})}),M=e?Ct(e):"Entity";return s.jsx("form",{onSubmit:Y,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:M}),s.jsx(Un,{entity:e,remittanceAmount:Bn(w),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"lg:mr-[324px]",children:s.jsxs("div",{className:"mx-auto w-full max-w-[720px] space-y-5",children:[s.jsxs("section",{className:il,children:[s.jsx(ll,{step:1,title:"Choose a State"}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>_(H=>!H),className:"flex w-full items-center justify-between rounded-xl border border-slate-200 bg-slate-50/80 px-4 py-4 text-left transition hover:border-gov-300 hover:bg-gov-50/40",children:[s.jsxs("span",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:s.jsx(L0,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:F??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Br,{className:`h-4 w-4 text-slate-400 transition ${P?"rotate-180":""}`})]}),P?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-2 max-h-64 overflow-y-auto rounded-xl border border-slate-200 bg-white shadow-lg",children:sl.map(H=>s.jsxs("button",{type:"button",onClick:()=>{p("state",H.code,{shouldValidate:!0}),_(!1)},className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${b===H.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:H.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:H.code})]},H.code))}):null,x.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.state.message}):null]}),s.jsx(Z,{label:"Reason for Payment",required:!0,error:(q=x.reasonForPayment)==null?void 0:q.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!x.reasonForPayment),...m("reasonForPayment"),children:[s.jsx("option",{value:"",children:"Select reason"}),T0.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsx(Br,{})]})})]})]}),s.jsxs("section",{className:`${il} transition ${E?"":"opacity-60"}`,children:[s.jsx(ll,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!E,className:"min-w-0 border-0 p-0",children:[s.jsx(aa,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:sa,children:[s.jsx(Z,{label:"State ID",required:!0,error:(K=x.stateAccountId)==null?void 0:K.message,children:s.jsx("input",{placeholder:"Enter ID",className:J(!!x.stateAccountId),...m("stateAccountId")})}),s.jsx(Z,{label:"Account ID",required:!0,error:(te=x.accountId)==null?void 0:te.message,children:s.jsx("input",{placeholder:"123456789-WHW",className:J(!!x.accountId),...m("accountId")})}),s.jsx(Z,{label:"Letter ID",children:s.jsx("input",{placeholder:"123456789-WHW",className:J(),...m("letterId")})})]}),s.jsxs("div",{className:al,children:[s.jsx(Z,{label:"Tax Year",required:!0,error:(W=x.taxYear)==null?void 0:W.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!x.taxYear),...m("taxYear"),children:[s.jsx("option",{value:"",children:"Select TY"}),o.map(H=>s.jsxs("option",{value:String(H),children:["TY ",H]},H))]}),s.jsx(Br,{})]})}),s.jsx(Z,{label:"Tax Period",required:!0,error:(ne=x.taxPeriod)==null?void 0:ne.message,children:s.jsxs(An,{children:[s.jsxs("select",{className:Yr(!!x.taxPeriod),...m("taxPeriod"),children:[s.jsx("option",{value:"",children:"Select"}),I0.map(H=>s.jsx("option",{value:H.value,children:H.label},H.value))]}),s.jsx(Br,{})]})})]})]})}),s.jsx(aa,{title:"Amount Info",children:s.jsxs("div",{className:al,children:[s.jsx(Z,{label:"Tax Amount",required:!0,error:(xe=x.taxAmount)==null?void 0:xe.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",className:J(!!x.taxAmount),...m("taxAmount")})}),s.jsx(Z,{label:"Payment Date",required:!0,error:(pe=x.paymentDate)==null?void 0:pe.message,children:s.jsx("input",{type:"date",min:l,className:J(!!x.paymentDate),...m("paymentDate")})})]})}),s.jsx(aa,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:sa,children:[s.jsx(De,{name:"bankAccountDetailId",control:h,render:({field:H})=>{var Pe;return s.jsx(uu,{value:H.value,onChange:H.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:d,isLoading:u,disabled:!e||!E,error:(Pe=x.bankAccountDetailId)==null?void 0:Pe.message,label:"Account Number"})}}),s.jsx(Z,{label:"Routing Number",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:J(!1,!0),...m("routingNumber")})}),s.jsx(Z,{label:"Account Type",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:J(!1,!0),...m("accountType")})})]}),s.jsx("div",{className:sa,children:s.jsx(Z,{label:"Bank Name",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:J(!1,!0),...m("bankName")})})})]})})]}),E?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:"Select a state and reason for payment to continue."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>t(n),className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsxs("button",{type:"submit",disabled:!e||!E,className:"inline-flex h-11 min-w-[120px] items-center justify-center gap-2 rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:["Next",s.jsx(z0,{})]})]})]})})]})},r.key)}function ll({step:e,title:t,className:r=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:e}),s.jsx("h3",{className:"text-sm font-bold uppercase tracking-wide text-slate-900",children:t})]})}function aa({title:e,children:t}){return s.jsxs("div",{className:"mt-6 first:mt-0",children:[s.jsx("h4",{className:"mb-4 text-xs font-semibold uppercase tracking-wide text-slate-400",children:e}),t]})}function L0(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]})}function z0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})}function wu(){const{selectedEntity:e}=ft();return s.jsx($0,{entity:e})}const M0="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",V0="I have reviewed the details and authorize this payment.",Su=/^[a-zA-Z\s]+$/;function ku(e){return e.replace(/[^a-zA-Z\s]/g,"")}const Bi=T().min(1,"Signature is required").regex(Su,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),q0=T().optional().refine(e=>!e||!e.trim()||Su.test(e),{message:"Signature must contain only letters"}),B0=Bt({agreementDate:T().min(1,"Date is required"),agreementAccepted:Zr().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:T().min(1,"Name of authorization person is required"),signature:Bi,title:T().min(1,"Title is required")}),U0="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ns="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Z0(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function W0(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function Y0({entity:e,paymentDraft:t}){const r=Se(),n=ge(),a=st(),i=Lr(n.state,"/payments"),[o,l]=N.useState(null),[c,u]=N.useState(!1),d=N.useMemo(()=>W0(),[]),m=Bn(t.taxAmount),{register:h,handleSubmit:f,watch:y,formState:{errors:p}}=wt({resolver:kt(B0),defaultValues:d}),x=y("agreementDate"),b=y("signature"),j=!!(b!=null&&b.trim()),w=h("signature"),k=async()=>{await a.invalidateQueries({queryKey:["dashboard"]}),await a.invalidateQueries({queryKey:["state-payments"]}),await a.invalidateQueries({queryKey:["remittance-payments"]})},E=async()=>{if(!e)return null;if(t.statePaymentDetailId){const Y=await Ab(t.statePaymentDetailId,R0(t));return await k(),Y}const F=await Cb(D0(e.entityId,t));return Ba({...t,statePaymentDetailId:F.statePaymentDetailId}),await k(),F},P=f(async()=>{if(e){l(null),u(!0);try{const F=await E();if(!F)return;await Xc(F.statePaymentDetailId),await k(),Ua(),r(i)}catch(F){l(et(F,"Failed to submit state payment."))}finally{u(!1)}}}),_=f(async()=>{if(e){l(null),u(!0);try{await E(),Ua(),r(i)}catch(F){l(et(F,"Failed to save draft."))}finally{u(!1)}}});return s.jsx("form",{onSubmit:P,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),s.jsx(Un,{entity:e,remittanceAmount:m,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"lg:mr-[324px]",children:[s.jsxs("section",{className:U0,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-slate-200 pb-5",children:[s.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:`${ns} min-w-[128px] py-2.5`,children:[s.jsx("p",{className:"text-[11px] font-medium text-slate-500",children:"Date"}),s.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-800",children:Z0(x)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:M0}),s.jsxs("label",{className:"mt-5 flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...h("agreementAccepted")}),s.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:V0})]}),p.agreementAccepted?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.agreementAccepted.message}):null,s.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("p",{className:"mb-4 text-sm font-medium text-gov-600",children:["Taxpayer's Signature",s.jsx("span",{className:"text-red-500",children:" *"})]}),s.jsxs("div",{className:"grid gap-5 md:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_minmax(0,1fr)] md:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:`${ns} py-7`,children:[s.jsx("input",{placeholder:"Enter name",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("authorizationPersonName")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[180px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Name of Authorization Person"})]}),p.authorizationPersonName?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.authorizationPersonName.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${ns} py-5`,children:[s.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${j?"min-h-[52px] text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:j?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,name:w.name,ref:w.ref,onBlur:w.onBlur,onChange:F=>{const Y=ku(F.target.value);F.target.value=Y,w.onChange(F)}}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[220px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Signature of Tax Payer"})]}),p.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.signature.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${ns} py-7`,children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("title")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[140px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Title"})]}),p.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.title.message}):null]})]})]})]}),o?s.jsx("div",{className:"mt-5",children:s.jsx(qt,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{Ba(t),r("/payments/state/new",{state:{from:i,paymentDraft:t}})},disabled:c,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:_,disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-gov-300 bg-gov-50 px-6 text-sm font-semibold text-gov-600 transition hover:bg-gov-100 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Submit Now"})]})]})]})})}function Cu(){const{selectedEntity:e}=ft(),t=ge(),{paymentDraft:r}=t.state??{},n=r??ju();return n?s.jsx(Y0,{entity:e,paymentDraft:n}):s.jsx(ht,{to:"/payments/state/new",replace:!0})}const Ui="/portal/federal-payments/form-8655-authorizations";function H0(e){return he(Ui,{method:"POST",body:e})}function K0(e){return he(`${Ui}/by-enrolment/${e}`)}function Q0(e,t){return he(`${Ui}/${e}`,{method:"PATCH",body:t})}async function Au(e){try{return await K0(e)}catch(t){if(t instanceof zn&&t.status===404)return null;throw t}}const Za=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function J0(e){const t=e.trim();return Za.includes(t)?t:"Other"}const G0="I understand that this agreement does not relieve me, as the taxpayer, of the responsibility to ensure that all tax returns are filed and that all deposits and payments are made and that I may enroll in the Electronic Federal Tax Payment System (EFTPS) to view deposits and payments made on my behalf.",X0="I further understand that this agreement does not authorize the reporting agent to sign any tax returns, to otherwise act as a legal representative of the taxpayer, or to represent the taxpayer before the IRS. I also understand that the reporting agent is not responsible for any penalties or interest that may be assessed against the taxpayer. I authorize the reporting agent to complete Form 8655, Reporting Agent Authorization, and to make deposits and payments on my behalf for the tax return(s) indicated above. I also authorize the reporting agent to receive confidential information and to perform acts as specified on Form 2848, Power of Attorney and Declaration of Representative, or Form 8821, Tax Information Authorization, as applicable.";function ev(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function Wa({label:e,required:t=!1,signature:r,title:n,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:u="Signature of taxpayer"}){const d=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:f,ref:y}=r;return s.jsxs("div",{children:[e?s.jsxs("p",{className:"mb-3 text-sm font-medium text-gov-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}):null,s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-6",children:[s.jsx("input",{ref:y,name:f,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${d?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:d?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:p=>{const x=ku(p.target.value);p.target.value=x,m(p)}}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:u})]}),c!=null&&c.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.signature}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...n}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Title"})]}),c!=null&&c.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-center text-sm text-slate-700",children:ev(o)}),s.jsx("input",{type:"hidden",...a})]}):s.jsx("input",{type:"date",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 focus:outline-none",...a}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Date"})]}),c!=null&&c.date?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function tv(e){return e.replace(/\D/g,"")}function Pu(e,t){var r,n;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:tv(t.ein),address:t.address.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),isSeasonalEmployer:t.isSeasonalEmployer,otherIdentificationNumber:((r=t.otherIdentificationNumber)==null?void 0:r.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((n=t.authorizationMonth)==null?void 0:n.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function rv(e){const{enrollmentId:t,...r}=Pu(0,e);return r}function nv(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:dr(e.ein),address:e.address,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,isSeasonalEmployer:e.isSeasonalEmployer,otherIdentificationNumber:e.otherIdentificationNumber??"",contactPerson:e.contactPerson,daytimePhone:Dr(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const sv=Bt({taxpayerName:T().min(1,"Taxpayer name is required"),tradeName:T().min(1,"Trade name is required"),ein:T().min(1,"EIN is required"),address:T().min(1,"Address is required"),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required"),isSeasonalEmployer:Zr(),otherIdentificationNumber:T().optional(),contactPerson:T().min(1,"Contact person is required"),daytimePhone:T().min(1,"Daytime telephone number is required"),faxNumber:T().default(""),authorizedTaxForm:T().min(1,"Select a tax form"),authorizationMonth:T().optional(),agreementAccepted:Zr().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:Bi,title:T().min(1,"Title is required"),signatureDate:T().min(1,"Date is required")}),ia="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function av(e,t){const r=new Date().toISOString().slice(0,10);return{taxpayerName:e?Ct(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.firstName)||"",ein:e?dr(e.idNumber):"",address:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",isSeasonalEmployer:!1,otherIdentificationNumber:"",contactPerson:e?`${e.firstName} ${e.lastName}`.trim():"",daytimePhone:e?Dr(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:J0(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:r}}function iv({entity:e,paymentDraft:t,initialAuthorization:r=null,readonly:n=!1}){var ne,xe,pe,H,Pe,pt,le,Re,ze,He,At,it,ot,Pt;const a=Se(),i=ge(),o=st(),l=Lr(i.state,jt()),c=Bn(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),f=N.useMemo(()=>r?nv(r):av(e,t),[e,r,t]),{register:y,handleSubmit:p,watch:x,setValue:b,reset:j,formState:{errors:w}}=wt({resolver:kt(sv),defaultValues:f});N.useEffect(()=>{j(f)},[f,j]);const k=x("authorizedTaxForm"),E=x("signature"),P=x("signatureDate"),_=e?Ct(e):"Entity",F=!0,Y=!0,M=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},se=async()=>{if(!e)return null;if(t.federalPaymentId){const Te=await Fi(t.federalPaymentId,Li(t));return await M(),Te}const oe=await Ii($i(e.entityId,t));return Mi({...t,federalPaymentId:oe.federalPaymentId,enrollmentId:oe.enrollmentId}),await M(),oe},q=async(oe,Te)=>{var xt;const lt=t.form8655AuthorizationId??((xt=await Au(oe))==null?void 0:xt.form8655AuthorizationId),_t=Te;return lt?Q0(lt,rv(_t)):H0(Pu(oe,_t))},K=async oe=>{if(!e)return;const Te=await se();Te&&(await q(Te.enrollmentId,oe),await o.invalidateQueries({queryKey:["form-8655",Te.enrollmentId]}),Vi(),a(jt()))},te=p(async oe=>{if(!(!e||n)){d(null),h(!0);try{await K(oe)}catch(Te){d(et(Te,"Failed to save federal payment draft."))}finally{h(!1)}}}),W=p(async oe=>{if(!(!e||n)){d(null),h(!0);try{await K(oe)}catch(Te){d(et(Te,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:te,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:_}),s.jsx(Un,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:ia,children:[s.jsx(Z,{label:"1. a) Name of the Taxpayer",required:!0,error:(ne=w.taxpayerName)==null?void 0:ne.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!w.taxpayerName,F),...y("taxpayerName")})}),s.jsx(Z,{label:"1. b) Trade Name, if any",required:!0,error:(xe=w.tradeName)==null?void 0:xe.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!w.tradeName,F),...y("tradeName")})}),s.jsx(Z,{label:"2. Employer Identification Number (EIN)",required:!0,error:(pe=w.ein)==null?void 0:pe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:F,className:J(!!w.ein,F),...y("ein")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Z,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(H=w.address)==null?void 0:H.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!w.address,F),...y("address")})})}),s.jsx(Z,{label:"3. b) City or Town",required:!0,error:(Pe=w.city)==null?void 0:Pe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!w.city,F),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${ia}`,children:[s.jsx(Z,{label:"3. c) State",required:!0,error:(pt=w.state)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!w.state,F),...y("state")})}),s.jsx(Z,{label:"3. d) ZIP Code",required:!0,error:(le=w.zipCode)==null?void 0:le.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!w.zipCode,F),...y("zipCode")})}),s.jsx(Z,{label:"3. e) Country",required:!0,error:(Re=w.country)==null?void 0:Re.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!w.country,F),...y("country")})})]}),s.jsxs("div",{className:`mt-5 ${ia}`,children:[s.jsx("div",{className:"flex items-end pb-2",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(Z,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!1,F),...y("otherIdentificationNumber")})}),s.jsx(Z,{label:"6. Contact Person",required:!0,error:(ze=w.contactPerson)==null?void 0:ze.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!w.contactPerson,F),...y("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(Z,{label:"7. Daytime Telephone Number",required:!0,error:(He=w.daytimePhone)==null?void 0:He.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:F,className:J(!!w.daytimePhone,F),...y("daytimePhone")})}),s.jsx(Z,{label:"8. Fax Number",error:(At=w.faxNumber)==null?void 0:At.message,children:s.jsx("input",{placeholder:"Enter number",className:J(!!w.faxNumber),...y("faxNumber")})})]})]}),s.jsxs(vr,{title:"Authorization of Reporting Agent To Make and Deposits and Payments (Caution: See Authorization Agreement.)",children:[s.jsx("p",{className:"mb-5 text-sm leading-6 text-slate-600",children:"Indicate the tax return(s) for which the reporting agent is authorized to make deposits or payments. Use the 'YYYY/MM' format to enter the month in which the authorization begins (for example, '2024/8' for August 2024)"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Za.slice(0,6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:k===oe,disabled:Y,onChange:()=>b("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Za.slice(6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:k===oe,disabled:Y,onChange:()=>b("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))})]}),w.authorizedTaxForm?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.authorizedTaxForm.message}):null]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:"border-t border-slate-200 pt-5",children:[s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:G0})," ",X0]})]}),w.agreementAccepted?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.agreementAccepted.message}):null]})]}),s.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:s.jsx(Wa,{label:"Taxpayer's Signature",required:!0,signature:y("signature"),title:y("title"),date:y("signatureDate"),signatureValue:E,dateValue:P,errors:{signature:(it=w.signature)==null?void 0:it.message,title:(ot=w.title)==null?void 0:ot.message,date:(Pt=w.signatureDate)==null?void 0:Pt.message}})})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(qt,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:m,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:W,disabled:m||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:m||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function _u(){const{selectedEntity:e}=ft(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Us(),{data:a,isLoading:i}=Ee({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>Ti(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=Ee({queryKey:["form-8655",o],queryFn:()=>Au(o),enabled:o!=null}),u=N.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form8655AuthorizationId:n.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[n,o,l]);return n?Oi(e)?s.jsx(ht,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(iv,{entity:e,paymentDraft:u??n,initialAuthorization:l}):s.jsx(ht,{to:"/payments/federal/new",replace:!0})}const Zi="/portal/federal-payments/form-9783-enrollments";function ov(e){return he(Zi,{method:"POST",body:e})}function lv(e){return he(`${Zi}/by-enrolment/${e}`)}function cv(e,t){return he(`${Zi}/${e}`,{method:"PATCH",body:t})}async function Eu(e){try{return await lv(e)}catch(t){if(t instanceof zn&&t.status===404)return null;throw t}}const uv="I hereby authorize the contact person listed in item 5 on this form, and the financial institution(s) listed in items 9-11 on this form, to process EFTPS payments and to receive confidential information for enrollment purposes, to answer inquiries regarding my account, and to resolve any issues that may arise. This authorization includes passwords, payment instructions, taxpayer names, and identifying numbers.",dv="By completing the financial institution information in items 9-11 on this form, I authorize the designated Financial Agents of the U.S. Treasury to initiate EFTPS debit entries to my financial institution account for federal tax payments. All debits will be made in accordance with U.S. Treasury regulations. This authorization remains in effect until written notification of termination is received and the Financial Agent has had a reasonable opportunity to act on it.",mv="Under penalties of perjury, I certify that I have the authority to sign this authorization on behalf of the taxpayer. If I am a corporate officer, partner, guardian, executor, receiver, administrator, trustee, or other party, I certify that I have the authority to execute this authorization on behalf of the taxpayer. If I am a tax practitioner, I certify that Form 2848 or Form 8655 is on file with the IRS.",oa=new Date().getFullYear(),hv=[String(oa-1),String(oa-2),String(oa-3)];function ss(e){return e.replace(/\D/g,"")}function Tu(e,t){var r,n,a,i;return{enrollmentId:e,primarySsn:ss(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ss(t.jointFilerSsn):null,taxpayerNames:t.taxpayerNames.trim(),primaryAddress:t.primaryAddress.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),internationalAddress:((r=t.internationalAddress)==null?void 0:r.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((n=t.contactInternationalAddress)==null?void 0:n.trim())||null,primaryTaxpayerPin:t.primaryTaxpayerPin.trim()||null,dateOfBirth:t.dateOfBirth||null,priorYearAgi:t.priorYearAgi.trim()?Number(t.priorYearAgi):null,agiTaxYear:t.agiTaxYear.trim()||null,financialPrimarySsn:ss(t.financialPrimarySsn),routingTransitNumber:ss(t.routingTransitNumber),accountNumber:t.accountNumber.trim(),accountType:t.accountType,disclosureAgreementOne:t.disclosureAgreementOne,disclosureAgreementTwo:t.disclosureAgreementTwo,authorityAgreement:t.authorityAgreement,taxpayerSignature:t.taxpayerSignature.trim()||null,taxpayerTitle:t.taxpayerTitle.trim(),taxpayerSignatureDate:t.taxpayerSignatureDate,jointFilerSignature:((a=t.jointFilerSignature)==null?void 0:a.trim())||null,jointFilerTitle:((i=t.jointFilerTitle)==null?void 0:i.trim())||null,jointFilerSignatureDate:t.jointFilerSignatureDate||null}}function fv(e){const{enrollmentId:t,...r}=Tu(0,e);return r}function pv(e){var r;const t=((r=e.accountType)==null?void 0:r.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:Dr(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Dr(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",financialPrimarySsn:e.financialPrimarySsn,routingTransitNumber:e.routingTransitNumber,accountNumber:e.accountNumber,accountType:t,disclosureAgreementOne:e.disclosureAgreementOne,disclosureAgreementTwo:e.disclosureAgreementTwo,authorityAgreement:e.authorityAgreement,taxpayerSignature:e.taxpayerSignature??"",taxpayerTitle:e.taxpayerTitle,taxpayerSignatureDate:e.taxpayerSignatureDate,jointFilerSignature:e.jointFilerSignature??"",jointFilerTitle:e.jointFilerTitle??"",jointFilerSignatureDate:e.jointFilerSignatureDate??""}}const xv=Bt({primarySsn:T().min(1,"Primary SSN is required"),jointFilerSsn:T().optional(),taxpayerNames:T().min(1,"Taxpayer name is required"),primaryAddress:T().min(1,"Primary address is required"),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required"),internationalAddress:T().optional(),primaryPhone:T().min(1,"Primary phone number is required"),primaryContactName:T().min(1,"Primary contact name is required"),primaryContactAddress:T().min(1,"Primary contact address is required"),contactCity:T().min(1,"Contact city is required"),contactState:T().min(1,"Contact state is required"),contactZipCode:T().min(1,"Contact ZIP code is required"),contactCountry:T().min(1,"Contact country is required"),contactPhone:T().min(1,"Contact phone number is required"),contactInternationalAddress:T().optional(),primaryTaxpayerPin:T().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:T().min(1,"Date of birth is required").refine(e=>Yb(e,Iu),{message:"You must be at least 18 years old"}),priorYearAgi:T().min(1,"Prior year adjusted gross income is required").refine(e=>!Number.isNaN(Number(e))&&Number(e)>=0,{message:"Enter a valid amount"}),agiTaxYear:T().min(1,"Prior tax year is required"),financialPrimarySsn:T().min(1,"Primary SSN is required"),routingTransitNumber:T().min(1,"Routing transit number is required"),accountNumber:T().min(1,"Account number is required"),accountType:Uc([Gs("Checking"),Gs("Savings"),Gs("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Zr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Zr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Zr().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:Bi,taxpayerTitle:T().min(1,"Title is required"),taxpayerSignatureDate:T().min(1,"Date is required"),jointFilerSignature:q0,jointFilerTitle:T().optional(),jointFilerSignatureDate:T().optional()}),gr="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",gv="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",yv=5,Iu=18;function Fu(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function Du(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:Fu(t.accountType)}}function bv(e,t){const r=new Date().toISOString().slice(0,10),n=e?Ct(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:n,primaryAddress:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"US",internationalAddress:"",primaryPhone:e?Dr(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...Du(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:r,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:r}}function vv({entity:e,paymentDraft:t,initialEnrollment:r=null,readonly:n=!1}){var _t,xt,mr,Et,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,zr,z,ae,g,S,C,D,R,B,O,U;const a=Se(),i=ge(),o=st(),l=Lr(i.state,jt()),c=Bn(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),[f,y]=N.useState(!1),{data:p=[]}=Ee({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>qn(e.entityId),enabled:(e==null?void 0:e.entityId)!=null}),x=N.useMemo(()=>{if(r)return pv(r);const $=p.find(Ie=>String(Ie.bankAccountDetailId)===t.bankAccountDetailId),X=Du(e,t);return{...bv(e,t),financialPrimarySsn:X.financialPrimarySsn,routingTransitNumber:X.routingTransitNumber||($==null?void 0:$.routingNumber)||"",accountNumber:X.accountNumber||($==null?void 0:$.accountNumber)||"",accountType:Fu(t.accountType||($==null?void 0:$.accountType))}},[e,r,t,p]),{register:b,handleSubmit:j,watch:w,setValue:k,reset:E,control:P,formState:{errors:_}}=wt({resolver:kt(xv),defaultValues:x});N.useEffect(()=>{E(x)},[x,E]);const F=w("taxpayerSignature"),Y=w("jointFilerSignature"),M=w("taxpayerSignatureDate"),se=w("jointFilerSignatureDate"),q=w("accountType"),K=w("taxpayerNames"),te=w("primaryAddress"),W=w("city"),ne=w("state"),xe=w("zipCode"),pe=w("country"),H=w("primaryPhone"),Pe=w("internationalAddress"),pt=e?Ct(e):"Entity",le=!0,Re=!0,ze=N.useMemo(()=>Wb(Iu),[]),He=()=>{k("primaryContactName",K,{shouldValidate:!0}),k("primaryContactAddress",te,{shouldValidate:!0}),k("contactCity",W,{shouldValidate:!0}),k("contactState",ne,{shouldValidate:!0}),k("contactZipCode",xe,{shouldValidate:!0}),k("contactCountry",pe,{shouldValidate:!0}),k("contactPhone",H,{shouldValidate:!0}),k("contactInternationalAddress",Pe??"",{shouldValidate:!0})},At=()=>{k("primaryContactName","",{shouldValidate:!0}),k("primaryContactAddress","",{shouldValidate:!0}),k("contactCity","",{shouldValidate:!0}),k("contactState","",{shouldValidate:!0}),k("contactZipCode","",{shouldValidate:!0}),k("contactCountry","",{shouldValidate:!0}),k("contactPhone","",{shouldValidate:!0}),k("contactInternationalAddress","",{shouldValidate:!0})};N.useEffect(()=>{f&&He()},[f,K,te,W,ne,xe,pe,H,Pe]);const it=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ot=async()=>{if(!e)return null;if(t.federalPaymentId){const X=await Fi(t.federalPaymentId,Li(t));return await it(),X}const $=await Ii($i(e.entityId,t));return Mi({...t,federalPaymentId:$.federalPaymentId,enrollmentId:$.enrollmentId}),await it(),$},Pt=async($,X)=>{var Ft;const Ie=t.form9783EnrollmentId??((Ft=await Eu($))==null?void 0:Ft.form9783EnrollmentId);return Ie?cv(Ie,fv(X)):ov(Tu($,X))},oe=async $=>{if(!e)return;const X=await ot();X&&(await Pt(X.enrollmentId,$),await o.invalidateQueries({queryKey:["form-9783",X.enrollmentId]}),Vi(),a(jt()))},Te=j(async $=>{if(!(!e||n)){d(null),h(!0);try{await oe($)}catch(X){d(et(X,"Failed to save federal payment draft."))}finally{h(!1)}}}),lt=j(async $=>{if(!(!e||n)){d(null),h(!0);try{await oe($)}catch(X){d(et(X,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:Te,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:pt}),s.jsx(Un,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs(vr,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:gr,children:[s.jsx(Z,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(_t=_.primarySsn)==null?void 0:_t.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:le,className:J(!!_.primarySsn,le),...b("primarySsn")})}),s.jsx(Z,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:le,className:J(!1,le),...b("jointFilerSsn")})}),s.jsx(Z,{label:"2. Taxpayer(S) name(S)",required:!0,error:(xt=_.taxpayerNames)==null?void 0:xt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:le,className:J(!!_.taxpayerNames,le),...b("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(Z,{label:"3. a) Primary taxpayer address",required:!0,error:(mr=_.primaryAddress)==null?void 0:mr.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.primaryAddress,le),...b("primaryAddress")})})}),s.jsx(Z,{label:"3. b) City or Town",required:!0,error:(Et=_.city)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.city,le),...b("city")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx(Z,{label:"3. c) State",required:!0,error:(Ut=_.state)==null?void 0:Ut.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:le,className:J(!!_.state,le),...b("state")})}),s.jsx(Z,{label:"3. d) ZIP code",required:!0,error:(Tt=_.zipCode)==null?void 0:Tt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.zipCode,le),...b("zipCode")})}),s.jsx(Z,{label:"3. e) Country",required:!0,error:(It=_.country)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Enter",readOnly:le,className:J(!!_.country,le),...b("country")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(Z,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:le,className:J(!1,le),...b("internationalAddress")})})}),s.jsx(Z,{label:"4. Primary taxpayer phone number",required:!0,error:(hr=_.primaryPhone)==null?void 0:hr.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:le,className:J(!!_.primaryPhone,le),...b("primaryPhone")})})]})]}),s.jsxs(vr,{title:"2. Contact Information",headerAction:s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",checked:f,disabled:n,onChange:$=>{const X=$.target.checked;y(X),X?He():At()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[s.jsxs("div",{className:gr,children:[s.jsx(Z,{label:"5. Primary contact name",required:!0,error:(Zt=_.primaryContactName)==null?void 0:Zt.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:f,className:J(!!_.primaryContactName,f),...b("primaryContactName")})}),s.jsx(Z,{label:"6. a) Primary contact address",required:!0,error:(fr=_.primaryContactAddress)==null?void 0:fr.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:f,className:J(!!_.primaryContactAddress,f),...b("primaryContactAddress")})}),s.jsx(Z,{label:"6. b) City or Town",required:!0,error:(Wt=_.contactCity)==null?void 0:Wt.message,children:s.jsx("input",{placeholder:"City",readOnly:f,className:J(!!_.contactCity,f),...b("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx(Z,{label:"6. c) State",required:!0,error:(Yt=_.contactState)==null?void 0:Yt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:f,className:J(!!_.contactState,f),...b("contactState")})}),s.jsx(Z,{label:"6. d) ZIP code",required:!0,error:(pr=_.contactZipCode)==null?void 0:pr.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:f,className:J(!!_.contactZipCode,f),...b("contactZipCode")})}),s.jsx(Z,{label:"6. f) Country",required:!0,error:(xr=_.contactCountry)==null?void 0:xr.message,children:s.jsx("input",{placeholder:"Country",readOnly:f,className:J(!!_.contactCountry,f),...b("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(Z,{label:"7. Primary taxpayer phone number",required:!0,error:(zr=_.contactPhone)==null?void 0:zr.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:J(!!_.contactPhone,f),...b("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(Z,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:J(!1,f),...b("contactInternationalAddress")})})})]})]}),s.jsx(vr,{title:"Taxpayer Details *",children:s.jsxs("div",{className:gv,children:[s.jsx(Z,{label:"1. Primary Taxpayer Pin",required:!0,error:(z=_.primaryTaxpayerPin)==null?void 0:z.message,children:s.jsx(De,{name:"primaryTaxpayerPin",control:P,render:({field:$})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:J(!!_.primaryTaxpayerPin),value:$.value,onChange:X=>$.onChange(Wr(X.target.value,yv)),onBlur:$.onBlur})})}),s.jsx(Z,{label:"2. Date of Birth",required:!0,error:(ae=_.dateOfBirth)==null?void 0:ae.message,children:s.jsx("input",{type:"date",max:ze,className:J(!!_.dateOfBirth),...b("dateOfBirth")})}),s.jsx(Z,{label:"3. Prior year adjusted gross income",required:!0,error:(g=_.priorYearAgi)==null?void 0:g.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:J(!!_.priorYearAgi),...b("priorYearAgi")})}),s.jsx(Z,{label:"4. Prior Tax Year",required:!0,error:(S=_.agiTaxYear)==null?void 0:S.message,children:s.jsxs("select",{className:Yr(!!_.agiTaxYear),...b("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),hv.map($=>s.jsx("option",{value:$,children:$},$))]})})]})}),s.jsxs(vr,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:gr,children:[s.jsx(Z,{label:"9. Primary SSN",required:!0,error:(C=_.financialPrimarySsn)==null?void 0:C.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:Re,className:J(!!_.financialPrimarySsn,Re),...b("financialPrimarySsn")})}),s.jsx(Z,{label:"10. Routing Transit Number (RTN)",required:!0,error:(D=_.routingTransitNumber)==null?void 0:D.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:Re,className:J(!!_.routingTransitNumber,Re),...b("routingTransitNumber")})}),s.jsx(Z,{label:"11. Account Number",required:!0,error:(R=_.accountNumber)==null?void 0:R.message,children:s.jsx("input",{placeholder:"Enter",readOnly:Re,className:J(!!_.accountNumber,Re),...b("accountNumber")})})]}),s.jsxs("div",{className:"mt-5",children:[s.jsx("p",{className:"mb-3 text-sm text-slate-600",children:"12. Type of Account"}),s.jsx("div",{className:"flex flex-wrap gap-6",children:["Checking","Savings"].map($=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:$,checked:q===$,disabled:Re,onChange:()=>k("accountType",$,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),$]},$))}),_.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.accountType.message}):null]})]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsx("p",{className:"mb-5 text-sm text-slate-600",children:"Read the following authorization agreements"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:uv})]}),_.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.disclosureAgreementOne.message}):null]}),s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:dv})]}),_.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.disclosureAgreementTwo.message}):null]}),s.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Authority to Execute an Authorization"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:mv})]}),_.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:_.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(Wa,{label:"Taxpayer's Signature",required:!0,signature:b("taxpayerSignature"),title:b("taxpayerTitle"),date:b("taxpayerSignatureDate"),signatureValue:F,dateValue:M,errors:{signature:(B=_.taxpayerSignature)==null?void 0:B.message,title:(O=_.taxpayerTitle)==null?void 0:O.message,date:(U=_.taxpayerSignatureDate)==null?void 0:U.message}}),s.jsx(Wa,{label:"Joint filer(s) Signature (Optional)",signature:b("jointFilerSignature"),title:b("jointFilerTitle"),date:b("jointFilerSignatureDate"),signatureValue:Y??"",dateValue:se??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(qt,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:m,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:lt,disabled:m||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:m||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function Ru(){const{selectedEntity:e}=ft(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Us(),{data:a,isLoading:i}=Ee({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>Ti(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=Ee({queryKey:["form-9783",o],queryFn:()=>Eu(o),enabled:o!=null}),u=N.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form9783EnrollmentId:n.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[n,o,l]);return n?e&&!Oi(e)?s.jsx(ht,{to:"/payments/federal/authorization",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(vv,{entity:e,paymentDraft:u??n,initialEnrollment:l}):s.jsx(ht,{to:"/payments/federal/new",replace:!0})}function jv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Nv({type:e}){return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:e})}function wv({status:e}){const t=e.toLowerCase();let r="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?r="bg-orange-50 text-orange-700":t.includes("irs accepted")?r="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?r="bg-red-50 text-red-600":t.includes("pending")&&(r="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r}`,children:e})}function Sv({forms:e=[],isLoading:t=!1,isError:r=!1}){return s.jsx("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"File Name"}),s.jsx("th",{className:"px-6 py-3",children:"Type"}),s.jsx("th",{className:"px-6 py-3",children:"Client"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Date"}),s.jsx("th",{className:"px-6 py-3",children:"Action"})]})}),s.jsx("tbody",{children:t?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Loading tax forms…"})}):r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Unable to load tax forms."})}):e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"No tax forms to display yet."})}):e.map(n=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3 font-medium text-slate-900",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gov-50 text-gov-600",children:s.jsx(kv,{className:"h-4 w-4"})}),n.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Nv,{type:n.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:n.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(wv,{status:n.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:jv(n.date)}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("button",{type:"button",className:"rounded-full border border-gov-200 bg-gov-50 px-4 py-1.5 text-xs font-semibold text-gov-600 transition hover:bg-gov-100",children:"View PDF"}),n.canSubmit?s.jsx("button",{type:"button",className:"rounded-full bg-gov-600 px-4 py-1.5 text-xs font-semibold text-white transition hover:bg-gov-700",children:"Submit"}):null]})})]},n.taxFormId))})]})})})}function kv({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V6A2.25 2.25 0 014.5 3.75h4.379a2.25 2.25 0 011.59.659l1.122 1.122A2.25 2.25 0 0013.128 6H19.5a2.25 2.25 0 012.25 2.25v10.5A2.25 2.25 0 0119.5 21H4.5a2.25 2.25 0 01-2.25-2.25v-6.75z"})})}function Cv(){return s.jsx(Sv,{})}const cl=160,Av=88,as=8;function Pv({account:e,entityId:t,onEdit:r}){const n=st(),{showSuccess:a,showError:i}=Es(),o=N.useRef(null),l=N.useRef(null),[c,u]=N.useState(!1),[d,m]=N.useState(!1),[h,f]=N.useState({}),y=()=>{var E;const x=o.current;if(!x)return;const b=x.getBoundingClientRect(),j=((E=l.current)==null?void 0:E.offsetHeight)??Av,k=window.innerHeight-b.bottom<j+as;f({position:"fixed",top:k?b.top-j-as:b.bottom+as,left:Math.max(as,b.right-cl),width:cl,zIndex:50})};N.useLayoutEffect(()=>{c&&(y(),requestAnimationFrame(y))},[c]),N.useEffect(()=>{if(!c)return;const x=j=>{var k,E;const w=j.target;(k=o.current)!=null&&k.contains(w)||(E=l.current)!=null&&E.contains(w)||u(!1)},b=()=>y();return document.addEventListener("mousedown",x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[c]);const p=async()=>{const x=gn(e);m(!0);try{await ru(e.bankAccountDetailId,{status:S0(e)}),await n.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),x?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(b){i("Action Not Completed",et(b,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:o,type:"button",disabled:d,onClick:()=>u(x=>!x),className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:["Actions",s.jsx(_v,{})]}),c?ks.createPortal(s.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[s.jsx("button",{type:"button",onClick:()=>{u(!1),r(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"}),s.jsx("button",{type:"button",disabled:d,onClick:()=>void p(),className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-60",children:k0(e)})]}),document.body):null]})}function _v(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}const Ou=["Checking","Savings"],Ev=Bt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${un} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ms(Ou,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")});function Tv({open:e,account:t,onClose:r}){const n=st(),{showSuccess:a,showError:i}=Es(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=wt({resolver:kt(Ev),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});N.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),N.useEffect(()=>{if(!e)return;const p=x=>{x.key==="Escape"&&r()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,r]);const y=m(async p=>{if(t){l(null),u(!0);try{await ru(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await n.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),r()}catch(x){const b=et(x,"Unable to update bank account.");l(b),i("Action Not Completed",b)}finally{u(!1)}}});return!e||!t?null:ks.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-bank-account-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),s.jsxs("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),y(p)},className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?s.jsx("div",{className:"mb-5",children:s.jsx(qt,{message:o})}):null,s.jsxs(lr,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(De,{name:"accountNumber",control:d,render:({field:p})=>{var x;return s.jsx(de,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:b=>p.onChange(Wr(b.target.value,un)),onBlur:p.onBlur,error:(x=f.accountNumber)==null?void 0:x.message})}}),s.jsx(De,{name:"routingNumber",control:d,render:({field:p})=>{var x;return s.jsx(de,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:b=>p.onChange(Wr(b.target.value,nu)),onBlur:p.onBlur,error:(x=f.routingNumber)==null?void 0:x.message})}}),s.jsx(De,{name:"accountType",control:d,render:({field:p})=>{var x;return s.jsx(Nt,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(x=f.accountType)==null?void 0:x.message,children:Ou.map(b=>s.jsx("option",{value:b,children:b},b))})}})]}),s.jsx(De,{name:"bankName",control:d,render:({field:p})=>{var x;return s.jsx(de,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(x=f.bankName)==null?void 0:x.message})}})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:r,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:c?"Saving…":"Save Changes"})]})]})]})]}),document.body)}const Rr=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Iv},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:Fv},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Dv},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Rv}];function Iv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 002.25-2.25V6.75A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25v10.5A2.25 2.25 0 004.5 19.5z"})})}function Fv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Dv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function Rv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})})}function dn({title:e,subtitle:t,icon:r,action:n}){return s.jsxs("div",{className:"mb-6 flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(r,{className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"text-sm text-slate-500",children:t})]})]}),n]})}function Ov(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function $v({status:e}){const t=gn({status:e});return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:t?"Active":"In-active"})}function Lv({entityId:e}){const[t,r]=N.useState(!1),[n,a]=N.useState(null),i=Rr.find(d=>d.id==="bank-accounts"),o=i.icon,{data:l=[],isLoading:c,isError:u}=Ee({queryKey:["bank-accounts",e],queryFn:()=>qn(e),enabled:e!==null});return s.jsxs("div",{children:[s.jsx(dn,{title:i.title,subtitle:i.subtitle,icon:o,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>r(!0),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(zv,{}),"Add Bank Account"]})}),s.jsx(au,{open:t,entityId:e,onClose:()=>r(!1)}),s.jsx(Tv,{open:n!==null,account:n,onClose:()=>a(null)}),s.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[700px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Bank"}),s.jsx("th",{className:"px-5 py-3",children:"Account"}),s.jsx("th",{className:"px-5 py-3",children:"Routing"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"}),s.jsx("th",{className:"px-5 py-3"})]})}),s.jsx("tbody",{children:c?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):u?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load bank accounts."})}):e?l.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No bank accounts connected yet."})}):l.map(d=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:d.bankName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Ov(d.accountNumber)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.routingNumber}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.accountType}),s.jsx("td",{className:"px-5 py-4",children:s.jsx($v,{status:d.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx(Pv,{account:d,entityId:e,onEdit:a})})]},d.bankAccountDetailId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage bank accounts."})})})]})})]})}function zv(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Mv({open:e,entity:t,onClose:r}){var x,b,j,w,k,E,P,_,F,Y;const n=st(),[a,i]=N.useState(null),[o,l]=N.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,formState:{errors:h}}=wt({resolver:kt(Kc),defaultValues:Qo(t)});N.useEffect(()=>{e&&(m(Qo(t)),i(null))},[t,e,m]),N.useEffect(()=>{if(!e)return;const M=se=>{se.key==="Escape"&&r()};return document.addEventListener("keydown",M),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",M),document.body.style.overflow=""}},[e,r]);const f=d("accountType"),y=f==="Individual"?Hc:Yc,p=u(async M=>{i(null),l(!0);try{await Sh(t.entityId,zy(M)),await n.invalidateQueries({queryKey:["entities","mine"]}),r()}catch(se){i(et(se,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?ks.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-entity-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),s.jsxs("form",{onSubmit:p,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?s.jsx("div",{className:"mb-5",children:s.jsx(qt,{message:a})}):null,s.jsxs("div",{className:"space-y-8",children:[s.jsx("input",{type:"hidden",...c("ein")}),s.jsx(lr,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(cn,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:f==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(x=h.businessName)==null?void 0:x.message,...c("businessName")}),s.jsx(de,{label:"Trade Name, if any",placeholder:"Enter",error:(b=h.tradeName)==null?void 0:b.message,...c("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"EIN",readOnly:!0,value:dr(t.idNumber),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(Nt,{label:"Entity Type",required:!0,error:(j=h.entityType)==null?void 0:j.message,...c("entityType"),children:y.map(M=>s.jsx("option",{value:M,children:M},M))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(w=h.email)==null?void 0:w.message,...c("email")}),s.jsxs("div",{children:[s.jsx(cn,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...c("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${h.phoneNumber?"border-red-300":"border-slate-200"}`,...c("phoneNumber")})]}),h.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:h.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(de,{label:"Address Line 1",required:!0,error:(k=h.address1)==null?void 0:k.message,...c("address1")}),s.jsx(de,{label:"Address Line 2",error:(E=h.address2)==null?void 0:E.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"City",required:!0,error:(P=h.city)==null?void 0:P.message,...c("city")}),s.jsxs(Nt,{label:"State",required:!0,error:(_=h.state)==null?void 0:_.message,...c("state"),children:[s.jsx("option",{value:"",children:"Select"}),ki.map(M=>s.jsx("option",{value:M,children:M},M))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"ZIP Code",required:!0,error:(F=h.zipCode)==null?void 0:F.message,...c("zipCode")}),s.jsxs(Nt,{label:"Country",required:!0,error:(Y=h.country)==null?void 0:Y.message,...c("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:r,disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save Changes"})]})]})]})]}),document.body):null}function Vv({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})}):e==="account"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})}):s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})}function wn({label:e,value:t,icon:r}){return s.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:s.jsx(Vv,{icon:r})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs text-slate-500",children:e}),s.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function qv(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function Bv({entity:e}){const[t,r]=N.useState(!1),n=Rr.find(c=>c.id==="entity-details"),a=n.icon;if(!e)return s.jsxs("div",{children:[s.jsx(dn,{title:n.title,subtitle:n.subtitle,icon:a}),s.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=Ct(e),o=`${e.firstName} ${e.lastName}`.trim()||i,l=Si(o);return s.jsxs("div",{children:[s.jsx(dn,{title:n.title,subtitle:n.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),s.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[s.jsx("span",{className:"flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xl font-semibold text-white",children:l}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(wn,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(wn,{label:"Tax ID",value:dr(e.idNumber),icon:"tax"}),s.jsx(wn,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(wn,{label:"Phone Number",value:Dr(e.phoneNumber),icon:"phone"}),s.jsx(wn,{label:"Account Type",value:qv(e.accountType),icon:"account"})]}),s.jsx(Mv,{open:t,entity:e,onClose:()=>r(!1)})]})}function $u({activeSection:e,onSectionChange:t,items:r}){return s.jsx("nav",{className:"space-y-2",children:r.map(n=>{const a=e===n.id,i=n.icon;return s.jsxs("button",{type:"button",onClick:()=>t(n.id),className:`flex w-full items-center gap-3 rounded-xl border px-4 py-3.5 text-left transition ${a?"border-gov-200 bg-gov-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300 hover:bg-slate-50"}`,children:[s.jsx("span",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${a?"bg-gov-600 text-white":"bg-slate-100 text-slate-500"}`,children:s.jsx(i,{className:"h-5 w-5"})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:`block text-sm font-semibold ${a?"text-slate-900":"text-slate-700"}`,children:n.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:n.subtitle})]}),s.jsx(Uv,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},n.id)})})}function Uv({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function Zv(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function Wv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Yv({type:e}){const t={Federal:"bg-gov-50 text-gov-700",State:"bg-sky-50 text-sky-700",Local:"bg-indigo-50 text-indigo-700"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]}`,children:e})}function Hv({entityId:e,transactions:t=[],isLoading:r=!1,isError:n=!1}){const a=Rr.find(l=>l.id==="payment-history"),i=a.icon,o=e!==null&&t.length>0;return s.jsxs("div",{children:[s.jsx(dn,{title:a.title,subtitle:a.subtitle,icon:i,action:s.jsxs("button",{type:"button",disabled:!o,className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(Kv,{}),"Export to Excel"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Date"}),s.jsx("th",{className:"px-5 py-3",children:"Amount"}),s.jsx("th",{className:"px-5 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Reference"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load payment history."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No payment transactions to display yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Wv(l.date)}),s.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:Zv(l.amount)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.jurisdiction}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Yv,{type:l.type})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.reference})]},l.paymentHistoryId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to view payment history."})})})]})})]})}function Kv(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"})})}function Qv({count:e}){const t=e===1?"1 Payment":`${e} Payments`;return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:t})}function Jv({status:e}){const r=(e??"Active").toLowerCase()==="active";return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:r?"Active":"In-active"})}function Gv(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function Xv({entityId:e,accounts:t=[],isLoading:r=!1,isError:n=!1}){const a=Se(),i=Rr.find(l=>l.id==="tax-accounts"),o=i.icon;return s.jsxs("div",{children:[s.jsx(dn,{title:i.title,subtitle:i.subtitle,icon:o,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>a("/settings/tax-accounts/new"),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(ej,{}),"Add Tax Account"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Federal/State ID"}),s.jsx("th",{className:"px-5 py-3",children:"Payments"}),s.jsx("th",{className:"px-5 py-3",children:"Form Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load tax accounts."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"No tax accounts connected yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.federalStateId}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Qv,{count:l.paymentCount})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Gv(l.formTypes)}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Jv,{status:l.status})})]},l.taxAccountId)):s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage tax accounts."})})})]})})]})}function ej(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const ul="rounded-2xl border border-slate-200 bg-white shadow-sm";function tj(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function Wi(){const{selectedEntity:e}=ft(),r=ge().state,[n,a]=N.useState(tj(r==null?void 0:r.section)?r.section:"bank-accounts");return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${ul} p-3`,children:s.jsx($u,{items:Rr,activeSection:n,onSectionChange:a})}),s.jsx("div",{className:`${ul} p-6 lg:p-8`,children:n==="bank-accounts"?s.jsx(Lv,{entityId:(e==null?void 0:e.entityId)??null}):n==="tax-accounts"?s.jsx(Xv,{entityId:(e==null?void 0:e.entityId)??null}):n==="payment-history"?s.jsx(Hv,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(Bv,{entity:e})})]})}const rj=["Alexandria","Arlington","Chesapeake","Hampton","Lynchburg","Newport News","Norfolk","Richmond","Roanoke","Virginia Beach"],nj=ki.map(e=>({code:e,name:e==="VA"?"Virginia":e})),sj=[{name:"virginiaTaxAccountId",label:"Virginia Tax Account ID",required:!0},{name:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID",required:!0},{name:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID",required:!0},{name:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number",required:!0},{name:"businessLocationCode",label:"Business Location Code",required:!0},{name:"franchiseTaxAccount",label:"Franchise Tax Account",required:!0},{name:"transientOccupancyTaxAccountId",label:"Transient Occupancy Tax Account ID",required:!1},{name:"certificateOfAuthorityNumber",label:"Certificate of Authority Number (Foreign Entities)",required:!1}],aj=[{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1}],ij=Bt({state:T().min(1,"State is required"),city:T().min(1,"City is required"),zipCode:T().min(1,"ZIP code is required"),address1:T().min(1,"Address Line 1 is required"),address2:T().optional(),virginiaTaxAccountId:T().optional(),virginiaWithholdingAccountingId:T().optional(),unemploymentTaxAccountId:T().optional(),virginiaDepartmentOfTaxationClientNumber:T().optional(),businessLocationCode:T().optional(),franchiseTaxAccount:T().optional(),transientOccupancyTaxAccountId:T().optional(),certificateOfAuthorityNumber:T().optional(),licensedProfessionalEmployerEntityNumber:T().optional()}),oj=ij.superRefine((e,t)=>{if(e.state!=="VA")return;const r=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const n of r){const a=e[n.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:Vr.custom,message:`${n.label} is required`,path:[n.key]})}}),lj={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function cj({onCancel:e,onSuccess:t}){var b,j,w,k,E,P;const{showSuccess:r}=Es(),[n,a]=N.useState(null),[i,o]=N.useState(!1),{register:l,handleSubmit:c,watch:u,setValue:d,formState:{errors:m}}=wt({resolver:kt(oj),defaultValues:lj}),h=u("state"),f=u("city"),y=h==="VA",p=N.useMemo(()=>h==="VA"?[...rj]:[],[h]);N.useEffect(()=>{if(p.length===0){f&&d("city","");return}f&&!p.includes(f)&&d("city","")},[p,f,d]);const x=c(async _=>{a(null),o(!0);try{await Promise.resolve(),r("Tax Account Ready","Tax account details captured. API save will be enabled soon."),t==null||t(_)}catch{a("Unable to save tax account. Please try again.")}finally{o(!1)}});return s.jsxs("form",{onSubmit:x,noValidate:!0,className:"space-y-8",children:[n?s.jsx(qt,{message:n}):null,s.jsx(lr,{step:1,title:"TAX ACCOUNT DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsxs(Nt,{label:"Select State",required:!0,error:(b=m.state)==null?void 0:b.message,...l("state"),children:[s.jsx("option",{value:"",children:"Select"}),nj.map(_=>s.jsx("option",{value:_.code,children:_.name},_.code))]}),p.length>0?s.jsxs(Nt,{label:"City",required:!0,error:(j=m.city)==null?void 0:j.message,...l("city"),children:[s.jsx("option",{value:"",children:"Select"}),p.map(_=>s.jsx("option",{value:_,children:_},_))]}):s.jsx(de,{label:"City",required:!0,placeholder:"Enter",error:(w=m.city)==null?void 0:w.message,...l("city")})]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:s.jsx(de,{label:"Zip Code",required:!0,placeholder:"Enter",error:(k=m.zipCode)==null?void 0:k.message,...l("zipCode")})}),s.jsx(de,{label:"Address Line 1",required:!0,placeholder:"Enter",error:(E=m.address1)==null?void 0:E.message,...l("address1")}),s.jsx(de,{label:"Address Line 2",placeholder:"Enter",error:(P=m.address2)==null?void 0:P.message,...l("address2")})]})}),y?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-slate-200"}),s.jsxs(lr,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:sj.map(_=>{var F;return s.jsx(de,{label:_.label,required:_.required,placeholder:"Enter",error:(F=m[_.name])==null?void 0:F.message,...l(_.name)},_.name)})}),s.jsx("div",{className:"mt-5 space-y-5",children:aj.map(_=>{var F;return s.jsx(de,{label:_.label,required:_.required,placeholder:"Enter",error:(F=m[_.name])==null?void 0:F.message,...l(_.name)},_.name)})})]})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:e,disabled:i,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:i,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:i?"Saving…":"Save"})]})]})}const la="rounded-2xl border border-slate-200 bg-white shadow-sm";function Yi(){const e=Se(),{selectedEntity:t}=ft(),r=Rr.find(i=>i.id==="tax-accounts"),n=r.icon,a=(i="tax-accounts")=>{e("/settings",{state:{section:i}})};return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${la} p-3`,children:s.jsx($u,{items:Rr,activeSection:"tax-accounts",onSectionChange:a})}),s.jsxs("div",{className:`${la} p-6 lg:p-8`,children:[s.jsx(dn,{title:r.title,subtitle:r.subtitle,icon:n}),s.jsx(cj,{onCancel:()=>a("tax-accounts"),onSuccess:()=>a("tax-accounts")})]})]}):s.jsx("div",{className:la+" p-6 lg:p-8",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function uj({paymentsMode:e="all"}){return s.jsxs(Ga,{children:[s.jsx(ee,{index:!0,element:s.jsx(oi,{})}),s.jsx(ee,{path:"create-entity",element:s.jsx(ci,{})}),s.jsx(ee,{path:"create-entity/form",element:s.jsx(Ci,{})}),s.jsxs(ee,{element:s.jsx(li,{}),children:[s.jsx(ee,{path:"entities",element:s.jsx(Ei,{})}),s.jsx(ee,{path:"dashboard",element:s.jsx(_i,{})}),s.jsx(ee,{path:"payments",element:s.jsx(Di,{paymentsMode:e})}),s.jsx(ee,{path:"payments/federal/new",element:s.jsx(gu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(bu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(vu,{})}),s.jsx(ee,{path:"payments/state/new",element:s.jsx(wu,{})}),s.jsx(ee,{path:"payments/state/authorization",element:s.jsx(Cu,{})}),s.jsx(ee,{path:"payments/federal/authorization",element:s.jsx(_u,{})}),s.jsx(ee,{path:"payments/federal/individual-enrollment",element:s.jsx(Ru,{})}),s.jsx(ee,{path:"tax-forms",element:s.jsx(Cv,{})}),s.jsx(ee,{path:"settings",element:s.jsx(Wi,{})}),s.jsx(ee,{path:"settings/tax-accounts/new",element:s.jsx(Yi,{})})]}),s.jsx(ee,{path:"*",element:s.jsx(ht,{to:"/",replace:!0})})]})}const dj=N.forwardRef(function(t,r){const n=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)}})),s.jsx(ii,{...t,navigateFnRef:n,selectEntityFnRef:a,children:s.jsx(uj,{paymentsMode:"all"})})}),mj=N.forwardRef(function(t,r){const n=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)}})),s.jsx(ii,{...t,navigateFnRef:n,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(Ga,{children:[s.jsx(ee,{index:!0,element:s.jsx(oi,{})}),s.jsx(ee,{path:"create-entity",element:s.jsx(ci,{})}),s.jsx(ee,{path:"create-entity/form",element:s.jsx(Ci,{})}),s.jsxs(ee,{element:s.jsx(li,{}),children:[s.jsx(ee,{path:"entities",element:s.jsx(Ei,{})}),s.jsx(ee,{path:"dashboard",element:s.jsx(_i,{})}),s.jsx(ee,{path:"payments",element:s.jsx(Di,{paymentsMode:"federal"})}),s.jsx(ee,{path:"payments/federal/new",element:s.jsx(gu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(bu,{})}),s.jsx(ee,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(vu,{})}),s.jsx(ee,{path:"payments/federal/authorization",element:s.jsx(_u,{})}),s.jsx(ee,{path:"payments/federal/individual-enrollment",element:s.jsx(Ru,{})}),s.jsx(ee,{path:"settings",element:s.jsx(Wi,{})}),s.jsx(ee,{path:"settings/tax-accounts/new",element:s.jsx(Yi,{})})]}),s.jsx(ee,{path:"*",element:s.jsx(ht,{to:"/",replace:!0})})]})})}),hj=N.forwardRef(function(t,r){const n=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)}})),s.jsx(ii,{...t,navigateFnRef:n,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(Ga,{children:[s.jsx(ee,{index:!0,element:s.jsx(oi,{})}),s.jsx(ee,{path:"create-entity",element:s.jsx(ci,{})}),s.jsx(ee,{path:"create-entity/form",element:s.jsx(Ci,{})}),s.jsxs(ee,{element:s.jsx(li,{}),children:[s.jsx(ee,{path:"entities",element:s.jsx(Ei,{})}),s.jsx(ee,{path:"dashboard",element:s.jsx(_i,{})}),s.jsx(ee,{path:"payments",element:s.jsx(Di,{paymentsMode:"state"})}),s.jsx(ee,{path:"payments/state/new",element:s.jsx(wu,{})}),s.jsx(ee,{path:"payments/state/authorization",element:s.jsx(Cu,{})}),s.jsx(ee,{path:"settings",element:s.jsx(Wi,{})}),s.jsx(ee,{path:"settings/tax-accounts/new",element:s.jsx(Yi,{})})]}),s.jsx(ee,{path:"*",element:s.jsx(ht,{to:"/",replace:!0})})]})})});exports.ApiError=zn;exports.FederalPaymentWidget=mj;exports.StatePaymentWidget=hj;exports.TaxRemittanceEmbedded=dj;exports.setRuntimeApiBaseUrl=tc;
76
76
  //# sourceMappingURL=index.cjs.map