@npm-zenwork/tax-remittance-ui 0.1.12 → 0.1.13

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 Gu=Object.defineProperty;var ao=e=>{throw TypeError(e)};var Xu=(e,t,r)=>t in e?Gu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var wn=(e,t,r)=>Xu(e,typeof t!="symbol"?t+"":t,r),Js=(e,t,r)=>t.has(e)||ao("Cannot "+r);var j=(e,t,r)=>(Js(e,t,"read from private field"),r?r.call(e):t.get(e)),X=(e,t,r)=>t.has(e)?ao("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Z=(e,t,r,s)=>(Js(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),le=(e,t,r)=>(Js(e,t,"access private method"),r);var Jn=(e,t,r,s)=>({set _(a){Z(e,t,a,r)},get _(){return j(e,t,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),v=require("react"),_s=require("react-dom");function ed(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const P=ed(v);/**
1
+ "use strict";var ad=Object.defineProperty;var io=e=>{throw TypeError(e)};var id=(e,t,n)=>t in e?ad(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wr=(e,t,n)=>id(e,typeof t!="symbol"?t+"":t,n),ea=(e,t,n)=>t.has(e)||io("Cannot "+n);var w=(e,t,n)=>(ea(e,t,"read from private field"),n?n.call(e):t.get(e)),J=(e,t,n)=>t.has(e)?io("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),U=(e,t,n,s)=>(ea(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),le=(e,t,n)=>(ea(e,t,"access private method"),n);var Xr=(e,t,n,s)=>({set _(a){U(e,t,a,n)},get _(){return w(e,t,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),v=require("react"),Vr=require("react-dom");function od(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const P=od(v);/**
2
2
  * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
@@ -7,53 +7,53 @@
7
7
  * LICENSE.md file in the root directory of this source tree.
8
8
  *
9
9
  * @license MIT
10
- */var ti=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,td=/^[\\/]{2}/;function rd(e,t){return t+e.replace(/\\/g,"/")}function io(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function nd(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:s=!1}=e,a;a=t.map((f,g)=>d(f,typeof f=="string"?null:f.state,g===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,g=null,p,b){let x=ad(a?u().pathname:"/",f,g,p,b);return ut(x.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),x}function m(f){return typeof f=="string"?f:ps(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 g=typeof f=="string"?$r(f):f;return{pathname:g.pathname||"",search:g.search||"",hash:g.hash||""}},push(f,g){o="PUSH";let p=io(f)?f:d(f,g);i+=1,a.splice(i,a.length,p),s&&l&&l({action:o,location:p,delta:1})},replace(f,g){o="REPLACE";let p=io(f)?f:d(f,g);a[i]=p,s&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let g=c(i+f),p=a[g];i=g,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function Pe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ut(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function sd(){return Math.random().toString(36).substring(2,10)}function ad(e,t,r=null,s,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?$r(t):t,state:r,key:t&&t.key||s||sd(),mask:a}}function ps({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 $r(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function _l(e,t,r="/"){return id(e,t,r,!1)}function id(e,t,r,s,a){let i=typeof t=="string"?$r(t):t,o=Kt(i.pathname||"/",r);if(o==null)return null;let l=od(e),c=null,u=yd(o);for(let d=0;c==null&&d<l.length;++d)c=gd(l[d],u,s);return c}function od(e){let t=Il(e);return ld(t),t}function Il(e,t=[],r=[],s="",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(s)&&c)return;Pe(d.relativePath.startsWith(s),`Absolute route path "${d.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(s.length)}let m=Et([s,d.relativePath]),h=r.concat(d);o.children&&o.children.length>0&&(Pe(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Il(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:pd(m,o.index),routesMeta:h.map((f,g)=>{let[p,b]=Dl(f.relativePath,f.caseSensitive,g===h.length-1);return{...f,matcher:p,compiledParams:b}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of Tl(o.path))i(o,l,!0,u)}),t}function Tl(e){let t=e.split("/");if(t.length===0)return[];let[r,...s]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=Tl(s.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 ld(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:xd(t.routesMeta.map(s=>s.childrenIndex),r.routesMeta.map(s=>s.childrenIndex)))}var cd=/^:[\w-]+$/,ud=3,dd=2,md=1,hd=10,fd=-2,oo=e=>e==="*";function pd(e,t){let r=e.split("/"),s=r.length;return r.some(oo)&&(s+=fd),t&&(s+=dd),r.filter(a=>!oo(a)).reduce((a,i)=>a+(cd.test(i)?ud:i===""?md:hd),s)}function xd(e,t){return e.length===t.length&&e.slice(0,-1).every((s,a)=>s===t[a])?e[e.length-1]-t[t.length-1]:0}function gd(e,t,r=!1){let{routesMeta:s}=e,a={},i="/",o=[];for(let l=0;l<s.length;++l){let c=s[l],u=l===s.length-1,d=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h=c.matcher&&c.compiledParams?Fl(m,d,c.matcher,c.compiledParams):xs(m,d),f=c.route;if(!h&&u&&r&&!s[s.length-1].route.index&&(h=xs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Et([i,h.pathname]),pathnameBase:jd(Et([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Et([i,h.pathnameBase]))}return o}function xs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,s]=Dl(e.path,e.caseSensitive,e.end);return Fl(e,t,r,s)}function Fl(e,t,r,s){let a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:s.reduce((u,{paramName:d,isOptional:m},h)=>{if(d==="*"){let g=l[h]||"";o=i.slice(0,i.length-g.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 Dl(e,t=!1,r=!0){ut(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 s=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(s.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("*")?(s.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),s]}function yd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ut(!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 Kt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,s=e.charAt(r);return s&&s!=="/"?null:e.slice(r)||"/"}function bd(e,t="/"){let{pathname:r,search:s="",hash:a=""}=typeof e=="string"?$r(e):e,i;return r?(r=Rl(r),r.startsWith("/")?i=lo(r.substring(1),"/"):i=lo(r,t)):i=t,{pathname:i,search:Nd(s),hash:wd(a)}}function lo(e,t){let r=gs(t).split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Gs(e,t,r,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. 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 vd(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ri(e){let t=vd(e);return t.map((r,s)=>s===t.length-1?r.pathname:r.pathnameBase)}function Is(e,t,r,s=!1){let a;typeof e=="string"?a=$r(e):(a={...e},Pe(!a.pathname||!a.pathname.includes("?"),Gs("?","pathname","search",a)),Pe(!a.pathname||!a.pathname.includes("#"),Gs("#","pathname","hash",a)),Pe(!a.search||!a.search.includes("#"),Gs("#","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(!s&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=bd(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Rl=e=>e.replace(/[\\/]{2,}/g,"/"),Et=e=>Rl(e.join("/")),gs=e=>e.replace(/\/+$/,""),jd=e=>gs(e).replace(/^\/*/,"/"),Nd=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,wd=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Sd=class{constructor(e,t,r,s=!1){this.status=e,this.statusText=t||"",this.internal=s,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function kd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Cd(e){let t=e.map(r=>r.route.path).filter(Boolean);return Et(t)||"/"}var Ol=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function $l(e,t){let r=e;if(typeof r!="string"||!ti.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let s=r,a=!1;if(Ol)try{let i=new URL(window.location.href),o=td.test(r)?new URL(rd(r,i.protocol)):new URL(r),l=Kt(o.pathname,t);o.origin===i.origin&&l!=null?r=l+o.search+o.hash:a=!0}catch{ut(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:a,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ll=["POST","PUT","PATCH","DELETE"];new Set(Ll);var Ad=["GET",...Ll];new Set(Ad);var Pd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Ed(e){try{return Pd.includes(new URL(e).protocol)}catch{return!1}}var pn=P.createContext(null);pn.displayName="DataRouter";var Ts=P.createContext(null);Ts.displayName="DataRouterState";var zl=P.createContext(!1);function _d(){return P.useContext(zl)}var Ml=P.createContext({isTransitioning:!1});Ml.displayName="ViewTransition";var Id=P.createContext(new Map);Id.displayName="Fetchers";var Td=P.createContext(null);Td.displayName="Await";var dt=P.createContext(null);dt.displayName="Navigation";var Vn=P.createContext(null);Vn.displayName="Location";var bt=P.createContext({outlet:null,matches:[],isDataRoute:!1});bt.displayName="Route";var ni=P.createContext(null);ni.displayName="RouteError";var ql="REACT_ROUTER_ERROR",Fd="REDIRECT",Dd="ROUTE_ERROR_RESPONSE";function Rd(e){if(e.startsWith(`${ql}:${Fd}:{`))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 Od(e){if(e.startsWith(`${ql}:${Dd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Sd(t.status,t.statusText,t.data)}catch{}}function $d(e,{relative:t}={}){Pe(xn(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:s}=P.useContext(dt),{hash:a,pathname:i,search:o}=Bn(e,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:Et([r,i])),s.createHref({pathname:l,search:o,hash:a})}function xn(){return P.useContext(Vn)!=null}function we(){return Pe(xn(),"useLocation() may be used only in the context of a <Router> component."),P.useContext(Vn).location}var Vl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Bl(e){P.useContext(dt).static||P.useLayoutEffect(e)}function Se(){let{isDataRoute:e}=P.useContext(bt);return e?Jd():Ld()}function Ld(){Pe(xn(),"useNavigate() may be used only in the context of a <Router> component.");let e=P.useContext(pn),{basename:t,navigator:r}=P.useContext(dt),{matches:s}=P.useContext(bt),{pathname:a}=we(),i=JSON.stringify(ri(s)),o=P.useRef(!1);return Bl(()=>{o.current=!0}),P.useCallback((c,u={})=>{if(ut(o.current,Vl),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=Is(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:Et([t,d.pathname])),(u.replace?r.replace:r.push)(d,u.state,u)},[t,r,i,a,e])}var Ul=P.createContext(null);function mt(){return P.useContext(Ul)}function zd(e){let t=P.useContext(bt).outlet;return P.useMemo(()=>t&&P.createElement(Ul.Provider,{value:e},t),[t,e])}function si(){let{matches:e}=P.useContext(bt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Bn(e,{relative:t}={}){let{matches:r}=P.useContext(bt),{pathname:s}=we(),a=JSON.stringify(ri(r));return P.useMemo(()=>Is(e,JSON.parse(a),s,t==="path"),[e,a,s,t])}function Md(e,t){return Zl(e,t)}function Zl(e,t,r){var b;Pe(xn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=P.useContext(dt),{matches:a}=P.useContext(bt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let x=u&&u.path||"";Yl(l,!u||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${x}">) 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 ni=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,ld=/^[\\/]{2}/;function cd(e,t){return t+e.replace(/\\/g,"/")}function oo(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ud(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:s=!1}=e,a;a=t.map((f,x)=>d(f,typeof f=="string"?null:f.state,x===0?"default":void 0,typeof f=="string"?void 0:f.mask));let i=c(n??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,x=null,p,N){let g=md(a?u().pathname:"/",f,x,p,N);return dt(g.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),g}function m(f){return typeof f=="string"?f:gs(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 x=typeof f=="string"?Mn(f):f;return{pathname:x.pathname||"",search:x.search||"",hash:x.hash||""}},push(f,x){o="PUSH";let p=oo(f)?f:d(f,x);i+=1,a.splice(i,a.length,p),s&&l&&l({action:o,location:p,delta:1})},replace(f,x){o="REPLACE";let p=oo(f)?f:d(f,x);a[i]=p,s&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let x=c(i+f),p=a[x];i=x,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function Ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function dt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function dd(){return Math.random().toString(36).substring(2,10)}function md(e,t,n=null,s,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Mn(t):t,state:n,key:t&&t.key||s||dd(),mask:a}}function gs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Mn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function Fl(e,t,n="/"){return hd(e,t,n,!1)}function hd(e,t,n,s,a){let i=typeof t=="string"?Mn(t):t,o=Jt(i.pathname||"/",n);if(o==null)return null;let l=fd(e),c=null,u=kd(o);for(let d=0;c==null&&d<l.length;++d)c=Sd(l[d],u,s);return c}function fd(e){let t=Dl(e);return pd(t),t}function Dl(e,t=[],n=[],s="",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(s)&&c)return;Ie(d.relativePath.startsWith(s),`Absolute route path "${d.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(s.length)}let m=Ct([s,d.relativePath]),h=n.concat(d);o.children&&o.children.length>0&&(Ie(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Dl(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:Nd(m,o.index),routesMeta:h.map((f,x)=>{let[p,N]=Ol(f.relativePath,f.caseSensitive,x===h.length-1);return{...f,matcher:p,compiledParams:N}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of Rl(o.path))i(o,l,!0,u)}),t}function Rl(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=Rl(s.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 pd(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:wd(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var xd=/^:[\w-]+$/,gd=3,yd=2,bd=1,vd=10,jd=-2,lo=e=>e==="*";function Nd(e,t){let n=e.split("/"),s=n.length;return n.some(lo)&&(s+=jd),t&&(s+=yd),n.filter(a=>!lo(a)).reduce((a,i)=>a+(xd.test(i)?gd:i===""?bd:vd),s)}function wd(e,t){return e.length===t.length&&e.slice(0,-1).every((s,a)=>s===t[a])?e[e.length-1]-t[t.length-1]:0}function Sd(e,t,n=!1){let{routesMeta:s}=e,a={},i="/",o=[];for(let l=0;l<s.length;++l){let c=s[l],u=l===s.length-1,d=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h=c.matcher&&c.compiledParams?$l(m,d,c.matcher,c.compiledParams):ys(m,d),f=c.route;if(!h&&u&&n&&!s[s.length-1].route.index&&(h=ys({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Ct([i,h.pathname]),pathnameBase:Pd(Ct([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Ct([i,h.pathnameBase]))}return o}function ys(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=Ol(e.path,e.caseSensitive,e.end);return $l(e,t,n,s)}function $l(e,t,n,s){let a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:s.reduce((u,{paramName:d,isOptional:m},h)=>{if(d==="*"){let x=l[h]||"";o=i.slice(0,i.length-x.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 Ol(e,t=!1,n=!0){dt(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 s=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(s.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("*")?(s.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),s]}function kd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return dt(!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 Jt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}function Cd(e,t="/"){let{pathname:n,search:s="",hash:a=""}=typeof e=="string"?Mn(e):e,i;return n?(n=Ll(n),n.startsWith("/")?i=co(n.substring(1),"/"):i=co(n,t)):i=t,{pathname:i,search:Ed(s),hash:Id(a)}}function co(e,t){let n=bs(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function ta(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ad(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ri(e){let t=Ad(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Ds(e,t,n,s=!1){let a;typeof e=="string"?a=Mn(e):(a={...e},Ie(!a.pathname||!a.pathname.includes("?"),ta("?","pathname","search",a)),Ie(!a.pathname||!a.pathname.includes("#"),ta("#","pathname","hash",a)),Ie(!a.search||!a.search.includes("#"),ta("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!s&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=Cd(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Ll=e=>e.replace(/[\\/]{2,}/g,"/"),Ct=e=>Ll(e.join("/")),bs=e=>e.replace(/\/+$/,""),Pd=e=>bs(e).replace(/^\/*/,"/"),Ed=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Id=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,_d=class{constructor(e,t,n,s=!1){this.status=e,this.statusText=t||"",this.internal=s,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Td(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(n=>n.route.path).filter(Boolean);return Ct(t)||"/"}var zl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ml(e,t){let n=e;if(typeof n!="string"||!ni.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,a=!1;if(zl)try{let i=new URL(window.location.href),o=ld.test(n)?new URL(cd(n,i.protocol)):new URL(n),l=Jt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{dt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ql=["POST","PUT","PATCH","DELETE"];new Set(ql);var Dd=["GET",...ql];new Set(Dd);var Rd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function $d(e){try{return Rd.includes(new URL(e).protocol)}catch{return!1}}var pr=P.createContext(null);pr.displayName="DataRouter";var Rs=P.createContext(null);Rs.displayName="DataRouterState";var Bl=P.createContext(!1);function Od(){return P.useContext(Bl)}var Vl=P.createContext({isTransitioning:!1});Vl.displayName="ViewTransition";var Ld=P.createContext(new Map);Ld.displayName="Fetchers";var zd=P.createContext(null);zd.displayName="Await";var mt=P.createContext(null);mt.displayName="Navigation";var Ur=P.createContext(null);Ur.displayName="Location";var gt=P.createContext({outlet:null,matches:[],isDataRoute:!1});gt.displayName="Route";var si=P.createContext(null);si.displayName="RouteError";var Ul="REACT_ROUTER_ERROR",Md="REDIRECT",qd="ROUTE_ERROR_RESPONSE";function Bd(e){if(e.startsWith(`${Ul}:${Md}:{`))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 Vd(e){if(e.startsWith(`${Ul}:${qd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new _d(t.status,t.statusText,t.data)}catch{}}function Ud(e,{relative:t}={}){Ie(xr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=P.useContext(mt),{hash:a,pathname:i,search:o}=Zr(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ct([n,i])),s.createHref({pathname:l,search:o,hash:a})}function xr(){return P.useContext(Ur)!=null}function Ce(){return Ie(xr(),"useLocation() may be used only in the context of a <Router> component."),P.useContext(Ur).location}var Zl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Wl(e){P.useContext(mt).static||P.useLayoutEffect(e)}function Ae(){let{isDataRoute:e}=P.useContext(gt);return e?sm():Zd()}function Zd(){Ie(xr(),"useNavigate() may be used only in the context of a <Router> component.");let e=P.useContext(pr),{basename:t,navigator:n}=P.useContext(mt),{matches:s}=P.useContext(gt),{pathname:a}=Ce(),i=JSON.stringify(ri(s)),o=P.useRef(!1);return Wl(()=>{o.current=!0}),P.useCallback((c,u={})=>{if(dt(o.current,Zl),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=Ds(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:Ct([t,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[t,n,i,a,e])}var Hl=P.createContext(null);function ht(){return P.useContext(Hl)}function Wd(e){let t=P.useContext(gt).outlet;return P.useMemo(()=>t&&P.createElement(Hl.Provider,{value:e},t),[t,e])}function ai(){let{matches:e}=P.useContext(gt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Zr(e,{relative:t}={}){let{matches:n}=P.useContext(gt),{pathname:s}=Ce(),a=JSON.stringify(ri(n));return P.useMemo(()=>Ds(e,JSON.parse(a),s,t==="path"),[e,a,s,t])}function Hd(e,t){return Yl(e,t)}function Yl(e,t,n){var N;Ie(xr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=P.useContext(mt),{matches:a}=P.useContext(gt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let g=u&&u.path||"";Ql(l,!u||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) 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="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let d=we(),m;if(t){let x=typeof t=="string"?$r(t):t;Pe(c==="/"||((b=x.pathname)==null?void 0:b.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 "${x.pathname}" was given in the \`location\` prop.`),m=x}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let x=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=r&&r.state.matches.length?r.state.matches.map(x=>Object.assign(x,{route:r.manifest[x.route.id]||x.route})):_l(e,{pathname:f});ut(u||g!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),ut(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.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=Zd(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},o,x.params),pathname:Et([c,s.encodeLocation?s.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Et([c,s.encodeLocation?s.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),a,r);return t&&p?P.createElement(Vn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function qd(){let e=Qd(),t=kd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:s},i={padding:"2px 4px",backgroundColor:s},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=P.createElement(P.Fragment,null,P.createElement("p",null,"💿 Hey developer 👋"),P.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",P.createElement("code",{style:i},"ErrorBoundary")," or"," ",P.createElement("code",{style:i},"errorElement")," prop on your route.")),P.createElement(P.Fragment,null,P.createElement("h2",null,"Unexpected Application Error!"),P.createElement("h3",{style:{fontStyle:"italic"}},t),r?P.createElement("pre",{style:a},r):null,o)}var Vd=P.createElement(qd,null),Wl=class extends P.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=Od(e.digest);r&&(e=r)}let t=e!==void 0?P.createElement(bt.Provider,{value:this.props.routeContext},P.createElement(ni.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?P.createElement(Bd,{error:e},t):t}};Wl.contextType=zl;var Xs=new WeakMap;function Bd({children:e,error:t}){let{basename:r}=P.useContext(dt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=Rd(t.digest);if(s){let a=Xs.get(t);if(a)throw a;let i=$l(s.location,r),o=i.absoluteURL||i.to;if(Ed(o))throw new Error("Invalid redirect location");if(Ol&&!Xs.get(t))if(i.isExternal||s.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:s.replace}));throw Xs.set(t,l),l}return P.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Ud({routeContext:e,match:t,children:r}){let s=P.useContext(pn);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),P.createElement(bt.Provider,{value:e},r)}function Zd(e,t=[],r){let s=r==null?void 0:r.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let a=e,i=s==null?void 0:s.errors;if(i!=null){let d=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Pe(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&&s){o=s.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}=s,g=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||g){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=s&&c?(d,m)=>{var h,f;c(d,{location:s.location,params:((f=(h=s.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:Cd(s.matches),errorInfo:m})}:void 0;return a.reduceRight((d,m,h)=>{let f,g=!1,p=null,b=null;s&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Vd,o&&(l<0&&h===0?(Yl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,b=null):l===h&&(g=!0,b=m.route.hydrateFallbackElement||null)));let x=t.concat(a.slice(0,h+1)),S=()=>{let w;return f?w=p:g?w=b:m.route.Component?w=P.createElement(m.route.Component,null):m.route.element?w=m.route.element:w=d,P.createElement(Ud,{match:m,routeContext:{outlet:d,matches:x,isDataRoute:s!=null},children:w})};return s&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?P.createElement(Wl,{location:s.location,revalidation:s.revalidation,component:p,error:f,children:S(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:u}):S()},null)}function ai(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wd(e){let t=P.useContext(pn);return Pe(t,ai(e)),t}function Yd(e){let t=P.useContext(Ts);return Pe(t,ai(e)),t}function Hd(e){let t=P.useContext(bt);return Pe(t,ai(e)),t}function ii(e){let t=Hd(e),r=t.matches[t.matches.length-1];return Pe(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Kd(){return ii("useRouteId")}function Qd(){var s;let e=P.useContext(ni),t=Yd("useRouteError"),r=ii("useRouteError");return e!==void 0?e:(s=t.errors)==null?void 0:s[r]}function Jd(){let{router:e}=Wd("useNavigate"),t=ii("useNavigate"),r=P.useRef(!1);return Bl(()=>{r.current=!0}),P.useCallback(async(a,i={})=>{ut(r.current,Vl),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var co={};function Yl(e,t,r){!t&&!co[e]&&(co[e]=!0,ut(!1,r))}P.memo(Gd);function Gd({routes:e,manifest:t,future:r,state:s,isStatic:a,onError:i}){return Zl(e,void 0,{manifest:t,state:s,isStatic:a,onError:i})}function Xd({basename:e,children:t,initialEntries:r,initialIndex:s,useTransitions:a}){let i=P.useRef();i.current==null&&(i.current=nd({initialEntries:r,initialIndex:s,v5Compat:!0}));let o=i.current,[l,c]=P.useState({action:o.action,location:o.location}),u=P.useCallback(d=>{a===!1?c(d):P.startTransition(()=>c(d))},[a]);return P.useLayoutEffect(()=>o.listen(u),[o,u]),P.createElement(tm,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Be({to:e,replace:t,state:r,relative:s}){Pe(xn(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=P.useContext(dt);ut(!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}=P.useContext(bt),{pathname:o}=we(),l=Se(),c=Is(e,ri(i),o,s==="path"),u=JSON.stringify(c);return P.useEffect(()=>{l(JSON.parse(u),{replace:t,state:r,relative:s})},[l,u,s,t,r]),null}function em(e){return zd(e.context)}function re(e){Pe(!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 tm({basename:e="/",children:t=null,location:r,navigationType:s="POP",navigator:a,static:i=!1,useTransitions:o}){Pe(!xn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=P.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof r=="string"&&(r=$r(r));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:g}=r,p=P.useMemo(()=>{let b=Kt(u,l);return b==null?null:{location:{pathname:b,search:d,hash:m,state:h,key:f,mask:g},navigationType:s}},[l,u,d,m,h,f,s,g]);return ut(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:P.createElement(dt.Provider,{value:c},P.createElement(Vn.Provider,{children:t,value:p}))}function oi({children:e,location:t}){return Md(ga(e),t)}function ga(e,t=[]){let r=[];return P.Children.forEach(e,(s,a)=>{if(!P.isValidElement(s))return;let i=[...t,a];if(s.type===P.Fragment){r.push.apply(r,ga(s.props.children,i));return}Pe(s.type===re,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Pe(!s.props.index||!s.props.children,"An index route cannot have child routes.");let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=ga(s.props.children,i)),r.push(o)}),r}var ds="get",ms="application/x-www-form-urlencoded";function Fs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function rm(e){return Fs(e)&&e.tagName.toLowerCase()==="button"}function nm(e){return Fs(e)&&e.tagName.toLowerCase()==="form"}function sm(e){return Fs(e)&&e.tagName.toLowerCase()==="input"}function am(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function im(e,t){return e.button===0&&(!t||t==="_self")&&!am(e)}function ya(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let s=e[r];return t.concat(Array.isArray(s)?s.map(a=>[r,a]):[[r,s]])},[]))}function om(e,t){let r=ya(e);return t&&t.forEach((s,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}var Gn=null;function lm(){if(Gn===null)try{new FormData(document.createElement("form"),0),Gn=!1}catch{Gn=!0}return Gn}var cm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ea(e){return e!=null&&!cm.has(e)?(ut(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ms}"`),null):e}function um(e,t){let r,s,a,i,o;if(nm(e)){let l=e.getAttribute("action");s=l?Kt(l,t):null,r=e.getAttribute("method")||ds,a=ea(e.getAttribute("enctype"))||ms,i=new FormData(e)}else if(rm(e)||sm(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(s=c?Kt(c,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||ds,a=ea(e.getAttribute("formenctype"))||ea(l.getAttribute("enctype"))||ms,i=new FormData(l,e),!lm()){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(Fs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=ds,s=null,a=ms,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:s,method:r.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function li(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Hl(e,t,r,s){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}_.${s}`:a.pathname=`${a.pathname}.${s}`:a.pathname==="/"?a.pathname=`_root.${s}`:t&&Kt(a.pathname,t)==="/"?a.pathname=`${gs(t)}/_root.${s}`:a.pathname=`${gs(a.pathname)}.${s}`,a}async function dm(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 mm(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 hm(e,t,r){let s=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await dm(i,r);return o.links?o.links():[]}return[]}));return gm(s.flat(1).filter(mm).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function uo(e,t,r,s,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=s.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 fm(e,t,{includeHydrateFallback:r}={}){return pm(e.map(s=>{let a=t.routes[s.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 pm(e){return[...new Set(e)]}function xm(e){let t={},r=Object.keys(e).sort();for(let s of r)t[s]=e[s];return t}function gm(e,t){let r=new Set;return new Set(t),e.reduce((s,a)=>{let i=JSON.stringify(xm(a));return r.has(i)||(r.add(i),s.push({key:i,link:a})),s},[])}function ci(){let e=P.useContext(pn);return li(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ym(){let e=P.useContext(Ts);return li(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ui=P.createContext(void 0);ui.displayName="FrameworkContext";function Ds(){let e=P.useContext(ui);return li(e,"You must render this element inside a <HydratedRouter> element"),e}function bm(e,t){let r=P.useContext(ui),[s,a]=P.useState(!1),[i,o]=P.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:m}=t,h=P.useRef(null);P.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let p=x=>{x.forEach(S=>{o(S.isIntersecting)})},b=new IntersectionObserver(p,{threshold:.5});return h.current&&b.observe(h.current),()=>{b.disconnect()}}},[e]),P.useEffect(()=>{if(s){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[s]);let f=()=>{a(!0)},g=()=>{a(!1),o(!1)};return r?e!=="intent"?[i,h,{}]:[i,h,{onFocus:Sn(l,f),onBlur:Sn(c,g),onMouseEnter:Sn(u,f),onMouseLeave:Sn(d,g),onTouchStart:Sn(m,f)}]:[!1,h,{}]}function Sn(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function vm({page:e,...t}){let r=_d(),{nonce:s}=Ds(),{router:a}=ci(),i=P.useMemo(()=>_l(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&s&&(t={...t,nonce:s}),r?P.createElement(Nm,{page:e,matches:i,...t}):P.createElement(wm,{page:e,matches:i,...t})):null}function jm(e){let{manifest:t,routeModules:r}=Ds(),[s,a]=P.useState([]);return P.useEffect(()=>{let i=!1;return hm(e,t,r).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,r]),s}function Nm({page:e,matches:t,...r}){let s=we(),{future:a}=Ds(),{basename:i}=ci(),o=P.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let l=Hl(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,s,t]);return P.createElement(P.Fragment,null,o.map(l=>P.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...r})))}function wm({page:e,matches:t,...r}){let s=we(),{future:a,manifest:i,routeModules:o}=Ds(),{basename:l}=ci(),{loaderData:c,matches:u}=ym(),d=P.useMemo(()=>uo(e,t,u,i,s,"data"),[e,t,u,i,s]),m=P.useMemo(()=>uo(e,t,u,i,s,"assets"),[e,t,u,i,s]),h=P.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let p=new Set,b=!1;if(t.forEach(S=>{var N;let w=i.routes[S.route.id];!w||!w.hasLoader||(!d.some(E=>E.route.id===S.route.id)&&S.route.id in c&&((N=o[S.route.id])!=null&&N.shouldRevalidate)||w.hasClientLoader?b=!0:p.add(S.route.id))}),p.size===0)return[];let x=Hl(e,l,a.v8_trailingSlashAwareDataRequests,"data");return b&&p.size>0&&x.searchParams.set("_routes",t.filter(S=>p.has(S.route.id)).map(S=>S.route.id).join(",")),[x.pathname+x.search]},[l,a.v8_trailingSlashAwareDataRequests,c,s,i,d,t,e,o]),f=P.useMemo(()=>fm(m,i),[m,i]),g=jm(m);return P.createElement(P.Fragment,null,h.map(p=>P.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...r})),f.map(p=>P.createElement("link",{key:p,rel:"modulepreload",href:p,...r})),g.map(({key:p,link:b})=>P.createElement("link",{key:p,nonce:r.nonce,...b,crossOrigin:b.crossOrigin??r.crossOrigin})))}function Sm(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var km=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{km&&(window.__reactRouterVersion="7.18.1")}catch{}var Kl=P.forwardRef(function({onClick:t,discover:r="render",prefetch:s="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...g},p){let{basename:b,navigator:x,useTransitions:S}=P.useContext(dt),w=typeof d=="string"&&ti.test(d),N=$l(d,b);d=N.to;let E=$d(d,{relative:a}),D=we(),A=null;if(l){let H=Is(l,[],D.mask?D.mask.pathname:"/",!0);b!=="/"&&(H.pathname=H.pathname==="/"?b:Et([b,H.pathname])),A=x.createHref(H)}let[I,_,L]=bm(s,g),ie=Em(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:S});function U(H){t&&t(H),H.defaultPrevented||ie(H)}let Q=!(N.isExternal||i),te=P.createElement("a",{...g,...L,href:(Q?A:void 0)||N.absoluteURL||E,onClick:Q?U:t,ref:Sm(p,_),target:u,"data-discover":!w&&r==="render"?"true":void 0});return I&&!w?P.createElement(P.Fragment,null,te,P.createElement(vm,{page:E})):te});Kl.displayName="Link";var Cm=P.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:s="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let m=Bn(o,{relative:u.relative}),h=we(),f=P.useContext(Ts),{navigator:g,basename:p}=P.useContext(dt),b=f!=null&&Rm(m)&&l===!0,x=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,S=h.pathname,w=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;r||(S=S.toLowerCase(),w=w?w.toLowerCase():null,x=x.toLowerCase()),w&&p&&(w=Kt(w,p)||w);const N=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let E=S===x||!a&&S.startsWith(x)&&S.charAt(N)==="/",D=w!=null&&(w===x||!a&&w.startsWith(x)&&w.charAt(x.length)==="/"),A={isActive:E,isPending:D,isTransitioning:b},I=E?t:void 0,_;typeof s=="function"?_=s(A):_=[s,E?"active":null,D?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let L=typeof i=="function"?i(A):i;return P.createElement(Kl,{...u,"aria-current":I,className:_,ref:d,style:L,to:o,viewTransition:l},typeof c=="function"?c(A):c)});Cm.displayName="NavLink";var Am=P.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:s,replace:a,state:i,method:o=ds,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},g)=>{let{useTransitions:p}=P.useContext(dt),b=Fm(),x=Dm(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",w=typeof l=="string"&&ti.test(l),N=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let D=E.nativeEvent.submitter,A=(D==null?void 0:D.getAttribute("formmethod"))||o,I=()=>b(D||E.currentTarget,{fetcherKey:t,method:A,navigate:r,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&r!==!1?P.startTransition(()=>I()):I()};return P.createElement("form",{ref:g,method:S,action:x,onSubmit:s?c:N,...f,"data-discover":!w&&e==="render"?"true":void 0})});Am.displayName="Form";function Pm(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=P.useContext(pn);return Pe(t,Pm(e)),t}function Em(e,{target:t,replace:r,mask:s,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=Se(),m=we(),h=Bn(e,{relative:o});return P.useCallback(f=>{if(im(f,t)){f.preventDefault();let g=r!==void 0?r:ps(m)===ps(h),p=()=>d(e,{replace:g,mask:s,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?P.startTransition(()=>p()):p()}},[m,d,h,r,s,a,t,e,i,o,l,c,u])}function _m(e){ut(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=P.useRef(ya(e)),r=P.useRef(!1),s=we(),a=P.useMemo(()=>om(s.search,r.current?null:t.current),[s.search]),i=Se(),o=P.useCallback((l,c)=>{const u=ya(typeof l=="function"?l(new URLSearchParams(a)):l);r.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var Im=0,Tm=()=>`__${String(++Im)}__`;function Fm(){let{router:e}=Ql("useSubmit"),{basename:t}=P.useContext(dt),r=Kd(),s=e.fetch,a=e.navigate;return P.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:m}=um(i,t);if(o.navigate===!1){let h=o.fetcherKey||Tm();await s(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})},[s,a,t,r])}function Dm(e,{relative:t}={}){let{basename:r}=P.useContext(dt),s=P.useContext(bt);Pe(s,"useFormAction must be used inside a RouteContext");let[a]=s.matches.slice(-1),i={...Bn(e||".",{relative:t})},o=we();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:Et([r,i.pathname])),ps(i)}function Rm(e,{relative:t}={}){let r=P.useContext(Ml);Pe(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=Ql("useViewTransitionState"),a=Bn(e,{relative:t});if(!r.isTransitioning)return!1;let i=Kt(r.currentLocation.pathname,s)||r.currentLocation.pathname,o=Kt(r.nextLocation.pathname,s)||r.nextLocation.pathname;return xs(a.pathname,o)!=null||xs(a.pathname,i)!=null}var gn=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(){}},Nr,nr,Jr,bl,Om=(bl=class extends gn{constructor(){super();X(this,Nr);X(this,nr);X(this,Jr);Z(this,Jr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){j(this,nr)||this.setEventListener(j(this,Jr))}onUnsubscribe(){var t;this.hasListeners()||((t=j(this,nr))==null||t.call(this),Z(this,nr,void 0))}setEventListener(t){var r;Z(this,Jr,t),(r=j(this,nr))==null||r.call(this),Z(this,nr,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){j(this,Nr)!==t&&(Z(this,Nr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof j(this,Nr)=="boolean"?j(this,Nr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Nr=new WeakMap,nr=new WeakMap,Jr=new WeakMap,bl),di=new Om,$m={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Tt,wr,vl,Lm=(vl=class{constructor(){X(this,Tt,$m);X(this,wr,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&j(this,wr)&&e!==j(this,Tt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:j(this,Tt),provider:e}),Z(this,Tt,e),process.env.NODE_ENV!=="production"&&Z(this,wr,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&Z(this,wr,!0),j(this,Tt).setTimeout(e,t)}clearTimeout(e){j(this,Tt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&Z(this,wr,!0),j(this,Tt).setInterval(e,t)}clearInterval(e){j(this,Tt).clearInterval(e)}},Tt=new WeakMap,wr=new WeakMap,vl),vr=new Lm;function zm(e){setTimeout(e,0)}var Mm=typeof window>"u"||"Deno"in globalThis;function et(){}function qm(e,t){return typeof e=="function"?e(t):e}function ba(e){return typeof e=="number"&&e>=0&&e!==1/0}function Jl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function hr(e,t){return typeof e=="function"?e(t):e}function ot(e,t){return typeof e=="function"?e(t):e}function mo(e,t){const{type:r="all",exact:s,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==mi(o,t.options))return!1}else if(!Fn(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 ho(e,t){const{exact:r,status:s,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(!Fn(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function mi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tr)(e)}function Tr(e){return JSON.stringify(e,(t,r)=>ja(r)?Object.keys(r).sort().reduce((s,a)=>(s[a]=r[a],s),{}):r)}function Fn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Fn(e[r],t[r])):!1}var Vm=Object.prototype.hasOwnProperty;function va(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=fo(e)&&fo(t);if(!s&&!(ja(e)&&ja(t)))return t;const i=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),l=o.length,c=s?new Array(l):{};let u=0;for(let d=0;d<l;d++){const m=s?d:o[d],h=e[m],f=t[m];if(h===f){c[m]=h,(s?d<i:Vm.call(e,m))&&u++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const g=va(h,f,r+1);c[m]=g,g===h&&u++}return i===l&&u===i?e:c}function ys(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 fo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ja(e){if(!po(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!po(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function po(e){return Object.prototype.toString.call(e)==="[object Object]"}function Bm(e){return new Promise(t=>{vr.setTimeout(t,e)})}function Na(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 va(e,t)}catch(s){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}]: ${s}`),s}return va(e,t)}return t}function Um(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function Zm(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var bs=Symbol();function Gl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===bs&&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===bs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function hi(e,t){return typeof e=="function"?e(...t):!!e}function Wm(e,t,r){let s=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),s||(s=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),e}var Dn=(()=>{let e=()=>Mm;return{isServer(){return e()},setIsServer(t){e=t}}})();function wa(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function s(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},r.reject=a=>{s({status:"rejected",reason:a}),t(a)},r}var Ym=zm;function Hm(){let e=[],t=0,r=l=>{l()},s=l=>{l()},a=Ym;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{s(()=>{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=>{s=l},setScheduler:l=>{a=l}}}var Le=Hm(),Gr,sr,Xr,jl,Km=(jl=class extends gn{constructor(){super();X(this,Gr,!0);X(this,sr);X(this,Xr);Z(this,Xr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){j(this,sr)||this.setEventListener(j(this,Xr))}onUnsubscribe(){var t;this.hasListeners()||((t=j(this,sr))==null||t.call(this),Z(this,sr,void 0))}setEventListener(t){var r;Z(this,Xr,t),(r=j(this,sr))==null||r.call(this),Z(this,sr,t(this.setOnline.bind(this)))}setOnline(t){j(this,Gr)!==t&&(Z(this,Gr,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return j(this,Gr)}},Gr=new WeakMap,sr=new WeakMap,Xr=new WeakMap,jl),vs=new Km;function Qm(e){return Math.min(1e3*2**e,3e4)}function Xl(e){return(e??"online")==="online"?vs.isOnline():!0}var Sa=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ec(e){let t=!1,r=0,s;const a=wa(),i=()=>a.status!=="pending",o=p=>{var b;if(!i()){const x=new Sa(p);h(x),(b=e.onCancel)==null||b.call(e,x)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>di.isFocused()&&(e.networkMode==="always"||vs.isOnline())&&e.canRun(),d=()=>Xl(e.networkMode)&&e.canRun(),m=p=>{i()||(s==null||s(),a.resolve(p))},h=p=>{i()||(s==null||s(),a.reject(p))},f=()=>new Promise(p=>{var b;s=x=>{(i()||u())&&p(x)},(b=e.onPause)==null||b.call(e)}).then(()=>{var p;s=void 0,i()||(p=e.onContinue)==null||p.call(e)}),g=()=>{if(i())return;let p;const b=r===0?e.initialPromise:void 0;try{p=b??e.fn()}catch(x){p=Promise.reject(x)}Promise.resolve(p).then(m).catch(x=>{var D;if(i())return;const S=e.retry??(Dn.isServer()?0:3),w=e.retryDelay??Qm,N=typeof w=="function"?w(r,x):w,E=S===!0||typeof S=="number"&&r<S||typeof S=="function"&&S(r,x);if(t||!E){h(x);return}r++,(D=e.onFail)==null||D.call(e,r,x),Bm(N).then(()=>u()?void 0:f()).then(()=>{t?h(x):g()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?g():f().then(g),a)}}var Sr,Nl,tc=(Nl=class{constructor(){X(this,Sr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ba(this.gcTime)&&Z(this,Sr,vr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Dn.isServer()?1/0:300*1e3))}clearGcTimeout(){j(this,Sr)!==void 0&&(vr.clearTimeout(j(this,Sr)),Z(this,Sr,void 0))}},Sr=new WeakMap,Nl);function Jm(e){return{onFetch:(t,r)=>{var d,m,h,f,g;const s=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=((g=t.state.data)==null?void 0:g.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const b=w=>{Wm(w,()=>t.signal,()=>p=!0)},x=Gl(t.options,t.fetchOptions),S=async(w,N,E)=>{if(p)return Promise.reject(t.signal.reason);if(N==null&&w.pages.length)return Promise.resolve(w);const A=(()=>{const ie={client:t.client,queryKey:t.queryKey,pageParam:N,direction:E?"backward":"forward",meta:t.options.meta};return b(ie),ie})(),I=await x(A),{maxPages:_}=t.options,L=E?Zm:Um;return{pages:L(w.pages,I,_),pageParams:L(w.pageParams,N,_)}};if(a&&i.length){const w=a==="backward",N=w?Gm:xo,E={pages:i,pageParams:o},D=N(s,E);l=await S(E,D,w)}else{const w=e??i.length;do{const N=c===0?o[0]??s.initialPageParam:xo(s,l);if(c>0&&N==null)break;l=await S(l,N),c++}while(c<w)}return l};t.options.persister?t.fetchFn=()=>{var p,b;return(b=(p=t.options).persister)==null?void 0:b.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function xo(e,{pages:t,pageParams:r}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,r[s],r):void 0}function Gm(e,{pages:t,pageParams:r}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,r[0],r):void 0}var en,kr,tn,yt,Cr,qe,$n,Ar,it,rc,Bt,wl,Xm=(wl=class extends tc{constructor(t){super();X(this,it);X(this,en);X(this,kr);X(this,tn);X(this,yt);X(this,Cr);X(this,qe);X(this,$n);X(this,Ar);Z(this,Ar,!1),Z(this,$n,t.defaultOptions),this.setOptions(t.options),this.observers=[],Z(this,Cr,t.client),Z(this,yt,j(this,Cr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Z(this,kr,yo(this.options)),this.state=t.state??j(this,kr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return j(this,en)}get promise(){var t;return(t=j(this,qe))==null?void 0:t.promise}setOptions(t){if(this.options={...j(this,$n),...t},t!=null&&t._type&&Z(this,en,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=yo(this.options);r.data!==void 0&&(this.setState(go(r.data,r.dataUpdatedAt)),Z(this,kr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&j(this,yt).remove(this)}setData(t,r){const s=Na(this.state.data,t,this.options);return le(this,it,Bt).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(t){le(this,it,Bt).call(this,{type:"setState",state:t})}cancel(t){var s,a;const r=(s=j(this,qe))==null?void 0:s.promise;return(a=j(this,qe))==null||a.cancel(t),r?r.then(et).catch(et):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return j(this,kr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>ot(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bs||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hr(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:!Jl(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=j(this,qe))==null||r.continue()}onOnline(){var r;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=j(this,qe))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),j(this,yt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(j(this,qe)&&(j(this,Ar)||le(this,it,rc).call(this)?j(this,qe).cancel({revert:!0}):j(this,qe).cancelRetry()),this.scheduleGc()),j(this,yt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||le(this,it,Bt).call(this,{type:"invalidate"})}async fetch(t,r){var u,d,m,h,f,g,p,b,x,S,w;if(this.state.fetchStatus!=="idle"&&((u=j(this,qe))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(j(this,qe))return j(this,qe).continueRetry(),j(this,qe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const N=this.observers.find(E=>E.options.queryFn);N&&this.setOptions(N.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 s=new AbortController,a=N=>{Object.defineProperty(N,"signal",{enumerable:!0,get:()=>(Z(this,Ar,!0),s.signal)})},i=()=>{const N=Gl(this.options,r),D=(()=>{const A={client:j(this,Cr),queryKey:this.queryKey,meta:this.meta};return a(A),A})();return Z(this,Ar,!1),this.options.persister?this.options.persister(N,D,this):N(D)},l=(()=>{const N={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:j(this,Cr),state:this.state,fetchFn:i};return a(N),N})(),c=j(this,en)==="infinite"?Jm(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),Z(this,tn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&le(this,it,Bt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),Z(this,qe,ec({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:N=>{N instanceof Sa&&N.revert&&this.setState({...j(this,tn),fetchStatus:"idle"}),s.abort()},onFail:(N,E)=>{le(this,it,Bt).call(this,{type:"failed",failureCount:N,error:E})},onPause:()=>{le(this,it,Bt).call(this,{type:"pause"})},onContinue:()=>{le(this,it,Bt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const N=await j(this,qe).start();if(N===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(N),(f=(h=j(this,yt).config).onSuccess)==null||f.call(h,N,this),(p=(g=j(this,yt).config).onSettled)==null||p.call(g,N,this.state.error,this),N}catch(N){if(N instanceof Sa){if(N.silent)return j(this,qe).promise;if(N.revert){if(this.state.data===void 0)throw N;return this.state.data}}throw le(this,it,Bt).call(this,{type:"error",error:N}),(x=(b=j(this,yt).config).onError)==null||x.call(b,N,this),(w=(S=j(this,yt).config).onSettled)==null||w.call(S,this.state.data,N,this),N}finally{this.scheduleGc()}}},en=new WeakMap,kr=new WeakMap,tn=new WeakMap,yt=new WeakMap,Cr=new WeakMap,qe=new WeakMap,$n=new WeakMap,Ar=new WeakMap,it=new WeakSet,rc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Bt=function(t){const r=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...nc(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...go(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Z(this,tn,t.manual?a:void 0),a;case"error":const i=t.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=r(this.state),Le.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),j(this,yt).notify({query:this,type:"updated",action:t})})},wl);function nc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Xl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function go(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function yo(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,s=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var rt,de,Ln,Xe,Pr,rn,Ut,ar,zn,nn,sn,Er,_r,ir,an,ge,En,ka,Ca,Aa,Pa,Ea,_a,Ia,sc,Sl,eh=(Sl=class extends gn{constructor(t,r){super();X(this,ge);X(this,rt);X(this,de);X(this,Ln);X(this,Xe);X(this,Pr);X(this,rn);X(this,Ut);X(this,ar);X(this,zn);X(this,nn);X(this,sn);X(this,Er);X(this,_r);X(this,ir);X(this,an,new Set);this.options=r,Z(this,rt,t),Z(this,ar,null),Z(this,Ut,wa()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(j(this,de).addObserver(this),bo(j(this,de),this.options)?le(this,ge,En).call(this):this.updateResult(),le(this,ge,Pa).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ta(j(this,de),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ta(j(this,de),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,le(this,ge,Ea).call(this),le(this,ge,_a).call(this),j(this,de).removeObserver(this)}setOptions(t){const r=this.options,s=j(this,de);if(this.options=j(this,rt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ot(this.options.enabled,j(this,de))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");le(this,ge,Ia).call(this),j(this,de).setOptions(this.options),r._defaulted&&!ys(this.options,r)&&j(this,rt).getQueryCache().notify({type:"observerOptionsUpdated",query:j(this,de),observer:this});const a=this.hasListeners();a&&vo(j(this,de),s,this.options,r)&&le(this,ge,En).call(this),this.updateResult(),a&&(j(this,de)!==s||ot(this.options.enabled,j(this,de))!==ot(r.enabled,j(this,de))||hr(this.options.staleTime,j(this,de))!==hr(r.staleTime,j(this,de)))&&le(this,ge,ka).call(this);const i=le(this,ge,Ca).call(this);a&&(j(this,de)!==s||ot(this.options.enabled,j(this,de))!==ot(r.enabled,j(this,de))||i!==j(this,ir))&&le(this,ge,Aa).call(this,i)}getOptimisticResult(t){const r=j(this,rt).getQueryCache().build(j(this,rt),t),s=this.createResult(r,t);return rh(this,s)&&(Z(this,Xe,s),Z(this,rn,this.options),Z(this,Pr,j(this,de).state)),s}getCurrentResult(){return j(this,Xe)}trackResult(t,r){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&j(this,Ut).status==="pending"&&j(this,Ut).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){j(this,an).add(t)}getCurrentQuery(){return j(this,de)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=j(this,rt).defaultQueryOptions(t),s=j(this,rt).getQueryCache().build(j(this,rt),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(t){return le(this,ge,En).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),j(this,Xe)))}createResult(t,r){var _;const s=j(this,de),a=this.options,i=j(this,Xe),o=j(this,Pr),l=j(this,rn),u=t!==s?t.state:j(this,Ln),{state:d}=t;let m={...d},h=!1,f;if(r._optimisticResults){const L=this.hasListeners(),ie=!L&&bo(t,r),U=L&&vo(t,s,r,a);(ie||U)&&(m={...m,...nc(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:g,errorUpdatedAt:p,status:b}=m;f=m.data;let x=!1;if(r.placeholderData!==void 0&&f===void 0&&b==="pending"){let L;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(L=i.data,x=!0):L=typeof r.placeholderData=="function"?r.placeholderData((_=j(this,sn))==null?void 0:_.state.data,j(this,sn)):r.placeholderData,L!==void 0&&(b="success",f=Na(i==null?void 0:i.data,L,r),h=!0)}if(r.select&&f!==void 0&&!x)if(i&&f===(o==null?void 0:o.data)&&r.select===j(this,zn))f=j(this,nn);else try{Z(this,zn,r.select),f=r.select(f),f=Na(i==null?void 0:i.data,f,r),Z(this,nn,f),Z(this,ar,null)}catch(L){Z(this,ar,L)}j(this,ar)&&(g=j(this,ar),f=j(this,nn),p=Date.now(),b="error");const S=m.fetchStatus==="fetching",w=b==="pending",N=b==="error",E=w&&S,D=f!==void 0,I={status:b,fetchStatus:m.fetchStatus,isPending:w,isSuccess:b==="success",isError:N,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:g,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!w,isLoadingError:N&&!D,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&D,isStale:fi(t,r),refetch:this.refetch,promise:j(this,Ut),isEnabled:ot(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=I.data!==void 0,ie=I.status==="error"&&!L,U=H=>{ie?H.reject(I.error):L&&H.resolve(I.data)},Q=()=>{const H=Z(this,Ut,I.promise=wa());U(H)},te=j(this,Ut);switch(te.status){case"pending":t.queryHash===s.queryHash&&U(te);break;case"fulfilled":(ie||I.data!==te.value)&&Q();break;case"rejected":(!ie||I.error!==te.reason)&&Q();break}}return I}updateResult(){const t=j(this,Xe),r=this.createResult(j(this,de),this.options);if(Z(this,Pr,j(this,de).state),Z(this,rn,this.options),j(this,Pr).data!==void 0&&Z(this,sn,j(this,de)),ys(r,t))return;Z(this,Xe,r);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!j(this,an).size)return!0;const o=new Set(i??j(this,an));return this.options.throwOnError&&o.add("error"),Object.keys(j(this,Xe)).some(l=>{const c=l;return j(this,Xe)[c]!==t[c]&&o.has(c)})};le(this,ge,sc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&le(this,ge,Pa).call(this)}},rt=new WeakMap,de=new WeakMap,Ln=new WeakMap,Xe=new WeakMap,Pr=new WeakMap,rn=new WeakMap,Ut=new WeakMap,ar=new WeakMap,zn=new WeakMap,nn=new WeakMap,sn=new WeakMap,Er=new WeakMap,_r=new WeakMap,ir=new WeakMap,an=new WeakMap,ge=new WeakSet,En=function(t){le(this,ge,Ia).call(this);let r=j(this,de).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(et)),r},ka=function(){le(this,ge,Ea).call(this);const t=hr(this.options.staleTime,j(this,de));if(Dn.isServer()||j(this,Xe).isStale||!ba(t))return;const s=Jl(j(this,Xe).dataUpdatedAt,t)+1;Z(this,Er,vr.setTimeout(()=>{j(this,Xe).isStale||this.updateResult()},s))},Ca=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(j(this,de)):this.options.refetchInterval)??!1},Aa=function(t){le(this,ge,_a).call(this),Z(this,ir,t),!(Dn.isServer()||ot(this.options.enabled,j(this,de))===!1||!ba(j(this,ir))||j(this,ir)===0)&&Z(this,_r,vr.setInterval(()=>{(this.options.refetchIntervalInBackground||di.isFocused())&&le(this,ge,En).call(this)},j(this,ir)))},Pa=function(){le(this,ge,ka).call(this),le(this,ge,Aa).call(this,le(this,ge,Ca).call(this))},Ea=function(){j(this,Er)!==void 0&&(vr.clearTimeout(j(this,Er)),Z(this,Er,void 0))},_a=function(){j(this,_r)!==void 0&&(vr.clearInterval(j(this,_r)),Z(this,_r,void 0))},Ia=function(){const t=j(this,rt).getQueryCache().build(j(this,rt),this.options);if(t===j(this,de))return;const r=j(this,de);Z(this,de,t),Z(this,Ln,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},sc=function(t){Le.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(j(this,Xe))}),j(this,rt).getQueryCache().notify({query:j(this,de),type:"observerResultsUpdated"})})},Sl);function th(e,t){return ot(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&ot(t.retryOnMount,e)===!1)}function bo(e,t){return th(e,t)||e.state.data!==void 0&&Ta(e,t,t.refetchOnMount)}function Ta(e,t,r){if(ot(t.enabled,e)!==!1&&hr(t.staleTime,e)!=="static"){const s=typeof r=="function"?r(e):r;return s==="always"||s!==!1&&fi(e,t)}return!1}function vo(e,t,r,s){return(e!==t||ot(s.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&fi(e,r)}function fi(e,t){return ot(t.enabled,e)!==!1&&e.isStaleByTime(hr(t.staleTime,e))}function rh(e,t){return!ys(e.getCurrentResult(),t)}var Mn,Ft,He,Ir,Dt,Xt,kl,nh=(kl=class extends tc{constructor(t){super();X(this,Dt);X(this,Mn);X(this,Ft);X(this,He);X(this,Ir);Z(this,Mn,t.client),this.mutationId=t.mutationId,Z(this,He,t.mutationCache),Z(this,Ft,[]),this.state=t.state||ac(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){j(this,Ft).includes(t)||(j(this,Ft).push(t),this.clearGcTimeout(),j(this,He).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Z(this,Ft,j(this,Ft).filter(r=>r!==t)),this.scheduleGc(),j(this,He).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){j(this,Ft).length||(this.state.status==="pending"?this.scheduleGc():j(this,He).remove(this))}continue(){var t;return((t=j(this,Ir))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,g,p,b,x,S,w,N,E,D,A;const r=()=>{le(this,Dt,Xt).call(this,{type:"continue"})},s={client:j(this,Mn),meta:this.options.meta,mutationKey:this.options.mutationKey};Z(this,Ir,ec({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(I,_)=>{le(this,Dt,Xt).call(this,{type:"failed",failureCount:I,error:_})},onPause:()=>{le(this,Dt,Xt).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>j(this,He).canRun(this)}));const a=this.state.status==="pending",i=!j(this,Ir).canStart();try{if(a)r();else{le(this,Dt,Xt).call(this,{type:"pending",variables:t,isPaused:i}),j(this,He).config.onMutate&&await j(this,He).config.onMutate(t,this,s);const _=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,s));_!==this.state.context&&le(this,Dt,Xt).call(this,{type:"pending",context:_,variables:t,isPaused:i})}const I=await j(this,Ir).start();return await((u=(c=j(this,He).config).onSuccess)==null?void 0:u.call(c,I,t,this.state.context,this,s)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,I,t,this.state.context,s)),await((f=(h=j(this,He).config).onSettled)==null?void 0:f.call(h,I,null,this.state.variables,this.state.context,this,s)),await((p=(g=this.options).onSettled)==null?void 0:p.call(g,I,null,t,this.state.context,s)),le(this,Dt,Xt).call(this,{type:"success",data:I}),I}catch(I){try{await((x=(b=j(this,He).config).onError)==null?void 0:x.call(b,I,t,this.state.context,this,s))}catch(_){Promise.reject(_)}try{await((w=(S=this.options).onError)==null?void 0:w.call(S,I,t,this.state.context,s))}catch(_){Promise.reject(_)}try{await((E=(N=j(this,He).config).onSettled)==null?void 0:E.call(N,void 0,I,this.state.variables,this.state.context,this,s))}catch(_){Promise.reject(_)}try{await((A=(D=this.options).onSettled)==null?void 0:A.call(D,void 0,I,t,this.state.context,s))}catch(_){Promise.reject(_)}throw le(this,Dt,Xt).call(this,{type:"error",error:I}),I}finally{j(this,He).runNext(this)}}},Mn=new WeakMap,Ft=new WeakMap,He=new WeakMap,Ir=new WeakMap,Dt=new WeakSet,Xt=function(t){const r=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Le.batch(()=>{j(this,Ft).forEach(s=>{s.onMutationUpdate(t)}),j(this,He).notify({mutation:this,type:"updated",action:t})})},kl);function ac(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Zt,At,qn,Cl,sh=(Cl=class extends gn{constructor(t={}){super();X(this,Zt);X(this,At);X(this,qn);this.config=t,Z(this,Zt,new Set),Z(this,At,new Map),Z(this,qn,0)}build(t,r,s){const a=new nh({client:t,mutationCache:this,mutationId:++Jn(this,qn)._,options:t.defaultMutationOptions(r),state:s});return this.add(a),a}add(t){j(this,Zt).add(t);const r=Xn(t);if(typeof r=="string"){const s=j(this,At).get(r);s?s.push(t):j(this,At).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(j(this,Zt).delete(t)){const r=Xn(t);if(typeof r=="string"){const s=j(this,At).get(r);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&j(this,At).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Xn(t);if(typeof r=="string"){const s=j(this,At).get(r),a=s==null?void 0:s.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const r=Xn(t);if(typeof r=="string"){const a=(s=j(this,At).get(r))==null?void 0:s.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Le.batch(()=>{j(this,Zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),j(this,Zt).clear(),j(this,At).clear()})}getAll(){return Array.from(j(this,Zt))}find(t){const r={exact:!0,...t};return this.getAll().find(s=>ho(r,s))}findAll(t={}){return this.getAll().filter(r=>ho(t,r))}notify(t){Le.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return Le.batch(()=>Promise.all(t.map(r=>r.continue().catch(et))))}},Zt=new WeakMap,At=new WeakMap,qn=new WeakMap,Cl);function Xn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Wt,or,nt,Yt,Ht,hs,Fa,Al,ah=(Al=class extends gn{constructor(t,r){super();X(this,Ht);X(this,Wt);X(this,or);X(this,nt);X(this,Yt);Z(this,Wt,t),this.setOptions(r),this.bindMethods(),le(this,Ht,hs).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var s;const r=this.options;this.options=j(this,Wt).defaultMutationOptions(t),ys(this.options,r)||j(this,Wt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:j(this,nt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Tr(r.mutationKey)!==Tr(this.options.mutationKey)?this.reset():((s=j(this,nt))==null?void 0:s.state.status)==="pending"&&j(this,nt).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=j(this,nt))==null||t.removeObserver(this)}onMutationUpdate(t){le(this,Ht,hs).call(this),le(this,Ht,Fa).call(this,t)}getCurrentResult(){return j(this,or)}reset(){var t;(t=j(this,nt))==null||t.removeObserver(this),Z(this,nt,void 0),le(this,Ht,hs).call(this),le(this,Ht,Fa).call(this)}mutate(t,r){var s;return Z(this,Yt,r),(s=j(this,nt))==null||s.removeObserver(this),Z(this,nt,j(this,Wt).getMutationCache().build(j(this,Wt),this.options)),j(this,nt).addObserver(this),j(this,nt).execute(t)}},Wt=new WeakMap,or=new WeakMap,nt=new WeakMap,Yt=new WeakMap,Ht=new WeakSet,hs=function(){var r;const t=((r=j(this,nt))==null?void 0:r.state)??ac();Z(this,or,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Fa=function(t){Le.batch(()=>{var r,s,a,i,o,l,c,u;if(j(this,Yt)&&this.hasListeners()){const d=j(this,or).variables,m=j(this,or).context,h={client:j(this,Wt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(s=(r=j(this,Yt)).onSuccess)==null||s.call(r,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=j(this,Yt)).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=j(this,Yt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=j(this,Yt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(j(this,or))})})},Al),Rt,Pl,ih=(Pl=class extends gn{constructor(t={}){super();X(this,Rt);this.config=t,Z(this,Rt,new Map)}build(t,r,s){const a=r.queryKey,i=r.queryHash??mi(a,r);let o=this.get(i);return o||(o=new Xm({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){j(this,Rt).has(t.queryHash)||(j(this,Rt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=j(this,Rt).get(t.queryHash);r&&(t.destroy(),r===t&&j(this,Rt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Le.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return j(this,Rt).get(t)}getAll(){return[...j(this,Rt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(s=>mo(r,s))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(s=>mo(t,s)):r}notify(t){Le.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Le.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Le.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Rt=new WeakMap,Pl),Ie,lr,cr,on,ln,ur,cn,un,El,oh=(El=class{constructor(e={}){X(this,Ie);X(this,lr);X(this,cr);X(this,on);X(this,ln);X(this,ur);X(this,cn);X(this,un);Z(this,Ie,e.queryCache||new ih),Z(this,lr,e.mutationCache||new sh),Z(this,cr,e.defaultOptions||{}),Z(this,on,new Map),Z(this,ln,new Map),Z(this,ur,0)}mount(){Jn(this,ur)._++,j(this,ur)===1&&(Z(this,cn,di.subscribe(async e=>{e&&(await this.resumePausedMutations(),j(this,Ie).onFocus())})),Z(this,un,vs.subscribe(async e=>{e&&(await this.resumePausedMutations(),j(this,Ie).onOnline())})))}unmount(){var e,t;Jn(this,ur)._--,j(this,ur)===0&&((e=j(this,cn))==null||e.call(this),Z(this,cn,void 0),(t=j(this,un))==null||t.call(this),Z(this,un,void 0))}isFetching(e){return j(this,Ie).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return j(this,lr).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=j(this,Ie).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=j(this,Ie).build(this,t),s=r.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(hr(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return j(this,Ie).findAll(e).map(({queryKey:t,state:r})=>{const s=r.data;return[t,s]})}setQueryData(e,t,r){const s=this.defaultQueryOptions({queryKey:e}),a=j(this,Ie).get(s.queryHash),i=a==null?void 0:a.state.data,o=qm(t,i);if(o!==void 0)return j(this,Ie).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return Le.batch(()=>j(this,Ie).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=j(this,Ie).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=j(this,Ie);Le.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=j(this,Ie);return Le.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},s=Le.batch(()=>j(this,Ie).findAll(e).map(a=>a.cancel(r)));return Promise.all(s).then(et).catch(et)}invalidateQueries(e,t={}){return Le.batch(()=>(j(this,Ie).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},s=Le.batch(()=>j(this,Ie).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(et)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(et)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=j(this,Ie).build(this,t);return r.isStaleByTime(hr(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(et).catch(et)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(et).catch(et)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return vs.isOnline()?j(this,lr).resumePausedMutations():Promise.resolve()}getQueryCache(){return j(this,Ie)}getMutationCache(){return j(this,lr)}getDefaultOptions(){return j(this,cr)}setDefaultOptions(e){Z(this,cr,e)}setQueryDefaults(e,t){j(this,on).set(Tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...j(this,on).values()],r={};return t.forEach(s=>{Fn(e,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(e,t){j(this,ln).set(Tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...j(this,ln).values()],r={};return t.forEach(s=>{Fn(e,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...j(this,cr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=mi(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===bs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...j(this,cr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){j(this,Ie).clear(),j(this,lr).clear()}},Ie=new WeakMap,lr=new WeakMap,cr=new WeakMap,on=new WeakMap,ln=new WeakMap,ur=new WeakMap,cn=new WeakMap,un=new WeakMap,El),ic=P.createContext(void 0),vt=e=>{const t=P.useContext(ic);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},lh=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(ic.Provider,{value:e,children:t})),oc=P.createContext(!1),ch=()=>P.useContext(oc);oc.Provider;function uh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var dh=P.createContext(uh()),mh=()=>P.useContext(dh),hh=(e,t,r)=>{const s=r!=null&&r.state.error&&typeof e.throwOnError=="function"?hi(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},fh=e=>{P.useEffect(()=>{e.clearReset()},[e])},ph=({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||hi(r,[e.error,s])),xh=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>r(s(...a)):r(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},gh=(e,t)=>e.isLoading&&e.isFetching&&!t,yh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,jo=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function bh(e,t,r){var f,g,p,b;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 s=ch(),a=mh(),i=vt(),o=i.defaultQueryOptions(e);(g=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||g.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=s?"isRestoring":c?"optimistic":void 0,xh(o),hh(o,a,l),fh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=P.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!s&&c;if(P.useSyncExternalStore(P.useCallback(x=>{const S=h?d.subscribe(Le.batchCalls(x)):et;return d.updateResult(),S},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),P.useEffect(()=>{d.setOptions(o)},[o,d]),yh(o,m))throw jo(o,d,a);if(ph({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((b=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||b.call(p,o,m),o.experimental_prefetchInRender&&!Dn.isServer()&&gh(m,s)){const x=u?jo(o,d,a):l==null?void 0:l.promise;x==null||x.catch(et).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function ve(e,t){return bh(e,eh)}function vh(e,t){const r=vt(),[s]=P.useState(()=>new ah(r,e));P.useEffect(()=>{s.setOptions(e)},[s,e]);const a=P.useSyncExternalStore(P.useCallback(o=>s.subscribe(Le.batchCalls(o)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=P.useCallback((o,l)=>{s.mutate(o,l).catch(et)},[s]);if(a.error&&hi(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function lc(e){return e.trim().replace(/\/+$/,"")}const Rs=new Map;function cc(e,t){Rs.set(e,t)}function jh(e){return Rs.get(e)}function Nh(e){Rs.delete(e)}function wh(e){for(const[t,r]of Rs)if(r.accessToken===e)return t}let Da=null;function uc(e){Da=lc(e)}let dc=null;function Sh(e){dc=e}function kh(){return dc}let mc=null;function Ch(e){mc=e.trim()}function Ah(){return mc}function Ph(){return Da!==null?Da:lc("")}const No={get apiBaseUrl(){return Ph()},apiVersion:"v1"};function Eh(e){const t=e.startsWith("/")?e:`/${e}`;return`${No.apiBaseUrl}/api/${No.apiVersion}${t}`}const hc="auth:session-expired";function _h(){window.dispatchEvent(new CustomEvent(hc))}function fc(e){return`${hc}:${e}`}const Ih=v.createContext(null);function Th({instanceId:e,accessToken:t,onSessionExpired:r,children:s}){const a=jh(e);return a&&cc(e,{...a,accessToken:t}),Sh(t),v.useEffect(()=>{if(!r)return;const i=fc(e),o=()=>r();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,r]),n.jsx(Ih.Provider,{value:{accessToken:t},children:s})}class yn extends Error{constructor(r,s,a,i,o){super(a??s);wn(this,"status");wn(this,"title");wn(this,"details");wn(this,"extensions");this.name="ApiError",this.status=r,this.title=s,this.details=i,this.extensions=o}}const pc="tax-remittance.auth";function Fh(){var t;const e=localStorage.getItem(pc);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?(Ra(),null):r}catch{return Ra(),null}}function Ra(){localStorage.removeItem(pc)}function Dh(){var e;return((e=Fh())==null?void 0:e.accessToken)??null}async function Rh(e){let t=null;try{t=await e.json()}catch{}const r=(t==null?void 0:t.title)??"Request failed",s=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new yn(e.status,r,s,a,t??void 0)}async function Un(e,t={}){const{body:r,auth:s=!0,headers:a,responseType:i="json",...o}=t,l=new Headers(a);i==="blob"?l.set("Accept","application/pdf"):i==="text"?l.set("Accept","text/html"):l.set("Accept","application/json"),r!==void 0&&l.set("Content-Type","application/json");let c=null;if(s){const m=kh()??Dh();m&&(c=m,l.set("Authorization",`Bearer ${m}`))}const u=Ah();u&&l.set("X-Client-ID",u);const d=await fetch(Eh(e),{...o,headers:l,body:r!==void 0?JSON.stringify(r):void 0});if(!d.ok){const m=await Rh(d);if(s&&m.status===401){Ra();const h=c?wh(c):void 0;h?window.dispatchEvent(new CustomEvent(fc(h))):_h()}throw m}if(d.status!==204)return i==="blob"?await d.blob():i==="text"?await d.text():await d.json()}async function fe(e,t={}){return(await Un(e,t)).data}const tt=10;function pi({search:e,pageNumber:t=1,pageSize:r=tt}={}){const s=new URLSearchParams({pageNumber:String(t),pageSize:String(r)});return e!=null&&e.trim()&&s.set("search",e.trim()),fe(`/portal/entities/mine?${s}`)}function Oh(e){return fe("/portal/entities",{method:"POST",body:e})}function $h(e,t){return fe(`/portal/entities/${e}`,{method:"PATCH",body:t})}const xc=v.createContext(null);function Lh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:r,children:s}){var p;const[a,i]=v.useState(null),{data:o=[],isLoading:l,isError:c,refetch:u}=ve({queryKey:["entities","mine"],queryFn:async()=>(await pi({pageNumber:1,pageSize:100})).items}),d=v.useRef(new Set),m=v.useRef(!1);v.useEffect(()=>{if(l)return;if(!m.current){o.forEach(x=>d.current.add(x.entityId)),m.current=!0;return}o.filter(x=>!d.current.has(x.entityId)).forEach(x=>{d.current.add(x.entityId),e==null||e(x)})},[o,l,e]);const h=a!==null&&o.some(b=>b.entityId===a)?a:((p=o[0])==null?void 0:p.entityId)??null,f=o.find(b=>b.entityId===h)??null,g=async()=>{await u()};return n.jsx(xc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:f,setSelectedEntityId:i,refetchEntities:g,enabledPayments:t,onPaymentRequired:r},children:s})}function Lr(){const e=v.useContext(xc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const zh=v.createContext(null);function Mh({theme:e,children:t}){const r={},s=r,a=(e==null?void 0:e.primaryColor)??"#2563eb";s["--embedded-primary"]=a,s["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,s["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";s["--embedded-secondary"]=i,s["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,s["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return s["--embedded-tertiary"]=o,s["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,s["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(s["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(r.fontFamily=e.fontFamily),s.minHeight="100%",n.jsx("div",{className:"tax-remittance-embedded",style:r,children:t})}const gc=v.createContext(null),qh=6e3;function Vh(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Bh({toast:e,onDismiss:t}){const r=e.variant==="success";return n.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:[n.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[n.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),n.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:n.jsx(Uh,{})})]}),n.jsx("div",{className:`mx-5 border-t ${r?"border-emerald-700":"border-red-300"}`}),n.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function Uh(){return n.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function Zh({children:e}){const[t,r]=v.useState([]),s=v.useCallback(o=>{r(l=>l.filter(c=>c.id!==o))},[]),a=v.useCallback((o,l,c)=>{const u=Vh();r(d=>[...d,{id:u,variant:o,title:l,message:c}]),window.setTimeout(()=>{s(u)},qh)},[s]),i=v.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return n.jsxs(gc.Provider,{value:i,children:[e,_s.createPortal(n.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=>n.jsx("div",{className:"pointer-events-auto",children:n.jsx(Bh,{toast:o,onDismiss:s})},o.id))}),document.body)]})}function Os(){const e=v.useContext(gc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class Wh extends v.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?n.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),n.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),n.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 Yh(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 Hh({navigateFnRef:e,onNavigate:t}){const r=Se(),s=we();return v.useEffect(()=>(e.current=r,()=>{e.current=null}),[r,e]),v.useEffect(()=>{t==null||t(Yh(s.pathname),s.pathname)},[s.pathname,t]),null}function Kh({selectEntityFnRef:e}){const{setSelectedEntityId:t}=Lr();return v.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function xi({appKey:e,accessToken:t,apiBaseUrl:r,theme:s,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:u,enabledPayments:d,children:m}){const[h]=v.useState(()=>crypto.randomUUID());cc(h,{apiBaseUrl:r.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),uc(r),Ch(e),v.useEffect(()=>()=>{Nh(h)},[h]);const[f]=v.useState(()=>new oh({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return n.jsx(zh.Provider,{value:h,children:n.jsx(Mh,{theme:s,children:n.jsx(lh,{client:f,children:n.jsx(Zh,{children:n.jsx(Th,{instanceId:h,accessToken:t,onSessionExpired:a,children:n.jsx(Xd,{children:n.jsxs(Lh,{onOrganizationCreated:i,enabledPayments:d,onPaymentRequired:l,children:[n.jsx(Hh,{navigateFnRef:c,onNavigate:o}),n.jsx(Kh,{selectEntityFnRef:u}),n.jsx(Wh,{children:m})]})})})})})})})}function gi(){const{entities:e,isLoading:t,isError:r,refetchEntities:s}=Lr(),a=Se();return v.useEffect(()=>{t||r||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,r,e,a]),t?n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600"})}):r?n.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:n.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.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"})})}),n.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),n.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),n.jsx("button",{type:"button",onClick:s,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 yi(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=Lr(),s=Se(),i=we().pathname.split("/").filter(Boolean).length>1;return n.jsxs("div",{className:"flex min-h-full flex-col bg-slate-50",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3",children:[i&&n.jsxs("button",{type:"button",onClick:()=>s(-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:[n.jsx(Qh,{}),"Back"]}),n.jsx("div",{className:"flex-1"})]}),n.jsx("main",{className:"flex-1 p-5",children:n.jsx(em,{context:{entities:e,selectedEntity:t,setSelectedEntityId:r}})})]})}function Qh(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}const Jh=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function Gh({onCreateClick:e}){return n.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[n.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:[n.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[n.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:n.jsx(wo,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),n.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Create Your Entity"}),n.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),n.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[n.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:Jh.map(t=>n.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[n.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:n.jsx(es,{})}),t]},t))}),n.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:[n.jsx(wo,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",n.jsx(Xh,{})]})]})]}),n.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:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(es,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),n.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(es,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),n.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(es,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function wo({className:e="h-5 w-5"}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:n.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 es({className:e="h-3 w-3"}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 16 16",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.5 8.5l3 3 6-6"})})}function Xh(){return n.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:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})}function bi(){const e=Se(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return n.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:n.jsx(Gh,{onCreateClick:t})})}var Zn=e=>e.type==="checkbox",dr=e=>e instanceof Date,Ze=e=>e==null;const vi=e=>typeof e=="object";var Ae=e=>!Ze(e)&&!Array.isArray(e)&&vi(e)&&!dr(e),Oa=e=>Ae(e)&&e.target?Zn(e.target)?e.target.checked:e.target.value:e,yc=(e,t)=>t.split(".").some((r,s,a)=>!isNaN(Number(r))&&e.has(a.slice(0,s).join("."))),bc=e=>{const t=e.constructor&&e.constructor.prototype;return Ae(t)&&t.hasOwnProperty("isPrototypeOf")},$s=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function _e(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if($s&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ae(e)&&bc(e)))return e;const s=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(s[a]=_e(e[a]));return s}const er={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Pt={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"},vc="root",ji=["__proto__","constructor","prototype"],ef=/^\w*$/;var Wn=e=>ef.test(e),je=e=>e===void 0;const tf=/[.[\]'"]/;var Ls=e=>e.split(tf).filter(Boolean),V=(e,t,r)=>{if(!t||!Ae(e))return r;const s=Wn(t)?[t]:Ls(t);if(s.some(i=>ji.includes(i)))return r;const a=s.reduce((i,o)=>Ze(i)?void 0:i[o],e);return je(a)||a===e?je(e[t])?r:e[t]:a},lt=e=>typeof e=="boolean",Ke=e=>typeof e=="function",xe=(e,t,r)=>{let s=-1;const a=Wn(t)?[t]:Ls(t),i=a.length,o=i-1;for(;++s<i;){const l=a[s];let c=r;if(s!==o){const u=e[l];c=Ae(u)||Array.isArray(u)?u:isNaN(+a[s+1])?{}:[]}if(ji.includes(l))return;e[l]=c,e=e[l]}};const jc=v.createContext(null);jc.displayName="HookFormControlContext";const Ni=()=>v.useContext(jc);var Nc=(e,t,r,s=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==Pt.all&&(t._proxyFormState[o]=!s||Pt.all),r&&(r[o]=!0),e[o]}});return a};const wi=$s?v.useLayoutEffect:v.useEffect;function rf(e){const t=Ni(),{control:r=t,disabled:s,name:a,exact:i}=e||{},[o,l]=v.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=v.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return wi(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!s&&l({...r._formState,...u,defaultValues:r._defaultValues})}}),[a,s,i]),v.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),v.useMemo(()=>Nc(o,r,c.current,!1),[o,r])}var Qe=e=>typeof e=="string",$a=(e,t,r,s,a)=>Qe(e)?(s&&t.watch.add(e),V(r,e,a)):Array.isArray(e)?e.map(i=>(s&&t.watch.add(i),V(r,i))):(s&&(t.watchAll=!0),r),La=e=>Ze(e)||!vi(e);const So=(e,t)=>t.length===0&&!Array.isArray(e)&&!bc(e);function ct(e,t,r=new WeakMap){if(e===t)return!0;if(La(e)||La(t))return Object.is(e,t);if(dr(e)&&dr(t))return Object.is(e.getTime(),t.getTime());const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;if(So(e,s)||So(t,a))return Object.is(e,t);if(!s.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 s){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(dr(l)&&dr(c)||(Ae(l)||Array.isArray(l))&&(Ae(c)||Array.isArray(c))?!ct(l,c,r):!Object.is(l,c))return!1}}return!0}function nf(e){const t=Ni(),{control:r=t,name:s,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=v.useRef(a),u=v.useRef(l),d=v.useRef(void 0),m=v.useRef(r),h=v.useRef(s);u.current=l;const[f,g]=v.useState(()=>{const N=r._getWatch(s,c.current);return u.current?u.current(N):N}),p=v.useCallback(N=>{const E=$a(s,r._names,N||r._formValues,!1,c.current);return u.current?u.current(E):E},[r._formValues,r._names,s]),b=v.useCallback(N=>{if(!i){const E=$a(s,r._names,N||r._formValues,!1,c.current);if(u.current){const D=u.current(E);ct(D,d.current)||(g(D),d.current=D)}else g(E)}},[r._formValues,r._names,i,s]);wi(()=>((m.current!==r||!ct(h.current,s))&&(m.current=r,h.current=s,b()),r._subscribe({name:s,formState:{values:!0},exact:o,callback:N=>{b(N.values)}})),[r,o,s,b]),v.useEffect(()=>r._removeUnmounted());const x=m.current!==r,S=h.current,w=v.useMemo(()=>{if(i)return null;const N=!x&&!ct(S,s);return x||N?p():null},[i,x,s,S,p]);return w!==null?w:f}function sf(e){const t=Ni(),{name:r,disabled:s,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=yc(a._names.array,r),u=v.useMemo(()=>V(a._formValues,r,V(a._defaultValues,r,o)),[a,r,o]),d=nf({control:a,name:r,defaultValue:u,exact:l}),m=rf({control:a,name:r,exact:l}),h=v.useRef(e),f=v.useRef(null),g=v.useRef(a.register(r,{...e.rules,value:d,...lt(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=v.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!V(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!V(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!V(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!V(m.validatingFields,r)},error:{enumerable:!0,get:()=>V(m.errors,r)}}),[m,r]),b=v.useCallback(N=>{const E=Oa(N);return V(a._fields,r)||(g.current=a.register(r,{...h.current.rules,value:E})),g.current.onChange({target:{value:Oa(N),name:r},type:er.CHANGE})},[r,a]),x=v.useCallback(()=>g.current.onBlur({target:{value:V(a._formValues,r),name:r},type:er.BLUR}),[r,a._formValues]),S=v.useCallback(N=>{N&&(f.current={focus:()=>Ke(N.focus)&&N.focus(),select:()=>Ke(N.select)&&N.select(),setCustomValidity:D=>Ke(N.setCustomValidity)&&N.setCustomValidity(D),reportValidity:()=>Ke(N.reportValidity)&&N.reportValidity()});const E=V(a._fields,r);E&&E._f&&N&&(E._f.ref=f.current)},[a._fields,r]),w=v.useMemo(()=>({name:r,value:d,...lt(s)||m.disabled?{disabled:m.disabled||s}:{},onChange:b,onBlur:x,ref:S}),[r,s,m.disabled,b,x,S,d]);return v.useEffect(()=>{const N=a._options.shouldUnregister||i;a.register(r,{...h.current.rules,...lt(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(D,A)=>{const I=V(a._fields,D);I&&I._f&&(I._f.mount=A)};if(E(r,!0),N){const D=_e(V(i?a._defaultValues:a._options.values||a._defaultValues,r,V(a._options.defaultValues,r,h.current.defaultValue)));xe(a._defaultValues,r,D),je(V(a._formValues,r))&&xe(a._formValues,r,D)}if(!c&&a.register(r),f.current){const D=V(a._fields,r);D&&D._f&&(D._f.ref=f.current)}return()=>{(c?N&&!a._state.action:N)?a.unregister(r):E(r,!1)}},[r,a,c,i]),v.useEffect(()=>{a._setDisabledField({disabled:s,name:r})},[s,r,a]),v.useMemo(()=>({field:w,formState:m,fieldState:p}),[w,m,p])}const Ve=e=>e.render(sf(e)),wc=e=>{const t={};for(const r of Object.keys(e))if(vi(e[r])&&e[r]!==null&&!dr(e[r])){const s=wc(e[r]);for(const a of Object.keys(s))t[`${r}.${a}`]=s[a]}else t[r]=e[r];return t},af=v.createContext(null);af.displayName="HookFormContext";var Si=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},Sc=e=>Array.isArray(e)?e.filter(Boolean):[],fs=e=>Array.isArray(e)?e:[e],ko=()=>{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 kc(e,t){const r={};for(const s in e)if(e.hasOwnProperty(s)){const a=e[s],i=t[s];if(a&&Ae(a)&&i){const o=kc(a,i);Ae(o)&&(r[s]=o)}else e[s]&&(r[s]=i)}return r}var Ue=e=>Ae(e)&&!Object.keys(e).length,ki=e=>e.type==="file",js=e=>{if(!$s)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Cc=e=>e.type==="select-multiple",Ci=e=>e.type==="radio",of=e=>Ci(e)||Zn(e),ta=e=>js(e)&&e.isConnected;function lf(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;){if(Ze(e)){e=void 0;break}e=e[t[s]],s++}return e}function cf(e){for(const t in e)if(e.hasOwnProperty(t)&&!je(e[t]))return!1;return!0}function $e(e,t){if(Qe(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:Wn(t)?[t]:Ls(t);if(r.some(o=>ji.includes(String(o))))return e;const s=r.length===1?e:lf(e,r),a=r.length-1,i=r[a];return s&&delete s[i],a!==0&&(Ae(s)&&Ue(s)||Array.isArray(s)&&cf(s))&&$e(e,r.slice(0,-1)),e}var uf=e=>{for(const t in e)if(Ke(e[t]))return!0;return!1};function Ac(e){return Array.isArray(e)||Ae(e)&&!uf(e)}function za(e,t={}){for(const r in e){const s=e[r];Ac(s)?(t[r]=Array.isArray(s)?[]:{},za(s,t[r])):je(s)||(t[r]=!0)}return t}function Ma(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>Ma(r));return t.some(r=>r!==void 0)?t:void 0}if(Ae(e)){const t={};for(const r in e){const s=Ma(e[r]);je(s)||(t[r]=s)}return Object.keys(t).length?t:void 0}}}function br(e,t,r){r||(r=za(t));for(const s in e){const a=e[s];if(Ac(a))je(t)||La(r[s])?r[s]=za(a,Array.isArray(a)?[]:{}):br(a,Ze(t)?{}:t[s],r[s]);else{const i=t[s];r[s]=!ct(a,i)}}return Ma(r)||{}}const Co={value:!1,isValid:!1},Ao={value:!0,isValid:!0};var Pc=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&&!je(e[0].attributes.value)?je(e[0].value)||e[0].value===""?Ao:{value:e[0].value,isValid:!0}:Ao:Co}return Co},Ec=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>je(e)?e:t?e===""?NaN:e&&+e:r&&Qe(e)?new Date(e):s?s(e):e;const Po={isValid:!1,value:null};var _c=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Po):Po;function Eo(e){const t=e.ref;return ki(t)?t.files:Ci(t)?_c(e.refs).value:Cc(t)?[...t.selectedOptions].map(({value:r})=>r):Zn(t)?Pc(e.refs).value:Ec(je(t.value)?e.ref.value:t.value,e)}var df=(e,t,r,s)=>{const a={};for(const i of e){const o=V(t,i);o&&xe(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}},Ns=e=>e instanceof RegExp,kn=e=>je(e)?e:Ns(e)?e.source:Ae(e)?Ns(e.value)?e.value.source:e.value:e,ts=e=>({isOnSubmit:!e||e===Pt.onSubmit,isOnBlur:e===Pt.onBlur,isOnChange:e===Pt.onChange,isOnAll:e===Pt.all,isOnTouch:e===Pt.onTouched});const _o="AsyncFunction";var mf=e=>{if(!e||!e.validate)return!1;if(Ke(e.validate))return e.validate.constructor.name===_o;if(Ae(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===_o)return!0}return!1},hf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ra=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const s of t.watch)if(e.startsWith(s)&&e.charAt(s.length)===".")return!0;return!1};const In=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const i=V(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!s)return!0;if(o.ref&&t(o.ref,o.name)&&!s)return!0;if(In(l,t))break}else if(Ae(l)&&In(l,t))break}}};function Io(e,t,r){const s=V(e,r);if(s||Wn(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=V(t,i),l=V(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 ff=(e,t,r,s)=>{r(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||s&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!s||Pt.all))},pf=(e,t,r)=>!e||!t||e===t||fs(e).some(s=>s&&(r?s===t||s.startsWith(t+"."):s.startsWith(t)||t.startsWith(s))),xf=(e,t,r,s,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:(r?s.isOnChange:a.isOnChange)?e:!0,gf=(e,t)=>!Sc(V(e,t)).length&&$e(e,t),To=(e,t,r)=>{const s=V(e,r),a=Array.isArray(s)?s:[];return xe(a,vc,t[r]),xe(e,r,a),e};function Fo(e,t,r="validate"){if(Qe(e)||Array.isArray(e)&&e.every(Qe)||lt(e)&&!e)return{type:r,message:Qe(e)?e:"",ref:t}}var Ur=e=>Ae(e)&&!Ns(e)?e:{value:e,message:""},Do=async(e,t,r,s,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:m,max:h,pattern:f,validate:g,name:p,valueAsNumber:b,mount:x}=e._f,S=V(r,p);if(!x||t.has(p))return{};const w=l?l[0]:o,N=U=>{if(a&&w.reportValidity){const Q=lt(U)?"":U||"";l?l.forEach(te=>te.setCustomValidity(Q)):w.setCustomValidity(Q),w.reportValidity()}},E={},D=Ci(o),A=Zn(o),I=D||A,_=(b||ki(o))&&je(o.value)&&je(S)||js(o)&&o.value===""||S===""||Array.isArray(S)&&!S.length,L=Si.bind(null,p,s,E),ie=(U,Q,te,H=Ct.maxLength,G=Ct.minLength)=>{const J=U?Q:te;E[p]={type:U?H:G,message:J,ref:o,...L(U?H:G,J)}};if(i?!Array.isArray(S)||!S.length:c&&(!I&&(_||Ze(S))||lt(S)&&!S||A&&!Pc(l).isValid||D&&!_c(l).isValid)){const{value:U,message:Q}=Qe(c)?{value:!!c,message:c}:Ur(c);if(U&&(E[p]={type:Ct.required,message:Q,ref:w,...L(Ct.required,Q)},!s))return N(Q),E}if(!_&&(!Ze(m)||!Ze(h))){let U,Q;const te=Ur(h),H=Ur(m);if(!Ze(S)&&!isNaN(S)){const G=o.valueAsNumber||S&&+S;Ze(te.value)||(U=G>te.value),Ze(H.value)||(Q=G<H.value)}else{const G=o.valueAsDate||new Date(S),J=pe=>new Date(new Date().toDateString()+" "+pe),he=o.type=="time",Te=o.type=="week";Qe(te.value)&&S&&(U=he?J(S)>J(te.value):Te?S>te.value:G>new Date(te.value)),Qe(H.value)&&S&&(Q=he?J(S)<J(H.value):Te?S<H.value:G<new Date(H.value))}if((U||Q)&&(ie(!!U,te.message,H.message,Ct.max,Ct.min),!s))return N(E[p].message),E}if((u||d)&&!_&&(Qe(S)||i&&Array.isArray(S))){const U=Ur(u),Q=Ur(d),te=!Ze(U.value)&&S.length>+U.value,H=!Ze(Q.value)&&S.length<+Q.value;if((te||H)&&(ie(te,U.message,Q.message),!s))return N(E[p].message),E}if(f&&!_&&Qe(S)){const{value:U,message:Q}=Ur(f);if(Ns(U)&&!S.match(U)&&(E[p]={type:Ct.pattern,message:Q,ref:o,...L(Ct.pattern,Q)},!s))return N(Q),E}if(g){if(Ke(g)){const U=await g(S,r),Q=Fo(U,w);if(Q&&(E[p]={...Q,...L(Ct.validate,Q.message)},!s))return N(Q.message),E}else if(Ae(g)){let U={};for(const Q in g){if(!Ue(U)&&!s)break;const te=Fo(await g[Q](S,r),w,Q);te&&(U={...te,...L(Q,te.message)},N(te.message),s&&(E[p]=U))}if(!Ue(U)&&(E[p]={ref:w,...U},!s))return E}}return N(!0),E};const yf={mode:Pt.onSubmit,reValidateMode:Pt.onChange,shouldFocusError:!0},na="form",Ic={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function bf(e={}){let t={...yf,...e},r={..._e(Ic),isLoading:Ke(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},s={},a=Ae(t.defaultValues)||Ae(t.values)?_e(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:_e(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=ts(t.mode),h=ts(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={...f};let p={...g};const b={array:ko(),state:ko()},x=t.criteriaMode===Pt.all,S=y=>k=>{clearTimeout(u),u=setTimeout(y,k)},w=async y=>{if(!o.keepIsValid&&!t.disabled&&(g.isValid||p.isValid||y)){let k;t.resolver?(k=Ue((await Q()).errors),N()):k=await G({fields:s,onlyCheckValid:!0,eventType:er.VALID}),k!==r.isValid&&b.state.next({isValid:k})}},N=(y,k)=>{!t.disabled&&(g.isValidating||g.validatingFields||p.isValidating||p.validatingFields)&&((y||Array.from(l.mount)).forEach(C=>{C&&(k?xe(r.validatingFields,C,k):$e(r.validatingFields,C))}),b.state.next({validatingFields:r.validatingFields,isValidating:!Ue(r.validatingFields)}))},E=()=>{r.dirtyFields=br(a,i)},D=(y,k=[],C,O,$=!0,W=!0)=>{if(O&&C&&!t.disabled){if(o.action=!0,W&&Array.isArray(V(s,y))){const M=C(V(s,y),O.argA,O.argB);$&&xe(s,y,M)}if(W&&Array.isArray(V(r.errors,y))){const M=C(V(r.errors,y),O.argA,O.argB);$&&xe(r.errors,y,M),gf(r.errors,y)}if((g.touchedFields||p.touchedFields)&&W&&Array.isArray(V(r.touchedFields,y))){const M=C(V(r.touchedFields,y),O.argA,O.argB);$&&xe(r.touchedFields,y,M)}(g.dirtyFields||p.dirtyFields)&&E(),b.state.next({name:y,isDirty:he(y,k),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else xe(i,y,k)},A=(y,k)=>{xe(r.errors,y,k),r.errors={...r.errors},b.state.next({errors:r.errors})},I=y=>{r.errors=y,b.state.next({errors:r.errors,isValid:!1})},_=y=>{const k=Wn(y)?[y]:Ls(y);let C=i,O=a;for(let $=0;$<k.length-1;$++){const W=k[$];if(C=Ze(C)?C:C[W],O=Ze(O)?O:O[W],C===null&&O!==null)return!0}return!1},L=(y,k,C,O)=>{const $=V(s,y);if($){if(_(y))return;const W=je(V(i,y)),M=V(i,y,je(C)?V(a,y):C);je(M)||O&&O.defaultChecked||k?xe(i,y,k?M:Eo($._f)):Re(y,M),o.mount&&!o.action&&(w(),W&&r.isDirty&&(g.isDirty||p.isDirty)&&(he()||(r.isDirty=!1,b.state.next({...r}))),e.shouldUnregister&&W&&!je(V(i,y))&&ra(y,l)&&(o.watch=!0))}},ie=(y,k,C,O,$)=>{let W=!1,M=!1;const Y={name:y};if(!t.disabled){if(!C||O){const q=ct(V(a,y),k);(g.isDirty||p.isDirty)&&(M=r.isDirty,r.isDirty=Y.isDirty=!q||he(),W=M!==Y.isDirty),M=!!V(r.dirtyFields,y),q!==r.isDirty?r.dirtyFields=br(a,i):q?$e(r.dirtyFields,y):xe(r.dirtyFields,y,!0),Y.dirtyFields=r.dirtyFields,W=W||(g.dirtyFields||p.dirtyFields)&&M!==!q}if(C){const q=V(r.touchedFields,y);q||(xe(r.touchedFields,y,C),Y.touchedFields=r.touchedFields,W=W||(g.touchedFields||p.touchedFields)&&q!==C)}W&&$&&b.state.next(Y)}return W?Y:{}},U=(y,k,C,O)=>{const $=V(r.errors,y),W=(g.isValid||p.isValid)&&lt(k)&&r.isValid!==k;if(t.delayError&&C?(c=S(()=>A(y,C)),c(t.delayError)):(clearTimeout(u),c=null,C?xe(r.errors,y,C):$e(r.errors,y),r.errors={...r.errors}),(C?!ct($,C):$)||!Ue(O)||W){const M={...O,...W&&lt(k)?{isValid:k}:{},errors:r.errors,name:y};r={...r,...M},b.state.next(M)}},Q=async y=>(N(y,!0),await t.resolver(i,t.context,df(y||l.mount,s,t.criteriaMode,t.shouldUseNativeValidation))),te=async y=>{const{errors:k}=await Q(y);if(N(y),y){for(const C of y){const O=V(k,C);O?l.array.has(C)&&Ae(O)&&!Object.keys(O).some($=>!Number.isNaN(Number($)))?To(r.errors,{[C]:O},C):xe(r.errors,C,O):$e(r.errors,C)}r.errors={...r.errors}}else r.errors=k;return k},H=async({name:y,eventType:k})=>{if(e.validate){const C=await e.validate({formValues:i,formState:r,name:y,eventType:k});if(Ae(C))for(const O in C){const $=C[O];$&&at(`${na}.${O}`,{message:Qe($.message)?$.message:"",type:$.type||Ct.validate})}else Qe(C)||!C?at(na,{message:C||"",type:Ct.validate}):Oe(na);return C}return!0},G=async({fields:y,onlyCheckValid:k,name:C,eventType:O,context:$={valid:!0,runRootValidation:!1}})=>{if(e.validate&&($.runRootValidation=!0,!await H({name:C,eventType:O})&&($.valid=!1,k)))return $.valid;for(const W in y){const M=y[W];if(M){const{_f:Y,...q}=M;if(Y){const ae=l.array.has(Y.name),Me=M._f&&mf(M._f),qt=g.validatingFields||g.isValidating||p.validatingFields||p.isValidating;Me&&qt&&N([Y.name],!0);const Vt=await Do(M,l.disabled,i,x,t.shouldUseNativeValidation&&!k,ae);if(Me&&qt&&N([Y.name]),Vt[Y.name]&&($.valid=!1,k)||(!k&&(V(Vt,Y.name)?ae?To(r.errors,Vt,Y.name):xe(r.errors,Y.name,Vt[Y.name]):$e(r.errors,Y.name)),e.shouldUseNativeValidation&&Vt[Y.name]))break}!Ue(q)&&await G({context:$,onlyCheckValid:k,fields:q,name:W,eventType:O})}}return $.valid},J=()=>{for(const y of l.unMount){const k=V(s,y);k&&(k._f.refs?k._f.refs.every(C=>!ta(C)):!ta(k._f.ref))&&pt(y)}l.unMount=new Set},he=(y,k)=>!t.disabled&&(y&&k&&xe(i,y,k),!ct(o.mount?i:a,a)),Te=(y,k,C)=>$a(y,l,{...o.mount?i:je(k)?a:Qe(y)?{[y]:k}:k},C,k),pe=y=>Sc(V(o.mount?i:a,y,t.shouldUnregister?V(a,y,[]):[])),Re=(y,k,C={},O=!1,$=!1)=>{const W=V(s,y);let M=k;if(W){const Y=W._f;Y&&(!Y.disabled&&xe(i,y,Ec(k,Y)),M=js(Y.ref)&&Ze(k)?"":k,Cc(Y.ref)?[...Y.ref.options].forEach(q=>q.selected=M.includes(q.value)):Y.refs?Zn(Y.ref)?Y.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(M)?q.checked=!!M.find(ae=>ae===q.value):q.checked=M===q.value||!!M)}):Y.refs.forEach(q=>q.checked=q.value===M):ki(Y.ref)?Y.ref.value="":(Y.ref.value=M,!Y.ref.type&&!$&&b.state.next({name:y,values:O?i:_e(i)})))}(C.shouldDirty||C.shouldTouch)&&ie(y,M,C.shouldTouch,C.shouldDirty,!$),C.shouldValidate&&Ye(y)},oe=(y,k,C,O=!1,$=!1)=>{for(const W in k){if(!k.hasOwnProperty(W))return;const M=k[W],Y=y+"."+W,q=V(s,Y);(l.array.has(y)||Ae(M)||q&&!q._f)&&!dr(M)?oe(Y,M,C,O,$):Re(Y,M,C,O,$)}},Ne=(y,k,C,O,$=!1)=>{const W=V(s,y),M=l.array.has(y),Y=O?k:_e(k),q=V(i,y),ae=ct(q,Y);if(ae||xe(i,y,Y),M)b.array.next({name:y,values:O?i:_e(i)}),(g.isDirty||g.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&(E(),$||b.state.next({name:y,dirtyFields:r.dirtyFields,isDirty:he(y,Y)}));else{const Me=Array.isArray(Y)&&!Y.length||Ue(Y);!W||W._f||Ze(Y)||Me?Re(y,Y,C,O,$):oe(y,Y,C,O,$)}if(!ae&&!$){const Me=ra(y,l),qt=O?i:_e(i);b.state.next({...Me&&r,name:o.mount||Me?y:void 0,values:qt})}},R=(y,k,C={})=>Ne(y,k,C,!1),ye=(y,k={})=>{const C=Ke(y)?y(i):y;if(!ct(i,C)){i={...i,...C};const O=wc(C);for(const $ of l.mount)$ in O&&Ne($,O[$],k,!0,!0);b.state.next({...r,name:void 0,type:void 0,...d?{values:i}:{}}),k.shouldValidate&&w()}},se=async y=>{o.mount=!0;const k=y.target;let C=k.name,O=!0;const $=V(s,C),W=M=>{O=Number.isNaN(M)||dr(M)&&isNaN(M.getTime())||ct(M,V(i,C,M))};if($){let M,Y;const q=k.type?Eo($._f):Oa(y),ae=y.type===er.BLUR||y.type===er.FOCUS_OUT,Me=!hf($._f)&&!e.validate&&!t.resolver&&!V(r.errors,C)&&!$._f.deps,qt=Me||xf(ae,V(r.touchedFields,C),r.isSubmitted,h,m),Vt=ra(C,l,ae);xe(i,C,q),ae?(!k||!k.readOnly)&&($._f.onBlur&&$._f.onBlur(y),c&&c(0)):$._f.onChange&&$._f.onChange(y);const Nn=ie(C,q,ae),Qu=!Ue(Nn)||Vt;if(!ae&&b.state.next({name:C,type:y.type,...d?{values:_e(i)}:{}}),qt)return(!Me||!r.isValid)&&(g.isValid||p.isValid)&&(t.mode==="onBlur"?ae&&w():ae||w()),Qu&&b.state.next({name:C,...Vt?{}:Nn});if(!t.resolver&&e.validate&&await H({name:C,eventType:y.type}),!ae&&Vt&&b.state.next({...r}),t.resolver){const{errors:no}=await Q([C]);if(N([C]),W(q),!O){!Ue(Nn)&&b.state.next(Nn);return}const Ju=Io(r.errors,s,C),so=Io(no,s,Ju.name||C);M=so.error,C=so.name,Y=Ue(no)}else N([C],!0),M=(await Do($,l.disabled,i,x,t.shouldUseNativeValidation))[C],N([C]),W(q),O&&(M?Y=!1:(g.isValid||p.isValid)&&(Y=await G({fields:s,onlyCheckValid:!0,name:C,eventType:y.type})));O&&($._f.deps&&(!Array.isArray($._f.deps)||$._f.deps.length>0)&&Ye($._f.deps),U(C,Y,M,Nn))}},Ce=(y,k)=>{if(V(r.errors,k)&&y.focus)return y.focus(),1},Ye=async(y,k={})=>{let C,O;const $=fs(y);if(t.resolver){const W=await te(je(y)?y:$);C=Ue(W),O=y?!$.some(M=>V(W,M)):C}else y?(O=(await Promise.all($.map(async W=>{const M=V(s,W);return await G({fields:M&&M._f?{[W]:M}:M,eventType:er.TRIGGER})}))).every(Boolean),!(!O&&!r.isValid)&&w()):O=C=await G({fields:s,name:y,eventType:er.TRIGGER});return b.state.next({...!Qe(y)||(g.isValid||p.isValid)&&C!==r.isValid?{}:{name:y},...t.resolver||!y?{isValid:C}:{},errors:r.errors}),k.shouldFocus&&!O&&In(s,Ce,y?$:l.mount),O},ht=(y,k)=>{let C={...o.mount?i:a};return k&&(C=kc(k.dirtyFields?r.dirtyFields:r.touchedFields,C)),je(y)?C:Qe(y)?V(C,y):y.map(O=>V(C,O))},ce=(y,k)=>({invalid:!!V((k||r).errors,y),isDirty:!!V((k||r).dirtyFields,y),error:V((k||r).errors,y),isValidating:!!V(r.validatingFields,y),isTouched:!!V((k||r).touchedFields,y)}),Oe=y=>{const k=y?fs(y):void 0;k==null||k.forEach(C=>$e(r.errors,C)),k?k.forEach(C=>{b.state.next({name:C,errors:r.errors})}):b.state.next({errors:{}})},at=(y,k,C)=>{const O=(V(s,y,{_f:{}})._f||{}).ref,$=V(r.errors,y)||{},{ref:W,message:M,type:Y,...q}=$;xe(r.errors,y,{...q,...k,ref:O}),b.state.next({name:y,errors:r.errors,isValid:!1}),C&&C.shouldFocus&&O&&O.focus&&O.focus()},Nt=(y,k)=>{if(Ke(y)){d++;const{unsubscribe:C}=b.state.subscribe({next:$=>"values"in $&&y($.values||Te(void 0,k),$)});let O=!1;return{unsubscribe:()=>{O||(O=!0,d--,C())}}}return Te(y,k,!0)},ft=y=>{var k;const C=!!(!((k=y.formState)===null||k===void 0)&&k.values);C&&d++;const{unsubscribe:O}=b.state.subscribe({next:W=>{if(pf(y.name,W.name,y.exact)&&ff(W,y.formState||g,gr,y.reRenderRoot)){const M={...i};y.callback({values:M,...r,...W,defaultValues:a})}}});if(!C)return O;let $=!1;return()=>{$||($=!0,d--,O())}},Mt=y=>(o.mount=!0,p={...p,...y.formState},ft({...y,formState:{...f,...y.formState}})),pt=(y,k={})=>{for(const C of y?fs(y):l.mount)l.mount.delete(C),l.array.delete(C),k.keepValue||($e(s,C),$e(i,C)),!k.keepError&&$e(r.errors,C),!k.keepDirty&&$e(r.dirtyFields,C),!k.keepTouched&&$e(r.touchedFields,C),!k.keepIsValidating&&$e(r.validatingFields,C),!t.shouldUnregister&&!k.keepDefaultValue&&$e(a,C);b.state.next({values:_e(i)}),b.state.next({...r,...k.keepDirty?{isDirty:he()}:{}}),!k.keepIsValid&&w()},wt=({disabled:y,name:k})=>{if(lt(y)&&o.mount||y||l.disabled.has(k)){const $=l.disabled.has(k)!==!!y;y?l.disabled.add(k):l.disabled.delete(k),$&&o.mount&&!o.action&&w()}},xt=(y,k={})=>{let C=V(s,y);const O=lt(k.disabled)||lt(t.disabled),$=!l.registerName.has(y)&&C&&C._f&&!C._f.mount;return xe(s,y,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:y}},name:y,mount:!0,...k}}),l.mount.add(y),C&&!$?wt({disabled:lt(k.disabled)?k.disabled:t.disabled,name:y}):L(y,!0,k.value),{...O?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:kn(k.min),max:kn(k.max),minLength:kn(k.minLength),maxLength:kn(k.maxLength),pattern:kn(k.pattern)}:{},name:y,onChange:se,onBlur:se,ref:W=>{if(W){l.registerName.add(y),xt(y,k),l.registerName.delete(y),C=V(s,y);const M=je(W.value)&&W.querySelectorAll&&W.querySelectorAll("input,select,textarea")[0]||W,Y=of(M),q=C._f.refs||[];if(Y?q.find(ae=>ae===M):M===C._f.ref)return;xe(s,y,{_f:{...C._f,...Y?{refs:[...q.filter(ta),M,...Array.isArray(V(a,y))?[{}]:[]],ref:{type:M.type,name:y}}:{ref:M}}}),L(y,!1,void 0,M)}else C=V(s,y,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(yc(l.array,y)&&o.action)&&l.unMount.add(y)}}},gt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&In(s,Ce,l.mount),_t=y=>{lt(y)&&(b.state.next({disabled:y}),In(s,(k,C)=>{const O=V(s,C);O&&(k.disabled=O._f.disabled||y,Array.isArray(O._f.refs)&&O._f.refs.forEach($=>{$.disabled=O._f.disabled||y}))},0,!1))},St=(y,k)=>async C=>{let O;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let $=_e(i);if(b.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:M}=await Q();N(),r.errors=W,$=_e(M)}else await G({fields:s,eventType:er.SUBMIT});if(l.disabled.size)for(const W of l.disabled)$e($,W);if($e(r.errors,vc),Ue(r.errors)){b.state.next({errors:{}});try{await y($,C)}catch(W){O=W}}else k&&await k({...r.errors},C),gt(),setTimeout(gt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ue(r.errors)&&!O,submitCount:r.submitCount+1,errors:r.errors}),O)throw O},It=(y,k={})=>{V(s,y)&&(je(k.defaultValue)?R(y,_e(V(a,y))):(R(y,k.defaultValue),xe(a,y,_e(k.defaultValue))),k.keepTouched||$e(r.touchedFields,y),k.keepDirty||($e(r.dirtyFields,y),r.isDirty=k.defaultValue?he(y,_e(V(a,y))):he()),k.keepError||($e(r.errors,y),g.isValid&&w()),b.state.next({...r}))},kt=(y,k={})=>{const C=y?_e(y):a,O=_e(C),$=Ue(y),W=O;if(k.keepDefaultValues||(a=C),!k.keepValues){if(k.keepDirtyValues){const M=new Set([...l.mount,...Object.keys(br(a,i))]);for(const Y of Array.from(M)){const q=V(r.dirtyFields,Y),ae=V(i,Y),Me=V(W,Y);q&&!je(ae)?xe(W,Y,ae):!q&&!je(Me)&&R(Y,Me)}}else{if($s&&je(y))for(const M of l.mount){const Y=V(s,M);if(Y&&Y._f){const q=Array.isArray(Y._f.refs)?Y._f.refs[0]:Y._f.ref;if(js(q)){const ae=q.closest("form");if(ae){ae.reset();break}}}}if(k.keepFieldsRef)for(const M of l.mount)R(M,V(W,M));else s={}}if(t.shouldUnregister){if(i=k.keepDefaultValues?_e(a):{},k.keepFieldsRef)for(const M of l.mount)xe(i,M,V(W,M))}else i=_e(W);b.array.next({values:{...W}}),b.state.next({name:void 0,type:void 0,values:{...W}})}l={mount:k.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=!g.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!Ue(W),o.watch=!!t.shouldUnregister,o.keepIsValid=!!k.keepIsValid,o.action=!1,k.keepErrors||(r.errors={}),b.state.next({submitCount:k.keepSubmitCount?r.submitCount:0,isDirty:$?!1:k.keepDirty?r.isDirty:k.keepValues?he():!!(k.keepDefaultValues&&!ct(y,a)),isSubmitted:k.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:$?{}:k.keepDirtyValues?k.keepDefaultValues&&i?br(a,i):r.dirtyFields:k.keepDefaultValues&&y?br(a,y):k.keepDirty?r.dirtyFields:{},touchedFields:k.keepTouched?r.touchedFields:{},errors:k.keepErrors?r.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},z=(y,k)=>kt(Ke(y)?y(i):y,{...t.resetOptions,...k}),ze=(y,k={})=>{const C=V(s,y),O=C&&C._f;if(O){const $=O.refs?O.refs[0]:O.ref;$.focus&&setTimeout(()=>{$.focus(),k.shouldSelect&&Ke($.select)&&$.select()})}},gr=y=>{const{name:k,type:C,values:O,...$}=y;r={...r,...$}},ue={control:{register:xt,unregister:pt,getFieldState:ce,handleSubmit:St,setError:at,_subscribe:ft,_runSchema:Q,_updateIsValidating:N,_focusError:gt,_getWatch:Te,_getDirty:he,_setValid:w,_setFieldArray:D,_setDisabledField:wt,_setErrors:I,_getFieldArray:pe,_reset:kt,_resetDefaultValues:()=>Ke(t.defaultValues)&&t.defaultValues().then(y=>{z(y,t.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:_t,_subjects:b,_proxyFormState:g,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(y){o=y},get _defaultValues(){return a},get _names(){return l},set _names(y){l=y},get _formState(){return r},get _options(){return t},set _options(y){t={...t,...y},m=ts(t.mode),h=ts(t.reValidateMode)}},subscribe:Mt,trigger:Ye,register:xt,handleSubmit:St,watch:Nt,setValue:R,setValues:ye,getValues:ht,reset:z,resetField:It,resetDefaultValues:(y,k={})=>{if(a=_e(y),!k.keepDirty){const C=br(a,i);r.dirtyFields=C,r.isDirty=!Ue(C)}k.keepIsValid||w(),b.state.next({...r,defaultValues:a})},clearErrors:Oe,unregister:pt,setError:at,setFocus:ze,getFieldState:ce};return{...ue,formControl:ue}}function $t(e={}){const t=v.useRef(void 0),r=v.useRef(void 0),s=v.useRef(e.formControl),[a,i]=v.useState(()=>({..._e(Ic),isLoading:Ke(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ke(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&s.current!==e.formControl)if(s.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Ke(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=bf(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,wi(()=>{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]),v.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),v.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),v.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),v.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),v.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),v.useEffect(()=>{var l;e.values&&!ct(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]),v.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=v.useMemo(()=>Nc(a,o),[o,a]),t.current}const Ro=(e,t,r)=>{if(e&&"reportValidity"in e){const s=V(r,t);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},qa=(e,t)=>{for(const r in t.fields){const s=t.fields[r];s&&s.ref&&"reportValidity"in s.ref?Ro(s.ref,r,e):s&&s.refs&&s.refs.forEach(a=>Ro(a,r,e))}},Oo=(e,t)=>{t.shouldUseNativeValidation&&qa(e,t);const r={};for(const s in e){const a=V(t.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(vf(t.names||Object.keys(e),s)){const o=Object.assign({},V(r,s));xe(o,"root",i),xe(r,s,o)}else xe(r,s,i)}return r},vf=(e,t)=>{const r=$o(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(s=>$o(s).match(`^${r}\\.\\d+`))};function $o(e){return e.replace(/[\[\]]/g,"")}var Lo;function F(e,t,r){function s(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;s(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:s}),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 Yr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Tc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Lo=globalThis).__zod_globalConfig??(Lo.__zod_globalConfig={});const Ai=globalThis.__zod_globalConfig;function Fr(e){return Ai}function Fc(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,a])=>t.indexOf(+s)===-1).map(([s,a])=>a)}function Va(e,t){return typeof t=="bigint"?t.toString():t}function Pi(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ei(e){return e==null}function _i(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const zo=Symbol("evaluating");function be(e,t,r){let s;Object.defineProperty(e,t,{get(){if(s!==zo)return s===void 0&&(s=zo,s=r()),s},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function zr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pr(...e){const t={};for(const r of e){const s=Object.getOwnPropertyDescriptors(r);Object.assign(t,s)}return Object.defineProperties({},t)}function Mo(e){return JSON.stringify(e)}function jf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Dc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ws(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Nf=Pi(()=>{var e;if(Ai.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 Rn(e){if(ws(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(ws(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Rc(e){return Rn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const wf=new Set(["string","number","symbol"]);function dn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xr(e,t,r){const s=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(s._zod.parent=e),s}function ne(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 Sf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function kf(e,t){const r=e._zod.def,s=r.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=pr(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 zr(this,"shape",o),o},checks:[]});return xr(e,i)}function Cf(e,t){const r=e._zod.def,s=r.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=pr(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 zr(this,"shape",o),o},checks:[]});return xr(e,i)}function Af(e,t){if(!Rn(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=pr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return zr(this,"shape",i),i}});return xr(e,a)}function Pf(e,t){if(!Rn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=pr(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return zr(this,"shape",s),s}});return xr(e,r)}function Ef(e,t){var s;if((s=e._zod.def.checks)!=null&&s.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r=pr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return zr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return xr(e,r)}function _f(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=pr(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 zr(this,"shape",c),c},checks:[]});return xr(t,o)}function If(e,t,r){const s=pr(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 zr(this,"shape",i),i}});return xr(t,s)}function Zr(e,t=0){var r;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((r=e.issues[s])==null?void 0:r.continue)!==!0)return!0;return!1}function Tf(e,t=0){var r;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((r=e.issues[s])==null?void 0:r.continue)===!1)return!0;return!1}function Oc(e,t){return t.map(r=>{var s;return(s=r).path??(s.path=[]),r.path.unshift(e),r})}function rs(e){return typeof e=="string"?e:e==null?void 0:e.message}function Dr(e,t,r){var c,u,d,m,h,f;const s=e.message?e.message:rs((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??rs((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??rs((h=r.customError)==null?void 0:h.call(r,e))??rs((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=s,t!=null&&t.reportInput&&(l.input=o),l}function Ii(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function On(...e){const[t,r,s]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:s}:{...t}}const $c=(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,Va,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ti=F("$ZodError",$c),zs=F("$ZodError",$c,{Parent:Error});function Ff(e,t=r=>r.message){const r={},s=[];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))):s.push(t(a));return{formErrors:s,fieldErrors:r}}function Df(e,t=r=>r.message){const r={_errors:[]},s=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>s({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")s({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")s({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 s(e),r}const Ms=e=>(t,r,s,a)=>{const i=s?{...s,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Yr;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Dr(c,i,Fr())));throw Dc(l,a==null?void 0:a.callee),l}return o.value},Rf=Ms(zs),qs=e=>async(t,r,s,a)=>{const i=s?{...s,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=>Dr(c,i,Fr())));throw Dc(l,a==null?void 0:a.callee),l}return o.value},Of=qs(zs),Vs=e=>(t,r,s)=>{const a=s?{...s,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Yr;return i.issues.length?{success:!1,error:new(e??Ti)(i.issues.map(o=>Dr(o,a,Fr())))}:{success:!0,data:i.value}},$f=Vs(zs),Bs=e=>async(t,r,s)=>{const a=s?{...s,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=>Dr(o,a,Fr())))}:{success:!0,data:i.value}},Lf=Bs(zs),zf=e=>(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Ms(e)(t,r,a)},Mf=e=>(t,r,s)=>Ms(e)(t,r,s),qf=e=>async(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return qs(e)(t,r,a)},Vf=e=>async(t,r,s)=>qs(e)(t,r,s),Bf=e=>(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Vs(e)(t,r,a)},Uf=e=>(t,r,s)=>Vs(e)(t,r,s),Zf=e=>async(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Bs(e)(t,r,a)},Wf=e=>async(t,r,s)=>Bs(e)(t,r,s),Yf=/^[cC][0-9a-z]{6,}$/,Hf=/^[0-9a-z]+$/,Kf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Qf=/^[0-9a-vA-V]{20}$/,Jf=/^[A-Za-z0-9]{27}$/,Gf=/^[a-zA-Z0-9_-]{21}$/,Xf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ep=/^([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})$/,qo=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)$/,tp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function np(){return new RegExp(rp,"u")}const sp=/^(?:(?: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])$/,ap=/^(([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}|:))$/,ip=/^((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])$/,op=/^(([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])$/,lp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lc=/^[A-Za-z0-9_-]*$/,cp=/^https?$/,up=/^\+[1-9]\d{6,14}$/,zc="(?:(?:\\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])))",dp=new RegExp(`^${zc}$`);function Mc(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 mp(e){return new RegExp(`^${Mc(e)}$`)}function hp(e){const t=Mc({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${r.join("|")})`;return new RegExp(`^${zc}T(?:${s})$`)}const fp=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}$`)},pp=/^(?:true|false)$/i,xp=/^[^A-Z]*$/,gp=/^[^a-z]*$/,Lt=F("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),yp=F("$ZodCheckMaxLength",(e,t)=>{var r;Lt.init(e,t),(r=e._zod.def).when??(r.when=s=>{const a=s.value;return!Ei(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const a=s.value;if(a.length<=t.maximum)return;const o=Ii(a);s.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),bp=F("$ZodCheckMinLength",(e,t)=>{var r;Lt.init(e,t),(r=e._zod.def).when??(r.when=s=>{const a=s.value;return!Ei(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const a=s.value;if(a.length>=t.minimum)return;const o=Ii(a);s.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),vp=F("$ZodCheckLengthEquals",(e,t)=>{var r;Lt.init(e,t),(r=e._zod.def).when??(r.when=s=>{const a=s.value;return!Ei(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=s=>{const a=s.value,i=a.length;if(i===t.length)return;const o=Ii(a),l=i>t.length;s.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Us=F("$ZodCheckStringFormat",(e,t)=>{var r,s;Lt.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})}):(s=e._zod).check??(s.check=()=>{})}),jp=F("$ZodCheckRegex",(e,t)=>{Us.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})}}),Np=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xp),Us.init(e,t)}),wp=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=gp),Us.init(e,t)}),Sp=F("$ZodCheckIncludes",(e,t)=>{Lt.init(e,t);const r=dn(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=s,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(s)}),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})}}),kp=F("$ZodCheckStartsWith",(e,t)=>{Lt.init(e,t);const r=new RegExp(`^${dn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),Cp=F("$ZodCheckEndsWith",(e,t)=>{Lt.init(e,t);const r=new RegExp(`.*${dn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),Ap=F("$ZodCheckOverwrite",(e,t)=>{Lt.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 s=t.split(`
13
- `).filter(o=>o),a=Math.min(...s.map(o=>o.length-o.trimStart().length)),i=s.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 Ep={major:4,minor:4,patch:3},Fe=F("$ZodType",(e,t)=>{var a;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ep;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const i of s)for(const o of i._zod.onattach)o(e);if(s.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=Zr(l),m;for(const h of c){if(h._zod.def.when){if(Tf(l)||!h._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,g=h._zod.check(l);if(g instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Yr;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await g,l.issues.length!==f&&(d||(d=Zr(l,f)))});else{if(l.issues.length===f)continue;d||(d=Zr(l,f))}}return m?m.then(()=>l):l},o=(l,c,u)=>{if(Zr(l))return l.aborted=!0,l;const d=i(c,s,u);if(d instanceof Promise){if(u.async===!1)throw new Yr;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 Yr;return u.then(d=>i(d,s,c))}return i(u,s,c)}}be(e,"~standard",()=>({validate:i=>{var o;try{const l=$f(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return Lf(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}))}),Fi=F("$ZodString",(e,t)=>{var r;Fe.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??fp(e._zod.bag),e._zod.parse=(s,a)=>{if(t.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:e}),s}}),ke=F("$ZodStringFormat",(e,t)=>{Us.init(e,t),Fi.init(e,t)}),_p=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ep),ke.init(e,t)}),Ip=F("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=qo(s))}else t.pattern??(t.pattern=qo());ke.init(e,t)}),Tp=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tp),ke.init(e,t)}),Fp=F("$ZodURL",(e,t)=>{ke.init(e,t),e._zod.check=r=>{var s;try{const a=r.value.trim();if(!t.normalize&&((s=t.protocol)==null?void 0:s.source)===cp.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})}}}),Dp=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=np()),ke.init(e,t)}),Rp=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Gf),ke.init(e,t)}),Op=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yf),ke.init(e,t)}),$p=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Hf),ke.init(e,t)}),Lp=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Kf),ke.init(e,t)}),zp=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qf),ke.init(e,t)}),Mp=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Jf),ke.init(e,t)}),qp=F("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hp(t)),ke.init(e,t)}),Vp=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=dp),ke.init(e,t)}),Bp=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=mp(t)),ke.init(e,t)}),Up=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Xf),ke.init(e,t)}),Zp=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=sp),ke.init(e,t),e._zod.bag.format="ipv4"}),Wp=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ap),ke.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})}}}),Yp=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ip),ke.init(e,t)}),Hp=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=op),ke.init(e,t),e._zod.check=r=>{const s=r.value.split("/");try{if(s.length!==2)throw new Error;const[a,i]=s;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 qc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Kp=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=lp),ke.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{qc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Qp(e){if(!Lc.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qc(r)}const Jp=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Lc),ke.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Qp(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Gp=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=up),ke.init(e,t)});function Xp(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[s]=r;if(!s)return!1;const a=JSON.parse(atob(s));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const ex=F("$ZodJWT",(e,t)=>{ke.init(e,t),e._zod.check=r=>{Xp(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),tx=F("$ZodBoolean",(e,t)=>{Fe.init(e,t),e._zod.pattern=pp,e._zod.parse=(r,s)=>{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}}),rx=F("$ZodUnknown",(e,t)=>{Fe.init(e,t),e._zod.parse=r=>r}),nx=F("$ZodNever",(e,t)=>{Fe.init(e,t),e._zod.parse=(r,s)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Vo(e,t,r){e.issues.length&&t.issues.push(...Oc(r,e.issues)),t.value[r]=e.value}const sx=F("$ZodArray",(e,t)=>{Fe.init(e,t),e._zod.parse=(r,s)=>{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:[]},s);c instanceof Promise?i.push(c.then(u=>Vo(u,r,o))):Vo(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function Ss(e,t,r,s,a,i){const o=r in s;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Oc(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 Vc(e){var s,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(s=e.shape)==null?void 0:s[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=Sf(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Bc(e,t,r,s,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:[]},s);f instanceof Promise?e.push(f.then(g=>Ss(g,r,h,t,d,m))):Ss(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 ax=F("$ZodObject",(e,t)=>{Fe.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 s=Pi(()=>Vc(t));be(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=ws,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=s.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],g=f._zod.optin==="optional",p=f._zod.optout==="optional",b=f._zod.run({value:u[h],issues:[]},c);b instanceof Promise?d.push(b.then(x=>Ss(x,l,h,u,g,p))):Ss(b,l,h,u,g,p)}return i?Bc(d,u,l,c,s.value,e):d.length?Promise.all(d).then(()=>l):l}}),ix=F("$ZodObjectJIT",(e,t)=>{ax.init(e,t);const r=e._zod.parse,s=Pi(()=>Vc(t)),a=h=>{var w,N;const f=new Pp(["shape","payload","ctx"]),g=s.value,p=E=>{const D=Mo(E);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};f.write("const input = payload.value;");const b=Object.create(null);let x=0;for(const E of g.keys)b[E]=`key_${x++}`;f.write("const newResult = {};");for(const E of g.keys){const D=b[E],A=Mo(E),I=h[E],_=((w=I==null?void 0:I._zod)==null?void 0:w.optin)==="optional",L=((N=I==null?void 0:I._zod)==null?void 0:N.optout)==="optional";f.write(`const ${D} = ${p(E)};`),_&&L?f.write(`
15
- if (${D}.issues.length) {
12
+ Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let d=Ce(),m;if(t){let g=typeof t=="string"?Mn(t):t;Ie(c==="/"||((N=g.pathname)==null?void 0:N.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 "${g.pathname}" was given in the \`location\` prop.`),m=g}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let g=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let x=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):Fl(e,{pathname:f});dt(u||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),dt(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.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=Gd(x&&x.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Ct([c,s.encodeLocation?s.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Ct([c,s.encodeLocation?s.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&p?P.createElement(Ur.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function Yd(){let e=rm(),t=Td(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:s},i={padding:"2px 4px",backgroundColor:s},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=P.createElement(P.Fragment,null,P.createElement("p",null,"💿 Hey developer 👋"),P.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",P.createElement("code",{style:i},"ErrorBoundary")," or"," ",P.createElement("code",{style:i},"errorElement")," prop on your route.")),P.createElement(P.Fragment,null,P.createElement("h2",null,"Unexpected Application Error!"),P.createElement("h3",{style:{fontStyle:"italic"}},t),n?P.createElement("pre",{style:a},n):null,o)}var Kd=P.createElement(Yd,null),Kl=class extends P.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 n=Vd(e.digest);n&&(e=n)}let t=e!==void 0?P.createElement(gt.Provider,{value:this.props.routeContext},P.createElement(si.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?P.createElement(Qd,{error:e},t):t}};Kl.contextType=Bl;var na=new WeakMap;function Qd({children:e,error:t}){let{basename:n}=P.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=Bd(t.digest);if(s){let a=na.get(t);if(a)throw a;let i=Ml(s.location,n),o=i.absoluteURL||i.to;if($d(o))throw new Error("Invalid redirect location");if(zl&&!na.get(t))if(i.isExternal||s.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:s.replace}));throw na.set(t,l),l}return P.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Jd({routeContext:e,match:t,children:n}){let s=P.useContext(pr);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),P.createElement(gt.Provider,{value:e},n)}function Gd(e,t=[],n){let s=n==null?void 0:n.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let a=e,i=s==null?void 0:s.errors;if(i!=null){let d=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Ie(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(n&&s){o=s.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}=s,x=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||x){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,u=s&&c?(d,m)=>{var h,f;c(d,{location:s.location,params:((f=(h=s.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:Fd(s.matches),errorInfo:m})}:void 0;return a.reduceRight((d,m,h)=>{let f,x=!1,p=null,N=null;s&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Kd,o&&(l<0&&h===0?(Ql("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,N=null):l===h&&(x=!0,N=m.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,h+1)),k=()=>{let j;return f?j=p:x?j=N:m.route.Component?j=P.createElement(m.route.Component,null):m.route.element?j=m.route.element:j=d,P.createElement(Jd,{match:m,routeContext:{outlet:d,matches:g,isDataRoute:s!=null},children:j})};return s&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?P.createElement(Kl,{location:s.location,revalidation:s.revalidation,component:p,error:f,children:k(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:u}):k()},null)}function ii(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xd(e){let t=P.useContext(pr);return Ie(t,ii(e)),t}function em(e){let t=P.useContext(Rs);return Ie(t,ii(e)),t}function tm(e){let t=P.useContext(gt);return Ie(t,ii(e)),t}function oi(e){let t=tm(e),n=t.matches[t.matches.length-1];return Ie(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function nm(){return oi("useRouteId")}function rm(){var s;let e=P.useContext(si),t=em("useRouteError"),n=oi("useRouteError");return e!==void 0?e:(s=t.errors)==null?void 0:s[n]}function sm(){let{router:e}=Xd("useNavigate"),t=oi("useNavigate"),n=P.useRef(!1);return Wl(()=>{n.current=!0}),P.useCallback(async(a,i={})=>{dt(n.current,Zl),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var uo={};function Ql(e,t,n){!t&&!uo[e]&&(uo[e]=!0,dt(!1,n))}P.memo(am);function am({routes:e,manifest:t,future:n,state:s,isStatic:a,onError:i}){return Yl(e,void 0,{manifest:t,state:s,isStatic:a,onError:i})}function im({basename:e,children:t,initialEntries:n,initialIndex:s,useTransitions:a}){let i=P.useRef();i.current==null&&(i.current=ud({initialEntries:n,initialIndex:s,v5Compat:!0}));let o=i.current,[l,c]=P.useState({action:o.action,location:o.location}),u=P.useCallback(d=>{a===!1?c(d):P.startTransition(()=>c(d))},[a]);return P.useLayoutEffect(()=>o.listen(u),[o,u]),P.createElement(lm,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Ve({to:e,replace:t,state:n,relative:s}){Ie(xr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=P.useContext(mt);dt(!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}=P.useContext(gt),{pathname:o}=Ce(),l=Ae(),c=Ds(e,ri(i),o,s==="path"),u=JSON.stringify(c);return P.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:s})},[l,u,s,t,n]),null}function om(e){return Wd(e.context)}function X(e){Ie(!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 lm({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:a,static:i=!1,useTransitions:o}){Ie(!xr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=P.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=Mn(n));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:x}=n,p=P.useMemo(()=>{let N=Jt(u,l);return N==null?null:{location:{pathname:N,search:d,hash:m,state:h,key:f,mask:x},navigationType:s}},[l,u,d,m,h,f,s,x]);return dt(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:P.createElement(mt.Provider,{value:c},P.createElement(Ur.Provider,{children:t,value:p}))}function li({children:e,location:t}){return Hd(va(e),t)}function va(e,t=[]){let n=[];return P.Children.forEach(e,(s,a)=>{if(!P.isValidElement(s))return;let i=[...t,a];if(s.type===P.Fragment){n.push.apply(n,va(s.props.children,i));return}Ie(s.type===X,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ie(!s.props.index||!s.props.children,"An index route cannot have child routes.");let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=va(s.props.children,i)),n.push(o)}),n}var hs="get",fs="application/x-www-form-urlencoded";function $s(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function cm(e){return $s(e)&&e.tagName.toLowerCase()==="button"}function um(e){return $s(e)&&e.tagName.toLowerCase()==="form"}function dm(e){return $s(e)&&e.tagName.toLowerCase()==="input"}function mm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function hm(e,t){return e.button===0&&(!t||t==="_self")&&!mm(e)}function ja(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let s=e[n];return t.concat(Array.isArray(s)?s.map(a=>[n,a]):[[n,s]])},[]))}function fm(e,t){let n=ja(e);return t&&t.forEach((s,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var es=null;function pm(){if(es===null)try{new FormData(document.createElement("form"),0),es=!1}catch{es=!0}return es}var xm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ra(e){return e!=null&&!xm.has(e)?(dt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${fs}"`),null):e}function gm(e,t){let n,s,a,i,o;if(um(e)){let l=e.getAttribute("action");s=l?Jt(l,t):null,n=e.getAttribute("method")||hs,a=ra(e.getAttribute("enctype"))||fs,i=new FormData(e)}else if(cm(e)||dm(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(s=c?Jt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||hs,a=ra(e.getAttribute("formenctype"))||ra(l.getAttribute("enctype"))||fs,i=new FormData(l,e),!pm()){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($s(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=hs,s=null,a=fs,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:s,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ci(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Jl(e,t,n,s){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${s}`:a.pathname=`${a.pathname}.${s}`:a.pathname==="/"?a.pathname=`_root.${s}`:t&&Jt(a.pathname,t)==="/"?a.pathname=`${bs(t)}/_root.${s}`:a.pathname=`${bs(a.pathname)}.${s}`,a}async function ym(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function bm(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 vm(e,t,n){let s=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await ym(i,n);return o.links?o.links():[]}return[]}));return Sm(s.flat(1).filter(bm).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function mo(e,t,n,s,a,i){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var d;return n[u].pathname!==c.pathname||((d=n[u].route.path)==null?void 0:d.endsWith("*"))&&n[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=s.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=n[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 jm(e,t,{includeHydrateFallback:n}={}){return Nm(e.map(s=>{let a=t.routes[s.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function Nm(e){return[...new Set(e)]}function wm(e){let t={},n=Object.keys(e).sort();for(let s of n)t[s]=e[s];return t}function Sm(e,t){let n=new Set;return new Set(t),e.reduce((s,a)=>{let i=JSON.stringify(wm(a));return n.has(i)||(n.add(i),s.push({key:i,link:a})),s},[])}function ui(){let e=P.useContext(pr);return ci(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function km(){let e=P.useContext(Rs);return ci(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var di=P.createContext(void 0);di.displayName="FrameworkContext";function Os(){let e=P.useContext(di);return ci(e,"You must render this element inside a <HydratedRouter> element"),e}function Cm(e,t){let n=P.useContext(di),[s,a]=P.useState(!1),[i,o]=P.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:m}=t,h=P.useRef(null);P.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let p=g=>{g.forEach(k=>{o(k.isIntersecting)})},N=new IntersectionObserver(p,{threshold:.5});return h.current&&N.observe(h.current),()=>{N.disconnect()}}},[e]),P.useEffect(()=>{if(s){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[s]);let f=()=>{a(!0)},x=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,h,{}]:[i,h,{onFocus:Sr(l,f),onBlur:Sr(c,x),onMouseEnter:Sr(u,f),onMouseLeave:Sr(d,x),onTouchStart:Sr(m,f)}]:[!1,h,{}]}function Sr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Am({page:e,...t}){let n=Od(),{nonce:s}=Os(),{router:a}=ui(),i=P.useMemo(()=>Fl(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&s&&(t={...t,nonce:s}),n?P.createElement(Em,{page:e,matches:i,...t}):P.createElement(Im,{page:e,matches:i,...t})):null}function Pm(e){let{manifest:t,routeModules:n}=Os(),[s,a]=P.useState([]);return P.useEffect(()=>{let i=!1;return vm(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),s}function Em({page:e,matches:t,...n}){let s=Ce(),{future:a}=Os(),{basename:i}=ui(),o=P.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let l=Jl(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,s,t]);return P.createElement(P.Fragment,null,o.map(l=>P.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function Im({page:e,matches:t,...n}){let s=Ce(),{future:a,manifest:i,routeModules:o}=Os(),{basename:l}=ui(),{loaderData:c,matches:u}=km(),d=P.useMemo(()=>mo(e,t,u,i,s,"data"),[e,t,u,i,s]),m=P.useMemo(()=>mo(e,t,u,i,s,"assets"),[e,t,u,i,s]),h=P.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let p=new Set,N=!1;if(t.forEach(k=>{var S;let j=i.routes[k.route.id];!j||!j.hasLoader||(!d.some(E=>E.route.id===k.route.id)&&k.route.id in c&&((S=o[k.route.id])!=null&&S.shouldRevalidate)||j.hasClientLoader?N=!0:p.add(k.route.id))}),p.size===0)return[];let g=Jl(e,l,a.v8_trailingSlashAwareDataRequests,"data");return N&&p.size>0&&g.searchParams.set("_routes",t.filter(k=>p.has(k.route.id)).map(k=>k.route.id).join(",")),[g.pathname+g.search]},[l,a.v8_trailingSlashAwareDataRequests,c,s,i,d,t,e,o]),f=P.useMemo(()=>jm(m,i),[m,i]),x=Pm(m);return P.createElement(P.Fragment,null,h.map(p=>P.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...n})),f.map(p=>P.createElement("link",{key:p,rel:"modulepreload",href:p,...n})),x.map(({key:p,link:N})=>P.createElement("link",{key:p,nonce:n.nonce,...N,crossOrigin:N.crossOrigin??n.crossOrigin})))}function _m(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Tm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Tm&&(window.__reactRouterVersion="7.18.1")}catch{}var Gl=P.forwardRef(function({onClick:t,discover:n="render",prefetch:s="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...x},p){let{basename:N,navigator:g,useTransitions:k}=P.useContext(mt),j=typeof d=="string"&&ni.test(d),S=Ml(d,N);d=S.to;let E=Ud(d,{relative:a}),T=Ce(),A=null;if(l){let H=Ds(l,[],T.mask?T.mask.pathname:"/",!0);N!=="/"&&(H.pathname=H.pathname==="/"?N:Ct([N,H.pathname])),A=g.createHref(H)}let[R,I,L]=Cm(s,x),ie=$m(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:k});function V(H){t&&t(H),H.defaultPrevented||ie(H)}let K=!(S.isExternal||i),te=P.createElement("a",{...x,...L,href:(K?A:void 0)||S.absoluteURL||E,onClick:K?V:t,ref:_m(p,I),target:u,"data-discover":!j&&n==="render"?"true":void 0});return R&&!j?P.createElement(P.Fragment,null,te,P.createElement(Am,{page:E})):te});Gl.displayName="Link";var Fm=P.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:s="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let m=Zr(o,{relative:u.relative}),h=Ce(),f=P.useContext(Rs),{navigator:x,basename:p}=P.useContext(mt),N=f!=null&&Bm(m)&&l===!0,g=x.encodeLocation?x.encodeLocation(m).pathname:m.pathname,k=h.pathname,j=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(k=k.toLowerCase(),j=j?j.toLowerCase():null,g=g.toLowerCase()),j&&p&&(j=Jt(j,p)||j);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let E=k===g||!a&&k.startsWith(g)&&k.charAt(S)==="/",T=j!=null&&(j===g||!a&&j.startsWith(g)&&j.charAt(g.length)==="/"),A={isActive:E,isPending:T,isTransitioning:N},R=E?t:void 0,I;typeof s=="function"?I=s(A):I=[s,E?"active":null,T?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let L=typeof i=="function"?i(A):i;return P.createElement(Gl,{...u,"aria-current":R,className:I,ref:d,style:L,to:o,viewTransition:l},typeof c=="function"?c(A):c)});Fm.displayName="NavLink";var Dm=P.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:s,replace:a,state:i,method:o=hs,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},x)=>{let{useTransitions:p}=P.useContext(mt),N=Mm(),g=qm(l,{relative:u}),k=o.toLowerCase()==="get"?"get":"post",j=typeof l=="string"&&ni.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let T=E.nativeEvent.submitter,A=(T==null?void 0:T.getAttribute("formmethod"))||o,R=()=>N(T||E.currentTarget,{fetcherKey:t,method:A,navigate:n,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&n!==!1?P.startTransition(()=>R()):R()};return P.createElement("form",{ref:x,method:k,action:g,onSubmit:s?c:S,...f,"data-discover":!j&&e==="render"?"true":void 0})});Dm.displayName="Form";function Rm(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xl(e){let t=P.useContext(pr);return Ie(t,Rm(e)),t}function $m(e,{target:t,replace:n,mask:s,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=Ae(),m=Ce(),h=Zr(e,{relative:o});return P.useCallback(f=>{if(hm(f,t)){f.preventDefault();let x=n!==void 0?n:gs(m)===gs(h),p=()=>d(e,{replace:x,mask:s,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?P.startTransition(()=>p()):p()}},[m,d,h,n,s,a,t,e,i,o,l,c,u])}function Om(e){dt(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=P.useRef(ja(e)),n=P.useRef(!1),s=Ce(),a=P.useMemo(()=>fm(s.search,n.current?null:t.current),[s.search]),i=Ae(),o=P.useCallback((l,c)=>{const u=ja(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var Lm=0,zm=()=>`__${String(++Lm)}__`;function Mm(){let{router:e}=Xl("useSubmit"),{basename:t}=P.useContext(mt),n=nm(),s=e.fetch,a=e.navigate;return P.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:m}=gm(i,t);if(o.navigate===!1){let h=o.fetcherKey||zm();await s(h,n,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:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[s,a,t,n])}function qm(e,{relative:t}={}){let{basename:n}=P.useContext(mt),s=P.useContext(gt);Ie(s,"useFormAction must be used inside a RouteContext");let[a]=s.matches.slice(-1),i={...Zr(e||".",{relative:t})},o=Ce();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"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ct([n,i.pathname])),gs(i)}function Bm(e,{relative:t}={}){let n=P.useContext(Vl);Ie(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=Xl("useViewTransitionState"),a=Zr(e,{relative:t});if(!n.isTransitioning)return!1;let i=Jt(n.currentLocation.pathname,s)||n.currentLocation.pathname,o=Jt(n.nextLocation.pathname,s)||n.nextLocation.pathname;return ys(a.pathname,o)!=null||ys(a.pathname,i)!=null}var gr=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(){}},Sn,an,Xn,Nl,Vm=(Nl=class extends gr{constructor(){super();J(this,Sn);J(this,an);J(this,Xn);U(this,Xn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){w(this,an)||this.setEventListener(w(this,Xn))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,an))==null||t.call(this),U(this,an,void 0))}setEventListener(t){var n;U(this,Xn,t),(n=w(this,an))==null||n.call(this),U(this,an,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){w(this,Sn)!==t&&(U(this,Sn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof w(this,Sn)=="boolean"?w(this,Sn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Sn=new WeakMap,an=new WeakMap,Xn=new WeakMap,Nl),mi=new Vm,Um={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},_t,kn,wl,Zm=(wl=class{constructor(){J(this,_t,Um);J(this,kn,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&w(this,kn)&&e!==w(this,_t)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:w(this,_t),provider:e}),U(this,_t,e),process.env.NODE_ENV!=="production"&&U(this,kn,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&U(this,kn,!0),w(this,_t).setTimeout(e,t)}clearTimeout(e){w(this,_t).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&U(this,kn,!0),w(this,_t).setInterval(e,t)}clearInterval(e){w(this,_t).clearInterval(e)}},_t=new WeakMap,kn=new WeakMap,wl),Nn=new Zm;function Wm(e){setTimeout(e,0)}var Hm=typeof window>"u"||"Deno"in globalThis;function et(){}function Ym(e,t){return typeof e=="function"?e(t):e}function Na(e){return typeof e=="number"&&e>=0&&e!==1/0}function ec(e,t){return Math.max(e+(t||0)-Date.now(),0)}function xn(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function ho(e,t){const{type:n="all",exact:s,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==hi(o,t.options))return!1}else if(!Dr(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function fo(e,t){const{exact:n,status:s,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Dn(t.options.mutationKey)!==Dn(i))return!1}else if(!Dr(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function hi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Dn)(e)}function Dn(e){return JSON.stringify(e,(t,n)=>Sa(n)?Object.keys(n).sort().reduce((s,a)=>(s[a]=n[a],s),{}):n)}function Dr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Dr(e[n],t[n])):!1}var Km=Object.prototype.hasOwnProperty;function wa(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=po(e)&&po(t);if(!s&&!(Sa(e)&&Sa(t)))return t;const i=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),l=o.length,c=s?new Array(l):{};let u=0;for(let d=0;d<l;d++){const m=s?d:o[d],h=e[m],f=t[m];if(h===f){c[m]=h,(s?d<i:Km.call(e,m))&&u++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const x=wa(h,f,n+1);c[m]=x,x===h&&u++}return i===l&&u===i?e:c}function vs(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function po(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sa(e){if(!xo(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!xo(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function xo(e){return Object.prototype.toString.call(e)==="[object Object]"}function Qm(e){return new Promise(t=>{Nn.setTimeout(t,e)})}function ka(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return wa(e,t)}catch(s){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. [${n.queryHash}]: ${s}`),s}return wa(e,t)}return t}function Jm(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function Gm(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var js=Symbol();function tc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===js&&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===js?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fi(e,t){return typeof e=="function"?e(...t):!!e}function Xm(e,t,n){let s=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),s||(s=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var Rr=(()=>{let e=()=>Hm;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ca(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function s(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},n.reject=a=>{s({status:"rejected",reason:a}),t(a)},n}var eh=Wm;function th(){let e=[],t=0,n=l=>{l()},s=l=>{l()},a=eh;const i=l=>{t?e.push(l):a(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{s(()=>{l.forEach(c=>{n(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=>{n=l},setBatchNotifyFunction:l=>{s=l},setScheduler:l=>{a=l}}}var ze=th(),er,on,tr,Sl,nh=(Sl=class extends gr{constructor(){super();J(this,er,!0);J(this,on);J(this,tr);U(this,tr,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}}})}onSubscribe(){w(this,on)||this.setEventListener(w(this,tr))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,on))==null||t.call(this),U(this,on,void 0))}setEventListener(t){var n;U(this,tr,t),(n=w(this,on))==null||n.call(this),U(this,on,t(this.setOnline.bind(this)))}setOnline(t){w(this,er)!==t&&(U(this,er,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return w(this,er)}},er=new WeakMap,on=new WeakMap,tr=new WeakMap,Sl),Ns=new nh;function rh(e){return Math.min(1e3*2**e,3e4)}function nc(e){return(e??"online")==="online"?Ns.isOnline():!0}var Aa=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function rc(e){let t=!1,n=0,s;const a=Ca(),i=()=>a.status!=="pending",o=p=>{var N;if(!i()){const g=new Aa(p);h(g),(N=e.onCancel)==null||N.call(e,g)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>mi.isFocused()&&(e.networkMode==="always"||Ns.isOnline())&&e.canRun(),d=()=>nc(e.networkMode)&&e.canRun(),m=p=>{i()||(s==null||s(),a.resolve(p))},h=p=>{i()||(s==null||s(),a.reject(p))},f=()=>new Promise(p=>{var N;s=g=>{(i()||u())&&p(g)},(N=e.onPause)==null||N.call(e)}).then(()=>{var p;s=void 0,i()||(p=e.onContinue)==null||p.call(e)}),x=()=>{if(i())return;let p;const N=n===0?e.initialPromise:void 0;try{p=N??e.fn()}catch(g){p=Promise.reject(g)}Promise.resolve(p).then(m).catch(g=>{var T;if(i())return;const k=e.retry??(Rr.isServer()?0:3),j=e.retryDelay??rh,S=typeof j=="function"?j(n,g):j,E=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,g);if(t||!E){h(g);return}n++,(T=e.onFail)==null||T.call(e,n,g),Qm(S).then(()=>u()?void 0:f()).then(()=>{t?h(g):x()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():f().then(x),a)}}var Cn,kl,sc=(kl=class{constructor(){J(this,Cn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Na(this.gcTime)&&U(this,Cn,Nn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Rr.isServer()?1/0:300*1e3))}clearGcTimeout(){w(this,Cn)!==void 0&&(Nn.clearTimeout(w(this,Cn)),U(this,Cn,void 0))}},Cn=new WeakMap,kl);function sh(e){return{onFetch:(t,n)=>{var d,m,h,f,x;const s=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=((x=t.state.data)==null?void 0:x.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const N=j=>{Xm(j,()=>t.signal,()=>p=!0)},g=tc(t.options,t.fetchOptions),k=async(j,S,E)=>{if(p)return Promise.reject(t.signal.reason);if(S==null&&j.pages.length)return Promise.resolve(j);const A=(()=>{const ie={client:t.client,queryKey:t.queryKey,pageParam:S,direction:E?"backward":"forward",meta:t.options.meta};return N(ie),ie})(),R=await g(A),{maxPages:I}=t.options,L=E?Gm:Jm;return{pages:L(j.pages,R,I),pageParams:L(j.pageParams,S,I)}};if(a&&i.length){const j=a==="backward",S=j?ah:go,E={pages:i,pageParams:o},T=S(s,E);l=await k(E,T,j)}else{const j=e??i.length;do{const S=c===0?o[0]??s.initialPageParam:go(s,l);if(c>0&&S==null)break;l=await k(l,S),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var p,N;return(N=(p=t.options).persister)==null?void 0:N.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function go(e,{pages:t,pageParams:n}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,n[s],n):void 0}function ah(e,{pages:t,pageParams:n}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,n[0],n):void 0}var nr,An,rr,xt,Pn,Be,Lr,En,ot,ac,Ut,Cl,ih=(Cl=class extends sc{constructor(t){super();J(this,ot);J(this,nr);J(this,An);J(this,rr);J(this,xt);J(this,Pn);J(this,Be);J(this,Lr);J(this,En);U(this,En,!1),U(this,Lr,t.defaultOptions),this.setOptions(t.options),this.observers=[],U(this,Pn,t.client),U(this,xt,w(this,Pn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,U(this,An,bo(this.options)),this.state=t.state??w(this,An),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return w(this,nr)}get promise(){var t;return(t=w(this,Be))==null?void 0:t.promise}setOptions(t){if(this.options={...w(this,Lr),...t},t!=null&&t._type&&U(this,nr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=bo(this.options);n.data!==void 0&&(this.setState(yo(n.data,n.dataUpdatedAt)),U(this,An,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&w(this,xt).remove(this)}setData(t,n){const s=ka(this.state.data,t,this.options);return le(this,ot,Ut).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(t){le(this,ot,Ut).call(this,{type:"setState",state:t})}cancel(t){var s,a;const n=(s=w(this,Be))==null?void 0:s.promise;return(a=w(this,Be))==null||a.cancel(t),n?n.then(et).catch(et):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return w(this,An)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===js||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>xn(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:!ec(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,Be))==null||n.continue()}onOnline(){var n;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,Be))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),w(this,xt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(w(this,Be)&&(w(this,En)||le(this,ot,ac).call(this)?w(this,Be).cancel({revert:!0}):w(this,Be).cancelRetry()),this.scheduleGc()),w(this,xt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||le(this,ot,Ut).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,m,h,f,x,p,N,g,k,j;if(this.state.fetchStatus!=="idle"&&((u=w(this,Be))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(w(this,Be))return w(this,Be).continueRetry(),w(this,Be).promise}if(t&&this.setOptions(t),!this.options.queryFn){const S=this.observers.find(E=>E.options.queryFn);S&&this.setOptions(S.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 s=new AbortController,a=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(U(this,En,!0),s.signal)})},i=()=>{const S=tc(this.options,n),T=(()=>{const A={client:w(this,Pn),queryKey:this.queryKey,meta:this.meta};return a(A),A})();return U(this,En,!1),this.options.persister?this.options.persister(S,T,this):S(T)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:w(this,Pn),state:this.state,fetchFn:i};return a(S),S})(),c=w(this,nr)==="infinite"?sh(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),U(this,rr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&le(this,ot,Ut).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),U(this,Be,rc({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof Aa&&S.revert&&this.setState({...w(this,rr),fetchStatus:"idle"}),s.abort()},onFail:(S,E)=>{le(this,ot,Ut).call(this,{type:"failed",failureCount:S,error:E})},onPause:()=>{le(this,ot,Ut).call(this,{type:"pause"})},onContinue:()=>{le(this,ot,Ut).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await w(this,Be).start();if(S===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(S),(f=(h=w(this,xt).config).onSuccess)==null||f.call(h,S,this),(p=(x=w(this,xt).config).onSettled)==null||p.call(x,S,this.state.error,this),S}catch(S){if(S instanceof Aa){if(S.silent)return w(this,Be).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw le(this,ot,Ut).call(this,{type:"error",error:S}),(g=(N=w(this,xt).config).onError)==null||g.call(N,S,this),(j=(k=w(this,xt).config).onSettled)==null||j.call(k,this.state.data,S,this),S}finally{this.scheduleGc()}}},nr=new WeakMap,An=new WeakMap,rr=new WeakMap,xt=new WeakMap,Pn=new WeakMap,Be=new WeakMap,Lr=new WeakMap,En=new WeakMap,ot=new WeakSet,ac=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Ut=function(t){const n=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...ic(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...yo(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return U(this,rr,t.manual?a:void 0),a;case"error":const i=t.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=n(this.state),ze.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),w(this,xt).notify({query:this,type:"updated",action:t})})},Cl);function ic(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:nc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function yo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function bo(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,s=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var nt,me,zr,Xe,In,sr,Zt,ln,Mr,ar,ir,_n,Tn,cn,or,ye,Er,Pa,Ea,Ia,_a,Ta,Fa,Da,oc,Al,oh=(Al=class extends gr{constructor(t,n){super();J(this,ye);J(this,nt);J(this,me);J(this,zr);J(this,Xe);J(this,In);J(this,sr);J(this,Zt);J(this,ln);J(this,Mr);J(this,ar);J(this,ir);J(this,_n);J(this,Tn);J(this,cn);J(this,or,new Set);this.options=n,U(this,nt,t),U(this,ln,null),U(this,Zt,Ca()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(w(this,me).addObserver(this),vo(w(this,me),this.options)?le(this,ye,Er).call(this):this.updateResult(),le(this,ye,_a).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ra(w(this,me),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ra(w(this,me),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,le(this,ye,Ta).call(this),le(this,ye,Fa).call(this),w(this,me).removeObserver(this)}setOptions(t){const n=this.options,s=w(this,me);if(this.options=w(this,nt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,w(this,me))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");le(this,ye,Da).call(this),w(this,me).setOptions(this.options),n._defaulted&&!vs(this.options,n)&&w(this,nt).getQueryCache().notify({type:"observerOptionsUpdated",query:w(this,me),observer:this});const a=this.hasListeners();a&&jo(w(this,me),s,this.options,n)&&le(this,ye,Er).call(this),this.updateResult(),a&&(w(this,me)!==s||lt(this.options.enabled,w(this,me))!==lt(n.enabled,w(this,me))||xn(this.options.staleTime,w(this,me))!==xn(n.staleTime,w(this,me)))&&le(this,ye,Pa).call(this);const i=le(this,ye,Ea).call(this);a&&(w(this,me)!==s||lt(this.options.enabled,w(this,me))!==lt(n.enabled,w(this,me))||i!==w(this,cn))&&le(this,ye,Ia).call(this,i)}getOptimisticResult(t){const n=w(this,nt).getQueryCache().build(w(this,nt),t),s=this.createResult(n,t);return ch(this,s)&&(U(this,Xe,s),U(this,sr,this.options),U(this,In,w(this,me).state)),s}getCurrentResult(){return w(this,Xe)}trackResult(t,n){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&w(this,Zt).status==="pending"&&w(this,Zt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){w(this,or).add(t)}getCurrentQuery(){return w(this,me)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=w(this,nt).defaultQueryOptions(t),s=w(this,nt).getQueryCache().build(w(this,nt),n);return s.fetch().then(()=>this.createResult(s,n))}fetch(t){return le(this,ye,Er).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),w(this,Xe)))}createResult(t,n){var I;const s=w(this,me),a=this.options,i=w(this,Xe),o=w(this,In),l=w(this,sr),u=t!==s?t.state:w(this,zr),{state:d}=t;let m={...d},h=!1,f;if(n._optimisticResults){const L=this.hasListeners(),ie=!L&&vo(t,n),V=L&&jo(t,s,n,a);(ie||V)&&(m={...m,...ic(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:x,errorUpdatedAt:p,status:N}=m;f=m.data;let g=!1;if(n.placeholderData!==void 0&&f===void 0&&N==="pending"){let L;i!=null&&i.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(L=i.data,g=!0):L=typeof n.placeholderData=="function"?n.placeholderData((I=w(this,ir))==null?void 0:I.state.data,w(this,ir)):n.placeholderData,L!==void 0&&(N="success",f=ka(i==null?void 0:i.data,L,n),h=!0)}if(n.select&&f!==void 0&&!g)if(i&&f===(o==null?void 0:o.data)&&n.select===w(this,Mr))f=w(this,ar);else try{U(this,Mr,n.select),f=n.select(f),f=ka(i==null?void 0:i.data,f,n),U(this,ar,f),U(this,ln,null)}catch(L){U(this,ln,L)}w(this,ln)&&(x=w(this,ln),f=w(this,ar),p=Date.now(),N="error");const k=m.fetchStatus==="fetching",j=N==="pending",S=N==="error",E=j&&k,T=f!==void 0,R={status:N,fetchStatus:m.fetchStatus,isPending:j,isSuccess:N==="success",isError:S,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:x,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:k,isRefetching:k&&!j,isLoadingError:S&&!T,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&T,isStale:pi(t,n),refetch:this.refetch,promise:w(this,Zt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=R.data!==void 0,ie=R.status==="error"&&!L,V=H=>{ie?H.reject(R.error):L&&H.resolve(R.data)},K=()=>{const H=U(this,Zt,R.promise=Ca());V(H)},te=w(this,Zt);switch(te.status){case"pending":t.queryHash===s.queryHash&&V(te);break;case"fulfilled":(ie||R.data!==te.value)&&K();break;case"rejected":(!ie||R.error!==te.reason)&&K();break}}return R}updateResult(){const t=w(this,Xe),n=this.createResult(w(this,me),this.options);if(U(this,In,w(this,me).state),U(this,sr,this.options),w(this,In).data!==void 0&&U(this,ir,w(this,me)),vs(n,t))return;U(this,Xe,n);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!w(this,or).size)return!0;const o=new Set(i??w(this,or));return this.options.throwOnError&&o.add("error"),Object.keys(w(this,Xe)).some(l=>{const c=l;return w(this,Xe)[c]!==t[c]&&o.has(c)})};le(this,ye,oc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&le(this,ye,_a).call(this)}},nt=new WeakMap,me=new WeakMap,zr=new WeakMap,Xe=new WeakMap,In=new WeakMap,sr=new WeakMap,Zt=new WeakMap,ln=new WeakMap,Mr=new WeakMap,ar=new WeakMap,ir=new WeakMap,_n=new WeakMap,Tn=new WeakMap,cn=new WeakMap,or=new WeakMap,ye=new WeakSet,Er=function(t){le(this,ye,Da).call(this);let n=w(this,me).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(et)),n},Pa=function(){le(this,ye,Ta).call(this);const t=xn(this.options.staleTime,w(this,me));if(Rr.isServer()||w(this,Xe).isStale||!Na(t))return;const s=ec(w(this,Xe).dataUpdatedAt,t)+1;U(this,_n,Nn.setTimeout(()=>{w(this,Xe).isStale||this.updateResult()},s))},Ea=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(w(this,me)):this.options.refetchInterval)??!1},Ia=function(t){le(this,ye,Fa).call(this),U(this,cn,t),!(Rr.isServer()||lt(this.options.enabled,w(this,me))===!1||!Na(w(this,cn))||w(this,cn)===0)&&U(this,Tn,Nn.setInterval(()=>{(this.options.refetchIntervalInBackground||mi.isFocused())&&le(this,ye,Er).call(this)},w(this,cn)))},_a=function(){le(this,ye,Pa).call(this),le(this,ye,Ia).call(this,le(this,ye,Ea).call(this))},Ta=function(){w(this,_n)!==void 0&&(Nn.clearTimeout(w(this,_n)),U(this,_n,void 0))},Fa=function(){w(this,Tn)!==void 0&&(Nn.clearInterval(w(this,Tn)),U(this,Tn,void 0))},Da=function(){const t=w(this,nt).getQueryCache().build(w(this,nt),this.options);if(t===w(this,me))return;const n=w(this,me);U(this,me,t),U(this,zr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},oc=function(t){ze.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(w(this,Xe))}),w(this,nt).getQueryCache().notify({query:w(this,me),type:"observerResultsUpdated"})})},Al);function lh(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&lt(t.retryOnMount,e)===!1)}function vo(e,t){return lh(e,t)||e.state.data!==void 0&&Ra(e,t,t.refetchOnMount)}function Ra(e,t,n){if(lt(t.enabled,e)!==!1&&xn(t.staleTime,e)!=="static"){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&pi(e,t)}return!1}function jo(e,t,n,s){return(e!==t||lt(s.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&pi(e,n)}function pi(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(xn(t.staleTime,e))}function ch(e,t){return!vs(e.getCurrentResult(),t)}var qr,Tt,He,Fn,Ft,tn,Pl,uh=(Pl=class extends sc{constructor(t){super();J(this,Ft);J(this,qr);J(this,Tt);J(this,He);J(this,Fn);U(this,qr,t.client),this.mutationId=t.mutationId,U(this,He,t.mutationCache),U(this,Tt,[]),this.state=t.state||lc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){w(this,Tt).includes(t)||(w(this,Tt).push(t),this.clearGcTimeout(),w(this,He).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){U(this,Tt,w(this,Tt).filter(n=>n!==t)),this.scheduleGc(),w(this,He).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){w(this,Tt).length||(this.state.status==="pending"?this.scheduleGc():w(this,He).remove(this))}continue(){var t;return((t=w(this,Fn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,x,p,N,g,k,j,S,E,T,A;const n=()=>{le(this,Ft,tn).call(this,{type:"continue"})},s={client:w(this,qr),meta:this.options.meta,mutationKey:this.options.mutationKey};U(this,Fn,rc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(R,I)=>{le(this,Ft,tn).call(this,{type:"failed",failureCount:R,error:I})},onPause:()=>{le(this,Ft,tn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>w(this,He).canRun(this)}));const a=this.state.status==="pending",i=!w(this,Fn).canStart();try{if(a)n();else{le(this,Ft,tn).call(this,{type:"pending",variables:t,isPaused:i}),w(this,He).config.onMutate&&await w(this,He).config.onMutate(t,this,s);const I=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,s));I!==this.state.context&&le(this,Ft,tn).call(this,{type:"pending",context:I,variables:t,isPaused:i})}const R=await w(this,Fn).start();return await((u=(c=w(this,He).config).onSuccess)==null?void 0:u.call(c,R,t,this.state.context,this,s)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,R,t,this.state.context,s)),await((f=(h=w(this,He).config).onSettled)==null?void 0:f.call(h,R,null,this.state.variables,this.state.context,this,s)),await((p=(x=this.options).onSettled)==null?void 0:p.call(x,R,null,t,this.state.context,s)),le(this,Ft,tn).call(this,{type:"success",data:R}),R}catch(R){try{await((g=(N=w(this,He).config).onError)==null?void 0:g.call(N,R,t,this.state.context,this,s))}catch(I){Promise.reject(I)}try{await((j=(k=this.options).onError)==null?void 0:j.call(k,R,t,this.state.context,s))}catch(I){Promise.reject(I)}try{await((E=(S=w(this,He).config).onSettled)==null?void 0:E.call(S,void 0,R,this.state.variables,this.state.context,this,s))}catch(I){Promise.reject(I)}try{await((A=(T=this.options).onSettled)==null?void 0:A.call(T,void 0,R,t,this.state.context,s))}catch(I){Promise.reject(I)}throw le(this,Ft,tn).call(this,{type:"error",error:R}),R}finally{w(this,He).runNext(this)}}},qr=new WeakMap,Tt=new WeakMap,He=new WeakMap,Fn=new WeakMap,Ft=new WeakSet,tn=function(t){const n=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ze.batch(()=>{w(this,Tt).forEach(s=>{s.onMutationUpdate(t)}),w(this,He).notify({mutation:this,type:"updated",action:t})})},Pl);function lc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Wt,St,Br,El,dh=(El=class extends gr{constructor(t={}){super();J(this,Wt);J(this,St);J(this,Br);this.config=t,U(this,Wt,new Set),U(this,St,new Map),U(this,Br,0)}build(t,n,s){const a=new uh({client:t,mutationCache:this,mutationId:++Xr(this,Br)._,options:t.defaultMutationOptions(n),state:s});return this.add(a),a}add(t){w(this,Wt).add(t);const n=ts(t);if(typeof n=="string"){const s=w(this,St).get(n);s?s.push(t):w(this,St).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(w(this,Wt).delete(t)){const n=ts(t);if(typeof n=="string"){const s=w(this,St).get(n);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&w(this,St).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ts(t);if(typeof n=="string"){const s=w(this,St).get(n),a=s==null?void 0:s.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const n=ts(t);if(typeof n=="string"){const a=(s=w(this,St).get(n))==null?void 0:s.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ze.batch(()=>{w(this,Wt).forEach(t=>{this.notify({type:"removed",mutation:t})}),w(this,Wt).clear(),w(this,St).clear()})}getAll(){return Array.from(w(this,Wt))}find(t){const n={exact:!0,...t};return this.getAll().find(s=>fo(n,s))}findAll(t={}){return this.getAll().filter(n=>fo(t,n))}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ze.batch(()=>Promise.all(t.map(n=>n.continue().catch(et))))}},Wt=new WeakMap,St=new WeakMap,Br=new WeakMap,El);function ts(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ht,un,rt,Yt,Qt,ps,$a,Il,mh=(Il=class extends gr{constructor(t,n){super();J(this,Qt);J(this,Ht);J(this,un);J(this,rt);J(this,Yt);U(this,Ht,t),this.setOptions(n),this.bindMethods(),le(this,Qt,ps).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var s;const n=this.options;this.options=w(this,Ht).defaultMutationOptions(t),vs(this.options,n)||w(this,Ht).getMutationCache().notify({type:"observerOptionsUpdated",mutation:w(this,rt),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Dn(n.mutationKey)!==Dn(this.options.mutationKey)?this.reset():((s=w(this,rt))==null?void 0:s.state.status)==="pending"&&w(this,rt).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=w(this,rt))==null||t.removeObserver(this)}onMutationUpdate(t){le(this,Qt,ps).call(this),le(this,Qt,$a).call(this,t)}getCurrentResult(){return w(this,un)}reset(){var t;(t=w(this,rt))==null||t.removeObserver(this),U(this,rt,void 0),le(this,Qt,ps).call(this),le(this,Qt,$a).call(this)}mutate(t,n){var s;return U(this,Yt,n),(s=w(this,rt))==null||s.removeObserver(this),U(this,rt,w(this,Ht).getMutationCache().build(w(this,Ht),this.options)),w(this,rt).addObserver(this),w(this,rt).execute(t)}},Ht=new WeakMap,un=new WeakMap,rt=new WeakMap,Yt=new WeakMap,Qt=new WeakSet,ps=function(){var n;const t=((n=w(this,rt))==null?void 0:n.state)??lc();U(this,un,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},$a=function(t){ze.batch(()=>{var n,s,a,i,o,l,c,u;if(w(this,Yt)&&this.hasListeners()){const d=w(this,un).variables,m=w(this,un).context,h={client:w(this,Ht),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(s=(n=w(this,Yt)).onSuccess)==null||s.call(n,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=w(this,Yt)).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=w(this,Yt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=w(this,Yt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(w(this,un))})})},Il),Dt,_l,hh=(_l=class extends gr{constructor(t={}){super();J(this,Dt);this.config=t,U(this,Dt,new Map)}build(t,n,s){const a=n.queryKey,i=n.queryHash??hi(a,n);let o=this.get(i);return o||(o=new ih({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){w(this,Dt).has(t.queryHash)||(w(this,Dt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=w(this,Dt).get(t.queryHash);n&&(t.destroy(),n===t&&w(this,Dt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ze.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return w(this,Dt).get(t)}getAll(){return[...w(this,Dt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(s=>ho(n,s))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(s=>ho(t,s)):n}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Dt=new WeakMap,_l),De,dn,mn,lr,cr,hn,ur,dr,Tl,fh=(Tl=class{constructor(e={}){J(this,De);J(this,dn);J(this,mn);J(this,lr);J(this,cr);J(this,hn);J(this,ur);J(this,dr);U(this,De,e.queryCache||new hh),U(this,dn,e.mutationCache||new dh),U(this,mn,e.defaultOptions||{}),U(this,lr,new Map),U(this,cr,new Map),U(this,hn,0)}mount(){Xr(this,hn)._++,w(this,hn)===1&&(U(this,ur,mi.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,De).onFocus())})),U(this,dr,Ns.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,De).onOnline())})))}unmount(){var e,t;Xr(this,hn)._--,w(this,hn)===0&&((e=w(this,ur))==null||e.call(this),U(this,ur,void 0),(t=w(this,dr))==null||t.call(this),U(this,dr,void 0))}isFetching(e){return w(this,De).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return w(this,dn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,De).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=w(this,De).build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(xn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return w(this,De).findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),a=w(this,De).get(s.queryHash),i=a==null?void 0:a.state.data,o=Ym(t,i);if(o!==void 0)return w(this,De).build(this,s).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>w(this,De).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,De).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=w(this,De);ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=w(this,De);return ze.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=ze.batch(()=>w(this,De).findAll(e).map(a=>a.cancel(n)));return Promise.all(s).then(et).catch(et)}invalidateQueries(e,t={}){return ze.batch(()=>(w(this,De).findAll(e).forEach(n=>{n.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 n={...t,cancelRefetch:t.cancelRefetch??!0},s=ze.batch(()=>w(this,De).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(et)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(et)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=w(this,De).build(this,t);return n.isStaleByTime(xn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(et).catch(et)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(et).catch(et)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ns.isOnline()?w(this,dn).resumePausedMutations():Promise.resolve()}getQueryCache(){return w(this,De)}getMutationCache(){return w(this,dn)}getDefaultOptions(){return w(this,mn)}setDefaultOptions(e){U(this,mn,e)}setQueryDefaults(e,t){w(this,lr).set(Dn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...w(this,lr).values()],n={};return t.forEach(s=>{Dr(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){w(this,cr).set(Dn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...w(this,cr).values()],n={};return t.forEach(s=>{Dr(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...w(this,mn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=hi(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===js&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...w(this,mn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){w(this,De).clear(),w(this,dn).clear()}},De=new WeakMap,dn=new WeakMap,mn=new WeakMap,lr=new WeakMap,cr=new WeakMap,hn=new WeakMap,ur=new WeakMap,dr=new WeakMap,Tl),cc=P.createContext(void 0),yt=e=>{const t=P.useContext(cc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ph=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(cc.Provider,{value:e,children:t})),uc=P.createContext(!1),xh=()=>P.useContext(uc);uc.Provider;function gh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var yh=P.createContext(gh()),bh=()=>P.useContext(yh),vh=(e,t,n)=>{const s=n!=null&&n.state.error&&typeof e.throwOnError=="function"?fi(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},jh=e=>{P.useEffect(()=>{e.clearReset()},[e])},Nh=({result:e,errorResetBoundary:t,throwOnError:n,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||fi(n,[e.error,s])),wh=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>n(s(...a)):n(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Sh=(e,t)=>e.isLoading&&e.isFetching&&!t,kh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,No=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ch(e,t,n){var f,x,p,N;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 s=xh(),a=bh(),i=yt(),o=i.defaultQueryOptions(e);(x=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||x.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=s?"isRestoring":c?"optimistic":void 0,wh(o),vh(o,a,l),jh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=P.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!s&&c;if(P.useSyncExternalStore(P.useCallback(g=>{const k=h?d.subscribe(ze.batchCalls(g)):et;return d.updateResult(),k},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),P.useEffect(()=>{d.setOptions(o)},[o,d]),kh(o,m))throw No(o,d,a);if(Nh({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((N=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||N.call(p,o,m),o.experimental_prefetchInRender&&!Rr.isServer()&&Sh(m,s)){const g=u?No(o,d,a):l==null?void 0:l.promise;g==null||g.catch(et).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function je(e,t){return Ch(e,oh)}function Ah(e,t){const n=yt(),[s]=P.useState(()=>new mh(n,e));P.useEffect(()=>{s.setOptions(e)},[s,e]);const a=P.useSyncExternalStore(P.useCallback(o=>s.subscribe(ze.batchCalls(o)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=P.useCallback((o,l)=>{s.mutate(o,l).catch(et)},[s]);if(a.error&&fi(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function dc(e){return e.trim().replace(/\/+$/,"")}const Ls=new Map;function mc(e,t){Ls.set(e,t)}function Ph(e){return Ls.get(e)}function Eh(e){Ls.delete(e)}function Ih(e){for(const[t,n]of Ls)if(n.accessToken===e)return t}let Oa=null;function hc(e){Oa=dc(e)}let fc=null;function _h(e){fc=e}function Th(){return fc}let pc=null;function Fh(e){pc=e.trim()}function Dh(){return pc}function Rh(){return Oa!==null?Oa:dc("")}const wo={get apiBaseUrl(){return Rh()},apiVersion:"v1"};function $h(e){const t=e.startsWith("/")?e:`/${e}`;return`${wo.apiBaseUrl}/api/${wo.apiVersion}${t}`}const xc="auth:session-expired";function Oh(){window.dispatchEvent(new CustomEvent(xc))}function gc(e){return`${xc}:${e}`}const Lh=v.createContext(null);function zh({instanceId:e,accessToken:t,onSessionExpired:n,children:s}){const a=Ph(e);return a&&mc(e,{...a,accessToken:t}),_h(t),v.useEffect(()=>{if(!n)return;const i=gc(e),o=()=>n();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,n]),r.jsx(Lh.Provider,{value:{accessToken:t},children:s})}class yr extends Error{constructor(n,s,a,i,o){super(a??s);wr(this,"status");wr(this,"title");wr(this,"details");wr(this,"extensions");this.name="ApiError",this.status=n,this.title=s,this.details=i,this.extensions=o}}const yc="tax-remittance.auth";function Mh(){var t;const e=localStorage.getItem(yc);if(!e)return null;try{const n=JSON.parse(e);return!n.accessToken||!((t=n.user)!=null&&t.userId)?null:new Date(n.user.expiresAt)<=new Date?(La(),null):n}catch{return La(),null}}function La(){localStorage.removeItem(yc)}function qh(){var e;return((e=Mh())==null?void 0:e.accessToken)??null}async function Bh(e){let t=null;try{t=await e.json()}catch{}const n=(t==null?void 0:t.title)??"Request failed",s=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new yr(e.status,n,s,a,t??void 0)}async function Wr(e,t={}){const{body:n,auth:s=!0,headers:a,responseType:i="json",...o}=t,l=new Headers(a);i==="blob"?l.set("Accept","application/pdf"):i==="text"?l.set("Accept","text/html"):l.set("Accept","application/json"),n!==void 0&&l.set("Content-Type","application/json");let c=null;if(s){const m=Th()??qh();m&&(c=m,l.set("Authorization",`Bearer ${m}`))}const u=Dh();u&&l.set("X-Client-ID",u);const d=await fetch($h(e),{...o,headers:l,body:n!==void 0?JSON.stringify(n):void 0});if(!d.ok){const m=await Bh(d);if(s&&m.status===401){La();const h=c?Ih(c):void 0;h?window.dispatchEvent(new CustomEvent(gc(h))):Oh()}throw m}if(d.status!==204)return i==="blob"?await d.blob():i==="text"?await d.text():await d.json()}async function pe(e,t={}){return(await Wr(e,t)).data}const tt=10;function xi({search:e,pageNumber:t=1,pageSize:n=tt}={}){const s=new URLSearchParams({pageNumber:String(t),pageSize:String(n)});return e!=null&&e.trim()&&s.set("search",e.trim()),pe(`/portal/entities/mine?${s}`)}function Vh(e){return pe("/portal/entities",{method:"POST",body:e})}function Uh(e,t){return pe(`/portal/entities/${e}`,{method:"PATCH",body:t})}const bc=v.createContext(null);function Zh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:n,children:s}){var p;const[a,i]=v.useState(null),{data:o=[],isLoading:l,isError:c,refetch:u}=je({queryKey:["entities","mine"],queryFn:async()=>(await xi({pageNumber:1,pageSize:100})).items}),d=v.useRef(new Set),m=v.useRef(!1);v.useEffect(()=>{if(l)return;if(!m.current){o.forEach(g=>d.current.add(g.entityId)),m.current=!0;return}o.filter(g=>!d.current.has(g.entityId)).forEach(g=>{d.current.add(g.entityId),e==null||e(g)})},[o,l,e]);const h=a!==null&&o.some(N=>N.entityId===a)?a:((p=o[0])==null?void 0:p.entityId)??null,f=o.find(N=>N.entityId===h)??null,x=async()=>{await u()};return r.jsx(bc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:f,setSelectedEntityId:i,refetchEntities:x,enabledPayments:t,onPaymentRequired:n},children:s})}function qn(){const e=v.useContext(bc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const Wh=v.createContext(null);function Hh({theme:e,children:t}){const n={},s=n,a=(e==null?void 0:e.primaryColor)??"#2563eb";s["--embedded-primary"]=a,s["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,s["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";s["--embedded-secondary"]=i,s["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,s["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return s["--embedded-tertiary"]=o,s["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,s["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(s["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(n.fontFamily=e.fontFamily),s.minHeight="100%",r.jsx("div",{className:"tax-remittance-embedded",style:n,children:t})}const vc=v.createContext(null),Yh=6e3;function Kh(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Qh({toast:e,onDismiss:t}){const n=e.variant==="success";return r.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${n?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[r.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),r.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 ${n?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:r.jsx(Jh,{})})]}),r.jsx("div",{className:`mx-5 border-t ${n?"border-emerald-700":"border-red-300"}`}),r.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function Jh(){return r.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function Gh({children:e}){const[t,n]=v.useState([]),s=v.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]),a=v.useCallback((o,l,c)=>{const u=Kh();n(d=>[...d,{id:u,variant:o,title:l,message:c}]),window.setTimeout(()=>{s(u)},Yh)},[s]),i=v.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return r.jsxs(vc.Provider,{value:i,children:[e,Vr.createPortal(r.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=>r.jsx("div",{className:"pointer-events-auto",children:r.jsx(Qh,{toast:o,onDismiss:s})},o.id))}),document.body)]})}function zs(){const e=v.useContext(vc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class Xh extends v.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?r.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[r.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),r.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),r.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 ef(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 tf({navigateFnRef:e,onNavigate:t}){const n=Ae(),s=Ce();return v.useEffect(()=>(e.current=n,()=>{e.current=null}),[n,e]),v.useEffect(()=>{t==null||t(ef(s.pathname),s.pathname)},[s.pathname,t]),null}function nf({selectEntityFnRef:e}){const{setSelectedEntityId:t}=qn();return v.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function gi({appKey:e,accessToken:t,apiBaseUrl:n,theme:s,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:u,enabledPayments:d,children:m}){const[h]=v.useState(()=>crypto.randomUUID());mc(h,{apiBaseUrl:n.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),hc(n),Fh(e),v.useEffect(()=>()=>{Eh(h)},[h]);const[f]=v.useState(()=>new fh({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return r.jsx(Wh.Provider,{value:h,children:r.jsx(Hh,{theme:s,children:r.jsx(ph,{client:f,children:r.jsx(Gh,{children:r.jsx(zh,{instanceId:h,accessToken:t,onSessionExpired:a,children:r.jsx(im,{children:r.jsxs(Zh,{onOrganizationCreated:i,enabledPayments:d,onPaymentRequired:l,children:[r.jsx(tf,{navigateFnRef:c,onNavigate:o}),r.jsx(nf,{selectEntityFnRef:u}),r.jsx(Xh,{children:m})]})})})})})})})}function yi(){const{entities:e,isLoading:t,isError:n,refetchEntities:s}=qn(),a=Ae();return v.useEffect(()=>{t||n||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,n,e,a]),t?r.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:r.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600"})}):n?r.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:r.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.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"})})}),r.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),r.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),r.jsx("button",{type:"button",onClick:s,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 bi(){const{entities:e,selectedEntity:t,setSelectedEntityId:n}=qn(),s=Ae(),i=Ce().pathname.split("/").filter(Boolean).length>1;return r.jsxs("div",{className:"flex min-h-full flex-col bg-slate-50",children:[r.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3",children:[i&&r.jsxs("button",{type:"button",onClick:()=>s(-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:[r.jsx(rf,{}),"Back"]}),r.jsx("div",{className:"flex-1"})]}),r.jsx("main",{className:"flex-1 p-5",children:r.jsx(om,{context:{entities:e,selectedEntity:t,setSelectedEntityId:n}})})]})}function rf(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}const sf=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function af({onCreateClick:e}){return r.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[r.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:[r.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[r.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:r.jsx(So,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),r.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Create Your Entity"}),r.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),r.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[r.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:sf.map(t=>r.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[r.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:r.jsx(ns,{})}),t]},t))}),r.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:[r.jsx(So,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",r.jsx(of,{})]})]})]}),r.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:[r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(ns,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),r.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(ns,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),r.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(ns,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function So({className:e="h-5 w-5"}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:r.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 ns({className:e="h-3 w-3"}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 16 16",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.5 8.5l3 3 6-6"})})}function of(){return r.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:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})}function vi(){const e=Ae(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return r.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:r.jsx(af,{onCreateClick:t})})}var Hr=e=>e.type==="checkbox",fn=e=>e instanceof Date,Ze=e=>e==null;const ji=e=>typeof e=="object";var Ee=e=>!Ze(e)&&!Array.isArray(e)&&ji(e)&&!fn(e),za=e=>Ee(e)&&e.target?Hr(e.target)?e.target.checked:e.target.value:e,jc=(e,t)=>t.split(".").some((n,s,a)=>!isNaN(Number(n))&&e.has(a.slice(0,s).join("."))),Nc=e=>{const t=e.constructor&&e.constructor.prototype;return Ee(t)&&t.hasOwnProperty("isPrototypeOf")},Ms=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Fe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Ms&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(Ee(e)&&Nc(e)))return e;const s=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(s[a]=Fe(e[a]));return s}const nn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},wt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},wc="root",Ni=["__proto__","constructor","prototype"],lf=/^\w*$/;var Yr=e=>lf.test(e),we=e=>e===void 0;const cf=/[.[\]'"]/;var qs=e=>e.split(cf).filter(Boolean),B=(e,t,n)=>{if(!t||!Ee(e))return n;const s=Yr(t)?[t]:qs(t);if(s.some(i=>Ni.includes(i)))return n;const a=s.reduce((i,o)=>Ze(i)?void 0:i[o],e);return we(a)||a===e?we(e[t])?n:e[t]:a},ct=e=>typeof e=="boolean",Ye=e=>typeof e=="function",ge=(e,t,n)=>{let s=-1;const a=Yr(t)?[t]:qs(t),i=a.length,o=i-1;for(;++s<i;){const l=a[s];let c=n;if(s!==o){const u=e[l];c=Ee(u)||Array.isArray(u)?u:isNaN(+a[s+1])?{}:[]}if(Ni.includes(l))return;e[l]=c,e=e[l]}};const Sc=v.createContext(null);Sc.displayName="HookFormControlContext";const wi=()=>v.useContext(Sc);var kc=(e,t,n,s=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==kt.all&&(t._proxyFormState[o]=!s||kt.all),n&&(n[o]=!0),e[o]}});return a};const Si=Ms?v.useLayoutEffect:v.useEffect;function uf(e){const t=wi(),{control:n=t,disabled:s,name:a,exact:i}=e||{},[o,l]=v.useState(()=>({...n._formState,defaultValues:n._defaultValues})),c=v.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Si(()=>n._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!s&&l({...n._formState,...u,defaultValues:n._defaultValues})}}),[a,s,i]),v.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),v.useMemo(()=>kc(o,n,c.current,!1),[o,n])}var Ke=e=>typeof e=="string",Ma=(e,t,n,s,a)=>Ke(e)?(s&&t.watch.add(e),B(n,e,a)):Array.isArray(e)?e.map(i=>(s&&t.watch.add(i),B(n,i))):(s&&(t.watchAll=!0),n),qa=e=>Ze(e)||!ji(e);const ko=(e,t)=>t.length===0&&!Array.isArray(e)&&!Nc(e);function ut(e,t,n=new WeakMap){if(e===t)return!0;if(qa(e)||qa(t))return Object.is(e,t);if(fn(e)&&fn(t))return Object.is(e.getTime(),t.getTime());const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;if(ko(e,s)||ko(t,a))return Object.is(e,t);if(!s.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=n.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),n.set(e,o)}for(const o of s){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(fn(l)&&fn(c)||(Ee(l)||Array.isArray(l))&&(Ee(c)||Array.isArray(c))?!ut(l,c,n):!Object.is(l,c))return!1}}return!0}function df(e){const t=wi(),{control:n=t,name:s,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=v.useRef(a),u=v.useRef(l),d=v.useRef(void 0),m=v.useRef(n),h=v.useRef(s);u.current=l;const[f,x]=v.useState(()=>{const S=n._getWatch(s,c.current);return u.current?u.current(S):S}),p=v.useCallback(S=>{const E=Ma(s,n._names,S||n._formValues,!1,c.current);return u.current?u.current(E):E},[n._formValues,n._names,s]),N=v.useCallback(S=>{if(!i){const E=Ma(s,n._names,S||n._formValues,!1,c.current);if(u.current){const T=u.current(E);ut(T,d.current)||(x(T),d.current=T)}else x(E)}},[n._formValues,n._names,i,s]);Si(()=>((m.current!==n||!ut(h.current,s))&&(m.current=n,h.current=s,N()),n._subscribe({name:s,formState:{values:!0},exact:o,callback:S=>{N(S.values)}})),[n,o,s,N]),v.useEffect(()=>n._removeUnmounted());const g=m.current!==n,k=h.current,j=v.useMemo(()=>{if(i)return null;const S=!g&&!ut(k,s);return g||S?p():null},[i,g,s,k,p]);return j!==null?j:f}function mf(e){const t=wi(),{name:n,disabled:s,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=jc(a._names.array,n),u=v.useMemo(()=>B(a._formValues,n,B(a._defaultValues,n,o)),[a,n,o]),d=df({control:a,name:n,defaultValue:u,exact:l}),m=uf({control:a,name:n,exact:l}),h=v.useRef(e),f=v.useRef(null),x=v.useRef(a.register(n,{...e.rules,value:d,...ct(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=v.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!B(m.errors,n)},isDirty:{enumerable:!0,get:()=>!!B(m.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!B(m.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!B(m.validatingFields,n)},error:{enumerable:!0,get:()=>B(m.errors,n)}}),[m,n]),N=v.useCallback(S=>{const E=za(S);return B(a._fields,n)||(x.current=a.register(n,{...h.current.rules,value:E})),x.current.onChange({target:{value:za(S),name:n},type:nn.CHANGE})},[n,a]),g=v.useCallback(()=>x.current.onBlur({target:{value:B(a._formValues,n),name:n},type:nn.BLUR}),[n,a._formValues]),k=v.useCallback(S=>{S&&(f.current={focus:()=>Ye(S.focus)&&S.focus(),select:()=>Ye(S.select)&&S.select(),setCustomValidity:T=>Ye(S.setCustomValidity)&&S.setCustomValidity(T),reportValidity:()=>Ye(S.reportValidity)&&S.reportValidity()});const E=B(a._fields,n);E&&E._f&&S&&(E._f.ref=f.current)},[a._fields,n]),j=v.useMemo(()=>({name:n,value:d,...ct(s)||m.disabled?{disabled:m.disabled||s}:{},onChange:N,onBlur:g,ref:k}),[n,s,m.disabled,N,g,k,d]);return v.useEffect(()=>{const S=a._options.shouldUnregister||i;a.register(n,{...h.current.rules,...ct(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(T,A)=>{const R=B(a._fields,T);R&&R._f&&(R._f.mount=A)};if(E(n,!0),S){const T=Fe(B(i?a._defaultValues:a._options.values||a._defaultValues,n,B(a._options.defaultValues,n,h.current.defaultValue)));ge(a._defaultValues,n,T),we(B(a._formValues,n))&&ge(a._formValues,n,T)}if(!c&&a.register(n),f.current){const T=B(a._fields,n);T&&T._f&&(T._f.ref=f.current)}return()=>{(c?S&&!a._state.action:S)?a.unregister(n):E(n,!1)}},[n,a,c,i]),v.useEffect(()=>{a._setDisabledField({disabled:s,name:n})},[s,n,a]),v.useMemo(()=>({field:j,formState:m,fieldState:p}),[j,m,p])}const Le=e=>e.render(mf(e)),Cc=e=>{const t={};for(const n of Object.keys(e))if(ji(e[n])&&e[n]!==null&&!fn(e[n])){const s=Cc(e[n]);for(const a of Object.keys(s))t[`${n}.${a}`]=s[a]}else t[n]=e[n];return t},hf=v.createContext(null);hf.displayName="HookFormContext";var ki=(e,t,n,s,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[s]:a||!0}}:{},Ac=e=>Array.isArray(e)?e.filter(Boolean):[],xs=e=>Array.isArray(e)?e:[e],Co=()=>{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 n={};for(const s in e)if(e.hasOwnProperty(s)){const a=e[s],i=t[s];if(a&&Ee(a)&&i){const o=Pc(a,i);Ee(o)&&(n[s]=o)}else e[s]&&(n[s]=i)}return n}var Ue=e=>Ee(e)&&!Object.keys(e).length,Ci=e=>e.type==="file",ws=e=>{if(!Ms)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ec=e=>e.type==="select-multiple",Ai=e=>e.type==="radio",ff=e=>Ai(e)||Hr(e),sa=e=>ws(e)&&e.isConnected;function pf(e,t){const n=t.slice(0,-1).length;let s=0;for(;s<n;){if(Ze(e)){e=void 0;break}e=e[t[s]],s++}return e}function xf(e){for(const t in e)if(e.hasOwnProperty(t)&&!we(e[t]))return!1;return!0}function Oe(e,t){if(Ke(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Yr(t)?[t]:qs(t);if(n.some(o=>Ni.includes(String(o))))return e;const s=n.length===1?e:pf(e,n),a=n.length-1,i=n[a];return s&&delete s[i],a!==0&&(Ee(s)&&Ue(s)||Array.isArray(s)&&xf(s))&&Oe(e,n.slice(0,-1)),e}var gf=e=>{for(const t in e)if(Ye(e[t]))return!0;return!1};function Ic(e){return Array.isArray(e)||Ee(e)&&!gf(e)}function Ba(e,t={}){for(const n in e){const s=e[n];Ic(s)?(t[n]=Array.isArray(s)?[]:{},Ba(s,t[n])):we(s)||(t[n]=!0)}return t}function Va(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>Va(n));return t.some(n=>n!==void 0)?t:void 0}if(Ee(e)){const t={};for(const n in e){const s=Va(e[n]);we(s)||(t[n]=s)}return Object.keys(t).length?t:void 0}}}function jn(e,t,n){n||(n=Ba(t));for(const s in e){const a=e[s];if(Ic(a))we(t)||qa(n[s])?n[s]=Ba(a,Array.isArray(a)?[]:{}):jn(a,Ze(t)?{}:t[s],n[s]);else{const i=t[s];n[s]=!ut(a,i)}}return Va(n)||{}}const Ao={value:!1,isValid:!1},Po={value:!0,isValid:!0};var _c=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!we(e[0].attributes.value)?we(e[0].value)||e[0].value===""?Po:{value:e[0].value,isValid:!0}:Po:Ao}return Ao},Tc=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:s})=>we(e)?e:t?e===""?NaN:e&&+e:n&&Ke(e)?new Date(e):s?s(e):e;const Eo={isValid:!1,value:null};var Fc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Eo):Eo;function Io(e){const t=e.ref;return Ci(t)?t.files:Ai(t)?Fc(e.refs).value:Ec(t)?[...t.selectedOptions].map(({value:n})=>n):Hr(t)?_c(e.refs).value:Tc(we(t.value)?e.ref.value:t.value,e)}var yf=(e,t,n,s)=>{const a={};for(const i of e){const o=B(t,i);o&&ge(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:s}},Ss=e=>e instanceof RegExp,kr=e=>we(e)?e:Ss(e)?e.source:Ee(e)?Ss(e.value)?e.value.source:e.value:e,rs=e=>({isOnSubmit:!e||e===kt.onSubmit,isOnBlur:e===kt.onBlur,isOnChange:e===kt.onChange,isOnAll:e===kt.all,isOnTouch:e===kt.onTouched});const _o="AsyncFunction";var bf=e=>{if(!e||!e.validate)return!1;if(Ye(e.validate))return e.validate.constructor.name===_o;if(Ee(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===_o)return!0}return!1},vf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),aa=(e,t,n)=>{if(n)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const s of t.watch)if(e.startsWith(s)&&e.charAt(s.length)===".")return!0;return!1};const Tr=(e,t,n,s)=>{for(const a of n||Object.keys(e)){const i=B(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!s)return!0;if(o.ref&&t(o.ref,o.name)&&!s)return!0;if(Tr(l,t))break}else if(Ee(l)&&Tr(l,t))break}}};function To(e,t,n){const s=B(e,n);if(s||Yr(n))return{error:s,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=B(t,i),l=B(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};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:n}}var jf=(e,t,n,s)=>{n(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||s&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!s||kt.all))},Nf=(e,t,n)=>!e||!t||e===t||xs(e).some(s=>s&&(n?s===t||s.startsWith(t+"."):s.startsWith(t)||t.startsWith(s))),wf=(e,t,n,s,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?s.isOnBlur:a.isOnBlur)?!e:(n?s.isOnChange:a.isOnChange)?e:!0,Sf=(e,t)=>!Ac(B(e,t)).length&&Oe(e,t),Fo=(e,t,n)=>{const s=B(e,n),a=Array.isArray(s)?s:[];return ge(a,wc,t[n]),ge(e,n,a),e};function Do(e,t,n="validate"){if(Ke(e)||Array.isArray(e)&&e.every(Ke)||ct(e)&&!e)return{type:n,message:Ke(e)?e:"",ref:t}}var Wn=e=>Ee(e)&&!Ss(e)?e:{value:e,message:""},Ro=async(e,t,n,s,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:m,max:h,pattern:f,validate:x,name:p,valueAsNumber:N,mount:g}=e._f,k=B(n,p);if(!g||t.has(p))return{};const j=l?l[0]:o,S=V=>{if(a&&j.reportValidity){const K=ct(V)?"":V||"";l?l.forEach(te=>te.setCustomValidity(K)):j.setCustomValidity(K),j.reportValidity()}},E={},T=Ai(o),A=Hr(o),R=T||A,I=(N||Ci(o))&&we(o.value)&&we(k)||ws(o)&&o.value===""||k===""||Array.isArray(k)&&!k.length,L=ki.bind(null,p,s,E),ie=(V,K,te,H=wt.maxLength,ce=wt.minLength)=>{const he=V?K:te;E[p]={type:V?H:ce,message:he,ref:o,...L(V?H:ce,he)}};if(i?!Array.isArray(k)||!k.length:c&&(!R&&(I||Ze(k))||ct(k)&&!k||A&&!_c(l).isValid||T&&!Fc(l).isValid)){const{value:V,message:K}=Ke(c)?{value:!!c,message:c}:Wn(c);if(V&&(E[p]={type:wt.required,message:K,ref:j,...L(wt.required,K)},!s))return S(K),E}if(!I&&(!Ze(m)||!Ze(h))){let V,K;const te=Wn(h),H=Wn(m);if(!Ze(k)&&!isNaN(k)){const ce=o.valueAsNumber||k&&+k;Ze(te.value)||(V=ce>te.value),Ze(H.value)||(K=ce<H.value)}else{const ce=o.valueAsDate||new Date(k),he=re=>new Date(new Date().toDateString()+" "+re),Q=o.type=="time",ke=o.type=="week";Ke(te.value)&&k&&(V=Q?he(k)>he(te.value):ke?k>te.value:ce>new Date(te.value)),Ke(H.value)&&k&&(K=Q?he(k)<he(H.value):ke?k<H.value:ce<new Date(H.value))}if((V||K)&&(ie(!!V,te.message,H.message,wt.max,wt.min),!s))return S(E[p].message),E}if((u||d)&&!I&&(Ke(k)||i&&Array.isArray(k))){const V=Wn(u),K=Wn(d),te=!Ze(V.value)&&k.length>+V.value,H=!Ze(K.value)&&k.length<+K.value;if((te||H)&&(ie(te,V.message,K.message),!s))return S(E[p].message),E}if(f&&!I&&Ke(k)){const{value:V,message:K}=Wn(f);if(Ss(V)&&!k.match(V)&&(E[p]={type:wt.pattern,message:K,ref:o,...L(wt.pattern,K)},!s))return S(K),E}if(x){if(Ye(x)){const V=await x(k,n),K=Do(V,j);if(K&&(E[p]={...K,...L(wt.validate,K.message)},!s))return S(K.message),E}else if(Ee(x)){let V={};for(const K in x){if(!Ue(V)&&!s)break;const te=Do(await x[K](k,n),j,K);te&&(V={...te,...L(K,te.message)},S(te.message),s&&(E[p]=V))}if(!Ue(V)&&(E[p]={ref:j,...V},!s))return E}}return S(!0),E};const kf={mode:kt.onSubmit,reValidateMode:kt.onChange,shouldFocusError:!0},ia="form",Dc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Cf(e={}){let t={...kf,...e},n={...Fe(Dc),isLoading:Ye(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},s={},a=Ee(t.defaultValues)||Ee(t.values)?Fe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:Fe(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=rs(t.mode),h=rs(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={...f};let p={...x};const N={array:Co(),state:Co()},g=t.criteriaMode===kt.all,k=b=>C=>{clearTimeout(u),u=setTimeout(b,C)},j=async b=>{if(!o.keepIsValid&&!t.disabled&&(x.isValid||p.isValid||b)){let C;t.resolver?(C=Ue((await K()).errors),S()):C=await ce({fields:s,onlyCheckValid:!0,eventType:nn.VALID}),C!==n.isValid&&N.state.next({isValid:C})}},S=(b,C)=>{!t.disabled&&(x.isValidating||x.validatingFields||p.isValidating||p.validatingFields)&&((b||Array.from(l.mount)).forEach(y=>{y&&(C?ge(n.validatingFields,y,C):Oe(n.validatingFields,y))}),N.state.next({validatingFields:n.validatingFields,isValidating:!Ue(n.validatingFields)}))},E=()=>{n.dirtyFields=jn(a,i)},T=(b,C=[],y,D,O=!0,Z=!0)=>{if(D&&y&&!t.disabled){if(o.action=!0,Z&&Array.isArray(B(s,b))){const M=y(B(s,b),D.argA,D.argB);O&&ge(s,b,M)}if(Z&&Array.isArray(B(n.errors,b))){const M=y(B(n.errors,b),D.argA,D.argB);O&&ge(n.errors,b,M),Sf(n.errors,b)}if((x.touchedFields||p.touchedFields)&&Z&&Array.isArray(B(n.touchedFields,b))){const M=y(B(n.touchedFields,b),D.argA,D.argB);O&&ge(n.touchedFields,b,M)}(x.dirtyFields||p.dirtyFields)&&E(),N.state.next({name:b,isDirty:Q(b,C),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ge(i,b,C)},A=(b,C)=>{ge(n.errors,b,C),n.errors={...n.errors},N.state.next({errors:n.errors})},R=b=>{n.errors=b,N.state.next({errors:n.errors,isValid:!1})},I=b=>{const C=Yr(b)?[b]:qs(b);let y=i,D=a;for(let O=0;O<C.length-1;O++){const Z=C[O];if(y=Ze(y)?y:y[Z],D=Ze(D)?D:D[Z],y===null&&D!==null)return!0}return!1},L=(b,C,y,D)=>{const O=B(s,b);if(O){if(I(b))return;const Z=we(B(i,b)),M=B(i,b,we(y)?B(a,b):y);we(M)||D&&D.defaultChecked||C?ge(i,b,C?M:Io(O._f)):Se(b,M),o.mount&&!o.action&&(j(),Z&&n.isDirty&&(x.isDirty||p.isDirty)&&(Q()||(n.isDirty=!1,N.state.next({...n}))),e.shouldUnregister&&Z&&!we(B(i,b))&&aa(b,l)&&(o.watch=!0))}},ie=(b,C,y,D,O)=>{let Z=!1,M=!1;const W={name:b};if(!t.disabled){if(!y||D){const q=ut(B(a,b),C);(x.isDirty||p.isDirty)&&(M=n.isDirty,n.isDirty=W.isDirty=!q||Q(),Z=M!==W.isDirty),M=!!B(n.dirtyFields,b),q!==n.isDirty?n.dirtyFields=jn(a,i):q?Oe(n.dirtyFields,b):ge(n.dirtyFields,b,!0),W.dirtyFields=n.dirtyFields,Z=Z||(x.dirtyFields||p.dirtyFields)&&M!==!q}if(y){const q=B(n.touchedFields,b);q||(ge(n.touchedFields,b,y),W.touchedFields=n.touchedFields,Z=Z||(x.touchedFields||p.touchedFields)&&q!==y)}Z&&O&&N.state.next(W)}return Z?W:{}},V=(b,C,y,D)=>{const O=B(n.errors,b),Z=(x.isValid||p.isValid)&&ct(C)&&n.isValid!==C;if(t.delayError&&y?(c=k(()=>A(b,y)),c(t.delayError)):(clearTimeout(u),c=null,y?ge(n.errors,b,y):Oe(n.errors,b),n.errors={...n.errors}),(y?!ut(O,y):O)||!Ue(D)||Z){const M={...D,...Z&&ct(C)?{isValid:C}:{},errors:n.errors,name:b};n={...n,...M},N.state.next(M)}},K=async b=>(S(b,!0),await t.resolver(i,t.context,yf(b||l.mount,s,t.criteriaMode,t.shouldUseNativeValidation))),te=async b=>{const{errors:C}=await K(b);if(S(b),b){for(const y of b){const D=B(C,y);D?l.array.has(y)&&Ee(D)&&!Object.keys(D).some(O=>!Number.isNaN(Number(O)))?Fo(n.errors,{[y]:D},y):ge(n.errors,y,D):Oe(n.errors,y)}n.errors={...n.errors}}else n.errors=C;return C},H=async({name:b,eventType:C})=>{if(e.validate){const y=await e.validate({formValues:i,formState:n,name:b,eventType:C});if(Ee(y))for(const D in y){const O=y[D];O&&Je(`${ia}.${D}`,{message:Ke(O.message)?O.message:"",type:O.type||wt.validate})}else Ke(y)||!y?Je(ia,{message:y||"",type:wt.validate}):Te(ia);return y}return!0},ce=async({fields:b,onlyCheckValid:C,name:y,eventType:D,context:O={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(O.runRootValidation=!0,!await H({name:y,eventType:D})&&(O.valid=!1,C)))return O.valid;for(const Z in b){const M=b[Z];if(M){const{_f:W,...q}=M;if(W){const ae=l.array.has(W.name),qe=M._f&&bf(M._f),Bt=x.validatingFields||x.isValidating||p.validatingFields||p.isValidating;qe&&Bt&&S([W.name],!0);const Vt=await Ro(M,l.disabled,i,g,t.shouldUseNativeValidation&&!C,ae);if(qe&&Bt&&S([W.name]),Vt[W.name]&&(O.valid=!1,C)||(!C&&(B(Vt,W.name)?ae?Fo(n.errors,Vt,W.name):ge(n.errors,W.name,Vt[W.name]):Oe(n.errors,W.name)),e.shouldUseNativeValidation&&Vt[W.name]))break}!Ue(q)&&await ce({context:O,onlyCheckValid:C,fields:q,name:Z,eventType:D})}}return O.valid},he=()=>{for(const b of l.unMount){const C=B(s,b);C&&(C._f.refs?C._f.refs.every(y=>!sa(y)):!sa(C._f.ref))&&ft(b)}l.unMount=new Set},Q=(b,C)=>!t.disabled&&(b&&C&&ge(i,b,C),!ut(o.mount?i:a,a)),ke=(b,C,y)=>Ma(b,l,{...o.mount?i:we(C)?a:Ke(b)?{[b]:C}:C},y,C),re=b=>Ac(B(o.mount?i:a,b,t.shouldUnregister?B(a,b,[]):[])),Se=(b,C,y={},D=!1,O=!1)=>{const Z=B(s,b);let M=C;if(Z){const W=Z._f;W&&(!W.disabled&&ge(i,b,Tc(C,W)),M=ws(W.ref)&&Ze(C)?"":C,Ec(W.ref)?[...W.ref.options].forEach(q=>q.selected=M.includes(q.value)):W.refs?Hr(W.ref)?W.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(M)?q.checked=!!M.find(ae=>ae===q.value):q.checked=M===q.value||!!M)}):W.refs.forEach(q=>q.checked=q.value===M):Ci(W.ref)?W.ref.value="":(W.ref.value=M,!W.ref.type&&!O&&N.state.next({name:b,values:D?i:Fe(i)})))}(y.shouldDirty||y.shouldTouch)&&ie(b,M,y.shouldTouch,y.shouldDirty,!O),y.shouldValidate&&se(b)},ue=(b,C,y,D=!1,O=!1)=>{for(const Z in C){if(!C.hasOwnProperty(Z))return;const M=C[Z],W=b+"."+Z,q=B(s,W);(l.array.has(b)||Ee(M)||q&&!q._f)&&!fn(M)?ue(W,M,y,D,O):Se(W,M,y,D,O)}},be=(b,C,y,D,O=!1)=>{const Z=B(s,b),M=l.array.has(b),W=D?C:Fe(C),q=B(i,b),ae=ut(q,W);if(ae||ge(i,b,W),M)N.array.next({name:b,values:D?i:Fe(i)}),(x.isDirty||x.dirtyFields||p.isDirty||p.dirtyFields)&&y.shouldDirty&&(E(),O||N.state.next({name:b,dirtyFields:n.dirtyFields,isDirty:Q(b,W)}));else{const qe=Array.isArray(W)&&!W.length||Ue(W);!Z||Z._f||Ze(W)||qe?Se(b,W,y,D,O):ue(b,W,y,D,O)}if(!ae&&!O){const qe=aa(b,l),Bt=D?i:Fe(i);N.state.next({...qe&&n,name:o.mount||qe?b:void 0,values:Bt})}},$=(b,C,y={})=>be(b,C,y,!1),xe=(b,C={})=>{const y=Ye(b)?b(i):b;if(!ut(i,y)){i={...i,...y};const D=Cc(y);for(const O of l.mount)O in D&&be(O,D[O],C,!0,!0);N.state.next({...n,name:void 0,type:void 0,...d?{values:i}:{}}),C.shouldValidate&&j()}},ee=async b=>{o.mount=!0;const C=b.target;let y=C.name,D=!0;const O=B(s,y),Z=M=>{D=Number.isNaN(M)||fn(M)&&isNaN(M.getTime())||ut(M,B(i,y,M))};if(O){let M,W;const q=C.type?Io(O._f):za(b),ae=b.type===nn.BLUR||b.type===nn.FOCUS_OUT,qe=!vf(O._f)&&!e.validate&&!t.resolver&&!B(n.errors,y)&&!O._f.deps,Bt=qe||wf(ae,B(n.touchedFields,y),n.isSubmitted,h,m),Vt=aa(y,l,ae);ge(i,y,q),ae?(!C||!C.readOnly)&&(O._f.onBlur&&O._f.onBlur(b),c&&c(0)):O._f.onChange&&O._f.onChange(b);const Nr=ie(y,q,ae),rd=!Ue(Nr)||Vt;if(!ae&&N.state.next({name:y,type:b.type,...d?{values:Fe(i)}:{}}),Bt)return(!qe||!n.isValid)&&(x.isValid||p.isValid)&&(t.mode==="onBlur"?ae&&j():ae||j()),rd&&N.state.next({name:y,...Vt?{}:Nr});if(!t.resolver&&e.validate&&await H({name:y,eventType:b.type}),!ae&&Vt&&N.state.next({...n}),t.resolver){const{errors:so}=await K([y]);if(S([y]),Z(q),!D){!Ue(Nr)&&N.state.next(Nr);return}const sd=To(n.errors,s,y),ao=To(so,s,sd.name||y);M=ao.error,y=ao.name,W=Ue(so)}else S([y],!0),M=(await Ro(O,l.disabled,i,g,t.shouldUseNativeValidation))[y],S([y]),Z(q),D&&(M?W=!1:(x.isValid||p.isValid)&&(W=await ce({fields:s,onlyCheckValid:!0,name:y,eventType:b.type})));D&&(O._f.deps&&(!Array.isArray(O._f.deps)||O._f.deps.length>0)&&se(O._f.deps),V(y,W,M,Nr))}},Ne=(b,C)=>{if(B(n.errors,C)&&b.focus)return b.focus(),1},se=async(b,C={})=>{let y,D;const O=xs(b);if(t.resolver){const Z=await te(we(b)?b:O);y=Ue(Z),D=b?!O.some(M=>B(Z,M)):y}else b?(D=(await Promise.all(O.map(async Z=>{const M=B(s,Z);return await ce({fields:M&&M._f?{[Z]:M}:M,eventType:nn.TRIGGER})}))).every(Boolean),!(!D&&!n.isValid)&&j()):D=y=await ce({fields:s,name:b,eventType:nn.TRIGGER});return N.state.next({...!Ke(b)||(x.isValid||p.isValid)&&y!==n.isValid?{}:{name:b},...t.resolver||!b?{isValid:y}:{},errors:n.errors}),C.shouldFocus&&!D&&Tr(s,Ne,b?O:l.mount),D},Me=(b,C)=>{let y={...o.mount?i:a};return C&&(y=Pc(C.dirtyFields?n.dirtyFields:n.touchedFields,y)),we(b)?y:Ke(b)?B(y,b):b.map(D=>B(y,D))},oe=(b,C)=>({invalid:!!B((C||n).errors,b),isDirty:!!B((C||n).dirtyFields,b),error:B((C||n).errors,b),isValidating:!!B(n.validatingFields,b),isTouched:!!B((C||n).touchedFields,b)}),Te=b=>{const C=b?xs(b):void 0;C==null||C.forEach(y=>Oe(n.errors,y)),C?C.forEach(y=>{N.state.next({name:y,errors:n.errors})}):N.state.next({errors:{}})},Je=(b,C,y)=>{const D=(B(s,b,{_f:{}})._f||{}).ref,O=B(n.errors,b)||{},{ref:Z,message:M,type:W,...q}=O;ge(n.errors,b,{...q,...C,ref:D}),N.state.next({name:b,errors:n.errors,isValid:!1}),y&&y.shouldFocus&&D&&D.focus&&D.focus()},at=(b,C)=>{if(Ye(b)){d++;const{unsubscribe:y}=N.state.subscribe({next:O=>"values"in O&&b(O.values||ke(void 0,C),O)});let D=!1;return{unsubscribe:()=>{D||(D=!0,d--,y())}}}return ke(b,C,!0)},it=b=>{var C;const y=!!(!((C=b.formState)===null||C===void 0)&&C.values);y&&d++;const{unsubscribe:D}=N.state.subscribe({next:Z=>{if(Nf(b.name,Z.name,b.exact)&&jf(Z,b.formState||x,It,b.reRenderRoot)){const M={...i};b.callback({values:M,...n,...Z,defaultValues:a})}}});if(!y)return D;let O=!1;return()=>{O||(O=!0,d--,D())}},Lt=b=>(o.mount=!0,p={...p,...b.formState},it({...b,formState:{...f,...b.formState}})),ft=(b,C={})=>{for(const y of b?xs(b):l.mount)l.mount.delete(y),l.array.delete(y),C.keepValue||(Oe(s,y),Oe(i,y)),!C.keepError&&Oe(n.errors,y),!C.keepDirty&&Oe(n.dirtyFields,y),!C.keepTouched&&Oe(n.touchedFields,y),!C.keepIsValidating&&Oe(n.validatingFields,y),!t.shouldUnregister&&!C.keepDefaultValue&&Oe(a,y);N.state.next({values:Fe(i)}),N.state.next({...n,...C.keepDirty?{isDirty:Q()}:{}}),!C.keepIsValid&&j()},vt=({disabled:b,name:C})=>{if(ct(b)&&o.mount||b||l.disabled.has(C)){const O=l.disabled.has(C)!==!!b;b?l.disabled.add(C):l.disabled.delete(C),O&&o.mount&&!o.action&&j()}},pt=(b,C={})=>{let y=B(s,b);const D=ct(C.disabled)||ct(t.disabled),O=!l.registerName.has(b)&&y&&y._f&&!y._f.mount;return ge(s,b,{...y||{},_f:{...y&&y._f?y._f:{ref:{name:b}},name:b,mount:!0,...C}}),l.mount.add(b),y&&!O?vt({disabled:ct(C.disabled)?C.disabled:t.disabled,name:b}):L(b,!0,C.value),{...D?{disabled:C.disabled||t.disabled}:{},...t.progressive?{required:!!C.required,min:kr(C.min),max:kr(C.max),minLength:kr(C.minLength),maxLength:kr(C.maxLength),pattern:kr(C.pattern)}:{},name:b,onChange:ee,onBlur:ee,ref:Z=>{if(Z){l.registerName.add(b),pt(b,C),l.registerName.delete(b),y=B(s,b);const M=we(Z.value)&&Z.querySelectorAll&&Z.querySelectorAll("input,select,textarea")[0]||Z,W=ff(M),q=y._f.refs||[];if(W?q.find(ae=>ae===M):M===y._f.ref)return;ge(s,b,{_f:{...y._f,...W?{refs:[...q.filter(sa),M,...Array.isArray(B(a,b))?[{}]:[]],ref:{type:M.type,name:b}}:{ref:M}}}),L(b,!1,void 0,M)}else y=B(s,b,{}),y._f&&(y._f.mount=!1),(t.shouldUnregister||C.shouldUnregister)&&!(jc(l.array,b)&&o.action)&&l.unMount.add(b)}}},jt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Tr(s,Ne,l.mount),zt=b=>{ct(b)&&(N.state.next({disabled:b}),Tr(s,(C,y)=>{const D=B(s,y);D&&(C.disabled=D._f.disabled||b,Array.isArray(D._f.refs)&&D._f.refs.forEach(O=>{O.disabled=D._f.disabled||b}))},0,!1))},At=(b,C)=>async y=>{let D;y&&(y.preventDefault&&y.preventDefault(),y.persist&&y.persist());let O=Fe(i);if(N.state.next({isSubmitting:!0}),t.resolver){const{errors:Z,values:M}=await K();S(),n.errors=Z,O=Fe(M)}else await ce({fields:s,eventType:nn.SUBMIT});if(l.disabled.size)for(const Z of l.disabled)Oe(O,Z);if(Oe(n.errors,wc),Ue(n.errors)){N.state.next({errors:{}});try{await b(O,y)}catch(Z){D=Z}}else C&&await C({...n.errors},y),jt(),setTimeout(jt);if(N.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ue(n.errors)&&!D,submitCount:n.submitCount+1,errors:n.errors}),D)throw D},Mt=(b,C={})=>{B(s,b)&&(we(C.defaultValue)?$(b,Fe(B(a,b))):($(b,C.defaultValue),ge(a,b,Fe(C.defaultValue))),C.keepTouched||Oe(n.touchedFields,b),C.keepDirty||(Oe(n.dirtyFields,b),n.isDirty=C.defaultValue?Q(b,Fe(B(a,b))):Q()),C.keepError||(Oe(n.errors,b),x.isValid&&j()),N.state.next({...n}))},Pt=(b,C={})=>{const y=b?Fe(b):a,D=Fe(y),O=Ue(b),Z=D;if(C.keepDefaultValues||(a=y),!C.keepValues){if(C.keepDirtyValues){const M=new Set([...l.mount,...Object.keys(jn(a,i))]);for(const W of Array.from(M)){const q=B(n.dirtyFields,W),ae=B(i,W),qe=B(Z,W);q&&!we(ae)?ge(Z,W,ae):!q&&!we(qe)&&$(W,qe)}}else{if(Ms&&we(b))for(const M of l.mount){const W=B(s,M);if(W&&W._f){const q=Array.isArray(W._f.refs)?W._f.refs[0]:W._f.ref;if(ws(q)){const ae=q.closest("form");if(ae){ae.reset();break}}}}if(C.keepFieldsRef)for(const M of l.mount)$(M,B(Z,M));else s={}}if(t.shouldUnregister){if(i=C.keepDefaultValues?Fe(a):{},C.keepFieldsRef)for(const M of l.mount)ge(i,M,B(Z,M))}else i=Fe(Z);N.array.next({values:{...Z}}),N.state.next({name:void 0,type:void 0,values:{...Z}})}l={mount:C.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=!x.isValid||!!C.keepIsValid||!!C.keepDirtyValues||!t.shouldUnregister&&!Ue(Z),o.watch=!!t.shouldUnregister,o.keepIsValid=!!C.keepIsValid,o.action=!1,C.keepErrors||(n.errors={}),N.state.next({submitCount:C.keepSubmitCount?n.submitCount:0,isDirty:O?!1:C.keepDirty?n.isDirty:C.keepValues?Q():!!(C.keepDefaultValues&&!ut(b,a)),isSubmitted:C.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:O?{}:C.keepDirtyValues?C.keepDefaultValues&&i?jn(a,i):n.dirtyFields:C.keepDefaultValues&&b?jn(a,b):C.keepDirty?n.dirtyFields:{},touchedFields:C.keepTouched?n.touchedFields:{},errors:C.keepErrors?n.errors:{},isSubmitSuccessful:C.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Nt=(b,C)=>Pt(Ye(b)?b(i):b,{...t.resetOptions,...C}),Et=(b,C={})=>{const y=B(s,b),D=y&&y._f;if(D){const O=D.refs?D.refs[0]:D.ref;O.focus&&setTimeout(()=>{O.focus(),C.shouldSelect&&Ye(O.select)&&O.select()})}},It=b=>{const{name:C,type:y,values:D,...O}=b;n={...n,...O}},de={control:{register:pt,unregister:ft,getFieldState:oe,handleSubmit:At,setError:Je,_subscribe:it,_runSchema:K,_updateIsValidating:S,_focusError:jt,_getWatch:ke,_getDirty:Q,_setValid:j,_setFieldArray:T,_setDisabledField:vt,_setErrors:R,_getFieldArray:re,_reset:Pt,_resetDefaultValues:()=>Ye(t.defaultValues)&&t.defaultValues().then(b=>{Nt(b,t.resetOptions),N.state.next({isLoading:!1})}),_removeUnmounted:he,_disableForm:zt,_subjects:N,_proxyFormState:x,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(b){o=b},get _defaultValues(){return a},get _names(){return l},set _names(b){l=b},get _formState(){return n},get _options(){return t},set _options(b){t={...t,...b},m=rs(t.mode),h=rs(t.reValidateMode)}},subscribe:Lt,trigger:se,register:pt,handleSubmit:At,watch:at,setValue:$,setValues:xe,getValues:Me,reset:Nt,resetField:Mt,resetDefaultValues:(b,C={})=>{if(a=Fe(b),!C.keepDirty){const y=jn(a,i);n.dirtyFields=y,n.isDirty=!Ue(y)}C.keepIsValid||j(),N.state.next({...n,defaultValues:a})},clearErrors:Te,unregister:ft,setError:Je,setFocus:Et,getFieldState:oe};return{...de,formControl:de}}function Rt(e={}){const t=v.useRef(void 0),n=v.useRef(void 0),s=v.useRef(e.formControl),[a,i]=v.useState(()=>({...Fe(Dc),isLoading:Ye(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ye(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&s.current!==e.formControl)if(s.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Ye(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=Cf(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,Si(()=>{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]),v.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),v.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),v.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),v.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),v.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),v.useEffect(()=>{var l;e.values&&!ut(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),v.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=v.useMemo(()=>kc(a,o),[o,a]),t.current}const $o=(e,t,n)=>{if(e&&"reportValidity"in e){const s=B(n,t);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},Ua=(e,t)=>{for(const n in t.fields){const s=t.fields[n];s&&s.ref&&"reportValidity"in s.ref?$o(s.ref,n,e):s&&s.refs&&s.refs.forEach(a=>$o(a,n,e))}},Oo=(e,t)=>{t.shouldUseNativeValidation&&Ua(e,t);const n={};for(const s in e){const a=B(t.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(Af(t.names||Object.keys(e),s)){const o=Object.assign({},B(n,s));ge(o,"root",i),ge(n,s,o)}else ge(n,s,i)}return n},Af=(e,t)=>{const n=Lo(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(s=>Lo(s).match(`^${n}\\.\\d+`))};function Lo(e){return e.replace(/[\[\]]/g,"")}var zo;function F(e,t,n){function s(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=(n==null?void 0:n.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const u=n!=null&&n.Parent?new i:this;s(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:s}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,u;return n!=null&&n.Parent&&l instanceof n.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 Kn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Rc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(zo=globalThis).__zod_globalConfig??(zo.__zod_globalConfig={});const Pi=globalThis.__zod_globalConfig;function Rn(e){return Pi}function $c(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,a])=>t.indexOf(+s)===-1).map(([s,a])=>a)}function Za(e,t){return typeof t=="bigint"?t.toString():t}function Ei(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ii(e){return e==null}function _i(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Mo=Symbol("evaluating");function ve(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==Mo)return s===void 0&&(s=Mo,s=n()),s},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Bn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function yn(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function qo(e){return JSON.stringify(e)}function Pf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Oc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ks(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ef=Ei(()=>{var e;if(Pi.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 $r(e){if(ks(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ks(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Lc(e){return $r(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const If=new Set(["string","number","symbol"]);function mr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bn(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(s._zod.parent=e),s}function ne(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 _f(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Tf(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=yn(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=n.shape[l])}return Bn(this,"shape",o),o},checks:[]});return bn(e,i)}function Ff(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=yn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Bn(this,"shape",o),o},checks:[]});return bn(e,i)}function Df(e,t){if(!$r(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.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=yn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Bn(this,"shape",i),i}});return bn(e,a)}function Rf(e,t){if(!$r(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=yn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Bn(this,"shape",s),s}});return bn(e,n)}function $f(e,t){var s;if((s=e._zod.def.checks)!=null&&s.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=yn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Bn(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bn(e,n)}function Of(e,t,n){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=yn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[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 Bn(this,"shape",c),c},checks:[]});return bn(t,o)}function Lf(e,t,n){const s=yn(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[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 Bn(this,"shape",i),i}});return bn(t,s)}function Hn(e,t=0){var n;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((n=e.issues[s])==null?void 0:n.continue)!==!0)return!0;return!1}function zf(e,t=0){var n;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((n=e.issues[s])==null?void 0:n.continue)===!1)return!0;return!1}function zc(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function ss(e){return typeof e=="string"?e:e==null?void 0:e.message}function $n(e,t,n){var c,u,d,m,h,f;const s=e.message?e.message:ss((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??ss((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??ss((h=n.customError)==null?void 0:h.call(n,e))??ss((f=n.localeError)==null?void 0:f.call(n,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=s,t!=null&&t.reportInput&&(l.input=o),l}function Ti(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Or(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const Mc=(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,Za,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fi=F("$ZodError",Mc),Bs=F("$ZodError",Mc,{Parent:Error});function Mf(e,t=n=>n.message){const n={},s=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):s.push(t(a));return{formErrors:s,fieldErrors:n}}function qf(e,t=n=>n.message){const n={_errors:[]},s=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>s({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")s({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")s({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)n._errors.push(t(o));else{let c=n,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 s(e),n}const Vs=e=>(t,n,s,a)=>{const i=s?{...s,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Kn;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>$n(c,i,Rn())));throw Oc(l,a==null?void 0:a.callee),l}return o.value},Bf=Vs(Bs),Us=e=>async(t,n,s,a)=>{const i=s?{...s,async:!0}:{async:!0};let o=t._zod.run({value:n,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=>$n(c,i,Rn())));throw Oc(l,a==null?void 0:a.callee),l}return o.value},Vf=Us(Bs),Zs=e=>(t,n,s)=>{const a=s?{...s,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Kn;return i.issues.length?{success:!1,error:new(e??Fi)(i.issues.map(o=>$n(o,a,Rn())))}:{success:!0,data:i.value}},Uf=Zs(Bs),Ws=e=>async(t,n,s)=>{const a=s?{...s,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>$n(o,a,Rn())))}:{success:!0,data:i.value}},Zf=Ws(Bs),Wf=e=>(t,n,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Vs(e)(t,n,a)},Hf=e=>(t,n,s)=>Vs(e)(t,n,s),Yf=e=>async(t,n,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Us(e)(t,n,a)},Kf=e=>async(t,n,s)=>Us(e)(t,n,s),Qf=e=>(t,n,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Zs(e)(t,n,a)},Jf=e=>(t,n,s)=>Zs(e)(t,n,s),Gf=e=>async(t,n,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Ws(e)(t,n,a)},Xf=e=>async(t,n,s)=>Ws(e)(t,n,s),ep=/^[cC][0-9a-z]{6,}$/,tp=/^[0-9a-z]+$/,np=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,rp=/^[0-9a-vA-V]{20}$/,sp=/^[A-Za-z0-9]{27}$/,ap=/^[a-zA-Z0-9_-]{21}$/,ip=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,op=/^([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})$/,Bo=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)$/,lp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,cp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function up(){return new RegExp(cp,"u")}const dp=/^(?:(?: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])$/,mp=/^(([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}|:))$/,hp=/^((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])$/,fp=/^(([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])$/,pp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qc=/^[A-Za-z0-9_-]*$/,xp=/^https?$/,gp=/^\+[1-9]\d{6,14}$/,Bc="(?:(?:\\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])))",yp=new RegExp(`^${Bc}$`);function Vc(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 bp(e){return new RegExp(`^${Vc(e)}$`)}function vp(e){const t=Vc({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${Bc}T(?:${s})$`)}const jp=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}$`)},Np=/^(?:true|false)$/i,wp=/^[^A-Z]*$/,Sp=/^[^a-z]*$/,$t=F("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),kp=F("$ZodCheckMaxLength",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!Ii(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const a=s.value;if(a.length<=t.maximum)return;const o=Ti(a);s.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Cp=F("$ZodCheckMinLength",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!Ii(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const a=s.value;if(a.length>=t.minimum)return;const o=Ti(a);s.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Ap=F("$ZodCheckLengthEquals",(e,t)=>{var n;$t.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!Ii(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=s=>{const a=s.value,i=a.length;if(i===t.length)return;const o=Ti(a),l=i>t.length;s.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Hs=F("$ZodCheckStringFormat",(e,t)=>{var n,s;$t.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?(n=e._zod).check??(n.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})}):(s=e._zod).check??(s.check=()=>{})}),Pp=F("$ZodCheckRegex",(e,t)=>{Hs.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ep=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=wp),Hs.init(e,t)}),Ip=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Sp),Hs.init(e,t)}),_p=F("$ZodCheckIncludes",(e,t)=>{$t.init(e,t);const n=mr(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(s)}),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})}}),Tp=F("$ZodCheckStartsWith",(e,t)=>{$t.init(e,t);const n=new RegExp(`^${mr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),Fp=F("$ZodCheckEndsWith",(e,t)=>{$t.init(e,t);const n=new RegExp(`.*${mr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),Dp=F("$ZodCheckOverwrite",(e,t)=>{$t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Rp{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 s=t.split(`
13
+ `).filter(o=>o),a=Math.min(...s.map(o=>o.length-o.trimStart().length)),i=s.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,n=this==null?void 0:this.args,a=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...n,a.join(`
14
+ `))}}const $p={major:4,minor:4,patch:3},Re=F("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$p;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const i of s)for(const o of i._zod.onattach)o(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,u)=>{let d=Hn(l),m;for(const h of c){if(h._zod.def.when){if(zf(l)||!h._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,x=h._zod.check(l);if(x instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Kn;if(m||x instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await x,l.issues.length!==f&&(d||(d=Hn(l,f)))});else{if(l.issues.length===f)continue;d||(d=Hn(l,f))}}return m?m.then(()=>l):l},o=(l,c,u)=>{if(Hn(l))return l.aborted=!0,l;const d=i(c,s,u);if(d instanceof Promise){if(u.async===!1)throw new Kn;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 Kn;return u.then(d=>i(d,s,c))}return i(u,s,c)}}ve(e,"~standard",()=>({validate:i=>{var o;try{const l=Uf(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return Zf(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}))}),Di=F("$ZodString",(e,t)=>{var n;Re.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??jp(e._zod.bag),e._zod.parse=(s,a)=>{if(t.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:e}),s}}),Pe=F("$ZodStringFormat",(e,t)=>{Hs.init(e,t),Di.init(e,t)}),Op=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=op),Pe.init(e,t)}),Lp=F("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Bo(s))}else t.pattern??(t.pattern=Bo());Pe.init(e,t)}),zp=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=lp),Pe.init(e,t)}),Mp=F("$ZodURL",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{var s;try{const a=n.value.trim();if(!t.normalize&&((s=t.protocol)==null?void 0:s.source)===xp.source&&!/^https?:\/\//i.test(a)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),qp=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=up()),Pe.init(e,t)}),Bp=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ap),Pe.init(e,t)}),Vp=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ep),Pe.init(e,t)}),Up=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=tp),Pe.init(e,t)}),Zp=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=np),Pe.init(e,t)}),Wp=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=rp),Pe.init(e,t)}),Hp=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sp),Pe.init(e,t)}),Yp=F("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=vp(t)),Pe.init(e,t)}),Kp=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=yp),Pe.init(e,t)}),Qp=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=bp(t)),Pe.init(e,t)}),Jp=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ip),Pe.init(e,t)}),Gp=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=dp),Pe.init(e,t),e._zod.bag.format="ipv4"}),Xp=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=mp),Pe.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ex=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=hp),Pe.init(e,t)}),tx=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=fp),Pe.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[a,i]=s;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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Uc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const nx=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=pp),Pe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Uc(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function rx(e){if(!qc.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Uc(n)}const sx=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qc),Pe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{rx(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ax=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=gp),Pe.init(e,t)});function ix(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const a=JSON.parse(atob(s));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const ox=F("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{ix(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),lx=F("$ZodBoolean",(e,t)=>{Re.init(e,t),e._zod.pattern=Np,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),cx=F("$ZodUnknown",(e,t)=>{Re.init(e,t),e._zod.parse=n=>n}),ux=F("$ZodNever",(e,t)=>{Re.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Vo(e,t,n){e.issues.length&&t.issues.push(...zc(n,e.issues)),t.value[n]=e.value}const dx=F("$ZodArray",(e,t)=>{Re.init(e,t),e._zod.parse=(n,s)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.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:[]},s);c instanceof Promise?i.push(c.then(u=>Vo(u,n,o))):Vo(c,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function Cs(e,t,n,s,a,i){const o=n in s;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...zc(n,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Zc(e){var s,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(s=e.shape)==null?void 0:s[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 n=_f(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Wc(e,t,n,s,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:[]},s);f instanceof Promise?e.push(f.then(x=>Cs(x,n,h,t,d,m))):Cs(f,n,h,t,d,m)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const mx=F("$ZodObject",(e,t)=>{Re.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const s=Ei(()=>Zc(t));ve(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=ks,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=s.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],x=f._zod.optin==="optional",p=f._zod.optout==="optional",N=f._zod.run({value:u[h],issues:[]},c);N instanceof Promise?d.push(N.then(g=>Cs(g,l,h,u,x,p))):Cs(N,l,h,u,x,p)}return i?Wc(d,u,l,c,s.value,e):d.length?Promise.all(d).then(()=>l):l}}),hx=F("$ZodObjectJIT",(e,t)=>{mx.init(e,t);const n=e._zod.parse,s=Ei(()=>Zc(t)),a=h=>{var j,S;const f=new Rp(["shape","payload","ctx"]),x=s.value,p=E=>{const T=qo(E);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};f.write("const input = payload.value;");const N=Object.create(null);let g=0;for(const E of x.keys)N[E]=`key_${g++}`;f.write("const newResult = {};");for(const E of x.keys){const T=N[E],A=qo(E),R=h[E],I=((j=R==null?void 0:R._zod)==null?void 0:j.optin)==="optional",L=((S=R==null?void 0:R._zod)==null?void 0:S.optout)==="optional";f.write(`const ${T} = ${p(E)};`),I&&L?f.write(`
15
+ if (${T}.issues.length) {
16
16
  if (${A} in input) {
17
- payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
17
+ payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
18
18
  ...iss,
19
19
  path: iss.path ? [${A}, ...iss.path] : [${A}]
20
20
  })));
21
21
  }
22
22
  }
23
23
 
24
- if (${D}.value === undefined) {
24
+ if (${T}.value === undefined) {
25
25
  if (${A} in input) {
26
26
  newResult[${A}] = undefined;
27
27
  }
28
28
  } else {
29
- newResult[${A}] = ${D}.value;
29
+ newResult[${A}] = ${T}.value;
30
30
  }
31
31
 
32
- `):_?f.write(`
33
- if (${D}.issues.length) {
34
- payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
32
+ `):I?f.write(`
33
+ if (${T}.issues.length) {
34
+ payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
35
35
  ...iss,
36
36
  path: iss.path ? [${A}, ...iss.path] : [${A}]
37
37
  })));
38
38
  }
39
39
 
40
- if (${D}.value === undefined) {
40
+ if (${T}.value === undefined) {
41
41
  if (${A} in input) {
42
42
  newResult[${A}] = undefined;
43
43
  }
44
44
  } else {
45
- newResult[${A}] = ${D}.value;
45
+ newResult[${A}] = ${T}.value;
46
46
  }
47
47
 
48
48
  `):f.write(`
49
- const ${D}_present = ${A} in input;
50
- if (${D}.issues.length) {
51
- payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
49
+ const ${T}_present = ${A} in input;
50
+ if (${T}.issues.length) {
51
+ payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
52
52
  ...iss,
53
53
  path: iss.path ? [${A}, ...iss.path] : [${A}]
54
54
  })));
55
55
  }
56
- if (!${D}_present && !${D}.issues.length) {
56
+ if (!${T}_present && !${T}.issues.length) {
57
57
  payload.issues.push({
58
58
  code: "invalid_type",
59
59
  expected: "nonoptional",
@@ -62,15 +62,15 @@ Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}
62
62
  });
63
63
  }
64
64
 
65
- if (${D}_present) {
66
- if (${D}.value === undefined) {
65
+ if (${T}_present) {
66
+ if (${T}.value === undefined) {
67
67
  newResult[${A}] = undefined;
68
68
  } else {
69
- newResult[${A}] = ${D}.value;
69
+ newResult[${A}] = ${T}.value;
70
70
  }
71
71
  }
72
72
 
73
- `)}f.write("payload.value = newResult;"),f.write("return payload;");const S=f.compile();return(E,D)=>S(h,E,D)};let i;const o=ws,l=!Ai.jitless,u=l&&Nf.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=s.value);const g=h.value;return o(g)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?Bc([],g,h,f,m,e):h):r(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h)}});function Bo(e,t,r,s){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Zr(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=>Dr(o,s,Fr())))}),t)}const ox=F("$ZodUnion",(e,t)=>{Fe.init(e,t),be(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),be(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),be(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),be(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${s.map(a=>_i(a.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(s,a)=>{if(r)return r(s,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:s.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=>Bo(l,s,e,a)):Bo(o,s,e,a)}}),lx=F("$ZodIntersection",(e,t)=>{Fe.init(e,t),e._zod.parse=(r,s)=>{const a=r.value,i=t.left._zod.run({value:a,issues:[]},s),o=t.right._zod.run({value:a,issues:[]},s);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Uo(r,c,u)):Uo(r,i,o)}});function Ba(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(Rn(e)&&Rn(t)){const r=Object.keys(t),s=Object.keys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of s){const o=Ba(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 s=0;s<e.length;s++){const a=e[s],i=t[s],o=Ba(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Uo(e,t,r){const s=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)s.has(c)||s.set(c,{}),s.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)s.has(c)||s.set(c,{}),s.get(c).r=!0;else e.issues.push(l);const i=[...s].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Zr(e))return e;const o=Ba(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 cx=F("$ZodEnum",(e,t)=>{Fe.init(e,t);const r=Fc(t.entries),s=new Set(r);e._zod.values=s,e._zod.pattern=new RegExp(`^(${r.filter(a=>wf.has(typeof a)).map(a=>typeof a=="string"?dn(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return s.has(o)||a.issues.push({code:"invalid_value",values:r,input:o,inst:e}),a}}),ux=F("$ZodLiteral",(e,t)=>{if(Fe.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(s=>typeof s=="string"?dn(s):s?dn(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,a)=>{const i=s.value;return r.has(i)||s.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),s}}),dx=F("$ZodTransform",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.parse=(r,s)=>{if(s.direction==="backward")throw new Tc(e.constructor.name);const a=t.transform(r.value,r);if(s.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(r.value=o,r.fallback=!0,r));if(a instanceof Promise)throw new Yr;return r.value=a,r.fallback=!0,r}});function Zo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Uc=F("$ZodOptional",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),be(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${_i(r.source)})?$`):void 0}),e._zod.parse=(r,s)=>{if(t.innerType._zod.optin==="optional"){const a=r.value,i=t.innerType._zod.run(r,s);return i instanceof Promise?i.then(o=>Zo(o,a)):Zo(i,a)}return r.value===void 0?r:t.innerType._zod.run(r,s)}}),mx=F("$ZodExactOptional",(e,t)=>{Uc.init(e,t),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,s)=>t.innerType._zod.run(r,s)}),hx=F("$ZodNullable",(e,t)=>{Fe.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${_i(r.source)}|null)$`):void 0}),be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,s)=>r.value===null?r:t.innerType._zod.run(r,s)}),fx=F("$ZodDefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,s)=>{if(s.direction==="backward")return t.innerType._zod.run(r,s);if(r.value===void 0)return r.value=t.defaultValue,r;const a=t.innerType._zod.run(r,s);return a instanceof Promise?a.then(i=>Wo(i,t)):Wo(a,t)}});function Wo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const px=F("$ZodPrefault",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,s)=>(s.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,s))}),xx=F("$ZodNonOptional",(e,t)=>{Fe.init(e,t),be(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(s=>s!==void 0)):void 0}),e._zod.parse=(r,s)=>{const a=t.innerType._zod.run(r,s);return a instanceof Promise?a.then(i=>Yo(i,e)):Yo(a,e)}});function Yo(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 gx=F("$ZodCatch",(e,t)=>{Fe.init(e,t),e._zod.optin="optional",be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,s)=>{if(s.direction==="backward")return t.innerType._zod.run(r,s);const a=t.innerType._zod.run(r,s);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=>Dr(o,s,Fr()))},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=>Dr(i,s,Fr()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),yx=F("$ZodPipe",(e,t)=>{Fe.init(e,t),be(e._zod,"values",()=>t.in._zod.values),be(e._zod,"optin",()=>t.in._zod.optin),be(e._zod,"optout",()=>t.out._zod.optout),be(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,s)=>{if(s.direction==="backward"){const i=t.out._zod.run(r,s);return i instanceof Promise?i.then(o=>ns(o,t.in,s)):ns(i,t.in,s)}const a=t.in._zod.run(r,s);return a instanceof Promise?a.then(i=>ns(i,t.out,s)):ns(a,t.out,s)}});function ns(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 bx=F("$ZodReadonly",(e,t)=>{Fe.init(e,t),be(e._zod,"propValues",()=>t.innerType._zod.propValues),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"optin",()=>{var r,s;return(s=(r=t.innerType)==null?void 0:r._zod)==null?void 0:s.optin}),be(e._zod,"optout",()=>{var r,s;return(s=(r=t.innerType)==null?void 0:r._zod)==null?void 0:s.optout}),e._zod.parse=(r,s)=>{if(s.direction==="backward")return t.innerType._zod.run(r,s);const a=t.innerType._zod.run(r,s);return a instanceof Promise?a.then(Ho):Ho(a)}});function Ho(e){return e.value=Object.freeze(e.value),e}const vx=F("$ZodCustom",(e,t)=>{Lt.init(e,t),Fe.init(e,t),e._zod.parse=(r,s)=>r,e._zod.check=r=>{const s=r.value,a=t.fn(s);if(a instanceof Promise)return a.then(i=>Ko(i,r,s,e));Ko(a,r,s,e)}});function Ko(e,t,r,s){if(!e){const a={code:"custom",input:r,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(a.params=s._zod.def.params),t.issues.push(On(a))}}var Qo;class jx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const s=r[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.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 s={...this.get(r)??{}};delete s.id;const a={...s,...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 Nx(){return new jx}(Qo=globalThis).__zod_globalRegistry??(Qo.__zod_globalRegistry=Nx());const _n=globalThis.__zod_globalRegistry;function wx(e,t){return new e({type:"string",...ne(t)})}function Zc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ne(t)})}function Jo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ne(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ne(t)})}function kx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ne(t)})}function Cx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ne(t)})}function Ax(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ne(t)})}function Px(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ne(t)})}function Ex(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ne(t)})}function _x(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ne(t)})}function Ix(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ne(t)})}function Tx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ne(t)})}function Fx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ne(t)})}function Dx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ne(t)})}function Rx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ne(t)})}function Ox(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ne(t)})}function $x(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ne(t)})}function Lx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ne(t)})}function zx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ne(t)})}function Mx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ne(t)})}function qx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ne(t)})}function Vx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ne(t)})}function Bx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ne(t)})}function Ux(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ne(t)})}function Zx(e,t){return new e({type:"string",format:"date",check:"string_format",...ne(t)})}function Wx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ne(t)})}function Yx(e,t){return new e({type:"string",format:"duration",check:"string_format",...ne(t)})}function Hx(e,t){return new e({type:"boolean",...ne(t)})}function Kx(e){return new e({type:"unknown"})}function Qx(e,t){return new e({type:"never",...ne(t)})}function Wc(e,t){return new yp({check:"max_length",...ne(t),maximum:e})}function ks(e,t){return new bp({check:"min_length",...ne(t),minimum:e})}function Yc(e,t){return new vp({check:"length_equals",...ne(t),length:e})}function Jx(e,t){return new jp({check:"string_format",format:"regex",...ne(t),pattern:e})}function Gx(e){return new Np({check:"string_format",format:"lowercase",...ne(e)})}function Xx(e){return new wp({check:"string_format",format:"uppercase",...ne(e)})}function eg(e,t){return new Sp({check:"string_format",format:"includes",...ne(t),includes:e})}function tg(e,t){return new kp({check:"string_format",format:"starts_with",...ne(t),prefix:e})}function rg(e,t){return new Cp({check:"string_format",format:"ends_with",...ne(t),suffix:e})}function bn(e){return new Ap({check:"overwrite",tx:e})}function ng(e){return bn(t=>t.normalize(e))}function sg(){return bn(e=>e.trim())}function ag(){return bn(e=>e.toLowerCase())}function ig(){return bn(e=>e.toUpperCase())}function og(){return bn(e=>jf(e))}function lg(e,t,r){return new e({type:"array",element:t,...ne(r)})}function cg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...ne(r)})}function ug(e,t){const r=dg(s=>(s.addIssue=a=>{if(typeof a=="string")s.issues.push(On(a,s.value,r._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=s.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),s.issues.push(On(i))}},e(s.value,s)),t);return r}function dg(e,t){const r=new Lt({check:"custom",...ne(t)});return r._zod.check=e,r}function Hc(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)??_n,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 We(e,t,r={path:[],schemaPath:[]}){var d,m;var s;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 g=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,g,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),We(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"&&Ge(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((s=o.schema).default??(s.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Kc(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 s=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=s.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.`);s.set(m,d[0])}}const a=d=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const b=(p=e.external.registry.get(d[0]))==null?void 0:p.id,x=e.external.uri??(w=>w);if(b)return{ref:x(b)};const S=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=S,{defId:S,ref:`${x("__shared")}#/${m}/${S}`}}if(d[1]===r)return{ref:"#"};const f=`#/${m}/`,g=d[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:f+g}},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 g=m.schema;for(const p in g)delete g[p];g.$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 k=f.compile();return(E,T)=>k(h,E,T)};let i;const o=ks,l=!Pi.jitless,u=l&&Ef.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=s.value);const x=h.value;return o(x)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?Wc([],x,h,f,m,e):h):n(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h)}});function Uo(e,t,n,s){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Hn(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>$n(o,s,Rn())))}),t)}const fx=F("$ZodUnion",(e,t)=>{Re.init(e,t),ve(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ve(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ve(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),ve(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${s.map(a=>_i(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(s,a)=>{if(n)return n(s,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:s.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=>Uo(l,s,e,a)):Uo(o,s,e,a)}}),px=F("$ZodIntersection",(e,t)=>{Re.init(e,t),e._zod.parse=(n,s)=>{const a=n.value,i=t.left._zod.run({value:a,issues:[]},s),o=t.right._zod.run({value:a,issues:[]},s);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Zo(n,c,u)):Zo(n,i,o)}});function Wa(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($r(e)&&$r(t)){const n=Object.keys(t),s=Object.keys(e).filter(i=>n.indexOf(i)!==-1),a={...e,...t};for(const i of s){const o=Wa(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 n=[];for(let s=0;s<e.length;s++){const a=e[s],i=t[s],o=Wa(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Zo(e,t,n){const s=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)s.has(c)||s.set(c,{}),s.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)s.has(c)||s.set(c,{}),s.get(c).r=!0;else e.issues.push(l);const i=[...s].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Hn(e))return e;const o=Wa(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const xx=F("$ZodEnum",(e,t)=>{Re.init(e,t);const n=$c(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(a=>If.has(typeof a)).map(a=>typeof a=="string"?mr(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return s.has(o)||a.issues.push({code:"invalid_value",values:n,input:o,inst:e}),a}}),gx=F("$ZodLiteral",(e,t)=>{if(Re.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?mr(s):s?mr(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,a)=>{const i=s.value;return n.has(i)||s.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),s}}),yx=F("$ZodTransform",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Rc(e.constructor.name);const a=t.transform(n.value,n);if(s.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(n.value=o,n.fallback=!0,n));if(a instanceof Promise)throw new Kn;return n.value=a,n.fallback=!0,n}});function Wo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Hc=F("$ZodOptional",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ve(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${_i(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const a=n.value,i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>Wo(o,a)):Wo(i,a)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),bx=F("$ZodExactOptional",(e,t)=>{Hc.init(e,t),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),vx=F("$ZodNullable",(e,t)=>{Re.init(e,t),ve(e._zod,"optin",()=>t.innerType._zod.optin),ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${_i(n.source)}|null)$`):void 0}),ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),jx=F("$ZodDefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(i=>Ho(i,t)):Ho(a,t)}});function Ho(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Nx=F("$ZodPrefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),wx=F("$ZodNonOptional",(e,t)=>{Re.init(e,t),ve(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(i=>Yo(i,e)):Yo(a,e)}});function Yo(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=F("$ZodCatch",(e,t)=>{Re.init(e,t),e._zod.optin="optional",ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>$n(o,s,Rn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>$n(i,s,Rn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),kx=F("$ZodPipe",(e,t)=>{Re.init(e,t),ve(e._zod,"values",()=>t.in._zod.values),ve(e._zod,"optin",()=>t.in._zod.optin),ve(e._zod,"optout",()=>t.out._zod.optout),ve(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const i=t.out._zod.run(n,s);return i instanceof Promise?i.then(o=>as(o,t.in,s)):as(i,t.in,s)}const a=t.in._zod.run(n,s);return a instanceof Promise?a.then(i=>as(i,t.out,s)):as(a,t.out,s)}});function as(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Cx=F("$ZodReadonly",(e,t)=>{Re.init(e,t),ve(e._zod,"propValues",()=>t.innerType._zod.propValues),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"optin",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optin}),ve(e._zod,"optout",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optout}),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(Ko):Ko(a)}});function Ko(e){return e.value=Object.freeze(e.value),e}const Ax=F("$ZodCustom",(e,t)=>{$t.init(e,t),Re.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,a=t.fn(s);if(a instanceof Promise)return a.then(i=>Qo(i,n,s,e));Qo(a,n,s,e)}});function Qo(e,t,n,s){if(!e){const a={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(a.params=s._zod.def.params),t.issues.push(Or(a))}}var Jo;class Px{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const a={...s,...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 Ex(){return new Px}(Jo=globalThis).__zod_globalRegistry??(Jo.__zod_globalRegistry=Ex());const Ir=globalThis.__zod_globalRegistry;function Ix(e,t){return new e({type:"string",...ne(t)})}function Yc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ne(t)})}function Go(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ne(t)})}function _x(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ne(t)})}function Tx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ne(t)})}function Fx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ne(t)})}function Dx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ne(t)})}function Rx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ne(t)})}function $x(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ne(t)})}function Ox(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ne(t)})}function Lx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ne(t)})}function zx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ne(t)})}function Mx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ne(t)})}function qx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ne(t)})}function Bx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ne(t)})}function Vx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ne(t)})}function Ux(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ne(t)})}function Zx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ne(t)})}function Wx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ne(t)})}function Hx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ne(t)})}function Yx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ne(t)})}function Kx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ne(t)})}function Qx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ne(t)})}function Jx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ne(t)})}function Gx(e,t){return new e({type:"string",format:"date",check:"string_format",...ne(t)})}function Xx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ne(t)})}function eg(e,t){return new e({type:"string",format:"duration",check:"string_format",...ne(t)})}function tg(e,t){return new e({type:"boolean",...ne(t)})}function ng(e){return new e({type:"unknown"})}function rg(e,t){return new e({type:"never",...ne(t)})}function Kc(e,t){return new kp({check:"max_length",...ne(t),maximum:e})}function As(e,t){return new Cp({check:"min_length",...ne(t),minimum:e})}function Qc(e,t){return new Ap({check:"length_equals",...ne(t),length:e})}function sg(e,t){return new Pp({check:"string_format",format:"regex",...ne(t),pattern:e})}function ag(e){return new Ep({check:"string_format",format:"lowercase",...ne(e)})}function ig(e){return new Ip({check:"string_format",format:"uppercase",...ne(e)})}function og(e,t){return new _p({check:"string_format",format:"includes",...ne(t),includes:e})}function lg(e,t){return new Tp({check:"string_format",format:"starts_with",...ne(t),prefix:e})}function cg(e,t){return new Fp({check:"string_format",format:"ends_with",...ne(t),suffix:e})}function br(e){return new Dp({check:"overwrite",tx:e})}function ug(e){return br(t=>t.normalize(e))}function dg(){return br(e=>e.trim())}function mg(){return br(e=>e.toLowerCase())}function hg(){return br(e=>e.toUpperCase())}function fg(){return br(e=>Pf(e))}function pg(e,t,n){return new e({type:"array",element:t,...ne(n)})}function xg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ne(n)})}function gg(e,t){const n=yg(s=>(s.addIssue=a=>{if(typeof a=="string")s.issues.push(Or(a,s.value,n._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=s.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),s.issues.push(Or(i))}},e(s.value,s)),t);return n}function yg(e,t){const n=new $t({check:"custom",...ne(t)});return n._zod.check=e,n}function Jc(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)??Ir,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 We(e,t,n={path:[],schemaPath:[]}){var d,m;var s;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.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={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const x=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,x,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),We(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"&&Ge(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((s=o.schema).default??(s.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Gc(e,t){var o,l,c,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=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=s.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.`);s.set(m,d[0])}}const a=d=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(p=e.external.registry.get(d[0]))==null?void 0:p.id,g=e.external.uri??(j=>j);if(N)return{ref:g(N)};const k=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=k,{defId:k,ref:`${g("__shared")}#/${m}/${k}`}}if(d[1]===n)return{ref:"#"};const f=`#/${m}/`,x=d[1].schema.id??`__schema${e.counter++}`;return{defId:x,ref:f+x}},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 x=m.schema;for(const p in x)delete x[p];x.$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 Qc(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 s=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,g={...f},p=h.ref;if(h.ref=null,p){s(p);const x=e.seen.get(p),S=x.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(S)):Object.assign(f,S),Object.assign(f,g),m._zod.parent===p)for(const N in f)N==="$ref"||N==="allOf"||N in g||delete f[N];if(S.$ref&&x.def)for(const N in f)N==="$ref"||N==="allOf"||N in x.def&&JSON.stringify(f[N])===JSON.stringify(x.def[N])&&delete f[N]}const b=m._zod.parent;if(b&&b!==p){s(b);const x=e.seen.get(b);if(x!=null&&x.schema.$ref&&(f.$ref=x.schema.$ref,x.def))for(const S in f)S==="$ref"||S==="allOf"||S in x.def&&JSON.stringify(f[S])===JSON.stringify(x.def[S])&&delete f[S]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())s(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:Cs(t,"input",e.processors),output:Cs(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return Ge(s.element,r);if(s.type==="set")return Ge(s.valueType,r);if(s.type==="lazy")return Ge(s.getter(),r);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return Ge(s.innerType,r);if(s.type==="intersection")return Ge(s.left,r)||Ge(s.right,r);if(s.type==="record"||s.type==="map")return Ge(s.keyType,r)||Ge(s.valueType,r);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ge(s.in,r)||Ge(s.out,r);if(s.type==="object"){for(const a in s.shape)if(Ge(s.shape[a],r))return!0;return!1}if(s.type==="union"){for(const a of s.options)if(Ge(a,r))return!0;return!1}if(s.type==="tuple"){for(const a of s.items)if(Ge(a,r))return!0;return!!(s.rest&&Ge(s.rest,r))}return!1}const mg=(e,t={})=>r=>{const s=Hc({...r,processors:t});return We(e,s),Kc(s,e),Qc(s,e)},Cs=(e,t,r={})=>s=>{const{libraryOptions:a,target:i}=s??{},o=Hc({...a??{},target:i,io:t,processors:r});return We(e,o),Kc(o,e),Qc(o,e)},hg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fg=(e,t,r,s)=>{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=hg[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}))])}},pg=(e,t,r,s)=>{r.type="boolean"},xg=(e,t,r,s)=>{r.not={}},gg=(e,t,r,s)=>{},yg=(e,t,r,s)=>{const a=e._zod.def,i=Fc(a.entries);i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},bg=(e,t,r,s)=>{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},vg=(e,t,r,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},jg=(e,t,r,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ng=(e,t,r,s)=>{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=We(i.element,t,{...s,path:[...s.path,"items"]})},wg=(e,t,r,s)=>{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]=We(o[d],t,{...s,path:[...s.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=We(i.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},Sg=(e,t,r,s)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>We(l,t,{...s,path:[...s.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=o:r.anyOf=o},kg=(e,t,r,s)=>{const a=e._zod.def,i=We(a.left,t,{...s,path:[...s.path,"allOf",0]}),o=We(a.right,t,{...s,path:[...s.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},Cg=(e,t,r,s)=>{const a=e._zod.def,i=We(a.innerType,t,s),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ag=(e,t,r,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType},Pg=(e,t,r,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},Eg=(e,t,r,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},_g=(e,t,r,s)=>{const a=e._zod.def;We(a.innerType,t,s);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},Ig=(e,t,r,s)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;We(o,t,s);const l=t.seen.get(e);l.ref=o},Tg=(e,t,r,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType,r.readOnly=!0},Jc=(e,t,r,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType};function Ua(){return Ua=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Ua.apply(null,arguments)}function Go(e,t){try{var r=e()}catch(s){return t(s)}return r&&r.then?r.then(void 0,t):r}function Fg(e,t){for(var r={};e.length;){var s=e[0],a=s.code,i=s.message,o=s.path.join(".");if(!r[o])if("unionErrors"in s){var l=s.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in s&&s.unionErrors.forEach(function(d){return d.errors.forEach(function(m){return e.push(m)})}),t){var c=r[o].types,u=c&&c[s.code];r[o]=Si(o,t,r,a,u?[].concat(u,s.message):s.message)}e.shift()}return r}function Dg(e,t){for(var r={},s=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(Ua({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=r[l].types,d=u&&u[a.code];r[l]=Si(l,t,r,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)s();return r}function zt(e,t,r){if(r===void 0&&(r={}),(function(s){return"_def"in s&&typeof s._def=="object"&&"typeName"in s._def})(e))return function(s,a,i){try{return Promise.resolve(Go(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](s,t)).then(function(o){return i.shouldUseNativeValidation&&qa({},i),{errors:{},values:r.raw?Object.assign({},s):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Oo(Fg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(s){return"_zod"in s&&typeof s._zod=="object"})(e))return function(s,a,i){try{return Promise.resolve(Go(function(){return Promise.resolve((r.mode==="sync"?Rf:Of)(e,s,t)).then(function(o){return i.shouldUseNativeValidation&&qa({},i),{errors:{},values:r.raw?Object.assign({},s):o}})},function(o){if((function(l){return l instanceof Ti})(o))return{values:{},errors:Oo(Dg(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 mn({label:e,required:t=!1,htmlFor:r}){return n.jsxs("label",{htmlFor:r,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?n.jsx("span",{className:"text-red-500",children:" *"}):null]})}const me=v.forwardRef(function({label:t,required:r=!1,error:s,id:a,className:i="",...o},l){const c=a??o.name;return n.jsxs("div",{children:[n.jsx(mn,{label:t,required:r,htmlFor:c}),n.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 ${s?"border-red-300":"border-slate-200"} ${i}`,...o}),s?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:s}):null]})}),Ot=v.forwardRef(function({label:t,required:r=!1,error:s,id:a,className:i="",children:o,...l},c){const u=a??l.name;return n.jsxs("div",{children:[n.jsx(mn,{label:t,required:r,htmlFor:u}),n.jsxs("div",{className:"relative",children:[n.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 ${s?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),n.jsx(Rg,{})]}),s?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:s}):null]})});function fr({step:e,title:t,muted:r=!1,children:s}){return n.jsxs("section",{className:"space-y-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[e?n.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,n.jsx("h3",{className:`text-sm font-semibold tracking-wide ${r?"text-slate-400":"text-gov-700"}`,children:t})]}),s]})}function Rg(){return n.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:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Qt({variant:e="error",title:t,message:r}){const s=e==="error"?"border-red-200 bg-red-50 text-red-800":"border-slate-200 bg-white text-slate-700";return n.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${s}`,role:"alert",children:[t?n.jsx("p",{className:"font-medium",children:t}):null,n.jsx("p",{className:t?"mt-1":void 0,children:r})]})}function st(e,t){var r;if(e instanceof yn){if(e.details){const s=(r=Object.values(e.details)[0])==null?void 0:r[0];if(s)return s}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Og=F("ZodISODateTime",(e,t)=>{qp.init(e,t),Ee.init(e,t)});function $g(e){return Ux(Og,e)}const Lg=F("ZodISODate",(e,t)=>{Vp.init(e,t),Ee.init(e,t)});function zg(e){return Zx(Lg,e)}const Mg=F("ZodISOTime",(e,t)=>{Bp.init(e,t),Ee.init(e,t)});function qg(e){return Wx(Mg,e)}const Vg=F("ZodISODuration",(e,t)=>{Up.init(e,t),Ee.init(e,t)});function Bg(e){return Yx(Vg,e)}const Ug=(e,t)=>{Ti.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Df(e,r)},flatten:{value:r=>Ff(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Va,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Va,2)}},isEmpty:{get(){return e.issues.length===0}}})},jt=F("ZodError",Ug,{Parent:Error}),Zg=Ms(jt),Wg=qs(jt),Yg=Vs(jt),Hg=Bs(jt),Kg=zf(jt),Qg=Mf(jt),Jg=qf(jt),Gg=Vf(jt),Xg=Bf(jt),ey=Uf(jt),ty=Zf(jt),ry=Wf(jt),Xo=new WeakMap;function Zs(e,t,r){const s=Object.getPrototypeOf(e);let a=Xo.get(s);if(a||(a=new Set,Xo.set(s,a)),!a.has(t)){a.add(t);for(const i in r){const o=r[i];Object.defineProperty(s,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 De=F("ZodType",(e,t)=>(Fe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cs(e,"input"),output:Cs(e,"output")}}),e.toJSONSchema=mg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,s)=>Zg(e,r,s,{callee:e.parse}),e.safeParse=(r,s)=>Yg(e,r,s),e.parseAsync=async(r,s)=>Wg(e,r,s,{callee:e.parseAsync}),e.safeParseAsync=async(r,s)=>Hg(e,r,s),e.spa=e.safeParseAsync,e.encode=(r,s)=>Kg(e,r,s),e.decode=(r,s)=>Qg(e,r,s),e.encodeAsync=async(r,s)=>Jg(e,r,s),e.decodeAsync=async(r,s)=>Gg(e,r,s),e.safeEncode=(r,s)=>Xg(e,r,s),e.safeDecode=(r,s)=>ey(e,r,s),e.safeEncodeAsync=async(r,s)=>ty(e,r,s),e.safeDecodeAsync=async(r,s)=>ry(e,r,s),Zs(e,"ZodType",{check(...r){const s=this.def;return this.clone(pr(s,{checks:[...s.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,s){return xr(this,r,s)},brand(){return this},register(r,s){return r.add(this,s),this},refine(r,s){return this.check(Hy(r,s))},superRefine(r,s){return this.check(Ky(r,s))},overwrite(r){return this.check(bn(r))},optional(){return rl(this)},exactOptional(){return Ry(this)},nullable(){return nl(this)},nullish(){return rl(nl(this))},nonoptional(r){return qy(this,r)},array(){return Cy(this)},or(r){return eu([this,r])},and(r){return _y(this,r)},transform(r){return sl(this,Fy(r))},default(r){return Ly(this,r)},prefault(r){return My(this,r)},catch(r){return By(this,r)},pipe(r){return sl(this,r)},readonly(){return Wy(this)},describe(r){const s=this.clone();return _n.add(s,{description:r}),s},meta(...r){if(r.length===0)return _n.get(this);const s=this.clone();return _n.add(s,r[0]),s},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=_n.get(e))==null?void 0:r.description},configurable:!0}),e)),Gc=F("_ZodString",(e,t)=>{Fi.init(e,t),De.init(e,t),e._zod.processJSONSchema=(s,a,i)=>fg(e,s,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(...s){return this.check(Jx(...s))},includes(...s){return this.check(eg(...s))},startsWith(...s){return this.check(tg(...s))},endsWith(...s){return this.check(rg(...s))},min(...s){return this.check(ks(...s))},max(...s){return this.check(Wc(...s))},length(...s){return this.check(Yc(...s))},nonempty(...s){return this.check(ks(1,...s))},lowercase(s){return this.check(Gx(s))},uppercase(s){return this.check(Xx(s))},trim(){return this.check(sg())},normalize(...s){return this.check(ng(...s))},toLowerCase(){return this.check(ag())},toUpperCase(){return this.check(ig())},slugify(){return this.check(og())}})}),ny=F("ZodString",(e,t)=>{Fi.init(e,t),Gc.init(e,t),e.email=r=>e.check(Zc(Xc,r)),e.url=r=>e.check(Px(ay,r)),e.jwt=r=>e.check(Bx(vy,r)),e.emoji=r=>e.check(Ex(iy,r)),e.guid=r=>e.check(Jo(el,r)),e.uuid=r=>e.check(Sx(ss,r)),e.uuidv4=r=>e.check(kx(ss,r)),e.uuidv6=r=>e.check(Cx(ss,r)),e.uuidv7=r=>e.check(Ax(ss,r)),e.nanoid=r=>e.check(_x(oy,r)),e.guid=r=>e.check(Jo(el,r)),e.cuid=r=>e.check(Ix(ly,r)),e.cuid2=r=>e.check(Tx(cy,r)),e.ulid=r=>e.check(Fx(uy,r)),e.base64=r=>e.check(Mx(gy,r)),e.base64url=r=>e.check(qx(yy,r)),e.xid=r=>e.check(Dx(dy,r)),e.ksuid=r=>e.check(Rx(my,r)),e.ipv4=r=>e.check(Ox(hy,r)),e.ipv6=r=>e.check($x(fy,r)),e.cidrv4=r=>e.check(Lx(py,r)),e.cidrv6=r=>e.check(zx(xy,r)),e.e164=r=>e.check(Vx(by,r)),e.datetime=r=>e.check($g(r)),e.date=r=>e.check(zg(r)),e.time=r=>e.check(qg(r)),e.duration=r=>e.check(Bg(r))});function T(e){return wx(ny,e)}const Ee=F("ZodStringFormat",(e,t)=>{ke.init(e,t),Gc.init(e,t)}),Xc=F("ZodEmail",(e,t)=>{Tp.init(e,t),Ee.init(e,t)});function sy(e){return Zc(Xc,e)}const el=F("ZodGUID",(e,t)=>{_p.init(e,t),Ee.init(e,t)}),ss=F("ZodUUID",(e,t)=>{Ip.init(e,t),Ee.init(e,t)}),ay=F("ZodURL",(e,t)=>{Fp.init(e,t),Ee.init(e,t)}),iy=F("ZodEmoji",(e,t)=>{Dp.init(e,t),Ee.init(e,t)}),oy=F("ZodNanoID",(e,t)=>{Rp.init(e,t),Ee.init(e,t)}),ly=F("ZodCUID",(e,t)=>{Op.init(e,t),Ee.init(e,t)}),cy=F("ZodCUID2",(e,t)=>{$p.init(e,t),Ee.init(e,t)}),uy=F("ZodULID",(e,t)=>{Lp.init(e,t),Ee.init(e,t)}),dy=F("ZodXID",(e,t)=>{zp.init(e,t),Ee.init(e,t)}),my=F("ZodKSUID",(e,t)=>{Mp.init(e,t),Ee.init(e,t)}),hy=F("ZodIPv4",(e,t)=>{Zp.init(e,t),Ee.init(e,t)}),fy=F("ZodIPv6",(e,t)=>{Wp.init(e,t),Ee.init(e,t)}),py=F("ZodCIDRv4",(e,t)=>{Yp.init(e,t),Ee.init(e,t)}),xy=F("ZodCIDRv6",(e,t)=>{Hp.init(e,t),Ee.init(e,t)}),gy=F("ZodBase64",(e,t)=>{Kp.init(e,t),Ee.init(e,t)}),yy=F("ZodBase64URL",(e,t)=>{Jp.init(e,t),Ee.init(e,t)}),by=F("ZodE164",(e,t)=>{Gp.init(e,t),Ee.init(e,t)}),vy=F("ZodJWT",(e,t)=>{ex.init(e,t),Ee.init(e,t)}),jy=F("ZodBoolean",(e,t)=>{tx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>pg(e,r,s)});function Hr(e){return Hx(jy,e)}const Ny=F("ZodUnknown",(e,t)=>{rx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>gg()});function tl(){return Kx(Ny)}const wy=F("ZodNever",(e,t)=>{nx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>xg(e,r,s)});function Sy(e){return Qx(wy,e)}const ky=F("ZodArray",(e,t)=>{sx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Ng(e,r,s,a),e.element=t.element,Zs(e,"ZodArray",{min(r,s){return this.check(ks(r,s))},nonempty(r){return this.check(ks(1,r))},max(r,s){return this.check(Wc(r,s))},length(r,s){return this.check(Yc(r,s))},unwrap(){return this.element}})});function Cy(e,t){return lg(ky,e,t)}const Ay=F("ZodObject",(e,t)=>{ix.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>wg(e,r,s,a),be(e,"shape",()=>t.shape),Zs(e,"ZodObject",{keyof(){return Ws(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:tl()})},loose(){return this.clone({...this._zod.def,catchall:tl()})},strict(){return this.clone({...this._zod.def,catchall:Sy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Af(this,r)},safeExtend(r){return Pf(this,r)},merge(r){return Ef(this,r)},pick(r){return kf(this,r)},omit(r){return Cf(this,r)},partial(...r){return _f(tu,this,r[0])},required(...r){return If(ru,this,r[0])}})});function Jt(e,t){const r={type:"object",shape:e??{},...ne(t)};return new Ay(r)}const Py=F("ZodUnion",(e,t)=>{ox.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Sg(e,r,s,a),e.options=t.options});function eu(e,t){return new Py({type:"union",options:e,...ne(t)})}const Ey=F("ZodIntersection",(e,t)=>{lx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>kg(e,r,s,a)});function _y(e,t){return new Ey({type:"intersection",left:e,right:t})}const Za=F("ZodEnum",(e,t)=>{cx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(s,a,i)=>yg(e,s,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(s,a)=>{const i={};for(const o of s)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Za({...t,checks:[],...ne(a),entries:i})},e.exclude=(s,a)=>{const i={...t.entries};for(const o of s)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Za({...t,checks:[],...ne(a),entries:i})}});function Ws(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Za({type:"enum",entries:r,...ne(t)})}const Iy=F("ZodLiteral",(e,t)=>{ux.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>bg(e,r,s),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 sa(e,t){return new Iy({type:"literal",values:Array.isArray(e)?e:[e],...ne(t)})}const Ty=F("ZodTransform",(e,t)=>{dx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>jg(e,r),e._zod.parse=(r,s)=>{if(s.direction==="backward")throw new Tc(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(On(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(On(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 Fy(e){return new Ty({type:"transform",transform:e})}const tu=F("ZodOptional",(e,t)=>{Uc.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Jc(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function rl(e){return new tu({type:"optional",innerType:e})}const Dy=F("ZodExactOptional",(e,t)=>{mx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Jc(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function Ry(e){return new Dy({type:"optional",innerType:e})}const Oy=F("ZodNullable",(e,t)=>{hx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Cg(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function nl(e){return new Oy({type:"nullable",innerType:e})}const $y=F("ZodDefault",(e,t)=>{fx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Pg(e,r,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ly(e,t){return new $y({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Rc(t)}})}const zy=F("ZodPrefault",(e,t)=>{px.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Eg(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function My(e,t){return new zy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Rc(t)}})}const ru=F("ZodNonOptional",(e,t)=>{xx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Ag(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function qy(e,t){return new ru({type:"nonoptional",innerType:e,...ne(t)})}const Vy=F("ZodCatch",(e,t)=>{gx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>_g(e,r,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function By(e,t){return new Vy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Uy=F("ZodPipe",(e,t)=>{yx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Ig(e,r,s,a),e.in=t.in,e.out=t.out});function sl(e,t){return new Uy({type:"pipe",in:e,out:t})}const Zy=F("ZodReadonly",(e,t)=>{bx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Tg(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function Wy(e){return new Zy({type:"readonly",innerType:e})}const Yy=F("ZodCustom",(e,t)=>{vx.init(e,t),De.init(e,t),e._zod.processJSONSchema=(r,s,a)=>vg(e,r)});function Hy(e,t={}){return cg(Yy,e,t)}function Ky(e,t){return ug(e,t)}const tr={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Di(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 Gt(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?(e.lastName||e.firstName).trim():`${e.firstName} ${e.lastName}`.trim()}function Mr(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function Rr(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)}`}const nu=["LLP","LLC","Corporation","S-Corp","Partnership"],su=["Sole Proprietorship"],Ri=["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"],Wa=10,au=Jt({accountType:Ws(["Business","Individual"]),firstName:T(),lastName:T(),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:sy("Enter a valid email"),countryCode:T().min(1),phoneNumber:T().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Wa,`Phone number must be ${Wa} 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")}).superRefine((e,t)=>{if(e.accountType==="Business"){e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Business name is required"});return}e.firstName.trim()||t.addIssue({code:"custom",path:["firstName"],message:"First name is required"}),e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Last name is required"})});function Qy(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(-Wa)}}function al(e){const{countryCode:t,national:r}=Qy(e.phoneNumber),s=e.accountType==="Individual",a=(e.lastName||e.firstName||"").trim();return{accountType:s?"Individual":"Business",firstName:s?e.firstName??"":"",lastName:s?e.lastName??"":a,tradeName:s?"":e.tradeName??"",ein:Mr(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 iu(e,t,r,s){if(e!==t){if(e==="Business"&&t==="Individual"){r("firstName",""),r("lastName",s),r("tradeName","");return}e==="Individual"&&t==="Business"&&(r("firstName",""),r("lastName",s))}}function ou(e){const t=e.lastName.trim();return e.accountType==="Business"?{accountType:e.accountType,firstName:"",lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName.trim(),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}:{accountType:e.accountType,firstName:e.firstName.trim(),lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,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 Jy(e){const{idNumber:t,...r}=ou(e);return r}function qr(e,t){const r=e==null?void 0:e.from;return r&&r.startsWith("/")&&!r.startsWith("//")?r:t}function Gy(){var A,I,_,L,ie,U,Q,te,H,G,J,he,Te;const e=Se(),t=we(),r=vt(),{data:s=[]}=ve({queryKey:["entities","mine"],queryFn:async()=>(await pi({pageNumber:1,pageSize:100})).items}),[a,i]=v.useState(null),[o,l]=v.useState(!1),c=s.length===0,u=c?"/create-entity":"/dashboard",d=qr(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:g,setValue:p,getValues:b,formState:{errors:x}}=$t({resolver:zt(au),shouldUnregister:!1,defaultValues:{accountType:"Individual",firstName:"",lastName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),S=g("accountType"),w=g("entityType"),N=S==="Individual"?su:nu,E=pe=>{const Re=b("accountType");if(Re===pe)return;const oe=b("lastName");iu(Re,pe,p,oe),p("accountType",pe),queueMicrotask(()=>{p("lastName",oe),p("firstName",""),Re==="Business"&&pe==="Individual"&&p("tradeName","")})};v.useEffect(()=>{N.includes(w)||p("entityType",S==="Individual"?"Sole Proprietorship":"LLP")},[S,w,N,p]);const D=f(async pe=>{i(null),l(!0);try{await Oh(ou(pe)),await r.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(Re){i(st(Re,"Unable to save entity. Please try again."))}finally{l(!1)}});return n.jsxs("form",{onSubmit:D,noValidate:!0,className:"space-y-8",children:[a?n.jsx(Qt,{message:a}):null,n.jsx(fr,{step:1,title:"ENTITY DETAILS",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{children:[n.jsx(mn,{label:"Account Type",required:!0}),n.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:"Business",checked:S==="Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>E("Business")}),"Business"]}),n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:"Individual",checked:S==="Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>E("Individual")}),"Individual"]})]})]}),n.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:S==="Individual"?n.jsxs(n.Fragment,{children:[n.jsx(me,{label:"First name",required:!0,placeholder:"Enter",error:(A=x.firstName)==null?void 0:A.message,...h("firstName")},"entity-first-name"),n.jsx(me,{label:"Last name",required:!0,placeholder:"Enter",error:(I=x.lastName)==null?void 0:I.message,...h("lastName")},"entity-last-name")]}):n.jsxs(n.Fragment,{children:[n.jsx(me,{label:"Business Name",required:!0,placeholder:"Enter",error:(_=x.lastName)==null?void 0:_.message,...h("lastName")},"entity-business-name"),n.jsx(me,{label:"Trade Name, if any",placeholder:"Enter",error:(L=x.tradeName)==null?void 0:L.message,...h("tradeName")},"entity-trade-name")]})}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"EIN",required:!0,placeholder:"**-*******",maxLength:10,error:(ie=x.ein)==null?void 0:ie.message,...h("ein")}),n.jsx(Ot,{label:"Entity Type",required:!0,error:(U=x.entityType)==null?void 0:U.message,...h("entityType"),children:N.map(pe=>n.jsx("option",{value:pe,children:pe},pe))})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(Q=x.email)==null?void 0:Q.message,...h("email")}),n.jsxs("div",{children:[n.jsx(mn,{label:"Phone Number",required:!0}),n.jsxs("div",{className:"flex gap-2",children:[n.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:[n.jsx("option",{value:"+1",children:"+1"}),n.jsx("option",{value:"+91",children:"+91"})]}),n.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?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.phoneNumber.message}):null]})]})]})}),n.jsx("div",{className:"border-t border-slate-200"}),n.jsx(fr,{title:"ADDRESS DETAILS",muted:!0,children:n.jsxs("div",{className:"space-y-5",children:[n.jsx(me,{label:"Address Line 1",required:!0,error:(te=x.address1)==null?void 0:te.message,...h("address1")}),n.jsx(me,{label:"Address Line 2",error:(H=x.address2)==null?void 0:H.message,...h("address2")}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"City",required:!0,error:(G=x.city)==null?void 0:G.message,...h("city")}),n.jsxs(Ot,{label:"State",required:!0,error:(J=x.state)==null?void 0:J.message,...h("state"),children:[n.jsx("option",{value:"",children:"Select"}),Ri.map(pe=>n.jsx("option",{value:pe,children:pe},pe))]})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"ZIP Code",required:!0,error:(he=x.zipCode)==null?void 0:he.message,...h("zipCode")}),n.jsxs(Ot,{label:"Country",required:!0,error:(Te=x.country)==null?void 0:Te.message,...h("country"),children:[n.jsx("option",{value:"United States",children:"United States"}),n.jsx("option",{value:"Canada",children:"Canada"})]})]})]})}),n.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-200 pt-6",children:[n.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"}),n.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 Oi(){const e=Se(),t=we(),r=qr(t.state,"/create-entity");return n.jsxs("div",{className:"relative min-h-full bg-slate-100/80 px-4 py-8 sm:px-6 sm:py-10",children:[n.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:[n.jsx(Xy,{}),"Back"]}),n.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:n.jsx(Gy,{})})]})}function Xy(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function eb(e,t){const r=new URLSearchParams({entityId:String(e)});return t!==void 0&&r.set("taxYear",String(t)),fe(`/portal/dashboard?${r}`)}function tb(e,t,r){const s=new URLSearchParams({entityId:String(e),category:t,taxYear:String(r)});return fe(`/portal/dashboard/summary?${s}`)}function rb(e,t,r){const s=new URLSearchParams({entityId:String(e),month:String(t)});return r!==void 0&&s.set("year",String(r)),fe(`/portal/dashboard/monthly-overview?${s}`)}function nb({entityId:e,search:t,taxYear:r,status:s,page:a=1,pageSize:i=tt}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),r&&o.set("taxYear",r),s&&s!=="all"&&o.set("status",s),fe(`/portal/dashboard/payments?${o}`)}function il({entityCount:e,showPaymentActions:t=!0}){const r=Se(),{enabledPayments:s}=Lr();return n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-wrap gap-3",children:[t&&s.includes("federal")&&n.jsxs("button",{type:"button",onClick:()=>r("/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:[n.jsx(aa,{}),"Add Federal Payments"]}),t&&s.includes("state")&&n.jsxs("button",{type:"button",onClick:()=>r("/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:[n.jsx(aa,{}),"Add State Payment"]}),t&&n.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:[n.jsx(aa,{}),"Add Local Payment",n.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs("button",{type:"button",onClick:()=>r("/entities"),className:"inline-flex items-center gap-1.5 rounded-[14px] border border-solid border-[#e5e7eb] bg-[#f9fafb] px-[15px] py-[9px] text-xs font-bold text-[#364153] transition hover:bg-slate-100",title:"View organizations",children:[n.jsx(sb,{}),"Entities (",e,")"]}),n.jsxs("button",{type:"button",onClick:()=>r("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-1.5 rounded-[14px] border-[1.5px] border-dashed border-[#16a34a] bg-[#f0fdf4] px-[15.5px] py-[9.5px] text-xs font-bold text-[#16a34a] transition hover:bg-green-50",children:[n.jsx(ab,{}),"Add Entity"]})]})]})}function aa(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function sb(){return n.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#364153]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})}function ab(){return n.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#16a34a]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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 ib({title:e,description:t,buttonLabel:r,onAdd:s,comingSoon:a=!1}){return n.jsxs("article",{className:"flex flex-col rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[n.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),n.jsx("p",{className:"mx-auto mt-4 max-w-xs text-sm leading-relaxed text-slate-500",children:t}),a?n.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"}):n.jsxs("button",{type:"button",onClick:s,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:[n.jsx(ob,{}),r]})]})}function ob(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Vr({label:e="Loading…"}){return n.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:n.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-slate-500",children:[n.jsx(lb,{}),n.jsx("span",{children:e})]})})}function lb(){return n.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:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.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 cb={Draft:"Draft"};function ub(e){switch((e??cb.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 Yn(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function db(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 $i="drafts";function Je(){return Ys($i)}function Ys(e){return`/payments?tab=${e}`}function lu(e){return e==="failed"?"rejected":e}function mb(e,t){return t.trim().toLowerCase()==="draft"?$i:lu(e)}const hb=["January","February","March","April","May","June","July","August","September","October","November","December"];function fb({entityId:e,initialOverview:t,isDashboardLoading:r=!1}){const s=Se(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=v.useState(null);v.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=ve({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>rb(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,g=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:xb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:gb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:yb,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Failed",amount:h.failed,icon:bb,iconClassName:"rounded-full bg-red-50 text-red-500",amountClassName:"text-red-500"}];return n.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?n.jsx(Vr,{}):null,n.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-4",children:[n.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-slate-500",children:"Overview of Month"}),n.jsxs("div",{className:"relative",children:[n.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:hb.map((p,b)=>n.jsx("option",{value:b+1,children:p},p))}),n.jsx(pb,{className:"pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gov-600"})]})]}),n.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-4",children:g.map(p=>{const b=p.icon;return n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center ${p.iconClassName}`,children:n.jsx(b,{})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-xs leading-4 text-slate-500",children:p.label}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsx("p",{className:`text-xl font-bold leading-7 ${p.amountClassName}`,children:Yn(p.amount)}),n.jsx("button",{type:"button",onClick:()=>s(Ys(lu(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 pb({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function xb(){return n.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[n.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"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 14.25v-1.5M11.25 13.5h1.5"})]})}function gb(){return n.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function yb(){return n.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})}function bb(){return n.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.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 ol(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function vb(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 ll(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const jb={primary:"bg-brand-600 text-white hover:bg-brand-700 focus-visible:ring-brand-500 disabled:bg-brand-600/60",secondary:"border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 focus-visible:ring-slate-400",ghost:"text-slate-600 hover:bg-slate-100 focus-visible:ring-slate-400"};function Nb({variant:e="primary",isLoading:t=!1,className:r="",children:s,disabled:a,...i}){return n.jsx("button",{type:"button",className:`inline-flex h-10 items-center justify-center rounded-lg px-4 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed ${jb[e]} ${r}`,disabled:a||t,...i,children:t?"Please wait…":s})}const wb=[10,20,50,100];function Sb(e,t){const r=e.trim();if(!/^\d+$/.test(r))return null;const s=Number(r);return!Number.isInteger(s)||s<1||s>t?null:s}function kb(){return n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:n.jsx("path",{d:"M12.5 4.5 7 10l5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cb(){return n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:n.jsx("path",{d:"M7.5 4.5 13 10l-5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function vn({page:e,pageSize:t,totalCount:r,onPageChange:s,onPageSizeChange:a,pageSizeOptions:i=wb,disabled:o=!1,className:l=""}){const c=t>0?Math.max(1,Math.ceil(r/t)):1,u=r===0?0:c,d=e>1,m=u>0&&e<u,h=r===0?0:(e-1)*t+1,f=Math.min(e*t,r),[g,p]=v.useState(String(e)),b=v.useRef(g);b.current=g,v.useEffect(()=>{p(String(e))},[e]);function x(w=b.current){if(o||u===0){p(String(e));return}const N=Sb(w,u);if(N===null){p(String(e));return}if(N===e){p(String(e));return}s(N)}function S(w){w.key==="Enter"&&(w.preventDefault(),x(w.currentTarget.value))}return r===0?null:n.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 border-t border-slate-200 bg-white px-6 py-3 ${l}`,children:[n.jsxs("p",{className:"text-sm text-slate-500",children:["Showing ",n.jsx("span",{className:"font-medium text-slate-700",children:h}),"–",n.jsx("span",{className:"font-medium text-slate-700",children:f})," of ",n.jsx("span",{className:"font-medium text-slate-700",children:r})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a?n.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[n.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),n.jsx("select",{value:t,disabled:o,onChange:w=>a(Number(w.target.value)),className:"rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(w=>n.jsx("option",{value:w,children:w},w))})]}):null,n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{type:"button",disabled:o||!d,onClick:()=>s(e-1),"aria-label":"Previous page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:n.jsx(kb,{})}),n.jsx("span",{className:"min-w-[5.5rem] text-center text-sm text-slate-600",children:u===0?"—":`Page ${e} of ${u}`}),n.jsx("button",{type:"button",disabled:o||!m,onClick:()=>s(e+1),"aria-label":"Next page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:n.jsx(Cb,{})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("label",{htmlFor:"pagination-go-to-page",className:"whitespace-nowrap text-sm text-slate-600",children:"Go to page"}),n.jsx("input",{id:"pagination-go-to-page",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:g,disabled:o||u===0,onChange:w=>p(w.target.value),onKeyDown:S,"aria-label":"Go to page number",className:"h-9 w-14 rounded-lg border border-slate-200 bg-white px-2 text-center text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"}),n.jsx(Nb,{type:"button",variant:"secondary",disabled:o||u===0,className:"h-9 px-3",onMouseDown:w=>{w.preventDefault()},onClick:()=>x(),children:"Go"})]})]})]})}const Ab=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],cl={total:0,page:1,pageSize:tt,items:[]};function Pb({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 n.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r[t]}`,children:e})}function Eb({entityId:e,initialPayments:t,isDashboardLoading:r=!1}){const s=Se(),[a,i]=v.useState(""),[o,l]=v.useState(""),[c,u]=v.useState(""),[d,m]=v.useState("all"),[h,f]=v.useState(1),[g,p]=v.useState(tt);v.useEffect(()=>{const _=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(_)},[a]),v.useEffect(()=>{f(1)},[o,c,d,e,g]);const b=!!o||!!c||d!=="all",x=e!==null&&(b||h>1||g!==tt),{data:S,isFetching:w}=ve({queryKey:["dashboard","payments",e,o,c,d,h,g],queryFn:()=>nb({entityId:e,search:o||void 0,taxYear:c||void 0,status:d,page:h,pageSize:g}),enabled:x,placeholderData:_=>_}),N=v.useMemo(()=>x?S??cl:t&&h===1&&g===tt?t:cl,[x,S,t,h,g]),E=v.useMemo(()=>N.items.map(vb),[N.items]),D=v.useMemo(()=>{const _=new Date().getFullYear();return[_,_-1,_-2].map(String)},[]),A=r||x&&w,I=(N.page-1)*N.pageSize;return n.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[A?n.jsx(Vr,{label:"Loading payments…"}):null,n.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-6 py-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:n.jsx(Ib,{})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-bold text-slate-900",children:"My Payments"}),n.jsxs("p",{className:"text-xs text-slate-500",children:[N.total," total payments"]})]})]})}),n.jsx("div",{className:"border-b border-slate-200 p-6",children:n.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:[n.jsxs("div",{children:[n.jsx("label",{htmlFor:"payment-search",className:"mb-1.5 block text-sm text-slate-600",children:"Search by State/Form Type"}),n.jsxs("div",{className:"relative",children:[n.jsx(_b,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),n.jsx("input",{id:"payment-search",type:"text",value:a,onChange:_=>i(_.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"})]})]}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"tax-period-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Tax Period"}),n.jsxs("div",{className:"relative",children:[n.jsxs("select",{id:"tax-period-filter",value:c,onChange:_=>u(_.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:[n.jsx("option",{value:"",children:"Select Year"}),D.map(_=>n.jsx("option",{value:_,children:_},_))]}),n.jsx(ul,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),n.jsxs("div",{className:"relative",children:[n.jsx("select",{id:"status-filter",value:d,onChange:_=>m(_.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:Ab.map(_=>n.jsx("option",{value:_.value,children:_.label},_.value))}),n.jsx(ul,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]})]})}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[n.jsx("th",{className:"px-6 py-3",children:"ID"}),n.jsx("th",{className:"px-6 py-3",children:"Jurisdiction / Type"}),n.jsx("th",{className:"px-6 py-3",children:"Period"}),n.jsx("th",{className:"px-6 py-3",children:"Amount"}),n.jsx("th",{className:"px-6 py-3",children:"Payment"}),n.jsx("th",{className:"px-6 py-3",children:"Status"}),n.jsx("th",{className:"px-6 py-3",children:"Form Type"}),n.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),n.jsx("tbody",{children:!A&&E.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:b?"No payments match your filters.":"No payments yet."})}):E.map((_,L)=>n.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[n.jsxs("td",{className:"px-6 py-4 font-medium text-slate-900",children:["#",I+L+1]}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:_.jurisdiction}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:_.period}),n.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Yn(_.amount)}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:_.paymentDate}),n.jsx("td",{className:"px-6 py-4",children:n.jsx(Pb,{label:_.statusLabel,status:_.status})}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:_.formType}),n.jsx("td",{className:"px-6 py-4",children:n.jsx("button",{type:"button",onClick:()=>s(Ys(mb(_.status,_.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${_.category}-${_.id}`))})]})}),n.jsx(vn,{page:h,pageSize:g,totalCount:N.total,onPageChange:f,onPageSizeChange:p,disabled:A||e===null})]})}function _b({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.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 ul({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Ib(){return n.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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 ia({entityId:e,category:t,title:r,subtitlePrefix:s,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:u=!1}){const[d,m]=v.useState(a);if(v.useEffect(()=>{m(a)},[e,a]),u)return n.jsxs("article",{className:"flex min-h-[220px] flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[n.jsxs("div",{className:"mb-4",children:[n.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),n.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:s})]}),n.jsx("div",{className:"flex flex-1 items-center justify-center",children:n.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:g}=ve({queryKey:["dashboard","summary",e,t,d],queryFn:()=>tb(e,t,d),enabled:e!==null&&!h,placeholderData:S=>S}),p=h?o?ol(o):ll():f?ol(f):ll(),b=db(p),x=l||g&&!h;return n.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[x?n.jsx(Vr,{}):null,n.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),n.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[s," (",p.count,")"]})]}),n.jsxs("div",{className:"relative shrink-0",children:[n.jsx("select",{value:d,onChange:S=>m(Number(S.target.value)),disabled:x,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(S=>n.jsxs("option",{value:S,children:["TY ",S]},S))}),n.jsx(Tb,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"})]})]}),n.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:c.map(S=>n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${S.dotClassName}`}),n.jsx("span",{className:"text-xs text-slate-500",children:S.label})]}),n.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Yn(p[S.key])})]},S.label))}),n.jsxs("div",{className:"mt-5",children:[n.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:b.map((S,w)=>S.width>0?n.jsx("span",{className:`${S.color} h-full`,style:{width:`${S.width}%`}},w):null)}),n.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function Tb({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.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."},Db=[{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"}],rr=new Date().getFullYear(),oa=[rr,rr-1,rr-2],Rb=[{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"}],Ob=[{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"}],$b=[{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 Li(){const e=Se(),{entities:t,selectedEntity:r,enabledPayments:s}=Lr(),a=(r==null?void 0:r.entityId)??null,{data:i,isLoading:o}=ve({queryKey:["dashboard",a,rr],queryFn:()=>eb(a,rr),enabled:a!==null});return!o&&i&&!i.hasPayments?n.jsxs("div",{className:"space-y-6",children:[n.jsx(il,{entityCount:t.length,showPaymentActions:!1}),n.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:Db.filter(l=>l.key==="local"||s.includes(l.key)).map(l=>n.jsx(ib,{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))})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsx(il,{entityCount:t.length}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.includes("federal")&&n.jsx(ia,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:rr,taxYearOptions:oa,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:Rb}),s.includes("state")&&n.jsx(ia,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:rr,taxYearOptions:oa,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:Ob}),n.jsx(ia,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:rr,taxYearOptions:oa,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:$b,comingSoon:!0})]}),n.jsx(fb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),n.jsx(Eb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}function zi(){const{selectedEntity:e,setSelectedEntityId:t,refetchEntities:r}=Lr(),s=Se(),[a,i]=v.useState(""),[o,l]=v.useState(""),[c,u]=v.useState(1),[d,m]=v.useState(tt);v.useEffect(()=>{const N=window.setTimeout(()=>l(a.trim()),300);return()=>window.clearTimeout(N)},[a]),v.useEffect(()=>{u(1)},[o,d]);const{data:h,isLoading:f,isFetching:g,isError:p}=ve({queryKey:["entities","mine","paged",o,c,d],queryFn:()=>pi({search:o||void 0,pageNumber:c,pageSize:d}),placeholderData:N=>N}),b=(h==null?void 0:h.items)??[],x=(h==null?void 0:h.totalCount)??0,S=g,w=async N=>{t(N.entityId),await r(),s("/dashboard",{replace:!0})};return n.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[n.jsxs("button",{type:"button",onClick:()=>s("/dashboard"),className:"inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5]",children:[n.jsx(zb,{}),"Back"]}),n.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>s("/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:[n.jsx(Mb,{}),"Add Entity"]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-[11px] font-semibold text-[#6a7282]",children:"Search by Entity Name/Email/EIN"}),n.jsx("input",{type:"search",value:a,onChange:N=>i(N.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"})]})]}),n.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-black/[0.12] bg-white",children:[S?n.jsx(Vr,{label:"Loading organizations…"}):null,n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"min-w-full text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"bg-[#f8f9fb]",children:[n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Client Name"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"EIN Number"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Email"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Phone"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Business Type"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Status"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Joined Date"}),n.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Action"})]})}),n.jsx("tbody",{children:f&&!h?n.jsx("tr",{children:n.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Loading organizations…"})}):p?n.jsx("tr",{children:n.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Unable to load organizations."})}):b.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:o?"No organizations match your search.":"No organizations yet."})}):b.map(N=>n.jsx(Lb,{entity:N,isSelected:N.entityId===(e==null?void 0:e.entityId),onSelect:()=>w(N)},N.entityId))})]})}),n.jsx(vn,{page:c,pageSize:d,totalCount:x,onPageChange:u,onPageSizeChange:m,disabled:f||g})]})]})}function Lb({entity:e,isSelected:t,onSelect:r}){var l;const s=Gt(e),a=Di(s),i=((l=e.status)==null?void 0:l.toLowerCase())==="active",o=e.createdAt?new Date(e.createdAt).toISOString().slice(0,10):"—";return n.jsxs("tr",{className:["border-b border-[#e0e0e0] last:border-b-0 transition-colors",t?"bg-[#f0f7ff]":"hover:bg-slate-50"].join(" "),children:[n.jsx("td",{className:"px-4 py-2.5",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.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}),n.jsx("span",{className:"font-semibold text-[#1e2939] text-[13px]",children:s})]})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:Mr(e.idNumber)})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-[12px] text-[#374151]",children:e.email||"—"})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-[12px] text-[#374151]",children:e.phoneNumber||"—"})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-[12px] text-[#374151]",children:e.entityType||"—"})}),n.jsx("td",{className:"px-4 py-2.5",children:n.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"})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-[12px] text-[#374151]",children:o})}),n.jsx("td",{className:"px-4 py-2.5",children:n.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 zb(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function Mb(){return n.jsx("svg",{className:"h-[15px] w-[15px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Mi(e){return fe(`/portal/federal-payments/${e}`)}function qb(e){return fe(`/portal/federal-payments/form-types?entityId=${e}`)}function Vb(e){const t=new URLSearchParams({formType:e});return fe(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function qi(e){return fe("/portal/federal-payments",{method:"POST",body:e})}function Vi(e,t){return fe(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function Bb(e){return fe(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function Ub(e){return Un(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function Zb(e){return Un(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function Wb(e){return Un(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function Yb(e){return Un(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function Hb({entityId:e,status:t,category:r="all",pageNumber:s=1,pageSize:a=tt}){const i=new URLSearchParams({entityId:String(e),pageNumber:String(s),pageSize:String(a)});return t&&i.set("status",t),r&&r!=="all"?i.set("category",r):r==="all"&&i.set("category","all"),fe(`/portal/remittance-payments?${i}`)}function Kb(e,t="all"){const r=new URLSearchParams({entityId:String(e)});return t&&r.set("category",t),fe(`/portal/remittance-payments/status-counts?${r}`)}function Qb(e){return fe("/portal/state-payments/states",{signal:e})}function Jb(e,t,r){const s=new URLSearchParams({entityId:String(e),state:t});return fe(`/portal/state-payments/payment-reasons?${s}`,{signal:r})}function Gb(e,t,r,s){const a=new URLSearchParams({entityId:String(e),state:t,reason:r});return fe(`/portal/state-payments/validation-metadata?${a}`,{signal:s})}function cu(e){return fe(`/portal/state-payments/${e}`)}function Xb(e){return fe("/portal/state-payments",{method:"POST",body:e})}function e0(e,t){return fe(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function t0(e){return fe(`/portal/state-payments/${e}/submit`,{method:"POST"})}function r0({open:e,title:t,html:r,isLoading:s=!1,error:a=null,downloadFileName:i="payment.pdf",onDownload:o,onClose:l}){const[c,u]=v.useState(!1);v.useEffect(()=>{if(!e)return;const m=h=>{h.key==="Escape"&&l()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,l]);const d=async()=>{if(!(!o||c)){u(!0);try{const m=await o(),h=URL.createObjectURL(m),f=document.createElement("a");f.href=h,f.download=i,f.click(),URL.revokeObjectURL(h)}finally{u(!1)}}};return e?n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[n.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:l}),n.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"payment-pdf-title",className:"relative flex h-[90vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 px-5 py-4",children:[n.jsx("h2",{id:"payment-pdf-title",className:"text-base font-semibold text-slate-900",children:t}),n.jsxs("div",{className:"flex items-center gap-2",children:[o?n.jsx("button",{type:"button",onClick:()=>void d(),disabled:c||s||!!a,className:"rounded-lg border border-gov-200 bg-gov-50 px-3 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100 disabled:opacity-60",children:c?"Downloading…":"Download"}):null,n.jsx("button",{type:"button",onClick:l,className:"rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Close"})]})]}),n.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:s?n.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"Loading…"}):a?n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-red-600",children:a}):r?n.jsx("iframe",{title:t,srcDoc:r,sandbox:"",className:"h-full w-full border-0 bg-white"}):n.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"No content available."})})]})]}):null}function la({onViewPdf:e,isViewPdfLoading:t}){return n.jsx("button",{type:"button",onClick:e,disabled:t,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 disabled:opacity-60",children:t?"Loading…":"View PDF"})}function n0({actionType:e,onView:t,onViewPdf:r,onEdit:s,onSubmit:a,isSubmitting:i=!1,isViewPdfLoading:o=!1}){return e==="draft-actions"?n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),n.jsx("button",{type:"button",onClick:s,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"}),n.jsx("button",{type:"button",onClick:a,disabled:i,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:i?"Submitting…":"Submit"})]}):e==="view-pdf"?n.jsx(la,{onViewPdf:r,isViewPdfLoading:o}):e==="rejected-actions"?n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),n.jsx(la,{onViewPdf:r,isViewPdfLoading:o}),n.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"})]}):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),n.jsx(la,{onViewPdf:r,isViewPdfLoading:o})]})}function s0(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),s=Number.parseInt(e.slice(4,6),10);return Number.isNaN(s)||s<1||s>12?e:`Q${Math.ceil(s/3)} ${r}`}function a0(e){return{id:e.id,category:e.category,referenceNo:e.referenceNumber??"—",jurisdiction:e.jurisdiction,period:s0(e.taxPeriod),amount:e.amount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:ub(e.status)}}function i0({className:e,...t}){return n.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:[n.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"}),n.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"}),n.jsx("path",{d:"M6.25 5.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M10 8.125H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M10 10.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}function o0({className:e,...t}){return n.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:[n.jsxs("g",{clipPath:"url(#scheduled-tab-icon-clip)",children:[n.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"}),n.jsx("path",{d:"M7.5 3.75V7.5L10 8.75",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("defs",{children:n.jsx("clipPath",{id:"scheduled-tab-icon-clip",children:n.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function l0({className:e,...t}){return n.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:n.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 c0({className:e,...t}){return n.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:[n.jsxs("g",{clipPath:"url(#rejected-tab-icon-clip)",children:[n.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"}),n.jsx("path",{d:"M7.5 5V7.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M7.5 10H7.50625",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("defs",{children:n.jsx("clipPath",{id:"rejected-tab-icon-clip",children:n.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function u0({className:e,...t}){return n.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:[n.jsxs("g",{clipPath:"url(#paid-tab-icon-clip)",children:[n.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"}),n.jsx("path",{d:"M5.625 7.5L6.875 8.75L9.375 6.25",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("defs",{children:n.jsx("clipPath",{id:"paid-tab-icon-clip",children:n.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}const uu=[{key:"drafts",label:"DRAFTS",Icon:i0,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:o0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:l0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:c0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:u0,iconClassName:"text-green-500"}],d0={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 dl(e){return e!==null&&uu.some(t=>t.key===e)}function Bi({paymentsMode:e="all"}){var Ne;const t=Se(),r=vt(),[s]=_m(),{selectedEntity:a}=mt(),{onPaymentRequired:i}=Lr(),o=(a==null?void 0:a.entityId)??null,l=s.get("tab"),[c,u]=v.useState(dl(l)?l:$i),[d,m]=v.useState(e==="all"?"all":e),h=e!=="all"?e:d,[f,g]=v.useState(1),[p,b]=v.useState(tt),[x,S]=v.useState(null),[w,N]=v.useState(null),[E,D]=v.useState(null);v.useEffect(()=>{dl(l)&&u(l)},[l]),v.useEffect(()=>{g(1),b(tt)},[c,o,d]),v.useEffect(()=>{g(1)},[p]);const A=d0[c],I=ve({queryKey:["remittance-payments","list",o,c,h,f,p],queryFn:()=>Hb({entityId:o,status:c,category:h,pageNumber:f,pageSize:p}),enabled:o!==null,placeholderData:R=>R}),_=ve({queryKey:["remittance-payments","status-counts",o,h],queryFn:()=>Kb(o,h),enabled:o!==null}),L=I.isLoading,ie=I.isFetching,U=o!==null&&ie,Q=v.useMemo(()=>{var R,ye,se,Ce,Ye;return{drafts:((R=_.data)==null?void 0:R.drafts)??0,scheduled:((ye=_.data)==null?void 0:ye.scheduled)??0,submitted:((se=_.data)==null?void 0:se.submitted)??0,rejected:((Ce=_.data)==null?void 0:Ce.rejected)??0,paid:((Ye=_.data)==null?void 0:Ye.paid)??0}},[_.data]),te=v.useMemo(()=>{var R;return(((R=I.data)==null?void 0:R.items)??[]).map(a0)},[I.data]),H=((Ne=I.data)==null?void 0:Ne.totalCount)??0,G=vh({mutationFn:async R=>{try{R.category==="federal"?await Bb(R.id):await t0(R.id)}catch(ye){if(ye instanceof yn&&ye.status===402&&i){const se=ye.extensions,Ce={paymentType:(se==null?void 0:se.paymentType)??R.category,paymentId:(se==null?void 0:se.paymentId)??R.id,expectedAmount:(se==null?void 0:se.expectedAmount)??"0.00",currency:(se==null?void 0:se.currency)??"USD",federalRecordCount:(se==null?void 0:se.federalRecordCount)??0,stateRecordCount:(se==null?void 0:se.stateRecordCount)??0,feePerFederal:(se==null?void 0:se.feePerFederal)??null,feePerState:(se==null?void 0:se.feePerState)??null};i(Ce);return}throw ye}},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:()=>S(null),onSettled:()=>S(null)});v.useEffect(()=>{const R=async()=>{await r.invalidateQueries({queryKey:["remittance-payments"]}),await r.invalidateQueries({queryKey:["dashboard"]}),await r.invalidateQueries({queryKey:["federal-payments"]}),await r.invalidateQueries({queryKey:["state-payments"]})};return window.addEventListener(ei,R),()=>window.removeEventListener(ei,R)},[r]);const J=R=>{S(`${R.category}-${R.id}`),G.mutate(R)},he=R=>{R.category==="federal"?t(`/payments/federal/${R.id}/view`):t(`/payments/state/${R.id}/view`)},Te=R=>{R.category==="federal"?t(`/payments/federal/${R.id}/edit`):t(`/payments/state/${R.id}/edit`)},pe=async R=>{const ye=`${R.category}-${R.id}`,se=`payment-${R.referenceNo}.pdf`;N(ye),D({title:`Payment PDF — ${R.referenceNo}`,html:null,category:R.category,paymentId:R.id,downloadFileName:se,isLoading:!0,error:null});try{const Ce=R.category==="federal"?await Wb(R.id):await Yb(R.id);D({title:`Payment PDF — ${R.referenceNo}`,html:Ce,category:R.category,paymentId:R.id,downloadFileName:se,isLoading:!1,error:null})}catch(Ce){D({title:`Payment PDF — ${R.referenceNo}`,html:null,category:R.category,paymentId:R.id,downloadFileName:se,isLoading:!1,error:st(Ce,"Unable to load payment PDF.")})}finally{N(null)}},Re=async()=>{if(!E)throw new Error("No payment selected");return E.category==="federal"?Ub(E.paymentId):Zb(E.paymentId)},oe=()=>D(null);return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=="state"&&n.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:[n.jsx(ca,{}),"Add Federal Payment"]}),e!=="federal"&&n.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:[n.jsx(ca,{}),"Add State Payment"]}),e==="all"&&n.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:[n.jsx(ca,{}),"Add Local Payments",n.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),n.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[U?n.jsx(Vr,{label:"Loading payments…"}):null,n.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:uu.map(R=>{const ye=c===R.key,se=R.Icon;return n.jsxs("button",{type:"button",onClick:()=>{u(R.key),t(Ys(R.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 ${ye?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[n.jsx(se,{className:`shrink-0 ${R.iconClassName}`}),R.label," (",Q[R.key],")"]},R.key)})}),n.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[n.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),n.jsxs("select",{value:d,onChange:R=>m(R.target.value),disabled:e!=="all",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 disabled:opacity-60",children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"federal",children:"Federal"}),n.jsx("option",{value:"state",children:"State"}),n.jsx("option",{value:"local",disabled:!0,children:"Local (Coming Soon)"})]})]}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[n.jsx("thead",{children:n.jsx("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:A.columns.map(R=>n.jsx("th",{className:"px-6 py-3",children:R},R))})}),n.jsx("tbody",{children:L&&!I.data?n.jsx("tr",{children:n.jsx("td",{colSpan:A.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):te.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:A.columns.length,className:"px-6 py-12 text-center text-slate-500",children:A.emptyMessage})}):te.map(R=>n.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[n.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:c==="drafts"?`#${R.id}`:R.referenceNo}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.jurisdiction}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.period}),n.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Yn(R.amount)}),c!=="paid"?n.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.paymentDate}):null,c==="rejected"?n.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.reason??"—"}):null,n.jsx("td",{className:"px-6 py-4",children:n.jsx(n0,{actionType:A.actionType,onView:()=>he(R),onViewPdf:()=>pe(R),onEdit:()=>Te(R),onSubmit:()=>J(R),isSubmitting:x===`${R.category}-${R.id}`,isViewPdfLoading:w===`${R.category}-${R.id}`})})]},`${R.category}-${R.id}`))})]})}),n.jsx(vn,{page:f,pageSize:p,totalCount:H,onPageChange:g,onPageSizeChange:b,disabled:L||o===null||ie})]}),n.jsx(r0,{open:E!==null,title:(E==null?void 0:E.title)??"Payment PDF",html:(E==null?void 0:E.html)??null,downloadFileName:E==null?void 0:E.downloadFileName,isLoading:(E==null?void 0:E.isLoading)??!1,error:(E==null?void 0:E.error)??null,onDownload:E&&!E.error?Re:void 0,onClose:oe})]})}function ca(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Hn({entityId:e,pageNumber:t=1,pageSize:r=tt}){const s=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(r)});return fe(`/portal/bank-accounts?${s}`)}function m0(e){return fe("/portal/bank-accounts",{method:"POST",body:e})}function du(e,t){return fe(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function jr({title:e,children:t,isFirst:r=!1,headerAction:s}){return n.jsxs("section",{className:r?"":"mt-8 border-t border-slate-100 pt-8",children:[n.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[n.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),s]}),t]})}const hn=17,mu=9;function Kr(e,t){return e.replace(/\D/g,"").slice(0,t)}const hu=["Checking","Savings"],h0=Jt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${hn} digits`),confirmAccountNumber:T().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${hn} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ws(hu,{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 f0({entityId:e,onCancel:t,onSuccess:r}){const s=vt(),{showSuccess:a,showError:i}=Os(),[o,l]=v.useState(null),[c,u]=v.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=$t({resolver:zt(h0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async g=>{l(null),u(!0);try{const p=await m0({entityId:e,bankName:g.bankName.trim(),accountNumber:g.accountNumber,routingNumber:g.routingNumber,accountType:g.accountType});await s.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),r(p.bankAccountDetailId)}catch(p){const b=st(p,"Unable to save bank account.");l(b),i("Action Not Completed",b)}finally{u(!1)}});return n.jsxs("form",{noValidate:!0,onSubmit:g=>{g.preventDefault(),g.stopPropagation(),f(g)},className:"space-y-6",children:[n.jsxs(fr,{step:2,title:"Add Bank Account Manually",children:[n.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Bank Account"}),n.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[n.jsx(Ve,{name:"accountNumber",control:d,render:({field:g})=>{var p;return n.jsx(me,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:g.value,onChange:b=>g.onChange(Kr(b.target.value,hn)),onBlur:g.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),n.jsx(Ve,{name:"confirmAccountNumber",control:d,render:({field:g})=>{var p;return n.jsx(me,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:g.value,onChange:b=>g.onChange(Kr(b.target.value,hn)),onBlur:g.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),n.jsx(Ve,{name:"routingNumber",control:d,render:({field:g})=>{var p;return n.jsx(me,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:g.value,onChange:b=>g.onChange(Kr(b.target.value,mu)),onBlur:g.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),n.jsx(Ve,{name:"accountType",control:d,render:({field:g})=>{var p;return n.jsx(Ot,{label:"Account Type",required:!0,value:g.value,onChange:g.onChange,onBlur:g.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:hu.map(b=>n.jsx("option",{value:b,children:b},b))})}})]}),n.jsx(Ve,{name:"bankName",control:d,render:({field:g})=>{var p;return n.jsx(me,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:g.value,onChange:g.onChange,onBlur:g.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?n.jsx(Qt,{message:o}):null,n.jsxs("div",{className:"flex flex-wrap gap-3",children:[n.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"}),n.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 fu({open:e,entityId:t,onClose:r,onAccountAdded:s}){const[a,i]=v.useState("choose");if(v.useEffect(()=>{e||i("choose")},[e]),v.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 n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[n.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),n.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?n.jsx(f0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{s==null||s(l),r()}}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.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"}),n.jsx("h2",{id:"add-bank-account-title",className:"text-sm font-medium uppercase tracking-[0.2em] text-slate-400",children:"Add Bank Account"})]}),n.jsx("div",{className:"my-6 h-px bg-slate-200"}),n.jsxs("div",{className:"space-y-4",children:[n.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:[n.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gov-600 text-white",children:n.jsx(p0,{className:"h-5 w-5"})}),n.jsx("span",{className:"text-base font-semibold text-slate-900",children:"Add Manually"})]}),n.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:[n.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-slate-200 bg-white",children:n.jsx(x0,{className:"h-6 w-6"})}),n.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function p0({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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 x0({className:e}){return n.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),n.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),n.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",fill:"#111827"}),n.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",fill:"#111827",opacity:"0.35"})]})}const g0=12,y0=["January","February","March","April","May","June","July","August","September","October","November","December"];function mr(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${s}`}function As(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const r=Number.parseInt(t[1],10),s=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(r,s,a);return i.getFullYear()!==r||i.getMonth()!==s||i.getDate()!==a?null:i}function Hs(e=new Date){const t=new Date(e);return e.getHours()>=g0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),mr(t)}function pu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),mr(t)}function b0(e=18,t=new Date){const r=new Date(t);return r.setFullYear(r.getFullYear()-e),r.setHours(0,0,0,0),mr(r)}function v0(e,t,r=new Date){const s=As(e);if(!s)return!1;const a=new Date(r);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),s.setHours(0,0,0,0),s<=a}function j0(e){const t=e.getDay();return t!==0&&t!==6}function Ya(e,t=new Date){if(!j0(e))return!1;const r=mr(e);return r>=Hs(t)&&r<=pu(t)}function xu(e,t=new Date){const r=As(e);return r?Ya(r,t):!1}function N0(e,t){return`${y0[t]} ${e}`}function w0(e,t){const r=new Date(e,t,1),s=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<=s;o+=1)i.push(new Date(e,t,o));return i}function ml(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Kn(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 gu({label:e,required:t=!1,htmlFor:r,info:s}){return n.jsxs("label",{htmlFor:r,className:"mb-1.5 flex items-center gap-1.5 text-sm text-slate-600",children:[n.jsxs("span",{children:[e,t?n.jsx("span",{className:"text-red-500",children:" *"}):null]}),s?n.jsx("span",{title:s,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":s,children:"i"}):null]})}function K({label:e,required:t,error:r,info:s,children:a}){return n.jsxs("div",{children:[n.jsx(gu,{label:e,required:t,info:s}),a,r?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}const yu=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 ee(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]"}`:yu(e)}function Qr(e){return`${yu(e)} appearance-none`}function Wr({className:e}){return n.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:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Tn({children:e}){return n.jsx("div",{className:"relative",children:e})}function bu({value:e,onChange:t,entityId:r,entityType:s="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[u,d]=v.useState(!1),[m,h]=v.useState(!1),f=v.useRef(null),g=a.find(b=>String(b.bankAccountDetailId)===e);v.useEffect(()=>{if(!u)return;const b=x=>{var S;(S=f.current)!=null&&S.contains(x.target)||d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[u]);const p=b=>{t(String(b)),h(!1),d(!1)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{ref:f,className:"relative",children:[n.jsx(gu,{label:c,required:!0}),n.jsxs("button",{type:"button",disabled:o||!r,onClick:()=>d(b=>!b),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:[n.jsx("span",{className:g?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":g?ml(g.accountNumber):"Bank account number"}),n.jsx(k0,{className:`shrink-0 text-slate-400 transition ${u?"rotate-180":""}`})]}),l?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,u?n.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:[n.jsx("div",{className:"p-3",children:n.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:[n.jsx(S0,{}),"Add Bank Account"]})}),n.jsx("div",{className:"border-t border-slate-200 px-4 py-2",children:n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"List of Bank Accounts"})}),n.jsx("div",{className:"max-h-64 overflow-y-auto pb-2",children:a.length===0?n.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):a.map(b=>{const x=String(b.bankAccountDetailId)===e;return n.jsxs("button",{type:"button",onClick:()=>{t(String(b.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${x?"bg-gov-50":""}`,children:[n.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:Di(b.bankName)}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:b.bankName}),n.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[ml(b.accountNumber),s?` · ${s}`:` · ${b.accountType}`]})]})]},b.bankAccountDetailId)})})]}):null]}),n.jsx(fu,{open:m,entityId:r,onClose:()=>h(!1),onAccountAdded:p})]})}function S0(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function k0({className:e=""}){return n.jsx("svg",{className:`h-4 w-4 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function C0(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Qn({entity:e,remittanceAmount:t="—",className:r=""}){if(!e)return n.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[n.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),n.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No entity selected."})]});const s=Gt(e);return n.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[n.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),n.jsxs("dl",{className:"space-y-4 p-5 text-sm",children:[n.jsx(Cn,{label:"Entity Name",value:s}),n.jsx(Cn,{label:"Tax ID",value:Mr(e.idNumber)}),n.jsx(Cn,{label:"Email ID",value:e.email}),n.jsx(Cn,{label:"Phone Number",value:Rr(e.phoneNumber)}),n.jsx(Cn,{label:"Address",value:C0(e)})]}),n.jsxs("div",{className:"border-t border-slate-100 px-5 py-4",children:[n.jsx("p",{className:"text-sm font-medium text-[#99A1AF]",children:"Remittance Amount"}),n.jsx("p",{className:"mt-1.5 text-xl font-bold text-gov-600",children:t})]})]})}function Cn({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm font-medium text-slate-500",children:e}),n.jsx("dd",{className:"mt-0.5 text-sm leading-relaxed text-slate-800",children:t})]})}const A0=[0,1,3,4,6,7,9,10],P0=[0,1,2,3,4,5,6,7,8,9,10],E0=[0,1,2,3,4,5,6,8,9,10,11],_0=[0,1,2,3,4,5,6,7,9,10,11],I0=["720","941"],T0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],F0=["7200D"],D0=["8963"];function vu(e){return I0.includes(e)?A0:T0.includes(e)?P0:F0.includes(e)?E0:D0.includes(e)?_0:[]}function R0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Ps(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 O0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function ju(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Es={941:"94105",944:"94405","CT-1":"10005"},An={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Ha={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 Ui(e,t){return!e||!t?!1:Es[e]===t}function Ks(e,t){return e==="CT-1"&&t===Es["CT-1"]}function $0(e,t){return e==="941"&&t===Es[941]||e==="944"&&t===Es[944]}function L0(e){return e==="CT-1"?{code1:An.tier1,code2:An.tier2,code3:""}:{code1:An.socialSecurity,code2:An.medicare,code3:An.withheld}}function Ka(e){return Ha.regex.test(e)}const z0=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,as=1e8;function M0(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 s=t.indexOf(".");let a=s===-1?t:t.slice(0,s);const i=s===-1?"":t.slice(s+1,s+3),o=s!==-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>as&&(a=String(as))}let l=s===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),z0.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>as)return String(as)}return l}return""}function Nu(e){return Ka(e)?Number.parseFloat(e):null}function q0(e,t,r,s){const a=[e,t];return s&&a.push(r),a.reduce((i,o)=>{const l=Nu(o);return l===null?i:i+l},0)}function V0(e,t){return Math.abs(e-t)<.005}function B0(e,t,r,s,a){if(!Ui(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=Ks(e,t);return{subcategoryCode1:r.trim()?"1":null,subcategoryCode2:s.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const U0=["Su","Mo","Tu","We","Th","Fr","Sa"];function Z0(){return n.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),n.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),n.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function W0({value:e,onChange:t,disabled:r=!1,hasError:s=!1}){const a=As(e),i=Hs(),o=pu(),[l,c]=v.useState(!1),[u,d]=v.useState(()=>a??As(i)??new Date),m=v.useRef(null),h=v.useId();v.useEffect(()=>{a&&d(a)},[e]),v.useEffect(()=>{if(!l)return;const x=S=>{var w;(w=m.current)!=null&&w.contains(S.target)||c(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[l]);const f=v.useMemo(()=>w0(u.getFullYear(),u.getMonth()),[u]),g=v.useMemo(()=>{const x=new Date(u.getFullYear(),u.getMonth()-1,1),S=new Date(x.getFullYear(),x.getMonth()+1,0);return mr(S)>=i},[u,i]),p=v.useMemo(()=>{const x=new Date(u.getFullYear(),u.getMonth()+1,1);return mr(x)<=o},[u,o]),b=x=>{Ya(x)&&(t(mr(x)),c(!1))};return n.jsxs("div",{ref:m,className:"relative",children:[n.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${s?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[n.jsx("input",{id:h,type:"text",readOnly:!0,disabled:r,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!r&&c(x=>!x),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"}),n.jsx("button",{type:"button",disabled:r,onClick:()=>c(x=>!x),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:n.jsx(Z0,{})})]}),l?n.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:[n.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),n.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[n.jsx("button",{type:"button",disabled:!g,onClick:()=>d(x=>new Date(x.getFullYear(),x.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:n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),n.jsx("span",{className:"text-sm font-semibold text-slate-900",children:N0(u.getFullYear(),u.getMonth())}),n.jsx("button",{type:"button",disabled:!p,onClick:()=>d(x=>new Date(x.getFullYear(),x.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:n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),n.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pt-2 text-center text-xs font-medium text-slate-500",children:U0.map(x=>n.jsx("div",{className:"py-1",children:x},x))}),n.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((x,S)=>{if(!x)return n.jsx("div",{},`empty-${S}`);const w=mr(x),N=e===w,E=!Ya(x);return n.jsx("button",{type:"button","aria-disabled":E,onClick:()=>b(x),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":N?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:x.getDate()},w)})})]}):null]})}function is({value:e,onChange:t,onBlur:r,name:s,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return n.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:s,value:e,disabled:a,readOnly:i,placeholder:o,className:ee(l,i),onChange:c=>t(M0(c.target.value)),onBlur:r})}const Y0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function H0(){return n.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),n.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),n.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function K0({value:e,onChange:t,disabled:r=!1,hasError:s=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=ju(),l=Ps(e),[c,u]=v.useState(!1),[d,m]=v.useState((l==null?void 0:l.year)??o),h=v.useRef(null),f=v.useId();v.useEffect(()=>{l&&m(l.year)},[e]),v.useEffect(()=>{if(!c)return;const w=N=>{var E;(E=h.current)!=null&&E.contains(N.target)||u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]);const g=R0(e),p=w=>!!a.includes(w),b=w=>{p(w)||(t(O0(d,w)),u(!1))},x=d>i,S=d<o;return n.jsxs("div",{ref:h,className:"relative",children:[n.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${s?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[n.jsx("input",{id:f,type:"text",readOnly:!0,disabled:r,value:g,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"}),n.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:n.jsx(H0,{})})]}),c?n.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:[n.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),n.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[n.jsx("button",{type:"button",disabled:!x,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:n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),n.jsx("span",{className:"text-sm font-semibold text-slate-900",children:d}),n.jsx("button",{type:"button",disabled:!S,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:n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),n.jsx("div",{className:"grid grid-cols-3 gap-1 p-3",children:Y0.map((w,N)=>{const E=(l==null?void 0:l.year)===d&&l.month===N&&e.length===6,D=p(N);return n.jsx("button",{type:"button","aria-disabled":D,onClick:()=>b(N),className:`rounded-lg px-2 py-2.5 text-sm transition ${D?"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 wu="Active",Q0="Inactive";function jn(e){return(e.status??wu).trim().toLowerCase()==="active"}function J0(e){return jn(e)?Q0:wu}function G0(e){return jn(e)?"Deactivate":"Activate"}function Zi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function X0(e){return Zi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function Su(e){const t=B0(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),r=Ks(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 Wi(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),...Su(t)}}function Yi(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),...Su(e)}}const Hi="federal-payment-draft";function Ki(e){sessionStorage.setItem(Hi,JSON.stringify(e))}function Qs(){const e=sessionStorage.getItem(Hi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Qi(){sessionStorage.removeItem(Hi)}function ev(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 tv=Jt({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=Ps(e);if(!t)return!1;const{minYear:r,maxYear:s}=ju();return t.year>=r&&t.year<=s},"Tax period must be within the last 3 years"),settlementDate:T().min(1,"This field is required").refine(e=>xu(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:T().min(1,"This field is required").refine(e=>Ka(e),Ha.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=Ps(e.taxPeriod);c&&vu(e.taxFormType).includes(c.month)&&t.addIssue({code:tr.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Ui(e.taxFormType,e.taxTypeCode))return;const r=Ks(e.taxFormType,e.taxTypeCode),s=$0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:tr.custom,message:"This field is required",path:[u]});return}Ka(c)||t.addIssue({code:tr.custom,message:Ha.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",s);const i=Nu(e.paymentAmount),o=q0(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",s);i!==null&&!V0(i,o)&&t.addIssue({code:tr.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),r&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:tr.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),os="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function ua(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 rv={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function nv(e,t){if(e)return ua(e);if(t!=null&&t.paymentDraft)return ua(t.paymentDraft);const r=Qs();return r?ua(r):rv}function ku({entity:e,initialDraft:t,readonly:r=!1,onCancel:s}){var Mt,pt,wt,xt,gt,_t,St,It,kt,z,ze,gr,Br;const a=Se(),i=we(),o=vt(),l=qr(i.state,Je()),c=i.state,u=v.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Qs()??null,[t,c==null?void 0:c.paymentDraft]),d=v.useRef(u==null?void 0:u.federalPaymentId),m=v.useRef(u==null?void 0:u.enrollmentId),[h,f]=v.useState(null),[g,p]=v.useState(!1),b=v.useMemo(()=>nv(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);v.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:x=[],isLoading:S}=ve({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Hn({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),w=v.useMemo(()=>x.filter(jn),[x]),{data:N=[],isLoading:E}=ve({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>qb(e.entityId),enabled:e!==null}),{register:D,control:A,handleSubmit:I,watch:_,setValue:L,trigger:ie,formState:{errors:U}}=$t({resolver:zt(tv),defaultValues:b}),Q=_("bankAccountDetailId"),te=_("paymentAmount"),H=_("taxFormType"),G=_("taxTypeCode"),J=_("taxPeriod"),he=_("settlementDate"),Te=_("subcategoryAmount1"),pe=_("subcategoryAmount2"),Re=_("subcategoryAmount3"),oe=v.useRef(H),Ne=v.useMemo(()=>H?vu(H):[],[H]),R=v.useMemo(()=>Ui(H,G),[H,G]),ye=v.useMemo(()=>Ks(H,G),[H,G]),{data:se=[],isLoading:Ce}=ve({queryKey:["federal-tax-type-codes",H],queryFn:()=>Vb(H),enabled:!!H});v.useEffect(()=>{oe.current&&oe.current!==H&&L("taxTypeCode",""),oe.current=H},[H,L]),v.useEffect(()=>{if(!J||!H)return;const B=Ps(J);B&&Ne.includes(B.month)&&L("taxPeriod","")},[H,J,Ne,L]),v.useEffect(()=>{he&&(xu(he)||L("settlementDate",""))},[he,L]),v.useEffect(()=>{if(!R){L("subcategoryCode1",""),L("subcategoryCode2",""),L("subcategoryCode3",""),L("subcategoryAmount1",""),L("subcategoryAmount2",""),L("subcategoryAmount3","");return}const B=L0(H);L("subcategoryCode1",B.code1),L("subcategoryCode2",B.code2),L("subcategoryCode3",ye?"":B.code3),ye&&L("subcategoryAmount3","")},[R,H,ye,L]),v.useEffect(()=>{R&&(ie("paymentAmount"),ie("subcategoryAmount1"),ie("subcategoryAmount2"),ie("subcategoryAmount3"))},[Te,pe,Re,R,ie]),v.useEffect(()=>{const B=w.find(ue=>String(ue.bankAccountDetailId)===Q);if(!B){Q&&(L("bankAccountDetailId",""),L("routingNumber",""),L("accountType",""),L("bankName",""));return}L("routingNumber",B.routingNumber),L("accountType",B.accountType),L("bankName",B.bankName)},[w,Q,L]);const Ye=B=>{const ue=w.find(y=>String(y.bankAccountDetailId)===B.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:B.taxpayerPin??"",secondaryTin:B.secondaryTin??"",bankAccountDetailId:B.bankAccountDetailId,routingNumber:B.routingNumber??(ue==null?void 0:ue.routingNumber)??"",accountNumber:(ue==null?void 0:ue.accountNumber)??"",accountType:B.accountType??(ue==null?void 0:ue.accountType)??"",bankName:B.bankName??(ue==null?void 0:ue.bankName)??"",taxFormType:B.taxFormType,taxTypeCode:B.taxTypeCode,taxPeriod:B.taxPeriod,settlementDate:B.settlementDate,paymentAmount:B.paymentAmount,subcategoryCode1:B.subcategoryCode1,subcategoryAmount1:B.subcategoryAmount1,subcategoryCode2:B.subcategoryCode2,subcategoryAmount2:B.subcategoryAmount2,subcategoryCode3:B.subcategoryCode3,subcategoryAmount3:B.subcategoryAmount3}},ht=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ce=async B=>{if(!e)return null;if(B.federalPaymentId){const y=await Vi(B.federalPaymentId,Yi(B));return d.current=y.federalPaymentId,m.current=y.enrollmentId,y}const ue=await qi(Wi(e.entityId,B));return d.current=ue.federalPaymentId,m.current=ue.enrollmentId,ue},Oe=I(async B=>{if(!(r||!e)){f(null),p(!0);try{const ue=Ye(B),y=await ce(ue);if(!y)return;const k={...ue,federalPaymentId:y.federalPaymentId,enrollmentId:y.enrollmentId};await ht(),Ki(k),a(X0(e),{state:{from:l,paymentDraft:k}})}catch(ue){f(st(ue,"Failed to save payment details."))}finally{p(!1)}}}),at=I(async B=>{if(!(!e||r)){f(null),p(!0);try{const ue=Ye(B);await ce(ue),await ht(),Qi(),a(Je())}catch(ue){f(st(ue,"Failed to save draft."))}finally{p(!1)}}}),Nt=()=>{if(s){s();return}a(l)},ft=e?Gt(e):"Entity";return n.jsxs("form",{onSubmit:Oe,noValidate:!0,className:"w-full space-y-6",children:[h?n.jsx(Qt,{message:h}):null,n.jsxs("div",{className:"relative w-full",children:[n.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:ft}),n.jsx(Qn,{entity:e,remittanceAmount:Kn(te),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),n.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:[n.jsx(jr,{title:"Enrolment Details",isFirst:!0,children:n.jsxs("div",{className:os,children:[n.jsx(K,{label:"Taxpayer PIN",required:!0,error:(Mt=U.taxpayerPin)==null?void 0:Mt.message,children:n.jsx("input",{placeholder:"Taxpayer PIN",className:ee(!!U.taxpayerPin),maxLength:4,disabled:r,...D("taxpayerPin")})}),n.jsx(K,{label:"Secondary TIN",error:(pt=U.secondaryTin)==null?void 0:pt.message,children:n.jsx("input",{placeholder:"Secondary TIN",className:ee(!!U.secondaryTin),maxLength:9,disabled:r,...D("secondaryTin")})}),n.jsx(Ve,{name:"bankAccountDetailId",control:A,render:({field:B})=>{var ue;return n.jsx(bu,{value:B.value,onChange:B.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:w,isLoading:S,disabled:!e||r,error:(ue=U.bankAccountDetailId)==null?void 0:ue.message})}}),n.jsx(K,{label:"Routing Number",required:!0,error:(wt=U.routingNumber)==null?void 0:wt.message,children:n.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:ee(!!U.routingNumber,!0),...D("routingNumber")})}),n.jsx(K,{label:"Account Type",required:!0,error:(xt=U.accountType)==null?void 0:xt.message,children:n.jsx("input",{readOnly:!0,placeholder:"Account Type",className:ee(!!U.accountType,!0),...D("accountType")})}),n.jsx(K,{label:"Bank Name",required:!0,error:(gt=U.bankName)==null?void 0:gt.message,children:n.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:ee(!!U.bankName,!0),...D("bankName")})})]})}),n.jsx(jr,{title:"Federal Payment",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:os,children:[n.jsx(K,{label:"Tax Form Type",required:!0,error:(_t=U.taxFormType)==null?void 0:_t.message,children:n.jsxs(Tn,{children:[n.jsxs("select",{className:Qr(!!U.taxFormType),disabled:E||!e||r,...D("taxFormType"),children:[n.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),N.map(B=>n.jsx("option",{value:B.value,children:B.value},B.value))]}),n.jsx(Wr,{})]})}),n.jsx(K,{label:"Payment Type",required:!0,error:(St=U.taxTypeCode)==null?void 0:St.message,children:n.jsxs(Tn,{children:[n.jsxs("select",{className:Qr(!!U.taxTypeCode),disabled:!H||Ce||r,...D("taxTypeCode"),children:[n.jsx("option",{value:"",children:H?Ce?"Loading payment types…":"Select payment type":"Select tax form first"}),se.map(B=>n.jsxs("option",{value:B.code,children:[B.code," - ",B.codeName]},B.code))]}),n.jsx(Wr,{})]})}),n.jsx(K,{label:"Tax Period",required:!0,error:(It=U.taxPeriod)==null?void 0:It.message,children:n.jsx(Ve,{name:"taxPeriod",control:A,render:({field:B})=>n.jsx(K0,{value:B.value,onChange:B.onChange,hasError:!!U.taxPeriod,disabled:!H||r,disabledMonths:Ne})})})]}),n.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[n.jsx(K,{label:"Settlement Date",required:!0,error:(kt=U.settlementDate)==null?void 0:kt.message,children:n.jsx(Ve,{name:"settlementDate",control:A,render:({field:B})=>n.jsx(W0,{value:B.value,onChange:B.onChange,hasError:!!U.settlementDate,disabled:r})})}),n.jsx(K,{label:"Payment Amount",required:!0,error:(z=U.paymentAmount)==null?void 0:z.message,children:n.jsx(Ve,{name:"paymentAmount",control:A,render:({field:B})=>n.jsx(is,{name:B.name,value:B.value,onChange:B.onChange,onBlur:B.onBlur,disabled:r,hasError:!!U.paymentAmount})})})]}),R?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:os,children:[n.jsx(K,{label:"Subcategory Code 1",children:n.jsx("input",{readOnly:!0,className:ee(!1,!0),...D("subcategoryCode1")})}),n.jsx(K,{label:"Subcategory Code 2",children:n.jsx("input",{readOnly:!0,className:ee(!1,!0),...D("subcategoryCode2")})}),ye?null:n.jsx(K,{label:"Subcategory Code 3",children:n.jsx("input",{readOnly:!0,className:ee(!1,!0),...D("subcategoryCode3")})})]}),n.jsxs("div",{className:os,children:[n.jsx(K,{label:"Subcategory Amount 1",required:!0,error:(ze=U.subcategoryAmount1)==null?void 0:ze.message,children:n.jsx(Ve,{name:"subcategoryAmount1",control:A,render:({field:B})=>n.jsx(is,{name:B.name,value:B.value??"",onChange:B.onChange,onBlur:B.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!U.subcategoryAmount1})})}),n.jsx(K,{label:"Subcategory Amount 2",required:!0,error:(gr=U.subcategoryAmount2)==null?void 0:gr.message,children:n.jsx(Ve,{name:"subcategoryAmount2",control:A,render:({field:B})=>n.jsx(is,{name:B.name,value:B.value??"",onChange:B.onChange,onBlur:B.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!U.subcategoryAmount2})})}),ye?null:n.jsx(K,{label:"Subcategory Amount 3",required:!0,error:(Br=U.subcategoryAmount3)==null?void 0:Br.message,children:n.jsx(Ve,{name:"subcategoryAmount3",control:A,render:({field:B})=>n.jsx(is,{name:B.name,value:B.value??"",onChange:B.onChange,onBlur:B.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!U.subcategoryAmount3})})})]})]}):null]})})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[n.jsx("button",{type:"button",onClick:Nt,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:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:at,disabled:!e||g,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:g?"Saving…":"Save as Draft"}),n.jsx("button",{type:"submit",disabled:!e||g,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:g?"Saving…":"Next"})]})]})]},i.key)}function Cu(){const{selectedEntity:e}=mt();return n.jsx(ku,{entity:e})}function Au({mode:e}){var m;const t=Se(),{federalPaymentId:r}=si(),{selectedEntity:s}=mt(),a=Number.parseInt(r??"",10),{data:i,isLoading:o,isError:l}=ve({queryKey:["federal-payment",a],queryFn:()=>Mi(a),enabled:Number.isFinite(a)}),{data:c=[]}=ve({queryKey:["bank-accounts",s==null?void 0:s.entityId],queryFn:async()=>(await Hn({entityId:s.entityId,pageNumber:1,pageSize:100})).items,enabled:s!==null&&i!==void 0}),u=v.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return ev(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 n.jsx(Be,{to:Je(),replace:!0});if(o)return n.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!u)return n.jsx(Be,{to:Je(),replace:!0});if(!s||i.entityId!==s.entityId)return n.jsx(Be,{to:Je(),replace:!0});const d=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return n.jsx(ku,{entity:s,initialDraft:u,readonly:d,onCancel:()=>t(Je())})}function Pu(){return mt(),n.jsx(Au,{mode:"edit"})}function Eu(){return mt(),n.jsx(Au,{mode:"view"})}const Ji="state-payment-draft";function Qa(e){sessionStorage.setItem(Ji,JSON.stringify(e))}function Ja(){const e=sessionStorage.getItem(Ji);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function _u(){sessionStorage.removeItem(Ji)}function Iu(e,t){return`${e}-${t}`}function sv(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Iu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function av(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Iu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}function iv(e){return Jt({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(t=>Number.parseFloat(t)>0,"Tax amount must be greater than 0").refine(t=>/^\d+(?:\.\d{1,2})?$/.test(t),"Use no more than two decimal places"),paymentDate:T().min(1,"Payment date is required").refine(t=>t>=Hs(),"Payment date must be a future date"),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional()}).superRefine((t,r)=>{const s=e(),a=s==null?void 0:s.stateId.pattern;if(a)try{new RegExp(`^(?:${a})$`).test(t.stateAccountId.trim().toUpperCase())||r.addIssue({code:tr.custom,path:["stateAccountId"],message:s.stateId.message})}catch{r.addIssue({code:tr.custom,path:["stateAccountId"],message:"State ID validation is temporarily unavailable"})}})}const da="grid gap-x-6 gap-y-5 sm:grid-cols-3",hl="grid gap-x-6 gap-y-5 sm:grid-cols-2",fl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",pl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function ma(e){return{state:e.state,reasonForPayment:ov(e.reasonForPayment),stateAccountId:e.stateAccountId,accountId:e.accountId,letterId:e.letterId??"",taxYear:e.taxYear,taxPeriod:e.taxPeriod,taxAmount:e.taxAmount,paymentDate:e.paymentDate,bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??""}}function ov(e){return e.trim().toUpperCase().replaceAll(" ","_")}function Tu({entity:e,initialDraft:t,readonly:r=!1,onCancel:s}){var pt,wt,xt,gt,_t,St,It,kt;const a=Se(),i=we(),o=qr(i.state,Je()),l=i.state,c=v.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??Ja()??null,[t,l==null?void 0:l.paymentDraft]),u=v.useRef(c==null?void 0:c.statePaymentDetailId),d=v.useMemo(()=>{if(t)return ma(t);if(l!=null&&l.paymentDraft)return ma(l.paymentDraft);if(l!=null&&l.resetDraft)return _u(),pl;const z=Ja();return z?ma(z):pl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),m=Hs(),{data:h=[],isLoading:f,isError:g}=ve({queryKey:["state-payment-states"],queryFn:({signal:z})=>Qb(z)}),{data:p=[],isLoading:b}=ve({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Hn({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),x=v.useMemo(()=>p.filter(jn),[p]),S=v.useRef(null),w=v.useMemo(()=>iv(()=>S.current),[]),{register:N,control:E,handleSubmit:D,watch:A,setValue:I,formState:{errors:_}}=$t({resolver:zt(w),defaultValues:d}),L=A("state"),ie=A("reasonForPayment"),U=A("taxAmount"),Q=A("bankAccountDetailId"),{data:te=[],isLoading:H,isError:G}=ve({queryKey:["state-payment-reasons",e==null?void 0:e.entityId,L],queryFn:({signal:z})=>Jb(e.entityId,L,z),enabled:e!==null&&!!L}),{data:J,isLoading:he,isError:Te}=ve({queryKey:["state-payment-validation-metadata",e==null?void 0:e.entityId,L,ie],queryFn:({signal:z})=>Gb(e.entityId,L,ie,z),enabled:e!==null&&!!(L&&ie)});S.current=J??null;const pe=(J==null?void 0:J.taxYearOptions)??[],Re=(J==null?void 0:J.taxPeriodOptions)??[],oe=!!(J&&L&&ie),[Ne,R]=v.useState(!1),[ye,se]=v.useState(""),Ce=v.useRef(null),Ye=(pt=h.find(z=>z.code===L))==null?void 0:pt.name,ht=v.useMemo(()=>{const z=ye.trim().toLowerCase();return z?h.filter(ze=>ze.name.toLowerCase().includes(z)||ze.code.toLowerCase().includes(z)):h},[ye,h]),ce=()=>{I("stateAccountId",""),I("accountId",""),I("letterId",""),I("taxYear",""),I("taxPeriod",""),I("taxAmount",""),I("paymentDate","")},Oe=z=>{I("state",z,{shouldValidate:!0}),I("reasonForPayment",""),ce(),se(""),R(!1)},at=z=>{z!==ie&&(I("reasonForPayment",z,{shouldValidate:!0}),ce())};v.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(u.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),v.useEffect(()=>{var z;Ne&&((z=Ce.current)==null||z.focus())},[Ne]),v.useEffect(()=>{!ie||H||G||te.some(z=>z.code===ie)||I("reasonForPayment","")},[H,G,te,ie,I]),v.useEffect(()=>{if(r)return;const z=x.find(ze=>String(ze.bankAccountDetailId)===Q);if(!z){Q&&(I("bankAccountDetailId",""),I("routingNumber",""),I("accountType",""),I("bankName",""));return}I("routingNumber",z.routingNumber),I("accountType",z.accountType),I("bankName",z.bankName)},[x,Q,I,r]);const Nt=D(z=>{if(r||!J)return;const ze={statePaymentDetailId:u.current,state:z.state,reasonForPayment:z.reasonForPayment,stateAccountId:z.stateAccountId.trim().toUpperCase(),accountId:z.accountId.trim(),letterId:z.letterId,taxYear:z.taxYear,taxPeriod:z.taxPeriod,taxAmount:z.taxAmount,paymentDate:z.paymentDate,bankAccountDetailId:z.bankAccountDetailId,routingNumber:z.routingNumber,accountType:z.accountType,bankName:z.bankName};Qa(ze),a("/payments/state/authorization",{state:{from:o,paymentDraft:ze}})}),ft=()=>{if(s){s();return}a(o)},Mt=e?Gt(e):"Entity";return n.jsx("form",{onSubmit:Nt,noValidate:!0,className:"w-full",children:n.jsxs("div",{className:"relative w-full",children:[n.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:Mt}),n.jsx(Qn,{entity:e,remittanceAmount:Kn(U),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),n.jsx("div",{className:"lg:mr-[324px]",children:n.jsxs("div",{className:"mx-auto w-full max-w-[720px] space-y-5",children:[n.jsxs("section",{className:fl,children:[n.jsx(xl,{step:1,title:"Choose a State"}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsxs("div",{className:"relative",children:[n.jsxs("button",{type:"button",disabled:r||f||g,onClick:()=>{se(""),R(z=>!z)},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 disabled:cursor-not-allowed disabled:opacity-70",children:[n.jsxs("span",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:n.jsx(lv,{})}),n.jsxs("span",{children:[n.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:f?"Loading states…":Ye??"Choose a state"}),n.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),n.jsx(Wr,{className:`h-4 w-4 text-slate-400 transition ${Ne?"rotate-180":""}`})]}),Ne?n.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:[n.jsx("div",{className:"border-b border-slate-100 p-2",children:n.jsx("input",{ref:Ce,type:"search",value:ye,onChange:z=>se(z.target.value),onKeyDown:z=>{z.key==="Escape"?R(!1):z.key==="Enter"&&z.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),n.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[ht.map(z=>n.jsxs("button",{type:"button",onClick:()=>Oe(z.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${L===z.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[n.jsx("span",{children:z.name}),n.jsx("span",{className:"text-xs font-medium text-slate-400",children:z.code})]},z.code)),ht.length===0?n.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,_.state?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:_.state.message}):null,g?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Unable to load states."}):null]}),n.jsx(K,{label:"Reason for Payment",required:!0,error:(wt=_.reasonForPayment)==null?void 0:wt.message,children:n.jsxs(Tn,{children:[n.jsxs("select",{disabled:r||!L||H||G,className:Qr(!!_.reasonForPayment),...N("reasonForPayment"),onChange:z=>at(z.target.value),children:[n.jsx("option",{value:"",children:H?"Loading reasons…":"Select reason"}),te.map(z=>n.jsx("option",{value:z.code,children:z.label},z.code))]}),n.jsx(Wr,{})]})}),G?n.jsx("p",{className:"text-xs text-red-600",children:"Unable to load payment reasons."}):null,L&&!H&&!G&&te.length===0?n.jsx("p",{className:"text-xs text-slate-500",children:"No supported payment reasons are available for this entity and state."}):null]})]}),n.jsxs("section",{className:`${fl} transition ${oe?"":"opacity-60"}`,children:[n.jsx(xl,{step:2,title:"Payment Form",className:"mb-5"}),n.jsxs("fieldset",{disabled:!oe||r,className:"min-w-0 border-0 p-0",children:[n.jsx(ha,{title:"Payment Details",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:da,children:[n.jsx(K,{label:"State ID",required:(J==null?void 0:J.stateId.required)??!0,error:(xt=_.stateAccountId)==null?void 0:xt.message,children:n.jsx("input",{placeholder:(J==null?void 0:J.stateId.example)??"Enter ID",className:ee(!!_.stateAccountId),...N("stateAccountId")})}),n.jsx(K,{label:"Account ID",required:(J==null?void 0:J.accountIdRequired)??!0,error:(gt=_.accountId)==null?void 0:gt.message,children:n.jsx("input",{placeholder:"123456789-WHW",className:ee(!!_.accountId),...N("accountId")})}),n.jsx(K,{label:"Letter ID",required:(J==null?void 0:J.letterIdRequired)??!1,children:n.jsx("input",{placeholder:"123456789-WHW",className:ee(),...N("letterId")})})]}),n.jsxs("div",{className:hl,children:[n.jsx(K,{label:"Tax Year",required:!0,error:(_t=_.taxYear)==null?void 0:_t.message,children:n.jsxs(Tn,{children:[n.jsxs("select",{className:Qr(!!_.taxYear),...N("taxYear"),children:[n.jsx("option",{value:"",children:"Select TY"}),pe.map(z=>n.jsxs("option",{value:String(z),children:["TY ",z]},z))]}),n.jsx(Wr,{})]})}),n.jsx(K,{label:(J==null?void 0:J.periodMode)==="account-assigned"?"Deposit Frequency":"Tax Period",required:!0,error:(St=_.taxPeriod)==null?void 0:St.message,children:n.jsxs(Tn,{children:[n.jsxs("select",{className:Qr(!!_.taxPeriod),...N("taxPeriod"),children:[n.jsx("option",{value:"",children:"Select"}),Re.map(z=>n.jsx("option",{value:z.value,children:z.label},z.value))]}),n.jsx(Wr,{})]})})]})]})}),n.jsx(ha,{title:"Amount Info",children:n.jsxs("div",{className:hl,children:[n.jsx(K,{label:"Tax Amount",required:!0,error:(It=_.taxAmount)==null?void 0:It.message,children:n.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",className:ee(!!_.taxAmount),...N("taxAmount")})}),n.jsx(K,{label:"Payment Date",required:!0,error:(kt=_.paymentDate)==null?void 0:kt.message,children:n.jsx("input",{type:"date",min:m,className:ee(!!_.paymentDate),...N("paymentDate")})})]})}),n.jsx(ha,{title:"Bank Account",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:da,children:[n.jsx(Ve,{name:"bankAccountDetailId",control:E,render:({field:z})=>{var ze;return n.jsx(bu,{value:z.value,onChange:z.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:x,isLoading:b,disabled:!e||!oe||r,error:(ze=_.bankAccountDetailId)==null?void 0:ze.message,label:"Account Number"})}}),n.jsx(K,{label:"Routing Number",required:!0,children:n.jsx("input",{readOnly:!0,placeholder:"9-digit",className:ee(!1,!0),...N("routingNumber")})}),n.jsx(K,{label:"Account Type",required:!0,children:n.jsx("input",{readOnly:!0,placeholder:"Select",className:ee(!1,!0),...N("accountType")})})]}),n.jsx("div",{className:da,children:n.jsx(K,{label:"Bank Name",children:n.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:ee(!1,!0),...N("bankName")})})})]})}),J!=null&&J.notes.length?n.jsx("div",{className:"mt-5 rounded-lg bg-amber-50 px-4 py-3 text-xs text-amber-800",children:J.notes.map(z=>n.jsx("p",{children:z},z))}):null]}),oe?null:n.jsx("p",{className:"mt-4 text-sm text-slate-500",children:he?"Loading payment requirements…":Te?"Unable to load payment requirements.":"Select a state and reason for payment to continue."})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx("button",{type:"button",onClick:ft,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:n.jsxs("button",{type:"submit",disabled:!e||!oe,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",n.jsx(cv,{})]})]})]})})]})},i.key)}function xl({step:e,title:t,className:r=""}){return n.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[n.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}),n.jsx("h3",{className:"text-sm font-bold uppercase tracking-wide text-slate-900",children:t})]})}function ha({title:e,children:t}){return n.jsxs("div",{className:"mt-6 first:mt-0",children:[n.jsx("h4",{className:"mb-4 text-xs font-semibold uppercase tracking-wide text-slate-400",children:e}),t]})}function lv(){return n.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),n.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 cv(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})}function Fu(){const{selectedEntity:e}=mt();return n.jsx(Tu,{entity:e})}function uv(e){const t=e.indexOf("-");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function Du(){var l;const{statePaymentId:e}=si(),{selectedEntity:t}=mt(),r=Number.parseInt(e??"",10),{data:s,isLoading:a,isError:i}=ve({queryKey:["state-payments",r],queryFn:()=>cu(r),enabled:t!==null&&Number.isFinite(r)}),o=v.useMemo(()=>{if(!s)return null;const[c,u]=uv(s.taxPeriod);return{statePaymentDetailId:s.statePaymentDetailId,state:s.state,reasonForPayment:"",stateAccountId:"",accountId:"",taxYear:c,taxPeriod:u,taxAmount:String(s.taxAmount),paymentDate:s.paymentDate,bankAccountDetailId:""}},[s]);return Number.isFinite(r)?a?n.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!s||!o?n.jsx(Be,{to:Je(),replace:!0}):!t||s.entityId!==t.entityId?n.jsx(Be,{to:Je(),replace:!0}):((l=s.status)==null?void 0:l.toLowerCase())!=="draft"?n.jsx(Be,{to:`/payments/state/${r}/view`,replace:!0}):n.jsx(Tu,{entity:t,initialDraft:o}):n.jsx(Be,{to:Je(),replace:!0})}function Ru(){var l,c;const{statePaymentId:e}=si(),t=Se(),{selectedEntity:r}=mt(),s=Number.parseInt(e??"",10),{data:a,isLoading:i,isError:o}=ve({queryKey:["state-payments",s],queryFn:()=>cu(s),enabled:r!==null&&Number.isFinite(s)});return Number.isFinite(s)?i?n.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!a?n.jsx(Be,{to:"/payments",replace:!0}):!r||a.entityId!==r.entityId?n.jsx(Be,{to:"/payments",replace:!0}):n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>t("/payments"),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-600 transition hover:bg-slate-50",children:[n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Back to Payments"]}),n.jsxs("h1",{className:"text-lg font-semibold text-slate-900",children:["State Payment ST-",a.statePaymentDetailId]})]}),n.jsx("div",{className:"w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",children:n.jsxs("dl",{className:"grid gap-x-8 gap-y-5 sm:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"State"}),n.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.state})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax Period"}),n.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.taxPeriod})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Amount"}),n.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:Yn(a.taxAmount)})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Payment Date"}),n.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.paymentDate})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Status"}),n.jsx("dd",{className:"mt-1",children:n.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${((l=a.status)==null?void 0:l.toLowerCase())==="paid"?"bg-green-100 text-green-800":((c=a.status)==null?void 0:c.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:a.status??"—"})})]}),a.reason&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Rejection Reason"}),n.jsx("dd",{className:"mt-1 text-sm text-slate-700",children:a.reason})]})]})})]}):n.jsx(Be,{to:"/payments",replace:!0})}const dv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",mv="I have reviewed the details and authorize this payment.",Ou=/^[a-zA-Z\s]+$/;function $u(e){return e.replace(/[^a-zA-Z\s]/g,"")}const Gi=T().min(1,"Signature is required").regex(Ou,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),hv=T().optional().refine(e=>!e||!e.trim()||Ou.test(e),{message:"Signature must contain only letters"}),fv=Jt({agreementDate:T().min(1,"Date is required"),agreementAccepted:Hr().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:T().min(1,"Name of authorization person is required"),signature:Gi,title:T().min(1,"Title is required")}),pv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ls="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function xv(e){const[t,r,s]=e.split("-");return!t||!r||!s?e:`${r}/${s}/${t}`}function gv(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function yv({entity:e,paymentDraft:t}){const r=Se(),s=we(),a=vt(),i=qr(s.state,Je()),[o,l]=v.useState(null),[c,u]=v.useState(!1),d=v.useMemo(()=>gv(),[]),m=Kn(t.taxAmount),{register:h,handleSubmit:f,watch:g,formState:{errors:p}}=$t({resolver:zt(fv),defaultValues:d}),b=g("agreementDate"),x=g("signature"),S=!!(x!=null&&x.trim()),w=h("signature"),N=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 L=await e0(t.statePaymentDetailId,av(t));return await N(),L}const _=await Xb(sv(e.entityId,t));return Qa({...t,statePaymentDetailId:_.statePaymentDetailId}),await N(),_},D=async()=>{e&&(await E(),_u(),r(Je()))},A=f(async()=>{if(e){l(null),u(!0);try{await D()}catch(_){l(st(_,"Failed to save state payment."))}finally{u(!1)}}}),I=f(async()=>{if(e){l(null),u(!0);try{await D()}catch(_){l(st(_,"Failed to save draft."))}finally{u(!1)}}});return n.jsx("form",{onSubmit:A,noValidate:!0,className:"w-full",children:n.jsxs("div",{className:"relative w-full",children:[n.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),n.jsx(Qn,{entity:e,remittanceAmount:m,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),n.jsxs("div",{className:"lg:mr-[324px]",children:[n.jsxs("section",{className:pv,children:[n.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-slate-200 pb-5",children:[n.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Authorization Agreement"}),n.jsxs("div",{className:`${ls} min-w-[128px] py-2.5`,children:[n.jsx("p",{className:"text-[11px] font-medium text-slate-500",children:"Date"}),n.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-800",children:xv(b)}),n.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),n.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:dv}),n.jsxs("label",{className:"mt-5 flex cursor-pointer items-start gap-3",children:[n.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")}),n.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:mv})]}),p.agreementAccepted?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.agreementAccepted.message}):null,n.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8",children:[n.jsxs("p",{className:"mb-4 text-sm font-medium text-gov-600",children:["Taxpayer's Signature",n.jsx("span",{className:"text-red-500",children:" *"})]}),n.jsxs("div",{className:"grid gap-5 md:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_minmax(0,1fr)] md:items-end",children:[n.jsxs("div",{children:[n.jsxs("div",{className:`${ls} py-7`,children:[n.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")}),n.jsx("div",{className:"mx-auto mt-6 w-full max-w-[180px] border-t border-slate-400"}),n.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Name of Authorization Person"})]}),p.authorizationPersonName?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.authorizationPersonName.message}):null]}),n.jsxs("div",{children:[n.jsxs("div",{className:`${ls} py-5`,children:[n.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${S?"min-h-[52px] text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:S?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,name:w.name,ref:w.ref,onBlur:w.onBlur,onChange:_=>{const L=$u(_.target.value);_.target.value=L,w.onChange(_)}}),n.jsx("div",{className:"mx-auto mt-6 w-full max-w-[220px] border-t border-slate-400"}),n.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Signature of Tax Payer"})]}),p.signature?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.signature.message}):null]}),n.jsxs("div",{children:[n.jsxs("div",{className:`${ls} py-7`,children:[n.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")}),n.jsx("div",{className:"mx-auto mt-6 w-full max-w-[140px] border-t border-slate-400"}),n.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Title"})]}),p.title?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.title.message}):null]})]})]})]}),o?n.jsx("div",{className:"mt-5",children:n.jsx(Qt,{message:o})}):null,n.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[n.jsx("button",{type:"button",onClick:()=>{Qa(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"}),n.jsx("button",{type:"button",onClick:I,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"}),n.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 Lu(){const{selectedEntity:e}=mt(),t=we(),{paymentDraft:r}=t.state??{},s=r??Ja();return s?n.jsx(yv,{entity:e,paymentDraft:s}):n.jsx(Be,{to:"/payments/state/new",replace:!0})}const Xi="/portal/federal-payments/form-8655-authorizations";function bv(e){return fe(Xi,{method:"POST",body:e})}function vv(e){return fe(`${Xi}/by-enrolment/${e}`)}function jv(e,t){return fe(`${Xi}/${e}`,{method:"PATCH",body:t})}async function zu(e){try{return await vv(e)}catch(t){if(t instanceof yn&&t.status===404)return null;throw t}}const Ga=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function Nv(e){const t=e.trim();return Ga.includes(t)?t:"Other"}const wv="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.",Sv="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 kv(e){const[t,r,s]=e.split("-");return!t||!r||!s?e:`${r}/${s}/${t}`}function Xa({label:e,required:t=!1,signature:r,title:s,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:g}=r;return n.jsxs("div",{children:[e?n.jsxs("p",{className:"mb-3 text-sm font-medium text-gov-600",children:[e,t?n.jsx("span",{className:"text-red-500",children:" *"}):null]}):null,n.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:[n.jsxs("div",{children:[n.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-6",children:[n.jsx("input",{ref:g,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 b=$u(p.target.value);p.target.value=b,m(p)}}),n.jsx("div",{className:"mt-8 border-t border-slate-400"}),n.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:u})]}),c!=null&&c.signature?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.signature}):null]}),n.jsxs("div",{children:[n.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[n.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",...s}),n.jsx("div",{className:"mt-8 border-t border-slate-400"}),n.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Title"})]}),c!=null&&c.title?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),n.jsxs("div",{children:[n.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-center text-sm text-slate-700",children:kv(o)}),n.jsx("input",{type:"hidden",...a})]}):n.jsx("input",{type:"date",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 focus:outline-none",...a}),n.jsx("div",{className:"mt-8 border-t border-slate-400"}),n.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Date"})]}),c!=null&&c.date?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function Cv(e){return e.replace(/\D/g,"")}function Mu(e,t){var r,s;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:Cv(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:((s=t.authorizationMonth)==null?void 0:s.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function Av(e){const{enrollmentId:t,...r}=Mu(0,e);return r}function Pv(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:Mr(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:Rr(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const Ev=Jt({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:Hr(),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:Hr().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:Gi,title:T().min(1,"Title is required"),signatureDate:T().min(1,"Date is required")}),fa="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function _v(e,t){const r=new Date().toISOString().slice(0,10);return{taxpayerName:e?Gt(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.lastName)||(e==null?void 0:e.firstName)||"",ein:e?Mr(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?Rr(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:Nv(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:r}}function Iv({entity:e,paymentDraft:t,initialAuthorization:r=null,readonly:s=!1}){var G,J,he,Te,pe,Re,oe,Ne,R,ye,se,Ce,Ye,ht;const a=Se(),i=we(),o=vt(),l=qr(i.state,Je()),c=Kn(t.paymentAmount),[u,d]=v.useState(null),[m,h]=v.useState(!1),f=v.useMemo(()=>r?Pv(r):_v(e,t),[e,r,t]),{register:g,handleSubmit:p,watch:b,setValue:x,reset:S,formState:{errors:w}}=$t({resolver:zt(Ev),defaultValues:f});v.useEffect(()=>{S(f)},[f,S]);const N=b("authorizedTaxForm"),E=b("signature"),D=b("signatureDate"),A=e?Gt(e):"Entity",I=!0,_=!0,L=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ie=async()=>{if(!e)return null;if(t.federalPaymentId){const Oe=await Vi(t.federalPaymentId,Yi(t));return await L(),Oe}const ce=await qi(Wi(e.entityId,t));return Ki({...t,federalPaymentId:ce.federalPaymentId,enrollmentId:ce.enrollmentId}),await L(),ce},U=async(ce,Oe)=>{var ft;const at=t.form8655AuthorizationId??((ft=await zu(ce))==null?void 0:ft.form8655AuthorizationId),Nt=Oe;return at?jv(at,Av(Nt)):bv(Mu(ce,Nt))},Q=async ce=>{if(!e)return;const Oe=await ie();Oe&&(await U(Oe.enrollmentId,ce),await o.invalidateQueries({queryKey:["form-8655",Oe.enrollmentId]}),Qi(),a(Je()))},te=p(async ce=>{if(!(!e||s)){d(null),h(!0);try{await Q(ce)}catch(Oe){d(st(Oe,"Failed to save federal payment draft."))}finally{h(!1)}}}),H=p(async ce=>{if(!(!e||s)){d(null),h(!0);try{await Q(ce)}catch(Oe){d(st(Oe,"Failed to save draft."))}finally{h(!1)}}});return n.jsxs("form",{onSubmit:te,noValidate:!0,className:"w-full space-y-6",children:[n.jsxs("div",{className:"relative w-full",children:[n.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:A}),n.jsx(Qn,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),n.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:n.jsxs("fieldset",{disabled:s,className:"min-w-0 border-0 p-0",children:[n.jsxs("section",{children:[n.jsxs("div",{className:fa,children:[n.jsx(K,{label:"1. a) Name of the Taxpayer",required:!0,error:(G=w.taxpayerName)==null?void 0:G.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:I,className:ee(!!w.taxpayerName,I),...g("taxpayerName")})}),n.jsx(K,{label:"1. b) Trade Name, if any",required:!0,error:(J=w.tradeName)==null?void 0:J.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:I,className:ee(!!w.tradeName,I),...g("tradeName")})}),n.jsx(K,{label:"2. Employer Identification Number (EIN)",required:!0,error:(he=w.ein)==null?void 0:he.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:I,className:ee(!!w.ein,I),...g("ein")})})]}),n.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[n.jsx("div",{className:"sm:col-span-2",children:n.jsx(K,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(Te=w.address)==null?void 0:Te.message,children:n.jsx("input",{placeholder:"Enter",readOnly:I,className:ee(!!w.address,I),...g("address")})})}),n.jsx(K,{label:"3. b) City or Town",required:!0,error:(pe=w.city)==null?void 0:pe.message,children:n.jsx("input",{placeholder:"Enter",readOnly:I,className:ee(!!w.city,I),...g("city")})})]}),n.jsxs("div",{className:`mt-5 ${fa}`,children:[n.jsx(K,{label:"3. c) State",required:!0,error:(Re=w.state)==null?void 0:Re.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:I,className:ee(!!w.state,I),...g("state")})}),n.jsx(K,{label:"3. d) ZIP Code",required:!0,error:(oe=w.zipCode)==null?void 0:oe.message,children:n.jsx("input",{placeholder:"Enter",readOnly:I,className:ee(!!w.zipCode,I),...g("zipCode")})}),n.jsx(K,{label:"3. e) Country",required:!0,error:(Ne=w.country)==null?void 0:Ne.message,children:n.jsx("input",{placeholder:"Enter",readOnly:I,className:ee(!!w.country,I),...g("country")})})]}),n.jsxs("div",{className:`mt-5 ${fa}`,children:[n.jsx("div",{className:"flex items-end pb-2",children:n.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...g("isSeasonalEmployer")}),n.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),n.jsx(K,{label:"5. Other Identification Number (Optional)",children:n.jsx("input",{placeholder:"Enter name",readOnly:I,className:ee(!1,I),...g("otherIdentificationNumber")})}),n.jsx(K,{label:"6. Contact Person",required:!0,error:(R=w.contactPerson)==null?void 0:R.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:I,className:ee(!!w.contactPerson,I),...g("contactPerson")})})]}),n.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[n.jsx(K,{label:"7. Daytime Telephone Number",required:!0,error:(ye=w.daytimePhone)==null?void 0:ye.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:I,className:ee(!!w.daytimePhone,I),...g("daytimePhone")})}),n.jsx(K,{label:"8. Fax Number",error:(se=w.faxNumber)==null?void 0:se.message,children:n.jsx("input",{placeholder:"Enter number",className:ee(!!w.faxNumber),...g("faxNumber")})})]})]}),n.jsxs(jr,{title:"Authorization of Reporting Agent To Make and Deposits and Payments (Caution: See Authorization Agreement.)",children:[n.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)"}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Ga.slice(0,6).map(ce=>n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:ce,checked:N===ce,disabled:_,onChange:()=>x("authorizedTaxForm",ce,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),ce]},ce))}),n.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Ga.slice(6).map(ce=>n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:ce,checked:N===ce,disabled:_,onChange:()=>x("authorizedTaxForm",ce,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),ce]},ce))})]}),w.authorizedTaxForm?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.authorizedTaxForm.message}):null]}),n.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[n.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),n.jsxs("div",{className:"border-t border-slate-200 pt-5",children:[n.jsxs("label",{className:"flex items-start gap-3",children:[n.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...g("agreementAccepted")}),n.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[n.jsx("span",{className:"font-semibold text-slate-900",children:wv})," ",Sv]})]}),w.agreementAccepted?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.agreementAccepted.message}):null]})]}),n.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:n.jsx(Xa,{label:"Taxpayer's Signature",required:!0,signature:g("signature"),title:g("title"),date:g("signatureDate"),signatureValue:E,dateValue:D,errors:{signature:(Ce=w.signature)==null?void 0:Ce.message,title:(Ye=w.title)==null?void 0:Ye.message,date:(ht=w.signatureDate)==null?void 0:ht.message}})})]})})]}),u?n.jsx("div",{className:"lg:mr-[324px]",children:n.jsx(Qt,{message:u})}):null,n.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[n.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"}),n.jsx("button",{type:"button",onClick:H,disabled:m||!e||s,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"}),n.jsx("button",{type:"submit",disabled:m||!e||s,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 qu(){const{selectedEntity:e}=mt(),t=we(),{paymentDraft:r}=t.state??{},s=r??Qs(),{data:a,isLoading:i}=ve({queryKey:["federal-payment",s==null?void 0:s.federalPaymentId],queryFn:()=>Mi(s.federalPaymentId),enabled:(s==null?void 0:s.federalPaymentId)!=null&&s.enrollmentId==null}),o=(s==null?void 0:s.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ve({queryKey:["form-8655",o],queryFn:()=>zu(o),enabled:o!=null}),u=v.useMemo(()=>s?{...s,enrollmentId:o??s.enrollmentId,form8655AuthorizationId:s.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[s,o,l]);return s?Zi(e)?n.jsx(Be,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):s.federalPaymentId!=null&&s.enrollmentId==null&&i||o!=null&&c?n.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):n.jsx(Iv,{entity:e,paymentDraft:u??s,initialAuthorization:l}):n.jsx(Be,{to:"/payments/federal/new",replace:!0})}const eo="/portal/federal-payments/form-9783-enrollments";function Tv(e){return fe(eo,{method:"POST",body:e})}function Fv(e){return fe(`${eo}/by-enrolment/${e}`)}function Dv(e,t){return fe(`${eo}/${e}`,{method:"PATCH",body:t})}async function Vu(e){try{return await Fv(e)}catch(t){if(t instanceof yn&&t.status===404)return null;throw t}}const Rv="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.",Ov="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.",$v="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.",pa=new Date().getFullYear(),Lv=[String(pa-1),String(pa-2),String(pa-3)];function cs(e){return e.replace(/\D/g,"")}function Bu(e,t){var r,s,a,i;return{enrollmentId:e,primarySsn:cs(t.primarySsn),jointFilerSsn:t.jointFilerSsn?cs(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:((s=t.contactInternationalAddress)==null?void 0:s.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:cs(t.financialPrimarySsn),routingTransitNumber:cs(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 zv(e){const{enrollmentId:t,...r}=Bu(0,e);return r}function Mv(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:Rr(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Rr(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 qv=Jt({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=>v0(e,Uu),{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:eu([sa("Checking"),sa("Savings"),sa("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Hr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Hr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Hr().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:Gi,taxpayerTitle:T().min(1,"Title is required"),taxpayerSignatureDate:T().min(1,"Date is required"),jointFilerSignature:hv,jointFilerTitle:T().optional(),jointFilerSignatureDate:T().optional()}),yr="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",Vv="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",Bv=5,Uu=18;function Zu(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function Wu(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:Zu(t.accountType)}}function Uv(e,t){const r=new Date().toISOString().slice(0,10),s=e?Gt(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:s,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?Rr(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...Wu(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:r,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:r}}function Zv({entity:e,paymentDraft:t,initialEnrollment:r=null,readonly:s=!1}){var Nt,ft,Mt,pt,wt,xt,gt,_t,St,It,kt,z,ze,gr,Br,B,ue,y,k,C,O,$,W,M,Y;const a=Se(),i=we(),o=vt(),l=qr(i.state,Je()),c=Kn(t.paymentAmount),[u,d]=v.useState(null),[m,h]=v.useState(!1),[f,g]=v.useState(!1),{data:p=[]}=ve({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Hn({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:(e==null?void 0:e.entityId)!=null}),b=v.useMemo(()=>{if(r)return Mv(r);const q=p.find(Me=>String(Me.bankAccountDetailId)===t.bankAccountDetailId),ae=Wu(e,t);return{...Uv(e,t),financialPrimarySsn:ae.financialPrimarySsn,routingTransitNumber:ae.routingTransitNumber||(q==null?void 0:q.routingNumber)||"",accountNumber:ae.accountNumber||(q==null?void 0:q.accountNumber)||"",accountType:Zu(t.accountType||(q==null?void 0:q.accountType))}},[e,r,t,p]),{register:x,handleSubmit:S,watch:w,setValue:N,reset:E,control:D,formState:{errors:A}}=$t({resolver:zt(qv),defaultValues:b});v.useEffect(()=>{E(b)},[b,E]);const I=w("taxpayerSignature"),_=w("jointFilerSignature"),L=w("taxpayerSignatureDate"),ie=w("jointFilerSignatureDate"),U=w("accountType"),Q=w("taxpayerNames"),te=w("primaryAddress"),H=w("city"),G=w("state"),J=w("zipCode"),he=w("country"),Te=w("primaryPhone"),pe=w("internationalAddress"),Re=e?Gt(e):"Entity",oe=!0,Ne=!0,R=v.useMemo(()=>b0(Uu),[]),ye=()=>{N("primaryContactName",Q,{shouldValidate:!0}),N("primaryContactAddress",te,{shouldValidate:!0}),N("contactCity",H,{shouldValidate:!0}),N("contactState",G,{shouldValidate:!0}),N("contactZipCode",J,{shouldValidate:!0}),N("contactCountry",he,{shouldValidate:!0}),N("contactPhone",Te,{shouldValidate:!0}),N("contactInternationalAddress",pe??"",{shouldValidate:!0})},se=()=>{N("primaryContactName","",{shouldValidate:!0}),N("primaryContactAddress","",{shouldValidate:!0}),N("contactCity","",{shouldValidate:!0}),N("contactState","",{shouldValidate:!0}),N("contactZipCode","",{shouldValidate:!0}),N("contactCountry","",{shouldValidate:!0}),N("contactPhone","",{shouldValidate:!0}),N("contactInternationalAddress","",{shouldValidate:!0})};v.useEffect(()=>{f&&ye()},[f,Q,te,H,G,J,he,Te,pe]);const Ce=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},Ye=async()=>{if(!e)return null;if(t.federalPaymentId){const ae=await Vi(t.federalPaymentId,Yi(t));return await Ce(),ae}const q=await qi(Wi(e.entityId,t));return Ki({...t,federalPaymentId:q.federalPaymentId,enrollmentId:q.enrollmentId}),await Ce(),q},ht=async(q,ae)=>{var qt;const Me=t.form9783EnrollmentId??((qt=await Vu(q))==null?void 0:qt.form9783EnrollmentId);return Me?Dv(Me,zv(ae)):Tv(Bu(q,ae))},ce=async q=>{if(!e)return;const ae=await Ye();ae&&(await ht(ae.enrollmentId,q),await o.invalidateQueries({queryKey:["form-9783",ae.enrollmentId]}),Qi(),a(Je()))},Oe=S(async q=>{if(!(!e||s)){d(null),h(!0);try{await ce(q)}catch(ae){d(st(ae,"Failed to save federal payment draft."))}finally{h(!1)}}}),at=S(async q=>{if(!(!e||s)){d(null),h(!0);try{await ce(q)}catch(ae){d(st(ae,"Failed to save draft."))}finally{h(!1)}}});return n.jsxs("form",{onSubmit:Oe,noValidate:!0,className:"w-full space-y-6",children:[n.jsxs("div",{className:"relative w-full",children:[n.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:Re}),n.jsx(Qn,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),n.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:n.jsxs("fieldset",{disabled:s,className:"min-w-0 border-0 p-0",children:[n.jsxs(jr,{title:"1. Taxpayer Information",isFirst:!0,children:[n.jsxs("div",{className:yr,children:[n.jsx(K,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(Nt=A.primarySsn)==null?void 0:Nt.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:oe,className:ee(!!A.primarySsn,oe),...x("primarySsn")})}),n.jsx(K,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:n.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:oe,className:ee(!1,oe),...x("jointFilerSsn")})}),n.jsx(K,{label:"2. Taxpayer(S) name(S)",required:!0,error:(ft=A.taxpayerNames)==null?void 0:ft.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:oe,className:ee(!!A.taxpayerNames,oe),...x("taxpayerNames")})})]}),n.jsxs("div",{className:`mt-5 ${yr}`,children:[n.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:n.jsx(K,{label:"3. a) Primary taxpayer address",required:!0,error:(Mt=A.primaryAddress)==null?void 0:Mt.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:ee(!!A.primaryAddress,oe),...x("primaryAddress")})})}),n.jsx(K,{label:"3. b) City or Town",required:!0,error:(pt=A.city)==null?void 0:pt.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:ee(!!A.city,oe),...x("city")})})]}),n.jsxs("div",{className:`mt-5 ${yr}`,children:[n.jsx(K,{label:"3. c) State",required:!0,error:(wt=A.state)==null?void 0:wt.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:oe,className:ee(!!A.state,oe),...x("state")})}),n.jsx(K,{label:"3. d) ZIP code",required:!0,error:(xt=A.zipCode)==null?void 0:xt.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:ee(!!A.zipCode,oe),...x("zipCode")})}),n.jsx(K,{label:"3. e) Country",required:!0,error:(gt=A.country)==null?void 0:gt.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:ee(!!A.country,oe),...x("country")})})]}),n.jsxs("div",{className:`mt-5 ${yr}`,children:[n.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:n.jsx(K,{label:"3. f) International address",children:n.jsx("input",{placeholder:"phone number (International number)",readOnly:oe,className:ee(!1,oe),...x("internationalAddress")})})}),n.jsx(K,{label:"4. Primary taxpayer phone number",required:!0,error:(_t=A.primaryPhone)==null?void 0:_t.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:oe,className:ee(!!A.primaryPhone,oe),...x("primaryPhone")})})]})]}),n.jsxs(jr,{title:"2. Contact Information",headerAction:n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"checkbox",checked:f,disabled:s,onChange:q=>{const ae=q.target.checked;g(ae),ae?ye():se()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[n.jsxs("div",{className:yr,children:[n.jsx(K,{label:"5. Primary contact name",required:!0,error:(St=A.primaryContactName)==null?void 0:St.message,children:n.jsx("input",{placeholder:"Payer Name",readOnly:f,className:ee(!!A.primaryContactName,f),...x("primaryContactName")})}),n.jsx(K,{label:"6. a) Primary contact address",required:!0,error:(It=A.primaryContactAddress)==null?void 0:It.message,children:n.jsx("input",{placeholder:"Payer Address",readOnly:f,className:ee(!!A.primaryContactAddress,f),...x("primaryContactAddress")})}),n.jsx(K,{label:"6. b) City or Town",required:!0,error:(kt=A.contactCity)==null?void 0:kt.message,children:n.jsx("input",{placeholder:"City",readOnly:f,className:ee(!!A.contactCity,f),...x("contactCity")})})]}),n.jsxs("div",{className:`mt-5 ${yr}`,children:[n.jsx(K,{label:"6. c) State",required:!0,error:(z=A.contactState)==null?void 0:z.message,children:n.jsx("input",{placeholder:"Payer State",readOnly:f,className:ee(!!A.contactState,f),...x("contactState")})}),n.jsx(K,{label:"6. d) ZIP code",required:!0,error:(ze=A.contactZipCode)==null?void 0:ze.message,children:n.jsx("input",{placeholder:"ZIP code",readOnly:f,className:ee(!!A.contactZipCode,f),...x("contactZipCode")})}),n.jsx(K,{label:"6. f) Country",required:!0,error:(gr=A.contactCountry)==null?void 0:gr.message,children:n.jsx("input",{placeholder:"Country",readOnly:f,className:ee(!!A.contactCountry,f),...x("contactCountry")})})]}),n.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[n.jsx(K,{label:"7. Primary taxpayer phone number",required:!0,error:(Br=A.contactPhone)==null?void 0:Br.message,children:n.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:ee(!!A.contactPhone,f),...x("contactPhone")})}),n.jsx("div",{className:"sm:col-span-2",children:n.jsx(K,{label:"8. International address",children:n.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:ee(!1,f),...x("contactInternationalAddress")})})})]})]}),n.jsx(jr,{title:"Taxpayer Details *",children:n.jsxs("div",{className:Vv,children:[n.jsx(K,{label:"1. Primary Taxpayer Pin",required:!0,error:(B=A.primaryTaxpayerPin)==null?void 0:B.message,children:n.jsx(Ve,{name:"primaryTaxpayerPin",control:D,render:({field:q})=>n.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:ee(!!A.primaryTaxpayerPin),value:q.value,onChange:ae=>q.onChange(Kr(ae.target.value,Bv)),onBlur:q.onBlur})})}),n.jsx(K,{label:"2. Date of Birth",required:!0,error:(ue=A.dateOfBirth)==null?void 0:ue.message,children:n.jsx("input",{type:"date",max:R,className:ee(!!A.dateOfBirth),...x("dateOfBirth")})}),n.jsx(K,{label:"3. Prior year adjusted gross income",required:!0,error:(y=A.priorYearAgi)==null?void 0:y.message,children:n.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:ee(!!A.priorYearAgi),...x("priorYearAgi")})}),n.jsx(K,{label:"4. Prior Tax Year",required:!0,error:(k=A.agiTaxYear)==null?void 0:k.message,children:n.jsxs("select",{className:Qr(!!A.agiTaxYear),...x("agiTaxYear"),children:[n.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),Lv.map(q=>n.jsx("option",{value:q,children:q},q))]})})]})}),n.jsxs(jr,{title:"3. Social Security Number and Financial Institution Information",children:[n.jsxs("div",{className:yr,children:[n.jsx(K,{label:"9. Primary SSN",required:!0,error:(C=A.financialPrimarySsn)==null?void 0:C.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:Ne,className:ee(!!A.financialPrimarySsn,Ne),...x("financialPrimarySsn")})}),n.jsx(K,{label:"10. Routing Transit Number (RTN)",required:!0,error:(O=A.routingTransitNumber)==null?void 0:O.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:Ne,className:ee(!!A.routingTransitNumber,Ne),...x("routingTransitNumber")})}),n.jsx(K,{label:"11. Account Number",required:!0,error:($=A.accountNumber)==null?void 0:$.message,children:n.jsx("input",{placeholder:"Enter",readOnly:Ne,className:ee(!!A.accountNumber,Ne),...x("accountNumber")})})]}),n.jsxs("div",{className:"mt-5",children:[n.jsx("p",{className:"mb-3 text-sm text-slate-600",children:"12. Type of Account"}),n.jsx("div",{className:"flex flex-wrap gap-6",children:["Checking","Savings"].map(q=>n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:q,checked:U===q,disabled:Ne,onChange:()=>N("accountType",q,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),q]},q))}),A.accountType?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.accountType.message}):null]})]}),n.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[n.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),n.jsx("p",{className:"mb-5 text-sm text-slate-600",children:"Read the following authorization agreements"}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),n.jsxs("label",{className:"flex items-start gap-3",children:[n.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...x("disclosureAgreementOne")}),n.jsx("span",{className:"text-sm leading-6 text-slate-700",children:Rv})]}),A.disclosureAgreementOne?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.disclosureAgreementOne.message}):null]}),n.jsxs("div",{children:[n.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),n.jsxs("label",{className:"flex items-start gap-3",children:[n.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...x("disclosureAgreementTwo")}),n.jsx("span",{className:"text-sm leading-6 text-slate-700",children:Ov})]}),A.disclosureAgreementTwo?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.disclosureAgreementTwo.message}):null]}),n.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[n.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Authority to Execute an Authorization"}),n.jsxs("label",{className:"flex items-start gap-3",children:[n.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...x("authorityAgreement")}),n.jsx("span",{className:"text-sm leading-6 text-slate-700",children:$v})]}),A.authorityAgreement?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.authorityAgreement.message}):null]})]})]}),n.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[n.jsx(Xa,{label:"Taxpayer's Signature",required:!0,signature:x("taxpayerSignature"),title:x("taxpayerTitle"),date:x("taxpayerSignatureDate"),signatureValue:I,dateValue:L,errors:{signature:(W=A.taxpayerSignature)==null?void 0:W.message,title:(M=A.taxpayerTitle)==null?void 0:M.message,date:(Y=A.taxpayerSignatureDate)==null?void 0:Y.message}}),n.jsx(Xa,{label:"Joint filer(s) Signature (Optional)",signature:x("jointFilerSignature"),title:x("jointFilerTitle"),date:x("jointFilerSignatureDate"),signatureValue:_??"",dateValue:ie??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?n.jsx("div",{className:"lg:mr-[324px]",children:n.jsx(Qt,{message:u})}):null,n.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[n.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"}),n.jsx("button",{type:"button",onClick:at,disabled:m||!e||s,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"}),n.jsx("button",{type:"submit",disabled:m||!e||s,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 Yu(){const{selectedEntity:e}=mt(),t=we(),{paymentDraft:r}=t.state??{},s=r??Qs(),{data:a,isLoading:i}=ve({queryKey:["federal-payment",s==null?void 0:s.federalPaymentId],queryFn:()=>Mi(s.federalPaymentId),enabled:(s==null?void 0:s.federalPaymentId)!=null&&s.enrollmentId==null}),o=(s==null?void 0:s.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ve({queryKey:["form-9783",o],queryFn:()=>Vu(o),enabled:o!=null}),u=v.useMemo(()=>s?{...s,enrollmentId:o??s.enrollmentId,form9783EnrollmentId:s.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[s,o,l]);return s?e&&!Zi(e)?n.jsx(Be,{to:"/payments/federal/authorization",replace:!0,state:t.state}):s.federalPaymentId!=null&&s.enrollmentId==null&&i||o!=null&&c?n.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):n.jsx(Zv,{entity:e,paymentDraft:u??s,initialEnrollment:l}):n.jsx(Be,{to:"/payments/federal/new",replace:!0})}function Wv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Yv({type:e}){return n.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 Hv({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"),n.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r}`,children:e})}function Kv({forms:e=[],isLoading:t=!1,isError:r=!1}){return n.jsx("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[n.jsx("th",{className:"px-6 py-3",children:"File Name"}),n.jsx("th",{className:"px-6 py-3",children:"Type"}),n.jsx("th",{className:"px-6 py-3",children:"Client"}),n.jsx("th",{className:"px-6 py-3",children:"Status"}),n.jsx("th",{className:"px-6 py-3",children:"Date"}),n.jsx("th",{className:"px-6 py-3",children:"Action"})]})}),n.jsx("tbody",{children:t?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Loading tax forms…"})}):r?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Unable to load tax forms."})}):e.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"No tax forms to display yet."})}):e.map(s=>n.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[n.jsx("td",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex items-center gap-3 font-medium text-slate-900",children:[n.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gov-50 text-gov-600",children:n.jsx(Qv,{className:"h-4 w-4"})}),s.fileName]})}),n.jsx("td",{className:"px-6 py-4",children:n.jsx(Yv,{type:s.type})}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:s.client}),n.jsx("td",{className:"px-6 py-4",children:n.jsx(Hv,{status:s.status})}),n.jsx("td",{className:"px-6 py-4 text-slate-600",children:Wv(s.date)}),n.jsx("td",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.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"}),s.canSubmit?n.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]})})]},s.taxFormId))})]})})})}function Qv({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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 Jv(){return n.jsx(Kv,{})}const gl=160,Gv=88,us=8;function Xv({account:e,entityId:t,onEdit:r}){const s=vt(),{showSuccess:a,showError:i}=Os(),o=v.useRef(null),l=v.useRef(null),[c,u]=v.useState(!1),[d,m]=v.useState(!1),[h,f]=v.useState({}),g=()=>{var E;const b=o.current;if(!b)return;const x=b.getBoundingClientRect(),S=((E=l.current)==null?void 0:E.offsetHeight)??Gv,N=window.innerHeight-x.bottom<S+us;f({position:"fixed",top:N?x.top-S-us:x.bottom+us,left:Math.max(us,x.right-gl),width:gl,zIndex:50})};v.useLayoutEffect(()=>{c&&(g(),requestAnimationFrame(g))},[c]),v.useEffect(()=>{if(!c)return;const b=S=>{var N,E;const w=S.target;(N=o.current)!=null&&N.contains(w)||(E=l.current)!=null&&E.contains(w)||u(!1)},x=()=>g();return document.addEventListener("mousedown",b),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},[c]);const p=async()=>{const b=jn(e);m(!0);try{await du(e.bankAccountDetailId,{status:J0(e)}),await s.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),b?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(x){i("Action Not Completed",st(x,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return n.jsxs("div",{className:"inline-block text-left",children:[n.jsxs("button",{ref:o,type:"button",disabled:d,onClick:()=>u(b=>!b),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",n.jsx(ej,{})]}),c?_s.createPortal(n.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[n.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"}),n.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:G0(e)})]}),document.body):null]})}function ej(){return n.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}const Hu=["Checking","Savings"],tj=Jt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${hn} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ws(Hu,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")});function rj({open:e,account:t,onClose:r}){const s=vt(),{showSuccess:a,showError:i}=Os(),[o,l]=v.useState(null),[c,u]=v.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=$t({resolver:zt(tj),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});v.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),v.useEffect(()=>{if(!e)return;const p=b=>{b.key==="Escape"&&r()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,r]);const g=m(async p=>{if(t){l(null),u(!0);try{await du(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await s.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),r()}catch(b){const x=st(b,"Unable to update bank account.");l(x),i("Action Not Completed",x)}finally{u(!1)}}});return!e||!t?null:_s.createPortal(n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[n.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),n.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:[n.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[n.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),n.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),n.jsxs("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),g(p)},className:"flex min-h-0 flex-1 flex-col",children:[n.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?n.jsx("div",{className:"mb-5",children:n.jsx(Qt,{message:o})}):null,n.jsxs(fr,{title:"Bank Account",children:[n.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[n.jsx(Ve,{name:"accountNumber",control:d,render:({field:p})=>{var b;return n.jsx(me,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:x=>p.onChange(Kr(x.target.value,hn)),onBlur:p.onBlur,error:(b=f.accountNumber)==null?void 0:b.message})}}),n.jsx(Ve,{name:"routingNumber",control:d,render:({field:p})=>{var b;return n.jsx(me,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:x=>p.onChange(Kr(x.target.value,mu)),onBlur:p.onBlur,error:(b=f.routingNumber)==null?void 0:b.message})}}),n.jsx(Ve,{name:"accountType",control:d,render:({field:p})=>{var b;return n.jsx(Ot,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(b=f.accountType)==null?void 0:b.message,children:Hu.map(x=>n.jsx("option",{value:x,children:x},x))})}})]}),n.jsx(Ve,{name:"bankName",control:d,render:({field:p})=>{var b;return n.jsx(me,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(b=f.bankName)==null?void 0:b.message})}})]})]}),n.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[n.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"}),n.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 Or=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:nj},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:sj},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:aj},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:ij}];function nj({className:e,...t}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:n.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 sj({className:e,...t}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:n.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 aj({className:e,...t}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:n.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 ij({className:e,...t}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:n.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 fn({title:e,subtitle:t,icon:r,action:s}){return n.jsxs("div",{className:"mb-6 flex flex-wrap items-start justify-between gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:n.jsx(r,{className:"h-5 w-5"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),n.jsx("p",{className:"text-sm text-slate-500",children:t})]})]}),s]})}function oj(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function lj({status:e}){const t=jn({status:e});return n.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 cj({entityId:e}){const[t,r]=v.useState(!1),[s,a]=v.useState(null),[i,o]=v.useState(1),[l,c]=v.useState(tt),u=Or.find(S=>S.id==="bank-accounts"),d=u.icon;v.useEffect(()=>{o(1)},[e,l]);const{data:m,isLoading:h,isError:f,isFetching:g}=ve({queryKey:["bank-accounts",e,i,l],queryFn:()=>Hn({entityId:e,pageNumber:i,pageSize:l}),enabled:e!==null,placeholderData:S=>S}),p=(m==null?void 0:m.items)??[],b=(m==null?void 0:m.totalCount)??0,x=e!==null&&g;return n.jsxs("div",{children:[n.jsx(fn,{title:u.title,subtitle:u.subtitle,icon:d,action:n.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:[n.jsx(uj,{}),"Add Bank Account"]})}),n.jsx(fu,{open:t,entityId:e,onClose:()=>r(!1)}),n.jsx(rj,{open:s!==null,account:s,onClose:()=>a(null)}),n.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[x?n.jsx(Vr,{label:"Loading bank accounts…"}):null,n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[700px] text-left text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[n.jsx("th",{className:"px-5 py-3",children:"Bank"}),n.jsx("th",{className:"px-5 py-3",children:"Account"}),n.jsx("th",{className:"px-5 py-3",children:"Routing"}),n.jsx("th",{className:"px-5 py-3",children:"Type"}),n.jsx("th",{className:"px-5 py-3",children:"Status"}),n.jsx("th",{className:"px-5 py-3"})]})}),n.jsx("tbody",{children:h&&!m?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):f?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load bank accounts."})}):e?p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No bank accounts connected yet."})}):p.map(S=>n.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[n.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:S.bankName}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:oj(S.accountNumber)}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:S.routingNumber}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:S.accountType}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(lj,{status:S.status})}),n.jsx("td",{className:"px-5 py-4 text-right",children:n.jsx(Xv,{account:S,entityId:e,onEdit:a})})]},S.bankAccountDetailId)):n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage bank accounts."})})})]})}),e!==null?n.jsx(vn,{page:i,pageSize:l,totalCount:b,onPageChange:o,onPageSizeChange:c,disabled:h||g}):null]})]})}function uj(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function dj({open:e,entity:t,onClose:r}){var N,E,D,A,I,_,L,ie,U,Q,te,H;const s=vt(),[a,i]=v.useState(null),[o,l]=v.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,setValue:h,getValues:f,formState:{errors:g}}=$t({resolver:zt(au),defaultValues:al(t),shouldUnregister:!1}),p=d("accountType"),b=d("entityType"),x=p==="Individual"?su:nu,S=G=>{const J=f("accountType");if(J===G)return;const he=f("lastName");iu(J,G,h,he),h("accountType",G),queueMicrotask(()=>{h("lastName",he),h("firstName",""),J==="Business"&&G==="Individual"&&h("tradeName","")})};v.useEffect(()=>{if(e){const G=al(t);m(G),i(null)}},[t,e,m]),v.useEffect(()=>{if(!e)return;const G=J=>{J.key==="Escape"&&r()};return document.addEventListener("keydown",G),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",G),document.body.style.overflow=""}},[e,r]),v.useEffect(()=>{x.includes(b)||h("entityType",p==="Individual"?"Sole Proprietorship":"LLP")},[p,b,x,h]);const w=u(async G=>{i(null),l(!0);try{await $h(t.entityId,Jy(G)),await s.invalidateQueries({queryKey:["entities","mine"]}),r()}catch(J){i(st(J,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?_s.createPortal(n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[n.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),n.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:[n.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[n.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),n.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),n.jsxs("form",{onSubmit:w,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[n.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?n.jsx("div",{className:"mb-5",children:n.jsx(Qt,{message:a})}):null,n.jsxs("div",{className:"space-y-8",children:[n.jsx("input",{type:"hidden",...c("ein")}),n.jsx(fr,{step:1,title:"ENTITY DETAILS",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{children:[n.jsx(mn,{label:"Account Type",required:!0}),n.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:"Business",checked:p==="Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>S("Business")}),"Business"]}),n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:"Individual",checked:p==="Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>S("Individual")}),"Individual"]})]})]}),n.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:p==="Individual"?n.jsxs(n.Fragment,{children:[n.jsx(me,{label:"First name",required:!0,placeholder:"Enter",error:(N=g.firstName)==null?void 0:N.message,...c("firstName")},"entity-first-name"),n.jsx(me,{label:"Last name",required:!0,placeholder:"Enter",error:(E=g.lastName)==null?void 0:E.message,...c("lastName")},"entity-last-name")]}):n.jsxs(n.Fragment,{children:[n.jsx(me,{label:"Business Name",required:!0,placeholder:"Enter",error:(D=g.lastName)==null?void 0:D.message,...c("lastName")},"entity-business-name"),n.jsx(me,{label:"Trade Name, if any",placeholder:"Enter",error:(A=g.tradeName)==null?void 0:A.message,...c("tradeName")},"entity-trade-name")]})}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"EIN",readOnly:!0,value:Mr(t.idNumber),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),n.jsx(Ot,{label:"Entity Type",required:!0,error:(I=g.entityType)==null?void 0:I.message,...c("entityType"),children:x.map(G=>n.jsx("option",{value:G,children:G},G))})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(_=g.email)==null?void 0:_.message,...c("email")}),n.jsxs("div",{children:[n.jsx(mn,{label:"Phone Number",required:!0}),n.jsxs("div",{className:"flex gap-2",children:[n.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:[n.jsx("option",{value:"+1",children:"+1"}),n.jsx("option",{value:"+91",children:"+91"})]}),n.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 ${g.phoneNumber?"border-red-300":"border-slate-200"}`,...c("phoneNumber")})]}),g.phoneNumber?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:g.phoneNumber.message}):null]})]})]})}),n.jsx("div",{className:"border-t border-slate-200"}),n.jsx(fr,{title:"ADDRESS DETAILS",muted:!0,children:n.jsxs("div",{className:"space-y-5",children:[n.jsx(me,{label:"Address Line 1",required:!0,error:(L=g.address1)==null?void 0:L.message,...c("address1")}),n.jsx(me,{label:"Address Line 2",error:(ie=g.address2)==null?void 0:ie.message,...c("address2")}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"City",required:!0,error:(U=g.city)==null?void 0:U.message,...c("city")}),n.jsxs(Ot,{label:"State",required:!0,error:(Q=g.state)==null?void 0:Q.message,...c("state"),children:[n.jsx("option",{value:"",children:"Select"}),Ri.map(G=>n.jsx("option",{value:G,children:G},G))]})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"ZIP Code",required:!0,error:(te=g.zipCode)==null?void 0:te.message,...c("zipCode")}),n.jsxs(Ot,{label:"Country",required:!0,error:(H=g.country)==null?void 0:H.message,...c("country"),children:[n.jsx("option",{value:"United States",children:"United States"}),n.jsx("option",{value:"Canada",children:"Canada"})]})]})]})})]})]}),n.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[n.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"}),n.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 mj({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?n.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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"?n.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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"})}):n.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:n.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 Pn({label:e,value:t,icon:r}){return n.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:n.jsx(mj,{icon:r})}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-xs text-slate-500",children:e}),n.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function hj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function fj({entity:e}){const[t,r]=v.useState(!1),s=Or.find(c=>c.id==="entity-details"),a=s.icon;if(!e)return n.jsxs("div",{children:[n.jsx(fn,{title:s.title,subtitle:s.subtitle,icon:a}),n.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:n.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=Gt(e),o=e.accountType==="Business"?i:`${e.firstName} ${e.lastName}`.trim()||i,l=Di(o);return n.jsxs("div",{children:[n.jsx(fn,{title:s.title,subtitle:s.subtitle,icon:a,action:n.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"})}),n.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[n.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}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),n.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),n.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[n.jsx(Pn,{label:"Entity Name",value:i,icon:"entity"}),n.jsx(Pn,{label:"Tax ID",value:Mr(e.idNumber),icon:"tax"}),n.jsx(Pn,{label:"Email Address",value:e.email,icon:"email"}),n.jsx(Pn,{label:"Phone Number",value:Rr(e.phoneNumber),icon:"phone"}),n.jsx(Pn,{label:"Account Type",value:hj(e.accountType),icon:"account"})]}),n.jsx(dj,{open:t,entity:e,onClose:()=>r(!1)})]})}function Ku({activeSection:e,onSectionChange:t,items:r}){return n.jsx("nav",{className:"space-y-2",children:r.map(s=>{const a=e===s.id,i=s.icon;return n.jsxs("button",{type:"button",onClick:()=>t(s.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:[n.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:n.jsx(i,{className:"h-5 w-5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:`block text-sm font-semibold ${a?"text-slate-900":"text-slate-700"}`,children:s.title}),n.jsx("span",{className:"block truncate text-xs text-slate-500",children:s.subtitle})]}),n.jsx(pj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},s.id)})})}function pj({className:e}){return n.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function xj({pageNumber:e=1,pageSize:t=tt}={}){const r=new URLSearchParams({pageNumber:String(e),pageSize:String(t)});return fe(`/portal/payments/transactions?${r}`)}function gj(e){const t=e.cardBrand?e.cardBrand.charAt(0).toUpperCase()+e.cardBrand.slice(1):null,r=t&&e.cardLast4?`${t} •••• ${e.cardLast4}`:e.cardholderName??"—";return{paymentHistoryId:e.govPayTransactionId,entityId:0,date:e.createdAt,amount:e.amount,jurisdiction:e.paymentType==="federal"?"Federal":"State",type:e.paymentType==="federal"?"Federal":"State",accountName:r,reference:e.stripePaymentIntentId}}function yj(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function bj(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function vj({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 n.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]}`,children:e})}function jj({entityId:e}){const t=Or.find(p=>p.id==="payment-history"),r=t.icon,[s,a]=v.useState(1),[i,o]=v.useState(tt);v.useEffect(()=>{a(1)},[e,i]);const{data:l,isLoading:c,isError:u,isFetching:d}=ve({queryKey:["payment-transactions",s,i],queryFn:()=>xj({pageNumber:s,pageSize:i}),enabled:e!==null,placeholderData:p=>p}),m=((l==null?void 0:l.items)??[]).map(gj),h=(l==null?void 0:l.totalCount)??0,f=e!==null&&h>0,g=e!==null&&d;return n.jsxs("div",{children:[n.jsx(fn,{title:t.title,subtitle:t.subtitle,icon:r,action:n.jsxs("button",{type:"button",disabled:!f,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:[n.jsx(Nj,{}),"Export to Excel"]})}),n.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[g?n.jsx(Vr,{label:"Loading payment history…"}):null,n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[n.jsx("th",{className:"px-5 py-3",children:"Date"}),n.jsx("th",{className:"px-5 py-3",children:"Amount"}),n.jsx("th",{className:"px-5 py-3",children:"Jurisdiction / Type"}),n.jsx("th",{className:"px-5 py-3",children:"Type"}),n.jsx("th",{className:"px-5 py-3",children:"Account Name"}),n.jsx("th",{className:"px-5 py-3",children:"Reference"})]})}),n.jsx("tbody",{children:c&&!l?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):u?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load payment history."})}):e?m.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No payment transactions to display yet."})}):m.map(p=>n.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[n.jsx("td",{className:"px-5 py-4 text-slate-600",children:bj(p.date)}),n.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:yj(p.amount)}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.jurisdiction}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(vj,{type:p.type})}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.accountName}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.reference})]},p.paymentHistoryId)):n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to view payment history."})})})]})}),e!==null?n.jsx(vn,{page:s,pageSize:i,totalCount:h,onPageChange:a,onPageSizeChange:o,disabled:c||d}):null]})]})}function Nj(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:n.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 wj({count:e}){const t=e===1?"1 Payment":`${e} Payments`;return n.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 Sj({status:e}){const r=(e??"Active").toLowerCase()==="active";return n.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 kj(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function Cj({entityId:e,accounts:t=[],isLoading:r=!1,isError:s=!1}){const a=Se(),i=Or.find(f=>f.id==="tax-accounts"),o=i.icon,[l,c]=v.useState(1),[u,d]=v.useState(tt);v.useEffect(()=>{c(1)},[e,u,t.length]);const m=t.length,h=v.useMemo(()=>{const f=(l-1)*u;return t.slice(f,f+u)},[t,l,u]);return n.jsxs("div",{children:[n.jsx(fn,{title:i.title,subtitle:i.subtitle,icon:o,action:n.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:[n.jsx(Aj,{}),"Add Tax Account"]})}),n.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[n.jsx("th",{className:"px-5 py-3",children:"Account Name"}),n.jsx("th",{className:"px-5 py-3",children:"Federal/State ID"}),n.jsx("th",{className:"px-5 py-3",children:"Payments"}),n.jsx("th",{className:"px-5 py-3",children:"Form Type"}),n.jsx("th",{className:"px-5 py-3",children:"Status"})]})}),n.jsx("tbody",{children:r?n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):s?n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load tax accounts."})}):e?m===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"No tax accounts connected yet."})}):h.map(f=>n.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[n.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:f.accountName}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.federalStateId}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(wj,{count:f.paymentCount})}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:kj(f.formTypes)}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(Sj,{status:f.status})})]},f.taxAccountId)):n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage tax accounts."})})})]})}),e!==null?n.jsx(vn,{page:l,pageSize:u,totalCount:m,onPageChange:c,onPageSizeChange:d,disabled:r}):null]})]})}function Aj(){return n.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const yl="rounded-2xl border border-slate-200 bg-white shadow-sm";function Pj(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function to(){const{selectedEntity:e}=mt(),r=we().state,[s,a]=v.useState(Pj(r==null?void 0:r.section)?r.section:"bank-accounts");return n.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[n.jsx("div",{className:`${yl} p-3`,children:n.jsx(Ku,{items:Or,activeSection:s,onSectionChange:a})}),n.jsx("div",{className:`${yl} p-6 lg:p-8`,children:s==="bank-accounts"?n.jsx(cj,{entityId:(e==null?void 0:e.entityId)??null}):s==="tax-accounts"?n.jsx(Cj,{entityId:(e==null?void 0:e.entityId)??null}):s==="payment-history"?n.jsx(jj,{entityId:(e==null?void 0:e.entityId)??null}):n.jsx(fj,{entity:e})})]})}const Ej=["Alexandria","Arlington","Chesapeake","Hampton","Lynchburg","Newport News","Norfolk","Richmond","Roanoke","Virginia Beach"],_j=Ri.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}],Tj=[{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1}],Fj=Jt({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()}),Dj=Fj.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 s of r){const a=e[s.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:tr.custom,message:`${s.label} is required`,path:[s.key]})}}),Rj={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function Oj({onCancel:e,onSuccess:t}){var x,S,w,N,E,D;const{showSuccess:r}=Os(),[s,a]=v.useState(null),[i,o]=v.useState(!1),{register:l,handleSubmit:c,watch:u,setValue:d,formState:{errors:m}}=$t({resolver:zt(Dj),defaultValues:Rj}),h=u("state"),f=u("city"),g=h==="VA",p=v.useMemo(()=>h==="VA"?[...Ej]:[],[h]);v.useEffect(()=>{if(p.length===0){f&&d("city","");return}f&&!p.includes(f)&&d("city","")},[p,f,d]);const b=c(async A=>{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(A)}catch{a("Unable to save tax account. Please try again.")}finally{o(!1)}});return n.jsxs("form",{onSubmit:b,noValidate:!0,className:"space-y-8",children:[s?n.jsx(Qt,{message:s}):null,n.jsx(fr,{step:1,title:"TAX ACCOUNT DETAILS",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsxs(Ot,{label:"Select State",required:!0,error:(x=m.state)==null?void 0:x.message,...l("state"),children:[n.jsx("option",{value:"",children:"Select"}),_j.map(A=>n.jsx("option",{value:A.code,children:A.name},A.code))]}),p.length>0?n.jsxs(Ot,{label:"City",required:!0,error:(S=m.city)==null?void 0:S.message,...l("city"),children:[n.jsx("option",{value:"",children:"Select"}),p.map(A=>n.jsx("option",{value:A,children:A},A))]}):n.jsx(me,{label:"City",required:!0,placeholder:"Enter",error:(w=m.city)==null?void 0:w.message,...l("city")})]}),n.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:n.jsx(me,{label:"Zip Code",required:!0,placeholder:"Enter",error:(N=m.zipCode)==null?void 0:N.message,...l("zipCode")})}),n.jsx(me,{label:"Address Line 1",required:!0,placeholder:"Enter",error:(E=m.address1)==null?void 0:E.message,...l("address1")}),n.jsx(me,{label:"Address Line 2",placeholder:"Enter",error:(D=m.address2)==null?void 0:D.message,...l("address2")})]})}),g?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-slate-200"}),n.jsxs(fr,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[n.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:Ij.map(A=>{var I;return n.jsx(me,{label:A.label,required:A.required,placeholder:"Enter",error:(I=m[A.name])==null?void 0:I.message,...l(A.name)},A.name)})}),n.jsx("div",{className:"mt-5 space-y-5",children:Tj.map(A=>{var I;return n.jsx(me,{label:A.label,required:A.required,placeholder:"Enter",error:(I=m[A.name])==null?void 0:I.message,...l(A.name)},A.name)})})]})]}):null,n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[n.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"}),n.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 xa="rounded-2xl border border-slate-200 bg-white shadow-sm";function ro(){const e=Se(),{selectedEntity:t}=mt(),r=Or.find(i=>i.id==="tax-accounts"),s=r.icon,a=(i="tax-accounts")=>{e("/settings",{state:{section:i}})};return t?n.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[n.jsx("div",{className:`${xa} p-3`,children:n.jsx(Ku,{items:Or,activeSection:"tax-accounts",onSectionChange:a})}),n.jsxs("div",{className:`${xa} p-6 lg:p-8`,children:[n.jsx(fn,{title:r.title,subtitle:r.subtitle,icon:s}),n.jsx(Oj,{onCancel:()=>a("tax-accounts"),onSuccess:()=>a("tax-accounts")})]})]}):n.jsx("div",{className:xa+" p-6 lg:p-8",children:n.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function $j({paymentsMode:e="all"}){return n.jsxs(oi,{children:[n.jsx(re,{index:!0,element:n.jsx(gi,{})}),n.jsx(re,{path:"create-entity",element:n.jsx(bi,{})}),n.jsx(re,{path:"create-entity/form",element:n.jsx(Oi,{})}),n.jsxs(re,{element:n.jsx(yi,{}),children:[n.jsx(re,{path:"entities",element:n.jsx(zi,{})}),n.jsx(re,{path:"dashboard",element:n.jsx(Li,{})}),n.jsx(re,{path:"payments",element:n.jsx(Bi,{paymentsMode:e})}),n.jsx(re,{path:"payments/federal/new",element:n.jsx(Cu,{})}),n.jsx(re,{path:"payments/federal/:federalPaymentId/edit",element:n.jsx(Pu,{})}),n.jsx(re,{path:"payments/federal/:federalPaymentId/view",element:n.jsx(Eu,{})}),n.jsx(re,{path:"payments/state/new",element:n.jsx(Fu,{})}),n.jsx(re,{path:"payments/state/:statePaymentDetailId/edit",element:n.jsx(Du,{})}),n.jsx(re,{path:"payments/state/:statePaymentDetailId/view",element:n.jsx(Ru,{})}),n.jsx(re,{path:"payments/state/authorization",element:n.jsx(Lu,{})}),n.jsx(re,{path:"payments/federal/authorization",element:n.jsx(qu,{})}),n.jsx(re,{path:"payments/federal/individual-enrollment",element:n.jsx(Yu,{})}),n.jsx(re,{path:"tax-forms",element:n.jsx(Jv,{})}),n.jsx(re,{path:"settings",element:n.jsx(to,{})}),n.jsx(re,{path:"settings/tax-accounts/new",element:n.jsx(ro,{})})]}),n.jsx(re,{path:"*",element:n.jsx(Be,{to:"/",replace:!0})})]})}const ei="tax-remittance:payment-complete",Lj=v.forwardRef(function(t,r){const s=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=s.current)==null?void 0:o.call(s,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(ei,{detail:{paymentId:i}}))}})),n.jsx(xi,{...t,navigateFnRef:s,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:n.jsx($j,{paymentsMode:"all"})})}),zj=v.forwardRef(function(t,r){const s=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=s.current)==null?void 0:o.call(s,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),n.jsx(xi,{...t,navigateFnRef:s,selectEntityFnRef:a,enabledPayments:["federal"],children:n.jsxs(oi,{children:[n.jsx(re,{index:!0,element:n.jsx(gi,{})}),n.jsx(re,{path:"create-entity",element:n.jsx(bi,{})}),n.jsx(re,{path:"create-entity/form",element:n.jsx(Oi,{})}),n.jsxs(re,{element:n.jsx(yi,{}),children:[n.jsx(re,{path:"entities",element:n.jsx(zi,{})}),n.jsx(re,{path:"dashboard",element:n.jsx(Li,{})}),n.jsx(re,{path:"payments",element:n.jsx(Bi,{paymentsMode:"federal"})}),n.jsx(re,{path:"payments/federal/new",element:n.jsx(Cu,{})}),n.jsx(re,{path:"payments/federal/:federalPaymentId/edit",element:n.jsx(Pu,{})}),n.jsx(re,{path:"payments/federal/:federalPaymentId/view",element:n.jsx(Eu,{})}),n.jsx(re,{path:"payments/federal/authorization",element:n.jsx(qu,{})}),n.jsx(re,{path:"payments/federal/individual-enrollment",element:n.jsx(Yu,{})}),n.jsx(re,{path:"settings",element:n.jsx(to,{})}),n.jsx(re,{path:"settings/tax-accounts/new",element:n.jsx(ro,{})})]}),n.jsx(re,{path:"*",element:n.jsx(Be,{to:"/",replace:!0})})]})})}),Mj=v.forwardRef(function(t,r){const s=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=s.current)==null?void 0:o.call(s,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),n.jsx(xi,{...t,navigateFnRef:s,selectEntityFnRef:a,enabledPayments:["state"],children:n.jsxs(oi,{children:[n.jsx(re,{index:!0,element:n.jsx(gi,{})}),n.jsx(re,{path:"create-entity",element:n.jsx(bi,{})}),n.jsx(re,{path:"create-entity/form",element:n.jsx(Oi,{})}),n.jsxs(re,{element:n.jsx(yi,{}),children:[n.jsx(re,{path:"entities",element:n.jsx(zi,{})}),n.jsx(re,{path:"dashboard",element:n.jsx(Li,{})}),n.jsx(re,{path:"payments",element:n.jsx(Bi,{paymentsMode:"state"})}),n.jsx(re,{path:"payments/state/new",element:n.jsx(Fu,{})}),n.jsx(re,{path:"payments/state/:statePaymentId/edit",element:n.jsx(Du,{})}),n.jsx(re,{path:"payments/state/:statePaymentId/view",element:n.jsx(Ru,{})}),n.jsx(re,{path:"payments/state/authorization",element:n.jsx(Lu,{})}),n.jsx(re,{path:"settings",element:n.jsx(to,{})}),n.jsx(re,{path:"settings/tax-accounts/new",element:n.jsx(ro,{})})]}),n.jsx(re,{path:"*",element:n.jsx(Be,{to:"/",replace:!0})})]})})});exports.ApiError=yn;exports.FederalPaymentWidget=zj;exports.StatePaymentWidget=Mj;exports.TaxRemittanceEmbedded=Lj;exports.setRuntimeApiBaseUrl=uc;
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 Xc(e,t){var l,c,u,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,x={...f},p=h.ref;if(h.ref=null,p){s(p);const g=e.seen.get(p),k=g.schema;if(k.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(k)):Object.assign(f,k),Object.assign(f,x),m._zod.parent===p)for(const S in f)S==="$ref"||S==="allOf"||S in x||delete f[S];if(k.$ref&&g.def)for(const S in f)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(f[S])===JSON.stringify(g.def[S])&&delete f[S]}const N=m._zod.parent;if(N&&N!==p){s(N);const g=e.seen.get(N);if(g!=null&&g.schema.$ref&&(f.$ref=g.schema.$ref,g.def))for(const k in f)k==="$ref"||k==="allOf"||k in g.def&&JSON.stringify(f[k])===JSON.stringify(g.def[k])&&delete f[k]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())s(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,n.def??n.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:Ps(t,"input",e.processors),output:Ps(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return Ge(s.element,n);if(s.type==="set")return Ge(s.valueType,n);if(s.type==="lazy")return Ge(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return Ge(s.innerType,n);if(s.type==="intersection")return Ge(s.left,n)||Ge(s.right,n);if(s.type==="record"||s.type==="map")return Ge(s.keyType,n)||Ge(s.valueType,n);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ge(s.in,n)||Ge(s.out,n);if(s.type==="object"){for(const a in s.shape)if(Ge(s.shape[a],n))return!0;return!1}if(s.type==="union"){for(const a of s.options)if(Ge(a,n))return!0;return!1}if(s.type==="tuple"){for(const a of s.items)if(Ge(a,n))return!0;return!!(s.rest&&Ge(s.rest,n))}return!1}const bg=(e,t={})=>n=>{const s=Jc({...n,processors:t});return We(e,s),Gc(s,e),Xc(s,e)},Ps=(e,t,n={})=>s=>{const{libraryOptions:a,target:i}=s??{},o=Jc({...a??{},target:i,io:t,processors:n});return We(e,o),Gc(o,e),Xc(o,e)},vg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jg=(e,t,n,s)=>{const a=n;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=vg[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}))])}},Ng=(e,t,n,s)=>{n.type="boolean"},wg=(e,t,n,s)=>{n.not={}},Sg=(e,t,n,s)=>{},kg=(e,t,n,s)=>{const a=e._zod.def,i=$c(a.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Cg=(e,t,n,s)=>{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];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},Ag=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Pg=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Eg=(e,t,n,s)=>{const a=n,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=We(i.element,t,{...s,path:[...s.path,"items"]})},Ig=(e,t,n,s)=>{var u;const a=n,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const d in o)a.properties[d]=We(o[d],t,{...s,path:[...s.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=We(i.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},_g=(e,t,n,s)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>We(l,t,{...s,path:[...s.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},Tg=(e,t,n,s)=>{const a=e._zod.def,i=We(a.left,t,{...s,path:[...s.path,"allOf",0]}),o=We(a.right,t,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];n.allOf=c},Fg=(e,t,n,s)=>{const a=e._zod.def,i=We(a.innerType,t,s),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Dg=(e,t,n,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType},Rg=(e,t,n,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},$g=(e,t,n,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Og=(e,t,n,s)=>{const a=e._zod.def;We(a.innerType,t,s);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")}n.default=o},Lg=(e,t,n,s)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;We(o,t,s);const l=t.seen.get(e);l.ref=o},zg=(e,t,n,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType,n.readOnly=!0},eu=(e,t,n,s)=>{const a=e._zod.def;We(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType};function Ha(){return Ha=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Ha.apply(null,arguments)}function Xo(e,t){try{var n=e()}catch(s){return t(s)}return n&&n.then?n.then(void 0,t):n}function Mg(e,t){for(var n={};e.length;){var s=e[0],a=s.code,i=s.message,o=s.path.join(".");if(!n[o])if("unionErrors"in s){var l=s.unionErrors[0].errors[0];n[o]={message:l.message,type:l.code}}else n[o]={message:i,type:a};if("unionErrors"in s&&s.unionErrors.forEach(function(d){return d.errors.forEach(function(m){return e.push(m)})}),t){var c=n[o].types,u=c&&c[s.code];n[o]=ki(o,t,n,a,u?[].concat(u,s.message):s.message)}e.shift()}return n}function qg(e,t){for(var n={},s=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!n[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];n[l]={message:c.message,type:c.code}}else n[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push(Ha({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=n[l].types,d=u&&u[a.code];n[l]=ki(l,t,n,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)s();return n}function Ot(e,t,n){if(n===void 0&&(n={}),(function(s){return"_def"in s&&typeof s._def=="object"&&"typeName"in s._def})(e))return function(s,a,i){try{return Promise.resolve(Xo(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](s,t)).then(function(o){return i.shouldUseNativeValidation&&Ua({},i),{errors:{},values:n.raw?Object.assign({},s):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Oo(Mg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(s){return"_zod"in s&&typeof s._zod=="object"})(e))return function(s,a,i){try{return Promise.resolve(Xo(function(){return Promise.resolve((n.mode==="sync"?Bf:Vf)(e,s,t)).then(function(o){return i.shouldUseNativeValidation&&Ua({},i),{errors:{},values:n.raw?Object.assign({},s):o}})},function(o){if((function(l){return l instanceof Fi})(o))return{values:{},errors:Oo(qg(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 On({label:e,required:t=!1,htmlFor:n}){return r.jsxs("label",{htmlFor:n,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?r.jsx("span",{className:"text-red-500",children:" *"}):null]})}const fe=v.forwardRef(function({label:t,required:n=!1,error:s,id:a,className:i="",...o},l){const c=a??o.name;return r.jsxs("div",{children:[r.jsx(On,{label:t,required:n,htmlFor:c}),r.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 ${s?"border-red-300":"border-slate-200"} ${i}`,...o}),s?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:s}):null]})}),Kt=v.forwardRef(function({label:t,required:n=!1,error:s,id:a,className:i="",children:o,...l},c){const u=a??l.name;return r.jsxs("div",{children:[r.jsx(On,{label:t,required:n,htmlFor:u}),r.jsxs("div",{className:"relative",children:[r.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 ${s?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),r.jsx(Bg,{})]}),s?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:s}):null]})});function gn({step:e,title:t,muted:n=!1,children:s}){return r.jsxs("section",{className:"space-y-5",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e?r.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,r.jsx("h3",{className:`text-sm font-semibold tracking-wide ${n?"text-slate-400":"text-gov-700"}`,children:t})]}),s]})}function Bg(){return r.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:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Gt({variant:e="error",title:t,message:n}){const s=e==="error"?"border-red-200 bg-red-50 text-red-800":"border-slate-200 bg-white text-slate-700";return r.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${s}`,role:"alert",children:[t?r.jsx("p",{className:"font-medium",children:t}):null,r.jsx("p",{className:t?"mt-1":void 0,children:n})]})}function st(e,t){var n;if(e instanceof yr){if(e.details){const s=(n=Object.values(e.details)[0])==null?void 0:n[0];if(s)return s}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Vg=F("ZodISODateTime",(e,t)=>{Yp.init(e,t),_e.init(e,t)});function Ug(e){return Jx(Vg,e)}const Zg=F("ZodISODate",(e,t)=>{Kp.init(e,t),_e.init(e,t)});function Wg(e){return Gx(Zg,e)}const Hg=F("ZodISOTime",(e,t)=>{Qp.init(e,t),_e.init(e,t)});function Yg(e){return Xx(Hg,e)}const Kg=F("ZodISODuration",(e,t)=>{Jp.init(e,t),_e.init(e,t)});function Qg(e){return eg(Kg,e)}const Jg=(e,t)=>{Fi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>qf(e,n)},flatten:{value:n=>Mf(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Za,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Za,2)}},isEmpty:{get(){return e.issues.length===0}}})},bt=F("ZodError",Jg,{Parent:Error}),Gg=Vs(bt),Xg=Us(bt),ey=Zs(bt),ty=Ws(bt),ny=Wf(bt),ry=Hf(bt),sy=Yf(bt),ay=Kf(bt),iy=Qf(bt),oy=Jf(bt),ly=Gf(bt),cy=Xf(bt),el=new WeakMap;function Ys(e,t,n){const s=Object.getPrototypeOf(e);let a=el.get(s);if(a||(a=new Set,el.set(s,a)),!a.has(t)){a.add(t);for(const i in n){const o=n[i];Object.defineProperty(s,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 $e=F("ZodType",(e,t)=>(Re.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ps(e,"input"),output:Ps(e,"output")}}),e.toJSONSchema=bg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,s)=>Gg(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>ey(e,n,s),e.parseAsync=async(n,s)=>Xg(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>ty(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>ny(e,n,s),e.decode=(n,s)=>ry(e,n,s),e.encodeAsync=async(n,s)=>sy(e,n,s),e.decodeAsync=async(n,s)=>ay(e,n,s),e.safeEncode=(n,s)=>iy(e,n,s),e.safeDecode=(n,s)=>oy(e,n,s),e.safeEncodeAsync=async(n,s)=>ly(e,n,s),e.safeDecodeAsync=async(n,s)=>cy(e,n,s),Ys(e,"ZodType",{check(...n){const s=this.def;return this.clone(yn(s,{checks:[...s.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,s){return bn(this,n,s)},brand(){return this},register(n,s){return n.add(this,s),this},refine(n,s){return this.check(tb(n,s))},superRefine(n,s){return this.check(nb(n,s))},overwrite(n){return this.check(br(n))},optional(){return rl(this)},exactOptional(){return By(this)},nullable(){return sl(this)},nullish(){return rl(sl(this))},nonoptional(n){return Yy(this,n)},array(){return Fy(this)},or(n){return ru([this,n])},and(n){return Oy(this,n)},transform(n){return al(this,My(n))},default(n){return Zy(this,n)},prefault(n){return Hy(this,n)},catch(n){return Qy(this,n)},pipe(n){return al(this,n)},readonly(){return Xy(this)},describe(n){const s=this.clone();return Ir.add(s,{description:n}),s},meta(...n){if(n.length===0)return Ir.get(this);const s=this.clone();return Ir.add(s,n[0]),s},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Ir.get(e))==null?void 0:n.description},configurable:!0}),e)),tu=F("_ZodString",(e,t)=>{Di.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,a,i)=>jg(e,s,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ys(e,"_ZodString",{regex(...s){return this.check(sg(...s))},includes(...s){return this.check(og(...s))},startsWith(...s){return this.check(lg(...s))},endsWith(...s){return this.check(cg(...s))},min(...s){return this.check(As(...s))},max(...s){return this.check(Kc(...s))},length(...s){return this.check(Qc(...s))},nonempty(...s){return this.check(As(1,...s))},lowercase(s){return this.check(ag(s))},uppercase(s){return this.check(ig(s))},trim(){return this.check(dg())},normalize(...s){return this.check(ug(...s))},toLowerCase(){return this.check(mg())},toUpperCase(){return this.check(hg())},slugify(){return this.check(fg())}})}),uy=F("ZodString",(e,t)=>{Di.init(e,t),tu.init(e,t),e.email=n=>e.check(Yc(nu,n)),e.url=n=>e.check(Rx(my,n)),e.jwt=n=>e.check(Qx(Ay,n)),e.emoji=n=>e.check($x(hy,n)),e.guid=n=>e.check(Go(tl,n)),e.uuid=n=>e.check(_x(is,n)),e.uuidv4=n=>e.check(Tx(is,n)),e.uuidv6=n=>e.check(Fx(is,n)),e.uuidv7=n=>e.check(Dx(is,n)),e.nanoid=n=>e.check(Ox(fy,n)),e.guid=n=>e.check(Go(tl,n)),e.cuid=n=>e.check(Lx(py,n)),e.cuid2=n=>e.check(zx(xy,n)),e.ulid=n=>e.check(Mx(gy,n)),e.base64=n=>e.check(Hx(Sy,n)),e.base64url=n=>e.check(Yx(ky,n)),e.xid=n=>e.check(qx(yy,n)),e.ksuid=n=>e.check(Bx(by,n)),e.ipv4=n=>e.check(Vx(vy,n)),e.ipv6=n=>e.check(Ux(jy,n)),e.cidrv4=n=>e.check(Zx(Ny,n)),e.cidrv6=n=>e.check(Wx(wy,n)),e.e164=n=>e.check(Kx(Cy,n)),e.datetime=n=>e.check(Ug(n)),e.date=n=>e.check(Wg(n)),e.time=n=>e.check(Yg(n)),e.duration=n=>e.check(Qg(n))});function _(e){return Ix(uy,e)}const _e=F("ZodStringFormat",(e,t)=>{Pe.init(e,t),tu.init(e,t)}),nu=F("ZodEmail",(e,t)=>{zp.init(e,t),_e.init(e,t)});function dy(e){return Yc(nu,e)}const tl=F("ZodGUID",(e,t)=>{Op.init(e,t),_e.init(e,t)}),is=F("ZodUUID",(e,t)=>{Lp.init(e,t),_e.init(e,t)}),my=F("ZodURL",(e,t)=>{Mp.init(e,t),_e.init(e,t)}),hy=F("ZodEmoji",(e,t)=>{qp.init(e,t),_e.init(e,t)}),fy=F("ZodNanoID",(e,t)=>{Bp.init(e,t),_e.init(e,t)}),py=F("ZodCUID",(e,t)=>{Vp.init(e,t),_e.init(e,t)}),xy=F("ZodCUID2",(e,t)=>{Up.init(e,t),_e.init(e,t)}),gy=F("ZodULID",(e,t)=>{Zp.init(e,t),_e.init(e,t)}),yy=F("ZodXID",(e,t)=>{Wp.init(e,t),_e.init(e,t)}),by=F("ZodKSUID",(e,t)=>{Hp.init(e,t),_e.init(e,t)}),vy=F("ZodIPv4",(e,t)=>{Gp.init(e,t),_e.init(e,t)}),jy=F("ZodIPv6",(e,t)=>{Xp.init(e,t),_e.init(e,t)}),Ny=F("ZodCIDRv4",(e,t)=>{ex.init(e,t),_e.init(e,t)}),wy=F("ZodCIDRv6",(e,t)=>{tx.init(e,t),_e.init(e,t)}),Sy=F("ZodBase64",(e,t)=>{nx.init(e,t),_e.init(e,t)}),ky=F("ZodBase64URL",(e,t)=>{sx.init(e,t),_e.init(e,t)}),Cy=F("ZodE164",(e,t)=>{ax.init(e,t),_e.init(e,t)}),Ay=F("ZodJWT",(e,t)=>{ox.init(e,t),_e.init(e,t)}),Py=F("ZodBoolean",(e,t)=>{lx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Ng(e,n,s)});function Qn(e){return tg(Py,e)}const Ey=F("ZodUnknown",(e,t)=>{cx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Sg()});function nl(){return ng(Ey)}const Iy=F("ZodNever",(e,t)=>{ux.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>wg(e,n,s)});function _y(e){return rg(Iy,e)}const Ty=F("ZodArray",(e,t)=>{dx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Eg(e,n,s,a),e.element=t.element,Ys(e,"ZodArray",{min(n,s){return this.check(As(n,s))},nonempty(n){return this.check(As(1,n))},max(n,s){return this.check(Kc(n,s))},length(n,s){return this.check(Qc(n,s))},unwrap(){return this.element}})});function Fy(e,t){return pg(Ty,e,t)}const Dy=F("ZodObject",(e,t)=>{hx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Ig(e,n,s,a),ve(e,"shape",()=>t.shape),Ys(e,"ZodObject",{keyof(){return Ks(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:nl()})},loose(){return this.clone({...this._zod.def,catchall:nl()})},strict(){return this.clone({...this._zod.def,catchall:_y()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Df(this,n)},safeExtend(n){return Rf(this,n)},merge(n){return $f(this,n)},pick(n){return Tf(this,n)},omit(n){return Ff(this,n)},partial(...n){return Of(su,this,n[0])},required(...n){return Lf(au,this,n[0])}})});function Xt(e,t){const n={type:"object",shape:e??{},...ne(t)};return new Dy(n)}const Ry=F("ZodUnion",(e,t)=>{fx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>_g(e,n,s,a),e.options=t.options});function ru(e,t){return new Ry({type:"union",options:e,...ne(t)})}const $y=F("ZodIntersection",(e,t)=>{px.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Tg(e,n,s,a)});function Oy(e,t){return new $y({type:"intersection",left:e,right:t})}const Ya=F("ZodEnum",(e,t)=>{xx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,a,i)=>kg(e,s,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,a)=>{const i={};for(const o of s)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ya({...t,checks:[],...ne(a),entries:i})},e.exclude=(s,a)=>{const i={...t.entries};for(const o of s)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ya({...t,checks:[],...ne(a),entries:i})}});function Ks(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Ya({type:"enum",entries:n,...ne(t)})}const Ly=F("ZodLiteral",(e,t)=>{gx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Cg(e,n,s),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 oa(e,t){return new Ly({type:"literal",values:Array.isArray(e)?e:[e],...ne(t)})}const zy=F("ZodTransform",(e,t)=>{yx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Pg(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Rc(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Or(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(Or(o))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function My(e){return new zy({type:"transform",transform:e})}const su=F("ZodOptional",(e,t)=>{Hc.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>eu(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function rl(e){return new su({type:"optional",innerType:e})}const qy=F("ZodExactOptional",(e,t)=>{bx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>eu(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function By(e){return new qy({type:"optional",innerType:e})}const Vy=F("ZodNullable",(e,t)=>{vx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Fg(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function sl(e){return new Vy({type:"nullable",innerType:e})}const Uy=F("ZodDefault",(e,t)=>{jx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Rg(e,n,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Zy(e,t){return new Uy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Lc(t)}})}const Wy=F("ZodPrefault",(e,t)=>{Nx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>$g(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function Hy(e,t){return new Wy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Lc(t)}})}const au=F("ZodNonOptional",(e,t)=>{wx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Dg(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function Yy(e,t){return new au({type:"nonoptional",innerType:e,...ne(t)})}const Ky=F("ZodCatch",(e,t)=>{Sx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Og(e,n,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qy(e,t){return new Ky({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Jy=F("ZodPipe",(e,t)=>{kx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Lg(e,n,s,a),e.in=t.in,e.out=t.out});function al(e,t){return new Jy({type:"pipe",in:e,out:t})}const Gy=F("ZodReadonly",(e,t)=>{Cx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>zg(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function Xy(e){return new Gy({type:"readonly",innerType:e})}const eb=F("ZodCustom",(e,t)=>{Ax.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,a)=>Ag(e,n)});function tb(e,t={}){return xg(eb,e,t)}function nb(e,t){return gg(e,t)}const rn={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Ri(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 en(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?(e.lastName||e.firstName).trim():`${e.firstName} ${e.lastName}`.trim()}function Vn(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function rb(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,3)}-${t.slice(3,5)}-${t.slice(5)}`}function sb(e,t){return t==="Individual"?rb(e):Vn(e)}function il(e,t){const n=e.replace(/\D/g,"").slice(0,9);return t==="Individual"?n.length<=3?n:n.length<=5?`${n.slice(0,3)}-${n.slice(3)}`:`${n.slice(0,3)}-${n.slice(3,5)}-${n.slice(5)}`:n.length<=2?n:`${n.slice(0,2)}-${n.slice(2)}`}function Ln(e){const t=e.replace(/\D/g,""),n=t.length===11&&t.startsWith("1")?t.slice(1):t;return n.length!==10?e:`+1 (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}const iu=["LLP","LLC","Corporation","S-Corp","Partnership"],ou=["Sole Proprietorship"],$i=["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"],ab={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming"},Ka=10,ib=/^\d{5}(-\d{4})?$/;function lu(e){const t=e.replace(/\D/g,"").slice(0,9);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`}const cu=Xt({accountType:Ks(["Business","Individual"]),firstName:_(),lastName:_(),tradeName:_(),ein:_(),entityType:_().min(1,"Entity type is required"),email:dy("Enter a valid email"),countryCode:_().min(1),phoneNumber:_().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Ka,`Phone number must be ${Ka} digits`),address1:_().min(1,"Address is required"),address2:_(),city:_().min(1,"City is required"),state:_().min(1,"State is required"),zipCode:_().min(1,"ZIP code is required"),country:_().min(1,"Country is required")}).superRefine((e,t)=>{e.country==="United States"&&!ib.test(e.zipCode.trim())&&t.addIssue({code:"custom",path:["zipCode"],message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)"});const n=e.accountType==="Individual"?"SSN":"EIN",s=e.ein.replace(/\D/g,"");if(s?s.length!==9&&t.addIssue({code:"custom",path:["ein"],message:`${n} must be 9 digits`}):t.addIssue({code:"custom",path:["ein"],message:`${n} is required`}),e.accountType==="Business"){e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Business name is required"});return}e.firstName.trim()||t.addIssue({code:"custom",path:["firstName"],message:"First name is required"}),e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Last name is required"})});function ob(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(-Ka)}}function ol(e){const{countryCode:t,national:n}=ob(e.phoneNumber),s=e.accountType==="Individual",a=(e.lastName||e.firstName||"").trim();return{accountType:s?"Individual":"Business",firstName:s?e.firstName??"":"",lastName:s?e.lastName??"":a,tradeName:s?"":e.tradeName??"",ein:Vn(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:n,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function uu(e,t,n,s){if(e!==t){if(e==="Business"&&t==="Individual"){n("firstName",""),n("lastName",s),n("tradeName","");return}e==="Individual"&&t==="Business"&&(n("firstName",""),n("lastName",s))}}function du(e){const t=e.lastName.trim();return e.accountType==="Business"?{accountType:e.accountType,firstName:"",lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName.trim(),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}:{accountType:e.accountType,firstName:e.firstName.trim(),lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,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 lb(e){const{idNumber:t,...n}=du(e);return n}function Un(e,t){const n=e==null?void 0:e.from;return n&&n.startsWith("/")&&!n.startsWith("//")?n:t}function cb(){var H,ce,he,Q,ke,re,Se,ue,be,$,xe,ee,Ne;const e=Ae(),t=Ce(),n=yt(),{data:s=[]}=je({queryKey:["entities","mine"],queryFn:async()=>(await xi({pageNumber:1,pageSize:100})).items}),[a,i]=v.useState(null),[o,l]=v.useState(!1),c=s.length===0,u=c?"/create-entity":"/dashboard",d=Un(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:x,setValue:p,getValues:N,formState:{errors:g}}=Rt({resolver:Ot(cu),shouldUnregister:!1,defaultValues:{accountType:"Individual",firstName:"",lastName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),k=x("accountType"),j=x("entityType"),S=k==="Individual"?ou:iu,E=k==="Individual",T=E?"SSN":"EIN",A=E?"***-**-****":"**-*******",R=E?11:10,I=x("country"),L=h("ein"),ie=h("phoneNumber"),V=h("zipCode"),K=se=>{const Me=N("accountType");if(Me===se)return;const oe=N("lastName");uu(Me,se,p,oe),p("accountType",se),p("ein",il(N("ein"),se)),queueMicrotask(()=>{p("lastName",oe),p("firstName",""),Me==="Business"&&se==="Individual"&&p("tradeName","")})};v.useEffect(()=>{S.includes(j)||p("entityType",k==="Individual"?"Sole Proprietorship":"LLP")},[k,j,S,p]);const te=f(async se=>{i(null),l(!0);try{await Vh(du(se)),await n.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(Me){i(st(Me,"Unable to save entity. Please try again."))}finally{l(!1)}});return r.jsxs("form",{onSubmit:te,noValidate:!0,className:"space-y-8",children:[a?r.jsx(Gt,{message:a}):null,r.jsx(gn,{step:1,title:"ENTITY DETAILS",children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx(On,{label:"Account Type",required:!0}),r.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:"Business",checked:k==="Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>K("Business")}),"Business"]}),r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:"Individual",checked:k==="Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>K("Individual")}),"Individual"]})]})]}),r.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:k==="Individual"?r.jsxs(r.Fragment,{children:[r.jsx(fe,{label:"First name",required:!0,maxLength:100,placeholder:"Enter",error:(H=g.firstName)==null?void 0:H.message,...h("firstName")},"entity-first-name"),r.jsx(fe,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter",error:(ce=g.lastName)==null?void 0:ce.message,...h("lastName")},"entity-last-name")]}):r.jsxs(r.Fragment,{children:[r.jsx(fe,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter",error:(he=g.lastName)==null?void 0:he.message,...h("lastName")},"entity-business-name"),r.jsx(fe,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter",error:(Q=g.tradeName)==null?void 0:Q.message,...h("tradeName")},"entity-trade-name")]})}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:T,required:!0,inputMode:"numeric",placeholder:A,maxLength:R,error:(ke=g.ein)==null?void 0:ke.message,...L,onChange:se=>{se.target.value=il(se.target.value,k),L.onChange(se)}}),r.jsx(Kt,{label:"Entity Type",required:!0,error:(re=g.entityType)==null?void 0:re.message,...h("entityType"),children:S.map(se=>r.jsx("option",{value:se,children:se},se))})]}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(Se=g.email)==null?void 0:Se.message,...h("email")}),r.jsxs("div",{children:[r.jsx(On,{label:"Phone Number",required:!0}),r.jsxs("div",{className:"flex gap-2",children:[r.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:[r.jsx("option",{value:"+1",children:"+1"}),r.jsx("option",{value:"+91",children:"+91"})]}),r.jsx("input",{type:"tel",inputMode:"numeric",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 ${g.phoneNumber?"border-red-300":"border-slate-200"}`,...ie,onChange:se=>{se.target.value=se.target.value.replace(/\D/g,"").slice(0,10),ie.onChange(se)}})]}),g.phoneNumber?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:g.phoneNumber.message}):null]})]})]})}),r.jsx("div",{className:"border-t border-slate-200"}),r.jsx(gn,{title:"ADDRESS DETAILS",muted:!0,children:r.jsxs("div",{className:"space-y-5",children:[r.jsx(fe,{label:"Address Line 1",required:!0,maxLength:200,error:(ue=g.address1)==null?void 0:ue.message,...h("address1")}),r.jsx(fe,{label:"Address Line 2",maxLength:200,error:(be=g.address2)==null?void 0:be.message,...h("address2")}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:"City",required:!0,maxLength:100,error:($=g.city)==null?void 0:$.message,...h("city")}),r.jsxs(Kt,{label:"State",required:!0,error:(xe=g.state)==null?void 0:xe.message,...h("state"),children:[r.jsx("option",{value:"",children:"Select"}),$i.map(se=>r.jsx("option",{value:se,children:se},se))]})]}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:"ZIP Code",required:!0,maxLength:10,placeholder:I==="United States"?"12345 or 12345-6789":void 0,error:(ee=g.zipCode)==null?void 0:ee.message,...V,onChange:se=>{I==="United States"&&(se.target.value=lu(se.target.value)),V.onChange(se)}}),r.jsxs(Kt,{label:"Country",required:!0,error:(Ne=g.country)==null?void 0:Ne.message,...h("country"),children:[r.jsx("option",{value:"United States",children:"United States"}),r.jsx("option",{value:"Canada",children:"Canada"})]})]})]})}),r.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-200 pt-6",children:[r.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"}),r.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 Oi(){const e=Ae(),t=Ce(),n=Un(t.state,"/create-entity");return r.jsxs("div",{className:"relative min-h-full bg-slate-100/80 px-4 py-8 sm:px-6 sm:py-10",children:[r.jsxs("button",{type:"button",onClick:()=>e(n),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:[r.jsx(ub,{}),"Back"]}),r.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:r.jsx(cb,{})})]})}function ub(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function db(e,t){const n=new URLSearchParams({entityId:String(e)});return t!==void 0&&n.set("taxYear",String(t)),pe(`/portal/dashboard?${n}`)}function mb(e,t,n){const s=new URLSearchParams({entityId:String(e),category:t,taxYear:String(n)});return pe(`/portal/dashboard/summary?${s}`)}function hb(e,t,n){const s=new URLSearchParams({entityId:String(e),month:String(t)});return n!==void 0&&s.set("year",String(n)),pe(`/portal/dashboard/monthly-overview?${s}`)}function fb({entityId:e,search:t,taxYear:n,status:s,page:a=1,pageSize:i=tt}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),n&&o.set("taxYear",n),s&&s!=="all"&&o.set("status",s),pe(`/portal/dashboard/payments?${o}`)}function ll({entityCount:e,showPaymentActions:t=!0}){const n=Ae(),{enabledPayments:s}=qn();return r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-wrap gap-3",children:[t&&s.includes("federal")&&r.jsxs("button",{type:"button",onClick:()=>n("/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:[r.jsx(la,{}),"Add Federal Payments"]}),t&&s.includes("state")&&r.jsxs("button",{type:"button",onClick:()=>n("/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:[r.jsx(la,{}),"Add State Payment"]}),t&&r.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:[r.jsx(la,{}),"Add Local Payment",r.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsxs("button",{type:"button",onClick:()=>n("/entities"),className:"inline-flex items-center gap-1.5 rounded-[14px] border border-solid border-[#e5e7eb] bg-[#f9fafb] px-[15px] py-[9px] text-xs font-bold text-[#364153] transition hover:bg-slate-100",title:"View organizations",children:[r.jsx(pb,{}),"Entities (",e,")"]}),r.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-1.5 rounded-[14px] border-[1.5px] border-dashed border-[#16a34a] bg-[#f0fdf4] px-[15.5px] py-[9.5px] text-xs font-bold text-[#16a34a] transition hover:bg-green-50",children:[r.jsx(xb,{}),"Add Entity"]})]})]})}function la(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function pb(){return r.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#364153]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})}function xb(){return r.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#16a34a]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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 gb({title:e,description:t,buttonLabel:n,onAdd:s,comingSoon:a=!1}){return r.jsxs("article",{className:"flex flex-col rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[r.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),r.jsx("p",{className:"mx-auto mt-4 max-w-xs text-sm leading-relaxed text-slate-500",children:t}),a?r.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"}):r.jsxs("button",{type:"button",onClick:s,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:[r.jsx(yb,{}),n]})]})}function yb(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Zn({label:e="Loading…"}){return r.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:r.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-slate-500",children:[r.jsx(bb,{}),r.jsx("span",{children:e})]})})}function bb(){return r.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:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.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 vb={Draft:"Draft"};function jb(e){switch((e??vb.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 Kr(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function Nb(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 Li="drafts";function Qe(){return Qs(Li)}function Qs(e){return`/payments?tab=${e}`}function mu(e){return e==="failed"?"rejected":e}function wb(e,t){return t.trim().toLowerCase()==="draft"?Li:mu(e)}const Sb=["January","February","March","April","May","June","July","August","September","October","November","December"];function kb({entityId:e,initialOverview:t,isDashboardLoading:n=!1}){const s=Ae(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=v.useState(null);v.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=je({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>hb(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=n||d&&!c,x=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:Ab,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:Pb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:Eb,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 r.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?r.jsx(Zn,{}):null,r.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-4",children:[r.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-slate-500",children:"Overview of Month"}),r.jsxs("div",{className:"relative",children:[r.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:Sb.map((p,N)=>r.jsx("option",{value:N+1,children:p},p))}),r.jsx(Cb,{className:"pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gov-600"})]})]}),r.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-4",children:x.map(p=>{const N=p.icon;return r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center ${p.iconClassName}`,children:r.jsx(N,{})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs leading-4 text-slate-500",children:p.label}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[r.jsx("p",{className:`text-xl font-bold leading-7 ${p.amountClassName}`,children:Kr(p.amount)}),r.jsx("button",{type:"button",onClick:()=>s(Qs(mu(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 Cb({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Ab(){return r.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[r.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"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 14.25v-1.5M11.25 13.5h1.5"})]})}function Pb(){return r.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function Eb(){return r.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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 r.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.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 cl(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function _b(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 ul(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const Tb={primary:"bg-brand-600 text-white hover:bg-brand-700 focus-visible:ring-brand-500 disabled:bg-brand-600/60",secondary:"border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 focus-visible:ring-slate-400",ghost:"text-slate-600 hover:bg-slate-100 focus-visible:ring-slate-400"};function Fb({variant:e="primary",isLoading:t=!1,className:n="",children:s,disabled:a,...i}){return r.jsx("button",{type:"button",className:`inline-flex h-10 items-center justify-center rounded-lg px-4 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed ${Tb[e]} ${n}`,disabled:a||t,...i,children:t?"Please wait…":s})}const Db=[10,20,50,100];function Rb(e,t){const n=e.trim();if(!/^\d+$/.test(n))return null;const s=Number(n);return!Number.isInteger(s)||s<1||s>t?null:s}function $b(){return r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M12.5 4.5 7 10l5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ob(){return r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M7.5 4.5 13 10l-5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function vr({page:e,pageSize:t,totalCount:n,onPageChange:s,onPageSizeChange:a,pageSizeOptions:i=Db,disabled:o=!1,className:l=""}){const c=t>0?Math.max(1,Math.ceil(n/t)):1,u=n===0?0:c,d=e>1,m=u>0&&e<u,h=n===0?0:(e-1)*t+1,f=Math.min(e*t,n),[x,p]=v.useState(String(e)),N=v.useRef(x);N.current=x,v.useEffect(()=>{p(String(e))},[e]);function g(j=N.current){if(o||u===0){p(String(e));return}const S=Rb(j,u);if(S===null){p(String(e));return}if(S===e){p(String(e));return}s(S)}function k(j){j.key==="Enter"&&(j.preventDefault(),g(j.currentTarget.value))}return n===0?null:r.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 border-t border-slate-200 bg-white px-6 py-3 ${l}`,children:[r.jsxs("p",{className:"text-sm text-slate-500",children:["Showing ",r.jsx("span",{className:"font-medium text-slate-700",children:h}),"–",r.jsx("span",{className:"font-medium text-slate-700",children:f})," of ",r.jsx("span",{className:"font-medium text-slate-700",children:n})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a?r.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[r.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),r.jsx("select",{value:t,disabled:o,onChange:j=>a(Number(j.target.value)),className:"rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(j=>r.jsx("option",{value:j,children:j},j))})]}):null,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",disabled:o||!d,onClick:()=>s(e-1),"aria-label":"Previous page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:r.jsx($b,{})}),r.jsx("span",{className:"min-w-[5.5rem] text-center text-sm text-slate-600",children:u===0?"—":`Page ${e} of ${u}`}),r.jsx("button",{type:"button",disabled:o||!m,onClick:()=>s(e+1),"aria-label":"Next page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:r.jsx(Ob,{})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("label",{htmlFor:"pagination-go-to-page",className:"whitespace-nowrap text-sm text-slate-600",children:"Go to page"}),r.jsx("input",{id:"pagination-go-to-page",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:x,disabled:o||u===0,onChange:j=>p(j.target.value),onKeyDown:k,"aria-label":"Go to page number",className:"h-9 w-14 rounded-lg border border-slate-200 bg-white px-2 text-center text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"}),r.jsx(Fb,{type:"button",variant:"secondary",disabled:o||u===0,className:"h-9 px-3",onMouseDown:j=>{j.preventDefault()},onClick:()=>g(),children:"Go"})]})]})]})}const Lb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],dl={total:0,page:1,pageSize:tt,items:[]};function zb({label:e,status:t}){const n={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 r.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n[t]}`,children:e})}function Mb({entityId:e,initialPayments:t,isDashboardLoading:n=!1}){const s=Ae(),[a,i]=v.useState(""),[o,l]=v.useState(""),[c,u]=v.useState(""),[d,m]=v.useState("all"),[h,f]=v.useState(1),[x,p]=v.useState(tt);v.useEffect(()=>{const I=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(I)},[a]),v.useEffect(()=>{f(1)},[o,c,d,e,x]);const N=!!o||!!c||d!=="all",g=e!==null&&(N||h>1||x!==tt),{data:k,isFetching:j}=je({queryKey:["dashboard","payments",e,o,c,d,h,x],queryFn:()=>fb({entityId:e,search:o||void 0,taxYear:c||void 0,status:d,page:h,pageSize:x}),enabled:g,placeholderData:I=>I}),S=v.useMemo(()=>g?k??dl:t&&h===1&&x===tt?t:dl,[g,k,t,h,x]),E=v.useMemo(()=>S.items.map(_b),[S.items]),T=v.useMemo(()=>{const I=new Date().getFullYear();return[I,I-1,I-2].map(String)},[]),A=n||g&&j,R=(S.page-1)*S.pageSize;return r.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[A?r.jsx(Zn,{label:"Loading payments…"}):null,r.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-6 py-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:r.jsx(Bb,{})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-base font-bold text-slate-900",children:"My Payments"}),r.jsxs("p",{className:"text-xs text-slate-500",children:[S.total," total payments"]})]})]})}),r.jsx("div",{className:"border-b border-slate-200 p-6",children:r.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:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"payment-search",className:"mb-1.5 block text-sm text-slate-600",children:"Search by State/Form Type"}),r.jsxs("div",{className:"relative",children:[r.jsx(qb,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),r.jsx("input",{id:"payment-search",type:"text",value:a,onChange:I=>i(I.target.value),placeholder:"All",disabled:n,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"})]})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"tax-period-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Tax Period"}),r.jsxs("div",{className:"relative",children:[r.jsxs("select",{id:"tax-period-filter",value:c,onChange:I=>u(I.target.value),disabled:n,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:[r.jsx("option",{value:"",children:"Select Year"}),T.map(I=>r.jsx("option",{value:I,children:I},I))]}),r.jsx(ml,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),r.jsxs("div",{className:"relative",children:[r.jsx("select",{id:"status-filter",value:d,onChange:I=>m(I.target.value),disabled:n,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(I=>r.jsx("option",{value:I.value,children:I.label},I.value))}),r.jsx(ml,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]})]})}),r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[r.jsx("th",{className:"px-6 py-3",children:"ID"}),r.jsx("th",{className:"px-6 py-3",children:"Jurisdiction / Type"}),r.jsx("th",{className:"px-6 py-3",children:"Period"}),r.jsx("th",{className:"px-6 py-3",children:"Amount"}),r.jsx("th",{className:"px-6 py-3",children:"Payment"}),r.jsx("th",{className:"px-6 py-3",children:"Status"}),r.jsx("th",{className:"px-6 py-3",children:"Form Type"}),r.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),r.jsx("tbody",{children:!A&&E.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:N?"No payments match your filters.":"No payments yet."})}):E.map((I,L)=>r.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[r.jsxs("td",{className:"px-6 py-4 font-medium text-slate-900",children:["#",R+L+1]}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.jurisdiction}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.period}),r.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(I.amount)}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.paymentDate}),r.jsx("td",{className:"px-6 py-4",children:r.jsx(zb,{label:I.statusLabel,status:I.status})}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.formType}),r.jsx("td",{className:"px-6 py-4",children:r.jsx("button",{type:"button",onClick:()=>s(Qs(wb(I.status,I.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${I.category}-${I.id}`))})]})}),r.jsx(vr,{page:h,pageSize:x,totalCount:S.total,onPageChange:f,onPageSizeChange:p,disabled:A||e===null})]})}function qb({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.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 ml({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Bb(){return r.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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 ca({entityId:e,category:t,title:n,subtitlePrefix:s,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:u=!1}){const[d,m]=v.useState(a);if(v.useEffect(()=>{m(a)},[e,a]),u)return r.jsxs("article",{className:"flex min-h-[220px] flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[r.jsxs("div",{className:"mb-4",children:[r.jsx("h3",{className:"text-base font-bold text-slate-900",children:n}),r.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:s})]}),r.jsx("div",{className:"flex flex-1 items-center justify-center",children:r.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:x}=je({queryKey:["dashboard","summary",e,t,d],queryFn:()=>mb(e,t,d),enabled:e!==null&&!h,placeholderData:k=>k}),p=h?o?cl(o):ul():f?cl(f):ul(),N=Nb(p),g=l||x&&!h;return r.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[g?r.jsx(Zn,{}):null,r.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-base font-bold text-slate-900",children:n}),r.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[s," (",p.count,")"]})]}),r.jsxs("div",{className:"relative shrink-0",children:[r.jsx("select",{value:d,onChange:k=>m(Number(k.target.value)),disabled:g,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(k=>r.jsxs("option",{value:k,children:["TY ",k]},k))}),r.jsx(Vb,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:c.map(k=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${k.dotClassName}`}),r.jsx("span",{className:"text-xs text-slate-500",children:k.label})]}),r.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Kr(p[k.key])})]},k.label))}),r.jsxs("div",{className:"mt-5",children:[r.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:N.map((k,j)=>k.width>0?r.jsx("span",{className:`${k.color} h-full`,style:{width:`${k.width}%`}},j):null)}),r.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function Vb({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const Ub={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."},Zb=[{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"}],sn=new Date().getFullYear(),ua=[sn,sn-1,sn-2],Wb=[{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"}],Hb=[{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 zi(){const e=Ae(),{entities:t,selectedEntity:n,enabledPayments:s}=qn(),a=(n==null?void 0:n.entityId)??null,{data:i,isLoading:o}=je({queryKey:["dashboard",a,sn],queryFn:()=>db(a,sn),enabled:a!==null});return!o&&i&&!i.hasPayments?r.jsxs("div",{className:"space-y-6",children:[r.jsx(ll,{entityCount:t.length,showPaymentActions:!1}),r.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:Zb.filter(l=>l.key==="local"||s.includes(l.key)).map(l=>r.jsx(gb,{title:l.title,description:Ub[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))})]}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(ll,{entityCount:t.length}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.includes("federal")&&r.jsx(ca,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:sn,taxYearOptions:ua,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:Wb}),s.includes("state")&&r.jsx(ca,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:sn,taxYearOptions:ua,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:Hb}),r.jsx(ca,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:sn,taxYearOptions:ua,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:Yb,comingSoon:!0})]}),r.jsx(kb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),r.jsx(Mb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}const hl=160,Kb=48,os=8;function Qb({entity:e,onEdit:t}){const n=v.useRef(null),s=v.useRef(null),[a,i]=v.useState(!1),[o,l]=v.useState({}),c=()=>{var x;const u=n.current;if(!u)return;const d=u.getBoundingClientRect(),m=((x=s.current)==null?void 0:x.offsetHeight)??Kb,f=window.innerHeight-d.bottom<m+os;l({position:"fixed",top:f?d.top-m-os:d.bottom+os,left:Math.max(os,d.right-hl),width:hl,zIndex:50})};return v.useLayoutEffect(()=>{a&&(c(),requestAnimationFrame(c))},[a]),v.useEffect(()=>{if(!a)return;const u=m=>{var f,x;const h=m.target;(f=n.current)!=null&&f.contains(h)||(x=s.current)!=null&&x.contains(h)||i(!1)},d=()=>c();return document.addEventListener("mousedown",u),window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{document.removeEventListener("mousedown",u),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[a]),r.jsxs("div",{className:"inline-block text-left",children:[r.jsxs("button",{ref:n,type:"button",onClick:()=>i(u=>!u),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",children:["Actions",r.jsx(Jb,{})]}),a?Vr.createPortal(r.jsx("div",{ref:s,style:o,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:r.jsx("button",{type:"button",onClick:()=>{i(!1),t(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"})}),document.body):null]})}function Jb(){return r.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}function hu({open:e,entity:t,onClose:n}){var R,I,L,ie,V,K,te,H,ce,he,Q,ke;const s=yt(),[a,i]=v.useState(null),[o,l]=v.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,setValue:h,getValues:f,formState:{errors:x}}=Rt({resolver:Ot(cu),defaultValues:ol(t),shouldUnregister:!1}),p=d("accountType"),N=d("entityType"),g=p==="Individual"?ou:iu,k=p==="Individual"?"SSN":"EIN",j=d("country"),S=c("phoneNumber"),E=c("zipCode"),T=re=>{const Se=f("accountType");if(Se===re)return;const ue=f("lastName");uu(Se,re,h,ue),h("accountType",re),queueMicrotask(()=>{h("lastName",ue),h("firstName",""),Se==="Business"&&re==="Individual"&&h("tradeName","")})};v.useEffect(()=>{if(e){const re=ol(t);m(re),i(null)}},[t,e,m]),v.useEffect(()=>{if(!e)return;const re=Se=>{Se.key==="Escape"&&n()};return document.addEventListener("keydown",re),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",re),document.body.style.overflow=""}},[e,n]),v.useEffect(()=>{g.includes(N)||h("entityType",p==="Individual"?"Sole Proprietorship":"LLP")},[p,N,g,h]);const A=u(async re=>{i(null),l(!0);try{await Uh(t.entityId,lb(re)),await s.invalidateQueries({queryKey:["entities","mine"]}),n()}catch(Se){i(st(Se,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?Vr.createPortal(r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:n}),r.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:[r.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[r.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),r.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),r.jsxs("form",{onSubmit:A,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?r.jsx("div",{className:"mb-5",children:r.jsx(Gt,{message:a})}):null,r.jsxs("div",{className:"space-y-8",children:[r.jsx("input",{type:"hidden",...c("ein")}),r.jsx(gn,{step:1,title:"ENTITY DETAILS",children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx(On,{label:"Account Type",required:!0}),r.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:"Business",checked:p==="Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>T("Business")}),"Business"]}),r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:"Individual",checked:p==="Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>T("Individual")}),"Individual"]})]})]}),r.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:p==="Individual"?r.jsxs(r.Fragment,{children:[r.jsx(fe,{label:"First name",required:!0,maxLength:100,placeholder:"Enter",error:(R=x.firstName)==null?void 0:R.message,...c("firstName")},"entity-first-name"),r.jsx(fe,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter",error:(I=x.lastName)==null?void 0:I.message,...c("lastName")},"entity-last-name")]}):r.jsxs(r.Fragment,{children:[r.jsx(fe,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter",error:(L=x.lastName)==null?void 0:L.message,...c("lastName")},"entity-business-name"),r.jsx(fe,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter",error:(ie=x.tradeName)==null?void 0:ie.message,...c("tradeName")},"entity-trade-name")]})}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:k,readOnly:!0,value:sb(t.idNumber,p),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),r.jsx(Kt,{label:"Entity Type",required:!0,error:(V=x.entityType)==null?void 0:V.message,...c("entityType"),children:g.map(re=>r.jsx("option",{value:re,children:re},re))})]}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(K=x.email)==null?void 0:K.message,...c("email")}),r.jsxs("div",{children:[r.jsx(On,{label:"Phone Number",required:!0}),r.jsxs("div",{className:"flex gap-2",children:[r.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:[r.jsx("option",{value:"+1",children:"+1"}),r.jsx("option",{value:"+91",children:"+91"})]}),r.jsx("input",{type:"tel",inputMode:"numeric",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"}`,...S,onChange:re=>{re.target.value=re.target.value.replace(/\D/g,"").slice(0,10),S.onChange(re)}})]}),x.phoneNumber?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.phoneNumber.message}):null]})]})]})}),r.jsx("div",{className:"border-t border-slate-200"}),r.jsx(gn,{title:"ADDRESS DETAILS",muted:!0,children:r.jsxs("div",{className:"space-y-5",children:[r.jsx(fe,{label:"Address Line 1",required:!0,maxLength:200,error:(te=x.address1)==null?void 0:te.message,...c("address1")}),r.jsx(fe,{label:"Address Line 2",maxLength:200,error:(H=x.address2)==null?void 0:H.message,...c("address2")}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:"City",required:!0,maxLength:100,error:(ce=x.city)==null?void 0:ce.message,...c("city")}),r.jsxs(Kt,{label:"State",required:!0,error:(he=x.state)==null?void 0:he.message,...c("state"),children:[r.jsx("option",{value:"",children:"Select"}),$i.map(re=>r.jsx("option",{value:re,children:re},re))]})]}),r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(fe,{label:"ZIP Code",required:!0,maxLength:10,placeholder:j==="United States"?"12345 or 12345-6789":void 0,error:(Q=x.zipCode)==null?void 0:Q.message,...E,onChange:re=>{j==="United States"&&(re.target.value=lu(re.target.value)),E.onChange(re)}}),r.jsxs(Kt,{label:"Country",required:!0,error:(ke=x.country)==null?void 0:ke.message,...c("country"),children:[r.jsx("option",{value:"United States",children:"United States"}),r.jsx("option",{value:"Canada",children:"Canada"})]})]})]})})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[r.jsx("button",{type:"button",onClick:n,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"}),r.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 Mi(){const{selectedEntity:e}=qn(),t=Ae(),[n,s]=v.useState(""),[a,i]=v.useState(""),[o,l]=v.useState(1),[c,u]=v.useState(tt),[d,m]=v.useState(null);v.useEffect(()=>{const j=window.setTimeout(()=>i(n.trim()),300);return()=>window.clearTimeout(j)},[n]),v.useEffect(()=>{l(1)},[a,c]);const{data:h,isLoading:f,isFetching:x,isError:p}=je({queryKey:["entities","mine","paged",a,o,c],queryFn:()=>xi({search:a||void 0,pageNumber:o,pageSize:c}),placeholderData:j=>j}),N=(h==null?void 0:h.items)??[],g=(h==null?void 0:h.totalCount)??0,k=x;return r.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[r.jsxs("button",{type:"button",onClick:()=>t("/dashboard"),className:"inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5]",children:[r.jsx(Xb,{}),"Back"]}),r.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>t("/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:[r.jsx(e0,{}),"Add Entity"]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#6a7282]",children:"Search by Entity Name/Email/EIN"}),r.jsx("input",{type:"search",value:n,onChange:j=>s(j.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"})]})]}),d?r.jsx(hu,{open:!0,entity:d,onClose:()=>m(null)}):null,r.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-black/[0.12] bg-white",children:[k?r.jsx(Zn,{label:"Loading organizations…"}):null,r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"min-w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-[#f8f9fb]",children:[r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Client Name"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"EIN Number"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Email"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Phone"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Business Type"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Status"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Joined Date"}),r.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Action"})]})}),r.jsx("tbody",{children:f&&!h?r.jsx("tr",{children:r.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Loading organizations…"})}):p?r.jsx("tr",{children:r.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Unable to load organizations."})}):N.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:a?"No organizations match your search.":"No organizations yet."})}):N.map(j=>r.jsx(Gb,{entity:j,isSelected:j.entityId===(e==null?void 0:e.entityId),onEdit:m},j.entityId))})]})}),r.jsx(vr,{page:o,pageSize:c,totalCount:g,onPageChange:l,onPageSizeChange:u,disabled:f||x})]})]})}function Gb({entity:e,isSelected:t,onEdit:n}){var l;const s=en(e),a=Ri(s),i=((l=e.status)==null?void 0:l.toLowerCase())==="active",o=e.createdAt?new Date(e.createdAt).toISOString().slice(0,10):"—";return r.jsxs("tr",{className:["border-b border-[#e0e0e0] last:border-b-0 transition-colors",t?"bg-[#f0f7ff]":"hover:bg-slate-50"].join(" "),children:[r.jsx("td",{className:"px-4 py-2.5",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.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}),r.jsx("span",{className:"font-semibold text-[#1e2939] text-[13px]",children:s})]})}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:Vn(e.idNumber)})}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx("span",{className:"text-[12px] text-[#374151]",children:e.email||"—"})}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx("span",{className:"text-[12px] text-[#374151]",children:e.phoneNumber||"—"})}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx("span",{className:"text-[12px] text-[#374151]",children:e.entityType||"—"})}),r.jsx("td",{className:"px-4 py-2.5",children:r.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"})}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx("span",{className:"text-[12px] text-[#374151]",children:o})}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx(Qb,{entity:e,onEdit:n})})]})}function Xb(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function e0(){return r.jsx("svg",{className:"h-[15px] w-[15px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function qi(e){return pe(`/portal/federal-payments/${e}`)}function t0(e){return pe(`/portal/federal-payments/form-types?entityId=${e}`)}function n0(e){const t=new URLSearchParams({formType:e});return pe(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Bi(e){return pe("/portal/federal-payments",{method:"POST",body:e})}function Vi(e,t){return pe(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function r0(e){return pe(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function s0(e){return Wr(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function a0(e){return Wr(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function i0(e){return Wr(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function o0(e){return Wr(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function l0({entityId:e,status:t,category:n="all",pageNumber:s=1,pageSize:a=tt}){const i=new URLSearchParams({entityId:String(e),pageNumber:String(s),pageSize:String(a)});return t&&i.set("status",t),n&&n!=="all"?i.set("category",n):n==="all"&&i.set("category","all"),pe(`/portal/remittance-payments?${i}`)}function c0(e,t="all"){const n=new URLSearchParams({entityId:String(e)});return t&&n.set("category",t),pe(`/portal/remittance-payments/status-counts?${n}`)}function u0(e){return pe("/portal/state-payments/states",{signal:e})}function d0(e,t,n){const s=new URLSearchParams({entityId:String(e),state:t});return pe(`/portal/state-payments/payment-reasons?${s}`,{signal:n})}function m0(e,t,n,s){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return pe(`/portal/state-payments/validation-metadata?${a}`,{signal:s})}function fu(e){return pe(`/portal/state-payments/${e}`)}function h0(e){return pe("/portal/state-payments",{method:"POST",body:e})}function f0(e,t){return pe(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function p0(e){return pe(`/portal/state-payments/${e}/submit`,{method:"POST"})}function x0({open:e,title:t,html:n,isLoading:s=!1,error:a=null,downloadFileName:i="payment.pdf",onDownload:o,onClose:l}){const[c,u]=v.useState(!1);v.useEffect(()=>{if(!e)return;const m=h=>{h.key==="Escape"&&l()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,l]);const d=async()=>{if(!(!o||c)){u(!0);try{const m=await o(),h=URL.createObjectURL(m),f=document.createElement("a");f.href=h,f.download=i,f.click(),URL.revokeObjectURL(h)}finally{u(!1)}}};return e?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:l}),r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"payment-pdf-title",className:"relative flex h-[90vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 px-5 py-4",children:[r.jsx("h2",{id:"payment-pdf-title",className:"text-base font-semibold text-slate-900",children:t}),r.jsxs("div",{className:"flex items-center gap-2",children:[o?r.jsx("button",{type:"button",onClick:()=>void d(),disabled:c||s||!!a,className:"rounded-lg border border-gov-200 bg-gov-50 px-3 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100 disabled:opacity-60",children:c?"Downloading…":"Download"}):null,r.jsx("button",{type:"button",onClick:l,className:"rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Close"})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:s?r.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"Loading…"}):a?r.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-red-600",children:a}):n?r.jsx("iframe",{title:t,srcDoc:n,sandbox:"",className:"h-full w-full border-0 bg-white"}):r.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"No content available."})})]})]}):null}function da({onViewPdf:e,isViewPdfLoading:t}){return r.jsx("button",{type:"button",onClick:e,disabled:t,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 disabled:opacity-60",children:t?"Loading…":"View PDF"})}function g0({actionType:e,onView:t,onViewPdf:n,onEdit:s,onSubmit:a,isSubmitting:i=!1,isViewPdfLoading:o=!1}){return e==="draft-actions"?r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),r.jsx("button",{type:"button",onClick:s,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"}),r.jsx("button",{type:"button",onClick:a,disabled:i,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:i?"Submitting…":"Submit"})]}):e==="view-pdf"?r.jsx(da,{onViewPdf:n,isViewPdfLoading:o}):e==="rejected-actions"?r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),r.jsx(da,{onViewPdf:n,isViewPdfLoading:o}),r.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"})]}):r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),r.jsx(da,{onViewPdf:n,isViewPdfLoading:o})]})}function y0(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 n=e.slice(0,4),s=Number.parseInt(e.slice(4,6),10);return Number.isNaN(s)||s<1||s>12?e:`Q${Math.ceil(s/3)} ${n}`}function b0(e){return{id:e.id,category:e.category,referenceNo:e.referenceNumber??"—",jurisdiction:e.jurisdiction,period:y0(e.taxPeriod),amount:e.amount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:jb(e.status)}}function v0({className:e,...t}){return r.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:[r.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"}),r.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"}),r.jsx("path",{d:"M6.25 5.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M10 8.125H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M10 10.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}function j0({className:e,...t}){return r.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:[r.jsxs("g",{clipPath:"url(#scheduled-tab-icon-clip)",children:[r.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"}),r.jsx("path",{d:"M7.5 3.75V7.5L10 8.75",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("defs",{children:r.jsx("clipPath",{id:"scheduled-tab-icon-clip",children:r.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function N0({className:e,...t}){return r.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:r.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 w0({className:e,...t}){return r.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:[r.jsxs("g",{clipPath:"url(#rejected-tab-icon-clip)",children:[r.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"}),r.jsx("path",{d:"M7.5 5V7.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M7.5 10H7.50625",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("defs",{children:r.jsx("clipPath",{id:"rejected-tab-icon-clip",children:r.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function S0({className:e,...t}){return r.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:[r.jsxs("g",{clipPath:"url(#paid-tab-icon-clip)",children:[r.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"}),r.jsx("path",{d:"M5.625 7.5L6.875 8.75L9.375 6.25",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("defs",{children:r.jsx("clipPath",{id:"paid-tab-icon-clip",children:r.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}const pu=[{key:"drafts",label:"DRAFTS",Icon:v0,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:j0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:N0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:w0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:S0,iconClassName:"text-green-500"}],k0={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 fl(e){return e!==null&&pu.some(t=>t.key===e)}function Ui({paymentsMode:e="all"}){var be;const t=Ae(),n=yt(),[s]=Om(),{selectedEntity:a}=ht(),{onPaymentRequired:i}=qn(),o=(a==null?void 0:a.entityId)??null,l=s.get("tab"),[c,u]=v.useState(fl(l)?l:Li),[d,m]=v.useState(e==="all"?"all":e),h=e!=="all"?e:d,[f,x]=v.useState(1),[p,N]=v.useState(tt),[g,k]=v.useState(null),[j,S]=v.useState(null),[E,T]=v.useState(null);v.useEffect(()=>{fl(l)&&u(l)},[l]),v.useEffect(()=>{x(1),N(tt)},[c,o,d]),v.useEffect(()=>{x(1)},[p]);const A=k0[c],R=je({queryKey:["remittance-payments","list",o,c,h,f,p],queryFn:()=>l0({entityId:o,status:c,category:h,pageNumber:f,pageSize:p}),enabled:o!==null,placeholderData:$=>$}),I=je({queryKey:["remittance-payments","status-counts",o,h],queryFn:()=>c0(o,h),enabled:o!==null}),L=R.isLoading,ie=R.isFetching,V=o!==null&&ie,K=v.useMemo(()=>{var $,xe,ee,Ne,se;return{drafts:(($=I.data)==null?void 0:$.drafts)??0,scheduled:((xe=I.data)==null?void 0:xe.scheduled)??0,submitted:((ee=I.data)==null?void 0:ee.submitted)??0,rejected:((Ne=I.data)==null?void 0:Ne.rejected)??0,paid:((se=I.data)==null?void 0:se.paid)??0}},[I.data]),te=v.useMemo(()=>{var $;return((($=R.data)==null?void 0:$.items)??[]).map(b0)},[R.data]),H=((be=R.data)==null?void 0:be.totalCount)??0,ce=Ah({mutationFn:async $=>{try{$.category==="federal"?await r0($.id):await p0($.id)}catch(xe){if(xe instanceof yr&&xe.status===402&&i){const ee=xe.extensions,Ne={paymentType:(ee==null?void 0:ee.paymentType)??$.category,paymentId:(ee==null?void 0:ee.paymentId)??$.id,expectedAmount:(ee==null?void 0:ee.expectedAmount)??"0.00",currency:(ee==null?void 0:ee.currency)??"USD",federalRecordCount:(ee==null?void 0:ee.federalRecordCount)??0,stateRecordCount:(ee==null?void 0:ee.stateRecordCount)??0,feePerFederal:(ee==null?void 0:ee.feePerFederal)??null,feePerState:(ee==null?void 0:ee.feePerState)??null};i(Ne);return}throw xe}},onSuccess:async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})},onError:()=>k(null),onSettled:()=>k(null)});v.useEffect(()=>{const $=async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})};return window.addEventListener(ti,$),()=>window.removeEventListener(ti,$)},[n]);const he=$=>{k(`${$.category}-${$.id}`),ce.mutate($)},Q=$=>{$.category==="federal"?t(`/payments/federal/${$.id}/view`):t(`/payments/state/${$.id}/view`)},ke=$=>{$.category==="federal"?t(`/payments/federal/${$.id}/edit`):t(`/payments/state/${$.id}/edit`)},re=async $=>{const xe=`${$.category}-${$.id}`,ee=`payment-${$.referenceNo}.pdf`;S(xe),T({title:`Payment PDF — ${$.referenceNo}`,html:null,category:$.category,paymentId:$.id,downloadFileName:ee,isLoading:!0,error:null});try{const Ne=$.category==="federal"?await i0($.id):await o0($.id);T({title:`Payment PDF — ${$.referenceNo}`,html:Ne,category:$.category,paymentId:$.id,downloadFileName:ee,isLoading:!1,error:null})}catch(Ne){T({title:`Payment PDF — ${$.referenceNo}`,html:null,category:$.category,paymentId:$.id,downloadFileName:ee,isLoading:!1,error:st(Ne,"Unable to load payment PDF.")})}finally{S(null)}},Se=async()=>{if(!E)throw new Error("No payment selected");return E.category==="federal"?s0(E.paymentId):a0(E.paymentId)},ue=()=>T(null);return r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=="state"&&r.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:[r.jsx(ma,{}),"Add Federal Payment"]}),e!=="federal"&&r.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:[r.jsx(ma,{}),"Add State Payment"]}),e==="all"&&r.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:[r.jsx(ma,{}),"Add Local Payments",r.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),r.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[V?r.jsx(Zn,{label:"Loading payments…"}):null,r.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:pu.map($=>{const xe=c===$.key,ee=$.Icon;return r.jsxs("button",{type:"button",onClick:()=>{u($.key),t(Qs($.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 ${xe?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[r.jsx(ee,{className:`shrink-0 ${$.iconClassName}`}),$.label," (",K[$.key],")"]},$.key)})}),r.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[r.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),r.jsxs("select",{value:d,onChange:$=>m($.target.value),disabled:e!=="all",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 disabled:opacity-60",children:[r.jsx("option",{value:"all",children:"All"}),r.jsx("option",{value:"federal",children:"Federal"}),r.jsx("option",{value:"state",children:"State"}),r.jsx("option",{value:"local",disabled:!0,children:"Local (Coming Soon)"})]})]}),r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[r.jsx("thead",{children:r.jsx("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:A.columns.map($=>r.jsx("th",{className:"px-6 py-3",children:$},$))})}),r.jsx("tbody",{children:L&&!R.data?r.jsx("tr",{children:r.jsx("td",{colSpan:A.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):te.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:A.columns.length,className:"px-6 py-12 text-center text-slate-500",children:A.emptyMessage})}):te.map($=>r.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[r.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:c==="drafts"?`#${$.id}`:$.referenceNo}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.jurisdiction}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.period}),r.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr($.amount)}),c!=="paid"?r.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.paymentDate}):null,c==="rejected"?r.jsx("td",{className:"px-6 py-4 text-slate-700",children:$.reason??"—"}):null,r.jsx("td",{className:"px-6 py-4",children:r.jsx(g0,{actionType:A.actionType,onView:()=>Q($),onViewPdf:()=>re($),onEdit:()=>ke($),onSubmit:()=>he($),isSubmitting:g===`${$.category}-${$.id}`,isViewPdfLoading:j===`${$.category}-${$.id}`})})]},`${$.category}-${$.id}`))})]})}),r.jsx(vr,{page:f,pageSize:p,totalCount:H,onPageChange:x,onPageSizeChange:N,disabled:L||o===null||ie})]}),r.jsx(x0,{open:E!==null,title:(E==null?void 0:E.title)??"Payment PDF",html:(E==null?void 0:E.html)??null,downloadFileName:E==null?void 0:E.downloadFileName,isLoading:(E==null?void 0:E.isLoading)??!1,error:(E==null?void 0:E.error)??null,onDownload:E&&!E.error?Se:void 0,onClose:ue})]})}function ma(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Qr({entityId:e,pageNumber:t=1,pageSize:n=tt}){const s=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return pe(`/portal/bank-accounts?${s}`)}function C0(e){return pe("/portal/bank-accounts",{method:"POST",body:e})}function xu(e,t){return pe(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function wn({title:e,children:t,isFirst:n=!1,headerAction:s}){return r.jsxs("section",{className:n?"":"mt-8 border-t border-slate-100 pt-8",children:[r.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),s]}),t]})}const hr=17,gu=9;function Jn(e,t){return e.replace(/\D/g,"").slice(0,t)}const yu=["Checking","Savings"],A0=Xt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${hr} digits`),confirmAccountNumber:_().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${hr} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ks(yu,{message:"Account type is required"}),bankName:_().min(1,"Bank name is required")}).refine(e=>e.accountNumber===e.confirmAccountNumber,{message:"Account numbers do not match",path:["confirmAccountNumber"]});function P0({entityId:e,onCancel:t,onSuccess:n}){const s=yt(),{showSuccess:a,showError:i}=zs(),[o,l]=v.useState(null),[c,u]=v.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=Rt({resolver:Ot(A0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async x=>{l(null),u(!0);try{const p=await C0({entityId:e,bankName:x.bankName.trim(),accountNumber:x.accountNumber,routingNumber:x.routingNumber,accountType:x.accountType});await s.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),n(p.bankAccountDetailId)}catch(p){const N=st(p,"Unable to save bank account.");l(N),i("Action Not Completed",N)}finally{u(!1)}});return r.jsxs("form",{noValidate:!0,onSubmit:x=>{x.preventDefault(),x.stopPropagation(),f(x)},className:"space-y-6",children:[r.jsxs(gn,{step:2,title:"Add Bank Account Manually",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Bank Account"}),r.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[r.jsx(Le,{name:"accountNumber",control:d,render:({field:x})=>{var p;return r.jsx(fe,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:N=>x.onChange(Jn(N.target.value,hr)),onBlur:x.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),r.jsx(Le,{name:"confirmAccountNumber",control:d,render:({field:x})=>{var p;return r.jsx(fe,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:N=>x.onChange(Jn(N.target.value,hr)),onBlur:x.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),r.jsx(Le,{name:"routingNumber",control:d,render:({field:x})=>{var p;return r.jsx(fe,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:N=>x.onChange(Jn(N.target.value,gu)),onBlur:x.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),r.jsx(Le,{name:"accountType",control:d,render:({field:x})=>{var p;return r.jsx(Kt,{label:"Account Type",required:!0,value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:yu.map(N=>r.jsx("option",{value:N,children:N},N))})}})]}),r.jsx(Le,{name:"bankName",control:d,render:({field:x})=>{var p;return r.jsx(fe,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?r.jsx(Gt,{message:o}):null,r.jsxs("div",{className:"flex flex-wrap gap-3",children:[r.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"}),r.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 bu({open:e,entityId:t,onClose:n,onAccountAdded:s}){const[a,i]=v.useState("choose");if(v.useEffect(()=>{e||i("choose")},[e]),v.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,n]),!e)return null;const o=a==="manual";return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:n}),r.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?r.jsx(P0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{s==null||s(l),n()}}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.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"}),r.jsx("h2",{id:"add-bank-account-title",className:"text-sm font-medium uppercase tracking-[0.2em] text-slate-400",children:"Add Bank Account"})]}),r.jsx("div",{className:"my-6 h-px bg-slate-200"}),r.jsxs("div",{className:"space-y-4",children:[r.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:[r.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gov-600 text-white",children:r.jsx(E0,{className:"h-5 w-5"})}),r.jsx("span",{className:"text-base font-semibold text-slate-900",children:"Add Manually"})]}),r.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:[r.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-slate-200 bg-white",children:r.jsx(I0,{className:"h-6 w-6"})}),r.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function E0({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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 I0({className:e}){return r.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),r.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),r.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",fill:"#111827"}),r.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",fill:"#111827",opacity:"0.35"})]})}const _0=12,T0=["January","February","March","April","May","June","July","August","September","October","November","December"];function pn(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function Es(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(n,s,a);return i.getFullYear()!==n||i.getMonth()!==s||i.getDate()!==a?null:i}function vu(e=new Date){const t=new Date(e);return e.getHours()>=_0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),pn(t)}function ju(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),pn(t)}function F0(e=18,t=new Date){const n=new Date(t);return n.setFullYear(n.getFullYear()-e),n.setHours(0,0,0,0),pn(n)}function D0(e,t,n=new Date){const s=Es(e);if(!s)return!1;const a=new Date(n);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),s.setHours(0,0,0,0),s<=a}function R0(e){const t=e.getDay();return t!==0&&t!==6}function Qa(e,t=new Date){if(!R0(e))return!1;const n=pn(e);return n>=vu(t)&&n<=ju(t)}function Js(e,t=new Date){const n=Es(e);return n?Qa(n,t):!1}function $0(e,t){return`${T0[t]} ${e}`}function O0(e,t){const n=new Date(e,t,1),s=new Date(e,t+1,0).getDate(),a=n.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=s;o+=1)i.push(new Date(e,t,o));return i}function pl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Jr(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 Nu({label:e,required:t=!1,htmlFor:n,info:s}){return r.jsxs("label",{htmlFor:n,className:"mb-1.5 flex items-center gap-1.5 text-sm text-slate-600",children:[r.jsxs("span",{children:[e,t?r.jsx("span",{className:"text-red-500",children:" *"}):null]}),s?r.jsx("span",{title:s,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":s,children:"i"}):null]})}function Y({label:e,required:t,error:n,info:s,children:a}){return r.jsxs("div",{children:[r.jsx(Nu,{label:e,required:t,info:s}),a,n?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}const wu=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 G(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]"}`:wu(e)}function Gn(e){return`${wu(e)} appearance-none`}function Yn({className:e}){return r.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:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Fr({children:e}){return r.jsx("div",{className:"relative",children:e})}function Su({value:e,onChange:t,entityId:n,entityType:s="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[u,d]=v.useState(!1),[m,h]=v.useState(!1),f=v.useRef(null),x=a.find(N=>String(N.bankAccountDetailId)===e);v.useEffect(()=>{if(!u)return;const N=g=>{var k;(k=f.current)!=null&&k.contains(g.target)||d(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[u]);const p=N=>{t(String(N)),h(!1),d(!1)};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{ref:f,className:"relative",children:[r.jsx(Nu,{label:c,required:!0}),r.jsxs("button",{type:"button",disabled:o||!n,onClick:()=>d(N=>!N),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:[r.jsx("span",{className:x?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":x?pl(x.accountNumber):"Bank account number"}),r.jsx(z0,{className:`shrink-0 text-slate-400 transition ${u?"rotate-180":""}`})]}),l?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,u?r.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:[r.jsx("div",{className:"p-3",children:r.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:[r.jsx(L0,{}),"Add Bank Account"]})}),r.jsx("div",{className:"border-t border-slate-200 px-4 py-2",children:r.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"List of Bank Accounts"})}),r.jsx("div",{className:"max-h-64 overflow-y-auto pb-2",children:a.length===0?r.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):a.map(N=>{const g=String(N.bankAccountDetailId)===e;return r.jsxs("button",{type:"button",onClick:()=>{t(String(N.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${g?"bg-gov-50":""}`,children:[r.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:Ri(N.bankName)}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:N.bankName}),r.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[pl(N.accountNumber),s?` · ${s}`:` · ${N.accountType}`]})]})]},N.bankAccountDetailId)})})]}):null]}),r.jsx(bu,{open:m,entityId:n,onClose:()=>h(!1),onAccountAdded:p})]})}function L0(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function z0({className:e=""}){return r.jsx("svg",{className:`h-4 w-4 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function M0(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Gr({entity:e,remittanceAmount:t="—",className:n=""}){if(!e)return r.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,children:[r.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),r.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No entity selected."})]});const s=en(e);return r.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,children:[r.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),r.jsxs("dl",{className:"space-y-4 p-5 text-sm",children:[r.jsx(Cr,{label:"Entity Name",value:s}),r.jsx(Cr,{label:"Tax ID",value:Vn(e.idNumber)}),r.jsx(Cr,{label:"Email ID",value:e.email}),r.jsx(Cr,{label:"Phone Number",value:Ln(e.phoneNumber)}),r.jsx(Cr,{label:"Address",value:M0(e)})]}),r.jsxs("div",{className:"border-t border-slate-100 px-5 py-4",children:[r.jsx("p",{className:"text-sm font-medium text-[#99A1AF]",children:"Remittance Amount"}),r.jsx("p",{className:"mt-1.5 text-xl font-bold text-gov-600",children:t})]})]})}function Cr({label:e,value:t}){return r.jsxs("div",{children:[r.jsx("dt",{className:"text-sm font-medium text-slate-500",children:e}),r.jsx("dd",{className:"mt-0.5 text-sm leading-relaxed text-slate-800",children:t})]})}const q0=[0,1,3,4,6,7,9,10],B0=[0,1,2,3,4,5,6,7,8,9,10],V0=[0,1,2,3,4,5,6,8,9,10,11],U0=[0,1,2,3,4,5,6,7,9,10,11],Z0=["720","941"],W0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],H0=["7200D"],Y0=["8963"];function ku(e){return Z0.includes(e)?q0:W0.includes(e)?B0:H0.includes(e)?V0:Y0.includes(e)?U0:[]}function K0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Is(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(n)||n<1||n>12?null:{year:t,month:n-1}}function Q0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function Cu(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const _s={941:"94105",944:"94405","CT-1":"10005"},Ar={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Ts={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 Zi(e,t){return!e||!t?!1:_s[e]===t}function Gs(e,t){return e==="CT-1"&&t===_s["CT-1"]}function J0(e,t){return e==="941"&&t===_s[941]||e==="944"&&t===_s[944]}function G0(e){return e==="CT-1"?{code1:Ar.tier1,code2:Ar.tier2,code3:""}:{code1:Ar.socialSecurity,code2:Ar.medicare,code3:Ar.withheld}}function Fs(e){return Ts.regex.test(e)}const X0=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,ls=1e8;function ev(e){if(!e)return"";let t="",n=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!n&&(t+=c,n=!0);const s=t.indexOf(".");let a=s===-1?t:t.slice(0,s);const i=s===-1?"":t.slice(s+1,s+3),o=s!==-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>ls&&(a=String(ls))}let l=s===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),X0.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>ls)return String(ls)}return l}return""}function Au(e){return Fs(e)?Number.parseFloat(e):null}function tv(e,t,n,s){const a=[e,t];return s&&a.push(n),a.reduce((i,o)=>{const l=Au(o);return l===null?i:i+l},0)}function nv(e,t){return Math.abs(e-t)<.005}function rv(e,t,n,s,a){if(!Zi(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=Gs(e,t);return{subcategoryCode1:n.trim()?"1":null,subcategoryCode2:s.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const sv=["Su","Mo","Tu","We","Th","Fr","Sa"];function av(){return r.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),r.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),r.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function Pu({value:e,onChange:t,disabled:n=!1,hasError:s=!1}){const a=Es(e),i=vu(),o=ju(),[l,c]=v.useState(!1),[u,d]=v.useState(()=>a??Es(i)??new Date),m=v.useRef(null),h=v.useId();v.useEffect(()=>{a&&d(a)},[e]),v.useEffect(()=>{if(!l)return;const g=k=>{var j;(j=m.current)!=null&&j.contains(k.target)||c(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]);const f=v.useMemo(()=>O0(u.getFullYear(),u.getMonth()),[u]),x=v.useMemo(()=>{const g=new Date(u.getFullYear(),u.getMonth()-1,1),k=new Date(g.getFullYear(),g.getMonth()+1,0);return pn(k)>=i},[u,i]),p=v.useMemo(()=>{const g=new Date(u.getFullYear(),u.getMonth()+1,1);return pn(g)<=o},[u,o]),N=g=>{Qa(g)&&(t(pn(g)),c(!1))};return r.jsxs("div",{ref:m,className:"relative",children:[r.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${s?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[r.jsx("input",{id:h,type:"text",readOnly:!0,disabled:n,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!n&&c(g=>!g),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),r.jsx("button",{type:"button",disabled:n,onClick:()=>c(g=>!g),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:r.jsx(av,{})})]}),l?r.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:[r.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),r.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[r.jsx("button",{type:"button",disabled:!x,onClick:()=>d(g=>new Date(g.getFullYear(),g.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:r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),r.jsx("span",{className:"text-sm font-semibold text-slate-900",children:$0(u.getFullYear(),u.getMonth())}),r.jsx("button",{type:"button",disabled:!p,onClick:()=>d(g=>new Date(g.getFullYear(),g.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:r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),r.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pt-2 text-center text-xs font-medium text-slate-500",children:sv.map(g=>r.jsx("div",{className:"py-1",children:g},g))}),r.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((g,k)=>{if(!g)return r.jsx("div",{},`empty-${k}`);const j=pn(g),S=e===j,E=!Qa(g);return r.jsx("button",{type:"button","aria-disabled":E,onClick:()=>N(g),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":S?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:g.getDate()},j)})})]}):null]})}function _r({value:e,onChange:t,onBlur:n,name:s,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return r.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:s,value:e,disabled:a,readOnly:i,placeholder:o,className:G(l,i),onChange:c=>t(ev(c.target.value)),onBlur:n})}const iv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ov(){return r.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),r.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),r.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function lv({value:e,onChange:t,disabled:n=!1,hasError:s=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=Cu(),l=Is(e),[c,u]=v.useState(!1),[d,m]=v.useState((l==null?void 0:l.year)??o),h=v.useRef(null),f=v.useId();v.useEffect(()=>{l&&m(l.year)},[e]),v.useEffect(()=>{if(!c)return;const j=S=>{var E;(E=h.current)!=null&&E.contains(S.target)||u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const x=K0(e),p=j=>!!a.includes(j),N=j=>{p(j)||(t(Q0(d,j)),u(!1))},g=d>i,k=d<o;return r.jsxs("div",{ref:h,className:"relative",children:[r.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${s?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[r.jsx("input",{id:f,type:"text",readOnly:!0,disabled:n,value:x,placeholder:"YYYY-MM",onClick:()=>!n&&u(j=>!j),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),r.jsx("button",{type:"button",disabled:n,onClick:()=>u(j=>!j),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:r.jsx(ov,{})})]}),c?r.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:[r.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),r.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[r.jsx("button",{type:"button",disabled:!g,onClick:()=>m(j=>j-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:r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),r.jsx("span",{className:"text-sm font-semibold text-slate-900",children:d}),r.jsx("button",{type:"button",disabled:!k,onClick:()=>m(j=>j+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:r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),r.jsx("div",{className:"grid grid-cols-3 gap-1 p-3",children:iv.map((j,S)=>{const E=(l==null?void 0:l.year)===d&&l.month===S&&e.length===6,T=p(S);return r.jsx("button",{type:"button","aria-disabled":T,onClick:()=>N(S),className:`rounded-lg px-2 py-2.5 text-sm transition ${T?"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:j},j)})})]}):null]})}const Eu="Active",cv="Inactive";function jr(e){return(e.status??Eu).trim().toLowerCase()==="active"}function uv(e){return jr(e)?cv:Eu}function dv(e){return jr(e)?"Deactivate":"Activate"}function Wi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function mv(e){return Wi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function Iu(e){const t=rv(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),n=Gs(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:!n&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function Hi(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),...Iu(t)}}function Yi(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),...Iu(e)}}const Ki="federal-payment-draft";function Qi(e){sessionStorage.setItem(Ki,JSON.stringify(e))}function Xs(){const e=sessionStorage.getItem(Ki);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ji(){sessionStorage.removeItem(Ki)}function hv(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 fv=Xt({taxpayerPin:_().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:_().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:_().min(1,"Bank account is required"),routingNumber:_().optional(),accountType:_().optional(),bankName:_().optional(),taxFormType:_().min(1,"Tax form type is required"),taxTypeCode:_().min(1,"Payment type is required"),taxPeriod:_().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=Is(e);if(!t)return!1;const{minYear:n,maxYear:s}=Cu();return t.year>=n&&t.year<=s},"Tax period must be within the last 3 years"),settlementDate:_().min(1,"This field is required").refine(e=>Js(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:_().min(1,"This field is required").refine(e=>Fs(e),Ts.errorMessage),subcategoryCode1:_().optional(),subcategoryAmount1:_().optional(),subcategoryCode2:_().optional(),subcategoryAmount2:_().optional(),subcategoryCode3:_().optional(),subcategoryAmount3:_().optional()}).superRefine((e,t)=>{var l;if(e.taxPeriod&&e.taxFormType){const c=Is(e.taxPeriod);c&&ku(e.taxFormType).includes(c.month)&&t.addIssue({code:rn.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Zi(e.taxFormType,e.taxTypeCode))return;const n=Gs(e.taxFormType,e.taxTypeCode),s=J0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:rn.custom,message:"This field is required",path:[u]});return}Fs(c)||t.addIssue({code:rn.custom,message:Ts.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",s);const i=Au(e.paymentAmount),o=tv(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",s);i!==null&&!nv(i,o)&&t.addIssue({code:rn.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),n&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:rn.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),cs="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function ha(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 pv={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function xv(e,t){if(e)return ha(e);if(t!=null&&t.paymentDraft)return ha(t.paymentDraft);const n=Xs();return n?ha(n):pv}function _u({entity:e,initialDraft:t,readonly:n=!1,onCancel:s}){var Lt,ft,vt,pt,jt,zt,At,Mt,Pt,Nt,Et,It,qt;const a=Ae(),i=Ce(),o=yt(),l=Un(i.state,Qe()),c=i.state,u=v.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Xs()??null,[t,c==null?void 0:c.paymentDraft]),d=v.useRef(u==null?void 0:u.federalPaymentId),m=v.useRef(u==null?void 0:u.enrollmentId),[h,f]=v.useState(null),[x,p]=v.useState(!1),N=v.useMemo(()=>xv(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);v.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:g=[],isLoading:k}=je({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Qr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),j=v.useMemo(()=>g.filter(jr),[g]),{data:S=[],isLoading:E}=je({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>t0(e.entityId),enabled:e!==null}),{register:T,control:A,handleSubmit:R,watch:I,setValue:L,trigger:ie,formState:{errors:V}}=Rt({resolver:Ot(fv),defaultValues:N}),K=I("bankAccountDetailId"),te=I("paymentAmount"),H=I("taxFormType"),ce=I("taxTypeCode"),he=I("taxPeriod"),Q=I("settlementDate"),ke=I("subcategoryAmount1"),re=I("subcategoryAmount2"),Se=I("subcategoryAmount3"),ue=v.useRef(H),be=v.useMemo(()=>H?ku(H):[],[H]),$=v.useMemo(()=>Zi(H,ce),[H,ce]),xe=v.useMemo(()=>Gs(H,ce),[H,ce]),{data:ee=[],isLoading:Ne}=je({queryKey:["federal-tax-type-codes",H],queryFn:()=>n0(H),enabled:!!H});v.useEffect(()=>{ue.current&&ue.current!==H&&L("taxTypeCode",""),ue.current=H},[H,L]),v.useEffect(()=>{if(!he||!H)return;const z=Is(he);z&&be.includes(z.month)&&L("taxPeriod","")},[H,he,be,L]),v.useEffect(()=>{Q&&(Js(Q)||L("settlementDate",""))},[Q,L]),v.useEffect(()=>{if(!$){L("subcategoryCode1",""),L("subcategoryCode2",""),L("subcategoryCode3",""),L("subcategoryAmount1",""),L("subcategoryAmount2",""),L("subcategoryAmount3","");return}const z=G0(H);L("subcategoryCode1",z.code1),L("subcategoryCode2",z.code2),L("subcategoryCode3",xe?"":z.code3),xe&&L("subcategoryAmount3","")},[$,H,xe,L]),v.useEffect(()=>{$&&(ie("paymentAmount"),ie("subcategoryAmount1"),ie("subcategoryAmount2"),ie("subcategoryAmount3"))},[ke,re,Se,$,ie]),v.useEffect(()=>{const z=j.find(de=>String(de.bankAccountDetailId)===K);if(!z){K&&(L("bankAccountDetailId",""),L("routingNumber",""),L("accountType",""),L("bankName",""));return}L("routingNumber",z.routingNumber),L("accountType",z.accountType),L("bankName",z.bankName)},[j,K,L]);const se=z=>{const de=j.find(b=>String(b.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??(de==null?void 0:de.routingNumber)??"",accountNumber:(de==null?void 0:de.accountNumber)??"",accountType:z.accountType??(de==null?void 0:de.accountType)??"",bankName:z.bankName??(de==null?void 0:de.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}},Me=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 b=await Vi(z.federalPaymentId,Yi(z));return d.current=b.federalPaymentId,m.current=b.enrollmentId,b}const de=await Bi(Hi(e.entityId,z));return d.current=de.federalPaymentId,m.current=de.enrollmentId,de},Te=R(async z=>{if(!(n||!e)){f(null),p(!0);try{const de=se(z),b=await oe(de);if(!b)return;const C={...de,federalPaymentId:b.federalPaymentId,enrollmentId:b.enrollmentId};await Me(),Qi(C),a(mv(e),{state:{from:l,paymentDraft:C}})}catch(de){f(st(de,"Failed to save payment details."))}finally{p(!1)}}}),Je=R(async z=>{if(!(!e||n)){f(null),p(!0);try{const de=se(z);await oe(de),await Me(),Ji(),a(Qe())}catch(de){f(st(de,"Failed to save draft."))}finally{p(!1)}}}),at=()=>{if(s){s();return}a(l)},it=e?en(e):"Entity";return r.jsxs("form",{onSubmit:Te,noValidate:!0,className:"w-full space-y-6",children:[h?r.jsx(Gt,{message:h}):null,r.jsxs("div",{className:"relative w-full",children:[r.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:it}),r.jsx(Gr,{entity:e,remittanceAmount:Jr(te),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),r.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:[r.jsx(wn,{title:"Enrolment Details",isFirst:!0,children:r.jsxs("div",{className:cs,children:[r.jsx(Y,{label:"Taxpayer PIN",required:!0,error:(Lt=V.taxpayerPin)==null?void 0:Lt.message,children:r.jsx("input",{placeholder:"Taxpayer PIN",className:G(!!V.taxpayerPin),maxLength:4,disabled:n,...T("taxpayerPin")})}),r.jsx(Y,{label:"Secondary TIN",error:(ft=V.secondaryTin)==null?void 0:ft.message,children:r.jsx("input",{placeholder:"Secondary TIN",className:G(!!V.secondaryTin),maxLength:9,disabled:n,...T("secondaryTin")})}),r.jsx(Le,{name:"bankAccountDetailId",control:A,render:({field:z})=>{var de;return r.jsx(Su,{value:z.value,onChange:z.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:j,isLoading:k,disabled:!e||n,error:(de=V.bankAccountDetailId)==null?void 0:de.message})}}),r.jsx(Y,{label:"Routing Number",required:!0,error:(vt=V.routingNumber)==null?void 0:vt.message,children:r.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:G(!!V.routingNumber,!0),...T("routingNumber")})}),r.jsx(Y,{label:"Account Type",required:!0,error:(pt=V.accountType)==null?void 0:pt.message,children:r.jsx("input",{readOnly:!0,placeholder:"Account Type",className:G(!!V.accountType,!0),...T("accountType")})}),r.jsx(Y,{label:"Bank Name",required:!0,error:(jt=V.bankName)==null?void 0:jt.message,children:r.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:G(!!V.bankName,!0),...T("bankName")})})]})}),r.jsx(wn,{title:"Federal Payment",children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:cs,children:[r.jsx(Y,{label:"Tax Form Type",required:!0,error:(zt=V.taxFormType)==null?void 0:zt.message,children:r.jsxs(Fr,{children:[r.jsxs("select",{className:Gn(!!V.taxFormType),disabled:E||!e||n,...T("taxFormType"),children:[r.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),S.map(z=>r.jsx("option",{value:z.value,children:z.value},z.value))]}),r.jsx(Yn,{})]})}),r.jsx(Y,{label:"Payment Type",required:!0,error:(At=V.taxTypeCode)==null?void 0:At.message,children:r.jsxs(Fr,{children:[r.jsxs("select",{className:Gn(!!V.taxTypeCode),disabled:!H||Ne||n,...T("taxTypeCode"),children:[r.jsx("option",{value:"",children:H?Ne?"Loading payment types…":"Select payment type":"Select tax form first"}),ee.map(z=>r.jsxs("option",{value:z.code,children:[z.code," - ",z.codeName]},z.code))]}),r.jsx(Yn,{})]})}),r.jsx(Y,{label:"Tax Period",required:!0,error:(Mt=V.taxPeriod)==null?void 0:Mt.message,children:r.jsx(Le,{name:"taxPeriod",control:A,render:({field:z})=>r.jsx(lv,{value:z.value,onChange:z.onChange,hasError:!!V.taxPeriod,disabled:!H||n,disabledMonths:be})})})]}),r.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[r.jsx(Y,{label:"Settlement Date",required:!0,error:(Pt=V.settlementDate)==null?void 0:Pt.message,children:r.jsx(Le,{name:"settlementDate",control:A,render:({field:z})=>r.jsx(Pu,{value:z.value,onChange:z.onChange,hasError:!!V.settlementDate,disabled:n})})}),r.jsx(Y,{label:"Payment Amount",required:!0,error:(Nt=V.paymentAmount)==null?void 0:Nt.message,children:r.jsx(Le,{name:"paymentAmount",control:A,render:({field:z})=>r.jsx(_r,{name:z.name,value:z.value,onChange:z.onChange,onBlur:z.onBlur,disabled:n,hasError:!!V.paymentAmount})})})]}),$?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:cs,children:[r.jsx(Y,{label:"Subcategory Code 1",children:r.jsx("input",{readOnly:!0,className:G(!1,!0),...T("subcategoryCode1")})}),r.jsx(Y,{label:"Subcategory Code 2",children:r.jsx("input",{readOnly:!0,className:G(!1,!0),...T("subcategoryCode2")})}),xe?null:r.jsx(Y,{label:"Subcategory Code 3",children:r.jsx("input",{readOnly:!0,className:G(!1,!0),...T("subcategoryCode3")})})]}),r.jsxs("div",{className:cs,children:[r.jsx(Y,{label:"Subcategory Amount 1",required:!0,error:(Et=V.subcategoryAmount1)==null?void 0:Et.message,children:r.jsx(Le,{name:"subcategoryAmount1",control:A,render:({field:z})=>r.jsx(_r,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount1})})}),r.jsx(Y,{label:"Subcategory Amount 2",required:!0,error:(It=V.subcategoryAmount2)==null?void 0:It.message,children:r.jsx(Le,{name:"subcategoryAmount2",control:A,render:({field:z})=>r.jsx(_r,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount2})})}),xe?null:r.jsx(Y,{label:"Subcategory Amount 3",required:!0,error:(qt=V.subcategoryAmount3)==null?void 0:qt.message,children:r.jsx(Le,{name:"subcategoryAmount3",control:A,render:({field:z})=>r.jsx(_r,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!V.subcategoryAmount3})})})]})]}):null]})})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[r.jsx("button",{type:"button",onClick:at,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:n?"Back":"Cancel"}),n?null:r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:Je,disabled:!e||x,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:x?"Saving…":"Save as Draft"}),r.jsx("button",{type:"submit",disabled:!e||x,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:x?"Saving…":"Next"})]})]})]},i.key)}function Tu(){const{selectedEntity:e}=ht();return r.jsx(_u,{entity:e})}function Fu({mode:e}){var m;const t=Ae(),{federalPaymentId:n}=ai(),{selectedEntity:s}=ht(),a=Number.parseInt(n??"",10),{data:i,isLoading:o,isError:l}=je({queryKey:["federal-payment",a],queryFn:()=>qi(a),enabled:Number.isFinite(a)}),{data:c=[]}=je({queryKey:["bank-accounts",s==null?void 0:s.entityId],queryFn:async()=>(await Qr({entityId:s.entityId,pageNumber:1,pageSize:100})).items,enabled:s!==null&&i!==void 0}),u=v.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return hv(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 r.jsx(Ve,{to:Qe(),replace:!0});if(o)return r.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!u)return r.jsx(Ve,{to:Qe(),replace:!0});if(!s||i.entityId!==s.entityId)return r.jsx(Ve,{to:Qe(),replace:!0});const d=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return r.jsx(_u,{entity:s,initialDraft:u,readonly:d,onCancel:()=>t(Qe())})}function Du(){return ht(),r.jsx(Fu,{mode:"edit"})}function Ru(){return ht(),r.jsx(Fu,{mode:"view"})}function gv(e){const t=[];return e.includes("\\d")&&t.push("0-9"),/[A-Z]/.test(e)&&t.push("A-Z"),e.includes("-")&&t.push("\\-"),e.includes(" ")&&t.push(" "),e.includes("/")&&t.push("/"),t.length?t.join(""):null}function yv(e,t){const n=e.toUpperCase();if(!t)return n;const s=gv(t);return s?n.replace(new RegExp(`[^${s}]`,"g"),""):n}function bv(e){if(!e)return null;const t=[];let n=0;try{for(;n<e.length;){if(e.startsWith("(?:",n))return null;const s=e[n];if(s==="-"||s===" "||s==="/"){t.push({type:"separator",char:s}),n+=1;continue}let a;if(s==="\\")a=e[n+1]==="d"?"digit":"letter",n+=2;else if(s==="["){const o=e.indexOf("]",n);if(o===-1)return null;a="letter",n=o+1}else a=s>="0"&&s<="9"?"digit":"letter",n+=1;const i=vv(e,n);if(i===null)return null;for(let o=0;o<i.count;o+=1)t.push({type:"slot",kind:a});n=i.nextIndex}}catch{return null}return t}function vv(e,t){if(e[t]!=="{")return{count:1,nextIndex:t};const n=e.indexOf("}",t);if(n===-1)throw new Error("Unterminated quantifier");const s=e.slice(t+1,n);if(s.includes(","))return null;const a=Number.parseInt(s,10);if(Number.isNaN(a))throw new Error("Bad quantifier");return{count:a,nextIndex:n+1}}function jv(e,t){const n=e.toUpperCase().replace(/[^0-9A-Z]/g,"").split("");let s="",a=0;for(const i of t){if(a>=n.length)break;if(i.type==="separator"){s+=i.char;continue}for(;a<n.length;){const o=n[a];a+=1;const l=o>="0"&&o<="9";if(i.kind==="digit"?l:!l){s+=o;break}}}return s}function Nv(e){if(e)try{const t=$u(e,0);return t.index===e.length?t.length:void 0}catch{return}}function $u(e,t){let n=t,s=0;for(;;){const a=wv(e,n);if(s=Math.max(s,a.length),n=a.index,e[n]==="|"){n+=1;continue}return{length:s,index:n}}}function wv(e,t){let n=t,s=0;for(;n<e.length&&e[n]!=="|"&&e[n]!==")";){const a=Sv(e,n);s+=a.length,n=a.index}return{length:s,index:n}}function Sv(e,t){let n=t,s;if(e.startsWith("(?:",n)){const a=$u(e,n+3);if(e[a.index]!==")")throw new Error("Unbalanced group");s=a.length,n=a.index+1}else if(e[n]==="\\")s=1,n+=2;else if(e[n]==="["){const a=e.indexOf("]",n);if(a===-1)throw new Error("Unterminated class");s=1,n=a+1}else s=1,n+=1;if(e[n]==="{"){const a=e.indexOf("}",n);if(a===-1)throw new Error("Unterminated quantifier");const i=e.slice(n+1,a).split(","),o=i.length===2?i[1]:i[0],l=Number.parseInt(o,10);if(Number.isNaN(l))throw new Error("Bad quantifier");s*=l,n=a+1}return{length:s,index:n}}const Gi="state-payment-draft";function Ja(e){sessionStorage.setItem(Gi,JSON.stringify(e))}function Ga(){const e=sessionStorage.getItem(Gi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ou(){sessionStorage.removeItem(Gi)}function Lu(e,t){return`${e}-${t}`}function kv(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Lu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function Cv(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Lu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}function Av(e){return Xt({state:_().min(1,"State is required"),reasonForPayment:_().min(1,"Reason for payment is required"),stateAccountId:_().min(1,"State ID is required"),accountId:_().min(1,"Account ID is required").refine(t=>/^\d{10,12}$/.test(t.trim()),"Account ID must be 10 to 12 digits"),letterId:_().optional().refine(t=>!t||/^[A-Za-z0-9]+$/.test(t),"Letter ID must be alphanumeric"),taxYear:_().min(1,"Tax year is required"),taxPeriod:_().min(1,"Tax period is required"),taxAmount:_().min(1,"Tax amount is required").refine(t=>Fs(t),Ts.errorMessage),paymentDate:_().min(1,"Payment date is required").refine(t=>Js(t),"Payment date must be a weekday within the allowed range"),bankAccountDetailId:_().min(1,"Bank account is required"),routingNumber:_().optional(),accountType:_().optional(),bankName:_().optional()}).superRefine((t,n)=>{const s=e(),a=s==null?void 0:s.stateId.pattern;if(a)try{new RegExp(`^(?:${a})$`).test(t.stateAccountId.trim().toUpperCase())||n.addIssue({code:rn.custom,path:["stateAccountId"],message:s.stateId.message})}catch{n.addIssue({code:rn.custom,path:["stateAccountId"],message:"State ID validation is temporarily unavailable"})}})}const fa="grid gap-x-6 gap-y-5 sm:grid-cols-3",xl="grid gap-x-6 gap-y-5 sm:grid-cols-2",gl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",yl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function pa(e){return{state:e.state,reasonForPayment:Pv(e.reasonForPayment),stateAccountId:e.stateAccountId,accountId:e.accountId,letterId:e.letterId??"",taxYear:e.taxYear,taxPeriod:e.taxPeriod,taxAmount:e.taxAmount,paymentDate:e.paymentDate,bankAccountDetailId:e.bankAccountDetailId,routingNumber:e.routingNumber??"",accountType:e.accountType??"",bankName:e.bankName??""}}function Pv(e){return e.trim().toUpperCase().replaceAll(" ","_")}function zu({entity:e,initialDraft:t,readonly:n=!1,onCancel:s}){var Nt,Et,It,qt,z,de,b,C;const a=Ae(),i=Ce(),o=Un(i.state,Qe()),l=i.state,c=v.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??Ga()??null,[t,l==null?void 0:l.paymentDraft]),u=v.useRef(c==null?void 0:c.statePaymentDetailId),d=v.useMemo(()=>{if(t)return pa(t);if(l!=null&&l.paymentDraft)return pa(l.paymentDraft);if(l!=null&&l.resetDraft)return Ou(),yl;const y=Ga();return y?pa(y):yl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),{data:m=[],isLoading:h,isError:f}=je({queryKey:["state-payment-states"],queryFn:({signal:y})=>u0(y)}),{data:x=[],isLoading:p}=je({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Qr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),N=v.useMemo(()=>x.filter(jr),[x]),g=v.useRef(null),k=v.useMemo(()=>Av(()=>g.current),[]),{register:j,control:S,handleSubmit:E,watch:T,setValue:A,clearErrors:R,formState:{errors:I}}=Rt({resolver:Ot(k),defaultValues:d}),L=T("state"),ie=T("reasonForPayment"),V=T("taxAmount"),K=T("paymentDate"),te=T("bankAccountDetailId"),{data:H=[],isLoading:ce,isError:he}=je({queryKey:["state-payment-reasons",e==null?void 0:e.entityId,L],queryFn:({signal:y})=>d0(e.entityId,L,y),enabled:e!==null&&!!L}),{data:Q,isLoading:ke,isError:re}=je({queryKey:["state-payment-validation-metadata",e==null?void 0:e.entityId,L,ie],queryFn:({signal:y})=>m0(e.entityId,L,ie,y),enabled:e!==null&&!!(L&&ie)});g.current=Q??null;const Se=(Q==null?void 0:Q.taxYearOptions)??[],ue=(Q==null?void 0:Q.taxPeriodOptions)??[],be=!!(Q&&L&&ie),$=(Q==null?void 0:Q.stateId.pattern)??null,xe=Nv($),ee=v.useMemo(()=>bv($),[$]),Ne=j("stateAccountId"),se=j("accountId"),Me=j("letterId"),[oe,Te]=v.useState(!1),[Je,at]=v.useState(""),it=v.useRef(null),Lt=(Nt=m.find(y=>y.code===L))==null?void 0:Nt.name,ft=v.useMemo(()=>{const y=Je.trim().toLowerCase();return y?m.filter(D=>D.name.toLowerCase().includes(y)||D.code.toLowerCase().includes(y)):m},[Je,m]),vt=["stateAccountId","accountId","letterId","taxYear","taxPeriod","taxAmount","paymentDate"],pt=()=>{vt.forEach(y=>A(y,"")),R([...vt,"bankAccountDetailId"])},jt=y=>{A("state",y,{shouldValidate:!0}),A("reasonForPayment",""),R("reasonForPayment"),pt(),at(""),Te(!1)},zt=y=>{y!==ie&&(A("reasonForPayment",y,{shouldValidate:!0}),pt())};v.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(u.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),v.useEffect(()=>{var y;oe&&((y=it.current)==null||y.focus())},[oe]),v.useEffect(()=>{!ie||ce||he||H.some(y=>y.code===ie)||A("reasonForPayment","")},[ce,he,H,ie,A]),v.useEffect(()=>{n||K&&!Js(K)&&A("paymentDate","")},[K,A,n]),v.useEffect(()=>{if(n)return;const y=N.find(D=>String(D.bankAccountDetailId)===te);if(!y){te&&(A("bankAccountDetailId",""),A("routingNumber",""),A("accountType",""),A("bankName",""));return}A("routingNumber",y.routingNumber),A("accountType",y.accountType),A("bankName",y.bankName)},[N,te,A,n]);const At=E(y=>{if(n||!Q)return;const D={statePaymentDetailId:u.current,state:y.state,reasonForPayment:y.reasonForPayment,stateAccountId:y.stateAccountId.trim().toUpperCase(),accountId:y.accountId.trim(),letterId:y.letterId,taxYear:y.taxYear,taxPeriod:y.taxPeriod,taxAmount:y.taxAmount,paymentDate:y.paymentDate,bankAccountDetailId:y.bankAccountDetailId,routingNumber:y.routingNumber,accountType:y.accountType,bankName:y.bankName};Ja(D),a("/payments/state/authorization",{state:{from:o,paymentDraft:D}})}),Mt=()=>{if(s){s();return}a(o)},Pt=e?en(e):"Entity";return r.jsx("form",{onSubmit:At,noValidate:!0,className:"w-full",children:r.jsxs("div",{className:"relative w-full",children:[r.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:Pt}),r.jsx(Gr,{entity:e,remittanceAmount:Jr(V),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),r.jsx("div",{className:"lg:mr-[324px]",children:r.jsxs("div",{className:"mx-auto w-full max-w-[720px] space-y-5",children:[r.jsxs("section",{className:gl,children:[r.jsx(bl,{step:1,title:"Choose a State"}),r.jsxs("div",{className:"mt-5 space-y-5",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{type:"button",disabled:n||h||f,onClick:()=>{at(""),Te(y=>!y)},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 disabled:cursor-not-allowed disabled:opacity-70",children:[r.jsxs("span",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:r.jsx(Ev,{})}),r.jsxs("span",{children:[r.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:h?"Loading states…":Lt??"Choose a state"}),r.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),r.jsx(Yn,{className:`h-4 w-4 text-slate-400 transition ${oe?"rotate-180":""}`})]}),oe?r.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:[r.jsx("div",{className:"border-b border-slate-100 p-2",children:r.jsx("input",{ref:it,type:"search",value:Je,onChange:y=>at(y.target.value),onKeyDown:y=>{y.key==="Escape"?Te(!1):y.key==="Enter"&&y.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[ft.map(y=>r.jsxs("button",{type:"button",onClick:()=>jt(y.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${L===y.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[r.jsx("span",{children:y.name}),r.jsx("span",{className:"text-xs font-medium text-slate-400",children:y.code})]},y.code)),ft.length===0?r.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,I.state?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:I.state.message}):null,f?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Unable to load states."}):null]}),r.jsx(Y,{label:"Reason for Payment",required:!0,error:(Et=I.reasonForPayment)==null?void 0:Et.message,children:r.jsxs(Fr,{children:[r.jsxs("select",{disabled:n||!L||ce||he,className:Gn(!!I.reasonForPayment),...j("reasonForPayment"),onChange:y=>zt(y.target.value),children:[r.jsx("option",{value:"",children:ce?"Loading reasons…":"Select reason"}),H.map(y=>r.jsx("option",{value:y.code,children:y.label},y.code))]}),r.jsx(Yn,{})]})}),he?r.jsx("p",{className:"text-xs text-red-600",children:"Unable to load payment reasons."}):null,L&&!ce&&!he&&H.length===0?r.jsx("p",{className:"text-xs text-slate-500",children:"No supported payment reasons are available for this entity and state."}):null]})]}),r.jsxs("section",{className:`${gl} transition ${be?"":"opacity-60"}`,children:[r.jsx(bl,{step:2,title:"Payment Form",className:"mb-5"}),r.jsxs("fieldset",{disabled:!be||n,className:"min-w-0 border-0 p-0",children:[r.jsx(xa,{title:"Payment Details",children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:fa,children:[r.jsx(Y,{label:"State ID",required:(Q==null?void 0:Q.stateId.required)??!0,error:(It=I.stateAccountId)==null?void 0:It.message,children:r.jsx("input",{placeholder:(Q==null?void 0:Q.stateId.example)??"Enter ID",maxLength:xe,className:G(!!I.stateAccountId),...Ne,onChange:y=>{y.target.value=ee?jv(y.target.value,ee):yv(y.target.value,$),Ne.onChange(y)}})}),r.jsx(Y,{label:"Account ID",required:(Q==null?void 0:Q.accountIdRequired)??!0,error:(qt=I.accountId)==null?void 0:qt.message,children:r.jsx("input",{inputMode:"numeric",placeholder:"10–12 digits",maxLength:12,className:G(!!I.accountId),...se,onChange:y=>{y.target.value=y.target.value.replace(/\D/g,"").slice(0,12),se.onChange(y)}})}),r.jsx(Y,{label:"Letter ID",required:(Q==null?void 0:Q.letterIdRequired)??!1,children:r.jsx("input",{placeholder:"Alphanumeric",maxLength:50,className:G(),...Me,onChange:y=>{y.target.value=y.target.value.replace(/[^A-Za-z0-9]/g,"").slice(0,50),Me.onChange(y)}})})]}),r.jsxs("div",{className:xl,children:[r.jsx(Y,{label:"Tax Year",required:!0,error:(z=I.taxYear)==null?void 0:z.message,children:r.jsxs(Fr,{children:[r.jsxs("select",{className:Gn(!!I.taxYear),...j("taxYear"),children:[r.jsx("option",{value:"",children:"Select TY"}),Se.map(y=>r.jsxs("option",{value:String(y),children:["TY ",y]},y))]}),r.jsx(Yn,{})]})}),r.jsx(Y,{label:(Q==null?void 0:Q.periodMode)==="account-assigned"?"Deposit Frequency":"Tax Period",required:!0,error:(de=I.taxPeriod)==null?void 0:de.message,children:r.jsxs(Fr,{children:[r.jsxs("select",{className:Gn(!!I.taxPeriod),...j("taxPeriod"),children:[r.jsx("option",{value:"",children:"Select"}),ue.map(y=>r.jsx("option",{value:y.value,children:y.label},y.value))]}),r.jsx(Yn,{})]})})]})]})}),r.jsx(xa,{title:"Amount Info",children:r.jsxs("div",{className:xl,children:[r.jsx(Y,{label:"Tax Amount",required:!0,error:(b=I.taxAmount)==null?void 0:b.message,children:r.jsx(Le,{name:"taxAmount",control:S,render:({field:y})=>r.jsx(_r,{name:y.name,value:y.value,onChange:y.onChange,onBlur:y.onBlur,disabled:n,hasError:!!I.taxAmount})})}),r.jsx(Y,{label:"Payment Date",required:!0,error:(C=I.paymentDate)==null?void 0:C.message,children:r.jsx(Le,{name:"paymentDate",control:S,render:({field:y})=>r.jsx(Pu,{value:y.value,onChange:y.onChange,hasError:!!I.paymentDate,disabled:n})})})]})}),r.jsx(xa,{title:"Bank Account",children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:fa,children:[r.jsx(Le,{name:"bankAccountDetailId",control:S,render:({field:y})=>{var D;return r.jsx(Su,{value:y.value,onChange:y.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:N,isLoading:p,disabled:!e||!be||n,error:(D=I.bankAccountDetailId)==null?void 0:D.message,label:"Account Number"})}}),r.jsx(Y,{label:"Routing Number",required:!0,children:r.jsx("input",{readOnly:!0,placeholder:"9-digit",className:G(!1,!0),...j("routingNumber")})}),r.jsx(Y,{label:"Account Type",required:!0,children:r.jsx("input",{readOnly:!0,placeholder:"Select",className:G(!1,!0),...j("accountType")})})]}),r.jsx("div",{className:fa,children:r.jsx(Y,{label:"Bank Name",children:r.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:G(!1,!0),...j("bankName")})})})]})}),Q!=null&&Q.notes.length?r.jsx("div",{className:"mt-5 rounded-lg bg-amber-50 px-4 py-3 text-xs text-amber-800",children:Q.notes.map(y=>r.jsx("p",{children:y},y))}):null]}),be?null:r.jsx("p",{className:"mt-4 text-sm text-slate-500",children:ke?"Loading payment requirements…":re?"Unable to load payment requirements.":"Select a state and reason for payment to continue."})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:Mt,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:n?"Back":"Cancel"}),n?null:r.jsxs("button",{type:"submit",disabled:!e||!be,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",r.jsx(Iv,{})]})]})]})})]})},i.key)}function bl({step:e,title:t,className:n=""}){return r.jsxs("div",{className:`flex items-center gap-3 ${n}`,children:[r.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}),r.jsx("h3",{className:"text-sm font-bold uppercase tracking-wide text-slate-900",children:t})]})}function xa({title:e,children:t}){return r.jsxs("div",{className:"mt-6 first:mt-0",children:[r.jsx("h4",{className:"mb-4 text-xs font-semibold uppercase tracking-wide text-slate-400",children:e}),t]})}function Ev(){return r.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),r.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 Iv(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})}function Mu(){const{selectedEntity:e}=ht();return r.jsx(zu,{entity:e})}function _v(e){const t=e.indexOf("-");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function qu(){var l;const{statePaymentId:e}=ai(),{selectedEntity:t}=ht(),n=Number.parseInt(e??"",10),{data:s,isLoading:a,isError:i}=je({queryKey:["state-payments",n],queryFn:()=>fu(n),enabled:t!==null&&Number.isFinite(n)}),o=v.useMemo(()=>{if(!s)return null;const[c,u]=_v(s.taxPeriod);return{statePaymentDetailId:s.statePaymentDetailId,state:s.state,reasonForPayment:"",stateAccountId:"",accountId:"",taxYear:c,taxPeriod:u,taxAmount:String(s.taxAmount),paymentDate:s.paymentDate,bankAccountDetailId:""}},[s]);return Number.isFinite(n)?a?r.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!s||!o?r.jsx(Ve,{to:Qe(),replace:!0}):!t||s.entityId!==t.entityId?r.jsx(Ve,{to:Qe(),replace:!0}):((l=s.status)==null?void 0:l.toLowerCase())!=="draft"?r.jsx(Ve,{to:`/payments/state/${n}/view`,replace:!0}):r.jsx(zu,{entity:t,initialDraft:o}):r.jsx(Ve,{to:Qe(),replace:!0})}function Bu(){var l,c;const{statePaymentId:e}=ai(),t=Ae(),{selectedEntity:n}=ht(),s=Number.parseInt(e??"",10),{data:a,isLoading:i,isError:o}=je({queryKey:["state-payments",s],queryFn:()=>fu(s),enabled:n!==null&&Number.isFinite(s)});return Number.isFinite(s)?i?r.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!a?r.jsx(Ve,{to:"/payments",replace:!0}):!n||a.entityId!==n.entityId?r.jsx(Ve,{to:"/payments",replace:!0}):r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>t("/payments"),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-600 transition hover:bg-slate-50",children:[r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Back to Payments"]}),r.jsxs("h1",{className:"text-lg font-semibold text-slate-900",children:["State Payment ST-",a.statePaymentDetailId]})]}),r.jsx("div",{className:"w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",children:r.jsxs("dl",{className:"grid gap-x-8 gap-y-5 sm:grid-cols-2",children:[r.jsxs("div",{children:[r.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"State"}),r.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.state})]}),r.jsxs("div",{children:[r.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax Period"}),r.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.taxPeriod})]}),r.jsxs("div",{children:[r.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Amount"}),r.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:Kr(a.taxAmount)})]}),r.jsxs("div",{children:[r.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Payment Date"}),r.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:a.paymentDate})]}),r.jsxs("div",{children:[r.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Status"}),r.jsx("dd",{className:"mt-1",children:r.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${((l=a.status)==null?void 0:l.toLowerCase())==="paid"?"bg-green-100 text-green-800":((c=a.status)==null?void 0:c.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:a.status??"—"})})]}),a.reason&&r.jsxs("div",{children:[r.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Rejection Reason"}),r.jsx("dd",{className:"mt-1 text-sm text-slate-700",children:a.reason})]})]})})]}):r.jsx(Ve,{to:"/payments",replace:!0})}const Tv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",Fv="I have reviewed the details and authorize this payment.",Vu=/^[a-zA-Z\s]+$/;function Uu(e){return e.replace(/[^a-zA-Z\s]/g,"")}const Xi=_().min(1,"Signature is required").regex(Vu,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),Dv=_().optional().refine(e=>!e||!e.trim()||Vu.test(e),{message:"Signature must contain only letters"}),Rv=Xt({agreementDate:_().min(1,"Date is required"),agreementAccepted:Qn().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:_().min(1,"Name of authorization person is required"),signature:Xi,title:_().min(1,"Title is required")}),$v="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",us="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Ov(e){const[t,n,s]=e.split("-");return!t||!n||!s?e:`${n}/${s}/${t}`}function Lv(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function zv({entity:e,paymentDraft:t}){const n=Ae(),s=Ce(),a=yt(),i=Un(s.state,Qe()),[o,l]=v.useState(null),[c,u]=v.useState(!1),d=v.useMemo(()=>Lv(),[]),m=Jr(t.taxAmount),{register:h,handleSubmit:f,watch:x,formState:{errors:p}}=Rt({resolver:Ot(Rv),defaultValues:d}),N=x("agreementDate"),g=x("signature"),k=!!(g!=null&&g.trim()),j=h("signature"),S=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 L=await f0(t.statePaymentDetailId,Cv(t));return await S(),L}const I=await h0(kv(e.entityId,t));return Ja({...t,statePaymentDetailId:I.statePaymentDetailId}),await S(),I},T=async()=>{e&&(await E(),Ou(),n(Qe()))},A=f(async()=>{if(e){l(null),u(!0);try{await T()}catch(I){l(st(I,"Failed to save state payment."))}finally{u(!1)}}}),R=f(async()=>{if(e){l(null),u(!0);try{await T()}catch(I){l(st(I,"Failed to save draft."))}finally{u(!1)}}});return r.jsx("form",{onSubmit:A,noValidate:!0,className:"w-full",children:r.jsxs("div",{className:"relative w-full",children:[r.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),r.jsx(Gr,{entity:e,remittanceAmount:m,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),r.jsxs("div",{className:"lg:mr-[324px]",children:[r.jsxs("section",{className:$v,children:[r.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-slate-200 pb-5",children:[r.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Authorization Agreement"}),r.jsxs("div",{className:`${us} min-w-[128px] py-2.5`,children:[r.jsx("p",{className:"text-[11px] font-medium text-slate-500",children:"Date"}),r.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-800",children:Ov(N)}),r.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),r.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:Tv}),r.jsxs("label",{className:"mt-5 flex cursor-pointer items-start gap-3",children:[r.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")}),r.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:Fv})]}),p.agreementAccepted?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.agreementAccepted.message}):null,r.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8",children:[r.jsxs("p",{className:"mb-4 text-sm font-medium text-gov-600",children:["Taxpayer's Signature",r.jsx("span",{className:"text-red-500",children:" *"})]}),r.jsxs("div",{className:"grid gap-5 md:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_minmax(0,1fr)] md:items-end",children:[r.jsxs("div",{children:[r.jsxs("div",{className:`${us} py-7`,children:[r.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")}),r.jsx("div",{className:"mx-auto mt-6 w-full max-w-[180px] border-t border-slate-400"}),r.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Name of Authorization Person"})]}),p.authorizationPersonName?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.authorizationPersonName.message}):null]}),r.jsxs("div",{children:[r.jsxs("div",{className:`${us} py-5`,children:[r.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${k?"min-h-[52px] text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:k?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,name:j.name,ref:j.ref,onBlur:j.onBlur,onChange:I=>{const L=Uu(I.target.value);I.target.value=L,j.onChange(I)}}),r.jsx("div",{className:"mx-auto mt-6 w-full max-w-[220px] border-t border-slate-400"}),r.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Signature of Tax Payer"})]}),p.signature?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.signature.message}):null]}),r.jsxs("div",{children:[r.jsxs("div",{className:`${us} py-7`,children:[r.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")}),r.jsx("div",{className:"mx-auto mt-6 w-full max-w-[140px] border-t border-slate-400"}),r.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Title"})]}),p.title?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.title.message}):null]})]})]})]}),o?r.jsx("div",{className:"mt-5",children:r.jsx(Gt,{message:o})}):null,r.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:()=>{Ja(t),n("/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"}),r.jsx("button",{type:"button",onClick:R,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"}),r.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 Zu(){const{selectedEntity:e}=ht(),t=Ce(),{paymentDraft:n}=t.state??{},s=n??Ga();return s?r.jsx(zv,{entity:e,paymentDraft:s}):r.jsx(Ve,{to:"/payments/state/new",replace:!0})}const eo="/portal/federal-payments/form-8655-authorizations";function Mv(e){return pe(eo,{method:"POST",body:e})}function qv(e){return pe(`${eo}/by-enrolment/${e}`)}function Bv(e,t){return pe(`${eo}/${e}`,{method:"PATCH",body:t})}async function Wu(e){try{return await qv(e)}catch(t){if(t instanceof yr&&t.status===404)return null;throw t}}const Xa=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function Vv(e){const t=e.trim();return Xa.includes(t)?t:"Other"}const Uv="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.",Zv="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 Wv(e){const[t,n,s]=e.split("-");return!t||!n||!s?e:`${n}/${s}/${t}`}function ei({label:e,required:t=!1,signature:n,title:s,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:x}=n;return r.jsxs("div",{children:[e?r.jsxs("p",{className:"mb-3 text-sm font-medium text-gov-600",children:[e,t?r.jsx("span",{className:"text-red-500",children:" *"}):null]}):null,r.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:[r.jsxs("div",{children:[r.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-6",children:[r.jsx("input",{ref:x,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 N=Uu(p.target.value);p.target.value=N,m(p)}}),r.jsx("div",{className:"mt-8 border-t border-slate-400"}),r.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:u})]}),c!=null&&c.signature?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.signature}):null]}),r.jsxs("div",{children:[r.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[r.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",...s}),r.jsx("div",{className:"mt-8 border-t border-slate-400"}),r.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Title"})]}),c!=null&&c.title?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),r.jsxs("div",{children:[r.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-center text-sm text-slate-700",children:Wv(o)}),r.jsx("input",{type:"hidden",...a})]}):r.jsx("input",{type:"date",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 focus:outline-none",...a}),r.jsx("div",{className:"mt-8 border-t border-slate-400"}),r.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Date"})]}),c!=null&&c.date?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function Hv(e){return e.replace(/\D/g,"")}function Hu(e,t){var n,s;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:Hv(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:((n=t.otherIdentificationNumber)==null?void 0:n.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((s=t.authorizationMonth)==null?void 0:s.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function Yv(e){const{enrollmentId:t,...n}=Hu(0,e);return n}function Kv(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:Vn(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:Ln(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const Qv=Xt({taxpayerName:_().min(1,"Taxpayer name is required"),tradeName:_().min(1,"Trade name is required"),ein:_().min(1,"EIN is required"),address:_().min(1,"Address is required"),city:_().min(1,"City is required"),state:_().min(1,"State is required"),zipCode:_().min(1,"ZIP code is required"),country:_().min(1,"Country is required"),isSeasonalEmployer:Qn(),otherIdentificationNumber:_().optional(),contactPerson:_().min(1,"Contact person is required"),daytimePhone:_().min(1,"Daytime telephone number is required"),faxNumber:_().default(""),authorizedTaxForm:_().min(1,"Select a tax form"),authorizationMonth:_().optional(),agreementAccepted:Qn().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:Xi,title:_().min(1,"Title is required"),signatureDate:_().min(1,"Date is required")}),ga="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function Jv(e,t){const n=new Date().toISOString().slice(0,10);return{taxpayerName:e?en(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.lastName)||(e==null?void 0:e.firstName)||"",ein:e?Vn(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?Ln(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:Vv(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:n}}function Gv({entity:e,paymentDraft:t,initialAuthorization:n=null,readonly:s=!1}){var ce,he,Q,ke,re,Se,ue,be,$,xe,ee,Ne,se,Me;const a=Ae(),i=Ce(),o=yt(),l=Un(i.state,Qe()),c=Jr(t.paymentAmount),[u,d]=v.useState(null),[m,h]=v.useState(!1),f=v.useMemo(()=>n?Kv(n):Jv(e,t),[e,n,t]),{register:x,handleSubmit:p,watch:N,setValue:g,reset:k,formState:{errors:j}}=Rt({resolver:Ot(Qv),defaultValues:f});v.useEffect(()=>{k(f)},[f,k]);const S=N("authorizedTaxForm"),E=N("signature"),T=N("signatureDate"),A=e?en(e):"Entity",R=!0,I=!0,L=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ie=async()=>{if(!e)return null;if(t.federalPaymentId){const Te=await Vi(t.federalPaymentId,Yi(t));return await L(),Te}const oe=await Bi(Hi(e.entityId,t));return Qi({...t,federalPaymentId:oe.federalPaymentId,enrollmentId:oe.enrollmentId}),await L(),oe},V=async(oe,Te)=>{var it;const Je=t.form8655AuthorizationId??((it=await Wu(oe))==null?void 0:it.form8655AuthorizationId),at=Te;return Je?Bv(Je,Yv(at)):Mv(Hu(oe,at))},K=async oe=>{if(!e)return;const Te=await ie();Te&&(await V(Te.enrollmentId,oe),await o.invalidateQueries({queryKey:["form-8655",Te.enrollmentId]}),Ji(),a(Qe()))},te=p(async oe=>{if(!(!e||s)){d(null),h(!0);try{await K(oe)}catch(Te){d(st(Te,"Failed to save federal payment draft."))}finally{h(!1)}}}),H=p(async oe=>{if(!(!e||s)){d(null),h(!0);try{await K(oe)}catch(Te){d(st(Te,"Failed to save draft."))}finally{h(!1)}}});return r.jsxs("form",{onSubmit:te,noValidate:!0,className:"w-full space-y-6",children:[r.jsxs("div",{className:"relative w-full",children:[r.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:A}),r.jsx(Gr,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),r.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:r.jsxs("fieldset",{disabled:s,className:"min-w-0 border-0 p-0",children:[r.jsxs("section",{children:[r.jsxs("div",{className:ga,children:[r.jsx(Y,{label:"1. a) Name of the Taxpayer",required:!0,error:(ce=j.taxpayerName)==null?void 0:ce.message,children:r.jsx("input",{placeholder:"Enter name",readOnly:R,className:G(!!j.taxpayerName,R),...x("taxpayerName")})}),r.jsx(Y,{label:"1. b) Trade Name, if any",required:!0,error:(he=j.tradeName)==null?void 0:he.message,children:r.jsx("input",{placeholder:"Enter name",readOnly:R,className:G(!!j.tradeName,R),...x("tradeName")})}),r.jsx(Y,{label:"2. Employer Identification Number (EIN)",required:!0,error:(Q=j.ein)==null?void 0:Q.message,children:r.jsx("input",{placeholder:"Enter number",readOnly:R,className:G(!!j.ein,R),...x("ein")})})]}),r.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[r.jsx("div",{className:"sm:col-span-2",children:r.jsx(Y,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(ke=j.address)==null?void 0:ke.message,children:r.jsx("input",{placeholder:"Enter",readOnly:R,className:G(!!j.address,R),...x("address")})})}),r.jsx(Y,{label:"3. b) City or Town",required:!0,error:(re=j.city)==null?void 0:re.message,children:r.jsx("input",{placeholder:"Enter",readOnly:R,className:G(!!j.city,R),...x("city")})})]}),r.jsxs("div",{className:`mt-5 ${ga}`,children:[r.jsx(Y,{label:"3. c) State",required:!0,error:(Se=j.state)==null?void 0:Se.message,children:r.jsx("input",{placeholder:"Enter name",readOnly:R,className:G(!!j.state,R),...x("state")})}),r.jsx(Y,{label:"3. d) ZIP Code",required:!0,error:(ue=j.zipCode)==null?void 0:ue.message,children:r.jsx("input",{placeholder:"Enter",readOnly:R,className:G(!!j.zipCode,R),...x("zipCode")})}),r.jsx(Y,{label:"3. e) Country",required:!0,error:(be=j.country)==null?void 0:be.message,children:r.jsx("input",{placeholder:"Enter",readOnly:R,className:G(!!j.country,R),...x("country")})})]}),r.jsxs("div",{className:`mt-5 ${ga}`,children:[r.jsx("div",{className:"flex items-end pb-2",children:r.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...x("isSeasonalEmployer")}),r.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),r.jsx(Y,{label:"5. Other Identification Number (Optional)",children:r.jsx("input",{placeholder:"Enter name",readOnly:R,className:G(!1,R),...x("otherIdentificationNumber")})}),r.jsx(Y,{label:"6. Contact Person",required:!0,error:($=j.contactPerson)==null?void 0:$.message,children:r.jsx("input",{placeholder:"Enter name",readOnly:R,className:G(!!j.contactPerson,R),...x("contactPerson")})})]}),r.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[r.jsx(Y,{label:"7. Daytime Telephone Number",required:!0,error:(xe=j.daytimePhone)==null?void 0:xe.message,children:r.jsx("input",{placeholder:"Enter number",readOnly:R,className:G(!!j.daytimePhone,R),...x("daytimePhone")})}),r.jsx(Y,{label:"8. Fax Number",error:(ee=j.faxNumber)==null?void 0:ee.message,children:r.jsx("input",{placeholder:"Enter number",className:G(!!j.faxNumber),...x("faxNumber")})})]})]}),r.jsxs(wn,{title:"Authorization of Reporting Agent To Make and Deposits and Payments (Caution: See Authorization Agreement.)",children:[r.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)"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Xa.slice(0,6).map(oe=>r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:oe,checked:S===oe,disabled:I,onChange:()=>g("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))}),r.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Xa.slice(6).map(oe=>r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:oe,checked:S===oe,disabled:I,onChange:()=>g("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))})]}),j.authorizedTaxForm?r.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.authorizedTaxForm.message}):null]}),r.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[r.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),r.jsxs("div",{className:"border-t border-slate-200 pt-5",children:[r.jsxs("label",{className:"flex items-start gap-3",children:[r.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...x("agreementAccepted")}),r.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[r.jsx("span",{className:"font-semibold text-slate-900",children:Uv})," ",Zv]})]}),j.agreementAccepted?r.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.agreementAccepted.message}):null]})]}),r.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:r.jsx(ei,{label:"Taxpayer's Signature",required:!0,signature:x("signature"),title:x("title"),date:x("signatureDate"),signatureValue:E,dateValue:T,errors:{signature:(Ne=j.signature)==null?void 0:Ne.message,title:(se=j.title)==null?void 0:se.message,date:(Me=j.signatureDate)==null?void 0:Me.message}})})]})})]}),u?r.jsx("div",{className:"lg:mr-[324px]",children:r.jsx(Gt,{message:u})}):null,r.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[r.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"}),r.jsx("button",{type:"button",onClick:H,disabled:m||!e||s,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"}),r.jsx("button",{type:"submit",disabled:m||!e||s,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 Yu(){const{selectedEntity:e}=ht(),t=Ce(),{paymentDraft:n}=t.state??{},s=n??Xs(),{data:a,isLoading:i}=je({queryKey:["federal-payment",s==null?void 0:s.federalPaymentId],queryFn:()=>qi(s.federalPaymentId),enabled:(s==null?void 0:s.federalPaymentId)!=null&&s.enrollmentId==null}),o=(s==null?void 0:s.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=je({queryKey:["form-8655",o],queryFn:()=>Wu(o),enabled:o!=null}),u=v.useMemo(()=>s?{...s,enrollmentId:o??s.enrollmentId,form8655AuthorizationId:s.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[s,o,l]);return s?Wi(e)?r.jsx(Ve,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):s.federalPaymentId!=null&&s.enrollmentId==null&&i||o!=null&&c?r.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):r.jsx(Gv,{entity:e,paymentDraft:u??s,initialAuthorization:l}):r.jsx(Ve,{to:"/payments/federal/new",replace:!0})}const to="/portal/federal-payments/form-9783-enrollments";function Xv(e){return pe(to,{method:"POST",body:e})}function ej(e){return pe(`${to}/by-enrolment/${e}`)}function tj(e,t){return pe(`${to}/${e}`,{method:"PATCH",body:t})}async function Ku(e){try{return await ej(e)}catch(t){if(t instanceof yr&&t.status===404)return null;throw t}}const nj="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.",rj="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.",sj="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.",ya=new Date().getFullYear(),aj=[String(ya-1),String(ya-2),String(ya-3)];function ds(e){return e.replace(/\D/g,"")}function Qu(e,t){var n,s,a,i;return{enrollmentId:e,primarySsn:ds(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ds(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:((n=t.internationalAddress)==null?void 0:n.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:((s=t.contactInternationalAddress)==null?void 0:s.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:ds(t.financialPrimarySsn),routingTransitNumber:ds(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 ij(e){const{enrollmentId:t,...n}=Qu(0,e);return n}function oj(e){var n;const t=((n=e.accountType)==null?void 0:n.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:Ln(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Ln(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 lj=Xt({primarySsn:_().min(1,"Primary SSN is required"),jointFilerSsn:_().optional(),taxpayerNames:_().min(1,"Taxpayer name is required"),primaryAddress:_().min(1,"Primary address is required"),city:_().min(1,"City is required"),state:_().min(1,"State is required"),zipCode:_().min(1,"ZIP code is required"),country:_().min(1,"Country is required"),internationalAddress:_().optional(),primaryPhone:_().min(1,"Primary phone number is required"),primaryContactName:_().min(1,"Primary contact name is required"),primaryContactAddress:_().min(1,"Primary contact address is required"),contactCity:_().min(1,"Contact city is required"),contactState:_().min(1,"Contact state is required"),contactZipCode:_().min(1,"Contact ZIP code is required"),contactCountry:_().min(1,"Contact country is required"),contactPhone:_().min(1,"Contact phone number is required"),contactInternationalAddress:_().optional(),primaryTaxpayerPin:_().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:_().min(1,"Date of birth is required").refine(e=>D0(e,Ju),{message:"You must be at least 18 years old"}),priorYearAgi:_().min(1,"Prior year adjusted gross income is required").refine(e=>!Number.isNaN(Number(e))&&Number(e)>=0,{message:"Enter a valid amount"}),agiTaxYear:_().min(1,"Prior tax year is required"),financialPrimarySsn:_().min(1,"Primary SSN is required"),routingTransitNumber:_().min(1,"Routing transit number is required"),accountNumber:_().min(1,"Account number is required"),accountType:ru([oa("Checking"),oa("Savings"),oa("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Qn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Qn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Qn().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:Xi,taxpayerTitle:_().min(1,"Title is required"),taxpayerSignatureDate:_().min(1,"Date is required"),jointFilerSignature:Dv,jointFilerTitle:_().optional(),jointFilerSignatureDate:_().optional()}),vn="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",cj="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",uj=5,Ju=18;function Gu(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function Xu(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:Gu(t.accountType)}}function dj(e,t){const n=new Date().toISOString().slice(0,10),s=e?en(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:s,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?Ln(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...Xu(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:n,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:n}}function mj({entity:e,paymentDraft:t,initialEnrollment:n=null,readonly:s=!1}){var at,it,Lt,ft,vt,pt,jt,zt,At,Mt,Pt,Nt,Et,It,qt,z,de,b,C,y,D,O,Z,M,W;const a=Ae(),i=Ce(),o=yt(),l=Un(i.state,Qe()),c=Jr(t.paymentAmount),[u,d]=v.useState(null),[m,h]=v.useState(!1),[f,x]=v.useState(!1),{data:p=[]}=je({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Qr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:(e==null?void 0:e.entityId)!=null}),N=v.useMemo(()=>{if(n)return oj(n);const q=p.find(qe=>String(qe.bankAccountDetailId)===t.bankAccountDetailId),ae=Xu(e,t);return{...dj(e,t),financialPrimarySsn:ae.financialPrimarySsn,routingTransitNumber:ae.routingTransitNumber||(q==null?void 0:q.routingNumber)||"",accountNumber:ae.accountNumber||(q==null?void 0:q.accountNumber)||"",accountType:Gu(t.accountType||(q==null?void 0:q.accountType))}},[e,n,t,p]),{register:g,handleSubmit:k,watch:j,setValue:S,reset:E,control:T,formState:{errors:A}}=Rt({resolver:Ot(lj),defaultValues:N});v.useEffect(()=>{E(N)},[N,E]);const R=j("taxpayerSignature"),I=j("jointFilerSignature"),L=j("taxpayerSignatureDate"),ie=j("jointFilerSignatureDate"),V=j("accountType"),K=j("taxpayerNames"),te=j("primaryAddress"),H=j("city"),ce=j("state"),he=j("zipCode"),Q=j("country"),ke=j("primaryPhone"),re=j("internationalAddress"),Se=e?en(e):"Entity",ue=!0,be=!0,$=v.useMemo(()=>F0(Ju),[]),xe=()=>{S("primaryContactName",K,{shouldValidate:!0}),S("primaryContactAddress",te,{shouldValidate:!0}),S("contactCity",H,{shouldValidate:!0}),S("contactState",ce,{shouldValidate:!0}),S("contactZipCode",he,{shouldValidate:!0}),S("contactCountry",Q,{shouldValidate:!0}),S("contactPhone",ke,{shouldValidate:!0}),S("contactInternationalAddress",re??"",{shouldValidate:!0})},ee=()=>{S("primaryContactName","",{shouldValidate:!0}),S("primaryContactAddress","",{shouldValidate:!0}),S("contactCity","",{shouldValidate:!0}),S("contactState","",{shouldValidate:!0}),S("contactZipCode","",{shouldValidate:!0}),S("contactCountry","",{shouldValidate:!0}),S("contactPhone","",{shouldValidate:!0}),S("contactInternationalAddress","",{shouldValidate:!0})};v.useEffect(()=>{f&&xe()},[f,K,te,H,ce,he,Q,ke,re]);const Ne=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 ae=await Vi(t.federalPaymentId,Yi(t));return await Ne(),ae}const q=await Bi(Hi(e.entityId,t));return Qi({...t,federalPaymentId:q.federalPaymentId,enrollmentId:q.enrollmentId}),await Ne(),q},Me=async(q,ae)=>{var Bt;const qe=t.form9783EnrollmentId??((Bt=await Ku(q))==null?void 0:Bt.form9783EnrollmentId);return qe?tj(qe,ij(ae)):Xv(Qu(q,ae))},oe=async q=>{if(!e)return;const ae=await se();ae&&(await Me(ae.enrollmentId,q),await o.invalidateQueries({queryKey:["form-9783",ae.enrollmentId]}),Ji(),a(Qe()))},Te=k(async q=>{if(!(!e||s)){d(null),h(!0);try{await oe(q)}catch(ae){d(st(ae,"Failed to save federal payment draft."))}finally{h(!1)}}}),Je=k(async q=>{if(!(!e||s)){d(null),h(!0);try{await oe(q)}catch(ae){d(st(ae,"Failed to save draft."))}finally{h(!1)}}});return r.jsxs("form",{onSubmit:Te,noValidate:!0,className:"w-full space-y-6",children:[r.jsxs("div",{className:"relative w-full",children:[r.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:Se}),r.jsx(Gr,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),r.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:r.jsxs("fieldset",{disabled:s,className:"min-w-0 border-0 p-0",children:[r.jsxs(wn,{title:"1. Taxpayer Information",isFirst:!0,children:[r.jsxs("div",{className:vn,children:[r.jsx(Y,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(at=A.primarySsn)==null?void 0:at.message,children:r.jsx("input",{placeholder:"Enter number",readOnly:ue,className:G(!!A.primarySsn,ue),...g("primarySsn")})}),r.jsx(Y,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:r.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:ue,className:G(!1,ue),...g("jointFilerSsn")})}),r.jsx(Y,{label:"2. Taxpayer(S) name(S)",required:!0,error:(it=A.taxpayerNames)==null?void 0:it.message,children:r.jsx("input",{placeholder:"Enter name",readOnly:ue,className:G(!!A.taxpayerNames,ue),...g("taxpayerNames")})})]}),r.jsxs("div",{className:`mt-5 ${vn}`,children:[r.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:r.jsx(Y,{label:"3. a) Primary taxpayer address",required:!0,error:(Lt=A.primaryAddress)==null?void 0:Lt.message,children:r.jsx("input",{placeholder:"Enter",readOnly:ue,className:G(!!A.primaryAddress,ue),...g("primaryAddress")})})}),r.jsx(Y,{label:"3. b) City or Town",required:!0,error:(ft=A.city)==null?void 0:ft.message,children:r.jsx("input",{placeholder:"Enter",readOnly:ue,className:G(!!A.city,ue),...g("city")})})]}),r.jsxs("div",{className:`mt-5 ${vn}`,children:[r.jsx(Y,{label:"3. c) State",required:!0,error:(vt=A.state)==null?void 0:vt.message,children:r.jsx("input",{placeholder:"Enter name",readOnly:ue,className:G(!!A.state,ue),...g("state")})}),r.jsx(Y,{label:"3. d) ZIP code",required:!0,error:(pt=A.zipCode)==null?void 0:pt.message,children:r.jsx("input",{placeholder:"Enter",readOnly:ue,className:G(!!A.zipCode,ue),...g("zipCode")})}),r.jsx(Y,{label:"3. e) Country",required:!0,error:(jt=A.country)==null?void 0:jt.message,children:r.jsx("input",{placeholder:"Enter",readOnly:ue,className:G(!!A.country,ue),...g("country")})})]}),r.jsxs("div",{className:`mt-5 ${vn}`,children:[r.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:r.jsx(Y,{label:"3. f) International address",children:r.jsx("input",{placeholder:"phone number (International number)",readOnly:ue,className:G(!1,ue),...g("internationalAddress")})})}),r.jsx(Y,{label:"4. Primary taxpayer phone number",required:!0,error:(zt=A.primaryPhone)==null?void 0:zt.message,children:r.jsx("input",{placeholder:"Enter number",readOnly:ue,className:G(!!A.primaryPhone,ue),...g("primaryPhone")})})]})]}),r.jsxs(wn,{title:"2. Contact Information",headerAction:r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"checkbox",checked:f,disabled:s,onChange:q=>{const ae=q.target.checked;x(ae),ae?xe():ee()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[r.jsxs("div",{className:vn,children:[r.jsx(Y,{label:"5. Primary contact name",required:!0,error:(At=A.primaryContactName)==null?void 0:At.message,children:r.jsx("input",{placeholder:"Payer Name",readOnly:f,className:G(!!A.primaryContactName,f),...g("primaryContactName")})}),r.jsx(Y,{label:"6. a) Primary contact address",required:!0,error:(Mt=A.primaryContactAddress)==null?void 0:Mt.message,children:r.jsx("input",{placeholder:"Payer Address",readOnly:f,className:G(!!A.primaryContactAddress,f),...g("primaryContactAddress")})}),r.jsx(Y,{label:"6. b) City or Town",required:!0,error:(Pt=A.contactCity)==null?void 0:Pt.message,children:r.jsx("input",{placeholder:"City",readOnly:f,className:G(!!A.contactCity,f),...g("contactCity")})})]}),r.jsxs("div",{className:`mt-5 ${vn}`,children:[r.jsx(Y,{label:"6. c) State",required:!0,error:(Nt=A.contactState)==null?void 0:Nt.message,children:r.jsx("input",{placeholder:"Payer State",readOnly:f,className:G(!!A.contactState,f),...g("contactState")})}),r.jsx(Y,{label:"6. d) ZIP code",required:!0,error:(Et=A.contactZipCode)==null?void 0:Et.message,children:r.jsx("input",{placeholder:"ZIP code",readOnly:f,className:G(!!A.contactZipCode,f),...g("contactZipCode")})}),r.jsx(Y,{label:"6. f) Country",required:!0,error:(It=A.contactCountry)==null?void 0:It.message,children:r.jsx("input",{placeholder:"Country",readOnly:f,className:G(!!A.contactCountry,f),...g("contactCountry")})})]}),r.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[r.jsx(Y,{label:"7. Primary taxpayer phone number",required:!0,error:(qt=A.contactPhone)==null?void 0:qt.message,children:r.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:G(!!A.contactPhone,f),...g("contactPhone")})}),r.jsx("div",{className:"sm:col-span-2",children:r.jsx(Y,{label:"8. International address",children:r.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:G(!1,f),...g("contactInternationalAddress")})})})]})]}),r.jsx(wn,{title:"Taxpayer Details *",children:r.jsxs("div",{className:cj,children:[r.jsx(Y,{label:"1. Primary Taxpayer Pin",required:!0,error:(z=A.primaryTaxpayerPin)==null?void 0:z.message,children:r.jsx(Le,{name:"primaryTaxpayerPin",control:T,render:({field:q})=>r.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:G(!!A.primaryTaxpayerPin),value:q.value,onChange:ae=>q.onChange(Jn(ae.target.value,uj)),onBlur:q.onBlur})})}),r.jsx(Y,{label:"2. Date of Birth",required:!0,error:(de=A.dateOfBirth)==null?void 0:de.message,children:r.jsx("input",{type:"date",max:$,className:G(!!A.dateOfBirth),...g("dateOfBirth")})}),r.jsx(Y,{label:"3. Prior year adjusted gross income",required:!0,error:(b=A.priorYearAgi)==null?void 0:b.message,children:r.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:G(!!A.priorYearAgi),...g("priorYearAgi")})}),r.jsx(Y,{label:"4. Prior Tax Year",required:!0,error:(C=A.agiTaxYear)==null?void 0:C.message,children:r.jsxs("select",{className:Gn(!!A.agiTaxYear),...g("agiTaxYear"),children:[r.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),aj.map(q=>r.jsx("option",{value:q,children:q},q))]})})]})}),r.jsxs(wn,{title:"3. Social Security Number and Financial Institution Information",children:[r.jsxs("div",{className:vn,children:[r.jsx(Y,{label:"9. Primary SSN",required:!0,error:(y=A.financialPrimarySsn)==null?void 0:y.message,children:r.jsx("input",{placeholder:"Enter number",readOnly:be,className:G(!!A.financialPrimarySsn,be),...g("financialPrimarySsn")})}),r.jsx(Y,{label:"10. Routing Transit Number (RTN)",required:!0,error:(D=A.routingTransitNumber)==null?void 0:D.message,children:r.jsx("input",{placeholder:"Enter number",readOnly:be,className:G(!!A.routingTransitNumber,be),...g("routingTransitNumber")})}),r.jsx(Y,{label:"11. Account Number",required:!0,error:(O=A.accountNumber)==null?void 0:O.message,children:r.jsx("input",{placeholder:"Enter",readOnly:be,className:G(!!A.accountNumber,be),...g("accountNumber")})})]}),r.jsxs("div",{className:"mt-5",children:[r.jsx("p",{className:"mb-3 text-sm text-slate-600",children:"12. Type of Account"}),r.jsx("div",{className:"flex flex-wrap gap-6",children:["Checking","Savings"].map(q=>r.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[r.jsx("input",{type:"radio",value:q,checked:V===q,disabled:be,onChange:()=>S("accountType",q,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),q]},q))}),A.accountType?r.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.accountType.message}):null]})]}),r.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[r.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),r.jsx("p",{className:"mb-5 text-sm text-slate-600",children:"Read the following authorization agreements"}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),r.jsxs("label",{className:"flex items-start gap-3",children:[r.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...g("disclosureAgreementOne")}),r.jsx("span",{className:"text-sm leading-6 text-slate-700",children:nj})]}),A.disclosureAgreementOne?r.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.disclosureAgreementOne.message}):null]}),r.jsxs("div",{children:[r.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),r.jsxs("label",{className:"flex items-start gap-3",children:[r.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...g("disclosureAgreementTwo")}),r.jsx("span",{className:"text-sm leading-6 text-slate-700",children:rj})]}),A.disclosureAgreementTwo?r.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.disclosureAgreementTwo.message}):null]}),r.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[r.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Authority to Execute an Authorization"}),r.jsxs("label",{className:"flex items-start gap-3",children:[r.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...g("authorityAgreement")}),r.jsx("span",{className:"text-sm leading-6 text-slate-700",children:sj})]}),A.authorityAgreement?r.jsx("p",{className:"mt-2 text-xs text-red-600",children:A.authorityAgreement.message}):null]})]})]}),r.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[r.jsx(ei,{label:"Taxpayer's Signature",required:!0,signature:g("taxpayerSignature"),title:g("taxpayerTitle"),date:g("taxpayerSignatureDate"),signatureValue:R,dateValue:L,errors:{signature:(Z=A.taxpayerSignature)==null?void 0:Z.message,title:(M=A.taxpayerTitle)==null?void 0:M.message,date:(W=A.taxpayerSignatureDate)==null?void 0:W.message}}),r.jsx(ei,{label:"Joint filer(s) Signature (Optional)",signature:g("jointFilerSignature"),title:g("jointFilerTitle"),date:g("jointFilerSignatureDate"),signatureValue:I??"",dateValue:ie??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?r.jsx("div",{className:"lg:mr-[324px]",children:r.jsx(Gt,{message:u})}):null,r.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[r.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"}),r.jsx("button",{type:"button",onClick:Je,disabled:m||!e||s,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"}),r.jsx("button",{type:"submit",disabled:m||!e||s,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 ed(){const{selectedEntity:e}=ht(),t=Ce(),{paymentDraft:n}=t.state??{},s=n??Xs(),{data:a,isLoading:i}=je({queryKey:["federal-payment",s==null?void 0:s.federalPaymentId],queryFn:()=>qi(s.federalPaymentId),enabled:(s==null?void 0:s.federalPaymentId)!=null&&s.enrollmentId==null}),o=(s==null?void 0:s.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=je({queryKey:["form-9783",o],queryFn:()=>Ku(o),enabled:o!=null}),u=v.useMemo(()=>s?{...s,enrollmentId:o??s.enrollmentId,form9783EnrollmentId:s.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[s,o,l]);return s?e&&!Wi(e)?r.jsx(Ve,{to:"/payments/federal/authorization",replace:!0,state:t.state}):s.federalPaymentId!=null&&s.enrollmentId==null&&i||o!=null&&c?r.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):r.jsx(mj,{entity:e,paymentDraft:u??s,initialEnrollment:l}):r.jsx(Ve,{to:"/payments/federal/new",replace:!0})}function hj(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function fj({type:e}){return r.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 pj({status:e}){const t=e.toLowerCase();let n="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?n="bg-orange-50 text-orange-700":t.includes("irs accepted")?n="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?n="bg-red-50 text-red-600":t.includes("pending")&&(n="bg-amber-50 text-amber-700"),r.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n}`,children:e})}function xj({forms:e=[],isLoading:t=!1,isError:n=!1}){return r.jsx("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[r.jsx("th",{className:"px-6 py-3",children:"File Name"}),r.jsx("th",{className:"px-6 py-3",children:"Type"}),r.jsx("th",{className:"px-6 py-3",children:"Client"}),r.jsx("th",{className:"px-6 py-3",children:"Status"}),r.jsx("th",{className:"px-6 py-3",children:"Date"}),r.jsx("th",{className:"px-6 py-3",children:"Action"})]})}),r.jsx("tbody",{children:t?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Loading tax forms…"})}):n?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Unable to load tax forms."})}):e.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"No tax forms to display yet."})}):e.map(s=>r.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[r.jsx("td",{className:"px-6 py-4",children:r.jsxs("div",{className:"flex items-center gap-3 font-medium text-slate-900",children:[r.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gov-50 text-gov-600",children:r.jsx(gj,{className:"h-4 w-4"})}),s.fileName]})}),r.jsx("td",{className:"px-6 py-4",children:r.jsx(fj,{type:s.type})}),r.jsx("td",{className:"px-6 py-4 text-slate-700",children:s.client}),r.jsx("td",{className:"px-6 py-4",children:r.jsx(pj,{status:s.status})}),r.jsx("td",{className:"px-6 py-4 text-slate-600",children:hj(s.date)}),r.jsx("td",{className:"px-6 py-4",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.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"}),s.canSubmit?r.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]})})]},s.taxFormId))})]})})})}function gj({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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 yj(){return r.jsx(xj,{})}const vl=160,bj=88,ms=8;function vj({account:e,entityId:t,onEdit:n}){const s=yt(),{showSuccess:a,showError:i}=zs(),o=v.useRef(null),l=v.useRef(null),[c,u]=v.useState(!1),[d,m]=v.useState(!1),[h,f]=v.useState({}),x=()=>{var E;const N=o.current;if(!N)return;const g=N.getBoundingClientRect(),k=((E=l.current)==null?void 0:E.offsetHeight)??bj,S=window.innerHeight-g.bottom<k+ms;f({position:"fixed",top:S?g.top-k-ms:g.bottom+ms,left:Math.max(ms,g.right-vl),width:vl,zIndex:50})};v.useLayoutEffect(()=>{c&&(x(),requestAnimationFrame(x))},[c]),v.useEffect(()=>{if(!c)return;const N=k=>{var S,E;const j=k.target;(S=o.current)!=null&&S.contains(j)||(E=l.current)!=null&&E.contains(j)||u(!1)},g=()=>x();return document.addEventListener("mousedown",N),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[c]);const p=async()=>{const N=jr(e);m(!0);try{await xu(e.bankAccountDetailId,{status:uv(e)}),await s.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),N?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(g){i("Action Not Completed",st(g,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return r.jsxs("div",{className:"inline-block text-left",children:[r.jsxs("button",{ref:o,type:"button",disabled:d,onClick:()=>u(N=>!N),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",r.jsx(jj,{})]}),c?Vr.createPortal(r.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[r.jsx("button",{type:"button",onClick:()=>{u(!1),n(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"}),r.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:dv(e)})]}),document.body):null]})}function jj(){return r.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}const td=["Checking","Savings"],Nj=Xt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${hr} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Ks(td,{message:"Account type is required"}),bankName:_().min(1,"Bank name is required")});function wj({open:e,account:t,onClose:n}){const s=yt(),{showSuccess:a,showError:i}=zs(),[o,l]=v.useState(null),[c,u]=v.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=Rt({resolver:Ot(Nj),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});v.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),v.useEffect(()=>{if(!e)return;const p=N=>{N.key==="Escape"&&n()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,n]);const x=m(async p=>{if(t){l(null),u(!0);try{await xu(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await s.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),n()}catch(N){const g=st(N,"Unable to update bank account.");l(g),i("Action Not Completed",g)}finally{u(!1)}}});return!e||!t?null:Vr.createPortal(r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:n}),r.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:[r.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[r.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),r.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),r.jsxs("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),x(p)},className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?r.jsx("div",{className:"mb-5",children:r.jsx(Gt,{message:o})}):null,r.jsxs(gn,{title:"Bank Account",children:[r.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[r.jsx(Le,{name:"accountNumber",control:d,render:({field:p})=>{var N;return r.jsx(fe,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:g=>p.onChange(Jn(g.target.value,hr)),onBlur:p.onBlur,error:(N=f.accountNumber)==null?void 0:N.message})}}),r.jsx(Le,{name:"routingNumber",control:d,render:({field:p})=>{var N;return r.jsx(fe,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:g=>p.onChange(Jn(g.target.value,gu)),onBlur:p.onBlur,error:(N=f.routingNumber)==null?void 0:N.message})}}),r.jsx(Le,{name:"accountType",control:d,render:({field:p})=>{var N;return r.jsx(Kt,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(N=f.accountType)==null?void 0:N.message,children:td.map(g=>r.jsx("option",{value:g,children:g},g))})}})]}),r.jsx(Le,{name:"bankName",control:d,render:({field:p})=>{var N;return r.jsx(fe,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(N=f.bankName)==null?void 0:N.message})}})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[r.jsx("button",{type:"button",onClick:n,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"}),r.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 zn=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Sj},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:kj},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Cj},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Aj}];function Sj({className:e,...t}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:r.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 kj({className:e,...t}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:r.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 Cj({className:e,...t}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:r.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 Aj({className:e,...t}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:r.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 fr({title:e,subtitle:t,icon:n,action:s}){return r.jsxs("div",{className:"mb-6 flex flex-wrap items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:r.jsx(n,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),r.jsx("p",{className:"text-sm text-slate-500",children:t})]})]}),s]})}function Pj(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Ej({status:e}){const t=jr({status:e});return r.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 Ij({entityId:e}){const[t,n]=v.useState(!1),[s,a]=v.useState(null),[i,o]=v.useState(1),[l,c]=v.useState(tt),u=zn.find(k=>k.id==="bank-accounts"),d=u.icon;v.useEffect(()=>{o(1)},[e,l]);const{data:m,isLoading:h,isError:f,isFetching:x}=je({queryKey:["bank-accounts",e,i,l],queryFn:()=>Qr({entityId:e,pageNumber:i,pageSize:l}),enabled:e!==null,placeholderData:k=>k}),p=(m==null?void 0:m.items)??[],N=(m==null?void 0:m.totalCount)??0,g=e!==null&&x;return r.jsxs("div",{children:[r.jsx(fr,{title:u.title,subtitle:u.subtitle,icon:d,action:r.jsxs("button",{type:"button",disabled:!e,onClick:()=>n(!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:[r.jsx(_j,{}),"Add Bank Account"]})}),r.jsx(bu,{open:t,entityId:e,onClose:()=>n(!1)}),r.jsx(wj,{open:s!==null,account:s,onClose:()=>a(null)}),r.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[g?r.jsx(Zn,{label:"Loading bank accounts…"}):null,r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[700px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[r.jsx("th",{className:"px-5 py-3",children:"Bank"}),r.jsx("th",{className:"px-5 py-3",children:"Account"}),r.jsx("th",{className:"px-5 py-3",children:"Routing"}),r.jsx("th",{className:"px-5 py-3",children:"Type"}),r.jsx("th",{className:"px-5 py-3",children:"Status"}),r.jsx("th",{className:"px-5 py-3"})]})}),r.jsx("tbody",{children:h&&!m?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):f?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load bank accounts."})}):e?p.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No bank accounts connected yet."})}):p.map(k=>r.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[r.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:k.bankName}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:Pj(k.accountNumber)}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:k.routingNumber}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:k.accountType}),r.jsx("td",{className:"px-5 py-4",children:r.jsx(Ej,{status:k.status})}),r.jsx("td",{className:"px-5 py-4 text-right",children:r.jsx(vj,{account:k,entityId:e,onEdit:a})})]},k.bankAccountDetailId)):r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage bank accounts."})})})]})}),e!==null?r.jsx(vr,{page:i,pageSize:l,totalCount:N,onPageChange:o,onPageSizeChange:c,disabled:h||x}):null]})]})}function _j(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Tj({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?r.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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"?r.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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"})}):r.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:r.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 Pr({label:e,value:t,icon:n}){return r.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:r.jsx(Tj,{icon:n})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-xs text-slate-500",children:e}),r.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function Fj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function Dj({entity:e}){const[t,n]=v.useState(!1),s=zn.find(c=>c.id==="entity-details"),a=s.icon;if(!e)return r.jsxs("div",{children:[r.jsx(fr,{title:s.title,subtitle:s.subtitle,icon:a}),r.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:r.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=en(e),o=e.accountType==="Business"?i:`${e.firstName} ${e.lastName}`.trim()||i,l=Ri(o);return r.jsxs("div",{children:[r.jsx(fr,{title:s.title,subtitle:s.subtitle,icon:a,action:r.jsx("button",{type:"button",onClick:()=>n(!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"})}),r.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[r.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}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),r.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),r.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[r.jsx(Pr,{label:"Entity Name",value:i,icon:"entity"}),r.jsx(Pr,{label:"Tax ID",value:Vn(e.idNumber),icon:"tax"}),r.jsx(Pr,{label:"Email Address",value:e.email,icon:"email"}),r.jsx(Pr,{label:"Phone Number",value:Ln(e.phoneNumber),icon:"phone"}),r.jsx(Pr,{label:"Account Type",value:Fj(e.accountType),icon:"account"})]}),r.jsx(hu,{open:t,entity:e,onClose:()=>n(!1)})]})}function nd({activeSection:e,onSectionChange:t,items:n}){return r.jsx("nav",{className:"space-y-2",children:n.map(s=>{const a=e===s.id,i=s.icon;return r.jsxs("button",{type:"button",onClick:()=>t(s.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:[r.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:r.jsx(i,{className:"h-5 w-5"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:`block text-sm font-semibold ${a?"text-slate-900":"text-slate-700"}`,children:s.title}),r.jsx("span",{className:"block truncate text-xs text-slate-500",children:s.subtitle})]}),r.jsx(Rj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},s.id)})})}function Rj({className:e}){return r.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function $j({pageNumber:e=1,pageSize:t=tt}={}){const n=new URLSearchParams({pageNumber:String(e),pageSize:String(t)});return pe(`/portal/payments/transactions?${n}`)}function Oj(e){const t=e.cardBrand?e.cardBrand.charAt(0).toUpperCase()+e.cardBrand.slice(1):null,n=t&&e.cardLast4?`${t} •••• ${e.cardLast4}`:e.cardholderName??"—";return{paymentHistoryId:e.govPayTransactionId,entityId:0,date:e.createdAt,amount:e.amount,jurisdiction:e.paymentType==="federal"?"Federal":"State",type:e.paymentType==="federal"?"Federal":"State",accountName:n,reference:e.stripePaymentIntentId}}function Lj(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function zj(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Mj({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 r.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]}`,children:e})}function qj({entityId:e}){const t=zn.find(p=>p.id==="payment-history"),n=t.icon,[s,a]=v.useState(1),[i,o]=v.useState(tt);v.useEffect(()=>{a(1)},[e,i]);const{data:l,isLoading:c,isError:u,isFetching:d}=je({queryKey:["payment-transactions",s,i],queryFn:()=>$j({pageNumber:s,pageSize:i}),enabled:e!==null,placeholderData:p=>p}),m=((l==null?void 0:l.items)??[]).map(Oj),h=(l==null?void 0:l.totalCount)??0,f=e!==null&&h>0,x=e!==null&&d;return r.jsxs("div",{children:[r.jsx(fr,{title:t.title,subtitle:t.subtitle,icon:n,action:r.jsxs("button",{type:"button",disabled:!f,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:[r.jsx(Bj,{}),"Export to Excel"]})}),r.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[x?r.jsx(Zn,{label:"Loading payment history…"}):null,r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[r.jsx("th",{className:"px-5 py-3",children:"Date"}),r.jsx("th",{className:"px-5 py-3",children:"Amount"}),r.jsx("th",{className:"px-5 py-3",children:"Jurisdiction / Type"}),r.jsx("th",{className:"px-5 py-3",children:"Type"}),r.jsx("th",{className:"px-5 py-3",children:"Account Name"}),r.jsx("th",{className:"px-5 py-3",children:"Reference"})]})}),r.jsx("tbody",{children:c&&!l?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):u?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load payment history."})}):e?m.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No payment transactions to display yet."})}):m.map(p=>r.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[r.jsx("td",{className:"px-5 py-4 text-slate-600",children:zj(p.date)}),r.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:Lj(p.amount)}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.jurisdiction}),r.jsx("td",{className:"px-5 py-4",children:r.jsx(Mj,{type:p.type})}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.accountName}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:p.reference})]},p.paymentHistoryId)):r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to view payment history."})})})]})}),e!==null?r.jsx(vr,{page:s,pageSize:i,totalCount:h,onPageChange:a,onPageSizeChange:o,disabled:c||d}):null]})]})}function Bj(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.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 Vj({count:e}){const t=e===1?"1 Payment":`${e} Payments`;return r.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 Uj({status:e}){const n=(e??"Active").toLowerCase()==="active";return r.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:n?"Active":"In-active"})}function Zj(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function Wj({entityId:e,accounts:t=[],isLoading:n=!1,isError:s=!1}){const a=Ae(),i=zn.find(f=>f.id==="tax-accounts"),o=i.icon,[l,c]=v.useState(1),[u,d]=v.useState(tt);v.useEffect(()=>{c(1)},[e,u,t.length]);const m=t.length,h=v.useMemo(()=>{const f=(l-1)*u;return t.slice(f,f+u)},[t,l,u]);return r.jsxs("div",{children:[r.jsx(fr,{title:i.title,subtitle:i.subtitle,icon:o,action:r.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:[r.jsx(Hj,{}),"Add Tax Account"]})}),r.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[r.jsx("th",{className:"px-5 py-3",children:"Account Name"}),r.jsx("th",{className:"px-5 py-3",children:"Federal/State ID"}),r.jsx("th",{className:"px-5 py-3",children:"Payments"}),r.jsx("th",{className:"px-5 py-3",children:"Form Type"}),r.jsx("th",{className:"px-5 py-3",children:"Status"})]})}),r.jsx("tbody",{children:n?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):s?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load tax accounts."})}):e?m===0?r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"No tax accounts connected yet."})}):h.map(f=>r.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[r.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:f.accountName}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.federalStateId}),r.jsx("td",{className:"px-5 py-4",children:r.jsx(Vj,{count:f.paymentCount})}),r.jsx("td",{className:"px-5 py-4 text-slate-600",children:Zj(f.formTypes)}),r.jsx("td",{className:"px-5 py-4",children:r.jsx(Uj,{status:f.status})})]},f.taxAccountId)):r.jsx("tr",{children:r.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage tax accounts."})})})]})}),e!==null?r.jsx(vr,{page:l,pageSize:u,totalCount:m,onPageChange:c,onPageSizeChange:d,disabled:n}):null]})]})}function Hj(){return r.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const jl="rounded-2xl border border-slate-200 bg-white shadow-sm";function Yj(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function no(){const{selectedEntity:e}=ht(),n=Ce().state,[s,a]=v.useState(Yj(n==null?void 0:n.section)?n.section:"bank-accounts");return r.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[r.jsx("div",{className:`${jl} p-3`,children:r.jsx(nd,{items:zn,activeSection:s,onSectionChange:a})}),r.jsx("div",{className:`${jl} p-6 lg:p-8`,children:s==="bank-accounts"?r.jsx(Ij,{entityId:(e==null?void 0:e.entityId)??null}):s==="tax-accounts"?r.jsx(Wj,{entityId:(e==null?void 0:e.entityId)??null}):s==="payment-history"?r.jsx(qj,{entityId:(e==null?void 0:e.entityId)??null}):r.jsx(Dj,{entity:e})})]})}function Kj({label:e,value:t,onChange:n,options:s,required:a=!1,disabled:i=!1,error:o,placeholder:l="Select a state"}){var k;const[c,u]=v.useState(!1),[d,m]=v.useState(""),h=v.useRef(null),f=v.useRef(null),x=v.useId(),p=(k=s.find(j=>j.code===t))==null?void 0:k.name,N=v.useMemo(()=>{const j=d.trim().toLowerCase();return j?s.filter(S=>S.name.toLowerCase().includes(j)||S.code.toLowerCase().includes(j)):s},[d,s]);v.useEffect(()=>{var j;c&&((j=f.current)==null||j.focus())},[c]),v.useEffect(()=>{if(!c)return;const j=S=>{var E;(E=h.current)!=null&&E.contains(S.target)||u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const g=j=>{n(j),m(""),u(!1)};return r.jsxs("div",{ref:h,className:"relative",children:[r.jsx(On,{label:e,required:a,htmlFor:x}),r.jsxs("button",{id:x,type:"button",disabled:i,onClick:()=>{m(""),u(j=>!j)},className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${o?"border-red-300":"border-slate-200 focus:border-gov-400"}`,children:[r.jsx("span",{className:p?"text-slate-900":"text-slate-400",children:p??l}),r.jsx(Qj,{open:c})]}),c?r.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:[r.jsx("div",{className:"border-b border-slate-100 p-2",children:r.jsx("input",{ref:f,type:"search",value:d,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Escape"?u(!1):j.key==="Enter"&&j.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[N.map(j=>r.jsxs("button",{type:"button",onClick:()=>g(j.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${t===j.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[r.jsx("span",{children:j.name}),r.jsx("span",{className:"text-xs font-medium text-slate-400",children:j.code})]},j.code)),N.length===0?r.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,o?r.jsx("p",{className:"mt-1 text-xs text-red-600",children:o}):null]})}function Qj({open:e}){return r.jsx("svg",{className:`h-4 w-4 shrink-0 text-slate-400 transition ${e?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const Jj=["Alexandria","Arlington","Chesapeake","Hampton","Lynchburg","Newport News","Norfolk","Richmond","Roanoke","Virginia Beach"],Gj=$i.map(e=>({code:e,name:ab[e]??e})),Xj=[{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}],eN=[{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1}],tN=Xt({state:_().min(1,"State is required"),city:_().min(1,"City is required"),zipCode:_().min(1,"ZIP code is required"),address1:_().min(1,"Address Line 1 is required"),address2:_().optional(),virginiaTaxAccountId:_().optional(),virginiaWithholdingAccountingId:_().optional(),unemploymentTaxAccountId:_().optional(),virginiaDepartmentOfTaxationClientNumber:_().optional(),businessLocationCode:_().optional(),franchiseTaxAccount:_().optional(),transientOccupancyTaxAccountId:_().optional(),certificateOfAuthorityNumber:_().optional(),licensedProfessionalEmployerEntityNumber:_().optional()}),nN=tN.superRefine((e,t)=>{if(e.state!=="VA")return;const n=[{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 s of n){const a=e[s.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:rn.custom,message:`${s.label} is required`,path:[s.key]})}}),rN={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function sN({onCancel:e,onSuccess:t}){var g,k,j,S,E,T;const{showSuccess:n}=zs(),[s,a]=v.useState(null),[i,o]=v.useState(!1),{register:l,handleSubmit:c,watch:u,setValue:d,formState:{errors:m}}=Rt({resolver:Ot(nN),defaultValues:rN}),h=u("state"),f=u("city"),x=h==="VA",p=v.useMemo(()=>h==="VA"?[...Jj]:[],[h]);v.useEffect(()=>{if(p.length===0){f&&d("city","");return}f&&!p.includes(f)&&d("city","")},[p,f,d]);const N=c(async A=>{a(null),o(!0);try{await Promise.resolve(),n("Tax Account Ready","Tax account details captured. API save will be enabled soon."),t==null||t(A)}catch{a("Unable to save tax account. Please try again.")}finally{o(!1)}});return r.jsxs("form",{onSubmit:N,noValidate:!0,className:"space-y-8",children:[s?r.jsx(Gt,{message:s}):null,r.jsx(gn,{step:1,title:"TAX ACCOUNT DETAILS",children:r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[r.jsx(Kj,{label:"Select State",required:!0,value:h,onChange:A=>d("state",A,{shouldValidate:!0}),options:Gj,error:(g=m.state)==null?void 0:g.message}),p.length>0?r.jsxs(Kt,{label:"City",required:!0,error:(k=m.city)==null?void 0:k.message,...l("city"),children:[r.jsx("option",{value:"",children:"Select"}),p.map(A=>r.jsx("option",{value:A,children:A},A))]}):r.jsx(fe,{label:"City",required:!0,placeholder:"Enter",error:(j=m.city)==null?void 0:j.message,...l("city")})]}),r.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:r.jsx(fe,{label:"Zip Code",required:!0,placeholder:"Enter",error:(S=m.zipCode)==null?void 0:S.message,...l("zipCode")})}),r.jsx(fe,{label:"Address Line 1",required:!0,placeholder:"Enter",error:(E=m.address1)==null?void 0:E.message,...l("address1")}),r.jsx(fe,{label:"Address Line 2",placeholder:"Enter",error:(T=m.address2)==null?void 0:T.message,...l("address2")})]})}),x?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"border-t border-slate-200"}),r.jsxs(gn,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[r.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:Xj.map(A=>{var R;return r.jsx(fe,{label:A.label,required:A.required,placeholder:"Enter",error:(R=m[A.name])==null?void 0:R.message,...l(A.name)},A.name)})}),r.jsx("div",{className:"mt-5 space-y-5",children:eN.map(A=>{var R;return r.jsx(fe,{label:A.label,required:A.required,placeholder:"Enter",error:(R=m[A.name])==null?void 0:R.message,...l(A.name)},A.name)})})]})]}):null,r.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[r.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"}),r.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 ba="rounded-2xl border border-slate-200 bg-white shadow-sm";function ro(){const e=Ae(),{selectedEntity:t}=ht(),n=zn.find(i=>i.id==="tax-accounts"),s=n.icon,a=(i="tax-accounts")=>{e("/settings",{state:{section:i}})};return t?r.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[r.jsx("div",{className:`${ba} p-3`,children:r.jsx(nd,{items:zn,activeSection:"tax-accounts",onSectionChange:a})}),r.jsxs("div",{className:`${ba} p-6 lg:p-8`,children:[r.jsx(fr,{title:n.title,subtitle:n.subtitle,icon:s}),r.jsx(sN,{onCancel:()=>a("tax-accounts"),onSuccess:()=>a("tax-accounts")})]})]}):r.jsx("div",{className:ba+" p-6 lg:p-8",children:r.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function aN({paymentsMode:e="all"}){return r.jsxs(li,{children:[r.jsx(X,{index:!0,element:r.jsx(yi,{})}),r.jsx(X,{path:"create-entity",element:r.jsx(vi,{})}),r.jsx(X,{path:"create-entity/form",element:r.jsx(Oi,{})}),r.jsxs(X,{element:r.jsx(bi,{}),children:[r.jsx(X,{path:"entities",element:r.jsx(Mi,{})}),r.jsx(X,{path:"dashboard",element:r.jsx(zi,{})}),r.jsx(X,{path:"payments",element:r.jsx(Ui,{paymentsMode:e})}),r.jsx(X,{path:"payments/federal/new",element:r.jsx(Tu,{})}),r.jsx(X,{path:"payments/federal/:federalPaymentId/edit",element:r.jsx(Du,{})}),r.jsx(X,{path:"payments/federal/:federalPaymentId/view",element:r.jsx(Ru,{})}),r.jsx(X,{path:"payments/state/new",element:r.jsx(Mu,{})}),r.jsx(X,{path:"payments/state/:statePaymentDetailId/edit",element:r.jsx(qu,{})}),r.jsx(X,{path:"payments/state/:statePaymentDetailId/view",element:r.jsx(Bu,{})}),r.jsx(X,{path:"payments/state/authorization",element:r.jsx(Zu,{})}),r.jsx(X,{path:"payments/federal/authorization",element:r.jsx(Yu,{})}),r.jsx(X,{path:"payments/federal/individual-enrollment",element:r.jsx(ed,{})}),r.jsx(X,{path:"tax-forms",element:r.jsx(yj,{})}),r.jsx(X,{path:"settings",element:r.jsx(no,{})}),r.jsx(X,{path:"settings/tax-accounts/new",element:r.jsx(ro,{})})]}),r.jsx(X,{path:"*",element:r.jsx(Ve,{to:"/",replace:!0})})]})}const ti="tax-remittance:payment-complete",iN=v.forwardRef(function(t,n){const s=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=s.current)==null?void 0:o.call(s,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(ti,{detail:{paymentId:i}}))}})),r.jsx(gi,{...t,navigateFnRef:s,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:r.jsx(aN,{paymentsMode:"all"})})}),oN=v.forwardRef(function(t,n){const s=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=s.current)==null?void 0:o.call(s,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),r.jsx(gi,{...t,navigateFnRef:s,selectEntityFnRef:a,enabledPayments:["federal"],children:r.jsxs(li,{children:[r.jsx(X,{index:!0,element:r.jsx(yi,{})}),r.jsx(X,{path:"create-entity",element:r.jsx(vi,{})}),r.jsx(X,{path:"create-entity/form",element:r.jsx(Oi,{})}),r.jsxs(X,{element:r.jsx(bi,{}),children:[r.jsx(X,{path:"entities",element:r.jsx(Mi,{})}),r.jsx(X,{path:"dashboard",element:r.jsx(zi,{})}),r.jsx(X,{path:"payments",element:r.jsx(Ui,{paymentsMode:"federal"})}),r.jsx(X,{path:"payments/federal/new",element:r.jsx(Tu,{})}),r.jsx(X,{path:"payments/federal/:federalPaymentId/edit",element:r.jsx(Du,{})}),r.jsx(X,{path:"payments/federal/:federalPaymentId/view",element:r.jsx(Ru,{})}),r.jsx(X,{path:"payments/federal/authorization",element:r.jsx(Yu,{})}),r.jsx(X,{path:"payments/federal/individual-enrollment",element:r.jsx(ed,{})}),r.jsx(X,{path:"settings",element:r.jsx(no,{})}),r.jsx(X,{path:"settings/tax-accounts/new",element:r.jsx(ro,{})})]}),r.jsx(X,{path:"*",element:r.jsx(Ve,{to:"/",replace:!0})})]})})}),lN=v.forwardRef(function(t,n){const s=v.useRef(null),a=v.useRef(null);return v.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=s.current)==null?void 0:o.call(s,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),r.jsx(gi,{...t,navigateFnRef:s,selectEntityFnRef:a,enabledPayments:["state"],children:r.jsxs(li,{children:[r.jsx(X,{index:!0,element:r.jsx(yi,{})}),r.jsx(X,{path:"create-entity",element:r.jsx(vi,{})}),r.jsx(X,{path:"create-entity/form",element:r.jsx(Oi,{})}),r.jsxs(X,{element:r.jsx(bi,{}),children:[r.jsx(X,{path:"entities",element:r.jsx(Mi,{})}),r.jsx(X,{path:"dashboard",element:r.jsx(zi,{})}),r.jsx(X,{path:"payments",element:r.jsx(Ui,{paymentsMode:"state"})}),r.jsx(X,{path:"payments/state/new",element:r.jsx(Mu,{})}),r.jsx(X,{path:"payments/state/:statePaymentId/edit",element:r.jsx(qu,{})}),r.jsx(X,{path:"payments/state/:statePaymentId/view",element:r.jsx(Bu,{})}),r.jsx(X,{path:"payments/state/authorization",element:r.jsx(Zu,{})}),r.jsx(X,{path:"settings",element:r.jsx(no,{})}),r.jsx(X,{path:"settings/tax-accounts/new",element:r.jsx(ro,{})})]}),r.jsx(X,{path:"*",element:r.jsx(Ve,{to:"/",replace:!0})})]})})});exports.ApiError=yr;exports.FederalPaymentWidget=oN;exports.StatePaymentWidget=lN;exports.TaxRemittanceEmbedded=iN;exports.setRuntimeApiBaseUrl=hc;
76
76
  //# sourceMappingURL=index.cjs.map