@npm-zenwork/tax-remittance-ui 0.1.15 → 0.2.0
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/api/reference.d.ts +14 -0
- package/dist/components/forms/FormCard.d.ts +17 -0
- package/dist/components/forms/PhoneInputGroup.d.ts +16 -0
- package/dist/components/forms/SegmentedControl.d.ts +22 -0
- package/dist/components/forms/StickyActionFooter.d.ts +17 -0
- package/dist/components/settings/SettingsCard.d.ts +14 -0
- package/dist/components/settings/taxAccountFormConfig.d.ts +17 -43
- package/dist/index.cjs +32 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4974 -4867
- package/dist/index.mjs.map +1 -1
- package/dist/lib/entityFormUtils.d.ts +7 -3
- package/dist/lib/useAddressReference.d.ts +13 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var fd=Object.defineProperty;var co=e=>{throw TypeError(e)};var pd=(e,t,n)=>t in e?fd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wr=(e,t,n)=>pd(e,typeof t!="symbol"?t+"":t,n),sa=(e,t,n)=>t.has(e)||co("Cannot "+n);var N=(e,t,n)=>(sa(e,t,"read from private field"),n?n.call(e):t.get(e)),G=(e,t,n)=>t.has(e)?co("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),W=(e,t,n,r)=>(sa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ce=(e,t,n)=>(sa(e,t,"access private method"),n);var es=(e,t,n,r)=>({set _(a){W(e,t,a,n)},get _(){return N(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),j=require("react"),Br=require("react-dom");function xd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const A=xd(j);/**
|
|
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 ai=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,cd=/^[\\/]{2}/;function ud(e,t){return t+e.replace(/\\/g,"/")}function lo(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function dd(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:r=!1}=e,a;a=t.map((f,x)=>d(f,typeof f=="string"?null:f.state,x===0?"default":void 0,typeof f=="string"?void 0:f.mask));let i=c(n??a.length-1),o="POP",l=null;function c(f){return Math.min(Math.max(f,0),a.length-1)}function u(){return a[i]}function d(f,x=null,p,v){let g=hd(a?u().pathname:"/",f,x,p,v);return dt(g.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),g}function m(f){return typeof f=="string"?f:bs(f)}return{get index(){return i},get action(){return o},get location(){return u()},createHref:m,createURL(f){return new URL(m(f),"http://localhost")},encodeLocation(f){let x=typeof f=="string"?Mn(f):f;return{pathname:x.pathname||"",search:x.search||"",hash:x.hash||""}},push(f,x){o="PUSH";let p=lo(f)?f:d(f,x);i+=1,a.splice(i,a.length,p),r&&l&&l({action:o,location:p,delta:1})},replace(f,x){o="REPLACE";let p=lo(f)?f:d(f,x);a[i]=p,r&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let x=c(i+f),p=a[x];i=x,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function Ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function dt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function md(){return Math.random().toString(36).substring(2,10)}function hd(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Mn(t):t,state:n,key:t&&t.key||r||md(),mask:a}}function bs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Mn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Fl(e,t,n="/"){return fd(e,t,n,!1)}function fd(e,t,n,r,a){let i=typeof t=="string"?Mn(t):t,o=Jt(i.pathname||"/",n);if(o==null)return null;let l=pd(e),c=null,u=Cd(o);for(let d=0;c==null&&d<l.length;++d)c=kd(l[d],u,r);return c}function pd(e){let t=Rl(e);return xd(t),t}function Rl(e,t=[],n=[],r="",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(r)&&c)return;Ie(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let m=Ct([r,d.relativePath]),h=n.concat(d);o.children&&o.children.length>0&&(Ie(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Rl(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:wd(m,o.index),routesMeta:h.map((f,x)=>{let[p,v]=Ll(f.relativePath,f.caseSensitive,x===h.length-1);return{...f,matcher:p,compiledParams:v}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let u of Ol(o.path))i(o,l,!0,u)}),t}function Ol(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=Ol(r.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 xd(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Sd(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var gd=/^:[\w-]+$/,yd=3,bd=2,vd=1,jd=10,Nd=-2,co=e=>e==="*";function wd(e,t){let n=e.split("/"),r=n.length;return n.some(co)&&(r+=Nd),t&&(r+=bd),n.filter(a=>!co(a)).reduce((a,i)=>a+(gd.test(i)?yd:i===""?vd:jd),r)}function Sd(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function kd(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.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):vs(m,d),f=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=vs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Ct([i,h.pathname]),pathnameBase:Ed(Ct([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Ct([i,h.pathnameBase]))}return o}function vs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Ll(e.path,e.caseSensitive,e.end);return $l(e,t,n,r)}function $l(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:m},h)=>{if(d==="*"){let x=l[h]||"";o=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const f=l[h];return m&&!f?u[d]=void 0:u[d]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function Ll(e,t=!1,n=!0){dt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,u,d)=>{if(r.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("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Cd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return dt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Jt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Ad(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Mn(e):e,i;return n?(n=zl(n),n.startsWith("/")?i=uo(n.substring(1),"/"):i=uo(n,t)):i=t,{pathname:i,search:Id(r),hash:Td(a)}}function uo(e,t){let n=js(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function sa(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Pd(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ii(e){let t=Pd(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Os(e,t,n,r=!1){let a;typeof e=="string"?a=Mn(e):(a={...e},Ie(!a.pathname||!a.pathname.includes("?"),sa("?","pathname","search",a)),Ie(!a.pathname||!a.pathname.includes("#"),sa("#","pathname","hash",a)),Ie(!a.search||!a.search.includes("#"),sa("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!r&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=Ad(a,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var zl=e=>e.replace(/[\\/]{2,}/g,"/"),Ct=e=>zl(e.join("/")),js=e=>e.replace(/\/+$/,""),Ed=e=>js(e).replace(/^\/*/,"/"),Id=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Td=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,_d=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Dd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Fd(e){let t=e.map(n=>n.route.path).filter(Boolean);return Ct(t)||"/"}var Ml=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ql(e,t){let n=e;if(typeof n!="string"||!ai.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Ml)try{let i=new URL(window.location.href),o=cd.test(n)?new URL(ud(n,i.protocol)):new URL(n),l=Jt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{dt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Vl=["POST","PUT","PATCH","DELETE"];new Set(Vl);var Rd=["GET",...Vl];new Set(Rd);var Od=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function $d(e){try{return Od.includes(new URL(e).protocol)}catch{return!1}}var pr=A.createContext(null);pr.displayName="DataRouter";var $s=A.createContext(null);$s.displayName="DataRouterState";var Bl=A.createContext(!1);function Ld(){return A.useContext(Bl)}var Ul=A.createContext({isTransitioning:!1});Ul.displayName="ViewTransition";var zd=A.createContext(new Map);zd.displayName="Fetchers";var Md=A.createContext(null);Md.displayName="Await";var mt=A.createContext(null);mt.displayName="Navigation";var Ur=A.createContext(null);Ur.displayName="Location";var yt=A.createContext({outlet:null,matches:[],isDataRoute:!1});yt.displayName="Route";var oi=A.createContext(null);oi.displayName="RouteError";var Zl="REACT_ROUTER_ERROR",qd="REDIRECT",Vd="ROUTE_ERROR_RESPONSE";function Bd(e){if(e.startsWith(`${Zl}:${qd}:{`))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 Ud(e){if(e.startsWith(`${Zl}:${Vd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new _d(t.status,t.statusText,t.data)}catch{}}function Zd(e,{relative:t}={}){Ie(xr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=A.useContext(mt),{hash:a,pathname:i,search:o}=Zr(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ct([n,i])),r.createHref({pathname:l,search:o,hash:a})}function xr(){return A.useContext(Ur)!=null}function Ce(){return Ie(xr(),"useLocation() may be used only in the context of a <Router> component."),A.useContext(Ur).location}var Wl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Yl(e){A.useContext(mt).static||A.useLayoutEffect(e)}function Ae(){let{isDataRoute:e}=A.useContext(yt);return e?am():Wd()}function Wd(){Ie(xr(),"useNavigate() may be used only in the context of a <Router> component.");let e=A.useContext(pr),{basename:t,navigator:n}=A.useContext(mt),{matches:r}=A.useContext(yt),{pathname:a}=Ce(),i=JSON.stringify(ii(r)),o=A.useRef(!1);return Yl(()=>{o.current=!0}),A.useCallback((c,u={})=>{if(dt(o.current,Wl),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=Os(c,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:Ct([t,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[t,n,i,a,e])}var Hl=A.createContext(null);function ht(){return A.useContext(Hl)}function Yd(e){let t=A.useContext(yt).outlet;return A.useMemo(()=>t&&A.createElement(Hl.Provider,{value:e},t),[t,e])}function Ls(){let{matches:e}=A.useContext(yt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Zr(e,{relative:t}={}){let{matches:n}=A.useContext(yt),{pathname:r}=Ce(),a=JSON.stringify(ii(n));return A.useMemo(()=>Os(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Hd(e,t){return Kl(e,t)}function Kl(e,t,n){var v;Ie(xr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=A.useContext(mt),{matches:a}=A.useContext(yt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let g=u&&u.path||"";Jl(l,!u||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
10
|
+
*/var ii=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,gd=/^[\\/]{2}/;function yd(e,t){return t+e.replace(/\\/g,"/")}function uo(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function bd(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:r=!1}=e,a;a=t.map((f,x)=>u(f,typeof f=="string"?null:f.state,x===0?"default":void 0,typeof f=="string"?void 0:f.mask));let i=c(n??a.length-1),o="POP",l=null;function c(f){return Math.min(Math.max(f,0),a.length-1)}function d(){return a[i]}function u(f,x=null,p,w){let g=jd(a?d().pathname:"/",f,x,p,w);return ht(g.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(f)}`),g}function m(f){return typeof f=="string"?f:bs(f)}return{get index(){return i},get action(){return o},get location(){return d()},createHref:m,createURL(f){return new URL(m(f),"http://localhost")},encodeLocation(f){let x=typeof f=="string"?Ln(f):f;return{pathname:x.pathname||"",search:x.search||"",hash:x.hash||""}},push(f,x){o="PUSH";let p=uo(f)?f:u(f,x);i+=1,a.splice(i,a.length,p),r&&l&&l({action:o,location:p,delta:1})},replace(f,x){o="REPLACE";let p=uo(f)?f:u(f,x);a[i]=p,r&&l&&l({action:o,location:p,delta:0})},go(f){o="POP";let x=c(i+f),p=a[x];i=x,l&&l({action:o,location:p,delta:f})},listen(f){return l=f,()=>{l=null}}}}function Ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ht(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function vd(){return Math.random().toString(36).substring(2,10)}function jd(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ln(t):t,state:n,key:t&&t.key||r||vd(),mask:a}}function bs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ln(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ol(e,t,n="/"){return wd(e,t,n,!1)}function wd(e,t,n,r,a){let i=typeof t=="string"?Ln(t):t,o=Gt(i.pathname||"/",n);if(o==null)return null;let l=Nd(e),c=null,d=Dd(o);for(let u=0;c==null&&u<l.length;++u)c=Fd(l[u],d,r);return c}function Nd(e){let t=Ll(e);return Sd(t),t}function Ll(e,t=[],n=[],r="",a=!1){let i=(o,l,c=a,d)=>{let u={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;Ie(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let m=At([r,u.relativePath]),h=n.concat(u);o.children&&o.children.length>0&&(Ie(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Ll(o.children,t,h,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:_d(m,o.index),routesMeta:h.map((f,x)=>{let[p,w]=ql(f.relativePath,f.caseSensitive,x===h.length-1);return{...f,matcher:p,compiledParams:w}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let d of zl(o.path))i(o,l,!0,d)}),t}function zl(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=zl(r.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 Sd(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Td(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var kd=/^:[\w-]+$/,Cd=3,Ad=2,Pd=1,Ed=10,Id=-2,mo=e=>e==="*";function _d(e,t){let n=e.split("/"),r=n.length;return n.some(mo)&&(r+=Id),t&&(r+=Ad),n.filter(a=>!mo(a)).reduce((a,i)=>a+(kd.test(i)?Cd:i===""?Pd:Ed),r)}function Td(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Fd(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=i==="/"?t:t.slice(i.length)||"/",m={path:c.relativePath,caseSensitive:c.caseSensitive,end:d},h=c.matcher&&c.compiledParams?Ml(m,u,c.matcher,c.compiledParams):vs(m,u),f=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=vs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:At([i,h.pathname]),pathnameBase:Od(At([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=At([i,h.pathnameBase]))}return o}function vs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ql(e.path,e.caseSensitive,e.end);return Ml(e,t,n,r)}function Ml(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((d,{paramName:u,isOptional:m},h)=>{if(u==="*"){let x=l[h]||"";o=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const f=l[h];return m&&!f?d[u]=void 0:d[u]=(f||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function ql(e,t=!1,n=!0){ht(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 r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,d,u)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let m=u.charAt(d+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Dd(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ht(!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 Gt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Rd(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Ln(e):e,i;return n?(n=Bl(n),n.startsWith("/")?i=ho(n.substring(1),"/"):i=ho(n,t)):i=t,{pathname:i,search:Ld(r),hash:zd(a)}}function ho(e,t){let n=js(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function aa(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function $d(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function oi(e){let t=$d(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Os(e,t,n,r=!1){let a;typeof e=="string"?a=Ln(e):(a={...e},Ie(!a.pathname||!a.pathname.includes("?"),aa("?","pathname","search",a)),Ie(!a.pathname||!a.pathname.includes("#"),aa("#","pathname","hash",a)),Ie(!a.search||!a.search.includes("#"),aa("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!r&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),m-=1;a.pathname=h.join("/")}l=m>=0?t[m]:"/"}let c=Rd(a,l),d=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var Bl=e=>e.replace(/[\\/]{2,}/g,"/"),At=e=>Bl(e.join("/")),js=e=>e.replace(/\/+$/,""),Od=e=>js(e).replace(/^\/*/,"/"),Ld=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,zd=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Md=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function qd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Bd(e){let t=e.map(n=>n.route.path).filter(Boolean);return At(t)||"/"}var Vl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ul(e,t){let n=e;if(typeof n!="string"||!ii.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Vl)try{let i=new URL(window.location.href),o=gd.test(n)?new URL(yd(n,i.protocol)):new URL(n),l=Gt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{ht(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Zl=["POST","PUT","PATCH","DELETE"];new Set(Zl);var Vd=["GET",...Zl];new Set(Vd);var Ud=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Zd(e){try{return Ud.includes(new URL(e).protocol)}catch{return!1}}var fr=A.createContext(null);fr.displayName="DataRouter";var Ls=A.createContext(null);Ls.displayName="DataRouterState";var Wl=A.createContext(!1);function Wd(){return A.useContext(Wl)}var Yl=A.createContext({isTransitioning:!1});Yl.displayName="ViewTransition";var Yd=A.createContext(new Map);Yd.displayName="Fetchers";var Hd=A.createContext(null);Hd.displayName="Await";var ft=A.createContext(null);ft.displayName="Navigation";var Vr=A.createContext(null);Vr.displayName="Location";var bt=A.createContext({outlet:null,matches:[],isDataRoute:!1});bt.displayName="Route";var li=A.createContext(null);li.displayName="RouteError";var Hl="REACT_ROUTER_ERROR",Kd="REDIRECT",Qd="ROUTE_ERROR_RESPONSE";function Jd(e){if(e.startsWith(`${Hl}:${Kd}:{`))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 Gd(e){if(e.startsWith(`${Hl}:${Qd}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Md(t.status,t.statusText,t.data)}catch{}}function Xd(e,{relative:t}={}){Ie(pr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=A.useContext(ft),{hash:a,pathname:i,search:o}=Ur(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:At([n,i])),r.createHref({pathname:l,search:o,hash:a})}function pr(){return A.useContext(Vr)!=null}function Se(){return Ie(pr(),"useLocation() may be used only in the context of a <Router> component."),A.useContext(Vr).location}var Kl="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ql(e){A.useContext(ft).static||A.useLayoutEffect(e)}function ke(){let{isDataRoute:e}=A.useContext(bt);return e?hm():em()}function em(){Ie(pr(),"useNavigate() may be used only in the context of a <Router> component.");let e=A.useContext(fr),{basename:t,navigator:n}=A.useContext(ft),{matches:r}=A.useContext(bt),{pathname:a}=Se(),i=JSON.stringify(oi(r)),o=A.useRef(!1);return Ql(()=>{o.current=!0}),A.useCallback((c,d={})=>{if(ht(o.current,Kl),!o.current)return;if(typeof c=="number"){n.go(c);return}let u=Os(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:At([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,i,a,e])}var Jl=A.createContext(null);function pt(){return A.useContext(Jl)}function tm(e){let t=A.useContext(bt).outlet;return A.useMemo(()=>t&&A.createElement(Jl.Provider,{value:e},t),[t,e])}function zs(){let{matches:e}=A.useContext(bt),t=e[e.length-1];return(t==null?void 0:t.params)??{}}function Ur(e,{relative:t}={}){let{matches:n}=A.useContext(bt),{pathname:r}=Se(),a=JSON.stringify(oi(n));return A.useMemo(()=>Os(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function nm(e,t){return Gl(e,t)}function Gl(e,t,n){var w;Ie(pr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=A.useContext(ft),{matches:a}=A.useContext(bt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";ec(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
11
11
|
|
|
12
|
-
Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let d=Ce(),m;if(t){let g=typeof t=="string"?Mn(t):t;Ie(c==="/"||((v=g.pathname)==null?void 0:v.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),m=g}else m=d;let h=m.pathname||"/",f=h;if(c!=="/"){let g=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let x=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):Fl(e,{pathname:f});dt(u||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),dt(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let p=Xd(x&&x.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Ct([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Ct([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&p?A.createElement(Ur.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function Kd(){let e=sm(),t=Dd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},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),n?A.createElement("pre",{style:a},n):null,o)}var Qd=A.createElement(Kd,null),Ql=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 n=Ud(e.digest);n&&(e=n)}let t=e!==void 0?A.createElement(yt.Provider,{value:this.props.routeContext},A.createElement(oi.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?A.createElement(Jd,{error:e},t):t}};Ql.contextType=Bl;var aa=new WeakMap;function Jd({children:e,error:t}){let{basename:n}=A.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Bd(t.digest);if(r){let a=aa.get(t);if(a)throw a;let i=ql(r.location,n),o=i.absoluteURL||i.to;if($d(o))throw new Error("Invalid redirect location");if(Ml&&!aa.get(t))if(i.isExternal||r.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw aa.set(t,l),l}return A.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function Gd({routeContext:e,match:t,children:n}){let r=A.useContext(pr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(yt.Provider,{value:e},n)}function Xd(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let d=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Ie(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,l=-1;if(n&&r){o=r.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}=r,x=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||x){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,u=r&&c?(d,m)=>{var h,f;c(d,{location:r.location,params:((f=(h=r.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:Fd(r.matches),errorInfo:m})}:void 0;return a.reduceRight((d,m,h)=>{let f,x=!1,p=null,v=null;r&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||Qd,o&&(l<0&&h===0?(Jl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):l===h&&(x=!0,v=m.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,h+1)),k=()=>{let j;return f?j=p:x?j=v:m.route.Component?j=A.createElement(m.route.Component,null):m.route.element?j=m.route.element:j=d,A.createElement(Gd,{match:m,routeContext:{outlet:d,matches:g,isDataRoute:r!=null},children:j})};return r&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?A.createElement(Ql,{location:r.location,revalidation:r.revalidation,component:p,error:f,children:k(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:u}):k()},null)}function li(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function em(e){let t=A.useContext(pr);return Ie(t,li(e)),t}function tm(e){let t=A.useContext($s);return Ie(t,li(e)),t}function nm(e){let t=A.useContext(yt);return Ie(t,li(e)),t}function ci(e){let t=nm(e),n=t.matches[t.matches.length-1];return Ie(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function rm(){return ci("useRouteId")}function sm(){var r;let e=A.useContext(oi),t=tm("useRouteError"),n=ci("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function am(){let{router:e}=em("useNavigate"),t=ci("useNavigate"),n=A.useRef(!1);return Yl(()=>{n.current=!0}),A.useCallback(async(a,i={})=>{dt(n.current,Wl),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var mo={};function Jl(e,t,n){!t&&!mo[e]&&(mo[e]=!0,dt(!1,n))}A.memo(im);function im({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return Kl(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function om({basename:e,children:t,initialEntries:n,initialIndex:r,useTransitions:a}){let i=A.useRef();i.current==null&&(i.current=dd({initialEntries:n,initialIndex:r,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(cm,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Be({to:e,replace:t,state:n,relative:r}){Ie(xr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=A.useContext(mt);dt(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:i}=A.useContext(yt),{pathname:o}=Ce(),l=Ae(),c=Os(e,ii(i),o,r==="path"),u=JSON.stringify(c);return A.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:r})},[l,u,r,t,n]),null}function lm(e){return Yd(e.context)}function G(e){Ie(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function cm({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Ie(!xr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=A.useMemo(()=>({basename:l,navigator:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=Mn(n));let{pathname:u="/",search:d="",hash:m="",state:h=null,key:f="default",mask:x}=n,p=A.useMemo(()=>{let v=Jt(u,l);return v==null?null:{location:{pathname:v,search:d,hash:m,state:h,key:f,mask:x},navigationType:r}},[l,u,d,m,h,f,r,x]);return dt(p!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${m}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:A.createElement(mt.Provider,{value:c},A.createElement(Ur.Provider,{children:t,value:p}))}function ui({children:e,location:t}){return Hd(wa(e),t)}function wa(e,t=[]){let n=[];return A.Children.forEach(e,(r,a)=>{if(!A.isValidElement(r))return;let i=[...t,a];if(r.type===A.Fragment){n.push.apply(n,wa(r.props.children,i));return}Ie(r.type===G,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ie(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=wa(r.props.children,i)),n.push(o)}),n}var fs="get",ps="application/x-www-form-urlencoded";function zs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function um(e){return zs(e)&&e.tagName.toLowerCase()==="button"}function dm(e){return zs(e)&&e.tagName.toLowerCase()==="form"}function mm(e){return zs(e)&&e.tagName.toLowerCase()==="input"}function hm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function fm(e,t){return e.button===0&&(!t||t==="_self")&&!hm(e)}function Sa(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function pm(e,t){let n=Sa(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var ts=null;function xm(){if(ts===null)try{new FormData(document.createElement("form"),0),ts=!1}catch{ts=!0}return ts}var gm=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ia(e){return e!=null&&!gm.has(e)?(dt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ps}"`),null):e}function ym(e,t){let n,r,a,i,o;if(dm(e)){let l=e.getAttribute("action");r=l?Jt(l,t):null,n=e.getAttribute("method")||fs,a=ia(e.getAttribute("enctype"))||ps,i=new FormData(e)}else if(um(e)||mm(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(r=c?Jt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||fs,a=ia(e.getAttribute("formenctype"))||ia(l.getAttribute("enctype"))||ps,i=new FormData(l,e),!xm()){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(zs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=fs,r=null,a=ps,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function di(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Gl(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Jt(a.pathname,t)==="/"?a.pathname=`${js(t)}/_root.${r}`:a.pathname=`${js(a.pathname)}.${r}`,a}async function bm(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function vm(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 jm(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await bm(i,n);return o.links?o.links():[]}return[]}));return km(r.flat(1).filter(vm).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function ho(e,t,n,r,a,i){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var d;return n[u].pathname!==c.pathname||((d=n[u].route.path)==null?void 0:d.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,u)=>o(c,u)||l(c,u)):i==="data"?t.filter((c,u)=>{var m;let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Nm(e,t,{includeHydrateFallback:n}={}){return wm(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function wm(e){return[...new Set(e)]}function Sm(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function km(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(Sm(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function mi(){let e=A.useContext(pr);return di(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Cm(){let e=A.useContext($s);return di(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var hi=A.createContext(void 0);hi.displayName="FrameworkContext";function Ms(){let e=A.useContext(hi);return di(e,"You must render this element inside a <HydratedRouter> element"),e}function Am(e,t){let n=A.useContext(hi),[r,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=g=>{g.forEach(k=>{o(k.isIntersecting)})},v=new IntersectionObserver(p,{threshold:.5});return h.current&&v.observe(h.current),()=>{v.disconnect()}}},[e]),A.useEffect(()=>{if(r){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[r]);let f=()=>{a(!0)},x=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,h,{}]:[i,h,{onFocus:Sr(l,f),onBlur:Sr(c,x),onMouseEnter:Sr(u,f),onMouseLeave:Sr(d,x),onTouchStart:Sr(m,f)}]:[!1,h,{}]}function Sr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Pm({page:e,...t}){let n=Ld(),{nonce:r}=Ms(),{router:a}=mi(),i=A.useMemo(()=>Fl(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?A.createElement(Im,{page:e,matches:i,...t}):A.createElement(Tm,{page:e,matches:i,...t})):null}function Em(e){let{manifest:t,routeModules:n}=Ms(),[r,a]=A.useState([]);return A.useEffect(()=>{let i=!1;return jm(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function Im({page:e,matches:t,...n}){let r=Ce(),{future:a}=Ms(),{basename:i}=mi(),o=A.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=Gl(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,r,t]);return A.createElement(A.Fragment,null,o.map(l=>A.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function Tm({page:e,matches:t,...n}){let r=Ce(),{future:a,manifest:i,routeModules:o}=Ms(),{basename:l}=mi(),{loaderData:c,matches:u}=Cm(),d=A.useMemo(()=>ho(e,t,u,i,r,"data"),[e,t,u,i,r]),m=A.useMemo(()=>ho(e,t,u,i,r,"assets"),[e,t,u,i,r]),h=A.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let p=new Set,v=!1;if(t.forEach(k=>{var S;let j=i.routes[k.route.id];!j||!j.hasLoader||(!d.some(E=>E.route.id===k.route.id)&&k.route.id in c&&((S=o[k.route.id])!=null&&S.shouldRevalidate)||j.hasClientLoader?v=!0:p.add(k.route.id))}),p.size===0)return[];let g=Gl(e,l,a.v8_trailingSlashAwareDataRequests,"data");return v&&p.size>0&&g.searchParams.set("_routes",t.filter(k=>p.has(k.route.id)).map(k=>k.route.id).join(",")),[g.pathname+g.search]},[l,a.v8_trailingSlashAwareDataRequests,c,r,i,d,t,e,o]),f=A.useMemo(()=>Nm(m,i),[m,i]),x=Em(m);return A.createElement(A.Fragment,null,h.map(p=>A.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...n})),f.map(p=>A.createElement("link",{key:p,rel:"modulepreload",href:p,...n})),x.map(({key:p,link:v})=>A.createElement("link",{key:p,nonce:n.nonce,...v,crossOrigin:v.crossOrigin??n.crossOrigin})))}function _m(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Dm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Dm&&(window.__reactRouterVersion="7.18.1")}catch{}var Xl=A.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...x},p){let{basename:v,navigator:g,useTransitions:k}=A.useContext(mt),j=typeof d=="string"&&ai.test(d),S=ql(d,v);d=S.to;let E=Zd(d,{relative:a}),_=Ce(),I=null;if(l){let Y=Os(l,[],_.mask?_.mask.pathname:"/",!0);v!=="/"&&(Y.pathname=Y.pathname==="/"?v:Ct([v,Y.pathname])),I=g.createHref(Y)}let[$,P,R]=Am(r,x),ee=$m(d,{replace:o,mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:k});function B(Y){t&&t(Y),Y.defaultPrevented||ee(Y)}let K=!(S.isExternal||i),ne=A.createElement("a",{...x,...R,href:(K?I:void 0)||S.absoluteURL||E,onClick:K?B:t,ref:_m(p,P),target:u,"data-discover":!j&&n==="render"?"true":void 0});return $&&!j?A.createElement(A.Fragment,null,ne,A.createElement(Pm,{page:E})):ne});Xl.displayName="Link";var Fm=A.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...u},d){let m=Zr(o,{relative:u.relative}),h=Ce(),f=A.useContext($s),{navigator:x,basename:p}=A.useContext(mt),v=f!=null&&Bm(m)&&l===!0,g=x.encodeLocation?x.encodeLocation(m).pathname:m.pathname,k=h.pathname,j=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(k=k.toLowerCase(),j=j?j.toLowerCase():null,g=g.toLowerCase()),j&&p&&(j=Jt(j,p)||j);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let E=k===g||!a&&k.startsWith(g)&&k.charAt(S)==="/",_=j!=null&&(j===g||!a&&j.startsWith(g)&&j.charAt(g.length)==="/"),I={isActive:E,isPending:_,isTransitioning:v},$=E?t:void 0,P;typeof r=="function"?P=r(I):P=[r,E?"active":null,_?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let R=typeof i=="function"?i(I):i;return A.createElement(Xl,{...u,"aria-current":$,className:P,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(I):c)});Fm.displayName="NavLink";var Rm=A.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=fs,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h,...f},x)=>{let{useTransitions:p}=A.useContext(mt),v=qm(),g=Vm(l,{relative:u}),k=o.toLowerCase()==="get"?"get":"post",j=typeof l=="string"&&ai.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let _=E.nativeEvent.submitter,I=(_==null?void 0:_.getAttribute("formmethod"))||o,$=()=>v(_||E.currentTarget,{fetcherKey:t,method:I,navigate:n,replace:a,state:i,relative:u,preventScrollReset:d,viewTransition:m,defaultShouldRevalidate:h});p&&n!==!1?A.startTransition(()=>$()):$()};return A.createElement("form",{ref:x,method:k,action:g,onSubmit:r?c:S,...f,"data-discover":!j&&e==="render"?"true":void 0})});Rm.displayName="Form";function Om(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ec(e){let t=A.useContext(pr);return Ie(t,Om(e)),t}function $m(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:u}={}){let d=Ae(),m=Ce(),h=Zr(e,{relative:o});return A.useCallback(f=>{if(fm(f,t)){f.preventDefault();let x=n!==void 0?n:bs(m)===bs(h),p=()=>d(e,{replace:x,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});u?A.startTransition(()=>p()):p()}},[m,d,h,n,r,a,t,e,i,o,l,c,u])}function Lm(e){dt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=A.useRef(Sa(e)),n=A.useRef(!1),r=Ce(),a=A.useMemo(()=>pm(r.search,n.current?null:t.current),[r.search]),i=Ae(),o=A.useCallback((l,c)=>{const u=Sa(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+u,c)},[i,a]);return[a,o]}var zm=0,Mm=()=>`__${String(++zm)}__`;function qm(){let{router:e}=ec("useSubmit"),{basename:t}=A.useContext(mt),n=rm(),r=e.fetch,a=e.navigate;return A.useCallback(async(i,o={})=>{let{action:l,method:c,encType:u,formData:d,body:m}=ym(i,t);if(o.navigate===!1){let h=o.fetcherKey||Mm();await r(h,n,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:m,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function Vm(e,{relative:t}={}){let{basename:n}=A.useContext(mt),r=A.useContext(yt);Ie(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...Zr(e||".",{relative:t})},o=Ce();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let d=l.toString();i.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ct([n,i.pathname])),bs(i)}function Bm(e,{relative:t}={}){let n=A.useContext(Ul);Ie(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ec("useViewTransitionState"),a=Zr(e,{relative:t});if(!n.isTransitioning)return!1;let i=Jt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Jt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vs(a.pathname,o)!=null||vs(a.pathname,i)!=null}var gr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Sn,sn,Gn,wl,Um=(wl=class extends gr{constructor(){super();J(this,Sn);J(this,sn);J(this,Gn);U(this,Gn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){w(this,sn)||this.setEventListener(w(this,Gn))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,sn))==null||t.call(this),U(this,sn,void 0))}setEventListener(t){var n;U(this,Gn,t),(n=w(this,sn))==null||n.call(this),U(this,sn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){w(this,Sn)!==t&&(U(this,Sn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof w(this,Sn)=="boolean"?w(this,Sn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Sn=new WeakMap,sn=new WeakMap,Gn=new WeakMap,wl),fi=new Um,Zm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Tt,kn,Sl,Wm=(Sl=class{constructor(){J(this,Tt,Zm);J(this,kn,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&w(this,kn)&&e!==w(this,Tt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:w(this,Tt),provider:e}),U(this,Tt,e),process.env.NODE_ENV!=="production"&&U(this,kn,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&U(this,kn,!0),w(this,Tt).setTimeout(e,t)}clearTimeout(e){w(this,Tt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&U(this,kn,!0),w(this,Tt).setInterval(e,t)}clearInterval(e){w(this,Tt).clearInterval(e)}},Tt=new WeakMap,kn=new WeakMap,Sl),Nn=new Wm;function Ym(e){setTimeout(e,0)}var Hm=typeof window>"u"||"Deno"in globalThis;function et(){}function Km(e,t){return typeof e=="function"?e(t):e}function ka(e){return typeof e=="number"&&e>=0&&e!==1/0}function tc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function pn(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function fo(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==pi(o,t.options))return!1}else if(!Fr(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function po(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Fn(t.options.mutationKey)!==Fn(i))return!1}else if(!Fr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function pi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Fn)(e)}function Fn(e){return JSON.stringify(e,(t,n)=>Aa(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function Fr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Fr(e[n],t[n])):!1}var Qm=Object.prototype.hasOwnProperty;function Ca(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=xo(e)&&xo(t);if(!r&&!(Aa(e)&&Aa(t)))return t;const i=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d<l;d++){const m=r?d:o[d],h=e[m],f=t[m];if(h===f){c[m]=h,(r?d<i:Qm.call(e,m))&&u++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const x=Ca(h,f,n+1);c[m]=x,x===h&&u++}return i===l&&u===i?e:c}function Ns(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function xo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Aa(e){if(!go(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!go(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function go(e){return Object.prototype.toString.call(e)==="[object Object]"}function Jm(e){return new Promise(t=>{Nn.setTimeout(t,e)})}function Pa(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Ca(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return Ca(e,t)}return t}function Gm(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Xm(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ws=Symbol();function nc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===ws&&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===ws?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function xi(e,t){return typeof e=="function"?e(...t):!!e}function eh(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var Rr=(()=>{let e=()=>Hm;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ea(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var th=Ym;function nh(){let e=[],t=0,n=l=>{l()},r=l=>{l()},a=th;const i=l=>{t?e.push(l):a(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{a=l}}}var ze=nh(),Xn,an,er,kl,rh=(kl=class extends gr{constructor(){super();J(this,Xn,!0);J(this,an);J(this,er);U(this,er,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){w(this,an)||this.setEventListener(w(this,er))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,an))==null||t.call(this),U(this,an,void 0))}setEventListener(t){var n;U(this,er,t),(n=w(this,an))==null||n.call(this),U(this,an,t(this.setOnline.bind(this)))}setOnline(t){w(this,Xn)!==t&&(U(this,Xn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return w(this,Xn)}},Xn=new WeakMap,an=new WeakMap,er=new WeakMap,kl),Ss=new rh;function sh(e){return Math.min(1e3*2**e,3e4)}function rc(e){return(e??"online")==="online"?Ss.isOnline():!0}var Ia=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function sc(e){let t=!1,n=0,r;const a=Ea(),i=()=>a.status!=="pending",o=p=>{var v;if(!i()){const g=new Ia(p);h(g),(v=e.onCancel)==null||v.call(e,g)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>fi.isFocused()&&(e.networkMode==="always"||Ss.isOnline())&&e.canRun(),d=()=>rc(e.networkMode)&&e.canRun(),m=p=>{i()||(r==null||r(),a.resolve(p))},h=p=>{i()||(r==null||r(),a.reject(p))},f=()=>new Promise(p=>{var v;r=g=>{(i()||u())&&p(g)},(v=e.onPause)==null||v.call(e)}).then(()=>{var p;r=void 0,i()||(p=e.onContinue)==null||p.call(e)}),x=()=>{if(i())return;let p;const v=n===0?e.initialPromise:void 0;try{p=v??e.fn()}catch(g){p=Promise.reject(g)}Promise.resolve(p).then(m).catch(g=>{var _;if(i())return;const k=e.retry??(Rr.isServer()?0:3),j=e.retryDelay??sh,S=typeof j=="function"?j(n,g):j,E=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,g);if(t||!E){h(g);return}n++,(_=e.onFail)==null||_.call(e,n,g),Jm(S).then(()=>u()?void 0:f()).then(()=>{t?h(g):x()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(r==null||r(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():f().then(x),a)}}var Cn,Cl,ac=(Cl=class{constructor(){J(this,Cn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ka(this.gcTime)&&U(this,Cn,Nn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Rr.isServer()?1/0:300*1e3))}clearGcTimeout(){w(this,Cn)!==void 0&&(Nn.clearTimeout(w(this,Cn)),U(this,Cn,void 0))}},Cn=new WeakMap,Cl);function ah(e){return{onFetch:(t,n)=>{var d,m,h,f,x;const r=t.options,a=(h=(m=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((x=t.state.data)==null?void 0:x.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let p=!1;const v=j=>{eh(j,()=>t.signal,()=>p=!0)},g=nc(t.options,t.fetchOptions),k=async(j,S,E)=>{if(p)return Promise.reject(t.signal.reason);if(S==null&&j.pages.length)return Promise.resolve(j);const I=(()=>{const ee={client:t.client,queryKey:t.queryKey,pageParam:S,direction:E?"backward":"forward",meta:t.options.meta};return v(ee),ee})(),$=await g(I),{maxPages:P}=t.options,R=E?Xm:Gm;return{pages:R(j.pages,$,P),pageParams:R(j.pageParams,S,P)}};if(a&&i.length){const j=a==="backward",S=j?ih:yo,E={pages:i,pageParams:o},_=S(r,E);l=await k(E,_,j)}else{const j=e??i.length;do{const S=c===0?o[0]??r.initialPageParam:yo(r,l);if(c>0&&S==null)break;l=await k(l,S),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var p,v;return(v=(p=t.options).persister)==null?void 0:v.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function yo(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ih(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var tr,An,nr,gt,Pn,Ve,Lr,En,ot,ic,Zt,Al,oh=(Al=class extends ac{constructor(t){super();J(this,ot);J(this,tr);J(this,An);J(this,nr);J(this,gt);J(this,Pn);J(this,Ve);J(this,Lr);J(this,En);U(this,En,!1),U(this,Lr,t.defaultOptions),this.setOptions(t.options),this.observers=[],U(this,Pn,t.client),U(this,gt,w(this,Pn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,U(this,An,vo(this.options)),this.state=t.state??w(this,An),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return w(this,tr)}get promise(){var t;return(t=w(this,Ve))==null?void 0:t.promise}setOptions(t){if(this.options={...w(this,Lr),...t},t!=null&&t._type&&U(this,tr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=vo(this.options);n.data!==void 0&&(this.setState(bo(n.data,n.dataUpdatedAt)),U(this,An,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&w(this,gt).remove(this)}setData(t,n){const r=Pa(this.state.data,t,this.options);return le(this,ot,Zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){le(this,ot,Zt).call(this,{type:"setState",state:t})}cancel(t){var r,a;const n=(r=w(this,Ve))==null?void 0:r.promise;return(a=w(this,Ve))==null||a.cancel(t),n?n.then(et).catch(et):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return w(this,An)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ws||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>pn(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:!tc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,Ve))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=w(this,Ve))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),w(this,gt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(w(this,Ve)&&(w(this,En)||le(this,ot,ic).call(this)?w(this,Ve).cancel({revert:!0}):w(this,Ve).cancelRetry()),this.scheduleGc()),w(this,gt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||le(this,ot,Zt).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,m,h,f,x,p,v,g,k,j;if(this.state.fetchStatus!=="idle"&&((u=w(this,Ve))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(w(this,Ve))return w(this,Ve).continueRetry(),w(this,Ve).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 r=new AbortController,a=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(U(this,En,!0),r.signal)})},i=()=>{const S=nc(this.options,n),_=(()=>{const I={client:w(this,Pn),queryKey:this.queryKey,meta:this.meta};return a(I),I})();return U(this,En,!1),this.options.persister?this.options.persister(S,_,this):S(_)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:w(this,Pn),state:this.state,fetchFn:i};return a(S),S})(),c=w(this,tr)==="infinite"?ah(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),U(this,nr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&le(this,ot,Zt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),U(this,Ve,sc({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof Ia&&S.revert&&this.setState({...w(this,nr),fetchStatus:"idle"}),r.abort()},onFail:(S,E)=>{le(this,ot,Zt).call(this,{type:"failed",failureCount:S,error:E})},onPause:()=>{le(this,ot,Zt).call(this,{type:"pause"})},onContinue:()=>{le(this,ot,Zt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await w(this,Ve).start();if(S===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(S),(f=(h=w(this,gt).config).onSuccess)==null||f.call(h,S,this),(p=(x=w(this,gt).config).onSettled)==null||p.call(x,S,this.state.error,this),S}catch(S){if(S instanceof Ia){if(S.silent)return w(this,Ve).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw le(this,ot,Zt).call(this,{type:"error",error:S}),(g=(v=w(this,gt).config).onError)==null||g.call(v,S,this),(j=(k=w(this,gt).config).onSettled)==null||j.call(k,this.state.data,S,this),S}finally{this.scheduleGc()}}},tr=new WeakMap,An=new WeakMap,nr=new WeakMap,gt=new WeakMap,Pn=new WeakMap,Ve=new WeakMap,Lr=new WeakMap,En=new WeakMap,ot=new WeakSet,ic=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...oc(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...bo(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return U(this,nr,t.manual?a:void 0),a;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),w(this,gt).notify({query:this,type:"updated",action:t})})},Al);function oc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:rc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function bo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function vo(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var nt,he,zr,Xe,In,rr,Wt,on,Mr,sr,ar,Tn,_n,ln,ir,ye,Er,Ta,_a,Da,Fa,Ra,Oa,$a,lc,Pl,lh=(Pl=class extends gr{constructor(t,n){super();J(this,ye);J(this,nt);J(this,he);J(this,zr);J(this,Xe);J(this,In);J(this,rr);J(this,Wt);J(this,on);J(this,Mr);J(this,sr);J(this,ar);J(this,Tn);J(this,_n);J(this,ln);J(this,ir,new Set);this.options=n,U(this,nt,t),U(this,on,null),U(this,Wt,Ea()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(w(this,he).addObserver(this),jo(w(this,he),this.options)?le(this,ye,Er).call(this):this.updateResult(),le(this,ye,Fa).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return La(w(this,he),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return La(w(this,he),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,le(this,ye,Ra).call(this),le(this,ye,Oa).call(this),w(this,he).removeObserver(this)}setOptions(t){const n=this.options,r=w(this,he);if(this.options=w(this,nt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,w(this,he))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");le(this,ye,$a).call(this),w(this,he).setOptions(this.options),n._defaulted&&!Ns(this.options,n)&&w(this,nt).getQueryCache().notify({type:"observerOptionsUpdated",query:w(this,he),observer:this});const a=this.hasListeners();a&&No(w(this,he),r,this.options,n)&&le(this,ye,Er).call(this),this.updateResult(),a&&(w(this,he)!==r||lt(this.options.enabled,w(this,he))!==lt(n.enabled,w(this,he))||pn(this.options.staleTime,w(this,he))!==pn(n.staleTime,w(this,he)))&&le(this,ye,Ta).call(this);const i=le(this,ye,_a).call(this);a&&(w(this,he)!==r||lt(this.options.enabled,w(this,he))!==lt(n.enabled,w(this,he))||i!==w(this,ln))&&le(this,ye,Da).call(this,i)}getOptimisticResult(t){const n=w(this,nt).getQueryCache().build(w(this,nt),t),r=this.createResult(n,t);return uh(this,r)&&(U(this,Xe,r),U(this,rr,this.options),U(this,In,w(this,he).state)),r}getCurrentResult(){return w(this,Xe)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&w(this,Wt).status==="pending"&&w(this,Wt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){w(this,ir).add(t)}getCurrentQuery(){return w(this,he)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=w(this,nt).defaultQueryOptions(t),r=w(this,nt).getQueryCache().build(w(this,nt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return le(this,ye,Er).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),w(this,Xe)))}createResult(t,n){var P;const r=w(this,he),a=this.options,i=w(this,Xe),o=w(this,In),l=w(this,rr),u=t!==r?t.state:w(this,zr),{state:d}=t;let m={...d},h=!1,f;if(n._optimisticResults){const R=this.hasListeners(),ee=!R&&jo(t,n),B=R&&No(t,r,n,a);(ee||B)&&(m={...m,...oc(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:x,errorUpdatedAt:p,status:v}=m;f=m.data;let g=!1;if(n.placeholderData!==void 0&&f===void 0&&v==="pending"){let R;i!=null&&i.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(R=i.data,g=!0):R=typeof n.placeholderData=="function"?n.placeholderData((P=w(this,ar))==null?void 0:P.state.data,w(this,ar)):n.placeholderData,R!==void 0&&(v="success",f=Pa(i==null?void 0:i.data,R,n),h=!0)}if(n.select&&f!==void 0&&!g)if(i&&f===(o==null?void 0:o.data)&&n.select===w(this,Mr))f=w(this,sr);else try{U(this,Mr,n.select),f=n.select(f),f=Pa(i==null?void 0:i.data,f,n),U(this,sr,f),U(this,on,null)}catch(R){U(this,on,R)}w(this,on)&&(x=w(this,on),f=w(this,sr),p=Date.now(),v="error");const k=m.fetchStatus==="fetching",j=v==="pending",S=v==="error",E=j&&k,_=f!==void 0,$={status:v,fetchStatus:m.fetchStatus,isPending:j,isSuccess:v==="success",isError:S,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:x,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:k,isRefetching:k&&!j,isLoadingError:S&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&_,isStale:gi(t,n),refetch:this.refetch,promise:w(this,Wt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=$.data!==void 0,ee=$.status==="error"&&!R,B=Y=>{ee?Y.reject($.error):R&&Y.resolve($.data)},K=()=>{const Y=U(this,Wt,$.promise=Ea());B(Y)},ne=w(this,Wt);switch(ne.status){case"pending":t.queryHash===r.queryHash&&B(ne);break;case"fulfilled":(ee||$.data!==ne.value)&&K();break;case"rejected":(!ee||$.error!==ne.reason)&&K();break}}return $}updateResult(){const t=w(this,Xe),n=this.createResult(w(this,he),this.options);if(U(this,In,w(this,he).state),U(this,rr,this.options),w(this,In).data!==void 0&&U(this,ar,w(this,he)),Ns(n,t))return;U(this,Xe,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!w(this,ir).size)return!0;const o=new Set(i??w(this,ir));return this.options.throwOnError&&o.add("error"),Object.keys(w(this,Xe)).some(l=>{const c=l;return w(this,Xe)[c]!==t[c]&&o.has(c)})};le(this,ye,lc).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&le(this,ye,Fa).call(this)}},nt=new WeakMap,he=new WeakMap,zr=new WeakMap,Xe=new WeakMap,In=new WeakMap,rr=new WeakMap,Wt=new WeakMap,on=new WeakMap,Mr=new WeakMap,sr=new WeakMap,ar=new WeakMap,Tn=new WeakMap,_n=new WeakMap,ln=new WeakMap,ir=new WeakMap,ye=new WeakSet,Er=function(t){le(this,ye,$a).call(this);let n=w(this,he).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(et)),n},Ta=function(){le(this,ye,Ra).call(this);const t=pn(this.options.staleTime,w(this,he));if(Rr.isServer()||w(this,Xe).isStale||!ka(t))return;const r=tc(w(this,Xe).dataUpdatedAt,t)+1;U(this,Tn,Nn.setTimeout(()=>{w(this,Xe).isStale||this.updateResult()},r))},_a=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(w(this,he)):this.options.refetchInterval)??!1},Da=function(t){le(this,ye,Oa).call(this),U(this,ln,t),!(Rr.isServer()||lt(this.options.enabled,w(this,he))===!1||!ka(w(this,ln))||w(this,ln)===0)&&U(this,_n,Nn.setInterval(()=>{(this.options.refetchIntervalInBackground||fi.isFocused())&&le(this,ye,Er).call(this)},w(this,ln)))},Fa=function(){le(this,ye,Ta).call(this),le(this,ye,Da).call(this,le(this,ye,_a).call(this))},Ra=function(){w(this,Tn)!==void 0&&(Nn.clearTimeout(w(this,Tn)),U(this,Tn,void 0))},Oa=function(){w(this,_n)!==void 0&&(Nn.clearInterval(w(this,_n)),U(this,_n,void 0))},$a=function(){const t=w(this,nt).getQueryCache().build(w(this,nt),this.options);if(t===w(this,he))return;const n=w(this,he);U(this,he,t),U(this,zr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},lc=function(t){ze.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(w(this,Xe))}),w(this,nt).getQueryCache().notify({query:w(this,he),type:"observerResultsUpdated"})})},Pl);function ch(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&<(t.retryOnMount,e)===!1)}function jo(e,t){return ch(e,t)||e.state.data!==void 0&&La(e,t,t.refetchOnMount)}function La(e,t,n){if(lt(t.enabled,e)!==!1&&pn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&gi(e,t)}return!1}function No(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&gi(e,n)}function gi(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(pn(t.staleTime,e))}function uh(e,t){return!Ns(e.getCurrentResult(),t)}var qr,_t,Ye,Dn,Dt,en,El,dh=(El=class extends ac{constructor(t){super();J(this,Dt);J(this,qr);J(this,_t);J(this,Ye);J(this,Dn);U(this,qr,t.client),this.mutationId=t.mutationId,U(this,Ye,t.mutationCache),U(this,_t,[]),this.state=t.state||cc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){w(this,_t).includes(t)||(w(this,_t).push(t),this.clearGcTimeout(),w(this,Ye).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){U(this,_t,w(this,_t).filter(n=>n!==t)),this.scheduleGc(),w(this,Ye).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){w(this,_t).length||(this.state.status==="pending"?this.scheduleGc():w(this,Ye).remove(this))}continue(){var t;return((t=w(this,Dn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,m,h,f,x,p,v,g,k,j,S,E,_,I;const n=()=>{le(this,Dt,en).call(this,{type:"continue"})},r={client:w(this,qr),meta:this.options.meta,mutationKey:this.options.mutationKey};U(this,Dn,sc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:($,P)=>{le(this,Dt,en).call(this,{type:"failed",failureCount:$,error:P})},onPause:()=>{le(this,Dt,en).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>w(this,Ye).canRun(this)}));const a=this.state.status==="pending",i=!w(this,Dn).canStart();try{if(a)n();else{le(this,Dt,en).call(this,{type:"pending",variables:t,isPaused:i}),w(this,Ye).config.onMutate&&await w(this,Ye).config.onMutate(t,this,r);const P=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,r));P!==this.state.context&&le(this,Dt,en).call(this,{type:"pending",context:P,variables:t,isPaused:i})}const $=await w(this,Dn).start();return await((u=(c=w(this,Ye).config).onSuccess)==null?void 0:u.call(c,$,t,this.state.context,this,r)),await((m=(d=this.options).onSuccess)==null?void 0:m.call(d,$,t,this.state.context,r)),await((f=(h=w(this,Ye).config).onSettled)==null?void 0:f.call(h,$,null,this.state.variables,this.state.context,this,r)),await((p=(x=this.options).onSettled)==null?void 0:p.call(x,$,null,t,this.state.context,r)),le(this,Dt,en).call(this,{type:"success",data:$}),$}catch($){try{await((g=(v=w(this,Ye).config).onError)==null?void 0:g.call(v,$,t,this.state.context,this,r))}catch(P){Promise.reject(P)}try{await((j=(k=this.options).onError)==null?void 0:j.call(k,$,t,this.state.context,r))}catch(P){Promise.reject(P)}try{await((E=(S=w(this,Ye).config).onSettled)==null?void 0:E.call(S,void 0,$,this.state.variables,this.state.context,this,r))}catch(P){Promise.reject(P)}try{await((I=(_=this.options).onSettled)==null?void 0:I.call(_,void 0,$,t,this.state.context,r))}catch(P){Promise.reject(P)}throw le(this,Dt,en).call(this,{type:"error",error:$}),$}finally{w(this,Ye).runNext(this)}}},qr=new WeakMap,_t=new WeakMap,Ye=new WeakMap,Dn=new WeakMap,Dt=new WeakSet,en=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,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{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ze.batch(()=>{w(this,_t).forEach(r=>{r.onMutationUpdate(t)}),w(this,Ye).notify({mutation:this,type:"updated",action:t})})},El);function cc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yt,St,Vr,Il,mh=(Il=class extends gr{constructor(t={}){super();J(this,Yt);J(this,St);J(this,Vr);this.config=t,U(this,Yt,new Set),U(this,St,new Map),U(this,Vr,0)}build(t,n,r){const a=new dh({client:t,mutationCache:this,mutationId:++es(this,Vr)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){w(this,Yt).add(t);const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n);r?r.push(t):w(this,St).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(w(this,Yt).delete(t)){const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&w(this,St).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ns(t);if(typeof n=="string"){const r=w(this,St).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=ns(t);if(typeof n=="string"){const a=(r=w(this,St).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ze.batch(()=>{w(this,Yt).forEach(t=>{this.notify({type:"removed",mutation:t})}),w(this,Yt).clear(),w(this,St).clear()})}getAll(){return Array.from(w(this,Yt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>po(n,r))}findAll(t={}){return this.getAll().filter(n=>po(t,n))}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ze.batch(()=>Promise.all(t.map(n=>n.continue().catch(et))))}},Yt=new WeakMap,St=new WeakMap,Vr=new WeakMap,Il);function ns(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ht,cn,rt,Kt,Qt,xs,za,Tl,hh=(Tl=class extends gr{constructor(t,n){super();J(this,Qt);J(this,Ht);J(this,cn);J(this,rt);J(this,Kt);U(this,Ht,t),this.setOptions(n),this.bindMethods(),le(this,Qt,xs).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=w(this,Ht).defaultMutationOptions(t),Ns(this.options,n)||w(this,Ht).getMutationCache().notify({type:"observerOptionsUpdated",mutation:w(this,rt),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Fn(n.mutationKey)!==Fn(this.options.mutationKey)?this.reset():((r=w(this,rt))==null?void 0:r.state.status)==="pending"&&w(this,rt).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=w(this,rt))==null||t.removeObserver(this)}onMutationUpdate(t){le(this,Qt,xs).call(this),le(this,Qt,za).call(this,t)}getCurrentResult(){return w(this,cn)}reset(){var t;(t=w(this,rt))==null||t.removeObserver(this),U(this,rt,void 0),le(this,Qt,xs).call(this),le(this,Qt,za).call(this)}mutate(t,n){var r;return U(this,Kt,n),(r=w(this,rt))==null||r.removeObserver(this),U(this,rt,w(this,Ht).getMutationCache().build(w(this,Ht),this.options)),w(this,rt).addObserver(this),w(this,rt).execute(t)}},Ht=new WeakMap,cn=new WeakMap,rt=new WeakMap,Kt=new WeakMap,Qt=new WeakSet,xs=function(){var n;const t=((n=w(this,rt))==null?void 0:n.state)??cc();U(this,cn,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},za=function(t){ze.batch(()=>{var n,r,a,i,o,l,c,u;if(w(this,Kt)&&this.hasListeners()){const d=w(this,cn).variables,m=w(this,cn).context,h={client:w(this,Ht),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(n=w(this,Kt)).onSuccess)==null||r.call(n,t.data,d,m,h)}catch(f){Promise.reject(f)}try{(i=(a=w(this,Kt)).onSettled)==null||i.call(a,t.data,null,d,m,h)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=w(this,Kt)).onError)==null||l.call(o,t.error,d,m,h)}catch(f){Promise.reject(f)}try{(u=(c=w(this,Kt)).onSettled)==null||u.call(c,void 0,t.error,d,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(d=>{d(w(this,cn))})})},Tl),Ft,_l,fh=(_l=class extends gr{constructor(t={}){super();J(this,Ft);this.config=t,U(this,Ft,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??pi(a,n);let o=this.get(i);return o||(o=new oh({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){w(this,Ft).has(t.queryHash)||(w(this,Ft).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=w(this,Ft).get(t.queryHash);n&&(t.destroy(),n===t&&w(this,Ft).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ze.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return w(this,Ft).get(t)}getAll(){return[...w(this,Ft).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>fo(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>fo(t,r)):n}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ft=new WeakMap,_l),Fe,un,dn,or,lr,mn,cr,ur,Dl,ph=(Dl=class{constructor(e={}){J(this,Fe);J(this,un);J(this,dn);J(this,or);J(this,lr);J(this,mn);J(this,cr);J(this,ur);U(this,Fe,e.queryCache||new fh),U(this,un,e.mutationCache||new mh),U(this,dn,e.defaultOptions||{}),U(this,or,new Map),U(this,lr,new Map),U(this,mn,0)}mount(){es(this,mn)._++,w(this,mn)===1&&(U(this,cr,fi.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,Fe).onFocus())})),U(this,ur,Ss.subscribe(async e=>{e&&(await this.resumePausedMutations(),w(this,Fe).onOnline())})))}unmount(){var e,t;es(this,mn)._--,w(this,mn)===0&&((e=w(this,cr))==null||e.call(this),U(this,cr,void 0),(t=w(this,ur))==null||t.call(this),U(this,ur,void 0))}isFetching(e){return w(this,Fe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return w(this,un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,Fe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=w(this,Fe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(pn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return w(this,Fe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=w(this,Fe).get(r.queryHash),i=a==null?void 0:a.state.data,o=Km(t,i);if(o!==void 0)return w(this,Fe).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>w(this,Fe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=w(this,Fe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=w(this,Fe);ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=w(this,Fe);return ze.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ze.batch(()=>w(this,Fe).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(et).catch(et)}invalidateQueries(e,t={}){return ze.batch(()=>(w(this,Fe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ze.batch(()=>w(this,Fe).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(et)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(et)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=w(this,Fe).build(this,t);return n.isStaleByTime(pn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(et).catch(et)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(et).catch(et)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ss.isOnline()?w(this,un).resumePausedMutations():Promise.resolve()}getQueryCache(){return w(this,Fe)}getMutationCache(){return w(this,un)}getDefaultOptions(){return w(this,dn)}setDefaultOptions(e){U(this,dn,e)}setQueryDefaults(e,t){w(this,or).set(Fn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...w(this,or).values()],n={};return t.forEach(r=>{Fr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){w(this,lr).set(Fn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...w(this,lr).values()],n={};return t.forEach(r=>{Fr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...w(this,dn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=pi(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===ws&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...w(this,dn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){w(this,Fe).clear(),w(this,un).clear()}},Fe=new WeakMap,un=new WeakMap,dn=new WeakMap,or=new WeakMap,lr=new WeakMap,mn=new WeakMap,cr=new WeakMap,ur=new WeakMap,Dl),uc=A.createContext(void 0),ft=e=>{const t=A.useContext(uc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},xh=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(uc.Provider,{value:e,children:t})),dc=A.createContext(!1),gh=()=>A.useContext(dc);dc.Provider;function yh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var bh=A.createContext(yh()),vh=()=>A.useContext(bh),jh=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?xi(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Nh=e=>{A.useEffect(()=>{e.clearReset()},[e])},wh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||xi(n,[e.error,r])),Sh=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},kh=(e,t)=>e.isLoading&&e.isFetching&&!t,Ch=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,wo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ah(e,t,n){var f,x,p,v;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 r=gh(),a=vh(),i=ft(),o=i.defaultQueryOptions(e);(x=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||x.call(f,o);const l=i.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`));const c=e.subscribed!==!1;o._optimisticResults=r?"isRestoring":c?"optimistic":void 0,Sh(o),jh(o,a,l),Nh(a);const u=!i.getQueryCache().get(o.queryHash),[d]=A.useState(()=>new t(i,o)),m=d.getOptimisticResult(o),h=!r&&c;if(A.useSyncExternalStore(A.useCallback(g=>{const k=h?d.subscribe(ze.batchCalls(g)):et;return d.updateResult(),k},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),A.useEffect(()=>{d.setOptions(o)},[o,d]),Ch(o,m))throw wo(o,d,a);if(wh({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((v=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||v.call(p,o,m),o.experimental_prefetchInRender&&!Rr.isServer()&&kh(m,r)){const g=u?wo(o,d,a):l==null?void 0:l.promise;g==null||g.catch(et).finally(()=>{d.updateResult()})}return o.notifyOnChangeProps?m:d.trackResult(m)}function ve(e,t){return Ah(e,lh)}function Ph(e,t){const n=ft(),[r]=A.useState(()=>new hh(n,e));A.useEffect(()=>{r.setOptions(e)},[r,e]);const a=A.useSyncExternalStore(A.useCallback(o=>r.subscribe(ze.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=A.useCallback((o,l)=>{r.mutate(o,l).catch(et)},[r]);if(a.error&&xi(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function mc(e){return e.trim().replace(/\/+$/,"")}const qs=new Map;function hc(e,t){qs.set(e,t)}function Eh(e){return qs.get(e)}function Ih(e){qs.delete(e)}function Th(e){for(const[t,n]of qs)if(n.accessToken===e)return t}let Ma=null;function fc(e){Ma=mc(e)}let pc=null;function _h(e){pc=e}function Dh(){return pc}let xc=null;function Fh(e){xc=e.trim()}function Rh(){return xc}function Oh(){return Ma!==null?Ma:mc("")}const So={get apiBaseUrl(){return Oh()},apiVersion:"v1"};function $h(e){const t=e.startsWith("/")?e:`/${e}`;return`${So.apiBaseUrl}/api/${So.apiVersion}${t}`}const gc="auth:session-expired";function Lh(){window.dispatchEvent(new CustomEvent(gc))}function yc(e){return`${gc}:${e}`}const zh=N.createContext(null);function Mh({instanceId:e,accessToken:t,onSessionExpired:n,children:r}){const a=Eh(e);return a&&hc(e,{...a,accessToken:t}),_h(t),N.useEffect(()=>{if(!n)return;const i=yc(e),o=()=>n();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,n]),s.jsx(zh.Provider,{value:{accessToken:t},children:r})}class yr extends Error{constructor(n,r,a,i,o){super(a??r);wr(this,"status");wr(this,"title");wr(this,"details");wr(this,"extensions");this.name="ApiError",this.status=n,this.title=r,this.details=i,this.extensions=o}}const bc="tax-remittance.auth";function qh(){var t;const e=localStorage.getItem(bc);if(!e)return null;try{const n=JSON.parse(e);return!n.accessToken||!((t=n.user)!=null&&t.userId)?null:new Date(n.user.expiresAt)<=new Date?(qa(),null):n}catch{return qa(),null}}function qa(){localStorage.removeItem(bc)}function Vh(){var e;return((e=qh())==null?void 0:e.accessToken)??null}async function Bh(e){let t=null;try{t=await e.json()}catch{}const n=(t==null?void 0:t.title)??"Request failed",r=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new yr(e.status,n,r,a,t??void 0)}async function Wr(e,t={}){const{body:n,auth:r=!0,headers:a,responseType:i="json",...o}=t,l=new Headers(a);i==="blob"?l.set("Accept","application/pdf"):i==="text"?l.set("Accept","text/html"):l.set("Accept","application/json"),n!==void 0&&l.set("Content-Type","application/json");let c=null;if(r){const m=Dh()??Vh();m&&(c=m,l.set("Authorization",`Bearer ${m}`))}const u=Rh();u&&l.set("X-Client-ID",u);const d=await fetch($h(e),{...o,headers:l,body:n!==void 0?JSON.stringify(n):void 0});if(!d.ok){const m=await Bh(d);if(r&&m.status===401){qa();const h=c?Th(c):void 0;h?window.dispatchEvent(new CustomEvent(yc(h))):Lh()}throw m}if(d.status!==204)return i==="blob"?await d.blob():i==="text"?await d.text():await d.json()}async function me(e,t={}){return(await Wr(e,t)).data}const st=10;function yi({search:e,pageNumber:t=1,pageSize:n=st}={}){const r=new URLSearchParams({pageNumber:String(t),pageSize:String(n)});return e!=null&&e.trim()&&r.set("search",e.trim()),me(`/portal/entities/mine?${r}`)}function Uh(e){return me("/portal/entities",{method:"POST",body:e})}function Zh(e,t){return me(`/portal/entities/${e}`,{method:"PATCH",body:t})}const vc=N.createContext(null);function Wh({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:n,children:r}){var p;const[a,i]=N.useState(null),{data:o=[],isLoading:l,isError:c,refetch:u}=ve({queryKey:["entities","mine"],queryFn:async()=>(await yi({pageNumber:1,pageSize:100})).items}),d=N.useRef(new Set),m=N.useRef(!1);N.useEffect(()=>{if(l)return;if(!m.current){o.forEach(g=>d.current.add(g.entityId)),m.current=!0;return}o.filter(g=>!d.current.has(g.entityId)).forEach(g=>{d.current.add(g.entityId),e==null||e(g)})},[o,l,e]);const h=a!==null&&o.some(v=>v.entityId===a)?a:((p=o[0])==null?void 0:p.entityId)??null,f=o.find(v=>v.entityId===h)??null,x=async()=>{await u()};return s.jsx(vc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:f,setSelectedEntityId:i,refetchEntities:x,enabledPayments:t,onPaymentRequired:n},children:r})}function qn(){const e=N.useContext(vc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const Yh=N.createContext(null);function Hh({theme:e,children:t}){const n={},r=n,a=(e==null?void 0:e.primaryColor)??"#2563eb";r["--embedded-primary"]=a,r["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,r["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";r["--embedded-secondary"]=i,r["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,r["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return r["--embedded-tertiary"]=o,r["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,r["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(r["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(n.fontFamily=e.fontFamily),r.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:n,children:t})}const jc=N.createContext(null),Kh=6e3;function Qh(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Jh({toast:e,onDismiss:t}){const n=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${n?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[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 ${n?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(Gh,{})})]}),s.jsx("div",{className:`mx-5 border-t ${n?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function Gh(){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 Xh({children:e}){const[t,n]=N.useState([]),r=N.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]),a=N.useCallback((o,l,c)=>{const u=Qh();n(d=>[...d,{id:u,variant:o,title:l,message:c}]),window.setTimeout(()=>{r(u)},Kh)},[r]),i=N.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(jc.Provider,{value:i,children:[e,Br.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(Jh,{toast:o,onDismiss:r})},o.id))}),document.body)]})}function Vs(){const e=N.useContext(jc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class ef 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 tf(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 nf({navigateFnRef:e,onNavigate:t}){const n=Ae(),r=Ce();return N.useEffect(()=>(e.current=n,()=>{e.current=null}),[n,e]),N.useEffect(()=>{t==null||t(tf(r.pathname),r.pathname)},[r.pathname,t]),null}function rf({selectEntityFnRef:e}){const{setSelectedEntityId:t}=qn();return N.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function bi({appKey:e,accessToken:t,apiBaseUrl:n,theme:r,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:u,enabledPayments:d,children:m}){const[h]=N.useState(()=>crypto.randomUUID());hc(h,{apiBaseUrl:n.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),fc(n),Fh(e),N.useEffect(()=>()=>{Ih(h)},[h]);const[f]=N.useState(()=>new ph({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return s.jsx(Yh.Provider,{value:h,children:s.jsx(Hh,{theme:r,children:s.jsx(xh,{client:f,children:s.jsx(Xh,{children:s.jsx(Mh,{instanceId:h,accessToken:t,onSessionExpired:a,children:s.jsx(om,{children:s.jsxs(Wh,{onOrganizationCreated:i,enabledPayments:d,onPaymentRequired:l,children:[s.jsx(nf,{navigateFnRef:c,onNavigate:o}),s.jsx(rf,{selectEntityFnRef:u}),s.jsx(ef,{children:m})]})})})})})})})}function vi(){const{entities:e,isLoading:t,isError:n,refetchEntities:r}=qn(),a=Ae();return N.useEffect(()=>{t||n||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,n,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"})}):n?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:r,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 ji(){const{entities:e,selectedEntity:t,setSelectedEntityId:n}=qn(),r=Ae(),i=Ce().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:()=>r(-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(sf,{}),"Back"]}),s.jsx("div",{className:"flex-1"})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(lm,{context:{entities:e,selectedEntity:t,setSelectedEntityId:n}})})]})}function sf(){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 af=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function of({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(ko,{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:af.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(rs,{})}),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(ko,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",s.jsx(lf,{})]})]})]}),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(rs,{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(rs,{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(rs,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function ko({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 rs({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 lf(){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 Ni(){const e=Ae(),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(of,{onCreateClick:t})})}var Yr=e=>e.type==="checkbox",hn=e=>e instanceof Date,Ze=e=>e==null;const wi=e=>typeof e=="object";var Ee=e=>!Ze(e)&&!Array.isArray(e)&&wi(e)&&!hn(e),Va=e=>Ee(e)&&e.target?Yr(e.target)?e.target.checked:e.target.value:e,Nc=(e,t)=>t.split(".").some((n,r,a)=>!isNaN(Number(n))&&e.has(a.slice(0,r).join("."))),wc=e=>{const t=e.constructor&&e.constructor.prototype;return Ee(t)&&t.hasOwnProperty("isPrototypeOf")},Bs=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function De(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Bs&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(Ee(e)&&wc(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=De(e[a]));return r}const tn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},wt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Sc="root",Si=["__proto__","constructor","prototype"],cf=/^\w*$/;var Hr=e=>cf.test(e),we=e=>e===void 0;const uf=/[.[\]'"]/;var Us=e=>e.split(uf).filter(Boolean),V=(e,t,n)=>{if(!t||!Ee(e))return n;const r=Hr(t)?[t]:Us(t);if(r.some(i=>Si.includes(i)))return n;const a=r.reduce((i,o)=>Ze(i)?void 0:i[o],e);return we(a)||a===e?we(e[t])?n:e[t]:a},ct=e=>typeof e=="boolean",He=e=>typeof e=="function",ge=(e,t,n)=>{let r=-1;const a=Hr(t)?[t]:Us(t),i=a.length,o=i-1;for(;++r<i;){const l=a[r];let c=n;if(r!==o){const u=e[l];c=Ee(u)||Array.isArray(u)?u:isNaN(+a[r+1])?{}:[]}if(Si.includes(l))return;e[l]=c,e=e[l]}};const kc=N.createContext(null);kc.displayName="HookFormControlContext";const ki=()=>N.useContext(kc);var Cc=(e,t,n,r=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==kt.all&&(t._proxyFormState[o]=!r||kt.all),n&&(n[o]=!0),e[o]}});return a};const Ci=Bs?N.useLayoutEffect:N.useEffect;function df(e){const t=ki(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[o,l]=N.useState(()=>({...n._formState,defaultValues:n._defaultValues})),c=N.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ci(()=>n._subscribe({name:a,formState:c.current,exact:i,callback:u=>{!r&&l({...n._formState,...u,defaultValues:n._defaultValues})}}),[a,r,i]),N.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),N.useMemo(()=>Cc(o,n,c.current,!1),[o,n])}var Ke=e=>typeof e=="string",Ba=(e,t,n,r,a)=>Ke(e)?(r&&t.watch.add(e),V(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),V(n,i))):(r&&(t.watchAll=!0),n),Ua=e=>Ze(e)||!wi(e);const Co=(e,t)=>t.length===0&&!Array.isArray(e)&&!wc(e);function ut(e,t,n=new WeakMap){if(e===t)return!0;if(Ua(e)||Ua(t))return Object.is(e,t);if(hn(e)&&hn(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(Co(e,r)||Co(t,a))return Object.is(e,t);if(!r.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=n.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),n.set(e,o)}for(const o of r){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(hn(l)&&hn(c)||(Ee(l)||Array.isArray(l))&&(Ee(c)||Array.isArray(c))?!ut(l,c,n):!Object.is(l,c))return!1}}return!0}function mf(e){const t=ki(),{control:n=t,name:r,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(n),h=N.useRef(r);u.current=l;const[f,x]=N.useState(()=>{const S=n._getWatch(r,c.current);return u.current?u.current(S):S}),p=N.useCallback(S=>{const E=Ba(r,n._names,S||n._formValues,!1,c.current);return u.current?u.current(E):E},[n._formValues,n._names,r]),v=N.useCallback(S=>{if(!i){const E=Ba(r,n._names,S||n._formValues,!1,c.current);if(u.current){const _=u.current(E);ut(_,d.current)||(x(_),d.current=_)}else x(E)}},[n._formValues,n._names,i,r]);Ci(()=>((m.current!==n||!ut(h.current,r))&&(m.current=n,h.current=r,v()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:S=>{v(S.values)}})),[n,o,r,v]),N.useEffect(()=>n._removeUnmounted());const g=m.current!==n,k=h.current,j=N.useMemo(()=>{if(i)return null;const S=!g&&!ut(k,r);return g||S?p():null},[i,g,r,k,p]);return j!==null?j:f}function hf(e){const t=ki(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=Nc(a._names.array,n),u=N.useMemo(()=>V(a._formValues,n,V(a._defaultValues,n,o)),[a,n,o]),d=mf({control:a,name:n,defaultValue:u,exact:l}),m=df({control:a,name:n,exact:l}),h=N.useRef(e),f=N.useRef(null),x=N.useRef(a.register(n,{...e.rules,value:d,...ct(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=N.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!V(m.errors,n)},isDirty:{enumerable:!0,get:()=>!!V(m.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!V(m.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!V(m.validatingFields,n)},error:{enumerable:!0,get:()=>V(m.errors,n)}}),[m,n]),v=N.useCallback(S=>{const E=Va(S);return V(a._fields,n)||(x.current=a.register(n,{...h.current.rules,value:E})),x.current.onChange({target:{value:Va(S),name:n},type:tn.CHANGE})},[n,a]),g=N.useCallback(()=>x.current.onBlur({target:{value:V(a._formValues,n),name:n},type:tn.BLUR}),[n,a._formValues]),k=N.useCallback(S=>{S&&(f.current={focus:()=>He(S.focus)&&S.focus(),select:()=>He(S.select)&&S.select(),setCustomValidity:_=>He(S.setCustomValidity)&&S.setCustomValidity(_),reportValidity:()=>He(S.reportValidity)&&S.reportValidity()});const E=V(a._fields,n);E&&E._f&&S&&(E._f.ref=f.current)},[a._fields,n]),j=N.useMemo(()=>({name:n,value:d,...ct(r)||m.disabled?{disabled:m.disabled||r}:{},onChange:v,onBlur:g,ref:k}),[n,r,m.disabled,v,g,k,d]);return N.useEffect(()=>{const S=a._options.shouldUnregister||i;a.register(n,{...h.current.rules,...ct(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(_,I)=>{const $=V(a._fields,_);$&&$._f&&($._f.mount=I)};if(E(n,!0),S){const _=De(V(i?a._defaultValues:a._options.values||a._defaultValues,n,V(a._options.defaultValues,n,h.current.defaultValue)));ge(a._defaultValues,n,_),we(V(a._formValues,n))&&ge(a._formValues,n,_)}if(!c&&a.register(n),f.current){const _=V(a._fields,n);_&&_._f&&(_._f.ref=f.current)}return()=>{(c?S&&!a._state.action:S)?a.unregister(n):E(n,!1)}},[n,a,c,i]),N.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),N.useMemo(()=>({field:j,formState:m,fieldState:p}),[j,m,p])}const Le=e=>e.render(hf(e)),Ac=e=>{const t={};for(const n of Object.keys(e))if(wi(e[n])&&e[n]!==null&&!hn(e[n])){const r=Ac(e[n]);for(const a of Object.keys(r))t[`${n}.${a}`]=r[a]}else t[n]=e[n];return t},ff=N.createContext(null);ff.displayName="HookFormContext";var Ai=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Pc=e=>Array.isArray(e)?e.filter(Boolean):[],gs=e=>Array.isArray(e)?e:[e],Ao=()=>{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 Ec(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&Ee(a)&&i){const o=Ec(a,i);Ee(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var Ue=e=>Ee(e)&&!Object.keys(e).length,Pi=e=>e.type==="file",ks=e=>{if(!Bs)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ic=e=>e.type==="select-multiple",Ei=e=>e.type==="radio",pf=e=>Ei(e)||Yr(e),oa=e=>ks(e)&&e.isConnected;function xf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;){if(Ze(e)){e=void 0;break}e=e[t[r]],r++}return e}function gf(e){for(const t in e)if(e.hasOwnProperty(t)&&!we(e[t]))return!1;return!0}function $e(e,t){if(Ke(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Hr(t)?[t]:Us(t);if(n.some(o=>Si.includes(String(o))))return e;const r=n.length===1?e:xf(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(Ee(r)&&Ue(r)||Array.isArray(r)&&gf(r))&&$e(e,n.slice(0,-1)),e}var yf=e=>{for(const t in e)if(He(e[t]))return!0;return!1};function Tc(e){return Array.isArray(e)||Ee(e)&&!yf(e)}function Za(e,t={}){for(const n in e){const r=e[n];Tc(r)?(t[n]=Array.isArray(r)?[]:{},Za(r,t[n])):we(r)||(t[n]=!0)}return t}function Wa(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>Wa(n));return t.some(n=>n!==void 0)?t:void 0}if(Ee(e)){const t={};for(const n in e){const r=Wa(e[n]);we(r)||(t[n]=r)}return Object.keys(t).length?t:void 0}}}function jn(e,t,n){n||(n=Za(t));for(const r in e){const a=e[r];if(Tc(a))we(t)||Ua(n[r])?n[r]=Za(a,Array.isArray(a)?[]:{}):jn(a,Ze(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!ut(a,i)}}return Wa(n)||{}}const Po={value:!1,isValid:!1},Eo={value:!0,isValid:!0};var _c=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!we(e[0].attributes.value)?we(e[0].value)||e[0].value===""?Eo:{value:e[0].value,isValid:!0}:Eo:Po}return Po},Dc=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>we(e)?e:t?e===""?NaN:e&&+e:n&&Ke(e)?new Date(e):r?r(e):e;const Io={isValid:!1,value:null};var Fc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Io):Io;function To(e){const t=e.ref;return Pi(t)?t.files:Ei(t)?Fc(e.refs).value:Ic(t)?[...t.selectedOptions].map(({value:n})=>n):Yr(t)?_c(e.refs).value:Dc(we(t.value)?e.ref.value:t.value,e)}var bf=(e,t,n,r)=>{const a={};for(const i of e){const o=V(t,i);o&&ge(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},Cs=e=>e instanceof RegExp,kr=e=>we(e)?e:Cs(e)?e.source:Ee(e)?Cs(e.value)?e.value.source:e.value:e,ss=e=>({isOnSubmit:!e||e===kt.onSubmit,isOnBlur:e===kt.onBlur,isOnChange:e===kt.onChange,isOnAll:e===kt.all,isOnTouch:e===kt.onTouched});const _o="AsyncFunction";var vf=e=>{if(!e||!e.validate)return!1;if(He(e.validate))return e.validate.constructor.name===_o;if(Ee(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===_o)return!0}return!1},jf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),la=(e,t,n)=>{if(n)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const r of t.watch)if(e.startsWith(r)&&e.charAt(r.length)===".")return!0;return!1};const _r=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=V(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(_r(l,t))break}else if(Ee(l)&&_r(l,t))break}}};function Do(e,t,n){const r=V(e,n);if(r||Hr(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=V(t,i),l=V(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:n}}var Nf=(e,t,n,r)=>{n(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||r&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!r||kt.all))},wf=(e,t,n)=>!e||!t||e===t||gs(e).some(r=>r&&(n?r===t||r.startsWith(t+"."):r.startsWith(t)||t.startsWith(r))),Sf=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,kf=(e,t)=>!Pc(V(e,t)).length&&$e(e,t),Fo=(e,t,n)=>{const r=V(e,n),a=Array.isArray(r)?r:[];return ge(a,Sc,t[n]),ge(e,n,a),e};function Ro(e,t,n="validate"){if(Ke(e)||Array.isArray(e)&&e.every(Ke)||ct(e)&&!e)return{type:n,message:Ke(e)?e:"",ref:t}}var Zn=e=>Ee(e)&&!Cs(e)?e:{value:e,message:""},Oo=async(e,t,n,r,a,i)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:m,max:h,pattern:f,validate:x,name:p,valueAsNumber:v,mount:g}=e._f,k=V(n,p);if(!g||t.has(p))return{};const j=l?l[0]:o,S=B=>{if(a&&j.reportValidity){const K=ct(B)?"":B||"";l?l.forEach(ne=>ne.setCustomValidity(K)):j.setCustomValidity(K),j.reportValidity()}},E={},_=Ei(o),I=Yr(o),$=_||I,P=(v||Pi(o))&&we(o.value)&&we(k)||ks(o)&&o.value===""||k===""||Array.isArray(k)&&!k.length,R=Ai.bind(null,p,r,E),ee=(B,K,ne,Y=wt.maxLength,ce=wt.minLength)=>{const fe=B?K:ne;E[p]={type:B?Y:ce,message:fe,ref:o,...R(B?Y:ce,fe)}};if(i?!Array.isArray(k)||!k.length:c&&(!$&&(P||Ze(k))||ct(k)&&!k||I&&!_c(l).isValid||_&&!Fc(l).isValid)){const{value:B,message:K}=Ke(c)?{value:!!c,message:c}:Zn(c);if(B&&(E[p]={type:wt.required,message:K,ref:j,...R(wt.required,K)},!r))return S(K),E}if(!P&&(!Ze(m)||!Ze(h))){let B,K;const ne=Zn(h),Y=Zn(m);if(!Ze(k)&&!isNaN(k)){const ce=o.valueAsNumber||k&&+k;Ze(ne.value)||(B=ce>ne.value),Ze(Y.value)||(K=ce<Y.value)}else{const ce=o.valueAsDate||new Date(k),fe=se=>new Date(new Date().toDateString()+" "+se),Q=o.type=="time",ke=o.type=="week";Ke(ne.value)&&k&&(B=Q?fe(k)>fe(ne.value):ke?k>ne.value:ce>new Date(ne.value)),Ke(Y.value)&&k&&(K=Q?fe(k)<fe(Y.value):ke?k<Y.value:ce<new Date(Y.value))}if((B||K)&&(ee(!!B,ne.message,Y.message,wt.max,wt.min),!r))return S(E[p].message),E}if((u||d)&&!P&&(Ke(k)||i&&Array.isArray(k))){const B=Zn(u),K=Zn(d),ne=!Ze(B.value)&&k.length>+B.value,Y=!Ze(K.value)&&k.length<+K.value;if((ne||Y)&&(ee(ne,B.message,K.message),!r))return S(E[p].message),E}if(f&&!P&&Ke(k)){const{value:B,message:K}=Zn(f);if(Cs(B)&&!k.match(B)&&(E[p]={type:wt.pattern,message:K,ref:o,...R(wt.pattern,K)},!r))return S(K),E}if(x){if(He(x)){const B=await x(k,n),K=Ro(B,j);if(K&&(E[p]={...K,...R(wt.validate,K.message)},!r))return S(K.message),E}else if(Ee(x)){let B={};for(const K in x){if(!Ue(B)&&!r)break;const ne=Ro(await x[K](k,n),j,K);ne&&(B={...ne,...R(K,ne.message)},S(ne.message),r&&(E[p]=B))}if(!Ue(B)&&(E[p]={ref:j,...B},!r))return E}}return S(!0),E};const Cf={mode:kt.onSubmit,reValidateMode:kt.onChange,shouldFocusError:!0},ca="form",Rc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Af(e={}){let t={...Cf,...e},n={...De(Rc),isLoading:He(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},a=Ee(t.defaultValues)||Ee(t.values)?De(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:De(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=ss(t.mode),h=ss(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={...f};let p={...x};const v={array:Ao(),state:Ao()},g=t.criteriaMode===kt.all,k=b=>C=>{clearTimeout(u),u=setTimeout(b,C)},j=async b=>{if(!o.keepIsValid&&!t.disabled&&(x.isValid||p.isValid||b)){let C;t.resolver?(C=Ue((await K()).errors),S()):C=await ce({fields:r,onlyCheckValid:!0,eventType:tn.VALID}),C!==n.isValid&&v.state.next({isValid:C})}},S=(b,C)=>{!t.disabled&&(x.isValidating||x.validatingFields||p.isValidating||p.validatingFields)&&((b||Array.from(l.mount)).forEach(y=>{y&&(C?ge(n.validatingFields,y,C):$e(n.validatingFields,y))}),v.state.next({validatingFields:n.validatingFields,isValidating:!Ue(n.validatingFields)}))},E=()=>{n.dirtyFields=jn(a,i)},_=(b,C=[],y,F,L=!0,Z=!0)=>{if(F&&y&&!t.disabled){if(o.action=!0,Z&&Array.isArray(V(r,b))){const M=y(V(r,b),F.argA,F.argB);L&&ge(r,b,M)}if(Z&&Array.isArray(V(n.errors,b))){const M=y(V(n.errors,b),F.argA,F.argB);L&&ge(n.errors,b,M),kf(n.errors,b)}if((x.touchedFields||p.touchedFields)&&Z&&Array.isArray(V(n.touchedFields,b))){const M=y(V(n.touchedFields,b),F.argA,F.argB);L&&ge(n.touchedFields,b,M)}(x.dirtyFields||p.dirtyFields)&&E(),v.state.next({name:b,isDirty:Q(b,C),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ge(i,b,C)},I=(b,C)=>{ge(n.errors,b,C),n.errors={...n.errors},v.state.next({errors:n.errors})},$=b=>{n.errors=b,v.state.next({errors:n.errors,isValid:!1})},P=b=>{const C=Hr(b)?[b]:Us(b);let y=i,F=a;for(let L=0;L<C.length-1;L++){const Z=C[L];if(y=Ze(y)?y:y[Z],F=Ze(F)?F:F[Z],y===null&&F!==null)return!0}return!1},R=(b,C,y,F)=>{const L=V(r,b);if(L){if(P(b))return;const Z=we(V(i,b)),M=V(i,b,we(y)?V(a,b):y);we(M)||F&&F.defaultChecked||C?ge(i,b,C?M:To(L._f)):Se(b,M),o.mount&&!o.action&&(j(),Z&&n.isDirty&&(x.isDirty||p.isDirty)&&(Q()||(n.isDirty=!1,v.state.next({...n}))),e.shouldUnregister&&Z&&!we(V(i,b))&&la(b,l)&&(o.watch=!0))}},ee=(b,C,y,F,L)=>{let Z=!1,M=!1;const W={name:b};if(!t.disabled){if(!y||F){const q=ut(V(a,b),C);(x.isDirty||p.isDirty)&&(M=n.isDirty,n.isDirty=W.isDirty=!q||Q(),Z=M!==W.isDirty),M=!!V(n.dirtyFields,b),q!==n.isDirty?n.dirtyFields=jn(a,i):q?$e(n.dirtyFields,b):ge(n.dirtyFields,b,!0),W.dirtyFields=n.dirtyFields,Z=Z||(x.dirtyFields||p.dirtyFields)&&M!==!q}if(y){const q=V(n.touchedFields,b);q||(ge(n.touchedFields,b,y),W.touchedFields=n.touchedFields,Z=Z||(x.touchedFields||p.touchedFields)&&q!==y)}Z&&L&&v.state.next(W)}return Z?W:{}},B=(b,C,y,F)=>{const L=V(n.errors,b),Z=(x.isValid||p.isValid)&&ct(C)&&n.isValid!==C;if(t.delayError&&y?(c=k(()=>I(b,y)),c(t.delayError)):(clearTimeout(u),c=null,y?ge(n.errors,b,y):$e(n.errors,b),n.errors={...n.errors}),(y?!ut(L,y):L)||!Ue(F)||Z){const M={...F,...Z&&ct(C)?{isValid:C}:{},errors:n.errors,name:b};n={...n,...M},v.state.next(M)}},K=async b=>(S(b,!0),await t.resolver(i,t.context,bf(b||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),ne=async b=>{const{errors:C}=await K(b);if(S(b),b){for(const y of b){const F=V(C,y);F?l.array.has(y)&&Ee(F)&&!Object.keys(F).some(L=>!Number.isNaN(Number(L)))?Fo(n.errors,{[y]:F},y):ge(n.errors,y,F):$e(n.errors,y)}n.errors={...n.errors}}else n.errors=C;return C},Y=async({name:b,eventType:C})=>{if(e.validate){const y=await e.validate({formValues:i,formState:n,name:b,eventType:C});if(Ee(y))for(const F in y){const L=y[F];L&&Je(`${ca}.${F}`,{message:Ke(L.message)?L.message:"",type:L.type||wt.validate})}else Ke(y)||!y?Je(ca,{message:y||"",type:wt.validate}):_e(ca);return y}return!0},ce=async({fields:b,onlyCheckValid:C,name:y,eventType:F,context:L={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(L.runRootValidation=!0,!await Y({name:y,eventType:F})&&(L.valid=!1,C)))return L.valid;for(const Z in b){const M=b[Z];if(M){const{_f:W,...q}=M;if(W){const ie=l.array.has(W.name),qe=M._f&&vf(M._f),Bt=x.validatingFields||x.isValidating||p.validatingFields||p.isValidating;qe&&Bt&&S([W.name],!0);const Ut=await Oo(M,l.disabled,i,g,t.shouldUseNativeValidation&&!C,ie);if(qe&&Bt&&S([W.name]),Ut[W.name]&&(L.valid=!1,C)||(!C&&(V(Ut,W.name)?ie?Fo(n.errors,Ut,W.name):ge(n.errors,W.name,Ut[W.name]):$e(n.errors,W.name)),e.shouldUseNativeValidation&&Ut[W.name]))break}!Ue(q)&&await ce({context:L,onlyCheckValid:C,fields:q,name:Z,eventType:F})}}return L.valid},fe=()=>{for(const b of l.unMount){const C=V(r,b);C&&(C._f.refs?C._f.refs.every(y=>!oa(y)):!oa(C._f.ref))&&pt(b)}l.unMount=new Set},Q=(b,C)=>!t.disabled&&(b&&C&&ge(i,b,C),!ut(o.mount?i:a,a)),ke=(b,C,y)=>Ba(b,l,{...o.mount?i:we(C)?a:Ke(b)?{[b]:C}:C},y,C),se=b=>Pc(V(o.mount?i:a,b,t.shouldUnregister?V(a,b,[]):[])),Se=(b,C,y={},F=!1,L=!1)=>{const Z=V(r,b);let M=C;if(Z){const W=Z._f;W&&(!W.disabled&&ge(i,b,Dc(C,W)),M=ks(W.ref)&&Ze(C)?"":C,Ic(W.ref)?[...W.ref.options].forEach(q=>q.selected=M.includes(q.value)):W.refs?Yr(W.ref)?W.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(M)?q.checked=!!M.find(ie=>ie===q.value):q.checked=M===q.value||!!M)}):W.refs.forEach(q=>q.checked=q.value===M):Pi(W.ref)?W.ref.value="":(W.ref.value=M,!W.ref.type&&!L&&v.state.next({name:b,values:F?i:De(i)})))}(y.shouldDirty||y.shouldTouch)&&ee(b,M,y.shouldTouch,y.shouldDirty,!L),y.shouldValidate&&ae(b)},ue=(b,C,y,F=!1,L=!1)=>{for(const Z in C){if(!C.hasOwnProperty(Z))return;const M=C[Z],W=b+"."+Z,q=V(r,W);(l.array.has(b)||Ee(M)||q&&!q._f)&&!hn(M)?ue(W,M,y,F,L):Se(W,M,y,F,L)}},be=(b,C,y,F,L=!1)=>{const Z=V(r,b),M=l.array.has(b),W=F?C:De(C),q=V(i,b),ie=ut(q,W);if(ie||ge(i,b,W),M)v.array.next({name:b,values:F?i:De(i)}),(x.isDirty||x.dirtyFields||p.isDirty||p.dirtyFields)&&y.shouldDirty&&(E(),L||v.state.next({name:b,dirtyFields:n.dirtyFields,isDirty:Q(b,W)}));else{const qe=Array.isArray(W)&&!W.length||Ue(W);!Z||Z._f||Ze(W)||qe?Se(b,W,y,F,L):ue(b,W,y,F,L)}if(!ie&&!L){const qe=la(b,l),Bt=F?i:De(i);v.state.next({...qe&&n,name:o.mount||qe?b:void 0,values:Bt})}},O=(b,C,y={})=>be(b,C,y,!1),xe=(b,C={})=>{const y=He(b)?b(i):b;if(!ut(i,y)){i={...i,...y};const F=Ac(y);for(const L of l.mount)L in F&&be(L,F[L],C,!0,!0);v.state.next({...n,name:void 0,type:void 0,...d?{values:i}:{}}),C.shouldValidate&&j()}},te=async b=>{o.mount=!0;const C=b.target;let y=C.name,F=!0;const L=V(r,y),Z=M=>{F=Number.isNaN(M)||hn(M)&&isNaN(M.getTime())||ut(M,V(i,y,M))};if(L){let M,W;const q=C.type?To(L._f):Va(b),ie=b.type===tn.BLUR||b.type===tn.FOCUS_OUT,qe=!jf(L._f)&&!e.validate&&!t.resolver&&!V(n.errors,y)&&!L._f.deps,Bt=qe||Sf(ie,V(n.touchedFields,y),n.isSubmitted,h,m),Ut=la(y,l,ie);ge(i,y,q),ie?(!C||!C.readOnly)&&(L._f.onBlur&&L._f.onBlur(b),c&&c(0)):L._f.onChange&&L._f.onChange(b);const Nr=ee(y,q,ie),sd=!Ue(Nr)||Ut;if(!ie&&v.state.next({name:y,type:b.type,...d?{values:De(i)}:{}}),Bt)return(!qe||!n.isValid)&&(x.isValid||p.isValid)&&(t.mode==="onBlur"?ie&&j():ie||j()),sd&&v.state.next({name:y,...Ut?{}:Nr});if(!t.resolver&&e.validate&&await Y({name:y,eventType:b.type}),!ie&&Ut&&v.state.next({...n}),t.resolver){const{errors:ao}=await K([y]);if(S([y]),Z(q),!F){!Ue(Nr)&&v.state.next(Nr);return}const ad=Do(n.errors,r,y),io=Do(ao,r,ad.name||y);M=io.error,y=io.name,W=Ue(ao)}else S([y],!0),M=(await Oo(L,l.disabled,i,g,t.shouldUseNativeValidation))[y],S([y]),Z(q),F&&(M?W=!1:(x.isValid||p.isValid)&&(W=await ce({fields:r,onlyCheckValid:!0,name:y,eventType:b.type})));F&&(L._f.deps&&(!Array.isArray(L._f.deps)||L._f.deps.length>0)&&ae(L._f.deps),B(y,W,M,Nr))}},Ne=(b,C)=>{if(V(n.errors,C)&&b.focus)return b.focus(),1},ae=async(b,C={})=>{let y,F;const L=gs(b);if(t.resolver){const Z=await ne(we(b)?b:L);y=Ue(Z),F=b?!L.some(M=>V(Z,M)):y}else b?(F=(await Promise.all(L.map(async Z=>{const M=V(r,Z);return await ce({fields:M&&M._f?{[Z]:M}:M,eventType:tn.TRIGGER})}))).every(Boolean),!(!F&&!n.isValid)&&j()):F=y=await ce({fields:r,name:b,eventType:tn.TRIGGER});return v.state.next({...!Ke(b)||(x.isValid||p.isValid)&&y!==n.isValid?{}:{name:b},...t.resolver||!b?{isValid:y}:{},errors:n.errors}),C.shouldFocus&&!F&&_r(r,Ne,b?L:l.mount),F},Me=(b,C)=>{let y={...o.mount?i:a};return C&&(y=Ec(C.dirtyFields?n.dirtyFields:n.touchedFields,y)),we(b)?y:Ke(b)?V(y,b):b.map(F=>V(y,F))},oe=(b,C)=>({invalid:!!V((C||n).errors,b),isDirty:!!V((C||n).dirtyFields,b),error:V((C||n).errors,b),isValidating:!!V(n.validatingFields,b),isTouched:!!V((C||n).touchedFields,b)}),_e=b=>{const C=b?gs(b):void 0;C==null||C.forEach(y=>$e(n.errors,y)),C?C.forEach(y=>{v.state.next({name:y,errors:n.errors})}):v.state.next({errors:{}})},Je=(b,C,y)=>{const F=(V(r,b,{_f:{}})._f||{}).ref,L=V(n.errors,b)||{},{ref:Z,message:M,type:W,...q}=L;ge(n.errors,b,{...q,...C,ref:F}),v.state.next({name:b,errors:n.errors,isValid:!1}),y&&y.shouldFocus&&F&&F.focus&&F.focus()},at=(b,C)=>{if(He(b)){d++;const{unsubscribe:y}=v.state.subscribe({next:L=>"values"in L&&b(L.values||ke(void 0,C),L)});let F=!1;return{unsubscribe:()=>{F||(F=!0,d--,y())}}}return ke(b,C,!0)},it=b=>{var C;const y=!!(!((C=b.formState)===null||C===void 0)&&C.values);y&&d++;const{unsubscribe:F}=v.state.subscribe({next:Z=>{if(wf(b.name,Z.name,b.exact)&&Nf(Z,b.formState||x,It,b.reRenderRoot)){const M={...i};b.callback({values:M,...n,...Z,defaultValues:a})}}});if(!y)return F;let L=!1;return()=>{L||(L=!0,d--,F())}},zt=b=>(o.mount=!0,p={...p,...b.formState},it({...b,formState:{...f,...b.formState}})),pt=(b,C={})=>{for(const y of b?gs(b):l.mount)l.mount.delete(y),l.array.delete(y),C.keepValue||($e(r,y),$e(i,y)),!C.keepError&&$e(n.errors,y),!C.keepDirty&&$e(n.dirtyFields,y),!C.keepTouched&&$e(n.touchedFields,y),!C.keepIsValidating&&$e(n.validatingFields,y),!t.shouldUnregister&&!C.keepDefaultValue&&$e(a,y);v.state.next({values:De(i)}),v.state.next({...n,...C.keepDirty?{isDirty:Q()}:{}}),!C.keepIsValid&&j()},vt=({disabled:b,name:C})=>{if(ct(b)&&o.mount||b||l.disabled.has(C)){const L=l.disabled.has(C)!==!!b;b?l.disabled.add(C):l.disabled.delete(C),L&&o.mount&&!o.action&&j()}},xt=(b,C={})=>{let y=V(r,b);const F=ct(C.disabled)||ct(t.disabled),L=!l.registerName.has(b)&&y&&y._f&&!y._f.mount;return ge(r,b,{...y||{},_f:{...y&&y._f?y._f:{ref:{name:b}},name:b,mount:!0,...C}}),l.mount.add(b),y&&!L?vt({disabled:ct(C.disabled)?C.disabled:t.disabled,name:b}):R(b,!0,C.value),{...F?{disabled:C.disabled||t.disabled}:{},...t.progressive?{required:!!C.required,min:kr(C.min),max:kr(C.max),minLength:kr(C.minLength),maxLength:kr(C.maxLength),pattern:kr(C.pattern)}:{},name:b,onChange:te,onBlur:te,ref:Z=>{if(Z){l.registerName.add(b),xt(b,C),l.registerName.delete(b),y=V(r,b);const M=we(Z.value)&&Z.querySelectorAll&&Z.querySelectorAll("input,select,textarea")[0]||Z,W=pf(M),q=y._f.refs||[];if(W?q.find(ie=>ie===M):M===y._f.ref)return;ge(r,b,{_f:{...y._f,...W?{refs:[...q.filter(oa),M,...Array.isArray(V(a,b))?[{}]:[]],ref:{type:M.type,name:b}}:{ref:M}}}),R(b,!1,void 0,M)}else y=V(r,b,{}),y._f&&(y._f.mount=!1),(t.shouldUnregister||C.shouldUnregister)&&!(Nc(l.array,b)&&o.action)&&l.unMount.add(b)}}},jt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&_r(r,Ne,l.mount),Mt=b=>{ct(b)&&(v.state.next({disabled:b}),_r(r,(C,y)=>{const F=V(r,y);F&&(C.disabled=F._f.disabled||b,Array.isArray(F._f.refs)&&F._f.refs.forEach(L=>{L.disabled=F._f.disabled||b}))},0,!1))},At=(b,C)=>async y=>{let F;y&&(y.preventDefault&&y.preventDefault(),y.persist&&y.persist());let L=De(i);if(v.state.next({isSubmitting:!0}),t.resolver){const{errors:Z,values:M}=await K();S(),n.errors=Z,L=De(M)}else await ce({fields:r,eventType:tn.SUBMIT});if(l.disabled.size)for(const Z of l.disabled)$e(L,Z);if($e(n.errors,Sc),Ue(n.errors)){v.state.next({errors:{}});try{await b(L,y)}catch(Z){F=Z}}else C&&await C({...n.errors},y),jt(),setTimeout(jt);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ue(n.errors)&&!F,submitCount:n.submitCount+1,errors:n.errors}),F)throw F},qt=(b,C={})=>{V(r,b)&&(we(C.defaultValue)?O(b,De(V(a,b))):(O(b,C.defaultValue),ge(a,b,De(C.defaultValue))),C.keepTouched||$e(n.touchedFields,b),C.keepDirty||($e(n.dirtyFields,b),n.isDirty=C.defaultValue?Q(b,De(V(a,b))):Q()),C.keepError||($e(n.errors,b),x.isValid&&j()),v.state.next({...n}))},Pt=(b,C={})=>{const y=b?De(b):a,F=De(y),L=Ue(b),Z=F;if(C.keepDefaultValues||(a=y),!C.keepValues){if(C.keepDirtyValues){const M=new Set([...l.mount,...Object.keys(jn(a,i))]);for(const W of Array.from(M)){const q=V(n.dirtyFields,W),ie=V(i,W),qe=V(Z,W);q&&!we(ie)?ge(Z,W,ie):!q&&!we(qe)&&O(W,qe)}}else{if(Bs&&we(b))for(const M of l.mount){const W=V(r,M);if(W&&W._f){const q=Array.isArray(W._f.refs)?W._f.refs[0]:W._f.ref;if(ks(q)){const ie=q.closest("form");if(ie){ie.reset();break}}}}if(C.keepFieldsRef)for(const M of l.mount)O(M,V(Z,M));else r={}}if(t.shouldUnregister){if(i=C.keepDefaultValues?De(a):{},C.keepFieldsRef)for(const M of l.mount)ge(i,M,V(Z,M))}else i=De(Z);v.array.next({values:{...Z}}),v.state.next({name:void 0,type:void 0,values:{...Z}})}l={mount:C.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!x.isValid||!!C.keepIsValid||!!C.keepDirtyValues||!t.shouldUnregister&&!Ue(Z),o.watch=!!t.shouldUnregister,o.keepIsValid=!!C.keepIsValid,o.action=!1,C.keepErrors||(n.errors={}),v.state.next({submitCount:C.keepSubmitCount?n.submitCount:0,isDirty:L?!1:C.keepDirty?n.isDirty:C.keepValues?Q():!!(C.keepDefaultValues&&!ut(b,a)),isSubmitted:C.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:C.keepDirtyValues?C.keepDefaultValues&&i?jn(a,i):n.dirtyFields:C.keepDefaultValues&&b?jn(a,b):C.keepDirty?n.dirtyFields:{},touchedFields:C.keepTouched?n.touchedFields:{},errors:C.keepErrors?n.errors:{},isSubmitSuccessful:C.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Nt=(b,C)=>Pt(He(b)?b(i):b,{...t.resetOptions,...C}),Et=(b,C={})=>{const y=V(r,b),F=y&&y._f;if(F){const L=F.refs?F.refs[0]:F.ref;L.focus&&setTimeout(()=>{L.focus(),C.shouldSelect&&He(L.select)&&L.select()})}},It=b=>{const{name:C,type:y,values:F,...L}=b;n={...n,...L}},de={control:{register:xt,unregister:pt,getFieldState:oe,handleSubmit:At,setError:Je,_subscribe:it,_runSchema:K,_updateIsValidating:S,_focusError:jt,_getWatch:ke,_getDirty:Q,_setValid:j,_setFieldArray:_,_setDisabledField:vt,_setErrors:$,_getFieldArray:se,_reset:Pt,_resetDefaultValues:()=>He(t.defaultValues)&&t.defaultValues().then(b=>{Nt(b,t.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:fe,_disableForm:Mt,_subjects:v,_proxyFormState:x,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(b){o=b},get _defaultValues(){return a},get _names(){return l},set _names(b){l=b},get _formState(){return n},get _options(){return t},set _options(b){t={...t,...b},m=ss(t.mode),h=ss(t.reValidateMode)}},subscribe:zt,trigger:ae,register:xt,handleSubmit:At,watch:at,setValue:O,setValues:xe,getValues:Me,reset:Nt,resetField:qt,resetDefaultValues:(b,C={})=>{if(a=De(b),!C.keepDirty){const y=jn(a,i);n.dirtyFields=y,n.isDirty=!Ue(y)}C.keepIsValid||j(),v.state.next({...n,defaultValues:a})},clearErrors:_e,unregister:pt,setError:Je,setFocus:Et,getFieldState:oe};return{...de,formControl:de}}function Rt(e={}){const t=N.useRef(void 0),n=N.useRef(void 0),r=N.useRef(e.formControl),[a,i]=N.useState(()=>({...De(Rc),isLoading:He(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:He(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&r.current!==e.formControl)if(r.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!He(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=Af(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,Ci(()=>{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&&!ut(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),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(()=>Cc(a,o),[o,a]),t.current}const $o=(e,t,n)=>{if(e&&"reportValidity"in e){const r=V(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Ya=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?$o(r.ref,n,e):r&&r.refs&&r.refs.forEach(a=>$o(a,n,e))}},Lo=(e,t)=>{t.shouldUseNativeValidation&&Ya(e,t);const n={};for(const r in e){const a=V(t.fields,r),i=Object.assign(e[r]||{},{ref:a&&a.ref});if(Pf(t.names||Object.keys(e),r)){const o=Object.assign({},V(n,r));ge(o,"root",i),ge(n,r,o)}else ge(n,r,i)}return n},Pf=(e,t)=>{const n=zo(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(r=>zo(r).match(`^${n}\\.\\d+`))};function zo(e){return e.replace(/[\[\]]/g,"")}var Mo;function D(e,t,n){function r(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=o.prototype,d=Object.keys(u);for(let m=0;m<d.length;m++){const h=d[m];h in l||(l[h]=u[h].bind(l))}}const a=(n==null?void 0:n.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const u=n!=null&&n.Parent?new i:this;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,u;return n!=null&&n.Parent&&l instanceof n.Parent?!0:(u=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Hn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Oc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Mo=globalThis).__zod_globalConfig??(Mo.__zod_globalConfig={});const Ii=globalThis.__zod_globalConfig;function Rn(e){return Ii}function $c(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function Ha(e,t){return typeof t=="bigint"?t.toString():t}function Ti(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function _i(e){return e==null}function Di(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const qo=Symbol("evaluating");function je(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==qo)return r===void 0&&(r=qo,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Vn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function yn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Vo(e){return JSON.stringify(e)}function Ef(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Lc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function As(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const If=Ti(()=>{var e;if(Ii.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 Or(e){if(As(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(As(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function zc(e){return Or(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Tf=new Set(["string","number","symbol"]);function dr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function re(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function _f(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Df(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=yn(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=n.shape[l])}return Vn(this,"shape",o),o},checks:[]});return bn(e,i)}function Ff(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=yn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Vn(this,"shape",o),o},checks:[]});return bn(e,i)}function Rf(e,t){if(!Or(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=yn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Vn(this,"shape",i),i}});return bn(e,a)}function Of(e,t){if(!Or(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=yn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Vn(this,"shape",r),r}});return bn(e,n)}function $f(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=yn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Vn(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bn(e,n)}function Lf(e,t,n){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=yn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return Vn(this,"shape",c),c},checks:[]});return bn(t,o)}function zf(e,t,n){const r=yn(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return Vn(this,"shape",i),i}});return bn(t,r)}function Wn(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Mf(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Mc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function as(e){return typeof e=="string"?e:e==null?void 0:e.message}function On(e,t,n){var c,u,d,m,h,f;const r=e.message?e.message:as((d=(u=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:u.error)==null?void 0:d.call(u,e))??as((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??as((h=n.customError)==null?void 0:h.call(n,e))??as((f=n.localeError)==null?void 0:f.call(n,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=r,t!=null&&t.reportInput&&(l.input=o),l}function Fi(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function $r(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const qc=(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,Ha,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ri=D("$ZodError",qc),Zs=D("$ZodError",qc,{Parent:Error});function qf(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function Vf(e,t=n=>n.message){const n={_errors:[]},r=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>r({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<l.length;){const d=l[u];u===l.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return r(e),n}const Ws=e=>(t,n,r,a)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Hn;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>On(c,i,Rn())));throw Lc(l,a==null?void 0:a.callee),l}return o.value},Bf=Ws(Zs),Ys=e=>async(t,n,r,a)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>On(c,i,Rn())));throw Lc(l,a==null?void 0:a.callee),l}return o.value},Uf=Ys(Zs),Hs=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Hn;return i.issues.length?{success:!1,error:new(e??Ri)(i.issues.map(o=>On(o,a,Rn())))}:{success:!0,data:i.value}},Zf=Hs(Zs),Ks=e=>async(t,n,r)=>{const a=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>On(o,a,Rn())))}:{success:!0,data:i.value}},Wf=Ks(Zs),Yf=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ws(e)(t,n,a)},Hf=e=>(t,n,r)=>Ws(e)(t,n,r),Kf=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ys(e)(t,n,a)},Qf=e=>async(t,n,r)=>Ys(e)(t,n,r),Jf=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Hs(e)(t,n,a)},Gf=e=>(t,n,r)=>Hs(e)(t,n,r),Xf=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ks(e)(t,n,a)},ep=e=>async(t,n,r)=>Ks(e)(t,n,r),tp=/^[cC][0-9a-z]{6,}$/,np=/^[0-9a-z]+$/,rp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,sp=/^[0-9a-vA-V]{20}$/,ap=/^[A-Za-z0-9]{27}$/,ip=/^[a-zA-Z0-9_-]{21}$/,op=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,lp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Bo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,cp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,up="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function dp(){return new RegExp(up,"u")}const mp=/^(?:(?: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])$/,hp=/^(([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}|:))$/,fp=/^((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])$/,pp=/^(([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])$/,xp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vc=/^[A-Za-z0-9_-]*$/,gp=/^https?$/,yp=/^\+[1-9]\d{6,14}$/,Bc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",bp=new RegExp(`^${Bc}$`);function Uc(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 vp(e){return new RegExp(`^${Uc(e)}$`)}function jp(e){const t=Uc({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Bc}T(?:${r})$`)}const Np=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}$`)},wp=/^(?:true|false)$/i,Sp=/^[^A-Z]*$/,kp=/^[^a-z]*$/,Ot=D("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Cp=D("$ZodCheckMaxLength",(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!_i(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const o=Fi(a);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Ap=D("$ZodCheckMinLength",(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!_i(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const o=Fi(a);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Pp=D("$ZodCheckLengthEquals",(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!_i(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,i=a.length;if(i===t.length)return;const o=Fi(a),l=i>t.length;r.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Qs=D("$ZodCheckStringFormat",(e,t)=>{var n,r;Ot.init(e,t),e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ep=D("$ZodCheckRegex",(e,t)=>{Qs.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ip=D("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Sp),Qs.init(e,t)}),Tp=D("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=kp),Qs.init(e,t)}),_p=D("$ZodCheckIncludes",(e,t)=>{Ot.init(e,t);const n=dr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Dp=D("$ZodCheckStartsWith",(e,t)=>{Ot.init(e,t);const n=new RegExp(`^${dr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Fp=D("$ZodCheckEndsWith",(e,t)=>{Ot.init(e,t);const n=new RegExp(`.*${dr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Rp=D("$ZodCheckOverwrite",(e,t)=>{Ot.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Op{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 r=t.split(`
|
|
12
|
+
Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let u=Se(),m;if(t){let g=typeof t=="string"?Ln(t):t;Ie(c==="/"||((w=g.pathname)==null?void 0:w.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),m=g}else m=u;let h=m.pathname||"/",f=h;if(c!=="/"){let g=c.replace(/^\//,"").split("/");f="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let x=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):Ol(e,{pathname:f});ht(d||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),ht(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let p=om(x&&x.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:At([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:At([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&p?A.createElement(Vr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...m},navigationType:"POP"}},p):p}function rm(){let e=mm(),t=qd(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},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),n?A.createElement("pre",{style:a},n):null,o)}var sm=A.createElement(rm,null),Xl=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 n=Gd(e.digest);n&&(e=n)}let t=e!==void 0?A.createElement(bt.Provider,{value:this.props.routeContext},A.createElement(li.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?A.createElement(am,{error:e},t):t}};Xl.contextType=Wl;var ia=new WeakMap;function am({children:e,error:t}){let{basename:n}=A.useContext(ft);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Jd(t.digest);if(r){let a=ia.get(t);if(a)throw a;let i=Ul(r.location,n),o=i.absoluteURL||i.to;if(Zd(o))throw new Error("Invalid redirect location");if(Vl&&!ia.get(t))if(i.isExternal||r.reloadDocument)window.location.href=o;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw ia.set(t,l),l}return A.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o}`})}}return e}function im({routeContext:e,match:t,children:n}){let r=A.useContext(fr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(bt.Provider,{value:e},n)}function om(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let u=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Ie(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let u=0;u<a.length;u++){let m=a[u];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=u),m.route.id){let{loaderData:h,errors:f}=r,x=m.route.loader&&!h.hasOwnProperty(m.route.id)&&(!f||f[m.route.id]===void 0);if(m.route.lazy||x){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(u,m)=>{var h,f;c(u,{location:r.location,params:((f=(h=r.matches)==null?void 0:h[0])==null?void 0:f.params)??{},pattern:Bd(r.matches),errorInfo:m})}:void 0;return a.reduceRight((u,m,h)=>{let f,x=!1,p=null,w=null;r&&(f=i&&m.route.id?i[m.route.id]:void 0,p=m.route.errorElement||sm,o&&(l<0&&h===0?(ec("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,w=null):l===h&&(x=!0,w=m.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,h+1)),k=()=>{let v;return f?v=p:x?v=w:m.route.Component?v=A.createElement(m.route.Component,null):m.route.element?v=m.route.element:v=u,A.createElement(im,{match:m,routeContext:{outlet:u,matches:g,isDataRoute:r!=null},children:v})};return r&&(m.route.ErrorBoundary||m.route.errorElement||h===0)?A.createElement(Xl,{location:r.location,revalidation:r.revalidation,component:p,error:f,children:k(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):k()},null)}function ci(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function lm(e){let t=A.useContext(fr);return Ie(t,ci(e)),t}function cm(e){let t=A.useContext(Ls);return Ie(t,ci(e)),t}function um(e){let t=A.useContext(bt);return Ie(t,ci(e)),t}function ui(e){let t=um(e),n=t.matches[t.matches.length-1];return Ie(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function dm(){return ui("useRouteId")}function mm(){var r;let e=A.useContext(li),t=cm("useRouteError"),n=ui("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function hm(){let{router:e}=lm("useNavigate"),t=ui("useNavigate"),n=A.useRef(!1);return Ql(()=>{n.current=!0}),A.useCallback(async(a,i={})=>{ht(n.current,Kl),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var fo={};function ec(e,t,n){!t&&!fo[e]&&(fo[e]=!0,ht(!1,n))}A.memo(fm);function fm({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return Gl(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function pm({basename:e,children:t,initialEntries:n,initialIndex:r,useTransitions:a}){let i=A.useRef();i.current==null&&(i.current=bd({initialEntries:n,initialIndex:r,v5Compat:!0}));let o=i.current,[l,c]=A.useState({action:o.action,location:o.location}),d=A.useCallback(u=>{a===!1?c(u):A.startTransition(()=>c(u))},[a]);return A.useLayoutEffect(()=>o.listen(d),[o,d]),A.createElement(gm,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,useTransitions:a})}function Ue({to:e,replace:t,state:n,relative:r}){Ie(pr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=A.useContext(ft);ht(!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(bt),{pathname:o}=Se(),l=ke(),c=Os(e,oi(i),o,r==="path"),d=JSON.stringify(c);return A.useEffect(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function xm(e){return tm(e.context)}function X(e){Ie(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function gm({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Ie(!pr(),"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 n=="string"&&(n=Ln(n));let{pathname:d="/",search:u="",hash:m="",state:h=null,key:f="default",mask:x}=n,p=A.useMemo(()=>{let w=Gt(d,l);return w==null?null:{location:{pathname:w,search:u,hash:m,state:h,key:f,mask:x},navigationType:r}},[l,d,u,m,h,f,r,x]);return ht(p!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${m}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:A.createElement(ft.Provider,{value:c},A.createElement(Vr.Provider,{children:t,value:p}))}function di({children:e,location:t}){return nm(Sa(e),t)}function Sa(e,t=[]){let n=[];return A.Children.forEach(e,(r,a)=>{if(!A.isValidElement(r))return;let i=[...t,a];if(r.type===A.Fragment){n.push.apply(n,Sa(r.props.children,i));return}Ie(r.type===X,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ie(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Sa(r.props.children,i)),n.push(o)}),n}var fs="get",ps="application/x-www-form-urlencoded";function Ms(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function ym(e){return Ms(e)&&e.tagName.toLowerCase()==="button"}function bm(e){return Ms(e)&&e.tagName.toLowerCase()==="form"}function vm(e){return Ms(e)&&e.tagName.toLowerCase()==="input"}function jm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function wm(e,t){return e.button===0&&(!t||t==="_self")&&!jm(e)}function ka(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Nm(e,t){let n=ka(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var ts=null;function Sm(){if(ts===null)try{new FormData(document.createElement("form"),0),ts=!1}catch{ts=!0}return ts}var km=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function oa(e){return e!=null&&!km.has(e)?(ht(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ps}"`),null):e}function Cm(e,t){let n,r,a,i,o;if(bm(e)){let l=e.getAttribute("action");r=l?Gt(l,t):null,n=e.getAttribute("method")||fs,a=oa(e.getAttribute("enctype"))||ps,i=new FormData(e)}else if(ym(e)||vm(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(r=c?Gt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||fs,a=oa(e.getAttribute("formenctype"))||oa(l.getAttribute("enctype"))||ps,i=new FormData(l,e),!Sm()){let{name:d,type:u,value:m}=e;if(u==="image"){let h=d?`${d}.`:"";i.append(`${h}x`,"0"),i.append(`${h}y`,"0")}else d&&i.append(d,m)}}else{if(Ms(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=fs,r=null,a=ps,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function mi(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function tc(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Gt(a.pathname,t)==="/"?a.pathname=`${js(t)}/_root.${r}`:a.pathname=`${js(a.pathname)}.${r}`,a}async function Am(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Pm(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 Em(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await Am(i,n);return o.links?o.links():[]}return[]}));return Fm(r.flat(1).filter(Pm).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function po(e,t,n,r,a,i){let o=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var u;return n[d].pathname!==c.pathname||((u=n[d].route.path)==null?void 0:u.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,d)=>o(c,d)||l(c,d)):i==="data"?t.filter((c,d)=>{var m;let u=r.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(o(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Im(e,t,{includeHydrateFallback:n}={}){return _m(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function _m(e){return[...new Set(e)]}function Tm(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Fm(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(Tm(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function hi(){let e=A.useContext(fr);return mi(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Dm(){let e=A.useContext(Ls);return mi(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var fi=A.createContext(void 0);fi.displayName="FrameworkContext";function qs(){let e=A.useContext(fi);return mi(e,"You must render this element inside a <HydratedRouter> element"),e}function Rm(e,t){let n=A.useContext(fi),[r,a]=A.useState(!1),[i,o]=A.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:m}=t,h=A.useRef(null);A.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let p=g=>{g.forEach(k=>{o(k.isIntersecting)})},w=new IntersectionObserver(p,{threshold:.5});return h.current&&w.observe(h.current),()=>{w.disconnect()}}},[e]),A.useEffect(()=>{if(r){let p=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(p)}}},[r]);let f=()=>{a(!0)},x=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,h,{}]:[i,h,{onFocus:Nr(l,f),onBlur:Nr(c,x),onMouseEnter:Nr(d,f),onMouseLeave:Nr(u,x),onTouchStart:Nr(m,f)}]:[!1,h,{}]}function Nr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function $m({page:e,...t}){let n=Wd(),{nonce:r}=qs(),{router:a}=hi(),i=A.useMemo(()=>Ol(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?A.createElement(Lm,{page:e,matches:i,...t}):A.createElement(zm,{page:e,matches:i,...t})):null}function Om(e){let{manifest:t,routeModules:n}=qs(),[r,a]=A.useState([]);return A.useEffect(()=>{let i=!1;return Em(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function Lm({page:e,matches:t,...n}){let r=Se(),{future:a}=qs(),{basename:i}=hi(),o=A.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=tc(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let u of t)typeof u.route.shouldRevalidate=="function"?c=!0:d.push(u.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,r,t]);return A.createElement(A.Fragment,null,o.map(l=>A.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function zm({page:e,matches:t,...n}){let r=Se(),{future:a,manifest:i,routeModules:o}=qs(),{basename:l}=hi(),{loaderData:c,matches:d}=Dm(),u=A.useMemo(()=>po(e,t,d,i,r,"data"),[e,t,d,i,r]),m=A.useMemo(()=>po(e,t,d,i,r,"assets"),[e,t,d,i,r]),h=A.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let p=new Set,w=!1;if(t.forEach(k=>{var S;let v=i.routes[k.route.id];!v||!v.hasLoader||(!u.some(E=>E.route.id===k.route.id)&&k.route.id in c&&((S=o[k.route.id])!=null&&S.shouldRevalidate)||v.hasClientLoader?w=!0:p.add(k.route.id))}),p.size===0)return[];let g=tc(e,l,a.v8_trailingSlashAwareDataRequests,"data");return w&&p.size>0&&g.searchParams.set("_routes",t.filter(k=>p.has(k.route.id)).map(k=>k.route.id).join(",")),[g.pathname+g.search]},[l,a.v8_trailingSlashAwareDataRequests,c,r,i,u,t,e,o]),f=A.useMemo(()=>Im(m,i),[m,i]),x=Om(m);return A.createElement(A.Fragment,null,h.map(p=>A.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...n})),f.map(p=>A.createElement("link",{key:p,rel:"modulepreload",href:p,...n})),x.map(({key:p,link:w})=>A.createElement("link",{key:p,nonce:n.nonce,...w,crossOrigin:w.crossOrigin??n.crossOrigin})))}function Mm(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var qm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{qm&&(window.__reactRouterVersion="7.18.1")}catch{}var nc=A.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:d,to:u,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:f,...x},p){let{basename:w,navigator:g,useTransitions:k}=A.useContext(ft),v=typeof u=="string"&&ii.test(u),S=Ul(u,w);u=S.to;let E=Xd(u,{relative:a}),T=Se(),P=null;if(l){let z=Os(l,[],T.mask?T.mask.pathname:"/",!0);w!=="/"&&(z.pathname=z.pathname==="/"?w:At([w,z.pathname])),P=g.createHref(z)}let[O,I,$]=Rm(r,x),ne=Zm(u,{replace:o,mask:l,state:c,target:d,preventScrollReset:m,relative:a,viewTransition:h,defaultShouldRevalidate:f,useTransitions:k});function q(z){t&&t(z),z.defaultPrevented||ne(z)}let K=!(S.isExternal||i),ee=A.createElement("a",{...x,...$,href:(K?P:void 0)||S.absoluteURL||E,onClick:K?q:t,ref:Mm(p,I),target:d,"data-discover":!v&&n==="render"?"true":void 0});return O&&!v?A.createElement(A.Fragment,null,ee,A.createElement($m,{page:E})):ee});nc.displayName="Link";var Bm=A.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...d},u){let m=Ur(o,{relative:d.relative}),h=Se(),f=A.useContext(Ls),{navigator:x,basename:p}=A.useContext(ft),w=f!=null&&Jm(m)&&l===!0,g=x.encodeLocation?x.encodeLocation(m).pathname:m.pathname,k=h.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(k=k.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&p&&(v=Gt(v,p)||v);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let E=k===g||!a&&k.startsWith(g)&&k.charAt(S)==="/",T=v!=null&&(v===g||!a&&v.startsWith(g)&&v.charAt(g.length)==="/"),P={isActive:E,isPending:T,isTransitioning:w},O=E?t:void 0,I;typeof r=="function"?I=r(P):I=[r,E?"active":null,T?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let $=typeof i=="function"?i(P):i;return A.createElement(nc,{...d,"aria-current":O,className:I,ref:u,style:$,to:o,viewTransition:l},typeof c=="function"?c(P):c)});Bm.displayName="NavLink";var Vm=A.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=fs,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:m,defaultShouldRevalidate:h,...f},x)=>{let{useTransitions:p}=A.useContext(ft),w=Km(),g=Qm(l,{relative:d}),k=o.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&ii.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let T=E.nativeEvent.submitter,P=(T==null?void 0:T.getAttribute("formmethod"))||o,O=()=>w(T||E.currentTarget,{fetcherKey:t,method:P,navigate:n,replace:a,state:i,relative:d,preventScrollReset:u,viewTransition:m,defaultShouldRevalidate:h});p&&n!==!1?A.startTransition(()=>O()):O()};return A.createElement("form",{ref:x,method:k,action:g,onSubmit:r?c:S,...f,"data-discover":!v&&e==="render"?"true":void 0})});Vm.displayName="Form";function Um(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rc(e){let t=A.useContext(fr);return Ie(t,Um(e)),t}function Zm(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let u=ke(),m=Se(),h=Ur(e,{relative:o});return A.useCallback(f=>{if(wm(f,t)){f.preventDefault();let x=n!==void 0?n:bs(m)===bs(h),p=()=>u(e,{replace:x,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});d?A.startTransition(()=>p()):p()}},[m,u,h,n,r,a,t,e,i,o,l,c,d])}function Wm(e){ht(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(ka(e)),n=A.useRef(!1),r=Se(),a=A.useMemo(()=>Nm(r.search,n.current?null:t.current),[r.search]),i=ke(),o=A.useCallback((l,c)=>{const d=ka(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var Ym=0,Hm=()=>`__${String(++Ym)}__`;function Km(){let{router:e}=rc("useSubmit"),{basename:t}=A.useContext(ft),n=dm(),r=e.fetch,a=e.navigate;return A.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:u,body:m}=Cm(i,t);if(o.navigate===!1){let h=o.fetcherKey||Hm();await r(h,n,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:m,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:m,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function Qm(e,{relative:t}={}){let{basename:n}=A.useContext(ft),r=A.useContext(bt);Ie(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...Ur(e||".",{relative:t})},o=Se();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let u=l.toString();i.search=u?`?${u}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:At([n,i.pathname])),bs(i)}function Jm(e,{relative:t}={}){let n=A.useContext(Yl);Ie(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=rc("useViewTransitionState"),a=Ur(e,{relative:t});if(!n.isTransitioning)return!1;let i=Gt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Gt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vs(a.pathname,o)!=null||vs(a.pathname,i)!=null}var xr=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(){}},Nn,sn,Qn,Cl,Gm=(Cl=class extends xr{constructor(){super();G(this,Nn);G(this,sn);G(this,Qn);W(this,Qn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){N(this,sn)||this.setEventListener(N(this,Qn))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,sn))==null||t.call(this),W(this,sn,void 0))}setEventListener(t){var n;W(this,Qn,t),(n=N(this,sn))==null||n.call(this),W(this,sn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){N(this,Nn)!==t&&(W(this,Nn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof N(this,Nn)=="boolean"?N(this,Nn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Nn=new WeakMap,sn=new WeakMap,Qn=new WeakMap,Cl),pi=new Gm,Xm={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Tt,Sn,Al,eh=(Al=class{constructor(){G(this,Tt,Xm);G(this,Sn,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,Sn)&&e!==N(this,Tt)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,Tt),provider:e}),W(this,Tt,e),process.env.NODE_ENV!=="production"&&W(this,Sn,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&W(this,Sn,!0),N(this,Tt).setTimeout(e,t)}clearTimeout(e){N(this,Tt).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&W(this,Sn,!0),N(this,Tt).setInterval(e,t)}clearInterval(e){N(this,Tt).clearInterval(e)}},Tt=new WeakMap,Sn=new WeakMap,Al),jn=new eh;function th(e){setTimeout(e,0)}var nh=typeof window>"u"||"Deno"in globalThis;function st(){}function rh(e,t){return typeof e=="function"?e(t):e}function Ca(e){return typeof e=="number"&&e>=0&&e!==1/0}function sc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function pn(e,t){return typeof e=="function"?e(t):e}function ut(e,t){return typeof e=="function"?e(t):e}function xo(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==xi(o,t.options))return!1}else if(!Fr(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function go(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Fn(t.options.mutationKey)!==Fn(i))return!1}else if(!Fr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function xi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Fn)(e)}function Fn(e){return JSON.stringify(e,(t,n)=>Pa(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function Fr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Fr(e[n],t[n])):!1}var sh=Object.prototype.hasOwnProperty;function Aa(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=yo(e)&&yo(t);if(!r&&!(Pa(e)&&Pa(t)))return t;const i=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,c=r?new Array(l):{};let d=0;for(let u=0;u<l;u++){const m=r?u:o[u],h=e[m],f=t[m];if(h===f){c[m]=h,(r?u<i:sh.call(e,m))&&d++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){c[m]=f;continue}const x=Aa(h,f,n+1);c[m]=x,x===h&&d++}return i===l&&d===i?e:c}function ws(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function yo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Pa(e){if(!bo(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!bo(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function bo(e){return Object.prototype.toString.call(e)==="[object Object]"}function ah(e){return new Promise(t=>{jn.setTimeout(t,e)})}function Ea(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Aa(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return Aa(e,t)}return t}function ih(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function oh(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ns=Symbol();function ac(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ns&&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===Ns?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function gi(e,t){return typeof e=="function"?e(...t):!!e}function lh(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var Dr=(()=>{let e=()=>nh;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ia(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var ch=th;function uh(){let e=[],t=0,n=l=>{l()},r=l=>{l()},a=ch;const i=l=>{t?e.push(l):a(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{a=l}}}var Me=uh(),Jn,an,Gn,Pl,dh=(Pl=class extends xr{constructor(){super();G(this,Jn,!0);G(this,an);G(this,Gn);W(this,Gn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){N(this,an)||this.setEventListener(N(this,Gn))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,an))==null||t.call(this),W(this,an,void 0))}setEventListener(t){var n;W(this,Gn,t),(n=N(this,an))==null||n.call(this),W(this,an,t(this.setOnline.bind(this)))}setOnline(t){N(this,Jn)!==t&&(W(this,Jn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return N(this,Jn)}},Jn=new WeakMap,an=new WeakMap,Gn=new WeakMap,Pl),Ss=new dh;function mh(e){return Math.min(1e3*2**e,3e4)}function ic(e){return(e??"online")==="online"?Ss.isOnline():!0}var _a=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function oc(e){let t=!1,n=0,r;const a=Ia(),i=()=>a.status!=="pending",o=p=>{var w;if(!i()){const g=new _a(p);h(g),(w=e.onCancel)==null||w.call(e,g)}},l=()=>{t=!0},c=()=>{t=!1},d=()=>pi.isFocused()&&(e.networkMode==="always"||Ss.isOnline())&&e.canRun(),u=()=>ic(e.networkMode)&&e.canRun(),m=p=>{i()||(r==null||r(),a.resolve(p))},h=p=>{i()||(r==null||r(),a.reject(p))},f=()=>new Promise(p=>{var w;r=g=>{(i()||d())&&p(g)},(w=e.onPause)==null||w.call(e)}).then(()=>{var p;r=void 0,i()||(p=e.onContinue)==null||p.call(e)}),x=()=>{if(i())return;let p;const w=n===0?e.initialPromise:void 0;try{p=w??e.fn()}catch(g){p=Promise.reject(g)}Promise.resolve(p).then(m).catch(g=>{var T;if(i())return;const k=e.retry??(Dr.isServer()?0:3),v=e.retryDelay??mh,S=typeof v=="function"?v(n,g):v,E=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,g);if(t||!E){h(g);return}n++,(T=e.onFail)==null||T.call(e,n,g),ah(S).then(()=>d()?void 0:f()).then(()=>{t?h(g):x()})})};return{promise:a,status:()=>a.status,cancel:o,continue:()=>(r==null||r(),a),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?x():f().then(x),a)}}var kn,El,lc=(El=class{constructor(){G(this,kn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ca(this.gcTime)&&W(this,kn,jn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Dr.isServer()?1/0:300*1e3))}clearGcTimeout(){N(this,kn)!==void 0&&(jn.clearTimeout(N(this,kn)),W(this,kn,void 0))}},kn=new WeakMap,El);function hh(e){return{onFetch:(t,n)=>{var u,m,h,f,x;const r=t.options,a=(h=(m=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:m.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((x=t.state.data)==null?void 0:x.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let p=!1;const w=v=>{lh(v,()=>t.signal,()=>p=!0)},g=ac(t.options,t.fetchOptions),k=async(v,S,E)=>{if(p)return Promise.reject(t.signal.reason);if(S==null&&v.pages.length)return Promise.resolve(v);const P=(()=>{const ne={client:t.client,queryKey:t.queryKey,pageParam:S,direction:E?"backward":"forward",meta:t.options.meta};return w(ne),ne})(),O=await g(P),{maxPages:I}=t.options,$=E?oh:ih;return{pages:$(v.pages,O,I),pageParams:$(v.pageParams,S,I)}};if(a&&i.length){const v=a==="backward",S=v?fh:vo,E={pages:i,pageParams:o},T=S(r,E);l=await k(E,T,v)}else{const v=e??i.length;do{const S=c===0?o[0]??r.initialPageParam:vo(r,l);if(c>0&&S==null)break;l=await k(l,S),c++}while(c<v)}return l};t.options.persister?t.fetchFn=()=>{var p,w;return(w=(p=t.options).persister)==null?void 0:w.call(p,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vo(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function fh(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Xn,Cn,er,yt,An,Ve,Or,Pn,ct,cc,Zt,Il,ph=(Il=class extends lc{constructor(t){super();G(this,ct);G(this,Xn);G(this,Cn);G(this,er);G(this,yt);G(this,An);G(this,Ve);G(this,Or);G(this,Pn);W(this,Pn,!1),W(this,Or,t.defaultOptions),this.setOptions(t.options),this.observers=[],W(this,An,t.client),W(this,yt,N(this,An).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,W(this,Cn,wo(this.options)),this.state=t.state??N(this,Cn),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return N(this,Xn)}get promise(){var t;return(t=N(this,Ve))==null?void 0:t.promise}setOptions(t){if(this.options={...N(this,Or),...t},t!=null&&t._type&&W(this,Xn,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=wo(this.options);n.data!==void 0&&(this.setState(jo(n.data,n.dataUpdatedAt)),W(this,Cn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,yt).remove(this)}setData(t,n){const r=Ea(this.state.data,t,this.options);return ce(this,ct,Zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){ce(this,ct,Zt).call(this,{type:"setState",state:t})}cancel(t){var r,a;const n=(r=N(this,Ve))==null?void 0:r.promise;return(a=N(this,Ve))==null||a.cancel(t),n?n.then(st).catch(st):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return N(this,Cn)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>ut(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ns||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>pn(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:!sc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=N(this,Ve))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=N(this,Ve))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),N(this,yt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(N(this,Ve)&&(N(this,Pn)||ce(this,ct,cc).call(this)?N(this,Ve).cancel({revert:!0}):N(this,Ve).cancelRetry()),this.scheduleGc()),N(this,yt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ce(this,ct,Zt).call(this,{type:"invalidate"})}async fetch(t,n){var d,u,m,h,f,x,p,w,g,k,v;if(this.state.fetchStatus!=="idle"&&((d=N(this,Ve))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(N(this,Ve))return N(this,Ve).continueRetry(),N(this,Ve).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 r=new AbortController,a=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(W(this,Pn,!0),r.signal)})},i=()=>{const S=ac(this.options,n),T=(()=>{const P={client:N(this,An),queryKey:this.queryKey,meta:this.meta};return a(P),P})();return W(this,Pn,!1),this.options.persister?this.options.persister(S,T,this):S(T)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:N(this,An),state:this.state,fetchFn:i};return a(S),S})(),c=N(this,Xn)==="infinite"?hh(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),W(this,er,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&ce(this,ct,Zt).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),W(this,Ve,oc({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof _a&&S.revert&&this.setState({...N(this,er),fetchStatus:"idle"}),r.abort()},onFail:(S,E)=>{ce(this,ct,Zt).call(this,{type:"failed",failureCount:S,error:E})},onPause:()=>{ce(this,ct,Zt).call(this,{type:"pause"})},onContinue:()=>{ce(this,ct,Zt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await N(this,Ve).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=N(this,yt).config).onSuccess)==null||f.call(h,S,this),(p=(x=N(this,yt).config).onSettled)==null||p.call(x,S,this.state.error,this),S}catch(S){if(S instanceof _a){if(S.silent)return N(this,Ve).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw ce(this,ct,Zt).call(this,{type:"error",error:S}),(g=(w=N(this,yt).config).onError)==null||g.call(w,S,this),(v=(k=N(this,yt).config).onSettled)==null||v.call(k,this.state.data,S,this),S}finally{this.scheduleGc()}}},Xn=new WeakMap,Cn=new WeakMap,er=new WeakMap,yt=new WeakMap,An=new WeakMap,Ve=new WeakMap,Or=new WeakMap,Pn=new WeakMap,ct=new WeakSet,cc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...uc(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...jo(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return W(this,er,t.manual?a:void 0),a;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Me.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),N(this,yt).notify({query:this,type:"updated",action:t})})},Il);function uc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ic(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function jo(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function wo(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var it,he,Lr,rt,En,tr,Wt,on,zr,nr,rr,In,_n,ln,sr,ve,Pr,Ta,Fa,Da,Ra,$a,Oa,La,dc,_l,xh=(_l=class extends xr{constructor(t,n){super();G(this,ve);G(this,it);G(this,he);G(this,Lr);G(this,rt);G(this,En);G(this,tr);G(this,Wt);G(this,on);G(this,zr);G(this,nr);G(this,rr);G(this,In);G(this,_n);G(this,ln);G(this,sr,new Set);this.options=n,W(this,it,t),W(this,on,null),W(this,Wt,Ia()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,he).addObserver(this),No(N(this,he),this.options)?ce(this,ve,Pr).call(this):this.updateResult(),ce(this,ve,Ra).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return za(N(this,he),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return za(N(this,he),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ce(this,ve,$a).call(this),ce(this,ve,Oa).call(this),N(this,he).removeObserver(this)}setOptions(t){const n=this.options,r=N(this,he);if(this.options=N(this,it).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ut(this.options.enabled,N(this,he))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ce(this,ve,La).call(this),N(this,he).setOptions(this.options),n._defaulted&&!ws(this.options,n)&&N(this,it).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,he),observer:this});const a=this.hasListeners();a&&So(N(this,he),r,this.options,n)&&ce(this,ve,Pr).call(this),this.updateResult(),a&&(N(this,he)!==r||ut(this.options.enabled,N(this,he))!==ut(n.enabled,N(this,he))||pn(this.options.staleTime,N(this,he))!==pn(n.staleTime,N(this,he)))&&ce(this,ve,Ta).call(this);const i=ce(this,ve,Fa).call(this);a&&(N(this,he)!==r||ut(this.options.enabled,N(this,he))!==ut(n.enabled,N(this,he))||i!==N(this,ln))&&ce(this,ve,Da).call(this,i)}getOptimisticResult(t){const n=N(this,it).getQueryCache().build(N(this,it),t),r=this.createResult(n,t);return yh(this,r)&&(W(this,rt,r),W(this,tr,this.options),W(this,En,N(this,he).state)),r}getCurrentResult(){return N(this,rt)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&N(this,Wt).status==="pending"&&N(this,Wt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){N(this,sr).add(t)}getCurrentQuery(){return N(this,he)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=N(this,it).defaultQueryOptions(t),r=N(this,it).getQueryCache().build(N(this,it),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ce(this,ve,Pr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,rt)))}createResult(t,n){var I;const r=N(this,he),a=this.options,i=N(this,rt),o=N(this,En),l=N(this,tr),d=t!==r?t.state:N(this,Lr),{state:u}=t;let m={...u},h=!1,f;if(n._optimisticResults){const $=this.hasListeners(),ne=!$&&No(t,n),q=$&&So(t,r,n,a);(ne||q)&&(m={...m,...uc(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:x,errorUpdatedAt:p,status:w}=m;f=m.data;let g=!1;if(n.placeholderData!==void 0&&f===void 0&&w==="pending"){let $;i!=null&&i.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?($=i.data,g=!0):$=typeof n.placeholderData=="function"?n.placeholderData((I=N(this,rr))==null?void 0:I.state.data,N(this,rr)):n.placeholderData,$!==void 0&&(w="success",f=Ea(i==null?void 0:i.data,$,n),h=!0)}if(n.select&&f!==void 0&&!g)if(i&&f===(o==null?void 0:o.data)&&n.select===N(this,zr))f=N(this,nr);else try{W(this,zr,n.select),f=n.select(f),f=Ea(i==null?void 0:i.data,f,n),W(this,nr,f),W(this,on,null)}catch($){W(this,on,$)}N(this,on)&&(x=N(this,on),f=N(this,nr),p=Date.now(),w="error");const k=m.fetchStatus==="fetching",v=w==="pending",S=w==="error",E=v&&k,T=f!==void 0,O={status:w,fetchStatus:m.fetchStatus,isPending:v,isSuccess:w==="success",isError:S,isInitialLoading:E,isLoading:E,data:f,dataUpdatedAt:m.dataUpdatedAt,error:x,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:k,isRefetching:k&&!v,isLoadingError:S&&!T,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&T,isStale:yi(t,n),refetch:this.refetch,promise:N(this,Wt),isEnabled:ut(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const $=O.data!==void 0,ne=O.status==="error"&&!$,q=z=>{ne?z.reject(O.error):$&&z.resolve(O.data)},K=()=>{const z=W(this,Wt,O.promise=Ia());q(z)},ee=N(this,Wt);switch(ee.status){case"pending":t.queryHash===r.queryHash&&q(ee);break;case"fulfilled":(ne||O.data!==ee.value)&&K();break;case"rejected":(!ne||O.error!==ee.reason)&&K();break}}return O}updateResult(){const t=N(this,rt),n=this.createResult(N(this,he),this.options);if(W(this,En,N(this,he).state),W(this,tr,this.options),N(this,En).data!==void 0&&W(this,rr,N(this,he)),ws(n,t))return;W(this,rt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!N(this,sr).size)return!0;const o=new Set(i??N(this,sr));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,rt)).some(l=>{const c=l;return N(this,rt)[c]!==t[c]&&o.has(c)})};ce(this,ve,dc).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ce(this,ve,Ra).call(this)}},it=new WeakMap,he=new WeakMap,Lr=new WeakMap,rt=new WeakMap,En=new WeakMap,tr=new WeakMap,Wt=new WeakMap,on=new WeakMap,zr=new WeakMap,nr=new WeakMap,rr=new WeakMap,In=new WeakMap,_n=new WeakMap,ln=new WeakMap,sr=new WeakMap,ve=new WeakSet,Pr=function(t){ce(this,ve,La).call(this);let n=N(this,he).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(st)),n},Ta=function(){ce(this,ve,$a).call(this);const t=pn(this.options.staleTime,N(this,he));if(Dr.isServer()||N(this,rt).isStale||!Ca(t))return;const r=sc(N(this,rt).dataUpdatedAt,t)+1;W(this,In,jn.setTimeout(()=>{N(this,rt).isStale||this.updateResult()},r))},Fa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,he)):this.options.refetchInterval)??!1},Da=function(t){ce(this,ve,Oa).call(this),W(this,ln,t),!(Dr.isServer()||ut(this.options.enabled,N(this,he))===!1||!Ca(N(this,ln))||N(this,ln)===0)&&W(this,_n,jn.setInterval(()=>{(this.options.refetchIntervalInBackground||pi.isFocused())&&ce(this,ve,Pr).call(this)},N(this,ln)))},Ra=function(){ce(this,ve,Ta).call(this),ce(this,ve,Da).call(this,ce(this,ve,Fa).call(this))},$a=function(){N(this,In)!==void 0&&(jn.clearTimeout(N(this,In)),W(this,In,void 0))},Oa=function(){N(this,_n)!==void 0&&(jn.clearInterval(N(this,_n)),W(this,_n,void 0))},La=function(){const t=N(this,it).getQueryCache().build(N(this,it),this.options);if(t===N(this,he))return;const n=N(this,he);W(this,he,t),W(this,Lr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},dc=function(t){Me.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(N(this,rt))}),N(this,it).getQueryCache().notify({query:N(this,he),type:"observerResultsUpdated"})})},_l);function gh(e,t){return ut(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&ut(t.retryOnMount,e)===!1)}function No(e,t){return gh(e,t)||e.state.data!==void 0&&za(e,t,t.refetchOnMount)}function za(e,t,n){if(ut(t.enabled,e)!==!1&&pn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&yi(e,t)}return!1}function So(e,t,n,r){return(e!==t||ut(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&yi(e,n)}function yi(e,t){return ut(t.enabled,e)!==!1&&e.isStaleByTime(pn(t.staleTime,e))}function yh(e,t){return!ws(e.getCurrentResult(),t)}var Mr,Ft,Ke,Tn,Dt,tn,Tl,bh=(Tl=class extends lc{constructor(t){super();G(this,Dt);G(this,Mr);G(this,Ft);G(this,Ke);G(this,Tn);W(this,Mr,t.client),this.mutationId=t.mutationId,W(this,Ke,t.mutationCache),W(this,Ft,[]),this.state=t.state||mc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){N(this,Ft).includes(t)||(N(this,Ft).push(t),this.clearGcTimeout(),N(this,Ke).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){W(this,Ft,N(this,Ft).filter(n=>n!==t)),this.scheduleGc(),N(this,Ke).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,Ft).length||(this.state.status==="pending"?this.scheduleGc():N(this,Ke).remove(this))}continue(){var t;return((t=N(this,Tn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,d,u,m,h,f,x,p,w,g,k,v,S,E,T,P;const n=()=>{ce(this,Dt,tn).call(this,{type:"continue"})},r={client:N(this,Mr),meta:this.options.meta,mutationKey:this.options.mutationKey};W(this,Tn,oc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(O,I)=>{ce(this,Dt,tn).call(this,{type:"failed",failureCount:O,error:I})},onPause:()=>{ce(this,Dt,tn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,Ke).canRun(this)}));const a=this.state.status==="pending",i=!N(this,Tn).canStart();try{if(a)n();else{ce(this,Dt,tn).call(this,{type:"pending",variables:t,isPaused:i}),N(this,Ke).config.onMutate&&await N(this,Ke).config.onMutate(t,this,r);const I=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,r));I!==this.state.context&&ce(this,Dt,tn).call(this,{type:"pending",context:I,variables:t,isPaused:i})}const O=await N(this,Tn).start();return await((d=(c=N(this,Ke).config).onSuccess)==null?void 0:d.call(c,O,t,this.state.context,this,r)),await((m=(u=this.options).onSuccess)==null?void 0:m.call(u,O,t,this.state.context,r)),await((f=(h=N(this,Ke).config).onSettled)==null?void 0:f.call(h,O,null,this.state.variables,this.state.context,this,r)),await((p=(x=this.options).onSettled)==null?void 0:p.call(x,O,null,t,this.state.context,r)),ce(this,Dt,tn).call(this,{type:"success",data:O}),O}catch(O){try{await((g=(w=N(this,Ke).config).onError)==null?void 0:g.call(w,O,t,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((v=(k=this.options).onError)==null?void 0:v.call(k,O,t,this.state.context,r))}catch(I){Promise.reject(I)}try{await((E=(S=N(this,Ke).config).onSettled)==null?void 0:E.call(S,void 0,O,this.state.variables,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((P=(T=this.options).onSettled)==null?void 0:P.call(T,void 0,O,t,this.state.context,r))}catch(I){Promise.reject(I)}throw ce(this,Dt,tn).call(this,{type:"error",error:O}),O}finally{N(this,Ke).runNext(this)}}},Mr=new WeakMap,Ft=new WeakMap,Ke=new WeakMap,Tn=new WeakMap,Dt=new WeakSet,tn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,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{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Me.batch(()=>{N(this,Ft).forEach(r=>{r.onMutationUpdate(t)}),N(this,Ke).notify({mutation:this,type:"updated",action:t})})},Tl);function mc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yt,kt,qr,Fl,vh=(Fl=class extends xr{constructor(t={}){super();G(this,Yt);G(this,kt);G(this,qr);this.config=t,W(this,Yt,new Set),W(this,kt,new Map),W(this,qr,0)}build(t,n,r){const a=new bh({client:t,mutationCache:this,mutationId:++es(this,qr)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){N(this,Yt).add(t);const n=ns(t);if(typeof n=="string"){const r=N(this,kt).get(n);r?r.push(t):N(this,kt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,Yt).delete(t)){const n=ns(t);if(typeof n=="string"){const r=N(this,kt).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&N(this,kt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ns(t);if(typeof n=="string"){const r=N(this,kt).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=ns(t);if(typeof n=="string"){const a=(r=N(this,kt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Me.batch(()=>{N(this,Yt).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,Yt).clear(),N(this,kt).clear()})}getAll(){return Array.from(N(this,Yt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>go(n,r))}findAll(t={}){return this.getAll().filter(n=>go(t,n))}notify(t){Me.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Me.batch(()=>Promise.all(t.map(n=>n.continue().catch(st))))}},Yt=new WeakMap,kt=new WeakMap,qr=new WeakMap,Fl);function ns(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ht,cn,ot,Kt,Jt,xs,Ma,Dl,jh=(Dl=class extends xr{constructor(t,n){super();G(this,Jt);G(this,Ht);G(this,cn);G(this,ot);G(this,Kt);W(this,Ht,t),this.setOptions(n),this.bindMethods(),ce(this,Jt,xs).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=N(this,Ht).defaultMutationOptions(t),ws(this.options,n)||N(this,Ht).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,ot),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Fn(n.mutationKey)!==Fn(this.options.mutationKey)?this.reset():((r=N(this,ot))==null?void 0:r.state.status)==="pending"&&N(this,ot).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,ot))==null||t.removeObserver(this)}onMutationUpdate(t){ce(this,Jt,xs).call(this),ce(this,Jt,Ma).call(this,t)}getCurrentResult(){return N(this,cn)}reset(){var t;(t=N(this,ot))==null||t.removeObserver(this),W(this,ot,void 0),ce(this,Jt,xs).call(this),ce(this,Jt,Ma).call(this)}mutate(t,n){var r;return W(this,Kt,n),(r=N(this,ot))==null||r.removeObserver(this),W(this,ot,N(this,Ht).getMutationCache().build(N(this,Ht),this.options)),N(this,ot).addObserver(this),N(this,ot).execute(t)}},Ht=new WeakMap,cn=new WeakMap,ot=new WeakMap,Kt=new WeakMap,Jt=new WeakSet,xs=function(){var n;const t=((n=N(this,ot))==null?void 0:n.state)??mc();W(this,cn,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Ma=function(t){Me.batch(()=>{var n,r,a,i,o,l,c,d;if(N(this,Kt)&&this.hasListeners()){const u=N(this,cn).variables,m=N(this,cn).context,h={client:N(this,Ht),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(n=N(this,Kt)).onSuccess)==null||r.call(n,t.data,u,m,h)}catch(f){Promise.reject(f)}try{(i=(a=N(this,Kt)).onSettled)==null||i.call(a,t.data,null,u,m,h)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(l=(o=N(this,Kt)).onError)==null||l.call(o,t.error,u,m,h)}catch(f){Promise.reject(f)}try{(d=(c=N(this,Kt)).onSettled)==null||d.call(c,void 0,t.error,u,m,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(u=>{u(N(this,cn))})})},Dl),Rt,Rl,wh=(Rl=class extends xr{constructor(t={}){super();G(this,Rt);this.config=t,W(this,Rt,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??xi(a,n);let o=this.get(i);return o||(o=new ph({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){N(this,Rt).has(t.queryHash)||(N(this,Rt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=N(this,Rt).get(t.queryHash);n&&(t.destroy(),n===t&&N(this,Rt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Me.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,Rt).get(t)}getAll(){return[...N(this,Rt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>xo(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>xo(t,r)):n}notify(t){Me.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Me.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Me.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Rt=new WeakMap,Rl),Fe,un,dn,ar,ir,mn,or,lr,$l,Nh=($l=class{constructor(e={}){G(this,Fe);G(this,un);G(this,dn);G(this,ar);G(this,ir);G(this,mn);G(this,or);G(this,lr);W(this,Fe,e.queryCache||new wh),W(this,un,e.mutationCache||new vh),W(this,dn,e.defaultOptions||{}),W(this,ar,new Map),W(this,ir,new Map),W(this,mn,0)}mount(){es(this,mn)._++,N(this,mn)===1&&(W(this,or,pi.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,Fe).onFocus())})),W(this,lr,Ss.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,Fe).onOnline())})))}unmount(){var e,t;es(this,mn)._--,N(this,mn)===0&&((e=N(this,or))==null||e.call(this),W(this,or,void 0),(t=N(this,lr))==null||t.call(this),W(this,lr,void 0))}isFetching(e){return N(this,Fe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=N(this,Fe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=N(this,Fe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(pn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return N(this,Fe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=N(this,Fe).get(r.queryHash),i=a==null?void 0:a.state.data,o=rh(t,i);if(o!==void 0)return N(this,Fe).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return Me.batch(()=>N(this,Fe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=N(this,Fe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=N(this,Fe);Me.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=N(this,Fe);return Me.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Me.batch(()=>N(this,Fe).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(st).catch(st)}invalidateQueries(e,t={}){return Me.batch(()=>(N(this,Fe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Me.batch(()=>N(this,Fe).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(st)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(st)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=N(this,Fe).build(this,t);return n.isStaleByTime(pn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(st).catch(st)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(st).catch(st)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Ss.isOnline()?N(this,un).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,Fe)}getMutationCache(){return N(this,un)}getDefaultOptions(){return N(this,dn)}setDefaultOptions(e){W(this,dn,e)}setQueryDefaults(e,t){N(this,ar).set(Fn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,ar).values()],n={};return t.forEach(r=>{Fr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){N(this,ir).set(Fn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,ir).values()],n={};return t.forEach(r=>{Fr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,dn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xi(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===Ns&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,dn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,Fe).clear(),N(this,un).clear()}},Fe=new WeakMap,un=new WeakMap,dn=new WeakMap,ar=new WeakMap,ir=new WeakMap,mn=new WeakMap,or=new WeakMap,lr=new WeakMap,$l),hc=A.createContext(void 0),xt=e=>{const t=A.useContext(hc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Sh=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(hc.Provider,{value:e,children:t})),fc=A.createContext(!1),kh=()=>A.useContext(fc);fc.Provider;function Ch(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ah=A.createContext(Ch()),Ph=()=>A.useContext(Ah),Eh=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?gi(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ih=e=>{A.useEffect(()=>{e.clearReset()},[e])},_h=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||gi(n,[e.error,r])),Th=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Fh=(e,t)=>e.isLoading&&e.isFetching&&!t,Dh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,ko=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Rh(e,t,n){var f,x,p,w;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 r=kh(),a=Ph(),i=xt(),o=i.defaultQueryOptions(e);(x=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||x.call(f,o);const l=i.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`));const c=e.subscribed!==!1;o._optimisticResults=r?"isRestoring":c?"optimistic":void 0,Th(o),Eh(o,a,l),Ih(a);const d=!i.getQueryCache().get(o.queryHash),[u]=A.useState(()=>new t(i,o)),m=u.getOptimisticResult(o),h=!r&&c;if(A.useSyncExternalStore(A.useCallback(g=>{const k=h?u.subscribe(Me.batchCalls(g)):st;return u.updateResult(),k},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),A.useEffect(()=>{u.setOptions(o)},[o,u]),Dh(o,m))throw ko(o,u,a);if(_h({result:m,errorResetBoundary:a,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw m.error;if((w=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||w.call(p,o,m),o.experimental_prefetchInRender&&!Dr.isServer()&&Fh(m,r)){const g=d?ko(o,u,a):l==null?void 0:l.promise;g==null||g.catch(st).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?m:u.trackResult(m)}function be(e,t){return Rh(e,xh)}function $h(e,t){const n=xt(),[r]=A.useState(()=>new jh(n,e));A.useEffect(()=>{r.setOptions(e)},[r,e]);const a=A.useSyncExternalStore(A.useCallback(o=>r.subscribe(Me.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=A.useCallback((o,l)=>{r.mutate(o,l).catch(st)},[r]);if(a.error&&gi(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function pc(e){return e.trim().replace(/\/+$/,"")}const Bs=new Map;function xc(e,t){Bs.set(e,t)}function Oh(e){return Bs.get(e)}function Lh(e){Bs.delete(e)}function zh(e){for(const[t,n]of Bs)if(n.accessToken===e)return t}let qa=null;function gc(e){qa=pc(e)}let yc=null;function Mh(e){yc=e}function qh(){return yc}let bc=null;function Bh(e){bc=e.trim()}function Vh(){return bc}function Uh(){return qa!==null?qa:pc("")}const Co={get apiBaseUrl(){return Uh()},apiVersion:"v1"};function Zh(e){const t=e.startsWith("/")?e:`/${e}`;return`${Co.apiBaseUrl}/api/${Co.apiVersion}${t}`}const vc="auth:session-expired";function Wh(){window.dispatchEvent(new CustomEvent(vc))}function jc(e){return`${vc}:${e}`}const Yh=j.createContext(null);function Hh({instanceId:e,accessToken:t,onSessionExpired:n,children:r}){const a=Oh(e);return a&&xc(e,{...a,accessToken:t}),Mh(t),j.useEffect(()=>{if(!n)return;const i=jc(e),o=()=>n();return window.addEventListener(i,o),()=>window.removeEventListener(i,o)},[e,n]),s.jsx(Yh.Provider,{value:{accessToken:t},children:r})}class gr extends Error{constructor(n,r,a,i,o){super(a??r);wr(this,"status");wr(this,"title");wr(this,"details");wr(this,"extensions");this.name="ApiError",this.status=n,this.title=r,this.details=i,this.extensions=o}}const wc="tax-remittance.auth";function Kh(){var t;const e=localStorage.getItem(wc);if(!e)return null;try{const n=JSON.parse(e);return!n.accessToken||!((t=n.user)!=null&&t.userId)?null:new Date(n.user.expiresAt)<=new Date?(Ba(),null):n}catch{return Ba(),null}}function Ba(){localStorage.removeItem(wc)}function Qh(){var e;return((e=Kh())==null?void 0:e.accessToken)??null}async function Jh(e){let t=null;try{t=await e.json()}catch{}const n=(t==null?void 0:t.title)??"Request failed",r=t==null?void 0:t.detail,a=t==null?void 0:t.errors;return new gr(e.status,n,r,a,t??void 0)}async function Zr(e,t={}){const{body:n,auth:r=!0,headers:a,responseType:i="json",...o}=t,l=new Headers(a);i==="blob"?l.set("Accept","application/pdf"):i==="text"?l.set("Accept","text/html"):l.set("Accept","application/json"),n!==void 0&&l.set("Content-Type","application/json");let c=null;if(r){const m=qh()??Qh();m&&(c=m,l.set("Authorization",`Bearer ${m}`))}const d=Vh();d&&l.set("X-Client-ID",d);const u=await fetch(Zh(e),{...o,headers:l,body:n!==void 0?JSON.stringify(n):void 0});if(!u.ok){const m=await Jh(u);if(r&&m.status===401){Ba();const h=c?zh(c):void 0;h?window.dispatchEvent(new CustomEvent(jc(h))):Wh()}throw m}if(u.status!==204)return i==="blob"?await u.blob():i==="text"?await u.text():await u.json()}async function me(e,t={}){return(await Zr(e,t)).data}const lt=10;function bi({search:e,pageNumber:t=1,pageSize:n=lt}={}){const r=new URLSearchParams({pageNumber:String(t),pageSize:String(n)});return e!=null&&e.trim()&&r.set("search",e.trim()),me(`/portal/entities/mine?${r}`)}function Gh(e){return me("/portal/entities",{method:"POST",body:e})}function Xh(e,t){return me(`/portal/entities/${e}`,{method:"PATCH",body:t})}const Nc=j.createContext(null);function ef({onOrganizationCreated:e,enabledPayments:t=["federal","state"],onPaymentRequired:n,children:r}){var p;const[a,i]=j.useState(null),{data:o=[],isLoading:l,isError:c,refetch:d}=be({queryKey:["entities","mine"],queryFn:async()=>(await bi({pageNumber:1,pageSize:100})).items}),u=j.useRef(new Set),m=j.useRef(!1);j.useEffect(()=>{if(l)return;if(!m.current){o.forEach(g=>u.current.add(g.entityId)),m.current=!0;return}o.filter(g=>!u.current.has(g.entityId)).forEach(g=>{u.current.add(g.entityId),e==null||e(g)})},[o,l,e]);const h=a!==null&&o.some(w=>w.entityId===a)?a:((p=o[0])==null?void 0:p.entityId)??null,f=o.find(w=>w.entityId===h)??null,x=async()=>{await d()};return s.jsx(Nc.Provider,{value:{entities:o,isLoading:l,isError:c,selectedEntity:f,setSelectedEntityId:i,refetchEntities:x,enabledPayments:t,onPaymentRequired:n},children:r})}function zn(){const e=j.useContext(Nc);if(!e)throw new Error("useEmbeddedContext must be used inside EmbeddedContextProvider");return e}const tf=j.createContext(null);function nf({theme:e,children:t}){const n={},r=n,a=(e==null?void 0:e.primaryColor)??"#2563eb";r["--embedded-primary"]=a,r["--embedded-primary-dark"]=`color-mix(in srgb, ${a} 82%, black)`,r["--embedded-primary-light"]=`color-mix(in srgb, ${a} 15%, white)`;const i=(e==null?void 0:e.secondaryColor)??"#0891b2";r["--embedded-secondary"]=i,r["--embedded-secondary-dark"]=`color-mix(in srgb, ${i} 82%, black)`,r["--embedded-secondary-light"]=`color-mix(in srgb, ${i} 15%, white)`;const o=(e==null?void 0:e.tertiaryColor)??"#7c3aed";return r["--embedded-tertiary"]=o,r["--embedded-tertiary-dark"]=`color-mix(in srgb, ${o} 82%, black)`,r["--embedded-tertiary-light"]=`color-mix(in srgb, ${o} 15%, white)`,e!=null&&e.borderRadius&&(r["--embedded-radius"]=e.borderRadius),e!=null&&e.fontFamily&&(n.fontFamily=e.fontFamily),r.minHeight="100%",s.jsx("div",{className:"tax-remittance-embedded",style:n,children:t})}const Sc=j.createContext(null),rf=6e3;function sf(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function af({toast:e,onDismiss:t}){const n=e.variant==="success";return s.jsxs("div",{role:"alert",className:`w-full max-w-md overflow-hidden rounded-xl border shadow-lg ${n?"border-emerald-700 bg-[#E8F7C8]":"border-red-300 bg-[#FCE8EA]"}`,children:[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 ${n?"border-emerald-800 text-emerald-900":"border-red-400 text-red-700"}`,children:s.jsx(of,{})})]}),s.jsx("div",{className:`mx-5 border-t ${n?"border-emerald-700":"border-red-300"}`}),s.jsx("p",{className:"px-5 py-4 text-sm text-slate-700",children:e.message})]})}function of(){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 lf({children:e}){const[t,n]=j.useState([]),r=j.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]),a=j.useCallback((o,l,c)=>{const d=sf();n(u=>[...u,{id:d,variant:o,title:l,message:c}]),window.setTimeout(()=>{r(d)},rf)},[r]),i=j.useMemo(()=>({showSuccess:(o,l)=>a("success",o,l),showError:(o,l)=>a("error",o,l)}),[a]);return s.jsxs(Sc.Provider,{value:i,children:[e,Br.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(af,{toast:o,onDismiss:r})},o.id))}),document.body)]})}function Vs(){const e=j.useContext(Sc);if(!e)throw new Error("useToast must be used within ToastProvider");return e}class cf extends j.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 uf(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 df({navigateFnRef:e,onNavigate:t}){const n=ke(),r=Se();return j.useEffect(()=>(e.current=n,()=>{e.current=null}),[n,e]),j.useEffect(()=>{t==null||t(uf(r.pathname),r.pathname)},[r.pathname,t]),null}function mf({selectEntityFnRef:e}){const{setSelectedEntityId:t}=zn();return j.useEffect(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function vi({appKey:e,accessToken:t,apiBaseUrl:n,theme:r,onSessionExpired:a,onOrganizationCreated:i,onNavigate:o,onPaymentRequired:l,navigateFnRef:c,selectEntityFnRef:d,enabledPayments:u,children:m}){const[h]=j.useState(()=>crypto.randomUUID());xc(h,{apiBaseUrl:n.trim().replace(/\/+$/,""),clientId:e.trim(),accessToken:t}),gc(n),Bh(e),j.useEffect(()=>()=>{Lh(h)},[h]);const[f]=j.useState(()=>new Nh({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return s.jsx(tf.Provider,{value:h,children:s.jsx(nf,{theme:r,children:s.jsx(Sh,{client:f,children:s.jsx(lf,{children:s.jsx(Hh,{instanceId:h,accessToken:t,onSessionExpired:a,children:s.jsx(pm,{children:s.jsxs(ef,{onOrganizationCreated:i,enabledPayments:u,onPaymentRequired:l,children:[s.jsx(df,{navigateFnRef:c,onNavigate:o}),s.jsx(mf,{selectEntityFnRef:d}),s.jsx(cf,{children:m})]})})})})})})})}function ji(){const{entities:e,isLoading:t,isError:n,refetchEntities:r}=zn(),a=ke();return j.useEffect(()=>{t||n||a(e.length===0?"/create-entity":"/dashboard",{replace:!0})},[t,n,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"})}):n?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:r,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 wi(){const{entities:e,selectedEntity:t,setSelectedEntityId:n}=zn(),r=ke(),i=Se().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:()=>r(-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(hf,{}),"Back"]}),s.jsx("div",{className:"flex-1"})]}),s.jsx("main",{className:"flex-1 p-5",children:s.jsx(xm,{context:{entities:e,selectedEntity:t,setSelectedEntityId:n}})})]})}function hf(){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 ff=["Organization name & EIN","Business type & primary state","Automatic dashboard access","Start managing tax payments"];function pf({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(Ao,{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:ff.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(rs,{})}),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(Ao,{className:"h-4 w-4 sm:h-[18px] sm:w-[18px]"}),"Create Entity",s.jsx(xf,{})]})]})]}),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(rs,{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(rs,{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(rs,{className:"h-3 w-3 text-emerald-500"}),"Free to start"]})]})]})}function Ao({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 rs({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 xf(){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 Ni(){const e=ke(),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(pf,{onCreateClick:t})})}var Wr=e=>e.type==="checkbox",hn=e=>e instanceof Date,We=e=>e==null;const Si=e=>typeof e=="object";var Ee=e=>!We(e)&&!Array.isArray(e)&&Si(e)&&!hn(e),Va=e=>Ee(e)&&e.target?Wr(e.target)?e.target.checked:e.target.value:e,kc=(e,t)=>t.split(".").some((n,r,a)=>!isNaN(Number(n))&&e.has(a.slice(0,r).join("."))),Cc=e=>{const t=e.constructor&&e.constructor.prototype;return Ee(t)&&t.hasOwnProperty("isPrototypeOf")},Us=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Te(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Us&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(Ee(e)&&Cc(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=Te(e[a]));return r}const nn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Ct={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},St={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ac="root",ki=["__proto__","constructor","prototype"],gf=/^\w*$/;var Yr=e=>gf.test(e),we=e=>e===void 0;const yf=/[.[\]'"]/;var Zs=e=>e.split(yf).filter(Boolean),Z=(e,t,n)=>{if(!t||!Ee(e))return n;const r=Yr(t)?[t]:Zs(t);if(r.some(i=>ki.includes(i)))return n;const a=r.reduce((i,o)=>We(i)?void 0:i[o],e);return we(a)||a===e?we(e[t])?n:e[t]:a},dt=e=>typeof e=="boolean",Qe=e=>typeof e=="function",ye=(e,t,n)=>{let r=-1;const a=Yr(t)?[t]:Zs(t),i=a.length,o=i-1;for(;++r<i;){const l=a[r];let c=n;if(r!==o){const d=e[l];c=Ee(d)||Array.isArray(d)?d:isNaN(+a[r+1])?{}:[]}if(ki.includes(l))return;e[l]=c,e=e[l]}};const Pc=j.createContext(null);Pc.displayName="HookFormControlContext";const Ci=()=>j.useContext(Pc);var Ec=(e,t,n,r=!0)=>{const a={};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==Ct.all&&(t._proxyFormState[o]=!r||Ct.all),n&&(n[o]=!0),e[o]}});return a};const Ai=Us?j.useLayoutEffect:j.useEffect;function bf(e){const t=Ci(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[o,l]=j.useState(()=>({...n._formState,defaultValues:n._defaultValues})),c=j.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Ai(()=>n._subscribe({name:a,formState:c.current,exact:i,callback:d=>{!r&&l({...n._formState,...d,defaultValues:n._defaultValues})}}),[a,r,i]),j.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),j.useMemo(()=>Ec(o,n,c.current,!1),[o,n])}var Je=e=>typeof e=="string",Ua=(e,t,n,r,a)=>Je(e)?(r&&t.watch.add(e),Z(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),Z(n,i))):(r&&(t.watchAll=!0),n),Za=e=>We(e)||!Si(e);const Po=(e,t)=>t.length===0&&!Array.isArray(e)&&!Cc(e);function mt(e,t,n=new WeakMap){if(e===t)return!0;if(Za(e)||Za(t))return Object.is(e,t);if(hn(e)&&hn(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(Po(e,r)||Po(t,a))return Object.is(e,t);if(!r.length&&Array.isArray(e)!==Array.isArray(t))return!1;const i=n.get(e);if(i&&i.has(t))return!0;if(i)i.add(t);else{const o=new WeakSet;o.add(t),n.set(e,o)}for(const o of r){const l=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(hn(l)&&hn(c)||(Ee(l)||Array.isArray(l))&&(Ee(c)||Array.isArray(c))?!mt(l,c,n):!Object.is(l,c))return!1}}return!0}function vf(e){const t=Ci(),{control:n=t,name:r,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},c=j.useRef(a),d=j.useRef(l),u=j.useRef(void 0),m=j.useRef(n),h=j.useRef(r);d.current=l;const[f,x]=j.useState(()=>{const S=n._getWatch(r,c.current);return d.current?d.current(S):S}),p=j.useCallback(S=>{const E=Ua(r,n._names,S||n._formValues,!1,c.current);return d.current?d.current(E):E},[n._formValues,n._names,r]),w=j.useCallback(S=>{if(!i){const E=Ua(r,n._names,S||n._formValues,!1,c.current);if(d.current){const T=d.current(E);mt(T,u.current)||(x(T),u.current=T)}else x(E)}},[n._formValues,n._names,i,r]);Ai(()=>((m.current!==n||!mt(h.current,r))&&(m.current=n,h.current=r,w()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:S=>{w(S.values)}})),[n,o,r,w]),j.useEffect(()=>n._removeUnmounted());const g=m.current!==n,k=h.current,v=j.useMemo(()=>{if(i)return null;const S=!g&&!mt(k,r);return g||S?p():null},[i,g,r,k,p]);return v!==null?v:f}function jf(e){const t=Ci(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,c=kc(a._names.array,n),d=j.useMemo(()=>Z(a._formValues,n,Z(a._defaultValues,n,o)),[a,n,o]),u=vf({control:a,name:n,defaultValue:d,exact:l}),m=bf({control:a,name:n,exact:l}),h=j.useRef(e),f=j.useRef(null),x=j.useRef(a.register(n,{...e.rules,value:u,...dt(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const p=j.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Z(m.errors,n)},isDirty:{enumerable:!0,get:()=>!!Z(m.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!Z(m.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!Z(m.validatingFields,n)},error:{enumerable:!0,get:()=>Z(m.errors,n)}}),[m,n]),w=j.useCallback(S=>{const E=Va(S);return Z(a._fields,n)||(x.current=a.register(n,{...h.current.rules,value:E})),x.current.onChange({target:{value:Va(S),name:n},type:nn.CHANGE})},[n,a]),g=j.useCallback(()=>x.current.onBlur({target:{value:Z(a._formValues,n),name:n},type:nn.BLUR}),[n,a._formValues]),k=j.useCallback(S=>{S&&(f.current={focus:()=>Qe(S.focus)&&S.focus(),select:()=>Qe(S.select)&&S.select(),setCustomValidity:T=>Qe(S.setCustomValidity)&&S.setCustomValidity(T),reportValidity:()=>Qe(S.reportValidity)&&S.reportValidity()});const E=Z(a._fields,n);E&&E._f&&S&&(E._f.ref=f.current)},[a._fields,n]),v=j.useMemo(()=>({name:n,value:u,...dt(r)||m.disabled?{disabled:m.disabled||r}:{},onChange:w,onBlur:g,ref:k}),[n,r,m.disabled,w,g,k,u]);return j.useEffect(()=>{const S=a._options.shouldUnregister||i;a.register(n,{...h.current.rules,...dt(h.current.disabled)?{disabled:h.current.disabled}:{}});const E=(T,P)=>{const O=Z(a._fields,T);O&&O._f&&(O._f.mount=P)};if(E(n,!0),S){const T=Te(Z(i?a._defaultValues:a._options.values||a._defaultValues,n,Z(a._options.defaultValues,n,h.current.defaultValue)));ye(a._defaultValues,n,T),we(Z(a._formValues,n))&&ye(a._formValues,n,T)}if(!c&&a.register(n),f.current){const T=Z(a._fields,n);T&&T._f&&(T._f.ref=f.current)}return()=>{(c?S&&!a._state.action:S)?a.unregister(n):E(n,!1)}},[n,a,c,i]),j.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),j.useMemo(()=>({field:v,formState:m,fieldState:p}),[v,m,p])}const ze=e=>e.render(jf(e)),Ic=e=>{const t={};for(const n of Object.keys(e))if(Si(e[n])&&e[n]!==null&&!hn(e[n])){const r=Ic(e[n]);for(const a of Object.keys(r))t[`${n}.${a}`]=r[a]}else t[n]=e[n];return t},wf=j.createContext(null);wf.displayName="HookFormContext";var Pi=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},_c=e=>Array.isArray(e)?e.filter(Boolean):[],gs=e=>Array.isArray(e)?e:[e],Eo=()=>{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 Tc(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&Ee(a)&&i){const o=Tc(a,i);Ee(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var Ze=e=>Ee(e)&&!Object.keys(e).length,Ei=e=>e.type==="file",ks=e=>{if(!Us)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Fc=e=>e.type==="select-multiple",Ii=e=>e.type==="radio",Nf=e=>Ii(e)||Wr(e),la=e=>ks(e)&&e.isConnected;function Sf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;){if(We(e)){e=void 0;break}e=e[t[r]],r++}return e}function kf(e){for(const t in e)if(e.hasOwnProperty(t)&&!we(e[t]))return!1;return!0}function Le(e,t){if(Je(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Yr(t)?[t]:Zs(t);if(n.some(o=>ki.includes(String(o))))return e;const r=n.length===1?e:Sf(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(Ee(r)&&Ze(r)||Array.isArray(r)&&kf(r))&&Le(e,n.slice(0,-1)),e}var Cf=e=>{for(const t in e)if(Qe(e[t]))return!0;return!1};function Dc(e){return Array.isArray(e)||Ee(e)&&!Cf(e)}function Wa(e,t={}){for(const n in e){const r=e[n];Dc(r)?(t[n]=Array.isArray(r)?[]:{},Wa(r,t[n])):we(r)||(t[n]=!0)}return t}function Ya(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>Ya(n));return t.some(n=>n!==void 0)?t:void 0}if(Ee(e)){const t={};for(const n in e){const r=Ya(e[n]);we(r)||(t[n]=r)}return Object.keys(t).length?t:void 0}}}function vn(e,t,n){n||(n=Wa(t));for(const r in e){const a=e[r];if(Dc(a))we(t)||Za(n[r])?n[r]=Wa(a,Array.isArray(a)?[]:{}):vn(a,We(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!mt(a,i)}}return Ya(n)||{}}const Io={value:!1,isValid:!1},_o={value:!0,isValid:!0};var Rc=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!we(e[0].attributes.value)?we(e[0].value)||e[0].value===""?_o:{value:e[0].value,isValid:!0}:_o:Io}return Io},$c=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>we(e)?e:t?e===""?NaN:e&&+e:n&&Je(e)?new Date(e):r?r(e):e;const To={isValid:!1,value:null};var Oc=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,To):To;function Fo(e){const t=e.ref;return Ei(t)?t.files:Ii(t)?Oc(e.refs).value:Fc(t)?[...t.selectedOptions].map(({value:n})=>n):Wr(t)?Rc(e.refs).value:$c(we(t.value)?e.ref.value:t.value,e)}var Af=(e,t,n,r)=>{const a={};for(const i of e){const o=Z(t,i);o&&ye(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},Cs=e=>e instanceof RegExp,Sr=e=>we(e)?e:Cs(e)?e.source:Ee(e)?Cs(e.value)?e.value.source:e.value:e,ss=e=>({isOnSubmit:!e||e===Ct.onSubmit,isOnBlur:e===Ct.onBlur,isOnChange:e===Ct.onChange,isOnAll:e===Ct.all,isOnTouch:e===Ct.onTouched});const Do="AsyncFunction";var Pf=e=>{if(!e||!e.validate)return!1;if(Qe(e.validate))return e.validate.constructor.name===Do;if(Ee(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Do)return!0}return!1},Ef=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ca=(e,t,n)=>{if(n)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const r of t.watch)if(e.startsWith(r)&&e.charAt(r.length)===".")return!0;return!1};const _r=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=Z(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(_r(l,t))break}else if(Ee(l)&&_r(l,t))break}}};function Ro(e,t,n){const r=Z(e,n);if(r||Yr(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=Z(t,i),l=Z(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:n}}var If=(e,t,n,r)=>{n(e);const{name:a,...i}=e,o=Object.keys(i);return!o.length||r&&o.length>=Object.keys(t).length||o.find(l=>t[l]===(!r||Ct.all))},_f=(e,t,n)=>!e||!t||e===t||gs(e).some(r=>r&&(n?r===t||r.startsWith(t+"."):r.startsWith(t)||t.startsWith(r))),Tf=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,Ff=(e,t)=>!_c(Z(e,t)).length&&Le(e,t),$o=(e,t,n)=>{const r=Z(e,n),a=Array.isArray(r)?r:[];return ye(a,Ac,t[n]),ye(e,n,a),e};function Oo(e,t,n="validate"){if(Je(e)||Array.isArray(e)&&e.every(Je)||dt(e)&&!e)return{type:n,message:Je(e)?e:"",ref:t}}var Vn=e=>Ee(e)&&!Cs(e)?e:{value:e,message:""},Lo=async(e,t,n,r,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:u,min:m,max:h,pattern:f,validate:x,name:p,valueAsNumber:w,mount:g}=e._f,k=Z(n,p);if(!g||t.has(p))return{};const v=l?l[0]:o,S=q=>{if(a&&v.reportValidity){const K=dt(q)?"":q||"";l?l.forEach(ee=>ee.setCustomValidity(K)):v.setCustomValidity(K),v.reportValidity()}},E={},T=Ii(o),P=Wr(o),O=T||P,I=(w||Ei(o))&&we(o.value)&&we(k)||ks(o)&&o.value===""||k===""||Array.isArray(k)&&!k.length,$=Pi.bind(null,p,r,E),ne=(q,K,ee,z=St.maxLength,ae=St.minLength)=>{const oe=q?K:ee;E[p]={type:q?z:ae,message:oe,ref:o,...$(q?z:ae,oe)}};if(i?!Array.isArray(k)||!k.length:c&&(!O&&(I||We(k))||dt(k)&&!k||P&&!Rc(l).isValid||T&&!Oc(l).isValid)){const{value:q,message:K}=Je(c)?{value:!!c,message:c}:Vn(c);if(q&&(E[p]={type:St.required,message:K,ref:v,...$(St.required,K)},!r))return S(K),E}if(!I&&(!We(m)||!We(h))){let q,K;const ee=Vn(h),z=Vn(m);if(!We(k)&&!isNaN(k)){const ae=o.valueAsNumber||k&&+k;We(ee.value)||(q=ae>ee.value),We(z.value)||(K=ae<z.value)}else{const ae=o.valueAsDate||new Date(k),oe=De=>new Date(new Date().toDateString()+" "+De),Q=o.type=="time",Ae=o.type=="week";Je(ee.value)&&k&&(q=Q?oe(k)>oe(ee.value):Ae?k>ee.value:ae>new Date(ee.value)),Je(z.value)&&k&&(K=Q?oe(k)<oe(z.value):Ae?k<z.value:ae<new Date(z.value))}if((q||K)&&(ne(!!q,ee.message,z.message,St.max,St.min),!r))return S(E[p].message),E}if((d||u)&&!I&&(Je(k)||i&&Array.isArray(k))){const q=Vn(d),K=Vn(u),ee=!We(q.value)&&k.length>+q.value,z=!We(K.value)&&k.length<+K.value;if((ee||z)&&(ne(ee,q.message,K.message),!r))return S(E[p].message),E}if(f&&!I&&Je(k)){const{value:q,message:K}=Vn(f);if(Cs(q)&&!k.match(q)&&(E[p]={type:St.pattern,message:K,ref:o,...$(St.pattern,K)},!r))return S(K),E}if(x){if(Qe(x)){const q=await x(k,n),K=Oo(q,v);if(K&&(E[p]={...K,...$(St.validate,K.message)},!r))return S(K.message),E}else if(Ee(x)){let q={};for(const K in x){if(!Ze(q)&&!r)break;const ee=Oo(await x[K](k,n),v,K);ee&&(q={...ee,...$(K,ee.message)},S(ee.message),r&&(E[p]=q))}if(!Ze(q)&&(E[p]={ref:v,...q},!r))return E}}return S(!0),E};const Df={mode:Ct.onSubmit,reValidateMode:Ct.onChange,shouldFocusError:!0},ua="form",Lc={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Rf(e={}){let t={...Df,...e},n={...Te(Lc),isLoading:Qe(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},a=Ee(t.defaultValues)||Ee(t.values)?Te(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:Te(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,d=0,u=0,m=ss(t.mode),h=ss(t.reValidateMode);const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={...f};let p={...x};const w={array:Eo(),state:Eo()},g=t.criteriaMode===Ct.all,k=b=>C=>{clearTimeout(d),d=setTimeout(b,C)},v=async b=>{if(!o.keepIsValid&&!t.disabled&&(x.isValid||p.isValid||b)){let C;t.resolver?(C=Ze((await K()).errors),S()):C=await ae({fields:r,onlyCheckValid:!0,eventType:nn.VALID}),C!==n.isValid&&w.state.next({isValid:C})}},S=(b,C)=>{!t.disabled&&(x.isValidating||x.validatingFields||p.isValidating||p.validatingFields)&&((b||Array.from(l.mount)).forEach(y=>{y&&(C?ye(n.validatingFields,y,C):Le(n.validatingFields,y))}),w.state.next({validatingFields:n.validatingFields,isValidating:!Ze(n.validatingFields)}))},E=()=>{n.dirtyFields=vn(a,i)},T=(b,C=[],y,D,L=!0,Y=!0)=>{if(D&&y&&!t.disabled){if(o.action=!0,Y&&Array.isArray(Z(r,b))){const B=y(Z(r,b),D.argA,D.argB);L&&ye(r,b,B)}if(Y&&Array.isArray(Z(n.errors,b))){const B=y(Z(n.errors,b),D.argA,D.argB);L&&ye(n.errors,b,B),Ff(n.errors,b)}if((x.touchedFields||p.touchedFields)&&Y&&Array.isArray(Z(n.touchedFields,b))){const B=y(Z(n.touchedFields,b),D.argA,D.argB);L&&ye(n.touchedFields,b,B)}(x.dirtyFields||p.dirtyFields)&&E(),w.state.next({name:b,isDirty:Q(b,C),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ye(i,b,C)},P=(b,C)=>{ye(n.errors,b,C),n.errors={...n.errors},w.state.next({errors:n.errors})},O=b=>{n.errors=b,w.state.next({errors:n.errors,isValid:!1})},I=b=>{const C=Yr(b)?[b]:Zs(b);let y=i,D=a;for(let L=0;L<C.length-1;L++){const Y=C[L];if(y=We(y)?y:y[Y],D=We(D)?D:D[Y],y===null&&D!==null)return!0}return!1},$=(b,C,y,D)=>{const L=Z(r,b);if(L){if(I(b))return;const Y=we(Z(i,b)),B=Z(i,b,we(y)?Z(a,b):y);we(B)||D&&D.defaultChecked||C?ye(i,b,C?B:Fo(L._f)):Oe(b,B),o.mount&&!o.action&&(v(),Y&&n.isDirty&&(x.isDirty||p.isDirty)&&(Q()||(n.isDirty=!1,w.state.next({...n}))),e.shouldUnregister&&Y&&!we(Z(i,b))&&ca(b,l)&&(o.watch=!0))}},ne=(b,C,y,D,L)=>{let Y=!1,B=!1;const H={name:b};if(!t.disabled){if(!y||D){const V=mt(Z(a,b),C);(x.isDirty||p.isDirty)&&(B=n.isDirty,n.isDirty=H.isDirty=!V||Q(),Y=B!==H.isDirty),B=!!Z(n.dirtyFields,b),V!==n.isDirty?n.dirtyFields=vn(a,i):V?Le(n.dirtyFields,b):ye(n.dirtyFields,b,!0),H.dirtyFields=n.dirtyFields,Y=Y||(x.dirtyFields||p.dirtyFields)&&B!==!V}if(y){const V=Z(n.touchedFields,b);V||(ye(n.touchedFields,b,y),H.touchedFields=n.touchedFields,Y=Y||(x.touchedFields||p.touchedFields)&&V!==y)}Y&&L&&w.state.next(H)}return Y?H:{}},q=(b,C,y,D)=>{const L=Z(n.errors,b),Y=(x.isValid||p.isValid)&&dt(C)&&n.isValid!==C;if(t.delayError&&y?(c=k(()=>P(b,y)),c(t.delayError)):(clearTimeout(d),c=null,y?ye(n.errors,b,y):Le(n.errors,b),n.errors={...n.errors}),(y?!mt(L,y):L)||!Ze(D)||Y){const B={...D,...Y&&dt(C)?{isValid:C}:{},errors:n.errors,name:b};n={...n,...B},w.state.next(B)}},K=async b=>(S(b,!0),await t.resolver(i,t.context,Af(b||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),ee=async b=>{const{errors:C}=await K(b);if(S(b),b){for(const y of b){const D=Z(C,y);D?l.array.has(y)&&Ee(D)&&!Object.keys(D).some(L=>!Number.isNaN(Number(L)))?$o(n.errors,{[y]:D},y):ye(n.errors,y,D):Le(n.errors,y)}n.errors={...n.errors}}else n.errors=C;return C},z=async({name:b,eventType:C})=>{if(e.validate){const y=await e.validate({formValues:i,formState:n,name:b,eventType:C});if(Ee(y))for(const D in y){const L=y[D];L&&qe(`${ua}.${D}`,{message:Je(L.message)?L.message:"",type:L.type||St.validate})}else Je(y)||!y?qe(ua,{message:y||"",type:St.validate}):Ne(ua);return y}return!0},ae=async({fields:b,onlyCheckValid:C,name:y,eventType:D,context:L={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(L.runRootValidation=!0,!await z({name:y,eventType:D})&&(L.valid=!1,C)))return L.valid;for(const Y in b){const B=b[Y];if(B){const{_f:H,...V}=B;if(H){const ie=l.array.has(H.name),Be=B._f&&Pf(B._f),Vt=x.validatingFields||x.isValidating||p.validatingFields||p.isValidating;Be&&Vt&&S([H.name],!0);const Ut=await Lo(B,l.disabled,i,g,t.shouldUseNativeValidation&&!C,ie);if(Be&&Vt&&S([H.name]),Ut[H.name]&&(L.valid=!1,C)||(!C&&(Z(Ut,H.name)?ie?$o(n.errors,Ut,H.name):ye(n.errors,H.name,Ut[H.name]):Le(n.errors,H.name)),e.shouldUseNativeValidation&&Ut[H.name]))break}!Ze(V)&&await ae({context:L,onlyCheckValid:C,fields:V,name:Y,eventType:D})}}return L.valid},oe=()=>{for(const b of l.unMount){const C=Z(r,b);C&&(C._f.refs?C._f.refs.every(y=>!la(y)):!la(C._f.ref))&&tt(b)}l.unMount=new Set},Q=(b,C)=>!t.disabled&&(b&&C&&ye(i,b,C),!mt(o.mount?i:a,a)),Ae=(b,C,y)=>Ua(b,l,{...o.mount?i:we(C)?a:Je(b)?{[b]:C}:C},y,C),De=b=>_c(Z(o.mount?i:a,b,t.shouldUnregister?Z(a,b,[]):[])),Oe=(b,C,y={},D=!1,L=!1)=>{const Y=Z(r,b);let B=C;if(Y){const H=Y._f;H&&(!H.disabled&&ye(i,b,$c(C,H)),B=ks(H.ref)&&We(C)?"":C,Fc(H.ref)?[...H.ref.options].forEach(V=>V.selected=B.includes(V.value)):H.refs?Wr(H.ref)?H.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(B)?V.checked=!!B.find(ie=>ie===V.value):V.checked=B===V.value||!!B)}):H.refs.forEach(V=>V.checked=V.value===B):Ei(H.ref)?H.ref.value="":(H.ref.value=B,!H.ref.type&&!L&&w.state.next({name:b,values:D?i:Te(i)})))}(y.shouldDirty||y.shouldTouch)&&ne(b,B,y.shouldTouch,y.shouldDirty,!L),y.shouldValidate&&Pe(b)},ue=(b,C,y,D=!1,L=!1)=>{for(const Y in C){if(!C.hasOwnProperty(Y))return;const B=C[Y],H=b+"."+Y,V=Z(r,H);(l.array.has(b)||Ee(B)||V&&!V._f)&&!hn(B)?ue(H,B,y,D,L):Oe(H,B,y,D,L)}},xe=(b,C,y,D,L=!1)=>{const Y=Z(r,b),B=l.array.has(b),H=D?C:Te(C),V=Z(i,b),ie=mt(V,H);if(ie||ye(i,b,H),B)w.array.next({name:b,values:D?i:Te(i)}),(x.isDirty||x.dirtyFields||p.isDirty||p.dirtyFields)&&y.shouldDirty&&(E(),L||w.state.next({name:b,dirtyFields:n.dirtyFields,isDirty:Q(b,H)}));else{const Be=Array.isArray(H)&&!H.length||Ze(H);!Y||Y._f||We(H)||Be?Oe(b,H,y,D,L):ue(b,H,y,D,L)}if(!ie&&!L){const Be=ca(b,l),Vt=D?i:Te(i);w.state.next({...Be&&n,name:o.mount||Be?b:void 0,values:Vt})}},R=(b,C,y={})=>xe(b,C,y,!1),pe=(b,C={})=>{const y=Qe(b)?b(i):b;if(!mt(i,y)){i={...i,...y};const D=Ic(y);for(const L of l.mount)L in D&&xe(L,D[L],C,!0,!0);w.state.next({...n,name:void 0,type:void 0,...u?{values:i}:{}}),C.shouldValidate&&v()}},U=async b=>{o.mount=!0;const C=b.target;let y=C.name,D=!0;const L=Z(r,y),Y=B=>{D=Number.isNaN(B)||hn(B)&&isNaN(B.getTime())||mt(B,Z(i,y,B))};if(L){let B,H;const V=C.type?Fo(L._f):Va(b),ie=b.type===nn.BLUR||b.type===nn.FOCUS_OUT,Be=!Ef(L._f)&&!e.validate&&!t.resolver&&!Z(n.errors,y)&&!L._f.deps,Vt=Be||Tf(ie,Z(n.touchedFields,y),n.isSubmitted,h,m),Ut=ca(y,l,ie);ye(i,y,V),ie?(!C||!C.readOnly)&&(L._f.onBlur&&L._f.onBlur(b),c&&c(0)):L._f.onChange&&L._f.onChange(b);const jr=ne(y,V,ie),md=!Ze(jr)||Ut;if(!ie&&w.state.next({name:y,type:b.type,...u?{values:Te(i)}:{}}),Vt)return(!Be||!n.isValid)&&(x.isValid||p.isValid)&&(t.mode==="onBlur"?ie&&v():ie||v()),md&&w.state.next({name:y,...Ut?{}:jr});if(!t.resolver&&e.validate&&await z({name:y,eventType:b.type}),!ie&&Ut&&w.state.next({...n}),t.resolver){const{errors:oo}=await K([y]);if(S([y]),Y(V),!D){!Ze(jr)&&w.state.next(jr);return}const hd=Ro(n.errors,r,y),lo=Ro(oo,r,hd.name||y);B=lo.error,y=lo.name,H=Ze(oo)}else S([y],!0),B=(await Lo(L,l.disabled,i,g,t.shouldUseNativeValidation))[y],S([y]),Y(V),D&&(B?H=!1:(x.isValid||p.isValid)&&(H=await ae({fields:r,onlyCheckValid:!0,name:y,eventType:b.type})));D&&(L._f.deps&&(!Array.isArray(L._f.deps)||L._f.deps.length>0)&&Pe(L._f.deps),q(y,H,B,jr))}},fe=(b,C)=>{if(Z(n.errors,C)&&b.focus)return b.focus(),1},Pe=async(b,C={})=>{let y,D;const L=gs(b);if(t.resolver){const Y=await ee(we(b)?b:L);y=Ze(Y),D=b?!L.some(B=>Z(Y,B)):y}else b?(D=(await Promise.all(L.map(async Y=>{const B=Z(r,Y);return await ae({fields:B&&B._f?{[Y]:B}:B,eventType:nn.TRIGGER})}))).every(Boolean),!(!D&&!n.isValid)&&v()):D=y=await ae({fields:r,name:b,eventType:nn.TRIGGER});return w.state.next({...!Je(b)||(x.isValid||p.isValid)&&y!==n.isValid?{}:{name:b},...t.resolver||!b?{isValid:y}:{},errors:n.errors}),C.shouldFocus&&!D&&_r(r,fe,b?L:l.mount),D},Xe=(b,C)=>{let y={...o.mount?i:a};return C&&(y=Tc(C.dirtyFields?n.dirtyFields:n.touchedFields,y)),we(b)?y:Je(b)?Z(y,b):b.map(D=>Z(y,D))},le=(b,C)=>({invalid:!!Z((C||n).errors,b),isDirty:!!Z((C||n).dirtyFields,b),error:Z((C||n).errors,b),isValidating:!!Z(n.validatingFields,b),isTouched:!!Z((C||n).touchedFields,b)}),Ne=b=>{const C=b?gs(b):void 0;C==null||C.forEach(y=>Le(n.errors,y)),C?C.forEach(y=>{w.state.next({name:y,errors:n.errors})}):w.state.next({errors:{}})},qe=(b,C,y)=>{const D=(Z(r,b,{_f:{}})._f||{}).ref,L=Z(n.errors,b)||{},{ref:Y,message:B,type:H,...V}=L;ye(n.errors,b,{...V,...C,ref:D}),w.state.next({name:b,errors:n.errors,isValid:!1}),y&&y.shouldFocus&&D&&D.focus&&D.focus()},He=(b,C)=>{if(Qe(b)){u++;const{unsubscribe:y}=w.state.subscribe({next:L=>"values"in L&&b(L.values||Ae(void 0,C),L)});let D=!1;return{unsubscribe:()=>{D||(D=!0,u--,y())}}}return Ae(b,C,!0)},re=b=>{var C;const y=!!(!((C=b.formState)===null||C===void 0)&&C.values);y&&u++;const{unsubscribe:D}=w.state.subscribe({next:Y=>{if(_f(b.name,Y.name,b.exact)&&If(Y,b.formState||x,_t,b.reRenderRoot)){const B={...i};b.callback({values:B,...n,...Y,defaultValues:a})}}});if(!y)return D;let L=!1;return()=>{L||(L=!0,u--,D())}},et=b=>(o.mount=!0,p={...p,...b.formState},re({...b,formState:{...f,...b.formState}})),tt=(b,C={})=>{for(const y of b?gs(b):l.mount)l.mount.delete(y),l.array.delete(y),C.keepValue||(Le(r,y),Le(i,y)),!C.keepError&&Le(n.errors,y),!C.keepDirty&&Le(n.dirtyFields,y),!C.keepTouched&&Le(n.touchedFields,y),!C.keepIsValidating&&Le(n.validatingFields,y),!t.shouldUnregister&&!C.keepDefaultValue&&Le(a,y);w.state.next({values:Te(i)}),w.state.next({...n,...C.keepDirty?{isDirty:Q()}:{}}),!C.keepIsValid&&v()},jt=({disabled:b,name:C})=>{if(dt(b)&&o.mount||b||l.disabled.has(C)){const L=l.disabled.has(C)!==!!b;b?l.disabled.add(C):l.disabled.delete(C),L&&o.mount&&!o.action&&v()}},gt=(b,C={})=>{let y=Z(r,b);const D=dt(C.disabled)||dt(t.disabled),L=!l.registerName.has(b)&&y&&y._f&&!y._f.mount;return ye(r,b,{...y||{},_f:{...y&&y._f?y._f:{ref:{name:b}},name:b,mount:!0,...C}}),l.mount.add(b),y&&!L?jt({disabled:dt(C.disabled)?C.disabled:t.disabled,name:b}):$(b,!0,C.value),{...D?{disabled:C.disabled||t.disabled}:{},...t.progressive?{required:!!C.required,min:Sr(C.min),max:Sr(C.max),minLength:Sr(C.minLength),maxLength:Sr(C.maxLength),pattern:Sr(C.pattern)}:{},name:b,onChange:U,onBlur:U,ref:Y=>{if(Y){l.registerName.add(b),gt(b,C),l.registerName.delete(b),y=Z(r,b);const B=we(Y.value)&&Y.querySelectorAll&&Y.querySelectorAll("input,select,textarea")[0]||Y,H=Nf(B),V=y._f.refs||[];if(H?V.find(ie=>ie===B):B===y._f.ref)return;ye(r,b,{_f:{...y._f,...H?{refs:[...V.filter(la),B,...Array.isArray(Z(a,b))?[{}]:[]],ref:{type:B.type,name:b}}:{ref:B}}}),$(b,!1,void 0,B)}else y=Z(r,b,{}),y._f&&(y._f.mount=!1),(t.shouldUnregister||C.shouldUnregister)&&!(kc(l.array,b)&&o.action)&&l.unMount.add(b)}}},wt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&_r(r,fe,l.mount),Mt=b=>{dt(b)&&(w.state.next({disabled:b}),_r(r,(C,y)=>{const D=Z(r,y);D&&(C.disabled=D._f.disabled||b,Array.isArray(D._f.refs)&&D._f.refs.forEach(L=>{L.disabled=D._f.disabled||b}))},0,!1))},Pt=(b,C)=>async y=>{let D;y&&(y.preventDefault&&y.preventDefault(),y.persist&&y.persist());let L=Te(i);if(w.state.next({isSubmitting:!0}),t.resolver){const{errors:Y,values:B}=await K();S(),n.errors=Y,L=Te(B)}else await ae({fields:r,eventType:nn.SUBMIT});if(l.disabled.size)for(const Y of l.disabled)Le(L,Y);if(Le(n.errors,Ac),Ze(n.errors)){w.state.next({errors:{}});try{await b(L,y)}catch(Y){D=Y}}else C&&await C({...n.errors},y),wt(),setTimeout(wt);if(w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ze(n.errors)&&!D,submitCount:n.submitCount+1,errors:n.errors}),D)throw D},qt=(b,C={})=>{Z(r,b)&&(we(C.defaultValue)?R(b,Te(Z(a,b))):(R(b,C.defaultValue),ye(a,b,Te(C.defaultValue))),C.keepTouched||Le(n.touchedFields,b),C.keepDirty||(Le(n.dirtyFields,b),n.isDirty=C.defaultValue?Q(b,Te(Z(a,b))):Q()),C.keepError||(Le(n.errors,b),x.isValid&&v()),w.state.next({...n}))},Et=(b,C={})=>{const y=b?Te(b):a,D=Te(y),L=Ze(b),Y=D;if(C.keepDefaultValues||(a=y),!C.keepValues){if(C.keepDirtyValues){const B=new Set([...l.mount,...Object.keys(vn(a,i))]);for(const H of Array.from(B)){const V=Z(n.dirtyFields,H),ie=Z(i,H),Be=Z(Y,H);V&&!we(ie)?ye(Y,H,ie):!V&&!we(Be)&&R(H,Be)}}else{if(Us&&we(b))for(const B of l.mount){const H=Z(r,B);if(H&&H._f){const V=Array.isArray(H._f.refs)?H._f.refs[0]:H._f.ref;if(ks(V)){const ie=V.closest("form");if(ie){ie.reset();break}}}}if(C.keepFieldsRef)for(const B of l.mount)R(B,Z(Y,B));else r={}}if(t.shouldUnregister){if(i=C.keepDefaultValues?Te(a):{},C.keepFieldsRef)for(const B of l.mount)ye(i,B,Z(Y,B))}else i=Te(Y);w.array.next({values:{...Y}}),w.state.next({name:void 0,type:void 0,values:{...Y}})}l={mount:C.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!x.isValid||!!C.keepIsValid||!!C.keepDirtyValues||!t.shouldUnregister&&!Ze(Y),o.watch=!!t.shouldUnregister,o.keepIsValid=!!C.keepIsValid,o.action=!1,C.keepErrors||(n.errors={}),w.state.next({submitCount:C.keepSubmitCount?n.submitCount:0,isDirty:L?!1:C.keepDirty?n.isDirty:C.keepValues?Q():!!(C.keepDefaultValues&&!mt(b,a)),isSubmitted:C.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:C.keepDirtyValues?C.keepDefaultValues&&i?vn(a,i):n.dirtyFields:C.keepDefaultValues&&b?vn(a,b):C.keepDirty?n.dirtyFields:{},touchedFields:C.keepTouched?n.touchedFields:{},errors:C.keepErrors?n.errors:{},isSubmitSuccessful:C.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Nt=(b,C)=>Et(Qe(b)?b(i):b,{...t.resetOptions,...C}),It=(b,C={})=>{const y=Z(r,b),D=y&&y._f;if(D){const L=D.refs?D.refs[0]:D.ref;L.focus&&setTimeout(()=>{L.focus(),C.shouldSelect&&Qe(L.select)&&L.select()})}},_t=b=>{const{name:C,type:y,values:D,...L}=b;n={...n,...L}},de={control:{register:gt,unregister:tt,getFieldState:le,handleSubmit:Pt,setError:qe,_subscribe:re,_runSchema:K,_updateIsValidating:S,_focusError:wt,_getWatch:Ae,_getDirty:Q,_setValid:v,_setFieldArray:T,_setDisabledField:jt,_setErrors:O,_getFieldArray:De,_reset:Et,_resetDefaultValues:()=>Qe(t.defaultValues)&&t.defaultValues().then(b=>{Nt(b,t.resetOptions),w.state.next({isLoading:!1})}),_removeUnmounted:oe,_disableForm:Mt,_subjects:w,_proxyFormState:x,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(b){o=b},get _defaultValues(){return a},get _names(){return l},set _names(b){l=b},get _formState(){return n},get _options(){return t},set _options(b){t={...t,...b},m=ss(t.mode),h=ss(t.reValidateMode)}},subscribe:et,trigger:Pe,register:gt,handleSubmit:Pt,watch:He,setValue:R,setValues:pe,getValues:Xe,reset:Nt,resetField:qt,resetDefaultValues:(b,C={})=>{if(a=Te(b),!C.keepDirty){const y=vn(a,i);n.dirtyFields=y,n.isDirty=!Ze(y)}C.keepIsValid||v(),w.state.next({...n,defaultValues:a})},clearErrors:Ne,unregister:tt,setError:qe,setFocus:It,getFieldState:le};return{...de,formControl:de}}function $t(e={}){const t=j.useRef(void 0),n=j.useRef(void 0),r=j.useRef(e.formControl),[a,i]=j.useState(()=>({...Te(Lc),isLoading:Qe(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Qe(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&r.current!==e.formControl)if(r.current=e.formControl,e.formControl)t.current={...e.formControl,formState:a},e.defaultValues&&!Qe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=Rf(e);t.current={...c,formState:a}}const o=t.current.control;return o._options=e,Ai(()=>{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]),j.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),j.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),j.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),j.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),j.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==a.isDirty&&o._subjects.state.next({isDirty:l})}},[o,a.isDirty]),j.useEffect(()=>{var l;e.values&&!mt(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),j.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=j.useMemo(()=>Ec(a,o),[o,a]),t.current}const zo=(e,t,n)=>{if(e&&"reportValidity"in e){const r=Z(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Ha=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?zo(r.ref,n,e):r&&r.refs&&r.refs.forEach(a=>zo(a,n,e))}},Mo=(e,t)=>{t.shouldUseNativeValidation&&Ha(e,t);const n={};for(const r in e){const a=Z(t.fields,r),i=Object.assign(e[r]||{},{ref:a&&a.ref});if($f(t.names||Object.keys(e),r)){const o=Object.assign({},Z(n,r));ye(o,"root",i),ye(n,r,o)}else ye(n,r,i)}return n},$f=(e,t)=>{const n=qo(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(r=>qo(r).match(`^${n}\\.\\d+`))};function qo(e){return e.replace(/[\[\]]/g,"")}var Bo;function F(e,t,n){function r(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 d=o.prototype,u=Object.keys(d);for(let m=0;m<u.length;m++){const h=u[m];h in l||(l[h]=d[h].bind(l))}}const a=(n==null?void 0:n.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var c;const d=n!=null&&n.Parent?new i:this;r(d,l),(c=d._zod).deferred??(c.deferred=[]);for(const u of d._zod.deferred)u();return d}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>{var c,d;return n!=null&&n.Parent&&l instanceof n.Parent?!0:(d=(c=l==null?void 0:l._zod)==null?void 0:c.traits)==null?void 0:d.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class Wn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class zc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Bo=globalThis).__zod_globalConfig??(Bo.__zod_globalConfig={});const _i=globalThis.__zod_globalConfig;function Dn(e){return _i}function Mc(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function Ka(e,t){return typeof t=="bigint"?t.toString():t}function Ti(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Fi(e){return e==null}function Di(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Vo=Symbol("evaluating");function je(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Vo)return r===void 0&&(r=Vo,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Mn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Uo(e){return JSON.stringify(e)}function Of(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const qc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function As(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Lf=Ti(()=>{var e;if(_i.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 Rr(e){if(As(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(As(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Bc(e){return Rr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const zf=new Set(["string","number","symbol"]);function cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function se(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 Mf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function qf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=gn(e._zod.def,{get shape(){const o={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(o[l]=n.shape[l])}return Mn(this,"shape",o),o},checks:[]});return yn(e,i)}function Bf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=gn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete o[l]}return Mn(this,"shape",o),o},checks:[]});return yn(e,i)}function Vf(e,t){if(!Rr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=gn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Mn(this,"shape",i),i}});return yn(e,a)}function Uf(e,t){if(!Rr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Mn(this,"shape",r),r}});return yn(e,n)}function Zf(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=gn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Mn(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return yn(e,n)}function Wf(e,t,n){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=gn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const d in n){if(!(d in l))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(c[d]=e?new e({type:"optional",innerType:l[d]}):l[d])}else for(const d in l)c[d]=e?new e({type:"optional",innerType:l[d]}):l[d];return Mn(this,"shape",c),c},checks:[]});return yn(t,o)}function Yf(e,t,n){const r=gn(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return Mn(this,"shape",i),i}});return yn(t,r)}function Un(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Hf(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Vc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function as(e){return typeof e=="string"?e:e==null?void 0:e.message}function Rn(e,t,n){var c,d,u,m,h,f;const r=e.message?e.message:as((u=(d=(c=e.inst)==null?void 0:c._zod.def)==null?void 0:d.error)==null?void 0:u.call(d,e))??as((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??as((h=n.customError)==null?void 0:h.call(n,e))??as((f=n.localeError)==null?void 0:f.call(n,e))??"Invalid input",{inst:a,continue:i,input:o,...l}=e;return l.path??(l.path=[]),l.message=r,t!=null&&t.reportInput&&(l.input=o),l}function Ri(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function $r(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Uc=(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,Ka,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$i=F("$ZodError",Uc),Ws=F("$ZodError",Uc,{Parent:Error});function Kf(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function Qf(e,t=n=>n.message){const n={_errors:[]},r=(a,i=[])=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>r({issues:l},[...i,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...i,...o.path]);else{const l=[...i,...o.path];if(l.length===0)n._errors.push(t(o));else{let c=n,d=0;for(;d<l.length;){const u=l[d];d===l.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}}};return r(e),n}const Ys=e=>(t,n,r,a)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Wn;if(o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Rn(c,i,Dn())));throw qc(l,a==null?void 0:a.callee),l}return o.value},Jf=Ys(Ws),Hs=e=>async(t,n,r,a)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new((a==null?void 0:a.Err)??e)(o.issues.map(c=>Rn(c,i,Dn())));throw qc(l,a==null?void 0:a.callee),l}return o.value},Gf=Hs(Ws),Ks=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Wn;return i.issues.length?{success:!1,error:new(e??$i)(i.issues.map(o=>Rn(o,a,Dn())))}:{success:!0,data:i.value}},Xf=Ks(Ws),Qs=e=>async(t,n,r)=>{const a=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Rn(o,a,Dn())))}:{success:!0,data:i.value}},ep=Qs(Ws),tp=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ys(e)(t,n,a)},np=e=>(t,n,r)=>Ys(e)(t,n,r),rp=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Hs(e)(t,n,a)},sp=e=>async(t,n,r)=>Hs(e)(t,n,r),ap=e=>(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Ks(e)(t,n,a)},ip=e=>(t,n,r)=>Ks(e)(t,n,r),op=e=>async(t,n,r)=>{const a=r?{...r,direction:"backward"}:{direction:"backward"};return Qs(e)(t,n,a)},lp=e=>async(t,n,r)=>Qs(e)(t,n,r),cp=/^[cC][0-9a-z]{6,}$/,up=/^[0-9a-z]+$/,dp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mp=/^[0-9a-vA-V]{20}$/,hp=/^[A-Za-z0-9]{27}$/,fp=/^[a-zA-Z0-9_-]{21}$/,pp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xp=/^([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)$/,gp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function bp(){return new RegExp(yp,"u")}const vp=/^(?:(?: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])$/,jp=/^(([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}|:))$/,wp=/^((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])$/,Np=/^(([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])$/,Sp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zc=/^[A-Za-z0-9_-]*$/,kp=/^https?$/,Cp=/^\+[1-9]\d{6,14}$/,Wc="(?:(?:\\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])))",Ap=new RegExp(`^${Wc}$`);function Yc(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 Pp(e){return new RegExp(`^${Yc(e)}$`)}function Ep(e){const t=Yc({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Wc}T(?:${r})$`)}const Ip=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}$`)},_p=/^(?:true|false)$/i,Tp=/^[^A-Z]*$/,Fp=/^[^a-z]*$/,Ot=F("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Dp=F("$ZodCheckMaxLength",(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Fi(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const o=Ri(a);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Rp=F("$ZodCheckMinLength",(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Fi(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const o=Ri(a);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),$p=F("$ZodCheckLengthEquals",(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!Fi(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,i=a.length;if(i===t.length)return;const o=Ri(a),l=i>t.length;r.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Js=F("$ZodCheckStringFormat",(e,t)=>{var n,r;Ot.init(e,t),e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Op=F("$ZodCheckRegex",(e,t)=>{Js.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Lp=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Tp),Js.init(e,t)}),zp=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Fp),Js.init(e,t)}),Mp=F("$ZodCheckIncludes",(e,t)=>{Ot.init(e,t);const n=cr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),qp=F("$ZodCheckStartsWith",(e,t)=>{Ot.init(e,t);const n=new RegExp(`^${cr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Bp=F("$ZodCheckEndsWith",(e,t)=>{Ot.init(e,t);const n=new RegExp(`.*${cr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Vp=F("$ZodCheckOverwrite",(e,t)=>{Ot.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Up{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 r=t.split(`
|
|
13
13
|
`).filter(o=>o),a=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,n=this==null?void 0:this.args,a=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...n,a.join(`
|
|
14
|
-
`))}}const
|
|
15
|
-
if (${
|
|
16
|
-
if (${
|
|
17
|
-
payload.issues = payload.issues.concat(${
|
|
14
|
+
`))}}const Zp={major:4,minor:4,patch:3},Re=F("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Zp;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const i of r)for(const o of i._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const i=(l,c,d)=>{let u=Un(l),m;for(const h of c){if(h._zod.def.when){if(Hf(l)||!h._zod.def.when(l))continue}else if(u)continue;const f=l.issues.length,x=h._zod.check(l);if(x instanceof Promise&&(d==null?void 0:d.async)===!1)throw new Wn;if(m||x instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await x,l.issues.length!==f&&(u||(u=Un(l,f)))});else{if(l.issues.length===f)continue;u||(u=Un(l,f))}}return m?m.then(()=>l):l},o=(l,c,d)=>{if(Un(l))return l.aborted=!0,l;const u=i(c,r,d);if(u instanceof Promise){if(d.async===!1)throw new Wn;return u.then(m=>e._zod.parse(m,d))}return e._zod.parse(u,d)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const u=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(m=>o(m,l,c)):o(u,l,c)}const d=e._zod.parse(l,c);if(d instanceof Promise){if(c.async===!1)throw new Wn;return d.then(u=>i(u,r,c))}return i(d,r,c)}}je(e,"~standard",()=>({validate:i=>{var o;try{const l=Xf(e,i);return l.success?{value:l.data}:{issues:(o=l.error)==null?void 0:o.issues}}catch{return ep(e,i).then(c=>{var d;return c.success?{value:c.data}:{issues:(d=c.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}))}),Oi=F("$ZodString",(e,t)=>{var n;Re.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Ip(e._zod.bag),e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ce=F("$ZodStringFormat",(e,t)=>{Js.init(e,t),Oi.init(e,t)}),Wp=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=xp),Ce.init(e,t)}),Yp=F("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Zo(r))}else t.pattern??(t.pattern=Zo());Ce.init(e,t)}),Hp=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=gp),Ce.init(e,t)}),Kp=F("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{var r;try{const a=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===kp.source&&!/^https?:\/\//i.test(a)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Qp=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=bp()),Ce.init(e,t)}),Jp=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=fp),Ce.init(e,t)}),Gp=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cp),Ce.init(e,t)}),Xp=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=up),Ce.init(e,t)}),ex=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=dp),Ce.init(e,t)}),tx=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=mp),Ce.init(e,t)}),nx=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hp),Ce.init(e,t)}),rx=F("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ep(t)),Ce.init(e,t)}),sx=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ap),Ce.init(e,t)}),ax=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Pp(t)),Ce.init(e,t)}),ix=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pp),Ce.init(e,t)}),ox=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=vp),Ce.init(e,t),e._zod.bag.format="ipv4"}),lx=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=jp),Ce.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),cx=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=wp),Ce.init(e,t)}),ux=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Np),Ce.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,i]=r;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Hc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const dx=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Sp),Ce.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Hc(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function mx(e){if(!Zc.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Hc(n)}const hx=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zc),Ce.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{mx(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),fx=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Cp),Ce.init(e,t)});function px(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const xx=F("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{px(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),gx=F("$ZodBoolean",(e,t)=>{Re.init(e,t),e._zod.pattern=_p,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),yx=F("$ZodUnknown",(e,t)=>{Re.init(e,t),e._zod.parse=n=>n}),bx=F("$ZodNever",(e,t)=>{Re.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Wo(e,t,n){e.issues.length&&t.issues.push(...Vc(n,e.issues)),t.value[n]=e.value}const vx=F("$ZodArray",(e,t)=>{Re.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.value=Array(a.length);const i=[];for(let o=0;o<a.length;o++){const l=a[o],c=t.element._zod.run({value:l,issues:[]},r);c instanceof Promise?i.push(c.then(d=>Wo(d,n,o))):Wo(c,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function Ps(e,t,n,r,a,i){const o=n in r;if(e.issues.length){if(a&&i&&!o)return;t.issues.push(...Vc(n,e.issues))}if(!o&&!a){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Kc(e){var r,a,i,o;const t=Object.keys(e.shape);for(const l of t)if(!((o=(i=(a=(r=e.shape)==null?void 0:r[l])==null?void 0:a._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const n=Mf(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Qc(e,t,n,r,a,i){const o=[],l=a.keySet,c=a.catchall._zod,d=c.def.type,u=c.optin==="optional",m=c.optout==="optional";for(const h in t){if(h==="__proto__"||l.has(h))continue;if(d==="never"){o.push(h);continue}const f=c.run({value:t[h],issues:[]},r);f instanceof Promise?e.push(f.then(x=>Ps(x,n,h,t,u,m))):Ps(f,n,h,t,u,m)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const jx=F("$ZodObject",(e,t)=>{Re.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=Ti(()=>Kc(t));je(e._zod,"propValues",()=>{const l=t.shape,c={};for(const d in l){const u=l[d]._zod;if(u.values){c[d]??(c[d]=new Set);for(const m of u.values)c[d].add(m)}}return c});const a=As,i=t.catchall;let o;e._zod.parse=(l,c)=>{o??(o=r.value);const d=l.value;if(!a(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const u=[],m=o.shape;for(const h of o.keys){const f=m[h],x=f._zod.optin==="optional",p=f._zod.optout==="optional",w=f._zod.run({value:d[h],issues:[]},c);w instanceof Promise?u.push(w.then(g=>Ps(g,l,h,d,x,p))):Ps(w,l,h,d,x,p)}return i?Qc(u,d,l,c,r.value,e):u.length?Promise.all(u).then(()=>l):l}}),wx=F("$ZodObjectJIT",(e,t)=>{jx.init(e,t);const n=e._zod.parse,r=Ti(()=>Kc(t)),a=h=>{var v,S;const f=new Up(["shape","payload","ctx"]),x=r.value,p=E=>{const T=Uo(E);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};f.write("const input = payload.value;");const w=Object.create(null);let g=0;for(const E of x.keys)w[E]=`key_${g++}`;f.write("const newResult = {};");for(const E of x.keys){const T=w[E],P=Uo(E),O=h[E],I=((v=O==null?void 0:O._zod)==null?void 0:v.optin)==="optional",$=((S=O==null?void 0:O._zod)==null?void 0:S.optout)==="optional";f.write(`const ${T} = ${p(E)};`),I&&$?f.write(`
|
|
15
|
+
if (${T}.issues.length) {
|
|
16
|
+
if (${P} in input) {
|
|
17
|
+
payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
|
|
18
18
|
...iss,
|
|
19
|
-
path: iss.path ? [${
|
|
19
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
20
20
|
})));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
if (${
|
|
25
|
-
if (${
|
|
26
|
-
newResult[${
|
|
24
|
+
if (${T}.value === undefined) {
|
|
25
|
+
if (${P} in input) {
|
|
26
|
+
newResult[${P}] = undefined;
|
|
27
27
|
}
|
|
28
28
|
} else {
|
|
29
|
-
newResult[${
|
|
29
|
+
newResult[${P}] = ${T}.value;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
`):
|
|
33
|
-
if (${
|
|
34
|
-
payload.issues = payload.issues.concat(${
|
|
32
|
+
`):I?f.write(`
|
|
33
|
+
if (${T}.issues.length) {
|
|
34
|
+
payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
|
|
35
35
|
...iss,
|
|
36
|
-
path: iss.path ? [${
|
|
36
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
37
37
|
})));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (${
|
|
41
|
-
if (${
|
|
42
|
-
newResult[${
|
|
40
|
+
if (${T}.value === undefined) {
|
|
41
|
+
if (${P} in input) {
|
|
42
|
+
newResult[${P}] = undefined;
|
|
43
43
|
}
|
|
44
44
|
} else {
|
|
45
|
-
newResult[${
|
|
45
|
+
newResult[${P}] = ${T}.value;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
`):f.write(`
|
|
49
|
-
const ${
|
|
50
|
-
if (${
|
|
51
|
-
payload.issues = payload.issues.concat(${
|
|
49
|
+
const ${T}_present = ${P} in input;
|
|
50
|
+
if (${T}.issues.length) {
|
|
51
|
+
payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
|
|
52
52
|
...iss,
|
|
53
|
-
path: iss.path ? [${
|
|
53
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
54
54
|
})));
|
|
55
55
|
}
|
|
56
|
-
if (!${
|
|
56
|
+
if (!${T}_present && !${T}.issues.length) {
|
|
57
57
|
payload.issues.push({
|
|
58
58
|
code: "invalid_type",
|
|
59
59
|
expected: "nonoptional",
|
|
60
60
|
input: undefined,
|
|
61
|
-
path: [${
|
|
61
|
+
path: [${P}]
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
if (${
|
|
66
|
-
if (${
|
|
67
|
-
newResult[${
|
|
65
|
+
if (${T}_present) {
|
|
66
|
+
if (${T}.value === undefined) {
|
|
67
|
+
newResult[${P}] = undefined;
|
|
68
68
|
} else {
|
|
69
|
-
newResult[${
|
|
69
|
+
newResult[${P}] = ${T}.value;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");const k=f.compile();return(E,_)=>k(h,E,_)};let i;const o=As,l=!Ii.jitless,u=l&&If.value,d=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=r.value);const x=h.value;return o(x)?l&&u&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),d?Yc([],x,h,f,m,e):h):n(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h)}});function Zo(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Wn(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>On(o,r,Rn())))}),t)}const px=D("$ZodUnion",(e,t)=>{Re.init(e,t),je(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),je(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),je(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),je(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${r.map(a=>Di(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,a)=>{if(n)return n(r,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:r.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,r,e,a)):Zo(o,r,e,a)}}),xx=D("$ZodIntersection",(e,t)=>{Re.init(e,t),e._zod.parse=(n,r)=>{const a=n.value,i=t.left._zod.run({value:a,issues:[]},r),o=t.right._zod.run({value:a,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,u])=>Wo(n,c,u)):Wo(n,i,o)}});function Ka(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(Or(e)&&Or(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),a={...e,...t};for(const i of r){const o=Ka(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};a[i]=o.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const a=e[r],i=t[r],o=Ka(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wo(e,t,n){const r=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Wn(e))return e;const o=Ka(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const gx=D("$ZodEnum",(e,t)=>{Re.init(e,t);const n=$c(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(a=>Tf.has(typeof a)).map(a=>typeof a=="string"?dr(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return r.has(o)||a.issues.push({code:"invalid_value",values:n,input:o,inst:e}),a}}),yx=D("$ZodLiteral",(e,t)=>{if(Re.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?dr(r):r?dr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,a)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),bx=D("$ZodTransform",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Oc(e.constructor.name);const a=t.transform(n.value,n);if(r.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(n.value=o,n.fallback=!0,n));if(a instanceof Promise)throw new Hn;return n.value=a,n.fallback=!0,n}});function Yo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Hc=D("$ZodOptional",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.optout="optional",je(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),je(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const a=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Yo(o,a)):Yo(i,a)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),vx=D("$ZodExactOptional",(e,t)=>{Hc.init(e,t),je(e._zod,"values",()=>t.innerType._zod.values),je(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),jx=D("$ZodNullable",(e,t)=>{Re.init(e,t),je(e._zod,"optin",()=>t.innerType._zod.optin),je(e._zod,"optout",()=>t.innerType._zod.optout),je(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)}|null)$`):void 0}),je(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Nx=D("$ZodDefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Ho(i,t)):Ho(a,t)}});function Ho(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const wx=D("$ZodPrefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Sx=D("$ZodNonOptional",(e,t)=>{Re.init(e,t),je(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Ko(i,e)):Ko(a,e)}});function Ko(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 kx=D("$ZodCatch",(e,t)=>{Re.init(e,t),e._zod.optin="optional",je(e._zod,"optout",()=>t.innerType._zod.optout),je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>On(o,r,Rn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>On(i,r,Rn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Cx=D("$ZodPipe",(e,t)=>{Re.init(e,t),je(e._zod,"values",()=>t.in._zod.values),je(e._zod,"optin",()=>t.in._zod.optin),je(e._zod,"optout",()=>t.out._zod.optout),je(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(o=>is(o,t.in,r)):is(i,t.in,r)}const a=t.in._zod.run(n,r);return a instanceof Promise?a.then(i=>is(i,t.out,r)):is(a,t.out,r)}});function is(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Ax=D("$ZodReadonly",(e,t)=>{Re.init(e,t),je(e._zod,"propValues",()=>t.innerType._zod.propValues),je(e._zod,"values",()=>t.innerType._zod.values),je(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),je(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(Qo):Qo(a)}});function Qo(e){return e.value=Object.freeze(e.value),e}const Px=D("$ZodCustom",(e,t)=>{Ot.init(e,t),Re.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,a=t.fn(r);if(a instanceof Promise)return a.then(i=>Jo(i,n,r,e));Jo(a,n,r,e)}});function Jo(e,t,n,r){if(!e){const a={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(a.params=r._zod.def.params),t.issues.push($r(a))}}var Go;class Ex{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const a={...r,...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 Ix(){return new Ex}(Go=globalThis).__zod_globalRegistry??(Go.__zod_globalRegistry=Ix());const Ir=globalThis.__zod_globalRegistry;function Tx(e,t){return new e({type:"string",...re(t)})}function Kc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...re(t)})}function Xo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...re(t)})}function _x(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...re(t)})}function Dx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...re(t)})}function Fx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...re(t)})}function Rx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...re(t)})}function Ox(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...re(t)})}function $x(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...re(t)})}function Lx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...re(t)})}function zx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...re(t)})}function Mx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...re(t)})}function qx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...re(t)})}function Vx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...re(t)})}function Bx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...re(t)})}function Ux(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...re(t)})}function Zx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...re(t)})}function Wx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...re(t)})}function Yx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...re(t)})}function Hx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...re(t)})}function Kx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...re(t)})}function Qx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...re(t)})}function Jx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...re(t)})}function Gx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...re(t)})}function Xx(e,t){return new e({type:"string",format:"date",check:"string_format",...re(t)})}function eg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...re(t)})}function tg(e,t){return new e({type:"string",format:"duration",check:"string_format",...re(t)})}function ng(e,t){return new e({type:"boolean",...re(t)})}function rg(e){return new e({type:"unknown"})}function sg(e,t){return new e({type:"never",...re(t)})}function Qc(e,t){return new Cp({check:"max_length",...re(t),maximum:e})}function Es(e,t){return new Ap({check:"min_length",...re(t),minimum:e})}function Jc(e,t){return new Pp({check:"length_equals",...re(t),length:e})}function ag(e,t){return new Ep({check:"string_format",format:"regex",...re(t),pattern:e})}function ig(e){return new Ip({check:"string_format",format:"lowercase",...re(e)})}function og(e){return new Tp({check:"string_format",format:"uppercase",...re(e)})}function lg(e,t){return new _p({check:"string_format",format:"includes",...re(t),includes:e})}function cg(e,t){return new Dp({check:"string_format",format:"starts_with",...re(t),prefix:e})}function ug(e,t){return new Fp({check:"string_format",format:"ends_with",...re(t),suffix:e})}function br(e){return new Rp({check:"overwrite",tx:e})}function dg(e){return br(t=>t.normalize(e))}function mg(){return br(e=>e.trim())}function hg(){return br(e=>e.toLowerCase())}function fg(){return br(e=>e.toUpperCase())}function pg(){return br(e=>Ef(e))}function xg(e,t,n){return new e({type:"array",element:t,...re(n)})}function gg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...re(n)})}function yg(e,t){const n=bg(r=>(r.addIssue=a=>{if(typeof a=="string")r.issues.push($r(a,r.value,n._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push($r(i))}},e(r.value,r)),t);return n}function bg(e,t){const n=new Ot({check:"custom",...re(t)});return n._zod.check=e,n}function Gc(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Ir,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function We(e,t,n={path:[],schemaPath:[]}){var d,m;var r;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const l=(m=(d=e._zod).toJSONSchema)==null?void 0:m.call(d);if(l)o.schema=l;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const x=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,x,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),We(f,t,h),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Ge(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Xc(e,t){var o,l,c,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=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=r.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.`);r.set(m,d[0])}}const a=d=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const v=(p=e.external.registry.get(d[0]))==null?void 0:p.id,g=e.external.uri??(j=>j);if(v)return{ref:g(v)};const k=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=k,{defId:k,ref:`${g("__shared")}#/${m}/${k}`}}if(d[1]===n)return{ref:"#"};const f=`#/${m}/`,x=d[1].schema.id??`__schema${e.counter++}`;return{defId:x,ref:f+x}},i=d=>{if(d[1].schema.$ref)return;const m=d[1],{ref:h,defId:f}=a(d);m.def={...m.schema},f&&(m.defId=f);const x=m.schema;for(const p in x)delete x[p];x.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const m=d[1];if(m.cycle)throw new Error(`Cycle detected: #/${(l=m.cycle)==null?void 0:l.join("/")}/<root>
|
|
73
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");const k=f.compile();return(E,T)=>k(h,E,T)};let i;const o=As,l=!_i.jitless,d=l&&Lf.value,u=t.catchall;let m;e._zod.parse=(h,f)=>{m??(m=r.value);const x=h.value;return o(x)?l&&d&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=a(t.shape)),h=i(h,f),u?Qc([],x,h,f,m,e):h):n(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h)}});function Yo(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const a=e.filter(i=>!Un(i));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(o=>Rn(o,r,Dn())))}),t)}const Nx=F("$ZodUnion",(e,t)=>{Re.init(e,t),je(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),je(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),je(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),je(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${r.map(a=>Di(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,a)=>{if(n)return n(r,a);let i=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:r.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=>Yo(l,r,e,a)):Yo(o,r,e,a)}}),Sx=F("$ZodIntersection",(e,t)=>{Re.init(e,t),e._zod.parse=(n,r)=>{const a=n.value,i=t.left._zod.run({value:a,issues:[]},r),o=t.right._zod.run({value:a,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,d])=>Ho(n,c,d)):Ho(n,i,o)}});function Qa(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(Rr(e)&&Rr(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),a={...e,...t};for(const i of r){const o=Qa(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};a[i]=o.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const a=e[r],i=t[r],o=Qa(a,i);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ho(e,t,n){const r=new Map;let a;for(const l of t.issues)if(l.code==="unrecognized_keys"){a??(a=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&a&&e.issues.push({...a,keys:i}),Un(e))return e;const o=Qa(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const kx=F("$ZodEnum",(e,t)=>{Re.init(e,t);const n=Mc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(a=>zf.has(typeof a)).map(a=>typeof a=="string"?cr(a):a.toString()).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return r.has(o)||a.issues.push({code:"invalid_value",values:n,input:o,inst:e}),a}}),Cx=F("$ZodLiteral",(e,t)=>{if(Re.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?cr(r):r?cr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,a)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Ax=F("$ZodTransform",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zc(e.constructor.name);const a=t.transform(n.value,n);if(r.async)return(a instanceof Promise?a:Promise.resolve(a)).then(o=>(n.value=o,n.fallback=!0,n));if(a instanceof Promise)throw new Wn;return n.value=a,n.fallback=!0,n}});function Ko(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Jc=F("$ZodOptional",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.optout="optional",je(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),je(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const a=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Ko(o,a)):Ko(i,a)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Px=F("$ZodExactOptional",(e,t)=>{Jc.init(e,t),je(e._zod,"values",()=>t.innerType._zod.values),je(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Ex=F("$ZodNullable",(e,t)=>{Re.init(e,t),je(e._zod,"optin",()=>t.innerType._zod.optin),je(e._zod,"optout",()=>t.innerType._zod.optout),je(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)}|null)$`):void 0}),je(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Ix=F("$ZodDefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Qo(i,t)):Qo(a,t)}});function Qo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const _x=F("$ZodPrefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Tx=F("$ZodNonOptional",(e,t)=>{Re.init(e,t),je(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>Jo(i,e)):Jo(a,e)}});function Jo(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 Fx=F("$ZodCatch",(e,t)=>{Re.init(e,t),e._zod.optin="optional",je(e._zod,"optout",()=>t.innerType._zod.optout),je(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>Rn(o,r,Dn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>Rn(i,r,Dn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Dx=F("$ZodPipe",(e,t)=>{Re.init(e,t),je(e._zod,"values",()=>t.in._zod.values),je(e._zod,"optin",()=>t.in._zod.optin),je(e._zod,"optout",()=>t.out._zod.optout),je(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(o=>is(o,t.in,r)):is(i,t.in,r)}const a=t.in._zod.run(n,r);return a instanceof Promise?a.then(i=>is(i,t.out,r)):is(a,t.out,r)}});function is(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Rx=F("$ZodReadonly",(e,t)=>{Re.init(e,t),je(e._zod,"propValues",()=>t.innerType._zod.propValues),je(e._zod,"values",()=>t.innerType._zod.values),je(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),je(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const a=t.innerType._zod.run(n,r);return a instanceof Promise?a.then(Go):Go(a)}});function Go(e){return e.value=Object.freeze(e.value),e}const $x=F("$ZodCustom",(e,t)=>{Ot.init(e,t),Re.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,a=t.fn(r);if(a instanceof Promise)return a.then(i=>Xo(i,n,r,e));Xo(a,n,r,e)}});function Xo(e,t,n,r){if(!e){const a={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(a.params=r._zod.def.params),t.issues.push($r(a))}}var el;class Ox{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const a={...r,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Lx(){return new Ox}(el=globalThis).__zod_globalRegistry??(el.__zod_globalRegistry=Lx());const Er=globalThis.__zod_globalRegistry;function zx(e,t){return new e({type:"string",...se(t)})}function Gc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...se(t)})}function tl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...se(t)})}function Mx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...se(t)})}function qx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...se(t)})}function Bx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...se(t)})}function Vx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...se(t)})}function Ux(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...se(t)})}function Zx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...se(t)})}function Wx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...se(t)})}function Yx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...se(t)})}function Hx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...se(t)})}function Kx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...se(t)})}function Qx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...se(t)})}function Jx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...se(t)})}function Gx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...se(t)})}function Xx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...se(t)})}function eg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...se(t)})}function tg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...se(t)})}function ng(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...se(t)})}function rg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...se(t)})}function sg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...se(t)})}function ag(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...se(t)})}function ig(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...se(t)})}function og(e,t){return new e({type:"string",format:"date",check:"string_format",...se(t)})}function lg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...se(t)})}function cg(e,t){return new e({type:"string",format:"duration",check:"string_format",...se(t)})}function ug(e,t){return new e({type:"boolean",...se(t)})}function dg(e){return new e({type:"unknown"})}function mg(e,t){return new e({type:"never",...se(t)})}function Xc(e,t){return new Dp({check:"max_length",...se(t),maximum:e})}function Es(e,t){return new Rp({check:"min_length",...se(t),minimum:e})}function eu(e,t){return new $p({check:"length_equals",...se(t),length:e})}function hg(e,t){return new Op({check:"string_format",format:"regex",...se(t),pattern:e})}function fg(e){return new Lp({check:"string_format",format:"lowercase",...se(e)})}function pg(e){return new zp({check:"string_format",format:"uppercase",...se(e)})}function xg(e,t){return new Mp({check:"string_format",format:"includes",...se(t),includes:e})}function gg(e,t){return new qp({check:"string_format",format:"starts_with",...se(t),prefix:e})}function yg(e,t){return new Bp({check:"string_format",format:"ends_with",...se(t),suffix:e})}function yr(e){return new Vp({check:"overwrite",tx:e})}function bg(e){return yr(t=>t.normalize(e))}function vg(){return yr(e=>e.trim())}function jg(){return yr(e=>e.toLowerCase())}function wg(){return yr(e=>e.toUpperCase())}function Ng(){return yr(e=>Of(e))}function Sg(e,t,n){return new e({type:"array",element:t,...se(n)})}function kg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...se(n)})}function Cg(e,t){const n=Ag(r=>(r.addIssue=a=>{if(typeof a=="string")r.issues.push($r(a,r.value,n._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push($r(i))}},e(r.value,r)),t);return n}function Ag(e,t){const n=new Ot({check:"custom",...se(t)});return n._zod.check=e,n}function tu(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)??Er,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 Ye(e,t,n={path:[],schemaPath:[]}){var u,m;var r;const a=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const l=(m=(u=e._zod).toJSONSchema)==null?void 0:m.call(u);if(l)o.schema=l;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,h);else{const x=o.schema,p=t.processors[a.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);p(e,t,x,h)}const f=e._zod.parent;f&&(o.ref||(o.ref=f),Ye(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"&&nt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function nu(e,t){var o,l,c,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const u of e.seen.entries()){const m=(o=e.metadataRegistry.get(u[0]))==null?void 0:o.id;if(m){const h=r.get(m);if(h&&h!==u[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,u[0])}}const a=u=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const w=(p=e.external.registry.get(u[0]))==null?void 0:p.id,g=e.external.uri??(v=>v);if(w)return{ref:g(w)};const k=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=k,{defId:k,ref:`${g("__shared")}#/${m}/${k}`}}if(u[1]===n)return{ref:"#"};const f=`#/${m}/`,x=u[1].schema.id??`__schema${e.counter++}`;return{defId:x,ref:f+x}},i=u=>{if(u[1].schema.$ref)return;const m=u[1],{ref:h,defId:f}=a(u);m.def={...m.schema},f&&(m.defId=f);const x=m.schema;for(const p in x)delete x[p];x.$ref=h};if(e.cycles==="throw")for(const u of e.seen.entries()){const m=u[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 eu(e,t){var l,c,u,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,x={...f},p=h.ref;if(h.ref=null,p){r(p);const g=e.seen.get(p),k=g.schema;if(k.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(k)):Object.assign(f,k),Object.assign(f,x),m._zod.parent===p)for(const S in f)S==="$ref"||S==="allOf"||S in x||delete f[S];if(k.$ref&&g.def)for(const S in f)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(f[S])===JSON.stringify(g.def[S])&&delete f[S]}const v=m._zod.parent;if(v&&v!==p){r(v);const g=e.seen.get(v);if(g!=null&&g.schema.$ref&&(f.$ref=g.schema.$ref,g.def))for(const k in f)k==="$ref"||k==="allOf"||k in g.def&&JSON.stringify(f[k])===JSON.stringify(g.def[k])&&delete f[k]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,n.def??n.schema);const i=(u=e.metadataRegistry.get(t))==null?void 0:u.id;i!==void 0&&a.id===i&&delete a.id;const o=((d=e.external)==null?void 0:d.defs)??{};for(const m of e.seen.entries()){const h=m[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?a.$defs=o:a.definitions=o);try{const m=JSON.parse(JSON.stringify(a));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Is(t,"input",e.processors),output:Is(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ge(r.element,n);if(r.type==="set")return Ge(r.valueType,n);if(r.type==="lazy")return Ge(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Ge(r.innerType,n);if(r.type==="intersection")return Ge(r.left,n)||Ge(r.right,n);if(r.type==="record"||r.type==="map")return Ge(r.keyType,n)||Ge(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ge(r.in,n)||Ge(r.out,n);if(r.type==="object"){for(const a in r.shape)if(Ge(r.shape[a],n))return!0;return!1}if(r.type==="union"){for(const a of r.options)if(Ge(a,n))return!0;return!1}if(r.type==="tuple"){for(const a of r.items)if(Ge(a,n))return!0;return!!(r.rest&&Ge(r.rest,n))}return!1}const vg=(e,t={})=>n=>{const r=Gc({...n,processors:t});return We(e,r),Xc(r,e),eu(r,e)},Is=(e,t,n={})=>r=>{const{libraryOptions:a,target:i}=r??{},o=Gc({...a??{},target:i,io:t,processors:n});return We(e,o),Xc(o,e),eu(o,e)},jg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ng=(e,t,n,r)=>{const a=n;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=jg[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}))])}},wg=(e,t,n,r)=>{n.type="boolean"},Sg=(e,t,n,r)=>{n.not={}},kg=(e,t,n,r)=>{},Cg=(e,t,n,r)=>{const a=e._zod.def,i=$c(a.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Ag=(e,t,n,r)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},Pg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Eg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ig=(e,t,n,r)=>{const a=n,i=e._zod.def,{minimum:o,maximum:l}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof l=="number"&&(a.maxItems=l),a.type="array",a.items=We(i.element,t,{...r,path:[...r.path,"items"]})},Tg=(e,t,n,r)=>{var u;const a=n,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const d in o)a.properties[d]=We(o[d],t,{...r,path:[...r.path,"properties",d]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(d=>{const m=i.shape[d]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((u=i.catchall)==null?void 0:u._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=We(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},_g=(e,t,n,r)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>We(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},Dg=(e,t,n,r)=>{const a=e._zod.def,i=We(a.left,t,{...r,path:[...r.path,"allOf",0]}),o=We(a.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];n.allOf=c},Fg=(e,t,n,r)=>{const a=e._zod.def,i=We(a.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Rg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType},Og=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},$g=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Lg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},zg=(e,t,n,r)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;We(o,t,r);const l=t.seen.get(e);l.ref=o},Mg=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.readOnly=!0},tu=(e,t,n,r)=>{const a=e._zod.def;We(a.innerType,t,r);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 n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Qa.apply(null,arguments)}function el(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function qg(e,t){for(var n={};e.length;){var r=e[0],a=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[o]={message:l.message,type:l.code}}else n[o]={message:i,type:a};if("unionErrors"in r&&r.unionErrors.forEach(function(d){return d.errors.forEach(function(m){return e.push(m)})}),t){var c=n[o].types,u=c&&c[r.code];n[o]=Ai(o,t,n,a,u?[].concat(u,r.message):r.message)}e.shift()}return n}function Vg(e,t){for(var n={},r=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!n[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];n[l]={message:c.message,type:c.code}}else n[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push(Qa({},h,{path:[].concat(a.path,h.path)}))})}),t){var u=n[l].types,d=u&&u[a.code];n[l]=Ai(l,t,n,i,d?[].concat(d,a.message):a.message)}e.shift()};e.length;)r();return n}function $t(e,t,n){if(n===void 0&&(n={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,a,i){try{return Promise.resolve(el(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(o){return i.shouldUseNativeValidation&&Ya({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Lo(qg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,a,i){try{return Promise.resolve(el(function(){return Promise.resolve((n.mode==="sync"?Bf:Uf)(e,r,t)).then(function(o){return i.shouldUseNativeValidation&&Ya({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return l instanceof Ri})(o))return{values:{},errors:Lo(Vg(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function $n({label:e,required:t=!1,htmlFor:n}){return s.jsxs("label",{htmlFor:n,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})}const pe=N.forwardRef(function({label:t,required:n=!1,error:r,id:a,className:i="",...o},l){const c=a??o.name;return s.jsxs("div",{children:[s.jsx($n,{label:t,required:n,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 ${r?"border-red-300":"border-slate-200"} ${i}`,...o}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}),xn=N.forwardRef(function({label:t,required:n=!1,error:r,id:a,className:i="",children:o,...l},c){const u=a??l.name;return s.jsxs("div",{children:[s.jsx($n,{label:t,required:n,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 ${r?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(Bg,{})]}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})});function gn({step:e,title:t,muted:n=!1,children:r}){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 ${n?"text-slate-400":"text-gov-700"}`,children:t})]}),r]})}function Bg(){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 Lt({variant:e="error",title:t,message:n}){const r=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 ${r}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:n})]})}function tt(e,t){var n;if(e instanceof yr){if(e.details){const r=(n=Object.values(e.details)[0])==null?void 0:n[0];if(r)return r}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Ug=D("ZodISODateTime",(e,t)=>{Kp.init(e,t),Te.init(e,t)});function Zg(e){return Gx(Ug,e)}const Wg=D("ZodISODate",(e,t)=>{Qp.init(e,t),Te.init(e,t)});function Yg(e){return Xx(Wg,e)}const Hg=D("ZodISOTime",(e,t)=>{Jp.init(e,t),Te.init(e,t)});function Kg(e){return eg(Hg,e)}const Qg=D("ZodISODuration",(e,t)=>{Gp.init(e,t),Te.init(e,t)});function Jg(e){return tg(Qg,e)}const Gg=(e,t)=>{Ri.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Vf(e,n)},flatten:{value:n=>qf(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ha,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ha,2)}},isEmpty:{get(){return e.issues.length===0}}})},bt=D("ZodError",Gg,{Parent:Error}),Xg=Ws(bt),ey=Ys(bt),ty=Hs(bt),ny=Ks(bt),ry=Yf(bt),sy=Hf(bt),ay=Kf(bt),iy=Qf(bt),oy=Jf(bt),ly=Gf(bt),cy=Xf(bt),uy=ep(bt),tl=new WeakMap;function Js(e,t,n){const r=Object.getPrototypeOf(e);let a=tl.get(r);if(a||(a=new Set,tl.set(r,a)),!a.has(t)){a.add(t);for(const i in n){const o=n[i];Object.defineProperty(r,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 Oe=D("ZodType",(e,t)=>(Re.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Is(e,"input"),output:Is(e,"output")}}),e.toJSONSchema=vg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>Xg(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>ty(e,n,r),e.parseAsync=async(n,r)=>ey(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>ny(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>ry(e,n,r),e.decode=(n,r)=>sy(e,n,r),e.encodeAsync=async(n,r)=>ay(e,n,r),e.decodeAsync=async(n,r)=>iy(e,n,r),e.safeEncode=(n,r)=>oy(e,n,r),e.safeDecode=(n,r)=>ly(e,n,r),e.safeEncodeAsync=async(n,r)=>cy(e,n,r),e.safeDecodeAsync=async(n,r)=>uy(e,n,r),Js(e,"ZodType",{check(...n){const r=this.def;return this.clone(yn(r,{checks:[...r.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return bn(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(nb(n,r))},superRefine(n,r){return this.check(rb(n,r))},overwrite(n){return this.check(br(n))},optional(){return sl(this)},exactOptional(){return By(this)},nullable(){return al(this)},nullish(){return sl(al(this))},nonoptional(n){return Ky(this,n)},array(){return Fy(this)},or(n){return su([this,n])},and(n){return Ly(this,n)},transform(n){return il(this,qy(n))},default(n){return Wy(this,n)},prefault(n){return Hy(this,n)},catch(n){return Jy(this,n)},pipe(n){return il(this,n)},readonly(){return eb(this)},describe(n){const r=this.clone();return Ir.add(r,{description:n}),r},meta(...n){if(n.length===0)return Ir.get(this);const r=this.clone();return Ir.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Ir.get(e))==null?void 0:n.description},configurable:!0}),e)),nu=D("_ZodString",(e,t)=>{Oi.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Ng(e,r,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Js(e,"_ZodString",{regex(...r){return this.check(ag(...r))},includes(...r){return this.check(lg(...r))},startsWith(...r){return this.check(cg(...r))},endsWith(...r){return this.check(ug(...r))},min(...r){return this.check(Es(...r))},max(...r){return this.check(Qc(...r))},length(...r){return this.check(Jc(...r))},nonempty(...r){return this.check(Es(1,...r))},lowercase(r){return this.check(ig(r))},uppercase(r){return this.check(og(r))},trim(){return this.check(mg())},normalize(...r){return this.check(dg(...r))},toLowerCase(){return this.check(hg())},toUpperCase(){return this.check(fg())},slugify(){return this.check(pg())}})}),dy=D("ZodString",(e,t)=>{Oi.init(e,t),nu.init(e,t),e.email=n=>e.check(Kc(ru,n)),e.url=n=>e.check(Ox(hy,n)),e.jwt=n=>e.check(Jx(Py,n)),e.emoji=n=>e.check($x(fy,n)),e.guid=n=>e.check(Xo(nl,n)),e.uuid=n=>e.check(_x(os,n)),e.uuidv4=n=>e.check(Dx(os,n)),e.uuidv6=n=>e.check(Fx(os,n)),e.uuidv7=n=>e.check(Rx(os,n)),e.nanoid=n=>e.check(Lx(py,n)),e.guid=n=>e.check(Xo(nl,n)),e.cuid=n=>e.check(zx(xy,n)),e.cuid2=n=>e.check(Mx(gy,n)),e.ulid=n=>e.check(qx(yy,n)),e.base64=n=>e.check(Hx(ky,n)),e.base64url=n=>e.check(Kx(Cy,n)),e.xid=n=>e.check(Vx(by,n)),e.ksuid=n=>e.check(Bx(vy,n)),e.ipv4=n=>e.check(Ux(jy,n)),e.ipv6=n=>e.check(Zx(Ny,n)),e.cidrv4=n=>e.check(Wx(wy,n)),e.cidrv6=n=>e.check(Yx(Sy,n)),e.e164=n=>e.check(Qx(Ay,n)),e.datetime=n=>e.check(Zg(n)),e.date=n=>e.check(Yg(n)),e.time=n=>e.check(Kg(n)),e.duration=n=>e.check(Jg(n))});function T(e){return Tx(dy,e)}const Te=D("ZodStringFormat",(e,t)=>{Pe.init(e,t),nu.init(e,t)}),ru=D("ZodEmail",(e,t)=>{Mp.init(e,t),Te.init(e,t)});function my(e){return Kc(ru,e)}const nl=D("ZodGUID",(e,t)=>{Lp.init(e,t),Te.init(e,t)}),os=D("ZodUUID",(e,t)=>{zp.init(e,t),Te.init(e,t)}),hy=D("ZodURL",(e,t)=>{qp.init(e,t),Te.init(e,t)}),fy=D("ZodEmoji",(e,t)=>{Vp.init(e,t),Te.init(e,t)}),py=D("ZodNanoID",(e,t)=>{Bp.init(e,t),Te.init(e,t)}),xy=D("ZodCUID",(e,t)=>{Up.init(e,t),Te.init(e,t)}),gy=D("ZodCUID2",(e,t)=>{Zp.init(e,t),Te.init(e,t)}),yy=D("ZodULID",(e,t)=>{Wp.init(e,t),Te.init(e,t)}),by=D("ZodXID",(e,t)=>{Yp.init(e,t),Te.init(e,t)}),vy=D("ZodKSUID",(e,t)=>{Hp.init(e,t),Te.init(e,t)}),jy=D("ZodIPv4",(e,t)=>{Xp.init(e,t),Te.init(e,t)}),Ny=D("ZodIPv6",(e,t)=>{ex.init(e,t),Te.init(e,t)}),wy=D("ZodCIDRv4",(e,t)=>{tx.init(e,t),Te.init(e,t)}),Sy=D("ZodCIDRv6",(e,t)=>{nx.init(e,t),Te.init(e,t)}),ky=D("ZodBase64",(e,t)=>{rx.init(e,t),Te.init(e,t)}),Cy=D("ZodBase64URL",(e,t)=>{ax.init(e,t),Te.init(e,t)}),Ay=D("ZodE164",(e,t)=>{ix.init(e,t),Te.init(e,t)}),Py=D("ZodJWT",(e,t)=>{lx.init(e,t),Te.init(e,t)}),Ey=D("ZodBoolean",(e,t)=>{cx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>wg(e,n,r)});function Kn(e){return ng(Ey,e)}const Iy=D("ZodUnknown",(e,t)=>{ux.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>kg()});function rl(){return rg(Iy)}const Ty=D("ZodNever",(e,t)=>{dx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Sg(e,n,r)});function _y(e){return sg(Ty,e)}const Dy=D("ZodArray",(e,t)=>{mx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Ig(e,n,r,a),e.element=t.element,Js(e,"ZodArray",{min(n,r){return this.check(Es(n,r))},nonempty(n){return this.check(Es(1,n))},max(n,r){return this.check(Qc(n,r))},length(n,r){return this.check(Jc(n,r))},unwrap(){return this.element}})});function Fy(e,t){return xg(Dy,e,t)}const Ry=D("ZodObject",(e,t)=>{fx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Tg(e,n,r,a),je(e,"shape",()=>t.shape),Js(e,"ZodObject",{keyof(){return Gs(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:rl()})},loose(){return this.clone({...this._zod.def,catchall:rl()})},strict(){return this.clone({...this._zod.def,catchall:_y()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Rf(this,n)},safeExtend(n){return Of(this,n)},merge(n){return $f(this,n)},pick(n){return Df(this,n)},omit(n){return Ff(this,n)},partial(...n){return Lf(au,this,n[0])},required(...n){return zf(iu,this,n[0])}})});function Gt(e,t){const n={type:"object",shape:e??{},...re(t)};return new Ry(n)}const Oy=D("ZodUnion",(e,t)=>{px.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>_g(e,n,r,a),e.options=t.options});function su(e,t){return new Oy({type:"union",options:e,...re(t)})}const $y=D("ZodIntersection",(e,t)=>{xx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Dg(e,n,r,a)});function Ly(e,t){return new $y({type:"intersection",left:e,right:t})}const Ja=D("ZodEnum",(e,t)=>{gx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Cg(e,r,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,a)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ja({...t,checks:[],...re(a),entries:i})},e.exclude=(r,a)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ja({...t,checks:[],...re(a),entries:i})}});function Gs(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ja({type:"enum",entries:n,...re(t)})}const zy=D("ZodLiteral",(e,t)=>{yx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Ag(e,n,r),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 ua(e,t){return new zy({type:"literal",values:Array.isArray(e)?e:[e],...re(t)})}const My=D("ZodTransform",(e,t)=>{bx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Eg(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Oc(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push($r(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push($r(o))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function qy(e){return new My({type:"transform",transform:e})}const au=D("ZodOptional",(e,t)=>{Hc.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>tu(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function sl(e){return new au({type:"optional",innerType:e})}const Vy=D("ZodExactOptional",(e,t)=>{vx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>tu(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function By(e){return new Vy({type:"optional",innerType:e})}const Uy=D("ZodNullable",(e,t)=>{jx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Fg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function al(e){return new Uy({type:"nullable",innerType:e})}const Zy=D("ZodDefault",(e,t)=>{Nx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Og(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Wy(e,t){return new Zy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():zc(t)}})}const Yy=D("ZodPrefault",(e,t)=>{wx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>$g(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function Hy(e,t){return new Yy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():zc(t)}})}const iu=D("ZodNonOptional",(e,t)=>{Sx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Rg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function Ky(e,t){return new iu({type:"nonoptional",innerType:e,...re(t)})}const Qy=D("ZodCatch",(e,t)=>{kx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Lg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Jy(e,t){return new Qy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Gy=D("ZodPipe",(e,t)=>{Cx.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>zg(e,n,r,a),e.in=t.in,e.out=t.out});function il(e,t){return new Gy({type:"pipe",in:e,out:t})}const Xy=D("ZodReadonly",(e,t)=>{Ax.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Mg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function eb(e){return new Xy({type:"readonly",innerType:e})}const tb=D("ZodCustom",(e,t)=>{Px.init(e,t),Oe.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Pg(e,n)});function nb(e,t={}){return gg(tb,e,t)}function rb(e,t){return yg(e,t)}const nn={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function $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 Xt(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?(e.lastName||e.firstName).trim():`${e.firstName} ${e.lastName}`.trim()}function Bn(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function sb(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,3)}-${t.slice(3,5)}-${t.slice(5)}`}function ab(e,t){return t==="Individual"?sb(e):Bn(e)}function ol(e,t){const n=e.replace(/\D/g,"").slice(0,9);return t==="Individual"?n.length<=3?n:n.length<=5?`${n.slice(0,3)}-${n.slice(3)}`:`${n.slice(0,3)}-${n.slice(3,5)}-${n.slice(5)}`:n.length<=2?n:`${n.slice(0,2)}-${n.slice(2)}`}function Ln(e){const t=e.replace(/\D/g,""),n=t.length===11&&t.startsWith("1")?t.slice(1):t;return n.length!==10?e:`+1 (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}const ou=["LLP","LLC","Corporation","S-Corp","Partnership"],lu=["Sole Proprietorship"],Li=["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"],ib={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming"},Ga=10,ob=/^\d{5}(-\d{4})?$/;function cu(e){const t=e.replace(/\D/g,"").slice(0,9);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`}const uu=Gt({accountType:Gs(["Business","Individual"]),firstName:T(),lastName:T(),tradeName:T(),ein:T(),entityType:T().min(1,"Entity type is required"),email:my("Enter a valid email"),countryCode:T().min(1),phoneNumber:T().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Ga,`Phone number must be ${Ga} digits`),address1:T().min(1,"Address is required"),address2:T(),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required")}).superRefine((e,t)=>{e.country==="United States"&&!ob.test(e.zipCode.trim())&&t.addIssue({code:"custom",path:["zipCode"],message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)"});const n=e.accountType==="Individual"?"SSN":"EIN",r=e.ein.replace(/\D/g,"");if(r?r.length!==9&&t.addIssue({code:"custom",path:["ein"],message:`${n} must be 9 digits`}):t.addIssue({code:"custom",path:["ein"],message:`${n} is required`}),e.accountType==="Business"){e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Business name is required"});return}e.firstName.trim()||t.addIssue({code:"custom",path:["firstName"],message:"First name is required"}),e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Last name is required"})});function lb(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(-Ga)}}function ll(e){const{countryCode:t,national:n}=lb(e.phoneNumber),r=e.accountType==="Individual",a=(e.lastName||e.firstName||"").trim();return{accountType:r?"Individual":"Business",firstName:r?e.firstName??"":"",lastName:r?e.lastName??"":a,tradeName:r?"":e.tradeName??"",ein:Bn(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:n,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function du(e,t,n,r){if(e!==t){if(e==="Business"&&t==="Individual"){n("firstName",""),n("lastName",r),n("tradeName","");return}e==="Individual"&&t==="Business"&&(n("firstName",""),n("lastName",r))}}function mu(e){const t=e.lastName.trim();return e.accountType==="Business"?{accountType:e.accountType,firstName:"",lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName.trim(),phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}:{accountType:e.accountType,firstName:e.firstName.trim(),lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:"",phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function cb(e){const{idNumber:t,...n}=mu(e);return n}function Un(e,t){const n=e==null?void 0:e.from;return n&&n.startsWith("/")&&!n.startsWith("//")?n:t}function ub(){var Y,ce,fe,Q,ke,se,Se,ue,be,O,xe,te,Ne;const e=Ae(),t=Ce(),n=ft(),{data:r=[]}=ve({queryKey:["entities","mine"],queryFn:async()=>(await yi({pageNumber:1,pageSize:100})).items}),[a,i]=N.useState(null),[o,l]=N.useState(!1),c=r.length===0,u=c?"/create-entity":"/dashboard",d=Un(t.state,u),m=()=>{e(d)},{register:h,handleSubmit:f,watch:x,setValue:p,getValues:v,formState:{errors:g}}=Rt({resolver:$t(uu),shouldUnregister:!1,defaultValues:{accountType:"Individual",firstName:"",lastName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),k=x("accountType"),j=x("entityType"),S=k==="Individual"?lu:ou,E=k==="Individual",_=E?"SSN":"EIN",I=E?"***-**-****":"**-*******",$=E?11:10,P=x("country"),R=h("ein"),ee=h("phoneNumber"),B=h("zipCode"),K=ae=>{const Me=v("accountType");if(Me===ae)return;const oe=v("lastName");du(Me,ae,p,oe),p("accountType",ae),p("ein",ol(v("ein"),ae)),queueMicrotask(()=>{p("lastName",oe),p("firstName",""),Me==="Business"&&ae==="Individual"&&p("tradeName","")})};N.useEffect(()=>{S.includes(j)||p("entityType",k==="Individual"?"Sole Proprietorship":"LLP")},[k,j,S,p]);const ne=f(async ae=>{i(null),l(!0);try{await Uh(mu(ae)),await n.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":d,{replace:!0})}catch(Me){i(tt(Me,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:ne,noValidate:!0,className:"space-y-8",children:[a?s.jsx(Lt,{message:a}):null,s.jsx(gn,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx($n,{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",checked:k==="Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>K("Business")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",checked:k==="Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>K("Individual")}),"Individual"]})]})]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:k==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(pe,{label:"First name",required:!0,maxLength:100,placeholder:"Enter",error:(Y=g.firstName)==null?void 0:Y.message,...h("firstName")},"entity-first-name"),s.jsx(pe,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter",error:(ce=g.lastName)==null?void 0:ce.message,...h("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(pe,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter",error:(fe=g.lastName)==null?void 0:fe.message,...h("lastName")},"entity-business-name"),s.jsx(pe,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter",error:(Q=g.tradeName)==null?void 0:Q.message,...h("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:_,required:!0,inputMode:"numeric",placeholder:I,maxLength:$,error:(ke=g.ein)==null?void 0:ke.message,...R,onChange:ae=>{ae.target.value=ol(ae.target.value,k),R.onChange(ae)}}),s.jsx(xn,{label:"Entity Type",required:!0,error:(se=g.entityType)==null?void 0:se.message,...h("entityType"),children:S.map(ae=>s.jsx("option",{value:ae,children:ae},ae))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(Se=g.email)==null?void 0:Se.message,...h("email")}),s.jsxs("div",{children:[s.jsx($n,{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",inputMode:"numeric",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${g.phoneNumber?"border-red-300":"border-slate-200"}`,...ee,onChange:ae=>{ae.target.value=ae.target.value.replace(/\D/g,"").slice(0,10),ee.onChange(ae)}})]}),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(gn,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(pe,{label:"Address Line 1",required:!0,maxLength:200,error:(ue=g.address1)==null?void 0:ue.message,...h("address1")}),s.jsx(pe,{label:"Address Line 2",maxLength:200,error:(be=g.address2)==null?void 0:be.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:"City",required:!0,maxLength:100,error:(O=g.city)==null?void 0:O.message,...h("city")}),s.jsxs(xn,{label:"State",required:!0,error:(xe=g.state)==null?void 0:xe.message,...h("state"),children:[s.jsx("option",{value:"",children:"Select"}),Li.map(ae=>s.jsx("option",{value:ae,children:ae},ae))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:"ZIP Code",required:!0,maxLength:10,placeholder:P==="United States"?"12345 or 12345-6789":void 0,error:(te=g.zipCode)==null?void 0:te.message,...B,onChange:ae=>{P==="United States"&&(ae.target.value=cu(ae.target.value)),B.onChange(ae)}}),s.jsxs(xn,{label:"Country",required:!0,error:(Ne=g.country)==null?void 0:Ne.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 zi(){const e=Ae(),t=Ce(),n=Un(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(n),className:"absolute left-4 top-4 inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white/80 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 sm:left-6 sm:top-6",children:[s.jsx(db,{}),"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(ub,{})})]})}function db(){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 mb(e,t){const n=new URLSearchParams({entityId:String(e)});return t!==void 0&&n.set("taxYear",String(t)),me(`/portal/dashboard?${n}`)}function hb(e,t,n){const r=new URLSearchParams({entityId:String(e),category:t,taxYear:String(n)});return me(`/portal/dashboard/summary?${r}`)}function fb(e,t,n){const r=new URLSearchParams({entityId:String(e),month:String(t)});return n!==void 0&&r.set("year",String(n)),me(`/portal/dashboard/monthly-overview?${r}`)}function pb({entityId:e,search:t,taxYear:n,status:r,page:a=1,pageSize:i=st}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),n&&o.set("taxYear",n),r&&r!=="all"&&o.set("status",r),me(`/portal/dashboard/payments?${o}`)}function cl({entityCount:e,showPaymentActions:t=!0}){const n=Ae(),{enabledPayments:r}=qn();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:[t&&r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>n("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(da,{}),"Add Federal Payments"]}),t&&r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>n("/payments/state/new",{state:{from:"/",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(da,{}),"Add State Payment"]}),t&&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(da,{}),"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:()=>n("/entities"),className:"inline-flex items-center gap-1.5 rounded-[14px] border border-solid border-[#e5e7eb] bg-[#f9fafb] px-[15px] py-[9px] text-xs font-bold text-[#364153] transition hover:bg-slate-100",title:"View organizations",children:[s.jsx(xb,{}),"Entities (",e,")"]}),s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-1.5 rounded-[14px] border-[1.5px] border-dashed border-[#16a34a] bg-[#f0fdf4] px-[15.5px] py-[9.5px] text-xs font-bold text-[#16a34a] transition hover:bg-green-50",children:[s.jsx(gb,{}),"Add Entity"]})]})]})}function da(){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 xb(){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 gb(){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 yb({title:e,description:t,buttonLabel:n,onAdd:r,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:r,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(bb,{}),n]})]})}function bb(){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 vr({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(vb,{}),s.jsx("span",{children:e})]})})}function vb(){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 jb={Draft:"Draft"};function Nb(e){switch((e??jb.Draft).trim().toLowerCase()){case"draft":case"pending":return"drafts";case"scheduled":return"scheduled";case"processing":return"submitted";case"rejected":return"rejected";case"accepted":return"paid";default:return"drafts"}}function Kr(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function wb(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 Mi="drafts";function Qe(){return Xs(Mi)}function Xs(e){return`/payments?tab=${e}`}function hu(e){return e==="failed"?"rejected":e}function Sb(e,t){return t.trim().toLowerCase()==="draft"?Mi:hu(e)}const kb=["January","February","March","April","May","June","July","August","September","October","November","December"];function Cb({entityId:e,initialOverview:t,isDashboardLoading:n=!1}){const r=Ae(),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}=ve({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>fb(e,i,a),enabled:e!==null&&i!==null,placeholderData:p=>p}),m={submitted:0,paid:0,scheduled:0,failed:0},h=c?t??m:u??m,f=n||d&&!c,x=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:Pb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:Eb,iconClassName:"rounded-full bg-emerald-50 text-emerald-600",amountClassName:"text-emerald-600"},{key:"scheduled",label:"Scheduled",amount:h.scheduled,icon:Ib,iconClassName:"rounded-xl bg-amber-50 text-amber-500",amountClassName:"text-amber-500"},{key:"failed",label:"Failed",amount:h.failed,icon:Tb,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(vr,{}):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:kb.map((p,v)=>s.jsx("option",{value:v+1,children:p},p))}),s.jsx(Ab,{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:x.map(p=>{const v=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(v,{})}),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:Kr(p.amount)}),s.jsx("button",{type:"button",onClick:()=>r(Xs(hu(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 Ab({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 Pb(){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 Eb(){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 Ib(){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 Tb(){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 ul(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function _b(e){return{id:e.id,jurisdiction:e.jurisdiction,period:e.period,amount:e.amount,paymentDate:e.paymentDate,status:e.status,statusLabel:e.statusLabel,formType:e.formType,category:e.category}}function dl(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const Db={primary:"bg-brand-600 text-white hover:bg-brand-700 focus-visible:ring-brand-500 disabled:bg-brand-600/60",secondary:"border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 focus-visible:ring-slate-400",ghost:"text-slate-600 hover:bg-slate-100 focus-visible:ring-slate-400"};function Fb({variant:e="primary",isLoading:t=!1,className:n="",children:r,disabled:a,...i}){return s.jsx("button",{type:"button",className:`inline-flex h-10 items-center justify-center rounded-lg px-4 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed ${Db[e]} ${n}`,disabled:a||t,...i,children:t?"Please wait…":r})}const Rb=[10,20,50,100];function Ob(e,t){const n=e.trim();if(!/^\d+$/.test(n))return null;const r=Number(n);return!Number.isInteger(r)||r<1||r>t?null:r}function $b(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M12.5 4.5 7 10l5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Lb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M7.5 4.5 13 10l-5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qr({page:e,pageSize:t,totalCount:n,onPageChange:r,onPageSizeChange:a,pageSizeOptions:i=Rb,disabled:o=!1,className:l=""}){const c=t>0?Math.max(1,Math.ceil(n/t)):1,u=n===0?0:c,d=e>1,m=u>0&&e<u,h=n===0?0:(e-1)*t+1,f=Math.min(e*t,n),[x,p]=N.useState(String(e)),v=N.useRef(x);v.current=x,N.useEffect(()=>{p(String(e))},[e]);function g(j=v.current){if(o||u===0){p(String(e));return}const S=Ob(j,u);if(S===null){p(String(e));return}if(S===e){p(String(e));return}r(S)}function k(j){j.key==="Enter"&&(j.preventDefault(),g(j.currentTarget.value))}return n===0?null:s.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 border-t border-slate-200 bg-white px-6 py-3 ${l}`,children:[s.jsxs("p",{className:"text-sm text-slate-500",children:["Showing ",s.jsx("span",{className:"font-medium text-slate-700",children:h}),"–",s.jsx("span",{className:"font-medium text-slate-700",children:f})," of ",s.jsx("span",{className:"font-medium text-slate-700",children:n})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a?s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[s.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),s.jsx("select",{value:t,disabled:o,onChange:j=>a(Number(j.target.value)),className:"rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(j=>s.jsx("option",{value:j,children:j},j))})]}):null,s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",disabled:o||!d,onClick:()=>r(e-1),"aria-label":"Previous page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx($b,{})}),s.jsx("span",{className:"min-w-[5.5rem] text-center text-sm text-slate-600",children:u===0?"—":`Page ${e} of ${u}`}),s.jsx("button",{type:"button",disabled:o||!m,onClick:()=>r(e+1),"aria-label":"Next page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Lb,{})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:"pagination-go-to-page",className:"whitespace-nowrap text-sm text-slate-600",children:"Go to page"}),s.jsx("input",{id:"pagination-go-to-page",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:x,disabled:o||u===0,onChange:j=>p(j.target.value),onKeyDown:k,"aria-label":"Go to page number",className:"h-9 w-14 rounded-lg border border-slate-200 bg-white px-2 text-center text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"}),s.jsx(Fb,{type:"button",variant:"secondary",disabled:o||u===0,className:"h-9 px-3",onMouseDown:j=>{j.preventDefault()},onClick:()=>g(),children:"Go"})]})]})]})}const zb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],ml={total:0,page:1,pageSize:st,items:[]};function Mb({label:e,status:t}){const n={scheduled:"bg-amber-50 text-amber-700",paid:"bg-emerald-50 text-emerald-700",submitted:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-600"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n[t]}`,children:e})}function qb({entityId:e,initialPayments:t,isDashboardLoading:n=!1}){const r=Ae(),[a,i]=N.useState(""),[o,l]=N.useState(""),[c,u]=N.useState(""),[d,m]=N.useState("all"),[h,f]=N.useState(1),[x,p]=N.useState(st);N.useEffect(()=>{const P=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(P)},[a]),N.useEffect(()=>{f(1)},[o,c,d,e,x]);const v=!!o||!!c||d!=="all",g=e!==null&&(v||h>1||x!==st),{data:k,isFetching:j}=ve({queryKey:["dashboard","payments",e,o,c,d,h,x],queryFn:()=>pb({entityId:e,search:o||void 0,taxYear:c||void 0,status:d,page:h,pageSize:x}),enabled:g,placeholderData:P=>P}),S=N.useMemo(()=>g?k??ml:t&&h===1&&x===st?t:ml,[g,k,t,h,x]),E=N.useMemo(()=>S.items.map(_b),[S.items]),_=N.useMemo(()=>{const P=new Date().getFullYear();return[P,P-1,P-2].map(String)},[]),I=n||g&&j,$=(S.page-1)*S.pageSize;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[I?s.jsx(vr,{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(Bb,{})}),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:[S.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(Vb,{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:P=>i(P.target.value),placeholder:"All",disabled:n,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),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:P=>u(P.target.value),disabled:n,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[s.jsx("option",{value:"",children:"Select Year"}),_.map(P=>s.jsx("option",{value:P,children:P},P))]}),s.jsx(hl,{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:P=>m(P.target.value),disabled:n,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:zb.map(P=>s.jsx("option",{value:P.value,children:P.label},P.value))}),s.jsx(hl,{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:!I&&E.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:v?"No payments match your filters.":"No payments yet."})}):E.map((P,R)=>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:["#",$+R+1]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(P.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Mb,{label:P.statusLabel,status:P.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:P.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("button",{type:"button",onClick:()=>r(Xs(Sb(P.status,P.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${P.category}-${P.id}`))})]})}),s.jsx(Qr,{page:h,pageSize:x,totalCount:S.total,onPageChange:f,onPageSizeChange:p,disabled:I||e===null})]})}function Vb({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 hl({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 Bb(){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 ma({entityId:e,category:t,title:n,subtitlePrefix:r,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:n}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:r})]}),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:x}=ve({queryKey:["dashboard","summary",e,t,d],queryFn:()=>hb(e,t,d),enabled:e!==null&&!h,placeholderData:k=>k}),p=h?o?ul(o):dl():f?ul(f):dl(),v=wb(p),g=l||x&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[g?s.jsx(vr,{}):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:n}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[r," (",p.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:d,onChange:k=>m(Number(k.target.value)),disabled:g,className:"appearance-none rounded-lg border border-slate-200 bg-white py-1.5 pl-3 pr-8 text-xs font-medium text-slate-700 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(k=>s.jsxs("option",{value:k,children:["TY ",k]},k))}),s.jsx(Ub,{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(k=>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 ${k.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:k.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Kr(p[k.key])})]},k.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:v.map((k,j)=>k.width>0?s.jsx("span",{className:`${k.color} h-full`,style:{width:`${k.width}%`}},j):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function Ub({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 Zb={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."},Wb=[{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"}],rn=new Date().getFullYear(),ha=[rn,rn-1,rn-2],Yb=[{label:"Submitted to IRS",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],Hb=[{label:"Submitted to State",key:"submitted",dotClassName:"bg-orange-400"},{label:"Paid",key:"paid",dotClassName:"bg-emerald-400"},{label:"Scheduled",key:"scheduled",dotClassName:"bg-amber-400"},{label:"Failed",key:"failed",dotClassName:"bg-red-400"}],Kb=[{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 qi(){const e=Ae(),{entities:t,selectedEntity:n,enabledPayments:r}=qn(),a=(n==null?void 0:n.entityId)??null,{data:i,isLoading:o}=ve({queryKey:["dashboard",a,rn],queryFn:()=>mb(a,rn),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(cl,{entityCount:t.length,showPaymentActions:!1}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:Wb.filter(l=>l.key==="local"||r.includes(l.key)).map(l=>s.jsx(yb,{title:l.title,description:Zb[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(cl,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[r.includes("federal")&&s.jsx(ma,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:rn,taxYearOptions:ha,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:Yb}),r.includes("state")&&s.jsx(ma,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:rn,taxYearOptions:ha,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:Hb}),s.jsx(ma,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:rn,taxYearOptions:ha,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:Kb,comingSoon:!0})]}),s.jsx(Cb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(qb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}const fl=160,Qb=48,ls=8;function Jb({entity:e,onEdit:t}){const n=N.useRef(null),r=N.useRef(null),[a,i]=N.useState(!1),[o,l]=N.useState({}),c=()=>{var x;const u=n.current;if(!u)return;const d=u.getBoundingClientRect(),m=((x=r.current)==null?void 0:x.offsetHeight)??Qb,f=window.innerHeight-d.bottom<m+ls;l({position:"fixed",top:f?d.top-m-ls:d.bottom+ls,left:Math.max(ls,d.right-fl),width:fl,zIndex:50})};return N.useLayoutEffect(()=>{a&&(c(),requestAnimationFrame(c))},[a]),N.useEffect(()=>{if(!a)return;const u=m=>{var f,x;const h=m.target;(f=n.current)!=null&&f.contains(h)||(x=r.current)!=null&&x.contains(h)||i(!1)},d=()=>c();return document.addEventListener("mousedown",u),window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{document.removeEventListener("mousedown",u),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[a]),s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:n,type:"button",onClick:()=>i(u=>!u),className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700",children:["Actions",s.jsx(Gb,{})]}),a?Br.createPortal(s.jsx("div",{ref:r,style:o,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:s.jsx("button",{type:"button",onClick:()=>{i(!1),t(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"})}),document.body):null]})}function Gb(){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"})})}function fu({open:e,entity:t,onClose:n}){var $,P,R,ee,B,K,ne,Y,ce,fe,Q,ke;const r=ft(),[a,i]=N.useState(null),[o,l]=N.useState(!1),{register:c,handleSubmit:u,watch:d,reset:m,setValue:h,getValues:f,formState:{errors:x}}=Rt({resolver:$t(uu),defaultValues:ll(t),shouldUnregister:!1}),p=d("accountType"),v=d("entityType"),g=p==="Individual"?lu:ou,k=p==="Individual"?"SSN":"EIN",j=d("country"),S=c("phoneNumber"),E=c("zipCode"),_=se=>{const Se=f("accountType");if(Se===se)return;const ue=f("lastName");du(Se,se,h,ue),h("accountType",se),queueMicrotask(()=>{h("lastName",ue),h("firstName",""),Se==="Business"&&se==="Individual"&&h("tradeName","")})};N.useEffect(()=>{if(e){const se=ll(t);m(se),i(null)}},[t,e,m]),N.useEffect(()=>{if(!e)return;const se=Se=>{Se.key==="Escape"&&n()};return document.addEventListener("keydown",se),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",se),document.body.style.overflow=""}},[e,n]),N.useEffect(()=>{g.includes(v)||h("entityType",p==="Individual"?"Sole Proprietorship":"LLP")},[p,v,g,h]);const I=u(async se=>{i(null),l(!0);try{await Zh(t.entityId,cb(se)),await r.invalidateQueries({queryKey:["entities","mine"]}),n()}catch(Se){i(tt(Se,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?Br.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:n}),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:I,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(Lt,{message:a})}):null,s.jsxs("div",{className:"space-y-8",children:[s.jsx("input",{type:"hidden",...c("ein")}),s.jsx(gn,{step:1,title:"ENTITY DETAILS",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx($n,{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",checked:p==="Business",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>_("Business")}),"Business"]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:"Individual",checked:p==="Individual",className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-500",onChange:()=>_("Individual")}),"Individual"]})]})]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:p==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(pe,{label:"First name",required:!0,maxLength:100,placeholder:"Enter",error:($=x.firstName)==null?void 0:$.message,...c("firstName")},"entity-first-name"),s.jsx(pe,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter",error:(P=x.lastName)==null?void 0:P.message,...c("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(pe,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter",error:(R=x.lastName)==null?void 0:R.message,...c("lastName")},"entity-business-name"),s.jsx(pe,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter",error:(ee=x.tradeName)==null?void 0:ee.message,...c("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:k,readOnly:!0,value:ab(t.idNumber,p),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(xn,{label:"Entity Type",required:!0,error:(B=x.entityType)==null?void 0:B.message,...c("entityType"),children:g.map(se=>s.jsx("option",{value:se,children:se},se))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(K=x.email)==null?void 0:K.message,...c("email")}),s.jsxs("div",{children:[s.jsx($n,{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",inputMode:"numeric",placeholder:"10 digits",maxLength:10,className:`block w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 ${x.phoneNumber?"border-red-300":"border-slate-200"}`,...S,onChange:se=>{se.target.value=se.target.value.replace(/\D/g,"").slice(0,10),S.onChange(se)}})]}),x.phoneNumber?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:x.phoneNumber.message}):null]})]})]})}),s.jsx("div",{className:"border-t border-slate-200"}),s.jsx(gn,{title:"ADDRESS DETAILS",muted:!0,children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(pe,{label:"Address Line 1",required:!0,maxLength:200,error:(ne=x.address1)==null?void 0:ne.message,...c("address1")}),s.jsx(pe,{label:"Address Line 2",maxLength:200,error:(Y=x.address2)==null?void 0:Y.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:"City",required:!0,maxLength:100,error:(ce=x.city)==null?void 0:ce.message,...c("city")}),s.jsxs(xn,{label:"State",required:!0,error:(fe=x.state)==null?void 0:fe.message,...c("state"),children:[s.jsx("option",{value:"",children:"Select"}),Li.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(pe,{label:"ZIP Code",required:!0,maxLength:10,placeholder:j==="United States"?"12345 or 12345-6789":void 0,error:(Q=x.zipCode)==null?void 0:Q.message,...E,onChange:se=>{j==="United States"&&(se.target.value=cu(se.target.value)),E.onChange(se)}}),s.jsxs(xn,{label:"Country",required:!0,error:(ke=x.country)==null?void 0:ke.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:n,disabled:o,className:"inline-flex h-10 items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),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 Vi(){const{selectedEntity:e}=qn(),t=Ae(),[n,r]=N.useState(""),[a,i]=N.useState(""),[o,l]=N.useState(1),[c,u]=N.useState(st),[d,m]=N.useState(null);N.useEffect(()=>{const j=window.setTimeout(()=>i(n.trim()),300);return()=>window.clearTimeout(j)},[n]),N.useEffect(()=>{l(1)},[a,c]);const{data:h,isLoading:f,isFetching:x,isError:p}=ve({queryKey:["entities","mine","paged",a,o,c],queryFn:()=>yi({search:a||void 0,pageNumber:o,pageSize:c}),placeholderData:j=>j}),v=(h==null?void 0:h.items)??[],g=(h==null?void 0:h.totalCount)??0,k=x;return s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("button",{type:"button",onClick:()=>t("/dashboard"),className:"inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5]",children:[s.jsx(e0,{}),"Back"]}),s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex shrink-0 items-center gap-2 rounded-[14px] bg-[#156bd5] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1260be]",children:[s.jsx(t0,{}),"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:n,onChange:j=>r(j.target.value),placeholder:"All",className:"h-[38px] w-[220px] rounded-lg border-2 border-[#e5e7eb] bg-[#f9fafb] px-3 text-sm text-slate-700 placeholder-[#99a1af] focus:border-[#156bd5] focus:outline-none"})]})]}),d?s.jsx(fu,{open:!0,entity:d,onClose:()=>m(null)}):null,s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-black/[0.12] bg-white",children:[k?s.jsx(vr,{label:"Loading organizations…"}):null,s.jsx("div",{className:"overflow-x-auto",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:f&&!h?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Loading organizations…"})}):p?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Unable to load organizations."})}):v.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:a?"No organizations match your search.":"No organizations yet."})}):v.map(j=>s.jsx(Xb,{entity:j,isSelected:j.entityId===(e==null?void 0:e.entityId),onEdit:m},j.entityId))})]})}),s.jsx(Qr,{page:o,pageSize:c,totalCount:g,onPageChange:l,onPageSizeChange:u,disabled:f||x})]})]})}function Xb({entity:e,isSelected:t,onEdit:n}){var l;const r=Xt(e),a=$i(r),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:r})]})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:Bn(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(Jb,{entity:e,onEdit:n})})]})}function e0(){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 t0(){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 Bi(e){return me(`/portal/federal-payments/${e}`)}function n0(e){return me(`/portal/federal-payments/form-types?entityId=${e}`)}function r0(e){const t=new URLSearchParams({formType:e});return me(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Ui(e){return me("/portal/federal-payments",{method:"POST",body:e})}function Zi(e,t){return me(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function s0(e){return me(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function a0(e){return Wr(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function i0(e){return Wr(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function o0(e){return Wr(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function l0(e){return Wr(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function c0({entityId:e,status:t,category:n="all",pageNumber:r=1,pageSize:a=st}){const i=new URLSearchParams({entityId:String(e),pageNumber:String(r),pageSize:String(a)});return t&&i.set("status",t),n&&n!=="all"?i.set("category",n):n==="all"&&i.set("category","all"),me(`/portal/remittance-payments?${i}`)}function u0(e,t="all"){const n=new URLSearchParams({entityId:String(e)});return t&&n.set("category",t),me(`/portal/remittance-payments/status-counts?${n}`)}function d0(e){return me("/portal/state-payments/states",{signal:e})}function m0(e,t,n){const r=new URLSearchParams({entityId:String(e),state:t});return me(`/portal/state-payments/payment-reasons?${r}`,{signal:n})}function h0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return me(`/portal/state-payments/validation-metadata?${a}`,{signal:r})}function f0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return me(`/portal/state-payments/form-references?${a}`,{signal:r})}function pu(e){return me(`/portal/state-payments/${e}`)}function p0(e){return me("/portal/state-payments",{method:"POST",body:e})}function x0(e,t){return me(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function g0(e){return me(`/portal/state-payments/${e}/submit`,{method:"POST"})}function y0({open:e,title:t,html:n,isLoading:r=!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?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:l}),s.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:[s.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 px-5 py-4",children:[s.jsx("h2",{id:"payment-pdf-title",className:"text-base font-semibold text-slate-900",children:t}),s.jsxs("div",{className:"flex items-center gap-2",children:[o?s.jsx("button",{type:"button",onClick:()=>void d(),disabled:c||r||!!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,s.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"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:r?s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"Loading…"}):a?s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-red-600",children:a}):n?s.jsx("iframe",{title:t,srcDoc:n,sandbox:"",className:"h-full w-full border-0 bg-white"}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"No content available."})})]})]}):null}function fa({onViewPdf:e,isViewPdfLoading:t}){return s.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 b0({actionType:e,onView:t,onViewPdf:n,onEdit:r,onSubmit:a,isSubmitting:i=!1,isViewPdfLoading:o=!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: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"?s.jsx(fa,{onViewPdf:n,isViewPdfLoading:o}):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(fa,{onViewPdf:n,isViewPdfLoading:o}),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.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(fa,{onViewPdf:n,isViewPdfLoading:o})]})}function v0(e){const t=/^(\d{4})-Q([1-4])$/.exec(e);if(t)return`Q${t[2]} ${t[1]}`;if(e.length!==6)return e;const n=e.slice(0,4),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(r)||r<1||r>12?e:`Q${Math.ceil(r/3)} ${n}`}function j0(e){return{id:e.id,category:e.category,referenceNo:e.referenceNumber??"—",jurisdiction:e.jurisdiction,period:v0(e.taxPeriod),amount:e.amount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Nb(e.status)}}function N0({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 w0({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 S0({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 k0({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 C0({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 xu=[{key:"drafts",label:"DRAFTS",Icon:N0,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:w0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:S0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:k0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:C0,iconClassName:"text-green-500"}],A0={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 pl(e){return e!==null&&xu.some(t=>t.key===e)}function Wi({paymentsMode:e="all"}){var be;const t=Ae(),n=ft(),[r]=Lm(),{selectedEntity:a}=ht(),{onPaymentRequired:i}=qn(),o=(a==null?void 0:a.entityId)??null,l=r.get("tab"),[c,u]=N.useState(pl(l)?l:Mi),[d,m]=N.useState(e==="all"?"all":e),h=e!=="all"?e:d,[f,x]=N.useState(1),[p,v]=N.useState(st),[g,k]=N.useState(null),[j,S]=N.useState(null),[E,_]=N.useState(null);N.useEffect(()=>{pl(l)&&u(l)},[l]),N.useEffect(()=>{x(1),v(st)},[c,o,d]),N.useEffect(()=>{x(1)},[p]);const I=A0[c],$=ve({queryKey:["remittance-payments","list",o,c,h,f,p],queryFn:()=>c0({entityId:o,status:c,category:h,pageNumber:f,pageSize:p}),enabled:o!==null,placeholderData:O=>O}),P=ve({queryKey:["remittance-payments","status-counts",o,h],queryFn:()=>u0(o,h),enabled:o!==null}),R=$.isLoading,ee=$.isFetching,B=o!==null&&ee,K=N.useMemo(()=>{var O,xe,te,Ne,ae;return{drafts:((O=P.data)==null?void 0:O.drafts)??0,scheduled:((xe=P.data)==null?void 0:xe.scheduled)??0,submitted:((te=P.data)==null?void 0:te.submitted)??0,rejected:((Ne=P.data)==null?void 0:Ne.rejected)??0,paid:((ae=P.data)==null?void 0:ae.paid)??0}},[P.data]),ne=N.useMemo(()=>{var O;return(((O=$.data)==null?void 0:O.items)??[]).map(j0)},[$.data]),Y=((be=$.data)==null?void 0:be.totalCount)??0,ce=Ph({mutationFn:async O=>{try{O.category==="federal"?await s0(O.id):await g0(O.id)}catch(xe){if(xe instanceof yr&&xe.status===402&&i){const te=xe.extensions,Ne={paymentType:(te==null?void 0:te.paymentType)??O.category,paymentId:(te==null?void 0:te.paymentId)??O.id,expectedAmount:(te==null?void 0:te.expectedAmount)??"0.00",currency:(te==null?void 0:te.currency)??"USD",federalRecordCount:(te==null?void 0:te.federalRecordCount)??0,stateRecordCount:(te==null?void 0:te.stateRecordCount)??0,feePerFederal:(te==null?void 0:te.feePerFederal)??null,feePerState:(te==null?void 0:te.feePerState)??null};i(Ne);return}throw xe}},onSuccess:async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})},onError:()=>k(null),onSettled:()=>k(null)});N.useEffect(()=>{const O=async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})};return window.addEventListener(si,O),()=>window.removeEventListener(si,O)},[n]);const fe=O=>{k(`${O.category}-${O.id}`),ce.mutate(O)},Q=O=>{O.category==="federal"?t(`/payments/federal/${O.id}/view`):t(`/payments/state/${O.id}/view`)},ke=O=>{O.category==="federal"?t(`/payments/federal/${O.id}/edit`):t(`/payments/state/${O.id}/edit`)},se=async O=>{const xe=`${O.category}-${O.id}`,te=`payment-${O.referenceNo}.pdf`;S(xe),_({title:`Payment PDF — ${O.referenceNo}`,html:null,category:O.category,paymentId:O.id,downloadFileName:te,isLoading:!0,error:null});try{const Ne=O.category==="federal"?await o0(O.id):await l0(O.id);_({title:`Payment PDF — ${O.referenceNo}`,html:Ne,category:O.category,paymentId:O.id,downloadFileName:te,isLoading:!1,error:null})}catch(Ne){_({title:`Payment PDF — ${O.referenceNo}`,html:null,category:O.category,paymentId:O.id,downloadFileName:te,isLoading:!1,error:tt(Ne,"Unable to load payment PDF.")})}finally{S(null)}},Se=async()=>{if(!E)throw new Error("No payment selected");return E.category==="federal"?a0(E.paymentId):i0(E.paymentId)},ue=()=>_(null);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(pa,{}),"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(pa,{}),"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(pa,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[B?s.jsx(vr,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:xu.map(O=>{const xe=c===O.key,te=O.Icon;return s.jsxs("button",{type:"button",onClick:()=>{u(O.key),t(Xs(O.key),{replace:!0})},className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${xe?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(te,{className:`shrink-0 ${O.iconClassName}`}),O.label," (",K[O.key],")"]},O.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:O=>m(O.target.value),disabled:e!=="all",className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[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:I.columns.map(O=>s.jsx("th",{className:"px-6 py-3",children:O},O))})}),s.jsx("tbody",{children:R&&!$.data?s.jsx("tr",{children:s.jsx("td",{colSpan:I.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):ne.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:I.columns.length,className:"px-6 py-12 text-center text-slate-500",children:I.emptyMessage})}):ne.map(O=>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"?`#${O.id}`:O.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:O.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:O.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(O.amount)}),c!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:O.paymentDate}):null,c==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:O.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(b0,{actionType:I.actionType,onView:()=>Q(O),onViewPdf:()=>se(O),onEdit:()=>ke(O),onSubmit:()=>fe(O),isSubmitting:g===`${O.category}-${O.id}`,isViewPdfLoading:j===`${O.category}-${O.id}`})})]},`${O.category}-${O.id}`))})]})}),s.jsx(Qr,{page:f,pageSize:p,totalCount:Y,onPageChange:x,onPageSizeChange:v,disabled:R||o===null||ee})]}),s.jsx(y0,{open:E!==null,title:(E==null?void 0:E.title)??"Payment PDF",html:(E==null?void 0:E.html)??null,downloadFileName:E==null?void 0:E.downloadFileName,isLoading:(E==null?void 0:E.isLoading)??!1,error:(E==null?void 0:E.error)??null,onDownload:E&&!E.error?Se:void 0,onClose:ue})]})}function pa(){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 Jr({entityId:e,pageNumber:t=1,pageSize:n=st}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return me(`/portal/bank-accounts?${r}`)}function P0(e){return me("/portal/bank-accounts",{method:"POST",body:e})}function gu(e,t){return me(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function wn({title:e,children:t,isFirst:n=!1,headerAction:r}){return s.jsxs("section",{className:n?"":"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}),r]}),t]})}const mr=17,yu=9;function Qn(e,t){return e.replace(/\D/g,"").slice(0,t)}const bu=["Checking","Savings"],E0=Gt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${mr} digits`),confirmAccountNumber:T().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${mr} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Gs(bu,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")}).refine(e=>e.accountNumber===e.confirmAccountNumber,{message:"Account numbers do not match",path:["confirmAccountNumber"]});function I0({entityId:e,onCancel:t,onSuccess:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,formState:{errors:h}}=Rt({resolver:$t(E0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async x=>{l(null),u(!0);try{const p=await P0({entityId:e,bankName:x.bankName.trim(),accountNumber:x.accountNumber,routingNumber:x.routingNumber,accountType:x.accountType});await r.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),n(p.bankAccountDetailId)}catch(p){const v=tt(p,"Unable to save bank account.");l(v),i("Action Not Completed",v)}finally{u(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:x=>{x.preventDefault(),x.stopPropagation(),f(x)},className:"space-y-6",children:[s.jsxs(gn,{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(Le,{name:"accountNumber",control:d,render:({field:x})=>{var p;return s.jsx(pe,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:v=>x.onChange(Qn(v.target.value,mr)),onBlur:x.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),s.jsx(Le,{name:"confirmAccountNumber",control:d,render:({field:x})=>{var p;return s.jsx(pe,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:v=>x.onChange(Qn(v.target.value,mr)),onBlur:x.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),s.jsx(Le,{name:"routingNumber",control:d,render:({field:x})=>{var p;return s.jsx(pe,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:v=>x.onChange(Qn(v.target.value,yu)),onBlur:x.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),s.jsx(Le,{name:"accountType",control:d,render:({field:x})=>{var p;return s.jsx(xn,{label:"Account Type",required:!0,value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:bu.map(v=>s.jsx("option",{value:v,children:v},v))})}})]}),s.jsx(Le,{name:"bankName",control:d,render:({field:x})=>{var p;return s.jsx(pe,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?s.jsx(Lt,{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 vu({open:e,entityId:t,onClose:n,onAccountAdded:r}){const[a,i]=N.useState("choose");if(N.useEffect(()=>{e||i("choose")},[e]),N.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,n]),!e)return null;const o=a==="manual";return 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:n}),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(I0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{r==null||r(l),n()}}):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(T0,{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(_0,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function T0({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 _0({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 D0=12,F0=["January","February","March","April","May","June","July","August","September","October","November","December"];function fn(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function Ts(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(n,r,a);return i.getFullYear()!==n||i.getMonth()!==r||i.getDate()!==a?null:i}function ju(e=new Date){const t=new Date(e);return e.getHours()>=D0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),fn(t)}function Nu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),fn(t)}function R0(e=18,t=new Date){const n=new Date(t);return n.setFullYear(n.getFullYear()-e),n.setHours(0,0,0,0),fn(n)}function O0(e,t,n=new Date){const r=Ts(e);if(!r)return!1;const a=new Date(n);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),r.setHours(0,0,0,0),r<=a}function $0(e){const t=e.getDay();return t!==0&&t!==6}function Xa(e,t=new Date){if(!$0(e))return!1;const n=fn(e);return n>=ju(t)&&n<=Nu(t)}function ea(e,t=new Date){const n=Ts(e);return n?Xa(n,t):!1}function L0(e,t){return`${F0[t]} ${e}`}function z0(e,t){const n=new Date(e,t,1),r=new Date(e,t+1,0).getDate(),a=n.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=r;o+=1)i.push(new Date(e,t,o));return i}function xl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Gr(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 wu({label:e,required:t=!1,htmlFor:n,info:r}){return s.jsxs("label",{htmlFor:n,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]}),r?s.jsx("span",{title:r,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":r,children:"i"}):null]})}function H({label:e,required:t,error:n,info:r,children:a}){return s.jsxs("div",{children:[s.jsx(wu,{label:e,required:t,info:r}),a,n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}const Su=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]"}`:Su(e)}function Jn(e){return`${Su(e)} appearance-none`}function Yn({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 Dr({children:e}){return s.jsx("div",{className:"relative",children:e})}function ku({value:e,onChange:t,entityId:n,entityType:r="",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),x=a.find(v=>String(v.bankAccountDetailId)===e);N.useEffect(()=>{if(!u)return;const v=g=>{var k;(k=f.current)!=null&&k.contains(g.target)||d(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[u]);const p=v=>{t(String(v)),h(!1),d(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,className:"relative",children:[s.jsx(wu,{label:c,required:!0}),s.jsxs("button",{type:"button",disabled:o||!n,onClick:()=>d(v=>!v),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:x?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":x?xl(x.accountNumber):"Bank account number"}),s.jsx(q0,{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(M0,{}),"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(v=>{const g=String(v.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(v.bankAccountDetailId)),d(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${g?"bg-gov-50":""}`,children:[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:$i(v.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:v.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[xl(v.accountNumber),r?` · ${r}`:` · ${v.accountType}`]})]})]},v.bankAccountDetailId)})})]}):null]}),s.jsx(vu,{open:m,entityId:n,onClose:()=>h(!1),onAccountAdded:p})]})}function M0(){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 q0({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 V0(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Xr({entity:e,remittanceAmount:t="—",className:n=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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 r=Xt(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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(Cr,{label:"Entity Name",value:r}),s.jsx(Cr,{label:"Tax ID",value:Bn(e.idNumber)}),s.jsx(Cr,{label:"Email ID",value:e.email}),s.jsx(Cr,{label:"Phone Number",value:Ln(e.phoneNumber)}),s.jsx(Cr,{label:"Address",value:V0(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 Cr({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 B0=[0,1,3,4,6,7,9,10],U0=[0,1,2,3,4,5,6,7,8,9,10],Z0=[0,1,2,3,4,5,6,8,9,10,11],W0=[0,1,2,3,4,5,6,7,9,10,11],Y0=["720","941"],H0=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],K0=["7200D"],Q0=["8963"];function Cu(e){return Y0.includes(e)?B0:H0.includes(e)?U0:K0.includes(e)?Z0:Q0.includes(e)?W0:[]}function J0(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function _s(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(n)||n<1||n>12?null:{year:t,month:n-1}}function G0(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function Au(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Ds={941:"94105",944:"94405","CT-1":"10005"},Ar={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Fs={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 Yi(e,t){return!e||!t?!1:Ds[e]===t}function ta(e,t){return e==="CT-1"&&t===Ds["CT-1"]}function X0(e,t){return e==="941"&&t===Ds[941]||e==="944"&&t===Ds[944]}function ev(e){return e==="CT-1"?{code1:Ar.tier1,code2:Ar.tier2,code3:""}:{code1:Ar.socialSecurity,code2:Ar.medicare,code3:Ar.withheld}}function Rs(e){return Fs.regex.test(e)}const tv=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,cs=1e8;function nv(e){if(!e)return"";let t="",n=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!n&&(t+=c,n=!0);const r=t.indexOf(".");let a=r===-1?t:t.slice(0,r);const i=r===-1?"":t.slice(r+1,r+3),o=r!==-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>cs&&(a=String(cs))}let l=r===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),tv.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>cs)return String(cs)}return l}return""}function Pu(e){return Rs(e)?Number.parseFloat(e):null}function rv(e,t,n,r){const a=[e,t];return r&&a.push(n),a.reduce((i,o)=>{const l=Pu(o);return l===null?i:i+l},0)}function sv(e,t){return Math.abs(e-t)<.005}function av(e,t,n,r,a){if(!Yi(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=ta(e,t);return{subcategoryCode1:n.trim()?"1":null,subcategoryCode2:r.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const iv=["Su","Mo","Tu","We","Th","Fr","Sa"];function ov(){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 Eu({value:e,onChange:t,disabled:n=!1,hasError:r=!1}){const a=Ts(e),i=ju(),o=Nu(),[l,c]=N.useState(!1),[u,d]=N.useState(()=>a??Ts(i)??new Date),m=N.useRef(null),h=N.useId();N.useEffect(()=>{a&&d(a)},[e]),N.useEffect(()=>{if(!l)return;const g=k=>{var j;(j=m.current)!=null&&j.contains(k.target)||c(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]);const f=N.useMemo(()=>z0(u.getFullYear(),u.getMonth()),[u]),x=N.useMemo(()=>{const g=new Date(u.getFullYear(),u.getMonth()-1,1),k=new Date(g.getFullYear(),g.getMonth()+1,0);return fn(k)>=i},[u,i]),p=N.useMemo(()=>{const g=new Date(u.getFullYear(),u.getMonth()+1,1);return fn(g)<=o},[u,o]),v=g=>{Xa(g)&&(t(fn(g)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:n,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!n&&c(g=>!g),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>c(g=>!g),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open settlement date picker",children:s.jsx(ov,{})})]}),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:!x,onClick:()=>d(g=>new Date(g.getFullYear(),g.getMonth()-1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous month",children: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:L0(u.getFullYear(),u.getMonth())}),s.jsx("button",{type:"button",disabled:!p,onClick:()=>d(g=>new Date(g.getFullYear(),g.getMonth()+1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next month",children: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:iv.map(g=>s.jsx("div",{className:"py-1",children:g},g))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((g,k)=>{if(!g)return s.jsx("div",{},`empty-${k}`);const j=fn(g),S=e===j,E=!Xa(g);return s.jsx("button",{type:"button","aria-disabled":E,onClick:()=>v(g),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":S?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:g.getDate()},j)})})]}):null]})}function Tr({value:e,onChange:t,onBlur:n,name:r,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:r,value:e,disabled:a,readOnly:i,placeholder:o,className:X(l,i),onChange:c=>t(nv(c.target.value)),onBlur:n})}const lv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function cv(){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 uv({value:e,onChange:t,disabled:n=!1,hasError:r=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=Au(),l=_s(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 x=J0(e),p=j=>!!a.includes(j),v=j=>{p(j)||(t(G0(d,j)),u(!1))},g=d>i,k=d<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:f,type:"text",readOnly:!0,disabled:n,value:x,placeholder:"YYYY-MM",onClick:()=>!n&&u(j=>!j),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>u(j=>!j),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open tax period picker",children:s.jsx(cv,{})})]}),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:!g,onClick:()=>m(j=>j-1),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous year",children: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:!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: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:lv.map((j,S)=>{const E=(l==null?void 0:l.year)===d&&l.month===S&&e.length===6,_=p(S);return s.jsx("button",{type:"button","aria-disabled":_,onClick:()=>v(S),className:`rounded-lg px-2 py-2.5 text-sm transition ${_?"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 Iu="Active",dv="Inactive";function jr(e){return(e.status??Iu).trim().toLowerCase()==="active"}function mv(e){return jr(e)?dv:Iu}function hv(e){return jr(e)?"Deactivate":"Activate"}function Hi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function fv(e){return Hi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function Tu(e){const t=av(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),n=ta(e.taxFormType,e.taxTypeCode);return{subcategoryCode1:t.subcategoryCode1,subcategoryAmount1:e.subcategoryAmount1?Number.parseFloat(e.subcategoryAmount1):null,subcategoryCode2:t.subcategoryCode2,subcategoryAmount2:e.subcategoryAmount2?Number.parseFloat(e.subcategoryAmount2):null,subcategoryCode3:t.subcategoryCode3,subcategoryAmount3:!n&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function Ki(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),...Tu(t)}}function Qi(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),...Tu(e)}}const Ji="federal-payment-draft";function Gi(e){sessionStorage.setItem(Ji,JSON.stringify(e))}function na(){const e=sessionStorage.getItem(Ji);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Xi(){sessionStorage.removeItem(Ji)}function pv(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 xv=Gt({taxpayerPin:T().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:T().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional(),taxFormType:T().min(1,"Tax form type is required"),taxTypeCode:T().min(1,"Payment type is required"),taxPeriod:T().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=_s(e);if(!t)return!1;const{minYear:n,maxYear:r}=Au();return t.year>=n&&t.year<=r},"Tax period must be within the last 3 years"),settlementDate:T().min(1,"This field is required").refine(e=>ea(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:T().min(1,"This field is required").refine(e=>Rs(e),Fs.errorMessage),subcategoryCode1:T().optional(),subcategoryAmount1:T().optional(),subcategoryCode2:T().optional(),subcategoryAmount2:T().optional(),subcategoryCode3:T().optional(),subcategoryAmount3:T().optional()}).superRefine((e,t)=>{var l;if(e.taxPeriod&&e.taxFormType){const c=_s(e.taxPeriod);c&&Cu(e.taxFormType).includes(c.month)&&t.addIssue({code:nn.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Yi(e.taxFormType,e.taxTypeCode))return;const n=ta(e.taxFormType,e.taxTypeCode),r=X0(e.taxFormType,e.taxTypeCode),a=(c,u,d)=>{if(!(c!=null&&c.trim())){d&&t.addIssue({code:nn.custom,message:"This field is required",path:[u]});return}Rs(c)||t.addIssue({code:nn.custom,message:Fs.errorMessage,path:[u]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",r);const i=Pu(e.paymentAmount),o=rv(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",r);i!==null&&!sv(i,o)&&t.addIssue({code:nn.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),n&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:nn.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),us="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function xa(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 gv={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function yv(e,t){if(e)return xa(e);if(t!=null&&t.paymentDraft)return xa(t.paymentDraft);const n=na();return n?xa(n):gv}function _u({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var zt,pt,vt,xt,jt,Mt,At,qt,Pt,Nt,Et,It,Vt;const a=Ae(),i=Ce(),o=ft(),l=Un(i.state,Qe()),c=i.state,u=N.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??na()??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),[x,p]=N.useState(!1),v=N.useMemo(()=>yv(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:g=[],isLoading:k}=ve({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),j=N.useMemo(()=>g.filter(jr),[g]),{data:S=[],isLoading:E}=ve({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>n0(e.entityId),enabled:e!==null}),{register:_,control:I,handleSubmit:$,watch:P,setValue:R,trigger:ee,formState:{errors:B}}=Rt({resolver:$t(xv),defaultValues:v}),K=P("bankAccountDetailId"),ne=P("paymentAmount"),Y=P("taxFormType"),ce=P("taxTypeCode"),fe=P("taxPeriod"),Q=P("settlementDate"),ke=P("subcategoryAmount1"),se=P("subcategoryAmount2"),Se=P("subcategoryAmount3"),ue=N.useRef(Y),be=N.useMemo(()=>Y?Cu(Y):[],[Y]),O=N.useMemo(()=>Yi(Y,ce),[Y,ce]),xe=N.useMemo(()=>ta(Y,ce),[Y,ce]),{data:te=[],isLoading:Ne}=ve({queryKey:["federal-tax-type-codes",Y],queryFn:()=>r0(Y),enabled:!!Y});N.useEffect(()=>{ue.current&&ue.current!==Y&&R("taxTypeCode",""),ue.current=Y},[Y,R]),N.useEffect(()=>{if(!fe||!Y)return;const z=_s(fe);z&&be.includes(z.month)&&R("taxPeriod","")},[Y,fe,be,R]),N.useEffect(()=>{Q&&(ea(Q)||R("settlementDate",""))},[Q,R]),N.useEffect(()=>{if(!O){R("subcategoryCode1",""),R("subcategoryCode2",""),R("subcategoryCode3",""),R("subcategoryAmount1",""),R("subcategoryAmount2",""),R("subcategoryAmount3","");return}const z=ev(Y);R("subcategoryCode1",z.code1),R("subcategoryCode2",z.code2),R("subcategoryCode3",xe?"":z.code3),xe&&R("subcategoryAmount3","")},[O,Y,xe,R]),N.useEffect(()=>{O&&(ee("paymentAmount"),ee("subcategoryAmount1"),ee("subcategoryAmount2"),ee("subcategoryAmount3"))},[ke,se,Se,O,ee]),N.useEffect(()=>{const z=j.find(de=>String(de.bankAccountDetailId)===K);if(!z){K&&(R("bankAccountDetailId",""),R("routingNumber",""),R("accountType",""),R("bankName",""));return}R("routingNumber",z.routingNumber),R("accountType",z.accountType),R("bankName",z.bankName)},[j,K,R]);const ae=z=>{const de=j.find(b=>String(b.bankAccountDetailId)===z.bankAccountDetailId);return{federalPaymentId:d.current,enrollmentId:m.current??(u==null?void 0:u.enrollmentId),form8655AuthorizationId:u==null?void 0:u.form8655AuthorizationId,form9783EnrollmentId:u==null?void 0:u.form9783EnrollmentId,taxpayerPin:z.taxpayerPin??"",secondaryTin:z.secondaryTin??"",bankAccountDetailId:z.bankAccountDetailId,routingNumber:z.routingNumber??(de==null?void 0:de.routingNumber)??"",accountNumber:(de==null?void 0:de.accountNumber)??"",accountType:z.accountType??(de==null?void 0:de.accountType)??"",bankName:z.bankName??(de==null?void 0:de.bankName)??"",taxFormType:z.taxFormType,taxTypeCode:z.taxTypeCode,taxPeriod:z.taxPeriod,settlementDate:z.settlementDate,paymentAmount:z.paymentAmount,subcategoryCode1:z.subcategoryCode1,subcategoryAmount1:z.subcategoryAmount1,subcategoryCode2:z.subcategoryCode2,subcategoryAmount2:z.subcategoryAmount2,subcategoryCode3:z.subcategoryCode3,subcategoryAmount3:z.subcategoryAmount3}},Me=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},oe=async z=>{if(!e)return null;if(z.federalPaymentId){const b=await Zi(z.federalPaymentId,Qi(z));return d.current=b.federalPaymentId,m.current=b.enrollmentId,b}const de=await Ui(Ki(e.entityId,z));return d.current=de.federalPaymentId,m.current=de.enrollmentId,de},_e=$(async z=>{if(!(n||!e)){f(null),p(!0);try{const de=ae(z),b=await oe(de);if(!b)return;const C={...de,federalPaymentId:b.federalPaymentId,enrollmentId:b.enrollmentId};await Me(),Gi(C),a(fv(e),{state:{from:l,paymentDraft:C}})}catch(de){f(tt(de,"Failed to save payment details."))}finally{p(!1)}}}),Je=$(async z=>{if(!(!e||n)){f(null),p(!0);try{const de=ae(z);await oe(de),await Me(),Xi(),a(Qe())}catch(de){f(tt(de,"Failed to save draft."))}finally{p(!1)}}}),at=()=>{if(r){r();return}a(l)},it=e?Xt(e):"Entity";return s.jsxs("form",{onSubmit:_e,noValidate:!0,className:"w-full space-y-6",children:[h?s.jsx(Lt,{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:it}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(ne),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(wn,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:us,children:[s.jsx(H,{label:"Taxpayer PIN",required:!0,error:(zt=B.taxpayerPin)==null?void 0:zt.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:X(!!B.taxpayerPin),maxLength:4,disabled:n,..._("taxpayerPin")})}),s.jsx(H,{label:"Secondary TIN",error:(pt=B.secondaryTin)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:X(!!B.secondaryTin),maxLength:9,disabled:n,..._("secondaryTin")})}),s.jsx(Le,{name:"bankAccountDetailId",control:I,render:({field:z})=>{var de;return s.jsx(ku,{value:z.value,onChange:z.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:j,isLoading:k,disabled:!e||n,error:(de=B.bankAccountDetailId)==null?void 0:de.message})}}),s.jsx(H,{label:"Routing Number",required:!0,error:(vt=B.routingNumber)==null?void 0:vt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:X(!!B.routingNumber,!0),..._("routingNumber")})}),s.jsx(H,{label:"Account Type",required:!0,error:(xt=B.accountType)==null?void 0:xt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:X(!!B.accountType,!0),..._("accountType")})}),s.jsx(H,{label:"Bank Name",required:!0,error:(jt=B.bankName)==null?void 0:jt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:X(!!B.bankName,!0),..._("bankName")})})]})}),s.jsx(wn,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:us,children:[s.jsx(H,{label:"Tax Form Type",required:!0,error:(Mt=B.taxFormType)==null?void 0:Mt.message,children:s.jsxs(Dr,{children:[s.jsxs("select",{className:Jn(!!B.taxFormType),disabled:E||!e||n,..._("taxFormType"),children:[s.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),S.map(z=>s.jsx("option",{value:z.value,children:z.value},z.value))]}),s.jsx(Yn,{})]})}),s.jsx(H,{label:"Payment Type",required:!0,error:(At=B.taxTypeCode)==null?void 0:At.message,children:s.jsxs(Dr,{children:[s.jsxs("select",{className:Jn(!!B.taxTypeCode),disabled:!Y||Ne||n,..._("taxTypeCode"),children:[s.jsx("option",{value:"",children:Y?Ne?"Loading payment types…":"Select payment type":"Select tax form first"}),te.map(z=>s.jsxs("option",{value:z.code,children:[z.code," - ",z.codeName]},z.code))]}),s.jsx(Yn,{})]})}),s.jsx(H,{label:"Tax Period",required:!0,error:(qt=B.taxPeriod)==null?void 0:qt.message,children:s.jsx(Le,{name:"taxPeriod",control:I,render:({field:z})=>s.jsx(uv,{value:z.value,onChange:z.onChange,hasError:!!B.taxPeriod,disabled:!Y||n,disabledMonths:be})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(H,{label:"Settlement Date",required:!0,error:(Pt=B.settlementDate)==null?void 0:Pt.message,children:s.jsx(Le,{name:"settlementDate",control:I,render:({field:z})=>s.jsx(Eu,{value:z.value,onChange:z.onChange,hasError:!!B.settlementDate,disabled:n})})}),s.jsx(H,{label:"Payment Amount",required:!0,error:(Nt=B.paymentAmount)==null?void 0:Nt.message,children:s.jsx(Le,{name:"paymentAmount",control:I,render:({field:z})=>s.jsx(Tr,{name:z.name,value:z.value,onChange:z.onChange,onBlur:z.onBlur,disabled:n,hasError:!!B.paymentAmount})})})]}),O?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:us,children:[s.jsx(H,{label:"Subcategory Code 1",children:s.jsx("input",{readOnly:!0,className:X(!1,!0),..._("subcategoryCode1")})}),s.jsx(H,{label:"Subcategory Code 2",children:s.jsx("input",{readOnly:!0,className:X(!1,!0),..._("subcategoryCode2")})}),xe?null:s.jsx(H,{label:"Subcategory Code 3",children:s.jsx("input",{readOnly:!0,className:X(!1,!0),..._("subcategoryCode3")})})]}),s.jsxs("div",{className:us,children:[s.jsx(H,{label:"Subcategory Amount 1",required:!0,error:(Et=B.subcategoryAmount1)==null?void 0:Et.message,children:s.jsx(Le,{name:"subcategoryAmount1",control:I,render:({field:z})=>s.jsx(Tr,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!B.subcategoryAmount1})})}),s.jsx(H,{label:"Subcategory Amount 2",required:!0,error:(It=B.subcategoryAmount2)==null?void 0:It.message,children:s.jsx(Le,{name:"subcategoryAmount2",control:I,render:({field:z})=>s.jsx(Tr,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!B.subcategoryAmount2})})}),xe?null:s.jsx(H,{label:"Subcategory Amount 3",required:!0,error:(Vt=B.subcategoryAmount3)==null?void 0:Vt.message,children:s.jsx(Le,{name:"subcategoryAmount3",control:I,render:({field:z})=>s.jsx(Tr,{name:z.name,value:z.value??"",onChange:z.onChange,onBlur:z.onBlur,disabled:n,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:at,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:n?"Back":"Cancel"}),n?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:Je,disabled:!e||x,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:x?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||x,className:"inline-flex h-11 min-w-[160px] items-center justify-center rounded-lg bg-gov-600 px-10 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:x?"Saving…":"Next"})]})]})]},i.key)}function Du(){const{selectedEntity:e}=ht();return s.jsx(_u,{entity:e})}function Fu({mode:e}){var m;const t=Ae(),{federalPaymentId:n}=Ls(),{selectedEntity:r}=ht(),a=Number.parseInt(n??"",10),{data:i,isLoading:o,isError:l}=ve({queryKey:["federal-payment",a],queryFn:()=>Bi(a),enabled:Number.isFinite(a)}),{data:c=[]}=ve({queryKey:["bank-accounts",r==null?void 0:r.entityId],queryFn:async()=>(await Jr({entityId:r.entityId,pageNumber:1,pageSize:100})).items,enabled:r!==null&&i!==void 0}),u=N.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return pv(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(Be,{to:Qe(),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(Be,{to:Qe(),replace:!0});if(!r||i.entityId!==r.entityId)return s.jsx(Be,{to:Qe(),replace:!0});const d=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(_u,{entity:r,initialDraft:u,readonly:d,onCancel:()=>t(Qe())})}function Ru(){return ht(),s.jsx(Fu,{mode:"edit"})}function Ou(){return ht(),s.jsx(Fu,{mode:"view"})}function bv(e){const t=[];return e.includes("\\d")&&t.push("0-9"),/[A-Z]/.test(e)&&t.push("A-Z"),e.includes("-")&&t.push("\\-"),e.includes(" ")&&t.push(" "),e.includes("/")&&t.push("/"),t.length?t.join(""):null}function vv(e,t){const n=e.toUpperCase();if(!t)return n;const r=bv(t);return r?n.replace(new RegExp(`[^${r}]`,"g"),""):n}function jv(e){if(!e)return null;const t=[];let n=0;try{for(;n<e.length;){if(e.startsWith("(?:",n))return null;const r=e[n];if(r==="-"||r===" "||r==="/"){t.push({type:"separator",char:r}),n+=1;continue}let a;if(r==="\\")a=e[n+1]==="d"?"digit":"letter",n+=2;else if(r==="["){const o=e.indexOf("]",n);if(o===-1)return null;a="letter",n=o+1}else a=r>="0"&&r<="9"?"digit":"letter",n+=1;const i=Nv(e,n);if(i===null)return null;for(let o=0;o<i.count;o+=1)t.push({type:"slot",kind:a});n=i.nextIndex}}catch{return null}return t}function Nv(e,t){if(e[t]!=="{")return{count:1,nextIndex:t};const n=e.indexOf("}",t);if(n===-1)throw new Error("Unterminated quantifier");const r=e.slice(t+1,n);if(r.includes(","))return null;const a=Number.parseInt(r,10);if(Number.isNaN(a))throw new Error("Bad quantifier");return{count:a,nextIndex:n+1}}function wv(e,t){const n=e.toUpperCase().replace(/[^0-9A-Z]/g,"").split("");let r="",a=0;for(const i of t){if(a>=n.length)break;if(i.type==="separator"){r+=i.char;continue}for(;a<n.length;){const o=n[a];a+=1;const l=o>="0"&&o<="9";if(i.kind==="digit"?l:!l){r+=o;break}}}return r}function Sv(e){if(e)try{const t=$u(e,0);return t.index===e.length?t.length:void 0}catch{return}}function $u(e,t){let n=t,r=0;for(;;){const a=kv(e,n);if(r=Math.max(r,a.length),n=a.index,e[n]==="|"){n+=1;continue}return{length:r,index:n}}}function kv(e,t){let n=t,r=0;for(;n<e.length&&e[n]!=="|"&&e[n]!==")";){const a=Cv(e,n);r+=a.length,n=a.index}return{length:r,index:n}}function Cv(e,t){let n=t,r;if(e.startsWith("(?:",n)){const a=$u(e,n+3);if(e[a.index]!==")")throw new Error("Unbalanced group");r=a.length,n=a.index+1}else if(e[n]==="\\")r=1,n+=2;else if(e[n]==="["){const a=e.indexOf("]",n);if(a===-1)throw new Error("Unterminated class");r=1,n=a+1}else r=1,n+=1;if(e[n]==="{"){const a=e.indexOf("}",n);if(a===-1)throw new Error("Unterminated quantifier");const i=e.slice(n+1,a).split(","),o=i.length===2?i[1]:i[0],l=Number.parseInt(o,10);if(Number.isNaN(l))throw new Error("Bad quantifier");r*=l,n=a+1}return{length:r,index:n}}const eo="state-payment-draft";function ei(e){sessionStorage.setItem(eo,JSON.stringify(e))}function ti(){const e=sessionStorage.getItem(eo);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Lu(){sessionStorage.removeItem(eo)}function zu(e,t){return`${e}-${t}`}function Av(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:zu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function Pv(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:zu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}function Ev(e){return Gt({state:T().min(1,"State is required"),reasonForPayment:T().min(1,"Reason for payment is required"),stateAccountId:T().min(1,"State ID is required"),accountId:T().min(1,"Account ID is required").refine(t=>/^\d{10,12}$/.test(t.trim()),"Account ID must be 10 to 12 digits"),letterId:T().optional().refine(t=>!t||/^[A-Za-z0-9]+$/.test(t),"Letter ID must be alphanumeric"),taxYear:T().min(1,"Tax year is required"),taxPeriod:T().min(1,"Tax period is required"),taxAmount:T().min(1,"Tax amount is required").refine(t=>Rs(t),Fs.errorMessage),paymentDate:T().min(1,"Payment date is required").refine(t=>ea(t),"Payment date must be a weekday within the allowed range"),bankAccountDetailId:T().min(1,"Bank account is required"),routingNumber:T().optional(),accountType:T().optional(),bankName:T().optional()}).superRefine((t,n)=>{const r=e(),a=r==null?void 0:r.stateId.pattern;if(a)try{new RegExp(`^(?:${a})$`).test(t.stateAccountId.trim().toUpperCase())||n.addIssue({code:nn.custom,path:["stateAccountId"],message:r.stateId.message})}catch{n.addIssue({code:nn.custom,path:["stateAccountId"],message:"State ID validation is temporarily unavailable"})}})}const ga="grid gap-x-6 gap-y-5 sm:grid-cols-3",gl="grid gap-x-6 gap-y-5 sm:grid-cols-2",yl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",bl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function ya(e){return{state:e.state,reasonForPayment:Iv(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 Iv(e){return e.trim().toUpperCase().replaceAll(" ","_")}function Mu({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var Nt,Et,It,Vt,z,de,b,C;const a=Ae(),i=Ce(),o=Un(i.state,Qe()),l=i.state,c=N.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??ti()??null,[t,l==null?void 0:l.paymentDraft]),u=N.useRef(c==null?void 0:c.statePaymentDetailId),d=N.useMemo(()=>{if(t)return ya(t);if(l!=null&&l.paymentDraft)return ya(l.paymentDraft);if(l!=null&&l.resetDraft)return Lu(),bl;const y=ti();return y?ya(y):bl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),{data:m=[],isLoading:h,isError:f}=ve({queryKey:["state-payment-states"],queryFn:({signal:y})=>d0(y)}),{data:x=[],isLoading:p}=ve({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),v=N.useMemo(()=>x.filter(jr),[x]),g=N.useRef(null),k=N.useMemo(()=>Ev(()=>g.current),[]),{register:j,control:S,handleSubmit:E,watch:_,setValue:I,clearErrors:$,formState:{errors:P}}=Rt({resolver:$t(k),defaultValues:d}),R=_("state"),ee=_("reasonForPayment"),B=_("taxAmount"),K=_("paymentDate"),ne=_("bankAccountDetailId"),{data:Y=[],isLoading:ce,isError:fe}=ve({queryKey:["state-payment-reasons",e==null?void 0:e.entityId,R],queryFn:({signal:y})=>m0(e.entityId,R,y),enabled:e!==null&&!!R}),{data:Q,isLoading:ke,isError:se}=ve({queryKey:["state-payment-validation-metadata",e==null?void 0:e.entityId,R,ee],queryFn:({signal:y})=>h0(e.entityId,R,ee,y),enabled:e!==null&&!!(R&&ee)});ve({queryKey:["state-payment-form-references",e==null?void 0:e.entityId,R,ee],queryFn:({signal:y})=>f0(e.entityId,R,ee,y),enabled:e!==null&&!!(R&&ee)}),g.current=Q??null;const Se=(Q==null?void 0:Q.taxYearOptions)??[],ue=(Q==null?void 0:Q.taxPeriodOptions)??[],be=!!(Q&&R&&ee),O=(Q==null?void 0:Q.stateId.pattern)??null,xe=Sv(O),te=N.useMemo(()=>jv(O),[O]),Ne=j("stateAccountId"),ae=j("accountId"),Me=j("letterId"),[oe,_e]=N.useState(!1),[Je,at]=N.useState(""),it=N.useRef(null),zt=(Nt=m.find(y=>y.code===R))==null?void 0:Nt.name,pt=N.useMemo(()=>{const y=Je.trim().toLowerCase();return y?m.filter(F=>F.name.toLowerCase().includes(y)||F.code.toLowerCase().includes(y)):m},[Je,m]),vt=["stateAccountId","accountId","letterId","taxYear","taxPeriod","taxAmount","paymentDate"],xt=()=>{vt.forEach(y=>I(y,"")),$([...vt,"bankAccountDetailId"])},jt=y=>{I("state",y,{shouldValidate:!0}),I("reasonForPayment",""),$("reasonForPayment"),xt(),at(""),_e(!1)},Mt=y=>{y!==ee&&(I("reasonForPayment",y,{shouldValidate:!0}),xt())};N.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(u.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),N.useEffect(()=>{var y;oe&&((y=it.current)==null||y.focus())},[oe]),N.useEffect(()=>{!ee||ce||fe||Y.some(y=>y.code===ee)||I("reasonForPayment","")},[ce,fe,Y,ee,I]),N.useEffect(()=>{n||K&&!ea(K)&&I("paymentDate","")},[K,I,n]),N.useEffect(()=>{if(n)return;const y=v.find(F=>String(F.bankAccountDetailId)===ne);if(!y){ne&&(I("bankAccountDetailId",""),I("routingNumber",""),I("accountType",""),I("bankName",""));return}I("routingNumber",y.routingNumber),I("accountType",y.accountType),I("bankName",y.bankName)},[v,ne,I,n]);const At=E(y=>{if(n||!Q)return;const F={statePaymentDetailId:u.current,state:y.state,reasonForPayment:y.reasonForPayment,stateAccountId:y.stateAccountId.trim().toUpperCase(),accountId:y.accountId.trim(),letterId:y.letterId,taxYear:y.taxYear,taxPeriod:y.taxPeriod,taxAmount:y.taxAmount,paymentDate:y.paymentDate,bankAccountDetailId:y.bankAccountDetailId,routingNumber:y.routingNumber,accountType:y.accountType,bankName:y.bankName};ei(F),a("/payments/state/authorization",{state:{from:o,paymentDraft:F}})}),qt=()=>{if(r){r();return}a(o)},Pt=e?Xt(e):"Entity";return s.jsx("form",{onSubmit:At,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:Pt}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(B),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:yl,children:[s.jsx(vl,{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:n||h||f,onClick:()=>{at(""),_e(y=>!y)},className:"flex w-full items-center justify-between rounded-xl border border-slate-200 bg-slate-50/80 px-4 py-4 text-left transition hover:border-gov-300 hover:bg-gov-50/40 disabled:cursor-not-allowed disabled:opacity-70",children:[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(Tv,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:h?"Loading states…":zt??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Yn,{className:`h-4 w-4 text-slate-400 transition ${oe?"rotate-180":""}`})]}),oe?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:it,type:"search",value:Je,onChange:y=>at(y.target.value),onKeyDown:y=>{y.key==="Escape"?_e(!1):y.key==="Enter"&&y.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[pt.map(y=>s.jsxs("button",{type:"button",onClick:()=>jt(y.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${R===y.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:y.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:y.code})]},y.code)),pt.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,P.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:P.state.message}):null,f?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Unable to load states."}):null]}),s.jsx(H,{label:"Reason for Payment",required:!0,error:(Et=P.reasonForPayment)==null?void 0:Et.message,children:s.jsxs(Dr,{children:[s.jsxs("select",{disabled:n||!R||ce||fe,className:Jn(!!P.reasonForPayment),...j("reasonForPayment"),onChange:y=>Mt(y.target.value),children:[s.jsx("option",{value:"",children:ce?"Loading reasons…":"Select reason"}),Y.map(y=>s.jsx("option",{value:y.code,children:y.label},y.code))]}),s.jsx(Yn,{})]})}),fe?s.jsx("p",{className:"text-xs text-red-600",children:"Unable to load payment reasons."}):null,R&&!ce&&!fe&&Y.length===0?s.jsx("p",{className:"text-xs text-slate-500",children:"No supported payment reasons are available for this entity and state."}):null]})]}),s.jsxs("section",{className:`${yl} transition ${be?"":"opacity-60"}`,children:[s.jsx(vl,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!be||n,className:"min-w-0 border-0 p-0",children:[s.jsx(ba,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ga,children:[s.jsx(H,{label:"State ID",required:(Q==null?void 0:Q.stateId.required)??!0,error:(It=P.stateAccountId)==null?void 0:It.message,children:s.jsx("input",{placeholder:(Q==null?void 0:Q.stateId.example)??"Enter ID",maxLength:xe,className:X(!!P.stateAccountId),...Ne,onChange:y=>{y.target.value=te?wv(y.target.value,te):vv(y.target.value,O),Ne.onChange(y)}})}),s.jsx(H,{label:"Account ID",required:(Q==null?void 0:Q.accountIdRequired)??!0,error:(Vt=P.accountId)==null?void 0:Vt.message,children:s.jsx("input",{inputMode:"numeric",placeholder:"10–12 digits",maxLength:12,className:X(!!P.accountId),...ae,onChange:y=>{y.target.value=y.target.value.replace(/\D/g,"").slice(0,12),ae.onChange(y)}})}),s.jsx(H,{label:"Letter ID",required:(Q==null?void 0:Q.letterIdRequired)??!1,children:s.jsx("input",{placeholder:"Alphanumeric",maxLength:50,className:X(),...Me,onChange:y=>{y.target.value=y.target.value.replace(/[^A-Za-z0-9]/g,"").slice(0,50),Me.onChange(y)}})})]}),s.jsxs("div",{className:gl,children:[s.jsx(H,{label:"Tax Year",required:!0,error:(z=P.taxYear)==null?void 0:z.message,children:s.jsxs(Dr,{children:[s.jsxs("select",{className:Jn(!!P.taxYear),...j("taxYear"),children:[s.jsx("option",{value:"",children:"Select TY"}),Se.map(y=>s.jsxs("option",{value:String(y),children:["TY ",y]},y))]}),s.jsx(Yn,{})]})}),s.jsx(H,{label:(Q==null?void 0:Q.periodMode)==="account-assigned"?"Deposit Frequency":"Tax Period",required:!0,error:(de=P.taxPeriod)==null?void 0:de.message,children:s.jsxs(Dr,{children:[s.jsxs("select",{className:Jn(!!P.taxPeriod),...j("taxPeriod"),children:[s.jsx("option",{value:"",children:"Select"}),ue.map(y=>s.jsx("option",{value:y.value,children:y.label},y.value))]}),s.jsx(Yn,{})]})})]})]})}),s.jsx(ba,{title:"Amount Info",children:s.jsxs("div",{className:gl,children:[s.jsx(H,{label:"Tax Amount",required:!0,error:(b=P.taxAmount)==null?void 0:b.message,children:s.jsx(Le,{name:"taxAmount",control:S,render:({field:y})=>s.jsx(Tr,{name:y.name,value:y.value,onChange:y.onChange,onBlur:y.onBlur,disabled:n,hasError:!!P.taxAmount})})}),s.jsx(H,{label:"Payment Date",required:!0,error:(C=P.paymentDate)==null?void 0:C.message,children:s.jsx(Le,{name:"paymentDate",control:S,render:({field:y})=>s.jsx(Eu,{value:y.value,onChange:y.onChange,hasError:!!P.paymentDate,disabled:n})})})]})}),s.jsx(ba,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ga,children:[s.jsx(Le,{name:"bankAccountDetailId",control:S,render:({field:y})=>{var F;return s.jsx(ku,{value:y.value,onChange:y.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:v,isLoading:p,disabled:!e||!be||n,error:(F=P.bankAccountDetailId)==null?void 0:F.message,label:"Account Number"})}}),s.jsx(H,{label:"Routing Number",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:X(!1,!0),...j("routingNumber")})}),s.jsx(H,{label:"Account Type",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:X(!1,!0),...j("accountType")})})]}),s.jsx("div",{className:ga,children:s.jsx(H,{label:"Bank Name",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:X(!1,!0),...j("bankName")})})})]})}),Q!=null&&Q.notes.length?s.jsx("div",{className:"mt-5 rounded-lg bg-amber-50 px-4 py-3 text-xs text-amber-800",children:Q.notes.map(y=>s.jsx("p",{children:y},y))}):null]}),be?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:ke?"Loading payment requirements…":se?"Unable to load payment requirements.":"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:qt,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:n?"Back":"Cancel"}),n?null:s.jsxs("button",{type:"submit",disabled:!e||!be,className:"inline-flex h-11 min-w-[120px] items-center justify-center gap-2 rounded-lg bg-gov-600 px-6 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:["Next",s.jsx(_v,{})]})]})]})})]})},i.key)}function vl({step:e,title:t,className:n=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${n}`,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 ba({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 Tv(){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 _v(){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 qu(){const{selectedEntity:e}=ht();return s.jsx(Mu,{entity:e})}function Dv(e){const t=e.indexOf("-");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function Vu(){var l;const{statePaymentId:e}=Ls(),{selectedEntity:t}=ht(),n=Number.parseInt(e??"",10),{data:r,isLoading:a,isError:i}=ve({queryKey:["state-payments",n],queryFn:()=>pu(n),enabled:t!==null&&Number.isFinite(n)}),o=N.useMemo(()=>{if(!r)return null;const[c,u]=Dv(r.taxPeriod);return{statePaymentDetailId:r.statePaymentDetailId,state:r.state,reasonForPayment:"",stateAccountId:"",accountId:"",taxYear:c,taxPeriod:u,taxAmount:String(r.taxAmount),paymentDate:r.paymentDate,bankAccountDetailId:""}},[r]);return Number.isFinite(n)?a?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!r||!o?s.jsx(Be,{to:Qe(),replace:!0}):!t||r.entityId!==t.entityId?s.jsx(Be,{to:Qe(),replace:!0}):((l=r.status)==null?void 0:l.toLowerCase())!=="draft"?s.jsx(Be,{to:`/payments/state/${n}/view`,replace:!0}):s.jsx(Mu,{entity:t,initialDraft:o}):s.jsx(Be,{to:Qe(),replace:!0})}function Bu(){var l,c;const{statePaymentId:e}=Ls(),t=Ae(),{selectedEntity:n}=ht(),r=Number.parseInt(e??"",10),{data:a,isLoading:i,isError:o}=ve({queryKey:["state-payments",r],queryFn:()=>pu(r),enabled:n!==null&&Number.isFinite(r)});return Number.isFinite(r)?i?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!a?s.jsx(Be,{to:"/payments",replace:!0}):!n||a.entityId!==n.entityId?s.jsx(Be,{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-",a.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:a.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:a.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:Kr(a.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:a.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 ${((l=a.status)==null?void 0:l.toLowerCase())==="paid"?"bg-green-100 text-green-800":((c=a.status)==null?void 0:c.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:a.status??"—"})})]}),a.reason&&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:a.reason})]})]})})]}):s.jsx(Be,{to:"/payments",replace:!0})}const Fv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",Rv="I have reviewed the details and authorize this payment.",Uu=/^[a-zA-Z\s]+$/;function Zu(e){return e.replace(/[^a-zA-Z\s]/g,"")}const to=T().min(1,"Signature is required").regex(Uu,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),Ov=T().optional().refine(e=>!e||!e.trim()||Uu.test(e),{message:"Signature must contain only letters"}),$v=Gt({agreementDate:T().min(1,"Date is required"),agreementAccepted:Kn().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:T().min(1,"Name of authorization person is required"),signature:to,title:T().min(1,"Title is required")}),Lv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ds="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function zv(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function Mv(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function qv({entity:e,paymentDraft:t}){const n=Ae(),r=Ce(),a=ft(),i=Un(r.state,Qe()),[o,l]=N.useState(null),[c,u]=N.useState(!1),d=N.useMemo(()=>Mv(),[]),m=Gr(t.taxAmount),{register:h,handleSubmit:f,watch:x,formState:{errors:p}}=Rt({resolver:$t($v),defaultValues:d}),v=x("agreementDate"),g=x("signature"),k=!!(g!=null&&g.trim()),j=h("signature"),S=async()=>{await a.invalidateQueries({queryKey:["dashboard"]}),await a.invalidateQueries({queryKey:["state-payments"]}),await a.invalidateQueries({queryKey:["remittance-payments"]})},E=async()=>{if(!e)return null;if(t.statePaymentDetailId){const R=await x0(t.statePaymentDetailId,Pv(t));return await S(),R}const P=await p0(Av(e.entityId,t));return ei({...t,statePaymentDetailId:P.statePaymentDetailId}),await S(),P},_=async()=>{e&&(await E(),Lu(),n(Qe()))},I=f(async()=>{if(e){l(null),u(!0);try{await _()}catch(P){l(tt(P,"Failed to save state payment."))}finally{u(!1)}}}),$=f(async()=>{if(e){l(null),u(!0);try{await _()}catch(P){l(tt(P,"Failed to save draft."))}finally{u(!1)}}});return s.jsx("form",{onSubmit:I,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(Xr,{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:Lv,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:`${ds} 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:zv(v)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:Fv}),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:Rv})]}),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:`${ds} 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:`${ds} 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 ${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:P=>{const R=Zu(P.target.value);P.target.value=R,j.onChange(P)}}),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:`${ds} 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(Lt,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{ei(t),n("/payments/state/new",{state:{from:i,paymentDraft:t}})},disabled:c,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:$,disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-gov-300 bg-gov-50 px-6 text-sm font-semibold text-gov-600 transition hover:bg-gov-100 disabled:cursor-not-allowed disabled:opacity-50",children:"Save as Draft"}),s.jsx("button",{type:"submit",disabled:c||!e,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg bg-gov-600 px-8 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-50",children:"Submit Now"})]})]})]})})}function Wu(){const{selectedEntity:e}=ht(),t=Ce(),{paymentDraft:n}=t.state??{},r=n??ti();return r?s.jsx(qv,{entity:e,paymentDraft:r}):s.jsx(Be,{to:"/payments/state/new",replace:!0})}const no="/portal/federal-payments/form-8655-authorizations";function Vv(e){return me(no,{method:"POST",body:e})}function Bv(e){return me(`${no}/by-enrolment/${e}`)}function Uv(e,t){return me(`${no}/${e}`,{method:"PATCH",body:t})}async function Yu(e){try{return await Bv(e)}catch(t){if(t instanceof yr&&t.status===404)return null;throw t}}const ni=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function Zv(e){const t=e.trim();return ni.includes(t)?t:"Other"}const Wv="I understand that this agreement does not relieve me, as the taxpayer, of the responsibility to ensure that all tax returns are filed and that all deposits and payments are made and that I may enroll in the Electronic Federal Tax Payment System (EFTPS) to view deposits and payments made on my behalf.",Yv="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 Hv(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function ri({label:e,required:t=!1,signature:n,title:r,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:u="Signature of taxpayer"}){const d=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:f,ref:x}=n;return 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:x,name:f,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${d?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:d?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:p=>{const v=Zu(p.target.value);p.target.value=v,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",...r}),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:Hv(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 Kv(e){return e.replace(/\D/g,"")}function Hu(e,t){var n,r;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:Kv(t.ein),address:t.address.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),isSeasonalEmployer:t.isSeasonalEmployer,otherIdentificationNumber:((n=t.otherIdentificationNumber)==null?void 0:n.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((r=t.authorizationMonth)==null?void 0:r.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function Qv(e){const{enrollmentId:t,...n}=Hu(0,e);return n}function Jv(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:Bn(e.ein),address:e.address,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,isSeasonalEmployer:e.isSeasonalEmployer,otherIdentificationNumber:e.otherIdentificationNumber??"",contactPerson:e.contactPerson,daytimePhone:Ln(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const Gv=Gt({taxpayerName:T().min(1,"Taxpayer name is required"),tradeName:T().min(1,"Trade name is required"),ein:T().min(1,"EIN is required"),address:T().min(1,"Address is required"),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required"),isSeasonalEmployer:Kn(),otherIdentificationNumber:T().optional(),contactPerson:T().min(1,"Contact person is required"),daytimePhone:T().min(1,"Daytime telephone number is required"),faxNumber:T().default(""),authorizedTaxForm:T().min(1,"Select a tax form"),authorizationMonth:T().optional(),agreementAccepted:Kn().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:to,title:T().min(1,"Title is required"),signatureDate:T().min(1,"Date is required")}),va="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function Xv(e,t){const n=new Date().toISOString().slice(0,10);return{taxpayerName:e?Xt(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.lastName)||(e==null?void 0:e.firstName)||"",ein:e?Bn(e.idNumber):"",address:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"United States",isSeasonalEmployer:!1,otherIdentificationNumber:"",contactPerson:e?`${e.firstName} ${e.lastName}`.trim():"",daytimePhone:e?Ln(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:Zv(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:n}}function ej({entity:e,paymentDraft:t,initialAuthorization:n=null,readonly:r=!1}){var ce,fe,Q,ke,se,Se,ue,be,O,xe,te,Ne,ae,Me;const a=Ae(),i=Ce(),o=ft(),l=Un(i.state,Qe()),c=Gr(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),f=N.useMemo(()=>n?Jv(n):Xv(e,t),[e,n,t]),{register:x,handleSubmit:p,watch:v,setValue:g,reset:k,formState:{errors:j}}=Rt({resolver:$t(Gv),defaultValues:f});N.useEffect(()=>{k(f)},[f,k]);const S=v("authorizedTaxForm"),E=v("signature"),_=v("signatureDate"),I=e?Xt(e):"Entity",$=!0,P=!0,R=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ee=async()=>{if(!e)return null;if(t.federalPaymentId){const _e=await Zi(t.federalPaymentId,Qi(t));return await R(),_e}const oe=await Ui(Ki(e.entityId,t));return Gi({...t,federalPaymentId:oe.federalPaymentId,enrollmentId:oe.enrollmentId}),await R(),oe},B=async(oe,_e)=>{var it;const Je=t.form8655AuthorizationId??((it=await Yu(oe))==null?void 0:it.form8655AuthorizationId),at=_e;return Je?Uv(Je,Qv(at)):Vv(Hu(oe,at))},K=async oe=>{if(!e)return;const _e=await ee();_e&&(await B(_e.enrollmentId,oe),await o.invalidateQueries({queryKey:["form-8655",_e.enrollmentId]}),Xi(),a(Qe()))},ne=p(async oe=>{if(!(!e||r)){d(null),h(!0);try{await K(oe)}catch(_e){d(tt(_e,"Failed to save federal payment draft."))}finally{h(!1)}}}),Y=p(async oe=>{if(!(!e||r)){d(null),h(!0);try{await K(oe)}catch(_e){d(tt(_e,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:ne,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:I}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:va,children:[s.jsx(H,{label:"1. a) Name of the Taxpayer",required:!0,error:(ce=j.taxpayerName)==null?void 0:ce.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:$,className:X(!!j.taxpayerName,$),...x("taxpayerName")})}),s.jsx(H,{label:"1. b) Trade Name, if any",required:!0,error:(fe=j.tradeName)==null?void 0:fe.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:$,className:X(!!j.tradeName,$),...x("tradeName")})}),s.jsx(H,{label:"2. Employer Identification Number (EIN)",required:!0,error:(Q=j.ein)==null?void 0:Q.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:$,className:X(!!j.ein,$),...x("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(H,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(ke=j.address)==null?void 0:ke.message,children:s.jsx("input",{placeholder:"Enter",readOnly:$,className:X(!!j.address,$),...x("address")})})}),s.jsx(H,{label:"3. b) City or Town",required:!0,error:(se=j.city)==null?void 0:se.message,children:s.jsx("input",{placeholder:"Enter",readOnly:$,className:X(!!j.city,$),...x("city")})})]}),s.jsxs("div",{className:`mt-5 ${va}`,children:[s.jsx(H,{label:"3. c) State",required:!0,error:(Se=j.state)==null?void 0:Se.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:$,className:X(!!j.state,$),...x("state")})}),s.jsx(H,{label:"3. d) ZIP Code",required:!0,error:(ue=j.zipCode)==null?void 0:ue.message,children:s.jsx("input",{placeholder:"Enter",readOnly:$,className:X(!!j.zipCode,$),...x("zipCode")})}),s.jsx(H,{label:"3. e) Country",required:!0,error:(be=j.country)==null?void 0:be.message,children:s.jsx("input",{placeholder:"Enter",readOnly:$,className:X(!!j.country,$),...x("country")})})]}),s.jsxs("div",{className:`mt-5 ${va}`,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",...x("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(H,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:$,className:X(!1,$),...x("otherIdentificationNumber")})}),s.jsx(H,{label:"6. Contact Person",required:!0,error:(O=j.contactPerson)==null?void 0:O.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:$,className:X(!!j.contactPerson,$),...x("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(H,{label:"7. Daytime Telephone Number",required:!0,error:(xe=j.daytimePhone)==null?void 0:xe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:$,className:X(!!j.daytimePhone,$),...x("daytimePhone")})}),s.jsx(H,{label:"8. Fax Number",error:(te=j.faxNumber)==null?void 0:te.message,children:s.jsx("input",{placeholder:"Enter number",className:X(!!j.faxNumber),...x("faxNumber")})})]})]}),s.jsxs(wn,{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:ni.slice(0,6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:S===oe,disabled:P,onChange:()=>g("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))}),s.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:ni.slice(6).map(oe=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:oe,checked:S===oe,disabled:P,onChange:()=>g("authorizedTaxForm",oe,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),oe]},oe))})]}),j.authorizedTaxForm?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",...x("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:Wv})," ",Yv]})]}),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(ri,{label:"Taxpayer's Signature",required:!0,signature:x("signature"),title:x("title"),date:x("signatureDate"),signatureValue:E,dateValue:_,errors:{signature:(Ne=j.signature)==null?void 0:Ne.message,title:(ae=j.title)==null?void 0:ae.message,date:(Me=j.signatureDate)==null?void 0:Me.message}})})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Lt,{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||r,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||r,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 Ku(){const{selectedEntity:e}=ht(),t=Ce(),{paymentDraft:n}=t.state??{},r=n??na(),{data:a,isLoading:i}=ve({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Bi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ve({queryKey:["form-8655",o],queryFn:()=>Yu(o),enabled:o!=null}),u=N.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form8655AuthorizationId:r.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[r,o,l]);return r?Hi(e)?s.jsx(Be,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(ej,{entity:e,paymentDraft:u??r,initialAuthorization:l}):s.jsx(Be,{to:"/payments/federal/new",replace:!0})}const ro="/portal/federal-payments/form-9783-enrollments";function tj(e){return me(ro,{method:"POST",body:e})}function nj(e){return me(`${ro}/by-enrolment/${e}`)}function rj(e,t){return me(`${ro}/${e}`,{method:"PATCH",body:t})}async function Qu(e){try{return await nj(e)}catch(t){if(t instanceof yr&&t.status===404)return null;throw t}}const sj="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.",aj="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.",ij="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.",ja=new Date().getFullYear(),oj=[String(ja-1),String(ja-2),String(ja-3)];function ms(e){return e.replace(/\D/g,"")}function Ju(e,t){var n,r,a,i;return{enrollmentId:e,primarySsn:ms(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ms(t.jointFilerSsn):null,taxpayerNames:t.taxpayerNames.trim(),primaryAddress:t.primaryAddress.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),internationalAddress:((n=t.internationalAddress)==null?void 0:n.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((r=t.contactInternationalAddress)==null?void 0:r.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:ms(t.financialPrimarySsn),routingTransitNumber:ms(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 lj(e){const{enrollmentId:t,...n}=Ju(0,e);return n}function cj(e){var n;const t=((n=e.accountType)==null?void 0:n.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:Ln(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:Ln(e.contactPhone),contactInternationalAddress:e.contactInternationalAddress??"",primaryTaxpayerPin:e.primaryTaxpayerPin??"",dateOfBirth:e.dateOfBirth??"",priorYearAgi:e.priorYearAgi!==null&&e.priorYearAgi!==void 0?String(e.priorYearAgi):"",agiTaxYear:e.agiTaxYear??"",financialPrimarySsn:e.financialPrimarySsn,routingTransitNumber:e.routingTransitNumber,accountNumber:e.accountNumber,accountType:t,disclosureAgreementOne:e.disclosureAgreementOne,disclosureAgreementTwo:e.disclosureAgreementTwo,authorityAgreement:e.authorityAgreement,taxpayerSignature:e.taxpayerSignature??"",taxpayerTitle:e.taxpayerTitle,taxpayerSignatureDate:e.taxpayerSignatureDate,jointFilerSignature:e.jointFilerSignature??"",jointFilerTitle:e.jointFilerTitle??"",jointFilerSignatureDate:e.jointFilerSignatureDate??""}}const uj=Gt({primarySsn:T().min(1,"Primary SSN is required"),jointFilerSsn:T().optional(),taxpayerNames:T().min(1,"Taxpayer name is required"),primaryAddress:T().min(1,"Primary address is required"),city:T().min(1,"City is required"),state:T().min(1,"State is required"),zipCode:T().min(1,"ZIP code is required"),country:T().min(1,"Country is required"),internationalAddress:T().optional(),primaryPhone:T().min(1,"Primary phone number is required"),primaryContactName:T().min(1,"Primary contact name is required"),primaryContactAddress:T().min(1,"Primary contact address is required"),contactCity:T().min(1,"Contact city is required"),contactState:T().min(1,"Contact state is required"),contactZipCode:T().min(1,"Contact ZIP code is required"),contactCountry:T().min(1,"Contact country is required"),contactPhone:T().min(1,"Contact phone number is required"),contactInternationalAddress:T().optional(),primaryTaxpayerPin:T().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:T().min(1,"Date of birth is required").refine(e=>O0(e,Gu),{message:"You must be at least 18 years old"}),priorYearAgi:T().min(1,"Prior year adjusted gross income is required").refine(e=>!Number.isNaN(Number(e))&&Number(e)>=0,{message:"Enter a valid amount"}),agiTaxYear:T().min(1,"Prior tax year is required"),financialPrimarySsn:T().min(1,"Primary SSN is required"),routingTransitNumber:T().min(1,"Routing transit number is required"),accountNumber:T().min(1,"Account number is required"),accountType:su([ua("Checking"),ua("Savings"),ua("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Kn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Kn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Kn().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:to,taxpayerTitle:T().min(1,"Title is required"),taxpayerSignatureDate:T().min(1,"Date is required"),jointFilerSignature:Ov,jointFilerTitle:T().optional(),jointFilerSignatureDate:T().optional()}),vn="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",dj="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",mj=5,Gu=18;function Xu(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function ed(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:Xu(t.accountType)}}function hj(e,t){const n=new Date().toISOString().slice(0,10),r=e?Xt(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:r,primaryAddress:(e==null?void 0:e.address1)??"",city:(e==null?void 0:e.city)??"",state:(e==null?void 0:e.state)??"",zipCode:(e==null?void 0:e.zipCode)??"",country:(e==null?void 0:e.country)??"US",internationalAddress:"",primaryPhone:e?Ln(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...ed(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:n,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:n}}function fj({entity:e,paymentDraft:t,initialEnrollment:n=null,readonly:r=!1}){var at,it,zt,pt,vt,xt,jt,Mt,At,qt,Pt,Nt,Et,It,Vt,z,de,b,C,y,F,L,Z,M,W;const a=Ae(),i=Ce(),o=ft(),l=Un(i.state,Qe()),c=Gr(t.paymentAmount),[u,d]=N.useState(null),[m,h]=N.useState(!1),[f,x]=N.useState(!1),{data:p=[]}=ve({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:(e==null?void 0:e.entityId)!=null}),v=N.useMemo(()=>{if(n)return cj(n);const q=p.find(qe=>String(qe.bankAccountDetailId)===t.bankAccountDetailId),ie=ed(e,t);return{...hj(e,t),financialPrimarySsn:ie.financialPrimarySsn,routingTransitNumber:ie.routingTransitNumber||(q==null?void 0:q.routingNumber)||"",accountNumber:ie.accountNumber||(q==null?void 0:q.accountNumber)||"",accountType:Xu(t.accountType||(q==null?void 0:q.accountType))}},[e,n,t,p]),{register:g,handleSubmit:k,watch:j,setValue:S,reset:E,control:_,formState:{errors:I}}=Rt({resolver:$t(uj),defaultValues:v});N.useEffect(()=>{E(v)},[v,E]);const $=j("taxpayerSignature"),P=j("jointFilerSignature"),R=j("taxpayerSignatureDate"),ee=j("jointFilerSignatureDate"),B=j("accountType"),K=j("taxpayerNames"),ne=j("primaryAddress"),Y=j("city"),ce=j("state"),fe=j("zipCode"),Q=j("country"),ke=j("primaryPhone"),se=j("internationalAddress"),Se=e?Xt(e):"Entity",ue=!0,be=!0,O=N.useMemo(()=>R0(Gu),[]),xe=()=>{S("primaryContactName",K,{shouldValidate:!0}),S("primaryContactAddress",ne,{shouldValidate:!0}),S("contactCity",Y,{shouldValidate:!0}),S("contactState",ce,{shouldValidate:!0}),S("contactZipCode",fe,{shouldValidate:!0}),S("contactCountry",Q,{shouldValidate:!0}),S("contactPhone",ke,{shouldValidate:!0}),S("contactInternationalAddress",se??"",{shouldValidate:!0})},te=()=>{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&&xe()},[f,K,ne,Y,ce,fe,Q,ke,se]);const Ne=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ae=async()=>{if(!e)return null;if(t.federalPaymentId){const ie=await Zi(t.federalPaymentId,Qi(t));return await Ne(),ie}const q=await Ui(Ki(e.entityId,t));return Gi({...t,federalPaymentId:q.federalPaymentId,enrollmentId:q.enrollmentId}),await Ne(),q},Me=async(q,ie)=>{var Bt;const qe=t.form9783EnrollmentId??((Bt=await Qu(q))==null?void 0:Bt.form9783EnrollmentId);return qe?rj(qe,lj(ie)):tj(Ju(q,ie))},oe=async q=>{if(!e)return;const ie=await ae();ie&&(await Me(ie.enrollmentId,q),await o.invalidateQueries({queryKey:["form-9783",ie.enrollmentId]}),Xi(),a(Qe()))},_e=k(async q=>{if(!(!e||r)){d(null),h(!0);try{await oe(q)}catch(ie){d(tt(ie,"Failed to save federal payment draft."))}finally{h(!1)}}}),Je=k(async q=>{if(!(!e||r)){d(null),h(!0);try{await oe(q)}catch(ie){d(tt(ie,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:_e,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:Se}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs(wn,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:vn,children:[s.jsx(H,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(at=I.primarySsn)==null?void 0:at.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ue,className:X(!!I.primarySsn,ue),...g("primarySsn")})}),s.jsx(H,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:ue,className:X(!1,ue),...g("jointFilerSsn")})}),s.jsx(H,{label:"2. Taxpayer(S) name(S)",required:!0,error:(it=I.taxpayerNames)==null?void 0:it.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ue,className:X(!!I.taxpayerNames,ue),...g("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${vn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(H,{label:"3. a) Primary taxpayer address",required:!0,error:(zt=I.primaryAddress)==null?void 0:zt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:X(!!I.primaryAddress,ue),...g("primaryAddress")})})}),s.jsx(H,{label:"3. b) City or Town",required:!0,error:(pt=I.city)==null?void 0:pt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:X(!!I.city,ue),...g("city")})})]}),s.jsxs("div",{className:`mt-5 ${vn}`,children:[s.jsx(H,{label:"3. c) State",required:!0,error:(vt=I.state)==null?void 0:vt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ue,className:X(!!I.state,ue),...g("state")})}),s.jsx(H,{label:"3. d) ZIP code",required:!0,error:(xt=I.zipCode)==null?void 0:xt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:X(!!I.zipCode,ue),...g("zipCode")})}),s.jsx(H,{label:"3. e) Country",required:!0,error:(jt=I.country)==null?void 0:jt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:X(!!I.country,ue),...g("country")})})]}),s.jsxs("div",{className:`mt-5 ${vn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(H,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:ue,className:X(!1,ue),...g("internationalAddress")})})}),s.jsx(H,{label:"4. Primary taxpayer phone number",required:!0,error:(Mt=I.primaryPhone)==null?void 0:Mt.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ue,className:X(!!I.primaryPhone,ue),...g("primaryPhone")})})]})]}),s.jsxs(wn,{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:r,onChange:q=>{const ie=q.target.checked;x(ie),ie?xe():te()},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:vn,children:[s.jsx(H,{label:"5. Primary contact name",required:!0,error:(At=I.primaryContactName)==null?void 0:At.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:f,className:X(!!I.primaryContactName,f),...g("primaryContactName")})}),s.jsx(H,{label:"6. a) Primary contact address",required:!0,error:(qt=I.primaryContactAddress)==null?void 0:qt.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:f,className:X(!!I.primaryContactAddress,f),...g("primaryContactAddress")})}),s.jsx(H,{label:"6. b) City or Town",required:!0,error:(Pt=I.contactCity)==null?void 0:Pt.message,children:s.jsx("input",{placeholder:"City",readOnly:f,className:X(!!I.contactCity,f),...g("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${vn}`,children:[s.jsx(H,{label:"6. c) State",required:!0,error:(Nt=I.contactState)==null?void 0:Nt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:f,className:X(!!I.contactState,f),...g("contactState")})}),s.jsx(H,{label:"6. d) ZIP code",required:!0,error:(Et=I.contactZipCode)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:f,className:X(!!I.contactZipCode,f),...g("contactZipCode")})}),s.jsx(H,{label:"6. f) Country",required:!0,error:(It=I.contactCountry)==null?void 0:It.message,children:s.jsx("input",{placeholder:"Country",readOnly:f,className:X(!!I.contactCountry,f),...g("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(H,{label:"7. Primary taxpayer phone number",required:!0,error:(Vt=I.contactPhone)==null?void 0:Vt.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:X(!!I.contactPhone,f),...g("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(H,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:X(!1,f),...g("contactInternationalAddress")})})})]})]}),s.jsx(wn,{title:"Taxpayer Details *",children:s.jsxs("div",{className:dj,children:[s.jsx(H,{label:"1. Primary Taxpayer Pin",required:!0,error:(z=I.primaryTaxpayerPin)==null?void 0:z.message,children:s.jsx(Le,{name:"primaryTaxpayerPin",control:_,render:({field:q})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:X(!!I.primaryTaxpayerPin),value:q.value,onChange:ie=>q.onChange(Qn(ie.target.value,mj)),onBlur:q.onBlur})})}),s.jsx(H,{label:"2. Date of Birth",required:!0,error:(de=I.dateOfBirth)==null?void 0:de.message,children:s.jsx("input",{type:"date",max:O,className:X(!!I.dateOfBirth),...g("dateOfBirth")})}),s.jsx(H,{label:"3. Prior year adjusted gross income",required:!0,error:(b=I.priorYearAgi)==null?void 0:b.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:X(!!I.priorYearAgi),...g("priorYearAgi")})}),s.jsx(H,{label:"4. Prior Tax Year",required:!0,error:(C=I.agiTaxYear)==null?void 0:C.message,children:s.jsxs("select",{className:Jn(!!I.agiTaxYear),...g("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),oj.map(q=>s.jsx("option",{value:q,children:q},q))]})})]})}),s.jsxs(wn,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:vn,children:[s.jsx(H,{label:"9. Primary SSN",required:!0,error:(y=I.financialPrimarySsn)==null?void 0:y.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:be,className:X(!!I.financialPrimarySsn,be),...g("financialPrimarySsn")})}),s.jsx(H,{label:"10. Routing Transit Number (RTN)",required:!0,error:(F=I.routingTransitNumber)==null?void 0:F.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:be,className:X(!!I.routingTransitNumber,be),...g("routingTransitNumber")})}),s.jsx(H,{label:"11. Account Number",required:!0,error:(L=I.accountNumber)==null?void 0:L.message,children:s.jsx("input",{placeholder:"Enter",readOnly:be,className:X(!!I.accountNumber,be),...g("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(q=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:q,checked:B===q,disabled:be,onChange:()=>S("accountType",q,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),q]},q))}),I.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:I.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",...g("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:sj})]}),I.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:I.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",...g("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:aj})]}),I.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:I.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",...g("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:ij})]}),I.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:I.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(ri,{label:"Taxpayer's Signature",required:!0,signature:g("taxpayerSignature"),title:g("taxpayerTitle"),date:g("taxpayerSignatureDate"),signatureValue:$,dateValue:R,errors:{signature:(Z=I.taxpayerSignature)==null?void 0:Z.message,title:(M=I.taxpayerTitle)==null?void 0:M.message,date:(W=I.taxpayerSignatureDate)==null?void 0:W.message}}),s.jsx(ri,{label:"Joint filer(s) Signature (Optional)",signature:g("jointFilerSignature"),title:g("jointFilerTitle"),date:g("jointFilerSignatureDate"),signatureValue:P??"",dateValue:ee??"",signatureCaption:"Signature of joint filer"})]})]})})]}),u?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(Lt,{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:Je,disabled:m||!e||r,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||r,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 td(){const{selectedEntity:e}=ht(),t=Ce(),{paymentDraft:n}=t.state??{},r=n??na(),{data:a,isLoading:i}=ve({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Bi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=ve({queryKey:["form-9783",o],queryFn:()=>Qu(o),enabled:o!=null}),u=N.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form9783EnrollmentId:r.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[r,o,l]);return r?e&&!Hi(e)?s.jsx(Be,{to:"/payments/federal/authorization",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(fj,{entity:e,paymentDraft:u??r,initialEnrollment:l}):s.jsx(Be,{to:"/payments/federal/new",replace:!0})}function pj(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function xj({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 gj({status:e}){const t=e.toLowerCase();let n="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?n="bg-orange-50 text-orange-700":t.includes("irs accepted")?n="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?n="bg-red-50 text-red-600":t.includes("pending")&&(n="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n}`,children:e})}function yj({forms:e=[],isLoading:t=!1,isError:n=!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…"})}):n?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(r=>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(bj,{className:"h-4 w-4"})}),r.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(xj,{type:r.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:r.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(gj,{status:r.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:pj(r.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"}),r.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]})})]},r.taxFormId))})]})})})}function bj({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 vj(){return s.jsx(yj,{})}const jl=160,jj=88,hs=8;function Nj({account:e,entityId:t,onEdit:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),o=N.useRef(null),l=N.useRef(null),[c,u]=N.useState(!1),[d,m]=N.useState(!1),[h,f]=N.useState({}),x=()=>{var E;const v=o.current;if(!v)return;const g=v.getBoundingClientRect(),k=((E=l.current)==null?void 0:E.offsetHeight)??jj,S=window.innerHeight-g.bottom<k+hs;f({position:"fixed",top:S?g.top-k-hs:g.bottom+hs,left:Math.max(hs,g.right-jl),width:jl,zIndex:50})};N.useLayoutEffect(()=>{c&&(x(),requestAnimationFrame(x))},[c]),N.useEffect(()=>{if(!c)return;const v=k=>{var S,E;const j=k.target;(S=o.current)!=null&&S.contains(j)||(E=l.current)!=null&&E.contains(j)||u(!1)},g=()=>x();return document.addEventListener("mousedown",v),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",v),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[c]);const p=async()=>{const v=jr(e);m(!0);try{await gu(e.bankAccountDetailId,{status:mv(e)}),await r.invalidateQueries({queryKey:["bank-accounts",t]}),u(!1),v?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(g){i("Action Not Completed",tt(g,"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(v=>!v),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(wj,{})]}),c?Br.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),n(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:hv(e)})]}),document.body):null]})}function wj(){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 nd=["Checking","Savings"],Sj=Gt({accountNumber:T().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${mr} digits`),routingNumber:T().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Gs(nd,{message:"Account type is required"}),bankName:T().min(1,"Bank name is required")});function kj({open:e,account:t,onClose:n}){const r=ft(),{showSuccess:a,showError:i}=Vs(),[o,l]=N.useState(null),[c,u]=N.useState(!1),{control:d,handleSubmit:m,reset:h,formState:{errors:f}}=Rt({resolver:$t(Sj),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=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,n]);const x=m(async p=>{if(t){l(null),u(!0);try{await gu(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await r.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),n()}catch(v){const g=tt(v,"Unable to update bank account.");l(g),i("Action Not Completed",g)}finally{u(!1)}}});return!e||!t?null:Br.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:n}),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(),x(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(Lt,{message:o})}):null,s.jsxs(gn,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(Le,{name:"accountNumber",control:d,render:({field:p})=>{var v;return s.jsx(pe,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:g=>p.onChange(Qn(g.target.value,mr)),onBlur:p.onBlur,error:(v=f.accountNumber)==null?void 0:v.message})}}),s.jsx(Le,{name:"routingNumber",control:d,render:({field:p})=>{var v;return s.jsx(pe,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:g=>p.onChange(Qn(g.target.value,yu)),onBlur:p.onBlur,error:(v=f.routingNumber)==null?void 0:v.message})}}),s.jsx(Le,{name:"accountType",control:d,render:({field:p})=>{var v;return s.jsx(xn,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(v=f.accountType)==null?void 0:v.message,children:nd.map(g=>s.jsx("option",{value:g,children:g},g))})}})]}),s.jsx(Le,{name:"bankName",control:d,render:({field:p})=>{var v;return s.jsx(pe,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(v=f.bankName)==null?void 0:v.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:n,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),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 zn=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Cj},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:Aj},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Pj},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Ej}];function Cj({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 Aj({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 Pj({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 Ej({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 hr({title:e,subtitle:t,icon:n,action:r}){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(n,{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})]})]}),r]})}function Ij(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Tj({status:e}){const t=jr({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 _j({entityId:e}){const[t,n]=N.useState(!1),[r,a]=N.useState(null),[i,o]=N.useState(1),[l,c]=N.useState(st),u=zn.find(k=>k.id==="bank-accounts"),d=u.icon;N.useEffect(()=>{o(1)},[e,l]);const{data:m,isLoading:h,isError:f,isFetching:x}=ve({queryKey:["bank-accounts",e,i,l],queryFn:()=>Jr({entityId:e,pageNumber:i,pageSize:l}),enabled:e!==null,placeholderData:k=>k}),p=(m==null?void 0:m.items)??[],v=(m==null?void 0:m.totalCount)??0,g=e!==null&&x;return s.jsxs("div",{children:[s.jsx(hr,{title:u.title,subtitle:u.subtitle,icon:d,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>n(!0),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(Dj,{}),"Add Bank Account"]})}),s.jsx(vu,{open:t,entityId:e,onClose:()=>n(!1)}),s.jsx(kj,{open:r!==null,account:r,onClose:()=>a(null)}),s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[g?s.jsx(vr,{label:"Loading bank accounts…"}):null,s.jsx("div",{className:"overflow-x-auto",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:h&&!m?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):f?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?p.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."})}):p.map(k=>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:k.bankName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Ij(k.accountNumber)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:k.routingNumber}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:k.accountType}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Tj,{status:k.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx(Nj,{account:k,entityId:e,onEdit:a})})]},k.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."})})})]})}),e!==null?s.jsx(Qr,{page:i,pageSize:l,totalCount:v,onPageChange:o,onPageSizeChange:c,disabled:h||x}):null]})]})}function Dj(){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 Fj({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 Pr({label:e,value:t,icon:n}){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(Fj,{icon:n})}),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 Oj({entity:e}){const[t,n]=N.useState(!1),r=zn.find(c=>c.id==="entity-details"),a=r.icon;if(!e)return s.jsxs("div",{children:[s.jsx(hr,{title:r.title,subtitle:r.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=Xt(e),o=e.accountType==="Business"?i:`${e.firstName} ${e.lastName}`.trim()||i,l=$i(o);return s.jsxs("div",{children:[s.jsx(hr,{title:r.title,subtitle:r.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>n(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),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(Pr,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(Pr,{label:"Tax ID",value:Bn(e.idNumber),icon:"tax"}),s.jsx(Pr,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(Pr,{label:"Phone Number",value:Ln(e.phoneNumber),icon:"phone"}),s.jsx(Pr,{label:"Account Type",value:Rj(e.accountType),icon:"account"})]}),s.jsx(fu,{open:t,entity:e,onClose:()=>n(!1)})]})}function rd({activeSection:e,onSectionChange:t,items:n}){return s.jsx("nav",{className:"space-y-2",children:n.map(r=>{const a=e===r.id,i=r.icon;return s.jsxs("button",{type:"button",onClick:()=>t(r.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:r.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:r.subtitle})]}),s.jsx($j,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},r.id)})})}function $j({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 Lj({entityId:e}){const t=zn.find(r=>r.id==="payment-history"),n=t.icon;return s.jsxs("div",{children:[s.jsx(hr,{title:t.title,subtitle:t.subtitle,icon:n,action:s.jsxs("button",{type:"button",disabled:!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(zj,{}),"Export to Excel"]})}),s.jsx("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:s.jsx("div",{className:"overflow-x-auto",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:e?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."})}):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 zj(){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 Mj({entityId:e,pageNumber:t=1,pageSize:n=st}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return me(`/portal/tax-accounts?${r}`)}function qj(e){return me(`/portal/tax-accounts/${e}`)}function Vj(e){return me("/portal/tax-accounts",{method:"POST",body:e})}function Bj(e,t){return me(`/portal/tax-accounts/${e}`,{method:"PATCH",body:t})}function Uj({entityId:e}){const t=Ae(),n=zn.find(f=>f.id==="tax-accounts"),r=n.icon,[a,i]=N.useState(1),[o,l]=N.useState(st);N.useEffect(()=>{i(1)},[e,o]);const{data:c,isLoading:u,isError:d}=ve({queryKey:["tax-accounts",e,a,o],queryFn:()=>Mj({entityId:e,pageNumber:a,pageSize:o}),enabled:e!==null}),m=(c==null?void 0:c.items)??[],h=(c==null?void 0:c.totalCount)??0;return s.jsxs("div",{children:[s.jsx(hr,{title:n.title,subtitle:n.subtitle,icon:r,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>t("/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(Zj,{}),"Add Tax Account"]})}),s.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:[s.jsx("div",{className:"overflow-x-auto",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:"Actions"})]})}),s.jsx("tbody",{children:e===null?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."})}):u?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):d?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."})}):h===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."})}):m.map(f=>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:f.state}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.taxAccountDetailId}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.status}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.state}),s.jsx("td",{className:"px-5 py-4",children:s.jsx("button",{type:"button",onClick:()=>t(`/settings/tax-accounts/${f.taxAccountDetailId}/edit`),className:"rounded-md px-2.5 py-1.5 text-sm font-medium text-gov-600 transition hover:bg-gov-50 hover:text-gov-700",children:"Edit"})})]},f.taxAccountDetailId))})]})}),e!==null?s.jsx(Qr,{page:a,pageSize:o,totalCount:h,onPageChange:i,onPageSizeChange:l,disabled:u}):null]})]})}function Zj(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const Nl="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 so(){const{selectedEntity:e}=ht(),n=Ce().state,[r,a]=N.useState(Wj(n==null?void 0:n.section)?n.section:"bank-accounts");return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Nl} p-3`,children:s.jsx(rd,{items:zn,activeSection:r,onSectionChange:a})}),s.jsx("div",{className:`${Nl} p-6 lg:p-8`,children:r==="bank-accounts"?s.jsx(_j,{entityId:(e==null?void 0:e.entityId)??null}):r==="tax-accounts"?s.jsx(Uj,{entityId:(e==null?void 0:e.entityId)??null}):r==="payment-history"?s.jsx(Lj,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(Oj,{entity:e})})]})}function Yj({label:e,value:t,onChange:n,options:r,required:a=!1,disabled:i=!1,error:o,placeholder:l="Select a state"}){var k;const[c,u]=N.useState(!1),[d,m]=N.useState(""),h=N.useRef(null),f=N.useRef(null),x=N.useId(),p=(k=r.find(j=>j.code===t))==null?void 0:k.name,v=N.useMemo(()=>{const j=d.trim().toLowerCase();return j?r.filter(S=>S.name.toLowerCase().includes(j)||S.code.toLowerCase().includes(j)):r},[d,r]);N.useEffect(()=>{var j;c&&((j=f.current)==null||j.focus())},[c]),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 g=j=>{n(j),m(""),u(!1)};return s.jsxs("div",{ref:h,className:"relative",children:[s.jsx($n,{label:e,required:a,htmlFor:x}),s.jsxs("button",{id:x,type:"button",disabled:i,onClick:()=>{m(""),u(j=>!j)},className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${o?"border-red-300":"border-slate-200 focus:border-gov-400"}`,children:[s.jsx("span",{className:p?"text-slate-900":"text-slate-400",children:p??l}),s.jsx(Hj,{open:c})]}),c?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:f,type:"search",value:d,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Escape"?u(!1):j.key==="Enter"&&j.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[v.map(j=>s.jsxs("button",{type:"button",onClick:()=>g(j.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${t===j.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:j.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:j.code})]},j.code)),v.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,o?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o}):null]})}function Hj({open:e}){return s.jsx("svg",{className:`h-4 w-4 shrink-0 text-slate-400 transition ${e?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}const Kj=Li.map(e=>({code:e,name:ib[e]??e})),Qj=[{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}],Gj=Gt({state:T().min(1,"State is required"),city:T().min(1,"City is required"),zipCode:T().min(1,"ZIP code is required"),address1:T().min(1,"Address Line 1 is required"),address2:T().optional(),virginiaTaxAccountId:T().optional(),virginiaWithholdingAccountingId:T().optional(),unemploymentTaxAccountId:T().optional(),virginiaDepartmentOfTaxationClientNumber:T().optional(),businessLocationCode:T().optional(),franchiseTaxAccount:T().optional(),transientOccupancyTaxAccountId:T().optional(),certificateOfAuthorityNumber:T().optional(),licensedProfessionalEmployerEntityNumber:T().optional()}),Xj=Gj.superRefine((e,t)=>{if(e.state!=="VA")return;const n=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const r of n){const a=e[r.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:nn.custom,message:`${r.label} is required`,path:[r.key]})}}),eN={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function tN(e){const t=e.virginia;return{state:e.state,city:e.city,zipCode:e.zipCode,address1:e.address1,address2:e.address2??"",virginiaTaxAccountId:(t==null?void 0:t.virginiaTaxAccountId)??"",virginiaWithholdingAccountingId:(t==null?void 0:t.virginiaWithholdingAccountingId)??"",unemploymentTaxAccountId:(t==null?void 0:t.unemploymentTaxAccountId)??"",virginiaDepartmentOfTaxationClientNumber:(t==null?void 0:t.virginiaDepartmentOfTaxationClientNumber)??"",businessLocationCode:(t==null?void 0:t.businessLocationCode)??"",franchiseTaxAccount:(t==null?void 0:t.franchiseTaxAccount)??"",transientOccupancyTaxAccountId:(t==null?void 0:t.transientOccupancyTaxAccountId)??"",certificateOfAuthorityNumber:(t==null?void 0:t.certificateOfAuthorityNumber)??"",licensedProfessionalEmployerEntityNumber:(t==null?void 0:t.licensedProfessionalEmployerEntityNumber)??""}}const ys=e=>{const t=e==null?void 0:e.trim();return t||null};function nN(e){var t,n,r,a,i,o;if(e.state==="VA")return{virginiaTaxAccountId:((t=e.virginiaTaxAccountId)==null?void 0:t.trim())??"",virginiaWithholdingAccountingId:((n=e.virginiaWithholdingAccountingId)==null?void 0:n.trim())??"",unemploymentTaxAccountId:((r=e.unemploymentTaxAccountId)==null?void 0:r.trim())??"",virginiaDepartmentOfTaxationClientNumber:((a=e.virginiaDepartmentOfTaxationClientNumber)==null?void 0:a.trim())??"",businessLocationCode:((i=e.businessLocationCode)==null?void 0:i.trim())??"",franchiseTaxAccount:((o=e.franchiseTaxAccount)==null?void 0:o.trim())??"",transientOccupancyTaxAccountId:ys(e.transientOccupancyTaxAccountId),certificateOfAuthorityNumber:ys(e.certificateOfAuthorityNumber),licensedProfessionalEmployerEntityNumber:ys(e.licensedProfessionalEmployerEntityNumber)}}function rN({entityId:e,taxAccountDetailId:t,initialValues:n,onCancel:r,onSuccess:a}){var S,E,_,I,$;const{showSuccess:i}=Vs(),o=ft(),l=t!=null,[c,u]=N.useState(null),[d,m]=N.useState(!1),{register:h,handleSubmit:f,watch:x,setValue:p,formState:{errors:v}}=Rt({resolver:$t(Xj),defaultValues:n??eN}),g=x("state"),k=g==="VA",j=f(async P=>{u(null),m(!0);try{const R={state:P.state,city:P.city.trim(),zipCode:P.zipCode.trim(),address1:P.address1.trim(),address2:ys(P.address2),virginia:nN(P)};if(l)await Bj(t,R);else{const ee={entityId:e,...R};await Vj(ee)}await o.invalidateQueries({queryKey:["tax-accounts",e]}),i(l?"Tax Account Updated":"Tax Account Added",l?"Tax account details were updated successfully.":"Tax account was created successfully."),a==null||a()}catch(R){u(tt(R,"Unable to save tax account. Please try again."))}finally{m(!1)}});return s.jsxs("form",{onSubmit:j,noValidate:!0,className:"space-y-8",children:[c?s.jsx(Lt,{message:c}):null,s.jsx(gn,{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.jsx(Yj,{label:"Select State",required:!0,value:g,onChange:P=>p("state",P,{shouldValidate:!0}),options:Kj,error:(S=v.state)==null?void 0:S.message}),s.jsx(pe,{label:"City",required:!0,placeholder:"Enter",error:(E=v.city)==null?void 0:E.message,...h("city")})]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:s.jsx(pe,{label:"Zip Code",required:!0,placeholder:"Enter",error:(_=v.zipCode)==null?void 0:_.message,...h("zipCode")})}),s.jsx(pe,{label:"Address Line 1",required:!0,placeholder:"Enter",error:(I=v.address1)==null?void 0:I.message,...h("address1")}),s.jsx(pe,{label:"Address Line 2",placeholder:"Enter",error:($=v.address2)==null?void 0:$.message,...h("address2")})]})}),k?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-slate-200"}),s.jsxs(gn,{title:"VIRGINIA STATE SPECIFIC INFORMATION",muted:!0,children:[s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:Qj.map(P=>{var R;return s.jsx(pe,{label:P.label,required:P.required,placeholder:"Enter",error:(R=v[P.name])==null?void 0:R.message,...h(P.name)},P.name)})}),s.jsx("div",{className:"mt-5 space-y-5",children:Jj.map(P=>{var R;return s.jsx(pe,{label:P.label,required:P.required,placeholder:"Enter",error:(R=v[P.name])==null?void 0:R.message,...h(P.name)},P.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:r,disabled:d,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:d,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:d?"Saving…":"Save"})]})]})}const Na="rounded-2xl border border-slate-200 bg-white shadow-sm";function fr(){const e=Ae(),{selectedEntity:t}=ht(),n=Ls(),r=n.taxAccountDetailId?Number(n.taxAccountDetailId):void 0,a=r!=null,i=zn.find(m=>m.id==="tax-accounts"),o=i.icon,l=(m="tax-accounts")=>{e("/settings",{state:{section:m}})},{data:c,isLoading:u,isError:d}=ve({queryKey:["tax-account",r],queryFn:()=>qj(r),enabled:a});return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Na} p-3`,children:s.jsx(rd,{items:zn,activeSection:"tax-accounts",onSectionChange:l})}),s.jsxs("div",{className:`${Na} p-6 lg:p-8`,children:[s.jsx(hr,{title:a?"Edit Tax Account":i.title,subtitle:i.subtitle,icon:o}),a&&u?s.jsx("p",{className:"text-sm text-slate-500",children:"Loading tax account…"}):a&&(d||!c)?s.jsx(Lt,{message:"Unable to load this tax account. Please try again."}):s.jsx(rN,{entityId:t.entityId,taxAccountDetailId:r,initialValues:c?tN(c):void 0,onCancel:()=>l("tax-accounts"),onSuccess:()=>l("tax-accounts")})]})]}):s.jsx("div",{className:Na+" 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 sN({paymentsMode:e="all"}){return s.jsxs(ui,{children:[s.jsx(G,{index:!0,element:s.jsx(vi,{})}),s.jsx(G,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(G,{path:"create-entity/form",element:s.jsx(zi,{})}),s.jsxs(G,{element:s.jsx(ji,{}),children:[s.jsx(G,{path:"entities",element:s.jsx(Vi,{})}),s.jsx(G,{path:"dashboard",element:s.jsx(qi,{})}),s.jsx(G,{path:"payments",element:s.jsx(Wi,{paymentsMode:e})}),s.jsx(G,{path:"payments/federal/new",element:s.jsx(Du,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Ru,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Ou,{})}),s.jsx(G,{path:"payments/state/new",element:s.jsx(qu,{})}),s.jsx(G,{path:"payments/state/:statePaymentDetailId/edit",element:s.jsx(Vu,{})}),s.jsx(G,{path:"payments/state/:statePaymentDetailId/view",element:s.jsx(Bu,{})}),s.jsx(G,{path:"payments/state/authorization",element:s.jsx(Wu,{})}),s.jsx(G,{path:"payments/federal/authorization",element:s.jsx(Ku,{})}),s.jsx(G,{path:"payments/federal/individual-enrollment",element:s.jsx(td,{})}),s.jsx(G,{path:"tax-forms",element:s.jsx(vj,{})}),s.jsx(G,{path:"settings",element:s.jsx(so,{})}),s.jsx(G,{path:"settings/tax-accounts/new",element:s.jsx(fr,{})}),s.jsx(G,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(fr,{})})]}),s.jsx(G,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})}const si="tax-remittance:payment-complete",aN=N.forwardRef(function(t,n){const r=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(si,{detail:{paymentId:i}}))}})),s.jsx(bi,{...t,navigateFnRef:r,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:s.jsx(sN,{paymentsMode:"all"})})}),iN=N.forwardRef(function(t,n){const r=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,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(bi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(ui,{children:[s.jsx(G,{index:!0,element:s.jsx(vi,{})}),s.jsx(G,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(G,{path:"create-entity/form",element:s.jsx(zi,{})}),s.jsxs(G,{element:s.jsx(ji,{}),children:[s.jsx(G,{path:"entities",element:s.jsx(Vi,{})}),s.jsx(G,{path:"dashboard",element:s.jsx(qi,{})}),s.jsx(G,{path:"payments",element:s.jsx(Wi,{paymentsMode:"federal"})}),s.jsx(G,{path:"payments/federal/new",element:s.jsx(Du,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Ru,{})}),s.jsx(G,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Ou,{})}),s.jsx(G,{path:"payments/federal/authorization",element:s.jsx(Ku,{})}),s.jsx(G,{path:"payments/federal/individual-enrollment",element:s.jsx(td,{})}),s.jsx(G,{path:"settings",element:s.jsx(so,{})}),s.jsx(G,{path:"settings/tax-accounts/new",element:s.jsx(fr,{})}),s.jsx(G,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(fr,{})})]}),s.jsx(G,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})})}),oN=N.forwardRef(function(t,n){const r=N.useRef(null),a=N.useRef(null);return N.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,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(bi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(ui,{children:[s.jsx(G,{index:!0,element:s.jsx(vi,{})}),s.jsx(G,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(G,{path:"create-entity/form",element:s.jsx(zi,{})}),s.jsxs(G,{element:s.jsx(ji,{}),children:[s.jsx(G,{path:"entities",element:s.jsx(Vi,{})}),s.jsx(G,{path:"dashboard",element:s.jsx(qi,{})}),s.jsx(G,{path:"payments",element:s.jsx(Wi,{paymentsMode:"state"})}),s.jsx(G,{path:"payments/state/new",element:s.jsx(qu,{})}),s.jsx(G,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Vu,{})}),s.jsx(G,{path:"payments/state/:statePaymentId/view",element:s.jsx(Bu,{})}),s.jsx(G,{path:"payments/state/authorization",element:s.jsx(Wu,{})}),s.jsx(G,{path:"settings",element:s.jsx(so,{})}),s.jsx(G,{path:"settings/tax-accounts/new",element:s.jsx(fr,{})}),s.jsx(G,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(fr,{})})]}),s.jsx(G,{path:"*",element:s.jsx(Be,{to:"/",replace:!0})})]})})});exports.ApiError=yr;exports.FederalPaymentWidget=iN;exports.StatePaymentWidget=oN;exports.TaxRemittanceEmbedded=aN;exports.setRuntimeApiBaseUrl=fc;
|
|
75
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const m=u[1];if(t===u[0]){i(u);continue}if(e.external){const f=(c=e.external.registry.get(u[0]))==null?void 0:c.id;if(t!==u[0]&&f){i(u);continue}}if((d=e.metadataRegistry.get(u[0]))==null?void 0:d.id){i(u);continue}if(m.cycle){i(u);continue}if(m.count>1&&e.reused==="ref"){i(u);continue}}}function ru(e,t){var l,c,d,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const h=e.seen.get(m);if(h.ref===null)return;const f=h.def??h.schema,x={...f},p=h.ref;if(h.ref=null,p){r(p);const g=e.seen.get(p),k=g.schema;if(k.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(k)):Object.assign(f,k),Object.assign(f,x),m._zod.parent===p)for(const S in f)S==="$ref"||S==="allOf"||S in x||delete f[S];if(k.$ref&&g.def)for(const S in f)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(f[S])===JSON.stringify(g.def[S])&&delete f[S]}const w=m._zod.parent;if(w&&w!==p){r(w);const g=e.seen.get(w);if(g!=null&&g.schema.$ref&&(f.$ref=g.schema.$ref,g.def))for(const k in f)k==="$ref"||k==="allOf"||k in g.def&&JSON.stringify(f[k])===JSON.stringify(g.def[k])&&delete f[k]}e.override({zodSchema:m,jsonSchema:f,path:h.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(m)}Object.assign(a,n.def??n.schema);const i=(d=e.metadataRegistry.get(t))==null?void 0:d.id;i!==void 0&&a.id===i&&delete a.id;const o=((u=e.external)==null?void 0:u.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:Is(t,"input",e.processors),output:Is(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function nt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return nt(r.element,n);if(r.type==="set")return nt(r.valueType,n);if(r.type==="lazy")return nt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return nt(r.innerType,n);if(r.type==="intersection")return nt(r.left,n)||nt(r.right,n);if(r.type==="record"||r.type==="map")return nt(r.keyType,n)||nt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:nt(r.in,n)||nt(r.out,n);if(r.type==="object"){for(const a in r.shape)if(nt(r.shape[a],n))return!0;return!1}if(r.type==="union"){for(const a of r.options)if(nt(a,n))return!0;return!1}if(r.type==="tuple"){for(const a of r.items)if(nt(a,n))return!0;return!!(r.rest&&nt(r.rest,n))}return!1}const Pg=(e,t={})=>n=>{const r=tu({...n,processors:t});return Ye(e,r),nu(r,e),ru(r,e)},Is=(e,t,n={})=>r=>{const{libraryOptions:a,target:i}=r??{},o=tu({...a??{},target:i,io:t,processors:n});return Ye(e,o),nu(o,e),ru(o,e)},Eg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ig=(e,t,n,r)=>{const a=n;a.type="string";const{minimum:i,maximum:o,format:l,patterns:c,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(a.minLength=i),typeof o=="number"&&(a.maxLength=o),l&&(a.format=Eg[l]??l,a.format===""&&delete a.format,l==="time"&&delete a.format),d&&(a.contentEncoding=d),c&&c.size>0){const u=[...c];u.length===1?a.pattern=u[0].source:u.length>1&&(a.allOf=[...u.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},_g=(e,t,n,r)=>{n.type="boolean"},Tg=(e,t,n,r)=>{n.not={}},Fg=(e,t,n,r)=>{},Dg=(e,t,n,r)=>{const a=e._zod.def,i=Mc(a.entries);i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),n.enum=i},Rg=(e,t,n,r)=>{const a=e._zod.def,i=[];for(const o of a.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else i.every(o=>typeof o=="number")&&(n.type="number"),i.every(o=>typeof o=="string")&&(n.type="string"),i.every(o=>typeof o=="boolean")&&(n.type="boolean"),i.every(o=>o===null)&&(n.type="null"),n.enum=i},$g=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Og=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Lg=(e,t,n,r)=>{const a=n,i=e._zod.def,{minimum:o,maximum:l}=e._zod.bag;typeof o=="number"&&(a.minItems=o),typeof l=="number"&&(a.maxItems=l),a.type="array",a.items=Ye(i.element,t,{...r,path:[...r.path,"items"]})},zg=(e,t,n,r)=>{var d;const a=n,i=e._zod.def;a.type="object",a.properties={};const o=i.shape;for(const u in o)a.properties[u]=Ye(o[u],t,{...r,path:[...r.path,"properties",u]});const l=new Set(Object.keys(o)),c=new Set([...l].filter(u=>{const m=i.shape[u]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(a.required=Array.from(c)),((d=i.catchall)==null?void 0:d._zod.def.type)==="never"?a.additionalProperties=!1:i.catchall?i.catchall&&(a.additionalProperties=Ye(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},Mg=(e,t,n,r)=>{const a=e._zod.def,i=a.inclusive===!1,o=a.options.map((l,c)=>Ye(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=o:n.anyOf=o},qg=(e,t,n,r)=>{const a=e._zod.def,i=Ye(a.left,t,{...r,path:[...r.path,"allOf",0]}),o=Ye(a.right,t,{...r,path:[...r.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,c=[...l(i)?i.allOf:[i],...l(o)?o.allOf:[o]];n.allOf=c},Bg=(e,t,n,r)=>{const a=e._zod.def,i=Ye(a.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=a.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Vg=(e,t,n,r)=>{const a=e._zod.def;Ye(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType},Ug=(e,t,n,r)=>{const a=e._zod.def;Ye(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},Zg=(e,t,n,r)=>{const a=e._zod.def;Ye(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},Wg=(e,t,n,r)=>{const a=e._zod.def;Ye(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType;let o;try{o=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},Yg=(e,t,n,r)=>{const a=e._zod.def,i=a.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?a.out:a.in:a.out;Ye(o,t,r);const l=t.seen.get(e);l.ref=o},Hg=(e,t,n,r)=>{const a=e._zod.def;Ye(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType,n.readOnly=!0},su=(e,t,n,r)=>{const a=e._zod.def;Ye(a.innerType,t,r);const i=t.seen.get(e);i.ref=a.innerType};function Ja(){return Ja=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ja.apply(null,arguments)}function nl(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Kg(e,t){for(var n={};e.length;){var r=e[0],a=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[o]={message:l.message,type:l.code}}else n[o]={message:i,type:a};if("unionErrors"in r&&r.unionErrors.forEach(function(u){return u.errors.forEach(function(m){return e.push(m)})}),t){var c=n[o].types,d=c&&c[r.code];n[o]=Pi(o,t,n,a,d?[].concat(d,r.message):r.message)}e.shift()}return n}function Qg(e,t){for(var n={},r=function(){var a=e[0],i=a.code,o=a.message,l=a.path.join(".");if(!n[l])if(a.code==="invalid_union"&&a.errors.length>0){var c=a.errors[0][0];n[l]={message:c.message,type:c.code}}else n[l]={message:o,type:i};if(a.code==="invalid_union"&&a.errors.forEach(function(m){return m.forEach(function(h){return e.push(Ja({},h,{path:[].concat(a.path,h.path)}))})}),t){var d=n[l].types,u=d&&d[a.code];n[l]=Pi(l,t,n,i,u?[].concat(u,a.message):a.message)}e.shift()};e.length;)r();return n}function Lt(e,t,n){if(n===void 0&&(n={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,a,i){try{return Promise.resolve(nl(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(o){return i.shouldUseNativeValidation&&Ha({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return Array.isArray(l==null?void 0:l.issues)})(o))return{values:{},errors:Mo(Kg(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,a,i){try{return Promise.resolve(nl(function(){return Promise.resolve((n.mode==="sync"?Jf:Gf)(e,r,t)).then(function(o){return i.shouldUseNativeValidation&&Ha({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return l instanceof $i})(o))return{values:{},errors:Mo(Qg(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function Hr({label:e,required:t=!1,htmlFor:n}){return s.jsxs("label",{htmlFor:n,className:"mb-1.5 block text-sm text-slate-600",children:[e,t?s.jsx("span",{className:"text-red-500",children:" *"}):null]})}const ge=j.forwardRef(function({label:t,required:n=!1,error:r,id:a,className:i="",...o},l){const c=a??o.name;return s.jsxs("div",{children:[s.jsx(Hr,{label:t,required:n,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 ${r?"border-red-300":"border-slate-200"} ${i}`,...o}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})}),xn=j.forwardRef(function({label:t,required:n=!1,error:r,id:a,className:i="",children:o,...l},c){const d=a??l.name;return s.jsxs("div",{children:[s.jsx(Hr,{label:t,required:n,htmlFor:d}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{ref:c,id:d,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 ${r?"border-red-300":"border-slate-200"} ${i}`,...l,children:o}),s.jsx(Jg,{})]}),r?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:r}):null]})});function au({step:e,title:t,muted:n=!1,children:r}){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 ${n?"text-slate-400":"text-gov-700"}`,children:t})]}),r]})}function Jg(){return s.jsx("svg",{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function _s({title:e,subtitle:t,step:n,children:r,className:a=""}){return s.jsxs("section",{className:`rounded-xl border border-slate-200 bg-white ${a}`,children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 px-6 py-4",children:[n?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:n}):null,s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:e}),t?s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:t}):null]})]}),s.jsx("div",{className:"space-y-5 p-6",children:r})]})}function iu({label:e,required:t=!1,options:n,value:r,onChange:a}){const i=j.useId(),o=j.useRef([]),l=n.findIndex(u=>u.value===r),c=u=>{var h;const m=(u+n.length)%n.length;a(n[m].value),(h=o.current[m])==null||h.focus()},d=u=>{u.key==="ArrowRight"||u.key==="ArrowDown"?(u.preventDefault(),c(l+1)):(u.key==="ArrowLeft"||u.key==="ArrowUp")&&(u.preventDefault(),c(l-1))};return s.jsxs("div",{children:[s.jsx(Hr,{label:e,required:t,htmlFor:i}),s.jsx("div",{id:i,role:"radiogroup","aria-label":e,onKeyDown:d,className:"grid gap-3",style:{gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map((u,m)=>{const h=u.value===r;return s.jsxs("button",{ref:f=>{o.current[m]=f},type:"button",role:"radio","aria-checked":h,tabIndex:h?0:-1,onClick:()=>a(u.value),className:`flex items-center justify-center gap-2 rounded-lg border px-4 py-3 text-sm font-semibold transition focus:outline-none focus-visible:ring-2 focus-visible:ring-gov-500 focus-visible:ring-offset-1 sm:text-base ${h?"border-gov-400 bg-gov-50 text-gov-700 shadow-sm ring-1 ring-gov-200":"border-slate-200 bg-white text-slate-600 hover:border-slate-300 hover:bg-slate-50"}`,children:[u.icon?s.jsx("span",{className:h?"text-gov-600":"text-slate-400",children:u.icon}):null,u.label,h?s.jsx(Gg,{}):null]},u.value)})})]})}function Gg(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}function ou({label:e="Phone Number",required:t=!1,error:n,countryCodeSelectProps:r,phoneInputProps:a}){const i=a.id??a.name,o=n&&i?`${i}-error`:void 0;return s.jsxs("div",{children:[s.jsx(Hr,{label:e,required:t,htmlFor:i}),s.jsxs("div",{className:`flex overflow-hidden rounded-lg border bg-white transition focus-within:ring-2 focus-within:ring-gov-200 ${n?"border-red-300":"border-slate-200 focus-within:border-gov-400"}`,children:[s.jsxs("select",{"aria-label":"Country code",...r,className:"shrink-0 border-r border-slate-200 bg-slate-50 px-3 py-2.5 text-sm text-slate-900 focus:outline-none",children:[s.jsx("option",{value:"+1",children:"+1"}),s.jsx("option",{value:"+91",children:"+91"})]}),s.jsx("input",{type:"tel",inputMode:"numeric","aria-invalid":n?!0:void 0,"aria-describedby":o,...a,id:i,className:"block w-full border-0 px-3 py-2.5 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0"})]}),n?s.jsx("p",{id:o,className:"mt-1 text-xs text-red-600",children:n}):null]})}function lu({onCancel:e,isSubmitting:t,submitLabel:n,submittingLabel:r,cancelLabel:a="Cancel",className:i=""}){return s.jsxs("div",{className:`sticky bottom-0 flex flex-col-reverse gap-3 border-t border-slate-200 bg-white py-4 sm:flex-row sm:items-center ${i}`,children:[s.jsx("button",{type:"button",onClick:e,disabled:t,className:"inline-flex h-11 w-full 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 sm:w-auto",children:a}),s.jsx("button",{type:"submit",disabled:t,className:"inline-flex h-11 w-full 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 sm:w-auto",children:t?r:n})]})}function zt({variant:e="error",title:t,message:n}){const r=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 ${r}`,role:"alert",children:[t?s.jsx("p",{className:"font-medium",children:t}):null,s.jsx("p",{className:t?"mt-1":void 0,children:n})]})}function at(e,t){var n;if(e instanceof gr){if(e.details){const r=(n=Object.values(e.details)[0])==null?void 0:n[0];if(r)return r}return e.message||t}return e instanceof Error&&e.message?e.message:t}const Xg=F("ZodISODateTime",(e,t)=>{rx.init(e,t),_e.init(e,t)});function ey(e){return ig(Xg,e)}const ty=F("ZodISODate",(e,t)=>{sx.init(e,t),_e.init(e,t)});function ny(e){return og(ty,e)}const ry=F("ZodISOTime",(e,t)=>{ax.init(e,t),_e.init(e,t)});function sy(e){return lg(ry,e)}const ay=F("ZodISODuration",(e,t)=>{ix.init(e,t),_e.init(e,t)});function iy(e){return cg(ay,e)}const oy=(e,t)=>{$i.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Qf(e,n)},flatten:{value:n=>Kf(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ka,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ka,2)}},isEmpty:{get(){return e.issues.length===0}}})},vt=F("ZodError",oy,{Parent:Error}),ly=Ys(vt),cy=Hs(vt),uy=Ks(vt),dy=Qs(vt),my=tp(vt),hy=np(vt),fy=rp(vt),py=sp(vt),xy=ap(vt),gy=ip(vt),yy=op(vt),by=lp(vt),rl=new WeakMap;function Gs(e,t,n){const r=Object.getPrototypeOf(e);let a=rl.get(r);if(a||(a=new Set,rl.set(r,a)),!a.has(t)){a.add(t);for(const i in n){const o=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const $e=F("ZodType",(e,t)=>(Re.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Is(e,"input"),output:Is(e,"output")}}),e.toJSONSchema=Pg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>ly(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>uy(e,n,r),e.parseAsync=async(n,r)=>cy(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>dy(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>my(e,n,r),e.decode=(n,r)=>hy(e,n,r),e.encodeAsync=async(n,r)=>fy(e,n,r),e.decodeAsync=async(n,r)=>py(e,n,r),e.safeEncode=(n,r)=>xy(e,n,r),e.safeDecode=(n,r)=>gy(e,n,r),e.safeEncodeAsync=async(n,r)=>yy(e,n,r),e.safeDecodeAsync=async(n,r)=>by(e,n,r),Gs(e,"ZodType",{check(...n){const r=this.def;return this.clone(gn(r,{checks:[...r.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return yn(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(db(n,r))},superRefine(n,r){return this.check(mb(n,r))},overwrite(n){return this.check(yr(n))},optional(){return il(this)},exactOptional(){return Gy(this)},nullable(){return ol(this)},nullish(){return il(ol(this))},nonoptional(n){return sb(this,n)},array(){return Vy(this)},or(n){return du([this,n])},and(n){return Yy(this,n)},transform(n){return ll(this,Qy(n))},default(n){return tb(this,n)},prefault(n){return rb(this,n)},catch(n){return ib(this,n)},pipe(n){return ll(this,n)},readonly(){return cb(this)},describe(n){const r=this.clone();return Er.add(r,{description:n}),r},meta(...n){if(n.length===0)return Er.get(this);const r=this.clone();return Er.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Er.get(e))==null?void 0:n.description},configurable:!0}),e)),cu=F("_ZodString",(e,t)=>{Oi.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Ig(e,r,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Gs(e,"_ZodString",{regex(...r){return this.check(hg(...r))},includes(...r){return this.check(xg(...r))},startsWith(...r){return this.check(gg(...r))},endsWith(...r){return this.check(yg(...r))},min(...r){return this.check(Es(...r))},max(...r){return this.check(Xc(...r))},length(...r){return this.check(eu(...r))},nonempty(...r){return this.check(Es(1,...r))},lowercase(r){return this.check(fg(r))},uppercase(r){return this.check(pg(r))},trim(){return this.check(vg())},normalize(...r){return this.check(bg(...r))},toLowerCase(){return this.check(jg())},toUpperCase(){return this.check(wg())},slugify(){return this.check(Ng())}})}),vy=F("ZodString",(e,t)=>{Oi.init(e,t),cu.init(e,t),e.email=n=>e.check(Gc(uu,n)),e.url=n=>e.check(Ux(wy,n)),e.jwt=n=>e.check(ag(Oy,n)),e.emoji=n=>e.check(Zx(Ny,n)),e.guid=n=>e.check(tl(sl,n)),e.uuid=n=>e.check(Mx(os,n)),e.uuidv4=n=>e.check(qx(os,n)),e.uuidv6=n=>e.check(Bx(os,n)),e.uuidv7=n=>e.check(Vx(os,n)),e.nanoid=n=>e.check(Wx(Sy,n)),e.guid=n=>e.check(tl(sl,n)),e.cuid=n=>e.check(Yx(ky,n)),e.cuid2=n=>e.check(Hx(Cy,n)),e.ulid=n=>e.check(Kx(Ay,n)),e.base64=n=>e.check(ng(Dy,n)),e.base64url=n=>e.check(rg(Ry,n)),e.xid=n=>e.check(Qx(Py,n)),e.ksuid=n=>e.check(Jx(Ey,n)),e.ipv4=n=>e.check(Gx(Iy,n)),e.ipv6=n=>e.check(Xx(_y,n)),e.cidrv4=n=>e.check(eg(Ty,n)),e.cidrv6=n=>e.check(tg(Fy,n)),e.e164=n=>e.check(sg($y,n)),e.datetime=n=>e.check(ey(n)),e.date=n=>e.check(ny(n)),e.time=n=>e.check(sy(n)),e.duration=n=>e.check(iy(n))});function _(e){return zx(vy,e)}const _e=F("ZodStringFormat",(e,t)=>{Ce.init(e,t),cu.init(e,t)}),uu=F("ZodEmail",(e,t)=>{Hp.init(e,t),_e.init(e,t)});function jy(e){return Gc(uu,e)}const sl=F("ZodGUID",(e,t)=>{Wp.init(e,t),_e.init(e,t)}),os=F("ZodUUID",(e,t)=>{Yp.init(e,t),_e.init(e,t)}),wy=F("ZodURL",(e,t)=>{Kp.init(e,t),_e.init(e,t)}),Ny=F("ZodEmoji",(e,t)=>{Qp.init(e,t),_e.init(e,t)}),Sy=F("ZodNanoID",(e,t)=>{Jp.init(e,t),_e.init(e,t)}),ky=F("ZodCUID",(e,t)=>{Gp.init(e,t),_e.init(e,t)}),Cy=F("ZodCUID2",(e,t)=>{Xp.init(e,t),_e.init(e,t)}),Ay=F("ZodULID",(e,t)=>{ex.init(e,t),_e.init(e,t)}),Py=F("ZodXID",(e,t)=>{tx.init(e,t),_e.init(e,t)}),Ey=F("ZodKSUID",(e,t)=>{nx.init(e,t),_e.init(e,t)}),Iy=F("ZodIPv4",(e,t)=>{ox.init(e,t),_e.init(e,t)}),_y=F("ZodIPv6",(e,t)=>{lx.init(e,t),_e.init(e,t)}),Ty=F("ZodCIDRv4",(e,t)=>{cx.init(e,t),_e.init(e,t)}),Fy=F("ZodCIDRv6",(e,t)=>{ux.init(e,t),_e.init(e,t)}),Dy=F("ZodBase64",(e,t)=>{dx.init(e,t),_e.init(e,t)}),Ry=F("ZodBase64URL",(e,t)=>{hx.init(e,t),_e.init(e,t)}),$y=F("ZodE164",(e,t)=>{fx.init(e,t),_e.init(e,t)}),Oy=F("ZodJWT",(e,t)=>{xx.init(e,t),_e.init(e,t)}),Ly=F("ZodBoolean",(e,t)=>{gx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>_g(e,n,r)});function Yn(e){return ug(Ly,e)}const zy=F("ZodUnknown",(e,t)=>{yx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Fg()});function al(){return dg(zy)}const My=F("ZodNever",(e,t)=>{bx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Tg(e,n,r)});function qy(e){return mg(My,e)}const By=F("ZodArray",(e,t)=>{vx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Lg(e,n,r,a),e.element=t.element,Gs(e,"ZodArray",{min(n,r){return this.check(Es(n,r))},nonempty(n){return this.check(Es(1,n))},max(n,r){return this.check(Xc(n,r))},length(n,r){return this.check(eu(n,r))},unwrap(){return this.element}})});function Vy(e,t){return Sg(By,e,t)}const Uy=F("ZodObject",(e,t)=>{wx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>zg(e,n,r,a),je(e,"shape",()=>t.shape),Gs(e,"ZodObject",{keyof(){return Xs(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:al()})},loose(){return this.clone({...this._zod.def,catchall:al()})},strict(){return this.clone({...this._zod.def,catchall:qy()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Vf(this,n)},safeExtend(n){return Uf(this,n)},merge(n){return Zf(this,n)},pick(n){return qf(this,n)},omit(n){return Bf(this,n)},partial(...n){return Wf(mu,this,n[0])},required(...n){return Yf(hu,this,n[0])}})});function Xt(e,t){const n={type:"object",shape:e??{},...se(t)};return new Uy(n)}const Zy=F("ZodUnion",(e,t)=>{Nx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Mg(e,n,r,a),e.options=t.options});function du(e,t){return new Zy({type:"union",options:e,...se(t)})}const Wy=F("ZodIntersection",(e,t)=>{Sx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>qg(e,n,r,a)});function Yy(e,t){return new Wy({type:"intersection",left:e,right:t})}const Ga=F("ZodEnum",(e,t)=>{kx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(r,a,i)=>Dg(e,r,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,a)=>{const i={};for(const o of r)if(n.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ga({...t,checks:[],...se(a),entries:i})},e.exclude=(r,a)=>{const i={...t.entries};for(const o of r)if(n.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ga({...t,checks:[],...se(a),entries:i})}});function Xs(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ga({type:"enum",entries:n,...se(t)})}const Hy=F("ZodLiteral",(e,t)=>{Cx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Rg(e,n,r),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 da(e,t){return new Hy({type:"literal",values:Array.isArray(e)?e:[e],...se(t)})}const Ky=F("ZodTransform",(e,t)=>{Ax.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Og(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new zc(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push($r(i,n.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push($r(o))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Qy(e){return new Ky({type:"transform",transform:e})}const mu=F("ZodOptional",(e,t)=>{Jc.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>su(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function il(e){return new mu({type:"optional",innerType:e})}const Jy=F("ZodExactOptional",(e,t)=>{Px.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>su(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function Gy(e){return new Jy({type:"optional",innerType:e})}const Xy=F("ZodNullable",(e,t)=>{Ex.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Bg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function ol(e){return new Xy({type:"nullable",innerType:e})}const eb=F("ZodDefault",(e,t)=>{Ix.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Ug(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tb(e,t){return new eb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Bc(t)}})}const nb=F("ZodPrefault",(e,t)=>{_x.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Zg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function rb(e,t){return new nb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Bc(t)}})}const hu=F("ZodNonOptional",(e,t)=>{Tx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Vg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function sb(e,t){return new hu({type:"nonoptional",innerType:e,...se(t)})}const ab=F("ZodCatch",(e,t)=>{Fx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Wg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ib(e,t){return new ab({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ob=F("ZodPipe",(e,t)=>{Dx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Yg(e,n,r,a),e.in=t.in,e.out=t.out});function ll(e,t){return new ob({type:"pipe",in:e,out:t})}const lb=F("ZodReadonly",(e,t)=>{Rx.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>Hg(e,n,r,a),e.unwrap=()=>e._zod.def.innerType});function cb(e){return new lb({type:"readonly",innerType:e})}const ub=F("ZodCustom",(e,t)=>{$x.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,r,a)=>$g(e,n)});function db(e,t={}){return kg(ub,e,t)}function mb(e,t){return Cg(e,t)}const Qt={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Li(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[t.length-1][0]}`.toUpperCase()}function en(e){return e.tradeName.trim()?e.tradeName:e.accountType==="Business"?(e.lastName||e.firstName).trim():`${e.firstName} ${e.lastName}`.trim()}function qn(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,2)}-${t.slice(2)}`}function hb(e){const t=e.replace(/\D/g,"");return t.length!==9?e:`${t.slice(0,3)}-${t.slice(3,5)}-${t.slice(5)}`}function fb(e,t){return t==="Individual"?hb(e):qn(e)}function cl(e,t){const n=e.replace(/\D/g,"").slice(0,9);return t==="Individual"?n.length<=3?n:n.length<=5?`${n.slice(0,3)}-${n.slice(3)}`:`${n.slice(0,3)}-${n.slice(3,5)}-${n.slice(5)}`:n.length<=2?n:`${n.slice(0,2)}-${n.slice(2)}`}function $n(e){const t=e.replace(/\D/g,""),n=t.length===11&&t.startsWith("1")?t.slice(1):t;return n.length!==10?e:`+1 (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}const fu=["LLP","LLC","Corporation","S-Corp","Partnership"],pu=["Sole Proprietorship"],pb=/^[A-Za-z][A-Za-z\s'.-]*$/,Xa=10,xu=/^\d{5}(-\d{4})?$/,xb=/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/;function zi(e){const t=e.replace(/\D/g,"").slice(0,9);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`}function gu(e){const t=e.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6);return t.length<=3?t:`${t.slice(0,3)} ${t.slice(3)}`}const yu=Xt({accountType:Xs(["Business","Individual"]),firstName:_(),lastName:_(),tradeName:_(),ein:_(),entityType:_().min(1,"Entity type is required"),email:jy("Enter a valid email"),countryCode:_().min(1),phoneNumber:_().min(1,"Phone number is required").refine(e=>e.replace(/\D/g,"").length===Xa,`Phone number must be ${Xa} digits`),address1:_().min(1,"Address is required"),address2:_(),city:_().min(1,"City is required"),state:_().min(1,"State is required"),zipCode:_().min(1,"ZIP code is required"),country:_().min(1,"Country is required")}).superRefine((e,t)=>{pb.test(e.city.trim())||t.addIssue({code:"custom",path:["city"],message:"City can only contain letters, spaces, apostrophes, and hyphens"}),e.country==="United States"&&!xu.test(e.zipCode.trim())?t.addIssue({code:"custom",path:["zipCode"],message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)"}):e.country==="Canada"&&!xb.test(e.zipCode.trim())&&t.addIssue({code:"custom",path:["zipCode"],message:"Enter a valid postal code (e.g. A1A 1A1)"});const n=e.accountType==="Individual"?"SSN":"EIN",r=e.ein.replace(/\D/g,"");if(r?r.length!==9&&t.addIssue({code:"custom",path:["ein"],message:`${n} must be 9 digits`}):t.addIssue({code:"custom",path:["ein"],message:`${n} is required`}),e.accountType==="Business"){e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Business name is required"});return}e.firstName.trim()||t.addIssue({code:"custom",path:["firstName"],message:"First name is required"}),e.lastName.trim()||t.addIssue({code:"custom",path:["lastName"],message:"Last name is required"})});function gb(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(-Xa)}}function ul(e){const{countryCode:t,national:n}=gb(e.phoneNumber),r=e.accountType==="Individual",a=(e.lastName||e.firstName||"").trim();return{accountType:r?"Individual":"Business",firstName:r?e.firstName??"":"",lastName:r?e.lastName??"":a,tradeName:r?"":e.tradeName??"",ein:qn(e.idNumber),entityType:e.entityType,email:e.email,countryCode:t,phoneNumber:n,address1:e.address1,address2:e.address2??"",city:e.city,state:e.state,zipCode:e.zipCode,country:e.country}}function bu(e,t,n,r){if(e!==t){if(e==="Business"&&t==="Individual"){n("firstName",""),n("lastName",r),n("tradeName","");return}e==="Individual"&&t==="Business"&&(n("firstName",""),n("lastName",r))}}function vu(e){const t=e.lastName.trim();return e.accountType==="Business"?{accountType:e.accountType,firstName:"",lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:e.tradeName.trim(),phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}:{accountType:e.accountType,firstName:e.firstName.trim(),lastName:t,idNumber:e.ein.replace(/\D/g,""),entityType:e.entityType,tradeName:"",phoneNumber:`${e.countryCode}${e.phoneNumber.replace(/\D/g,"")}`,email:e.email,address1:e.address1,address2:e.address2||null,city:e.city,state:e.state,country:e.country,zipCode:e.zipCode}}function yb(e){const{idNumber:t,...n}=vu(e);return n}function bb(e){return me(`/portal/reference/states?country=${encodeURIComponent(e)}`)}function Mi(e){const{data:t}=be({queryKey:["reference","states",e],queryFn:()=>bb(e),enabled:!!e,staleTime:1/0});return t??[]}function ur(e,t,n){const r=e.find(o=>o.code===t);if(!r||r.zipRanges.length===0)return!0;const a=n.replace(/\D/g,"");if(a.length<5)return!0;const i=Number(a.slice(0,3));return r.zipRanges.some(o=>i>=o.from&&i<=o.to)}function Bn(e,t){const n=e==null?void 0:e.from;return n&&n.startsWith("/")&&!n.startsWith("//")?n:t}function vb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 21h18M5 21V6a1 1 0 011-1h4a1 1 0 011 1v15m0 0V3a1 1 0 011-1h4a1 1 0 011 1v18M9 9h.01M9 12h.01M9 15h.01"})})}function jb(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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 wb(){var De,Oe,ue,xe,R,pe,U,fe,Pe,Xe,le,Ne,qe,He;const e=ke(),t=Se(),n=xt(),{data:r=[]}=be({queryKey:["entities","mine"],queryFn:async()=>(await bi({pageNumber:1,pageSize:100})).items}),[a,i]=j.useState(null),[o,l]=j.useState(!1),c=r.length===0,d=c?"/create-entity":"/dashboard",u=Bn(t.state,d),m=()=>{e(u)},{register:h,handleSubmit:f,watch:x,setValue:p,getValues:w,formState:{errors:g}}=$t({resolver:Lt(yu),shouldUnregister:!1,defaultValues:{accountType:"Individual",firstName:"",lastName:"",tradeName:"",ein:"",entityType:"Sole Proprietorship",email:"",countryCode:"+1",phoneNumber:"",address1:"",address2:"",city:"",state:"",zipCode:"",country:"United States"}}),k=x("accountType"),v=x("entityType"),S=k==="Individual"?pu:fu,E=k==="Individual",T=E?"SSN":"EIN",P=E?"***-**-****":"**-*******",O=E?11:10,I=x("country"),$=x("state"),ne=x("zipCode"),q=I==="United States",K=Mi(I),ee=$.length>0&&ne.trim().length>0&&!ur(K,$,ne),z=h("ein"),ae=h("phoneNumber"),oe=h("zipCode");j.useEffect(()=>{$&&K.length>0&&!K.some(re=>re.code===$)&&p("state","")},[I,K]);const Q=re=>{const et=w("accountType");if(et===re)return;const tt=w("lastName");bu(et,re,p,tt),p("accountType",re),p("ein",cl(w("ein"),re)),queueMicrotask(()=>{p("lastName",tt),p("firstName",""),et==="Business"&&re==="Individual"&&p("tradeName","")})};j.useEffect(()=>{S.includes(v)||p("entityType",k==="Individual"?"Sole Proprietorship":"LLP")},[k,v,S,p]);const Ae=f(async re=>{if(i(null),!ur(K,re.state,re.zipCode)){i(`ZIP code does not match the selected state (${re.state}).`);return}l(!0);try{await Gh(vu(re)),await n.invalidateQueries({queryKey:["entities","mine"]}),e(c?"/dashboard":u,{replace:!0})}catch(et){i(at(et,"Unable to save entity. Please try again."))}finally{l(!1)}});return s.jsxs("form",{onSubmit:Ae,noValidate:!0,className:"w-full max-w-4xl space-y-6 lg:max-w-5xl xl:max-w-6xl",children:[a?s.jsx(zt,{message:a}):null,s.jsxs(_s,{step:1,title:"Basic Information",subtitle:"Enter the primary details for this entity.",children:[s.jsx(iu,{label:"Account Type",required:!0,value:k,onChange:Q,options:[{label:"Business",value:"Business",icon:s.jsx(vb,{})},{label:"Individual",value:"Individual",icon:s.jsx(jb,{})}]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:k==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(ge,{label:"First name",required:!0,maxLength:100,placeholder:"Enter first name",error:(De=g.firstName)==null?void 0:De.message,...h("firstName")},"entity-first-name"),s.jsx(ge,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter last name",error:(Oe=g.lastName)==null?void 0:Oe.message,...h("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(ge,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter business name",error:(ue=g.lastName)==null?void 0:ue.message,...h("lastName")},"entity-business-name"),s.jsx(ge,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter trade name (optional)",error:(xe=g.tradeName)==null?void 0:xe.message,...h("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:T,required:!0,inputMode:"numeric",placeholder:P,maxLength:O,error:(R=g.ein)==null?void 0:R.message,...z,onChange:re=>{re.target.value=cl(re.target.value,k),z.onChange(re)}}),s.jsx(xn,{label:"Entity Type",required:!0,error:(pe=g.entityType)==null?void 0:pe.message,...h("entityType"),children:S.map(re=>s.jsx("option",{value:re,children:re},re))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(U=g.email)==null?void 0:U.message,...h("email")}),s.jsx(ou,{required:!0,error:(fe=g.phoneNumber)==null?void 0:fe.message,countryCodeSelectProps:h("countryCode"),phoneInputProps:{placeholder:"Enter 10-digit phone number",maxLength:10,...ae,onChange:re=>{re.target.value=re.target.value.replace(/\D/g,"").slice(0,10),ae.onChange(re)}}})]})]}),s.jsxs(_s,{step:2,title:"Address Information",subtitle:"Enter the registered address.",children:[s.jsx(ge,{label:"Address Line 1",required:!0,maxLength:200,placeholder:"Enter address line 1",error:(Pe=g.address1)==null?void 0:Pe.message,...h("address1")}),s.jsx(ge,{label:"Address Line 2",maxLength:200,placeholder:"Enter address line 2 (optional)",error:(Xe=g.address2)==null?void 0:Xe.message,...h("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:"City",required:!0,maxLength:100,placeholder:"Enter city",error:(le=g.city)==null?void 0:le.message,...h("city")}),s.jsxs(xn,{label:q?"State":"Province",required:!0,error:(Ne=g.state)==null?void 0:Ne.message,...h("state"),children:[s.jsx("option",{value:"",children:q?"Select state":"Select province"}),K.map(re=>s.jsx("option",{value:re.code,children:re.name},re.code))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:q?"ZIP Code":"Postal Code",required:!0,maxLength:10,placeholder:q?"12345 or 12345-6789":"A1A 1A1",error:((qe=g.zipCode)==null?void 0:qe.message)??(ee?`ZIP code does not match the selected state (${$}).`:void 0),...oe,onChange:re=>{re.target.value=q?zi(re.target.value):gu(re.target.value),oe.onChange(re)}}),s.jsxs(xn,{label:"Country",required:!0,error:(He=g.country)==null?void 0:He.message,...h("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]}),s.jsx(lu,{onCancel:m,isSubmitting:o,submitLabel:"Create Entity",submittingLabel:"Creating…"})]})}function qi(){const e=ke(),t=Se(),n=Bn(t.state,"/create-entity");return s.jsx("div",{className:"min-h-full bg-slate-50 px-4 py-6 sm:px-8 sm:py-8",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl lg:max-w-5xl xl:max-w-6xl",children:[s.jsxs("button",{type:"button",onClick:()=>e(n),className:"inline-flex items-center gap-1.5 rounded-lg py-1 text-sm font-medium text-slate-600 transition hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-500",children:[s.jsx(Nb,{}),"Back"]}),s.jsxs("div",{className:"mb-6 mt-4",children:[s.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:"Create Entity"}),s.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Add the business or individual responsible for tax accounts and payments."})]}),s.jsx(wb,{})]})})}function Nb(){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 Sb(e,t){const n=new URLSearchParams({entityId:String(e)});return t!==void 0&&n.set("taxYear",String(t)),me(`/portal/dashboard?${n}`)}function kb(e,t,n){const r=new URLSearchParams({entityId:String(e),category:t,taxYear:String(n)});return me(`/portal/dashboard/summary?${r}`)}function Cb(e,t,n){const r=new URLSearchParams({entityId:String(e),month:String(t)});return n!==void 0&&r.set("year",String(n)),me(`/portal/dashboard/monthly-overview?${r}`)}function Ab({entityId:e,search:t,taxYear:n,status:r,page:a=1,pageSize:i=lt}){const o=new URLSearchParams({entityId:String(e),page:String(a),pageSize:String(i)});return t&&o.set("search",t),n&&o.set("taxYear",n),r&&r!=="all"&&o.set("status",r),me(`/portal/dashboard/payments?${o}`)}function dl({entityCount:e,showPaymentActions:t=!0}){const n=ke(),{enabledPayments:r}=zn();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:[t&&r.includes("federal")&&s.jsxs("button",{type:"button",onClick:()=>n("/payments/federal/new",{state:{from:"/"}}),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:[s.jsx(ma,{}),"Add Federal Payments"]}),t&&r.includes("state")&&s.jsxs("button",{type:"button",onClick:()=>n("/payments/state/new",{state:{from:"/",resetDraft:!0}}),className:"inline-flex items-center gap-2 rounded-lg border border-gov-600 bg-white px-4 py-2.5 text-sm font-semibold text-gov-600 transition hover:bg-gov-50",children:[s.jsx(ma,{}),"Add State Payment"]}),t&&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(ma,{}),"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:()=>n("/entities"),className:"inline-flex items-center gap-1.5 rounded-[14px] border border-solid border-[#e5e7eb] bg-[#f9fafb] px-[15px] py-[9px] text-xs font-bold text-[#364153] transition hover:bg-slate-100",title:"View organizations",children:[s.jsx(Pb,{}),"Entities (",e,")"]}),s.jsxs("button",{type:"button",onClick:()=>n("/create-entity/form",{state:{from:"/dashboard"}}),className:"inline-flex items-center gap-1.5 rounded-[14px] border-[1.5px] border-dashed border-[#16a34a] bg-[#f0fdf4] px-[15.5px] py-[9.5px] text-xs font-bold text-[#16a34a] transition hover:bg-green-50",children:[s.jsx(Eb,{}),"Add Entity"]})]})]})}function ma(){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 Pb(){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 Eb(){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 Ib({title:e,description:t,buttonLabel:n,onAdd:r,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:r,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(_b,{}),n]})]})}function _b(){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 br({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(Tb,{}),s.jsx("span",{children:e})]})})}function Tb(){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 Fb={Draft:"Draft"};function Db(e){switch((e??Fb.Draft).trim().toLowerCase()){case"draft":case"pending":return"drafts";case"scheduled":return"scheduled";case"processing":return"submitted";case"rejected":return"rejected";case"accepted":return"paid";default:return"drafts"}}function Kr(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:e%1===0?0:2,maximumFractionDigits:2}).format(e)}function Rb(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 Bi="drafts";function Ge(){return ea(Bi)}function ea(e){return`/payments?tab=${e}`}function ju(e){return e==="failed"?"rejected":e}function $b(e,t){return t.trim().toLowerCase()==="draft"?Bi:ju(e)}const Ob=["January","February","March","April","May","June","July","August","September","October","November","December"];function Lb({entityId:e,initialOverview:t,isDashboardLoading:n=!1}){const r=ke(),a=(t==null?void 0:t.year)??new Date().getFullYear(),[i,o]=j.useState(null);j.useEffect(()=>{o(null)},[e]);const l=i??(t==null?void 0:t.month)??new Date().getMonth()+1,c=i===null,{data:d,isFetching:u}=be({queryKey:["dashboard","monthly-overview",e,i,a],queryFn:()=>Cb(e,i,a),enabled:e!==null&&i!==null,placeholderData:p=>p}),m={submitted:0,paid:0,scheduled:0,failed:0},h=c?t??m:d??m,f=n||u&&!c,x=[{key:"submitted",label:"Submitted to Fed/State/Local",amount:h.submitted,icon:Mb,iconClassName:"rounded-xl bg-orange-50 text-orange-500",amountClassName:"text-orange-500"},{key:"paid",label:"Paid",amount:h.paid,icon:qb,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 s.jsxs("section",{className:"relative rounded-xl border border-slate-200 bg-white p-6",children:[f?s.jsx(br,{}):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:Ob.map((p,w)=>s.jsx("option",{value:w+1,children:p},p))}),s.jsx(zb,{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:x.map(p=>{const w=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(w,{})}),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:Kr(p.amount)}),s.jsx("button",{type:"button",onClick:()=>r(ea(ju(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 zb({className:e}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Mb(){return s.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 qb(){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 Bb(){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 Vb(){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 ml(e){return{count:e.count,submitted:e.submitted,paid:e.paid,scheduled:e.scheduled,failed:e.failed,percentDone:e.percentDone}}function Ub(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 hl(){return{count:0,submitted:0,paid:0,scheduled:0,failed:0,percentDone:0}}const Zb={primary:"bg-brand-600 text-white hover:bg-brand-700 focus-visible:ring-brand-500 disabled:bg-brand-600/60",secondary:"border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 focus-visible:ring-slate-400",ghost:"text-slate-600 hover:bg-slate-100 focus-visible:ring-slate-400"};function Wb({variant:e="primary",isLoading:t=!1,className:n="",children:r,disabled:a,...i}){return s.jsx("button",{type:"button",className:`inline-flex h-10 items-center justify-center rounded-lg px-4 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed ${Zb[e]} ${n}`,disabled:a||t,...i,children:t?"Please wait…":r})}const Yb=[10,20,50,100];function Hb(e,t){const n=e.trim();if(!/^\d+$/.test(n))return null;const r=Number(n);return!Number.isInteger(r)||r<1||r>t?null:r}function Kb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M12.5 4.5 7 10l5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qb(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M7.5 4.5 13 10l-5.5 5.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qr({page:e,pageSize:t,totalCount:n,onPageChange:r,onPageSizeChange:a,pageSizeOptions:i=Yb,disabled:o=!1,className:l=""}){const c=t>0?Math.max(1,Math.ceil(n/t)):1,d=n===0?0:c,u=e>1,m=d>0&&e<d,h=n===0?0:(e-1)*t+1,f=Math.min(e*t,n),[x,p]=j.useState(String(e)),w=j.useRef(x);w.current=x,j.useEffect(()=>{p(String(e))},[e]);function g(v=w.current){if(o||d===0){p(String(e));return}const S=Hb(v,d);if(S===null){p(String(e));return}if(S===e){p(String(e));return}r(S)}function k(v){v.key==="Enter"&&(v.preventDefault(),g(v.currentTarget.value))}return n===0?null:s.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 border-t border-slate-200 bg-white px-6 py-3 ${l}`,children:[s.jsxs("p",{className:"text-sm text-slate-500",children:["Showing ",s.jsx("span",{className:"font-medium text-slate-700",children:h}),"–",s.jsx("span",{className:"font-medium text-slate-700",children:f})," of ",s.jsx("span",{className:"font-medium text-slate-700",children:n})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a?s.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[s.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),s.jsx("select",{value:t,disabled:o,onChange:v=>a(Number(v.target.value)),className:"rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(v=>s.jsx("option",{value:v,children:v},v))})]}):null,s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",disabled:o||!u,onClick:()=>r(e-1),"aria-label":"Previous page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Kb,{})}),s.jsx("span",{className:"min-w-[5.5rem] text-center text-sm text-slate-600",children:d===0?"—":`Page ${e} of ${d}`}),s.jsx("button",{type:"button",disabled:o||!m,onClick:()=>r(e+1),"aria-label":"Next page",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-slate-700 transition hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gov-200 disabled:cursor-not-allowed disabled:text-slate-300 disabled:hover:bg-transparent",children:s.jsx(Qb,{})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:"pagination-go-to-page",className:"whitespace-nowrap text-sm text-slate-600",children:"Go to page"}),s.jsx("input",{id:"pagination-go-to-page",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:x,disabled:o||d===0,onChange:v=>p(v.target.value),onKeyDown:k,"aria-label":"Go to page number",className:"h-9 w-14 rounded-lg border border-slate-200 bg-white px-2 text-center text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"}),s.jsx(Wb,{type:"button",variant:"secondary",disabled:o||d===0,className:"h-9 px-3",onMouseDown:v=>{v.preventDefault()},onClick:()=>g(),children:"Go"})]})]})]})}const Jb=[{value:"all",label:"All"},{value:"scheduled",label:"Scheduled"},{value:"paid",label:"Completed"},{value:"submitted",label:"Submitted"},{value:"failed",label:"Failed"}],fl={total:0,page:1,pageSize:lt,items:[]};function Gb({label:e,status:t}){const n={scheduled:"bg-amber-50 text-amber-700",paid:"bg-emerald-50 text-emerald-700",submitted:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-600"};return s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n[t]}`,children:e})}function Xb({entityId:e,initialPayments:t,isDashboardLoading:n=!1}){const r=ke(),[a,i]=j.useState(""),[o,l]=j.useState(""),[c,d]=j.useState(""),[u,m]=j.useState("all"),[h,f]=j.useState(1),[x,p]=j.useState(lt);j.useEffect(()=>{const I=window.setTimeout(()=>l(a),300);return()=>window.clearTimeout(I)},[a]),j.useEffect(()=>{f(1)},[o,c,u,e,x]);const w=!!o||!!c||u!=="all",g=e!==null&&(w||h>1||x!==lt),{data:k,isFetching:v}=be({queryKey:["dashboard","payments",e,o,c,u,h,x],queryFn:()=>Ab({entityId:e,search:o||void 0,taxYear:c||void 0,status:u,page:h,pageSize:x}),enabled:g,placeholderData:I=>I}),S=j.useMemo(()=>g?k??fl:t&&h===1&&x===lt?t:fl,[g,k,t,h,x]),E=j.useMemo(()=>S.items.map(Ub),[S.items]),T=j.useMemo(()=>{const I=new Date().getFullYear();return[I,I-1,I-2].map(String)},[]),P=n||g&&v,O=(S.page-1)*S.pageSize;return s.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[P?s.jsx(br,{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(t0,{})}),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:[S.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(e0,{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:I=>i(I.target.value),placeholder:"All",disabled:n,className:"block w-full rounded-lg border border-slate-200 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60"})]})]}),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:I=>d(I.target.value),disabled:n,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[s.jsx("option",{value:"",children:"Select Year"}),T.map(I=>s.jsx("option",{value:I,children:I},I))]}),s.jsx(pl,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"status-filter",className:"mb-1.5 block text-sm text-slate-600",children:"Filter by Status"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{id:"status-filter",value:u,onChange:I=>m(I.target.value),disabled:n,className:"block w-full appearance-none rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:Jb.map(I=>s.jsx("option",{value:I.value,children:I.label},I.value))}),s.jsx(pl,{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:!P&&E.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-slate-500",children:w?"No payments match your filters.":"No payments yet."})}):E.map((I,$)=>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:["#",O+$+1]}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(I.amount)}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.paymentDate}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Gb,{label:I.statusLabel,status:I.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:I.formType}),s.jsx("td",{className:"px-6 py-4",children:s.jsx("button",{type:"button",onClick:()=>r(ea($b(I.status,I.statusLabel))),className:"text-sm font-medium text-gov-600 hover:text-gov-700",children:"View"})})]},`${I.category}-${I.id}`))})]})}),s.jsx(Qr,{page:h,pageSize:x,totalCount:S.total,onPageChange:f,onPageSizeChange:p,disabled:P||e===null})]})}function e0({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 pl({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 t0(){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 ha({entityId:e,category:t,title:n,subtitlePrefix:r,defaultTaxYear:a,taxYearOptions:i,initialSummary:o,isDashboardLoading:l=!1,stats:c,comingSoon:d=!1}){const[u,m]=j.useState(a);if(j.useEffect(()=>{m(a)},[e,a]),d)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:n}),s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:r})]}),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=u===a,{data:f,isFetching:x}=be({queryKey:["dashboard","summary",e,t,u],queryFn:()=>kb(e,t,u),enabled:e!==null&&!h,placeholderData:k=>k}),p=h?o?ml(o):hl():f?ml(f):hl(),w=Rb(p),g=l||x&&!h;return s.jsxs("article",{className:"relative flex flex-col rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[g?s.jsx(br,{}):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:n}),s.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[r," (",p.count,")"]})]}),s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("select",{value:u,onChange:k=>m(Number(k.target.value)),disabled:g,className:"appearance-none rounded-lg border border-slate-200 bg-white py-1.5 pl-3 pr-8 text-xs font-medium text-slate-700 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:i.map(k=>s.jsxs("option",{value:k,children:["TY ",k]},k))}),s.jsx(n0,{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(k=>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 ${k.dotClassName}`}),s.jsx("span",{className:"text-xs text-slate-500",children:k.label})]}),s.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-900",children:Kr(p[k.key])})]},k.label))}),s.jsxs("div",{className:"mt-5",children:[s.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-slate-100",children:w.map((k,v)=>k.width>0?s.jsx("span",{className:`${k.color} h-full`,style:{width:`${k.width}%`}},v):null)}),s.jsxs("p",{className:"mt-2 text-xs font-medium text-slate-600",children:[p.percentDone,"% done"]})]})]})}function n0({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 r0={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."},s0=[{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"}],rn=new Date().getFullYear(),fa=[rn,rn-1,rn-2],a0=[{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"}],i0=[{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"}],o0=[{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 Vi(){const e=ke(),{entities:t,selectedEntity:n,enabledPayments:r}=zn(),a=(n==null?void 0:n.entityId)??null,{data:i,isLoading:o}=be({queryKey:["dashboard",a,rn],queryFn:()=>Sb(a,rn),enabled:a!==null});return!o&&i&&!i.hasPayments?s.jsxs("div",{className:"space-y-6",children:[s.jsx(dl,{entityCount:t.length,showPaymentActions:!1}),s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 xl:grid-cols-3",children:s0.filter(l=>l.key==="local"||r.includes(l.key)).map(l=>s.jsx(Ib,{title:l.title,description:r0[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(dl,{entityCount:t.length}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[r.includes("federal")&&s.jsx(ha,{entityId:a,category:"federal",title:"Federal Payments",subtitlePrefix:"IRS & Federal agencies",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.federal,isDashboardLoading:o,stats:a0}),r.includes("state")&&s.jsx(ha,{entityId:a,category:"state",title:"All State Payments",subtitlePrefix:"State tax authorities",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.state,isDashboardLoading:o,stats:i0}),s.jsx(ha,{entityId:a,category:"local",title:"Local Payments",subtitlePrefix:"Local tax authorities",defaultTaxYear:rn,taxYearOptions:fa,initialSummary:i==null?void 0:i.local,isDashboardLoading:o,stats:o0,comingSoon:!0})]}),s.jsx(Lb,{entityId:a,initialOverview:i==null?void 0:i.monthlyOverview,isDashboardLoading:o}),s.jsx(Xb,{entityId:a,initialPayments:i==null?void 0:i.payments,isDashboardLoading:o})]})}const xl=160,l0=48,ls=8;function c0({entity:e,onEdit:t}){const n=j.useRef(null),r=j.useRef(null),[a,i]=j.useState(!1),[o,l]=j.useState({}),c=()=>{var x;const d=n.current;if(!d)return;const u=d.getBoundingClientRect(),m=((x=r.current)==null?void 0:x.offsetHeight)??l0,f=window.innerHeight-u.bottom<m+ls;l({position:"fixed",top:f?u.top-m-ls:u.bottom+ls,left:Math.max(ls,u.right-xl),width:xl,zIndex:50})};return j.useLayoutEffect(()=>{a&&(c(),requestAnimationFrame(c))},[a]),j.useEffect(()=>{if(!a)return;const d=m=>{var f,x;const h=m.target;(f=n.current)!=null&&f.contains(h)||(x=r.current)!=null&&x.contains(h)||i(!1)},u=()=>c();return document.addEventListener("mousedown",d),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[a]),s.jsxs("div",{className:"inline-block text-left",children:[s.jsxs("button",{ref:n,type:"button",onClick:()=>i(d=>!d),className:"inline-flex items-center gap-1.5 rounded-lg bg-gov-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-gov-700",children:["Actions",s.jsx(u0,{})]}),a?Br.createPortal(s.jsx("div",{ref:r,style:o,className:"overflow-hidden rounded-lg border border-slate-200 bg-white py-1 shadow-lg",children:s.jsx("button",{type:"button",onClick:()=>{i(!1),t(e)},className:"block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-50",children:"Edit"})}),document.body):null]})}function u0(){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"})})}function d0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 21h18M5 21V6a1 1 0 011-1h4a1 1 0 011 1v15m0 0V3a1 1 0 011-1h4a1 1 0 011 1v18M9 9h.01M9 12h.01M9 15h.01"})})}function m0(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.75",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 wu({open:e,entity:t,onClose:n}){var K,ee,z,ae,oe,Q,Ae,De,Oe,ue,xe,R,pe;const r=xt(),[a,i]=j.useState(null),[o,l]=j.useState(!1),{register:c,handleSubmit:d,watch:u,reset:m,setValue:h,getValues:f,formState:{errors:x}}=$t({resolver:Lt(yu),defaultValues:ul(t),shouldUnregister:!1}),p=u("accountType"),w=u("entityType"),g=p==="Individual"?pu:fu,k=p==="Individual"?"SSN":"EIN",v=u("country"),S=u("state"),E=u("zipCode"),T=v==="United States",P=Mi(v),O=S.length>0&&E.trim().length>0&&!ur(P,S,E),I=c("phoneNumber"),$=c("zipCode");j.useEffect(()=>{S&&P.length>0&&!P.some(U=>U.code===S)&&h("state","")},[v,P]);const ne=U=>{const fe=f("accountType");if(fe===U)return;const Pe=f("lastName");bu(fe,U,h,Pe),h("accountType",U),queueMicrotask(()=>{h("lastName",Pe),h("firstName",""),fe==="Business"&&U==="Individual"&&h("tradeName","")})};j.useEffect(()=>{if(e){const U=ul(t);m(U),i(null)}},[t,e,m]),j.useEffect(()=>{if(!e)return;const U=fe=>{fe.key==="Escape"&&n()};return document.addEventListener("keydown",U),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",U),document.body.style.overflow=""}},[e,n]),j.useEffect(()=>{g.includes(w)||h("entityType",p==="Individual"?"Sole Proprietorship":"LLP")},[p,w,g,h]);const q=d(async U=>{if(i(null),!ur(P,U.state,U.zipCode)){i(`ZIP code does not match the selected state (${U.state}).`);return}l(!0);try{await Xh(t.entityId,yb(U)),await r.invalidateQueries({queryKey:["entities","mine"]}),n()}catch(fe){i(at(fe,"Unable to update entity. Please try again."))}finally{l(!1)}});return e?Br.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:n}),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-4xl 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:q,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(zt,{message:a})}):null,s.jsx("input",{type:"hidden",...c("ein")}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_s,{step:1,title:"Basic Information",subtitle:"Enter the primary details for this entity.",children:[s.jsx(iu,{label:"Account Type",required:!0,value:p,onChange:ne,options:[{label:"Business",value:"Business",icon:s.jsx(d0,{})},{label:"Individual",value:"Individual",icon:s.jsx(m0,{})}]}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:p==="Individual"?s.jsxs(s.Fragment,{children:[s.jsx(ge,{label:"First name",required:!0,maxLength:100,placeholder:"Enter first name",error:(K=x.firstName)==null?void 0:K.message,...c("firstName")},"entity-first-name"),s.jsx(ge,{label:"Last name",required:!0,maxLength:100,placeholder:"Enter last name",error:(ee=x.lastName)==null?void 0:ee.message,...c("lastName")},"entity-last-name")]}):s.jsxs(s.Fragment,{children:[s.jsx(ge,{label:"Business Name",required:!0,maxLength:150,placeholder:"Enter business name",error:(z=x.lastName)==null?void 0:z.message,...c("lastName")},"entity-business-name"),s.jsx(ge,{label:"Trade Name, if any",maxLength:150,placeholder:"Enter trade name (optional)",error:(ae=x.tradeName)==null?void 0:ae.message,...c("tradeName")},"entity-trade-name")]})}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:k,readOnly:!0,value:fb(t.idNumber,p),className:"cursor-default bg-[#F9FAFB] text-slate-700"}),s.jsx(xn,{label:"Entity Type",required:!0,error:(oe=x.entityType)==null?void 0:oe.message,...c("entityType"),children:g.map(U=>s.jsx("option",{value:U,children:U},U))})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:"Email ID",required:!0,type:"email",maxLength:254,placeholder:"sample@mail.com",error:(Q=x.email)==null?void 0:Q.message,...c("email")}),s.jsx(ou,{required:!0,error:(Ae=x.phoneNumber)==null?void 0:Ae.message,countryCodeSelectProps:c("countryCode"),phoneInputProps:{placeholder:"Enter 10-digit phone number",maxLength:10,...I,onChange:U=>{U.target.value=U.target.value.replace(/\D/g,"").slice(0,10),I.onChange(U)}}})]})]}),s.jsxs(_s,{step:2,title:"Address Information",subtitle:"Enter the registered address.",children:[s.jsx(ge,{label:"Address Line 1",required:!0,maxLength:200,placeholder:"Enter address line 1",error:(De=x.address1)==null?void 0:De.message,...c("address1")}),s.jsx(ge,{label:"Address Line 2",maxLength:200,placeholder:"Enter address line 2 (optional)",error:(Oe=x.address2)==null?void 0:Oe.message,...c("address2")}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:"City",required:!0,maxLength:100,placeholder:"Enter city",error:(ue=x.city)==null?void 0:ue.message,...c("city")}),s.jsxs(xn,{label:T?"State":"Province",required:!0,error:(xe=x.state)==null?void 0:xe.message,...c("state"),children:[s.jsx("option",{value:"",children:T?"Select state":"Select province"}),P.map(U=>s.jsx("option",{value:U.code,children:U.name},U.code))]})]}),s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:T?"ZIP Code":"Postal Code",required:!0,maxLength:10,placeholder:T?"12345 or 12345-6789":"A1A 1A1",error:((R=x.zipCode)==null?void 0:R.message)??(O?`ZIP code does not match the selected state (${S}).`:void 0),...$,onChange:U=>{U.target.value=T?zi(U.target.value):gu(U.target.value),$.onChange(U)}}),s.jsxs(xn,{label:"Country",required:!0,error:(pe=x.country)==null?void 0:pe.message,...c("country"),children:[s.jsx("option",{value:"United States",children:"United States"}),s.jsx("option",{value:"Canada",children:"Canada"})]})]})]})]})]}),s.jsx(lu,{className:"px-6",onCancel:n,isSubmitting:o,submitLabel:"Save Changes",submittingLabel:"Saving…"})]})]})]}),document.body):null}function Ui(){const{selectedEntity:e}=zn(),t=ke(),[n,r]=j.useState(""),[a,i]=j.useState(""),[o,l]=j.useState(1),[c,d]=j.useState(lt),[u,m]=j.useState(null);j.useEffect(()=>{const v=window.setTimeout(()=>i(n.trim()),300);return()=>window.clearTimeout(v)},[n]),j.useEffect(()=>{l(1)},[a,c]);const{data:h,isLoading:f,isFetching:x,isError:p}=be({queryKey:["entities","mine","paged",a,o,c],queryFn:()=>bi({search:a||void 0,pageNumber:o,pageSize:c}),placeholderData:v=>v}),w=(h==null?void 0:h.items)??[],g=(h==null?void 0:h.totalCount)??0,k=x;return s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("button",{type:"button",onClick:()=>t("/dashboard"),className:"inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium text-slate-600 transition hover:bg-white hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#156bd5]",children:[s.jsx(f0,{}),"Back"]}),s.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>t("/create-entity/form",{state:{from:"/entities"}}),className:"inline-flex shrink-0 items-center gap-2 rounded-[14px] bg-[#156bd5] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1260be]",children:[s.jsx(p0,{}),"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:n,onChange:v=>r(v.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"})]})]}),u?s.jsx(wu,{open:!0,entity:u,onClose:()=>m(null)}):null,s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-black/[0.12] bg-white",children:[k?s.jsx(br,{label:"Loading organizations…"}):null,s.jsx("div",{className:"overflow-x-auto",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:f&&!h?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Loading organizations…"})}):p?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:"Unable to load organizations."})}):w.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:8,className:"py-10 text-center text-sm text-slate-400",children:a?"No organizations match your search.":"No organizations yet."})}):w.map(v=>s.jsx(h0,{entity:v,isSelected:v.entityId===(e==null?void 0:e.entityId),onEdit:m},v.entityId))})]})}),s.jsx(Qr,{page:o,pageSize:c,totalCount:g,onPageChange:l,onPageSizeChange:d,disabled:f||x})]})]})}function h0({entity:e,isSelected:t,onEdit:n}){var l;const r=en(e),a=Li(r),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:r})]})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx("span",{className:"font-mono text-[12px] text-[#374151]",children:qn(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(c0,{entity:e,onEdit:n})})]})}function f0(){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 p0(){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 Zi(e){return me(`/portal/federal-payments/${e}`)}function x0(e){return me(`/portal/federal-payments/form-types?entityId=${e}`)}function g0(e){const t=new URLSearchParams({formType:e});return me(`/portal/federal-payments/tax-type-codes?${t.toString()}`)}function Wi(e){return me("/portal/federal-payments",{method:"POST",body:e})}function Yi(e,t){return me(`/portal/federal-payments/${e}`,{method:"PATCH",body:t})}function y0(e){return me(`/portal/federal-payments/${e}/submit`,{method:"POST"})}function b0(e){return Zr(`/portal/federal-payments/${e}/pdf`,{responseType:"blob"})}function v0(e){return Zr(`/portal/state-payments/${e}/pdf`,{responseType:"blob"})}function j0(e){return Zr(`/portal/federal-payments/${e}/pdf-html`,{responseType:"text"})}function w0(e){return Zr(`/portal/state-payments/${e}/pdf-html`,{responseType:"text"})}function N0({entityId:e,status:t,category:n="all",pageNumber:r=1,pageSize:a=lt}){const i=new URLSearchParams({entityId:String(e),pageNumber:String(r),pageSize:String(a)});return t&&i.set("status",t),n&&n!=="all"?i.set("category",n):n==="all"&&i.set("category","all"),me(`/portal/remittance-payments?${i}`)}function S0(e,t="all"){const n=new URLSearchParams({entityId:String(e)});return t&&n.set("category",t),me(`/portal/remittance-payments/status-counts?${n}`)}function k0(e){return me("/portal/state-payments/states",{signal:e})}function C0(e,t,n){const r=new URLSearchParams({entityId:String(e),state:t});return me(`/portal/state-payments/payment-reasons?${r}`,{signal:n})}function A0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return me(`/portal/state-payments/validation-metadata?${a}`,{signal:r})}function P0(e,t,n,r){const a=new URLSearchParams({entityId:String(e),state:t,reason:n});return me(`/portal/state-payments/form-references?${a}`,{signal:r})}function Nu(e){return me(`/portal/state-payments/${e}`)}function E0(e){return me("/portal/state-payments",{method:"POST",body:e})}function I0(e,t){return me(`/portal/state-payments/${e}`,{method:"PATCH",body:t})}function _0(e){return me(`/portal/state-payments/${e}/submit`,{method:"POST"})}function T0({open:e,title:t,html:n,isLoading:r=!1,error:a=null,downloadFileName:i="payment.pdf",onDownload:o,onClose:l}){const[c,d]=j.useState(!1);j.useEffect(()=>{if(!e)return;const m=h=>{h.key==="Escape"&&l()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,l]);const u=async()=>{if(!(!o||c)){d(!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{d(!1)}}};return e?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:l}),s.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:[s.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 px-5 py-4",children:[s.jsx("h2",{id:"payment-pdf-title",className:"text-base font-semibold text-slate-900",children:t}),s.jsxs("div",{className:"flex items-center gap-2",children:[o?s.jsx("button",{type:"button",onClick:()=>void u(),disabled:c||r||!!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,s.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"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:r?s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"Loading…"}):a?s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-red-600",children:a}):n?s.jsx("iframe",{title:t,srcDoc:n,sandbox:"",className:"h-full w-full border-0 bg-white"}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-500",children:"No content available."})})]})]}):null}function pa({onViewPdf:e,isViewPdfLoading:t}){return s.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 F0({actionType:e,onView:t,onViewPdf:n,onEdit:r,onSubmit:a,isSubmitting:i=!1,isViewPdfLoading:o=!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: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"?s.jsx(pa,{onViewPdf:n,isViewPdfLoading:o}):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(pa,{onViewPdf:n,isViewPdfLoading:o}),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.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(pa,{onViewPdf:n,isViewPdfLoading:o})]})}function D0(e){const t=/^(\d{4})-Q([1-4])$/.exec(e);if(t)return`Q${t[2]} ${t[1]}`;if(e.length!==6)return e;const n=e.slice(0,4),r=Number.parseInt(e.slice(4,6),10);return Number.isNaN(r)||r<1||r>12?e:`Q${Math.ceil(r/3)} ${n}`}function R0(e){return{id:e.id,category:e.category,referenceNo:e.referenceNumber??"—",jurisdiction:e.jurisdiction,period:D0(e.taxPeriod),amount:e.amount,paymentDate:e.paymentDate,status:e.status,reason:e.reason,tab:Db(e.status)}}function $0({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 O0({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 L0({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 z0({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 M0({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 Su=[{key:"drafts",label:"DRAFTS",Icon:$0,iconClassName:"text-gray-500"},{key:"scheduled",label:"SCHEDULED",Icon:O0,iconClassName:"text-yellow-500"},{key:"submitted",label:"SUBMITTED TO FED/STATE",Icon:L0,iconClassName:"text-[#FF733D]"},{key:"rejected",label:"REJECTED",Icon:z0,iconClassName:"text-red-500"},{key:"paid",label:"PAID",Icon:M0,iconClassName:"text-green-500"}],q0={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 gl(e){return e!==null&&Su.some(t=>t.key===e)}function Hi({paymentsMode:e="all"}){var xe;const t=ke(),n=xt(),[r]=Wm(),{selectedEntity:a}=pt(),{onPaymentRequired:i}=zn(),o=(a==null?void 0:a.entityId)??null,l=r.get("tab"),[c,d]=j.useState(gl(l)?l:Bi),[u,m]=j.useState(e==="all"?"all":e),h=e!=="all"?e:u,[f,x]=j.useState(1),[p,w]=j.useState(lt),[g,k]=j.useState(null),[v,S]=j.useState(null),[E,T]=j.useState(null);j.useEffect(()=>{gl(l)&&d(l)},[l]),j.useEffect(()=>{x(1),w(lt)},[c,o,u]),j.useEffect(()=>{x(1)},[p]);const P=q0[c],O=be({queryKey:["remittance-payments","list",o,c,h,f,p],queryFn:()=>N0({entityId:o,status:c,category:h,pageNumber:f,pageSize:p}),enabled:o!==null,placeholderData:R=>R}),I=be({queryKey:["remittance-payments","status-counts",o,h],queryFn:()=>S0(o,h),enabled:o!==null}),$=O.isLoading,ne=O.isFetching,q=o!==null&&ne,K=j.useMemo(()=>{var R,pe,U,fe,Pe;return{drafts:((R=I.data)==null?void 0:R.drafts)??0,scheduled:((pe=I.data)==null?void 0:pe.scheduled)??0,submitted:((U=I.data)==null?void 0:U.submitted)??0,rejected:((fe=I.data)==null?void 0:fe.rejected)??0,paid:((Pe=I.data)==null?void 0:Pe.paid)??0}},[I.data]),ee=j.useMemo(()=>{var R;return(((R=O.data)==null?void 0:R.items)??[]).map(R0)},[O.data]),z=((xe=O.data)==null?void 0:xe.totalCount)??0,ae=$h({mutationFn:async R=>{try{R.category==="federal"?await y0(R.id):await _0(R.id)}catch(pe){if(pe instanceof gr&&pe.status===402&&i){const U=pe.extensions,fe={paymentType:(U==null?void 0:U.paymentType)??R.category,paymentId:(U==null?void 0:U.paymentId)??R.id,expectedAmount:(U==null?void 0:U.expectedAmount)??"0.00",currency:(U==null?void 0:U.currency)??"USD",federalRecordCount:(U==null?void 0:U.federalRecordCount)??0,stateRecordCount:(U==null?void 0:U.stateRecordCount)??0,feePerFederal:(U==null?void 0:U.feePerFederal)??null,feePerState:(U==null?void 0:U.feePerState)??null};i(fe);return}throw pe}},onSuccess:async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})},onError:()=>k(null),onSettled:()=>k(null)});j.useEffect(()=>{const R=async()=>{await n.invalidateQueries({queryKey:["remittance-payments"]}),await n.invalidateQueries({queryKey:["dashboard"]}),await n.invalidateQueries({queryKey:["federal-payments"]}),await n.invalidateQueries({queryKey:["state-payments"]})};return window.addEventListener(ai,R),()=>window.removeEventListener(ai,R)},[n]);const oe=R=>{k(`${R.category}-${R.id}`),ae.mutate(R)},Q=R=>{R.category==="federal"?t(`/payments/federal/${R.id}/view`):t(`/payments/state/${R.id}/view`)},Ae=R=>{R.category==="federal"?t(`/payments/federal/${R.id}/edit`):t(`/payments/state/${R.id}/edit`)},De=async R=>{const pe=`${R.category}-${R.id}`,U=`payment-${R.referenceNo}.pdf`;S(pe),T({title:`Payment PDF — ${R.referenceNo}`,html:null,category:R.category,paymentId:R.id,downloadFileName:U,isLoading:!0,error:null});try{const fe=R.category==="federal"?await j0(R.id):await w0(R.id);T({title:`Payment PDF — ${R.referenceNo}`,html:fe,category:R.category,paymentId:R.id,downloadFileName:U,isLoading:!1,error:null})}catch(fe){T({title:`Payment PDF — ${R.referenceNo}`,html:null,category:R.category,paymentId:R.id,downloadFileName:U,isLoading:!1,error:at(fe,"Unable to load payment PDF.")})}finally{S(null)}},Oe=async()=>{if(!E)throw new Error("No payment selected");return E.category==="federal"?b0(E.paymentId):v0(E.paymentId)},ue=()=>T(null);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(xa,{}),"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(xa,{}),"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(xa,{}),"Add Local Payments",s.jsx("span",{className:"text-xs font-medium",children:"(Coming Soon)"})]})]}),s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[q?s.jsx(br,{label:"Loading payments…"}):null,s.jsx("div",{className:"flex flex-wrap gap-1 border-b border-slate-200 px-4 pt-4",children:Su.map(R=>{const pe=c===R.key,U=R.Icon;return s.jsxs("button",{type:"button",onClick:()=>{d(R.key),t(ea(R.key),{replace:!0})},className:`mb-[-1px] flex items-center gap-2 border-b-2 px-4 py-3 text-xs font-semibold tracking-wide transition ${pe?"border-gov-600 text-gov-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[s.jsx(U,{className:`shrink-0 ${R.iconClassName}`}),R.label," (",K[R.key],")"]},R.key)})}),s.jsxs("div",{className:"border-b border-slate-200 px-6 py-4",children:[s.jsx("label",{className:"mb-1.5 block text-sm text-slate-600",children:"Select Payment Type"}),s.jsxs("select",{value:u,onChange:R=>m(R.target.value),disabled:e!=="all",className:"w-full max-w-xs rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 focus:border-gov-400 focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:opacity-60",children:[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:P.columns.map(R=>s.jsx("th",{className:"px-6 py-3",children:R},R))})}),s.jsx("tbody",{children:$&&!O.data?s.jsx("tr",{children:s.jsx("td",{colSpan:P.columns.length,className:"px-6 py-12 text-center text-slate-500",children:"Loading payments…"})}):ee.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:P.columns.length,className:"px-6 py-12 text-center text-slate-500",children:P.emptyMessage})}):ee.map(R=>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"?`#${R.id}`:R.referenceNo}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.jurisdiction}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.period}),s.jsx("td",{className:"px-6 py-4 font-medium text-slate-900",children:Kr(R.amount)}),c!=="paid"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.paymentDate}):null,c==="rejected"?s.jsx("td",{className:"px-6 py-4 text-slate-700",children:R.reason??"—"}):null,s.jsx("td",{className:"px-6 py-4",children:s.jsx(F0,{actionType:P.actionType,onView:()=>Q(R),onViewPdf:()=>De(R),onEdit:()=>Ae(R),onSubmit:()=>oe(R),isSubmitting:g===`${R.category}-${R.id}`,isViewPdfLoading:v===`${R.category}-${R.id}`})})]},`${R.category}-${R.id}`))})]})}),s.jsx(Qr,{page:f,pageSize:p,totalCount:z,onPageChange:x,onPageSizeChange:w,disabled:$||o===null||ne})]}),s.jsx(T0,{open:E!==null,title:(E==null?void 0:E.title)??"Payment PDF",html:(E==null?void 0:E.html)??null,downloadFileName:E==null?void 0:E.downloadFileName,isLoading:(E==null?void 0:E.isLoading)??!1,error:(E==null?void 0:E.error)??null,onDownload:E&&!E.error?Oe:void 0,onClose:ue})]})}function xa(){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 Jr({entityId:e,pageNumber:t=1,pageSize:n=lt}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return me(`/portal/bank-accounts?${r}`)}function B0(e){return me("/portal/bank-accounts",{method:"POST",body:e})}function ku(e,t){return me(`/portal/bank-accounts/${e}`,{method:"PATCH",body:t})}function wn({title:e,children:t,isFirst:n=!1,headerAction:r}){return s.jsxs("section",{className:n?"":"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}),r]}),t]})}const dr=17,Cu=9;function Hn(e,t){return e.replace(/\D/g,"").slice(0,t)}const Au=["Checking","Savings"],V0=Xt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dr} digits`),confirmAccountNumber:_().min(1,"Please confirm the account number").regex(/^\d{1,17}$/,`Account number must be 1 to ${dr} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Xs(Au,{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 U0({entityId:e,onCancel:t,onSuccess:n}){const r=xt(),{showSuccess:a,showError:i}=Vs(),[o,l]=j.useState(null),[c,d]=j.useState(!1),{control:u,handleSubmit:m,formState:{errors:h}}=$t({resolver:Lt(V0),defaultValues:{accountNumber:"",confirmAccountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}}),f=m(async x=>{l(null),d(!0);try{const p=await B0({entityId:e,bankName:x.bankName.trim(),accountNumber:x.accountNumber,routingNumber:x.routingNumber,accountType:x.accountType});await r.invalidateQueries({queryKey:["bank-accounts",e]}),a("Bank Account Added","Bank account added successfully."),n(p.bankAccountDetailId)}catch(p){const w=at(p,"Unable to save bank account.");l(w),i("Action Not Completed",w)}finally{d(!1)}});return s.jsxs("form",{noValidate:!0,onSubmit:x=>{x.preventDefault(),x.stopPropagation(),f(x)},className:"space-y-6",children:[s.jsxs(au,{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(ze,{name:"accountNumber",control:u,render:({field:x})=>{var p;return s.jsx(ge,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:w=>x.onChange(Hn(w.target.value,dr)),onBlur:x.onBlur,error:(p=h.accountNumber)==null?void 0:p.message})}}),s.jsx(ze,{name:"confirmAccountNumber",control:u,render:({field:x})=>{var p;return s.jsx(ge,{label:"Confirm Account Number",required:!0,placeholder:"Re-enter account number",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:w=>x.onChange(Hn(w.target.value,dr)),onBlur:x.onBlur,error:(p=h.confirmAccountNumber)==null?void 0:p.message})}}),s.jsx(ze,{name:"routingNumber",control:u,render:({field:x})=>{var p;return s.jsx(ge,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:x.value,onChange:w=>x.onChange(Hn(w.target.value,Cu)),onBlur:x.onBlur,error:(p=h.routingNumber)==null?void 0:p.message})}}),s.jsx(ze,{name:"accountType",control:u,render:({field:x})=>{var p;return s.jsx(xn,{label:"Account Type",required:!0,value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(p=h.accountType)==null?void 0:p.message,children:Au.map(w=>s.jsx("option",{value:w,children:w},w))})}})]}),s.jsx(ze,{name:"bankName",control:u,render:({field:x})=>{var p;return s.jsx(ge,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:x.value,onChange:x.onChange,onBlur:x.onBlur,error:(p=h.bankName)==null?void 0:p.message})}})]}),o?s.jsx(zt,{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 Pu({open:e,entityId:t,onClose:n,onAccountAdded:r}){const[a,i]=j.useState("choose");if(j.useEffect(()=>{e||i("choose")},[e]),j.useEffect(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,n]),!e)return null;const o=a==="manual";return 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:n}),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(U0,{entityId:t,onCancel:()=>i("choose"),onSuccess:l=>{r==null||r(l),n()}}):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(Z0,{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(W0,{className:"h-6 w-6"})}),s.jsx("span",{className:"text-base font-medium text-slate-400",children:"Connect with Plaid"})]})]})]})})]})}function Z0({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 W0({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 Y0=12,H0=["January","February","March","April","May","June","July","August","September","October","November","December"];function fn(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function Ts(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10)-1,a=Number.parseInt(t[3],10),i=new Date(n,r,a);return i.getFullYear()!==n||i.getMonth()!==r||i.getDate()!==a?null:i}function Eu(e=new Date){const t=new Date(e);return e.getHours()>=Y0&&t.setDate(t.getDate()+1),t.setHours(0,0,0,0),fn(t)}function Iu(e=new Date){const t=new Date(e);return t.setFullYear(t.getFullYear()+1),t.setHours(0,0,0,0),fn(t)}function K0(e=18,t=new Date){const n=new Date(t);return n.setFullYear(n.getFullYear()-e),n.setHours(0,0,0,0),fn(n)}function Q0(e,t,n=new Date){const r=Ts(e);if(!r)return!1;const a=new Date(n);return a.setFullYear(a.getFullYear()-t),a.setHours(0,0,0,0),r.setHours(0,0,0,0),r<=a}function J0(e){const t=e.getDay();return t!==0&&t!==6}function ei(e,t=new Date){if(!J0(e))return!1;const n=fn(e);return n>=Eu(t)&&n<=Iu(t)}function ta(e,t=new Date){const n=Ts(e);return n?ei(n,t):!1}function G0(e,t){return`${H0[t]} ${e}`}function X0(e,t){const n=new Date(e,t,1),r=new Date(e,t+1,0).getDate(),a=n.getDay(),i=[];for(let o=0;o<a;o+=1)i.push(null);for(let o=1;o<=r;o+=1)i.push(new Date(e,t,o));return i}function yl(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Gr(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 _u({label:e,required:t=!1,htmlFor:n,info:r}){return s.jsxs("label",{htmlFor:n,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]}),r?s.jsx("span",{title:r,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":r,children:"i"}):null]})}function J({label:e,required:t,error:n,info:r,children:a}){return s.jsxs("div",{children:[s.jsx(_u,{label:e,required:t,info:r}),a,n?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:n}):null]})}const Tu=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 te(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]"}`:Tu(e)}function Kn(e){return`${Tu(e)} appearance-none`}function Zn({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 Tr({children:e}){return s.jsx("div",{className:"relative",children:e})}function Fu({value:e,onChange:t,entityId:n,entityType:r="",bankAccounts:a,isLoading:i=!1,disabled:o=!1,error:l,label:c="Bank Account Number"}){const[d,u]=j.useState(!1),[m,h]=j.useState(!1),f=j.useRef(null),x=a.find(w=>String(w.bankAccountDetailId)===e);j.useEffect(()=>{if(!d)return;const w=g=>{var k;(k=f.current)!=null&&k.contains(g.target)||u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[d]);const p=w=>{t(String(w)),h(!1),u(!1)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,className:"relative",children:[s.jsx(_u,{label:c,required:!0}),s.jsxs("button",{type:"button",disabled:o||!n,onClick:()=>u(w=>!w),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:x?"text-slate-900":"text-slate-400",children:i?"Loading accounts…":x?yl(x.accountNumber):"Bank account number"}),s.jsx(tv,{className:`shrink-0 text-slate-400 transition ${d?"rotate-180":""}`})]}),l?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:l}):null,d?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:()=>{u(!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(ev,{}),"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(w=>{const g=String(w.bankAccountDetailId)===e;return s.jsxs("button",{type:"button",onClick:()=>{t(String(w.bankAccountDetailId)),u(!1)},className:`flex w-full items-center gap-3 px-4 py-3 text-left transition hover:bg-slate-50 ${g?"bg-gov-50":""}`,children:[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:Li(w.bankName)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-semibold text-slate-900",children:w.bankName}),s.jsxs("span",{className:"block truncate text-xs text-slate-500",children:[yl(w.accountNumber),r?` · ${r}`:` · ${w.accountType}`]})]})]},w.bankAccountDetailId)})})]}):null]}),s.jsx(Pu,{open:m,entityId:n,onClose:()=>h(!1),onAccountAdded:p})]})}function ev(){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 tv({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 nv(e){const t=e.address2?`, ${e.address2}`:"";return`${e.address1}${t}, ${e.city}, ${e.state} ${e.zipCode}`}function Xr({entity:e,remittanceAmount:t="—",className:n=""}){if(!e)return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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 r=en(e);return s.jsxs("aside",{className:`overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm ${n}`,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(kr,{label:"Entity Name",value:r}),s.jsx(kr,{label:"Tax ID",value:qn(e.idNumber)}),s.jsx(kr,{label:"Email ID",value:e.email}),s.jsx(kr,{label:"Phone Number",value:$n(e.phoneNumber)}),s.jsx(kr,{label:"Address",value:nv(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 kr({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 rv=[0,1,3,4,6,7,9,10],sv=[0,1,2,3,4,5,6,7,8,9,10],av=[0,1,2,3,4,5,6,8,9,10,11],iv=[0,1,2,3,4,5,6,7,9,10,11],ov=["720","941"],lv=["706-GS (D)","706-GS (T)","926","940","943","944","945","1042","2438","3520","6069","8752","CT-1"],cv=["7200D"],uv=["8963"];function Du(e){return ov.includes(e)?rv:lv.includes(e)?sv:cv.includes(e)?av:uv.includes(e)?iv:[]}function dv(e){return e.length!==6?"":`${e.slice(0,4)}-${e.slice(4,6)}`}function Fs(e){if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10);return Number.isNaN(t)||Number.isNaN(n)||n<1||n>12?null:{year:t,month:n-1}}function mv(e,t){return`${e}${String(t+1).padStart(2,"0")}`}function Ru(){const e=new Date().getFullYear();return{minYear:e-2,maxYear:e}}const Ds={941:"94105",944:"94405","CT-1":"10005"},Cr={socialSecurity:"Social Security",medicare:"Medicare",withheld:"Withheld",tier1:"Tier 1(FICA)",tier2:"Tier 2 (Industry)"},Rs={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 Ki(e,t){return!e||!t?!1:Ds[e]===t}function na(e,t){return e==="CT-1"&&t===Ds["CT-1"]}function hv(e,t){return e==="941"&&t===Ds[941]||e==="944"&&t===Ds[944]}function fv(e){return e==="CT-1"?{code1:Cr.tier1,code2:Cr.tier2,code3:""}:{code1:Cr.socialSecurity,code2:Cr.medicare,code3:Cr.withheld}}function $s(e){return Rs.regex.test(e)}const pv=/^(?:\d{0,8}(?:\.\d{0,2})?|100000000(?:\.\d{0,2})?)$/,cs=1e8;function xv(e){if(!e)return"";let t="",n=!1;for(const c of e)c>="0"&&c<="9"?t+=c:c==="."&&!n&&(t+=c,n=!0);const r=t.indexOf(".");let a=r===-1?t:t.slice(0,r);const i=r===-1?"":t.slice(r+1,r+3),o=r!==-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>cs&&(a=String(cs))}let l=r===-1?a:`${a}.${i}`;if(o&&(l=`${a}.`),pv.test(l)){if(!l.endsWith(".")&&l!==""){const c=Number.parseFloat(l);if(!Number.isNaN(c)&&c>cs)return String(cs)}return l}return""}function $u(e){return $s(e)?Number.parseFloat(e):null}function gv(e,t,n,r){const a=[e,t];return r&&a.push(n),a.reduce((i,o)=>{const l=$u(o);return l===null?i:i+l},0)}function yv(e,t){return Math.abs(e-t)<.005}function bv(e,t,n,r,a){if(!Ki(e,t))return{subcategoryCode1:null,subcategoryCode2:null,subcategoryCode3:null};const i=na(e,t);return{subcategoryCode1:n.trim()?"1":null,subcategoryCode2:r.trim()?"2":null,subcategoryCode3:!i&&a.trim()?"3":null}}const vv=["Su","Mo","Tu","We","Th","Fr","Sa"];function jv(){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 Ou({value:e,onChange:t,disabled:n=!1,hasError:r=!1}){const a=Ts(e),i=Eu(),o=Iu(),[l,c]=j.useState(!1),[d,u]=j.useState(()=>a??Ts(i)??new Date),m=j.useRef(null),h=j.useId();j.useEffect(()=>{a&&u(a)},[e]),j.useEffect(()=>{if(!l)return;const g=k=>{var v;(v=m.current)!=null&&v.contains(k.target)||c(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]);const f=j.useMemo(()=>X0(d.getFullYear(),d.getMonth()),[d]),x=j.useMemo(()=>{const g=new Date(d.getFullYear(),d.getMonth()-1,1),k=new Date(g.getFullYear(),g.getMonth()+1,0);return fn(k)>=i},[d,i]),p=j.useMemo(()=>{const g=new Date(d.getFullYear(),d.getMonth()+1,1);return fn(g)<=o},[d,o]),w=g=>{ei(g)&&(t(fn(g)),c(!1))};return s.jsxs("div",{ref:m,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:h,type:"text",readOnly:!0,disabled:n,value:e,placeholder:"YYYY-MM-DD",onClick:()=>!n&&c(g=>!g),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>c(g=>!g),className:"shrink-0 rounded p-0.5 text-gov-600 transition hover:bg-gov-50 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Open settlement date picker",children:s.jsx(jv,{})})]}),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:!x,onClick:()=>u(g=>new Date(g.getFullYear(),g.getMonth()-1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Previous month",children: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:G0(d.getFullYear(),d.getMonth())}),s.jsx("button",{type:"button",disabled:!p,onClick:()=>u(g=>new Date(g.getFullYear(),g.getMonth()+1,1)),className:"rounded p-1 text-slate-500 transition hover:bg-white hover:text-slate-800 disabled:cursor-not-allowed disabled:opacity-30","aria-label":"Next month",children: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:vv.map(g=>s.jsx("div",{className:"py-1",children:g},g))}),s.jsx("div",{className:"grid grid-cols-7 gap-1 p-3 pt-1",children:f.map((g,k)=>{if(!g)return s.jsx("div",{},`empty-${k}`);const v=fn(g),S=e===v,E=!ei(g);return s.jsx("button",{type:"button","aria-disabled":E,onClick:()=>w(g),className:`rounded-lg px-1 py-2 text-sm transition ${E?"cursor-not-allowed text-slate-300 hover:bg-sky-50":S?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:g.getDate()},v)})})]}):null]})}function Ir({value:e,onChange:t,onBlur:n,name:r,disabled:a=!1,readOnly:i=!1,placeholder:o="0.00",hasError:l=!1}){return s.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",name:r,value:e,disabled:a,readOnly:i,placeholder:o,className:te(l,i),onChange:c=>t(xv(c.target.value)),onBlur:n})}const wv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Nv(){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 Sv({value:e,onChange:t,disabled:n=!1,hasError:r=!1,disabledMonths:a=[]}){const{minYear:i,maxYear:o}=Ru(),l=Fs(e),[c,d]=j.useState(!1),[u,m]=j.useState((l==null?void 0:l.year)??o),h=j.useRef(null),f=j.useId();j.useEffect(()=>{l&&m(l.year)},[e]),j.useEffect(()=>{if(!c)return;const v=S=>{var E;(E=h.current)!=null&&E.contains(S.target)||d(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]);const x=dv(e),p=v=>!!a.includes(v),w=v=>{p(v)||(t(mv(u,v)),d(!1))},g=u>i,k=u<o;return s.jsxs("div",{ref:h,className:"relative",children:[s.jsxs("div",{className:`flex items-center gap-2 rounded-lg border bg-white px-3 py-2.5 transition ${r?"border-red-300":"border-slate-200 focus-within:border-gov-400 focus-within:ring-2 focus-within:ring-gov-200"} ${n?"cursor-not-allowed bg-[#F9FAFB] opacity-60":""}`,children:[s.jsx("input",{id:f,type:"text",readOnly:!0,disabled:n,value:x,placeholder:"YYYY-MM",onClick:()=>!n&&d(v=>!v),className:"w-full cursor-pointer border-0 bg-transparent p-0 text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-0 disabled:cursor-not-allowed"}),s.jsx("button",{type:"button",disabled:n,onClick:()=>d(v=>!v),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(Nv,{})})]}),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:!g,onClick:()=>m(v=>v-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:u}),s.jsx("button",{type:"button",disabled:!k,onClick:()=>m(v=>v+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:wv.map((v,S)=>{const E=(l==null?void 0:l.year)===u&&l.month===S&&e.length===6,T=p(S);return s.jsx("button",{type:"button","aria-disabled":T,onClick:()=>w(S),className:`rounded-lg px-2 py-2.5 text-sm transition ${T?"cursor-not-allowed text-slate-300 hover:bg-sky-50":E?"bg-sky-100 font-semibold text-slate-900":"font-medium text-slate-800 hover:bg-slate-50"}`,children:v},v)})})]}):null]})}const Lu="Active",kv="Inactive";function vr(e){return(e.status??Lu).trim().toLowerCase()==="active"}function Cv(e){return vr(e)?kv:Lu}function Av(e){return vr(e)?"Deactivate":"Activate"}function Qi(e){var t;return((t=e==null?void 0:e.accountType)==null?void 0:t.trim().toLowerCase())==="individual"}function Pv(e){return Qi(e)?"/payments/federal/individual-enrollment":"/payments/federal/authorization"}function zu(e){const t=bv(e.taxFormType,e.taxTypeCode,e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??""),n=na(e.taxFormType,e.taxTypeCode);return{subcategoryCode1:t.subcategoryCode1,subcategoryAmount1:e.subcategoryAmount1?Number.parseFloat(e.subcategoryAmount1):null,subcategoryCode2:t.subcategoryCode2,subcategoryAmount2:e.subcategoryAmount2?Number.parseFloat(e.subcategoryAmount2):null,subcategoryCode3:t.subcategoryCode3,subcategoryAmount3:!n&&e.subcategoryAmount3?Number.parseFloat(e.subcategoryAmount3):null}}function Ji(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),...zu(t)}}function Gi(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),...zu(e)}}const Xi="federal-payment-draft";function eo(e){sessionStorage.setItem(Xi,JSON.stringify(e))}function ra(){const e=sessionStorage.getItem(Xi);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function to(){sessionStorage.removeItem(Xi)}function Ev(e,t={}){return{federalPaymentId:e.federalPaymentId,enrollmentId:e.enrollmentId,taxpayerPin:e.taxpayerPin??"",secondaryTin:e.secondaryTin??"",bankAccountDetailId:e.bankAccountDetailId?String(e.bankAccountDetailId):"",routingNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:t.accountType??"",bankName:t.bankName??"",taxFormType:e.taxFormType,taxTypeCode:e.taxTypeCode,taxPeriod:e.taxPeriod,settlementDate:e.settlementDate,paymentAmount:String(e.paymentAmount),subcategoryAmount1:e.subcategoryAmount1!=null?String(e.subcategoryAmount1):"",subcategoryAmount2:e.subcategoryAmount2!=null?String(e.subcategoryAmount2):"",subcategoryAmount3:e.subcategoryAmount3!=null?String(e.subcategoryAmount3):""}}const Iv=Xt({taxpayerPin:_().max(4,"Taxpayer PIN must not exceed 4 characters").optional(),secondaryTin:_().max(9,"Secondary TIN must not exceed 9 characters").optional(),bankAccountDetailId:_().min(1,"Bank account is required"),routingNumber:_().optional(),accountType:_().optional(),bankName:_().optional(),taxFormType:_().min(1,"Tax form type is required"),taxTypeCode:_().min(1,"Payment type is required"),taxPeriod:_().min(1,"This field is required").regex(/^\d{6}$/,"Tax period must be in YYYY-MM format").refine(e=>{const t=Fs(e);if(!t)return!1;const{minYear:n,maxYear:r}=Ru();return t.year>=n&&t.year<=r},"Tax period must be within the last 3 years"),settlementDate:_().min(1,"This field is required").refine(e=>ta(e),"Settlement date must be a weekday within the allowed range"),paymentAmount:_().min(1,"This field is required").refine(e=>$s(e),Rs.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=Fs(e.taxPeriod);c&&Du(e.taxFormType).includes(c.month)&&t.addIssue({code:Qt.custom,message:"Tax period must be a valid month for the selected tax form",path:["taxPeriod"]})}if(!Ki(e.taxFormType,e.taxTypeCode))return;const n=na(e.taxFormType,e.taxTypeCode),r=hv(e.taxFormType,e.taxTypeCode),a=(c,d,u)=>{if(!(c!=null&&c.trim())){u&&t.addIssue({code:Qt.custom,message:"This field is required",path:[d]});return}$s(c)||t.addIssue({code:Qt.custom,message:Rs.errorMessage,path:[d]})};a(e.subcategoryAmount1,"subcategoryAmount1",!0),a(e.subcategoryAmount2,"subcategoryAmount2",!0),a(e.subcategoryAmount3,"subcategoryAmount3",r);const i=$u(e.paymentAmount),o=gv(e.subcategoryAmount1??"",e.subcategoryAmount2??"",e.subcategoryAmount3??"",r);i!==null&&!yv(i,o)&&t.addIssue({code:Qt.custom,message:"Payment amount must equal the sum of subcategory amounts",path:["paymentAmount"]}),n&&((l=e.subcategoryAmount3)!=null&&l.trim())&&t.addIssue({code:Qt.custom,message:"Subcategory amount 3 is not used for CT-1 payments",path:["subcategoryAmount3"]})}),us="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function ga(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 _v={taxpayerPin:"",secondaryTin:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:"",taxFormType:"",taxTypeCode:"",taxPeriod:"",settlementDate:"",paymentAmount:"",subcategoryCode1:"",subcategoryAmount1:"",subcategoryCode2:"",subcategoryAmount2:"",subcategoryCode3:"",subcategoryAmount3:""};function Tv(e,t){if(e)return ga(e);if(t!=null&&t.paymentDraft)return ga(t.paymentDraft);const n=ra();return n?ga(n):_v}function Mu({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var et,tt,jt,gt,wt,Mt,Pt,qt,Et,Nt,It,_t,Bt;const a=ke(),i=Se(),o=xt(),l=Bn(i.state,Ge()),c=i.state,d=j.useMemo(()=>t??(c==null?void 0:c.paymentDraft)??ra()??null,[t,c==null?void 0:c.paymentDraft]),u=j.useRef(d==null?void 0:d.federalPaymentId),m=j.useRef(d==null?void 0:d.enrollmentId),[h,f]=j.useState(null),[x,p]=j.useState(!1),w=j.useMemo(()=>Tv(t,c),[t,c==null?void 0:c.paymentDraft,i.key]);j.useEffect(()=>{d!=null&&d.federalPaymentId&&(u.current=d.federalPaymentId),d!=null&&d.enrollmentId&&(m.current=d.enrollmentId)},[d==null?void 0:d.federalPaymentId,d==null?void 0:d.enrollmentId]);const{data:g=[],isLoading:k}=be({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),v=j.useMemo(()=>g.filter(vr),[g]),{data:S=[],isLoading:E}=be({queryKey:["federal-form-types",e==null?void 0:e.entityId],queryFn:()=>x0(e.entityId),enabled:e!==null}),{register:T,control:P,handleSubmit:O,watch:I,setValue:$,trigger:ne,formState:{errors:q}}=$t({resolver:Lt(Iv),defaultValues:w}),K=I("bankAccountDetailId"),ee=I("paymentAmount"),z=I("taxFormType"),ae=I("taxTypeCode"),oe=I("taxPeriod"),Q=I("settlementDate"),Ae=I("subcategoryAmount1"),De=I("subcategoryAmount2"),Oe=I("subcategoryAmount3"),ue=j.useRef(z),xe=j.useMemo(()=>z?Du(z):[],[z]),R=j.useMemo(()=>Ki(z,ae),[z,ae]),pe=j.useMemo(()=>na(z,ae),[z,ae]),{data:U=[],isLoading:fe}=be({queryKey:["federal-tax-type-codes",z],queryFn:()=>g0(z),enabled:!!z});j.useEffect(()=>{ue.current&&ue.current!==z&&$("taxTypeCode",""),ue.current=z},[z,$]),j.useEffect(()=>{if(!oe||!z)return;const M=Fs(oe);M&&xe.includes(M.month)&&$("taxPeriod","")},[z,oe,xe,$]),j.useEffect(()=>{Q&&(ta(Q)||$("settlementDate",""))},[Q,$]),j.useEffect(()=>{if(!R){$("subcategoryCode1",""),$("subcategoryCode2",""),$("subcategoryCode3",""),$("subcategoryAmount1",""),$("subcategoryAmount2",""),$("subcategoryAmount3","");return}const M=fv(z);$("subcategoryCode1",M.code1),$("subcategoryCode2",M.code2),$("subcategoryCode3",pe?"":M.code3),pe&&$("subcategoryAmount3","")},[R,z,pe,$]),j.useEffect(()=>{R&&(ne("paymentAmount"),ne("subcategoryAmount1"),ne("subcategoryAmount2"),ne("subcategoryAmount3"))},[Ae,De,Oe,R,ne]),j.useEffect(()=>{const M=v.find(de=>String(de.bankAccountDetailId)===K);if(!M){K&&($("bankAccountDetailId",""),$("routingNumber",""),$("accountType",""),$("bankName",""));return}$("routingNumber",M.routingNumber),$("accountType",M.accountType),$("bankName",M.bankName)},[v,K,$]);const Pe=M=>{const de=v.find(b=>String(b.bankAccountDetailId)===M.bankAccountDetailId);return{federalPaymentId:u.current,enrollmentId:m.current??(d==null?void 0:d.enrollmentId),form8655AuthorizationId:d==null?void 0:d.form8655AuthorizationId,form9783EnrollmentId:d==null?void 0:d.form9783EnrollmentId,taxpayerPin:M.taxpayerPin??"",secondaryTin:M.secondaryTin??"",bankAccountDetailId:M.bankAccountDetailId,routingNumber:M.routingNumber??(de==null?void 0:de.routingNumber)??"",accountNumber:(de==null?void 0:de.accountNumber)??"",accountType:M.accountType??(de==null?void 0:de.accountType)??"",bankName:M.bankName??(de==null?void 0:de.bankName)??"",taxFormType:M.taxFormType,taxTypeCode:M.taxTypeCode,taxPeriod:M.taxPeriod,settlementDate:M.settlementDate,paymentAmount:M.paymentAmount,subcategoryCode1:M.subcategoryCode1,subcategoryAmount1:M.subcategoryAmount1,subcategoryCode2:M.subcategoryCode2,subcategoryAmount2:M.subcategoryAmount2,subcategoryCode3:M.subcategoryCode3,subcategoryAmount3:M.subcategoryAmount3}},Xe=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},le=async M=>{if(!e)return null;if(M.federalPaymentId){const b=await Yi(M.federalPaymentId,Gi(M));return u.current=b.federalPaymentId,m.current=b.enrollmentId,b}const de=await Wi(Ji(e.entityId,M));return u.current=de.federalPaymentId,m.current=de.enrollmentId,de},Ne=O(async M=>{if(!(n||!e)){f(null),p(!0);try{const de=Pe(M),b=await le(de);if(!b)return;const C={...de,federalPaymentId:b.federalPaymentId,enrollmentId:b.enrollmentId};await Xe(),eo(C),a(Pv(e),{state:{from:l,paymentDraft:C}})}catch(de){f(at(de,"Failed to save payment details."))}finally{p(!1)}}}),qe=O(async M=>{if(!(!e||n)){f(null),p(!0);try{const de=Pe(M);await le(de),await Xe(),to(),a(Ge())}catch(de){f(at(de,"Failed to save draft."))}finally{p(!1)}}}),He=()=>{if(r){r();return}a(l)},re=e?en(e):"Entity";return s.jsxs("form",{onSubmit:Ne,noValidate:!0,className:"w-full space-y-6",children:[h?s.jsx(zt,{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:re}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(ee),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(wn,{title:"Enrolment Details",isFirst:!0,children:s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Taxpayer PIN",required:!0,error:(et=q.taxpayerPin)==null?void 0:et.message,children:s.jsx("input",{placeholder:"Taxpayer PIN",className:te(!!q.taxpayerPin),maxLength:4,disabled:n,...T("taxpayerPin")})}),s.jsx(J,{label:"Secondary TIN",error:(tt=q.secondaryTin)==null?void 0:tt.message,children:s.jsx("input",{placeholder:"Secondary TIN",className:te(!!q.secondaryTin),maxLength:9,disabled:n,...T("secondaryTin")})}),s.jsx(ze,{name:"bankAccountDetailId",control:P,render:({field:M})=>{var de;return s.jsx(Fu,{value:M.value,onChange:M.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:v,isLoading:k,disabled:!e||n,error:(de=q.bankAccountDetailId)==null?void 0:de.message})}}),s.jsx(J,{label:"Routing Number",required:!0,error:(jt=q.routingNumber)==null?void 0:jt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Routing Number",className:te(!!q.routingNumber,!0),...T("routingNumber")})}),s.jsx(J,{label:"Account Type",required:!0,error:(gt=q.accountType)==null?void 0:gt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Account Type",className:te(!!q.accountType,!0),...T("accountType")})}),s.jsx(J,{label:"Bank Name",required:!0,error:(wt=q.bankName)==null?void 0:wt.message,children:s.jsx("input",{readOnly:!0,placeholder:"Bank Name",className:te(!!q.bankName,!0),...T("bankName")})})]})}),s.jsx(wn,{title:"Federal Payment",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Tax Form Type",required:!0,error:(Mt=q.taxFormType)==null?void 0:Mt.message,children:s.jsxs(Tr,{children:[s.jsxs("select",{className:Kn(!!q.taxFormType),disabled:E||!e||n,...T("taxFormType"),children:[s.jsx("option",{value:"",children:E?"Loading form types…":"Select form type"}),S.map(M=>s.jsx("option",{value:M.value,children:M.value},M.value))]}),s.jsx(Zn,{})]})}),s.jsx(J,{label:"Payment Type",required:!0,error:(Pt=q.taxTypeCode)==null?void 0:Pt.message,children:s.jsxs(Tr,{children:[s.jsxs("select",{className:Kn(!!q.taxTypeCode),disabled:!z||fe||n,...T("taxTypeCode"),children:[s.jsx("option",{value:"",children:z?fe?"Loading payment types…":"Select payment type":"Select tax form first"}),U.map(M=>s.jsxs("option",{value:M.code,children:[M.code," - ",M.codeName]},M.code))]}),s.jsx(Zn,{})]})}),s.jsx(J,{label:"Tax Period",required:!0,error:(qt=q.taxPeriod)==null?void 0:qt.message,children:s.jsx(ze,{name:"taxPeriod",control:P,render:({field:M})=>s.jsx(Sv,{value:M.value,onChange:M.onChange,hasError:!!q.taxPeriod,disabled:!z||n,disabledMonths:xe})})})]}),s.jsxs("div",{className:"grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",children:[s.jsx(J,{label:"Settlement Date",required:!0,error:(Et=q.settlementDate)==null?void 0:Et.message,children:s.jsx(ze,{name:"settlementDate",control:P,render:({field:M})=>s.jsx(Ou,{value:M.value,onChange:M.onChange,hasError:!!q.settlementDate,disabled:n})})}),s.jsx(J,{label:"Payment Amount",required:!0,error:(Nt=q.paymentAmount)==null?void 0:Nt.message,children:s.jsx(ze,{name:"paymentAmount",control:P,render:({field:M})=>s.jsx(Ir,{name:M.name,value:M.value,onChange:M.onChange,onBlur:M.onBlur,disabled:n,hasError:!!q.paymentAmount})})})]}),R?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Subcategory Code 1",children:s.jsx("input",{readOnly:!0,className:te(!1,!0),...T("subcategoryCode1")})}),s.jsx(J,{label:"Subcategory Code 2",children:s.jsx("input",{readOnly:!0,className:te(!1,!0),...T("subcategoryCode2")})}),pe?null:s.jsx(J,{label:"Subcategory Code 3",children:s.jsx("input",{readOnly:!0,className:te(!1,!0),...T("subcategoryCode3")})})]}),s.jsxs("div",{className:us,children:[s.jsx(J,{label:"Subcategory Amount 1",required:!0,error:(It=q.subcategoryAmount1)==null?void 0:It.message,children:s.jsx(ze,{name:"subcategoryAmount1",control:P,render:({field:M})=>s.jsx(Ir,{name:M.name,value:M.value??"",onChange:M.onChange,onBlur:M.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!q.subcategoryAmount1})})}),s.jsx(J,{label:"Subcategory Amount 2",required:!0,error:(_t=q.subcategoryAmount2)==null?void 0:_t.message,children:s.jsx(ze,{name:"subcategoryAmount2",control:P,render:({field:M})=>s.jsx(Ir,{name:M.name,value:M.value??"",onChange:M.onChange,onBlur:M.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!q.subcategoryAmount2})})}),pe?null:s.jsx(J,{label:"Subcategory Amount 3",required:!0,error:(Bt=q.subcategoryAmount3)==null?void 0:Bt.message,children:s.jsx(ze,{name:"subcategoryAmount3",control:P,render:({field:M})=>s.jsx(Ir,{name:M.name,value:M.value??"",onChange:M.onChange,onBlur:M.onBlur,disabled:n,placeholder:"Enter amount",hasError:!!q.subcategoryAmount3})})})]})]}):null]})})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 lg:mr-[324px]",children:[s.jsx("button",{type:"button",onClick:He,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:n?"Back":"Cancel"}),n?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:qe,disabled:!e||x,className:"inline-flex h-11 min-w-[140px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:x?"Saving…":"Save as Draft"}),s.jsx("button",{type:"submit",disabled:!e||x,className:"inline-flex h-11 min-w-[160px] items-center justify-center rounded-lg bg-gov-600 px-10 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:opacity-60",children:x?"Saving…":"Next"})]})]})]},i.key)}function qu(){const{selectedEntity:e}=pt();return s.jsx(Mu,{entity:e})}function Bu({mode:e}){var m;const t=ke(),{federalPaymentId:n}=zs(),{selectedEntity:r}=pt(),a=Number.parseInt(n??"",10),{data:i,isLoading:o,isError:l}=be({queryKey:["federal-payment",a],queryFn:()=>Zi(a),enabled:Number.isFinite(a)}),{data:c=[]}=be({queryKey:["bank-accounts",r==null?void 0:r.entityId],queryFn:async()=>(await Jr({entityId:r.entityId,pageNumber:1,pageSize:100})).items,enabled:r!==null&&i!==void 0}),d=j.useMemo(()=>{if(!i)return null;const h=c.find(f=>f.bankAccountDetailId===i.bankAccountDetailId);return Ev(i,{routingNumber:h==null?void 0:h.routingNumber,accountNumber:h==null?void 0:h.accountNumber,accountType:h==null?void 0:h.accountType,bankName:h==null?void 0:h.bankName})},[i,c]);if(!Number.isFinite(a))return s.jsx(Ue,{to:Ge(),replace:!0});if(o)return s.jsx("p",{className:"text-sm text-slate-600",children:"Loading federal payment…"});if(l||!i||!d)return s.jsx(Ue,{to:Ge(),replace:!0});if(!r||i.entityId!==r.entityId)return s.jsx(Ue,{to:Ge(),replace:!0});const u=e==="view"||((m=i.status)==null?void 0:m.toLowerCase())!=="draft";return s.jsx(Mu,{entity:r,initialDraft:d,readonly:u,onCancel:()=>t(Ge())})}function Vu(){return pt(),s.jsx(Bu,{mode:"edit"})}function Uu(){return pt(),s.jsx(Bu,{mode:"view"})}function Fv(e){const t=[];return e.includes("\\d")&&t.push("0-9"),/[A-Z]/.test(e)&&t.push("A-Z"),e.includes("-")&&t.push("\\-"),e.includes(" ")&&t.push(" "),e.includes("/")&&t.push("/"),t.length?t.join(""):null}function Dv(e,t){const n=e.toUpperCase();if(!t)return n;const r=Fv(t);return r?n.replace(new RegExp(`[^${r}]`,"g"),""):n}function Rv(e){if(!e)return null;const t=[];let n=0;try{for(;n<e.length;){if(e.startsWith("(?:",n))return null;const r=e[n];if(r==="-"||r===" "||r==="/"){t.push({type:"separator",char:r}),n+=1;continue}let a;if(r==="\\")a=e[n+1]==="d"?"digit":"letter",n+=2;else if(r==="["){const o=e.indexOf("]",n);if(o===-1)return null;a="letter",n=o+1}else a=r>="0"&&r<="9"?"digit":"letter",n+=1;const i=$v(e,n);if(i===null)return null;for(let o=0;o<i.count;o+=1)t.push({type:"slot",kind:a});n=i.nextIndex}}catch{return null}return t}function $v(e,t){if(e[t]!=="{")return{count:1,nextIndex:t};const n=e.indexOf("}",t);if(n===-1)throw new Error("Unterminated quantifier");const r=e.slice(t+1,n);if(r.includes(","))return null;const a=Number.parseInt(r,10);if(Number.isNaN(a))throw new Error("Bad quantifier");return{count:a,nextIndex:n+1}}function Ov(e,t){const n=e.toUpperCase().replace(/[^0-9A-Z]/g,"").split("");let r="",a=0;for(const i of t){if(a>=n.length)break;if(i.type==="separator"){r+=i.char;continue}for(;a<n.length;){const o=n[a];a+=1;const l=o>="0"&&o<="9";if(i.kind==="digit"?l:!l){r+=o;break}}}return r}function Lv(e){if(e)try{const t=Zu(e,0);return t.index===e.length?t.length:void 0}catch{return}}function Zu(e,t){let n=t,r=0;for(;;){const a=zv(e,n);if(r=Math.max(r,a.length),n=a.index,e[n]==="|"){n+=1;continue}return{length:r,index:n}}}function zv(e,t){let n=t,r=0;for(;n<e.length&&e[n]!=="|"&&e[n]!==")";){const a=Mv(e,n);r+=a.length,n=a.index}return{length:r,index:n}}function Mv(e,t){let n=t,r;if(e.startsWith("(?:",n)){const a=Zu(e,n+3);if(e[a.index]!==")")throw new Error("Unbalanced group");r=a.length,n=a.index+1}else if(e[n]==="\\")r=1,n+=2;else if(e[n]==="["){const a=e.indexOf("]",n);if(a===-1)throw new Error("Unterminated class");r=1,n=a+1}else r=1,n+=1;if(e[n]==="{"){const a=e.indexOf("}",n);if(a===-1)throw new Error("Unterminated quantifier");const i=e.slice(n+1,a).split(","),o=i.length===2?i[1]:i[0],l=Number.parseInt(o,10);if(Number.isNaN(l))throw new Error("Bad quantifier");r*=l,n=a+1}return{length:r,index:n}}const no="state-payment-draft";function ti(e){sessionStorage.setItem(no,JSON.stringify(e))}function ni(){const e=sessionStorage.getItem(no);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Wu(){sessionStorage.removeItem(no)}function Yu(e,t){return`${e}-${t}`}function qv(e,t){return{entityId:e,state:t.state,reasonForPayment:t.reasonForPayment,stateAccountId:t.stateAccountId,accountId:t.accountId,taxPeriod:Yu(t.taxYear,t.taxPeriod),taxAmount:Number.parseFloat(t.taxAmount),paymentDate:t.paymentDate,bankAccountDetailId:Number.parseInt(t.bankAccountDetailId,10)}}function Bv(e){return{state:e.state,reasonForPayment:e.reasonForPayment,stateAccountId:e.stateAccountId,accountId:e.accountId,taxPeriod:Yu(e.taxYear,e.taxPeriod),taxAmount:Number.parseFloat(e.taxAmount),paymentDate:e.paymentDate,bankAccountDetailId:Number.parseInt(e.bankAccountDetailId,10)}}function Vv(e){return Xt({state:_().min(1,"State is required"),reasonForPayment:_().min(1,"Reason for payment is required"),stateAccountId:_().min(1,"State ID is required"),accountId:_().min(1,"Account ID is required").refine(t=>/^\d{10,12}$/.test(t.trim()),"Account ID must be 10 to 12 digits"),letterId:_().optional().refine(t=>!t||/^[A-Za-z0-9]+$/.test(t),"Letter ID must be alphanumeric"),taxYear:_().min(1,"Tax year is required"),taxPeriod:_().min(1,"Tax period is required"),taxAmount:_().min(1,"Tax amount is required").refine(t=>$s(t),Rs.errorMessage),paymentDate:_().min(1,"Payment date is required").refine(t=>ta(t),"Payment date must be a weekday within the allowed range"),bankAccountDetailId:_().min(1,"Bank account is required"),routingNumber:_().optional(),accountType:_().optional(),bankName:_().optional()}).superRefine((t,n)=>{const r=e(),a=r==null?void 0:r.stateId.pattern;if(a)try{new RegExp(`^(?:${a})$`).test(t.stateAccountId.trim().toUpperCase())||n.addIssue({code:Qt.custom,path:["stateAccountId"],message:r.stateId.message})}catch{n.addIssue({code:Qt.custom,path:["stateAccountId"],message:"State ID validation is temporarily unavailable"})}})}const ya="grid gap-x-6 gap-y-5 sm:grid-cols-3",bl="grid gap-x-6 gap-y-5 sm:grid-cols-2",vl="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",jl={state:"",reasonForPayment:"",stateAccountId:"",accountId:"",letterId:"",taxYear:"",taxPeriod:"",taxAmount:"",paymentDate:"",bankAccountDetailId:"",routingNumber:"",accountType:"",bankName:""};function ba(e){return{state:e.state,reasonForPayment:Uv(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 Uv(e){return e.trim().toUpperCase().replaceAll(" ","_")}function Hu({entity:e,initialDraft:t,readonly:n=!1,onCancel:r}){var Nt,It,_t,Bt,M,de,b,C;const a=ke(),i=Se(),o=Bn(i.state,Ge()),l=i.state,c=j.useMemo(()=>t??(l==null?void 0:l.paymentDraft)??ni()??null,[t,l==null?void 0:l.paymentDraft]),d=j.useRef(c==null?void 0:c.statePaymentDetailId),u=j.useMemo(()=>{if(t)return ba(t);if(l!=null&&l.paymentDraft)return ba(l.paymentDraft);if(l!=null&&l.resetDraft)return Wu(),jl;const y=ni();return y?ba(y):jl},[t,l==null?void 0:l.paymentDraft,l==null?void 0:l.resetDraft,i.key]),{data:m=[],isLoading:h,isError:f}=be({queryKey:["state-payment-states"],queryFn:({signal:y})=>k0(y)}),{data:x=[],isLoading:p}=be({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:e!==null}),w=j.useMemo(()=>x.filter(vr),[x]),g=j.useRef(null),k=j.useMemo(()=>Vv(()=>g.current),[]),{register:v,control:S,handleSubmit:E,watch:T,setValue:P,clearErrors:O,formState:{errors:I}}=$t({resolver:Lt(k),defaultValues:u}),$=T("state"),ne=T("reasonForPayment"),q=T("taxAmount"),K=T("paymentDate"),ee=T("bankAccountDetailId"),{data:z=[],isLoading:ae,isError:oe}=be({queryKey:["state-payment-reasons",e==null?void 0:e.entityId,$],queryFn:({signal:y})=>C0(e.entityId,$,y),enabled:e!==null&&!!$}),{data:Q,isLoading:Ae,isError:De}=be({queryKey:["state-payment-validation-metadata",e==null?void 0:e.entityId,$,ne],queryFn:({signal:y})=>A0(e.entityId,$,ne,y),enabled:e!==null&&!!($&&ne)});be({queryKey:["state-payment-form-references",e==null?void 0:e.entityId,$,ne],queryFn:({signal:y})=>P0(e.entityId,$,ne,y),enabled:e!==null&&!!($&&ne)}),g.current=Q??null;const Oe=(Q==null?void 0:Q.taxYearOptions)??[],ue=(Q==null?void 0:Q.taxPeriodOptions)??[],xe=!!(Q&&$&&ne),R=(Q==null?void 0:Q.stateId.pattern)??null,pe=Lv(R),U=j.useMemo(()=>Rv(R),[R]),fe=v("stateAccountId"),Pe=v("accountId"),Xe=v("letterId"),[le,Ne]=j.useState(!1),[qe,He]=j.useState(""),re=j.useRef(null),et=(Nt=m.find(y=>y.code===$))==null?void 0:Nt.name,tt=j.useMemo(()=>{const y=qe.trim().toLowerCase();return y?m.filter(D=>D.name.toLowerCase().includes(y)||D.code.toLowerCase().includes(y)):m},[qe,m]),jt=["stateAccountId","accountId","letterId","taxYear","taxPeriod","taxAmount","paymentDate"],gt=()=>{jt.forEach(y=>P(y,"")),O([...jt,"bankAccountDetailId"])},wt=y=>{P("state",y,{shouldValidate:!0}),P("reasonForPayment",""),O("reasonForPayment"),gt(),He(""),Ne(!1)},Mt=y=>{y!==ne&&(P("reasonForPayment",y,{shouldValidate:!0}),gt())};j.useEffect(()=>{c!=null&&c.statePaymentDetailId&&(d.current=c.statePaymentDetailId)},[c==null?void 0:c.statePaymentDetailId]),j.useEffect(()=>{var y;le&&((y=re.current)==null||y.focus())},[le]),j.useEffect(()=>{!ne||ae||oe||z.some(y=>y.code===ne)||P("reasonForPayment","")},[ae,oe,z,ne,P]),j.useEffect(()=>{n||K&&!ta(K)&&P("paymentDate","")},[K,P,n]),j.useEffect(()=>{if(n)return;const y=w.find(D=>String(D.bankAccountDetailId)===ee);if(!y){ee&&(P("bankAccountDetailId",""),P("routingNumber",""),P("accountType",""),P("bankName",""));return}P("routingNumber",y.routingNumber),P("accountType",y.accountType),P("bankName",y.bankName)},[w,ee,P,n]);const Pt=E(y=>{if(n||!Q)return;const D={statePaymentDetailId:d.current,state:y.state,reasonForPayment:y.reasonForPayment,stateAccountId:y.stateAccountId.trim().toUpperCase(),accountId:y.accountId.trim(),letterId:y.letterId,taxYear:y.taxYear,taxPeriod:y.taxPeriod,taxAmount:y.taxAmount,paymentDate:y.paymentDate,bankAccountDetailId:y.bankAccountDetailId,routingNumber:y.routingNumber,accountType:y.accountType,bankName:y.bankName};ti(D),a("/payments/state/authorization",{state:{from:o,paymentDraft:D}})}),qt=()=>{if(r){r();return}a(o)},Et=e?en(e):"Entity";return s.jsx("form",{onSubmit:Pt,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:Et}),s.jsx(Xr,{entity:e,remittanceAmount:Gr(q),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:vl,children:[s.jsx(wl,{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:n||h||f,onClick:()=>{He(""),Ne(y=>!y)},className:"flex w-full items-center justify-between rounded-xl border border-slate-200 bg-slate-50/80 px-4 py-4 text-left transition hover:border-gov-300 hover:bg-gov-50/40 disabled:cursor-not-allowed disabled:opacity-70",children:[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(Zv,{})}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-sm font-semibold text-slate-900",children:h?"Loading states…":et??"Choose a state"}),s.jsx("span",{className:"block text-xs text-slate-500",children:"Tap to select the tax jurisdiction"})]})]}),s.jsx(Zn,{className:`h-4 w-4 text-slate-400 transition ${le?"rotate-180":""}`})]}),le?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:re,type:"search",value:qe,onChange:y=>He(y.target.value),onKeyDown:y=>{y.key==="Escape"?Ne(!1):y.key==="Enter"&&y.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[tt.map(y=>s.jsxs("button",{type:"button",onClick:()=>wt(y.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${$===y.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:y.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:y.code})]},y.code)),tt.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,I.state?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:I.state.message}):null,f?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Unable to load states."}):null]}),s.jsx(J,{label:"Reason for Payment",required:!0,error:(It=I.reasonForPayment)==null?void 0:It.message,children:s.jsxs(Tr,{children:[s.jsxs("select",{disabled:n||!$||ae||oe,className:Kn(!!I.reasonForPayment),...v("reasonForPayment"),onChange:y=>Mt(y.target.value),children:[s.jsx("option",{value:"",children:ae?"Loading reasons…":"Select reason"}),z.map(y=>s.jsx("option",{value:y.code,children:y.label},y.code))]}),s.jsx(Zn,{})]})}),oe?s.jsx("p",{className:"text-xs text-red-600",children:"Unable to load payment reasons."}):null,$&&!ae&&!oe&&z.length===0?s.jsx("p",{className:"text-xs text-slate-500",children:"No supported payment reasons are available for this entity and state."}):null]})]}),s.jsxs("section",{className:`${vl} transition ${xe?"":"opacity-60"}`,children:[s.jsx(wl,{step:2,title:"Payment Form",className:"mb-5"}),s.jsxs("fieldset",{disabled:!xe||n,className:"min-w-0 border-0 p-0",children:[s.jsx(va,{title:"Payment Details",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ya,children:[s.jsx(J,{label:"State ID",required:(Q==null?void 0:Q.stateId.required)??!0,error:(_t=I.stateAccountId)==null?void 0:_t.message,children:s.jsx("input",{placeholder:(Q==null?void 0:Q.stateId.example)??"Enter ID",maxLength:pe,className:te(!!I.stateAccountId),...fe,onChange:y=>{y.target.value=U?Ov(y.target.value,U):Dv(y.target.value,R),fe.onChange(y)}})}),s.jsx(J,{label:"Account ID",required:(Q==null?void 0:Q.accountIdRequired)??!0,error:(Bt=I.accountId)==null?void 0:Bt.message,children:s.jsx("input",{inputMode:"numeric",placeholder:"10–12 digits",maxLength:12,className:te(!!I.accountId),...Pe,onChange:y=>{y.target.value=y.target.value.replace(/\D/g,"").slice(0,12),Pe.onChange(y)}})}),s.jsx(J,{label:"Letter ID",required:(Q==null?void 0:Q.letterIdRequired)??!1,children:s.jsx("input",{placeholder:"Alphanumeric",maxLength:50,className:te(),...Xe,onChange:y=>{y.target.value=y.target.value.replace(/[^A-Za-z0-9]/g,"").slice(0,50),Xe.onChange(y)}})})]}),s.jsxs("div",{className:bl,children:[s.jsx(J,{label:"Tax Year",required:!0,error:(M=I.taxYear)==null?void 0:M.message,children:s.jsxs(Tr,{children:[s.jsxs("select",{className:Kn(!!I.taxYear),...v("taxYear"),children:[s.jsx("option",{value:"",children:"Select TY"}),Oe.map(y=>s.jsxs("option",{value:String(y),children:["TY ",y]},y))]}),s.jsx(Zn,{})]})}),s.jsx(J,{label:(Q==null?void 0:Q.periodMode)==="account-assigned"?"Deposit Frequency":"Tax Period",required:!0,error:(de=I.taxPeriod)==null?void 0:de.message,children:s.jsxs(Tr,{children:[s.jsxs("select",{className:Kn(!!I.taxPeriod),...v("taxPeriod"),children:[s.jsx("option",{value:"",children:"Select"}),ue.map(y=>s.jsx("option",{value:y.value,children:y.label},y.value))]}),s.jsx(Zn,{})]})})]})]})}),s.jsx(va,{title:"Amount Info",children:s.jsxs("div",{className:bl,children:[s.jsx(J,{label:"Tax Amount",required:!0,error:(b=I.taxAmount)==null?void 0:b.message,children:s.jsx(ze,{name:"taxAmount",control:S,render:({field:y})=>s.jsx(Ir,{name:y.name,value:y.value,onChange:y.onChange,onBlur:y.onBlur,disabled:n,hasError:!!I.taxAmount})})}),s.jsx(J,{label:"Payment Date",required:!0,error:(C=I.paymentDate)==null?void 0:C.message,children:s.jsx(ze,{name:"paymentDate",control:S,render:({field:y})=>s.jsx(Ou,{value:y.value,onChange:y.onChange,hasError:!!I.paymentDate,disabled:n})})})]})}),s.jsx(va,{title:"Bank Account",children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:ya,children:[s.jsx(ze,{name:"bankAccountDetailId",control:S,render:({field:y})=>{var D;return s.jsx(Fu,{value:y.value,onChange:y.onChange,entityId:(e==null?void 0:e.entityId)??null,entityType:e==null?void 0:e.entityType,bankAccounts:w,isLoading:p,disabled:!e||!xe||n,error:(D=I.bankAccountDetailId)==null?void 0:D.message,label:"Account Number"})}}),s.jsx(J,{label:"Routing Number",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"9-digit",className:te(!1,!0),...v("routingNumber")})}),s.jsx(J,{label:"Account Type",required:!0,children:s.jsx("input",{readOnly:!0,placeholder:"Select",className:te(!1,!0),...v("accountType")})})]}),s.jsx("div",{className:ya,children:s.jsx(J,{label:"Bank Name",children:s.jsx("input",{readOnly:!0,placeholder:"e.g. Chase Bank",className:te(!1,!0),...v("bankName")})})})]})}),Q!=null&&Q.notes.length?s.jsx("div",{className:"mt-5 rounded-lg bg-amber-50 px-4 py-3 text-xs text-amber-800",children:Q.notes.map(y=>s.jsx("p",{children:y},y))}):null]}),xe?null:s.jsx("p",{className:"mt-4 text-sm text-slate-500",children:Ae?"Loading payment requirements…":De?"Unable to load payment requirements.":"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:qt,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50",children:n?"Back":"Cancel"}),n?null:s.jsxs("button",{type:"submit",disabled:!e||!xe,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(Wv,{})]})]})]})})]})},i.key)}function wl({step:e,title:t,className:n=""}){return s.jsxs("div",{className:`flex items-center gap-3 ${n}`,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 va({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 Zv(){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 Wv(){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 Ku(){const{selectedEntity:e}=pt();return s.jsx(Hu,{entity:e})}function Yv(e){const t=e.indexOf("-");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function Qu(){var l;const{statePaymentId:e}=zs(),{selectedEntity:t}=pt(),n=Number.parseInt(e??"",10),{data:r,isLoading:a,isError:i}=be({queryKey:["state-payments",n],queryFn:()=>Nu(n),enabled:t!==null&&Number.isFinite(n)}),o=j.useMemo(()=>{if(!r)return null;const[c,d]=Yv(r.taxPeriod);return{statePaymentDetailId:r.statePaymentDetailId,state:r.state,reasonForPayment:"",stateAccountId:"",accountId:"",taxYear:c,taxPeriod:d,taxAmount:String(r.taxAmount),paymentDate:r.paymentDate,bankAccountDetailId:""}},[r]);return Number.isFinite(n)?a?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):i||!r||!o?s.jsx(Ue,{to:Ge(),replace:!0}):!t||r.entityId!==t.entityId?s.jsx(Ue,{to:Ge(),replace:!0}):((l=r.status)==null?void 0:l.toLowerCase())!=="draft"?s.jsx(Ue,{to:`/payments/state/${n}/view`,replace:!0}):s.jsx(Hu,{entity:t,initialDraft:o}):s.jsx(Ue,{to:Ge(),replace:!0})}function Ju(){var l,c;const{statePaymentId:e}=zs(),t=ke(),{selectedEntity:n}=pt(),r=Number.parseInt(e??"",10),{data:a,isLoading:i,isError:o}=be({queryKey:["state-payments",r],queryFn:()=>Nu(r),enabled:n!==null&&Number.isFinite(r)});return Number.isFinite(r)?i?s.jsx("p",{className:"px-6 py-12 text-sm text-slate-500",children:"Loading state payment…"}):o||!a?s.jsx(Ue,{to:"/payments",replace:!0}):!n||a.entityId!==n.entityId?s.jsx(Ue,{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-",a.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:a.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:a.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:Kr(a.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:a.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 ${((l=a.status)==null?void 0:l.toLowerCase())==="paid"?"bg-green-100 text-green-800":((c=a.status)==null?void 0:c.toLowerCase())==="rejected"?"bg-red-100 text-red-800":"bg-slate-100 text-slate-700"}`,children:a.status??"—"})})]}),a.reason&&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:a.reason})]})]})})]}):s.jsx(Ue,{to:"/payments",replace:!0})}const Hv="By proceeding, you authorize the payment to the selected tax authority and acknowledge that you are responsible for the accuracy of the information provided.",Kv="I have reviewed the details and authorize this payment.",Gu=/^[a-zA-Z\s]+$/;function Xu(e){return e.replace(/[^a-zA-Z\s]/g,"")}const ro=_().min(1,"Signature is required").regex(Gu,"Signature must contain only letters").refine(e=>e.trim().length>0,{message:"Signature is required"}),Qv=_().optional().refine(e=>!e||!e.trim()||Gu.test(e),{message:"Signature must contain only letters"}),Jv=Xt({agreementDate:_().min(1,"Date is required"),agreementAccepted:Yn().refine(e=>e,{message:"You must accept the authorization agreement"}),authorizationPersonName:_().min(1,"Name of authorization person is required"),signature:ro,title:_().min(1,"Title is required")}),Gv="w-full rounded-2xl border border-slate-200 bg-white p-6 shadow-sm lg:p-8",ds="rounded-lg border border-slate-200 bg-[#F9FAFB] px-4 text-center";function Xv(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function ej(){return{agreementDate:new Date().toISOString().slice(0,10),agreementAccepted:!1,authorizationPersonName:"",signature:"",title:""}}function tj({entity:e,paymentDraft:t}){const n=ke(),r=Se(),a=xt(),i=Bn(r.state,Ge()),[o,l]=j.useState(null),[c,d]=j.useState(!1),u=j.useMemo(()=>ej(),[]),m=Gr(t.taxAmount),{register:h,handleSubmit:f,watch:x,formState:{errors:p}}=$t({resolver:Lt(Jv),defaultValues:u}),w=x("agreementDate"),g=x("signature"),k=!!(g!=null&&g.trim()),v=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 I0(t.statePaymentDetailId,Bv(t));return await S(),$}const I=await E0(qv(e.entityId,t));return ti({...t,statePaymentDetailId:I.statePaymentDetailId}),await S(),I},T=async()=>{e&&(await E(),Wu(),n(Ge()))},P=f(async()=>{if(e){l(null),d(!0);try{await T()}catch(I){l(at(I,"Failed to save state payment."))}finally{d(!1)}}}),O=f(async()=>{if(e){l(null),d(!0);try{await T()}catch(I){l(at(I,"Failed to save draft."))}finally{d(!1)}}});return s.jsx("form",{onSubmit:P,noValidate:!0,className:"w-full",children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("h2",{className:"mb-5 text-[28px] font-bold leading-tight text-slate-900 lg:pr-[324px]",children:"Payment Authorization"}),s.jsx(Xr,{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:Gv,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:`${ds} 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:Xv(w)}),s.jsx("input",{type:"hidden",...h("agreementDate")})]})]}),s.jsx("p",{className:"mt-5 text-sm leading-relaxed text-slate-600",children:Hv}),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:Kv})]}),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:`${ds} 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:`${ds} 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 ${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:v.name,ref:v.ref,onBlur:v.onBlur,onChange:I=>{const $=Xu(I.target.value);I.target.value=$,v.onChange(I)}}),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:`${ds} 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(zt,{message:o})}):null,s.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:()=>{ti(t),n("/payments/state/new",{state:{from:i,paymentDraft:t}})},disabled:c,className:"inline-flex h-11 min-w-[120px] items-center justify-center rounded-lg border border-slate-300 bg-white px-6 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.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"}),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 ed(){const{selectedEntity:e}=pt(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ni();return r?s.jsx(tj,{entity:e,paymentDraft:r}):s.jsx(Ue,{to:"/payments/state/new",replace:!0})}const so="/portal/federal-payments/form-8655-authorizations";function nj(e){return me(so,{method:"POST",body:e})}function rj(e){return me(`${so}/by-enrolment/${e}`)}function sj(e,t){return me(`${so}/${e}`,{method:"PATCH",body:t})}async function td(e){try{return await rj(e)}catch(t){if(t instanceof gr&&t.status===404)return null;throw t}}const ri=["720","940","941","943","944","945","990-PF","990-T","1041","1042","1120","CT-1","Other"];function aj(e){const t=e.trim();return ri.includes(t)?t:"Other"}const ij="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.",oj="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 lj(e){const[t,n,r]=e.split("-");return!t||!n||!r?e:`${n}/${r}/${t}`}function si({label:e,required:t=!1,signature:n,title:r,date:a,signatureValue:i,dateValue:o="",dateReadOnly:l=!0,errors:c,signatureCaption:d="Signature of taxpayer"}){const u=!!(i!=null&&i.trim()),{onChange:m,onBlur:h,name:f,ref:x}=n;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:x,name:f,placeholder:"Sign here",autoComplete:"off",spellCheck:!1,className:`w-full border-0 bg-transparent text-center focus:outline-none ${u?"text-4xl leading-tight tracking-wide text-slate-800":"text-sm text-slate-400 placeholder:text-slate-400"}`,style:u?{fontFamily:"'Great Vibes', 'Segoe Script', cursive"}:void 0,onBlur:h,onChange:p=>{const w=Xu(p.target.value);p.target.value=w,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:d})]}),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",...r}),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:lj(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 cj(e){return e.replace(/\D/g,"")}function nd(e,t){var n,r;return{enrollmentId:e,taxpayerName:t.taxpayerName.trim(),tradeName:t.tradeName.trim(),ein:cj(t.ein),address:t.address.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),isSeasonalEmployer:t.isSeasonalEmployer,otherIdentificationNumber:((n=t.otherIdentificationNumber)==null?void 0:n.trim())||null,contactPerson:t.contactPerson.trim(),daytimePhone:t.daytimePhone.trim(),faxNumber:t.faxNumber.trim(),authorizedTaxForm:t.authorizedTaxForm,authorizationStartMonth:((r=t.authorizationMonth)==null?void 0:r.trim())||null,agreementAccepted:t.agreementAccepted,taxpayerSignature:t.signature.trim()||null,taxpayerTitle:t.title.trim(),signatureDate:t.signatureDate}}function uj(e){const{enrollmentId:t,...n}=nd(0,e);return n}function dj(e){return{taxpayerName:e.taxpayerName,tradeName:e.tradeName,ein:qn(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:$n(e.daytimePhone),faxNumber:e.faxNumber,authorizedTaxForm:e.authorizedTaxForm,authorizationMonth:e.authorizationStartMonth??"",agreementAccepted:e.agreementAccepted,signature:e.taxpayerSignature??"",title:e.taxpayerTitle,signatureDate:e.signatureDate}}const mj=Xt({taxpayerName:_().min(1,"Taxpayer name is required"),tradeName:_().min(1,"Trade name is required"),ein:_().min(1,"EIN is required"),address:_().min(1,"Address is required"),city:_().min(1,"City is required"),state:_().min(1,"State is required"),zipCode:_().min(1,"ZIP code is required"),country:_().min(1,"Country is required"),isSeasonalEmployer:Yn(),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:Yn().refine(e=>e,{message:"You must accept the authorization agreement"}),signature:ro,title:_().min(1,"Title is required"),signatureDate:_().min(1,"Date is required")}),ja="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3";function hj(e,t){const n=new Date().toISOString().slice(0,10);return{taxpayerName:e?en(e):"",tradeName:(e==null?void 0:e.tradeName)||(e==null?void 0:e.lastName)||(e==null?void 0:e.firstName)||"",ein:e?qn(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?$n(e.phoneNumber):"",faxNumber:"",authorizedTaxForm:aj(t.taxFormType),authorizationMonth:"",agreementAccepted:!1,signature:"",title:"",signatureDate:n}}function fj({entity:e,paymentDraft:t,initialAuthorization:n=null,readonly:r=!1}){var ae,oe,Q,Ae,De,Oe,ue,xe,R,pe,U,fe,Pe,Xe;const a=ke(),i=Se(),o=xt(),l=Bn(i.state,Ge()),c=Gr(t.paymentAmount),[d,u]=j.useState(null),[m,h]=j.useState(!1),f=j.useMemo(()=>n?dj(n):hj(e,t),[e,n,t]),{register:x,handleSubmit:p,watch:w,setValue:g,reset:k,formState:{errors:v}}=$t({resolver:Lt(mj),defaultValues:f});j.useEffect(()=>{k(f)},[f,k]);const S=w("authorizedTaxForm"),E=w("signature"),T=w("signatureDate"),P=e?en(e):"Entity",O=!0,I=!0,$=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},ne=async()=>{if(!e)return null;if(t.federalPaymentId){const Ne=await Yi(t.federalPaymentId,Gi(t));return await $(),Ne}const le=await Wi(Ji(e.entityId,t));return eo({...t,federalPaymentId:le.federalPaymentId,enrollmentId:le.enrollmentId}),await $(),le},q=async(le,Ne)=>{var re;const qe=t.form8655AuthorizationId??((re=await td(le))==null?void 0:re.form8655AuthorizationId),He=Ne;return qe?sj(qe,uj(He)):nj(nd(le,He))},K=async le=>{if(!e)return;const Ne=await ne();Ne&&(await q(Ne.enrollmentId,le),await o.invalidateQueries({queryKey:["form-8655",Ne.enrollmentId]}),to(),a(Ge()))},ee=p(async le=>{if(!(!e||r)){u(null),h(!0);try{await K(le)}catch(Ne){u(at(Ne,"Failed to save federal payment draft."))}finally{h(!1)}}}),z=p(async le=>{if(!(!e||r)){u(null),h(!0);try{await K(le)}catch(Ne){u(at(Ne,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:ee,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:P}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs("section",{children:[s.jsxs("div",{className:ja,children:[s.jsx(J,{label:"1. a) Name of the Taxpayer",required:!0,error:(ae=v.taxpayerName)==null?void 0:ae.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:O,className:te(!!v.taxpayerName,O),...x("taxpayerName")})}),s.jsx(J,{label:"1. b) Trade Name, if any",required:!0,error:(oe=v.tradeName)==null?void 0:oe.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:O,className:te(!!v.tradeName,O),...x("tradeName")})}),s.jsx(J,{label:"2. Employer Identification Number (EIN)",required:!0,error:(Q=v.ein)==null?void 0:Q.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:O,className:te(!!v.ein,O),...x("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(J,{label:"3. a) Address (Number, Street, and Room/Suite No)",required:!0,error:(Ae=v.address)==null?void 0:Ae.message,children:s.jsx("input",{placeholder:"Enter",readOnly:O,className:te(!!v.address,O),...x("address")})})}),s.jsx(J,{label:"3. b) City or Town",required:!0,error:(De=v.city)==null?void 0:De.message,children:s.jsx("input",{placeholder:"Enter",readOnly:O,className:te(!!v.city,O),...x("city")})})]}),s.jsxs("div",{className:`mt-5 ${ja}`,children:[s.jsx(J,{label:"3. c) State",required:!0,error:(Oe=v.state)==null?void 0:Oe.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:O,className:te(!!v.state,O),...x("state")})}),s.jsx(J,{label:"3. d) ZIP Code",required:!0,error:(ue=v.zipCode)==null?void 0:ue.message,children:s.jsx("input",{placeholder:"Enter",readOnly:O,className:te(!!v.zipCode,O),...x("zipCode")})}),s.jsx(J,{label:"3. e) Country",required:!0,error:(xe=v.country)==null?void 0:xe.message,children:s.jsx("input",{placeholder:"Enter",readOnly:O,className:te(!!v.country,O),...x("country")})})]}),s.jsxs("div",{className:`mt-5 ${ja}`,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",...x("isSeasonalEmployer")}),s.jsx("span",{children:"4. If you are a Seasonal Employer"})]})}),s.jsx(J,{label:"5. Other Identification Number (Optional)",children:s.jsx("input",{placeholder:"Enter name",readOnly:O,className:te(!1,O),...x("otherIdentificationNumber")})}),s.jsx(J,{label:"6. Contact Person",required:!0,error:(R=v.contactPerson)==null?void 0:R.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:O,className:te(!!v.contactPerson,O),...x("contactPerson")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-2",children:[s.jsx(J,{label:"7. Daytime Telephone Number",required:!0,error:(pe=v.daytimePhone)==null?void 0:pe.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:O,className:te(!!v.daytimePhone,O),...x("daytimePhone")})}),s.jsx(J,{label:"8. Fax Number",error:(U=v.faxNumber)==null?void 0:U.message,children:s.jsx("input",{placeholder:"Enter number",className:te(!!v.faxNumber),...x("faxNumber")})})]})]}),s.jsxs(wn,{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:ri.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:I,onChange:()=>g("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:ri.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:I,onChange:()=>g("authorizedTaxForm",le,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),le]},le))})]}),v.authorizedTaxForm?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:v.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",...x("agreementAccepted")}),s.jsxs("span",{className:"text-sm leading-6 text-slate-700",children:[s.jsx("span",{className:"font-semibold text-slate-900",children:ij})," ",oj]})]}),v.agreementAccepted?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:v.agreementAccepted.message}):null]})]}),s.jsx("section",{className:"mt-8 border-t border-slate-100 pt-8",children:s.jsx(si,{label:"Taxpayer's Signature",required:!0,signature:x("signature"),title:x("title"),date:x("signatureDate"),signatureValue:E,dateValue:T,errors:{signature:(fe=v.signature)==null?void 0:fe.message,title:(Pe=v.title)==null?void 0:Pe.message,date:(Xe=v.signatureDate)==null?void 0:Xe.message}})})]})})]}),d?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(zt,{message:d})}):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:z,disabled:m||!e||r,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||r,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 rd(){const{selectedEntity:e}=pt(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ra(),{data:a,isLoading:i}=be({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Zi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=be({queryKey:["form-8655",o],queryFn:()=>td(o),enabled:o!=null}),d=j.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form8655AuthorizationId:r.form8655AuthorizationId??(l==null?void 0:l.form8655AuthorizationId)}:null,[r,o,l]);return r?Qi(e)?s.jsx(Ue,{to:"/payments/federal/individual-enrollment",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading authorization form…"}):s.jsx(fj,{entity:e,paymentDraft:d??r,initialAuthorization:l}):s.jsx(Ue,{to:"/payments/federal/new",replace:!0})}const ao="/portal/federal-payments/form-9783-enrollments";function pj(e){return me(ao,{method:"POST",body:e})}function xj(e){return me(`${ao}/by-enrolment/${e}`)}function gj(e,t){return me(`${ao}/${e}`,{method:"PATCH",body:t})}async function sd(e){try{return await xj(e)}catch(t){if(t instanceof gr&&t.status===404)return null;throw t}}const yj="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.",bj="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.",vj="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.",wa=new Date().getFullYear(),jj=[String(wa-1),String(wa-2),String(wa-3)];function ms(e){return e.replace(/\D/g,"")}function ad(e,t){var n,r,a,i;return{enrollmentId:e,primarySsn:ms(t.primarySsn),jointFilerSsn:t.jointFilerSsn?ms(t.jointFilerSsn):null,taxpayerNames:t.taxpayerNames.trim(),primaryAddress:t.primaryAddress.trim(),city:t.city.trim(),state:t.state.trim(),zipCode:t.zipCode.trim(),country:t.country.trim(),internationalAddress:((n=t.internationalAddress)==null?void 0:n.trim())||null,primaryPhone:t.primaryPhone.trim(),primaryContactName:t.primaryContactName.trim(),primaryContactAddress:t.primaryContactAddress.trim(),contactCity:t.contactCity.trim(),contactState:t.contactState.trim(),contactZipCode:t.contactZipCode.trim(),contactCountry:t.contactCountry.trim(),contactPhone:t.contactPhone.trim(),contactInternationalAddress:((r=t.contactInternationalAddress)==null?void 0:r.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:ms(t.financialPrimarySsn),routingTransitNumber:ms(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 wj(e){const{enrollmentId:t,...n}=ad(0,e);return n}function Nj(e){var n;const t=((n=e.accountType)==null?void 0:n.toLowerCase())==="savings"?"Savings":"Checking";return{primarySsn:e.primarySsn,jointFilerSsn:e.jointFilerSsn??"",taxpayerNames:e.taxpayerNames,primaryAddress:e.primaryAddress,city:e.city,state:e.state,zipCode:e.zipCode,country:e.country,internationalAddress:e.internationalAddress??"",primaryPhone:$n(e.primaryPhone),primaryContactName:e.primaryContactName,primaryContactAddress:e.primaryContactAddress,contactCity:e.contactCity,contactState:e.contactState,contactZipCode:e.contactZipCode,contactCountry:e.contactCountry,contactPhone:$n(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 Sj=Xt({primarySsn:_().min(1,"Primary SSN is required"),jointFilerSsn:_().optional(),taxpayerNames:_().min(1,"Taxpayer name is required"),primaryAddress:_().min(1,"Primary address is required"),city:_().min(1,"City is required"),state:_().min(1,"State is required"),zipCode:_().min(1,"ZIP code is required"),country:_().min(1,"Country is required"),internationalAddress:_().optional(),primaryPhone:_().min(1,"Primary phone number is required"),primaryContactName:_().min(1,"Primary contact name is required"),primaryContactAddress:_().min(1,"Primary contact address is required"),contactCity:_().min(1,"Contact city is required"),contactState:_().min(1,"Contact state is required"),contactZipCode:_().min(1,"Contact ZIP code is required"),contactCountry:_().min(1,"Contact country is required"),contactPhone:_().min(1,"Contact phone number is required"),contactInternationalAddress:_().optional(),primaryTaxpayerPin:_().min(1,"Primary taxpayer PIN is required").regex(/^\d{5}$/,"Primary taxpayer PIN must be exactly 5 digits"),dateOfBirth:_().min(1,"Date of birth is required").refine(e=>Q0(e,id),{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:du([da("Checking"),da("Savings"),da("")]).refine(e=>e==="Checking"||e==="Savings",{message:"Account type is required"}),disclosureAgreementOne:Yn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),disclosureAgreementTwo:Yn().refine(e=>e,{message:"You must accept the disclosure authorization agreement"}),authorityAgreement:Yn().refine(e=>e,{message:"You must accept the authority agreement"}),taxpayerSignature:ro,taxpayerTitle:_().min(1,"Title is required"),taxpayerSignatureDate:_().min(1,"Date is required"),jointFilerSignature:Qv,jointFilerTitle:_().optional(),jointFilerSignatureDate:_().optional()}),bn="grid gap-x-6 gap-y-5 sm:grid-cols-2 xl:grid-cols-3",kj="grid gap-x-6 gap-y-5 sm:grid-cols-2 lg:grid-cols-4",Cj=5,id=18;function od(e){return e?e.toLowerCase()==="savings"?"Savings":"Checking":""}function ld(e,t){return{financialPrimarySsn:(e==null?void 0:e.idNumber)??"",routingTransitNumber:t.routingNumber??"",accountNumber:t.accountNumber??"",accountType:od(t.accountType)}}function Aj(e,t){const n=new Date().toISOString().slice(0,10),r=e?en(e):"";return{primarySsn:(e==null?void 0:e.idNumber)??"",jointFilerSsn:"",taxpayerNames:r,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?$n(e.phoneNumber):"",primaryContactName:"",primaryContactAddress:"",contactCity:"",contactState:"",contactZipCode:"",contactCountry:"",contactPhone:"",contactInternationalAddress:"",...ld(e,t),primaryTaxpayerPin:"",dateOfBirth:"",priorYearAgi:"",agiTaxYear:"",disclosureAgreementOne:!1,disclosureAgreementTwo:!1,authorityAgreement:!1,taxpayerSignature:"",taxpayerTitle:"",taxpayerSignatureDate:n,jointFilerSignature:"",jointFilerTitle:"",jointFilerSignatureDate:n}}function Pj({entity:e,paymentDraft:t,initialEnrollment:n=null,readonly:r=!1}){var He,re,et,tt,jt,gt,wt,Mt,Pt,qt,Et,Nt,It,_t,Bt,M,de,b,C,y,D,L,Y,B,H;const a=ke(),i=Se(),o=xt(),l=Bn(i.state,Ge()),c=Gr(t.paymentAmount),[d,u]=j.useState(null),[m,h]=j.useState(!1),[f,x]=j.useState(!1),{data:p=[]}=be({queryKey:["bank-accounts",e==null?void 0:e.entityId],queryFn:async()=>(await Jr({entityId:e.entityId,pageNumber:1,pageSize:100})).items,enabled:(e==null?void 0:e.entityId)!=null}),w=j.useMemo(()=>{if(n)return Nj(n);const V=p.find(Be=>String(Be.bankAccountDetailId)===t.bankAccountDetailId),ie=ld(e,t);return{...Aj(e,t),financialPrimarySsn:ie.financialPrimarySsn,routingTransitNumber:ie.routingTransitNumber||(V==null?void 0:V.routingNumber)||"",accountNumber:ie.accountNumber||(V==null?void 0:V.accountNumber)||"",accountType:od(t.accountType||(V==null?void 0:V.accountType))}},[e,n,t,p]),{register:g,handleSubmit:k,watch:v,setValue:S,reset:E,control:T,formState:{errors:P}}=$t({resolver:Lt(Sj),defaultValues:w});j.useEffect(()=>{E(w)},[w,E]);const O=v("taxpayerSignature"),I=v("jointFilerSignature"),$=v("taxpayerSignatureDate"),ne=v("jointFilerSignatureDate"),q=v("accountType"),K=v("taxpayerNames"),ee=v("primaryAddress"),z=v("city"),ae=v("state"),oe=v("zipCode"),Q=v("country"),Ae=v("primaryPhone"),De=v("internationalAddress"),Oe=e?en(e):"Entity",ue=!0,xe=!0,R=j.useMemo(()=>K0(id),[]),pe=()=>{S("primaryContactName",K,{shouldValidate:!0}),S("primaryContactAddress",ee,{shouldValidate:!0}),S("contactCity",z,{shouldValidate:!0}),S("contactState",ae,{shouldValidate:!0}),S("contactZipCode",oe,{shouldValidate:!0}),S("contactCountry",Q,{shouldValidate:!0}),S("contactPhone",Ae,{shouldValidate:!0}),S("contactInternationalAddress",De??"",{shouldValidate:!0})},U=()=>{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})};j.useEffect(()=>{f&&pe()},[f,K,ee,z,ae,oe,Q,Ae,De]);const fe=async()=>{await o.invalidateQueries({queryKey:["dashboard"]}),await o.invalidateQueries({queryKey:["federal-payments"]}),await o.invalidateQueries({queryKey:["remittance-payments"]})},Pe=async()=>{if(!e)return null;if(t.federalPaymentId){const ie=await Yi(t.federalPaymentId,Gi(t));return await fe(),ie}const V=await Wi(Ji(e.entityId,t));return eo({...t,federalPaymentId:V.federalPaymentId,enrollmentId:V.enrollmentId}),await fe(),V},Xe=async(V,ie)=>{var Vt;const Be=t.form9783EnrollmentId??((Vt=await sd(V))==null?void 0:Vt.form9783EnrollmentId);return Be?gj(Be,wj(ie)):pj(ad(V,ie))},le=async V=>{if(!e)return;const ie=await Pe();ie&&(await Xe(ie.enrollmentId,V),await o.invalidateQueries({queryKey:["form-9783",ie.enrollmentId]}),to(),a(Ge()))},Ne=k(async V=>{if(!(!e||r)){u(null),h(!0);try{await le(V)}catch(ie){u(at(ie,"Failed to save federal payment draft."))}finally{h(!1)}}}),qe=k(async V=>{if(!(!e||r)){u(null),h(!0);try{await le(V)}catch(ie){u(at(ie,"Failed to save draft."))}finally{h(!1)}}});return s.jsxs("form",{onSubmit:Ne,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:Oe}),s.jsx(Xr,{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:r,className:"min-w-0 border-0 p-0",children:[s.jsxs(wn,{title:"1. Taxpayer Information",isFirst:!0,children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"1. a) Primary Social Security Number (SSN)",required:!0,error:(He=P.primarySsn)==null?void 0:He.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ue,className:te(!!P.primarySsn,ue),...g("primarySsn")})}),s.jsx(J,{label:"1. b) Joint filer's taxpayer ID No (SSN)",children:s.jsx("input",{placeholder:"Other Identification number (optional)",readOnly:ue,className:te(!1,ue),...g("jointFilerSsn")})}),s.jsx(J,{label:"2. Taxpayer(S) name(S)",required:!0,error:(re=P.taxpayerNames)==null?void 0:re.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ue,className:te(!!P.taxpayerNames,ue),...g("taxpayerNames")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(J,{label:"3. a) Primary taxpayer address",required:!0,error:(et=P.primaryAddress)==null?void 0:et.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:te(!!P.primaryAddress,ue),...g("primaryAddress")})})}),s.jsx(J,{label:"3. b) City or Town",required:!0,error:(tt=P.city)==null?void 0:tt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:te(!!P.city,ue),...g("city")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx(J,{label:"3. c) State",required:!0,error:(jt=P.state)==null?void 0:jt.message,children:s.jsx("input",{placeholder:"Enter name",readOnly:ue,className:te(!!P.state,ue),...g("state")})}),s.jsx(J,{label:"3. d) ZIP code",required:!0,error:(gt=P.zipCode)==null?void 0:gt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:te(!!P.zipCode,ue),...g("zipCode")})}),s.jsx(J,{label:"3. e) Country",required:!0,error:(wt=P.country)==null?void 0:wt.message,children:s.jsx("input",{placeholder:"Enter",readOnly:ue,className:te(!!P.country,ue),...g("country")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx("div",{className:"sm:col-span-2 xl:col-span-2",children:s.jsx(J,{label:"3. f) International address",children:s.jsx("input",{placeholder:"phone number (International number)",readOnly:ue,className:te(!1,ue),...g("internationalAddress")})})}),s.jsx(J,{label:"4. Primary taxpayer phone number",required:!0,error:(Mt=P.primaryPhone)==null?void 0:Mt.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:ue,className:te(!!P.primaryPhone,ue),...g("primaryPhone")})})]})]}),s.jsxs(wn,{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:r,onChange:V=>{const ie=V.target.checked;x(ie),ie?pe():U()},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:bn,children:[s.jsx(J,{label:"5. Primary contact name",required:!0,error:(Pt=P.primaryContactName)==null?void 0:Pt.message,children:s.jsx("input",{placeholder:"Payer Name",readOnly:f,className:te(!!P.primaryContactName,f),...g("primaryContactName")})}),s.jsx(J,{label:"6. a) Primary contact address",required:!0,error:(qt=P.primaryContactAddress)==null?void 0:qt.message,children:s.jsx("input",{placeholder:"Payer Address",readOnly:f,className:te(!!P.primaryContactAddress,f),...g("primaryContactAddress")})}),s.jsx(J,{label:"6. b) City or Town",required:!0,error:(Et=P.contactCity)==null?void 0:Et.message,children:s.jsx("input",{placeholder:"City",readOnly:f,className:te(!!P.contactCity,f),...g("contactCity")})})]}),s.jsxs("div",{className:`mt-5 ${bn}`,children:[s.jsx(J,{label:"6. c) State",required:!0,error:(Nt=P.contactState)==null?void 0:Nt.message,children:s.jsx("input",{placeholder:"Payer State",readOnly:f,className:te(!!P.contactState,f),...g("contactState")})}),s.jsx(J,{label:"6. d) ZIP code",required:!0,error:(It=P.contactZipCode)==null?void 0:It.message,children:s.jsx("input",{placeholder:"ZIP code",readOnly:f,className:te(!!P.contactZipCode,f),...g("contactZipCode")})}),s.jsx(J,{label:"6. f) Country",required:!0,error:(_t=P.contactCountry)==null?void 0:_t.message,children:s.jsx("input",{placeholder:"Country",readOnly:f,className:te(!!P.contactCountry,f),...g("contactCountry")})})]}),s.jsxs("div",{className:"mt-5 grid gap-x-6 gap-y-5 sm:grid-cols-3",children:[s.jsx(J,{label:"7. Primary taxpayer phone number",required:!0,error:(Bt=P.contactPhone)==null?void 0:Bt.message,children:s.jsx("input",{placeholder:"Payer Phone",readOnly:f,className:te(!!P.contactPhone,f),...g("contactPhone")})}),s.jsx("div",{className:"sm:col-span-2",children:s.jsx(J,{label:"8. International address",children:s.jsx("input",{placeholder:"Phone Number (International number)",readOnly:f,className:te(!1,f),...g("contactInternationalAddress")})})})]})]}),s.jsx(wn,{title:"Taxpayer Details *",children:s.jsxs("div",{className:kj,children:[s.jsx(J,{label:"1. Primary Taxpayer Pin",required:!0,error:(M=P.primaryTaxpayerPin)==null?void 0:M.message,children:s.jsx(ze,{name:"primaryTaxpayerPin",control:T,render:({field:V})=>s.jsx("input",{placeholder:"Primary Taxpayer Pin",inputMode:"numeric",className:te(!!P.primaryTaxpayerPin),value:V.value,onChange:ie=>V.onChange(Hn(ie.target.value,Cj)),onBlur:V.onBlur})})}),s.jsx(J,{label:"2. Date of Birth",required:!0,error:(de=P.dateOfBirth)==null?void 0:de.message,children:s.jsx("input",{type:"date",max:R,className:te(!!P.dateOfBirth),...g("dateOfBirth")})}),s.jsx(J,{label:"3. Prior year adjusted gross income",required:!0,error:(b=P.priorYearAgi)==null?void 0:b.message,children:s.jsx("input",{placeholder:"Prior Year Adjusted Gross Income",inputMode:"decimal",className:te(!!P.priorYearAgi),...g("priorYearAgi")})}),s.jsx(J,{label:"4. Prior Tax Year",required:!0,error:(C=P.agiTaxYear)==null?void 0:C.message,children:s.jsxs("select",{className:Kn(!!P.agiTaxYear),...g("agiTaxYear"),children:[s.jsx("option",{value:"",disabled:!0,children:"AGI Tax Year"}),jj.map(V=>s.jsx("option",{value:V,children:V},V))]})})]})}),s.jsxs(wn,{title:"3. Social Security Number and Financial Institution Information",children:[s.jsxs("div",{className:bn,children:[s.jsx(J,{label:"9. Primary SSN",required:!0,error:(y=P.financialPrimarySsn)==null?void 0:y.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:xe,className:te(!!P.financialPrimarySsn,xe),...g("financialPrimarySsn")})}),s.jsx(J,{label:"10. Routing Transit Number (RTN)",required:!0,error:(D=P.routingTransitNumber)==null?void 0:D.message,children:s.jsx("input",{placeholder:"Enter number",readOnly:xe,className:te(!!P.routingTransitNumber,xe),...g("routingTransitNumber")})}),s.jsx(J,{label:"11. Account Number",required:!0,error:(L=P.accountNumber)==null?void 0:L.message,children:s.jsx("input",{placeholder:"Enter",readOnly:xe,className:te(!!P.accountNumber,xe),...g("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(V=>s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700",children:[s.jsx("input",{type:"radio",value:V,checked:q===V,disabled:xe,onChange:()=>S("accountType",V,{shouldValidate:!0}),className:"h-4 w-4 border-slate-300 text-gov-600 focus:ring-gov-200 disabled:cursor-default"}),V]},V))}),P.accountType?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.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",...g("disclosureAgreementOne")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:yj})]}),P.disclosureAgreementOne?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.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",...g("disclosureAgreementTwo")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:bj})]}),P.disclosureAgreementTwo?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.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",...g("authorityAgreement")}),s.jsx("span",{className:"text-sm leading-6 text-slate-700",children:vj})]}),P.authorityAgreement?s.jsx("p",{className:"mt-2 text-xs text-red-600",children:P.authorityAgreement.message}):null]})]})]}),s.jsxs("section",{className:"mt-8 space-y-8 border-t border-slate-100 pt-8",children:[s.jsx(si,{label:"Taxpayer's Signature",required:!0,signature:g("taxpayerSignature"),title:g("taxpayerTitle"),date:g("taxpayerSignatureDate"),signatureValue:O,dateValue:$,errors:{signature:(Y=P.taxpayerSignature)==null?void 0:Y.message,title:(B=P.taxpayerTitle)==null?void 0:B.message,date:(H=P.taxpayerSignatureDate)==null?void 0:H.message}}),s.jsx(si,{label:"Joint filer(s) Signature (Optional)",signature:g("jointFilerSignature"),title:g("jointFilerTitle"),date:g("jointFilerSignatureDate"),signatureValue:I??"",dateValue:ne??"",signatureCaption:"Signature of joint filer"})]})]})})]}),d?s.jsx("div",{className:"lg:mr-[324px]",children:s.jsx(zt,{message:d})}):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:qe,disabled:m||!e||r,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||r,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 cd(){const{selectedEntity:e}=pt(),t=Se(),{paymentDraft:n}=t.state??{},r=n??ra(),{data:a,isLoading:i}=be({queryKey:["federal-payment",r==null?void 0:r.federalPaymentId],queryFn:()=>Zi(r.federalPaymentId),enabled:(r==null?void 0:r.federalPaymentId)!=null&&r.enrollmentId==null}),o=(r==null?void 0:r.enrollmentId)??(a==null?void 0:a.enrollmentId),{data:l,isLoading:c}=be({queryKey:["form-9783",o],queryFn:()=>sd(o),enabled:o!=null}),d=j.useMemo(()=>r?{...r,enrollmentId:o??r.enrollmentId,form9783EnrollmentId:r.form9783EnrollmentId??(l==null?void 0:l.form9783EnrollmentId)}:null,[r,o,l]);return r?e&&!Qi(e)?s.jsx(Ue,{to:"/payments/federal/authorization",replace:!0,state:t.state}):r.federalPaymentId!=null&&r.enrollmentId==null&&i||o!=null&&c?s.jsx("p",{className:"text-sm text-slate-600",children:"Loading enrollment form…"}):s.jsx(Pj,{entity:e,paymentDraft:d??r,initialEnrollment:l}):s.jsx(Ue,{to:"/payments/federal/new",replace:!0})}function Ej(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function Ij({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 _j({status:e}){const t=e.toLowerCase();let n="bg-slate-100 text-slate-600";return t.includes("submitted to state")||t.includes("submitted to fed")?n="bg-orange-50 text-orange-700":t.includes("irs accepted")?n="bg-emerald-50 text-emerald-700":t.includes("irs rejected")?n="bg-red-50 text-red-600":t.includes("pending")&&(n="bg-amber-50 text-amber-700"),s.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ${n}`,children:e})}function Tj({forms:e=[],isLoading:t=!1,isError:n=!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…"})}):n?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(r=>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(Fj,{className:"h-4 w-4"})}),r.fileName]})}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(Ij,{type:r.type})}),s.jsx("td",{className:"px-6 py-4 text-slate-700",children:r.client}),s.jsx("td",{className:"px-6 py-4",children:s.jsx(_j,{status:r.status})}),s.jsx("td",{className:"px-6 py-4 text-slate-600",children:Ej(r.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"}),r.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]})})]},r.taxFormId))})]})})})}function Fj({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 Dj(){return s.jsx(Tj,{})}const Nl=160,Rj=88,hs=8;function $j({account:e,entityId:t,onEdit:n}){const r=xt(),{showSuccess:a,showError:i}=Vs(),o=j.useRef(null),l=j.useRef(null),[c,d]=j.useState(!1),[u,m]=j.useState(!1),[h,f]=j.useState({}),x=()=>{var E;const w=o.current;if(!w)return;const g=w.getBoundingClientRect(),k=((E=l.current)==null?void 0:E.offsetHeight)??Rj,S=window.innerHeight-g.bottom<k+hs;f({position:"fixed",top:S?g.top-k-hs:g.bottom+hs,left:Math.max(hs,g.right-Nl),width:Nl,zIndex:50})};j.useLayoutEffect(()=>{c&&(x(),requestAnimationFrame(x))},[c]),j.useEffect(()=>{if(!c)return;const w=k=>{var S,E;const v=k.target;(S=o.current)!=null&&S.contains(v)||(E=l.current)!=null&&E.contains(v)||d(!1)},g=()=>x();return document.addEventListener("mousedown",w),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",w),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[c]);const p=async()=>{const w=vr(e);m(!0);try{await ku(e.bankAccountDetailId,{status:Cv(e)}),await r.invalidateQueries({queryKey:["bank-accounts",t]}),d(!1),w?a("Bank Account Deactivated","Bank account deactivated successfully."):a("Bank Account Activated","Bank account activated successfully.")}catch(g){i("Action Not Completed",at(g,"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:u,onClick:()=>d(w=>!w),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(Oj,{})]}),c?Br.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:()=>{d(!1),n(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:u,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:Av(e)})]}),document.body):null]})}function Oj(){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 ud=["Checking","Savings"],Lj=Xt({accountNumber:_().min(1,"Account number is required").regex(/^\d{1,17}$/,`Account number must be 1 to ${dr} digits`),routingNumber:_().min(1,"Routing number is required").regex(/^\d{9}$/,"Routing number must be exactly 9 digits"),accountType:Xs(ud,{message:"Account type is required"}),bankName:_().min(1,"Bank name is required")});function zj({open:e,account:t,onClose:n}){const r=xt(),{showSuccess:a,showError:i}=Vs(),[o,l]=j.useState(null),[c,d]=j.useState(!1),{control:u,handleSubmit:m,reset:h,formState:{errors:f}}=$t({resolver:Lt(Lj),defaultValues:{accountNumber:"",routingNumber:"",accountType:"Checking",bankName:""}});j.useEffect(()=>{!e||!t||(h({accountNumber:t.accountNumber,routingNumber:t.routingNumber,accountType:t.accountType==="Savings"?"Savings":"Checking",bankName:t.bankName}),l(null))},[t,e,h]),j.useEffect(()=>{if(!e)return;const p=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",p),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p),document.body.style.overflow=""}},[e,n]);const x=m(async p=>{if(t){l(null),d(!0);try{await ku(t.bankAccountDetailId,{bankName:p.bankName.trim(),accountNumber:p.accountNumber,routingNumber:p.routingNumber,accountType:p.accountType}),await r.invalidateQueries({queryKey:["bank-accounts",t.entityId]}),a("Bank Account Updated","Bank account updated successfully."),n()}catch(w){const g=at(w,"Unable to update bank account.");l(g),i("Action Not Completed",g)}finally{d(!1)}}});return!e||!t?null:Br.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:n}),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(),x(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(zt,{message:o})}):null,s.jsxs(au,{title:"Bank Account",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(ze,{name:"accountNumber",control:u,render:({field:p})=>{var w;return s.jsx(ge,{label:"Account Number",required:!0,placeholder:"Bank account number",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:g=>p.onChange(Hn(g.target.value,dr)),onBlur:p.onBlur,error:(w=f.accountNumber)==null?void 0:w.message})}}),s.jsx(ze,{name:"routingNumber",control:u,render:({field:p})=>{var w;return s.jsx(ge,{label:"Routing Number",required:!0,placeholder:"9-digit ABA",inputMode:"numeric",autoComplete:"off",value:p.value,onChange:g=>p.onChange(Hn(g.target.value,Cu)),onBlur:p.onBlur,error:(w=f.routingNumber)==null?void 0:w.message})}}),s.jsx(ze,{name:"accountType",control:u,render:({field:p})=>{var w;return s.jsx(xn,{label:"Account Type",required:!0,value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(w=f.accountType)==null?void 0:w.message,children:ud.map(g=>s.jsx("option",{value:g,children:g},g))})}})]}),s.jsx(ze,{name:"bankName",control:u,render:({field:p})=>{var w;return s.jsx(ge,{label:"Account / Bank Name",required:!0,placeholder:"e.g. Chase Bank",value:p.value,onChange:p.onChange,onBlur:p.onBlur,error:(w=f.bankName)==null?void 0:w.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:n,disabled:c,className:"inline-flex h-11 items-center justify-center rounded-lg border border-slate-200 bg-white px-6 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-60",children:"Cancel"}),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 On=[{id:"bank-accounts",title:"Bank Accounts",subtitle:"Connected bank accounts",icon:Mj},{id:"tax-accounts",title:"Tax Accounts",subtitle:"IRS & state tax accounts",icon:qj},{id:"payment-history",title:"Payment History",subtitle:"Past payment transactions",icon:Bj},{id:"entity-details",title:"Entity Details",subtitle:"Your account details",icon:Vj}];function Mj({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 qj({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 Bj({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 Vj({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 mr({title:e,subtitle:t,icon:n,action:r}){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(n,{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})]})]}),r]})}function Uj(e){return`******${e.replace(/\D/g,"").slice(-4)||e.slice(-4)}`}function Zj({status:e}){const t=vr({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 Wj({entityId:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,o]=j.useState(1),[l,c]=j.useState(lt),d=On.find(k=>k.id==="bank-accounts"),u=d.icon;j.useEffect(()=>{o(1)},[e,l]);const{data:m,isLoading:h,isError:f,isFetching:x}=be({queryKey:["bank-accounts",e,i,l],queryFn:()=>Jr({entityId:e,pageNumber:i,pageSize:l}),enabled:e!==null,placeholderData:k=>k}),p=(m==null?void 0:m.items)??[],w=(m==null?void 0:m.totalCount)??0,g=e!==null&&x;return s.jsxs("div",{children:[s.jsx(mr,{title:d.title,subtitle:d.subtitle,icon:u,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>n(!0),className:"inline-flex items-center gap-2 rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(Yj,{}),"Add Bank Account"]})}),s.jsx(Pu,{open:t,entityId:e,onClose:()=>n(!1)}),s.jsx(zj,{open:r!==null,account:r,onClose:()=>a(null)}),s.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:[g?s.jsx(br,{label:"Loading bank accounts…"}):null,s.jsx("div",{className:"overflow-x-auto",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:h&&!m?s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-5 py-12 text-center text-slate-500",children:"Loading bank accounts…"})}):f?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?p.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."})}):p.map(k=>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:k.bankName}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:Uj(k.accountNumber)}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:k.routingNumber}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:k.accountType}),s.jsx("td",{className:"px-5 py-4",children:s.jsx(Zj,{status:k.status})}),s.jsx("td",{className:"px-5 py-4 text-right",children:s.jsx($j,{account:k,entityId:e,onEdit:a})})]},k.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."})})})]})}),e!==null?s.jsx(Qr,{page:i,pageSize:l,totalCount:w,onPageChange:o,onPageSizeChange:c,disabled:h||x}):null]})]})}function Yj(){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 Hj({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 Ar({label:e,value:t,icon:n}){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(Hj,{icon:n})}),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 Kj(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"—"}function Qj({entity:e}){const[t,n]=j.useState(!1),r=On.find(c=>c.id==="entity-details"),a=r.icon;if(!e)return s.jsxs("div",{children:[s.jsx(mr,{title:r.title,subtitle:r.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=en(e),o=e.accountType==="Business"?i:`${e.firstName} ${e.lastName}`.trim()||i,l=Li(o);return s.jsxs("div",{children:[s.jsx(mr,{title:r.title,subtitle:r.subtitle,icon:a,action:s.jsx("button",{type:"button",onClick:()=>n(!0),className:"inline-flex items-center rounded-lg bg-gov-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-gov-700",children:"Edit"})}),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(Ar,{label:"Entity Name",value:i,icon:"entity"}),s.jsx(Ar,{label:"Tax ID",value:qn(e.idNumber),icon:"tax"}),s.jsx(Ar,{label:"Email Address",value:e.email,icon:"email"}),s.jsx(Ar,{label:"Phone Number",value:$n(e.phoneNumber),icon:"phone"}),s.jsx(Ar,{label:"Account Type",value:Kj(e.accountType),icon:"account"})]}),s.jsx(wu,{open:t,entity:e,onClose:()=>n(!1)})]})}function dd({activeSection:e,onSectionChange:t,items:n}){return s.jsx("nav",{className:"space-y-2",children:n.map(r=>{const a=e===r.id,i=r.icon;return s.jsxs("button",{type:"button",onClick:()=>t(r.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:r.title}),s.jsx("span",{className:"block truncate text-xs text-slate-500",children:r.subtitle})]}),s.jsx(Jj,{className:`h-4 w-4 shrink-0 ${a?"text-gov-600":"text-slate-300"}`})]},r.id)})})}function Jj({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 Gj({entityId:e}){const t=On.find(r=>r.id==="payment-history"),n=t.icon;return s.jsxs("div",{children:[s.jsx(mr,{title:t.title,subtitle:t.subtitle,icon:n,action:s.jsxs("button",{type:"button",disabled:!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(Xj,{}),"Export to Excel"]})}),s.jsx("div",{className:"relative overflow-hidden rounded-xl border border-slate-200",children:s.jsx("div",{className:"overflow-x-auto",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:e?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."})}):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 Xj(){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 e1({entityId:e,pageNumber:t=1,pageSize:n=lt}){const r=new URLSearchParams({entityId:String(e),pageNumber:String(t),pageSize:String(n)});return me(`/portal/tax-accounts?${r}`)}function t1(e){return me(`/portal/tax-accounts/${e}`)}function n1(e){return me("/portal/tax-accounts",{method:"POST",body:e})}function r1(e,t){return me(`/portal/tax-accounts/${e}`,{method:"PATCH",body:t})}function s1({entityId:e}){const t=ke(),n=On.find(f=>f.id==="tax-accounts"),r=n.icon,[a,i]=j.useState(1),[o,l]=j.useState(lt);j.useEffect(()=>{i(1)},[e,o]);const{data:c,isLoading:d,isError:u}=be({queryKey:["tax-accounts",e,a,o],queryFn:()=>e1({entityId:e,pageNumber:a,pageSize:o}),enabled:e!==null}),m=(c==null?void 0:c.items)??[],h=(c==null?void 0:c.totalCount)??0;return s.jsxs("div",{children:[s.jsx(mr,{title:n.title,subtitle:n.subtitle,icon:r,action:s.jsxs("button",{type:"button",disabled:!e,onClick:()=>t("/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(a1,{}),"Add Tax Account"]})}),s.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200",children:[s.jsx("div",{className:"overflow-x-auto",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:"Actions"})]})}),s.jsx("tbody",{children:e===null?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."})}):d?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-slate-500",children:"Loading tax accounts…"})}):u?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."})}):h===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."})}):m.map(f=>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:f.state}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.taxAccountDetailId}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.status}),s.jsx("td",{className:"px-5 py-4 text-slate-600",children:f.state}),s.jsx("td",{className:"px-5 py-4",children:s.jsx("button",{type:"button",onClick:()=>t(`/settings/tax-accounts/${f.taxAccountDetailId}/edit`),className:"rounded-md px-2.5 py-1.5 text-sm font-medium text-gov-600 transition hover:bg-gov-50 hover:text-gov-700",children:"Edit"})})]},f.taxAccountDetailId))})]})}),e!==null?s.jsx(Qr,{page:a,pageSize:o,totalCount:h,onPageChange:i,onPageSizeChange:l,disabled:d}):null]})]})}function a1(){return s.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}const Sl="rounded-2xl border border-slate-200 bg-white shadow-sm";function i1(e){return e==="bank-accounts"||e==="tax-accounts"||e==="payment-history"||e==="entity-details"}function io(){const{selectedEntity:e}=pt(),n=Se().state,[r,a]=j.useState(i1(n==null?void 0:n.section)?n.section:"bank-accounts");return s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Sl} p-3`,children:s.jsx(dd,{items:On,activeSection:r,onSectionChange:a})}),s.jsx("div",{className:`${Sl} p-6 lg:p-8`,children:r==="bank-accounts"?s.jsx(Wj,{entityId:(e==null?void 0:e.entityId)??null}):r==="tax-accounts"?s.jsx(s1,{entityId:(e==null?void 0:e.entityId)??null}):r==="payment-history"?s.jsx(Gj,{entityId:(e==null?void 0:e.entityId)??null}):s.jsx(Qj,{entity:e})})]})}function o1({label:e,value:t,onChange:n,options:r,required:a=!1,disabled:i=!1,error:o,placeholder:l="Select a state"}){var k;const[c,d]=j.useState(!1),[u,m]=j.useState(""),h=j.useRef(null),f=j.useRef(null),x=j.useId(),p=(k=r.find(v=>v.code===t))==null?void 0:k.name,w=j.useMemo(()=>{const v=u.trim().toLowerCase();return v?r.filter(S=>S.name.toLowerCase().includes(v)||S.code.toLowerCase().includes(v)):r},[u,r]);j.useEffect(()=>{var v;c&&((v=f.current)==null||v.focus())},[c]),j.useEffect(()=>{if(!c)return;const v=S=>{var E;(E=h.current)!=null&&E.contains(S.target)||d(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]);const g=v=>{n(v),m(""),d(!1)};return s.jsxs("div",{ref:h,className:"relative",children:[s.jsx(Hr,{label:e,required:a,htmlFor:x}),s.jsxs("button",{id:x,type:"button",disabled:i,onClick:()=>{m(""),d(v=>!v)},className:`flex w-full items-center justify-between rounded-lg border bg-white px-3 py-2.5 text-left text-sm transition focus:outline-none focus:ring-2 focus:ring-gov-200 disabled:cursor-not-allowed disabled:opacity-60 ${o?"border-red-300":"border-slate-200 focus:border-gov-400"}`,children:[s.jsx("span",{className:p?"text-slate-900":"text-slate-400",children:p??l}),s.jsx(l1,{open:c})]}),c?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:"border-b border-slate-100 p-2",children:s.jsx("input",{ref:f,type:"search",value:u,onChange:v=>m(v.target.value),onKeyDown:v=>{v.key==="Escape"?d(!1):v.key==="Enter"&&v.preventDefault()},placeholder:"Search by state name or code","aria-label":"Search states",className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 focus:border-gov-400 focus:bg-white focus:ring-2 focus:ring-gov-100"})}),s.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[w.map(v=>s.jsxs("button",{type:"button",onClick:()=>g(v.code),className:`flex w-full items-center justify-between px-4 py-3 text-left text-sm transition hover:bg-slate-50 ${t===v.code?"bg-gov-50 text-gov-700":"text-slate-700"}`,children:[s.jsx("span",{children:v.name}),s.jsx("span",{className:"text-xs font-medium text-slate-400",children:v.code})]},v.code)),w.length===0?s.jsx("p",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No states found."}):null]})]}):null,o?s.jsx("p",{className:"mt-1 text-xs text-red-600",children:o}):null]})}function l1({open:e}){return s.jsx("svg",{className:`h-4 w-4 shrink-0 text-slate-400 transition ${e?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function kl({title:e,subtitle:t,children:n,className:r=""}){return s.jsxs("section",{className:`rounded-xl border border-slate-200 bg-white ${r}`,children:[s.jsxs("div",{className:"border-b border-slate-100 px-5 py-4",children:[s.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:e}),t?s.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:t}):null]}),s.jsx("div",{className:"space-y-5 p-5",children:n})]})}const c1=[{title:"Business Registration",fields:[{name:"virginiaTaxAccountId",label:"Virginia Tax Account ID",required:!0,placeholder:"e.g. 30123456789"},{name:"businessLocationCode",label:"Business Location Code",required:!0,placeholder:"e.g. 001"},{name:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number",required:!0,placeholder:"e.g. 12345678"}]},{title:"Payroll / Withholding",fields:[{name:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID",required:!0,placeholder:"e.g. 30123456789-WTH"},{name:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID",required:!0,placeholder:"e.g. 1234567"}]},{title:"Sales and Franchise Tax",fields:[{name:"franchiseTaxAccount",label:"Franchise Tax Account",required:!0,placeholder:"e.g. 30123456789-FRN"},{name:"transientOccupancyTaxAccountId",label:"Transient Occupancy Tax Account ID",required:!1,placeholder:"e.g. 30123456789-TOT"}]},{title:"Other Registrations",fields:[{name:"certificateOfAuthorityNumber",label:"Certificate of Authority Number (Foreign Entities)",required:!1,placeholder:"e.g. F123456789"},{name:"licensedProfessionalEmployerEntityNumber",label:"Licensed Professional Employer (POE) Entity Number",required:!1,placeholder:"e.g. POE-00123"}]}],u1={VA:c1},d1="United States",m1=Xt({state:_().min(1,"State is required"),city:_().min(1,"City is required"),zipCode:_().min(1,"ZIP code is required"),address1:_().min(1,"Address Line 1 is required"),address2:_().optional(),virginiaTaxAccountId:_().optional(),virginiaWithholdingAccountingId:_().optional(),unemploymentTaxAccountId:_().optional(),virginiaDepartmentOfTaxationClientNumber:_().optional(),businessLocationCode:_().optional(),franchiseTaxAccount:_().optional(),transientOccupancyTaxAccountId:_().optional(),certificateOfAuthorityNumber:_().optional(),licensedProfessionalEmployerEntityNumber:_().optional()}),h1=m1.superRefine((e,t)=>{if(xu.test(e.zipCode.trim())||t.addIssue({code:Qt.custom,message:"Enter a 5-digit ZIP or ZIP+4 (e.g. 12345 or 12345-6789)",path:["zipCode"]}),e.state!=="VA")return;const n=[{key:"virginiaTaxAccountId",label:"Virginia Tax Account ID"},{key:"virginiaWithholdingAccountingId",label:"Virginia Withholding Accounting ID"},{key:"unemploymentTaxAccountId",label:"Unemployment Tax Account ID"},{key:"virginiaDepartmentOfTaxationClientNumber",label:"Virginia Department of Taxation Client Number"},{key:"businessLocationCode",label:"Business Location Code"},{key:"franchiseTaxAccount",label:"Franchise Tax Account"}];for(const r of n){const a=e[r.key];(typeof a!="string"||!a.trim())&&t.addIssue({code:Qt.custom,message:`${r.label} is required`,path:[r.key]})}}),f1={state:"VA",city:"",zipCode:"",address1:"",address2:"",virginiaTaxAccountId:"",virginiaWithholdingAccountingId:"",unemploymentTaxAccountId:"",virginiaDepartmentOfTaxationClientNumber:"",businessLocationCode:"",franchiseTaxAccount:"",transientOccupancyTaxAccountId:"",certificateOfAuthorityNumber:"",licensedProfessionalEmployerEntityNumber:""};function p1(e){const t=e.virginia;return{state:e.state,city:e.city,zipCode:e.zipCode,address1:e.address1,address2:e.address2??"",virginiaTaxAccountId:(t==null?void 0:t.virginiaTaxAccountId)??"",virginiaWithholdingAccountingId:(t==null?void 0:t.virginiaWithholdingAccountingId)??"",unemploymentTaxAccountId:(t==null?void 0:t.unemploymentTaxAccountId)??"",virginiaDepartmentOfTaxationClientNumber:(t==null?void 0:t.virginiaDepartmentOfTaxationClientNumber)??"",businessLocationCode:(t==null?void 0:t.businessLocationCode)??"",franchiseTaxAccount:(t==null?void 0:t.franchiseTaxAccount)??"",transientOccupancyTaxAccountId:(t==null?void 0:t.transientOccupancyTaxAccountId)??"",certificateOfAuthorityNumber:(t==null?void 0:t.certificateOfAuthorityNumber)??"",licensedProfessionalEmployerEntityNumber:(t==null?void 0:t.licensedProfessionalEmployerEntityNumber)??""}}const ys=e=>{const t=e==null?void 0:e.trim();return t||null};function x1(e){var t,n,r,a,i,o;if(e.state==="VA")return{virginiaTaxAccountId:((t=e.virginiaTaxAccountId)==null?void 0:t.trim())??"",virginiaWithholdingAccountingId:((n=e.virginiaWithholdingAccountingId)==null?void 0:n.trim())??"",unemploymentTaxAccountId:((r=e.unemploymentTaxAccountId)==null?void 0:r.trim())??"",virginiaDepartmentOfTaxationClientNumber:((a=e.virginiaDepartmentOfTaxationClientNumber)==null?void 0:a.trim())??"",businessLocationCode:((i=e.businessLocationCode)==null?void 0:i.trim())??"",franchiseTaxAccount:((o=e.franchiseTaxAccount)==null?void 0:o.trim())??"",transientOccupancyTaxAccountId:ys(e.transientOccupancyTaxAccountId),certificateOfAuthorityNumber:ys(e.certificateOfAuthorityNumber),licensedProfessionalEmployerEntityNumber:ys(e.licensedProfessionalEmployerEntityNumber)}}function g1({entityId:e,taxAccountDetailId:t,initialValues:n,onCancel:r,onSuccess:a}){var I,$,ne,q,K,ee;const{showSuccess:i}=Vs(),o=xt(),l=t!=null,[c,d]=j.useState(null),[u,m]=j.useState(!1),{register:h,handleSubmit:f,watch:x,setValue:p,formState:{errors:w}}=$t({resolver:Lt(h1),defaultValues:n??f1}),g=h("zipCode"),k=x("state"),v=x("zipCode"),S=Mi(d1),E=u1[k],T=((I=S.find(z=>z.code===k))==null?void 0:I.name)??k,P=k.length>0&&v.trim().length>0&&!ur(S,k,v),O=f(async z=>{if(d(null),!ur(S,z.state,z.zipCode)){d(`ZIP code does not match the selected state (${z.state}).`);return}m(!0);try{const ae={state:z.state,city:z.city.trim(),zipCode:z.zipCode.trim(),address1:z.address1.trim(),address2:ys(z.address2),virginia:x1(z)};if(l)await r1(t,ae);else{const oe={entityId:e,...ae};await n1(oe)}await o.invalidateQueries({queryKey:["tax-accounts",e]}),i(l?"Tax Account Updated":"Tax Account Added",l?"Tax account details were updated successfully.":"Tax account was created successfully."),a==null||a()}catch(ae){d(at(ae,"Unable to save tax account. Please try again."))}finally{m(!1)}});return s.jsxs("form",{onSubmit:O,noValidate:!0,className:"max-w-4xl space-y-6",children:[c?s.jsx(zt,{message:c}):null,s.jsxs("div",{children:[s.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Tax jurisdiction"}),s.jsx("div",{className:"max-w-xs",children:s.jsx(o1,{label:"State",required:!0,value:k,onChange:z=>p("state",z,{shouldValidate:!0}),options:S.map(z=>({code:z.code,name:z.name})),error:($=w.state)==null?void 0:$.message})})]}),s.jsxs(kl,{title:"Common Information",subtitle:"Applies to every state this entity is registered in.",children:[s.jsxs("div",{className:"grid gap-5 sm:grid-cols-2",children:[s.jsx(ge,{label:"City",required:!0,placeholder:"e.g. Richmond",error:(ne=w.city)==null?void 0:ne.message,...h("city")}),s.jsx(ge,{label:"Zip Code",required:!0,maxLength:10,placeholder:"12345 or 12345-6789",error:((q=w.zipCode)==null?void 0:q.message)??(P?`ZIP code does not match the selected state (${k}).`:void 0),...g,onChange:z=>{z.target.value=zi(z.target.value),g.onChange(z)}})]}),s.jsx(ge,{label:"Address Line 1",required:!0,placeholder:"e.g. 123 Main Street",error:(K=w.address1)==null?void 0:K.message,...h("address1")}),s.jsx(ge,{label:"Address Line 2",placeholder:"Suite, unit, etc. (optional)",error:(ee=w.address2)==null?void 0:ee.message,...h("address2")})]}),E?s.jsx(kl,{title:`${T} Tax Registration`,children:E.map((z,ae)=>s.jsxs("div",{className:ae>0?"border-t border-slate-100 pt-5":"",children:[s.jsx("h4",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-gov-700",children:z.title}),s.jsx("div",{className:"grid gap-5 sm:grid-cols-2",children:z.fields.map(oe=>{var Q;return s.jsx(ge,{label:oe.label,required:oe.required,placeholder:oe.placeholder??"Enter",error:(Q=w[oe.name])==null?void 0:Q.message,...h(oe.name)},oe.name)})})]},z.title))}):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:r,disabled:u,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:u,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:u?"Saving…":"Save"})]})]})}const Na="rounded-2xl border border-slate-200 bg-white shadow-sm";function hr(){const e=ke(),{selectedEntity:t}=pt(),n=zs(),r=n.taxAccountDetailId?Number(n.taxAccountDetailId):void 0,a=r!=null,i=On.find(m=>m.id==="tax-accounts"),o=i.icon,l=(m="tax-accounts")=>{e("/settings",{state:{section:m}})},{data:c,isLoading:d,isError:u}=be({queryKey:["tax-account",r],queryFn:()=>t1(r),enabled:a});return t?s.jsxs("div",{className:"grid items-start gap-5 lg:grid-cols-[300px_minmax(0,1fr)]",children:[s.jsx("div",{className:`${Na} p-3`,children:s.jsx(dd,{items:On,activeSection:"tax-accounts",onSectionChange:l})}),s.jsxs("div",{className:`${Na} p-6 lg:p-8`,children:[s.jsx(mr,{title:a?"Edit Tax Account":i.title,subtitle:i.subtitle,icon:o}),a&&d?s.jsx("p",{className:"text-sm text-slate-500",children:"Loading tax account…"}):a&&(u||!c)?s.jsx(zt,{message:"Unable to load this tax account. Please try again."}):s.jsx(g1,{entityId:t.entityId,taxAccountDetailId:r,initialValues:c?p1(c):void 0,onCancel:()=>l("tax-accounts"),onSuccess:()=>l("tax-accounts")})]})]}):s.jsx("div",{className:Na+" 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 y1({paymentsMode:e="all"}){return s.jsxs(di,{children:[s.jsx(X,{index:!0,element:s.jsx(ji,{})}),s.jsx(X,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(X,{path:"create-entity/form",element:s.jsx(qi,{})}),s.jsxs(X,{element:s.jsx(wi,{}),children:[s.jsx(X,{path:"entities",element:s.jsx(Ui,{})}),s.jsx(X,{path:"dashboard",element:s.jsx(Vi,{})}),s.jsx(X,{path:"payments",element:s.jsx(Hi,{paymentsMode:e})}),s.jsx(X,{path:"payments/federal/new",element:s.jsx(qu,{})}),s.jsx(X,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Vu,{})}),s.jsx(X,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Uu,{})}),s.jsx(X,{path:"payments/state/new",element:s.jsx(Ku,{})}),s.jsx(X,{path:"payments/state/:statePaymentDetailId/edit",element:s.jsx(Qu,{})}),s.jsx(X,{path:"payments/state/:statePaymentDetailId/view",element:s.jsx(Ju,{})}),s.jsx(X,{path:"payments/state/authorization",element:s.jsx(ed,{})}),s.jsx(X,{path:"payments/federal/authorization",element:s.jsx(rd,{})}),s.jsx(X,{path:"payments/federal/individual-enrollment",element:s.jsx(cd,{})}),s.jsx(X,{path:"tax-forms",element:s.jsx(Dj,{})}),s.jsx(X,{path:"settings",element:s.jsx(io,{})}),s.jsx(X,{path:"settings/tax-accounts/new",element:s.jsx(hr,{})}),s.jsx(X,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(hr,{})})]}),s.jsx(X,{path:"*",element:s.jsx(Ue,{to:"/",replace:!0})})]})}const ai="tax-remittance:payment-complete",b1=j.forwardRef(function(t,n){const r=j.useRef(null),a=j.useRef(null);return j.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,i)},selectEntity:i=>{var o;return(o=a.current)==null?void 0:o.call(a,i)},notifyPaymentComplete:i=>{window.dispatchEvent(new CustomEvent(ai,{detail:{paymentId:i}}))}})),s.jsx(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,onPaymentRequired:t.onPaymentRequired,children:s.jsx(y1,{paymentsMode:"all"})})}),v1=j.forwardRef(function(t,n){const r=j.useRef(null),a=j.useRef(null);return j.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,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(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["federal"],children:s.jsxs(di,{children:[s.jsx(X,{index:!0,element:s.jsx(ji,{})}),s.jsx(X,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(X,{path:"create-entity/form",element:s.jsx(qi,{})}),s.jsxs(X,{element:s.jsx(wi,{}),children:[s.jsx(X,{path:"entities",element:s.jsx(Ui,{})}),s.jsx(X,{path:"dashboard",element:s.jsx(Vi,{})}),s.jsx(X,{path:"payments",element:s.jsx(Hi,{paymentsMode:"federal"})}),s.jsx(X,{path:"payments/federal/new",element:s.jsx(qu,{})}),s.jsx(X,{path:"payments/federal/:federalPaymentId/edit",element:s.jsx(Vu,{})}),s.jsx(X,{path:"payments/federal/:federalPaymentId/view",element:s.jsx(Uu,{})}),s.jsx(X,{path:"payments/federal/authorization",element:s.jsx(rd,{})}),s.jsx(X,{path:"payments/federal/individual-enrollment",element:s.jsx(cd,{})}),s.jsx(X,{path:"settings",element:s.jsx(io,{})}),s.jsx(X,{path:"settings/tax-accounts/new",element:s.jsx(hr,{})}),s.jsx(X,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(hr,{})})]}),s.jsx(X,{path:"*",element:s.jsx(Ue,{to:"/",replace:!0})})]})})}),j1=j.forwardRef(function(t,n){const r=j.useRef(null),a=j.useRef(null);return j.useImperativeHandle(n,()=>({navigate:i=>{var o;return(o=r.current)==null?void 0:o.call(r,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(vi,{...t,navigateFnRef:r,selectEntityFnRef:a,enabledPayments:["state"],children:s.jsxs(di,{children:[s.jsx(X,{index:!0,element:s.jsx(ji,{})}),s.jsx(X,{path:"create-entity",element:s.jsx(Ni,{})}),s.jsx(X,{path:"create-entity/form",element:s.jsx(qi,{})}),s.jsxs(X,{element:s.jsx(wi,{}),children:[s.jsx(X,{path:"entities",element:s.jsx(Ui,{})}),s.jsx(X,{path:"dashboard",element:s.jsx(Vi,{})}),s.jsx(X,{path:"payments",element:s.jsx(Hi,{paymentsMode:"state"})}),s.jsx(X,{path:"payments/state/new",element:s.jsx(Ku,{})}),s.jsx(X,{path:"payments/state/:statePaymentId/edit",element:s.jsx(Qu,{})}),s.jsx(X,{path:"payments/state/:statePaymentId/view",element:s.jsx(Ju,{})}),s.jsx(X,{path:"payments/state/authorization",element:s.jsx(ed,{})}),s.jsx(X,{path:"settings",element:s.jsx(io,{})}),s.jsx(X,{path:"settings/tax-accounts/new",element:s.jsx(hr,{})}),s.jsx(X,{path:"settings/tax-accounts/:taxAccountDetailId/edit",element:s.jsx(hr,{})})]}),s.jsx(X,{path:"*",element:s.jsx(Ue,{to:"/",replace:!0})})]})})});exports.ApiError=gr;exports.FederalPaymentWidget=v1;exports.StatePaymentWidget=j1;exports.TaxRemittanceEmbedded=b1;exports.setRuntimeApiBaseUrl=gc;
|
|
76
76
|
//# sourceMappingURL=index.cjs.map
|