@npm-zenwork/tax-remittance-ui 0.1.9 → 0.1.10

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 Qu=Object.defineProperty;var to=e=>{throw TypeError(e)};var Ju=(e,t,r)=>t in e?Qu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var vn=(e,t,r)=>Ju(e,typeof t!="symbol"?t+"":t,r),Ys=(e,t,r)=>t.has(e)||to("Cannot "+r);var v=(e,t,r)=>(Ys(e,t,"read from private field"),r?r.call(e):t.get(e)),K=(e,t,r)=>t.has(e)?to("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),V=(e,t,r,n)=>(Ys(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),re=(e,t,r)=>(Ys(e,t,"access private method"),r);var Yn=(e,t,r,n)=>({set _(a){V(e,t,a,r)},get _(){return v(e,t,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),N=require("react"),Cs=require("react-dom");function Gu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const P=Gu(N);/**
1
+ "use strict";var Gu=Object.defineProperty;var no=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 vn=(e,t,r)=>Xu(e,typeof t!="symbol"?t+"":t,r),Hs=(e,t,r)=>t.has(e)||no("Cannot "+r);var v=(e,t,r)=>(Hs(e,t,"read from private field"),r?r.call(e):t.get(e)),G=(e,t,r)=>t.has(e)?no("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),B=(e,t,r,s)=>(Hs(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),ne=(e,t,r)=>(Hs(e,t,"access private method"),r);var Hn=(e,t,r,s)=>({set _(a){B(e,t,a,r)},get _(){return v(e,t,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),N=require("react"),As=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 A=ed(N);/**
2
2
  * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
@@ -7,70 +7,70 @@
7
7
  * LICENSE.md file in the root directory of this source tree.
8
8
  *
9
9
  * @license MIT
10
- */var Qa=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Xu=/^[\\/]{2}/;function ed(e,t){return t+e.replace(/\\/g,"/")}function ro(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function td(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:n=!1}=e,a;a=t.map((f,b)=>d(f,typeof f=="string"?null:f.state,b===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,b=null,p,g){let y=nd(a?u().pathname:"/",f,b,p,g);return nt(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),y}function m(f){return typeof f=="string"?f:ds(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 b=typeof f=="string"?Or(f):f;return{pathname:b.pathname||"",search:b.search||"",hash:b.hash||""}},push(f,b){o="PUSH";let p=ro(f)?f:d(f,b);i+=1,a.splice(i,a.length,p),n&&l&&l({action:o,location:p,delta:1})},replace(f,b){o="REPLACE";let p=ro(f)?f:d(f,b);a[i]=p,n&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let b=c(i+f),p=a[b];i=b,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function je(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function nt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function rd(){return Math.random().toString(36).substring(2,10)}function nd(e,t,r=null,n,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Or(t):t,state:r,key:t&&t.key||n||rd(),mask:a}}function ds({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Or(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function Al(e,t,r="/"){return sd(e,t,r,!1)}function sd(e,t,r,n,a){let i=typeof t=="string"?Or(t):t,o=qt(i.pathname||"/",r);if(o==null)return null;let l=ad(e),c=null,u=xd(o);for(let d=0;c==null&&d<l.length;++d)c=pd(l[d],u,n);return c}function ad(e){let t=Pl(e);return id(t),t}function Pl(e,t=[],r=[],n="",a=!1){let i=(o,l,c=a,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(n)&&c)return;je(d.relativePath.startsWith(n),`Absolute route path "${d.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(n.length)}let m=gt([n,d.relativePath]),h=r.concat(d);o.children&&o.children.length>0&&(je(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Pl(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:hd(m,o.index),routesMeta:h.map((f,b)=>{let[p,g]=Tl(f.relativePath,f.caseSensitive,b===h.length-1);return{...f,matcher:p,compiledParams:g}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of El(o.path))i(o,l,!0,u)}),t}function El(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let o=El(n.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function id(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:fd(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var od=/^:[\w-]+$/,ld=3,cd=2,ud=1,dd=10,md=-2,no=e=>e==="*";function hd(e,t){let r=e.split("/"),n=r.length;return r.some(no)&&(n+=md),t&&(n+=cd),r.filter(a=>!no(a)).reduce((a,i)=>a+(od.test(i)?ld:i===""?ud:dd),n)}function fd(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function pd(e,t,r=!1){let{routesMeta:n}=e,a={},i="/",o=[];for(let l=0;l<n.length;++l){let c=n[l],u=l===n.length-1,d=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:u},h=c.matcher&&c.compiledParams?_l(m,d,c.matcher,c.compiledParams):ms(m,d),f=c.route;if(!h&&u&&r&&!n[n.length-1].route.index&&(h=ms({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:gt([i,h.pathname]),pathnameBase:bd(gt([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=gt([i,h.pathnameBase]))}return o}function ms(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=Tl(e.path,e.caseSensitive,e.end);return _l(e,t,r,n)}function _l(e,t,r,n){let a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce((u,{paramName:d,isOptional:m},h)=>{if(d==="*"){let b=l[h]||"";o=i.slice(0,i.length-b.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 Tl(e,t=!1,r=!0){nt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(n.push({paramName:l,isOptional:c!=null}),c){let m=d.charAt(u+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function xd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return nt(!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 qt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function gd(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Or(e):e,i;return r?(r=Il(r),r.startsWith("/")?i=so(r.substring(1),"/"):i=so(r,t)):i=t,{pathname:i,search:vd(n),hash:jd(a)}}function so(e,t){let r=hs(t).split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Hs(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function yd(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Ja(e){let t=yd(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function As(e,t,r,n=!1){let a;typeof e=="string"?a=Or(e):(a={...e},je(!a.pathname||!a.pathname.includes("?"),Hs("?","pathname","search",a)),je(!a.pathname||!a.pathname.includes("#"),Hs("#","pathname","hash",a)),je(!a.search||!a.search.includes("#"),Hs("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let m=t.length-1;if(!n&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=gd(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Il=e=>e.replace(/[\\/]{2,}/g,"/"),gt=e=>Il(e.join("/")),hs=e=>e.replace(/\/+$/,""),bd=e=>hs(e).replace(/^\/*/,"/"),vd=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,jd=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Nd=class{constructor(e,t,r,n=!1){this.status=e,this.statusText=t||"",this.internal=n,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function wd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Sd(e){let t=e.map(r=>r.route.path).filter(Boolean);return gt(t)||"/"}var Fl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Dl(e,t){let r=e;if(typeof r!="string"||!Qa.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let n=r,a=!1;if(Fl)try{let i=new URL(window.location.href),o=Xu.test(r)?new URL(ed(r,i.protocol)):new URL(r),l=qt(o.pathname,t);o.origin===i.origin&&l!=null?r=l+o.search+o.hash:a=!0}catch{nt(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:a,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Rl=["POST","PUT","PATCH","DELETE"];new Set(Rl);var kd=["GET",...Rl];new Set(kd);var Cd=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Ad(e){try{return Cd.includes(new URL(e).protocol)}catch{return!1}}var hn=P.createContext(null);hn.displayName="DataRouter";var Ps=P.createContext(null);Ps.displayName="DataRouterState";var Ol=P.createContext(!1);function Pd(){return P.useContext(Ol)}var $l=P.createContext({isTransitioning:!1});$l.displayName="ViewTransition";var Ed=P.createContext(new Map);Ed.displayName="Fetchers";var _d=P.createContext(null);_d.displayName="Await";var at=P.createContext(null);at.displayName="Navigation";var zn=P.createContext(null);zn.displayName="Location";var lt=P.createContext({outlet:null,matches:[],isDataRoute:!1});lt.displayName="Route";var Ga=P.createContext(null);Ga.displayName="RouteError";var Ll="REACT_ROUTER_ERROR",Td="REDIRECT",Id="ROUTE_ERROR_RESPONSE";function Fd(e){if(e.startsWith(`${Ll}:${Td}:{`))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 Dd(e){if(e.startsWith(`${Ll}:${Id}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Nd(t.status,t.statusText,t.data)}catch{}}function Rd(e,{relative:t}={}){je(fn(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:n}=P.useContext(at),{hash:a,pathname:i,search:o}=Mn(e,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:gt([r,i])),n.createHref({pathname:l,search:o,hash:a})}function fn(){return P.useContext(zn)!=null}function ge(){return je(fn(),"useLocation() may be used only in the context of a <Router> component."),P.useContext(zn).location}var zl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ml(e){P.useContext(at).static||P.useLayoutEffect(e)}function ye(){let{isDataRoute:e}=P.useContext(lt);return e?Kd():Od()}function Od(){je(fn(),"useNavigate() may be used only in the context of a <Router> component.");let e=P.useContext(hn),{basename:t,navigator:r}=P.useContext(at),{matches:n}=P.useContext(lt),{pathname:a}=ge(),i=JSON.stringify(Ja(n)),o=P.useRef(!1);return Ml(()=>{o.current=!0}),P.useCallback((c,u={})=>{if(nt(o.current,zl),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=As(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:gt([t,d.pathname])),(u.replace?r.replace:r.push)(d,u.state,u)},[t,r,i,a,e])}var ql=P.createContext(null);function it(){return P.useContext(ql)}function $d(e){let t=P.useContext(lt).outlet;return P.useMemo(()=>t&&P.createElement(ql.Provider,{value:e},t),[t,e])}function Xa(){let{matches:e}=P.useContext(lt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Mn(e,{relative:t}={}){let{matches:r}=P.useContext(lt),{pathname:n}=ge(),a=JSON.stringify(Ja(r));return P.useMemo(()=>As(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function Ld(e,t){return Vl(e,t)}function Vl(e,t,r){var g;je(fn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:n}=P.useContext(at),{matches:a}=P.useContext(lt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let y=u&&u.path||"";Ul(l,!u||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${y}">) 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 Ga=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,td=/^[\\/]{2}/;function rd(e,t){return t+e.replace(/\\/g,"/")}function so(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,b)=>d(f,typeof f=="string"?null:f.state,b===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,b=null,p,x){let y=ad(a?u().pathname:"/",f,b,p,x);return st(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),y}function m(f){return typeof f=="string"?f:ms(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 b=typeof f=="string"?Or(f):f;return{pathname:b.pathname||"",search:b.search||"",hash:b.hash||""}},push(f,b){o="PUSH";let p=so(f)?f:d(f,b);i+=1,a.splice(i,a.length,p),s&&l&&l({action:o,location:p,delta:1})},replace(f,b){o="REPLACE";let p=so(f)?f:d(f,b);a[i]=p,s&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let b=c(i+f),p=a[b];i=b,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function je(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function st(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"?Or(t):t,state:r,key:t&&t.key||s||sd(),mask:a}}function ms({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Or(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function El(e,t,r="/"){return id(e,t,r,!1)}function id(e,t,r,s,a){let i=typeof t=="string"?Or(t):t,o=qt(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=_l(e);return ld(t),t}function _l(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;je(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=gt([s,d.relativePath]),h=r.concat(d);o.children&&o.children.length>0&&(je(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),_l(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:pd(m,o.index),routesMeta:h.map((f,b)=>{let[p,x]=Fl(f.relativePath,f.caseSensitive,b===h.length-1);return{...f,matcher:p,compiledParams:x}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of 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,ao=e=>e==="*";function pd(e,t){let r=e.split("/"),s=r.length;return r.some(ao)&&(s+=fd),t&&(s+=dd),r.filter(a=>!ao(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?Il(m,d,c.matcher,c.compiledParams):hs(m,d),f=c.route;if(!h&&u&&r&&!s[s.length-1].route.index&&(h=hs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:gt([i,h.pathname]),pathnameBase:jd(gt([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=gt([i,h.pathnameBase]))}return o}function hs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,s]=Fl(e.path,e.caseSensitive,e.end);return Il(e,t,r,s)}function Il(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 b=l[h]||"";o=i.slice(0,i.length-b.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 Fl(e,t=!1,r=!0){st(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 st(!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 qt(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"?Or(e):e,i;return r?(r=Dl(r),r.startsWith("/")?i=io(r.substring(1),"/"):i=io(r,t)):i=t,{pathname:i,search:Nd(s),hash:wd(a)}}function io(e,t){let r=fs(t).split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Ks(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 Xa(e){let t=vd(e);return t.map((r,s)=>s===t.length-1?r.pathname:r.pathnameBase)}function Ps(e,t,r,s=!1){let a;typeof e=="string"?a=Or(e):(a={...e},je(!a.pathname||!a.pathname.includes("?"),Ks("?","pathname","search",a)),je(!a.pathname||!a.pathname.includes("#"),Ks("#","pathname","hash",a)),je(!a.search||!a.search.includes("#"),Ks("#","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 Dl=e=>e.replace(/[\\/]{2,}/g,"/"),gt=e=>Dl(e.join("/")),fs=e=>e.replace(/\/+$/,""),jd=e=>fs(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 gt(t)||"/"}var Rl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ol(e,t){let r=e;if(typeof r!="string"||!Ga.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let s=r,a=!1;if(Rl)try{let i=new URL(window.location.href),o=td.test(r)?new URL(rd(r,i.protocol)):new URL(r),l=qt(o.pathname,t);o.origin===i.origin&&l!=null?r=l+o.search+o.hash:a=!0}catch{st(!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 $l=["POST","PUT","PATCH","DELETE"];new Set($l);var Ad=["GET",...$l];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 hn=A.createContext(null);hn.displayName="DataRouter";var Es=A.createContext(null);Es.displayName="DataRouterState";var Ll=A.createContext(!1);function _d(){return A.useContext(Ll)}var zl=A.createContext({isTransitioning:!1});zl.displayName="ViewTransition";var Td=A.createContext(new Map);Td.displayName="Fetchers";var Id=A.createContext(null);Id.displayName="Await";var at=A.createContext(null);at.displayName="Navigation";var zn=A.createContext(null);zn.displayName="Location";var lt=A.createContext({outlet:null,matches:[],isDataRoute:!1});lt.displayName="Route";var ei=A.createContext(null);ei.displayName="RouteError";var Ml="REACT_ROUTER_ERROR",Fd="REDIRECT",Dd="ROUTE_ERROR_RESPONSE";function Rd(e){if(e.startsWith(`${Ml}:${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(`${Ml}:${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}={}){je(fn(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:s}=A.useContext(at),{hash:a,pathname:i,search:o}=Mn(e,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:gt([r,i])),s.createHref({pathname:l,search:o,hash:a})}function fn(){return A.useContext(zn)!=null}function ge(){return je(fn(),"useLocation() may be used only in the context of a <Router> component."),A.useContext(zn).location}var ql="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Vl(e){A.useContext(at).static||A.useLayoutEffect(e)}function ye(){let{isDataRoute:e}=A.useContext(lt);return e?Jd():Ld()}function Ld(){je(fn(),"useNavigate() may be used only in the context of a <Router> component.");let e=A.useContext(hn),{basename:t,navigator:r}=A.useContext(at),{matches:s}=A.useContext(lt),{pathname:a}=ge(),i=JSON.stringify(Xa(s)),o=A.useRef(!1);return Vl(()=>{o.current=!0}),A.useCallback((c,u={})=>{if(st(o.current,ql),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=Ps(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:gt([t,d.pathname])),(u.replace?r.replace:r.push)(d,u.state,u)},[t,r,i,a,e])}var Bl=A.createContext(null);function it(){return A.useContext(Bl)}function zd(e){let t=A.useContext(lt).outlet;return A.useMemo(()=>t&&A.createElement(Bl.Provider,{value:e},t),[t,e])}function ti(){let{matches:e}=A.useContext(lt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Mn(e,{relative:t}={}){let{matches:r}=A.useContext(lt),{pathname:s}=ge(),a=JSON.stringify(Xa(r));return A.useMemo(()=>Ps(e,JSON.parse(a),s,t==="path"),[e,a,s,t])}function Md(e,t){return Ul(e,t)}function Ul(e,t,r){var x;je(fn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=A.useContext(at),{matches:a}=A.useContext(lt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let y=u&&u.path||"";Wl(l,!u||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${y}">) 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="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let d=ge(),m;if(t){let y=typeof t=="string"?Or(t):t;je(c==="/"||((g=y.pathname)==null?void 0:g.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 "${y.pathname}" was given in the \`location\` prop.`),m=y}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let y=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(y.length).join("/")}let b=r&&r.state.matches.length?r.state.matches.map(y=>Object.assign(y,{route:r.manifest[y.route.id]||y.route})):Al(e,{pathname:f});nt(u||b!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),nt(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.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=Bd(b&&b.map(y=>Object.assign({},y,{params:Object.assign({},o,y.params),pathname:gt([c,n.encodeLocation?n.encodeLocation(y.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:gt([c,n.encodeLocation?n.encodeLocation(y.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),a,r);return t&&p?P.createElement(zn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function zd(){let e=Hd(),t=wd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=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 Md=P.createElement(zd,null),Bl=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=Dd(e.digest);r&&(e=r)}let t=e!==void 0?P.createElement(lt.Provider,{value:this.props.routeContext},P.createElement(Ga.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?P.createElement(qd,{error:e},t):t}};Bl.contextType=Ol;var Ks=new WeakMap;function qd({children:e,error:t}){let{basename:r}=P.useContext(at);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let n=Fd(t.digest);if(n){let a=Ks.get(t);if(a)throw a;let i=Dl(n.location,r),o=i.absoluteURL||i.to;if(Ad(o))throw new Error("Invalid redirect location");if(Fl&&!Ks.get(t))if(i.isExternal||n.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:n.replace}));throw Ks.set(t,l),l}return P.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Vd({routeContext:e,match:t,children:r}){let n=P.useContext(hn);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),P.createElement(lt.Provider,{value:e},r)}function Bd(e,t=[],r){let n=r==null?void 0:r.state;if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let d=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);je(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,l=-1;if(r&&n){o=n.renderFallback;for(let d=0;d<a.length;d++){let m=a[d];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=d),m.route.id){let{loaderData:h,errors:f}=n,b=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||b){r.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=r==null?void 0:r.onError,u=n&&c?(d,m)=>{var h,f;c(d,{location:n.location,params:((f=(h=n.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:Sd(n.matches),errorInfo:m})}:void 0;return a.reduceRight((d,m,h)=>{let f,b=!1,p=null,g=null;n&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Md,o&&(l<0&&h===0?(Ul("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,g=null):l===h&&(b=!0,g=m.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,h+1)),A=()=>{let j;return f?j=p:b?j=g:m.route.Component?j=P.createElement(m.route.Component,null):m.route.element?j=m.route.element:j=d,P.createElement(Vd,{match:m,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:j})};return n&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?P.createElement(Bl,{location:n.location,revalidation:n.revalidation,component:p,error:f,children:A(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):A()},null)}function ei(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ud(e){let t=P.useContext(hn);return je(t,ei(e)),t}function Zd(e){let t=P.useContext(Ps);return je(t,ei(e)),t}function Wd(e){let t=P.useContext(lt);return je(t,ei(e)),t}function ti(e){let t=Wd(e),r=t.matches[t.matches.length-1];return je(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Yd(){return ti("useRouteId")}function Hd(){var n;let e=P.useContext(Ga),t=Zd("useRouteError"),r=ti("useRouteError");return e!==void 0?e:(n=t.errors)==null?void 0:n[r]}function Kd(){let{router:e}=Ud("useNavigate"),t=ti("useNavigate"),r=P.useRef(!1);return Ml(()=>{r.current=!0}),P.useCallback(async(a,i={})=>{nt(r.current,zl),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var ao={};function Ul(e,t,r){!t&&!ao[e]&&(ao[e]=!0,nt(!1,r))}P.memo(Qd);function Qd({routes:e,manifest:t,future:r,state:n,isStatic:a,onError:i}){return Vl(e,void 0,{manifest:t,state:n,isStatic:a,onError:i})}function Jd({basename:e,children:t,initialEntries:r,initialIndex:n,useTransitions:a}){let i=P.useRef();i.current==null&&(i.current=td({initialEntries:r,initialIndex:n,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(Xd,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Oe({to:e,replace:t,state:r,relative:n}){je(fn(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=P.useContext(at);nt(!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(lt),{pathname:o}=ge(),l=ye(),c=As(e,Ja(i),o,n==="path"),u=JSON.stringify(c);return P.useEffect(()=>{l(JSON.parse(u),{replace:t,state:r,relative:n})},[l,u,n,t,r]),null}function Gd(e){return $d(e.context)}function G(e){je(!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 Xd({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:i=!1,useTransitions:o}){je(!fn(),"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=Or(r));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:b}=r,p=P.useMemo(()=>{let g=qt(u,l);return g==null?null:{location:{pathname:g,search:d,hash:m,state:h,key:f,mask:b},navigationType:n}},[l,u,d,m,h,f,n,b]);return nt(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(at.Provider,{value:c},P.createElement(zn.Provider,{children:t,value:p}))}function ri({children:e,location:t}){return Ld(ma(e),t)}function ma(e,t=[]){let r=[];return P.Children.forEach(e,(n,a)=>{if(!P.isValidElement(n))return;let i=[...t,a];if(n.type===P.Fragment){r.push.apply(r,ma(n.props.children,i));return}je(n.type===G,`[${typeof n.type=="string"?n.type:n.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),je(!n.props.index||!n.props.children,"An index route cannot have child routes.");let o={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,middleware:n.props.middleware,loader:n.props.loader,action:n.props.action,hydrateFallbackElement:n.props.hydrateFallbackElement,HydrateFallback:n.props.HydrateFallback,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.hasErrorBoundary===!0||n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=ma(n.props.children,i)),r.push(o)}),r}var os="get",ls="application/x-www-form-urlencoded";function Es(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function em(e){return Es(e)&&e.tagName.toLowerCase()==="button"}function tm(e){return Es(e)&&e.tagName.toLowerCase()==="form"}function rm(e){return Es(e)&&e.tagName.toLowerCase()==="input"}function nm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function sm(e,t){return e.button===0&&(!t||t==="_self")&&!nm(e)}function ha(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function am(e,t){let r=ha(e);return t&&t.forEach((n,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}var Hn=null;function im(){if(Hn===null)try{new FormData(document.createElement("form"),0),Hn=!1}catch{Hn=!0}return Hn}var om=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Qs(e){return e!=null&&!om.has(e)?(nt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ls}"`),null):e}function lm(e,t){let r,n,a,i,o;if(tm(e)){let l=e.getAttribute("action");n=l?qt(l,t):null,r=e.getAttribute("method")||os,a=Qs(e.getAttribute("enctype"))||ls,i=new FormData(e)}else if(em(e)||rm(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(n=c?qt(c,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||os,a=Qs(e.getAttribute("formenctype"))||Qs(l.getAttribute("enctype"))||ls,i=new FormData(l,e),!im()){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(Es(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=os,n=null,a=ls,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ni(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Zl(e,t,r,n){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${n}`:a.pathname=`${a.pathname}.${n}`:a.pathname==="/"?a.pathname=`_root.${n}`:t&&qt(a.pathname,t)==="/"?a.pathname=`${hs(t)}/_root.${n}`:a.pathname=`${hs(a.pathname)}.${n}`,a}async function cm(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 um(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 dm(e,t,r){let n=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await cm(i,r);return o.links?o.links():[]}return[]}));return pm(n.flat(1).filter(um).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function io(e,t,r,n,a,i){let o=(c,u)=>r[u]?c.route.id!==r[u].route.id:!0,l=(c,u)=>{var d;return r[u].pathname!==c.pathname||((d=r[u].route.path)==null?void 0:d.endsWith("*"))&&r[u].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,u)=>o(c,u)||l(c,u)):i==="data"?t.filter((c,u)=>{var m;let d=n.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=r[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function mm(e,t,{includeHydrateFallback:r}={}){return hm(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),r&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function hm(e){return[...new Set(e)]}function fm(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function pm(e,t){let r=new Set;return new Set(t),e.reduce((n,a)=>{let i=JSON.stringify(fm(a));return r.has(i)||(r.add(i),n.push({key:i,link:a})),n},[])}function si(){let e=P.useContext(hn);return ni(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function xm(){let e=P.useContext(Ps);return ni(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ai=P.createContext(void 0);ai.displayName="FrameworkContext";function _s(){let e=P.useContext(ai);return ni(e,"You must render this element inside a <HydratedRouter> element"),e}function gm(e,t){let r=P.useContext(ai),[n,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=y=>{y.forEach(A=>{o(A.isIntersecting)})},g=new IntersectionObserver(p,{threshold:.5});return h.current&&g.observe(h.current),()=>{g.disconnect()}}},[e]),P.useEffect(()=>{if(n){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[n]);let f=()=>{a(!0)},b=()=>{a(!1),o(!1)};return r?e!=="intent"?[i,h,{}]:[i,h,{onFocus:jn(l,f),onBlur:jn(c,b),onMouseEnter:jn(u,f),onMouseLeave:jn(d,b),onTouchStart:jn(m,f)}]:[!1,h,{}]}function jn(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function ym({page:e,...t}){let r=Pd(),{nonce:n}=_s(),{router:a}=si(),i=P.useMemo(()=>Al(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&n&&(t={...t,nonce:n}),r?P.createElement(vm,{page:e,matches:i,...t}):P.createElement(jm,{page:e,matches:i,...t})):null}function bm(e){let{manifest:t,routeModules:r}=_s(),[n,a]=P.useState([]);return P.useEffect(()=>{let i=!1;return dm(e,t,r).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,r]),n}function vm({page:e,matches:t,...r}){let n=ge(),{future:a}=_s(),{basename:i}=si(),o=P.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let l=Zl(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,u=[];for(let d of t)typeof d.route.shouldRevalidate=="function"?c=!0:u.push(d.route.id);return c&&u.length>0&&l.searchParams.set("_routes",u.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,n,t]);return P.createElement(P.Fragment,null,o.map(l=>P.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...r})))}function jm({page:e,matches:t,...r}){let n=ge(),{future:a,manifest:i,routeModules:o}=_s(),{basename:l}=si(),{loaderData:c,matches:u}=xm(),d=P.useMemo(()=>io(e,t,u,i,n,"data"),[e,t,u,i,n]),m=P.useMemo(()=>io(e,t,u,i,n,"assets"),[e,t,u,i,n]),h=P.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let p=new Set,g=!1;if(t.forEach(A=>{var S;let j=i.routes[A.route.id];!j||!j.hasLoader||(!d.some(E=>E.route.id===A.route.id)&&A.route.id in c&&((S=o[A.route.id])!=null&&S.shouldRevalidate)||j.hasClientLoader?g=!0:p.add(A.route.id))}),p.size===0)return[];let y=Zl(e,l,a.v8_trailingSlashAwareDataRequests,"data");return g&&p.size>0&&y.searchParams.set("_routes",t.filter(A=>p.has(A.route.id)).map(A=>A.route.id).join(",")),[y.pathname+y.search]},[l,a.v8_trailingSlashAwareDataRequests,c,n,i,d,t,e,o]),f=P.useMemo(()=>mm(m,i),[m,i]),b=bm(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})),b.map(({key:p,link:g})=>P.createElement("link",{key:p,nonce:r.nonce,...g,crossOrigin:g.crossOrigin??r.crossOrigin})))}function Nm(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var wm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{wm&&(window.__reactRouterVersion="7.18.1")}catch{}var Wl=P.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...b},p){let{basename:g,navigator:y,useTransitions:A}=P.useContext(at),j=typeof d=="string"&&Qa.test(d),S=Dl(d,g);d=S.to;let E=Rd(d,{relative:a}),I=ge(),w=null;if(l){let Y=As(l,[],I.mask?I.mask.pathname:"/",!0);g!=="/"&&(Y.pathname=Y.pathname==="/"?g:gt([g,Y.pathname])),w=y.createHref(Y)}let[F,D,$]=gm(n,b),se=Am(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:A});function B(Y){t&&t(Y),Y.defaultPrevented||se(Y)}let Q=!(S.isExternal||i),te=P.createElement("a",{...b,...$,href:(Q?w:void 0)||S.absoluteURL||E,onClick:Q?B:t,ref:Nm(p,D),target:u,"data-discover":!j&&r==="render"?"true":void 0});return F&&!j?P.createElement(P.Fragment,null,te,P.createElement(ym,{page:E})):te});Wl.displayName="Link";var Sm=P.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let m=Mn(o,{relative:u.relative}),h=ge(),f=P.useContext(Ps),{navigator:b,basename:p}=P.useContext(at),g=f!=null&&Fm(m)&&l===!0,y=b.encodeLocation?b.encodeLocation(m).pathname:m.pathname,A=h.pathname,j=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;r||(A=A.toLowerCase(),j=j?j.toLowerCase():null,y=y.toLowerCase()),j&&p&&(j=qt(j,p)||j);const S=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let E=A===y||!a&&A.startsWith(y)&&A.charAt(S)==="/",I=j!=null&&(j===y||!a&&j.startsWith(y)&&j.charAt(y.length)==="/"),w={isActive:E,isPending:I,isTransitioning:g},F=E?t:void 0,D;typeof n=="function"?D=n(w):D=[n,E?"active":null,I?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let $=typeof i=="function"?i(w):i;return P.createElement(Wl,{...u,"aria-current":F,className:D,ref:d,style:$,to:o,viewTransition:l},typeof c=="function"?c(w):c)});Sm.displayName="NavLink";var km=P.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:n,replace:a,state:i,method:o=os,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},b)=>{let{useTransitions:p}=P.useContext(at),g=Tm(),y=Im(l,{relative:u}),A=o.toLowerCase()==="get"?"get":"post",j=typeof l=="string"&&Qa.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let I=E.nativeEvent.submitter,w=(I==null?void 0:I.getAttribute("formmethod"))||o,F=()=>g(I||E.currentTarget,{fetcherKey:t,method:w,navigate:r,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&r!==!1?P.startTransition(()=>F()):F()};return P.createElement("form",{ref:b,method:A,action:y,onSubmit:n?c:S,...f,"data-discover":!j&&e==="render"?"true":void 0})});km.displayName="Form";function Cm(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yl(e){let t=P.useContext(hn);return je(t,Cm(e)),t}function Am(e,{target:t,replace:r,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=ye(),m=ge(),h=Mn(e,{relative:o});return P.useCallback(f=>{if(sm(f,t)){f.preventDefault();let b=r!==void 0?r:ds(m)===ds(h),p=()=>d(e,{replace:b,mask:n,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?P.startTransition(()=>p()):p()}},[m,d,h,r,n,a,t,e,i,o,l,c,u])}function Pm(e){nt(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(ha(e)),r=P.useRef(!1),n=ge(),a=P.useMemo(()=>am(n.search,r.current?null:t.current),[n.search]),i=ye(),o=P.useCallback((l,c)=>{const u=ha(typeof l=="function"?l(new URLSearchParams(a)):l);r.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var Em=0,_m=()=>`__${String(++Em)}__`;function Tm(){let{router:e}=Yl("useSubmit"),{basename:t}=P.useContext(at),r=Yd(),n=e.fetch,a=e.navigate;return P.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:m}=lm(i,t);if(o.navigate===!1){let h=o.fetcherKey||_m();await n(h,r,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:r,flushSync:o.flushSync,viewTransition:o.viewTransition})},[n,a,t,r])}function Im(e,{relative:t}={}){let{basename:r}=P.useContext(at),n=P.useContext(lt);je(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),i={...Mn(e||".",{relative:t})},o=ge();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let d=l.toString();i.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(i.pathname=i.pathname==="/"?r:gt([r,i.pathname])),ds(i)}function Fm(e,{relative:t}={}){let r=P.useContext($l);je(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=Yl("useViewTransitionState"),a=Mn(e,{relative:t});if(!r.isTransitioning)return!1;let i=qt(r.currentLocation.pathname,n)||r.currentLocation.pathname,o=qt(r.nextLocation.pathname,n)||r.nextLocation.pathname;return ms(a.pathname,o)!=null||ms(a.pathname,i)!=null}var pn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},jr,Jt,Kr,xl,Dm=(xl=class extends pn{constructor(){super();K(this,jr);K(this,Jt);K(this,Kr);V(this,Kr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){v(this,Jt)||this.setEventListener(v(this,Kr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Jt))==null||t.call(this),V(this,Jt,void 0))}setEventListener(t){var r;V(this,Kr,t),(r=v(this,Jt))==null||r.call(this),V(this,Jt,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){v(this,jr)!==t&&(V(this,jr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof v(this,jr)=="boolean"?v(this,jr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},jr=new WeakMap,Jt=new WeakMap,Kr=new WeakMap,xl),ii=new Dm,Rm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},bt,Nr,gl,Om=(gl=class{constructor(){K(this,bt,Rm);K(this,Nr,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&v(this,Nr)&&e!==v(this,bt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:v(this,bt),provider:e}),V(this,bt,e),process.env.NODE_ENV!=="production"&&V(this,Nr,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&V(this,Nr,!0),v(this,bt).setTimeout(e,t)}clearTimeout(e){v(this,bt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&V(this,Nr,!0),v(this,bt).setInterval(e,t)}clearInterval(e){v(this,bt).clearInterval(e)}},bt=new WeakMap,Nr=new WeakMap,gl),br=new Om;function $m(e){setTimeout(e,0)}var Lm=typeof window>"u"||"Deno"in globalThis;function He(){}function zm(e,t){return typeof e=="function"?e(t):e}function fa(e){return typeof e=="number"&&e>=0&&e!==1/0}function Hl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function or(e,t){return typeof e=="function"?e(t):e}function et(e,t){return typeof e=="function"?e(t):e}function oo(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(n){if(t.queryHash!==oi(o,t.options))return!1}else if(!_n(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 lo(e,t){const{exact:r,status:n,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Tr(t.options.mutationKey)!==Tr(i))return!1}else if(!_n(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function oi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tr)(e)}function Tr(e){return JSON.stringify(e,(t,r)=>xa(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function _n(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>_n(e[r],t[r])):!1}var Mm=Object.prototype.hasOwnProperty;function pa(e,t,r=0){if(e===t)return e;if(r>500)return t;const n=co(e)&&co(t);if(!n&&!(xa(e)&&xa(t)))return t;const i=(n?e:Object.keys(e)).length,o=n?t:Object.keys(t),l=o.length,c=n?new Array(l):{};let u=0;for(let d=0;d<l;d++){const m=n?d:o[d],h=e[m],f=t[m];if(h===f){c[m]=h,(n?d<i:Mm.call(e,m))&&u++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const b=pa(h,f,r+1);c[m]=b,b===h&&u++}return i===l&&u===i?e:c}function fs(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 co(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function xa(e){if(!uo(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!uo(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function uo(e){return Object.prototype.toString.call(e)==="[object Object]"}function qm(e){return new Promise(t=>{br.setTimeout(t,e)})}function ga(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 pa(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`),n}return pa(e,t)}return t}function Vm(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Bm(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var ps=Symbol();function Kl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===ps&&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===ps?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function li(e,t){return typeof e=="function"?e(...t):!!e}function Um(e,t,r){let n=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),n||(n=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),e}var Tn=(()=>{let e=()=>Lm;return{isServer(){return e()},setIsServer(t){e=t}}})();function ya(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),t(a)},r}var Zm=$m;function Wm(){let e=[],t=0,r=l=>{l()},n=l=>{l()},a=Zm;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var Te=Wm(),Qr,Gt,Jr,yl,Ym=(yl=class extends pn{constructor(){super();K(this,Qr,!0);K(this,Gt);K(this,Jr);V(this,Jr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){v(this,Gt)||this.setEventListener(v(this,Jr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Gt))==null||t.call(this),V(this,Gt,void 0))}setEventListener(t){var r;V(this,Jr,t),(r=v(this,Gt))==null||r.call(this),V(this,Gt,t(this.setOnline.bind(this)))}setOnline(t){v(this,Qr)!==t&&(V(this,Qr,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return v(this,Qr)}},Qr=new WeakMap,Gt=new WeakMap,Jr=new WeakMap,yl),xs=new Ym;function Hm(e){return Math.min(1e3*2**e,3e4)}function Ql(e){return(e??"online")==="online"?xs.isOnline():!0}var ba=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Jl(e){let t=!1,r=0,n;const a=ya(),i=()=>a.status!=="pending",o=p=>{var g;if(!i()){const y=new ba(p);h(y),(g=e.onCancel)==null||g.call(e,y)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>ii.isFocused()&&(e.networkMode==="always"||xs.isOnline())&&e.canRun(),d=()=>Ql(e.networkMode)&&e.canRun(),m=p=>{i()||(n==null||n(),a.resolve(p))},h=p=>{i()||(n==null||n(),a.reject(p))},f=()=>new Promise(p=>{var g;n=y=>{(i()||u())&&p(y)},(g=e.onPause)==null||g.call(e)}).then(()=>{var p;n=void 0,i()||(p=e.onContinue)==null||p.call(e)}),b=()=>{if(i())return;let p;const g=r===0?e.initialPromise:void 0;try{p=g??e.fn()}catch(y){p=Promise.reject(y)}Promise.resolve(p).then(m).catch(y=>{var I;if(i())return;const A=e.retry??(Tn.isServer()?0:3),j=e.retryDelay??Hm,S=typeof j=="function"?j(r,y):j,E=A===!0||typeof A=="number"&&r<A||typeof A=="function"&&A(r,y);if(t||!E){h(y);return}r++,(I=e.onFail)==null||I.call(e,r,y),qm(S).then(()=>u()?void 0:f()).then(()=>{t?h(y):b()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():f().then(b),a)}}var wr,bl,Gl=(bl=class{constructor(){K(this,wr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),fa(this.gcTime)&&V(this,wr,br.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Tn.isServer()?1/0:300*1e3))}clearGcTimeout(){v(this,wr)!==void 0&&(br.clearTimeout(v(this,wr)),V(this,wr,void 0))}},wr=new WeakMap,bl);function Km(e){return{onFetch:(t,r)=>{var d,m,h,f,b;const n=t.options,a=(h=(m=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((b=t.state.data)==null?void 0:b.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const g=j=>{Um(j,()=>t.signal,()=>p=!0)},y=Kl(t.options,t.fetchOptions),A=async(j,S,E)=>{if(p)return Promise.reject(t.signal.reason);if(S==null&&j.pages.length)return Promise.resolve(j);const w=(()=>{const se={client:t.client,queryKey:t.queryKey,pageParam:S,direction:E?"backward":"forward",meta:t.options.meta};return g(se),se})(),F=await y(w),{maxPages:D}=t.options,$=E?Bm:Vm;return{pages:$(j.pages,F,D),pageParams:$(j.pageParams,S,D)}};if(a&&i.length){const j=a==="backward",S=j?Qm:mo,E={pages:i,pageParams:o},I=S(n,E);l=await A(E,I,j)}else{const j=e??i.length;do{const S=c===0?o[0]??n.initialPageParam:mo(n,l);if(c>0&&S==null)break;l=await A(l,S),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var p,g;return(g=(p=t.options).persister)==null?void 0:g.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function mo(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Qm(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Gr,Sr,Xr,ot,kr,De,Dn,Cr,Xe,Xl,Rt,vl,Jm=(vl=class extends Gl{constructor(t){super();K(this,Xe);K(this,Gr);K(this,Sr);K(this,Xr);K(this,ot);K(this,kr);K(this,De);K(this,Dn);K(this,Cr);V(this,Cr,!1),V(this,Dn,t.defaultOptions),this.setOptions(t.options),this.observers=[],V(this,kr,t.client),V(this,ot,v(this,kr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,V(this,Sr,fo(this.options)),this.state=t.state??v(this,Sr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return v(this,Gr)}get promise(){var t;return(t=v(this,De))==null?void 0:t.promise}setOptions(t){if(this.options={...v(this,Dn),...t},t!=null&&t._type&&V(this,Gr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=fo(this.options);r.data!==void 0&&(this.setState(ho(r.data,r.dataUpdatedAt)),V(this,Sr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,ot).remove(this)}setData(t,r){const n=ga(this.state.data,t,this.options);return re(this,Xe,Rt).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t){re(this,Xe,Rt).call(this,{type:"setState",state:t})}cancel(t){var n,a;const r=(n=v(this,De))==null?void 0:n.promise;return(a=v(this,De))==null||a.cancel(t),r?r.then(He).catch(He):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return v(this,Sr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>et(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ps||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>or(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Hl(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,De))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,De))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),v(this,ot).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(v(this,De)&&(v(this,Cr)||re(this,Xe,Xl).call(this)?v(this,De).cancel({revert:!0}):v(this,De).cancelRetry()),this.scheduleGc()),v(this,ot).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||re(this,Xe,Rt).call(this,{type:"invalidate"})}async fetch(t,r){var u,d,m,h,f,b,p,g,y,A,j;if(this.state.fetchStatus!=="idle"&&((u=v(this,De))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(v(this,De))return v(this,De).continueRetry(),v(this,De).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 n=new AbortController,a=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(V(this,Cr,!0),n.signal)})},i=()=>{const S=Kl(this.options,r),I=(()=>{const w={client:v(this,kr),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return V(this,Cr,!1),this.options.persister?this.options.persister(S,I,this):S(I)},l=(()=>{const S={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:v(this,kr),state:this.state,fetchFn:i};return a(S),S})(),c=v(this,Gr)==="infinite"?Km(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),V(this,Xr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&re(this,Xe,Rt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),V(this,De,Jl({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof ba&&S.revert&&this.setState({...v(this,Xr),fetchStatus:"idle"}),n.abort()},onFail:(S,E)=>{re(this,Xe,Rt).call(this,{type:"failed",failureCount:S,error:E})},onPause:()=>{re(this,Xe,Rt).call(this,{type:"pause"})},onContinue:()=>{re(this,Xe,Rt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await v(this,De).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=v(this,ot).config).onSuccess)==null||f.call(h,S,this),(p=(b=v(this,ot).config).onSettled)==null||p.call(b,S,this.state.error,this),S}catch(S){if(S instanceof ba){if(S.silent)return v(this,De).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw re(this,Xe,Rt).call(this,{type:"error",error:S}),(y=(g=v(this,ot).config).onError)==null||y.call(g,S,this),(j=(A=v(this,ot).config).onSettled)==null||j.call(A,this.state.data,S,this),S}finally{this.scheduleGc()}}},Gr=new WeakMap,Sr=new WeakMap,Xr=new WeakMap,ot=new WeakMap,kr=new WeakMap,De=new WeakMap,Dn=new WeakMap,Cr=new WeakMap,Xe=new WeakSet,Xl=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Rt=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...ec(n.data,this.options),fetchMeta:t.meta??null};case"success":const a={...n,...ho(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return V(this,Xr,t.manual?a:void 0),a;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),Te.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),v(this,ot).notify({query:this,type:"updated",action:t})})},vl);function ec(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ql(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ho(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fo(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Qe,ie,Rn,Ye,Ar,en,Ot,Xt,On,tn,rn,Pr,Er,er,nn,ue,Cn,va,ja,Na,wa,Sa,ka,Ca,tc,jl,Gm=(jl=class extends pn{constructor(t,r){super();K(this,ue);K(this,Qe);K(this,ie);K(this,Rn);K(this,Ye);K(this,Ar);K(this,en);K(this,Ot);K(this,Xt);K(this,On);K(this,tn);K(this,rn);K(this,Pr);K(this,Er);K(this,er);K(this,nn,new Set);this.options=r,V(this,Qe,t),V(this,Xt,null),V(this,Ot,ya()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,ie).addObserver(this),po(v(this,ie),this.options)?re(this,ue,Cn).call(this):this.updateResult(),re(this,ue,wa).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Aa(v(this,ie),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Aa(v(this,ie),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,re(this,ue,Sa).call(this),re(this,ue,ka).call(this),v(this,ie).removeObserver(this)}setOptions(t){const r=this.options,n=v(this,ie);if(this.options=v(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof et(this.options.enabled,v(this,ie))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");re(this,ue,Ca).call(this),v(this,ie).setOptions(this.options),r._defaulted&&!fs(this.options,r)&&v(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,ie),observer:this});const a=this.hasListeners();a&&xo(v(this,ie),n,this.options,r)&&re(this,ue,Cn).call(this),this.updateResult(),a&&(v(this,ie)!==n||et(this.options.enabled,v(this,ie))!==et(r.enabled,v(this,ie))||or(this.options.staleTime,v(this,ie))!==or(r.staleTime,v(this,ie)))&&re(this,ue,va).call(this);const i=re(this,ue,ja).call(this);a&&(v(this,ie)!==n||et(this.options.enabled,v(this,ie))!==et(r.enabled,v(this,ie))||i!==v(this,er))&&re(this,ue,Na).call(this,i)}getOptimisticResult(t){const r=v(this,Qe).getQueryCache().build(v(this,Qe),t),n=this.createResult(r,t);return eh(this,n)&&(V(this,Ye,n),V(this,en,this.options),V(this,Ar,v(this,ie).state)),n}getCurrentResult(){return v(this,Ye)}trackResult(t,r){return new Proxy(t,{get:(n,a)=>(this.trackProp(a),r==null||r(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&v(this,Ot).status==="pending"&&v(this,Ot).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,a))})}trackProp(t){v(this,nn).add(t)}getCurrentQuery(){return v(this,ie)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=v(this,Qe).defaultQueryOptions(t),n=v(this,Qe).getQueryCache().build(v(this,Qe),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return re(this,ue,Cn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,Ye)))}createResult(t,r){var D;const n=v(this,ie),a=this.options,i=v(this,Ye),o=v(this,Ar),l=v(this,en),u=t!==n?t.state:v(this,Rn),{state:d}=t;let m={...d},h=!1,f;if(r._optimisticResults){const $=this.hasListeners(),se=!$&&po(t,r),B=$&&xo(t,n,r,a);(se||B)&&(m={...m,...ec(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:b,errorUpdatedAt:p,status:g}=m;f=m.data;let y=!1;if(r.placeholderData!==void 0&&f===void 0&&g==="pending"){let $;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?($=i.data,y=!0):$=typeof r.placeholderData=="function"?r.placeholderData((D=v(this,rn))==null?void 0:D.state.data,v(this,rn)):r.placeholderData,$!==void 0&&(g="success",f=ga(i==null?void 0:i.data,$,r),h=!0)}if(r.select&&f!==void 0&&!y)if(i&&f===(o==null?void 0:o.data)&&r.select===v(this,On))f=v(this,tn);else try{V(this,On,r.select),f=r.select(f),f=ga(i==null?void 0:i.data,f,r),V(this,tn,f),V(this,Xt,null)}catch($){V(this,Xt,$)}v(this,Xt)&&(b=v(this,Xt),f=v(this,tn),p=Date.now(),g="error");const A=m.fetchStatus==="fetching",j=g==="pending",S=g==="error",E=j&&A,I=f!==void 0,F={status:g,fetchStatus:m.fetchStatus,isPending:j,isSuccess:g==="success",isError:S,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:b,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:A,isRefetching:A&&!j,isLoadingError:S&&!I,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&I,isStale:ci(t,r),refetch:this.refetch,promise:v(this,Ot),isEnabled:et(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const $=F.data!==void 0,se=F.status==="error"&&!$,B=Y=>{se?Y.reject(F.error):$&&Y.resolve(F.data)},Q=()=>{const Y=V(this,Ot,F.promise=ya());B(Y)},te=v(this,Ot);switch(te.status){case"pending":t.queryHash===n.queryHash&&B(te);break;case"fulfilled":(se||F.data!==te.value)&&Q();break;case"rejected":(!se||F.error!==te.reason)&&Q();break}}return F}updateResult(){const t=v(this,Ye),r=this.createResult(v(this,ie),this.options);if(V(this,Ar,v(this,ie).state),V(this,en,this.options),v(this,Ar).data!==void 0&&V(this,rn,v(this,ie)),fs(r,t))return;V(this,Ye,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!v(this,nn).size)return!0;const o=new Set(i??v(this,nn));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,Ye)).some(l=>{const c=l;return v(this,Ye)[c]!==t[c]&&o.has(c)})};re(this,ue,tc).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&re(this,ue,wa).call(this)}},Qe=new WeakMap,ie=new WeakMap,Rn=new WeakMap,Ye=new WeakMap,Ar=new WeakMap,en=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,On=new WeakMap,tn=new WeakMap,rn=new WeakMap,Pr=new WeakMap,Er=new WeakMap,er=new WeakMap,nn=new WeakMap,ue=new WeakSet,Cn=function(t){re(this,ue,Ca).call(this);let r=v(this,ie).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(He)),r},va=function(){re(this,ue,Sa).call(this);const t=or(this.options.staleTime,v(this,ie));if(Tn.isServer()||v(this,Ye).isStale||!fa(t))return;const n=Hl(v(this,Ye).dataUpdatedAt,t)+1;V(this,Pr,br.setTimeout(()=>{v(this,Ye).isStale||this.updateResult()},n))},ja=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,ie)):this.options.refetchInterval)??!1},Na=function(t){re(this,ue,ka).call(this),V(this,er,t),!(Tn.isServer()||et(this.options.enabled,v(this,ie))===!1||!fa(v(this,er))||v(this,er)===0)&&V(this,Er,br.setInterval(()=>{(this.options.refetchIntervalInBackground||ii.isFocused())&&re(this,ue,Cn).call(this)},v(this,er)))},wa=function(){re(this,ue,va).call(this),re(this,ue,Na).call(this,re(this,ue,ja).call(this))},Sa=function(){v(this,Pr)!==void 0&&(br.clearTimeout(v(this,Pr)),V(this,Pr,void 0))},ka=function(){v(this,Er)!==void 0&&(br.clearInterval(v(this,Er)),V(this,Er,void 0))},Ca=function(){const t=v(this,Qe).getQueryCache().build(v(this,Qe),this.options);if(t===v(this,ie))return;const r=v(this,ie);V(this,ie,t),V(this,Rn,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},tc=function(t){Te.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(v(this,Ye))}),v(this,Qe).getQueryCache().notify({query:v(this,ie),type:"observerResultsUpdated"})})},jl);function Xm(e,t){return et(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&et(t.retryOnMount,e)===!1)}function po(e,t){return Xm(e,t)||e.state.data!==void 0&&Aa(e,t,t.refetchOnMount)}function Aa(e,t,r){if(et(t.enabled,e)!==!1&&or(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&ci(e,t)}return!1}function xo(e,t,r,n){return(e!==t||et(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&ci(e,r)}function ci(e,t){return et(t.enabled,e)!==!1&&e.isStaleByTime(or(t.staleTime,e))}function eh(e,t){return!fs(e.getCurrentResult(),t)}var $n,vt,Ve,_r,jt,Ht,Nl,th=(Nl=class extends Gl{constructor(t){super();K(this,jt);K(this,$n);K(this,vt);K(this,Ve);K(this,_r);V(this,$n,t.client),this.mutationId=t.mutationId,V(this,Ve,t.mutationCache),V(this,vt,[]),this.state=t.state||rc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){v(this,vt).includes(t)||(v(this,vt).push(t),this.clearGcTimeout(),v(this,Ve).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){V(this,vt,v(this,vt).filter(r=>r!==t)),this.scheduleGc(),v(this,Ve).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){v(this,vt).length||(this.state.status==="pending"?this.scheduleGc():v(this,Ve).remove(this))}continue(){var t;return((t=v(this,_r))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,b,p,g,y,A,j,S,E,I,w;const r=()=>{re(this,jt,Ht).call(this,{type:"continue"})},n={client:v(this,$n),meta:this.options.meta,mutationKey:this.options.mutationKey};V(this,_r,Jl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(F,D)=>{re(this,jt,Ht).call(this,{type:"failed",failureCount:F,error:D})},onPause:()=>{re(this,jt,Ht).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,Ve).canRun(this)}));const a=this.state.status==="pending",i=!v(this,_r).canStart();try{if(a)r();else{re(this,jt,Ht).call(this,{type:"pending",variables:t,isPaused:i}),v(this,Ve).config.onMutate&&await v(this,Ve).config.onMutate(t,this,n);const D=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,n));D!==this.state.context&&re(this,jt,Ht).call(this,{type:"pending",context:D,variables:t,isPaused:i})}const F=await v(this,_r).start();return await((u=(c=v(this,Ve).config).onSuccess)==null?void 0:u.call(c,F,t,this.state.context,this,n)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,F,t,this.state.context,n)),await((f=(h=v(this,Ve).config).onSettled)==null?void 0:f.call(h,F,null,this.state.variables,this.state.context,this,n)),await((p=(b=this.options).onSettled)==null?void 0:p.call(b,F,null,t,this.state.context,n)),re(this,jt,Ht).call(this,{type:"success",data:F}),F}catch(F){try{await((y=(g=v(this,Ve).config).onError)==null?void 0:y.call(g,F,t,this.state.context,this,n))}catch(D){Promise.reject(D)}try{await((j=(A=this.options).onError)==null?void 0:j.call(A,F,t,this.state.context,n))}catch(D){Promise.reject(D)}try{await((E=(S=v(this,Ve).config).onSettled)==null?void 0:E.call(S,void 0,F,this.state.variables,this.state.context,this,n))}catch(D){Promise.reject(D)}try{await((w=(I=this.options).onSettled)==null?void 0:w.call(I,void 0,F,t,this.state.context,n))}catch(D){Promise.reject(D)}throw re(this,jt,Ht).call(this,{type:"error",error:F}),F}finally{v(this,Ve).runNext(this)}}},$n=new WeakMap,vt=new WeakMap,Ve=new WeakMap,_r=new WeakMap,jt=new WeakSet,Ht=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Te.batch(()=>{v(this,vt).forEach(n=>{n.onMutationUpdate(t)}),v(this,Ve).notify({mutation:this,type:"updated",action:t})})},Nl);function rc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $t,pt,Ln,wl,rh=(wl=class extends pn{constructor(t={}){super();K(this,$t);K(this,pt);K(this,Ln);this.config=t,V(this,$t,new Set),V(this,pt,new Map),V(this,Ln,0)}build(t,r,n){const a=new th({client:t,mutationCache:this,mutationId:++Yn(this,Ln)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){v(this,$t).add(t);const r=Kn(t);if(typeof r=="string"){const n=v(this,pt).get(r);n?n.push(t):v(this,pt).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(v(this,$t).delete(t)){const r=Kn(t);if(typeof r=="string"){const n=v(this,pt).get(r);if(n)if(n.length>1){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}else n[0]===t&&v(this,pt).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Kn(t);if(typeof r=="string"){const n=v(this,pt).get(r),a=n==null?void 0:n.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var n;const r=Kn(t);if(typeof r=="string"){const a=(n=v(this,pt).get(r))==null?void 0:n.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Te.batch(()=>{v(this,$t).forEach(t=>{this.notify({type:"removed",mutation:t})}),v(this,$t).clear(),v(this,pt).clear()})}getAll(){return Array.from(v(this,$t))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>lo(r,n))}findAll(t={}){return this.getAll().filter(r=>lo(t,r))}notify(t){Te.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return Te.batch(()=>Promise.all(t.map(r=>r.continue().catch(He))))}},$t=new WeakMap,pt=new WeakMap,Ln=new WeakMap,wl);function Kn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Lt,tr,Je,zt,Mt,cs,Pa,Sl,nh=(Sl=class extends pn{constructor(t,r){super();K(this,Mt);K(this,Lt);K(this,tr);K(this,Je);K(this,zt);V(this,Lt,t),this.setOptions(r),this.bindMethods(),re(this,Mt,cs).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=v(this,Lt).defaultMutationOptions(t),fs(this.options,r)||v(this,Lt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:v(this,Je),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Tr(r.mutationKey)!==Tr(this.options.mutationKey)?this.reset():((n=v(this,Je))==null?void 0:n.state.status)==="pending"&&v(this,Je).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=v(this,Je))==null||t.removeObserver(this)}onMutationUpdate(t){re(this,Mt,cs).call(this),re(this,Mt,Pa).call(this,t)}getCurrentResult(){return v(this,tr)}reset(){var t;(t=v(this,Je))==null||t.removeObserver(this),V(this,Je,void 0),re(this,Mt,cs).call(this),re(this,Mt,Pa).call(this)}mutate(t,r){var n;return V(this,zt,r),(n=v(this,Je))==null||n.removeObserver(this),V(this,Je,v(this,Lt).getMutationCache().build(v(this,Lt),this.options)),v(this,Je).addObserver(this),v(this,Je).execute(t)}},Lt=new WeakMap,tr=new WeakMap,Je=new WeakMap,zt=new WeakMap,Mt=new WeakSet,cs=function(){var r;const t=((r=v(this,Je))==null?void 0:r.state)??rc();V(this,tr,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Pa=function(t){Te.batch(()=>{var r,n,a,i,o,l,c,u;if(v(this,zt)&&this.hasListeners()){const d=v(this,tr).variables,m=v(this,tr).context,h={client:v(this,Lt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(n=(r=v(this,zt)).onSuccess)==null||n.call(r,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=v(this,zt)).onSettled)==null||i.call(a,t.data,null,d,m,h)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=v(this,zt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=v(this,zt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(v(this,tr))})})},Sl),Nt,kl,sh=(kl=class extends pn{constructor(t={}){super();K(this,Nt);this.config=t,V(this,Nt,new Map)}build(t,r,n){const a=r.queryKey,i=r.queryHash??oi(a,r);let o=this.get(i);return o||(o=new Jm({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){v(this,Nt).has(t.queryHash)||(v(this,Nt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=v(this,Nt).get(t.queryHash);r&&(t.destroy(),r===t&&v(this,Nt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Te.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return v(this,Nt).get(t)}getAll(){return[...v(this,Nt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>oo(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>oo(t,n)):r}notify(t){Te.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Te.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Te.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Nt=new WeakMap,kl),Se,rr,nr,sn,an,sr,on,ln,Cl,ah=(Cl=class{constructor(e={}){K(this,Se);K(this,rr);K(this,nr);K(this,sn);K(this,an);K(this,sr);K(this,on);K(this,ln);V(this,Se,e.queryCache||new sh),V(this,rr,e.mutationCache||new rh),V(this,nr,e.defaultOptions||{}),V(this,sn,new Map),V(this,an,new Map),V(this,sr,0)}mount(){Yn(this,sr)._++,v(this,sr)===1&&(V(this,on,ii.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,Se).onFocus())})),V(this,ln,xs.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,Se).onOnline())})))}unmount(){var e,t;Yn(this,sr)._--,v(this,sr)===0&&((e=v(this,on))==null||e.call(this),V(this,on,void 0),(t=v(this,ln))==null||t.call(this),V(this,ln,void 0))}isFetching(e){return v(this,Se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return v(this,rr).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,Se).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=v(this,Se).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(or(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return v(this,Se).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=v(this,Se).get(n.queryHash),i=a==null?void 0:a.state.data,o=zm(t,i);if(o!==void 0)return v(this,Se).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return Te.batch(()=>v(this,Se).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,Se).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=v(this,Se);Te.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=v(this,Se);return Te.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=Te.batch(()=>v(this,Se).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(He).catch(He)}invalidateQueries(e,t={}){return Te.batch(()=>(v(this,Se).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=Te.batch(()=>v(this,Se).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(He)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(He)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=v(this,Se).build(this,t);return r.isStaleByTime(or(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(He).catch(He)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(He).catch(He)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return xs.isOnline()?v(this,rr).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,Se)}getMutationCache(){return v(this,rr)}getDefaultOptions(){return v(this,nr)}setDefaultOptions(e){V(this,nr,e)}setQueryDefaults(e,t){v(this,sn).set(Tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...v(this,sn).values()],r={};return t.forEach(n=>{_n(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){v(this,an).set(Tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...v(this,an).values()],r={};return t.forEach(n=>{_n(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...v(this,nr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=oi(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===ps&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...v(this,nr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){v(this,Se).clear(),v(this,rr).clear()}},Se=new WeakMap,rr=new WeakMap,nr=new WeakMap,sn=new WeakMap,an=new WeakMap,sr=new WeakMap,on=new WeakMap,ln=new WeakMap,Cl),nc=P.createContext(void 0),ct=e=>{const t=P.useContext(nc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ih=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(nc.Provider,{value:e,children:t})),sc=P.createContext(!1),oh=()=>P.useContext(sc);sc.Provider;function lh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ch=P.createContext(lh()),uh=()=>P.useContext(ch),dh=(e,t,r)=>{const n=r!=null&&r.state.error&&typeof e.throwOnError=="function"?li(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},mh=e=>{P.useEffect(()=>{e.clearReset()},[e])},hh=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||li(r,[e.error,n])),fh=e=>{if(e.suspense){const r=a=>a==="static"?a:Math.max(a??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...a)=>r(n(...a)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ph=(e,t)=>e.isLoading&&e.isFetching&&!t,xh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,go=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function gh(e,t,r){var f,b,p,g;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=oh(),a=uh(),i=ct(),o=i.defaultQueryOptions(e);(b=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||b.call(f,o);const l=i.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`));const c=e.subscribed!==!1;o._optimisticResults=n?"isRestoring":c?"optimistic":void 0,fh(o),dh(o,a,l),mh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=P.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!n&&c;if(P.useSyncExternalStore(P.useCallback(y=>{const A=h?d.subscribe(Te.batchCalls(y)):He;return d.updateResult(),A},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),P.useEffect(()=>{d.setOptions(o)},[o,d]),xh(o,m))throw go(o,d,a);if(hh({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((g=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||g.call(p,o,m),o.experimental_prefetchInRender&&!Tn.isServer()&&ph(m,n)){const y=u?go(o,d,a):l==null?void 0:l.promise;y==null||y.catch(He).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function ke(e,t){return gh(e,Gm)}function yh(e,t){const r=ct(),[n]=P.useState(()=>new nh(r,e));P.useEffect(()=>{n.setOptions(e)},[n,e]);const a=P.useSyncExternalStore(P.useCallback(o=>n.subscribe(Te.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=P.useCallback((o,l)=>{n.mutate(o,l).catch(He)},[n]);if(a.error&&li(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function ac(e){return e.trim().replace(/\/+$/,"")}const Ts=new Map;function ic(e,t){Ts.set(e,t)}function bh(e){return Ts.get(e)}function vh(e){Ts.delete(e)}function jh(e){for(const[t,r]of Ts)if(r.accessToken===e)return t}let Ea=null;function oc(e){Ea=ac(e)}let lc=null;function Nh(e){lc=e}function wh(){return lc}let cc=null;function Sh(e){cc=e.trim()}function kh(){return cc}function Ch(){return Ea!==null?Ea:ac("")}const yo={get apiBaseUrl(){return Ch()},apiVersion:"v1"};function Ah(e){const t=e.startsWith("/")?e:`/${e}`;return`${yo.apiBaseUrl}/api/${yo.apiVersion}${t}`}const uc="auth:session-expired";function Ph(){window.dispatchEvent(new CustomEvent(uc))}function dc(e){return`${uc}:${e}`}const Eh=N.createContext(null);function _h({instanceId:e,accessToken:t,onSessionExpired:r,children:n}){const a=bh(e);return a&&ic(e,{...a,accessToken:t}),Nh(t),N.useEffect(()=>{if(!r)return;const i=dc(e),o=()=>r();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,r]),s.jsx(Eh.Provider,{value:{accessToken:t},children:n})}class xn extends Error{constructor(r,n,a,i,o){super(a??n);vn(this,"status");vn(this,"title");vn(this,"details");vn(this,"extensions");this.name="ApiError",this.status=r,this.title=n,this.details=i,this.extensions=o}}const mc="tax-remittance.auth";function Th(){var t;const e=localStorage.getItem(mc);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?(_a(),null):r}catch{return _a(),null}}function _a(){localStorage.removeItem(mc)}function Ih(){var e;return((e=Th())==null?void 0:e.accessToken)??null}async function Fh(e){let t=null;try{t=await e.json()}catch{}const r=(t==null?void 0:t.title)??"Request failed",n=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new xn(e.status,r,n,a,t??void 0)}async function Dh(e,t={}){const{body:r,auth:n=!0,headers:a,...i}=t,o=new Headers(a);o.set("Accept","application/json"),r!==void 0&&o.set("Content-Type","application/json");let l=null;if(n){const d=wh()??Ih();d&&(l=d,o.set("Authorization",`Bearer ${d}`))}const c=kh();c&&o.set("X-Client-ID",c);const u=await fetch(Ah(e),{...i,headers:o,body:r!==void 0?JSON.stringify(r):void 0});if(!u.ok){const d=await Fh(u);if(n&&d.status===401){_a();const m=l?jh(l):void 0;m?window.dispatchEvent(new CustomEvent(dc(m))):Ph()}throw d}if(u.status!==204)return await u.json()}async function he(e,t={}){return(await Dh(e,t)).data}function hc(){return he("/portal/entities/mine")}function Rh(e){return he("/portal/entities",{method:"POST",body:e})}function Oh(e,t){return he(`/portal/entities/${e}`,{method:"PATCH",body:t})}const fc=N.createContext(null);function $h({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:r,children:n}){var p;const[a,i]=N.useState(null),{data:o=[],isLoading:l,isError:c,refetch:u}=ke({queryKey:["entities","mine"],queryFn:hc}),d=N.useRef(new Set),m=N.useRef(!1);N.useEffect(()=>{if(l)return;if(!m.current){o.forEach(y=>d.current.add(y.entityId)),m.current=!0;return}o.filter(y=>!d.current.has(y.entityId)).forEach(y=>{d.current.add(y.entityId),e==null||e(y)})},[o,l,e]);const h=a!==null&&o.some(g=>g.entityId===a)?a:((p=o[0])==null?void 0:p.entityId)??null,f=o.find(g=>g.entityId===h)??null,b=async()=>{await u()};return s.jsx(fc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:f,setSelectedEntityId:i,refetchEntities:b,enabledPayments:t,onPaymentRequired:r},children:n})}function $r(){const e=N.useContext(fc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const Lh=N.createContext(null);function zh({theme:e,children:t}){const r={},n=r,a=(e==null?void 0:e.primaryColor)??"#2563eb";n["--embedded-primary"]=a,n["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,n["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";n["--embedded-secondary"]=i,n["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,n["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return n["--embedded-tertiary"]=o,n["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,n["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(n["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(r.fontFamily=e.fontFamily),n.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:r,children:t})}const pc=N.createContext(null),Mh=6e3;function qh(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Vh({toast:e,onDismiss:t}){const r=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${r?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 py-4",children:[s.jsx("p",{className:"text-base font-bold text-slate-900",children:e.title}),s.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>t(e.id),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border transition hover:opacity-80 ${r?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(Bh,{})})]}),s.jsx("div",{className:`mx-5 border-t ${r?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function Bh(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function Uh({children:e}){const[t,r]=N.useState([]),n=N.useCallback(o=>{r(l=>l.filter(c=>c.id!==o))},[]),a=N.useCallback((o,l,c)=>{const u=qh();r(d=>[...d,{id:u,variant:o,title:l,message:c}]),window.setTimeout(()=>{n(u)},Mh)},[n]),i=N.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(pc.Provider,{value:i,children:[e,Cs.createPortal(s.jsx("div",{className:"pointer-events-none fixed right-4 top-4 z-[200] flex w-[min(100vw-2rem,28rem)] flex-col gap-3",children:t.map(o=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(Vh,{toast:o,onDismiss:n})},o.id))}),document.body)]})}function Is(){const e=N.useContext(pc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class Zh extends N.Component{constructor(t){super(t),this.state={hasError:!1,message:""}}static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:"Unexpected error"}}render(){return this.state.hasError?s.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("p",{className:"text-sm font-medium text-red-600",children:"Something went wrong loading this widget."}),s.jsx("p",{className:"text-xs text-slate-400",children:this.state.message}),s.jsx("button",{type:"button",className:"rounded-md bg-slate-100 px-4 py-2 text-sm text-slate-600 hover:bg-slate-200",onClick:()=>this.setState({hasError:!1,message:""}),children:"Try again"})]}):this.props.children}}function Wh(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 Yh({navigateFnRef:e,onNavigate:t}){const r=ye(),n=ge();return N.useEffect(()=>(e.current=r,()=>{e.current=null}),[r,e]),N.useEffect(()=>{t==null||t(Wh(n.pathname),n.pathname)},[n.pathname,t]),null}function Hh({selectEntityFnRef:e}){const{setSelectedEntityId:t}=$r();return N.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function ui({appKey:e,accessToken:t,apiBaseUrl:r,theme:n,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:u,enabledPayments:d,children:m}){const[h]=N.useState(()=>crypto.randomUUID());ic(h,{apiBaseUrl:r.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),oc(r),Sh(e),N.useEffect(()=>()=>{vh(h)},[h]);const[f]=N.useState(()=>new ah({defaultOptions:{queries:{retry:1,staleTime:300*1e3,refetchOnWindowFocus:!1}}}));return s.jsx(Lh.Provider,{value:h,children:s.jsx(zh,{theme:n,children:s.jsx(ih,{client:f,children:s.jsx(Uh,{children:s.jsx(_h,{instanceId:h,accessToken:t,onSessionExpired:a,children:s.jsx(Jd,{children:s.jsxs($h,{onOrganizationCreated:i,enabledPayments:d,onPaymentRequired:l,children:[s.jsx(Yh,{navigateFnRef:c,onNavigate:o}),s.jsx(Hh,{selectEntityFnRef:u}),s.jsx(Zh,{children:m})]})})})})})})})}function di(){const{entities:e,isLoading:t,isError:r,refetchEntities:n}=$r(),a=ye();return N.useEffect(()=>{t||r||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,r,e,a]),t?s.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600"})}):r?s.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-3 px-4 text-center",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-50",children:s.jsx("svg",{className:"h-5 w-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}),s.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Unable to load your account"}),s.jsx("p",{className:"text-xs text-slate-500",children:"Check your connection and try again."}),s.jsx("button",{type:"button",onClick:n,className:"mt-1 rounded-md bg-slate-100 px-4 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-200",children:"Retry"})]}):null}function mi(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=$r(),n=ye(),i=ge().pathname.split("/").filter(Boolean).length>1;return s.jsxs("div",{className:"flex min-h-full flex-col bg-slate-50",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3",children:[i&&s.jsxs("button",{type:"button",onClick:()=>n(-1),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-slate-500 transition hover:bg-slate-100 hover:text-slate-700",children:[s.jsx(Kh,{}),"Back"]}),s.jsx("div",{className:"flex-1"})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(Gd,{context:{entities:e,selectedEntity:t,setSelectedEntityId:r}})})]})}function Kh(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}const Qh=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function Jh({onCreateClick:e}){return s.jsxs("div",{className:"mx-auto w-full max-w-[528px]",children:[s.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-[#f3f4f6] bg-white shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)] sm:rounded-[24px]",children:[s.jsxs("div",{className:"bg-[#bccadb] px-5 pb-6 pt-6 text-center sm:px-8 sm:pb-8 sm:pt-8",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-white/20 sm:h-16 sm:w-16",children:s.jsx(bo,{className:"h-6 w-6 text-white sm:h-8 sm:w-8"})}),s.jsx("h2",{className:"mt-3 text-xl font-black tracking-tight text-[#1e2939] sm:mt-4 sm:text-2xl",children:"Create Your Entity"}),s.jsx("p",{className:"mt-1 text-sm text-[#1e2939]/80",children:"Get set up in under 1 minute"})]}),s.jsxs("div",{className:"bg-white px-5 py-5 sm:px-8 sm:py-6",children:[s.jsx("ul",{className:"space-y-2.5 sm:space-y-3",children:Qh.map(t=>s.jsxs("li",{className:"flex items-center gap-3 text-sm text-[#4a5565]",children:[s.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[#dfeeff] text-[#156bd5]",children:s.jsx(Qn,{})}),t]},t))}),s.jsxs("button",{type:"button",onClick:e,className:"mt-5 flex h-12 w-full items-center justify-center gap-2 rounded-2xl bg-[#156bd5] text-sm font-black text-white transition hover:bg-[#125bb8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5] focus-visible:ring-offset-2 sm:mt-6 sm:h-14 sm:text-base",children:[s.jsx(bo,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",s.jsx(Gh,{})]})]})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 text-xs text-[#99a1af] sm:mt-5 sm:gap-x-4",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Qn,{className:"h-3 w-3 text-emerald-500"}),"SOC 2 Certified"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Qn,{className:"h-3 w-3 text-emerald-500"}),"Bank-grade encryption"]}),s.jsx("span",{className:"hidden h-3 w-px bg-[#e5e7eb] sm:block","aria-hidden":!0}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Qn,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function bo({className:e="h-5 w-5"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Qn({className:e="h-3 w-3"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 16 16",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.5 8.5l3 3 6-6"})})}function Gh(){return s.jsx("svg",{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"})})}function hi(){const e=ye(),t=()=>{e("/create-entity/form",{state:{from:"/create-entity"}})};return s.jsx("div",{className:"flex items-center justify-center bg-transparent px-0 py-0",children:s.jsx(Jh,{onCreateClick:t})})}var qn=e=>e.type==="checkbox",ar=e=>e instanceof Date,Me=e=>e==null;const fi=e=>typeof e=="object";var ve=e=>!Me(e)&&!Array.isArray(e)&&fi(e)&&!ar(e),Ta=e=>ve(e)&&e.target?qn(e.target)?e.target.checked:e.target.value:e,xc=(e,t)=>t.split(".").some((r,n,a)=>!isNaN(Number(r))&&e.has(a.slice(0,n).join("."))),gc=e=>{const t=e.constructor&&e.constructor.prototype;return ve(t)&&t.hasOwnProperty("isPrototypeOf")},Fs=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function we(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Fs&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(ve(e)&&gc(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=we(e[a]));return n}const Kt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},xt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},yc="root",pi=["__proto__","constructor","prototype"],Xh=/^\w*$/;var Vn=e=>Xh.test(e),fe=e=>e===void 0;const ef=/[.[\]'"]/;var Ds=e=>e.split(ef).filter(Boolean),M=(e,t,r)=>{if(!t||!ve(e))return r;const n=Vn(t)?[t]:Ds(t);if(n.some(i=>pi.includes(i)))return r;const a=n.reduce((i,o)=>Me(i)?void 0:i[o],e);return fe(a)||a===e?fe(e[t])?r:e[t]:a},tt=e=>typeof e=="boolean",Be=e=>typeof e=="function",ce=(e,t,r)=>{let n=-1;const a=Vn(t)?[t]:Ds(t),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=r;if(n!==o){const u=e[l];c=ve(u)||Array.isArray(u)?u:isNaN(+a[n+1])?{}:[]}if(pi.includes(l))return;e[l]=c,e=e[l]}};const bc=N.createContext(null);bc.displayName="HookFormControlContext";const xi=()=>N.useContext(bc);var vc=(e,t,r,n=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==xt.all&&(t._proxyFormState[o]=!n||xt.all),r&&(r[o]=!0),e[o]}});return a};const gi=Fs?N.useLayoutEffect:N.useEffect;function tf(e){const t=xi(),{control:r=t,disabled:n,name:a,exact:i}=e||{},[o,l]=N.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=N.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return gi(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!n&&l({...r._formState,...u,defaultValues:r._defaultValues})}}),[a,n,i]),N.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),N.useMemo(()=>vc(o,r,c.current,!1),[o,r])}var Ue=e=>typeof e=="string",Ia=(e,t,r,n,a)=>Ue(e)?(n&&t.watch.add(e),M(r,e,a)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),M(r,i))):(n&&(t.watchAll=!0),r),Fa=e=>Me(e)||!fi(e);const vo=(e,t)=>t.length===0&&!Array.isArray(e)&&!gc(e);function rt(e,t,r=new WeakMap){if(e===t)return!0;if(Fa(e)||Fa(t))return Object.is(e,t);if(ar(e)&&ar(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(vo(e,n)||vo(t,a))return Object.is(e,t);if(!n.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=r.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),r.set(e,o)}for(const o of n){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(ar(l)&&ar(c)||(ve(l)||Array.isArray(l))&&(ve(c)||Array.isArray(c))?!rt(l,c,r):!Object.is(l,c))return!1}}return!0}function rf(e){const t=xi(),{control:r=t,name:n,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=N.useRef(a),u=N.useRef(l),d=N.useRef(void 0),m=N.useRef(r),h=N.useRef(n);u.current=l;const[f,b]=N.useState(()=>{const S=r._getWatch(n,c.current);return u.current?u.current(S):S}),p=N.useCallback(S=>{const E=Ia(n,r._names,S||r._formValues,!1,c.current);return u.current?u.current(E):E},[r._formValues,r._names,n]),g=N.useCallback(S=>{if(!i){const E=Ia(n,r._names,S||r._formValues,!1,c.current);if(u.current){const I=u.current(E);rt(I,d.current)||(b(I),d.current=I)}else b(E)}},[r._formValues,r._names,i,n]);gi(()=>((m.current!==r||!rt(h.current,n))&&(m.current=r,h.current=n,g()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:S=>{g(S.values)}})),[r,o,n,g]),N.useEffect(()=>r._removeUnmounted());const y=m.current!==r,A=h.current,j=N.useMemo(()=>{if(i)return null;const S=!y&&!rt(A,n);return y||S?p():null},[i,y,n,A,p]);return j!==null?j:f}function nf(e){const t=xi(),{name:r,disabled:n,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=xc(a._names.array,r),u=N.useMemo(()=>M(a._formValues,r,M(a._defaultValues,r,o)),[a,r,o]),d=rf({control:a,name:r,defaultValue:u,exact:l}),m=tf({control:a,name:r,exact:l}),h=N.useRef(e),f=N.useRef(null),b=N.useRef(a.register(r,{...e.rules,value:d,...tt(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=N.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!M(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!M(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!M(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!M(m.validatingFields,r)},error:{enumerable:!0,get:()=>M(m.errors,r)}}),[m,r]),g=N.useCallback(S=>{const E=Ta(S);return M(a._fields,r)||(b.current=a.register(r,{...h.current.rules,value:E})),b.current.onChange({target:{value:Ta(S),name:r},type:Kt.CHANGE})},[r,a]),y=N.useCallback(()=>b.current.onBlur({target:{value:M(a._formValues,r),name:r},type:Kt.BLUR}),[r,a._formValues]),A=N.useCallback(S=>{S&&(f.current={focus:()=>Be(S.focus)&&S.focus(),select:()=>Be(S.select)&&S.select(),setCustomValidity:I=>Be(S.setCustomValidity)&&S.setCustomValidity(I),reportValidity:()=>Be(S.reportValidity)&&S.reportValidity()});const E=M(a._fields,r);E&&E._f&&S&&(E._f.ref=f.current)},[a._fields,r]),j=N.useMemo(()=>({name:r,value:d,...tt(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:g,onBlur:y,ref:A}),[r,n,m.disabled,g,y,A,d]);return N.useEffect(()=>{const S=a._options.shouldUnregister||i;a.register(r,{...h.current.rules,...tt(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(I,w)=>{const F=M(a._fields,I);F&&F._f&&(F._f.mount=w)};if(E(r,!0),S){const I=we(M(i?a._defaultValues:a._options.values||a._defaultValues,r,M(a._options.defaultValues,r,h.current.defaultValue)));ce(a._defaultValues,r,I),fe(M(a._formValues,r))&&ce(a._formValues,r,I)}if(!c&&a.register(r),f.current){const I=M(a._fields,r);I&&I._f&&(I._f.ref=f.current)}return()=>{(c?S&&!a._state.action:S)?a.unregister(r):E(r,!1)}},[r,a,c,i]),N.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),N.useMemo(()=>({field:j,formState:m,fieldState:p}),[j,m,p])}const Re=e=>e.render(nf(e)),jc=e=>{const t={};for(const r of Object.keys(e))if(fi(e[r])&&e[r]!==null&&!ar(e[r])){const n=jc(e[r]);for(const a of Object.keys(n))t[`${r}.${a}`]=n[a]}else t[r]=e[r];return t},sf=N.createContext(null);sf.displayName="HookFormContext";var yi=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},Nc=e=>Array.isArray(e)?e.filter(Boolean):[],us=e=>Array.isArray(e)?e:[e],jo=()=>{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 wc(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],i=t[n];if(a&&ve(a)&&i){const o=wc(a,i);ve(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var ze=e=>ve(e)&&!Object.keys(e).length,bi=e=>e.type==="file",gs=e=>{if(!Fs)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Sc=e=>e.type==="select-multiple",vi=e=>e.type==="radio",af=e=>vi(e)||qn(e),Js=e=>gs(e)&&e.isConnected;function of(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;){if(Me(e)){e=void 0;break}e=e[t[n]],n++}return e}function lf(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function Ee(e,t){if(Ue(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:Vn(t)?[t]:Ds(t);if(r.some(o=>pi.includes(String(o))))return e;const n=r.length===1?e:of(e,r),a=r.length-1,i=r[a];return n&&delete n[i],a!==0&&(ve(n)&&ze(n)||Array.isArray(n)&&lf(n))&&Ee(e,r.slice(0,-1)),e}var cf=e=>{for(const t in e)if(Be(e[t]))return!0;return!1};function kc(e){return Array.isArray(e)||ve(e)&&!cf(e)}function Da(e,t={}){for(const r in e){const n=e[r];kc(n)?(t[r]=Array.isArray(n)?[]:{},Da(n,t[r])):fe(n)||(t[r]=!0)}return t}function Ra(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>Ra(r));return t.some(r=>r!==void 0)?t:void 0}if(ve(e)){const t={};for(const r in e){const n=Ra(e[r]);fe(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function yr(e,t,r){r||(r=Da(t));for(const n in e){const a=e[n];if(kc(a))fe(t)||Fa(r[n])?r[n]=Da(a,Array.isArray(a)?[]:{}):yr(a,Me(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!rt(a,i)}}return Ra(r)||{}}const No={value:!1,isValid:!1},wo={value:!0,isValid:!0};var Cc=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?wo:{value:e[0].value,isValid:!0}:wo:No}return No},Ac=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>fe(e)?e:t?e===""?NaN:e&&+e:r&&Ue(e)?new Date(e):n?n(e):e;const So={isValid:!1,value:null};var Pc=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,So):So;function ko(e){const t=e.ref;return bi(t)?t.files:vi(t)?Pc(e.refs).value:Sc(t)?[...t.selectedOptions].map(({value:r})=>r):qn(t)?Cc(e.refs).value:Ac(fe(t.value)?e.ref.value:t.value,e)}var uf=(e,t,r,n)=>{const a={};for(const i of e){const o=M(t,i);o&&ce(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},ys=e=>e instanceof RegExp,Nn=e=>fe(e)?e:ys(e)?e.source:ve(e)?ys(e.value)?e.value.source:e.value:e,Jn=e=>({isOnSubmit:!e||e===xt.onSubmit,isOnBlur:e===xt.onBlur,isOnChange:e===xt.onChange,isOnAll:e===xt.all,isOnTouch:e===xt.onTouched});const Co="AsyncFunction";var df=e=>{if(!e||!e.validate)return!1;if(Be(e.validate))return e.validate.constructor.name===Co;if(ve(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Co)return!0}return!1},mf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Gs=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const n of t.watch)if(e.startsWith(n)&&e.charAt(n.length)===".")return!0;return!1};const Pn=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const i=M(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(Pn(l,t))break}else if(ve(l)&&Pn(l,t))break}}};function Ao(e,t,r){const n=M(e,r);if(n||Vn(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=M(t,i),l=M(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 hf=(e,t,r,n)=>{r(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||n&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!n||xt.all))},ff=(e,t,r)=>!e||!t||e===t||us(e).some(n=>n&&(r?n===t||n.startsWith(t+"."):n.startsWith(t)||t.startsWith(n))),pf=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,xf=(e,t)=>!Nc(M(e,t)).length&&Ee(e,t),Po=(e,t,r)=>{const n=M(e,r),a=Array.isArray(n)?n:[];return ce(a,yc,t[r]),ce(e,r,a),e};function Eo(e,t,r="validate"){if(Ue(e)||Array.isArray(e)&&e.every(Ue)||tt(e)&&!e)return{type:r,message:Ue(e)?e:"",ref:t}}var qr=e=>ve(e)&&!ys(e)?e:{value:e,message:""},_o=async(e,t,r,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:m,max:h,pattern:f,validate:b,name:p,valueAsNumber:g,mount:y}=e._f,A=M(r,p);if(!y||t.has(p))return{};const j=l?l[0]:o,S=B=>{if(a&&j.reportValidity){const Q=tt(B)?"":B||"";l?l.forEach(te=>te.setCustomValidity(Q)):j.setCustomValidity(Q),j.reportValidity()}},E={},I=vi(o),w=qn(o),F=I||w,D=(g||bi(o))&&fe(o.value)&&fe(A)||gs(o)&&o.value===""||A===""||Array.isArray(A)&&!A.length,$=yi.bind(null,p,n,E),se=(B,Q,te,Y=ft.maxLength,ne=ft.minLength)=>{const xe=B?Q:te;E[p]={type:B?Y:ne,message:xe,ref:o,...$(B?Y:ne,xe)}};if(i?!Array.isArray(A)||!A.length:c&&(!F&&(D||Me(A))||tt(A)&&!A||w&&!Cc(l).isValid||I&&!Pc(l).isValid)){const{value:B,message:Q}=Ue(c)?{value:!!c,message:c}:qr(c);if(B&&(E[p]={type:ft.required,message:Q,ref:j,...$(ft.required,Q)},!n))return S(Q),E}if(!D&&(!Me(m)||!Me(h))){let B,Q;const te=qr(h),Y=qr(m);if(!Me(A)&&!isNaN(A)){const ne=o.valueAsNumber||A&&+A;Me(te.value)||(B=ne>te.value),Me(Y.value)||(Q=ne<Y.value)}else{const ne=o.valueAsDate||new Date(A),xe=Ke=>new Date(new Date().toDateString()+" "+Ke),pe=o.type=="time",$e=o.type=="week";Ue(te.value)&&A&&(B=pe?xe(A)>xe(te.value):$e?A>te.value:ne>new Date(te.value)),Ue(Y.value)&&A&&(Q=pe?xe(A)<xe(Y.value):$e?A<Y.value:ne<new Date(Y.value))}if((B||Q)&&(se(!!B,te.message,Y.message,ft.max,ft.min),!n))return S(E[p].message),E}if((u||d)&&!D&&(Ue(A)||i&&Array.isArray(A))){const B=qr(u),Q=qr(d),te=!Me(B.value)&&A.length>+B.value,Y=!Me(Q.value)&&A.length<+Q.value;if((te||Y)&&(se(te,B.message,Q.message),!n))return S(E[p].message),E}if(f&&!D&&Ue(A)){const{value:B,message:Q}=qr(f);if(ys(B)&&!A.match(B)&&(E[p]={type:ft.pattern,message:Q,ref:o,...$(ft.pattern,Q)},!n))return S(Q),E}if(b){if(Be(b)){const B=await b(A,r),Q=Eo(B,j);if(Q&&(E[p]={...Q,...$(ft.validate,Q.message)},!n))return S(Q.message),E}else if(ve(b)){let B={};for(const Q in b){if(!ze(B)&&!n)break;const te=Eo(await b[Q](A,r),j,Q);te&&(B={...te,...$(Q,te.message)},S(te.message),n&&(E[p]=B))}if(!ze(B)&&(E[p]={ref:j,...B},!n))return E}}return S(!0),E};const gf={mode:xt.onSubmit,reValidateMode:xt.onChange,shouldFocusError:!0},Xs="form",Ec={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function yf(e={}){let t={...gf,...e},r={...we(Ec),isLoading:Be(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},a=ve(t.defaultValues)||ve(t.values)?we(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:we(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0,d=0,m=Jn(t.mode),h=Jn(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={...f};let p={...b};const g={array:jo(),state:jo()},y=t.criteriaMode===xt.all,A=x=>k=>{clearTimeout(u),u=setTimeout(x,k)},j=async x=>{if(!o.keepIsValid&&!t.disabled&&(b.isValid||p.isValid||x)){let k;t.resolver?(k=ze((await Q()).errors),S()):k=await ne({fields:n,onlyCheckValid:!0,eventType:Kt.VALID}),k!==r.isValid&&g.state.next({isValid:k})}},S=(x,k)=>{!t.disabled&&(b.isValidating||b.validatingFields||p.isValidating||p.validatingFields)&&((x||Array.from(l.mount)).forEach(C=>{C&&(k?ce(r.validatingFields,C,k):Ee(r.validatingFields,C))}),g.state.next({validatingFields:r.validatingFields,isValidating:!ze(r.validatingFields)}))},E=()=>{r.dirtyFields=yr(a,i)},I=(x,k=[],C,R,O=!0,U=!0)=>{if(R&&C&&!t.disabled){if(o.action=!0,U&&Array.isArray(M(n,x))){const L=C(M(n,x),R.argA,R.argB);O&&ce(n,x,L)}if(U&&Array.isArray(M(r.errors,x))){const L=C(M(r.errors,x),R.argA,R.argB);O&&ce(r.errors,x,L),xf(r.errors,x)}if((b.touchedFields||p.touchedFields)&&U&&Array.isArray(M(r.touchedFields,x))){const L=C(M(r.touchedFields,x),R.argA,R.argB);O&&ce(r.touchedFields,x,L)}(b.dirtyFields||p.dirtyFields)&&E(),g.state.next({name:x,isDirty:pe(x,k),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ce(i,x,k)},w=(x,k)=>{ce(r.errors,x,k),r.errors={...r.errors},g.state.next({errors:r.errors})},F=x=>{r.errors=x,g.state.next({errors:r.errors,isValid:!1})},D=x=>{const k=Vn(x)?[x]:Ds(x);let C=i,R=a;for(let O=0;O<k.length-1;O++){const U=k[O];if(C=Me(C)?C:C[U],R=Me(R)?R:R[U],C===null&&R!==null)return!0}return!1},$=(x,k,C,R)=>{const O=M(n,x);if(O){if(D(x))return;const U=fe(M(i,x)),L=M(i,x,fe(C)?M(a,x):C);fe(L)||R&&R.defaultChecked||k?ce(i,x,k?L:ko(O._f)):Ge(x,L),o.mount&&!o.action&&(j(),U&&r.isDirty&&(b.isDirty||p.isDirty)&&(pe()||(r.isDirty=!1,g.state.next({...r}))),e.shouldUnregister&&U&&!fe(M(i,x))&&Gs(x,l)&&(o.watch=!0))}},se=(x,k,C,R,O)=>{let U=!1,L=!1;const Z={name:x};if(!t.disabled){if(!C||R){const z=rt(M(a,x),k);(b.isDirty||p.isDirty)&&(L=r.isDirty,r.isDirty=Z.isDirty=!z||pe(),U=L!==Z.isDirty),L=!!M(r.dirtyFields,x),z!==r.isDirty?r.dirtyFields=yr(a,i):z?Ee(r.dirtyFields,x):ce(r.dirtyFields,x,!0),Z.dirtyFields=r.dirtyFields,U=U||(b.dirtyFields||p.dirtyFields)&&L!==!z}if(C){const z=M(r.touchedFields,x);z||(ce(r.touchedFields,x,C),Z.touchedFields=r.touchedFields,U=U||(b.touchedFields||p.touchedFields)&&z!==C)}U&&O&&g.state.next(Z)}return U?Z:{}},B=(x,k,C,R)=>{const O=M(r.errors,x),U=(b.isValid||p.isValid)&&tt(k)&&r.isValid!==k;if(t.delayError&&C?(c=A(()=>w(x,C)),c(t.delayError)):(clearTimeout(u),c=null,C?ce(r.errors,x,C):Ee(r.errors,x),r.errors={...r.errors}),(C?!rt(O,C):O)||!ze(R)||U){const L={...R,...U&&tt(k)?{isValid:k}:{},errors:r.errors,name:x};r={...r,...L},g.state.next(L)}},Q=async x=>(S(x,!0),await t.resolver(i,t.context,uf(x||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),te=async x=>{const{errors:k}=await Q(x);if(S(x),x){for(const C of x){const R=M(k,C);R?l.array.has(C)&&ve(R)&&!Object.keys(R).some(O=>!Number.isNaN(Number(O)))?Po(r.errors,{[C]:R},C):ce(r.errors,C,R):Ee(r.errors,C)}r.errors={...r.errors}}else r.errors=k;return k},Y=async({name:x,eventType:k})=>{if(e.validate){const C=await e.validate({formValues:i,formState:r,name:x,eventType:k});if(ve(C))for(const R in C){const O=C[R];O&&ht(`${Xs}.${R}`,{message:Ue(O.message)?O.message:"",type:O.type||ft.validate})}else Ue(C)||!C?ht(Xs,{message:C||"",type:ft.validate}):Ie(Xs);return C}return!0},ne=async({fields:x,onlyCheckValid:k,name:C,eventType:R,context:O={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(O.runRootValidation=!0,!await Y({name:C,eventType:R})&&(O.valid=!1,k)))return O.valid;for(const U in x){const L=x[U];if(L){const{_f:Z,...z}=L;if(Z){const ee=l.array.has(Z.name),Fe=L._f&&df(L._f),Ft=b.validatingFields||b.isValidating||p.validatingFields||p.isValidating;Fe&&Ft&&S([Z.name],!0);const Dt=await _o(L,l.disabled,i,y,t.shouldUseNativeValidation&&!k,ee);if(Fe&&Ft&&S([Z.name]),Dt[Z.name]&&(O.valid=!1,k)||(!k&&(M(Dt,Z.name)?ee?Po(r.errors,Dt,Z.name):ce(r.errors,Z.name,Dt[Z.name]):Ee(r.errors,Z.name)),e.shouldUseNativeValidation&&Dt[Z.name]))break}!ze(z)&&await ne({context:O,onlyCheckValid:k,fields:z,name:U,eventType:R})}}return O.valid},xe=()=>{for(const x of l.unMount){const k=M(n,x);k&&(k._f.refs?k._f.refs.every(C=>!Js(C)):!Js(k._f.ref))&&_t(x)}l.unMount=new Set},pe=(x,k)=>!t.disabled&&(x&&k&&ce(i,x,k),!rt(o.mount?i:a,a)),$e=(x,k,C)=>Ia(x,l,{...o.mount?i:fe(k)?a:Ue(x)?{[x]:k}:k},C,k),Ke=x=>Nc(M(o.mount?i:a,x,t.shouldUnregister?M(a,x,[]):[])),Ge=(x,k,C={},R=!1,O=!1)=>{const U=M(n,x);let L=k;if(U){const Z=U._f;Z&&(!Z.disabled&&ce(i,x,Ac(k,Z)),L=gs(Z.ref)&&Me(k)?"":k,Sc(Z.ref)?[...Z.ref.options].forEach(z=>z.selected=L.includes(z.value)):Z.refs?qn(Z.ref)?Z.refs.forEach(z=>{(!z.defaultChecked||!z.disabled)&&(Array.isArray(L)?z.checked=!!L.find(ee=>ee===z.value):z.checked=L===z.value||!!L)}):Z.refs.forEach(z=>z.checked=z.value===L):bi(Z.ref)?Z.ref.value="":(Z.ref.value=L,!Z.ref.type&&!O&&g.state.next({name:x,values:R?i:we(i)})))}(C.shouldDirty||C.shouldTouch)&&se(x,L,C.shouldTouch,C.shouldDirty,!O),C.shouldValidate&&mt(x)},oe=(x,k,C,R=!1,O=!1)=>{for(const U in k){if(!k.hasOwnProperty(U))return;const L=k[U],Z=x+"."+U,z=M(n,Z);(l.array.has(x)||ve(L)||z&&!z._f)&&!ar(L)?oe(Z,L,C,R,O):Ge(Z,L,C,R,O)}},Pe=(x,k,C,R,O=!1)=>{const U=M(n,x),L=l.array.has(x),Z=R?k:we(k),z=M(i,x),ee=rt(z,Z);if(ee||ce(i,x,Z),L)g.array.next({name:x,values:R?i:we(i)}),(b.isDirty||b.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&(E(),O||g.state.next({name:x,dirtyFields:r.dirtyFields,isDirty:pe(x,Z)}));else{const Fe=Array.isArray(Z)&&!Z.length||ze(Z);!U||U._f||Me(Z)||Fe?Ge(x,Z,C,R,O):oe(x,Z,C,R,O)}if(!ee&&!O){const Fe=Gs(x,l),Ft=R?i:we(i);g.state.next({...Fe&&r,name:o.mount||Fe?x:void 0,values:Ft})}},_e=(x,k,C={})=>Pe(x,k,C,!1),H=(x,k={})=>{const C=Be(x)?x(i):x;if(!rt(i,C)){i={...i,...C};const R=jc(C);for(const O of l.mount)O in R&&Pe(O,R[O],k,!0,!0);g.state.next({...r,name:void 0,type:void 0,...d?{values:i}:{}}),k.shouldValidate&&j()}},Le=async x=>{o.mount=!0;const k=x.target;let C=k.name,R=!0;const O=M(n,C),U=L=>{R=Number.isNaN(L)||ar(L)&&isNaN(L.getTime())||rt(L,M(i,C,L))};if(O){let L,Z;const z=k.type?ko(O._f):Ta(x),ee=x.type===Kt.BLUR||x.type===Kt.FOCUS_OUT,Fe=!mf(O._f)&&!e.validate&&!t.resolver&&!M(r.errors,C)&&!O._f.deps,Ft=Fe||pf(ee,M(r.touchedFields,C),r.isSubmitted,h,m),Dt=Gs(C,l,ee);ce(i,C,z),ee?(!k||!k.readOnly)&&(O._f.onBlur&&O._f.onBlur(x),c&&c(0)):O._f.onChange&&O._f.onChange(x);const bn=se(C,z,ee),Hu=!ze(bn)||Dt;if(!ee&&g.state.next({name:C,type:x.type,...d?{values:we(i)}:{}}),Ft)return(!Fe||!r.isValid)&&(b.isValid||p.isValid)&&(t.mode==="onBlur"?ee&&j():ee||j()),Hu&&g.state.next({name:C,...Dt?{}:bn});if(!t.resolver&&e.validate&&await Y({name:C,eventType:x.type}),!ee&&Dt&&g.state.next({...r}),t.resolver){const{errors:Xi}=await Q([C]);if(S([C]),U(z),!R){!ze(bn)&&g.state.next(bn);return}const Ku=Ao(r.errors,n,C),eo=Ao(Xi,n,Ku.name||C);L=eo.error,C=eo.name,Z=ze(Xi)}else S([C],!0),L=(await _o(O,l.disabled,i,y,t.shouldUseNativeValidation))[C],S([C]),U(z),R&&(L?Z=!1:(b.isValid||p.isValid)&&(Z=await ne({fields:n,onlyCheckValid:!0,name:C,eventType:x.type})));R&&(O._f.deps&&(!Array.isArray(O._f.deps)||O._f.deps.length>0)&&mt(O._f.deps),B(C,Z,L,bn))}},dt=(x,k)=>{if(M(r.errors,k)&&x.focus)return x.focus(),1},mt=async(x,k={})=>{let C,R;const O=us(x);if(t.resolver){const U=await te(fe(x)?x:O);C=ze(U),R=x?!O.some(L=>M(U,L)):C}else x?(R=(await Promise.all(O.map(async U=>{const L=M(n,U);return await ne({fields:L&&L._f?{[U]:L}:L,eventType:Kt.TRIGGER})}))).every(Boolean),!(!R&&!r.isValid)&&j()):R=C=await ne({fields:n,name:x,eventType:Kt.TRIGGER});return g.state.next({...!Ue(x)||(b.isValid||p.isValid)&&C!==r.isValid?{}:{name:x},...t.resolver||!x?{isValid:C}:{},errors:r.errors}),k.shouldFocus&&!R&&Pn(n,dt,x?O:l.mount),R},Pt=(x,k)=>{let C={...o.mount?i:a};return k&&(C=wc(k.dirtyFields?r.dirtyFields:r.touchedFields,C)),fe(x)?C:Ue(x)?M(C,x):x.map(R=>M(C,R))},le=(x,k)=>({invalid:!!M((k||r).errors,x),isDirty:!!M((k||r).dirtyFields,x),error:M((k||r).errors,x),isValidating:!!M(r.validatingFields,x),isTouched:!!M((k||r).touchedFields,x)}),Ie=x=>{const k=x?us(x):void 0;k==null||k.forEach(C=>Ee(r.errors,C)),k?k.forEach(C=>{g.state.next({name:C,errors:r.errors})}):g.state.next({errors:{}})},ht=(x,k,C)=>{const R=(M(n,x,{_f:{}})._f||{}).ref,O=M(r.errors,x)||{},{ref:U,message:L,type:Z,...z}=O;ce(r.errors,x,{...z,...k,ref:R}),g.state.next({name:x,errors:r.errors,isValid:!1}),C&&C.shouldFocus&&R&&R.focus&&R.focus()},Et=(x,k)=>{if(Be(x)){d++;const{unsubscribe:C}=g.state.subscribe({next:O=>"values"in O&&x(O.values||$e(void 0,k),O)});let R=!1;return{unsubscribe:()=>{R||(R=!0,d--,C())}}}return $e(x,k,!0)},yt=x=>{var k;const C=!!(!((k=x.formState)===null||k===void 0)&&k.values);C&&d++;const{unsubscribe:R}=g.state.subscribe({next:U=>{if(ff(x.name,U.name,x.exact)&&hf(U,x.formState||b,xr,x.reRenderRoot)){const L={...i};x.callback({values:L,...r,...U,defaultValues:a})}}});if(!C)return R;let O=!1;return()=>{O||(O=!0,d--,R())}},mr=x=>(o.mount=!0,p={...p,...x.formState},yt({...x,formState:{...f,...x.formState}})),_t=(x,k={})=>{for(const C of x?us(x):l.mount)l.mount.delete(C),l.array.delete(C),k.keepValue||(Ee(n,C),Ee(i,C)),!k.keepError&&Ee(r.errors,C),!k.keepDirty&&Ee(r.dirtyFields,C),!k.keepTouched&&Ee(r.touchedFields,C),!k.keepIsValidating&&Ee(r.validatingFields,C),!t.shouldUnregister&&!k.keepDefaultValue&&Ee(a,C);g.state.next({values:we(i)}),g.state.next({...r,...k.keepDirty?{isDirty:pe()}:{}}),!k.keepIsValid&&j()},Ut=({disabled:x,name:k})=>{if(tt(x)&&o.mount||x||l.disabled.has(k)){const O=l.disabled.has(k)!==!!x;x?l.disabled.add(k):l.disabled.delete(k),O&&o.mount&&!o.action&&j()}},Tt=(x,k={})=>{let C=M(n,x);const R=tt(k.disabled)||tt(t.disabled),O=!l.registerName.has(x)&&C&&C._f&&!C._f.mount;return ce(n,x,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:x}},name:x,mount:!0,...k}}),l.mount.add(x),C&&!O?Ut({disabled:tt(k.disabled)?k.disabled:t.disabled,name:x}):$(x,!0,k.value),{...R?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:Nn(k.min),max:Nn(k.max),minLength:Nn(k.minLength),maxLength:Nn(k.maxLength),pattern:Nn(k.pattern)}:{},name:x,onChange:Le,onBlur:Le,ref:U=>{if(U){l.registerName.add(x),Tt(x,k),l.registerName.delete(x),C=M(n,x);const L=fe(U.value)&&U.querySelectorAll&&U.querySelectorAll("input,select,textarea")[0]||U,Z=af(L),z=C._f.refs||[];if(Z?z.find(ee=>ee===L):L===C._f.ref)return;ce(n,x,{_f:{...C._f,...Z?{refs:[...z.filter(Js),L,...Array.isArray(M(a,x))?[{}]:[]],ref:{type:L.type,name:x}}:{ref:L}}}),$(x,!1,void 0,L)}else C=M(n,x,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(xc(l.array,x)&&o.action)&&l.unMount.add(x)}}},It=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Pn(n,dt,l.mount),hr=x=>{tt(x)&&(g.state.next({disabled:x}),Pn(n,(k,C)=>{const R=M(n,C);R&&(k.disabled=R._f.disabled||x,Array.isArray(R._f.refs)&&R._f.refs.forEach(O=>{O.disabled=R._f.disabled||x}))},0,!1))},Zt=(x,k)=>async C=>{let R;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let O=we(i);if(g.state.next({isSubmitting:!0}),t.resolver){const{errors:U,values:L}=await Q();S(),r.errors=U,O=we(L)}else await ne({fields:n,eventType:Kt.SUBMIT});if(l.disabled.size)for(const U of l.disabled)Ee(O,U);if(Ee(r.errors,yc),ze(r.errors)){g.state.next({errors:{}});try{await x(O,C)}catch(U){R=U}}else k&&await k({...r.errors},C),It(),setTimeout(It);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ze(r.errors)&&!R,submitCount:r.submitCount+1,errors:r.errors}),R)throw R},fr=(x,k={})=>{M(n,x)&&(fe(k.defaultValue)?_e(x,we(M(a,x))):(_e(x,k.defaultValue),ce(a,x,we(k.defaultValue))),k.keepTouched||Ee(r.touchedFields,x),k.keepDirty||(Ee(r.dirtyFields,x),r.isDirty=k.defaultValue?pe(x,we(M(a,x))):pe()),k.keepError||(Ee(r.errors,x),b.isValid&&j()),g.state.next({...r}))},Wt=(x,k={})=>{const C=x?we(x):a,R=we(C),O=ze(x),U=R;if(k.keepDefaultValues||(a=C),!k.keepValues){if(k.keepDirtyValues){const L=new Set([...l.mount,...Object.keys(yr(a,i))]);for(const Z of Array.from(L)){const z=M(r.dirtyFields,Z),ee=M(i,Z),Fe=M(U,Z);z&&!fe(ee)?ce(U,Z,ee):!z&&!fe(Fe)&&_e(Z,Fe)}}else{if(Fs&&fe(x))for(const L of l.mount){const Z=M(n,L);if(Z&&Z._f){const z=Array.isArray(Z._f.refs)?Z._f.refs[0]:Z._f.ref;if(gs(z)){const ee=z.closest("form");if(ee){ee.reset();break}}}}if(k.keepFieldsRef)for(const L of l.mount)_e(L,M(U,L));else n={}}if(t.shouldUnregister){if(i=k.keepDefaultValues?we(a):{},k.keepFieldsRef)for(const L of l.mount)ce(i,L,M(U,L))}else i=we(U);g.array.next({values:{...U}}),g.state.next({name:void 0,type:void 0,values:{...U}})}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=!b.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!ze(U),o.watch=!!t.shouldUnregister,o.keepIsValid=!!k.keepIsValid,o.action=!1,k.keepErrors||(r.errors={}),g.state.next({submitCount:k.keepSubmitCount?r.submitCount:0,isDirty:O?!1:k.keepDirty?r.isDirty:k.keepValues?pe():!!(k.keepDefaultValues&&!rt(x,a)),isSubmitted:k.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:O?{}:k.keepDirtyValues?k.keepDefaultValues&&i?yr(a,i):r.dirtyFields:k.keepDefaultValues&&x?yr(a,x):k.keepDirty?r.dirtyFields:{},touchedFields:k.keepTouched?r.touchedFields:{},errors:k.keepErrors?r.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Yt=(x,k)=>Wt(Be(x)?x(i):x,{...t.resetOptions,...k}),pr=(x,k={})=>{const C=M(n,x),R=C&&C._f;if(R){const O=R.refs?R.refs[0]:R.ref;O.focus&&setTimeout(()=>{O.focus(),k.shouldSelect&&Be(O.select)&&O.select()})}},xr=x=>{const{name:k,type:C,values:R,...O}=x;r={...r,...O}},ae={control:{register:Tt,unregister:_t,getFieldState:le,handleSubmit:Zt,setError:ht,_subscribe:yt,_runSchema:Q,_updateIsValidating:S,_focusError:It,_getWatch:$e,_getDirty:pe,_setValid:j,_setFieldArray:I,_setDisabledField:Ut,_setErrors:F,_getFieldArray:Ke,_reset:Wt,_resetDefaultValues:()=>Be(t.defaultValues)&&t.defaultValues().then(x=>{Yt(x,t.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:xe,_disableForm:hr,_subjects:g,_proxyFormState:b,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(x){o=x},get _defaultValues(){return a},get _names(){return l},set _names(x){l=x},get _formState(){return r},get _options(){return t},set _options(x){t={...t,...x},m=Jn(t.mode),h=Jn(t.reValidateMode)}},subscribe:mr,trigger:mt,register:Tt,handleSubmit:Zt,watch:Et,setValue:_e,setValues:H,getValues:Pt,reset:Yt,resetField:fr,resetDefaultValues:(x,k={})=>{if(a=we(x),!k.keepDirty){const C=yr(a,i);r.dirtyFields=C,r.isDirty=!ze(C)}k.keepIsValid||j(),g.state.next({...r,defaultValues:a})},clearErrors:Ie,unregister:_t,setError:ht,setFocus:pr,getFieldState:le};return{...ae,formControl:ae}}function St(e={}){const t=N.useRef(void 0),r=N.useRef(void 0),n=N.useRef(e.formControl),[a,i]=N.useState(()=>({...we(Ec),isLoading:Be(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Be(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Be(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=yf(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,gi(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,l},[o]),N.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),N.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),N.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),N.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),N.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),N.useEffect(()=>{var l;e.values&&!rt(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),N.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=N.useMemo(()=>vc(a,o),[o,a]),t.current}const To=(e,t,r)=>{if(e&&"reportValidity"in e){const n=M(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},Oa=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?To(n.ref,r,e):n&&n.refs&&n.refs.forEach(a=>To(a,r,e))}},Io=(e,t)=>{t.shouldUseNativeValidation&&Oa(e,t);const r={};for(const n in e){const a=M(t.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(bf(t.names||Object.keys(e),n)){const o=Object.assign({},M(r,n));ce(o,"root",i),ce(r,n,o)}else ce(r,n,i)}return r},bf=(e,t)=>{const r=Fo(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(n=>Fo(n).match(`^${r}\\.\\d+`))};function Fo(e){return e.replace(/[\[\]]/g,"")}var Do;function T(e,t,r){function n(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=o.prototype,d=Object.keys(u);for(let m=0;m<d.length;m++){const h=d[m];h in l||(l[h]=u[h].bind(l))}}const a=(r==null?void 0:r.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const u=r!=null&&r.Parent?new i:this;n(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,u;return r!=null&&r.Parent&&l instanceof r.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Zr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class _c extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Do=globalThis).__zod_globalConfig??(Do.__zod_globalConfig={});const ji=globalThis.__zod_globalConfig;function Ir(e){return ji}function Tc(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function $a(e,t){return typeof t=="bigint"?t.toString():t}function Ni(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wi(e){return e==null}function Si(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const Ro=Symbol("evaluating");function me(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ro)return n===void 0&&(n=Ro,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Lr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function cr(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Oo(e){return JSON.stringify(e)}function vf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ic="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function bs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const jf=Ni(()=>{var e;if(ji.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 In(e){if(bs(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(bs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Fc(e){return In(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Nf=new Set(["string","number","symbol"]);function cn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ur(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function X(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 wf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Sf(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=cr(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=r.shape[l])}return Lr(this,"shape",o),o},checks:[]});return ur(e,i)}function kf(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=cr(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Lr(this,"shape",o),o},checks:[]});return ur(e,i)}function Cf(e,t){if(!In(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=cr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Lr(this,"shape",i),i}});return ur(e,a)}function Af(e,t){if(!In(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=cr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Lr(this,"shape",n),n}});return ur(e,r)}function Pf(e,t){var n;if((n=e._zod.def.checks)!=null&&n.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const r=cr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Lr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ur(e,r)}function Ef(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=cr(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(r)for(const u in r){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return Lr(this,"shape",c),c},checks:[]});return ur(t,o)}function _f(e,t,r){const n=cr(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return Lr(this,"shape",i),i}});return ur(t,n)}function Br(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)!==!0)return!0;return!1}function Tf(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)===!1)return!0;return!1}function Dc(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Gn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Fr(e,t,r){var c,u,d,m,h,f;const n=e.message?e.message:Gn((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??Gn((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??Gn((h=r.customError)==null?void 0:h.call(r,e))??Gn((f=r.localeError)==null?void 0:f.call(r,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=n,t!=null&&t.reportInput&&(l.input=o),l}function ki(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Rc=(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,$a,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ci=T("$ZodError",Rc),Rs=T("$ZodError",Rc,{Parent:Error});function If(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function Ff(e,t=r=>r.message){const r={_errors:[]},n=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>n({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")n({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")n({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)r._errors.push(t(o));else{let c=r,u=0;for(;u<l.length;){const d=l[u];u===l.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return n(e),r}const Os=e=>(t,r,n,a)=>{const i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Zr;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Ic(l,a==null?void 0:a.callee),l}return o.value},Df=Os(Rs),$s=e=>async(t,r,n,a)=>{const i=n?{...n,async:!0}:{async:!0};let o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Ic(l,a==null?void 0:a.callee),l}return o.value},Rf=$s(Rs),Ls=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Zr;return i.issues.length?{success:!1,error:new(e??Ci)(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},Of=Ls(Rs),zs=e=>async(t,r,n)=>{const a=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},$f=zs(Rs),Lf=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Os(e)(t,r,a)},zf=e=>(t,r,n)=>Os(e)(t,r,n),Mf=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return $s(e)(t,r,a)},qf=e=>async(t,r,n)=>$s(e)(t,r,n),Vf=e=>(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return Ls(e)(t,r,a)},Bf=e=>(t,r,n)=>Ls(e)(t,r,n),Uf=e=>async(t,r,n)=>{const a=n?{...n,direction:"backward"}:{direction:"backward"};return zs(e)(t,r,a)},Zf=e=>async(t,r,n)=>zs(e)(t,r,n),Wf=/^[cC][0-9a-z]{6,}$/,Yf=/^[0-9a-z]+$/,Hf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Kf=/^[0-9a-vA-V]{20}$/,Qf=/^[A-Za-z0-9]{27}$/,Jf=/^[a-zA-Z0-9_-]{21}$/,Gf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Xf=/^([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})$/,$o=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)$/,ep=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rp(){return new RegExp(tp,"u")}const np=/^(?:(?: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])$/,sp=/^(([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}|:))$/,ap=/^((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])$/,ip=/^(([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])$/,op=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Oc=/^[A-Za-z0-9_-]*$/,lp=/^https?$/,cp=/^\+[1-9]\d{6,14}$/,$c="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",up=new RegExp(`^${$c}$`);function Lc(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 dp(e){return new RegExp(`^${Lc(e)}$`)}function mp(e){const t=Lc({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${$c}T(?:${n})$`)}const hp=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}$`)},fp=/^(?:true|false)$/i,pp=/^[^A-Z]*$/,xp=/^[^a-z]*$/,kt=T("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),gp=T("$ZodCheckMaxLength",(e,t)=>{var r;kt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!wi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const o=ki(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),yp=T("$ZodCheckMinLength",(e,t)=>{var r;kt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!wi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const o=ki(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),bp=T("$ZodCheckLengthEquals",(e,t)=>{var r;kt.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!wi(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,i=a.length;if(i===t.length)return;const o=ki(a),l=i>t.length;n.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ms=T("$ZodCheckStringFormat",(e,t)=>{var r,n;kt.init(e,t),e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),vp=T("$ZodCheckRegex",(e,t)=>{Ms.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})}}),jp=T("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pp),Ms.init(e,t)}),Np=T("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xp),Ms.init(e,t)}),wp=T("$ZodCheckIncludes",(e,t)=>{kt.init(e,t);const r=cn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Sp=T("$ZodCheckStartsWith",(e,t)=>{kt.init(e,t);const r=new RegExp(`^${cn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),kp=T("$ZodCheckEndsWith",(e,t)=>{kt.init(e,t);const r=new RegExp(`.*${cn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Cp=T("$ZodCheckOverwrite",(e,t)=>{kt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Ap{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
13
- `).filter(o=>o),a=Math.min(...n.map(o=>o.length-o.trimStart().length)),i=n.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,r=this==null?void 0:this.args,a=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...r,a.join(`
14
- `))}}const Pp={major:4,minor:4,patch:3},Ce=T("$ZodType",(e,t)=>{var a;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pp;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const i of n)for(const o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,u)=>{let d=Br(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,b=h._zod.check(l);if(b instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Zr;if(m||b instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await b,l.issues.length!==f&&(d||(d=Br(l,f)))});else{if(l.issues.length===f)continue;d||(d=Br(l,f))}}return m?m.then(()=>l):l},o=(l,c,u)=>{if(Br(l))return l.aborted=!0,l;const d=i(c,n,u);if(d instanceof Promise){if(u.async===!1)throw new Zr;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 Zr;return u.then(d=>i(d,n,c))}return i(u,n,c)}}me(e,"~standard",()=>({validate:i=>{var o;try{const l=Of(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return $f(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}))}),Ai=T("$ZodString",(e,t)=>{var r;Ce.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??hp(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),be=T("$ZodStringFormat",(e,t)=>{Ms.init(e,t),Ai.init(e,t)}),Ep=T("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Xf),be.init(e,t)}),_p=T("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$o(n))}else t.pattern??(t.pattern=$o());be.init(e,t)}),Tp=T("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ep),be.init(e,t)}),Ip=T("$ZodURL",(e,t)=>{be.init(e,t),e._zod.check=r=>{var n;try{const a=r.value.trim();if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===lp.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})}}}),Fp=T("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rp()),be.init(e,t)}),Dp=T("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jf),be.init(e,t)}),Rp=T("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Wf),be.init(e,t)}),Op=T("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yf),be.init(e,t)}),$p=T("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hf),be.init(e,t)}),Lp=T("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Kf),be.init(e,t)}),zp=T("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qf),be.init(e,t)}),Mp=T("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=mp(t)),be.init(e,t)}),qp=T("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=up),be.init(e,t)}),Vp=T("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=dp(t)),be.init(e,t)}),Bp=T("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Gf),be.init(e,t)}),Up=T("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=np),be.init(e,t),e._zod.bag.format="ipv4"}),Zp=T("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sp),be.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})}}}),Wp=T("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ap),be.init(e,t)}),Yp=T("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ip),be.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function zc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Hp=T("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=op),be.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{zc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Kp(e){if(!Oc.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return zc(r)}const Qp=T("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Oc),be.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Kp(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Jp=T("$ZodE164",(e,t)=>{t.pattern??(t.pattern=cp),be.init(e,t)});function Gp(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const a=JSON.parse(atob(n));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const Xp=T("$ZodJWT",(e,t)=>{be.init(e,t),e._zod.check=r=>{Gp(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ex=T("$ZodBoolean",(e,t)=>{Ce.init(e,t),e._zod.pattern=fp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const a=r.value;return typeof a=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),r}}),tx=T("$ZodUnknown",(e,t)=>{Ce.init(e,t),e._zod.parse=r=>r}),rx=T("$ZodNever",(e,t)=>{Ce.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Lo(e,t,r){e.issues.length&&t.issues.push(...Dc(r,e.issues)),t.value[r]=e.value}const nx=T("$ZodArray",(e,t)=>{Ce.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=Array(a.length);const i=[];for(let o=0;o<a.length;o++){const l=a[o],c=t.element._zod.run({value:l,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Lo(u,r,o))):Lo(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function vs(e,t,r,n,a,i){const o=r in n;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Dc(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 Mc(e){var n,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(n=e.shape)==null?void 0:n[l])==null?void 0:a._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const r=wf(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function qc(e,t,r,n,a,i){const o=[],l=a.keySet,c=a.catchall._zod,u=c.def.type,d=c.optin==="optional",m=c.optout==="optional";for(const h in t){if(h==="__proto__"||l.has(h))continue;if(u==="never"){o.push(h);continue}const f=c.run({value:t[h],issues:[]},n);f instanceof Promise?e.push(f.then(b=>vs(b,r,h,t,d,m))):vs(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 sx=T("$ZodObject",(e,t)=>{Ce.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!(r!=null&&r.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=Ni(()=>Mc(t));me(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const d=l[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const m of d.values)c[u].add(m)}}return c});const a=bs,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=n.value);const u=l.value;if(!a(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const d=[],m=o.shape;for(const h of o.keys){const f=m[h],b=f._zod.optin==="optional",p=f._zod.optout==="optional",g=f._zod.run({value:u[h],issues:[]},c);g instanceof Promise?d.push(g.then(y=>vs(y,l,h,u,b,p))):vs(g,l,h,u,b,p)}return i?qc(d,u,l,c,n.value,e):d.length?Promise.all(d).then(()=>l):l}}),ax=T("$ZodObjectJIT",(e,t)=>{sx.init(e,t);const r=e._zod.parse,n=Ni(()=>Mc(t)),a=h=>{var j,S;const f=new Ap(["shape","payload","ctx"]),b=n.value,p=E=>{const I=Oo(E);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};f.write("const input = payload.value;");const g=Object.create(null);let y=0;for(const E of b.keys)g[E]=`key_${y++}`;f.write("const newResult = {};");for(const E of b.keys){const I=g[E],w=Oo(E),F=h[E],D=((j=F==null?void 0:F._zod)==null?void 0:j.optin)==="optional",$=((S=F==null?void 0:F._zod)==null?void 0:S.optout)==="optional";f.write(`const ${I} = ${p(E)};`),D&&$?f.write(`
15
- if (${I}.issues.length) {
16
- if (${w} in input) {
17
- payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
12
+ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let d=ge(),m;if(t){let y=typeof t=="string"?Or(t):t;je(c==="/"||((x=y.pathname)==null?void 0:x.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${y.pathname}" was given in the \`location\` prop.`),m=y}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let y=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(y.length).join("/")}let b=r&&r.state.matches.length?r.state.matches.map(y=>Object.assign(y,{route:r.manifest[y.route.id]||y.route})):El(e,{pathname:f});st(u||b!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),st(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.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(b&&b.map(y=>Object.assign({},y,{params:Object.assign({},o,y.params),pathname:gt([c,s.encodeLocation?s.encodeLocation(y.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:gt([c,s.encodeLocation?s.encodeLocation(y.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),a,r);return t&&p?A.createElement(zn.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=A.createElement(A.Fragment,null,A.createElement("p",null,"💿 Hey developer 👋"),A.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",A.createElement("code",{style:i},"ErrorBoundary")," or"," ",A.createElement("code",{style:i},"errorElement")," prop on your route.")),A.createElement(A.Fragment,null,A.createElement("h2",null,"Unexpected Application Error!"),A.createElement("h3",{style:{fontStyle:"italic"}},t),r?A.createElement("pre",{style:a},r):null,o)}var Vd=A.createElement(qd,null),Zl=class extends A.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const r=Od(e.digest);r&&(e=r)}let t=e!==void 0?A.createElement(lt.Provider,{value:this.props.routeContext},A.createElement(ei.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?A.createElement(Bd,{error:e},t):t}};Zl.contextType=Ll;var Qs=new WeakMap;function Bd({children:e,error:t}){let{basename:r}=A.useContext(at);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=Rd(t.digest);if(s){let a=Qs.get(t);if(a)throw a;let i=Ol(s.location,r),o=i.absoluteURL||i.to;if(Ed(o))throw new Error("Invalid redirect location");if(Rl&&!Qs.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 Qs.set(t,l),l}return A.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Ud({routeContext:e,match:t,children:r}){let s=A.useContext(hn);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(lt.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);je(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,b=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||b){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,b=!1,p=null,x=null;s&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Vd,o&&(l<0&&h===0?(Wl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,x=null):l===h&&(b=!0,x=m.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,h+1)),k=()=>{let j;return f?j=p:b?j=x:m.route.Component?j=A.createElement(m.route.Component,null):m.route.element?j=m.route.element:j=d,A.createElement(Ud,{match:m,routeContext:{outlet:d,matches:y,isDataRoute:s!=null},children:j})};return s&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?A.createElement(Zl,{location:s.location,revalidation:s.revalidation,component:p,error:f,children:k(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):k()},null)}function ri(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=A.useContext(hn);return je(t,ri(e)),t}function Yd(e){let t=A.useContext(Es);return je(t,ri(e)),t}function Hd(e){let t=A.useContext(lt);return je(t,ri(e)),t}function ni(e){let t=Hd(e),r=t.matches[t.matches.length-1];return je(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function Kd(){return ni("useRouteId")}function Qd(){var s;let e=A.useContext(ei),t=Yd("useRouteError"),r=ni("useRouteError");return e!==void 0?e:(s=t.errors)==null?void 0:s[r]}function Jd(){let{router:e}=Wd("useNavigate"),t=ni("useNavigate"),r=A.useRef(!1);return Vl(()=>{r.current=!0}),A.useCallback(async(a,i={})=>{st(r.current,ql),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var oo={};function Wl(e,t,r){!t&&!oo[e]&&(oo[e]=!0,st(!1,r))}A.memo(Gd);function Gd({routes:e,manifest:t,future:r,state:s,isStatic:a,onError:i}){return Ul(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=A.useRef();i.current==null&&(i.current=nd({initialEntries:r,initialIndex:s,v5Compat:!0}));let o=i.current,[l,c]=A.useState({action:o.action,location:o.location}),u=A.useCallback(d=>{a===!1?c(d):A.startTransition(()=>c(d))},[a]);return A.useLayoutEffect(()=>o.listen(u),[o,u]),A.createElement(tm,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Oe({to:e,replace:t,state:r,relative:s}){je(fn(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=A.useContext(at);st(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:i}=A.useContext(lt),{pathname:o}=ge(),l=ye(),c=Ps(e,Xa(i),o,s==="path"),u=JSON.stringify(c);return A.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 ee(e){je(!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}){je(!fn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=A.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof r=="string"&&(r=Or(r));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:b}=r,p=A.useMemo(()=>{let x=qt(u,l);return x==null?null:{location:{pathname:x,search:d,hash:m,state:h,key:f,mask:b},navigationType:s}},[l,u,d,m,h,f,s,b]);return st(p!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${m}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:A.createElement(at.Provider,{value:c},A.createElement(zn.Provider,{children:t,value:p}))}function si({children:e,location:t}){return Md(fa(e),t)}function fa(e,t=[]){let r=[];return A.Children.forEach(e,(s,a)=>{if(!A.isValidElement(s))return;let i=[...t,a];if(s.type===A.Fragment){r.push.apply(r,fa(s.props.children,i));return}je(s.type===ee,`[${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>`),je(!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=fa(s.props.children,i)),r.push(o)}),r}var ls="get",cs="application/x-www-form-urlencoded";function _s(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function rm(e){return _s(e)&&e.tagName.toLowerCase()==="button"}function nm(e){return _s(e)&&e.tagName.toLowerCase()==="form"}function sm(e){return _s(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 pa(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=pa(e);return t&&t.forEach((s,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}var Kn=null;function lm(){if(Kn===null)try{new FormData(document.createElement("form"),0),Kn=!1}catch{Kn=!0}return Kn}var cm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Js(e){return e!=null&&!cm.has(e)?(st(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${cs}"`),null):e}function um(e,t){let r,s,a,i,o;if(nm(e)){let l=e.getAttribute("action");s=l?qt(l,t):null,r=e.getAttribute("method")||ls,a=Js(e.getAttribute("enctype"))||cs,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?qt(c,t):null,r=e.getAttribute("formmethod")||l.getAttribute("method")||ls,a=Js(e.getAttribute("formenctype"))||Js(l.getAttribute("enctype"))||cs,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(_s(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=ls,s=null,a=cs,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 ai(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Yl(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&&qt(a.pathname,t)==="/"?a.pathname=`${fs(t)}/_root.${s}`:a.pathname=`${fs(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 lo(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 ii(){let e=A.useContext(hn);return ai(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ym(){let e=A.useContext(Es);return ai(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var oi=A.createContext(void 0);oi.displayName="FrameworkContext";function Ts(){let e=A.useContext(oi);return ai(e,"You must render this element inside a <HydratedRouter> element"),e}function bm(e,t){let r=A.useContext(oi),[s,a]=A.useState(!1),[i,o]=A.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:m}=t,h=A.useRef(null);A.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let p=y=>{y.forEach(k=>{o(k.isIntersecting)})},x=new IntersectionObserver(p,{threshold:.5});return h.current&&x.observe(h.current),()=>{x.disconnect()}}},[e]),A.useEffect(()=>{if(s){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[s]);let f=()=>{a(!0)},b=()=>{a(!1),o(!1)};return r?e!=="intent"?[i,h,{}]:[i,h,{onFocus:jn(l,f),onBlur:jn(c,b),onMouseEnter:jn(u,f),onMouseLeave:jn(d,b),onTouchStart:jn(m,f)}]:[!1,h,{}]}function jn(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function vm({page:e,...t}){let r=_d(),{nonce:s}=Ts(),{router:a}=ii(),i=A.useMemo(()=>El(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&s&&(t={...t,nonce:s}),r?A.createElement(Nm,{page:e,matches:i,...t}):A.createElement(wm,{page:e,matches:i,...t})):null}function jm(e){let{manifest:t,routeModules:r}=Ts(),[s,a]=A.useState([]);return A.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=ge(),{future:a}=Ts(),{basename:i}=ii(),o=A.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let l=Yl(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 A.createElement(A.Fragment,null,o.map(l=>A.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...r})))}function wm({page:e,matches:t,...r}){let s=ge(),{future:a,manifest:i,routeModules:o}=Ts(),{basename:l}=ii(),{loaderData:c,matches:u}=ym(),d=A.useMemo(()=>lo(e,t,u,i,s,"data"),[e,t,u,i,s]),m=A.useMemo(()=>lo(e,t,u,i,s,"assets"),[e,t,u,i,s]),h=A.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let p=new Set,x=!1;if(t.forEach(k=>{var w;let j=i.routes[k.route.id];!j||!j.hasLoader||(!d.some(E=>E.route.id===k.route.id)&&k.route.id in c&&((w=o[k.route.id])!=null&&w.shouldRevalidate)||j.hasClientLoader?x=!0:p.add(k.route.id))}),p.size===0)return[];let y=Yl(e,l,a.v8_trailingSlashAwareDataRequests,"data");return x&&p.size>0&&y.searchParams.set("_routes",t.filter(k=>p.has(k.route.id)).map(k=>k.route.id).join(",")),[y.pathname+y.search]},[l,a.v8_trailingSlashAwareDataRequests,c,s,i,d,t,e,o]),f=A.useMemo(()=>fm(m,i),[m,i]),b=jm(m);return A.createElement(A.Fragment,null,h.map(p=>A.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...r})),f.map(p=>A.createElement("link",{key:p,rel:"modulepreload",href:p,...r})),b.map(({key:p,link:x})=>A.createElement("link",{key:p,nonce:r.nonce,...x,crossOrigin:x.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 Hl=A.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,...b},p){let{basename:x,navigator:y,useTransitions:k}=A.useContext(at),j=typeof d=="string"&&Ga.test(d),w=Ol(d,x);d=w.to;let E=$d(d,{relative:a}),F=ge(),P=null;if(l){let W=Ps(l,[],F.mask?F.mask.pathname:"/",!0);x!=="/"&&(W.pathname=W.pathname==="/"?x:gt([x,W.pathname])),P=y.createHref(W)}let[O,Z,$]=bm(s,b),se=Em(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:k});function V(W){t&&t(W),W.defaultPrevented||se(W)}let J=!(w.isExternal||i),T=A.createElement("a",{...b,...$,href:(J?P:void 0)||w.absoluteURL||E,onClick:J?V:t,ref:Sm(p,Z),target:u,"data-discover":!j&&r==="render"?"true":void 0});return O&&!j?A.createElement(A.Fragment,null,T,A.createElement(vm,{page:E})):T});Hl.displayName="Link";var Cm=A.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=Mn(o,{relative:u.relative}),h=ge(),f=A.useContext(Es),{navigator:b,basename:p}=A.useContext(at),x=f!=null&&Rm(m)&&l===!0,y=b.encodeLocation?b.encodeLocation(m).pathname:m.pathname,k=h.pathname,j=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;r||(k=k.toLowerCase(),j=j?j.toLowerCase():null,y=y.toLowerCase()),j&&p&&(j=qt(j,p)||j);const w=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let E=k===y||!a&&k.startsWith(y)&&k.charAt(w)==="/",F=j!=null&&(j===y||!a&&j.startsWith(y)&&j.charAt(y.length)==="/"),P={isActive:E,isPending:F,isTransitioning:x},O=E?t:void 0,Z;typeof s=="function"?Z=s(P):Z=[s,E?"active":null,F?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let $=typeof i=="function"?i(P):i;return A.createElement(Hl,{...u,"aria-current":O,className:Z,ref:d,style:$,to:o,viewTransition:l},typeof c=="function"?c(P):c)});Cm.displayName="NavLink";var Am=A.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:s,replace:a,state:i,method:o=ls,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},b)=>{let{useTransitions:p}=A.useContext(at),x=Fm(),y=Dm(l,{relative:u}),k=o.toLowerCase()==="get"?"get":"post",j=typeof l=="string"&&Ga.test(l),w=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let F=E.nativeEvent.submitter,P=(F==null?void 0:F.getAttribute("formmethod"))||o,O=()=>x(F||E.currentTarget,{fetcherKey:t,method:P,navigate:r,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&r!==!1?A.startTransition(()=>O()):O()};return A.createElement("form",{ref:b,method:k,action:y,onSubmit:s?c:w,...f,"data-discover":!j&&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 Kl(e){let t=A.useContext(hn);return je(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=ye(),m=ge(),h=Mn(e,{relative:o});return A.useCallback(f=>{if(im(f,t)){f.preventDefault();let b=r!==void 0?r:ms(m)===ms(h),p=()=>d(e,{replace:b,mask:s,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?A.startTransition(()=>p()):p()}},[m,d,h,r,s,a,t,e,i,o,l,c,u])}function _m(e){st(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=A.useRef(pa(e)),r=A.useRef(!1),s=ge(),a=A.useMemo(()=>om(s.search,r.current?null:t.current),[s.search]),i=ye(),o=A.useCallback((l,c)=>{const u=pa(typeof l=="function"?l(new URLSearchParams(a)):l);r.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var Tm=0,Im=()=>`__${String(++Tm)}__`;function Fm(){let{router:e}=Kl("useSubmit"),{basename:t}=A.useContext(at),r=Kd(),s=e.fetch,a=e.navigate;return A.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||Im();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}=A.useContext(at),s=A.useContext(lt);je(s,"useFormAction must be used inside a RouteContext");let[a]=s.matches.slice(-1),i={...Mn(e||".",{relative:t})},o=ge();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let d=l.toString();i.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(i.pathname=i.pathname==="/"?r:gt([r,i.pathname])),ms(i)}function Rm(e,{relative:t}={}){let r=A.useContext(zl);je(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=Kl("useViewTransitionState"),a=Mn(e,{relative:t});if(!r.isTransitioning)return!1;let i=qt(r.currentLocation.pathname,s)||r.currentLocation.pathname,o=qt(r.nextLocation.pathname,s)||r.nextLocation.pathname;return hs(a.pathname,o)!=null||hs(a.pathname,i)!=null}var pn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},jr,Jt,Kr,yl,Om=(yl=class extends pn{constructor(){super();G(this,jr);G(this,Jt);G(this,Kr);B(this,Kr,t=>{if(typeof window<"u"&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){v(this,Jt)||this.setEventListener(v(this,Kr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Jt))==null||t.call(this),B(this,Jt,void 0))}setEventListener(t){var r;B(this,Kr,t),(r=v(this,Jt))==null||r.call(this),B(this,Jt,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){v(this,jr)!==t&&(B(this,jr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof v(this,jr)=="boolean"?v(this,jr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},jr=new WeakMap,Jt=new WeakMap,Kr=new WeakMap,yl),li=new Om,$m={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},bt,Nr,bl,Lm=(bl=class{constructor(){G(this,bt,$m);G(this,Nr,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&v(this,Nr)&&e!==v(this,bt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:v(this,bt),provider:e}),B(this,bt,e),process.env.NODE_ENV!=="production"&&B(this,Nr,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&B(this,Nr,!0),v(this,bt).setTimeout(e,t)}clearTimeout(e){v(this,bt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&B(this,Nr,!0),v(this,bt).setInterval(e,t)}clearInterval(e){v(this,bt).clearInterval(e)}},bt=new WeakMap,Nr=new WeakMap,bl),br=new Lm;function zm(e){setTimeout(e,0)}var Mm=typeof window>"u"||"Deno"in globalThis;function He(){}function qm(e,t){return typeof e=="function"?e(t):e}function xa(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ql(e,t){return Math.max(e+(t||0)-Date.now(),0)}function or(e,t){return typeof e=="function"?e(t):e}function tt(e,t){return typeof e=="function"?e(t):e}function co(e,t){const{type:r="all",exact:s,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==ci(o,t.options))return!1}else if(!_n(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 uo(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(!_n(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function ci(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tr)(e)}function Tr(e){return JSON.stringify(e,(t,r)=>ya(r)?Object.keys(r).sort().reduce((s,a)=>(s[a]=r[a],s),{}):r)}function _n(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>_n(e[r],t[r])):!1}var Vm=Object.prototype.hasOwnProperty;function ga(e,t,r=0){if(e===t)return e;if(r>500)return t;const s=mo(e)&&mo(t);if(!s&&!(ya(e)&&ya(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 b=ga(h,f,r+1);c[m]=b,b===h&&u++}return i===l&&u===i?e:c}function ps(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 mo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ya(e){if(!ho(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!ho(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ho(e){return Object.prototype.toString.call(e)==="[object Object]"}function Bm(e){return new Promise(t=>{br.setTimeout(t,e)})}function ba(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 ga(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 ga(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 xs=Symbol();function Jl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===xs&&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===xs?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ui(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 Tn=(()=>{let e=()=>Mm;return{isServer(){return e()},setIsServer(t){e=t}}})();function va(){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 Te=Hm(),Qr,Gt,Jr,vl,Km=(vl=class extends pn{constructor(){super();G(this,Qr,!0);G(this,Gt);G(this,Jr);B(this,Jr,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(){v(this,Gt)||this.setEventListener(v(this,Jr))}onUnsubscribe(){var t;this.hasListeners()||((t=v(this,Gt))==null||t.call(this),B(this,Gt,void 0))}setEventListener(t){var r;B(this,Jr,t),(r=v(this,Gt))==null||r.call(this),B(this,Gt,t(this.setOnline.bind(this)))}setOnline(t){v(this,Qr)!==t&&(B(this,Qr,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return v(this,Qr)}},Qr=new WeakMap,Gt=new WeakMap,Jr=new WeakMap,vl),gs=new Km;function Qm(e){return Math.min(1e3*2**e,3e4)}function Gl(e){return(e??"online")==="online"?gs.isOnline():!0}var ja=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Xl(e){let t=!1,r=0,s;const a=va(),i=()=>a.status!=="pending",o=p=>{var x;if(!i()){const y=new ja(p);h(y),(x=e.onCancel)==null||x.call(e,y)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>li.isFocused()&&(e.networkMode==="always"||gs.isOnline())&&e.canRun(),d=()=>Gl(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 x;s=y=>{(i()||u())&&p(y)},(x=e.onPause)==null||x.call(e)}).then(()=>{var p;s=void 0,i()||(p=e.onContinue)==null||p.call(e)}),b=()=>{if(i())return;let p;const x=r===0?e.initialPromise:void 0;try{p=x??e.fn()}catch(y){p=Promise.reject(y)}Promise.resolve(p).then(m).catch(y=>{var F;if(i())return;const k=e.retry??(Tn.isServer()?0:3),j=e.retryDelay??Qm,w=typeof j=="function"?j(r,y):j,E=k===!0||typeof k=="number"&&r<k||typeof k=="function"&&k(r,y);if(t||!E){h(y);return}r++,(F=e.onFail)==null||F.call(e,r,y),Bm(w).then(()=>u()?void 0:f()).then(()=>{t?h(y):b()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():f().then(b),a)}}var wr,jl,ec=(jl=class{constructor(){G(this,wr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xa(this.gcTime)&&B(this,wr,br.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Tn.isServer()?1/0:300*1e3))}clearGcTimeout(){v(this,wr)!==void 0&&(br.clearTimeout(v(this,wr)),B(this,wr,void 0))}},wr=new WeakMap,jl);function Jm(e){return{onFetch:(t,r)=>{var d,m,h,f,b;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=((b=t.state.data)==null?void 0:b.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const x=j=>{Wm(j,()=>t.signal,()=>p=!0)},y=Jl(t.options,t.fetchOptions),k=async(j,w,E)=>{if(p)return Promise.reject(t.signal.reason);if(w==null&&j.pages.length)return Promise.resolve(j);const P=(()=>{const se={client:t.client,queryKey:t.queryKey,pageParam:w,direction:E?"backward":"forward",meta:t.options.meta};return x(se),se})(),O=await y(P),{maxPages:Z}=t.options,$=E?Zm:Um;return{pages:$(j.pages,O,Z),pageParams:$(j.pageParams,w,Z)}};if(a&&i.length){const j=a==="backward",w=j?Gm:fo,E={pages:i,pageParams:o},F=w(s,E);l=await k(E,F,j)}else{const j=e??i.length;do{const w=c===0?o[0]??s.initialPageParam:fo(s,l);if(c>0&&w==null)break;l=await k(l,w),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var p,x;return(x=(p=t.options).persister)==null?void 0:x.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=u}}}function fo(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 Gr,Sr,Xr,ot,kr,De,Dn,Cr,et,tc,Rt,Nl,Xm=(Nl=class extends ec{constructor(t){super();G(this,et);G(this,Gr);G(this,Sr);G(this,Xr);G(this,ot);G(this,kr);G(this,De);G(this,Dn);G(this,Cr);B(this,Cr,!1),B(this,Dn,t.defaultOptions),this.setOptions(t.options),this.observers=[],B(this,kr,t.client),B(this,ot,v(this,kr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,B(this,Sr,xo(this.options)),this.state=t.state??v(this,Sr),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return v(this,Gr)}get promise(){var t;return(t=v(this,De))==null?void 0:t.promise}setOptions(t){if(this.options={...v(this,Dn),...t},t!=null&&t._type&&B(this,Gr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=xo(this.options);r.data!==void 0&&(this.setState(po(r.data,r.dataUpdatedAt)),B(this,Sr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&v(this,ot).remove(this)}setData(t,r){const s=ba(this.state.data,t,this.options);return ne(this,et,Rt).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(t){ne(this,et,Rt).call(this,{type:"setState",state:t})}cancel(t){var s,a;const r=(s=v(this,De))==null?void 0:s.promise;return(a=v(this,De))==null||a.cancel(t),r?r.then(He).catch(He):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return v(this,Sr)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>tt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xs||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>or(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Ql(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,De))==null||r.continue()}onOnline(){var r;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=v(this,De))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),v(this,ot).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(v(this,De)&&(v(this,Cr)||ne(this,et,tc).call(this)?v(this,De).cancel({revert:!0}):v(this,De).cancelRetry()),this.scheduleGc()),v(this,ot).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ne(this,et,Rt).call(this,{type:"invalidate"})}async fetch(t,r){var u,d,m,h,f,b,p,x,y,k,j;if(this.state.fetchStatus!=="idle"&&((u=v(this,De))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(v(this,De))return v(this,De).continueRetry(),v(this,De).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(E=>E.options.queryFn);w&&this.setOptions(w.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=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(B(this,Cr,!0),s.signal)})},i=()=>{const w=Jl(this.options,r),F=(()=>{const P={client:v(this,kr),queryKey:this.queryKey,meta:this.meta};return a(P),P})();return B(this,Cr,!1),this.options.persister?this.options.persister(w,F,this):w(F)},l=(()=>{const w={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:v(this,kr),state:this.state,fetchFn:i};return a(w),w})(),c=v(this,Gr)==="infinite"?Jm(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),B(this,Xr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&ne(this,et,Rt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),B(this,De,Xl({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:w=>{w instanceof ja&&w.revert&&this.setState({...v(this,Xr),fetchStatus:"idle"}),s.abort()},onFail:(w,E)=>{ne(this,et,Rt).call(this,{type:"failed",failureCount:w,error:E})},onPause:()=>{ne(this,et,Rt).call(this,{type:"pause"})},onContinue:()=>{ne(this,et,Rt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const w=await v(this,De).start();if(w===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(w),(f=(h=v(this,ot).config).onSuccess)==null||f.call(h,w,this),(p=(b=v(this,ot).config).onSettled)==null||p.call(b,w,this.state.error,this),w}catch(w){if(w instanceof ja){if(w.silent)return v(this,De).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw ne(this,et,Rt).call(this,{type:"error",error:w}),(y=(x=v(this,ot).config).onError)==null||y.call(x,w,this),(j=(k=v(this,ot).config).onSettled)==null||j.call(k,this.state.data,w,this),w}finally{this.scheduleGc()}}},Gr=new WeakMap,Sr=new WeakMap,Xr=new WeakMap,ot=new WeakMap,kr=new WeakMap,De=new WeakMap,Dn=new WeakMap,Cr=new WeakMap,et=new WeakSet,tc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Rt=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,...rc(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...po(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return B(this,Xr,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),Te.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),v(this,ot).notify({query:this,type:"updated",action:t})})},Nl);function rc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function po(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function xo(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 Qe,ie,Rn,Ye,Ar,en,Ot,Xt,On,tn,rn,Pr,Er,er,nn,de,Cn,Na,wa,Sa,ka,Ca,Aa,Pa,nc,wl,eh=(wl=class extends pn{constructor(t,r){super();G(this,de);G(this,Qe);G(this,ie);G(this,Rn);G(this,Ye);G(this,Ar);G(this,en);G(this,Ot);G(this,Xt);G(this,On);G(this,tn);G(this,rn);G(this,Pr);G(this,Er);G(this,er);G(this,nn,new Set);this.options=r,B(this,Qe,t),B(this,Xt,null),B(this,Ot,va()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(v(this,ie).addObserver(this),go(v(this,ie),this.options)?ne(this,de,Cn).call(this):this.updateResult(),ne(this,de,ka).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ea(v(this,ie),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ea(v(this,ie),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ne(this,de,Ca).call(this),ne(this,de,Aa).call(this),v(this,ie).removeObserver(this)}setOptions(t){const r=this.options,s=v(this,ie);if(this.options=v(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof tt(this.options.enabled,v(this,ie))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ne(this,de,Pa).call(this),v(this,ie).setOptions(this.options),r._defaulted&&!ps(this.options,r)&&v(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:v(this,ie),observer:this});const a=this.hasListeners();a&&yo(v(this,ie),s,this.options,r)&&ne(this,de,Cn).call(this),this.updateResult(),a&&(v(this,ie)!==s||tt(this.options.enabled,v(this,ie))!==tt(r.enabled,v(this,ie))||or(this.options.staleTime,v(this,ie))!==or(r.staleTime,v(this,ie)))&&ne(this,de,Na).call(this);const i=ne(this,de,wa).call(this);a&&(v(this,ie)!==s||tt(this.options.enabled,v(this,ie))!==tt(r.enabled,v(this,ie))||i!==v(this,er))&&ne(this,de,Sa).call(this,i)}getOptimisticResult(t){const r=v(this,Qe).getQueryCache().build(v(this,Qe),t),s=this.createResult(r,t);return rh(this,s)&&(B(this,Ye,s),B(this,en,this.options),B(this,Ar,v(this,ie).state)),s}getCurrentResult(){return v(this,Ye)}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&&v(this,Ot).status==="pending"&&v(this,Ot).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){v(this,nn).add(t)}getCurrentQuery(){return v(this,ie)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=v(this,Qe).defaultQueryOptions(t),s=v(this,Qe).getQueryCache().build(v(this,Qe),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(t){return ne(this,de,Cn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),v(this,Ye)))}createResult(t,r){var Z;const s=v(this,ie),a=this.options,i=v(this,Ye),o=v(this,Ar),l=v(this,en),u=t!==s?t.state:v(this,Rn),{state:d}=t;let m={...d},h=!1,f;if(r._optimisticResults){const $=this.hasListeners(),se=!$&&go(t,r),V=$&&yo(t,s,r,a);(se||V)&&(m={...m,...rc(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:b,errorUpdatedAt:p,status:x}=m;f=m.data;let y=!1;if(r.placeholderData!==void 0&&f===void 0&&x==="pending"){let $;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?($=i.data,y=!0):$=typeof r.placeholderData=="function"?r.placeholderData((Z=v(this,rn))==null?void 0:Z.state.data,v(this,rn)):r.placeholderData,$!==void 0&&(x="success",f=ba(i==null?void 0:i.data,$,r),h=!0)}if(r.select&&f!==void 0&&!y)if(i&&f===(o==null?void 0:o.data)&&r.select===v(this,On))f=v(this,tn);else try{B(this,On,r.select),f=r.select(f),f=ba(i==null?void 0:i.data,f,r),B(this,tn,f),B(this,Xt,null)}catch($){B(this,Xt,$)}v(this,Xt)&&(b=v(this,Xt),f=v(this,tn),p=Date.now(),x="error");const k=m.fetchStatus==="fetching",j=x==="pending",w=x==="error",E=j&&k,F=f!==void 0,O={status:x,fetchStatus:m.fetchStatus,isPending:j,isSuccess:x==="success",isError:w,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:b,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:w&&!F,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&F,isStale:di(t,r),refetch:this.refetch,promise:v(this,Ot),isEnabled:tt(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const $=O.data!==void 0,se=O.status==="error"&&!$,V=W=>{se?W.reject(O.error):$&&W.resolve(O.data)},J=()=>{const W=B(this,Ot,O.promise=va());V(W)},T=v(this,Ot);switch(T.status){case"pending":t.queryHash===s.queryHash&&V(T);break;case"fulfilled":(se||O.data!==T.value)&&J();break;case"rejected":(!se||O.error!==T.reason)&&J();break}}return O}updateResult(){const t=v(this,Ye),r=this.createResult(v(this,ie),this.options);if(B(this,Ar,v(this,ie).state),B(this,en,this.options),v(this,Ar).data!==void 0&&B(this,rn,v(this,ie)),ps(r,t))return;B(this,Ye,r);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!v(this,nn).size)return!0;const o=new Set(i??v(this,nn));return this.options.throwOnError&&o.add("error"),Object.keys(v(this,Ye)).some(l=>{const c=l;return v(this,Ye)[c]!==t[c]&&o.has(c)})};ne(this,de,nc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ne(this,de,ka).call(this)}},Qe=new WeakMap,ie=new WeakMap,Rn=new WeakMap,Ye=new WeakMap,Ar=new WeakMap,en=new WeakMap,Ot=new WeakMap,Xt=new WeakMap,On=new WeakMap,tn=new WeakMap,rn=new WeakMap,Pr=new WeakMap,Er=new WeakMap,er=new WeakMap,nn=new WeakMap,de=new WeakSet,Cn=function(t){ne(this,de,Pa).call(this);let r=v(this,ie).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(He)),r},Na=function(){ne(this,de,Ca).call(this);const t=or(this.options.staleTime,v(this,ie));if(Tn.isServer()||v(this,Ye).isStale||!xa(t))return;const s=Ql(v(this,Ye).dataUpdatedAt,t)+1;B(this,Pr,br.setTimeout(()=>{v(this,Ye).isStale||this.updateResult()},s))},wa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(v(this,ie)):this.options.refetchInterval)??!1},Sa=function(t){ne(this,de,Aa).call(this),B(this,er,t),!(Tn.isServer()||tt(this.options.enabled,v(this,ie))===!1||!xa(v(this,er))||v(this,er)===0)&&B(this,Er,br.setInterval(()=>{(this.options.refetchIntervalInBackground||li.isFocused())&&ne(this,de,Cn).call(this)},v(this,er)))},ka=function(){ne(this,de,Na).call(this),ne(this,de,Sa).call(this,ne(this,de,wa).call(this))},Ca=function(){v(this,Pr)!==void 0&&(br.clearTimeout(v(this,Pr)),B(this,Pr,void 0))},Aa=function(){v(this,Er)!==void 0&&(br.clearInterval(v(this,Er)),B(this,Er,void 0))},Pa=function(){const t=v(this,Qe).getQueryCache().build(v(this,Qe),this.options);if(t===v(this,ie))return;const r=v(this,ie);B(this,ie,t),B(this,Rn,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},nc=function(t){Te.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(v(this,Ye))}),v(this,Qe).getQueryCache().notify({query:v(this,ie),type:"observerResultsUpdated"})})},wl);function th(e,t){return tt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&tt(t.retryOnMount,e)===!1)}function go(e,t){return th(e,t)||e.state.data!==void 0&&Ea(e,t,t.refetchOnMount)}function Ea(e,t,r){if(tt(t.enabled,e)!==!1&&or(t.staleTime,e)!=="static"){const s=typeof r=="function"?r(e):r;return s==="always"||s!==!1&&di(e,t)}return!1}function yo(e,t,r,s){return(e!==t||tt(s.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&di(e,r)}function di(e,t){return tt(t.enabled,e)!==!1&&e.isStaleByTime(or(t.staleTime,e))}function rh(e,t){return!ps(e.getCurrentResult(),t)}var $n,vt,Ve,_r,jt,Ht,Sl,nh=(Sl=class extends ec{constructor(t){super();G(this,jt);G(this,$n);G(this,vt);G(this,Ve);G(this,_r);B(this,$n,t.client),this.mutationId=t.mutationId,B(this,Ve,t.mutationCache),B(this,vt,[]),this.state=t.state||sc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){v(this,vt).includes(t)||(v(this,vt).push(t),this.clearGcTimeout(),v(this,Ve).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){B(this,vt,v(this,vt).filter(r=>r!==t)),this.scheduleGc(),v(this,Ve).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){v(this,vt).length||(this.state.status==="pending"?this.scheduleGc():v(this,Ve).remove(this))}continue(){var t;return((t=v(this,_r))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,b,p,x,y,k,j,w,E,F,P;const r=()=>{ne(this,jt,Ht).call(this,{type:"continue"})},s={client:v(this,$n),meta:this.options.meta,mutationKey:this.options.mutationKey};B(this,_r,Xl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(O,Z)=>{ne(this,jt,Ht).call(this,{type:"failed",failureCount:O,error:Z})},onPause:()=>{ne(this,jt,Ht).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>v(this,Ve).canRun(this)}));const a=this.state.status==="pending",i=!v(this,_r).canStart();try{if(a)r();else{ne(this,jt,Ht).call(this,{type:"pending",variables:t,isPaused:i}),v(this,Ve).config.onMutate&&await v(this,Ve).config.onMutate(t,this,s);const Z=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,s));Z!==this.state.context&&ne(this,jt,Ht).call(this,{type:"pending",context:Z,variables:t,isPaused:i})}const O=await v(this,_r).start();return await((u=(c=v(this,Ve).config).onSuccess)==null?void 0:u.call(c,O,t,this.state.context,this,s)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,O,t,this.state.context,s)),await((f=(h=v(this,Ve).config).onSettled)==null?void 0:f.call(h,O,null,this.state.variables,this.state.context,this,s)),await((p=(b=this.options).onSettled)==null?void 0:p.call(b,O,null,t,this.state.context,s)),ne(this,jt,Ht).call(this,{type:"success",data:O}),O}catch(O){try{await((y=(x=v(this,Ve).config).onError)==null?void 0:y.call(x,O,t,this.state.context,this,s))}catch(Z){Promise.reject(Z)}try{await((j=(k=this.options).onError)==null?void 0:j.call(k,O,t,this.state.context,s))}catch(Z){Promise.reject(Z)}try{await((E=(w=v(this,Ve).config).onSettled)==null?void 0:E.call(w,void 0,O,this.state.variables,this.state.context,this,s))}catch(Z){Promise.reject(Z)}try{await((P=(F=this.options).onSettled)==null?void 0:P.call(F,void 0,O,t,this.state.context,s))}catch(Z){Promise.reject(Z)}throw ne(this,jt,Ht).call(this,{type:"error",error:O}),O}finally{v(this,Ve).runNext(this)}}},$n=new WeakMap,vt=new WeakMap,Ve=new WeakMap,_r=new WeakMap,jt=new WeakSet,Ht=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),Te.batch(()=>{v(this,vt).forEach(s=>{s.onMutationUpdate(t)}),v(this,Ve).notify({mutation:this,type:"updated",action:t})})},Sl);function sc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $t,pt,Ln,kl,sh=(kl=class extends pn{constructor(t={}){super();G(this,$t);G(this,pt);G(this,Ln);this.config=t,B(this,$t,new Set),B(this,pt,new Map),B(this,Ln,0)}build(t,r,s){const a=new nh({client:t,mutationCache:this,mutationId:++Hn(this,Ln)._,options:t.defaultMutationOptions(r),state:s});return this.add(a),a}add(t){v(this,$t).add(t);const r=Qn(t);if(typeof r=="string"){const s=v(this,pt).get(r);s?s.push(t):v(this,pt).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(v(this,$t).delete(t)){const r=Qn(t);if(typeof r=="string"){const s=v(this,pt).get(r);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&v(this,pt).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Qn(t);if(typeof r=="string"){const s=v(this,pt).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=Qn(t);if(typeof r=="string"){const a=(s=v(this,pt).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(){Te.batch(()=>{v(this,$t).forEach(t=>{this.notify({type:"removed",mutation:t})}),v(this,$t).clear(),v(this,pt).clear()})}getAll(){return Array.from(v(this,$t))}find(t){const r={exact:!0,...t};return this.getAll().find(s=>uo(r,s))}findAll(t={}){return this.getAll().filter(r=>uo(t,r))}notify(t){Te.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return Te.batch(()=>Promise.all(t.map(r=>r.continue().catch(He))))}},$t=new WeakMap,pt=new WeakMap,Ln=new WeakMap,kl);function Qn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Lt,tr,Je,zt,Mt,us,_a,Cl,ah=(Cl=class extends pn{constructor(t,r){super();G(this,Mt);G(this,Lt);G(this,tr);G(this,Je);G(this,zt);B(this,Lt,t),this.setOptions(r),this.bindMethods(),ne(this,Mt,us).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=v(this,Lt).defaultMutationOptions(t),ps(this.options,r)||v(this,Lt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:v(this,Je),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Tr(r.mutationKey)!==Tr(this.options.mutationKey)?this.reset():((s=v(this,Je))==null?void 0:s.state.status)==="pending"&&v(this,Je).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=v(this,Je))==null||t.removeObserver(this)}onMutationUpdate(t){ne(this,Mt,us).call(this),ne(this,Mt,_a).call(this,t)}getCurrentResult(){return v(this,tr)}reset(){var t;(t=v(this,Je))==null||t.removeObserver(this),B(this,Je,void 0),ne(this,Mt,us).call(this),ne(this,Mt,_a).call(this)}mutate(t,r){var s;return B(this,zt,r),(s=v(this,Je))==null||s.removeObserver(this),B(this,Je,v(this,Lt).getMutationCache().build(v(this,Lt),this.options)),v(this,Je).addObserver(this),v(this,Je).execute(t)}},Lt=new WeakMap,tr=new WeakMap,Je=new WeakMap,zt=new WeakMap,Mt=new WeakSet,us=function(){var r;const t=((r=v(this,Je))==null?void 0:r.state)??sc();B(this,tr,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},_a=function(t){Te.batch(()=>{var r,s,a,i,o,l,c,u;if(v(this,zt)&&this.hasListeners()){const d=v(this,tr).variables,m=v(this,tr).context,h={client:v(this,Lt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(s=(r=v(this,zt)).onSuccess)==null||s.call(r,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=v(this,zt)).onSettled)==null||i.call(a,t.data,null,d,m,h)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=v(this,zt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=v(this,zt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(v(this,tr))})})},Cl),Nt,Al,ih=(Al=class extends pn{constructor(t={}){super();G(this,Nt);this.config=t,B(this,Nt,new Map)}build(t,r,s){const a=r.queryKey,i=r.queryHash??ci(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){v(this,Nt).has(t.queryHash)||(v(this,Nt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=v(this,Nt).get(t.queryHash);r&&(t.destroy(),r===t&&v(this,Nt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Te.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return v(this,Nt).get(t)}getAll(){return[...v(this,Nt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(s=>co(r,s))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(s=>co(t,s)):r}notify(t){Te.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Te.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Te.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Nt=new WeakMap,Al),Se,rr,nr,sn,an,sr,on,ln,Pl,oh=(Pl=class{constructor(e={}){G(this,Se);G(this,rr);G(this,nr);G(this,sn);G(this,an);G(this,sr);G(this,on);G(this,ln);B(this,Se,e.queryCache||new ih),B(this,rr,e.mutationCache||new sh),B(this,nr,e.defaultOptions||{}),B(this,sn,new Map),B(this,an,new Map),B(this,sr,0)}mount(){Hn(this,sr)._++,v(this,sr)===1&&(B(this,on,li.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,Se).onFocus())})),B(this,ln,gs.subscribe(async e=>{e&&(await this.resumePausedMutations(),v(this,Se).onOnline())})))}unmount(){var e,t;Hn(this,sr)._--,v(this,sr)===0&&((e=v(this,on))==null||e.call(this),B(this,on,void 0),(t=v(this,ln))==null||t.call(this),B(this,ln,void 0))}isFetching(e){return v(this,Se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return v(this,rr).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,Se).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=v(this,Se).build(this,t),s=r.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(or(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return v(this,Se).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=v(this,Se).get(s.queryHash),i=a==null?void 0:a.state.data,o=qm(t,i);if(o!==void 0)return v(this,Se).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return Te.batch(()=>v(this,Se).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=v(this,Se).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=v(this,Se);Te.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=v(this,Se);return Te.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},s=Te.batch(()=>v(this,Se).findAll(e).map(a=>a.cancel(r)));return Promise.all(s).then(He).catch(He)}invalidateQueries(e,t={}){return Te.batch(()=>(v(this,Se).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=Te.batch(()=>v(this,Se).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(He)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(He)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=v(this,Se).build(this,t);return r.isStaleByTime(or(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(He).catch(He)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(He).catch(He)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return gs.isOnline()?v(this,rr).resumePausedMutations():Promise.resolve()}getQueryCache(){return v(this,Se)}getMutationCache(){return v(this,rr)}getDefaultOptions(){return v(this,nr)}setDefaultOptions(e){B(this,nr,e)}setQueryDefaults(e,t){v(this,sn).set(Tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...v(this,sn).values()],r={};return t.forEach(s=>{_n(e,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(e,t){v(this,an).set(Tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...v(this,an).values()],r={};return t.forEach(s=>{_n(e,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...v(this,nr).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ci(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===xs&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...v(this,nr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){v(this,Se).clear(),v(this,rr).clear()}},Se=new WeakMap,rr=new WeakMap,nr=new WeakMap,sn=new WeakMap,an=new WeakMap,sr=new WeakMap,on=new WeakMap,ln=new WeakMap,Pl),ac=A.createContext(void 0),ct=e=>{const t=A.useContext(ac);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},lh=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(ac.Provider,{value:e,children:t})),ic=A.createContext(!1),ch=()=>A.useContext(ic);ic.Provider;function uh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var dh=A.createContext(uh()),mh=()=>A.useContext(dh),hh=(e,t,r)=>{const s=r!=null&&r.state.error&&typeof e.throwOnError=="function"?ui(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},fh=e=>{A.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||ui(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,bo=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function bh(e,t,r){var f,b,p,x;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const s=ch(),a=mh(),i=ct(),o=i.defaultQueryOptions(e);(b=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||b.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]=A.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!s&&c;if(A.useSyncExternalStore(A.useCallback(y=>{const k=h?d.subscribe(Te.batchCalls(y)):He;return d.updateResult(),k},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),A.useEffect(()=>{d.setOptions(o)},[o,d]),yh(o,m))throw bo(o,d,a);if(ph({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((x=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||x.call(p,o,m),o.experimental_prefetchInRender&&!Tn.isServer()&&gh(m,s)){const y=u?bo(o,d,a):l==null?void 0:l.promise;y==null||y.catch(He).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function ke(e,t){return bh(e,eh)}function vh(e,t){const r=ct(),[s]=A.useState(()=>new ah(r,e));A.useEffect(()=>{s.setOptions(e)},[s,e]);const a=A.useSyncExternalStore(A.useCallback(o=>s.subscribe(Te.batchCalls(o)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=A.useCallback((o,l)=>{s.mutate(o,l).catch(He)},[s]);if(a.error&&ui(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function oc(e){return e.trim().replace(/\/+$/,"")}const Is=new Map;function lc(e,t){Is.set(e,t)}function jh(e){return Is.get(e)}function Nh(e){Is.delete(e)}function wh(e){for(const[t,r]of Is)if(r.accessToken===e)return t}let Ta=null;function cc(e){Ta=oc(e)}let uc=null;function Sh(e){uc=e}function kh(){return uc}let dc=null;function Ch(e){dc=e.trim()}function Ah(){return dc}function Ph(){return Ta!==null?Ta:oc("")}const vo={get apiBaseUrl(){return Ph()},apiVersion:"v1"};function Eh(e){const t=e.startsWith("/")?e:`/${e}`;return`${vo.apiBaseUrl}/api/${vo.apiVersion}${t}`}const mc="auth:session-expired";function _h(){window.dispatchEvent(new CustomEvent(mc))}function hc(e){return`${mc}:${e}`}const Th=N.createContext(null);function Ih({instanceId:e,accessToken:t,onSessionExpired:r,children:s}){const a=jh(e);return a&&lc(e,{...a,accessToken:t}),Sh(t),N.useEffect(()=>{if(!r)return;const i=hc(e),o=()=>r();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,r]),n.jsx(Th.Provider,{value:{accessToken:t},children:s})}class xn extends Error{constructor(r,s,a,i,o){super(a??s);vn(this,"status");vn(this,"title");vn(this,"details");vn(this,"extensions");this.name="ApiError",this.status=r,this.title=s,this.details=i,this.extensions=o}}const fc="tax-remittance.auth";function Fh(){var t;const e=localStorage.getItem(fc);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?(Ia(),null):r}catch{return Ia(),null}}function Ia(){localStorage.removeItem(fc)}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 xn(e.status,r,s,a,t??void 0)}async function qn(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){Ia();const h=c?wh(c):void 0;h?window.dispatchEvent(new CustomEvent(hc(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 qn(e,t)).data}function pc(){return fe("/portal/entities/mine")}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=N.createContext(null);function Lh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:r,children:s}){var p;const[a,i]=N.useState(null),{data:o=[],isLoading:l,isError:c,refetch:u}=ke({queryKey:["entities","mine"],queryFn:pc}),d=N.useRef(new Set),m=N.useRef(!1);N.useEffect(()=>{if(l)return;if(!m.current){o.forEach(y=>d.current.add(y.entityId)),m.current=!0;return}o.filter(y=>!d.current.has(y.entityId)).forEach(y=>{d.current.add(y.entityId),e==null||e(y)})},[o,l,e]);const h=a!==null&&o.some(x=>x.entityId===a)?a:((p=o[0])==null?void 0:p.entityId)??null,f=o.find(x=>x.entityId===h)??null,b=async()=>{await u()};return n.jsx(xc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:f,setSelectedEntityId:i,refetchEntities:b,enabledPayments:t,onPaymentRequired:r},children:s})}function $r(){const e=N.useContext(xc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const zh=N.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=N.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]=N.useState([]),s=N.useCallback(o=>{r(l=>l.filter(c=>c.id!==o))},[]),a=N.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=N.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,As.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 Fs(){const e=N.useContext(gc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class Wh extends N.Component{constructor(t){super(t),this.state={hasError:!1,message:""}}static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:"Unexpected error"}}render(){return this.state.hasError?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=ye(),s=ge();return N.useEffect(()=>(e.current=r,()=>{e.current=null}),[r,e]),N.useEffect(()=>{t==null||t(Yh(s.pathname),s.pathname)},[s.pathname,t]),null}function Kh({selectEntityFnRef:e}){const{setSelectedEntityId:t}=$r();return N.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function mi({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]=N.useState(()=>crypto.randomUUID());lc(h,{apiBaseUrl:r.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),cc(r),Ch(e),N.useEffect(()=>()=>{Nh(h)},[h]);const[f]=N.useState(()=>new oh({defaultOptions:{queries:{retry:1,staleTime:300*1e3,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(Ih,{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 hi(){const{entities:e,isLoading:t,isError:r,refetchEntities:s}=$r(),a=ye();return N.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 fi(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=$r(),s=ye(),i=ge().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(jo,{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(Jn,{})}),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(jo,{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(Jn,{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(Jn,{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(Jn,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function jo({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 Jn({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 pi(){const e=ye(),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 Vn=e=>e.type==="checkbox",ar=e=>e instanceof Date,Me=e=>e==null;const xi=e=>typeof e=="object";var ve=e=>!Me(e)&&!Array.isArray(e)&&xi(e)&&!ar(e),Fa=e=>ve(e)&&e.target?Vn(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 ve(t)&&t.hasOwnProperty("isPrototypeOf")},Ds=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function we(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Ds&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(ve(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]=we(e[a]));return s}const Kt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},xt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},vc="root",gi=["__proto__","constructor","prototype"],ef=/^\w*$/;var Bn=e=>ef.test(e),pe=e=>e===void 0;const tf=/[.[\]'"]/;var Rs=e=>e.split(tf).filter(Boolean),M=(e,t,r)=>{if(!t||!ve(e))return r;const s=Bn(t)?[t]:Rs(t);if(s.some(i=>gi.includes(i)))return r;const a=s.reduce((i,o)=>Me(i)?void 0:i[o],e);return pe(a)||a===e?pe(e[t])?r:e[t]:a},rt=e=>typeof e=="boolean",Be=e=>typeof e=="function",ue=(e,t,r)=>{let s=-1;const a=Bn(t)?[t]:Rs(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=ve(u)||Array.isArray(u)?u:isNaN(+a[s+1])?{}:[]}if(gi.includes(l))return;e[l]=c,e=e[l]}};const jc=N.createContext(null);jc.displayName="HookFormControlContext";const yi=()=>N.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]!==xt.all&&(t._proxyFormState[o]=!s||xt.all),r&&(r[o]=!0),e[o]}});return a};const bi=Ds?N.useLayoutEffect:N.useEffect;function rf(e){const t=yi(),{control:r=t,disabled:s,name:a,exact:i}=e||{},[o,l]=N.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=N.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return bi(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!s&&l({...r._formState,...u,defaultValues:r._defaultValues})}}),[a,s,i]),N.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),N.useMemo(()=>Nc(o,r,c.current,!1),[o,r])}var Ue=e=>typeof e=="string",Da=(e,t,r,s,a)=>Ue(e)?(s&&t.watch.add(e),M(r,e,a)):Array.isArray(e)?e.map(i=>(s&&t.watch.add(i),M(r,i))):(s&&(t.watchAll=!0),r),Ra=e=>Me(e)||!xi(e);const No=(e,t)=>t.length===0&&!Array.isArray(e)&&!bc(e);function nt(e,t,r=new WeakMap){if(e===t)return!0;if(Ra(e)||Ra(t))return Object.is(e,t);if(ar(e)&&ar(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(No(e,s)||No(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(ar(l)&&ar(c)||(ve(l)||Array.isArray(l))&&(ve(c)||Array.isArray(c))?!nt(l,c,r):!Object.is(l,c))return!1}}return!0}function nf(e){const t=yi(),{control:r=t,name:s,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=N.useRef(a),u=N.useRef(l),d=N.useRef(void 0),m=N.useRef(r),h=N.useRef(s);u.current=l;const[f,b]=N.useState(()=>{const w=r._getWatch(s,c.current);return u.current?u.current(w):w}),p=N.useCallback(w=>{const E=Da(s,r._names,w||r._formValues,!1,c.current);return u.current?u.current(E):E},[r._formValues,r._names,s]),x=N.useCallback(w=>{if(!i){const E=Da(s,r._names,w||r._formValues,!1,c.current);if(u.current){const F=u.current(E);nt(F,d.current)||(b(F),d.current=F)}else b(E)}},[r._formValues,r._names,i,s]);bi(()=>((m.current!==r||!nt(h.current,s))&&(m.current=r,h.current=s,x()),r._subscribe({name:s,formState:{values:!0},exact:o,callback:w=>{x(w.values)}})),[r,o,s,x]),N.useEffect(()=>r._removeUnmounted());const y=m.current!==r,k=h.current,j=N.useMemo(()=>{if(i)return null;const w=!y&&!nt(k,s);return y||w?p():null},[i,y,s,k,p]);return j!==null?j:f}function sf(e){const t=yi(),{name:r,disabled:s,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=yc(a._names.array,r),u=N.useMemo(()=>M(a._formValues,r,M(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=N.useRef(e),f=N.useRef(null),b=N.useRef(a.register(r,{...e.rules,value:d,...rt(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=N.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!M(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!M(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!M(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!M(m.validatingFields,r)},error:{enumerable:!0,get:()=>M(m.errors,r)}}),[m,r]),x=N.useCallback(w=>{const E=Fa(w);return M(a._fields,r)||(b.current=a.register(r,{...h.current.rules,value:E})),b.current.onChange({target:{value:Fa(w),name:r},type:Kt.CHANGE})},[r,a]),y=N.useCallback(()=>b.current.onBlur({target:{value:M(a._formValues,r),name:r},type:Kt.BLUR}),[r,a._formValues]),k=N.useCallback(w=>{w&&(f.current={focus:()=>Be(w.focus)&&w.focus(),select:()=>Be(w.select)&&w.select(),setCustomValidity:F=>Be(w.setCustomValidity)&&w.setCustomValidity(F),reportValidity:()=>Be(w.reportValidity)&&w.reportValidity()});const E=M(a._fields,r);E&&E._f&&w&&(E._f.ref=f.current)},[a._fields,r]),j=N.useMemo(()=>({name:r,value:d,...rt(s)||m.disabled?{disabled:m.disabled||s}:{},onChange:x,onBlur:y,ref:k}),[r,s,m.disabled,x,y,k,d]);return N.useEffect(()=>{const w=a._options.shouldUnregister||i;a.register(r,{...h.current.rules,...rt(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(F,P)=>{const O=M(a._fields,F);O&&O._f&&(O._f.mount=P)};if(E(r,!0),w){const F=we(M(i?a._defaultValues:a._options.values||a._defaultValues,r,M(a._options.defaultValues,r,h.current.defaultValue)));ue(a._defaultValues,r,F),pe(M(a._formValues,r))&&ue(a._formValues,r,F)}if(!c&&a.register(r),f.current){const F=M(a._fields,r);F&&F._f&&(F._f.ref=f.current)}return()=>{(c?w&&!a._state.action:w)?a.unregister(r):E(r,!1)}},[r,a,c,i]),N.useEffect(()=>{a._setDisabledField({disabled:s,name:r})},[s,r,a]),N.useMemo(()=>({field:j,formState:m,fieldState:p}),[j,m,p])}const Re=e=>e.render(sf(e)),wc=e=>{const t={};for(const r of Object.keys(e))if(xi(e[r])&&e[r]!==null&&!ar(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=N.createContext(null);af.displayName="HookFormContext";var vi=(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):[],ds=e=>Array.isArray(e)?e:[e],wo=()=>{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&&ve(a)&&i){const o=kc(a,i);ve(o)&&(r[s]=o)}else e[s]&&(r[s]=i)}return r}var ze=e=>ve(e)&&!Object.keys(e).length,ji=e=>e.type==="file",ys=e=>{if(!Ds)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Cc=e=>e.type==="select-multiple",Ni=e=>e.type==="radio",of=e=>Ni(e)||Vn(e),Gs=e=>ys(e)&&e.isConnected;function lf(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;){if(Me(e)){e=void 0;break}e=e[t[s]],s++}return e}function cf(e){for(const t in e)if(e.hasOwnProperty(t)&&!pe(e[t]))return!1;return!0}function Ee(e,t){if(Ue(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:Bn(t)?[t]:Rs(t);if(r.some(o=>gi.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&&(ve(s)&&ze(s)||Array.isArray(s)&&cf(s))&&Ee(e,r.slice(0,-1)),e}var uf=e=>{for(const t in e)if(Be(e[t]))return!0;return!1};function Ac(e){return Array.isArray(e)||ve(e)&&!uf(e)}function Oa(e,t={}){for(const r in e){const s=e[r];Ac(s)?(t[r]=Array.isArray(s)?[]:{},Oa(s,t[r])):pe(s)||(t[r]=!0)}return t}function $a(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>$a(r));return t.some(r=>r!==void 0)?t:void 0}if(ve(e)){const t={};for(const r in e){const s=$a(e[r]);pe(s)||(t[r]=s)}return Object.keys(t).length?t:void 0}}}function yr(e,t,r){r||(r=Oa(t));for(const s in e){const a=e[s];if(Ac(a))pe(t)||Ra(r[s])?r[s]=Oa(a,Array.isArray(a)?[]:{}):yr(a,Me(t)?{}:t[s],r[s]);else{const i=t[s];r[s]=!nt(a,i)}}return $a(r)||{}}const So={value:!1,isValid:!1},ko={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&&!pe(e[0].attributes.value)?pe(e[0].value)||e[0].value===""?ko:{value:e[0].value,isValid:!0}:ko:So}return So},Ec=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>pe(e)?e:t?e===""?NaN:e&&+e:r&&Ue(e)?new Date(e):s?s(e):e;const Co={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,Co):Co;function Ao(e){const t=e.ref;return ji(t)?t.files:Ni(t)?_c(e.refs).value:Cc(t)?[...t.selectedOptions].map(({value:r})=>r):Vn(t)?Pc(e.refs).value:Ec(pe(t.value)?e.ref.value:t.value,e)}var df=(e,t,r,s)=>{const a={};for(const i of e){const o=M(t,i);o&&ue(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}},bs=e=>e instanceof RegExp,Nn=e=>pe(e)?e:bs(e)?e.source:ve(e)?bs(e.value)?e.value.source:e.value:e,Gn=e=>({isOnSubmit:!e||e===xt.onSubmit,isOnBlur:e===xt.onBlur,isOnChange:e===xt.onChange,isOnAll:e===xt.all,isOnTouch:e===xt.onTouched});const Po="AsyncFunction";var mf=e=>{if(!e||!e.validate)return!1;if(Be(e.validate))return e.validate.constructor.name===Po;if(ve(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Po)return!0}return!1},hf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Xs=(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 Pn=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const i=M(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(Pn(l,t))break}else if(ve(l)&&Pn(l,t))break}}};function Eo(e,t,r){const s=M(e,r);if(s||Bn(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=M(t,i),l=M(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||xt.all))},pf=(e,t,r)=>!e||!t||e===t||ds(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(M(e,t)).length&&Ee(e,t),_o=(e,t,r)=>{const s=M(e,r),a=Array.isArray(s)?s:[];return ue(a,vc,t[r]),ue(e,r,a),e};function To(e,t,r="validate"){if(Ue(e)||Array.isArray(e)&&e.every(Ue)||rt(e)&&!e)return{type:r,message:Ue(e)?e:"",ref:t}}var qr=e=>ve(e)&&!bs(e)?e:{value:e,message:""},Io=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:b,name:p,valueAsNumber:x,mount:y}=e._f,k=M(r,p);if(!y||t.has(p))return{};const j=l?l[0]:o,w=V=>{if(a&&j.reportValidity){const J=rt(V)?"":V||"";l?l.forEach(T=>T.setCustomValidity(J)):j.setCustomValidity(J),j.reportValidity()}},E={},F=Ni(o),P=Vn(o),O=F||P,Z=(x||ji(o))&&pe(o.value)&&pe(k)||ys(o)&&o.value===""||k===""||Array.isArray(k)&&!k.length,$=vi.bind(null,p,s,E),se=(V,J,T,W=ft.maxLength,H=ft.minLength)=>{const ce=V?J:T;E[p]={type:V?W:H,message:ce,ref:o,...$(V?W:H,ce)}};if(i?!Array.isArray(k)||!k.length:c&&(!O&&(Z||Me(k))||rt(k)&&!k||P&&!Pc(l).isValid||F&&!_c(l).isValid)){const{value:V,message:J}=Ue(c)?{value:!!c,message:c}:qr(c);if(V&&(E[p]={type:ft.required,message:J,ref:j,...$(ft.required,J)},!s))return w(J),E}if(!Z&&(!Me(m)||!Me(h))){let V,J;const T=qr(h),W=qr(m);if(!Me(k)&&!isNaN(k)){const H=o.valueAsNumber||k&&+k;Me(T.value)||(V=H>T.value),Me(W.value)||(J=H<W.value)}else{const H=o.valueAsDate||new Date(k),ce=Ke=>new Date(new Date().toDateString()+" "+Ke),xe=o.type=="time",$e=o.type=="week";Ue(T.value)&&k&&(V=xe?ce(k)>ce(T.value):$e?k>T.value:H>new Date(T.value)),Ue(W.value)&&k&&(J=xe?ce(k)<ce(W.value):$e?k<W.value:H<new Date(W.value))}if((V||J)&&(se(!!V,T.message,W.message,ft.max,ft.min),!s))return w(E[p].message),E}if((u||d)&&!Z&&(Ue(k)||i&&Array.isArray(k))){const V=qr(u),J=qr(d),T=!Me(V.value)&&k.length>+V.value,W=!Me(J.value)&&k.length<+J.value;if((T||W)&&(se(T,V.message,J.message),!s))return w(E[p].message),E}if(f&&!Z&&Ue(k)){const{value:V,message:J}=qr(f);if(bs(V)&&!k.match(V)&&(E[p]={type:ft.pattern,message:J,ref:o,...$(ft.pattern,J)},!s))return w(J),E}if(b){if(Be(b)){const V=await b(k,r),J=To(V,j);if(J&&(E[p]={...J,...$(ft.validate,J.message)},!s))return w(J.message),E}else if(ve(b)){let V={};for(const J in b){if(!ze(V)&&!s)break;const T=To(await b[J](k,r),j,J);T&&(V={...T,...$(J,T.message)},w(T.message),s&&(E[p]=V))}if(!ze(V)&&(E[p]={ref:j,...V},!s))return E}}return w(!0),E};const yf={mode:xt.onSubmit,reValidateMode:xt.onChange,shouldFocusError:!0},ea="form",Tc={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={...we(Tc),isLoading:Be(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},s={},a=ve(t.defaultValues)||ve(t.values)?we(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:we(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0,d=0,m=Gn(t.mode),h=Gn(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={...f};let p={...b};const x={array:wo(),state:wo()},y=t.criteriaMode===xt.all,k=g=>S=>{clearTimeout(u),u=setTimeout(g,S)},j=async g=>{if(!o.keepIsValid&&!t.disabled&&(b.isValid||p.isValid||g)){let S;t.resolver?(S=ze((await J()).errors),w()):S=await H({fields:s,onlyCheckValid:!0,eventType:Kt.VALID}),S!==r.isValid&&x.state.next({isValid:S})}},w=(g,S)=>{!t.disabled&&(b.isValidating||b.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(l.mount)).forEach(C=>{C&&(S?ue(r.validatingFields,C,S):Ee(r.validatingFields,C))}),x.state.next({validatingFields:r.validatingFields,isValidating:!ze(r.validatingFields)}))},E=()=>{r.dirtyFields=yr(a,i)},F=(g,S=[],C,D,R=!0,U=!0)=>{if(D&&C&&!t.disabled){if(o.action=!0,U&&Array.isArray(M(s,g))){const L=C(M(s,g),D.argA,D.argB);R&&ue(s,g,L)}if(U&&Array.isArray(M(r.errors,g))){const L=C(M(r.errors,g),D.argA,D.argB);R&&ue(r.errors,g,L),gf(r.errors,g)}if((b.touchedFields||p.touchedFields)&&U&&Array.isArray(M(r.touchedFields,g))){const L=C(M(r.touchedFields,g),D.argA,D.argB);R&&ue(r.touchedFields,g,L)}(b.dirtyFields||p.dirtyFields)&&E(),x.state.next({name:g,isDirty:xe(g,S),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ue(i,g,S)},P=(g,S)=>{ue(r.errors,g,S),r.errors={...r.errors},x.state.next({errors:r.errors})},O=g=>{r.errors=g,x.state.next({errors:r.errors,isValid:!1})},Z=g=>{const S=Bn(g)?[g]:Rs(g);let C=i,D=a;for(let R=0;R<S.length-1;R++){const U=S[R];if(C=Me(C)?C:C[U],D=Me(D)?D:D[U],C===null&&D!==null)return!0}return!1},$=(g,S,C,D)=>{const R=M(s,g);if(R){if(Z(g))return;const U=pe(M(i,g)),L=M(i,g,pe(C)?M(a,g):C);pe(L)||D&&D.defaultChecked||S?ue(i,g,S?L:Ao(R._f)):Xe(g,L),o.mount&&!o.action&&(j(),U&&r.isDirty&&(b.isDirty||p.isDirty)&&(xe()||(r.isDirty=!1,x.state.next({...r}))),e.shouldUnregister&&U&&!pe(M(i,g))&&Xs(g,l)&&(o.watch=!0))}},se=(g,S,C,D,R)=>{let U=!1,L=!1;const Y={name:g};if(!t.disabled){if(!C||D){const z=nt(M(a,g),S);(b.isDirty||p.isDirty)&&(L=r.isDirty,r.isDirty=Y.isDirty=!z||xe(),U=L!==Y.isDirty),L=!!M(r.dirtyFields,g),z!==r.isDirty?r.dirtyFields=yr(a,i):z?Ee(r.dirtyFields,g):ue(r.dirtyFields,g,!0),Y.dirtyFields=r.dirtyFields,U=U||(b.dirtyFields||p.dirtyFields)&&L!==!z}if(C){const z=M(r.touchedFields,g);z||(ue(r.touchedFields,g,C),Y.touchedFields=r.touchedFields,U=U||(b.touchedFields||p.touchedFields)&&z!==C)}U&&R&&x.state.next(Y)}return U?Y:{}},V=(g,S,C,D)=>{const R=M(r.errors,g),U=(b.isValid||p.isValid)&&rt(S)&&r.isValid!==S;if(t.delayError&&C?(c=k(()=>P(g,C)),c(t.delayError)):(clearTimeout(u),c=null,C?ue(r.errors,g,C):Ee(r.errors,g),r.errors={...r.errors}),(C?!nt(R,C):R)||!ze(D)||U){const L={...D,...U&&rt(S)?{isValid:S}:{},errors:r.errors,name:g};r={...r,...L},x.state.next(L)}},J=async g=>(w(g,!0),await t.resolver(i,t.context,df(g||l.mount,s,t.criteriaMode,t.shouldUseNativeValidation))),T=async g=>{const{errors:S}=await J(g);if(w(g),g){for(const C of g){const D=M(S,C);D?l.array.has(C)&&ve(D)&&!Object.keys(D).some(R=>!Number.isNaN(Number(R)))?_o(r.errors,{[C]:D},C):ue(r.errors,C,D):Ee(r.errors,C)}r.errors={...r.errors}}else r.errors=S;return S},W=async({name:g,eventType:S})=>{if(e.validate){const C=await e.validate({formValues:i,formState:r,name:g,eventType:S});if(ve(C))for(const D in C){const R=C[D];R&&ht(`${ea}.${D}`,{message:Ue(R.message)?R.message:"",type:R.type||ft.validate})}else Ue(C)||!C?ht(ea,{message:C||"",type:ft.validate}):Ie(ea);return C}return!0},H=async({fields:g,onlyCheckValid:S,name:C,eventType:D,context:R={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(R.runRootValidation=!0,!await W({name:C,eventType:D})&&(R.valid=!1,S)))return R.valid;for(const U in g){const L=g[U];if(L){const{_f:Y,...z}=L;if(Y){const re=l.array.has(Y.name),Fe=L._f&&mf(L._f),Ft=b.validatingFields||b.isValidating||p.validatingFields||p.isValidating;Fe&&Ft&&w([Y.name],!0);const Dt=await Io(L,l.disabled,i,y,t.shouldUseNativeValidation&&!S,re);if(Fe&&Ft&&w([Y.name]),Dt[Y.name]&&(R.valid=!1,S)||(!S&&(M(Dt,Y.name)?re?_o(r.errors,Dt,Y.name):ue(r.errors,Y.name,Dt[Y.name]):Ee(r.errors,Y.name)),e.shouldUseNativeValidation&&Dt[Y.name]))break}!ze(z)&&await H({context:R,onlyCheckValid:S,fields:z,name:U,eventType:D})}}return R.valid},ce=()=>{for(const g of l.unMount){const S=M(s,g);S&&(S._f.refs?S._f.refs.every(C=>!Gs(C)):!Gs(S._f.ref))&&_t(g)}l.unMount=new Set},xe=(g,S)=>!t.disabled&&(g&&S&&ue(i,g,S),!nt(o.mount?i:a,a)),$e=(g,S,C)=>Da(g,l,{...o.mount?i:pe(S)?a:Ue(g)?{[g]:S}:S},C,S),Ke=g=>Sc(M(o.mount?i:a,g,t.shouldUnregister?M(a,g,[]):[])),Xe=(g,S,C={},D=!1,R=!1)=>{const U=M(s,g);let L=S;if(U){const Y=U._f;Y&&(!Y.disabled&&ue(i,g,Ec(S,Y)),L=ys(Y.ref)&&Me(S)?"":S,Cc(Y.ref)?[...Y.ref.options].forEach(z=>z.selected=L.includes(z.value)):Y.refs?Vn(Y.ref)?Y.refs.forEach(z=>{(!z.defaultChecked||!z.disabled)&&(Array.isArray(L)?z.checked=!!L.find(re=>re===z.value):z.checked=L===z.value||!!L)}):Y.refs.forEach(z=>z.checked=z.value===L):ji(Y.ref)?Y.ref.value="":(Y.ref.value=L,!Y.ref.type&&!R&&x.state.next({name:g,values:D?i:we(i)})))}(C.shouldDirty||C.shouldTouch)&&se(g,L,C.shouldTouch,C.shouldDirty,!R),C.shouldValidate&&mt(g)},oe=(g,S,C,D=!1,R=!1)=>{for(const U in S){if(!S.hasOwnProperty(U))return;const L=S[U],Y=g+"."+U,z=M(s,Y);(l.array.has(g)||ve(L)||z&&!z._f)&&!ar(L)?oe(Y,L,C,D,R):Xe(Y,L,C,D,R)}},Pe=(g,S,C,D,R=!1)=>{const U=M(s,g),L=l.array.has(g),Y=D?S:we(S),z=M(i,g),re=nt(z,Y);if(re||ue(i,g,Y),L)x.array.next({name:g,values:D?i:we(i)}),(b.isDirty||b.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&(E(),R||x.state.next({name:g,dirtyFields:r.dirtyFields,isDirty:xe(g,Y)}));else{const Fe=Array.isArray(Y)&&!Y.length||ze(Y);!U||U._f||Me(Y)||Fe?Xe(g,Y,C,D,R):oe(g,Y,C,D,R)}if(!re&&!R){const Fe=Xs(g,l),Ft=D?i:we(i);x.state.next({...Fe&&r,name:o.mount||Fe?g:void 0,values:Ft})}},_e=(g,S,C={})=>Pe(g,S,C,!1),Q=(g,S={})=>{const C=Be(g)?g(i):g;if(!nt(i,C)){i={...i,...C};const D=wc(C);for(const R of l.mount)R in D&&Pe(R,D[R],S,!0,!0);x.state.next({...r,name:void 0,type:void 0,...d?{values:i}:{}}),S.shouldValidate&&j()}},Le=async g=>{o.mount=!0;const S=g.target;let C=S.name,D=!0;const R=M(s,C),U=L=>{D=Number.isNaN(L)||ar(L)&&isNaN(L.getTime())||nt(L,M(i,C,L))};if(R){let L,Y;const z=S.type?Ao(R._f):Fa(g),re=g.type===Kt.BLUR||g.type===Kt.FOCUS_OUT,Fe=!hf(R._f)&&!e.validate&&!t.resolver&&!M(r.errors,C)&&!R._f.deps,Ft=Fe||xf(re,M(r.touchedFields,C),r.isSubmitted,h,m),Dt=Xs(C,l,re);ue(i,C,z),re?(!S||!S.readOnly)&&(R._f.onBlur&&R._f.onBlur(g),c&&c(0)):R._f.onChange&&R._f.onChange(g);const bn=se(C,z,re),Qu=!ze(bn)||Dt;if(!re&&x.state.next({name:C,type:g.type,...d?{values:we(i)}:{}}),Ft)return(!Fe||!r.isValid)&&(b.isValid||p.isValid)&&(t.mode==="onBlur"?re&&j():re||j()),Qu&&x.state.next({name:C,...Dt?{}:bn});if(!t.resolver&&e.validate&&await W({name:C,eventType:g.type}),!re&&Dt&&x.state.next({...r}),t.resolver){const{errors:to}=await J([C]);if(w([C]),U(z),!D){!ze(bn)&&x.state.next(bn);return}const Ju=Eo(r.errors,s,C),ro=Eo(to,s,Ju.name||C);L=ro.error,C=ro.name,Y=ze(to)}else w([C],!0),L=(await Io(R,l.disabled,i,y,t.shouldUseNativeValidation))[C],w([C]),U(z),D&&(L?Y=!1:(b.isValid||p.isValid)&&(Y=await H({fields:s,onlyCheckValid:!0,name:C,eventType:g.type})));D&&(R._f.deps&&(!Array.isArray(R._f.deps)||R._f.deps.length>0)&&mt(R._f.deps),V(C,Y,L,bn))}},dt=(g,S)=>{if(M(r.errors,S)&&g.focus)return g.focus(),1},mt=async(g,S={})=>{let C,D;const R=ds(g);if(t.resolver){const U=await T(pe(g)?g:R);C=ze(U),D=g?!R.some(L=>M(U,L)):C}else g?(D=(await Promise.all(R.map(async U=>{const L=M(s,U);return await H({fields:L&&L._f?{[U]:L}:L,eventType:Kt.TRIGGER})}))).every(Boolean),!(!D&&!r.isValid)&&j()):D=C=await H({fields:s,name:g,eventType:Kt.TRIGGER});return x.state.next({...!Ue(g)||(b.isValid||p.isValid)&&C!==r.isValid?{}:{name:g},...t.resolver||!g?{isValid:C}:{},errors:r.errors}),S.shouldFocus&&!D&&Pn(s,dt,g?R:l.mount),D},Pt=(g,S)=>{let C={...o.mount?i:a};return S&&(C=kc(S.dirtyFields?r.dirtyFields:r.touchedFields,C)),pe(g)?C:Ue(g)?M(C,g):g.map(D=>M(C,D))},le=(g,S)=>({invalid:!!M((S||r).errors,g),isDirty:!!M((S||r).dirtyFields,g),error:M((S||r).errors,g),isValidating:!!M(r.validatingFields,g),isTouched:!!M((S||r).touchedFields,g)}),Ie=g=>{const S=g?ds(g):void 0;S==null||S.forEach(C=>Ee(r.errors,C)),S?S.forEach(C=>{x.state.next({name:C,errors:r.errors})}):x.state.next({errors:{}})},ht=(g,S,C)=>{const D=(M(s,g,{_f:{}})._f||{}).ref,R=M(r.errors,g)||{},{ref:U,message:L,type:Y,...z}=R;ue(r.errors,g,{...z,...S,ref:D}),x.state.next({name:g,errors:r.errors,isValid:!1}),C&&C.shouldFocus&&D&&D.focus&&D.focus()},Et=(g,S)=>{if(Be(g)){d++;const{unsubscribe:C}=x.state.subscribe({next:R=>"values"in R&&g(R.values||$e(void 0,S),R)});let D=!1;return{unsubscribe:()=>{D||(D=!0,d--,C())}}}return $e(g,S,!0)},yt=g=>{var S;const C=!!(!((S=g.formState)===null||S===void 0)&&S.values);C&&d++;const{unsubscribe:D}=x.state.subscribe({next:U=>{if(pf(g.name,U.name,g.exact)&&ff(U,g.formState||b,xr,g.reRenderRoot)){const L={...i};g.callback({values:L,...r,...U,defaultValues:a})}}});if(!C)return D;let R=!1;return()=>{R||(R=!0,d--,D())}},mr=g=>(o.mount=!0,p={...p,...g.formState},yt({...g,formState:{...f,...g.formState}})),_t=(g,S={})=>{for(const C of g?ds(g):l.mount)l.mount.delete(C),l.array.delete(C),S.keepValue||(Ee(s,C),Ee(i,C)),!S.keepError&&Ee(r.errors,C),!S.keepDirty&&Ee(r.dirtyFields,C),!S.keepTouched&&Ee(r.touchedFields,C),!S.keepIsValidating&&Ee(r.validatingFields,C),!t.shouldUnregister&&!S.keepDefaultValue&&Ee(a,C);x.state.next({values:we(i)}),x.state.next({...r,...S.keepDirty?{isDirty:xe()}:{}}),!S.keepIsValid&&j()},Ut=({disabled:g,name:S})=>{if(rt(g)&&o.mount||g||l.disabled.has(S)){const R=l.disabled.has(S)!==!!g;g?l.disabled.add(S):l.disabled.delete(S),R&&o.mount&&!o.action&&j()}},Tt=(g,S={})=>{let C=M(s,g);const D=rt(S.disabled)||rt(t.disabled),R=!l.registerName.has(g)&&C&&C._f&&!C._f.mount;return ue(s,g,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:g}},name:g,mount:!0,...S}}),l.mount.add(g),C&&!R?Ut({disabled:rt(S.disabled)?S.disabled:t.disabled,name:g}):$(g,!0,S.value),{...D?{disabled:S.disabled||t.disabled}:{},...t.progressive?{required:!!S.required,min:Nn(S.min),max:Nn(S.max),minLength:Nn(S.minLength),maxLength:Nn(S.maxLength),pattern:Nn(S.pattern)}:{},name:g,onChange:Le,onBlur:Le,ref:U=>{if(U){l.registerName.add(g),Tt(g,S),l.registerName.delete(g),C=M(s,g);const L=pe(U.value)&&U.querySelectorAll&&U.querySelectorAll("input,select,textarea")[0]||U,Y=of(L),z=C._f.refs||[];if(Y?z.find(re=>re===L):L===C._f.ref)return;ue(s,g,{_f:{...C._f,...Y?{refs:[...z.filter(Gs),L,...Array.isArray(M(a,g))?[{}]:[]],ref:{type:L.type,name:g}}:{ref:L}}}),$(g,!1,void 0,L)}else C=M(s,g,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||S.shouldUnregister)&&!(yc(l.array,g)&&o.action)&&l.unMount.add(g)}}},It=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Pn(s,dt,l.mount),hr=g=>{rt(g)&&(x.state.next({disabled:g}),Pn(s,(S,C)=>{const D=M(s,C);D&&(S.disabled=D._f.disabled||g,Array.isArray(D._f.refs)&&D._f.refs.forEach(R=>{R.disabled=D._f.disabled||g}))},0,!1))},Zt=(g,S)=>async C=>{let D;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let R=we(i);if(x.state.next({isSubmitting:!0}),t.resolver){const{errors:U,values:L}=await J();w(),r.errors=U,R=we(L)}else await H({fields:s,eventType:Kt.SUBMIT});if(l.disabled.size)for(const U of l.disabled)Ee(R,U);if(Ee(r.errors,vc),ze(r.errors)){x.state.next({errors:{}});try{await g(R,C)}catch(U){D=U}}else S&&await S({...r.errors},C),It(),setTimeout(It);if(x.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ze(r.errors)&&!D,submitCount:r.submitCount+1,errors:r.errors}),D)throw D},fr=(g,S={})=>{M(s,g)&&(pe(S.defaultValue)?_e(g,we(M(a,g))):(_e(g,S.defaultValue),ue(a,g,we(S.defaultValue))),S.keepTouched||Ee(r.touchedFields,g),S.keepDirty||(Ee(r.dirtyFields,g),r.isDirty=S.defaultValue?xe(g,we(M(a,g))):xe()),S.keepError||(Ee(r.errors,g),b.isValid&&j()),x.state.next({...r}))},Wt=(g,S={})=>{const C=g?we(g):a,D=we(C),R=ze(g),U=D;if(S.keepDefaultValues||(a=C),!S.keepValues){if(S.keepDirtyValues){const L=new Set([...l.mount,...Object.keys(yr(a,i))]);for(const Y of Array.from(L)){const z=M(r.dirtyFields,Y),re=M(i,Y),Fe=M(U,Y);z&&!pe(re)?ue(U,Y,re):!z&&!pe(Fe)&&_e(Y,Fe)}}else{if(Ds&&pe(g))for(const L of l.mount){const Y=M(s,L);if(Y&&Y._f){const z=Array.isArray(Y._f.refs)?Y._f.refs[0]:Y._f.ref;if(ys(z)){const re=z.closest("form");if(re){re.reset();break}}}}if(S.keepFieldsRef)for(const L of l.mount)_e(L,M(U,L));else s={}}if(t.shouldUnregister){if(i=S.keepDefaultValues?we(a):{},S.keepFieldsRef)for(const L of l.mount)ue(i,L,M(U,L))}else i=we(U);x.array.next({values:{...U}}),x.state.next({name:void 0,type:void 0,values:{...U}})}l={mount:S.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!b.isValid||!!S.keepIsValid||!!S.keepDirtyValues||!t.shouldUnregister&&!ze(U),o.watch=!!t.shouldUnregister,o.keepIsValid=!!S.keepIsValid,o.action=!1,S.keepErrors||(r.errors={}),x.state.next({submitCount:S.keepSubmitCount?r.submitCount:0,isDirty:R?!1:S.keepDirty?r.isDirty:S.keepValues?xe():!!(S.keepDefaultValues&&!nt(g,a)),isSubmitted:S.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:R?{}:S.keepDirtyValues?S.keepDefaultValues&&i?yr(a,i):r.dirtyFields:S.keepDefaultValues&&g?yr(a,g):S.keepDirty?r.dirtyFields:{},touchedFields:S.keepTouched?r.touchedFields:{},errors:S.keepErrors?r.errors:{},isSubmitSuccessful:S.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Yt=(g,S)=>Wt(Be(g)?g(i):g,{...t.resetOptions,...S}),pr=(g,S={})=>{const C=M(s,g),D=C&&C._f;if(D){const R=D.refs?D.refs[0]:D.ref;R.focus&&setTimeout(()=>{R.focus(),S.shouldSelect&&Be(R.select)&&R.select()})}},xr=g=>{const{name:S,type:C,values:D,...R}=g;r={...r,...R}},ae={control:{register:Tt,unregister:_t,getFieldState:le,handleSubmit:Zt,setError:ht,_subscribe:yt,_runSchema:J,_updateIsValidating:w,_focusError:It,_getWatch:$e,_getDirty:xe,_setValid:j,_setFieldArray:F,_setDisabledField:Ut,_setErrors:O,_getFieldArray:Ke,_reset:Wt,_resetDefaultValues:()=>Be(t.defaultValues)&&t.defaultValues().then(g=>{Yt(g,t.resetOptions),x.state.next({isLoading:!1})}),_removeUnmounted:ce,_disableForm:hr,_subjects:x,_proxyFormState:b,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(g){o=g},get _defaultValues(){return a},get _names(){return l},set _names(g){l=g},get _formState(){return r},get _options(){return t},set _options(g){t={...t,...g},m=Gn(t.mode),h=Gn(t.reValidateMode)}},subscribe:mr,trigger:mt,register:Tt,handleSubmit:Zt,watch:Et,setValue:_e,setValues:Q,getValues:Pt,reset:Yt,resetField:fr,resetDefaultValues:(g,S={})=>{if(a=we(g),!S.keepDirty){const C=yr(a,i);r.dirtyFields=C,r.isDirty=!ze(C)}S.keepIsValid||j(),x.state.next({...r,defaultValues:a})},clearErrors:Ie,unregister:_t,setError:ht,setFocus:pr,getFieldState:le};return{...ae,formControl:ae}}function St(e={}){const t=N.useRef(void 0),r=N.useRef(void 0),s=N.useRef(e.formControl),[a,i]=N.useState(()=>({...we(Tc),isLoading:Be(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Be(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&&!Be(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,bi(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,l},[o]),N.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),N.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),N.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),N.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),N.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),N.useEffect(()=>{var l;e.values&&!nt(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),N.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=N.useMemo(()=>Nc(a,o),[o,a]),t.current}const Fo=(e,t,r)=>{if(e&&"reportValidity"in e){const s=M(r,t);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},La=(e,t)=>{for(const r in t.fields){const s=t.fields[r];s&&s.ref&&"reportValidity"in s.ref?Fo(s.ref,r,e):s&&s.refs&&s.refs.forEach(a=>Fo(a,r,e))}},Do=(e,t)=>{t.shouldUseNativeValidation&&La(e,t);const r={};for(const s in e){const a=M(t.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(vf(t.names||Object.keys(e),s)){const o=Object.assign({},M(r,s));ue(o,"root",i),ue(r,s,o)}else ue(r,s,i)}return r},vf=(e,t)=>{const r=Ro(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(s=>Ro(s).match(`^${r}\\.\\d+`))};function Ro(e){return e.replace(/[\[\]]/g,"")}var Oo;function I(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 Zr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ic extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Oo=globalThis).__zod_globalConfig??(Oo.__zod_globalConfig={});const wi=globalThis.__zod_globalConfig;function Ir(e){return wi}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 za(e,t){return typeof t=="bigint"?t.toString():t}function Si(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ki(e){return e==null}function Ci(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const $o=Symbol("evaluating");function he(e,t,r){let s;Object.defineProperty(e,t,{get(){if(s!==$o)return s===void 0&&(s=$o,s=r()),s},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Lr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function cr(...e){const t={};for(const r of e){const s=Object.getOwnPropertyDescriptors(r);Object.assign(t,s)}return Object.defineProperties({},t)}function Lo(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 vs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Nf=Si(()=>{var e;if(wi.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 In(e){if(vs(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(vs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Rc(e){return In(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 cn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ur(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 te(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=cr(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=r.shape[l])}return Lr(this,"shape",o),o},checks:[]});return ur(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=cr(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in r.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Lr(this,"shape",o),o},checks:[]});return ur(e,i)}function Af(e,t){if(!In(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=cr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Lr(this,"shape",i),i}});return ur(e,a)}function Pf(e,t){if(!In(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=cr(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Lr(this,"shape",s),s}});return ur(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=cr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Lr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ur(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=cr(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(r)for(const u in r){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return Lr(this,"shape",c),c},checks:[]});return ur(t,o)}function Tf(e,t,r){const s=cr(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return Lr(this,"shape",i),i}});return ur(t,s)}function Br(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 If(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 Xn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Fr(e,t,r){var c,u,d,m,h,f;const s=e.message?e.message:Xn((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??Xn((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??Xn((h=r.customError)==null?void 0:h.call(r,e))??Xn((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 Ai(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fn(...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,za,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pi=I("$ZodError",$c),Os=I("$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 $s=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 Zr;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Fr(c,i,Ir())));throw Dc(l,a==null?void 0:a.callee),l}return o.value},Rf=$s(Os),Ls=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=>Fr(c,i,Ir())));throw Dc(l,a==null?void 0:a.callee),l}return o.value},Of=Ls(Os),zs=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 Zr;return i.issues.length?{success:!1,error:new(e??Pi)(i.issues.map(o=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},$f=zs(Os),Ms=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=>Fr(o,a,Ir())))}:{success:!0,data:i.value}},Lf=Ms(Os),zf=e=>(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return $s(e)(t,r,a)},Mf=e=>(t,r,s)=>$s(e)(t,r,s),qf=e=>async(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Ls(e)(t,r,a)},Vf=e=>async(t,r,s)=>Ls(e)(t,r,s),Bf=e=>(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return zs(e)(t,r,a)},Uf=e=>(t,r,s)=>zs(e)(t,r,s),Zf=e=>async(t,r,s)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return Ms(e)(t,r,a)},Wf=e=>async(t,r,s)=>Ms(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})$/,zo=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]*$/,kt=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),yp=I("$ZodCheckMaxLength",(e,t)=>{var r;kt.init(e,t),(r=e._zod.def).when??(r.when=s=>{const a=s.value;return!ki(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=Ai(a);s.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),bp=I("$ZodCheckMinLength",(e,t)=>{var r;kt.init(e,t),(r=e._zod.def).when??(r.when=s=>{const a=s.value;return!ki(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=Ai(a);s.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),vp=I("$ZodCheckLengthEquals",(e,t)=>{var r;kt.init(e,t),(r=e._zod.def).when??(r.when=s=>{const a=s.value;return!ki(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=Ai(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})}}),qs=I("$ZodCheckStringFormat",(e,t)=>{var r,s;kt.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=I("$ZodCheckRegex",(e,t)=>{qs.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=I("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xp),qs.init(e,t)}),wp=I("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=gp),qs.init(e,t)}),Sp=I("$ZodCheckIncludes",(e,t)=>{kt.init(e,t);const r=cn(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=I("$ZodCheckStartsWith",(e,t)=>{kt.init(e,t);const r=new RegExp(`^${cn(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=I("$ZodCheckEndsWith",(e,t)=>{kt.init(e,t);const r=new RegExp(`.*${cn(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=I("$ZodCheckOverwrite",(e,t)=>{kt.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},Ce=I("$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=Br(l),m;for(const h of c){if(h._zod.def.when){if(If(l)||!h._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,b=h._zod.check(l);if(b instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Zr;if(m||b instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await b,l.issues.length!==f&&(d||(d=Br(l,f)))});else{if(l.issues.length===f)continue;d||(d=Br(l,f))}}return m?m.then(()=>l):l},o=(l,c,u)=>{if(Br(l))return l.aborted=!0,l;const d=i(c,s,u);if(d instanceof Promise){if(u.async===!1)throw new Zr;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 Zr;return u.then(d=>i(d,s,c))}return i(u,s,c)}}he(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}))}),Ei=I("$ZodString",(e,t)=>{var r;Ce.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}}),be=I("$ZodStringFormat",(e,t)=>{qs.init(e,t),Ei.init(e,t)}),_p=I("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ep),be.init(e,t)}),Tp=I("$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=zo(s))}else t.pattern??(t.pattern=zo());be.init(e,t)}),Ip=I("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tp),be.init(e,t)}),Fp=I("$ZodURL",(e,t)=>{be.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=I("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=np()),be.init(e,t)}),Rp=I("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Gf),be.init(e,t)}),Op=I("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yf),be.init(e,t)}),$p=I("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Hf),be.init(e,t)}),Lp=I("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Kf),be.init(e,t)}),zp=I("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qf),be.init(e,t)}),Mp=I("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Jf),be.init(e,t)}),qp=I("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hp(t)),be.init(e,t)}),Vp=I("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=dp),be.init(e,t)}),Bp=I("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=mp(t)),be.init(e,t)}),Up=I("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Xf),be.init(e,t)}),Zp=I("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=sp),be.init(e,t),e._zod.bag.format="ipv4"}),Wp=I("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ap),be.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=I("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ip),be.init(e,t)}),Hp=I("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=op),be.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=I("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=lp),be.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=I("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Lc),be.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=I("$ZodE164",(e,t)=>{t.pattern??(t.pattern=up),be.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=I("$ZodJWT",(e,t)=>{be.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=I("$ZodBoolean",(e,t)=>{Ce.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=I("$ZodUnknown",(e,t)=>{Ce.init(e,t),e._zod.parse=r=>r}),nx=I("$ZodNever",(e,t)=>{Ce.init(e,t),e._zod.parse=(r,s)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Mo(e,t,r){e.issues.length&&t.issues.push(...Oc(r,e.issues)),t.value[r]=e.value}const sx=I("$ZodArray",(e,t)=>{Ce.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=>Mo(u,r,o))):Mo(c,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function js(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(b=>js(b,r,h,t,d,m))):js(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=I("$ZodObject",(e,t)=>{Ce.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=Si(()=>Vc(t));he(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=vs,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],b=f._zod.optin==="optional",p=f._zod.optout==="optional",x=f._zod.run({value:u[h],issues:[]},c);x instanceof Promise?d.push(x.then(y=>js(y,l,h,u,b,p))):js(x,l,h,u,b,p)}return i?Bc(d,u,l,c,s.value,e):d.length?Promise.all(d).then(()=>l):l}}),ix=I("$ZodObjectJIT",(e,t)=>{ax.init(e,t);const r=e._zod.parse,s=Si(()=>Vc(t)),a=h=>{var j,w;const f=new Pp(["shape","payload","ctx"]),b=s.value,p=E=>{const F=Lo(E);return`shape[${F}]._zod.run({ value: input[${F}], issues: [] }, ctx)`};f.write("const input = payload.value;");const x=Object.create(null);let y=0;for(const E of b.keys)x[E]=`key_${y++}`;f.write("const newResult = {};");for(const E of b.keys){const F=x[E],P=Lo(E),O=h[E],Z=((j=O==null?void 0:O._zod)==null?void 0:j.optin)==="optional",$=((w=O==null?void 0:O._zod)==null?void 0:w.optout)==="optional";f.write(`const ${F} = ${p(E)};`),Z&&$?f.write(`
15
+ if (${F}.issues.length) {
16
+ if (${P} in input) {
17
+ payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
18
18
  ...iss,
19
- path: iss.path ? [${w}, ...iss.path] : [${w}]
19
+ path: iss.path ? [${P}, ...iss.path] : [${P}]
20
20
  })));
21
21
  }
22
22
  }
23
23
 
24
- if (${I}.value === undefined) {
25
- if (${w} in input) {
26
- newResult[${w}] = undefined;
24
+ if (${F}.value === undefined) {
25
+ if (${P} in input) {
26
+ newResult[${P}] = undefined;
27
27
  }
28
28
  } else {
29
- newResult[${w}] = ${I}.value;
29
+ newResult[${P}] = ${F}.value;
30
30
  }
31
31
 
32
- `):D?f.write(`
33
- if (${I}.issues.length) {
34
- payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
32
+ `):Z?f.write(`
33
+ if (${F}.issues.length) {
34
+ payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
35
35
  ...iss,
36
- path: iss.path ? [${w}, ...iss.path] : [${w}]
36
+ path: iss.path ? [${P}, ...iss.path] : [${P}]
37
37
  })));
38
38
  }
39
39
 
40
- if (${I}.value === undefined) {
41
- if (${w} in input) {
42
- newResult[${w}] = undefined;
40
+ if (${F}.value === undefined) {
41
+ if (${P} in input) {
42
+ newResult[${P}] = undefined;
43
43
  }
44
44
  } else {
45
- newResult[${w}] = ${I}.value;
45
+ newResult[${P}] = ${F}.value;
46
46
  }
47
47
 
48
48
  `):f.write(`
49
- const ${I}_present = ${w} in input;
50
- if (${I}.issues.length) {
51
- payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
49
+ const ${F}_present = ${P} in input;
50
+ if (${F}.issues.length) {
51
+ payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
52
52
  ...iss,
53
- path: iss.path ? [${w}, ...iss.path] : [${w}]
53
+ path: iss.path ? [${P}, ...iss.path] : [${P}]
54
54
  })));
55
55
  }
56
- if (!${I}_present && !${I}.issues.length) {
56
+ if (!${F}_present && !${F}.issues.length) {
57
57
  payload.issues.push({
58
58
  code: "invalid_type",
59
59
  expected: "nonoptional",
60
60
  input: undefined,
61
- path: [${w}]
61
+ path: [${P}]
62
62
  });
63
63
  }
64
64
 
65
- if (${I}_present) {
66
- if (${I}.value === undefined) {
67
- newResult[${w}] = undefined;
65
+ if (${F}_present) {
66
+ if (${F}.value === undefined) {
67
+ newResult[${P}] = undefined;
68
68
  } else {
69
- newResult[${w}] = ${I}.value;
69
+ newResult[${P}] = ${F}.value;
70
70
  }
71
71
  }
72
72
 
73
- `)}f.write("payload.value = newResult;"),f.write("return payload;");const A=f.compile();return(E,I)=>A(h,E,I)};let i;const o=bs,l=!ji.jitless,u=l&&jf.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=n.value);const b=h.value;return o(b)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?qc([],b,h,f,m,e):h):r(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),h)}});function zo(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Br(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>Fr(o,n,Ir())))}),t)}const ix=T("$ZodUnion",(e,t)=>{Ce.init(e,t),me(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),me(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),me(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),me(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${n.map(a=>Si(a.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,a)=>{if(r)return r(n,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:n.value,issues:[]},a);if(c instanceof Promise)o.push(c),i=!0;else{if(c.issues.length===0)return c;o.push(c)}}return i?Promise.all(o).then(l=>zo(l,n,e,a)):zo(o,n,e,a)}}),ox=T("$ZodIntersection",(e,t)=>{Ce.init(e,t),e._zod.parse=(r,n)=>{const a=r.value,i=t.left._zod.run({value:a,issues:[]},n),o=t.right._zod.run({value:a,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Mo(r,c,u)):Mo(r,i,o)}});function La(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(In(e)&&In(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of n){const o=La(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};a[i]=o.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const a=e[n],i=t[n],o=La(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Mo(e,t,r){const n=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(l);for(const l of r.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(l);const i=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Br(e))return e;const o=La(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 lx=T("$ZodEnum",(e,t)=>{Ce.init(e,t);const r=Tc(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(a=>Nf.has(typeof a)).map(a=>typeof a=="string"?cn(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:r,input:o,inst:e}),a}}),cx=T("$ZodLiteral",(e,t)=>{if(Ce.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?cn(n):n?cn(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,a)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),ux=T("$ZodTransform",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new _c(e.constructor.name);const a=t.transform(r.value,r);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(r.value=o,r.fallback=!0,r));if(a instanceof Promise)throw new Zr;return r.value=a,r.fallback=!0,r}});function qo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Vc=T("$ZodOptional",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",e._zod.optout="optional",me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),me(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Si(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const a=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>qo(o,a)):qo(i,a)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),dx=T("$ZodExactOptional",(e,t)=>{Vc.init(e,t),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),mx=T("$ZodNullable",(e,t)=>{Ce.init(e,t),me(e._zod,"optin",()=>t.innerType._zod.optin),me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Si(r.source)}|null)$`):void 0}),me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),hx=T("$ZodDefault",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>Vo(i,t)):Vo(a,t)}});function Vo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const fx=T("$ZodPrefault",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),px=T("$ZodNonOptional",(e,t)=>{Ce.init(e,t),me(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>Bo(i,e)):Bo(a,e)}});function Bo(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 xx=T("$ZodCatch",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>Fr(o,n,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(i=>Fr(i,n,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),gx=T("$ZodPipe",(e,t)=>{Ce.init(e,t),me(e._zod,"values",()=>t.in._zod.values),me(e._zod,"optin",()=>t.in._zod.optin),me(e._zod,"optout",()=>t.out._zod.optout),me(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Xn(o,t.in,n)):Xn(i,t.in,n)}const a=t.in._zod.run(r,n);return a instanceof Promise?a.then(i=>Xn(i,t.out,n)):Xn(a,t.out,n)}});function Xn(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 yx=T("$ZodReadonly",(e,t)=>{Ce.init(e,t),me(e._zod,"propValues",()=>t.innerType._zod.propValues),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"optin",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),me(e._zod,"optout",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optout}),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(Uo):Uo(a)}});function Uo(e){return e.value=Object.freeze(e.value),e}const bx=T("$ZodCustom",(e,t)=>{kt.init(e,t),Ce.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,a=t.fn(n);if(a instanceof Promise)return a.then(i=>Zo(i,r,n,e));Zo(a,r,n,e)}});function Zo(e,t,r,n){if(!e){const a={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(a.params=n._zod.def.params),t.issues.push(Fn(a))}}var Wo;class vx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const a={...n,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function jx(){return new vx}(Wo=globalThis).__zod_globalRegistry??(Wo.__zod_globalRegistry=jx());const An=globalThis.__zod_globalRegistry;function Nx(e,t){return new e({type:"string",...X(t)})}function Bc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...X(t)})}function Yo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...X(t)})}function wx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...X(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...X(t)})}function kx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...X(t)})}function Cx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...X(t)})}function Ax(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...X(t)})}function Px(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...X(t)})}function Ex(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...X(t)})}function _x(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...X(t)})}function Tx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...X(t)})}function Ix(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...X(t)})}function Fx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...X(t)})}function Dx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...X(t)})}function Rx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...X(t)})}function Ox(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...X(t)})}function $x(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...X(t)})}function Lx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...X(t)})}function zx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...X(t)})}function Mx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...X(t)})}function qx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...X(t)})}function Vx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...X(t)})}function Bx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...X(t)})}function Ux(e,t){return new e({type:"string",format:"date",check:"string_format",...X(t)})}function Zx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...X(t)})}function Wx(e,t){return new e({type:"string",format:"duration",check:"string_format",...X(t)})}function Yx(e,t){return new e({type:"boolean",...X(t)})}function Hx(e){return new e({type:"unknown"})}function Kx(e,t){return new e({type:"never",...X(t)})}function Uc(e,t){return new gp({check:"max_length",...X(t),maximum:e})}function js(e,t){return new yp({check:"min_length",...X(t),minimum:e})}function Zc(e,t){return new bp({check:"length_equals",...X(t),length:e})}function Qx(e,t){return new vp({check:"string_format",format:"regex",...X(t),pattern:e})}function Jx(e){return new jp({check:"string_format",format:"lowercase",...X(e)})}function Gx(e){return new Np({check:"string_format",format:"uppercase",...X(e)})}function Xx(e,t){return new wp({check:"string_format",format:"includes",...X(t),includes:e})}function eg(e,t){return new Sp({check:"string_format",format:"starts_with",...X(t),prefix:e})}function tg(e,t){return new kp({check:"string_format",format:"ends_with",...X(t),suffix:e})}function gn(e){return new Cp({check:"overwrite",tx:e})}function rg(e){return gn(t=>t.normalize(e))}function ng(){return gn(e=>e.trim())}function sg(){return gn(e=>e.toLowerCase())}function ag(){return gn(e=>e.toUpperCase())}function ig(){return gn(e=>vf(e))}function og(e,t,r){return new e({type:"array",element:t,...X(r)})}function lg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...X(r)})}function cg(e,t){const r=ug(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Fn(a,n.value,r._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(Fn(i))}},e(n.value,n)),t);return r}function ug(e,t){const r=new kt({check:"custom",...X(t)});return r._zod.check=e,r}function Wc(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)??An,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 qe(e,t,r={path:[],schemaPath:[]}){var d,m;var n;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const l=(m=(d=e._zod).toJSONSchema)==null?void 0:m.call(d);if(l)o.schema=l;else{const h={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const b=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,b,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),qe(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"&&We(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Yc(e,t){var o,l,c,u;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const d of e.seen.entries()){const m=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(m){const h=n.get(m);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(m,d[0])}}const a=d=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=(p=e.external.registry.get(d[0]))==null?void 0:p.id,y=e.external.uri??(j=>j);if(g)return{ref:y(g)};const A=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=A,{defId:A,ref:`${y("__shared")}#/${m}/${A}`}}if(d[1]===r)return{ref:"#"};const f=`#/${m}/`,b=d[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:f+b}},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 b=m.schema;for(const p in b)delete b[p];b.$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,F)=>k(h,E,F)};let i;const o=vs,l=!wi.jitless,u=l&&Nf.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=s.value);const b=h.value;return o(b)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?Bc([],b,h,f,m,e):h):r(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),h)}});function qo(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=>!Br(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>Fr(o,s,Ir())))}),t)}const ox=I("$ZodUnion",(e,t)=>{Ce.init(e,t),he(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),he(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),he(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),he(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=>Ci(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=>qo(l,s,e,a)):qo(o,s,e,a)}}),lx=I("$ZodIntersection",(e,t)=>{Ce.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])=>Vo(r,c,u)):Vo(r,i,o)}});function Ma(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(In(e)&&In(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=Ma(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=Ma(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 Vo(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}),Br(e))return e;const o=Ma(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=I("$ZodEnum",(e,t)=>{Ce.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"?cn(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=I("$ZodLiteral",(e,t)=>{if(Ce.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"?cn(s):s?cn(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=I("$ZodTransform",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",e._zod.parse=(r,s)=>{if(s.direction==="backward")throw new Ic(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 Zr;return r.value=a,r.fallback=!0,r}});function Bo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Uc=I("$ZodOptional",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",e._zod.optout="optional",he(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),he(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ci(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=>Bo(o,a)):Bo(i,a)}return r.value===void 0?r:t.innerType._zod.run(r,s)}}),mx=I("$ZodExactOptional",(e,t)=>{Uc.init(e,t),he(e._zod,"values",()=>t.innerType._zod.values),he(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,s)=>t.innerType._zod.run(r,s)}),hx=I("$ZodNullable",(e,t)=>{Ce.init(e,t),he(e._zod,"optin",()=>t.innerType._zod.optin),he(e._zod,"optout",()=>t.innerType._zod.optout),he(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ci(r.source)}|null)$`):void 0}),he(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=I("$ZodDefault",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",he(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=>Uo(i,t)):Uo(a,t)}});function Uo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const px=I("$ZodPrefault",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",he(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=I("$ZodNonOptional",(e,t)=>{Ce.init(e,t),he(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=>Zo(i,e)):Zo(a,e)}});function Zo(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=I("$ZodCatch",(e,t)=>{Ce.init(e,t),e._zod.optin="optional",he(e._zod,"optout",()=>t.innerType._zod.optout),he(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=>Fr(o,s,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(i=>Fr(i,s,Ir()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),yx=I("$ZodPipe",(e,t)=>{Ce.init(e,t),he(e._zod,"values",()=>t.in._zod.values),he(e._zod,"optin",()=>t.in._zod.optin),he(e._zod,"optout",()=>t.out._zod.optout),he(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=>es(o,t.in,s)):es(i,t.in,s)}const a=t.in._zod.run(r,s);return a instanceof Promise?a.then(i=>es(i,t.out,s)):es(a,t.out,s)}});function es(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=I("$ZodReadonly",(e,t)=>{Ce.init(e,t),he(e._zod,"propValues",()=>t.innerType._zod.propValues),he(e._zod,"values",()=>t.innerType._zod.values),he(e._zod,"optin",()=>{var r,s;return(s=(r=t.innerType)==null?void 0:r._zod)==null?void 0:s.optin}),he(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(Wo):Wo(a)}});function Wo(e){return e.value=Object.freeze(e.value),e}const vx=I("$ZodCustom",(e,t)=>{kt.init(e,t),Ce.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=>Yo(i,r,s,e));Yo(a,r,s,e)}});function Yo(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(Fn(a))}}var Ho;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}(Ho=globalThis).__zod_globalRegistry??(Ho.__zod_globalRegistry=Nx());const An=globalThis.__zod_globalRegistry;function wx(e,t){return new e({type:"string",...te(t)})}function Zc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...te(t)})}function Ko(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...te(t)})}function Sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...te(t)})}function kx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...te(t)})}function Cx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...te(t)})}function Ax(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...te(t)})}function Px(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...te(t)})}function Ex(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...te(t)})}function _x(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...te(t)})}function Tx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...te(t)})}function Ix(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...te(t)})}function Fx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...te(t)})}function Dx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...te(t)})}function Rx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...te(t)})}function Ox(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...te(t)})}function $x(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...te(t)})}function Lx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...te(t)})}function zx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...te(t)})}function Mx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...te(t)})}function qx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...te(t)})}function Vx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...te(t)})}function Bx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...te(t)})}function Ux(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...te(t)})}function Zx(e,t){return new e({type:"string",format:"date",check:"string_format",...te(t)})}function Wx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...te(t)})}function Yx(e,t){return new e({type:"string",format:"duration",check:"string_format",...te(t)})}function Hx(e,t){return new e({type:"boolean",...te(t)})}function Kx(e){return new e({type:"unknown"})}function Qx(e,t){return new e({type:"never",...te(t)})}function Wc(e,t){return new yp({check:"max_length",...te(t),maximum:e})}function Ns(e,t){return new bp({check:"min_length",...te(t),minimum:e})}function Yc(e,t){return new vp({check:"length_equals",...te(t),length:e})}function Jx(e,t){return new jp({check:"string_format",format:"regex",...te(t),pattern:e})}function Gx(e){return new Np({check:"string_format",format:"lowercase",...te(e)})}function Xx(e){return new wp({check:"string_format",format:"uppercase",...te(e)})}function eg(e,t){return new Sp({check:"string_format",format:"includes",...te(t),includes:e})}function tg(e,t){return new kp({check:"string_format",format:"starts_with",...te(t),prefix:e})}function rg(e,t){return new Cp({check:"string_format",format:"ends_with",...te(t),suffix:e})}function gn(e){return new Ap({check:"overwrite",tx:e})}function ng(e){return gn(t=>t.normalize(e))}function sg(){return gn(e=>e.trim())}function ag(){return gn(e=>e.toLowerCase())}function ig(){return gn(e=>e.toUpperCase())}function og(){return gn(e=>jf(e))}function lg(e,t,r){return new e({type:"array",element:t,...te(r)})}function cg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...te(r)})}function ug(e,t){const r=dg(s=>(s.addIssue=a=>{if(typeof a=="string")s.issues.push(Fn(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(Fn(i))}},e(s.value,s)),t);return r}function dg(e,t){const r=new kt({check:"custom",...te(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)??An,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 qe(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 b=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,b,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),qe(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"&&We(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 x=(p=e.external.registry.get(d[0]))==null?void 0:p.id,y=e.external.uri??(j=>j);if(x)return{ref:y(x)};const k=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=k,{defId:k,ref:`${y("__shared")}#/${m}/${k}`}}if(d[1]===r)return{ref:"#"};const f=`#/${m}/`,b=d[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:f+b}},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 b=m.schema;for(const p in b)delete b[p];b.$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 Hc(e,t){var l,c,u,d;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,b={...f},p=h.ref;if(h.ref=null,p){n(p);const y=e.seen.get(p),A=y.schema;if(A.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(A)):Object.assign(f,A),Object.assign(f,b),m._zod.parent===p)for(const S in f)S==="$ref"||S==="allOf"||S in b||delete f[S];if(A.$ref&&y.def)for(const S in f)S==="$ref"||S==="allOf"||S in y.def&&JSON.stringify(f[S])===JSON.stringify(y.def[S])&&delete f[S]}const g=m._zod.parent;if(g&&g!==p){n(g);const y=e.seen.get(g);if(y!=null&&y.schema.$ref&&(f.$ref=y.schema.$ref,y.def))for(const A in f)A==="$ref"||A==="allOf"||A in y.def&&JSON.stringify(f[A])===JSON.stringify(y.def[A])&&delete f[A]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())n(m[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,r.def??r.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&a.id===i&&delete a.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const m of e.seen.entries()){const h=m[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const m=JSON.parse(JSON.stringify(a));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ns(t,"input",e.processors),output:Ns(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function We(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return We(n.element,r);if(n.type==="set")return We(n.valueType,r);if(n.type==="lazy")return We(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return We(n.innerType,r);if(n.type==="intersection")return We(n.left,r)||We(n.right,r);if(n.type==="record"||n.type==="map")return We(n.keyType,r)||We(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:We(n.in,r)||We(n.out,r);if(n.type==="object"){for(const a in n.shape)if(We(n.shape[a],r))return!0;return!1}if(n.type==="union"){for(const a of n.options)if(We(a,r))return!0;return!1}if(n.type==="tuple"){for(const a of n.items)if(We(a,r))return!0;return!!(n.rest&&We(n.rest,r))}return!1}const dg=(e,t={})=>r=>{const n=Wc({...r,processors:t});return qe(e,n),Yc(n,e),Hc(n,e)},Ns=(e,t,r={})=>n=>{const{libraryOptions:a,target:i}=n??{},o=Wc({...a??{},target:i,io:t,processors:r});return qe(e,o),Yc(o,e),Hc(o,e)},mg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hg=(e,t,r,n)=>{const a=r;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=mg[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}))])}},fg=(e,t,r,n)=>{r.type="boolean"},pg=(e,t,r,n)=>{r.not={}},xg=(e,t,r,n)=>{},gg=(e,t,r,n)=>{const a=e._zod.def,i=Tc(a.entries);i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},yg=(e,t,r,n)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),i.every(o=>typeof o=="boolean")&&(r.type="boolean"),i.every(o=>o===null)&&(r.type="null"),r.enum=i},bg=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},vg=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jg=(e,t,r,n)=>{const a=r,i=e._zod.def,{minimum:o,maximum:l}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof l=="number"&&(a.maxItems=l),a.type="array",a.items=qe(i.element,t,{...n,path:[...n.path,"items"]})},Ng=(e,t,r,n)=>{var u;const a=r,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const d in o)a.properties[d]=qe(o[d],t,{...n,path:[...n.path,"properties",d]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(d=>{const m=i.shape[d]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=qe(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},wg=(e,t,r,n)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>qe(l,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=o:r.anyOf=o},Sg=(e,t,r,n)=>{const a=e._zod.def,i=qe(a.left,t,{...n,path:[...n.path,"allOf",0]}),o=qe(a.right,t,{...n,path:[...n.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];r.allOf=c},kg=(e,t,r,n)=>{const a=e._zod.def,i=qe(a.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Cg=(e,t,r,n)=>{const a=e._zod.def;qe(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType},Ag=(e,t,r,n)=>{const a=e._zod.def;qe(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.default=JSON.parse(JSON.stringify(a.defaultValue))},Pg=(e,t,r,n)=>{const a=e._zod.def;qe(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Eg=(e,t,r,n)=>{const a=e._zod.def;qe(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},_g=(e,t,r,n)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;qe(o,t,n);const l=t.seen.get(e);l.ref=o},Tg=(e,t,r,n)=>{const a=e._zod.def;qe(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType,r.readOnly=!0},Kc=(e,t,r,n)=>{const a=e._zod.def;qe(a.innerType,t,n);const i=t.seen.get(e);i.ref=a.innerType};function za(){return za=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},za.apply(null,arguments)}function Ho(e,t){try{var r=e()}catch(n){return t(n)}return r&&r.then?r.then(void 0,t):r}function Ig(e,t){for(var r={};e.length;){var n=e[0],a=n.code,i=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var l=n.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(d){return d.errors.forEach(function(m){return e.push(m)})}),t){var c=r[o].types,u=c&&c[n.code];r[o]=yi(o,t,r,a,u?[].concat(u,n.message):n.message)}e.shift()}return r}function Fg(e,t){for(var r={},n=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!r[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];r[l]={message:c.message,type:c.code}}else r[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push(za({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=r[l].types,d=u&&u[a.code];r[l]=yi(l,t,r,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)n();return r}function Ct(e,t,r){if(r===void 0&&(r={}),(function(n){return"_def"in n&&typeof n._def=="object"&&"typeName"in n._def})(e))return function(n,a,i){try{return Promise.resolve(Ho(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(o){return i.shouldUseNativeValidation&&Oa({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Io(Ig(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(n){return"_zod"in n&&typeof n._zod=="object"})(e))return function(n,a,i){try{return Promise.resolve(Ho(function(){return Promise.resolve((r.mode==="sync"?Df:Rf)(e,n,t)).then(function(o){return i.shouldUseNativeValidation&&Oa({},i),{errors:{},values:r.raw?Object.assign({},n):o}})},function(o){if((function(l){return l instanceof Ci})(o))return{values:{},errors:Io(Fg(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 un({label:e,required:t=!1,htmlFor:r}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})}const de=N.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",...o},l){const c=a??o.name;return s.jsxs("div",{children:[s.jsx(un,{label:t,required:r,htmlFor:c}),s.jsx("input",{ref:l,id:c,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...o}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}),wt=N.forwardRef(function({label:t,required:r=!1,error:n,id:a,className:i="",children:o,...l},c){const u=a??l.name;return s.jsxs("div",{children:[s.jsx(un,{label:t,required:r,htmlFor:u}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:u,className:`block w-full appearance-none rounded-lg border bg-white px-3 py-2.5 pr-10 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${n?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(Dg,{})]}),n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})});function lr({step:e,title:t,muted:r=!1,children:n}){return s.jsxs("section",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[e?s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:e}):null,s.jsx("h3",{className:`text-sm font-semibold tracking-wide ${r?"text-slate-400":"text-gov-700"}`,children:t})]}),n]})}function Dg(){return s.jsx("svg",{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Vt({variant:e="error",title:t,message:r}){const n=e==="error"?"border-red-200 bg-red-50 text-red-800":"border-slate-200 bg-white text-slate-700";return s.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${n}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:r})]})}function st(e,t){var r;if(e instanceof xn){if(e.details){const n=(r=Object.values(e.details)[0])==null?void 0:r[0];if(n)return n}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Rg=T("ZodISODateTime",(e,t)=>{Mp.init(e,t),Ne.init(e,t)});function Og(e){return Bx(Rg,e)}const $g=T("ZodISODate",(e,t)=>{qp.init(e,t),Ne.init(e,t)});function Lg(e){return Ux($g,e)}const zg=T("ZodISOTime",(e,t)=>{Vp.init(e,t),Ne.init(e,t)});function Mg(e){return Zx(zg,e)}const qg=T("ZodISODuration",(e,t)=>{Bp.init(e,t),Ne.init(e,t)});function Vg(e){return Wx(qg,e)}const Bg=(e,t)=>{Ci.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Ff(e,r)},flatten:{value:r=>If(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,$a,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,$a,2)}},isEmpty:{get(){return e.issues.length===0}}})},ut=T("ZodError",Bg,{Parent:Error}),Ug=Os(ut),Zg=$s(ut),Wg=Ls(ut),Yg=zs(ut),Hg=Lf(ut),Kg=zf(ut),Qg=Mf(ut),Jg=qf(ut),Gg=Vf(ut),Xg=Bf(ut),ey=Uf(ut),ty=Zf(ut),Ko=new WeakMap;function qs(e,t,r){const n=Object.getPrototypeOf(e);let a=Ko.get(n);if(a||(a=new Set,Ko.set(n,a)),!a.has(t)){a.add(t);for(const i in r){const o=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const Ae=T("ZodType",(e,t)=>(Ce.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ns(e,"input"),output:Ns(e,"output")}}),e.toJSONSchema=dg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Ug(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Wg(e,r,n),e.parseAsync=async(r,n)=>Zg(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Yg(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Hg(e,r,n),e.decode=(r,n)=>Kg(e,r,n),e.encodeAsync=async(r,n)=>Qg(e,r,n),e.decodeAsync=async(r,n)=>Jg(e,r,n),e.safeEncode=(r,n)=>Gg(e,r,n),e.safeDecode=(r,n)=>Xg(e,r,n),e.safeEncodeAsync=async(r,n)=>ey(e,r,n),e.safeDecodeAsync=async(r,n)=>ty(e,r,n),qs(e,"ZodType",{check(...r){const n=this.def;return this.clone(cr(n,{checks:[...n.checks??[],...r.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ur(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Yy(r,n))},superRefine(r,n){return this.check(Hy(r,n))},overwrite(r){return this.check(gn(r))},optional(){return Go(this)},exactOptional(){return Dy(this)},nullable(){return Xo(this)},nullish(){return Go(Xo(this))},nonoptional(r){return My(this,r)},array(){return ky(this)},or(r){return Gc([this,r])},and(r){return Ey(this,r)},transform(r){return el(this,Iy(r))},default(r){return $y(this,r)},prefault(r){return zy(this,r)},catch(r){return Vy(this,r)},pipe(r){return el(this,r)},readonly(){return Zy(this)},describe(r){const n=this.clone();return An.add(n,{description:r}),n},meta(...r){if(r.length===0)return An.get(this);const n=this.clone();return An.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){var r;return(r=An.get(e))==null?void 0:r.description},configurable:!0}),e)),Qc=T("_ZodString",(e,t)=>{Ai.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(n,a,i)=>hg(e,n,a);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,qs(e,"_ZodString",{regex(...n){return this.check(Qx(...n))},includes(...n){return this.check(Xx(...n))},startsWith(...n){return this.check(eg(...n))},endsWith(...n){return this.check(tg(...n))},min(...n){return this.check(js(...n))},max(...n){return this.check(Uc(...n))},length(...n){return this.check(Zc(...n))},nonempty(...n){return this.check(js(1,...n))},lowercase(n){return this.check(Jx(n))},uppercase(n){return this.check(Gx(n))},trim(){return this.check(ng())},normalize(...n){return this.check(rg(...n))},toLowerCase(){return this.check(sg())},toUpperCase(){return this.check(ag())},slugify(){return this.check(ig())}})}),ry=T("ZodString",(e,t)=>{Ai.init(e,t),Qc.init(e,t),e.email=r=>e.check(Bc(Jc,r)),e.url=r=>e.check(Ax(sy,r)),e.jwt=r=>e.check(Vx(by,r)),e.emoji=r=>e.check(Px(ay,r)),e.guid=r=>e.check(Yo(Qo,r)),e.uuid=r=>e.check(wx(es,r)),e.uuidv4=r=>e.check(Sx(es,r)),e.uuidv6=r=>e.check(kx(es,r)),e.uuidv7=r=>e.check(Cx(es,r)),e.nanoid=r=>e.check(Ex(iy,r)),e.guid=r=>e.check(Yo(Qo,r)),e.cuid=r=>e.check(_x(oy,r)),e.cuid2=r=>e.check(Tx(ly,r)),e.ulid=r=>e.check(Ix(cy,r)),e.base64=r=>e.check(zx(xy,r)),e.base64url=r=>e.check(Mx(gy,r)),e.xid=r=>e.check(Fx(uy,r)),e.ksuid=r=>e.check(Dx(dy,r)),e.ipv4=r=>e.check(Rx(my,r)),e.ipv6=r=>e.check(Ox(hy,r)),e.cidrv4=r=>e.check($x(fy,r)),e.cidrv6=r=>e.check(Lx(py,r)),e.e164=r=>e.check(qx(yy,r)),e.datetime=r=>e.check(Og(r)),e.date=r=>e.check(Lg(r)),e.time=r=>e.check(Mg(r)),e.duration=r=>e.check(Vg(r))});function _(e){return Nx(ry,e)}const Ne=T("ZodStringFormat",(e,t)=>{be.init(e,t),Qc.init(e,t)}),Jc=T("ZodEmail",(e,t)=>{Tp.init(e,t),Ne.init(e,t)});function ny(e){return Bc(Jc,e)}const Qo=T("ZodGUID",(e,t)=>{Ep.init(e,t),Ne.init(e,t)}),es=T("ZodUUID",(e,t)=>{_p.init(e,t),Ne.init(e,t)}),sy=T("ZodURL",(e,t)=>{Ip.init(e,t),Ne.init(e,t)}),ay=T("ZodEmoji",(e,t)=>{Fp.init(e,t),Ne.init(e,t)}),iy=T("ZodNanoID",(e,t)=>{Dp.init(e,t),Ne.init(e,t)}),oy=T("ZodCUID",(e,t)=>{Rp.init(e,t),Ne.init(e,t)}),ly=T("ZodCUID2",(e,t)=>{Op.init(e,t),Ne.init(e,t)}),cy=T("ZodULID",(e,t)=>{$p.init(e,t),Ne.init(e,t)}),uy=T("ZodXID",(e,t)=>{Lp.init(e,t),Ne.init(e,t)}),dy=T("ZodKSUID",(e,t)=>{zp.init(e,t),Ne.init(e,t)}),my=T("ZodIPv4",(e,t)=>{Up.init(e,t),Ne.init(e,t)}),hy=T("ZodIPv6",(e,t)=>{Zp.init(e,t),Ne.init(e,t)}),fy=T("ZodCIDRv4",(e,t)=>{Wp.init(e,t),Ne.init(e,t)}),py=T("ZodCIDRv6",(e,t)=>{Yp.init(e,t),Ne.init(e,t)}),xy=T("ZodBase64",(e,t)=>{Hp.init(e,t),Ne.init(e,t)}),gy=T("ZodBase64URL",(e,t)=>{Qp.init(e,t),Ne.init(e,t)}),yy=T("ZodE164",(e,t)=>{Jp.init(e,t),Ne.init(e,t)}),by=T("ZodJWT",(e,t)=>{Xp.init(e,t),Ne.init(e,t)}),vy=T("ZodBoolean",(e,t)=>{ex.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>fg(e,r,n)});function Wr(e){return Yx(vy,e)}const jy=T("ZodUnknown",(e,t)=>{tx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>xg()});function Jo(){return Hx(jy)}const Ny=T("ZodNever",(e,t)=>{rx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>pg(e,r,n)});function wy(e){return Kx(Ny,e)}const Sy=T("ZodArray",(e,t)=>{nx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>jg(e,r,n,a),e.element=t.element,qs(e,"ZodArray",{min(r,n){return this.check(js(r,n))},nonempty(r){return this.check(js(1,r))},max(r,n){return this.check(Uc(r,n))},length(r,n){return this.check(Zc(r,n))},unwrap(){return this.element}})});function ky(e,t){return og(Sy,e,t)}const Cy=T("ZodObject",(e,t)=>{ax.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ng(e,r,n,a),me(e,"shape",()=>t.shape),qs(e,"ZodObject",{keyof(){return Vs(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Jo()})},loose(){return this.clone({...this._zod.def,catchall:Jo()})},strict(){return this.clone({...this._zod.def,catchall:wy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Cf(this,r)},safeExtend(r){return Af(this,r)},merge(r){return Pf(this,r)},pick(r){return Sf(this,r)},omit(r){return kf(this,r)},partial(...r){return Ef(Xc,this,r[0])},required(...r){return _f(eu,this,r[0])}})});function Bt(e,t){const r={type:"object",shape:e??{},...X(t)};return new Cy(r)}const Ay=T("ZodUnion",(e,t)=>{ix.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>wg(e,r,n,a),e.options=t.options});function Gc(e,t){return new Ay({type:"union",options:e,...X(t)})}const Py=T("ZodIntersection",(e,t)=>{ox.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Sg(e,r,n,a)});function Ey(e,t){return new Py({type:"intersection",left:e,right:t})}const Ma=T("ZodEnum",(e,t)=>{lx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(n,a,i)=>gg(e,n,a),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,a)=>{const i={};for(const o of n)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ma({...t,checks:[],...X(a),entries:i})},e.exclude=(n,a)=>{const i={...t.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ma({...t,checks:[],...X(a),entries:i})}});function Vs(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ma({type:"enum",entries:r,...X(t)})}const _y=T("ZodLiteral",(e,t)=>{cx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>yg(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ea(e,t){return new _y({type:"literal",values:Array.isArray(e)?e:[e],...X(t)})}const Ty=T("ZodTransform",(e,t)=>{ux.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>vg(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new _c(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Fn(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(Fn(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 Iy(e){return new Ty({type:"transform",transform:e})}const Xc=T("ZodOptional",(e,t)=>{Vc.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Kc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Go(e){return new Xc({type:"optional",innerType:e})}const Fy=T("ZodExactOptional",(e,t)=>{dx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Kc(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Dy(e){return new Fy({type:"optional",innerType:e})}const Ry=T("ZodNullable",(e,t)=>{mx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>kg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Xo(e){return new Ry({type:"nullable",innerType:e})}const Oy=T("ZodDefault",(e,t)=>{hx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Ag(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $y(e,t){return new Oy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Fc(t)}})}const Ly=T("ZodPrefault",(e,t)=>{fx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Pg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function zy(e,t){return new Ly({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Fc(t)}})}const eu=T("ZodNonOptional",(e,t)=>{px.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Cg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function My(e,t){return new eu({type:"nonoptional",innerType:e,...X(t)})}const qy=T("ZodCatch",(e,t)=>{xx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Eg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vy(e,t){return new qy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const By=T("ZodPipe",(e,t)=>{gx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>_g(e,r,n,a),e.in=t.in,e.out=t.out});function el(e,t){return new By({type:"pipe",in:e,out:t})}const Uy=T("ZodReadonly",(e,t)=>{yx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>Tg(e,r,n,a),e.unwrap=()=>e._zod.def.innerType});function Zy(e){return new Uy({type:"readonly",innerType:e})}const Wy=T("ZodCustom",(e,t)=>{bx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,n,a)=>bg(e,r)});function Yy(e,t={}){return lg(Wy,e,t)}function Hy(e,t){return cg(e,t)}const Vr={custom:"custom"};function Pi(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 At(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?e.firstName:`${e.firstName} ${e.lastName}`.trim()}function dr(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function Dr(e){const t=e.replace(/\D/g,""),r=t.length===11&&t.startsWith("1")?t.slice(1):t;return r.length!==10?e:`+1 (${r.slice(0,3)}) ${r.slice(3,6)}-${r.slice(6)}`}function Ky(e,t){const r=t.trim().toLowerCase();if(!r)return!0;const n=At(e).toLowerCase(),a=e.email.toLowerCase(),i=e.idNumber.replace(/\D/g,"");return n.includes(r)||a.includes(r)||i.includes(r.replace(/\D/g,""))||dr(e.idNumber).toLowerCase().includes(r)}const tu=["LLP","LLC","Corporation","S-Corp","Partnership"],ru=["Sole Proprietorship"],Ei=["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"],qa=10,nu=Bt({accountType:Vs(["Business","Individual"]),businessName:_().min(1,"Business name is required"),tradeName:_(),ein:_().min(1,"EIN is required").refine(e=>e.replace(/\D/g,"").length===9,"EIN must be 9 digits"),entityType:_().min(1,"Entity type is required"),email:ny("Enter a valid email"),countryCode:_().min(1),phoneNumber:_().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===qa,`Phone number must be ${qa} 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")});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(-qa)}}function tl(e){const{countryCode:t,national:r}=Qy(e.phoneNumber),n=e.accountType==="Individual"?`${e.firstName} ${e.lastName}`.trim():e.firstName;return{accountType:e.accountType==="Individual"?"Individual":"Business",businessName:n,tradeName:e.tradeName??"",ein:dr(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:r,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function Jy(e){const t=e.businessName.trim().split(/\s+/),r=t[0]??e.businessName,n=e.accountType==="Individual"?t.slice(1).join(" ")||r:e.businessName.trim();return{firstName:r,lastName:n}}function su(e){const{firstName:t,lastName:r}=Jy(e);return{accountType:e.accountType,firstName:t,lastName:r,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName,phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function Gy(e){const{idNumber:t,...r}=su(e);return r}function zr(e,t){const r=e==null?void 0:e.from;return r&&r.startsWith("/")&&!r.startsWith("//")?r:t}function Xy(){var E,I,w,F,D,$,se,B,Q,te,Y;const e=ye(),t=ge(),r=ct(),{data:n=[]}=ke({queryKey:["entities","mine"],queryFn:hc}),[a,i]=N.useState(null),[o,l]=N.useState(!1),c=n.length===0,u=c?"/create-entity":"/dashboard",d=zr(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:b,setValue:p,formState:{errors:g}}=St({resolver:Ct(nu),defaultValues:{accountType:"Individual",businessName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),y=b("accountType"),A=b("entityType"),j=y==="Individual"?ru:tu;N.useEffect(()=>{j.includes(A)||p("entityType",y==="Individual"?"Sole Proprietorship":"LLP")},[y,A,j,p]);const S=f(async ne=>{i(null),l(!0);try{await Rh(su(ne)),await r.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(xe){i(st(xe,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:S,noValidate:!0,className:"space-y-8",children:[a?s.jsx(Vt,{message:a}):null,s.jsx(lr,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(un,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:y==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(E=g.businessName)==null?void 0:E.message,...h("businessName")}),s.jsx(de,{label:"Trade Name, if any",placeholder:"Enter",error:(I=g.tradeName)==null?void 0:I.message,...h("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"EIN",required:!0,placeholder:"**-*******",maxLength:10,error:(w=g.ein)==null?void 0:w.message,...h("ein")}),s.jsx(wt,{label:"Entity Type",required:!0,error:(F=g.entityType)==null?void 0:F.message,...h("entityType"),children:j.map(ne=>s.jsx("option",{value:ne,children:ne},ne))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(D=g.email)==null?void 0:D.message,...h("email")}),s.jsxs("div",{children:[s.jsx(un,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...h("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${g.phoneNumber?"border-red-300":"border-slate-200"}`,...h("phoneNumber")})]}),g.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:g.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(de,{label:"Address Line 1",required:!0,error:($=g.address1)==null?void 0:$.message,...h("address1")}),s.jsx(de,{label:"Address Line 2",error:(se=g.address2)==null?void 0:se.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"City",required:!0,error:(B=g.city)==null?void 0:B.message,...h("city")}),s.jsxs(wt,{label:"State",required:!0,error:(Q=g.state)==null?void 0:Q.message,...h("state"),children:[s.jsx("option",{value:"",children:"Select"}),Ei.map(ne=>s.jsx("option",{value:ne,children:ne},ne))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"ZIP Code",required:!0,error:(te=g.zipCode)==null?void 0:te.message,...h("zipCode")}),s.jsxs(wt,{label:"Country",required:!0,error:(Y=g.country)==null?void 0:Y.message,...h("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})}),s.jsxs("div",{className:"flex items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:m,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save"})]})]})}function _i(){const e=ye(),t=ge(),r=zr(t.state,"/create-entity");return s.jsxs("div",{className:"relative min-h-full bg-slate-100/80 px-4 py-8 sm:px-6 sm:py-10",children:[s.jsxs("button",{type:"button",onClick:()=>e(r),className:"absolute left-4 top-4 inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white/80 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 sm:left-6 sm:top-6",children:[s.jsx(eb,{}),"Back"]}),s.jsx("div",{className:"mx-auto mt-8 max-w-3xl rounded-2xl border border-slate-200/80 bg-white p-6 shadow-sm sm:mt-4 sm:p-8",children:s.jsx(Xy,{})})]})}function eb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function tb(e,t){const r=new URLSearchParams({entityId:String(e)});return t!==void 0&&r.set("taxYear",String(t)),he(`/portal/dashboard?${r}`)}function rb(e,t,r){const n=new URLSearchParams({entityId:String(e),category:t,taxYear:String(r)});return he(`/portal/dashboard/summary?${n}`)}function nb(e,t,r){const n=new URLSearchParams({entityId:String(e),month:String(t)});return r!==void 0&&n.set("year",String(r)),he(`/portal/dashboard/monthly-overview?${n}`)}function sb({entityId:e,search:t,taxYear:r,status:n,page:a=1,pageSize:i=20}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),r&&o.set("taxYear",r),n&&n!=="all"&&o.set("status",n),he(`/portal/dashboard/payments?${o}`)}function rl({entityCount:e}){const t=ye(),{enabledPayments:r}=$r();return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(ta,{}),"Add Federal Payments"]}),r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(ta,{}),"Add State Payment"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(ta,{}),"Add Local Payment",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>t("/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:[s.jsx(ab,{}),"Entities (",e,")"]}),s.jsxs("button",{type:"button",onClick:()=>t("/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:[s.jsx(ib,{}),"Add Entity"]})]})]})}function ta(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function ab(){return s.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#364153]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.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 ib(){return s.jsx("svg",{className:"h-[13px] w-[13px] shrink-0 text-[#16a34a]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.356 0-4.564-.64-6.374-1.766z"})})}function ob({title:e,description:t,buttonLabel:r,onAdd:n,comingSoon:a=!1}){return s.jsxs("article",{className:"flex flex-col rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"mx-auto mt-4 max-w-xs text-sm leading-relaxed text-slate-500",children:t}),a?s.jsx("span",{className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-5 py-2.5 text-sm font-semibold text-slate-500",children:"Coming Soon"}):s.jsxs("button",{type:"button",onClick:n,className:"mx-auto mt-8 inline-flex items-center gap-2 rounded-lg bg-gov-600 px-5 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(lb,{}),r]})]})}function lb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Ti({label:e="Loading…"}){return s.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-[inherit] bg-white/75","aria-live":"polite","aria-busy":"true",children:s.jsxs("div",{className:"flex items-center gap-2.5 text-sm text-slate-500",children:[s.jsx(cb,{}),s.jsx("span",{children:e})]})})}function cb(){return s.jsxs("svg",{className:"h-5 w-5 animate-spin text-gov-600",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}const ub={Draft:"Draft"};function au(e){switch((e??ub.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 Bn(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 Ii="drafts";function Ze(){return Bs(Ii)}function Bs(e){return`/payments?tab=${e}`}function iu(e){return e==="failed"?"rejected":e}function mb(e,t){return t.trim().toLowerCase()==="draft"?Ii:iu(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 n=ye(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=N.useState(null);N.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=ke({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>nb(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,b=[{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 s.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?s.jsx(Ti,{}):null,s.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-4",children:[s.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-slate-500",children:"Overview of Month"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:l,onChange:p=>o(Number(p.target.value)),disabled:f,className:"appearance-none rounded-full border border-gov-600 bg-white py-1.5 pl-4 pr-8 text-sm font-medium text-gov-600 focus:border-gov-600 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:hb.map((p,g)=>s.jsx("option",{value:g+1,children:p},p))}),s.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"})]})]}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-4",children:b.map(p=>{const g=p.icon;return s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center ${p.iconClassName}`,children:s.jsx(g,{})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs leading-4 text-slate-500",children:p.label}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("p",{className:`text-xl font-bold leading-7 ${p.amountClassName}`,children:Bn(p.amount)}),s.jsx("button",{type:"button",onClick:()=>n(Bs(iu(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 s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function xb(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 14.25v-1.5M11.25 13.5h1.5"})]})}function gb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function yb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})}function bb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}function nl(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 sl(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const jb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],al={total:0,items:[]};function Nb({label:e,status:t}){const r={scheduled:"bg-amber-50 text-amber-700",paid:"bg-emerald-50 text-emerald-700",submitted:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-600"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r[t]}`,children:e})}function wb({entityId:e,initialPayments:t,isDashboardLoading:r=!1}){const n=ye(),[a,i]=N.useState(""),[o,l]=N.useState(""),[c,u]=N.useState(""),[d,m]=N.useState("all");N.useEffect(()=>{const j=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(j)},[a]);const h=!!o||!!c||d!=="all",{data:f,isFetching:b}=ke({queryKey:["dashboard","payments",e,o,c,d],queryFn:()=>sb({entityId:e,search:o||void 0,taxYear:c||void 0,status:d}),enabled:e!==null&&h,placeholderData:j=>j}),p=h?f??t??al:t??al,g=N.useMemo(()=>p.items.map(vb),[p.items]),y=N.useMemo(()=>{const j=new Date().getFullYear();return[j,j-1,j-2].map(String)},[]),A=r||h&&b;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[A?s.jsx(Ti,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(kb,{})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-bold text-slate-900",children:"My Payments"}),s.jsxs("p",{className:"text-xs text-slate-500",children:[p.total," total payments"]})]})]})}),s.jsx("div",{className:"border-b border-slate-200 p-6",children:s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"payment-search",className:"mb-1.5 block text-sm text-slate-600",children:"Search by State/Form Type"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sb,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),s.jsx("input",{id:"payment-search",type:"text",value:a,onChange:j=>i(j.target.value),placeholder:"All",disabled:r,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"tax-period-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Tax Period"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{id:"tax-period-filter",value:c,onChange:j=>u(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[s.jsx("option",{value:"",children:"Select Year"}),y.map(j=>s.jsx("option",{value:j,children:j},j))]}),s.jsx(il,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{id:"status-filter",value:d,onChange:j=>m(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:jb.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))}),s.jsx(il,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"ID"}),s.jsx("th",{className:"px-6 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-6 py-3",children:"Period"}),s.jsx("th",{className:"px-6 py-3",children:"Amount"}),s.jsx("th",{className:"px-6 py-3",children:"Payment"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Form Type"}),s.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),s.jsx("tbody",{children:!A&&g.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:h?"No payments match your filters.":"No payments yet."})}):g.map((j,S)=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsxs("td",{className:"px-6 py-4 font-medium text-slate-900",children:["#",S+1]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Bn(j.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Nb,{label:j.statusLabel,status:j.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("button",{type:"button",onClick:()=>n(Bs(mb(j.status,j.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${j.category}-${j.id}`))})]})})]})}function Sb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})})}function il({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function kb(){return s.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function ra({entityId:e,category:t,title:r,subtitlePrefix:n,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:u=!1}){const[d,m]=N.useState(a);if(N.useEffect(()=>{m(a)},[e,a]),u)return s.jsxs("article",{className:"flex min-h-[220px] flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:n})]}),s.jsx("div",{className:"flex flex-1 items-center justify-center",children:s.jsx("span",{className:"rounded-full border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-500",children:"Coming Soon"})})]});const h=d===a,{data:f,isFetching:b}=ke({queryKey:["dashboard","summary",e,t,d],queryFn:()=>rb(e,t,d),enabled:e!==null&&!h,placeholderData:A=>A}),p=h?o?nl(o):sl():f?nl(f):sl(),g=db(p),y=l||b&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[y?s.jsx(Ti,{}):null,s.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-bold text-slate-900",children:r}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[n," (",p.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:d,onChange:A=>m(Number(A.target.value)),disabled:y,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(A=>s.jsxs("option",{value:A,children:["TY ",A]},A))}),s.jsx(Cb,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"})]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:c.map(A=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${A.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:A.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Bn(p[A.key])})]},A.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:g.map((A,j)=>A.width>0?s.jsx("span",{className:`${A.color} h-full`,style:{width:`${A.width}%`}},j):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function Cb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const Ab={federal:"Schedule federal tax deposits directly to the IRS — EFTPS payments, 941, 940, and more.",state:"Submit state tax remittances to the relevant state authority on time, every time.",local:"Local tax payment support is coming soon. Stay tuned for updates."},Pb=[{key:"federal",title:"Add Your First Federal Payment",buttonLabel:"Add Federal Payment"},{key:"state",title:"Add Your First State Payment",buttonLabel:"Add State Payment"},{key:"local",title:"Add Your First Local Payment",buttonLabel:"Add Local Payments"}],Qt=new Date().getFullYear(),na=[Qt,Qt-1,Qt-2],Eb=[{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"}],_b=[{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"}],Tb=[{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 Fi(){const e=ye(),{entities:t,selectedEntity:r,enabledPayments:n}=$r(),a=(r==null?void 0:r.entityId)??null,{data:i,isLoading:o}=ke({queryKey:["dashboard",a,Qt],queryFn:()=>tb(a,Qt),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(rl,{entityCount:t.length}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:Pb.filter(l=>l.key==="local"||n.includes(l.key)).map(l=>s.jsx(ob,{title:l.title,description:Ab[l.key],buttonLabel:l.buttonLabel,onAdd:l.key==="federal"?()=>e("/payments/federal/new",{state:{from:"/dashboard"}}):l.key==="state"?()=>e("/payments/state/new",{state:{from:"/dashboard",resetDraft:!0}}):void 0,comingSoon:l.key==="local"},l.key))})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(rl,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[n.includes("federal")&&s.jsx(ra,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:Qt,taxYearOptions:na,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:Eb}),n.includes("state")&&s.jsx(ra,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:Qt,taxYearOptions:na,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:_b}),s.jsx(ra,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:Qt,taxYearOptions:na,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:Tb,comingSoon:!0})]}),s.jsx(fb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(wb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}function Di(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=$r(),n=ye(),[a,i]=N.useState(""),o=e.filter(c=>Ky(c,a)),l=c=>{r(c.entityId),n("/dashboard",{replace:!0})};return s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("button",{type:"button",onClick:()=>n("/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:[s.jsx(Fb,{}),"Back"]}),s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex shrink-0 items-center gap-2 rounded-[14px] bg-[#156bd5] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1260be]",children:[s.jsx(Db,{}),"Add Entity"]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-[11px] font-semibold text-[#6a7282]",children:"Search by Entity Name/Email/EIN"}),s.jsx("input",{type:"search",value:a,onChange:c=>i(c.target.value),placeholder:"All",className:"h-[38px] w-[220px] rounded-lg border-2 border-[#e5e7eb] bg-[#f9fafb] px-3 text-sm text-slate-700 placeholder-[#99a1af] focus:border-[#156bd5] focus:outline-none"})]})]}),s.jsx("div",{className:"overflow-x-auto rounded-xl border border-black/[0.12] bg-white",children:s.jsxs("table",{className:"min-w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#f8f9fb]",children:[s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Client Name"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"EIN Number"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Email"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Phone"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Business Type"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Status"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Joined Date"}),s.jsx("th",{className:"border-b border-[#e0e0e0] px-4 py-3 text-left text-[11px] font-bold tracking-wide text-[#374151]",children:"Action"})]})}),s.jsx("tbody",{children:o.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"No organizations match your search."})}):o.map(c=>s.jsx(Ib,{entity:c,isSelected:c.entityId===(t==null?void 0:t.entityId),onSelect:()=>l(c)},c.entityId))})]})})]})}function Ib({entity:e,isSelected:t,onSelect:r}){var l;const n=At(e),a=Pi(n),i=((l=e.status)==null?void 0:l.toLowerCase())==="active",o=e.createdAt?new Date(e.createdAt).toISOString().slice(0,10):"—";return s.jsxs("tr",{className:["border-b border-[#e0e0e0] last:border-b-0 transition-colors",t?"bg-[#f0f7ff]":"hover:bg-slate-50"].join(" "),children:[s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] bg-[#156bd5] text-[11px] font-bold text-white",children:a}),s.jsx("span",{className:"font-semibold text-[#1e2939] text-[13px]",children:n})]})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:dr(e.idNumber)})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.email||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.phoneNumber||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:e.entityType||"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:["inline-flex items-center rounded-full px-2 py-0.5 text-[11px]",i?"bg-[#e1f6da] text-[#010d1d]":"bg-[#feeceb] text-[#010d1d]"].join(" "),children:i?"Active":"In-active"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"text-[12px] text-[#374151]",children:o})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 rounded-full bg-[#dcebfd] px-2.5 py-0.5 text-[11px] font-semibold text-[#156bd5] transition hover:bg-[#c5ddfb]",children:t?"Selected":"Select"})})]})}function Fb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function Db(){return s.jsx("svg",{className:"h-[15px] w-[15px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Rb(e){return he(`/portal/federal-payments?entityId=${e}`)}function Ri(e){return he(`/portal/federal-payments/${e}`)}function Ob(e){return he(`/portal/federal-payments/form-types?entityId=${e}`)}function $b(e){const t=new URLSearchParams({formType:e});return he(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Oi(e){return he("/portal/federal-payments",{method:"POST",body:e})}function $i(e,t){return he(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function Lb(e){return he(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function Li(e){return he(`/portal/state-payments?entityId=${e}`)}function zb(e){return he("/portal/state-payments",{method:"POST",body:e})}function Mb(e,t){return he(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function qb(e){return he(`/portal/state-payments/${e}/submit`,{method:"POST"})}function Vb({actionType:e,onView:t,onEdit:r,onSubmit:n,isSubmitting:a=!1}){return e==="draft-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",onClick:r,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"Edit"}),s.jsx("button",{type:"button",onClick:n,disabled:a,className:"rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:opacity-60",children:a?"Submitting…":"Submit"})]}):e==="view-pdf"?s.jsx("button",{type:"button",className:"rounded-lg border border-gov-200 bg-gov-50 px-4 py-1.5 text-sm font-medium text-gov-600 hover:bg-gov-100",children:"View PDF"}):e==="rejected-actions"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"}),s.jsx("button",{type:"button",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-semibold text-red-600 hover:bg-red-100",children:"Re-Submit"})]}):s.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})}function ou(e){const t=/^(\d{4})-Q([1-4])$/.exec(e);if(t)return`Q${t[2]} ${t[1]}`;if(e.length!==6)return e;const r=e.slice(0,4),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(n)||n<1||n>12?e:`Q${Math.ceil(n/3)} ${r}`}function Bb(e){return{id:e.federalPaymentId,category:"federal",referenceNo:`FED-${e.federalPaymentId}`,jurisdiction:"IRS - Federal",period:ou(e.taxPeriod),amount:e.paymentAmount,paymentDate:e.settlementDate,status:e.status,reason:e.reason,tab:au(e.status)}}function Ub(e){return{id:e.statePaymentDetailId,category:"state",referenceNo:`ST-${e.statePaymentDetailId}`,jurisdiction:`${e.state} (State)`,period:ou(e.taxPeriod),amount:e.taxAmount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:au(e.status)}}function Zb(e,t,r){return e.filter(n=>n.tab!==t?!1:r==="all"?!0:n.category===r)}function Wb(e){return e.reduce((t,r)=>(t[r.tab]+=1,t),{drafts:0,scheduled:0,submitted:0,rejected:0,paid:0})}function Yb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsx("path",{d:"M9.375 1.25H3.75C3.41848 1.25 3.10054 1.3817 2.86612 1.61612C2.6317 1.85054 2.5 2.16848 2.5 2.5V12.5C2.5 12.8315 2.6317 13.1495 2.86612 13.3839C3.10054 13.6183 3.41848 13.75 3.75 13.75H11.25C11.5815 13.75 11.8995 13.6183 12.1339 13.3839C12.3683 13.1495 12.5 12.8315 12.5 12.5V4.375L9.375 1.25Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M8.75 1.25V3.75C8.75 4.08152 8.8817 4.39946 9.11612 4.63388C9.35054 4.8683 9.66848 5 10 5H12.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.25 5.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 8.125H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 10.625H5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Hb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#scheduled-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 3.75V7.5L10 8.75",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"scheduled-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function Kb({className:e,...t}){return s.jsx("svg",{width:"12",height:"10",viewBox:"0 0 12 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:s.jsx("path",{d:"M0 10V0L11.875 5L0 10ZM1.25 8.125L8.65625 5L1.25 1.875V4.0625L5 5L1.25 5.9375V8.125Z",fill:"currentColor"})})}function Qb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#rejected-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 5V7.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 10H7.50625",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"rejected-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}function Jb({className:e,...t}){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":!0,...t,children:[s.jsxs("g",{clipPath:"url(#paid-tab-icon-clip)",children:[s.jsx("path",{d:"M7.5 13.75C10.9518 13.75 13.75 10.9518 13.75 7.5C13.75 4.04822 10.9518 1.25 7.5 1.25C4.04822 1.25 1.25 4.04822 1.25 7.5C1.25 10.9518 4.04822 13.75 7.5 13.75Z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.625 7.5L6.875 8.75L9.375 6.25",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"paid-tab-icon-clip",children:s.jsx("rect",{width:"15",height:"15",fill:"white"})})})]})}const lu=[{key:"drafts",label:"DRAFTS",Icon:Yb,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:Hb,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:Kb,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:Qb,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:Jb,iconClassName:"text-green-500"}],Gb={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 ol(e){return e!==null&&lu.some(t=>t.key===e)}function zi({paymentsMode:e="all"}){const t=ye(),r=ct(),[n]=Pm(),{selectedEntity:a}=it(),{onPaymentRequired:i}=$r(),o=(a==null?void 0:a.entityId)??null,l=n.get("tab"),[c,u]=N.useState(ol(l)?l:Ii),[d,m]=N.useState(e==="all"?"all":e),[h,f]=N.useState(null);N.useEffect(()=>{ol(l)&&u(l)},[l]);const b=Gb[c],{data:p=[],isLoading:g}=ke({queryKey:["remittance-payments",o,e],queryFn:async()=>{const[w,F]=await Promise.all([e!=="state"?Rb(o):Promise.resolve([]),e!=="federal"?Li(o):Promise.resolve([])]);return[...w.map(Bb),...F.map(Ub)]},enabled:o!==null}),y=N.useMemo(()=>Wb(p),[p]),A=N.useMemo(()=>Zb(p,c,d),[p,c,d]),j=yh({mutationFn:async w=>{try{w.category==="federal"?await Lb(w.id):await qb(w.id)}catch(F){if(F instanceof xn&&F.status===402&&i){const D=F.extensions,$={paymentType:(D==null?void 0:D.paymentType)??w.category,paymentId:(D==null?void 0:D.paymentId)??w.id,expectedAmount:(D==null?void 0:D.expectedAmount)??"0.00",currency:(D==null?void 0:D.currency)??"USD",federalRecordCount:(D==null?void 0:D.federalRecordCount)??0,stateRecordCount:(D==null?void 0:D.stateRecordCount)??0,feePerFederal:(D==null?void 0:D.feePerFederal)??null,feePerState:(D==null?void 0:D.feePerState)??null};i($);return}throw F}},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:()=>f(null),onSettled:()=>f(null)});N.useEffect(()=>{const w=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(Ka,w),()=>window.removeEventListener(Ka,w)},[r]);const S=w=>{f(`${w.category}-${w.id}`),j.mutate(w)},E=w=>{w.category==="federal"?t(`/payments/federal/${w.id}/view`):t(`/payments/state/${w.id}/view`)},I=w=>{w.category==="federal"?t(`/payments/federal/${w.id}/edit`):t(`/payments/state/${w.id}/edit`)};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=="state"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/payments"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(sa,{}),"Add Federal Payment"]}),e!=="federal"&&s.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/payments",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(sa,{}),"Add State Payment"]}),e==="all"&&s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"inline-flex cursor-not-allowed items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-semibold text-slate-400",children:[s.jsx(sa,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:lu.map(w=>{const F=c===w.key,D=w.Icon;return s.jsxs("button",{type:"button",onClick:()=>{u(w.key),t(Bs(w.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 ${F?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(D,{className:`shrink-0 ${w.iconClassName}`}),w.label," (",y[w.key],")"]},w.key)})}),s.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[s.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",children:[s.jsx("option",{value:"all",children:"All"}),s.jsx("option",{value:"federal",children:"Federal"}),s.jsx("option",{value:"state",children:"State"}),s.jsx("option",{value:"local",disabled:!0,children:"Local (Coming Soon)"})]})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[800px] text-left text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:b.columns.map(w=>s.jsx("th",{className:"px-6 py-3",children:w},w))})}),s.jsx("tbody",{children:g?s.jsx("tr",{children:s.jsx("td",{colSpan:b.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):A.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:b.columns.length,className:"px-6 py-12 text-center text-slate-500",children:b.emptyMessage})}):A.map(w=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:c==="drafts"?`#${w.id}`:w.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:w.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:w.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Bn(w.amount)}),c!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:w.paymentDate}):null,c==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:w.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(Vb,{actionType:b.actionType,onView:()=>E(w),onEdit:()=>I(w),onSubmit:()=>S(w),isSubmitting:h===`${w.category}-${w.id}`})})]},`${w.category}-${w.id}`))})]})})]})]})}function sa(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function Un(e){return he(`/portal/bank-accounts?entityId=${e}`)}function Xb(e){return he("/portal/bank-accounts",{method:"POST",body:e})}function cu(e,t){return he(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function vr({title:e,children:t,isFirst:r=!1,headerAction:n}){return s.jsxs("section",{className:r?"":"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"text-base font-semibold text-gov-600",children:e}),n]}),t]})}const dn=17,uu=9;function Yr(e,t){return e.replace(/\D/g,"").slice(0,t)}const du=["Checking","Savings"],e0=Bt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dn} digits`),confirmAccountNumber:_().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${dn} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Vs(du,{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 t0({entityId:e,onCancel:t,onSuccess:r}){const n=ct(),{showSuccess:a,showError:i}=Is(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=St({resolver:Ct(e0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async b=>{l(null),u(!0);try{const p=await Xb({entityId:e,bankName:b.bankName.trim(),accountNumber:b.accountNumber,routingNumber:b.routingNumber,accountType:b.accountType});await n.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),r(p.bankAccountDetailId)}catch(p){const g=st(p,"Unable to save bank account.");l(g),i("Action Not Completed",g)}finally{u(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:b=>{b.preventDefault(),b.stopPropagation(),f(b)},className:"space-y-6",children:[s.jsxs(lr,{step:2,title:"Add Bank Account Manually",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Bank Account"}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(Re,{name:"accountNumber",control:d,render:({field:b})=>{var p;return s.jsx(de,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:b.value,onChange:g=>b.onChange(Yr(g.target.value,dn)),onBlur:b.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),s.jsx(Re,{name:"confirmAccountNumber",control:d,render:({field:b})=>{var p;return s.jsx(de,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:b.value,onChange:g=>b.onChange(Yr(g.target.value,dn)),onBlur:b.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),s.jsx(Re,{name:"routingNumber",control:d,render:({field:b})=>{var p;return s.jsx(de,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:b.value,onChange:g=>b.onChange(Yr(g.target.value,uu)),onBlur:b.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),s.jsx(Re,{name:"accountType",control:d,render:({field:b})=>{var p;return s.jsx(wt,{label:"Account Type",required:!0,value:b.value,onChange:b.onChange,onBlur:b.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:du.map(g=>s.jsx("option",{value:g,children:g},g))})}})]}),s.jsx(Re,{name:"bankName",control:d,render:({field:b})=>{var p;return s.jsx(de,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:b.value,onChange:b.onChange,onBlur:b.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?s.jsx(Vt,{message:o}):null,s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx("button",{type:"button",onClick:t,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"button",disabled:c,onClick:()=>void f(),className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:c?"Saving…":"Save"})]})]})}function mu({open:e,entityId:t,onClose:r,onAccountAdded:n}){const[a,i]=N.useState("choose");if(N.useEffect(()=>{e||i("choose")},[e]),N.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,r]),!e)return null;const o=a==="manual";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"add-bank-account-title",className:`relative w-full rounded-3xl bg-white p-8 shadow-xl ${o?"max-w-2xl":"max-w-[420px]"}`,children:o&&t?s.jsx(t0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{n==null||n(l),r()}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:"1"}),s.jsx("h2",{id:"add-bank-account-title",className:"text-sm font-medium uppercase tracking-[0.2em] text-slate-400",children:"Add Bank Account"})]}),s.jsx("div",{className:"my-6 h-px bg-slate-200"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("button",{type:"button",onClick:()=>i("manual"),disabled:!t,className:"flex w-full items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gov-600 text-white",children:s.jsx(r0,{className:"h-5 w-5"})}),s.jsx("span",{className:"text-base font-semibold text-slate-900",children:"Add Manually"})]}),s.jsxs("button",{type:"button",disabled:!0,title:"Coming soon",className:"flex w-full cursor-not-allowed items-center gap-4 rounded-full border border-slate-200 px-5 py-4 text-left opacity-60",children:[s.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-slate-200 bg-white",children:s.jsx(n0,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function r0({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 7.5h10.5M6.75 12h10.5m-10.5 4.5h10.5M3.75 6.75A2.25 2.25 0 016 3.75h12A2.25 2.25 0 0120.25 6.75v10.5A2.25 2.25 0 0118 21H6A2.25 2.25 0 013.75 18.75V6.75z"})})}function n0({className:e}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",fill:"#111827"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",fill:"#111827",opacity:"0.35"})]})}const s0=12,a0=["January","February","March","April","May","June","July","August","September","October","November","December"];function ir(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function ws(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const r=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(r,n,a);return i.getFullYear()!==r||i.getMonth()!==n||i.getDate()!==a?null:i}function Us(e=new Date){const t=new Date(e);return e.getHours()>=s0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),ir(t)}function hu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),ir(t)}function i0(e=18,t=new Date){const r=new Date(t);return r.setFullYear(r.getFullYear()-e),r.setHours(0,0,0,0),ir(r)}function o0(e,t,r=new Date){const n=ws(e);if(!n)return!1;const a=new Date(r);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),n.setHours(0,0,0,0),n<=a}function l0(e){const t=e.getDay();return t!==0&&t!==6}function Va(e,t=new Date){if(!l0(e))return!1;const r=ir(e);return r>=Us(t)&&r<=hu(t)}function fu(e,t=new Date){const r=ws(e);return r?Va(r,t):!1}function c0(e,t){return`${a0[t]} ${e}`}function u0(e,t){const r=new Date(e,t,1),n=new Date(e,t+1,0).getDate(),a=r.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=n;o+=1)i.push(new Date(e,t,o));return i}function ll(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Zn(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 pu({label:e,required:t=!1,htmlFor:r,info:n}){return s.jsxs("label",{htmlFor:r,className:"mb-1.5 flex items-center gap-1.5 text-sm text-slate-600",children:[s.jsxs("span",{children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}),n?s.jsx("span",{title:n,className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-slate-300 text-[10px] font-semibold leading-none text-slate-400","aria-label":n,children:"i"}):null]})}function W({label:e,required:t,error:r,info:n,children:a}){return s.jsxs("div",{children:[s.jsx(pu,{label:e,required:t,info:n}),a,r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}const xu=e=>`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${e?"border-red-300":"border-slate-200"}`;function J(e,t=!1){return t?`block w-full cursor-default rounded-lg border bg-[#F9FAFB] px-3 py-2.5 text-sm text-slate-700 focus:outline-none ${e?"border-red-300":"border-[#E5E7EB]"}`:xu(e)}function Hr(e){return`${xu(e)} appearance-none`}function Ur({className:e}){return s.jsx("svg",{className:e??"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function En({children:e}){return s.jsx("div",{className:"relative",children:e})}function gu({value:e,onChange:t,entityId:r,entityType:n="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[u,d]=N.useState(!1),[m,h]=N.useState(!1),f=N.useRef(null),b=a.find(g=>String(g.bankAccountDetailId)===e);N.useEffect(()=>{if(!u)return;const g=y=>{var A;(A=f.current)!=null&&A.contains(y.target)||d(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[u]);const p=g=>{t(String(g)),h(!1),d(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,className:"relative",children:[s.jsx(pu,{label:c,required:!0}),s.jsxs("button",{type:"button",disabled:o||!r,onClick:()=>d(g=>!g),className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${l?"border-red-300":"border-slate-200"}`,children:[s.jsx("span",{className:b?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":b?ll(b.accountNumber):"Bank account number"}),s.jsx(m0,{className:`shrink-0 text-slate-400 transition ${u?"rotate-180":""}`})]}),l?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,u?s.jsxs("div",{className:"absolute left-0 right-0 z-20 mt-2 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"p-3",children:s.jsxs("button",{type:"button",onClick:()=>{d(!1),h(!0)},className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-gov-700",children:[s.jsx(d0,{}),"Add Bank Account"]})}),s.jsx("div",{className:"border-t border-slate-200 px-4 py-2",children:s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"List of Bank Accounts"})}),s.jsx("div",{className:"max-h-64 overflow-y-auto pb-2",children:a.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No bank accounts yet."}):a.map(g=>{const y=String(g.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(g.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${y?"bg-gov-50":""}`,children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xs font-semibold text-white",children:Pi(g.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:g.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[ll(g.accountNumber),n?` · ${n}`:` · ${g.accountType}`]})]})]},g.bankAccountDetailId)})})]}):null]}),s.jsx(mu,{open:m,entityId:r,onClose:()=>h(!1),onAccountAdded:p})]})}function d0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function m0({className:e=""}){return s.jsx("svg",{className:`h-4 w-4 ${e}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function h0(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Wn({entity:e,remittanceAmount:t="—",className:r=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No entity selected."})]});const n=At(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${r}`,children:[s.jsx("div",{className:"bg-[#7F95B0] px-5 py-3.5 text-xs font-semibold uppercase tracking-wider text-white",children:"Entity Details"}),s.jsxs("dl",{className:"space-y-4 p-5 text-sm",children:[s.jsx(wn,{label:"Entity Name",value:n}),s.jsx(wn,{label:"Tax ID",value:dr(e.idNumber)}),s.jsx(wn,{label:"Email ID",value:e.email}),s.jsx(wn,{label:"Phone Number",value:Dr(e.phoneNumber)}),s.jsx(wn,{label:"Address",value:h0(e)})]}),s.jsxs("div",{className:"border-t border-slate-100 px-5 py-4",children:[s.jsx("p",{className:"text-sm font-medium text-[#99A1AF]",children:"Remittance Amount"}),s.jsx("p",{className:"mt-1.5 text-xl font-bold text-gov-600",children:t})]})]})}function wn({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm font-medium text-slate-500",children:e}),s.jsx("dd",{className:"mt-0.5 text-sm leading-relaxed text-slate-800",children:t})]})}const f0=[0,1,3,4,6,7,9,10],p0=[0,1,2,3,4,5,6,7,8,9,10],x0=[0,1,2,3,4,5,6,8,9,10,11],g0=[0,1,2,3,4,5,6,7,9,10,11],y0=["720","941"],b0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],v0=["7200D"],j0=["8963"];function yu(e){return y0.includes(e)?f0:b0.includes(e)?p0:v0.includes(e)?x0:j0.includes(e)?g0:[]}function N0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Ss(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 w0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function bu(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const ks={941:"94105",944:"94405","CT-1":"10005"},Sn={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Ba={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 Mi(e,t){return!e||!t?!1:ks[e]===t}function Zs(e,t){return e==="CT-1"&&t===ks["CT-1"]}function S0(e,t){return e==="941"&&t===ks[941]||e==="944"&&t===ks[944]}function k0(e){return e==="CT-1"?{code1:Sn.tier1,code2:Sn.tier2,code3:""}:{code1:Sn.socialSecurity,code2:Sn.medicare,code3:Sn.withheld}}function Ua(e){return Ba.regex.test(e)}const C0=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,ts=1e8;function A0(e){if(!e)return"";let t="",r=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!r&&(t+=c,r=!0);const n=t.indexOf(".");let a=n===-1?t:t.slice(0,n);const i=n===-1?"":t.slice(n+1,n+3),o=n!==-1&&t.endsWith(".");if(a.length>9&&(a=a.slice(0,9)),a.length===9&&a!=="100000000"&&(a=a.slice(0,8)),a.length>0&&!o&&i===""){const c=Number.parseInt(a,10);!Number.isNaN(c)&&c>ts&&(a=String(ts))}let l=n===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),C0.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>ts)return String(ts)}return l}return""}function vu(e){return Ua(e)?Number.parseFloat(e):null}function P0(e,t,r,n){const a=[e,t];return n&&a.push(r),a.reduce((i,o)=>{const l=vu(o);return l===null?i:i+l},0)}function E0(e,t){return Math.abs(e-t)<.005}function _0(e,t,r,n,a){if(!Mi(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=Zs(e,t);return{subcategoryCode1:r.trim()?"1":null,subcategoryCode2:n.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const T0=["Su","Mo","Tu","We","Th","Fr","Sa"];function I0(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function F0({value:e,onChange:t,disabled:r=!1,hasError:n=!1}){const a=ws(e),i=Us(),o=hu(),[l,c]=N.useState(!1),[u,d]=N.useState(()=>a??ws(i)??new Date),m=N.useRef(null),h=N.useId();N.useEffect(()=>{a&&d(a)},[e]),N.useEffect(()=>{if(!l)return;const y=A=>{var j;(j=m.current)!=null&&j.contains(A.target)||c(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]);const f=N.useMemo(()=>u0(u.getFullYear(),u.getMonth()),[u]),b=N.useMemo(()=>{const y=new Date(u.getFullYear(),u.getMonth()-1,1),A=new Date(y.getFullYear(),y.getMonth()+1,0);return ir(A)>=i},[u,i]),p=N.useMemo(()=>{const y=new Date(u.getFullYear(),u.getMonth()+1,1);return ir(y)<=o},[u,o]),g=y=>{Va(y)&&(t(ir(y)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:r,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!r&&c(y=>!y),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>c(y=>!y),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open settlement date picker",children:s.jsx(I0,{})})]}),l?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[300px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!b,onClick:()=>d(y=>new Date(y.getFullYear(),y.getMonth()-1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:c0(u.getFullYear(),u.getMonth())}),s.jsx("button",{type:"button",disabled:!p,onClick:()=>d(y=>new Date(y.getFullYear(),y.getMonth()+1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next month",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pt-2 text-center text-xs font-medium text-slate-500",children:T0.map(y=>s.jsx("div",{className:"py-1",children:y},y))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((y,A)=>{if(!y)return s.jsx("div",{},`empty-${A}`);const j=ir(y),S=e===j,E=!Va(y);return s.jsx("button",{type:"button","aria-disabled":E,onClick:()=>g(y),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:y.getDate()},j)})})]}):null]})}function rs({value:e,onChange:t,onBlur:r,name:n,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:n,value:e,disabled:a,readOnly:i,placeholder:o,className:J(l,i),onChange:c=>t(A0(c.target.value)),onBlur:r})}const D0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R0(){return s.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M3 9h18",className:"stroke-gov-600",strokeWidth:"1.5"}),s.jsx("path",{d:"M8 3v4M16 3v4",className:"stroke-gov-600",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"15",r:"1.5",className:"fill-gov-600"})]})}function O0({value:e,onChange:t,disabled:r=!1,hasError:n=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=bu(),l=Ss(e),[c,u]=N.useState(!1),[d,m]=N.useState((l==null?void 0:l.year)??o),h=N.useRef(null),f=N.useId();N.useEffect(()=>{l&&m(l.year)},[e]),N.useEffect(()=>{if(!c)return;const 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 b=N0(e),p=j=>!!a.includes(j),g=j=>{p(j)||(t(w0(d,j)),u(!1))},y=d>i,A=d<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 border-b bg-transparent pb-2 transition ${n?"border-red-400":"border-slate-300 focus-within:border-gov-500"}`,children:[s.jsx("input",{id:f,type:"text",readOnly:!0,disabled:r,value:b,placeholder:"YYYY-MM",onClick:()=>!r&&u(j=>!j),className:"w-full cursor-pointer border-0 bg-transparent text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),s.jsx("button",{type:"button",disabled:r,onClick:()=>u(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:s.jsx(R0,{})})]}),c?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+8px)] z-50 w-[280px] rounded-xl border border-slate-200 bg-white shadow-lg",children:[s.jsx("div",{className:"absolute -top-2 left-8 h-4 w-4 rotate-45 border-l border-t border-slate-200 bg-white"}),s.jsxs("div",{className:"flex items-center justify-between rounded-t-xl bg-slate-50 px-4 py-3",children:[s.jsx("button",{type:"button",disabled:!y,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:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),s.jsx("span",{className:"text-sm font-semibold text-slate-900",children:d}),s.jsx("button",{type:"button",disabled:!A,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:s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),s.jsx("div",{className:"grid grid-cols-3 gap-1 p-3",children:D0.map((j,S)=>{const E=(l==null?void 0:l.year)===d&&l.month===S&&e.length===6,I=p(S);return s.jsx("button",{type:"button","aria-disabled":I,onClick:()=>g(S),className:`rounded-lg px-2 py-2.5 text-sm transition ${I?"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 ju="Active",$0="Inactive";function yn(e){return(e.status??ju).trim().toLowerCase()==="active"}function L0(e){return yn(e)?$0:ju}function z0(e){return yn(e)?"Deactivate":"Activate"}function qi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function M0(e){return qi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function Nu(e){const t=_0(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),r=Zs(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 Vi(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),...Nu(t)}}function Bi(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),...Nu(e)}}const Ui="federal-payment-draft";function Zi(e){sessionStorage.setItem(Ui,JSON.stringify(e))}function Ws(){const e=sessionStorage.getItem(Ui);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Wi(){sessionStorage.removeItem(Ui)}function q0(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 V0=Bt({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=Ss(e);if(!t)return!1;const{minYear:r,maxYear:n}=bu();return t.year>=r&&t.year<=n},"Tax period must be within the last 3 years"),settlementDate:_().min(1,"This field is required").refine(e=>fu(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:_().min(1,"This field is required").refine(e=>Ua(e),Ba.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=Ss(e.taxPeriod);c&&yu(e.taxFormType).includes(c.month)&&t.addIssue({code:Vr.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Mi(e.taxFormType,e.taxTypeCode))return;const r=Zs(e.taxFormType,e.taxTypeCode),n=S0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:Vr.custom,message:"This field is required",path:[u]});return}Ua(c)||t.addIssue({code:Vr.custom,message:Ba.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",n);const i=vu(e.paymentAmount),o=P0(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",n);i!==null&&!E0(i,o)&&t.addIssue({code:Vr.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),r&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Vr.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),ns="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function aa(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 B0={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function U0(e,t){if(e)return aa(e);if(t!=null&&t.paymentDraft)return aa(t.paymentDraft);const r=Ws();return r?aa(r):B0}function wu({entity:e,initialDraft:t,readonly:r=!1,onCancel:n}){var mr,_t,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,Mr;const a=ye(),i=ge(),o=ct(),l=zr(i.state,Ze()),c=i.state,u=N.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Ws()??null,[t,c==null?void 0:c.paymentDraft]),d=N.useRef(u==null?void 0:u.federalPaymentId),m=N.useRef(u==null?void 0:u.enrollmentId),[h,f]=N.useState(null),[b,p]=N.useState(!1),g=N.useMemo(()=>U0(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);N.useEffect(()=>{u!=null&&u.federalPaymentId&&(d.current=u.federalPaymentId),u!=null&&u.enrollmentId&&(m.current=u.enrollmentId)},[u==null?void 0:u.federalPaymentId,u==null?void 0:u.enrollmentId]);const{data:y=[],isLoading:A}=ke({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Un(e.entityId),enabled:e!==null}),j=N.useMemo(()=>y.filter(yn),[y]),{data:S=[],isLoading:E}=ke({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>Ob(e.entityId),enabled:e!==null}),{register:I,control:w,handleSubmit:F,watch:D,setValue:$,trigger:se,formState:{errors:B}}=St({resolver:Ct(V0),defaultValues:g}),Q=D("bankAccountDetailId"),te=D("paymentAmount"),Y=D("taxFormType"),ne=D("taxTypeCode"),xe=D("taxPeriod"),pe=D("settlementDate"),$e=D("subcategoryAmount1"),Ke=D("subcategoryAmount2"),Ge=D("subcategoryAmount3"),oe=N.useRef(Y),Pe=N.useMemo(()=>Y?yu(Y):[],[Y]),_e=N.useMemo(()=>Mi(Y,ne),[Y,ne]),H=N.useMemo(()=>Zs(Y,ne),[Y,ne]),{data:Le=[],isLoading:dt}=ke({queryKey:["federal-tax-type-codes",Y],queryFn:()=>$b(Y),enabled:!!Y});N.useEffect(()=>{oe.current&&oe.current!==Y&&$("taxTypeCode",""),oe.current=Y},[Y,$]),N.useEffect(()=>{if(!xe||!Y)return;const q=Ss(xe);q&&Pe.includes(q.month)&&$("taxPeriod","")},[Y,xe,Pe,$]),N.useEffect(()=>{pe&&(fu(pe)||$("settlementDate",""))},[pe,$]),N.useEffect(()=>{if(!_e){$("subcategoryCode1",""),$("subcategoryCode2",""),$("subcategoryCode3",""),$("subcategoryAmount1",""),$("subcategoryAmount2",""),$("subcategoryAmount3","");return}const q=k0(Y);$("subcategoryCode1",q.code1),$("subcategoryCode2",q.code2),$("subcategoryCode3",H?"":q.code3),H&&$("subcategoryAmount3","")},[_e,Y,H,$]),N.useEffect(()=>{_e&&(se("paymentAmount"),se("subcategoryAmount1"),se("subcategoryAmount2"),se("subcategoryAmount3"))},[$e,Ke,Ge,_e,se]),N.useEffect(()=>{const q=j.find(ae=>String(ae.bankAccountDetailId)===Q);if(!q){Q&&($("bankAccountDetailId",""),$("routingNumber",""),$("accountType",""),$("bankName",""));return}$("routingNumber",q.routingNumber),$("accountType",q.accountType),$("bankName",q.bankName)},[j,Q,$]);const mt=q=>{const ae=j.find(x=>String(x.bankAccountDetailId)===q.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:q.taxpayerPin??"",secondaryTin:q.secondaryTin??"",bankAccountDetailId:q.bankAccountDetailId,routingNumber:q.routingNumber??(ae==null?void 0:ae.routingNumber)??"",accountNumber:(ae==null?void 0:ae.accountNumber)??"",accountType:q.accountType??(ae==null?void 0:ae.accountType)??"",bankName:q.bankName??(ae==null?void 0:ae.bankName)??"",taxFormType:q.taxFormType,taxTypeCode:q.taxTypeCode,taxPeriod:q.taxPeriod,settlementDate:q.settlementDate,paymentAmount:q.paymentAmount,subcategoryCode1:q.subcategoryCode1,subcategoryAmount1:q.subcategoryAmount1,subcategoryCode2:q.subcategoryCode2,subcategoryAmount2:q.subcategoryAmount2,subcategoryCode3:q.subcategoryCode3,subcategoryAmount3:q.subcategoryAmount3}},Pt=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},le=async q=>{if(!e)return null;if(q.federalPaymentId){const x=await $i(q.federalPaymentId,Bi(q));return d.current=x.federalPaymentId,m.current=x.enrollmentId,x}const ae=await Oi(Vi(e.entityId,q));return d.current=ae.federalPaymentId,m.current=ae.enrollmentId,ae},Ie=F(async q=>{if(!(r||!e)){f(null),p(!0);try{const ae=mt(q),x=await le(ae);if(!x)return;const k={...ae,federalPaymentId:x.federalPaymentId,enrollmentId:x.enrollmentId};await Pt(),Zi(k),a(M0(e),{state:{from:l,paymentDraft:k}})}catch(ae){f(st(ae,"Failed to save payment details."))}finally{p(!1)}}}),ht=F(async q=>{if(!(!e||r)){f(null),p(!0);try{const ae=mt(q);await le(ae),await Pt(),Wi(),a(Ze())}catch(ae){f(st(ae,"Failed to save draft."))}finally{p(!1)}}}),Et=()=>{if(n){n();return}a(l)},yt=e?At(e):"Entity";return s.jsxs("form",{onSubmit:Ie,noValidate:!0,className:"w-full space-y-6",children:[h?s.jsx(Vt,{message:h}):null,s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:yt}),s.jsx(Wn,{entity:e,remittanceAmount:Zn(te),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:[s.jsx(vr,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:ns,children:[s.jsx(W,{label:"Taxpayer PIN",required:!0,error:(mr=B.taxpayerPin)==null?void 0:mr.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:J(!!B.taxpayerPin),maxLength:4,disabled:r,...I("taxpayerPin")})}),s.jsx(W,{label:"Secondary TIN",error:(_t=B.secondaryTin)==null?void 0:_t.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:J(!!B.secondaryTin),maxLength:9,disabled:r,...I("secondaryTin")})}),s.jsx(Re,{name:"bankAccountDetailId",control:w,render:({field:q})=>{var ae;return s.jsx(gu,{value:q.value,onChange:q.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:j,isLoading:A,disabled:!e||r,error:(ae=B.bankAccountDetailId)==null?void 0:ae.message})}}),s.jsx(W,{label:"Routing Number",required:!0,error:(Ut=B.routingNumber)==null?void 0:Ut.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:J(!!B.routingNumber,!0),...I("routingNumber")})}),s.jsx(W,{label:"Account Type",required:!0,error:(Tt=B.accountType)==null?void 0:Tt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:J(!!B.accountType,!0),...I("accountType")})}),s.jsx(W,{label:"Bank Name",required:!0,error:(It=B.bankName)==null?void 0:It.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:J(!!B.bankName,!0),...I("bankName")})})]})}),s.jsx(vr,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ns,children:[s.jsx(W,{label:"Tax Form Type",required:!0,error:(hr=B.taxFormType)==null?void 0:hr.message,children:s.jsxs(En,{children:[s.jsxs("select",{className:Hr(!!B.taxFormType),disabled:E||!e||r,...I("taxFormType"),children:[s.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),S.map(q=>s.jsx("option",{value:q.value,children:q.value},q.value))]}),s.jsx(Ur,{})]})}),s.jsx(W,{label:"Payment Type",required:!0,error:(Zt=B.taxTypeCode)==null?void 0:Zt.message,children:s.jsxs(En,{children:[s.jsxs("select",{className:Hr(!!B.taxTypeCode),disabled:!Y||dt||r,...I("taxTypeCode"),children:[s.jsx("option",{value:"",children:Y?dt?"Loading payment types…":"Select payment type":"Select tax form first"}),Le.map(q=>s.jsxs("option",{value:q.code,children:[q.code," - ",q.codeName]},q.code))]}),s.jsx(Ur,{})]})}),s.jsx(W,{label:"Tax Period",required:!0,error:(fr=B.taxPeriod)==null?void 0:fr.message,children:s.jsx(Re,{name:"taxPeriod",control:w,render:({field:q})=>s.jsx(O0,{value:q.value,onChange:q.onChange,hasError:!!B.taxPeriod,disabled:!Y||r,disabledMonths:Pe})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(W,{label:"Settlement Date",required:!0,error:(Wt=B.settlementDate)==null?void 0:Wt.message,children:s.jsx(Re,{name:"settlementDate",control:w,render:({field:q})=>s.jsx(F0,{value:q.value,onChange:q.onChange,hasError:!!B.settlementDate,disabled:r})})}),s.jsx(W,{label:"Payment Amount",required:!0,error:(Yt=B.paymentAmount)==null?void 0:Yt.message,children:s.jsx(Re,{name:"paymentAmount",control:w,render:({field:q})=>s.jsx(rs,{name:q.name,value:q.value,onChange:q.onChange,onBlur:q.onBlur,disabled:r,hasError:!!B.paymentAmount})})})]}),_e?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:ns,children:[s.jsx(W,{label:"Subcategory Code 1",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...I("subcategoryCode1")})}),s.jsx(W,{label:"Subcategory Code 2",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...I("subcategoryCode2")})}),H?null:s.jsx(W,{label:"Subcategory Code 3",children:s.jsx("input",{readOnly:!0,className:J(!1,!0),...I("subcategoryCode3")})})]}),s.jsxs("div",{className:ns,children:[s.jsx(W,{label:"Subcategory Amount 1",required:!0,error:(pr=B.subcategoryAmount1)==null?void 0:pr.message,children:s.jsx(Re,{name:"subcategoryAmount1",control:w,render:({field:q})=>s.jsx(rs,{name:q.name,value:q.value??"",onChange:q.onChange,onBlur:q.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!B.subcategoryAmount1})})}),s.jsx(W,{label:"Subcategory Amount 2",required:!0,error:(xr=B.subcategoryAmount2)==null?void 0:xr.message,children:s.jsx(Re,{name:"subcategoryAmount2",control:w,render:({field:q})=>s.jsx(rs,{name:q.name,value:q.value??"",onChange:q.onChange,onBlur:q.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!B.subcategoryAmount2})})}),H?null:s.jsx(W,{label:"Subcategory Amount 3",required:!0,error:(Mr=B.subcategoryAmount3)==null?void 0:Mr.message,children:s.jsx(Re,{name:"subcategoryAmount3",control:w,render:({field:q})=>s.jsx(rs,{name:q.name,value:q.value??"",onChange:q.onChange,onBlur:q.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!B.subcategoryAmount3})})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:Et,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:r?"Back":"Cancel"}),r?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:ht,disabled:!e||b,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:b?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||b,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:b?"Saving…":"Next"})]})]})]},i.key)}function Su(){const{selectedEntity:e}=it();return s.jsx(wu,{entity:e})}function ku({mode:e}){var m;const t=ye(),{federalPaymentId:r}=Xa(),{selectedEntity:n}=it(),a=Number.parseInt(r??"",10),{data:i,isLoading:o,isError:l}=ke({queryKey:["federal-payment",a],queryFn:()=>Ri(a),enabled:Number.isFinite(a)}),{data:c=[]}=ke({queryKey:["bank-accounts",n==null?void 0:n.entityId],queryFn:()=>Un(n.entityId),enabled:n!==null&&i!==void 0}),u=N.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return q0(i,{routingNumber:h==null?void 0:h.routingNumber,accountNumber:h==null?void 0:h.accountNumber,accountType:h==null?void 0:h.accountType,bankName:h==null?void 0:h.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(Oe,{to:Ze(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!u)return s.jsx(Oe,{to:Ze(),replace:!0});if(!n||i.entityId!==n.entityId)return s.jsx(Oe,{to:Ze(),replace:!0});const d=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(wu,{entity:n,initialDraft:u,readonly:d,onCancel:()=>t(Ze())})}function Cu(){return it(),s.jsx(ku,{mode:"edit"})}function Au(){return it(),s.jsx(ku,{mode:"view"})}const Z0=["Withholding Tax","Estimated Tax","Income Tax"],cl=[{code:"VA",name:"Virginia"}],W0=[{value:"Q1",label:"Q1"},{value:"Q2",label:"Q2"},{value:"Q3",label:"Q3"},{value:"Q4",label:"Q4"}];function Y0(){const e=new Date().getFullYear();return[e,e-1,e-2]}const Yi="state-payment-draft";function Za(e){sessionStorage.setItem(Yi,JSON.stringify(e))}function Wa(){const e=sessionStorage.getItem(Yi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Pu(){sessionStorage.removeItem(Yi)}function Eu(e,t){return`${e}-${t}`}function H0(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Eu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function K0(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Eu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}const Q0=Bt({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"),letterId:_().optional(),taxYear:_().min(1,"Tax year is required"),taxPeriod:_().min(1,"Tax period is required"),taxAmount:_().min(1,"Tax amount is required").refine(e=>Number.parseFloat(e)>0,"Tax amount must be greater than 0"),paymentDate:_().min(1,"Payment date is required").refine(e=>e>=Us(),"Payment date must be a future date"),bankAccountDetailId:_().min(1,"Bank account is required"),routingNumber:_().optional(),accountType:_().optional(),bankName:_().optional()}),ia="grid gap-x-6 gap-y-5 sm:grid-cols-3",ul="grid gap-x-6 gap-y-5 sm:grid-cols-2",dl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ml={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function oa(e){return{state:e.state,reasonForPayment: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 _u({entity:e,initialDraft:t,readonly:r=!1,onCancel:n}){var xe,pe,$e,Ke,Ge,oe,Pe,_e;const a=ye(),i=ge(),o=zr(i.state,Ze()),l=i.state,c=N.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??Wa()??null,[t,l==null?void 0:l.paymentDraft]),u=N.useRef(c==null?void 0:c.statePaymentDetailId),d=N.useMemo(()=>{if(t)return oa(t);if(l!=null&&l.paymentDraft)return oa(l.paymentDraft);if(l!=null&&l.resetDraft)return Pu(),ml;const H=Wa();return H?oa(H):ml},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),m=N.useMemo(()=>Y0(),[]),h=Us(),{data:f=[],isLoading:b}=ke({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Un(e.entityId),enabled:e!==null}),p=N.useMemo(()=>f.filter(yn),[f]),{register:g,control:y,handleSubmit:A,watch:j,setValue:S,formState:{errors:E}}=St({resolver:Ct(Q0),defaultValues:d}),I=j("state"),w=j("reasonForPayment"),F=j("taxAmount"),D=j("bankAccountDetailId"),$=!!(I&&w),[se,B]=N.useState(!1),Q=(xe=cl.find(H=>H.code===I))==null?void 0:xe.name;N.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(u.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),N.useEffect(()=>{if(r)return;const H=p.find(Le=>String(Le.bankAccountDetailId)===D);if(!H){D&&(S("bankAccountDetailId",""),S("routingNumber",""),S("accountType",""),S("bankName",""));return}S("routingNumber",H.routingNumber),S("accountType",H.accountType),S("bankName",H.bankName)},[p,D,S,r]);const te=A(H=>{if(r)return;const Le={statePaymentDetailId:u.current,state:H.state,reasonForPayment:H.reasonForPayment,stateAccountId:H.stateAccountId,accountId:H.accountId,letterId:H.letterId,taxYear:H.taxYear,taxPeriod:H.taxPeriod,taxAmount:H.taxAmount,paymentDate:H.paymentDate,bankAccountDetailId:H.bankAccountDetailId,routingNumber:H.routingNumber,accountType:H.accountType,bankName:H.bankName};Za(Le),a("/payments/state/authorization",{state:{from:o,paymentDraft:Le}})}),Y=()=>{if(n){n();return}a(o)},ne=e?At(e):"Entity";return s.jsx("form",{onSubmit:te,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:ne}),s.jsx(Wn,{entity:e,remittanceAmount:Zn(F),className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"lg:mr-[324px]",children:s.jsxs("div",{className:"mx-auto w-full max-w-[720px] space-y-5",children:[s.jsxs("section",{className:dl,children:[s.jsx(hl,{step:1,title:"Choose a State"}),s.jsxs("div",{className:"mt-5 space-y-5",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",disabled:r,onClick:()=>B(H=>!H),className:"flex w-full items-center justify-between rounded-xl border border-slate-200 bg-slate-50/80 px-4 py-4 text-left transition hover:border-gov-300 hover:bg-gov-50/40 disabled:cursor-not-allowed disabled:opacity-70",children:[s.jsxs("span",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-gov-100 text-gov-600",children:s.jsx(J0,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:Q??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Ur,{className:`h-4 w-4 text-slate-400 transition ${se?"rotate-180":""}`})]}),se?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-2 max-h-64 overflow-y-auto rounded-xl border border-slate-200 bg-white shadow-lg",children:cl.map(H=>s.jsxs("button",{type:"button",onClick:()=>{S("state",H.code,{shouldValidate:!0}),B(!1)},className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${I===H.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:H.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:H.code})]},H.code))}):null,E.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:E.state.message}):null]}),s.jsx(W,{label:"Reason for Payment",required:!0,error:(pe=E.reasonForPayment)==null?void 0:pe.message,children:s.jsxs(En,{children:[s.jsxs("select",{disabled:r,className:Hr(!!E.reasonForPayment),...g("reasonForPayment"),children:[s.jsx("option",{value:"",children:"Select reason"}),Z0.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsx(Ur,{})]})})]})]}),s.jsxs("section",{className:`${dl} transition ${$?"":"opacity-60"}`,children:[s.jsx(hl,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!$||r,className:"min-w-0 border-0 p-0",children:[s.jsx(la,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ia,children:[s.jsx(W,{label:"State ID",required:!0,error:($e=E.stateAccountId)==null?void 0:$e.message,children:s.jsx("input",{placeholder:"Enter ID",className:J(!!E.stateAccountId),...g("stateAccountId")})}),s.jsx(W,{label:"Account ID",required:!0,error:(Ke=E.accountId)==null?void 0:Ke.message,children:s.jsx("input",{placeholder:"123456789-WHW",className:J(!!E.accountId),...g("accountId")})}),s.jsx(W,{label:"Letter ID",children:s.jsx("input",{placeholder:"123456789-WHW",className:J(),...g("letterId")})})]}),s.jsxs("div",{className:ul,children:[s.jsx(W,{label:"Tax Year",required:!0,error:(Ge=E.taxYear)==null?void 0:Ge.message,children:s.jsxs(En,{children:[s.jsxs("select",{className:Hr(!!E.taxYear),...g("taxYear"),children:[s.jsx("option",{value:"",children:"Select TY"}),m.map(H=>s.jsxs("option",{value:String(H),children:["TY ",H]},H))]}),s.jsx(Ur,{})]})}),s.jsx(W,{label:"Tax Period",required:!0,error:(oe=E.taxPeriod)==null?void 0:oe.message,children:s.jsxs(En,{children:[s.jsxs("select",{className:Hr(!!E.taxPeriod),...g("taxPeriod"),children:[s.jsx("option",{value:"",children:"Select"}),W0.map(H=>s.jsx("option",{value:H.value,children:H.label},H.value))]}),s.jsx(Ur,{})]})})]})]})}),s.jsx(la,{title:"Amount Info",children:s.jsxs("div",{className:ul,children:[s.jsx(W,{label:"Tax Amount",required:!0,error:(Pe=E.taxAmount)==null?void 0:Pe.message,children:s.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",className:J(!!E.taxAmount),...g("taxAmount")})}),s.jsx(W,{label:"Payment Date",required:!0,error:(_e=E.paymentDate)==null?void 0:_e.message,children:s.jsx("input",{type:"date",min:h,className:J(!!E.paymentDate),...g("paymentDate")})})]})}),s.jsx(la,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ia,children:[s.jsx(Re,{name:"bankAccountDetailId",control:y,render:({field:H})=>{var Le;return s.jsx(gu,{value:H.value,onChange:H.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:p,isLoading:b,disabled:!e||!$||r,error:(Le=E.bankAccountDetailId)==null?void 0:Le.message,label:"Account Number"})}}),s.jsx(W,{label:"Routing Number",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:J(!1,!0),...g("routingNumber")})}),s.jsx(W,{label:"Account Type",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:J(!1,!0),...g("accountType")})})]}),s.jsx("div",{className:ia,children:s.jsx(W,{label:"Bank Name",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:J(!1,!0),...g("bankName")})})})]})})]}),$?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:"Select a state and reason for payment to continue."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:Y,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:r?"Back":"Cancel"}),r?null:s.jsxs("button",{type:"submit",disabled:!e||!$,className:"inline-flex h-11 min-w-[120px] items-center justify-center gap-2 rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:["Next",s.jsx(G0,{})]})]})]})})]})},i.key)}function hl({step:e,title:t,className:r=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gov-600 text-sm font-semibold text-white",children:e}),s.jsx("h3",{className:"text-sm font-bold uppercase tracking-wide text-slate-900",children:t})]})}function la({title:e,children:t}){return s.jsxs("div",{className:"mt-6 first:mt-0",children:[s.jsx("h4",{className:"mb-4 text-xs font-semibold uppercase tracking-wide text-slate-400",children:e}),t]})}function J0(){return s.jsxs("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]})}function G0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})}function Tu(){const{selectedEntity:e}=it();return s.jsx(_u,{entity:e})}function X0(e){const t=e.indexOf("-");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function Iu(){var c;const{statePaymentId:e}=Xa(),{selectedEntity:t}=it(),r=Number.parseInt(e??"",10),{data:n=[],isLoading:a,isError:i}=ke({queryKey:["state-payments",t==null?void 0:t.entityId],queryFn:()=>Li(t.entityId),enabled:t!==null&&Number.isFinite(r)}),o=n.find(u=>u.statePaymentDetailId===r)??null,l=N.useMemo(()=>{if(!o)return null;const[u,d]=X0(o.taxPeriod);return{statePaymentDetailId:o.statePaymentDetailId,state:o.state,reasonForPayment:"",stateAccountId:"",accountId:"",taxYear:u,taxPeriod:d,taxAmount:String(o.taxAmount),paymentDate:o.paymentDate,bankAccountDetailId:""}},[o]);return Number.isFinite(r)?a?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!o||!l?s.jsx(Oe,{to:Ze(),replace:!0}):!t||o.entityId!==t.entityId?s.jsx(Oe,{to:Ze(),replace:!0}):((c=o.status)==null?void 0:c.toLowerCase())!=="draft"?s.jsx(Oe,{to:`/payments/state/${r}/view`,replace:!0}):s.jsx(_u,{entity:t,initialDraft:l}):s.jsx(Oe,{to:Ze(),replace:!0})}function Fu(){var c,u;const{statePaymentId:e}=Xa(),t=ye(),{selectedEntity:r}=it(),n=Number.parseInt(e??"",10),{data:a=[],isLoading:i,isError:o}=ke({queryKey:["state-payments",r==null?void 0:r.entityId],queryFn:()=>Li(r.entityId),enabled:r!==null&&Number.isFinite(n)}),l=a.find(d=>d.statePaymentDetailId===n)??null;return Number.isFinite(n)?i?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!l?s.jsx(Oe,{to:"/payments",replace:!0}):!r||l.entityId!==r.entityId?s.jsx(Oe,{to:"/payments",replace:!0}):s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Back to Payments"]}),s.jsxs("h1",{className:"text-lg font-semibold text-slate-900",children:["State Payment ST-",l.statePaymentDetailId]})]}),s.jsx("div",{className:"w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",children:s.jsxs("dl",{className:"grid gap-x-8 gap-y-5 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"State"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:l.state})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax Period"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:l.taxPeriod})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Amount"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:Bn(l.taxAmount)})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Payment Date"}),s.jsx("dd",{className:"mt-1 text-sm font-medium text-slate-900",children:l.paymentDate})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Status"}),s.jsx("dd",{className:"mt-1",children:s.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${((c=l.status)==null?void 0:c.toLowerCase())==="paid"?"bg-green-100 text-green-800":((u=l.status)==null?void 0:u.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:l.status??"—"})})]}),l.reason&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Rejection Reason"}),s.jsx("dd",{className:"mt-1 text-sm text-slate-700",children:l.reason})]})]})})]}):s.jsx(Oe,{to:"/payments",replace:!0})}const ev="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",tv="I have reviewed the details and authorize this payment.",Du=/^[a-zA-Z\s]+$/;function Ru(e){return e.replace(/[^a-zA-Z\s]/g,"")}const Hi=_().min(1,"Signature is required").regex(Du,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),rv=_().optional().refine(e=>!e||!e.trim()||Du.test(e),{message:"Signature must contain only letters"}),nv=Bt({agreementDate:_().min(1,"Date is required"),agreementAccepted:Wr().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:_().min(1,"Name of authorization person is required"),signature:Hi,title:_().min(1,"Title is required")}),sv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ss="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function av(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function iv(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function ov({entity:e,paymentDraft:t}){const r=ye(),n=ge(),a=ct(),i=zr(n.state,Ze()),[o,l]=N.useState(null),[c,u]=N.useState(!1),d=N.useMemo(()=>iv(),[]),m=Zn(t.taxAmount),{register:h,handleSubmit:f,watch:b,formState:{errors:p}}=St({resolver:Ct(nv),defaultValues:d}),g=b("agreementDate"),y=b("signature"),A=!!(y!=null&&y.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 $=await Mb(t.statePaymentDetailId,K0(t));return await S(),$}const D=await zb(H0(e.entityId,t));return Za({...t,statePaymentDetailId:D.statePaymentDetailId}),await S(),D},I=async()=>{e&&(await E(),Pu(),r(Ze()))},w=f(async()=>{if(e){l(null),u(!0);try{await I()}catch(D){l(st(D,"Failed to save state payment."))}finally{u(!1)}}}),F=f(async()=>{if(e){l(null),u(!0);try{await I()}catch(D){l(st(D,"Failed to save draft."))}finally{u(!1)}}});return s.jsx("form",{onSubmit:w,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),s.jsx(Wn,{entity:e,remittanceAmount:m,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsxs("div",{className:"lg:mr-[324px]",children:[s.jsxs("section",{className:sv,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-slate-200 pb-5",children:[s.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:`${ss} min-w-[128px] py-2.5`,children:[s.jsx("p",{className:"text-[11px] font-medium text-slate-500",children:"Date"}),s.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-800",children:av(g)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:ev}),s.jsxs("label",{className:"mt-5 flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...h("agreementAccepted")}),s.jsx("span",{className:"text-sm font-semibold leading-6 text-slate-800",children:tv})]}),p.agreementAccepted?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.agreementAccepted.message}):null,s.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsxs("p",{className:"mb-4 text-sm font-medium text-gov-600",children:["Taxpayer's Signature",s.jsx("span",{className:"text-red-500",children:" *"})]}),s.jsxs("div",{className:"grid gap-5 md:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_minmax(0,1fr)] md:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:`${ss} py-7`,children:[s.jsx("input",{placeholder:"Enter name",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("authorizationPersonName")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[180px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Name of Authorization Person"})]}),p.authorizationPersonName?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.authorizationPersonName.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${ss} py-5`,children:[s.jsx("input",{placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${A?"min-h-[52px] text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:A?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,name:j.name,ref:j.ref,onBlur:j.onBlur,onChange:D=>{const $=Ru(D.target.value);D.target.value=$,j.onChange(D)}}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[220px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Signature of Tax Payer"})]}),p.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.signature.message}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:`${ss} py-7`,children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...h("title")}),s.jsx("div",{className:"mx-auto mt-6 w-full max-w-[140px] border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Title"})]}),p.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:p.title.message}):null]})]})]})]}),o?s.jsx("div",{className:"mt-5",children:s.jsx(Vt,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{Za(t),r("/payments/state/new",{state:{from:i,paymentDraft:t}})},disabled:c,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:F,disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-gov-300 bg-gov-50 px-6 text-sm font-semibold text-gov-600 transition hover:bg-gov-100 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Submit Now"})]})]})]})})}function Ou(){const{selectedEntity:e}=it(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Wa();return n?s.jsx(ov,{entity:e,paymentDraft:n}):s.jsx(Oe,{to:"/payments/state/new",replace:!0})}const Ki="/portal/federal-payments/form-8655-authorizations";function lv(e){return he(Ki,{method:"POST",body:e})}function cv(e){return he(`${Ki}/by-enrolment/${e}`)}function uv(e,t){return he(`${Ki}/${e}`,{method:"PATCH",body:t})}async function $u(e){try{return await cv(e)}catch(t){if(t instanceof xn&&t.status===404)return null;throw t}}const Ya=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function dv(e){const t=e.trim();return Ya.includes(t)?t:"Other"}const mv="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.",hv="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 fv(e){const[t,r,n]=e.split("-");return!t||!r||!n?e:`${r}/${n}/${t}`}function Ha({label:e,required:t=!1,signature:r,title:n,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:u="Signature of taxpayer"}){const d=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:f,ref:b}=r;return s.jsxs("div",{children:[e?s.jsxs("p",{className:"mb-3 text-sm font-medium text-gov-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]}):null,s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)] lg:items-end",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-6",children:[s.jsx("input",{ref:b,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 g=Ru(p.target.value);p.target.value=g,m(p)}}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:u})]}),c!=null&&c.signature?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.signature}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[s.jsx("input",{placeholder:"Enter title",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 placeholder:text-slate-400 focus:outline-none",...n}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Title"})]}),c!=null&&c.title?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.title}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 py-8",children:[l?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-center text-sm text-slate-700",children:fv(o)}),s.jsx("input",{type:"hidden",...a})]}):s.jsx("input",{type:"date",className:"w-full border-0 bg-transparent text-center text-sm text-slate-700 focus:outline-none",...a}),s.jsx("div",{className:"mt-8 border-t border-slate-400"}),s.jsx("p",{className:"mt-2 text-center text-xs text-slate-500",children:"Date"})]}),c!=null&&c.date?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:c.date}):null]})]})]})}function pv(e){return e.replace(/\D/g,"")}function Lu(e,t){var r,n;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:pv(t.ein),address:t.address.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),isSeasonalEmployer:t.isSeasonalEmployer,otherIdentificationNumber:((r=t.otherIdentificationNumber)==null?void 0:r.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((n=t.authorizationMonth)==null?void 0:n.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function xv(e){const{enrollmentId:t,...r}=Lu(0,e);return r}function gv(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:dr(e.ein),address:e.address,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,isSeasonalEmployer:e.isSeasonalEmployer,otherIdentificationNumber:e.otherIdentificationNumber??"",contactPerson:e.contactPerson,daytimePhone:Dr(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const yv=Bt({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:Wr(),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:Wr().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:Hi,title:_().min(1,"Title is required"),signatureDate:_().min(1,"Date is required")}),ca="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function bv(e,t){const r=new Date().toISOString().slice(0,10);return{taxpayerName:e?At(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.firstName)||"",ein:e?dr(e.idNumber):"",address:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",isSeasonalEmployer:!1,otherIdentificationNumber:"",contactPerson:e?`${e.firstName} ${e.lastName}`.trim():"",daytimePhone:e?Dr(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:dv(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:r}}function vv({entity:e,paymentDraft:t,initialAuthorization:r=null,readonly:n=!1}){var ne,xe,pe,$e,Ke,Ge,oe,Pe,_e,H,Le,dt,mt,Pt;const a=ye(),i=ge(),o=ct(),l=zr(i.state,Ze()),c=Zn(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),f=N.useMemo(()=>r?gv(r):bv(e,t),[e,r,t]),{register:b,handleSubmit:p,watch:g,setValue:y,reset:A,formState:{errors:j}}=St({resolver:Ct(yv),defaultValues:f});N.useEffect(()=>{A(f)},[f,A]);const S=g("authorizedTaxForm"),E=g("signature"),I=g("signatureDate"),w=e?At(e):"Entity",F=!0,D=!0,$=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 Ie=await $i(t.federalPaymentId,Bi(t));return await $(),Ie}const le=await Oi(Vi(e.entityId,t));return Zi({...t,federalPaymentId:le.federalPaymentId,enrollmentId:le.enrollmentId}),await $(),le},B=async(le,Ie)=>{var yt;const ht=t.form8655AuthorizationId??((yt=await $u(le))==null?void 0:yt.form8655AuthorizationId),Et=Ie;return ht?uv(ht,xv(Et)):lv(Lu(le,Et))},Q=async le=>{if(!e)return;const Ie=await se();Ie&&(await B(Ie.enrollmentId,le),await o.invalidateQueries({queryKey:["form-8655",Ie.enrollmentId]}),Wi(),a(Ze()))},te=p(async le=>{if(!(!e||n)){d(null),h(!0);try{await Q(le)}catch(Ie){d(st(Ie,"Failed to save federal payment draft."))}finally{h(!1)}}}),Y=p(async le=>{if(!(!e||n)){d(null),h(!0);try{await Q(le)}catch(Ie){d(st(Ie,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:te,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:w}),s.jsx(Wn,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:ca,children:[s.jsx(W,{label:"1. a) Name of the Taxpayer",required:!0,error:(ne=j.taxpayerName)==null?void 0:ne.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!j.taxpayerName,F),...b("taxpayerName")})}),s.jsx(W,{label:"1. b) Trade Name, if any",required:!0,error:(xe=j.tradeName)==null?void 0:xe.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!j.tradeName,F),...b("tradeName")})}),s.jsx(W,{label:"2. Employer Identification Number (EIN)",required:!0,error:(pe=j.ein)==null?void 0:pe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:F,className:J(!!j.ein,F),...b("ein")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx("div",{className:"sm:col-span-2",children:s.jsx(W,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:($e=j.address)==null?void 0:$e.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!j.address,F),...b("address")})})}),s.jsx(W,{label:"3. b) City or Town",required:!0,error:(Ke=j.city)==null?void 0:Ke.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!j.city,F),...b("city")})})]}),s.jsxs("div",{className:`mt-5 ${ca}`,children:[s.jsx(W,{label:"3. c) State",required:!0,error:(Ge=j.state)==null?void 0:Ge.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!j.state,F),...b("state")})}),s.jsx(W,{label:"3. d) ZIP Code",required:!0,error:(oe=j.zipCode)==null?void 0:oe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!j.zipCode,F),...b("zipCode")})}),s.jsx(W,{label:"3. e) Country",required:!0,error:(Pe=j.country)==null?void 0:Pe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:F,className:J(!!j.country,F),...b("country")})})]}),s.jsxs("div",{className:`mt-5 ${ca}`,children:[s.jsx("div",{className:"flex items-end pb-2",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(W,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!1,F),...b("otherIdentificationNumber")})}),s.jsx(W,{label:"6. Contact Person",required:!0,error:(_e=j.contactPerson)==null?void 0:_e.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:F,className:J(!!j.contactPerson,F),...b("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(W,{label:"7. Daytime Telephone Number",required:!0,error:(H=j.daytimePhone)==null?void 0:H.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:F,className:J(!!j.daytimePhone,F),...b("daytimePhone")})}),s.jsx(W,{label:"8. Fax Number",error:(Le=j.faxNumber)==null?void 0:Le.message,children:s.jsx("input",{placeholder:"Enter number",className:J(!!j.faxNumber),...b("faxNumber")})})]})]}),s.jsxs(vr,{title:"Authorization of Reporting Agent To Make and Deposits and Payments (Caution: See Authorization Agreement.)",children:[s.jsx("p",{className:"mb-5 text-sm leading-6 text-slate-600",children:"Indicate the tax return(s) for which the reporting agent is authorized to make deposits or payments. Use the 'YYYY/MM' format to enter the month in which the authorization begins (for example, '2024/8' for August 2024)"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Ya.slice(0,6).map(le=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:le,checked:S===le,disabled:D,onChange:()=>y("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Ya.slice(6).map(le=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:le,checked:S===le,disabled:D,onChange:()=>y("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))})]}),j.authorizedTaxForm?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.authorizedTaxForm.message}):null]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsxs("div",{className:"border-t border-slate-200 pt-5",children:[s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...b("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:mv})," ",hv]})]}),j.agreementAccepted?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.agreementAccepted.message}):null]})]}),s.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:s.jsx(Ha,{label:"Taxpayer's Signature",required:!0,signature:b("signature"),title:b("title"),date:b("signatureDate"),signatureValue:E,dateValue:I,errors:{signature:(dt=j.signature)==null?void 0:dt.message,title:(mt=j.title)==null?void 0:mt.message,date:(Pt=j.signatureDate)==null?void 0:Pt.message}})})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Vt,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:m,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Y,disabled:m||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:m||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function zu(){const{selectedEntity:e}=it(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Ws(),{data:a,isLoading:i}=ke({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>Ri(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ke({queryKey:["form-8655",o],queryFn:()=>$u(o),enabled:o!=null}),u=N.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form8655AuthorizationId:n.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[n,o,l]);return n?qi(e)?s.jsx(Oe,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(vv,{entity:e,paymentDraft:u??n,initialAuthorization:l}):s.jsx(Oe,{to:"/payments/federal/new",replace:!0})}const Qi="/portal/federal-payments/form-9783-enrollments";function jv(e){return he(Qi,{method:"POST",body:e})}function Nv(e){return he(`${Qi}/by-enrolment/${e}`)}function wv(e,t){return he(`${Qi}/${e}`,{method:"PATCH",body:t})}async function Mu(e){try{return await Nv(e)}catch(t){if(t instanceof xn&&t.status===404)return null;throw t}}const Sv="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.",kv="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.",Cv="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.",ua=new Date().getFullYear(),Av=[String(ua-1),String(ua-2),String(ua-3)];function as(e){return e.replace(/\D/g,"")}function qu(e,t){var r,n,a,i;return{enrollmentId:e,primarySsn:as(t.primarySsn),jointFilerSsn:t.jointFilerSsn?as(t.jointFilerSsn):null,taxpayerNames:t.taxpayerNames.trim(),primaryAddress:t.primaryAddress.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),internationalAddress:((r=t.internationalAddress)==null?void 0:r.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((n=t.contactInternationalAddress)==null?void 0:n.trim())||null,primaryTaxpayerPin:t.primaryTaxpayerPin.trim()||null,dateOfBirth:t.dateOfBirth||null,priorYearAgi:t.priorYearAgi.trim()?Number(t.priorYearAgi):null,agiTaxYear:t.agiTaxYear.trim()||null,financialPrimarySsn:as(t.financialPrimarySsn),routingTransitNumber:as(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 Pv(e){const{enrollmentId:t,...r}=qu(0,e);return r}function Ev(e){var r;const t=((r=e.accountType)==null?void 0:r.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:Dr(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Dr(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",financialPrimarySsn:e.financialPrimarySsn,routingTransitNumber:e.routingTransitNumber,accountNumber:e.accountNumber,accountType:t,disclosureAgreementOne:e.disclosureAgreementOne,disclosureAgreementTwo:e.disclosureAgreementTwo,authorityAgreement:e.authorityAgreement,taxpayerSignature:e.taxpayerSignature??"",taxpayerTitle:e.taxpayerTitle,taxpayerSignatureDate:e.taxpayerSignatureDate,jointFilerSignature:e.jointFilerSignature??"",jointFilerTitle:e.jointFilerTitle??"",jointFilerSignatureDate:e.jointFilerSignatureDate??""}}const _v=Bt({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=>o0(e,Vu),{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:Gc([ea("Checking"),ea("Savings"),ea("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Wr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Wr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Wr().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:Hi,taxpayerTitle:_().min(1,"Title is required"),taxpayerSignatureDate:_().min(1,"Date is required"),jointFilerSignature:rv,jointFilerTitle:_().optional(),jointFilerSignatureDate:_().optional()}),gr="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",Tv="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",Iv=5,Vu=18;function Bu(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function Uu(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:Bu(t.accountType)}}function Fv(e,t){const r=new Date().toISOString().slice(0,10),n=e?At(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:n,primaryAddress:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"US",internationalAddress:"",primaryPhone:e?Dr(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...Uu(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:r,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:r}}function Dv({entity:e,paymentDraft:t,initialEnrollment:r=null,readonly:n=!1}){var Et,yt,mr,_t,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,Mr,q,ae,x,k,C,R,O,U,L,Z;const a=ye(),i=ge(),o=ct(),l=zr(i.state,Ze()),c=Zn(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),[f,b]=N.useState(!1),{data:p=[]}=ke({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Un(e.entityId),enabled:(e==null?void 0:e.entityId)!=null}),g=N.useMemo(()=>{if(r)return Ev(r);const z=p.find(Fe=>String(Fe.bankAccountDetailId)===t.bankAccountDetailId),ee=Uu(e,t);return{...Fv(e,t),financialPrimarySsn:ee.financialPrimarySsn,routingTransitNumber:ee.routingTransitNumber||(z==null?void 0:z.routingNumber)||"",accountNumber:ee.accountNumber||(z==null?void 0:z.accountNumber)||"",accountType:Bu(t.accountType||(z==null?void 0:z.accountType))}},[e,r,t,p]),{register:y,handleSubmit:A,watch:j,setValue:S,reset:E,control:I,formState:{errors:w}}=St({resolver:Ct(_v),defaultValues:g});N.useEffect(()=>{E(g)},[g,E]);const F=j("taxpayerSignature"),D=j("jointFilerSignature"),$=j("taxpayerSignatureDate"),se=j("jointFilerSignatureDate"),B=j("accountType"),Q=j("taxpayerNames"),te=j("primaryAddress"),Y=j("city"),ne=j("state"),xe=j("zipCode"),pe=j("country"),$e=j("primaryPhone"),Ke=j("internationalAddress"),Ge=e?At(e):"Entity",oe=!0,Pe=!0,_e=N.useMemo(()=>i0(Vu),[]),H=()=>{S("primaryContactName",Q,{shouldValidate:!0}),S("primaryContactAddress",te,{shouldValidate:!0}),S("contactCity",Y,{shouldValidate:!0}),S("contactState",ne,{shouldValidate:!0}),S("contactZipCode",xe,{shouldValidate:!0}),S("contactCountry",pe,{shouldValidate:!0}),S("contactPhone",$e,{shouldValidate:!0}),S("contactInternationalAddress",Ke??"",{shouldValidate:!0})},Le=()=>{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})};N.useEffect(()=>{f&&H()},[f,Q,te,Y,ne,xe,pe,$e,Ke]);const dt=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},mt=async()=>{if(!e)return null;if(t.federalPaymentId){const ee=await $i(t.federalPaymentId,Bi(t));return await dt(),ee}const z=await Oi(Vi(e.entityId,t));return Zi({...t,federalPaymentId:z.federalPaymentId,enrollmentId:z.enrollmentId}),await dt(),z},Pt=async(z,ee)=>{var Ft;const Fe=t.form9783EnrollmentId??((Ft=await Mu(z))==null?void 0:Ft.form9783EnrollmentId);return Fe?wv(Fe,Pv(ee)):jv(qu(z,ee))},le=async z=>{if(!e)return;const ee=await mt();ee&&(await Pt(ee.enrollmentId,z),await o.invalidateQueries({queryKey:["form-9783",ee.enrollmentId]}),Wi(),a(Ze()))},Ie=A(async z=>{if(!(!e||n)){d(null),h(!0);try{await le(z)}catch(ee){d(st(ee,"Failed to save federal payment draft."))}finally{h(!1)}}}),ht=A(async z=>{if(!(!e||n)){d(null),h(!0);try{await le(z)}catch(ee){d(st(ee,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:Ie,noValidate:!0,className:"w-full space-y-6",children:[s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-4 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:Ge}),s.jsx(Wn,{entity:e,remittanceAmount:c,className:"mb-4 w-full lg:absolute lg:top-0 lg:right-0 lg:mb-0 lg:w-[300px]"}),s.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:mr-[324px] lg:p-8",children:s.jsxs("fieldset",{disabled:n,className:"min-w-0 border-0 p-0",children:[s.jsxs(vr,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:gr,children:[s.jsx(W,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(Et=w.primarySsn)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:oe,className:J(!!w.primarySsn,oe),...y("primarySsn")})}),s.jsx(W,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:oe,className:J(!1,oe),...y("jointFilerSsn")})}),s.jsx(W,{label:"2. Taxpayer(S) name(S)",required:!0,error:(yt=w.taxpayerNames)==null?void 0:yt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:oe,className:J(!!w.taxpayerNames,oe),...y("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(W,{label:"3. a) Primary taxpayer address",required:!0,error:(mr=w.primaryAddress)==null?void 0:mr.message,children:s.jsx("input",{placeholder:"Enter",readOnly:oe,className:J(!!w.primaryAddress,oe),...y("primaryAddress")})})}),s.jsx(W,{label:"3. b) City or Town",required:!0,error:(_t=w.city)==null?void 0:_t.message,children:s.jsx("input",{placeholder:"Enter",readOnly:oe,className:J(!!w.city,oe),...y("city")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx(W,{label:"3. c) State",required:!0,error:(Ut=w.state)==null?void 0:Ut.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:oe,className:J(!!w.state,oe),...y("state")})}),s.jsx(W,{label:"3. d) ZIP code",required:!0,error:(Tt=w.zipCode)==null?void 0:Tt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:oe,className:J(!!w.zipCode,oe),...y("zipCode")})}),s.jsx(W,{label:"3. e) Country",required:!0,error:(It=w.country)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Enter",readOnly:oe,className:J(!!w.country,oe),...y("country")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(W,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:oe,className:J(!1,oe),...y("internationalAddress")})})}),s.jsx(W,{label:"4. Primary taxpayer phone number",required:!0,error:(hr=w.primaryPhone)==null?void 0:hr.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:oe,className:J(!!w.primaryPhone,oe),...y("primaryPhone")})})]})]}),s.jsxs(vr,{title:"2. Contact Information",headerAction:s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"checkbox",checked:f,disabled:n,onChange:z=>{const ee=z.target.checked;b(ee),ee?H():Le()},className:"h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200"}),"Same as Taxpayer Information"]}),children:[s.jsxs("div",{className:gr,children:[s.jsx(W,{label:"5. Primary contact name",required:!0,error:(Zt=w.primaryContactName)==null?void 0:Zt.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:f,className:J(!!w.primaryContactName,f),...y("primaryContactName")})}),s.jsx(W,{label:"6. a) Primary contact address",required:!0,error:(fr=w.primaryContactAddress)==null?void 0:fr.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:f,className:J(!!w.primaryContactAddress,f),...y("primaryContactAddress")})}),s.jsx(W,{label:"6. b) City or Town",required:!0,error:(Wt=w.contactCity)==null?void 0:Wt.message,children:s.jsx("input",{placeholder:"City",readOnly:f,className:J(!!w.contactCity,f),...y("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${gr}`,children:[s.jsx(W,{label:"6. c) State",required:!0,error:(Yt=w.contactState)==null?void 0:Yt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:f,className:J(!!w.contactState,f),...y("contactState")})}),s.jsx(W,{label:"6. d) ZIP code",required:!0,error:(pr=w.contactZipCode)==null?void 0:pr.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:f,className:J(!!w.contactZipCode,f),...y("contactZipCode")})}),s.jsx(W,{label:"6. f) Country",required:!0,error:(xr=w.contactCountry)==null?void 0:xr.message,children:s.jsx("input",{placeholder:"Country",readOnly:f,className:J(!!w.contactCountry,f),...y("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(W,{label:"7. Primary taxpayer phone number",required:!0,error:(Mr=w.contactPhone)==null?void 0:Mr.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:J(!!w.contactPhone,f),...y("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(W,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:J(!1,f),...y("contactInternationalAddress")})})})]})]}),s.jsx(vr,{title:"Taxpayer Details *",children:s.jsxs("div",{className:Tv,children:[s.jsx(W,{label:"1. Primary Taxpayer Pin",required:!0,error:(q=w.primaryTaxpayerPin)==null?void 0:q.message,children:s.jsx(Re,{name:"primaryTaxpayerPin",control:I,render:({field:z})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:J(!!w.primaryTaxpayerPin),value:z.value,onChange:ee=>z.onChange(Yr(ee.target.value,Iv)),onBlur:z.onBlur})})}),s.jsx(W,{label:"2. Date of Birth",required:!0,error:(ae=w.dateOfBirth)==null?void 0:ae.message,children:s.jsx("input",{type:"date",max:_e,className:J(!!w.dateOfBirth),...y("dateOfBirth")})}),s.jsx(W,{label:"3. Prior year adjusted gross income",required:!0,error:(x=w.priorYearAgi)==null?void 0:x.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:J(!!w.priorYearAgi),...y("priorYearAgi")})}),s.jsx(W,{label:"4. Prior Tax Year",required:!0,error:(k=w.agiTaxYear)==null?void 0:k.message,children:s.jsxs("select",{className:Hr(!!w.agiTaxYear),...y("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),Av.map(z=>s.jsx("option",{value:z,children:z},z))]})})]})}),s.jsxs(vr,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:gr,children:[s.jsx(W,{label:"9. Primary SSN",required:!0,error:(C=w.financialPrimarySsn)==null?void 0:C.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:Pe,className:J(!!w.financialPrimarySsn,Pe),...y("financialPrimarySsn")})}),s.jsx(W,{label:"10. Routing Transit Number (RTN)",required:!0,error:(R=w.routingTransitNumber)==null?void 0:R.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:Pe,className:J(!!w.routingTransitNumber,Pe),...y("routingTransitNumber")})}),s.jsx(W,{label:"11. Account Number",required:!0,error:(O=w.accountNumber)==null?void 0:O.message,children:s.jsx("input",{placeholder:"Enter",readOnly:Pe,className:J(!!w.accountNumber,Pe),...y("accountNumber")})})]}),s.jsxs("div",{className:"mt-5",children:[s.jsx("p",{className:"mb-3 text-sm text-slate-600",children:"12. Type of Account"}),s.jsx("div",{className:"flex flex-wrap gap-6",children:["Checking","Savings"].map(z=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:z,checked:B===z,disabled:Pe,onChange:()=>S("accountType",z,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),z]},z))}),w.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.accountType.message}):null]})]}),s.jsxs("section",{className:"mt-8 border-t border-slate-100 pt-8",children:[s.jsx("h3",{className:"mb-4 text-base font-semibold text-slate-900",children:"Authorization Agreement"}),s.jsx("p",{className:"mb-5 text-sm text-slate-600",children:"Read the following authorization agreements"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:Sv})]}),w.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.disclosureAgreementOne.message}):null]}),s.jsxs("div",{children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Disclosure Authorization Agreement"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:kv})]}),w.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.disclosureAgreementTwo.message}):null]}),s.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[s.jsx("p",{className:"mb-3 text-sm font-semibold text-slate-900",children:"Authority to Execute an Authorization"}),s.jsxs("label",{className:"flex items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-slate-300 text-gov-600 focus:ring-gov-200",...y("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:Cv})]}),w.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:w.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(Ha,{label:"Taxpayer's Signature",required:!0,signature:y("taxpayerSignature"),title:y("taxpayerTitle"),date:y("taxpayerSignatureDate"),signatureValue:F,dateValue:$,errors:{signature:(U=w.taxpayerSignature)==null?void 0:U.message,title:(L=w.taxpayerTitle)==null?void 0:L.message,date:(Z=w.taxpayerSignatureDate)==null?void 0:Z.message}}),s.jsx(Ha,{label:"Joint filer(s) Signature (Optional)",signature:y("jointFilerSignature"),title:y("jointFilerTitle"),date:y("jointFilerSignatureDate"),signatureValue:D??"",dateValue:se??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Vt,{message:u})}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:()=>a(l),disabled:m,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:ht,disabled:m||!e||n,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:m||!e||n,className:"inline-flex h-11 min-w-[180px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Review and Submit"})]})]})}function Zu(){const{selectedEntity:e}=it(),t=ge(),{paymentDraft:r}=t.state??{},n=r??Ws(),{data:a,isLoading:i}=ke({queryKey:["federal-payment",n==null?void 0:n.federalPaymentId],queryFn:()=>Ri(n.federalPaymentId),enabled:(n==null?void 0:n.federalPaymentId)!=null&&n.enrollmentId==null}),o=(n==null?void 0:n.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ke({queryKey:["form-9783",o],queryFn:()=>Mu(o),enabled:o!=null}),u=N.useMemo(()=>n?{...n,enrollmentId:o??n.enrollmentId,form9783EnrollmentId:n.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[n,o,l]);return n?e&&!qi(e)?s.jsx(Oe,{to:"/payments/federal/authorization",replace:!0,state:t.state}):n.federalPaymentId!=null&&n.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(Dv,{entity:e,paymentDraft:u??n,initialEnrollment:l}):s.jsx(Oe,{to:"/payments/federal/new",replace:!0})}function Rv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Ov({type:e}){return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:e})}function $v({status:e}){const t=e.toLowerCase();let r="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?r="bg-orange-50 text-orange-700":t.includes("irs accepted")?r="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?r="bg-red-50 text-red-600":t.includes("pending")&&(r="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r}`,children:e})}function Lv({forms:e=[],isLoading:t=!1,isError:r=!1}){return s.jsx("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-6 py-3",children:"File Name"}),s.jsx("th",{className:"px-6 py-3",children:"Type"}),s.jsx("th",{className:"px-6 py-3",children:"Client"}),s.jsx("th",{className:"px-6 py-3",children:"Status"}),s.jsx("th",{className:"px-6 py-3",children:"Date"}),s.jsx("th",{className:"px-6 py-3",children:"Action"})]})}),s.jsx("tbody",{children:t?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Loading tax forms…"})}):r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"Unable to load tax forms."})}):e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-slate-500",children:"No tax forms to display yet."})}):e.map(n=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex items-center gap-3 font-medium text-slate-900",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gov-50 text-gov-600",children:s.jsx(zv,{className:"h-4 w-4"})}),n.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Ov,{type:n.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:n.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx($v,{status:n.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:Rv(n.date)}),s.jsx("td",{className:"px-6 py-4",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("button",{type:"button",className:"rounded-full border border-gov-200 bg-gov-50 px-4 py-1.5 text-xs font-semibold text-gov-600 transition hover:bg-gov-100",children:"View PDF"}),n.canSubmit?s.jsx("button",{type:"button",className:"rounded-full bg-gov-600 px-4 py-1.5 text-xs font-semibold text-white transition hover:bg-gov-700",children:"Submit"}):null]})})]},n.taxFormId))})]})})})}function zv({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V6A2.25 2.25 0 014.5 3.75h4.379a2.25 2.25 0 011.59.659l1.122 1.122A2.25 2.25 0 0013.128 6H19.5a2.25 2.25 0 012.25 2.25v10.5A2.25 2.25 0 0119.5 21H4.5a2.25 2.25 0 01-2.25-2.25v-6.75z"})})}function Mv(){return s.jsx(Lv,{})}const fl=160,qv=88,is=8;function Vv({account:e,entityId:t,onEdit:r}){const n=ct(),{showSuccess:a,showError:i}=Is(),o=N.useRef(null),l=N.useRef(null),[c,u]=N.useState(!1),[d,m]=N.useState(!1),[h,f]=N.useState({}),b=()=>{var E;const g=o.current;if(!g)return;const y=g.getBoundingClientRect(),A=((E=l.current)==null?void 0:E.offsetHeight)??qv,S=window.innerHeight-y.bottom<A+is;f({position:"fixed",top:S?y.top-A-is:y.bottom+is,left:Math.max(is,y.right-fl),width:fl,zIndex:50})};N.useLayoutEffect(()=>{c&&(b(),requestAnimationFrame(b))},[c]),N.useEffect(()=>{if(!c)return;const g=A=>{var S,E;const j=A.target;(S=o.current)!=null&&S.contains(j)||(E=l.current)!=null&&E.contains(j)||u(!1)},y=()=>b();return document.addEventListener("mousedown",g),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",g),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[c]);const p=async()=>{const g=yn(e);m(!0);try{await cu(e.bankAccountDetailId,{status:L0(e)}),await n.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),g?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(y){i("Action Not Completed",st(y,"Cannot deactivate this bank account because it is linked to a payment that has not been accepted yet."))}finally{m(!1)}};return s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:o,type:"button",disabled:d,onClick:()=>u(g=>!g),className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:["Actions",s.jsx(Bv,{})]}),c?Cs.createPortal(s.jsxs("div",{ref:l,style:h,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:[s.jsx("button",{type:"button",onClick:()=>{u(!1),r(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"}),s.jsx("button",{type:"button",disabled:d,onClick:()=>void p(),className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-60",children:z0(e)})]}),document.body):null]})}function Bv(){return s.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}const Wu=["Checking","Savings"],Uv=Bt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dn} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Vs(Wu,{message:"Account type is required"}),bankName:_().min(1,"Bank name is required")});function Zv({open:e,account:t,onClose:r}){const n=ct(),{showSuccess:a,showError:i}=Is(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=St({resolver:Ct(Uv),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});N.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),N.useEffect(()=>{if(!e)return;const p=g=>{g.key==="Escape"&&r()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,r]);const b=m(async p=>{if(t){l(null),u(!0);try{await cu(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await n.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),r()}catch(g){const y=st(g,"Unable to update bank account.");l(y),i("Action Not Completed",y)}finally{u(!1)}}});return!e||!t?null:Cs.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-bank-account-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-bank-account-title",className:"text-lg font-bold text-slate-900",children:"Edit Bank Account"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update bank account details."})]}),s.jsxs("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),b(p)},className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[o?s.jsx("div",{className:"mb-5",children:s.jsx(Vt,{message:o})}):null,s.jsxs(lr,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(Re,{name:"accountNumber",control:d,render:({field:p})=>{var g;return s.jsx(de,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:y=>p.onChange(Yr(y.target.value,dn)),onBlur:p.onBlur,error:(g=f.accountNumber)==null?void 0:g.message})}}),s.jsx(Re,{name:"routingNumber",control:d,render:({field:p})=>{var g;return s.jsx(de,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:y=>p.onChange(Yr(y.target.value,uu)),onBlur:p.onBlur,error:(g=f.routingNumber)==null?void 0:g.message})}}),s.jsx(Re,{name:"accountType",control:d,render:({field:p})=>{var g;return s.jsx(wt,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(g=f.accountType)==null?void 0:g.message,children:Wu.map(y=>s.jsx("option",{value:y,children:y},y))})}})]}),s.jsx(Re,{name:"bankName",control:d,render:({field:p})=>{var g;return s.jsx(de,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(g=f.bankName)==null?void 0:g.message})}})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:r,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:c?"Saving…":"Save Changes"})]})]})]})]}),document.body)}const Rr=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Wv},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:Yv},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Hv},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Kv}];function Wv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 002.25-2.25V6.75A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25v10.5A2.25 2.25 0 004.5 19.5z"})})}function Yv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 21h18M12 3l9 4.5v1.5H3V7.5L12 3z"})})}function Hv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}function Kv({className:e,...t}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",...t,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})})}function mn({title:e,subtitle:t,icon:r,action:n}){return s.jsxs("div",{className:"mb-6 flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gov-50 text-gov-600",children:s.jsx(r,{className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-slate-900",children:e}),s.jsx("p",{className:"text-sm text-slate-500",children:t})]})]}),n]})}function Qv(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Jv({status:e}){const t=yn({status:e});return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:t?"Active":"In-active"})}function Gv({entityId:e}){const[t,r]=N.useState(!1),[n,a]=N.useState(null),i=Rr.find(d=>d.id==="bank-accounts"),o=i.icon,{data:l=[],isLoading:c,isError:u}=ke({queryKey:["bank-accounts",e],queryFn:()=>Un(e),enabled:e!==null});return s.jsxs("div",{children:[s.jsx(mn,{title:i.title,subtitle:i.subtitle,icon:o,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>r(!0),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(Xv,{}),"Add Bank Account"]})}),s.jsx(mu,{open:t,entityId:e,onClose:()=>r(!1)}),s.jsx(Zv,{open:n!==null,account:n,onClose:()=>a(null)}),s.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[700px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Bank"}),s.jsx("th",{className:"px-5 py-3",children:"Account"}),s.jsx("th",{className:"px-5 py-3",children:"Routing"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"}),s.jsx("th",{className:"px-5 py-3"})]})}),s.jsx("tbody",{children:c?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):u?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load bank accounts."})}):e?l.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No bank accounts connected yet."})}):l.map(d=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:d.bankName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Qv(d.accountNumber)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.routingNumber}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.accountType}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Jv,{status:d.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx(Vv,{account:d,entityId:e,onEdit:a})})]},d.bankAccountDetailId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage bank accounts."})})})]})})]})}function Xv(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function ej({open:e,entity:t,onClose:r}){var g,y,A,j,S,E,I,w,F,D;const n=ct(),[a,i]=N.useState(null),[o,l]=N.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,formState:{errors:h}}=St({resolver:Ct(nu),defaultValues:tl(t)});N.useEffect(()=>{e&&(m(tl(t)),i(null))},[t,e,m]),N.useEffect(()=>{if(!e)return;const $=se=>{se.key==="Escape"&&r()};return document.addEventListener("keydown",$),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",$),document.body.style.overflow=""}},[e,r]);const f=d("accountType"),b=f==="Individual"?ru:tu,p=u(async $=>{i(null),l(!0);try{await Oh(t.entityId,Gy($)),await n.invalidateQueries({queryKey:["entities","mine"]}),r()}catch(se){i(st(se,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?Cs.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("button",{type:"button","aria-label":"Close dialog",className:"absolute inset-0 bg-slate-900/40",onClick:r}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"edit-entity-title",className:"relative z-10 flex max-h-[90vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[s.jsxs("div",{className:"border-b border-slate-200 px-6 py-5",children:[s.jsx("h2",{id:"edit-entity-title",className:"text-lg font-bold text-slate-900",children:"Edit Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Update your entity profile details."})]}),s.jsxs("form",{onSubmit:p,noValidate:!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"overflow-y-auto px-6 py-6",children:[a?s.jsx("div",{className:"mb-5",children:s.jsx(Vt,{message:a})}):null,s.jsxs("div",{className:"space-y-8",children:[s.jsx("input",{type:"hidden",...c("ein")}),s.jsx(lr,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(un,{label:"Account Type",required:!0}),s.jsxs("div",{className:"mt-2 flex items-center gap-6",children:[s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Individual"]})]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:f==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(g=h.businessName)==null?void 0:g.message,...c("businessName")}),s.jsx(de,{label:"Trade Name, if any",placeholder:"Enter",error:(y=h.tradeName)==null?void 0:y.message,...c("tradeName")})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"EIN",readOnly:!0,value:dr(t.idNumber),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(wt,{label:"Entity Type",required:!0,error:(A=h.entityType)==null?void 0:A.message,...c("entityType"),children:b.map($=>s.jsx("option",{value:$,children:$},$))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"Email ID",required:!0,type:"email",placeholder:"sample@mail.com",error:(j=h.email)==null?void 0:j.message,...c("email")}),s.jsxs("div",{children:[s.jsx(un,{label:"Phone Number",required:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{className:"w-24 shrink-0 appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",...c("countryCode"),children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${h.phoneNumber?"border-red-300":"border-slate-200"}`,...c("phoneNumber")})]}),h.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:h.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(de,{label:"Address Line 1",required:!0,error:(S=h.address1)==null?void 0:S.message,...c("address1")}),s.jsx(de,{label:"Address Line 2",error:(E=h.address2)==null?void 0:E.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"City",required:!0,error:(I=h.city)==null?void 0:I.message,...c("city")}),s.jsxs(wt,{label:"State",required:!0,error:(w=h.state)==null?void 0:w.message,...c("state"),children:[s.jsx("option",{value:"",children:"Select"}),Ei.map($=>s.jsx("option",{value:$,children:$},$))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(de,{label:"ZIP Code",required:!0,error:(F=h.zipCode)==null?void 0:F.message,...c("zipCode")}),s.jsxs(wt,{label:"Country",required:!0,error:(D=h.country)==null?void 0:D.message,...c("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-slate-200 px-6 py-4",children:[s.jsx("button",{type:"button",onClick:r,disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:o?"Saving…":"Save Changes"})]})]})]})]}),document.body):null}function tj({icon:e}){const t="h-5 w-5 text-gov-600";return e==="phone"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"})}):e==="account"?s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"})}):s.jsx("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})})}function kn({label:e,value:t,icon:r}){return s.jsx("div",{className:"rounded-xl border border-slate-200 bg-[#F9FAFB] px-4 py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-gov-50",children:s.jsx(tj,{icon:r})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs text-slate-500",children:e}),s.jsx("p",{className:"mt-1 break-words text-sm font-semibold text-slate-900",children:t||"—"})]})]})})}function rj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function nj({entity:e}){const[t,r]=N.useState(!1),n=Rr.find(c=>c.id==="entity-details"),a=n.icon;if(!e)return s.jsxs("div",{children:[s.jsx(mn,{title:n.title,subtitle:n.subtitle,icon:a}),s.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/50 px-6 py-16 text-center",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to view its details."})})]});const i=At(e),o=`${e.firstName} ${e.lastName}`.trim()||i,l=Pi(o);return s.jsxs("div",{children:[s.jsx(mn,{title:n.title,subtitle:n.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),s.jsxs("div",{className:"mb-8 flex items-center gap-4 border-b border-slate-100 pb-8",children:[s.jsx("span",{className:"flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-gov-600 text-xl font-semibold text-white",children:l}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-xl font-bold text-slate-900",children:o}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:e.email})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(kn,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(kn,{label:"Tax ID",value:dr(e.idNumber),icon:"tax"}),s.jsx(kn,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(kn,{label:"Phone Number",value:Dr(e.phoneNumber),icon:"phone"}),s.jsx(kn,{label:"Account Type",value:rj(e.accountType),icon:"account"})]}),s.jsx(ej,{open:t,entity:e,onClose:()=>r(!1)})]})}function Yu({activeSection:e,onSectionChange:t,items:r}){return s.jsx("nav",{className:"space-y-2",children:r.map(n=>{const a=e===n.id,i=n.icon;return s.jsxs("button",{type:"button",onClick:()=>t(n.id),className:`flex w-full items-center gap-3 rounded-xl border px-4 py-3.5 text-left transition ${a?"border-gov-200 bg-gov-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300 hover:bg-slate-50"}`,children:[s.jsx("span",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${a?"bg-gov-600 text-white":"bg-slate-100 text-slate-500"}`,children:s.jsx(i,{className:"h-5 w-5"})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:`block text-sm font-semibold ${a?"text-slate-900":"text-slate-700"}`,children:n.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:n.subtitle})]}),s.jsx(sj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},n.id)})})}function sj({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function aj(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function ij(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function oj({type:e}){const t={Federal:"bg-gov-50 text-gov-700",State:"bg-sky-50 text-sky-700",Local:"bg-indigo-50 text-indigo-700"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]}`,children:e})}function lj({entityId:e,transactions:t=[],isLoading:r=!1,isError:n=!1}){const a=Rr.find(l=>l.id==="payment-history"),i=a.icon,o=e!==null&&t.length>0;return s.jsxs("div",{children:[s.jsx(mn,{title:a.title,subtitle:a.subtitle,icon:i,action:s.jsxs("button",{type:"button",disabled:!o,className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(cj,{}),"Export to Excel"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Date"}),s.jsx("th",{className:"px-5 py-3",children:"Amount"}),s.jsx("th",{className:"px-5 py-3",children:"Jurisdiction / Type"}),s.jsx("th",{className:"px-5 py-3",children:"Type"}),s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Reference"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load payment history."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"No payment transactions to display yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 text-slate-600",children:ij(l.date)}),s.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:aj(l.amount)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.jurisdiction}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(oj,{type:l.type})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.reference})]},l.paymentHistoryId)):s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to view payment history."})})})]})})]})}function cj(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"})})}function uj({count:e}){const t=e===1?"1 Payment":`${e} Payments`;return s.jsx("span",{className:"inline-flex rounded-full bg-gov-50 px-2.5 py-0.5 text-xs font-medium text-gov-700",children:t})}function dj({status:e}){const r=(e??"Active").toLowerCase()==="active";return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-600"}`,children:r?"Active":"In-active"})}function mj(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function hj({entityId:e,accounts:t=[],isLoading:r=!1,isError:n=!1}){const a=ye(),i=Rr.find(l=>l.id==="tax-accounts"),o=i.icon;return s.jsxs("div",{children:[s.jsx(mn,{title:i.title,subtitle:i.subtitle,icon:o,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>a("/settings/tax-accounts/new"),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(fj,{}),"Add Tax Account"]})}),s.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50/80 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[s.jsx("th",{className:"px-5 py-3",children:"Account Name"}),s.jsx("th",{className:"px-5 py-3",children:"Federal/State ID"}),s.jsx("th",{className:"px-5 py-3",children:"Payments"}),s.jsx("th",{className:"px-5 py-3",children:"Form Type"}),s.jsx("th",{className:"px-5 py-3",children:"Status"})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):n?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Unable to load tax accounts."})}):e?t.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"No tax accounts connected yet."})}):t.map(l=>s.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[s.jsx("td",{className:"px-5 py-4 font-medium text-slate-900",children:l.accountName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.federalStateId}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(uj,{count:l.paymentCount})}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:mj(l.formTypes)}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(dj,{status:l.status})})]},l.taxAccountId)):s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Create an entity to manage tax accounts."})})})]})})]})}function fj(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}function pj(){return he("/portal/payments/transactions")}function xj(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}}const pl="rounded-2xl border border-slate-200 bg-white shadow-sm";function gj(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function Ji(){const{selectedEntity:e}=it(),r=ge().state,[n,a]=N.useState(gj(r==null?void 0:r.section)?r.section:"bank-accounts"),{data:i,isLoading:o,isError:l}=ke({queryKey:["payment-transactions"],queryFn:pj,enabled:n==="payment-history"}),c=i==null?void 0:i.map(xj);return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${pl} p-3`,children:s.jsx(Yu,{items:Rr,activeSection:n,onSectionChange:a})}),s.jsx("div",{className:`${pl} p-6 lg:p-8`,children:n==="bank-accounts"?s.jsx(Gv,{entityId:(e==null?void 0:e.entityId)??null}):n==="tax-accounts"?s.jsx(hj,{entityId:(e==null?void 0:e.entityId)??null}):n==="payment-history"?s.jsx(lj,{entityId:(e==null?void 0:e.entityId)??null,transactions:c,isLoading:o,isError:l}):s.jsx(nj,{entity:e})})]})}const yj=["Alexandria","Arlington","Chesapeake","Hampton","Lynchburg","Newport News","Norfolk","Richmond","Roanoke","Virginia Beach"],bj=Ei.map(e=>({code:e,name:e==="VA"?"Virginia":e})),vj=[{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}],jj=[{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1}],Nj=Bt({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()}),wj=Nj.superRefine((e,t)=>{if(e.state!=="VA")return;const r=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const n of r){const a=e[n.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:Vr.custom,message:`${n.label} is required`,path:[n.key]})}}),Sj={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function kj({onCancel:e,onSuccess:t}){var y,A,j,S,E,I;const{showSuccess:r}=Is(),[n,a]=N.useState(null),[i,o]=N.useState(!1),{register:l,handleSubmit:c,watch:u,setValue:d,formState:{errors:m}}=St({resolver:Ct(wj),defaultValues:Sj}),h=u("state"),f=u("city"),b=h==="VA",p=N.useMemo(()=>h==="VA"?[...yj]:[],[h]);N.useEffect(()=>{if(p.length===0){f&&d("city","");return}f&&!p.includes(f)&&d("city","")},[p,f,d]);const g=c(async w=>{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(w)}catch{a("Unable to save tax account. Please try again.")}finally{o(!1)}});return s.jsxs("form",{onSubmit:g,noValidate:!0,className:"space-y-8",children:[n?s.jsx(Vt,{message:n}):null,s.jsx(lr,{step:1,title:"TAX ACCOUNT DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsxs(wt,{label:"Select State",required:!0,error:(y=m.state)==null?void 0:y.message,...l("state"),children:[s.jsx("option",{value:"",children:"Select"}),bj.map(w=>s.jsx("option",{value:w.code,children:w.name},w.code))]}),p.length>0?s.jsxs(wt,{label:"City",required:!0,error:(A=m.city)==null?void 0:A.message,...l("city"),children:[s.jsx("option",{value:"",children:"Select"}),p.map(w=>s.jsx("option",{value:w,children:w},w))]}):s.jsx(de,{label:"City",required:!0,placeholder:"Enter",error:(j=m.city)==null?void 0:j.message,...l("city")})]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:s.jsx(de,{label:"Zip Code",required:!0,placeholder:"Enter",error:(S=m.zipCode)==null?void 0:S.message,...l("zipCode")})}),s.jsx(de,{label:"Address Line 1",required:!0,placeholder:"Enter",error:(E=m.address1)==null?void 0:E.message,...l("address1")}),s.jsx(de,{label:"Address Line 2",placeholder:"Enter",error:(I=m.address2)==null?void 0:I.message,...l("address2")})]})}),b?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-slate-200"}),s.jsxs(lr,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:vj.map(w=>{var F;return s.jsx(de,{label:w.label,required:w.required,placeholder:"Enter",error:(F=m[w.name])==null?void 0:F.message,...l(w.name)},w.name)})}),s.jsx("div",{className:"mt-5 space-y-5",children:jj.map(w=>{var F;return s.jsx(de,{label:w.label,required:w.required,placeholder:"Enter",error:(F=m[w.name])==null?void 0:F.message,...l(w.name)},w.name)})})]})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-slate-200 pt-6",children:[s.jsx("button",{type:"button",onClick:e,disabled:i,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:i,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:i?"Saving…":"Save"})]})]})}const da="rounded-2xl border border-slate-200 bg-white shadow-sm";function Gi(){const e=ye(),{selectedEntity:t}=it(),r=Rr.find(i=>i.id==="tax-accounts"),n=r.icon,a=(i="tax-accounts")=>{e("/settings",{state:{section:i}})};return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${da} p-3`,children:s.jsx(Yu,{items:Rr,activeSection:"tax-accounts",onSectionChange:a})}),s.jsxs("div",{className:`${da} p-6 lg:p-8`,children:[s.jsx(mn,{title:r.title,subtitle:r.subtitle,icon:n}),s.jsx(kj,{onCancel:()=>a("tax-accounts"),onSuccess:()=>a("tax-accounts")})]})]}):s.jsx("div",{className:da+" p-6 lg:p-8",children:s.jsx("p",{className:"text-sm text-slate-500",children:"Select an entity to add a tax account."})})}function Cj({paymentsMode:e="all"}){return s.jsxs(ri,{children:[s.jsx(G,{index:!0,element:s.jsx(di,{})}),s.jsx(G,{path:"create-entity",element:s.jsx(hi,{})}),s.jsx(G,{path:"create-entity/form",element:s.jsx(_i,{})}),s.jsxs(G,{element:s.jsx(mi,{}),children:[s.jsx(G,{path:"entities",element:s.jsx(Di,{})}),s.jsx(G,{path:"dashboard",element:s.jsx(Fi,{})}),s.jsx(G,{path:"payments",element:s.jsx(zi,{paymentsMode:e})}),s.jsx(G,{path:"payments/federal/new",element:s.jsx(Su,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Cu,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Au,{})}),s.jsx(G,{path:"payments/state/new",element:s.jsx(Tu,{})}),s.jsx(G,{path:"payments/state/:statePaymentDetailId/edit",element:s.jsx(Iu,{})}),s.jsx(G,{path:"payments/state/:statePaymentDetailId/view",element:s.jsx(Fu,{})}),s.jsx(G,{path:"payments/state/authorization",element:s.jsx(Ou,{})}),s.jsx(G,{path:"payments/federal/authorization",element:s.jsx(zu,{})}),s.jsx(G,{path:"payments/federal/individual-enrollment",element:s.jsx(Zu,{})}),s.jsx(G,{path:"tax-forms",element:s.jsx(Mv,{})}),s.jsx(G,{path:"settings",element:s.jsx(Ji,{})}),s.jsx(G,{path:"settings/tax-accounts/new",element:s.jsx(Gi,{})})]}),s.jsx(G,{path:"*",element:s.jsx(Oe,{to:"/",replace:!0})})]})}const Ka="tax-remittance:payment-complete",Aj=N.forwardRef(function(t,r){const n=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(Ka,{detail:{paymentId:i}}))}})),s.jsx(ui,{...t,navigateFnRef:n,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:s.jsx(Cj,{paymentsMode:"all"})})}),Pj=N.forwardRef(function(t,r){const n=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),s.jsx(ui,{...t,navigateFnRef:n,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(ri,{children:[s.jsx(G,{index:!0,element:s.jsx(di,{})}),s.jsx(G,{path:"create-entity",element:s.jsx(hi,{})}),s.jsx(G,{path:"create-entity/form",element:s.jsx(_i,{})}),s.jsxs(G,{element:s.jsx(mi,{}),children:[s.jsx(G,{path:"entities",element:s.jsx(Di,{})}),s.jsx(G,{path:"dashboard",element:s.jsx(Fi,{})}),s.jsx(G,{path:"payments",element:s.jsx(zi,{paymentsMode:"federal"})}),s.jsx(G,{path:"payments/federal/new",element:s.jsx(Su,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Cu,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Au,{})}),s.jsx(G,{path:"payments/federal/authorization",element:s.jsx(zu,{})}),s.jsx(G,{path:"payments/federal/individual-enrollment",element:s.jsx(Zu,{})}),s.jsx(G,{path:"settings",element:s.jsx(Ji,{})}),s.jsx(G,{path:"settings/tax-accounts/new",element:s.jsx(Gi,{})})]}),s.jsx(G,{path:"*",element:s.jsx(Oe,{to:"/",replace:!0})})]})})}),Ej=N.forwardRef(function(t,r){const n=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(r,()=>({navigate:i=>{var o;return(o=n.current)==null?void 0:o.call(n,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent("tax-remittance:payment-complete",{detail:{paymentId:i}}))}})),s.jsx(ui,{...t,navigateFnRef:n,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(ri,{children:[s.jsx(G,{index:!0,element:s.jsx(di,{})}),s.jsx(G,{path:"create-entity",element:s.jsx(hi,{})}),s.jsx(G,{path:"create-entity/form",element:s.jsx(_i,{})}),s.jsxs(G,{element:s.jsx(mi,{}),children:[s.jsx(G,{path:"entities",element:s.jsx(Di,{})}),s.jsx(G,{path:"dashboard",element:s.jsx(Fi,{})}),s.jsx(G,{path:"payments",element:s.jsx(zi,{paymentsMode:"state"})}),s.jsx(G,{path:"payments/state/new",element:s.jsx(Tu,{})}),s.jsx(G,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Iu,{})}),s.jsx(G,{path:"payments/state/:statePaymentId/view",element:s.jsx(Fu,{})}),s.jsx(G,{path:"payments/state/authorization",element:s.jsx(Ou,{})}),s.jsx(G,{path:"settings",element:s.jsx(Ji,{})}),s.jsx(G,{path:"settings/tax-accounts/new",element:s.jsx(Gi,{})})]}),s.jsx(G,{path:"*",element:s.jsx(Oe,{to:"/",replace:!0})})]})})});exports.ApiError=xn;exports.FederalPaymentWidget=Pj;exports.StatePaymentWidget=Ej;exports.TaxRemittanceEmbedded=Aj;exports.setRuntimeApiBaseUrl=oc;
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,b={...f},p=h.ref;if(h.ref=null,p){s(p);const y=e.seen.get(p),k=y.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,b),m._zod.parent===p)for(const w in f)w==="$ref"||w==="allOf"||w in b||delete f[w];if(k.$ref&&y.def)for(const w in f)w==="$ref"||w==="allOf"||w in y.def&&JSON.stringify(f[w])===JSON.stringify(y.def[w])&&delete f[w]}const x=m._zod.parent;if(x&&x!==p){s(x);const y=e.seen.get(x);if(y!=null&&y.schema.$ref&&(f.$ref=y.schema.$ref,y.def))for(const k in f)k==="$ref"||k==="allOf"||k in y.def&&JSON.stringify(f[k])===JSON.stringify(y.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,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:ws(t,"input",e.processors),output:ws(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function We(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 We(s.element,r);if(s.type==="set")return We(s.valueType,r);if(s.type==="lazy")return We(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 We(s.innerType,r);if(s.type==="intersection")return We(s.left,r)||We(s.right,r);if(s.type==="record"||s.type==="map")return We(s.keyType,r)||We(s.valueType,r);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:We(s.in,r)||We(s.out,r);if(s.type==="object"){for(const a in s.shape)if(We(s.shape[a],r))return!0;return!1}if(s.type==="union"){for(const a of s.options)if(We(a,r))return!0;return!1}if(s.type==="tuple"){for(const a of s.items)if(We(a,r))return!0;return!!(s.rest&&We(s.rest,r))}return!1}const mg=(e,t={})=>r=>{const s=Hc({...r,processors:t});return qe(e,s),Kc(s,e),Qc(s,e)},ws=(e,t,r={})=>s=>{const{libraryOptions:a,target:i}=s??{},o=Hc({...a??{},target:i,io:t,processors:r});return qe(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=qe(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]=qe(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=qe(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)=>qe(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=qe(a.left,t,{...s,path:[...s.path,"allOf",0]}),o=qe(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=qe(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;qe(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType},Pg=(e,t,r,s)=>{const a=e._zod.def;qe(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;qe(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;qe(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},Tg=(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;qe(o,t,s);const l=t.seen.get(e);l.ref=o},Ig=(e,t,r,s)=>{const a=e._zod.def;qe(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;qe(a.innerType,t,s);const i=t.seen.get(e);i.ref=a.innerType};function qa(){return qa=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},qa.apply(null,arguments)}function Qo(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]=vi(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(qa({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=r[l].types,d=u&&u[a.code];r[l]=vi(l,t,r,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)s();return r}function Ct(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(Qo(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](s,t)).then(function(o){return i.shouldUseNativeValidation&&La({},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:Do(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(Qo(function(){return Promise.resolve((r.mode==="sync"?Rf:Of)(e,s,t)).then(function(o){return i.shouldUseNativeValidation&&La({},i),{errors:{},values:r.raw?Object.assign({},s):o}})},function(o){if((function(l){return l instanceof Pi})(o))return{values:{},errors:Do(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 un({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=N.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(un,{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]})}),wt=N.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(un,{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 lr({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 Vt({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 Ge(e,t){var r;if(e instanceof xn){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=I("ZodISODateTime",(e,t)=>{qp.init(e,t),Ne.init(e,t)});function $g(e){return Ux(Og,e)}const Lg=I("ZodISODate",(e,t)=>{Vp.init(e,t),Ne.init(e,t)});function zg(e){return Zx(Lg,e)}const Mg=I("ZodISOTime",(e,t)=>{Bp.init(e,t),Ne.init(e,t)});function qg(e){return Wx(Mg,e)}const Vg=I("ZodISODuration",(e,t)=>{Up.init(e,t),Ne.init(e,t)});function Bg(e){return Yx(Vg,e)}const Ug=(e,t)=>{Pi.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,za,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,za,2)}},isEmpty:{get(){return e.issues.length===0}}})},ut=I("ZodError",Ug,{Parent:Error}),Zg=$s(ut),Wg=Ls(ut),Yg=zs(ut),Hg=Ms(ut),Kg=zf(ut),Qg=Mf(ut),Jg=qf(ut),Gg=Vf(ut),Xg=Bf(ut),ey=Uf(ut),ty=Zf(ut),ry=Wf(ut),Jo=new WeakMap;function Vs(e,t,r){const s=Object.getPrototypeOf(e);let a=Jo.get(s);if(a||(a=new Set,Jo.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 Ae=I("ZodType",(e,t)=>(Ce.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ws(e,"input"),output:ws(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),Vs(e,"ZodType",{check(...r){const s=this.def;return this.clone(cr(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 ur(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(gn(r))},optional(){return el(this)},exactOptional(){return Ry(this)},nullable(){return tl(this)},nullish(){return el(tl(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 rl(this,Fy(r))},default(r){return Ly(this,r)},prefault(r){return My(this,r)},catch(r){return By(this,r)},pipe(r){return rl(this,r)},readonly(){return Wy(this)},describe(r){const s=this.clone();return An.add(s,{description:r}),s},meta(...r){if(r.length===0)return An.get(this);const s=this.clone();return An.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=An.get(e))==null?void 0:r.description},configurable:!0}),e)),Gc=I("_ZodString",(e,t)=>{Ei.init(e,t),Ae.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,Vs(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(Ns(...s))},max(...s){return this.check(Wc(...s))},length(...s){return this.check(Yc(...s))},nonempty(...s){return this.check(Ns(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=I("ZodString",(e,t)=>{Ei.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(Ko(Go,r)),e.uuid=r=>e.check(Sx(ts,r)),e.uuidv4=r=>e.check(kx(ts,r)),e.uuidv6=r=>e.check(Cx(ts,r)),e.uuidv7=r=>e.check(Ax(ts,r)),e.nanoid=r=>e.check(_x(oy,r)),e.guid=r=>e.check(Ko(Go,r)),e.cuid=r=>e.check(Tx(ly,r)),e.cuid2=r=>e.check(Ix(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 _(e){return wx(ny,e)}const Ne=I("ZodStringFormat",(e,t)=>{be.init(e,t),Gc.init(e,t)}),Xc=I("ZodEmail",(e,t)=>{Ip.init(e,t),Ne.init(e,t)});function sy(e){return Zc(Xc,e)}const Go=I("ZodGUID",(e,t)=>{_p.init(e,t),Ne.init(e,t)}),ts=I("ZodUUID",(e,t)=>{Tp.init(e,t),Ne.init(e,t)}),ay=I("ZodURL",(e,t)=>{Fp.init(e,t),Ne.init(e,t)}),iy=I("ZodEmoji",(e,t)=>{Dp.init(e,t),Ne.init(e,t)}),oy=I("ZodNanoID",(e,t)=>{Rp.init(e,t),Ne.init(e,t)}),ly=I("ZodCUID",(e,t)=>{Op.init(e,t),Ne.init(e,t)}),cy=I("ZodCUID2",(e,t)=>{$p.init(e,t),Ne.init(e,t)}),uy=I("ZodULID",(e,t)=>{Lp.init(e,t),Ne.init(e,t)}),dy=I("ZodXID",(e,t)=>{zp.init(e,t),Ne.init(e,t)}),my=I("ZodKSUID",(e,t)=>{Mp.init(e,t),Ne.init(e,t)}),hy=I("ZodIPv4",(e,t)=>{Zp.init(e,t),Ne.init(e,t)}),fy=I("ZodIPv6",(e,t)=>{Wp.init(e,t),Ne.init(e,t)}),py=I("ZodCIDRv4",(e,t)=>{Yp.init(e,t),Ne.init(e,t)}),xy=I("ZodCIDRv6",(e,t)=>{Hp.init(e,t),Ne.init(e,t)}),gy=I("ZodBase64",(e,t)=>{Kp.init(e,t),Ne.init(e,t)}),yy=I("ZodBase64URL",(e,t)=>{Jp.init(e,t),Ne.init(e,t)}),by=I("ZodE164",(e,t)=>{Gp.init(e,t),Ne.init(e,t)}),vy=I("ZodJWT",(e,t)=>{ex.init(e,t),Ne.init(e,t)}),jy=I("ZodBoolean",(e,t)=>{tx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>pg(e,r,s)});function Wr(e){return Hx(jy,e)}const Ny=I("ZodUnknown",(e,t)=>{rx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>gg()});function Xo(){return Kx(Ny)}const wy=I("ZodNever",(e,t)=>{nx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>xg(e,r,s)});function Sy(e){return Qx(wy,e)}const ky=I("ZodArray",(e,t)=>{sx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Ng(e,r,s,a),e.element=t.element,Vs(e,"ZodArray",{min(r,s){return this.check(Ns(r,s))},nonempty(r){return this.check(Ns(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=I("ZodObject",(e,t)=>{ix.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>wg(e,r,s,a),he(e,"shape",()=>t.shape),Vs(e,"ZodObject",{keyof(){return Bs(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Xo()})},loose(){return this.clone({...this._zod.def,catchall:Xo()})},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 Tf(ru,this,r[0])}})});function Bt(e,t){const r={type:"object",shape:e??{},...te(t)};return new Ay(r)}const Py=I("ZodUnion",(e,t)=>{ox.init(e,t),Ae.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,...te(t)})}const Ey=I("ZodIntersection",(e,t)=>{lx.init(e,t),Ae.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 Va=I("ZodEnum",(e,t)=>{cx.init(e,t),Ae.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 Va({...t,checks:[],...te(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 Va({...t,checks:[],...te(a),entries:i})}});function Bs(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Va({type:"enum",entries:r,...te(t)})}const Ty=I("ZodLiteral",(e,t)=>{ux.init(e,t),Ae.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 ta(e,t){return new Ty({type:"literal",values:Array.isArray(e)?e:[e],...te(t)})}const Iy=I("ZodTransform",(e,t)=>{dx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>jg(e,r),e._zod.parse=(r,s)=>{if(s.direction==="backward")throw new Ic(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Fn(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(Fn(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 Iy({type:"transform",transform:e})}const tu=I("ZodOptional",(e,t)=>{Uc.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Jc(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function el(e){return new tu({type:"optional",innerType:e})}const Dy=I("ZodExactOptional",(e,t)=>{mx.init(e,t),Ae.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=I("ZodNullable",(e,t)=>{hx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Cg(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function tl(e){return new Oy({type:"nullable",innerType:e})}const $y=I("ZodDefault",(e,t)=>{fx.init(e,t),Ae.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=I("ZodPrefault",(e,t)=>{px.init(e,t),Ae.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=I("ZodNonOptional",(e,t)=>{xx.init(e,t),Ae.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,...te(t)})}const Vy=I("ZodCatch",(e,t)=>{gx.init(e,t),Ae.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=I("ZodPipe",(e,t)=>{yx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Tg(e,r,s,a),e.in=t.in,e.out=t.out});function rl(e,t){return new Uy({type:"pipe",in:e,out:t})}const Zy=I("ZodReadonly",(e,t)=>{bx.init(e,t),Ae.init(e,t),e._zod.processJSONSchema=(r,s,a)=>Ig(e,r,s,a),e.unwrap=()=>e._zod.def.innerType});function Wy(e){return new Zy({type:"readonly",innerType:e})}const Yy=I("ZodCustom",(e,t)=>{vx.init(e,t),Ae.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 Vr={custom:"custom"};function _i(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 At(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?e.firstName:`${e.firstName} ${e.lastName}`.trim()}function dr(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function Dr(e){const t=e.replace(/\D/g,""),r=t.length===11&&t.startsWith("1")?t.slice(1):t;return r.length!==10?e:`+1 (${r.slice(0,3)}) ${r.slice(3,6)}-${r.slice(6)}`}function Qy(e,t){const r=t.trim().toLowerCase();if(!r)return!0;const s=At(e).toLowerCase(),a=e.email.toLowerCase(),i=e.idNumber.replace(/\D/g,"");return s.includes(r)||a.includes(r)||i.includes(r.replace(/\D/g,""))||dr(e.idNumber).toLowerCase().includes(r)}const nu=["LLP","LLC","Corporation","S-Corp","Partnership"],su=["Sole Proprietorship"],Ti=["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"],Ba=10,au=Bt({accountType:Bs(["Business","Individual"]),businessName:_().min(1,"Business name is required"),tradeName:_(),ein:_().min(1,"EIN is required").refine(e=>e.replace(/\D/g,"").length===9,"EIN must be 9 digits"),entityType:_().min(1,"Entity type is required"),email:sy("Enter a valid email"),countryCode:_().min(1),phoneNumber:_().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Ba,`Phone number must be ${Ba} 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")});function Jy(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(-Ba)}}function nl(e){const{countryCode:t,national:r}=Jy(e.phoneNumber),s=e.accountType==="Individual"?`${e.firstName} ${e.lastName}`.trim():e.firstName;return{accountType:e.accountType==="Individual"?"Individual":"Business",businessName:s,tradeName:e.tradeName??"",ein:dr(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:r,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function Gy(e){const t=e.businessName.trim().split(/\s+/),r=t[0]??e.businessName,s=e.accountType==="Individual"?t.slice(1).join(" ")||r:e.businessName.trim();return{firstName:r,lastName:s}}function iu(e){const{firstName:t,lastName:r}=Gy(e);return{accountType:e.accountType,firstName:t,lastName:r,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName,phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function Xy(e){const{idNumber:t,...r}=iu(e);return r}function zr(e,t){const r=e==null?void 0:e.from;return r&&r.startsWith("/")&&!r.startsWith("//")?r:t}function eb(){var E,F,P,O,Z,$,se,V,J,T,W;const e=ye(),t=ge(),r=ct(),{data:s=[]}=ke({queryKey:["entities","mine"],queryFn:pc}),[a,i]=N.useState(null),[o,l]=N.useState(!1),c=s.length===0,u=c?"/create-entity":"/dashboard",d=zr(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:b,setValue:p,formState:{errors:x}}=St({resolver:Ct(au),defaultValues:{accountType:"Individual",businessName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),y=b("accountType"),k=b("entityType"),j=y==="Individual"?su:nu;N.useEffect(()=>{j.includes(k)||p("entityType",y==="Individual"?"Sole Proprietorship":"LLP")},[y,k,j,p]);const w=f(async H=>{i(null),l(!0);try{await Oh(iu(H)),await r.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(ce){i(Ge(ce,"Unable to save entity. Please try again."))}finally{l(!1)}});return n.jsxs("form",{onSubmit:w,noValidate:!0,className:"space-y-8",children:[a?n.jsx(Vt,{message:a}):null,n.jsx(lr,{step:1,title:"ENTITY DETAILS",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{children:[n.jsx(un,{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",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Business"]}),n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...h("accountType")}),"Individual"]})]})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:y==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(E=x.businessName)==null?void 0:E.message,...h("businessName")}),n.jsx(me,{label:"Trade Name, if any",placeholder:"Enter",error:(F=x.tradeName)==null?void 0:F.message,...h("tradeName")})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"EIN",required:!0,placeholder:"**-*******",maxLength:10,error:(P=x.ein)==null?void 0:P.message,...h("ein")}),n.jsx(wt,{label:"Entity Type",required:!0,error:(O=x.entityType)==null?void 0:O.message,...h("entityType"),children:j.map(H=>n.jsx("option",{value:H,children:H},H))})]}),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:(Z=x.email)==null?void 0:Z.message,...h("email")}),n.jsxs("div",{children:[n.jsx(un,{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(lr,{title:"ADDRESS DETAILS",muted:!0,children:n.jsxs("div",{className:"space-y-5",children:[n.jsx(me,{label:"Address Line 1",required:!0,error:($=x.address1)==null?void 0:$.message,...h("address1")}),n.jsx(me,{label:"Address Line 2",error:(se=x.address2)==null?void 0:se.message,...h("address2")}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"City",required:!0,error:(V=x.city)==null?void 0:V.message,...h("city")}),n.jsxs(wt,{label:"State",required:!0,error:(J=x.state)==null?void 0:J.message,...h("state"),children:[n.jsx("option",{value:"",children:"Select"}),Ti.map(H=>n.jsx("option",{value:H,children:H},H))]})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"ZIP Code",required:!0,error:(T=x.zipCode)==null?void 0:T.message,...h("zipCode")}),n.jsxs(wt,{label:"Country",required:!0,error:(W=x.country)==null?void 0:W.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 Ii(){const e=ye(),t=ge(),r=zr(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(tb,{}),"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(eb,{})})]})}function tb(){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 rb(e,t){const r=new URLSearchParams({entityId:String(e)});return t!==void 0&&r.set("taxYear",String(t)),fe(`/portal/dashboard?${r}`)}function nb(e,t,r){const s=new URLSearchParams({entityId:String(e),category:t,taxYear:String(r)});return fe(`/portal/dashboard/summary?${s}`)}function sb(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 ab({entityId:e,search:t,taxYear:r,status:s,page:a=1,pageSize:i=20}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),r&&o.set("taxYear",r),s&&s!=="all"&&o.set("status",s),fe(`/portal/dashboard/payments?${o}`)}function sl({entityCount:e}){const t=ye(),{enabledPayments:r}=$r();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:[r.includes("federal")&&n.jsxs("button",{type:"button",onClick:()=>t("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[n.jsx(ra,{}),"Add Federal Payments"]}),r.includes("state")&&n.jsxs("button",{type:"button",onClick:()=>t("/payments/state/new",{state:{from:"/",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[n.jsx(ra,{}),"Add State Payment"]}),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(ra,{}),"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:()=>t("/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(ib,{}),"Entities (",e,")"]}),n.jsxs("button",{type:"button",onClick:()=>t("/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(ob,{}),"Add Entity"]})]})]})}function ra(){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 ib(){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 ob(){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 lb({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(cb,{}),r]})]})}function cb(){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 Fi({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(ub,{}),n.jsx("span",{children:e})]})})}function ub(){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 db={Draft:"Draft"};function ou(e){switch((e??db.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 Un(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function mb(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 Di="drafts";function Ze(){return Us(Di)}function Us(e){return`/payments?tab=${e}`}function lu(e){return e==="failed"?"rejected":e}function hb(e,t){return t.trim().toLowerCase()==="draft"?Di:lu(e)}const fb=["January","February","March","April","May","June","July","August","September","October","November","December"];function pb({entityId:e,initialOverview:t,isDashboardLoading:r=!1}){const s=ye(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=N.useState(null);N.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:u,isFetching:d}=ke({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>sb(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,b=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:gb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:yb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:bb,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Failed",amount:h.failed,icon:vb,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(Fi,{}):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:fb.map((p,x)=>n.jsx("option",{value:x+1,children:p},p))}),n.jsx(xb,{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:b.map(p=>{const x=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(x,{})}),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:Un(p.amount)}),n.jsx("button",{type:"button",onClick:()=>s(Us(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 xb({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 gb(){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 yb(){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 bb(){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 vb(){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 al(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function jb(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 il(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const Nb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],ol={total:0,items:[]};function wb({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 Sb({entityId:e,initialPayments:t,isDashboardLoading:r=!1}){const s=ye(),[a,i]=N.useState(""),[o,l]=N.useState(""),[c,u]=N.useState(""),[d,m]=N.useState("all");N.useEffect(()=>{const j=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(j)},[a]);const h=!!o||!!c||d!=="all",{data:f,isFetching:b}=ke({queryKey:["dashboard","payments",e,o,c,d],queryFn:()=>ab({entityId:e,search:o||void 0,taxYear:c||void 0,status:d}),enabled:e!==null&&h,placeholderData:j=>j}),p=h?f??t??ol:t??ol,x=N.useMemo(()=>p.items.map(jb),[p.items]),y=N.useMemo(()=>{const j=new Date().getFullYear();return[j,j-1,j-2].map(String)},[]),k=r||h&&b;return n.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[k?n.jsx(Fi,{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(Cb,{})}),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:[p.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(kb,{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:j=>i(j.target.value),placeholder:"All",disabled:r,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),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:j=>u(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[n.jsx("option",{value:"",children:"Select Year"}),y.map(j=>n.jsx("option",{value:j,children:j},j))]}),n.jsx(ll,{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:j=>m(j.target.value),disabled:r,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:Nb.map(j=>n.jsx("option",{value:j.value,children:j.label},j.value))}),n.jsx(ll,{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:!k&&x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:h?"No payments match your filters.":"No payments yet."})}):x.map((j,w)=>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:["#",w+1]}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.jurisdiction}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.period}),n.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Un(j.amount)}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.paymentDate}),n.jsx("td",{className:"px-6 py-4",children:n.jsx(wb,{label:j.statusLabel,status:j.status})}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:j.formType}),n.jsx("td",{className:"px-6 py-4",children:n.jsx("button",{type:"button",onClick:()=>s(Us(hb(j.status,j.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${j.category}-${j.id}`))})]})})]})}function kb({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 ll({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 Cb(){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 na({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]=N.useState(a);if(N.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:b}=ke({queryKey:["dashboard","summary",e,t,d],queryFn:()=>nb(e,t,d),enabled:e!==null&&!h,placeholderData:k=>k}),p=h?o?al(o):il():f?al(f):il(),x=mb(p),y=l||b&&!h;return n.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[y?n.jsx(Fi,{}):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:k=>m(Number(k.target.value)),disabled:y,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=>n.jsxs("option",{value:k,children:["TY ",k]},k))}),n.jsx(Ab,{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(k=>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 ${k.dotClassName}`}),n.jsx("span",{className:"text-xs text-slate-500",children:k.label})]}),n.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Un(p[k.key])})]},k.label))}),n.jsxs("div",{className:"mt-5",children:[n.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:x.map((k,j)=>k.width>0?n.jsx("span",{className:`${k.color} h-full`,style:{width:`${k.width}%`}},j):null)}),n.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function Ab({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 Pb={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."},Eb=[{key:"federal",title:"Add Your First Federal Payment",buttonLabel:"Add Federal Payment"},{key:"state",title:"Add Your First State Payment",buttonLabel:"Add State Payment"},{key:"local",title:"Add Your First Local Payment",buttonLabel:"Add Local Payments"}],Qt=new Date().getFullYear(),sa=[Qt,Qt-1,Qt-2],_b=[{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"}],Tb=[{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"}],Ib=[{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 Ri(){const e=ye(),{entities:t,selectedEntity:r,enabledPayments:s}=$r(),a=(r==null?void 0:r.entityId)??null,{data:i,isLoading:o}=ke({queryKey:["dashboard",a,Qt],queryFn:()=>rb(a,Qt),enabled:a!==null});return!o&&i&&!i.hasPayments?n.jsxs("div",{className:"space-y-6",children:[n.jsx(sl,{entityCount:t.length}),n.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:Eb.filter(l=>l.key==="local"||s.includes(l.key)).map(l=>n.jsx(lb,{title:l.title,description:Pb[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(sl,{entityCount:t.length}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.includes("federal")&&n.jsx(na,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:Qt,taxYearOptions:sa,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:_b}),s.includes("state")&&n.jsx(na,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:Qt,taxYearOptions:sa,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:Tb}),n.jsx(na,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:Qt,taxYearOptions:sa,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:Ib,comingSoon:!0})]}),n.jsx(pb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),n.jsx(Sb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}function Oi(){const{entities:e,selectedEntity:t,setSelectedEntityId:r}=$r(),s=ye(),[a,i]=N.useState(""),o=e.filter(c=>Qy(c,a)),l=c=>{r(c.entityId),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(Db,{}),"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(Rb,{}),"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:c=>i(c.target.value),placeholder:"All",className:"h-[38px] w-[220px] rounded-lg border-2 border-[#e5e7eb] bg-[#f9fafb] px-3 text-sm text-slate-700 placeholder-[#99a1af] focus:border-[#156bd5] focus:outline-none"})]})]}),n.jsx("div",{className:"overflow-x-auto rounded-xl border border-black/[0.12] bg-white",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:o.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"No organizations match your search."})}):o.map(c=>n.jsx(Fb,{entity:c,isSelected:c.entityId===(t==null?void 0:t.entityId),onSelect:()=>l(c)},c.entityId))})]})})]})}function Fb({entity:e,isSelected:t,onSelect:r}){var l;const s=At(e),a=_i(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:dr(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 Db(){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 Rb(){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 Ob(e){return fe(`/portal/federal-payments?entityId=${e}`)}function $i(e){return fe(`/portal/federal-payments/${e}`)}function $b(e){return fe(`/portal/federal-payments/form-types?entityId=${e}`)}function Lb(e){const t=new URLSearchParams({formType:e});return fe(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Li(e){return fe("/portal/federal-payments",{method:"POST",body:e})}function zi(e,t){return fe(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function zb(e){return fe(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function Mb(e){return qn(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function qb(e){return qn(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function Vb(e){return qn(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function Bb(e){return qn(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function Mi(e){return fe(`/portal/state-payments?entityId=${e}`)}function Ub(e){return fe("/portal/state-payments",{method:"POST",body:e})}function Zb(e,t){return fe(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function Wb(e){return fe(`/portal/state-payments/${e}/submit`,{method:"POST"})}function Yb({open:e,title:t,html:r,isLoading:s=!1,error:a=null,downloadFileName:i="payment.pdf",onDownload:o,onClose:l}){const[c,u]=N.useState(!1);N.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 aa({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 Hb({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(aa,{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(aa,{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(aa,{onViewPdf:r,isViewPdfLoading:o})]})}function cu(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 Kb(e){return{id:e.federalPaymentId,category:"federal",referenceNo:e.referenceNumber??"—",jurisdiction:"IRS - Federal",period:cu(e.taxPeriod),amount:e.paymentAmount,paymentDate:e.settlementDate,status:e.status,reason:e.reason,tab:ou(e.status)}}function Qb(e){return{id:e.statePaymentDetailId,category:"state",referenceNo:e.referenceNumber??"—",jurisdiction:`${e.state} (State)`,period:cu(e.taxPeriod),amount:e.taxAmount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:ou(e.status)}}function Jb(e,t,r){return e.filter(s=>s.tab!==t?!1:r==="all"?!0:s.category===r)}function Gb(e){return e.reduce((t,r)=>(t[r.tab]+=1,t),{drafts:0,scheduled:0,submitted:0,rejected:0,paid:0})}function Xb({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 e0({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 t0({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 r0({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 n0({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:Xb,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:e0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:t0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:r0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:n0,iconClassName:"text-green-500"}],s0={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 cl(e){return e!==null&&uu.some(t=>t.key===e)}function qi({paymentsMode:e="all"}){const t=ye(),r=ct(),[s]=_m(),{selectedEntity:a}=it(),{onPaymentRequired:i}=$r(),o=(a==null?void 0:a.entityId)??null,l=s.get("tab"),[c,u]=N.useState(cl(l)?l:Di),[d,m]=N.useState(e==="all"?"all":e),[h,f]=N.useState(null),[b,p]=N.useState(null),[x,y]=N.useState(null);N.useEffect(()=>{cl(l)&&u(l)},[l]);const k=s0[c],{data:j=[],isLoading:w}=ke({queryKey:["remittance-payments",o,e],queryFn:async()=>{const[T,W]=await Promise.all([e!=="state"?Ob(o):Promise.resolve([]),e!=="federal"?Mi(o):Promise.resolve([])]);return[...T.map(Kb),...W.map(Qb)]},enabled:o!==null}),E=N.useMemo(()=>Gb(j),[j]),F=N.useMemo(()=>Jb(j,c,d),[j,c,d]),P=vh({mutationFn:async T=>{try{T.category==="federal"?await zb(T.id):await Wb(T.id)}catch(W){if(W instanceof xn&&W.status===402&&i){const H=W.extensions,ce={paymentType:(H==null?void 0:H.paymentType)??T.category,paymentId:(H==null?void 0:H.paymentId)??T.id,expectedAmount:(H==null?void 0:H.expectedAmount)??"0.00",currency:(H==null?void 0:H.currency)??"USD",federalRecordCount:(H==null?void 0:H.federalRecordCount)??0,stateRecordCount:(H==null?void 0:H.stateRecordCount)??0,feePerFederal:(H==null?void 0:H.feePerFederal)??null,feePerState:(H==null?void 0:H.feePerState)??null};i(ce);return}throw W}},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:()=>f(null),onSettled:()=>f(null)});N.useEffect(()=>{const T=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(Ja,T),()=>window.removeEventListener(Ja,T)},[r]);const O=T=>{f(`${T.category}-${T.id}`),P.mutate(T)},Z=T=>{T.category==="federal"?t(`/payments/federal/${T.id}/view`):t(`/payments/state/${T.id}/view`)},$=T=>{T.category==="federal"?t(`/payments/federal/${T.id}/edit`):t(`/payments/state/${T.id}/edit`)},se=async T=>{const W=`${T.category}-${T.id}`,H=`payment-${T.referenceNo}.pdf`;p(W),y({title:`Payment PDF — ${T.referenceNo}`,html:null,category:T.category,paymentId:T.id,downloadFileName:H,isLoading:!0,error:null});try{const ce=T.category==="federal"?await Vb(T.id):await Bb(T.id);y({title:`Payment PDF — ${T.referenceNo}`,html:ce,category:T.category,paymentId:T.id,downloadFileName:H,isLoading:!1,error:null})}catch(ce){y({title:`Payment PDF — ${T.referenceNo}`,html:null,category:T.category,paymentId:T.id,downloadFileName:H,isLoading:!1,error:Ge(ce,"Unable to load payment PDF.")})}finally{p(null)}},V=async()=>{if(!x)throw new Error("No payment selected");return x.category==="federal"?Mb(x.paymentId):qb(x.paymentId)},J=()=>y(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(ia,{}),"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(ia,{}),"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(ia,{}),"Add Local Payments",n.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),n.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[n.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:uu.map(T=>{const W=c===T.key,H=T.Icon;return n.jsxs("button",{type:"button",onClick:()=>{u(T.key),t(Us(T.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 ${W?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[n.jsx(H,{className:`shrink-0 ${T.iconClassName}`}),T.label," (",E[T.key],")"]},T.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:T=>m(T.target.value),className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200",children:[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:k.columns.map(T=>n.jsx("th",{className:"px-6 py-3",children:T},T))})}),n.jsx("tbody",{children:w?n.jsx("tr",{children:n.jsx("td",{colSpan:k.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):F.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:k.columns.length,className:"px-6 py-12 text-center text-slate-500",children:k.emptyMessage})}):F.map(T=>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"?`#${T.id}`:T.referenceNo}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.jurisdiction}),n.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.period}),n.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Un(T.amount)}),c!=="paid"?n.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.paymentDate}):null,c==="rejected"?n.jsx("td",{className:"px-6 py-4 text-slate-700",children:T.reason??"—"}):null,n.jsx("td",{className:"px-6 py-4",children:n.jsx(Hb,{actionType:k.actionType,onView:()=>Z(T),onViewPdf:()=>se(T),onEdit:()=>$(T),onSubmit:()=>O(T),isSubmitting:h===`${T.category}-${T.id}`,isViewPdfLoading:b===`${T.category}-${T.id}`})})]},`${T.category}-${T.id}`))})]})})]}),n.jsx(Yb,{open:x!==null,title:(x==null?void 0:x.title)??"Payment PDF",html:(x==null?void 0:x.html)??null,downloadFileName:x==null?void 0:x.downloadFileName,isLoading:(x==null?void 0:x.isLoading)??!1,error:(x==null?void 0:x.error)??null,onDownload:x&&!x.error?V:void 0,onClose:J})]})}function ia(){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 Zn(e){return fe(`/portal/bank-accounts?entityId=${e}`)}function a0(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 vr({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 dn=17,mu=9;function Yr(e,t){return e.replace(/\D/g,"").slice(0,t)}const hu=["Checking","Savings"],i0=Bt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dn} digits`),confirmAccountNumber:_().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${dn} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Bs(hu,{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 o0({entityId:e,onCancel:t,onSuccess:r}){const s=ct(),{showSuccess:a,showError:i}=Fs(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=St({resolver:Ct(i0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async b=>{l(null),u(!0);try{const p=await a0({entityId:e,bankName:b.bankName.trim(),accountNumber:b.accountNumber,routingNumber:b.routingNumber,accountType:b.accountType});await s.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),r(p.bankAccountDetailId)}catch(p){const x=Ge(p,"Unable to save bank account.");l(x),i("Action Not Completed",x)}finally{u(!1)}});return n.jsxs("form",{noValidate:!0,onSubmit:b=>{b.preventDefault(),b.stopPropagation(),f(b)},className:"space-y-6",children:[n.jsxs(lr,{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(Re,{name:"accountNumber",control:d,render:({field:b})=>{var p;return n.jsx(me,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:b.value,onChange:x=>b.onChange(Yr(x.target.value,dn)),onBlur:b.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),n.jsx(Re,{name:"confirmAccountNumber",control:d,render:({field:b})=>{var p;return n.jsx(me,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:b.value,onChange:x=>b.onChange(Yr(x.target.value,dn)),onBlur:b.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),n.jsx(Re,{name:"routingNumber",control:d,render:({field:b})=>{var p;return n.jsx(me,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:b.value,onChange:x=>b.onChange(Yr(x.target.value,mu)),onBlur:b.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),n.jsx(Re,{name:"accountType",control:d,render:({field:b})=>{var p;return n.jsx(wt,{label:"Account Type",required:!0,value:b.value,onChange:b.onChange,onBlur:b.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:hu.map(x=>n.jsx("option",{value:x,children:x},x))})}})]}),n.jsx(Re,{name:"bankName",control:d,render:({field:b})=>{var p;return n.jsx(me,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:b.value,onChange:b.onChange,onBlur:b.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?n.jsx(Vt,{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]=N.useState("choose");if(N.useEffect(()=>{e||i("choose")},[e]),N.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&r()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,r]),!e)return null;const o=a==="manual";return 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(o0,{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(l0,{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(c0,{className:"h-6 w-6"})}),n.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function l0({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 c0({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 u0=12,d0=["January","February","March","April","May","June","July","August","September","October","November","December"];function ir(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${s}`}function Ss(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 Zs(e=new Date){const t=new Date(e);return e.getHours()>=u0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),ir(t)}function pu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),ir(t)}function m0(e=18,t=new Date){const r=new Date(t);return r.setFullYear(r.getFullYear()-e),r.setHours(0,0,0,0),ir(r)}function h0(e,t,r=new Date){const s=Ss(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 f0(e){const t=e.getDay();return t!==0&&t!==6}function Ua(e,t=new Date){if(!f0(e))return!1;const r=ir(e);return r>=Zs(t)&&r<=pu(t)}function xu(e,t=new Date){const r=Ss(e);return r?Ua(r,t):!1}function p0(e,t){return`${d0[t]} ${e}`}function x0(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 ul(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Wn(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 X(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 Hr(e){return`${yu(e)} appearance-none`}function Ur({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 En({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]=N.useState(!1),[m,h]=N.useState(!1),f=N.useRef(null),b=a.find(x=>String(x.bankAccountDetailId)===e);N.useEffect(()=>{if(!u)return;const x=y=>{var k;(k=f.current)!=null&&k.contains(y.target)||d(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[u]);const p=x=>{t(String(x)),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(x=>!x),className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${l?"border-red-300":"border-slate-200"}`,children:[n.jsx("span",{className:b?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":b?ul(b.accountNumber):"Bank account number"}),n.jsx(y0,{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(g0,{}),"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(x=>{const y=String(x.bankAccountDetailId)===e;return n.jsxs("button",{type:"button",onClick:()=>{t(String(x.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${y?"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:_i(x.bankName)}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:x.bankName}),n.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[ul(x.accountNumber),s?` · ${s}`:` · ${x.accountType}`]})]})]},x.bankAccountDetailId)})})]}):null]}),n.jsx(fu,{open:m,entityId:r,onClose:()=>h(!1),onAccountAdded:p})]})}function g0(){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 y0({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 b0(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Yn({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=At(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(wn,{label:"Entity Name",value:s}),n.jsx(wn,{label:"Tax ID",value:dr(e.idNumber)}),n.jsx(wn,{label:"Email ID",value:e.email}),n.jsx(wn,{label:"Phone Number",value:Dr(e.phoneNumber)}),n.jsx(wn,{label:"Address",value:b0(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 wn({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 v0=[0,1,3,4,6,7,9,10],j0=[0,1,2,3,4,5,6,7,8,9,10],N0=[0,1,2,3,4,5,6,8,9,10,11],w0=[0,1,2,3,4,5,6,7,9,10,11],S0=["720","941"],k0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],C0=["7200D"],A0=["8963"];function vu(e){return S0.includes(e)?v0:k0.includes(e)?j0:C0.includes(e)?N0:A0.includes(e)?w0:[]}function P0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function ks(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 E0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function ju(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Cs={941:"94105",944:"94405","CT-1":"10005"},Sn={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Za={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 Vi(e,t){return!e||!t?!1:Cs[e]===t}function Ws(e,t){return e==="CT-1"&&t===Cs["CT-1"]}function _0(e,t){return e==="941"&&t===Cs[941]||e==="944"&&t===Cs[944]}function T0(e){return e==="CT-1"?{code1:Sn.tier1,code2:Sn.tier2,code3:""}:{code1:Sn.socialSecurity,code2:Sn.medicare,code3:Sn.withheld}}function Wa(e){return Za.regex.test(e)}const I0=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,rs=1e8;function F0(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>rs&&(a=String(rs))}let l=s===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),I0.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>rs)return String(rs)}return l}return""}function Nu(e){return Wa(e)?Number.parseFloat(e):null}function D0(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 R0(e,t){return Math.abs(e-t)<.005}function O0(e,t,r,s,a){if(!Vi(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=Ws(e,t);return{subcategoryCode1:r.trim()?"1":null,subcategoryCode2:s.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const $0=["Su","Mo","Tu","We","Th","Fr","Sa"];function L0(){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 z0({value:e,onChange:t,disabled:r=!1,hasError:s=!1}){const a=Ss(e),i=Zs(),o=pu(),[l,c]=N.useState(!1),[u,d]=N.useState(()=>a??Ss(i)??new Date),m=N.useRef(null),h=N.useId();N.useEffect(()=>{a&&d(a)},[e]),N.useEffect(()=>{if(!l)return;const y=k=>{var j;(j=m.current)!=null&&j.contains(k.target)||c(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]);const f=N.useMemo(()=>x0(u.getFullYear(),u.getMonth()),[u]),b=N.useMemo(()=>{const y=new Date(u.getFullYear(),u.getMonth()-1,1),k=new Date(y.getFullYear(),y.getMonth()+1,0);return ir(k)>=i},[u,i]),p=N.useMemo(()=>{const y=new Date(u.getFullYear(),u.getMonth()+1,1);return ir(y)<=o},[u,o]),x=y=>{Ua(y)&&(t(ir(y)),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(y=>!y),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(y=>!y),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(L0,{})})]}),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:!b,onClick:()=>d(y=>new Date(y.getFullYear(),y.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:p0(u.getFullYear(),u.getMonth())}),n.jsx("button",{type:"button",disabled:!p,onClick:()=>d(y=>new Date(y.getFullYear(),y.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:$0.map(y=>n.jsx("div",{className:"py-1",children:y},y))}),n.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((y,k)=>{if(!y)return n.jsx("div",{},`empty-${k}`);const j=ir(y),w=e===j,E=!Ua(y);return n.jsx("button",{type:"button","aria-disabled":E,onClick:()=>x(y),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":w?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:y.getDate()},j)})})]}):null]})}function ns({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:X(l,i),onChange:c=>t(F0(c.target.value)),onBlur:r})}const M0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function q0(){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 V0({value:e,onChange:t,disabled:r=!1,hasError:s=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=ju(),l=ks(e),[c,u]=N.useState(!1),[d,m]=N.useState((l==null?void 0:l.year)??o),h=N.useRef(null),f=N.useId();N.useEffect(()=>{l&&m(l.year)},[e]),N.useEffect(()=>{if(!c)return;const j=w=>{var E;(E=h.current)!=null&&E.contains(w.target)||u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const b=P0(e),p=j=>!!a.includes(j),x=j=>{p(j)||(t(E0(d,j)),u(!1))},y=d>i,k=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:b,placeholder:"YYYY-MM",onClick:()=>!r&&u(j=>!j),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(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:n.jsx(q0,{})})]}),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:!y,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: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:!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: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:M0.map((j,w)=>{const E=(l==null?void 0:l.year)===d&&l.month===w&&e.length===6,F=p(w);return n.jsx("button",{type:"button","aria-disabled":F,onClick:()=>x(w),className:`rounded-lg px-2 py-2.5 text-sm transition ${F?"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 wu="Active",B0="Inactive";function yn(e){return(e.status??wu).trim().toLowerCase()==="active"}function U0(e){return yn(e)?B0:wu}function Z0(e){return yn(e)?"Deactivate":"Activate"}function Bi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function W0(e){return Bi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function Su(e){const t=O0(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),r=Ws(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 Ui(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 Zi(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 Wi="federal-payment-draft";function Yi(e){sessionStorage.setItem(Wi,JSON.stringify(e))}function Ys(){const e=sessionStorage.getItem(Wi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Hi(){sessionStorage.removeItem(Wi)}function Y0(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 H0=Bt({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=ks(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:_().min(1,"This field is required").refine(e=>xu(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:_().min(1,"This field is required").refine(e=>Wa(e),Za.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=ks(e.taxPeriod);c&&vu(e.taxFormType).includes(c.month)&&t.addIssue({code:Vr.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Vi(e.taxFormType,e.taxTypeCode))return;const r=Ws(e.taxFormType,e.taxTypeCode),s=_0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:Vr.custom,message:"This field is required",path:[u]});return}Wa(c)||t.addIssue({code:Vr.custom,message:Za.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",s);const i=Nu(e.paymentAmount),o=D0(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",s);i!==null&&!R0(i,o)&&t.addIssue({code:Vr.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),r&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Vr.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),ss="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function oa(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 K0={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function Q0(e,t){if(e)return oa(e);if(t!=null&&t.paymentDraft)return oa(t.paymentDraft);const r=Ys();return r?oa(r):K0}function ku({entity:e,initialDraft:t,readonly:r=!1,onCancel:s}){var mr,_t,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,Mr;const a=ye(),i=ge(),o=ct(),l=zr(i.state,Ze()),c=i.state,u=N.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??Ys()??null,[t,c==null?void 0:c.paymentDraft]),d=N.useRef(u==null?void 0:u.federalPaymentId),m=N.useRef(u==null?void 0:u.enrollmentId),[h,f]=N.useState(null),[b,p]=N.useState(!1),x=N.useMemo(()=>Q0(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);N.useEffect(()=>{u!=null&&u.federalPaymentId&&(d.current=u.federalPaymentId),u!=null&&u.enrollmentId&&(m.current=u.enrollmentId)},[u==null?void 0:u.federalPaymentId,u==null?void 0:u.enrollmentId]);const{data:y=[],isLoading:k}=ke({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Zn(e.entityId),enabled:e!==null}),j=N.useMemo(()=>y.filter(yn),[y]),{data:w=[],isLoading:E}=ke({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>$b(e.entityId),enabled:e!==null}),{register:F,control:P,handleSubmit:O,watch:Z,setValue:$,trigger:se,formState:{errors:V}}=St({resolver:Ct(H0),defaultValues:x}),J=Z("bankAccountDetailId"),T=Z("paymentAmount"),W=Z("taxFormType"),H=Z("taxTypeCode"),ce=Z("taxPeriod"),xe=Z("settlementDate"),$e=Z("subcategoryAmount1"),Ke=Z("subcategoryAmount2"),Xe=Z("subcategoryAmount3"),oe=N.useRef(W),Pe=N.useMemo(()=>W?vu(W):[],[W]),_e=N.useMemo(()=>Vi(W,H),[W,H]),Q=N.useMemo(()=>Ws(W,H),[W,H]),{data:Le=[],isLoading:dt}=ke({queryKey:["federal-tax-type-codes",W],queryFn:()=>Lb(W),enabled:!!W});N.useEffect(()=>{oe.current&&oe.current!==W&&$("taxTypeCode",""),oe.current=W},[W,$]),N.useEffect(()=>{if(!ce||!W)return;const q=ks(ce);q&&Pe.includes(q.month)&&$("taxPeriod","")},[W,ce,Pe,$]),N.useEffect(()=>{xe&&(xu(xe)||$("settlementDate",""))},[xe,$]),N.useEffect(()=>{if(!_e){$("subcategoryCode1",""),$("subcategoryCode2",""),$("subcategoryCode3",""),$("subcategoryAmount1",""),$("subcategoryAmount2",""),$("subcategoryAmount3","");return}const q=T0(W);$("subcategoryCode1",q.code1),$("subcategoryCode2",q.code2),$("subcategoryCode3",Q?"":q.code3),Q&&$("subcategoryAmount3","")},[_e,W,Q,$]),N.useEffect(()=>{_e&&(se("paymentAmount"),se("subcategoryAmount1"),se("subcategoryAmount2"),se("subcategoryAmount3"))},[$e,Ke,Xe,_e,se]),N.useEffect(()=>{const q=j.find(ae=>String(ae.bankAccountDetailId)===J);if(!q){J&&($("bankAccountDetailId",""),$("routingNumber",""),$("accountType",""),$("bankName",""));return}$("routingNumber",q.routingNumber),$("accountType",q.accountType),$("bankName",q.bankName)},[j,J,$]);const mt=q=>{const ae=j.find(g=>String(g.bankAccountDetailId)===q.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:q.taxpayerPin??"",secondaryTin:q.secondaryTin??"",bankAccountDetailId:q.bankAccountDetailId,routingNumber:q.routingNumber??(ae==null?void 0:ae.routingNumber)??"",accountNumber:(ae==null?void 0:ae.accountNumber)??"",accountType:q.accountType??(ae==null?void 0:ae.accountType)??"",bankName:q.bankName??(ae==null?void 0:ae.bankName)??"",taxFormType:q.taxFormType,taxTypeCode:q.taxTypeCode,taxPeriod:q.taxPeriod,settlementDate:q.settlementDate,paymentAmount:q.paymentAmount,subcategoryCode1:q.subcategoryCode1,subcategoryAmount1:q.subcategoryAmount1,subcategoryCode2:q.subcategoryCode2,subcategoryAmount2:q.subcategoryAmount2,subcategoryCode3:q.subcategoryCode3,subcategoryAmount3:q.subcategoryAmount3}},Pt=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},le=async q=>{if(!e)return null;if(q.federalPaymentId){const g=await zi(q.federalPaymentId,Zi(q));return d.current=g.federalPaymentId,m.current=g.enrollmentId,g}const ae=await Li(Ui(e.entityId,q));return d.current=ae.federalPaymentId,m.current=ae.enrollmentId,ae},Ie=O(async q=>{if(!(r||!e)){f(null),p(!0);try{const ae=mt(q),g=await le(ae);if(!g)return;const S={...ae,federalPaymentId:g.federalPaymentId,enrollmentId:g.enrollmentId};await Pt(),Yi(S),a(W0(e),{state:{from:l,paymentDraft:S}})}catch(ae){f(Ge(ae,"Failed to save payment details."))}finally{p(!1)}}}),ht=O(async q=>{if(!(!e||r)){f(null),p(!0);try{const ae=mt(q);await le(ae),await Pt(),Hi(),a(Ze())}catch(ae){f(Ge(ae,"Failed to save draft."))}finally{p(!1)}}}),Et=()=>{if(s){s();return}a(l)},yt=e?At(e):"Entity";return n.jsxs("form",{onSubmit:Ie,noValidate:!0,className:"w-full space-y-6",children:[h?n.jsx(Vt,{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:yt}),n.jsx(Yn,{entity:e,remittanceAmount:Wn(T),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(vr,{title:"Enrolment Details",isFirst:!0,children:n.jsxs("div",{className:ss,children:[n.jsx(K,{label:"Taxpayer PIN",required:!0,error:(mr=V.taxpayerPin)==null?void 0:mr.message,children:n.jsx("input",{placeholder:"Taxpayer PIN",className:X(!!V.taxpayerPin),maxLength:4,disabled:r,...F("taxpayerPin")})}),n.jsx(K,{label:"Secondary TIN",error:(_t=V.secondaryTin)==null?void 0:_t.message,children:n.jsx("input",{placeholder:"Secondary TIN",className:X(!!V.secondaryTin),maxLength:9,disabled:r,...F("secondaryTin")})}),n.jsx(Re,{name:"bankAccountDetailId",control:P,render:({field:q})=>{var ae;return n.jsx(bu,{value:q.value,onChange:q.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:j,isLoading:k,disabled:!e||r,error:(ae=V.bankAccountDetailId)==null?void 0:ae.message})}}),n.jsx(K,{label:"Routing Number",required:!0,error:(Ut=V.routingNumber)==null?void 0:Ut.message,children:n.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:X(!!V.routingNumber,!0),...F("routingNumber")})}),n.jsx(K,{label:"Account Type",required:!0,error:(Tt=V.accountType)==null?void 0:Tt.message,children:n.jsx("input",{readOnly:!0,placeholder:"Account Type",className:X(!!V.accountType,!0),...F("accountType")})}),n.jsx(K,{label:"Bank Name",required:!0,error:(It=V.bankName)==null?void 0:It.message,children:n.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:X(!!V.bankName,!0),...F("bankName")})})]})}),n.jsx(vr,{title:"Federal Payment",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:ss,children:[n.jsx(K,{label:"Tax Form Type",required:!0,error:(hr=V.taxFormType)==null?void 0:hr.message,children:n.jsxs(En,{children:[n.jsxs("select",{className:Hr(!!V.taxFormType),disabled:E||!e||r,...F("taxFormType"),children:[n.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),w.map(q=>n.jsx("option",{value:q.value,children:q.value},q.value))]}),n.jsx(Ur,{})]})}),n.jsx(K,{label:"Payment Type",required:!0,error:(Zt=V.taxTypeCode)==null?void 0:Zt.message,children:n.jsxs(En,{children:[n.jsxs("select",{className:Hr(!!V.taxTypeCode),disabled:!W||dt||r,...F("taxTypeCode"),children:[n.jsx("option",{value:"",children:W?dt?"Loading payment types…":"Select payment type":"Select tax form first"}),Le.map(q=>n.jsxs("option",{value:q.code,children:[q.code," - ",q.codeName]},q.code))]}),n.jsx(Ur,{})]})}),n.jsx(K,{label:"Tax Period",required:!0,error:(fr=V.taxPeriod)==null?void 0:fr.message,children:n.jsx(Re,{name:"taxPeriod",control:P,render:({field:q})=>n.jsx(V0,{value:q.value,onChange:q.onChange,hasError:!!V.taxPeriod,disabled:!W||r,disabledMonths:Pe})})})]}),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:(Wt=V.settlementDate)==null?void 0:Wt.message,children:n.jsx(Re,{name:"settlementDate",control:P,render:({field:q})=>n.jsx(z0,{value:q.value,onChange:q.onChange,hasError:!!V.settlementDate,disabled:r})})}),n.jsx(K,{label:"Payment Amount",required:!0,error:(Yt=V.paymentAmount)==null?void 0:Yt.message,children:n.jsx(Re,{name:"paymentAmount",control:P,render:({field:q})=>n.jsx(ns,{name:q.name,value:q.value,onChange:q.onChange,onBlur:q.onBlur,disabled:r,hasError:!!V.paymentAmount})})})]}),_e?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ss,children:[n.jsx(K,{label:"Subcategory Code 1",children:n.jsx("input",{readOnly:!0,className:X(!1,!0),...F("subcategoryCode1")})}),n.jsx(K,{label:"Subcategory Code 2",children:n.jsx("input",{readOnly:!0,className:X(!1,!0),...F("subcategoryCode2")})}),Q?null:n.jsx(K,{label:"Subcategory Code 3",children:n.jsx("input",{readOnly:!0,className:X(!1,!0),...F("subcategoryCode3")})})]}),n.jsxs("div",{className:ss,children:[n.jsx(K,{label:"Subcategory Amount 1",required:!0,error:(pr=V.subcategoryAmount1)==null?void 0:pr.message,children:n.jsx(Re,{name:"subcategoryAmount1",control:P,render:({field:q})=>n.jsx(ns,{name:q.name,value:q.value??"",onChange:q.onChange,onBlur:q.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!V.subcategoryAmount1})})}),n.jsx(K,{label:"Subcategory Amount 2",required:!0,error:(xr=V.subcategoryAmount2)==null?void 0:xr.message,children:n.jsx(Re,{name:"subcategoryAmount2",control:P,render:({field:q})=>n.jsx(ns,{name:q.name,value:q.value??"",onChange:q.onChange,onBlur:q.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!V.subcategoryAmount2})})}),Q?null:n.jsx(K,{label:"Subcategory Amount 3",required:!0,error:(Mr=V.subcategoryAmount3)==null?void 0:Mr.message,children:n.jsx(Re,{name:"subcategoryAmount3",control:P,render:({field:q})=>n.jsx(ns,{name:q.name,value:q.value??"",onChange:q.onChange,onBlur:q.onBlur,disabled:r,placeholder:"Enter amount",hasError:!!V.subcategoryAmount3})})})]})]}):null]})})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[n.jsx("button",{type:"button",onClick:Et,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:ht,disabled:!e||b,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:b?"Saving…":"Save as Draft"}),n.jsx("button",{type:"submit",disabled:!e||b,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:b?"Saving…":"Next"})]})]})]},i.key)}function Cu(){const{selectedEntity:e}=it();return n.jsx(ku,{entity:e})}function Au({mode:e}){var m;const t=ye(),{federalPaymentId:r}=ti(),{selectedEntity:s}=it(),a=Number.parseInt(r??"",10),{data:i,isLoading:o,isError:l}=ke({queryKey:["federal-payment",a],queryFn:()=>$i(a),enabled:Number.isFinite(a)}),{data:c=[]}=ke({queryKey:["bank-accounts",s==null?void 0:s.entityId],queryFn:()=>Zn(s.entityId),enabled:s!==null&&i!==void 0}),u=N.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return Y0(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(Oe,{to:Ze(),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(Oe,{to:Ze(),replace:!0});if(!s||i.entityId!==s.entityId)return n.jsx(Oe,{to:Ze(),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(Ze())})}function Pu(){return it(),n.jsx(Au,{mode:"edit"})}function Eu(){return it(),n.jsx(Au,{mode:"view"})}const J0=["Withholding Tax","Estimated Tax","Income Tax"],dl=[{code:"VA",name:"Virginia"}],G0=[{value:"Q1",label:"Q1"},{value:"Q2",label:"Q2"},{value:"Q3",label:"Q3"},{value:"Q4",label:"Q4"}];function X0(){const e=new Date().getFullYear();return[e,e-1,e-2]}const Ki="state-payment-draft";function Ya(e){sessionStorage.setItem(Ki,JSON.stringify(e))}function Ha(){const e=sessionStorage.getItem(Ki);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function _u(){sessionStorage.removeItem(Ki)}function Tu(e,t){return`${e}-${t}`}function ev(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Tu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function tv(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Tu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}const rv=Bt({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"),letterId:_().optional(),taxYear:_().min(1,"Tax year is required"),taxPeriod:_().min(1,"Tax period is required"),taxAmount:_().min(1,"Tax amount is required").refine(e=>Number.parseFloat(e)>0,"Tax amount must be greater than 0"),paymentDate:_().min(1,"Payment date is required").refine(e=>e>=Zs(),"Payment date must be a future date"),bankAccountDetailId:_().min(1,"Bank account is required"),routingNumber:_().optional(),accountType:_().optional(),bankName:_().optional()}),la="grid gap-x-6 gap-y-5 sm:grid-cols-3",ml="grid gap-x-6 gap-y-5 sm:grid-cols-2",hl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",fl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function ca(e){return{state:e.state,reasonForPayment: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 Iu({entity:e,initialDraft:t,readonly:r=!1,onCancel:s}){var ce,xe,$e,Ke,Xe,oe,Pe,_e;const a=ye(),i=ge(),o=zr(i.state,Ze()),l=i.state,c=N.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??Ha()??null,[t,l==null?void 0:l.paymentDraft]),u=N.useRef(c==null?void 0:c.statePaymentDetailId),d=N.useMemo(()=>{if(t)return ca(t);if(l!=null&&l.paymentDraft)return ca(l.paymentDraft);if(l!=null&&l.resetDraft)return _u(),fl;const Q=Ha();return Q?ca(Q):fl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),m=N.useMemo(()=>X0(),[]),h=Zs(),{data:f=[],isLoading:b}=ke({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Zn(e.entityId),enabled:e!==null}),p=N.useMemo(()=>f.filter(yn),[f]),{register:x,control:y,handleSubmit:k,watch:j,setValue:w,formState:{errors:E}}=St({resolver:Ct(rv),defaultValues:d}),F=j("state"),P=j("reasonForPayment"),O=j("taxAmount"),Z=j("bankAccountDetailId"),$=!!(F&&P),[se,V]=N.useState(!1),J=(ce=dl.find(Q=>Q.code===F))==null?void 0:ce.name;N.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(u.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),N.useEffect(()=>{if(r)return;const Q=p.find(Le=>String(Le.bankAccountDetailId)===Z);if(!Q){Z&&(w("bankAccountDetailId",""),w("routingNumber",""),w("accountType",""),w("bankName",""));return}w("routingNumber",Q.routingNumber),w("accountType",Q.accountType),w("bankName",Q.bankName)},[p,Z,w,r]);const T=k(Q=>{if(r)return;const Le={statePaymentDetailId:u.current,state:Q.state,reasonForPayment:Q.reasonForPayment,stateAccountId:Q.stateAccountId,accountId:Q.accountId,letterId:Q.letterId,taxYear:Q.taxYear,taxPeriod:Q.taxPeriod,taxAmount:Q.taxAmount,paymentDate:Q.paymentDate,bankAccountDetailId:Q.bankAccountDetailId,routingNumber:Q.routingNumber,accountType:Q.accountType,bankName:Q.bankName};Ya(Le),a("/payments/state/authorization",{state:{from:o,paymentDraft:Le}})}),W=()=>{if(s){s();return}a(o)},H=e?At(e):"Entity";return n.jsx("form",{onSubmit:T,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:H}),n.jsx(Yn,{entity:e,remittanceAmount:Wn(O),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:hl,children:[n.jsx(pl,{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,onClick:()=>V(Q=>!Q),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(nv,{})}),n.jsxs("span",{children:[n.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:J??"Choose a state"}),n.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),n.jsx(Ur,{className:`h-4 w-4 text-slate-400 transition ${se?"rotate-180":""}`})]}),se?n.jsx("div",{className:"absolute left-0 right-0 z-20 mt-2 max-h-64 overflow-y-auto rounded-xl border border-slate-200 bg-white shadow-lg",children:dl.map(Q=>n.jsxs("button",{type:"button",onClick:()=>{w("state",Q.code,{shouldValidate:!0}),V(!1)},className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${F===Q.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[n.jsx("span",{children:Q.name}),n.jsx("span",{className:"text-xs font-medium text-slate-400",children:Q.code})]},Q.code))}):null,E.state?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:E.state.message}):null]}),n.jsx(K,{label:"Reason for Payment",required:!0,error:(xe=E.reasonForPayment)==null?void 0:xe.message,children:n.jsxs(En,{children:[n.jsxs("select",{disabled:r,className:Hr(!!E.reasonForPayment),...x("reasonForPayment"),children:[n.jsx("option",{value:"",children:"Select reason"}),J0.map(Q=>n.jsx("option",{value:Q,children:Q},Q))]}),n.jsx(Ur,{})]})})]})]}),n.jsxs("section",{className:`${hl} transition ${$?"":"opacity-60"}`,children:[n.jsx(pl,{step:2,title:"Payment Form",className:"mb-5"}),n.jsxs("fieldset",{disabled:!$||r,className:"min-w-0 border-0 p-0",children:[n.jsx(ua,{title:"Payment Details",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:la,children:[n.jsx(K,{label:"State ID",required:!0,error:($e=E.stateAccountId)==null?void 0:$e.message,children:n.jsx("input",{placeholder:"Enter ID",className:X(!!E.stateAccountId),...x("stateAccountId")})}),n.jsx(K,{label:"Account ID",required:!0,error:(Ke=E.accountId)==null?void 0:Ke.message,children:n.jsx("input",{placeholder:"123456789-WHW",className:X(!!E.accountId),...x("accountId")})}),n.jsx(K,{label:"Letter ID",children:n.jsx("input",{placeholder:"123456789-WHW",className:X(),...x("letterId")})})]}),n.jsxs("div",{className:ml,children:[n.jsx(K,{label:"Tax Year",required:!0,error:(Xe=E.taxYear)==null?void 0:Xe.message,children:n.jsxs(En,{children:[n.jsxs("select",{className:Hr(!!E.taxYear),...x("taxYear"),children:[n.jsx("option",{value:"",children:"Select TY"}),m.map(Q=>n.jsxs("option",{value:String(Q),children:["TY ",Q]},Q))]}),n.jsx(Ur,{})]})}),n.jsx(K,{label:"Tax Period",required:!0,error:(oe=E.taxPeriod)==null?void 0:oe.message,children:n.jsxs(En,{children:[n.jsxs("select",{className:Hr(!!E.taxPeriod),...x("taxPeriod"),children:[n.jsx("option",{value:"",children:"Select"}),G0.map(Q=>n.jsx("option",{value:Q.value,children:Q.label},Q.value))]}),n.jsx(Ur,{})]})})]})]})}),n.jsx(ua,{title:"Amount Info",children:n.jsxs("div",{className:ml,children:[n.jsx(K,{label:"Tax Amount",required:!0,error:(Pe=E.taxAmount)==null?void 0:Pe.message,children:n.jsx("input",{type:"number",step:"0.01",min:"0",placeholder:"0.00",className:X(!!E.taxAmount),...x("taxAmount")})}),n.jsx(K,{label:"Payment Date",required:!0,error:(_e=E.paymentDate)==null?void 0:_e.message,children:n.jsx("input",{type:"date",min:h,className:X(!!E.paymentDate),...x("paymentDate")})})]})}),n.jsx(ua,{title:"Bank Account",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{className:la,children:[n.jsx(Re,{name:"bankAccountDetailId",control:y,render:({field:Q})=>{var Le;return n.jsx(bu,{value:Q.value,onChange:Q.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:p,isLoading:b,disabled:!e||!$||r,error:(Le=E.bankAccountDetailId)==null?void 0:Le.message,label:"Account Number"})}}),n.jsx(K,{label:"Routing Number",required:!0,children:n.jsx("input",{readOnly:!0,placeholder:"9-digit",className:X(!1,!0),...x("routingNumber")})}),n.jsx(K,{label:"Account Type",required:!0,children:n.jsx("input",{readOnly:!0,placeholder:"Select",className:X(!1,!0),...x("accountType")})})]}),n.jsx("div",{className:la,children:n.jsx(K,{label:"Bank Name",children:n.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:X(!1,!0),...x("bankName")})})})]})})]}),$?null:n.jsx("p",{className:"mt-4 text-sm text-slate-500",children:"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:W,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||!$,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(sv,{})]})]})]})})]})},i.key)}function pl({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 ua({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 nv(){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 sv(){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}=it();return n.jsx(Iu,{entity:e})}function av(e){const t=e.indexOf("-");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function Du(){var c;const{statePaymentId:e}=ti(),{selectedEntity:t}=it(),r=Number.parseInt(e??"",10),{data:s=[],isLoading:a,isError:i}=ke({queryKey:["state-payments",t==null?void 0:t.entityId],queryFn:()=>Mi(t.entityId),enabled:t!==null&&Number.isFinite(r)}),o=s.find(u=>u.statePaymentDetailId===r)??null,l=N.useMemo(()=>{if(!o)return null;const[u,d]=av(o.taxPeriod);return{statePaymentDetailId:o.statePaymentDetailId,state:o.state,reasonForPayment:"",stateAccountId:"",accountId:"",taxYear:u,taxPeriod:d,taxAmount:String(o.taxAmount),paymentDate:o.paymentDate,bankAccountDetailId:""}},[o]);return Number.isFinite(r)?a?n.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!o||!l?n.jsx(Oe,{to:Ze(),replace:!0}):!t||o.entityId!==t.entityId?n.jsx(Oe,{to:Ze(),replace:!0}):((c=o.status)==null?void 0:c.toLowerCase())!=="draft"?n.jsx(Oe,{to:`/payments/state/${r}/view`,replace:!0}):n.jsx(Iu,{entity:t,initialDraft:l}):n.jsx(Oe,{to:Ze(),replace:!0})}function Ru(){var c,u;const{statePaymentId:e}=ti(),t=ye(),{selectedEntity:r}=it(),s=Number.parseInt(e??"",10),{data:a=[],isLoading:i,isError:o}=ke({queryKey:["state-payments",r==null?void 0:r.entityId],queryFn:()=>Mi(r.entityId),enabled:r!==null&&Number.isFinite(s)}),l=a.find(d=>d.statePaymentDetailId===s)??null;return Number.isFinite(s)?i?n.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!l?n.jsx(Oe,{to:"/payments",replace:!0}):!r||l.entityId!==r.entityId?n.jsx(Oe,{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-",l.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:l.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:l.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:Un(l.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:l.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 ${((c=l.status)==null?void 0:c.toLowerCase())==="paid"?"bg-green-100 text-green-800":((u=l.status)==null?void 0:u.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:l.status??"—"})})]}),l.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:l.reason})]})]})})]}):n.jsx(Oe,{to:"/payments",replace:!0})}const iv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",ov="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 Qi=_().min(1,"Signature is required").regex(Ou,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),lv=_().optional().refine(e=>!e||!e.trim()||Ou.test(e),{message:"Signature must contain only letters"}),cv=Bt({agreementDate:_().min(1,"Date is required"),agreementAccepted:Wr().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:_().min(1,"Name of authorization person is required"),signature:Qi,title:_().min(1,"Title is required")}),uv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",as="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function dv(e){const[t,r,s]=e.split("-");return!t||!r||!s?e:`${r}/${s}/${t}`}function mv(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function hv({entity:e,paymentDraft:t}){const r=ye(),s=ge(),a=ct(),i=zr(s.state,Ze()),[o,l]=N.useState(null),[c,u]=N.useState(!1),d=N.useMemo(()=>mv(),[]),m=Wn(t.taxAmount),{register:h,handleSubmit:f,watch:b,formState:{errors:p}}=St({resolver:Ct(cv),defaultValues:d}),x=b("agreementDate"),y=b("signature"),k=!!(y!=null&&y.trim()),j=h("signature"),w=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 $=await Zb(t.statePaymentDetailId,tv(t));return await w(),$}const Z=await Ub(ev(e.entityId,t));return Ya({...t,statePaymentDetailId:Z.statePaymentDetailId}),await w(),Z},F=async()=>{e&&(await E(),_u(),r(Ze()))},P=f(async()=>{if(e){l(null),u(!0);try{await F()}catch(Z){l(Ge(Z,"Failed to save state payment."))}finally{u(!1)}}}),O=f(async()=>{if(e){l(null),u(!0);try{await F()}catch(Z){l(Ge(Z,"Failed to save draft."))}finally{u(!1)}}});return n.jsx("form",{onSubmit:P,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(Yn,{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:uv,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:`${as} 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:dv(x)}),n.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),n.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:iv}),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:ov})]}),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:`${as} 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:`${as} 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 ${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:Z=>{const $=$u(Z.target.value);Z.target.value=$,j.onChange(Z)}}),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:`${as} 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(Vt,{message:o})}):null,n.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[n.jsx("button",{type:"button",onClick:()=>{Ya(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:O,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}=it(),t=ge(),{paymentDraft:r}=t.state??{},s=r??Ha();return s?n.jsx(hv,{entity:e,paymentDraft:s}):n.jsx(Oe,{to:"/payments/state/new",replace:!0})}const Ji="/portal/federal-payments/form-8655-authorizations";function fv(e){return fe(Ji,{method:"POST",body:e})}function pv(e){return fe(`${Ji}/by-enrolment/${e}`)}function xv(e,t){return fe(`${Ji}/${e}`,{method:"PATCH",body:t})}async function zu(e){try{return await pv(e)}catch(t){if(t instanceof xn&&t.status===404)return null;throw t}}const Ka=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function gv(e){const t=e.trim();return Ka.includes(t)?t:"Other"}const yv="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.",bv="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 vv(e){const[t,r,s]=e.split("-");return!t||!r||!s?e:`${r}/${s}/${t}`}function Qa({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:b}=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:b,name:f,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${d?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:d?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:p=>{const x=$u(p.target.value);p.target.value=x,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:vv(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 jv(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:jv(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 Nv(e){const{enrollmentId:t,...r}=Mu(0,e);return r}function wv(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:dr(e.ein),address:e.address,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,isSeasonalEmployer:e.isSeasonalEmployer,otherIdentificationNumber:e.otherIdentificationNumber??"",contactPerson:e.contactPerson,daytimePhone:Dr(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const Sv=Bt({taxpayerName:_().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:Wr(),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:Wr().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:Qi,title:_().min(1,"Title is required"),signatureDate:_().min(1,"Date is required")}),da="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function kv(e,t){const r=new Date().toISOString().slice(0,10);return{taxpayerName:e?At(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.firstName)||"",ein:e?dr(e.idNumber):"",address:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",isSeasonalEmployer:!1,otherIdentificationNumber:"",contactPerson:e?`${e.firstName} ${e.lastName}`.trim():"",daytimePhone:e?Dr(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:gv(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:r}}function Cv({entity:e,paymentDraft:t,initialAuthorization:r=null,readonly:s=!1}){var H,ce,xe,$e,Ke,Xe,oe,Pe,_e,Q,Le,dt,mt,Pt;const a=ye(),i=ge(),o=ct(),l=zr(i.state,Ze()),c=Wn(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),f=N.useMemo(()=>r?wv(r):kv(e,t),[e,r,t]),{register:b,handleSubmit:p,watch:x,setValue:y,reset:k,formState:{errors:j}}=St({resolver:Ct(Sv),defaultValues:f});N.useEffect(()=>{k(f)},[f,k]);const w=x("authorizedTaxForm"),E=x("signature"),F=x("signatureDate"),P=e?At(e):"Entity",O=!0,Z=!0,$=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 Ie=await zi(t.federalPaymentId,Zi(t));return await $(),Ie}const le=await Li(Ui(e.entityId,t));return Yi({...t,federalPaymentId:le.federalPaymentId,enrollmentId:le.enrollmentId}),await $(),le},V=async(le,Ie)=>{var yt;const ht=t.form8655AuthorizationId??((yt=await zu(le))==null?void 0:yt.form8655AuthorizationId),Et=Ie;return ht?xv(ht,Nv(Et)):fv(Mu(le,Et))},J=async le=>{if(!e)return;const Ie=await se();Ie&&(await V(Ie.enrollmentId,le),await o.invalidateQueries({queryKey:["form-8655",Ie.enrollmentId]}),Hi(),a(Ze()))},T=p(async le=>{if(!(!e||s)){d(null),h(!0);try{await J(le)}catch(Ie){d(Ge(Ie,"Failed to save federal payment draft."))}finally{h(!1)}}}),W=p(async le=>{if(!(!e||s)){d(null),h(!0);try{await J(le)}catch(Ie){d(Ge(Ie,"Failed to save draft."))}finally{h(!1)}}});return n.jsxs("form",{onSubmit:T,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:P}),n.jsx(Yn,{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:da,children:[n.jsx(K,{label:"1. a) Name of the Taxpayer",required:!0,error:(H=j.taxpayerName)==null?void 0:H.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:O,className:X(!!j.taxpayerName,O),...b("taxpayerName")})}),n.jsx(K,{label:"1. b) Trade Name, if any",required:!0,error:(ce=j.tradeName)==null?void 0:ce.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:O,className:X(!!j.tradeName,O),...b("tradeName")})}),n.jsx(K,{label:"2. Employer Identification Number (EIN)",required:!0,error:(xe=j.ein)==null?void 0:xe.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:O,className:X(!!j.ein,O),...b("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:($e=j.address)==null?void 0:$e.message,children:n.jsx("input",{placeholder:"Enter",readOnly:O,className:X(!!j.address,O),...b("address")})})}),n.jsx(K,{label:"3. b) City or Town",required:!0,error:(Ke=j.city)==null?void 0:Ke.message,children:n.jsx("input",{placeholder:"Enter",readOnly:O,className:X(!!j.city,O),...b("city")})})]}),n.jsxs("div",{className:`mt-5 ${da}`,children:[n.jsx(K,{label:"3. c) State",required:!0,error:(Xe=j.state)==null?void 0:Xe.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:O,className:X(!!j.state,O),...b("state")})}),n.jsx(K,{label:"3. d) ZIP Code",required:!0,error:(oe=j.zipCode)==null?void 0:oe.message,children:n.jsx("input",{placeholder:"Enter",readOnly:O,className:X(!!j.zipCode,O),...b("zipCode")})}),n.jsx(K,{label:"3. e) Country",required:!0,error:(Pe=j.country)==null?void 0:Pe.message,children:n.jsx("input",{placeholder:"Enter",readOnly:O,className:X(!!j.country,O),...b("country")})})]}),n.jsxs("div",{className:`mt-5 ${da}`,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",...b("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:O,className:X(!1,O),...b("otherIdentificationNumber")})}),n.jsx(K,{label:"6. Contact Person",required:!0,error:(_e=j.contactPerson)==null?void 0:_e.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:O,className:X(!!j.contactPerson,O),...b("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:(Q=j.daytimePhone)==null?void 0:Q.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:O,className:X(!!j.daytimePhone,O),...b("daytimePhone")})}),n.jsx(K,{label:"8. Fax Number",error:(Le=j.faxNumber)==null?void 0:Le.message,children:n.jsx("input",{placeholder:"Enter number",className:X(!!j.faxNumber),...b("faxNumber")})})]})]}),n.jsxs(vr,{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:Ka.slice(0,6).map(le=>n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:le,checked:w===le,disabled:Z,onChange:()=>y("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))}),n.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:Ka.slice(6).map(le=>n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:le,checked:w===le,disabled:Z,onChange:()=>y("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))})]}),j.authorizedTaxForm?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.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",...b("agreementAccepted")}),n.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[n.jsx("span",{className:"font-semibold text-slate-900",children:yv})," ",bv]})]}),j.agreementAccepted?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:j.agreementAccepted.message}):null]})]}),n.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:n.jsx(Qa,{label:"Taxpayer's Signature",required:!0,signature:b("signature"),title:b("title"),date:b("signatureDate"),signatureValue:E,dateValue:F,errors:{signature:(dt=j.signature)==null?void 0:dt.message,title:(mt=j.title)==null?void 0:mt.message,date:(Pt=j.signatureDate)==null?void 0:Pt.message}})})]})})]}),u?n.jsx("div",{className:"lg:mr-[324px]",children:n.jsx(Vt,{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:W,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}=it(),t=ge(),{paymentDraft:r}=t.state??{},s=r??Ys(),{data:a,isLoading:i}=ke({queryKey:["federal-payment",s==null?void 0:s.federalPaymentId],queryFn:()=>$i(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}=ke({queryKey:["form-8655",o],queryFn:()=>zu(o),enabled:o!=null}),u=N.useMemo(()=>s?{...s,enrollmentId:o??s.enrollmentId,form8655AuthorizationId:s.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[s,o,l]);return s?Bi(e)?n.jsx(Oe,{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(Cv,{entity:e,paymentDraft:u??s,initialAuthorization:l}):n.jsx(Oe,{to:"/payments/federal/new",replace:!0})}const Gi="/portal/federal-payments/form-9783-enrollments";function Av(e){return fe(Gi,{method:"POST",body:e})}function Pv(e){return fe(`${Gi}/by-enrolment/${e}`)}function Ev(e,t){return fe(`${Gi}/${e}`,{method:"PATCH",body:t})}async function Vu(e){try{return await Pv(e)}catch(t){if(t instanceof xn&&t.status===404)return null;throw t}}const _v="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.",Tv="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.",Iv="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.",ma=new Date().getFullYear(),Fv=[String(ma-1),String(ma-2),String(ma-3)];function is(e){return e.replace(/\D/g,"")}function Bu(e,t){var r,s,a,i;return{enrollmentId:e,primarySsn:is(t.primarySsn),jointFilerSsn:t.jointFilerSsn?is(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:is(t.financialPrimarySsn),routingTransitNumber:is(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 Dv(e){const{enrollmentId:t,...r}=Bu(0,e);return r}function Rv(e){var r;const t=((r=e.accountType)==null?void 0:r.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:Dr(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Dr(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",financialPrimarySsn:e.financialPrimarySsn,routingTransitNumber:e.routingTransitNumber,accountNumber:e.accountNumber,accountType:t,disclosureAgreementOne:e.disclosureAgreementOne,disclosureAgreementTwo:e.disclosureAgreementTwo,authorityAgreement:e.authorityAgreement,taxpayerSignature:e.taxpayerSignature??"",taxpayerTitle:e.taxpayerTitle,taxpayerSignatureDate:e.taxpayerSignatureDate,jointFilerSignature:e.jointFilerSignature??"",jointFilerTitle:e.jointFilerTitle??"",jointFilerSignatureDate:e.jointFilerSignatureDate??""}}const Ov=Bt({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=>h0(e,Uu),{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:eu([ta("Checking"),ta("Savings"),ta("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Wr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Wr().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Wr().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:Qi,taxpayerTitle:_().min(1,"Title is required"),taxpayerSignatureDate:_().min(1,"Date is required"),jointFilerSignature:lv,jointFilerTitle:_().optional(),jointFilerSignatureDate:_().optional()}),gr="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",$v="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",Lv=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 zv(e,t){const r=new Date().toISOString().slice(0,10),s=e?At(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?Dr(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 Mv({entity:e,paymentDraft:t,initialEnrollment:r=null,readonly:s=!1}){var Et,yt,mr,_t,Ut,Tt,It,hr,Zt,fr,Wt,Yt,pr,xr,Mr,q,ae,g,S,C,D,R,U,L,Y;const a=ye(),i=ge(),o=ct(),l=zr(i.state,Ze()),c=Wn(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),[f,b]=N.useState(!1),{data:p=[]}=ke({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:()=>Zn(e.entityId),enabled:(e==null?void 0:e.entityId)!=null}),x=N.useMemo(()=>{if(r)return Rv(r);const z=p.find(Fe=>String(Fe.bankAccountDetailId)===t.bankAccountDetailId),re=Wu(e,t);return{...zv(e,t),financialPrimarySsn:re.financialPrimarySsn,routingTransitNumber:re.routingTransitNumber||(z==null?void 0:z.routingNumber)||"",accountNumber:re.accountNumber||(z==null?void 0:z.accountNumber)||"",accountType:Zu(t.accountType||(z==null?void 0:z.accountType))}},[e,r,t,p]),{register:y,handleSubmit:k,watch:j,setValue:w,reset:E,control:F,formState:{errors:P}}=St({resolver:Ct(Ov),defaultValues:x});N.useEffect(()=>{E(x)},[x,E]);const O=j("taxpayerSignature"),Z=j("jointFilerSignature"),$=j("taxpayerSignatureDate"),se=j("jointFilerSignatureDate"),V=j("accountType"),J=j("taxpayerNames"),T=j("primaryAddress"),W=j("city"),H=j("state"),ce=j("zipCode"),xe=j("country"),$e=j("primaryPhone"),Ke=j("internationalAddress"),Xe=e?At(e):"Entity",oe=!0,Pe=!0,_e=N.useMemo(()=>m0(Uu),[]),Q=()=>{w("primaryContactName",J,{shouldValidate:!0}),w("primaryContactAddress",T,{shouldValidate:!0}),w("contactCity",W,{shouldValidate:!0}),w("contactState",H,{shouldValidate:!0}),w("contactZipCode",ce,{shouldValidate:!0}),w("contactCountry",xe,{shouldValidate:!0}),w("contactPhone",$e,{shouldValidate:!0}),w("contactInternationalAddress",Ke??"",{shouldValidate:!0})},Le=()=>{w("primaryContactName","",{shouldValidate:!0}),w("primaryContactAddress","",{shouldValidate:!0}),w("contactCity","",{shouldValidate:!0}),w("contactState","",{shouldValidate:!0}),w("contactZipCode","",{shouldValidate:!0}),w("contactCountry","",{shouldValidate:!0}),w("contactPhone","",{shouldValidate:!0}),w("contactInternationalAddress","",{shouldValidate:!0})};N.useEffect(()=>{f&&Q()},[f,J,T,W,H,ce,xe,$e,Ke]);const dt=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},mt=async()=>{if(!e)return null;if(t.federalPaymentId){const re=await zi(t.federalPaymentId,Zi(t));return await dt(),re}const z=await Li(Ui(e.entityId,t));return Yi({...t,federalPaymentId:z.federalPaymentId,enrollmentId:z.enrollmentId}),await dt(),z},Pt=async(z,re)=>{var Ft;const Fe=t.form9783EnrollmentId??((Ft=await Vu(z))==null?void 0:Ft.form9783EnrollmentId);return Fe?Ev(Fe,Dv(re)):Av(Bu(z,re))},le=async z=>{if(!e)return;const re=await mt();re&&(await Pt(re.enrollmentId,z),await o.invalidateQueries({queryKey:["form-9783",re.enrollmentId]}),Hi(),a(Ze()))},Ie=k(async z=>{if(!(!e||s)){d(null),h(!0);try{await le(z)}catch(re){d(Ge(re,"Failed to save federal payment draft."))}finally{h(!1)}}}),ht=k(async z=>{if(!(!e||s)){d(null),h(!0);try{await le(z)}catch(re){d(Ge(re,"Failed to save draft."))}finally{h(!1)}}});return n.jsxs("form",{onSubmit:Ie,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:Xe}),n.jsx(Yn,{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(vr,{title:"1. Taxpayer Information",isFirst:!0,children:[n.jsxs("div",{className:gr,children:[n.jsx(K,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(Et=P.primarySsn)==null?void 0:Et.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:oe,className:X(!!P.primarySsn,oe),...y("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:X(!1,oe),...y("jointFilerSsn")})}),n.jsx(K,{label:"2. Taxpayer(S) name(S)",required:!0,error:(yt=P.taxpayerNames)==null?void 0:yt.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:oe,className:X(!!P.taxpayerNames,oe),...y("taxpayerNames")})})]}),n.jsxs("div",{className:`mt-5 ${gr}`,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:(mr=P.primaryAddress)==null?void 0:mr.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:X(!!P.primaryAddress,oe),...y("primaryAddress")})})}),n.jsx(K,{label:"3. b) City or Town",required:!0,error:(_t=P.city)==null?void 0:_t.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:X(!!P.city,oe),...y("city")})})]}),n.jsxs("div",{className:`mt-5 ${gr}`,children:[n.jsx(K,{label:"3. c) State",required:!0,error:(Ut=P.state)==null?void 0:Ut.message,children:n.jsx("input",{placeholder:"Enter name",readOnly:oe,className:X(!!P.state,oe),...y("state")})}),n.jsx(K,{label:"3. d) ZIP code",required:!0,error:(Tt=P.zipCode)==null?void 0:Tt.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:X(!!P.zipCode,oe),...y("zipCode")})}),n.jsx(K,{label:"3. e) Country",required:!0,error:(It=P.country)==null?void 0:It.message,children:n.jsx("input",{placeholder:"Enter",readOnly:oe,className:X(!!P.country,oe),...y("country")})})]}),n.jsxs("div",{className:`mt-5 ${gr}`,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:X(!1,oe),...y("internationalAddress")})})}),n.jsx(K,{label:"4. Primary taxpayer phone number",required:!0,error:(hr=P.primaryPhone)==null?void 0:hr.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:oe,className:X(!!P.primaryPhone,oe),...y("primaryPhone")})})]})]}),n.jsxs(vr,{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:z=>{const re=z.target.checked;b(re),re?Q():Le()},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:gr,children:[n.jsx(K,{label:"5. Primary contact name",required:!0,error:(Zt=P.primaryContactName)==null?void 0:Zt.message,children:n.jsx("input",{placeholder:"Payer Name",readOnly:f,className:X(!!P.primaryContactName,f),...y("primaryContactName")})}),n.jsx(K,{label:"6. a) Primary contact address",required:!0,error:(fr=P.primaryContactAddress)==null?void 0:fr.message,children:n.jsx("input",{placeholder:"Payer Address",readOnly:f,className:X(!!P.primaryContactAddress,f),...y("primaryContactAddress")})}),n.jsx(K,{label:"6. b) City or Town",required:!0,error:(Wt=P.contactCity)==null?void 0:Wt.message,children:n.jsx("input",{placeholder:"City",readOnly:f,className:X(!!P.contactCity,f),...y("contactCity")})})]}),n.jsxs("div",{className:`mt-5 ${gr}`,children:[n.jsx(K,{label:"6. c) State",required:!0,error:(Yt=P.contactState)==null?void 0:Yt.message,children:n.jsx("input",{placeholder:"Payer State",readOnly:f,className:X(!!P.contactState,f),...y("contactState")})}),n.jsx(K,{label:"6. d) ZIP code",required:!0,error:(pr=P.contactZipCode)==null?void 0:pr.message,children:n.jsx("input",{placeholder:"ZIP code",readOnly:f,className:X(!!P.contactZipCode,f),...y("contactZipCode")})}),n.jsx(K,{label:"6. f) Country",required:!0,error:(xr=P.contactCountry)==null?void 0:xr.message,children:n.jsx("input",{placeholder:"Country",readOnly:f,className:X(!!P.contactCountry,f),...y("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:(Mr=P.contactPhone)==null?void 0:Mr.message,children:n.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:X(!!P.contactPhone,f),...y("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:X(!1,f),...y("contactInternationalAddress")})})})]})]}),n.jsx(vr,{title:"Taxpayer Details *",children:n.jsxs("div",{className:$v,children:[n.jsx(K,{label:"1. Primary Taxpayer Pin",required:!0,error:(q=P.primaryTaxpayerPin)==null?void 0:q.message,children:n.jsx(Re,{name:"primaryTaxpayerPin",control:F,render:({field:z})=>n.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:X(!!P.primaryTaxpayerPin),value:z.value,onChange:re=>z.onChange(Yr(re.target.value,Lv)),onBlur:z.onBlur})})}),n.jsx(K,{label:"2. Date of Birth",required:!0,error:(ae=P.dateOfBirth)==null?void 0:ae.message,children:n.jsx("input",{type:"date",max:_e,className:X(!!P.dateOfBirth),...y("dateOfBirth")})}),n.jsx(K,{label:"3. Prior year adjusted gross income",required:!0,error:(g=P.priorYearAgi)==null?void 0:g.message,children:n.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:X(!!P.priorYearAgi),...y("priorYearAgi")})}),n.jsx(K,{label:"4. Prior Tax Year",required:!0,error:(S=P.agiTaxYear)==null?void 0:S.message,children:n.jsxs("select",{className:Hr(!!P.agiTaxYear),...y("agiTaxYear"),children:[n.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),Fv.map(z=>n.jsx("option",{value:z,children:z},z))]})})]})}),n.jsxs(vr,{title:"3. Social Security Number and Financial Institution Information",children:[n.jsxs("div",{className:gr,children:[n.jsx(K,{label:"9. Primary SSN",required:!0,error:(C=P.financialPrimarySsn)==null?void 0:C.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:Pe,className:X(!!P.financialPrimarySsn,Pe),...y("financialPrimarySsn")})}),n.jsx(K,{label:"10. Routing Transit Number (RTN)",required:!0,error:(D=P.routingTransitNumber)==null?void 0:D.message,children:n.jsx("input",{placeholder:"Enter number",readOnly:Pe,className:X(!!P.routingTransitNumber,Pe),...y("routingTransitNumber")})}),n.jsx(K,{label:"11. Account Number",required:!0,error:(R=P.accountNumber)==null?void 0:R.message,children:n.jsx("input",{placeholder:"Enter",readOnly:Pe,className:X(!!P.accountNumber,Pe),...y("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(z=>n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:z,checked:V===z,disabled:Pe,onChange:()=>w("accountType",z,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),z]},z))}),P.accountType?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.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",...y("disclosureAgreementOne")}),n.jsx("span",{className:"text-sm leading-6 text-slate-700",children:_v})]}),P.disclosureAgreementOne?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.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",...y("disclosureAgreementTwo")}),n.jsx("span",{className:"text-sm leading-6 text-slate-700",children:Tv})]}),P.disclosureAgreementTwo?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.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",...y("authorityAgreement")}),n.jsx("span",{className:"text-sm leading-6 text-slate-700",children:Iv})]}),P.authorityAgreement?n.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.authorityAgreement.message}):null]})]})]}),n.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[n.jsx(Qa,{label:"Taxpayer's Signature",required:!0,signature:y("taxpayerSignature"),title:y("taxpayerTitle"),date:y("taxpayerSignatureDate"),signatureValue:O,dateValue:$,errors:{signature:(U=P.taxpayerSignature)==null?void 0:U.message,title:(L=P.taxpayerTitle)==null?void 0:L.message,date:(Y=P.taxpayerSignatureDate)==null?void 0:Y.message}}),n.jsx(Qa,{label:"Joint filer(s) Signature (Optional)",signature:y("jointFilerSignature"),title:y("jointFilerTitle"),date:y("jointFilerSignatureDate"),signatureValue:Z??"",dateValue:se??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?n.jsx("div",{className:"lg:mr-[324px]",children:n.jsx(Vt,{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:ht,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}=it(),t=ge(),{paymentDraft:r}=t.state??{},s=r??Ys(),{data:a,isLoading:i}=ke({queryKey:["federal-payment",s==null?void 0:s.federalPaymentId],queryFn:()=>$i(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}=ke({queryKey:["form-9783",o],queryFn:()=>Vu(o),enabled:o!=null}),u=N.useMemo(()=>s?{...s,enrollmentId:o??s.enrollmentId,form9783EnrollmentId:s.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[s,o,l]);return s?e&&!Bi(e)?n.jsx(Oe,{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(Mv,{entity:e,paymentDraft:u??s,initialEnrollment:l}):n.jsx(Oe,{to:"/payments/federal/new",replace:!0})}function qv(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Vv({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 Bv({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 Uv({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(Zv,{className:"h-4 w-4"})}),s.fileName]})}),n.jsx("td",{className:"px-6 py-4",children:n.jsx(Vv,{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(Bv,{status:s.status})}),n.jsx("td",{className:"px-6 py-4 text-slate-600",children:qv(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 Zv({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 Wv(){return n.jsx(Uv,{})}const xl=160,Yv=88,os=8;function Hv({account:e,entityId:t,onEdit:r}){const s=ct(),{showSuccess:a,showError:i}=Fs(),o=N.useRef(null),l=N.useRef(null),[c,u]=N.useState(!1),[d,m]=N.useState(!1),[h,f]=N.useState({}),b=()=>{var E;const x=o.current;if(!x)return;const y=x.getBoundingClientRect(),k=((E=l.current)==null?void 0:E.offsetHeight)??Yv,w=window.innerHeight-y.bottom<k+os;f({position:"fixed",top:w?y.top-k-os:y.bottom+os,left:Math.max(os,y.right-xl),width:xl,zIndex:50})};N.useLayoutEffect(()=>{c&&(b(),requestAnimationFrame(b))},[c]),N.useEffect(()=>{if(!c)return;const x=k=>{var w,E;const j=k.target;(w=o.current)!=null&&w.contains(j)||(E=l.current)!=null&&E.contains(j)||u(!1)},y=()=>b();return document.addEventListener("mousedown",x),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[c]);const p=async()=>{const x=yn(e);m(!0);try{await du(e.bankAccountDetailId,{status:U0(e)}),await s.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),x?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(y){i("Action Not Completed",Ge(y,"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(x=>!x),className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:["Actions",n.jsx(Kv,{})]}),c?As.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:Z0(e)})]}),document.body):null]})}function Kv(){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"],Qv=Bt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dn} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Bs(Hu,{message:"Account type is required"}),bankName:_().min(1,"Bank name is required")});function Jv({open:e,account:t,onClose:r}){const s=ct(),{showSuccess:a,showError:i}=Fs(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=St({resolver:Ct(Qv),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});N.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),N.useEffect(()=>{if(!e)return;const p=x=>{x.key==="Escape"&&r()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,r]);const b=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(x){const y=Ge(x,"Unable to update bank account.");l(y),i("Action Not Completed",y)}finally{u(!1)}}});return!e||!t?null:As.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(),b(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(Vt,{message:o})}):null,n.jsxs(lr,{title:"Bank Account",children:[n.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[n.jsx(Re,{name:"accountNumber",control:d,render:({field:p})=>{var x;return n.jsx(me,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:y=>p.onChange(Yr(y.target.value,dn)),onBlur:p.onBlur,error:(x=f.accountNumber)==null?void 0:x.message})}}),n.jsx(Re,{name:"routingNumber",control:d,render:({field:p})=>{var x;return n.jsx(me,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:y=>p.onChange(Yr(y.target.value,mu)),onBlur:p.onBlur,error:(x=f.routingNumber)==null?void 0:x.message})}}),n.jsx(Re,{name:"accountType",control:d,render:({field:p})=>{var x;return n.jsx(wt,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(x=f.accountType)==null?void 0:x.message,children:Hu.map(y=>n.jsx("option",{value:y,children:y},y))})}})]}),n.jsx(Re,{name:"bankName",control:d,render:({field:p})=>{var x;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:(x=f.bankName)==null?void 0:x.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 Rr=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Gv},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:Xv},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:ej},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:tj}];function Gv({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 Xv({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 ej({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 tj({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 mn({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 rj(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function nj({status:e}){const t=yn({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 sj({entityId:e}){const[t,r]=N.useState(!1),[s,a]=N.useState(null),i=Rr.find(d=>d.id==="bank-accounts"),o=i.icon,{data:l=[],isLoading:c,isError:u}=ke({queryKey:["bank-accounts",e],queryFn:()=>Zn(e),enabled:e!==null});return n.jsxs("div",{children:[n.jsx(mn,{title:i.title,subtitle:i.subtitle,icon:o,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(aj,{}),"Add Bank Account"]})}),n.jsx(fu,{open:t,entityId:e,onClose:()=>r(!1)}),n.jsx(Jv,{open:s!==null,account:s,onClose:()=>a(null)}),n.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200",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:c?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):u?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?l.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."})}):l.map(d=>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:d.bankName}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:rj(d.accountNumber)}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.routingNumber}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:d.accountType}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(nj,{status:d.status})}),n.jsx("td",{className:"px-5 py-4 text-right",children:n.jsx(Hv,{account:d,entityId:e,onEdit:a})})]},d.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."})})})]})})]})}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"})})}function ij({open:e,entity:t,onClose:r}){var x,y,k,j,w,E,F,P,O,Z;const s=ct(),[a,i]=N.useState(null),[o,l]=N.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,formState:{errors:h}}=St({resolver:Ct(au),defaultValues:nl(t)});N.useEffect(()=>{e&&(m(nl(t)),i(null))},[t,e,m]),N.useEffect(()=>{if(!e)return;const $=se=>{se.key==="Escape"&&r()};return document.addEventListener("keydown",$),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",$),document.body.style.overflow=""}},[e,r]);const f=d("accountType"),b=f==="Individual"?su:nu,p=u(async $=>{i(null),l(!0);try{await $h(t.entityId,Xy($)),await s.invalidateQueries({queryKey:["entities","mine"]}),r()}catch(se){i(Ge(se,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?As.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:p,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(Vt,{message:a})}):null,n.jsxs("div",{className:"space-y-8",children:[n.jsx("input",{type:"hidden",...c("ein")}),n.jsx(lr,{step:1,title:"ENTITY DETAILS",children:n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{children:[n.jsx(un,{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",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Business"]}),n.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[n.jsx("input",{type:"radio",value:"Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",...c("accountType")}),"Individual"]})]})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:f==="Individual"?"Full name":"Business Name",required:!0,placeholder:"Enter",error:(x=h.businessName)==null?void 0:x.message,...c("businessName")}),n.jsx(me,{label:"Trade Name, if any",placeholder:"Enter",error:(y=h.tradeName)==null?void 0:y.message,...c("tradeName")})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"EIN",readOnly:!0,value:dr(t.idNumber),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),n.jsx(wt,{label:"Entity Type",required:!0,error:(k=h.entityType)==null?void 0:k.message,...c("entityType"),children:b.map($=>n.jsx("option",{value:$,children:$},$))})]}),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:(j=h.email)==null?void 0:j.message,...c("email")}),n.jsxs("div",{children:[n.jsx(un,{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 ${h.phoneNumber?"border-red-300":"border-slate-200"}`,...c("phoneNumber")})]}),h.phoneNumber?n.jsx("p",{className:"mt-1 text-xs text-red-600",children:h.phoneNumber.message}):null]})]})]})}),n.jsx("div",{className:"border-t border-slate-200"}),n.jsx(lr,{title:"ADDRESS DETAILS",muted:!0,children:n.jsxs("div",{className:"space-y-5",children:[n.jsx(me,{label:"Address Line 1",required:!0,error:(w=h.address1)==null?void 0:w.message,...c("address1")}),n.jsx(me,{label:"Address Line 2",error:(E=h.address2)==null?void 0:E.message,...c("address2")}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"City",required:!0,error:(F=h.city)==null?void 0:F.message,...c("city")}),n.jsxs(wt,{label:"State",required:!0,error:(P=h.state)==null?void 0:P.message,...c("state"),children:[n.jsx("option",{value:"",children:"Select"}),Ti.map($=>n.jsx("option",{value:$,children:$},$))]})]}),n.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[n.jsx(me,{label:"ZIP Code",required:!0,error:(O=h.zipCode)==null?void 0:O.message,...c("zipCode")}),n.jsxs(wt,{label:"Country",required:!0,error:(Z=h.country)==null?void 0:Z.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 oj({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 kn({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(oj,{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 lj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function cj({entity:e}){const[t,r]=N.useState(!1),s=Rr.find(c=>c.id==="entity-details"),a=s.icon;if(!e)return n.jsxs("div",{children:[n.jsx(mn,{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=At(e),o=`${e.firstName} ${e.lastName}`.trim()||i,l=_i(o);return n.jsxs("div",{children:[n.jsx(mn,{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(kn,{label:"Entity Name",value:i,icon:"entity"}),n.jsx(kn,{label:"Tax ID",value:dr(e.idNumber),icon:"tax"}),n.jsx(kn,{label:"Email Address",value:e.email,icon:"email"}),n.jsx(kn,{label:"Phone Number",value:Dr(e.phoneNumber),icon:"phone"}),n.jsx(kn,{label:"Account Type",value:lj(e.accountType),icon:"account"})]}),n.jsx(ij,{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(uj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},s.id)})})}function uj({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 dj(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e)}function mj(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function hj({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 fj({entityId:e,transactions:t=[],isLoading:r=!1,isError:s=!1}){const a=Rr.find(l=>l.id==="payment-history"),i=a.icon,o=e!==null&&t.length>0;return n.jsxs("div",{children:[n.jsx(mn,{title:a.title,subtitle:a.subtitle,icon:i,action:n.jsxs("button",{type:"button",disabled:!o,className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[n.jsx(pj,{}),"Export to Excel"]})}),n.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",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:r?n.jsx("tr",{children:n.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading payment history…"})}):s?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?t.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."})}):t.map(l=>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:mj(l.date)}),n.jsx("td",{className:"px-5 py-4 font-semibold text-slate-900",children:dj(l.amount)}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.jurisdiction}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(hj,{type:l.type})}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.accountName}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.reference})]},l.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."})})})]})})]})}function pj(){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 xj({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 gj({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 yj(e){return e.length===0?"—":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")}...`}function bj({entityId:e,accounts:t=[],isLoading:r=!1,isError:s=!1}){const a=ye(),i=Rr.find(l=>l.id==="tax-accounts"),o=i.icon;return n.jsxs("div",{children:[n.jsx(mn,{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(vj,{}),"Add Tax Account"]})}),n.jsx("div",{className:"overflow-hidden rounded-xl border border-slate-200",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?t.length===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."})}):t.map(l=>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:l.accountName}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:l.federalStateId}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(xj,{count:l.paymentCount})}),n.jsx("td",{className:"px-5 py-4 text-slate-600",children:yj(l.formTypes)}),n.jsx("td",{className:"px-5 py-4",children:n.jsx(gj,{status:l.status})})]},l.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."})})})]})})]})}function vj(){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 jj(){return fe("/portal/payments/transactions")}function Nj(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}}const gl="rounded-2xl border border-slate-200 bg-white shadow-sm";function wj(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function Xi(){const{selectedEntity:e}=it(),r=ge().state,[s,a]=N.useState(wj(r==null?void 0:r.section)?r.section:"bank-accounts"),{data:i,isLoading:o,isError:l}=ke({queryKey:["payment-transactions"],queryFn:jj,enabled:s==="payment-history"}),c=i==null?void 0:i.map(Nj);return n.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[n.jsx("div",{className:`${gl} p-3`,children:n.jsx(Ku,{items:Rr,activeSection:s,onSectionChange:a})}),n.jsx("div",{className:`${gl} p-6 lg:p-8`,children:s==="bank-accounts"?n.jsx(sj,{entityId:(e==null?void 0:e.entityId)??null}):s==="tax-accounts"?n.jsx(bj,{entityId:(e==null?void 0:e.entityId)??null}):s==="payment-history"?n.jsx(fj,{entityId:(e==null?void 0:e.entityId)??null,transactions:c,isLoading:o,isError:l}):n.jsx(cj,{entity:e})})]})}const Sj=["Alexandria","Arlington","Chesapeake","Hampton","Lynchburg","Newport News","Norfolk","Richmond","Roanoke","Virginia Beach"],kj=Ti.map(e=>({code:e,name:e==="VA"?"Virginia":e})),Cj=[{name:"virginiaTaxAccountId",label:"Virginia Tax Account ID",required:!0},{name:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID",required:!0},{name:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID",required:!0},{name:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number",required:!0},{name:"businessLocationCode",label:"Business Location Code",required:!0},{name:"franchiseTaxAccount",label:"Franchise Tax Account",required:!0},{name:"transientOccupancyTaxAccountId",label:"Transient Occupancy Tax Account ID",required:!1},{name:"certificateOfAuthorityNumber",label:"Certificate of Authority Number (Foreign Entities)",required:!1}],Aj=[{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1}],Pj=Bt({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()}),Ej=Pj.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:Vr.custom,message:`${s.label} is required`,path:[s.key]})}}),_j={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function Tj({onCancel:e,onSuccess:t}){var y,k,j,w,E,F;const{showSuccess:r}=Fs(),[s,a]=N.useState(null),[i,o]=N.useState(!1),{register:l,handleSubmit:c,watch:u,setValue:d,formState:{errors:m}}=St({resolver:Ct(Ej),defaultValues:_j}),h=u("state"),f=u("city"),b=h==="VA",p=N.useMemo(()=>h==="VA"?[...Sj]:[],[h]);N.useEffect(()=>{if(p.length===0){f&&d("city","");return}f&&!p.includes(f)&&d("city","")},[p,f,d]);const x=c(async P=>{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(P)}catch{a("Unable to save tax account. Please try again.")}finally{o(!1)}});return n.jsxs("form",{onSubmit:x,noValidate:!0,className:"space-y-8",children:[s?n.jsx(Vt,{message:s}):null,n.jsx(lr,{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(wt,{label:"Select State",required:!0,error:(y=m.state)==null?void 0:y.message,...l("state"),children:[n.jsx("option",{value:"",children:"Select"}),kj.map(P=>n.jsx("option",{value:P.code,children:P.name},P.code))]}),p.length>0?n.jsxs(wt,{label:"City",required:!0,error:(k=m.city)==null?void 0:k.message,...l("city"),children:[n.jsx("option",{value:"",children:"Select"}),p.map(P=>n.jsx("option",{value:P,children:P},P))]}):n.jsx(me,{label:"City",required:!0,placeholder:"Enter",error:(j=m.city)==null?void 0:j.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:(w=m.zipCode)==null?void 0:w.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:(F=m.address2)==null?void 0:F.message,...l("address2")})]})}),b?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-slate-200"}),n.jsxs(lr,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[n.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:Cj.map(P=>{var O;return n.jsx(me,{label:P.label,required:P.required,placeholder:"Enter",error:(O=m[P.name])==null?void 0:O.message,...l(P.name)},P.name)})}),n.jsx("div",{className:"mt-5 space-y-5",children:Aj.map(P=>{var O;return n.jsx(me,{label:P.label,required:P.required,placeholder:"Enter",error:(O=m[P.name])==null?void 0:O.message,...l(P.name)},P.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 ha="rounded-2xl border border-slate-200 bg-white shadow-sm";function eo(){const e=ye(),{selectedEntity:t}=it(),r=Rr.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:`${ha} p-3`,children:n.jsx(Ku,{items:Rr,activeSection:"tax-accounts",onSectionChange:a})}),n.jsxs("div",{className:`${ha} p-6 lg:p-8`,children:[n.jsx(mn,{title:r.title,subtitle:r.subtitle,icon:s}),n.jsx(Tj,{onCancel:()=>a("tax-accounts"),onSuccess:()=>a("tax-accounts")})]})]}):n.jsx("div",{className:ha+" 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 Ij({paymentsMode:e="all"}){return n.jsxs(si,{children:[n.jsx(ee,{index:!0,element:n.jsx(hi,{})}),n.jsx(ee,{path:"create-entity",element:n.jsx(pi,{})}),n.jsx(ee,{path:"create-entity/form",element:n.jsx(Ii,{})}),n.jsxs(ee,{element:n.jsx(fi,{}),children:[n.jsx(ee,{path:"entities",element:n.jsx(Oi,{})}),n.jsx(ee,{path:"dashboard",element:n.jsx(Ri,{})}),n.jsx(ee,{path:"payments",element:n.jsx(qi,{paymentsMode:e})}),n.jsx(ee,{path:"payments/federal/new",element:n.jsx(Cu,{})}),n.jsx(ee,{path:"payments/federal/:federalPaymentId/edit",element:n.jsx(Pu,{})}),n.jsx(ee,{path:"payments/federal/:federalPaymentId/view",element:n.jsx(Eu,{})}),n.jsx(ee,{path:"payments/state/new",element:n.jsx(Fu,{})}),n.jsx(ee,{path:"payments/state/:statePaymentDetailId/edit",element:n.jsx(Du,{})}),n.jsx(ee,{path:"payments/state/:statePaymentDetailId/view",element:n.jsx(Ru,{})}),n.jsx(ee,{path:"payments/state/authorization",element:n.jsx(Lu,{})}),n.jsx(ee,{path:"payments/federal/authorization",element:n.jsx(qu,{})}),n.jsx(ee,{path:"payments/federal/individual-enrollment",element:n.jsx(Yu,{})}),n.jsx(ee,{path:"tax-forms",element:n.jsx(Wv,{})}),n.jsx(ee,{path:"settings",element:n.jsx(Xi,{})}),n.jsx(ee,{path:"settings/tax-accounts/new",element:n.jsx(eo,{})})]}),n.jsx(ee,{path:"*",element:n.jsx(Oe,{to:"/",replace:!0})})]})}const Ja="tax-remittance:payment-complete",Fj=N.forwardRef(function(t,r){const s=N.useRef(null),a=N.useRef(null);return N.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(Ja,{detail:{paymentId:i}}))}})),n.jsx(mi,{...t,navigateFnRef:s,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:n.jsx(Ij,{paymentsMode:"all"})})}),Dj=N.forwardRef(function(t,r){const s=N.useRef(null),a=N.useRef(null);return N.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(mi,{...t,navigateFnRef:s,selectEntityFnRef:a,enabledPayments:["federal"],children:n.jsxs(si,{children:[n.jsx(ee,{index:!0,element:n.jsx(hi,{})}),n.jsx(ee,{path:"create-entity",element:n.jsx(pi,{})}),n.jsx(ee,{path:"create-entity/form",element:n.jsx(Ii,{})}),n.jsxs(ee,{element:n.jsx(fi,{}),children:[n.jsx(ee,{path:"entities",element:n.jsx(Oi,{})}),n.jsx(ee,{path:"dashboard",element:n.jsx(Ri,{})}),n.jsx(ee,{path:"payments",element:n.jsx(qi,{paymentsMode:"federal"})}),n.jsx(ee,{path:"payments/federal/new",element:n.jsx(Cu,{})}),n.jsx(ee,{path:"payments/federal/:federalPaymentId/edit",element:n.jsx(Pu,{})}),n.jsx(ee,{path:"payments/federal/:federalPaymentId/view",element:n.jsx(Eu,{})}),n.jsx(ee,{path:"payments/federal/authorization",element:n.jsx(qu,{})}),n.jsx(ee,{path:"payments/federal/individual-enrollment",element:n.jsx(Yu,{})}),n.jsx(ee,{path:"settings",element:n.jsx(Xi,{})}),n.jsx(ee,{path:"settings/tax-accounts/new",element:n.jsx(eo,{})})]}),n.jsx(ee,{path:"*",element:n.jsx(Oe,{to:"/",replace:!0})})]})})}),Rj=N.forwardRef(function(t,r){const s=N.useRef(null),a=N.useRef(null);return N.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(mi,{...t,navigateFnRef:s,selectEntityFnRef:a,enabledPayments:["state"],children:n.jsxs(si,{children:[n.jsx(ee,{index:!0,element:n.jsx(hi,{})}),n.jsx(ee,{path:"create-entity",element:n.jsx(pi,{})}),n.jsx(ee,{path:"create-entity/form",element:n.jsx(Ii,{})}),n.jsxs(ee,{element:n.jsx(fi,{}),children:[n.jsx(ee,{path:"entities",element:n.jsx(Oi,{})}),n.jsx(ee,{path:"dashboard",element:n.jsx(Ri,{})}),n.jsx(ee,{path:"payments",element:n.jsx(qi,{paymentsMode:"state"})}),n.jsx(ee,{path:"payments/state/new",element:n.jsx(Fu,{})}),n.jsx(ee,{path:"payments/state/:statePaymentId/edit",element:n.jsx(Du,{})}),n.jsx(ee,{path:"payments/state/:statePaymentId/view",element:n.jsx(Ru,{})}),n.jsx(ee,{path:"payments/state/authorization",element:n.jsx(Lu,{})}),n.jsx(ee,{path:"settings",element:n.jsx(Xi,{})}),n.jsx(ee,{path:"settings/tax-accounts/new",element:n.jsx(eo,{})})]}),n.jsx(ee,{path:"*",element:n.jsx(Oe,{to:"/",replace:!0})})]})})});exports.ApiError=xn;exports.FederalPaymentWidget=Dj;exports.StatePaymentWidget=Rj;exports.TaxRemittanceEmbedded=Fj;exports.setRuntimeApiBaseUrl=cc;
76
76
  //# sourceMappingURL=index.cjs.map