PageSourceSearch

https://www.ai-bookkeeping.ai/assets/index-yl3rb8F0.js

js ai-bookkeeping.ai collected 2026-10-05 14:19:36 UTC 954,582 bytes, 98 lines download raw bytes

vendor: 5,741 bytes, lines 1-9
1function p5(e,n){for(var s=0;s<n.length;s++){const a=n[s];if(typeof a!="string"&&!Array.isArray(a)){for(const o in a)if(o!=="default"&&!(o in e)){const l=Object.getOwnPropertyDescriptor(a,o);l&&Object.defineProperty(e,o,l.get?l:{enumerable:!0,get:()=>a[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function s(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(o){if(o.ep)return;o.ep=!0;const l=s(o);fetch(o.href,l)}})();function Bv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Om={exports:{}},Pi={},$m={exports:{}},Pe={};/**
2 * @license React
3 * react.production.min.js
4 *
5 * Copyright (c) Facebook, Inc. and its affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */var j0;function f5(){if(j0)return Pe;j0=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.iterator;function b(L){return L===null||typeof L!="object"?null:(L=g&&L[g]||L["@@iterator"],typeof L=="function"?L:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function k(L,F,V){this.props=L,this.context=F,this.refs=w,this.updater=V||v}k.prototype.isReactComponent={},k.prototype.setState=function(L,F){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,F,"setState")},k.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function _(){}_.prototype=k.prototype;function S(L,F,V){this.props=L,this.context=F,this.refs=w,this.updater=V||v}var T=S.prototype=new _;T.constructor=S,N(T,k.prototype),T.isPureReactComponent=!0;var E=Array.isArray,A=Object.prototype.hasOwnProperty,I={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function W(L,F,V){var q,ee={},je=null,ke=null;if(F!=null)for(q in F.ref!==void 0&&(ke=F.ref),F.key!==void 0&&(je=""+F.key),F)A.call(F,q)&&!R.hasOwnProperty(q)&&(ee[q]=F[q]);var me=arguments.length-2;if(me===1)ee.children=V;else if(1<me){for(var Ne=Array(me),Oe=0;Oe<me;Oe++)Ne[Oe]=arguments[Oe+2];ee.children=Ne}if(L&&L.defaultProps)for(q in me=L.defaultProps,me)ee[q]===void 0&&(ee[q]=me[q]);return{$$typeof:e,type:L,key:je,ref:ke,props:ee,_owner:I.current}}function Y(L,F){return{$$typeof:e,type:L.type,key:F,ref:L.ref,props:L.props,_owner:L._owner}}function K(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function X(L){var F={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(V){return F[V]})}var se=/\/+/g;function ne(L,F){return typeof L=="object"&&L!==null&&L.key!=null?X(""+L.key):F.toString(36)}function Z(L,F,V,q,ee){var je=typeof L;(je==="undefined"||je==="boolean")&&(L=null);var ke=!1;if(L===null)ke=!0;else switch(je){case"string":case"number":ke=!0;break;case"object":switch(L.$$typeof){case e:case n:ke=!0}}if(ke)return ke=L,ee=ee(ke),L=q===""?"."+ne(ke,0):q,E(ee)?(V="",L!=null&&(V=L.replace(se,"$&/")+"/"),Z(ee,F,V,"",function(Oe){return Oe})):ee!=null&&(K(ee)&&(ee=Y(ee,V+(!ee.key||ke&&ke.key===ee.key?"":(""+ee.key).replace(se,"$&/")+"/")+L)),F.push(ee)),1;if(ke=0,q=q===""?".":q+":",E(L))for(var me=0;me<L.length;me++){je=L[me];var Ne=q+ne(je,me);ke+=Z(je,F,V,Ne,ee)}else if(Ne=b(L),typeof Ne=="function")for(L=Ne.call(L),me=0;!(je=L.next()).done;)je=je.value,Ne=q+ne(je,me++),ke+=Z(je,F,V,Ne,ee);else if(je==="object")throw F=String(L),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return ke}function ue(L,F,V){if(L==null)return L;var q=[],ee=0;return Z(L,q,"","",function(je){return F.call(V,je,ee++)}),q}function re(L){if(L._status===-1){var F=L._result;F=F(),F.then(function(V){(L._status===0||L._status===-1)&&(L._status=1,L._result=V)},function(V){(L._status===0||L._status===-1)&&(L._status=2,L._result=V)}),L._status===-1&&(L._status=0,L._result=F)}if(L._status===1)return L._result.default;throw L._result}var H={current:null},M={transition:null},Q={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:M,ReactCurrentOwner:I};function $(){throw Error("act(...) is not supported in production builds of React.")}return Pe.Children={map:ue,forEach:function(L,F,V){ue(L,function(){F.apply(this,arguments)},V)},count:function(L){var F=0;return ue(L,function(){F++}),F},toArray:function(L){return ue(L,function(F){return F})||[]},only:function(L){if(!K(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Pe.Component=k,Pe.Fragment=s,Pe.Profiler=o,Pe.PureComponent=S,Pe.StrictMode=a,Pe.Suspense=p,Pe.__SECRET_INT
vendor: 5,422 bytes, lines 9-25
9ERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,Pe.act=$,Pe.cloneElement=function(L,F,V){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var q=N({},L.props),ee=L.key,je=L.ref,ke=L._owner;if(F!=null){if(F.ref!==void 0&&(je=F.ref,ke=I.current),F.key!==void 0&&(ee=""+F.key),L.type&&L.type.defaultProps)var me=L.type.defaultProps;for(Ne in F)A.call(F,Ne)&&!R.hasOwnProperty(Ne)&&(q[Ne]=F[Ne]===void 0&&me!==void 0?me[Ne]:F[Ne])}var Ne=arguments.length-2;if(Ne===1)q.children=V;else if(1<Ne){me=Array(Ne);for(var Oe=0;Oe<Ne;Oe++)me[Oe]=arguments[Oe+2];q.children=me}return{$$typeof:e,type:L.type,key:ee,ref:je,props:q,_owner:ke}},Pe.createContext=function(L){return L={$$typeof:d,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:l,_context:L},L.Consumer=L},Pe.createElement=W,Pe.createFactory=function(L){var F=W.bind(null,L);return F.type=L,F},Pe.createRef=function(){return{current:null}},Pe.forwardRef=function(L){return{$$typeof:u,render:L}},Pe.isValidElement=K,Pe.lazy=function(L){return{$$typeof:f,_payload:{_status:-1,_result:L},_init:re}},Pe.memo=function(L,F){return{$$typeof:h,type:L,compare:F===void 0?null:F}},Pe.startTransition=function(L){var F=M.transition;M.transition={};try{L()}finally{M.transition=F}},Pe.unstable_act=$,Pe.useCallback=function(L,F){return H.current.useCallback(L,F)},Pe.useContext=function(L){return H.current.useContext(L)},Pe.useDebugValue=function(){},Pe.useDeferredValue=function(L){return H.current.useDeferredValue(L)},Pe.useEffect=function(L,F){return H.current.useEffect(L,F)},Pe.useId=function(){return H.current.useId()},Pe.useImperativeHandle=function(L,F,V){return H.current.useImperativeHandle(L,F,V)},Pe.useInsertionEffect=function(L,F){return H.current.useInsertionEffect(L,F)},Pe.useLayoutEffect=function(L,F){return H.current.useLayoutEffect(L,F)},Pe.useMemo=function(L,F){return H.current.useMemo(L,F)},Pe.useReducer=function(L,F,V){return H.current.useReducer(L,F,V)},Pe.useRef=function(L){return H.current.useRef(L)},Pe.useState=function(L){return H.current.useState(L)},Pe.useSyncExternalStore=function(L,F,V){return H.current.useSyncExternalStore(L,F,V)},Pe.useTransition=function(){return H.current.useTransition()},Pe.version="18.3.1",Pe}var w0;function ad(){return w0||(w0=1,$m.exports=f5()),$m.exports}/**
10 * @license React
11 * react-jsx-runtime.production.min.js
12 *
13 * Copyright (c) Facebook, Inc. and its affiliates.
14 *
15 * This source code is licensed under the MIT license found in the
16 * LICENSE file in the root directory of this source tree.
17 */var N0;function h5(){if(N0)return Pi;N0=1;var e=ad(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(u,p,h){var f,g={},b=null,v=null;h!==void 0&&(b=""+h),p.key!==void 0&&(b=""+p.key),p.ref!==void 0&&(v=p.ref);for(f in p)a.call(p,f)&&!l.hasOwnProperty(f)&&(g[f]=p[f]);if(u&&u.defaultProps)for(f in p=u.defaultProps,p)g[f]===void 0&&(g[f]=p[f]);return{$$typeof:n,type:u,key:b,ref:v,props:g,_owner:o.current}}return Pi.Fragment=s,Pi.jsx=d,Pi.jsxs=d,Pi}var _0;function x5(){return _0||(_0=1,Om.exports=h5()),Om.exports}var t=x5(),x=ad();const Uv=Bv(x),g5=p5({__proto__:null,default:Uv},[x]);var zl={},Mm={exports:{}},Gt={},Bm={exports:{}},Um={};/**
18 * @license React
19 * scheduler.production.min.js
20 *
21 * Copyright (c) Facebook, Inc. and its affiliates.
22 *
23 * This source code is licensed under the MIT license found in the
24 * LICENSE file in the root directory of this source tree.
25 */var k0;function y5(){return k0||(k0=1,(function(e){function n(M,Q){var $=M.length;M.push(Q);e:for(;0<$;){var L=$-1>>>1,F=M[L];if(0<o(F,Q))M[L]=Q,M[$]=F,$=L;else break e}}function s(M){return M.length===0?null:M[0]}function a(M){if(M.length===0)return null;var Q=M[0],$=M.pop();if($!==Q){M[0]=$;e:for(var L=0,F=M.length,V=F>>>1;L<V;){var q=2*(L+1)-1,ee=M[q],je=q+1,ke=M[je];if(0>o(ee,$))je<F&&0>o(ke,ee)?(M[L]=ke,M[je]=$,L=je):(M[L]=ee,M[q]=$,L=q);else if(je<F&&0>o(ke,$))M[L]=ke,M[je]=$,L=je;else break e}}return Q}function o(M,Q){var $=M.sortIndex-Q.sortIndex;return $!==0?$:M.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var p=[],h=[],f=1,g=null,b=3,v=!1,N=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(M){for(var Q=s(h);Q!==null;){if(Q.callback===null)a(h);else if(Q.startTime<=M)a(h),Q.sortIndex=Q.expirationTime,n(p,Q);else break;Q=s(h)}}function E(M){if(w=!1,T(M),!N)if(s(p)!==null)N=!0,re(A);else{var Q=s(h);Q!==null&&H(E,Q.startTime-M)}}function A(M,Q){N=!1,w&&(w=!1,_(W),W=-1),v=!0;var $=b;try{for(T(Q),g=s(p);g!==null&&(!(g.expirationTime>Q)||M&&!X());){var L=g.callback;if(typeof L=="function"){g.callback=null,b=g.priorityLevel;var F=L(g.expirationTime<=Q);Q=e.unstable_now(),typeof F=="function"?g.callback=F:g===s(p)&&a(p),T(Q)}else a(p);g=s(p)}if(g!==null)var V=!0;
vendor: 51,258 bytes, lines 25-38
25else{var q=s(h);q!==null&&H(E,q.startTime-Q),V=!1}return V}finally{g=null,b=$,v=!1}}var I=!1,R=null,W=-1,Y=5,K=-1;function X(){return!(e.unstable_now()-K<Y)}function se(){if(R!==null){var M=e.unstable_now();K=M;var Q=!0;try{Q=R(!0,M)}finally{Q?ne():(I=!1,R=null)}}else I=!1}var ne;if(typeof S=="function")ne=function(){S(se)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,ue=Z.port2;Z.port1.onmessage=se,ne=function(){ue.postMessage(null)}}else ne=function(){k(se,0)};function re(M){R=M,I||(I=!0,ne())}function H(M,Q){W=k(function(){M(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){N||v||(N=!0,re(A))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return s(p)},e.unstable_next=function(M){switch(b){case 1:case 2:case 3:var Q=3;break;default:Q=b}var $=b;b=Q;try{return M()}finally{b=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,Q){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var $=b;b=M;try{return Q()}finally{b=$}},e.unstable_scheduleCallback=function(M,Q,$){var L=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?L+$:L):$=L,M){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=$+F,M={id:f++,callback:Q,priorityLevel:M,startTime:$,expirationTime:F,sortIndex:-1},$>L?(M.sortIndex=$,n(h,M),s(p)===null&&M===s(h)&&(w?(_(W),W=-1):w=!0,H(E,$-L))):(M.sortIndex=F,n(p,M),N||v||(N=!0,re(A))),M},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(M){var Q=b;return function(){var $=b;b=Q;try{return M.apply(this,arguments)}finally{b=$}}}})(Um)),Um}var S0;function b5(){return S0||(S0=1,Bm.exports=y5()),Bm.exports}/**
26 * @license React
27 * react-dom.production.min.js
28 *
29 * Copyright (c) Facebook, Inc. and its affiliates.
30 *
31 * This source code is licensed under the MIT license found in the
32 * LICENSE file in the root directory of this source tree.
33 */var C0;function v5(){if(C0)return Gt;C0=1;var e=ad(),n=b5();function s(r){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+r,c=1;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,o={};function l(r,i){d(r,i),d(r+"Capture",i)}function d(r,i){for(o[r]=i,r=0;r<i.length;r++)a.add(i[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},g={};function b(r){return p.call(g,r)?!0:p.call(f,r)?!1:h.test(r)?g[r]=!0:(f[r]=!0,!1)}function v(r,i,c,m){if(c!==null&&c.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return m?!1:c!==null?!c.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function N(r,i,c,m){if(i===null||typeof i>"u"||v(r,i,c,m))return!0;if(m)return!1;if(c!==null)switch(c.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function w(r,i,c,m,y,j,C){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=m,this.attributeNamespace=y,this.mustUseProperty=c,this.propertyName=r,this.type=i,this.sanitizeURL=j,this.removeEmptyString=C}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){k[r]=new w(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var i=r[0];k[i]=new w(i,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){k[r]=new w(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){k[r]=new w(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){k[r]=new w(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){k[r]=new w(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){k[r]=new w(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){k[r]=new w(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){k[r]=new w(r,5,!1,r.toLowerCase(),null,!1,!1)});var _=/[\-:]([a-z])/g;function S(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var i=r.replace(_,S);k[i]=new w(i,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var i=r.replace(_,S);k[i]=new w(i,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var i=r.replace(_,S);k[i]=new w(i,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){k[r]=new w(r,1,!1,r.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){k[r]=new w(r,1,!1,r.toLowerCase(),null,!0,!0)});function T(r,i,c,m){var y=k.hasOwnProperty(i)?k[i]:null;(y!==null?y.type!==0:m||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(N(i,c,y,m)&&(c=null),m||y===null?b(i)&&(c===null?r.removeAttribute(i):r.setAttribute(i,""+c)):y.mustUseProperty?r[y.propertyName]=c===null?y.type===3?!1:"":c:(i=y.attributeName,m=y.attributeNamespace,c===null?r.removeAttribute(i):(y=y.type,c=y===3||y===4&&c===!0?"":""+c,m?r.setAttributeNS(m,i,c):r.setAttribute(i,c))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),I=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),K=Symbol.for("react.provider"),X=Symbol.for("react.context"),se=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),ue=Symbol.for("react.memo"),re=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),M=Symbol.iterator;function Q(r){return r===null||typeof r!="object"?null:(r=M&&r[M]||r["@@iterator"],typeof r=="function"?r:null)}var $=Object.assign,L;function F(r){if(L===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);L=i&&i[1]||""}return`
34`+L+r}var V=!1;function q(r,i){if(!r||V)return"";V=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(G){var m=G}Reflect.construct(r,[],i)}else{try{i.call()}catch(G){m=G}r.call(i.prototype)}else{try{throw Error()}catch(G){m=G}r()}}catch(G){if(G&&m&&typeof G.stack=="string"){for(var y=G.stack.split(`
35`),j=m.stack.split(`
36`),C=y.length-1,P=j.length-1;1<=C&&0<=P&&y[C]!==j[P];)P--;for(;1<=C&&0<=P;C--,P--)if(y[C]!==j[P]){if(C!==1||P!==1)do if(C--,P--,0>P||y[C]!==j[P]){var D=`
37`+y[C].replace(" at new "," at ");return r.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",r.displayName)),D}while(1<=C&&0<=P);break}}}finally{V=!1,Error.prepareStackTrace=c}return(r=r?r.displayName||r.name:"")?F(r):""}function ee(r){switch(r.tag){case 5:return F(r.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return r=q(r.type,!1),r;case 11:return r=q(r.type.render,!1),r;case 1:return r=q(r.type,!0),r;default:return""}}function je(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case R:return"Fragment";case I:return"Portal";case Y:return"Profiler";case W:return"StrictMode";case ne:return"Suspense";case Z:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case X:return(r.displayName||"Context")+".Consumer";case K:return(r._context.displayName||"Context")+".Provider";case se:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ue:return i=r.displayName||null,i!==null?i:je(r.type)||"Memo";case re:i=r._payload,r=r._init;try{return je(r(i))}catch{}}return null}function ke(r){var i=r.type;switch(r.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=i.render,r=r.displayName||r.name||"",i.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(i);case 8:return i===W?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function me(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ne(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Oe(r){var i=Ne(r)?"checked":"value",c=Object.getOwnPropertyDescriptor(r.constructor.prototype,i),m=""+r[i];if(!r.hasOwnProperty(i)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var y=c.get,j=c.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return y.call(this)},set:function(C){m=""+C,j.call(this,C)}}),Object.defineProperty(r,i,{enumerable:c.enumerable}),{getValue:function(){return m},setValue:function(C){m=""+C},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function mt(r){r._valueTracker||(r._valueTracker=Oe(r))}function he(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var c=i.getValue(),m="";return r&&(m=Ne(r)?r.checked?"true":"false":r.value),r=m,r!==c?(i.setValue(r),!0):!1}function Se(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function ae(r,i){var c=i.checked;return $({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??r._wrapperState.initialChecked})}function J(r,i){var c=i.defaultValue==null?"":i.defaultValue,m=i.checked!=null?i.checked:i.defaultChecked;c=me(i.value!=null?i.value:c),r._wrapperState={initialChecked:m,initialValue:c,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function pe(r,i){i=i.checked,i!=null&&T(r,"checked",i,!1)}function Re(r,i){pe(r,i);var c=me(i.value),m=i.type;if(c!=null)m==="number"?(c===0&&r.value===""||r.value!=c)&&(r.value=""+c):r.value!==""+c&&(r.value=""+c);else if(m==="submit"||m==="reset"){r.removeAttribute("value");return}i.hasOwnProperty("value")?xt(r,i.type,c):i.hasOwnProperty("defaultValue")&&xt(r,i.type,me(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(r.defaultChecked=!!i.defaultChecked)}function We(r,i,c){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var m=i.type;if(!(m!=="submit"&&m!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+r._wrapperState.initialValue,c||i===r.value||(r.value=i),r.defaultValue=i}c=r.name,c!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,c!==""&&(r.name=c)}function xt(r,i,c){(i!=="number"||Se(r.ownerDocument)!==r)&&(c==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+c&&(r.defaultValue=""+c))}var Ct=Array.isArray;function Un(r,i,c,m){if(r=r.options,i){i={};for(var y=0;y<c.length;y++)i["$"+c[y]]=!0;for(c=0;c<r.length;c++)y=i.hasOwnProperty("$"+r[c].value),r[c].selected!==y&&(r[c].selected=y),y&&m&&(r[c].defaultSelected=!0)}else{for(c=""+me(c),i=null,y=0;y<r.length;y++){if(r[y].value===c){r[y].selected=!0,m&&(r[y].defaultSelected=!0);return}i!==null||r[y].disabled||(i=r[y])}i!==null&&(i.selected=!0)}}function de(r,i){if(i.dangerouslySetInnerHTML!=null)throw Error(s(91));return $({},i,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Be(r,i){var c=i.value;if(c==null){if(c=i.children,i=i.defaultValue,c!=null){if(i!=null)throw Error(s(92));if(Ct(c)){if(1<c.length)throw Error(s(93));c=c[0]}i=c}i==null&&(i=""),c=i}r._wrapperState={initialValue:me(c)}}function Ze(r,i){var c=me(i.value),m=me(i.defaultValue);c!=null&&(c=""+c,c!==r.value&&(r.value=c),i.defaultValue==null&&r.defaultValue!==c&&(r.defaultValue=c)),m!=null&&(r.defaultValue=""+m)}function ws(r){var i=r.textContent;i===r._wrapperState.initialValue&&i!==""&&i!==null&&(r.value=i)}function Ka(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Gd(r,i){return r==null||r==="http://www.w3.org/1999/xhtml"?Ka(i):r==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var Po,Fh=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,c,m,y){MSApp.execUnsafeLocalFunction(function(){return r(i,c,m,y)})}:r})(function(r,i){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=i;else{for(Po=Po||document.createElement("div"),Po.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=Po.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;i.firstChild;)r.appendChild(i.firstChild)}});function Qa(r,i){if(i){var c=r.firstChild;if(c&&c===r.lastChild&&c.nodeType===3){c.nodeValue=i;return}}r.textContent=i}var Ja={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},g2=["Webkit","ms","Moz","O"];Object.keys(Ja).forEach(function(r){g2.forEach(function(i){i=i+r.charAt(0).toUpperCase()+r.substring(1),Ja[i]=Ja[r]})});function Dh(r,i,c){return i==null||typeof i=="boolean"||i===""?"":c||typeof i!="number"||i===0||Ja.hasOwnProperty(r)&&Ja[r]?(""+i).trim():i+"px"}function Oh(r,i){r=r.style;for(var c in i)if(i.hasOwnProperty(c)){var m=c.indexOf("--")===0,y=Dh(c,i[c],m);c==="float"&&(c="cssFloat"),m?r.setProperty(c,y):r[c]=y}}var y2=$({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Kd(r,i){if(i){if(y2[r]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(s(137,r));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(s(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(s(61))}if(i.style!=null&&typeof i.style!="object")throw Error(s(62))}}function Qd(r,i){if(r.indexOf("-")===-1)return typeof i.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Jd=null;function Xd(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Zd=null,qr=null,Vr=null;function $h(r){if(r=bi(r)){if(typeof Zd!="function")throw Error(s(280));var i=r.stateNode;i&&(i=sl(i),Zd(r.stateNode,r.type,i))}}function Mh(r){qr?Vr?Vr.push(r):Vr=[r]:qr=r}function Bh(){if(qr){var r=qr,i=Vr;if(Vr=qr=null,$h(r),i)for(r=0;r<i.length;r++)$h(i[r])}}function Uh(r,i){return r(i)}function zh(){}var eu=!1;function Wh(r,i,c){if(eu)return r(i,c);eu=!0;try{return Uh(r,i,c)}finally{eu=!1,(qr!==null||Vr!==null)&&(zh(),Bh())}}function Xa(r,i){var c=r.stateNode;if(c===null)return null;var m=sl(c);if(m===null)return null;c=m[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(r=r.type,m=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!m;break e;default:r=!1}if(r)return null;if(c&&typeof c!="function")throw Error(s(231,i,typeof c));return c}var tu=!1;if(u)try{var Za={};Object.defineProperty(Za,"passive",{get:function(){tu=!0}}),window.addEventListener("test",Za,Za),window.removeEventListener("test",Za,Za)}catch{tu=!1}function b2(r,i,c,m,y,j,C,P,D){var G=Array.prototype.slice.call(arguments,3);try{i.apply(c,G)}catch(oe){this.onError(oe)}}var ei=!1,Fo=null,Do=!1,nu=null,v2={onError:function(r){ei=!0,Fo=r}};function j2(r,i,c,m,y,j,C,P,D){ei=!1,Fo=null,b2.apply(v2,arguments)}function w2(r,i,c,m,y,j,C,P,D){if(j2.apply(this,arguments),ei){if(ei){var G=Fo;ei=!1,Fo=null}else throw Error(s(198));Do||(Do=!0,nu=G)}}function tr(r){var i=r,c=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(c=i.return),r=i.return;while(r)}return i.tag===3?c:null}function Hh(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function qh(r){if(tr(r)!==r)throw Error(s(188))}function N2(r){var i=r.alternate;if(!i){if(i=tr(r),i===null)throw Error(s(188));return i!==r?null:r}for(var c=r,m=i;;){var y=c.return;if(y===null)break;var j=y.alternate;if(j===null){if(m=y.return,m!==null){c=m;continue}break}if(y.child===j.child){for(j=y.child;j;){if(j===c)return qh(y),r;if(j===m)return qh(y),i;j=j.sibling}throw Error(s(188))}if(c.return!==m.return)c=y,m=j;else{for(var C=!1,P=y.child;P;){if(P===c){C=!0,c=y,m=j;break}if(P===m){C=!0,m=y,c=j;break}P=P.sibling}if(!C){for(P=j.child;P;){if(P===c){C=!0,c=j,m=y;break}if(P===m){C=!0,m=j,c=y;break}P=P.sibling}if(!C)throw Error(s(189))}}if(c.alternate!==m)throw Error(s(190))}if(c.tag!==3)throw Error(s(188));return c.stateNode.current===c?r:i}function Vh(r){return r=N2(r),r!==null?Yh(r):null}function Yh(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var i=Yh(r);if(i!==null)return i;r=r.sibling}return null}var Gh=n.unstable_scheduleCallback,Kh=n.unstable_cancelCallback,_2=n.unstable_shouldYield,k2=n.unstable_requestPaint,rt=n.unstable_now,S2=n.unstable_getCurrentPriorityLevel,su=n.unstable_ImmediatePriority,Qh=n.unstable_UserBlockingPriority,Oo=n.unstable_NormalPriority,C2=n.unstable_LowPriority,Jh=n.unstable_IdlePriority,$o=null,zn=null;function E2(r){if(zn&&typeof zn.onCommitFiberRoot=="function")try{zn.onCommitFiberRoot($o,r,void 0,(r.current.flags&128)===128)}catch{}}var wn=Math.clz32?Math.clz32:L2,A2=Math.log,T2=Math.LN2;function L2(r){return r>>>=0,r===0?32:31-(A2(r)/T2|0)|0}var Mo=64,Bo=4194304;function ti(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Uo(r,i){var c=r.pendingLanes;if(c===0)return 0;var m=0,y=r.suspendedLanes,j=r.pingedLanes,C=c&268435455;if(C!==0){var P=C&~y;P!==0?m=ti(P):(j&=C,j!==0&&(m=ti(j)))}else C=c&~y,C!==0?m=ti(C):j!==0&&(m=ti(j));if(m===0)return 0;if(i!==0&&i!==m&&(i&y)===0&&(y=m&-m,j=i&-i,y>=j||y===16&&(j&4194240)!==0))return i;if((m&4)!==0&&(m|=c&16),i=r.entangledLanes,i!==0)for(r=r.entanglements,i&=m;0<i;)c=31-wn(i),y=1<<c,m|=r[c],i&=~y;return m}function R2(r,i){switch(r){case 1:case 2:case 4:return i+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function I2(r,i){for(var c=r.suspendedLanes,m=r.pingedLanes,y=r.expirationTimes,j=r.pendingLanes;0<j;){var C=31-wn(j),P=1<<C,D=y[C];D===-1?((P&c)===0||(P&m)!==0)&&(y[C]=R2(P,i)):D<=i&&(r.expiredLanes|=P),j&=~P}}function ru(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Xh(){var r=Mo;return Mo<<=1,(Mo&4194240)===0&&(Mo=64),r}function au(r){for(var i=[],c=0;31>c;c++)i.push(r);return i}function ni(r,i,c){r.pendingLanes|=i,i!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,i=31-wn(i),r[i]=c}function P2(r,i){var c=r.pendingLanes&~i;r.pendingLanes=i,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=i,r.mutableReadLanes&=i,r.entangledLanes&=i,i=r.entanglements;var m=r.eventTimes;for(r=r.expirationTimes;0<c;){var y=31-wn(c),j=1<<y;i[y]=0,m[y]=-1,r[y]=-1,c&=~j}}function iu(r,i){var c=r.entangledLanes|=i;for(r=r.entanglements;c;){var m=31-wn(c),y=1<<m;y&i|r[m]&i&&(r[m]|=i),c&=~y}}var ze=0;function Zh(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var ex,ou,tx,nx,sx,lu=!1,zo=[],Ns=null,_s=null,ks=null,si=new Map,ri=new Map,Ss=[],F2="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function rx(r,i){switch(r){case"focusin":case"focusout":Ns=null;break;case"dragenter":case"dragleave":_s=null;break;case"mouseover":case"mouseout":ks=null;break;case"pointerover":case"pointerout":si.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":ri.delete(i.pointerId)}}function ai(r,i,c,m,y,j){return r===null||r.nativeEvent!==j?(r={blockedOn:i,domEventName:c,eventSystemFlags:m,nativeEvent:j,targetContainers:[y]},i!==null&&(i=bi(i),i!==null&&ou(i)),r):(r.eventSystemFlags|=m,i=r.targetContainers,y!==null&&i.indexOf(y)===-1&&i.push(y),r)}function D2(r,i,c,m,y){switch(i){case"focusin":return Ns=ai(Ns,r,i,c,m,y),!0;case"dragenter":return _s=ai(_s,r,i,c,m,y),!0;case"mouseover":return ks=ai(ks,r,i,c,m,y),!0;case"pointerover":var j=y.pointerId;return si.set(j,ai(si.get(j)||null,r,i,c,m,y)),!0;case"gotpointercapture":return j=y.pointerId,ri.set(j,ai(ri.get(j)||null,r,i,c,m,y)),!0}return!1}function ax(r){var i=nr(r.target);if(i!==null){var c=tr(i);if(c!==null){if(i=c.tag,i===13){if(i=Hh(c),i!==null){r.blockedOn=i,sx(r.priority,function(){tx(c)});return}}else if(i===3&&c.stateNode.current.memoizedState.isDehydrated){r.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Wo(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var c=du(r.domEventName,r.eventSystemFlags,i[0],r.nativeEvent);if(c===null){c=r.nativeEvent;var m=new c.constructor(c.type,c);Jd=m,c.target.dispatchEvent(m),Jd=null}else return i=bi(c),i!==null&&ou(i),r.blockedOn=c,!1;i.shift()}return!0}function ix(r,i,c){Wo(r)&&c.delete(i)}function O2(){lu=!1,Ns!==null&&Wo(Ns)&&(Ns=null),_s!==null&&Wo(_s)&&(_s=null),ks!==null&&Wo(ks)&&(ks=null),si.forEach(ix),ri.forEach(ix)}function ii(r,i){r.blockedOn===i&&(r.blockedOn=null,lu||(lu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,O2)))}function oi(r){function i(y){return ii(y,r)}if(0<zo.length){ii(zo[0],r);for(var c=1;c<zo.length;c++){var m=zo[c];m.blockedOn===r&&(m.blockedOn=null)}}for(Ns!==null&&ii(Ns,r),_s!==null&&ii(_s,r),ks!==null&&ii(ks,r),si.forEach(i),ri.forEach(i),c=0;c<Ss.length;c++)m=Ss[c],m.blockedOn===r&&(m.blockedOn=null);for(;0<Ss.length&&(c=Ss[0],c.blockedOn===null);)ax(c),c.blockedOn===null&&Ss.shift()}var Yr=E.ReactCurrentBatchConfig,Ho=!0;function $2(r,i,c,m){var y=ze,j=Yr.transition;Yr.transition=null;try{ze=1,cu(r,i,c,m)}finally{ze=y,Yr.transition=j}}function M2(r,i,c,m){var y=ze,j=Yr.transition;Yr.transition=null;try{ze=4,cu(r,i,c,m)}finally{ze=y,Yr.transition=j}}function cu(r,i,c,m){if(Ho){var y=du(r,i,c,m);if(y===null)Cu(r,i,m,qo,c),rx(r,m);else if(D2(y,r,i,c,m))m.stopPropagation();else if(rx(r,m),i&4&&-1<F2.indexOf(r)){for(;y!==null;){var j=bi(y);if(j!==null&&ex(j),j=du(r,i,c,m),j===null&&Cu(r,i,m,qo,c),j===y)break;y=j}y!==null&&m.stopPropagation()}else Cu(r,i,m,null,c)}}var qo=null;function du(r,i,c,m){if(qo=null,r=Xd(m),r=nr(r),r!==null)if(i=tr(r),i===null)r=null;else if(c=i.tag,c===13){if(r=Hh(i),r!==null)return r;r=null}else if(c===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null);return qo=r,null}function ox(r){switch(r){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(S2()){case su:return 1;case Qh:return 4;case Oo:case C2:return 16;case Jh:return 536870912;default:return 16}default:return 16}}var Cs=null,uu=null,Vo=null;function lx(){if(Vo)return Vo;var r,i=uu,c=i.length,m,y="value"in Cs?Cs.value:Cs.textContent,j=y.length;for(r=0;r<c&&i[r]===y[r];r++);var C=c-r;for(m=1;m<=C&&i[c-m]===y[j-m];m++);return Vo=y.slice(r,1<m?1-m:void 0)}function Yo(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function Go(){return!0}function cx(){return!1}function Jt(r){function i(c,m,y,j,C){this._reactName=c,this._targetInst=y,this.type=m,this.nativeEvent=j,this.target=C,this.currentTarget=null;for(var P in r)r.hasOwnProperty(P)&&(c=r[P],this[P]=c?c(j):j[P]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?Go:cx,this.isPropagationStopped=cx,this}return $(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=Go)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=Go)},persist:function(){},isPersistent:Go}),i}var Gr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mu=Jt(Gr),li=$({},Gr,{view:0,detail:0}),B2=Jt(li),pu,fu,ci,Ko=$({},li,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xu,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==ci&&(ci&&r.type==="mousemove"?(pu=r.screenX-ci.screenX,fu=r.screenY-ci.screenY):fu=pu=0,ci=r),pu)},movementY:function(r){return"movementY"in r?r.movementY:fu}}),dx=Jt(Ko),U2=$({},Ko,{dataTransfer:0}),z2=Jt(U2),W2=$({},li,{relatedTarget:0}),hu=Jt(W2),H2=$({},Gr,{animationName:0,elapsedTime:0,pseudoElement:0}),q2=Jt(H2),V2=$({},Gr,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Y2=Jt(V2),G2=$({},Gr,{data:0}),ux=Jt(G2),K2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Q2={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},J2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function X2(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=J2[r])?!!i[r]:!1}function xu(){return X2}var Z2=$({},li,{key:function(r){if(r.key){var i=K2[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=Yo(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Q2[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xu,charCode:function(r){return r.type==="keypress"?Yo(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Yo(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),eN=Jt(Z2),tN=$({},Ko,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),mx=Jt(tN),nN=$({},li,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xu}),sN=Jt(nN),rN=$({},Gr,{propertyName:0,elapsedTime:0,pseudoElement:0}),aN=Jt(rN),iN=$({},Ko,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),oN=Jt(iN),lN=[9,13,27,32],gu=u&&"CompositionEvent"in window,di=null;u&&"documentMode"in document&&(di=document.documentMode);var cN=u&&"TextEvent"in window&&!di,px=u&&(!gu||di&&8<di&&11>=di),fx=" ",hx=!1;function xx(r,i){switch(r){case"keyup":return lN.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gx(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Kr=!1;function dN(r,i){switch(r){case"compositionend":return gx(i);case"keypress":return i.which!==32?null:(hx=!0,fx);case"textInput":return r=i.data,r===fx&&hx?null:r;default:return null}}function uN(r,i){if(Kr)return r==="compositionend"||!gu&&xx(r,i)?(r=lx(),Vo=uu=Cs=null,Kr=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return px&&i.locale!=="ko"?null:i.data;default:return null}}var mN={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function yx(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!mN[r.type]:i==="textarea"}function bx(r,i,c,m){Mh(m),i=el(i,"onChange"),0<i.length&&(c=new mu("onChange","change",null,c,m),r.push({event:c,listeners:i}))}var ui=null,mi=null;function pN(r){Ox(r,0)}function Qo(r){var i=ea(r);if(he(i))return r}function fN(r,i){if(r==="change")return i}var vx=!1;if(u){var yu;if(u){var bu="oninput"in document;if(!bu){var jx=document.createElement("div");jx.setAttribute("oninput","return;"),bu=typeof jx.oninput=="function"}yu=bu}else yu=!1;vx=yu&&(!document.documentMode||9<document.documentMode)}function wx(){ui&&(ui.detachEvent("onpropertychange",Nx),mi=ui=null)}function Nx(r){if(r.propertyName==="value"&&Qo(mi)){var i=[];bx(i,mi,r,Xd(r)),Wh(pN,i)}}function hN(r,i,c){r==="focusin"?(wx(),ui=i,mi=c,ui.attachEvent("onpropertychange",Nx)):r==="focusout"&&wx()}function xN(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Qo(mi)}function gN(r,i){if(r==="click")return Qo(i)}function yN(r,i){if(r==="input"||r==="change")return Qo(i)}function bN(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Nn=typeof Object.is=="function"?Object.is:bN;function pi(r,i){if(Nn(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var c=Object.keys(r),m=Object.keys(i);if(c.length!==m.length)return!1;for(m=0;m<c.length;m++){var y=c[m];if(!p.call(i,y)||!Nn(r[y],i[y]))return!1}return!0}function _x(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function kx(r,i){var c=_x(r);r=0;for(var m;c;){if(c.nodeType===3){if(m=r+c.textContent.length,r<=i&&m>=i)return{node:c,offset:i-r};r=m}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=_x(c)}}function Sx(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?Sx(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function Cx(){for(var r=window,i=Se();i instanceof r.HTMLIFrameElement;){try{var c=typeof i.contentWindow.location.href=="string"}catch{c=!1}if(c)r=i.contentWindow;else break;i=Se(r.document)}return i}function vu(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}function vN(r){var i=Cx(),c=r.focusedElem,m=r.selectionRange;if(i!==c&&c&&c.ownerDocument&&Sx(c.ownerDocument.documentElement,c)){if(m!==null&&vu(c)){if(i=m.start,r=m.end,r===void 0&&(r=i),"selectionStart"in c)c.selectionStart=i,c.selectionEnd=Math.min(r,c.value.length);else if(r=(i=c.ownerDocument||document)&&i.defaultView||window,r.getSelection){r=r.getSelection();var y=c.textContent.length,j=Math.min(m.start,y);m=m.end===void 0?j:Math.min(m.end,y),!r.extend&&j>m&&(y=m,m=j,j=y),y=kx(c,j);var C=kx(c,m);y&&C&&(r.rangeCount!==1||r.anchorNode!==y.node||r.anchorOffset!==y.offset||r.focusNode!==C.node||r.focusOffset!==C.offset)&&(i=i.createRange(),i.setStart(y.node,y.offset),r.removeAllRanges(),j>m?(r.addRange(i),r.extend(C.node,C.offset)):(i.setEnd(C.node,C.offset),r.addRange(i)))}}for(i=[],r=c;r=r.parentNode;)r.nodeType===1&&i.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<i.length;c++)r=i[c],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var jN=u&&"documentMode"in document&&11>=document.documentMode,Qr=null,ju=null,fi=null,wu=!1;function Ex(r,i,c){var m=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;wu||Qr==null||Qr!==Se(m)||(m=Qr,"selectionStart"in m&&vu(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),fi&&pi(fi,m)||(fi=m,m=el(ju,"onSelect"),0<m.length&&(i=new mu("onSelect","select",null,i,c),r.push({event:i,listeners:m}),i.target=Qr)))}function Jo(r,i){var c={};return c[r.toLowerCase()]=i.toLowerCase(),c["Webkit"+r]="webkit"+i,c["Moz"+r]="moz"+i,c}var Jr={animationend:Jo("Animation","AnimationEnd"),animationiteration:Jo("Animation","AnimationIteration"),animationstart:Jo("Animation","AnimationStart"),transitionend:Jo("Transition","TransitionEnd")},Nu={},Ax={};u&&(Ax=document.createElement("div").style,"AnimationEvent"in window||(delete Jr.animationend.animation,delete Jr.animationiteration.animation,delete Jr.animationstart.animation),"TransitionEvent"in window||delete Jr.transitionend.transition);function Xo(r){if(Nu[r])return Nu[r];if(!Jr[r])return r;var i=Jr[r],c;for(c in i)if(i.hasOwnProperty(c)&&c in Ax)return Nu[r]=i[c];return r}var Tx=Xo("animationend"),Lx=Xo("animationiteration"),Rx=Xo("animationstart"),Ix=Xo("transitionend"),Px=new Map,Fx="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Es(r,i){Px.set(r,i),l(i,[r])}for(var _u=0;_u<Fx.length;_u++){var ku=Fx[_u],wN=ku.toLowerCase(),NN=ku[0].toUpperCase()+ku.slice(1);Es(wN,"on"+NN)}Es(Tx,"onAnimationEnd"),Es(Lx,"onAnimationIteration"),Es(Rx,"onAnimationStart"),Es("dblclick","onDoubleClick"),Es("focusin","onFocus"),Es("focusout","onBlur"),Es(Ix,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var hi="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_N=new Set("cancel close invalid load scroll toggle".split(" ").concat(hi));function Dx(r,i,c){var m=r.type||"unknown-event";r.currentTarget=c,w2(m,i,void 0,r),r.currentTarget=null}function Ox(r,i){i=(i&4)!==0;for(var c=0;c<r.length;c++){var m=r[c],y=m.event;m=m.listeners;e:{var j=void 0;if(i)for(var C=m.length-1;0<=C;C--){var P=m[C],D=P.instance,G=P.currentTarget;if(P=P.listener,D!==j&&y.isPropagationStopped())break e;Dx(y,P,G),j=D}else for(C=0;C<m.length;C++){if(P=m[C],D=P.instance,G=P.currentTarget,P=P.listener,D!==j&&y.isPropagationStopped())break e;Dx(y,P,G),j=D}}}if(Do)throw r=nu,Do=!1,nu=null,r}function Ve(r,i){var c=i[Iu];c===void 0&&(c=i[Iu]=new Set);var m=r+"__bubble";c.has(m)||($x(i,r,2,!1),c.add(m))}function Su(r,i,c){var m=0;i&&(m|=4),$x(c,r,m,i)}var Zo="_reactListening"+Math.random().toString(36).slice(2);function xi(r){if(!r[Zo]){r[Zo]=!0,a.forEach(function(c){c!=="selectionchange"&&(_N.has(c)||Su(c,!1,r),Su(c,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[Zo]||(i[Zo]=!0,Su("selectionchange",!1,i))}}function $x(r,i,c,m){switch(ox(i)){case 1:var y=$2;break;case 4:y=M2;break;default:y=cu}c=y.bind(null,i,c,r),y=void 0,!tu||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(y=!0),m?y!==void 0?r.addEventListener(i,c,{capture:!0,passive:y}):r.addEventListener(i,c,!0):y!==void 0?r.addEventListener(i,c,{passive:y}):r.addEventListener(i,c,!1)}function Cu(r,i,c,m,y){var j=m;if((i&1)===0&&(i&2)===0&&m!==null)e:for(;;){if(m===null)return;var C=m.tag;if(C===3||C===4){var P=m.stateNode.containerInfo;if(P===y||P.nodeType===8&&P.parentNode===y)break;if(C===4)for(C=m.return;C!==null;){var D=C.tag;if((D===3||D===4)&&(D=C.stateNode.containerInfo,D===y||D.nodeType===8&&D.parentNode===y))return;C=C.return}for(;P!==null;){if(C=nr(P),C===null)return;if(D=C.tag,D===5||D===6){m=j=C;continue e}P=P.parentNode}}m=m.return}Wh(function(){var G=j,oe=Xd(c),le=[];e:{var ie=Px.get(r);if(ie!==void 0){var fe=mu,ge=r;switch(r){case"keypress":if(Yo(c)===0)break e;case"keydown":case"keyup":fe=eN;break;case"focusin":ge="focus",fe=hu;break;case"focusout":ge="blur",fe=hu;break;case"beforeblur":case"afterblur":fe=hu;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=dx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=z2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=sN;break;case Tx:case Lx:case Rx:fe=q2;break;case Ix:fe=aN;break;case"scroll":fe=B2;break;case"wheel":fe=oN;break;case"copy":case"cut":case"paste":fe=Y2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=mx}var we=(i&4)!==0,at=!we&&r==="scroll",U=we?ie!==null?ie+"Capture":null:ie;we=[];for(var O=G,z;O!==null;){z=O;var ce=z.stateNode;if(z.tag===5&&ce!==null&&(z=ce,U!==null&&(ce=Xa(O,U),ce!=null&&we.push(gi(O,ce,z)))),at)break;O=O.return}0<we.length&&(ie=new fe(ie,ge,null,c,oe),le.push({event:ie,listeners:we}))}}if((i&7)===0){e:{if(ie=r==="mouseover"||r==="pointerover",fe=r==="mouseout"||r==="pointerout",ie&&c!==Jd&&(ge=c.relatedTarget||c.fromElement)&&(nr(ge)||ge[Xn]))break e;if((fe||ie)&&(ie=oe.window===oe?oe:(ie=oe.ownerDocument)?ie.defaultView||ie.parentWindow:window,fe?(ge=c.relatedTarget||c.toElement,fe=G,ge=ge?nr(ge):null,ge!==null&&(at=tr(ge),ge!==at||ge.tag!==5&&ge.tag!==6)&&(ge=null)):(fe=null,ge=G),fe!==ge)){if(we=dx,ce="onMouseLeave",U="onMouseEnter",O="mouse",(r==="pointerout"||r==="pointerover")&&(we=mx,ce="onPointerLeave",U="onPointerEnter",O="pointer"),at=fe==null?ie:ea(fe),z=ge==null?ie:ea(ge),ie=new we(ce,O+"leave",fe,c,oe),ie.target=at,ie.relatedTarget=z,ce=null,nr(oe)===G&&(we=new we(U,O+"enter",ge,c,oe),we.target=z,we.relatedTarget=at,ce=we),at=ce,fe&&ge)t:{for(we=fe,U=ge,O=0,z=we;z;z=Xr(z))O++;for(z=0,ce=U;ce;ce=Xr(ce))z++;for(;0<O-z;)we=Xr(we),O--;for(;0<z-O;)U=Xr(U),z--;for(;O--;){if(we===U||U!==null&&we===U.alternate)break t;we=Xr(we),U=Xr(U)}we=null}else we=null;fe!==null&&Mx(le,ie,fe,we,!1),ge!==null&&at!==null&&Mx(le,at,ge,we,!0)}}e:{if(ie=G?ea(G):window,fe=ie.nodeName&&ie.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ie.type==="file")var _e=fN;else if(yx(ie))if(vx)_e=yN;else{_e=xN;var Ce=hN}else(fe=ie.nodeName)&&fe.toLowerCase()==="input"&&(ie.type==="checkbox"||ie.type==="radio")&&(_e=gN);if(_e&&(_e=_e(r,G))){bx(le,_e,c,oe);break e}Ce&&Ce(r,ie,G),r==="focusout"&&(Ce=ie._wrapperState)&&Ce.controlled&&ie.type==="number"&&xt(ie,"number",ie.value)}switch(Ce=G?ea(G):window,r){case"focusin":(yx(Ce)||Ce.contentEditable==="true")&&(Qr=Ce,ju=G,fi=null);break;case"focusout":fi=ju=Qr=null;break;case"mousedown":wu=!0;break;case"contextmenu":case"mouseup":case"dragend":wu=!1,Ex(le,c,oe);break;case"selectionchange":if(jN)break;case"keydown":case"keyup":Ex(le,c,oe)}var Ee;if(gu)e:{switch(r){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else Kr?xx(r,c)&&(Le="onCompositionEnd"):r==="keydown"&&c.keyCode===229&&(Le="onCompositionStart");Le&&(px&&c.locale!=="ko"&&(Kr||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&Kr&&(Ee=lx()):(Cs=oe,uu="value"in Cs?Cs.value:Cs.textContent,Kr=!0)),Ce=el(G,Le),0<Ce.length&&(Le=new ux(Le,r,null,c,oe),le.push({event:Le,listeners:Ce}),Ee?Le.data=Ee:(Ee=gx(c),Ee!==null&&(Le.data=Ee)))),(Ee=cN?dN(r,c):uN(r,c))&&(G=el(G,"onBeforeInput"),0<G.length&&(oe=new ux("onBeforeInput","beforeinput",null,c,oe),le.push({event:oe,listeners:G}),oe.data=Ee))}Ox(le,i)})}function gi(r,i,c){return{instance:r,listener:i,currentTarget:c}}function el(r,i){for(var c=i+"Capture",m=[];r!==null;){var y=r,j=y.stateNode;y.tag===5&&j!==null&&(y=j,j=Xa(r,c),j!=null&&m.unshift(gi(r,j,y)),j=Xa(r,i),j!=null&&m.push(gi(r,j,y))),r=r.return}return m}function Xr(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Mx(r,i,c,m,y){for(var j=i._reactName,C=[];c!==null&&c!==m;){var P=c,D=P.alternate,G=P.stateNode;if(D!==null&&D===m)break;P.tag===5&&G!==null&&(P=G,y?(D=Xa(c,j),D!=null&&C.unshift(gi(c,D,P))):y||(D=Xa(c,j),D!=null&&C.push(gi(c,D,P)))),c=c.return}C.length!==0&&r.push({event:i,listeners:C})}var kN=/\r\n?/g,SN=/\u0000|\uFFFD/g;function Bx(r){return(typeof r=="string"?r:""+r).replace(kN,`
38`).replace(SN,"")}function tl(r,i,c){if(i=Bx(i),Bx(r)!==i&&c)throw Error(s(425))}function nl(){}var Eu=null,Au=null;function Tu(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Lu=typeof setTimeout=="function"?setTimeout:void 0,CN=typeof clearTimeout=="function"?clearTimeout:void 0,Ux=typeof Promise=="function"?Promise:void 0,EN=typeof queueMicrotask=="function"?queueMicrotask:typeof Ux<"u"?function(r){return Ux.resolve(null).then(r).catch(AN)}:Lu;function AN(r){setTimeout(function(){throw r})}function Ru(r,i){var c=i,m=0;do{var y=c.nextSibling;if(r.removeChild(c),y&&y.nodeType===8)if(c=y.data,c==="/$"){if(m===0){r.removeChild(y),oi(i);return}m--}else c!=="$"&&c!=="$?"&&c!=="$!"||m++;c=y}while(c);oi(i)}function As(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return r}function zx(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="$"||c==="$!"||c==="$?"){if(i===0)return r;i--}else c==="/$"&&i++}r=r.previousSibling}return null}var Zr=Math.random().toString(36).slice(2),Wn="__reactFiber$"+Zr,yi="__reactProps$"+Zr,Xn="__reactContainer$"+Zr,Iu="__reactEvents$"+Zr,TN="__reactListeners$"+Zr,LN="__reactHandles$"+Zr;function nr(r){var i=r[Wn];if(i)return i;for(var c=r.parentNode;c;){if(i=c[Xn]||c[Wn]){if(c=i.alternate,i.child!==null||c!==null&&c.child!==null)for(r=zx(r);r!==null;){if(c=r[Wn])return c;r=zx(r)}return i}r=c,c=r.parentNode}return null}function bi(r){return r=r[Wn]||r[Xn],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function ea(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(s(33))}function sl(r){return r[yi]||null}var Pu=[],ta=-1;function Ts(r){return{current:r}}function Ye(r){0>ta||(r.current=Pu[ta],Pu[ta]=null,ta--)}function He(r,i){ta++,Pu[ta]=r.current,r.current=i}var Ls={},Et=Ts(Ls),Wt=Ts(!1),sr=Ls;function na(r,i){var c=r.type.contextTypes;if(!c)return Ls;var m=r.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===i)return m.__reactInternalMemoizedMaskedChildContext;var y={},j;for(j in c)y[j]=i[j];return m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=i,r.__reactInternalMemoizedMaskedChildContext=y),y}function Ht(r){return r=r.childContextTypes,r!=null}function rl(){Ye(Wt),Ye(Et)}function Wx(r,i,c){if(Et.current!==Ls)throw Error(s(168));He(Et,i),He(Wt,c)}function Hx(r,i,c){var m=r.stateNode;if(i=i.childContextTypes,typeof m.getChildContext!="function")return c;m=m.getChildContext();for(var y in m)if(!(y in i))throw Error(s(108,ke(r)||"Unknown",y));return $({},c,m)}function al(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Ls,sr=Et.current,He(Et,r),He(Wt,Wt.current),!0}function qx(r,i,c){var m=r.stateNode;if(!m)throw Error(s(169));c?(r=Hx(r,i,sr),m.__reactInternalMemoizedMergedChildContext=r,Ye(Wt),Ye(Et),He(Et,r)):Ye(Wt),He(Wt,c)}var Zn=null,il=!1,Fu=!1;function Vx(r){Zn===null?Zn=[r]:Zn.push(r)}function RN(r){il=!0,Vx(r)}function Rs(){if(!Fu&&Zn!==null){Fu=!0;var r=0,i=ze;try{var c=Zn;for(ze=1;r<c.length;r++){var m=c[r];do m=m(!0);while(m!==null)}Zn=null,il=!1}catch(y){throw Zn!==null&&(Zn=Zn.slice(r+1)),Gh(su,Rs),y}finally{ze=i,Fu=!1}}return null}var sa=[],ra=0,ol=null,ll=0,cn=[],dn=0,rr=null,es=1,ts="";function ar(r,i){sa[ra++]=ll,sa[ra++]=ol,ol=r,ll=i}function Yx(r,i,c){cn[dn++]=es,cn[dn++]=ts,cn[dn++]=rr,rr=r;var m=es;r=ts;var y=32-wn(m)-1;m&=~(1<<y),c+=1;var j=32-wn(i)+y;if(30<j){var C=y-y%5;j=(m&(1<<C)-1).toString(32),m>>=C,y-=C,es=1<<32-wn(i)+y|c<<y|m,ts=j+r}else es=1<<j|c<<y|m,ts=r}function Du(r){r.return!==null&&(ar(r,1),Yx(r,1,0))}function Ou(r){for(;r===ol;)ol=sa[--ra],sa[ra]=null,ll=sa[--ra],sa[ra]=null;for(;r===rr;)rr=cn[--dn],cn[dn]=null,ts=cn[--dn],cn[dn]=null,es=cn[--dn],cn[dn]=null}var Xt=null,Zt=null,Qe=!1,_n=null;function Gx(r,i){var c=fn(5,null,null,0);c.elementType="DELETED",c.stateNode=i,c.return=r,i=r.deletions,i===null?(r.deletions=[c],r.flags|=16):i.push(c)}function Kx(r,i){switch(r.tag){case 5:var c=r.type;return i=i.nodeType!==1||c.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(r.stateNode=i,Xt=r,Zt=As(i.firstChild),!0):!1;
vendor: 4,434 bytes, line 38
38case 6:return i=r.pendingProps===""||i.nodeType!==3?null:i,i!==null?(r.stateNode=i,Xt=r,Zt=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(c=rr!==null?{id:es,overflow:ts}:null,r.memoizedState={dehydrated:i,treeContext:c,retryLane:1073741824},c=fn(18,null,null,0),c.stateNode=i,c.return=r,r.child=c,Xt=r,Zt=null,!0):!1;default:return!1}}function $u(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Mu(r){if(Qe){var i=Zt;if(i){var c=i;if(!Kx(r,i)){if($u(r))throw Error(s(418));i=As(c.nextSibling);var m=Xt;i&&Kx(r,i)?Gx(m,c):(r.flags=r.flags&-4097|2,Qe=!1,Xt=r)}}else{if($u(r))throw Error(s(418));r.flags=r.flags&-4097|2,Qe=!1,Xt=r}}}function Qx(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Xt=r}function cl(r){if(r!==Xt)return!1;if(!Qe)return Qx(r),Qe=!0,!1;var i;if((i=r.tag!==3)&&!(i=r.tag!==5)&&(i=r.type,i=i!=="head"&&i!=="body"&&!Tu(r.type,r.memoizedProps)),i&&(i=Zt)){if($u(r))throw Jx(),Error(s(418));for(;i;)Gx(r,i),i=As(i.nextSibling)}if(Qx(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));e:{for(r=r.nextSibling,i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="/$"){if(i===0){Zt=As(r.nextSibling);break e}i--}else c!=="$"&&c!=="$!"&&c!=="$?"||i++}r=r.nextSibling}Zt=null}}else Zt=Xt?As(r.stateNode.nextSibling):null;return!0}function Jx(){for(var r=Zt;r;)r=As(r.nextSibling)}function aa(){Zt=Xt=null,Qe=!1}function Bu(r){_n===null?_n=[r]:_n.push(r)}var IN=E.ReactCurrentBatchConfig;function vi(r,i,c){if(r=c.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(s(309));var m=c.stateNode}if(!m)throw Error(s(147,r));var y=m,j=""+r;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===j?i.ref:(i=function(C){var P=y.refs;C===null?delete P[j]:P[j]=C},i._stringRef=j,i)}if(typeof r!="string")throw Error(s(284));if(!c._owner)throw Error(s(290,r))}return r}function dl(r,i){throw r=Object.prototype.toString.call(i),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r))}function Xx(r){var i=r._init;return i(r._payload)}function Zx(r){function i(U,O){if(r){var z=U.deletions;z===null?(U.deletions=[O],U.flags|=16):z.push(O)}}function c(U,O){if(!r)return null;for(;O!==null;)i(U,O),O=O.sibling;return null}function m(U,O){for(U=new Map;O!==null;)O.key!==null?U.set(O.key,O):U.set(O.index,O),O=O.sibling;return U}function y(U,O){return U=Bs(U,O),U.index=0,U.sibling=null,U}function j(U,O,z){return U.index=z,r?(z=U.alternate,z!==null?(z=z.index,z<O?(U.flags|=2,O):z):(U.flags|=2,O)):(U.flags|=1048576,O)}function C(U){return r&&U.alternate===null&&(U.flags|=2),U}function P(U,O,z,ce){return O===null||O.tag!==6?(O=Lm(z,U.mode,ce),O.return=U,O):(O=y(O,z),O.return=U,O)}function D(U,O,z,ce){var _e=z.type;return _e===R?oe(U,O,z.props.children,ce,z.key):O!==null&&(O.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===re&&Xx(_e)===O.type)?(ce=y(O,z.props),ce.ref=vi(U,O,z),ce.return=U,ce):(ce=Pl(z.type,z.key,z.props,null,U.mode,ce),ce.ref=vi(U,O,z),ce.return=U,ce)}function G(U,O,z,ce){return O===null||O.tag!==4||O.stateNode.containerInfo!==z.containerInfo||O.stateNode.implementation!==z.implementation?(O=Rm(z,U.mode,ce),O.return=U,O):(O=y(O,z.children||[]),O.return=U,O)}function oe(U,O,z,ce,_e){return O===null||O.tag!==7?(O=pr(z,U.mode,ce,_e),O.return=U,O):(O=y(O,z),O.return=U,O)}function le(U,O,z){if(typeof O=="string"&&O!==""||typeof O=="number")return O=Lm(""+O,U.mode,z),O.return=U,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case A:return z=Pl(O.type,O.key,O.props,null,U.mode,z),z.ref=vi(U,null,O),z.return=U,z;case I:return O=Rm(O,U.mode,z),O.return=U,O;case re:var ce=O._init;return le(U,ce(O._payload),z)}if(Ct(O)||Q(O))return O=pr(O,U.mode,z,null),O.return=U,O;dl(U,O)}return null}function ie(U,O,z,ce){var _e=O!==null?O.key:null;if(typeof z=="string"&&z!==""||typeof z=="number")return _e!==null?null:P(U,O,""+z,ce);if(typeof z=="object"&&z!==null){switch(z.$$typeof){case A:return z.key===_e?D(U,O,z,ce):null;case I:return z.key===_e?G(U,O,z,ce):null;case re:return _e=z._init,ie(U,O,_e(z._payload),ce)}if(Ct(z)||Q(z))return _e!==null?null:oe(U,O,z,ce,null);dl(U,z)}return null}function fe(U,O,z,ce,_e){if(typeof ce=="string"&&ce!==""||typeof ce=="number")return U=U.get(z)||null,P(O,U,""+ce,_e);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case A:return U=U.get(ce.key===null?z:ce.ke
vendor: 10,077 bytes, line 38
38y)||null,D(O,U,ce,_e);case I:return U=U.get(ce.key===null?z:ce.key)||null,G(O,U,ce,_e);case re:var Ce=ce._init;return fe(U,O,z,Ce(ce._payload),_e)}if(Ct(ce)||Q(ce))return U=U.get(z)||null,oe(O,U,ce,_e,null);dl(O,ce)}return null}function ge(U,O,z,ce){for(var _e=null,Ce=null,Ee=O,Le=O=0,bt=null;Ee!==null&&Le<z.length;Le++){Ee.index>Le?(bt=Ee,Ee=null):bt=Ee.sibling;var $e=ie(U,Ee,z[Le],ce);if($e===null){Ee===null&&(Ee=bt);break}r&&Ee&&$e.alternate===null&&i(U,Ee),O=j($e,O,Le),Ce===null?_e=$e:Ce.sibling=$e,Ce=$e,Ee=bt}if(Le===z.length)return c(U,Ee),Qe&&ar(U,Le),_e;if(Ee===null){for(;Le<z.length;Le++)Ee=le(U,z[Le],ce),Ee!==null&&(O=j(Ee,O,Le),Ce===null?_e=Ee:Ce.sibling=Ee,Ce=Ee);return Qe&&ar(U,Le),_e}for(Ee=m(U,Ee);Le<z.length;Le++)bt=fe(Ee,U,Le,z[Le],ce),bt!==null&&(r&&bt.alternate!==null&&Ee.delete(bt.key===null?Le:bt.key),O=j(bt,O,Le),Ce===null?_e=bt:Ce.sibling=bt,Ce=bt);return r&&Ee.forEach(function(Us){return i(U,Us)}),Qe&&ar(U,Le),_e}function we(U,O,z,ce){var _e=Q(z);if(typeof _e!="function")throw Error(s(150));if(z=_e.call(z),z==null)throw Error(s(151));for(var Ce=_e=null,Ee=O,Le=O=0,bt=null,$e=z.next();Ee!==null&&!$e.done;Le++,$e=z.next()){Ee.index>Le?(bt=Ee,Ee=null):bt=Ee.sibling;var Us=ie(U,Ee,$e.value,ce);if(Us===null){Ee===null&&(Ee=bt);break}r&&Ee&&Us.alternate===null&&i(U,Ee),O=j(Us,O,Le),Ce===null?_e=Us:Ce.sibling=Us,Ce=Us,Ee=bt}if($e.done)return c(U,Ee),Qe&&ar(U,Le),_e;if(Ee===null){for(;!$e.done;Le++,$e=z.next())$e=le(U,$e.value,ce),$e!==null&&(O=j($e,O,Le),Ce===null?_e=$e:Ce.sibling=$e,Ce=$e);return Qe&&ar(U,Le),_e}for(Ee=m(U,Ee);!$e.done;Le++,$e=z.next())$e=fe(Ee,U,Le,$e.value,ce),$e!==null&&(r&&$e.alternate!==null&&Ee.delete($e.key===null?Le:$e.key),O=j($e,O,Le),Ce===null?_e=$e:Ce.sibling=$e,Ce=$e);return r&&Ee.forEach(function(m5){return i(U,m5)}),Qe&&ar(U,Le),_e}function at(U,O,z,ce){if(typeof z=="object"&&z!==null&&z.type===R&&z.key===null&&(z=z.props.children),typeof z=="object"&&z!==null){switch(z.$$typeof){case A:e:{for(var _e=z.key,Ce=O;Ce!==null;){if(Ce.key===_e){if(_e=z.type,_e===R){if(Ce.tag===7){c(U,Ce.sibling),O=y(Ce,z.props.children),O.return=U,U=O;break e}}else if(Ce.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===re&&Xx(_e)===Ce.type){c(U,Ce.sibling),O=y(Ce,z.props),O.ref=vi(U,Ce,z),O.return=U,U=O;break e}c(U,Ce);break}else i(U,Ce);Ce=Ce.sibling}z.type===R?(O=pr(z.props.children,U.mode,ce,z.key),O.return=U,U=O):(ce=Pl(z.type,z.key,z.props,null,U.mode,ce),ce.ref=vi(U,O,z),ce.return=U,U=ce)}return C(U);case I:e:{for(Ce=z.key;O!==null;){if(O.key===Ce)if(O.tag===4&&O.stateNode.containerInfo===z.containerInfo&&O.stateNode.implementation===z.implementation){c(U,O.sibling),O=y(O,z.children||[]),O.return=U,U=O;break e}else{c(U,O);break}else i(U,O);O=O.sibling}O=Rm(z,U.mode,ce),O.return=U,U=O}return C(U);case re:return Ce=z._init,at(U,O,Ce(z._payload),ce)}if(Ct(z))return ge(U,O,z,ce);if(Q(z))return we(U,O,z,ce);dl(U,z)}return typeof z=="string"&&z!==""||typeof z=="number"?(z=""+z,O!==null&&O.tag===6?(c(U,O.sibling),O=y(O,z),O.return=U,U=O):(c(U,O),O=Lm(z,U.mode,ce),O.return=U,U=O),C(U)):c(U,O)}return at}var ia=Zx(!0),eg=Zx(!1),ul=Ts(null),ml=null,oa=null,Uu=null;function zu(){Uu=oa=ml=null}function Wu(r){var i=ul.current;Ye(ul),r._currentValue=i}function Hu(r,i,c){for(;r!==null;){var m=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,m!==null&&(m.childLanes|=i)):m!==null&&(m.childLanes&i)!==i&&(m.childLanes|=i),r===c)break;r=r.return}}function la(r,i){ml=r,Uu=oa=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&i)!==0&&(qt=!0),r.firstContext=null)}function un(r){var i=r._currentValue;if(Uu!==r)if(r={context:r,memoizedValue:i,next:null},oa===null){if(ml===null)throw Error(s(308));oa=r,ml.dependencies={lanes:0,firstContext:r}}else oa=oa.next=r;return i}var ir=null;function qu(r){ir===null?ir=[r]:ir.push(r)}function tg(r,i,c,m){var y=i.interleaved;return y===null?(c.next=c,qu(i)):(c.next=y.next,y.next=c),i.interleaved=c,ns(r,m)}function ns(r,i){r.lanes|=i;var c=r.alternate;for(c!==null&&(c.lanes|=i),c=r,r=r.return;r!==null;)r.childLanes|=i,c=r.alternate,c!==null&&(c.childLanes|=i),c=r,r=r.return;return c.tag===3?c.stateNode:null}var Is=!1;function Vu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ng(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function ss(r,i){return{eventTime:r,lane:i,tag:0,payload:null,callback:null,next:null}}function Ps(r,i,c){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(De&2)!==0){var y=m.pending;return y===null?i.next=i:(i.next=y.next,y.next=i),m.pending=i,ns(r,c)}return y=m.interleaved,y===null?(i.next=i,qu(m)):(i.next=y.next,y.next=i),m.interleaved=i,ns(r,c)}function pl(r,i,c){if(i=i.updateQueue,i!==null&&(i=i.shared,(c&4194240)!==0)){var m=i.lanes;m&=r.pendingLanes,c|=m,i.lanes=c,iu(r,c)}}function sg(r,i){var c=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,c===m)){var y=null,j=null;if(c=c.firstBaseUpdate,c!==null){do{var C={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};j===null?y=j=C:j=j.next=C,c=c.next}while(c!==null);j===null?y=j=i:j=j.next=i}else y=j=i;c={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:j,shared:m.shared,effects:m.effects},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=i:r.next=i,c.lastBaseUpdate=i}function fl(r,i,c,m){var y=r.updateQueue;Is=!1;var j=y.firstBaseUpdate,C=y.lastBaseUpdate,P=y.shared.pending;if(P!==null){y.shared.pending=null;var D=P,G=D.next;D.next=null,C===null?j=G:C.next=G,C=D;var oe=r.alternate;oe!==null&&(oe=oe.updateQueue,P=oe.lastBaseUpdate,P!==C&&(P===null?oe.firstBaseUpdate=G:P.next=G,oe.lastBaseUpdate=D))}if(j!==null){var le=y.baseState;C=0,oe=G=D=null,P=j;do{var ie=P.lane,fe=P.eventTime;if((m&ie)===ie){oe!==null&&(oe=oe.next={eventTime:fe,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ge=r,we=P;switch(ie=i,fe=c,we.tag){case 1:if(ge=we.payload,typeof ge=="function"){le=ge.call(fe,le,ie);break e}le=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=we.payload,ie=typeof ge=="function"?ge.call(fe,le,ie):ge,ie==null)break e;le=$({},le,ie);break e;case 2:Is=!0}}P.callback!==null&&P.lane!==0&&(r.flags|=64,ie=y.effects,ie===null?y.effects=[P]:ie.push(P))}else fe={eventTime:fe,lane:ie,tag:P.tag,payload:P.payload,callback:P.callback,next:null},oe===null?(G=oe=fe,D=le):oe=oe.next=fe,C|=ie;if(P=P.next,P===null){if(P=y.shared.pending,P===null)break;ie=P,P=ie.next,ie.next=null,y.lastBaseUpdate=ie,y.shared.pending=null}}while(!0);if(oe===null&&(D=le),y.baseState=D,y.firstBaseUpdate=G,y.lastBaseUpdate=oe,i=y.shared.interleaved,i!==null){y=i;do C|=y.lane,y=y.next;while(y!==i)}else j===null&&(y.shared.lanes=0);cr|=C,r.lanes=C,r.memoizedState=le}}function rg(r,i,c){if(r=i.effects,i.effects=null,r!==null)for(i=0;i<r.length;i++){var m=r[i],y=m.callback;if(y!==null){if(m.callback=null,m=c,typeof y!="function")throw Error(s(191,y));y.call(m)}}}var ji={},Hn=Ts(ji),wi=Ts(ji),Ni=Ts(ji);function or(r){if(r===ji)throw Error(s(174));return r}function Yu(r,i){switch(He(Ni,i),He(wi,r),He(Hn,ji),r=i.nodeType,r){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Gd(null,"");break;default:r=r===8?i.parentNode:i,i=r.namespaceURI||null,r=r.tagName,i=Gd(i,r)}Ye(Hn),He(Hn,i)}function ca(){Ye(Hn),Ye(wi),Ye(Ni)}function ag(r){or(Ni.current);var i=or(Hn.current),c=Gd(i,r.type);i!==c&&(He(wi,r),He(Hn,c))}function Gu(r){wi.current===r&&(Ye(Hn),Ye(wi))}var et=Ts(0);function hl(r){for(var i=r;i!==null;){if(i.tag===13){var c=i.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Ku=[];function Qu(){for(var r=0;r<Ku.length;r++)Ku[r]._workInProgressVersionPrimary=null;Ku.length=0}var xl=E.ReactCurrentDispatcher,Ju=E.ReactCurrentBatchConfig,lr=0,tt=null,pt=null,gt=null,gl=!1,_i=!1,ki=0,PN=0;function At(){throw Error(s(321))}function Xu(r,i){if(i===null)return!1;for(var c=0;c<i.length&&c<r.length;c++)if(!Nn(r[c],i[c]))return!1;return!0}function Zu(r,i,c,m,y,j){if(lr=j,tt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,xl.current=r===null||r.memoizedState===null?$N:MN,r=c(m,y),_i){j=0;do{if(_i=!1,ki=0,25<=j)throw Error(s(301));j+=1,gt=pt=null,i.updateQueue=null,xl.current=BN,r=c(m,y)}while(_i)}if(xl.current=vl,i=pt!==null&&pt.next!==null,lr=0,gt=pt=tt=null,gl=!1,i)throw Error(s(300));return r}function em(){var r=ki!==0;return ki=0,r}function qn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gt===null?tt.memoizedState=gt=r:gt=gt.next=r,gt}function mn(){if(pt===null){var r=tt.alternate;r=r!==null?r.memoizedState:null}else r=pt.next;var i=gt===null?tt.memoizedState:gt.next;if(i!==null)gt=i,pt=r;else{if(r===null)throw Error(s(310));pt=r,r={memoizedState:pt.memoizedState,baseState:pt.baseState,baseQueue:pt.baseQueue,queue:pt.queue,next:null},gt===null?tt.memoizedState=gt=r:gt=gt.next=r}return gt}function Si(r,i){return typeof i=="function"?i(r):i}function tm(r){var i=mn(),c=i.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=r;var m=pt,y=m.baseQueue,j=c.pending;if(j!==null){if(y!==null){var C=y.next;y.next=j.next,j.next=C}m.baseQueue=y=j,c.pending=null}if(y!==null){j=y.next,m=m.baseState;var P=C=null,D=null,G=j;do{var oe=G.lane;if((lr&oe)===oe)D!==null&&(D=D.next={lane:0,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),m=G.hasEagerState?G.eagerState:r(m,G.action);else{var le={lane:oe,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null};D===null?(P=D=le,C=m):D=D.next=le,tt.lanes|=oe,cr|=oe}G=G.next}
vendor: 5,173 bytes, line 38
38while(G!==null&&G!==j);D===null?C=m:D.next=P,Nn(m,i.memoizedState)||(qt=!0),i.memoizedState=m,i.baseState=C,i.baseQueue=D,c.lastRenderedState=m}if(r=c.interleaved,r!==null){y=r;do j=y.lane,tt.lanes|=j,cr|=j,y=y.next;while(y!==r)}else y===null&&(c.lanes=0);return[i.memoizedState,c.dispatch]}function nm(r){var i=mn(),c=i.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=r;var m=c.dispatch,y=c.pending,j=i.memoizedState;if(y!==null){c.pending=null;var C=y=y.next;do j=r(j,C.action),C=C.next;while(C!==y);Nn(j,i.memoizedState)||(qt=!0),i.memoizedState=j,i.baseQueue===null&&(i.baseState=j),c.lastRenderedState=j}return[j,m]}function ig(){}function og(r,i){var c=tt,m=mn(),y=i(),j=!Nn(m.memoizedState,y);if(j&&(m.memoizedState=y,qt=!0),m=m.queue,sm(dg.bind(null,c,m,r),[r]),m.getSnapshot!==i||j||gt!==null&&gt.memoizedState.tag&1){if(c.flags|=2048,Ci(9,cg.bind(null,c,m,y,i),void 0,null),yt===null)throw Error(s(349));(lr&30)!==0||lg(c,i,y)}return y}function lg(r,i,c){r.flags|=16384,r={getSnapshot:i,value:c},i=tt.updateQueue,i===null?(i={lastEffect:null,stores:null},tt.updateQueue=i,i.stores=[r]):(c=i.stores,c===null?i.stores=[r]:c.push(r))}function cg(r,i,c,m){i.value=c,i.getSnapshot=m,ug(i)&&mg(r)}function dg(r,i,c){return c(function(){ug(i)&&mg(r)})}function ug(r){var i=r.getSnapshot;r=r.value;try{var c=i();return!Nn(r,c)}catch{return!0}}function mg(r){var i=ns(r,1);i!==null&&En(i,r,1,-1)}function pg(r){var i=qn();return typeof r=="function"&&(r=r()),i.memoizedState=i.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Si,lastRenderedState:r},i.queue=r,r=r.dispatch=ON.bind(null,tt,r),[i.memoizedState,r]}function Ci(r,i,c,m){return r={tag:r,create:i,destroy:c,deps:m,next:null},i=tt.updateQueue,i===null?(i={lastEffect:null,stores:null},tt.updateQueue=i,i.lastEffect=r.next=r):(c=i.lastEffect,c===null?i.lastEffect=r.next=r:(m=c.next,c.next=r,r.next=m,i.lastEffect=r)),r}function fg(){return mn().memoizedState}function yl(r,i,c,m){var y=qn();tt.flags|=r,y.memoizedState=Ci(1|i,c,void 0,m===void 0?null:m)}function bl(r,i,c,m){var y=mn();m=m===void 0?null:m;var j=void 0;if(pt!==null){var C=pt.memoizedState;if(j=C.destroy,m!==null&&Xu(m,C.deps)){y.memoizedState=Ci(i,c,j,m);return}}tt.flags|=r,y.memoizedState=Ci(1|i,c,j,m)}function hg(r,i){return yl(8390656,8,r,i)}function sm(r,i){return bl(2048,8,r,i)}function xg(r,i){return bl(4,2,r,i)}function gg(r,i){return bl(4,4,r,i)}function yg(r,i){if(typeof i=="function")return r=r(),i(r),function(){i(null)};if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function bg(r,i,c){return c=c!=null?c.concat([r]):null,bl(4,4,yg.bind(null,i,r),c)}function rm(){}function vg(r,i){var c=mn();i=i===void 0?null:i;var m=c.memoizedState;return m!==null&&i!==null&&Xu(i,m[1])?m[0]:(c.memoizedState=[r,i],r)}function jg(r,i){var c=mn();i=i===void 0?null:i;var m=c.memoizedState;return m!==null&&i!==null&&Xu(i,m[1])?m[0]:(r=r(),c.memoizedState=[r,i],r)}function wg(r,i,c){return(lr&21)===0?(r.baseState&&(r.baseState=!1,qt=!0),r.memoizedState=c):(Nn(c,i)||(c=Xh(),tt.lanes|=c,cr|=c,r.baseState=!0),i)}function FN(r,i){var c=ze;ze=c!==0&&4>c?c:4,r(!0);var m=Ju.transition;Ju.transition={};try{r(!1),i()}finally{ze=c,Ju.transition=m}}function Ng(){return mn().memoizedState}function DN(r,i,c){var m=$s(r);if(c={lane:m,action:c,hasEagerState:!1,eagerState:null,next:null},_g(r))kg(i,c);else if(c=tg(r,i,c,m),c!==null){var y=Dt();En(c,r,m,y),Sg(c,i,m)}}function ON(r,i,c){var m=$s(r),y={lane:m,action:c,hasEagerState:!1,eagerState:null,next:null};if(_g(r))kg(i,y);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=i.lastRenderedReducer,j!==null))try{var C=i.lastRenderedState,P=j(C,c);if(y.hasEagerState=!0,y.eagerState=P,Nn(P,C)){var D=i.interleaved;D===null?(y.next=y,qu(i)):(y.next=D.next,D.next=y),i.interleaved=y;return}}catch{}finally{}c=tg(r,i,y,m),c!==null&&(y=Dt(),En(c,r,m,y),Sg(c,i,m))}}function _g(r){var i=r.alternate;return r===tt||i!==null&&i===tt}function kg(r,i){_i=gl=!0;var c=r.pending;c===null?i.next=i:(i.next=c.next,c.next=i),r.pending=i}function Sg(r,i,c){if((c&4194240)!==0){var m=i.lanes;m&=r.pendingLanes,c|=m,i.lanes=c,iu(r,c)}}var vl={readContext:un,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useInsertionEffect:At,useLayoutEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useMutableSource:At,useSyncExternalStore:At,useId:At,unstable_isNewReconciler:!1},$N={readContext:un,useCallback:function(r,i){return qn().memoizedState=[r,i===void 0?null:i],r},useContext:un,useEffect:hg,useImperativeHandle:function(r,i,c){return c=c!=null?c.concat([r]):null,yl(4194308,4,yg.bind(null,i,r),c)},useLayoutEffect:function(r,i){return yl(4194308,4,r,i)},useInsertionEffect:function(r,i){return yl(4,2,r,i)},useMemo:function(r,i){var c=qn();return i=i===void 0?null:i,r=r(),c.memoizedState=[r,i],r},useReducer:function(r,i,c){var m=qn();return i=c!==void 0?c(i):i,m.memoizedState=m.baseState=i,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:i},m.queue=r,r=r.dispatch=DN.bind(null,tt,r),[m.memoizedState,r]}
vendor: 7,454 bytes, lines 38-40
38,useRef:function(r){var i=qn();return r={current:r},i.memoizedState=r},useState:pg,useDebugValue:rm,useDeferredValue:function(r){return qn().memoizedState=r},useTransition:function(){var r=pg(!1),i=r[0];return r=FN.bind(null,r[1]),qn().memoizedState=r,[i,r]},useMutableSource:function(){},useSyncExternalStore:function(r,i,c){var m=tt,y=qn();if(Qe){if(c===void 0)throw Error(s(407));c=c()}else{if(c=i(),yt===null)throw Error(s(349));(lr&30)!==0||lg(m,i,c)}y.memoizedState=c;var j={value:c,getSnapshot:i};return y.queue=j,hg(dg.bind(null,m,j,r),[r]),m.flags|=2048,Ci(9,cg.bind(null,m,j,c,i),void 0,null),c},useId:function(){var r=qn(),i=yt.identifierPrefix;if(Qe){var c=ts,m=es;c=(m&~(1<<32-wn(m)-1)).toString(32)+c,i=":"+i+"R"+c,c=ki++,0<c&&(i+="H"+c.toString(32)),i+=":"}else c=PN++,i=":"+i+"r"+c.toString(32)+":";return r.memoizedState=i},unstable_isNewReconciler:!1},MN={readContext:un,useCallback:vg,useContext:un,useEffect:sm,useImperativeHandle:bg,useInsertionEffect:xg,useLayoutEffect:gg,useMemo:jg,useReducer:tm,useRef:fg,useState:function(){return tm(Si)},useDebugValue:rm,useDeferredValue:function(r){var i=mn();return wg(i,pt.memoizedState,r)},useTransition:function(){var r=tm(Si)[0],i=mn().memoizedState;return[r,i]},useMutableSource:ig,useSyncExternalStore:og,useId:Ng,unstable_isNewReconciler:!1},BN={readContext:un,useCallback:vg,useContext:un,useEffect:sm,useImperativeHandle:bg,useInsertionEffect:xg,useLayoutEffect:gg,useMemo:jg,useReducer:nm,useRef:fg,useState:function(){return nm(Si)},useDebugValue:rm,useDeferredValue:function(r){var i=mn();return pt===null?i.memoizedState=r:wg(i,pt.memoizedState,r)},useTransition:function(){var r=nm(Si)[0],i=mn().memoizedState;return[r,i]},useMutableSource:ig,useSyncExternalStore:og,useId:Ng,unstable_isNewReconciler:!1};function kn(r,i){if(r&&r.defaultProps){i=$({},i),r=r.defaultProps;for(var c in r)i[c]===void 0&&(i[c]=r[c]);return i}return i}function am(r,i,c,m){i=r.memoizedState,c=c(m,i),c=c==null?i:$({},i,c),r.memoizedState=c,r.lanes===0&&(r.updateQueue.baseState=c)}var jl={isMounted:function(r){return(r=r._reactInternals)?tr(r)===r:!1},enqueueSetState:function(r,i,c){r=r._reactInternals;var m=Dt(),y=$s(r),j=ss(m,y);j.payload=i,c!=null&&(j.callback=c),i=Ps(r,j,y),i!==null&&(En(i,r,y,m),pl(i,r,y))},enqueueReplaceState:function(r,i,c){r=r._reactInternals;var m=Dt(),y=$s(r),j=ss(m,y);j.tag=1,j.payload=i,c!=null&&(j.callback=c),i=Ps(r,j,y),i!==null&&(En(i,r,y,m),pl(i,r,y))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var c=Dt(),m=$s(r),y=ss(c,m);y.tag=2,i!=null&&(y.callback=i),i=Ps(r,y,m),i!==null&&(En(i,r,m,c),pl(i,r,m))}};function Cg(r,i,c,m,y,j,C){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,j,C):i.prototype&&i.prototype.isPureReactComponent?!pi(c,m)||!pi(y,j):!0}function Eg(r,i,c){var m=!1,y=Ls,j=i.contextType;return typeof j=="object"&&j!==null?j=un(j):(y=Ht(i)?sr:Et.current,m=i.contextTypes,j=(m=m!=null)?na(r,y):Ls),i=new i(c,j),r.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=jl,r.stateNode=i,i._reactInternals=r,m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=y,r.__reactInternalMemoizedMaskedChildContext=j),i}function Ag(r,i,c,m){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(c,m),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(c,m),i.state!==r&&jl.enqueueReplaceState(i,i.state,null)}function im(r,i,c,m){var y=r.stateNode;y.props=c,y.state=r.memoizedState,y.refs={},Vu(r);var j=i.contextType;typeof j=="object"&&j!==null?y.context=un(j):(j=Ht(i)?sr:Et.current,y.context=na(r,j)),y.state=r.memoizedState,j=i.getDerivedStateFromProps,typeof j=="function"&&(am(r,i,j,c),y.state=r.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(i=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),i!==y.state&&jl.enqueueReplaceState(y,y.state,null),fl(r,c,y,m),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308)}function da(r,i){try{var c="",m=i;do c+=ee(m),m=m.return;while(m);var y=c}catch(j){y=`
39Error generating stack: `+j.message+`
40`+j.stack}return{value:r,source:i,stack:y,digest:null}}function om(r,i,c){return{value:r,source:null,stack:c??null,digest:i??null}}function lm(r,i){try{console.error(i.value)}catch(c){setTimeout(function(){throw c})}}var UN=typeof WeakMap=="function"?WeakMap:Map;function Tg(r,i,c){c=ss(-1,c),c.tag=3,c.payload={element:null};var m=i.value;return c.callback=function(){El||(El=!0,Nm=m),lm(r,i)},c}function Lg(r,i,c){c=ss(-1,c),c.tag=3;var m=r.type.getDerivedStateFromError;if(typeof m=="function"){var y=i.value;c.payload=function(){return m(y)},c.callback=function(){lm(r,i)}}var j=r.stateNode;return j!==null&&typeof j.componentDidCatch=="function"&&(c.callback=function(){lm(r,i),typeof m!="function"&&(Ds===null?Ds=new Set([this]):Ds.add(this));var C=i.stack;this.componentDidCatch(i.value,{componentStack:C!==null?C:""})}),c}function Rg(r,i,c){var m=r.pingCache;if(m===null){m=r.pingCache=new UN;var y=new Set;m.set(i,y)}else y=m.get(i),y===void 0&&(y=new Set,m.set(i,y));y.has(c)||(y.add(c),r=t5.bind(null,r,i,c),i.then(r,r))}function Ig(r){do{var i;if((i=r.tag===13)&&(i=r.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return r;r=r.return}while(r!==null);return null}function Pg(r,i,c,m,y){return(r.mode&1)===0?(r===i?r.flags|=65536:(r.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(i=ss(-1,1),i.tag=2,Ps(c,i,1))),c.lanes|=1),r):(r.flags|=65536,r.lanes=y,r)}var zN=E.ReactCurrentOwner,qt=!1;function Ft(r,i,c,m){i.child=r===null?eg(i,null,c,m):ia(i,r.child,c,m)}function Fg(r,i,c,m,y){c=c.render;var j=i.ref;return la(i,y),m=Zu(r,i,c,m,j,y),c=em(),r!==null&&!qt?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~y,rs(r,i,y)):(Qe&&c&&Du(i),i.flags|=1,Ft(r,i,m,y),i.child)}function Dg(r,i,c,m,y){if(r===null){var j=c.type;return typeof j=="function"&&!Tm(j)&&j.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(i.tag=15,i.type=j,Og(r,i,j,m,y)):(r=Pl(c.type,null,m,i,i.mode,y),r.ref=i.ref,r.return=i,i.child=r)}if(j=r.child,(r.lanes&y)===0){var C=j.memoizedProps;if(c=c.compare,c=c!==null?c:pi,c(C,m)&&r.ref===i.ref)return rs(r,i,y)}return i.flags|=1,r=Bs(j,m),r.ref=i.ref,r.return=i,i.child=r}function Og(r,i,c,m,y){if(r!==null){var j=r.memoizedProps;if(pi(j,m)&&r.ref===i.ref)if(qt=!1,i.pendingProps=m=j,(r.lanes&y)!==0)(r.flags&131072)!==0&&(qt=!0);else return i.lanes=r.lanes,rs(r,i,y)}return cm(r,i,c,m,y)}function $g(r,i,c){var m=i.pendingProps,y=m.children,j=r!==null?r.memoizedState:null;if(m.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},He(ma,en),en|=c;else{if((c&1073741824)===0)return r=j!==null?j.baseLanes|c:c,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:r,cachePool:null,transitions:null},i.updateQueue=null,He(ma,en),en|=r,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=j!==null?j.baseLanes:c,He(ma,en),en|=m}else j!==null?(m=j.baseLanes|c,i.memoizedState=null):m=c,He(ma,en),en|=m;return Ft(r,i,y,c),i.child}function Mg(r,i){var c=i.ref;(r===null&&c!==null||r!==null&&r.ref!==c)&&(i.flags|=512,i.flags|=2097152)}
vendor: 14,746 bytes, line 40
40function cm(r,i,c,m,y){var j=Ht(c)?sr:Et.current;return j=na(i,j),la(i,y),c=Zu(r,i,c,m,j,y),m=em(),r!==null&&!qt?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~y,rs(r,i,y)):(Qe&&m&&Du(i),i.flags|=1,Ft(r,i,c,y),i.child)}function Bg(r,i,c,m,y){if(Ht(c)){var j=!0;al(i)}else j=!1;if(la(i,y),i.stateNode===null)Nl(r,i),Eg(i,c,m),im(i,c,m,y),m=!0;else if(r===null){var C=i.stateNode,P=i.memoizedProps;C.props=P;var D=C.context,G=c.contextType;typeof G=="object"&&G!==null?G=un(G):(G=Ht(c)?sr:Et.current,G=na(i,G));var oe=c.getDerivedStateFromProps,le=typeof oe=="function"||typeof C.getSnapshotBeforeUpdate=="function";le||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(P!==m||D!==G)&&Ag(i,C,m,G),Is=!1;var ie=i.memoizedState;C.state=ie,fl(i,m,C,y),D=i.memoizedState,P!==m||ie!==D||Wt.current||Is?(typeof oe=="function"&&(am(i,c,oe,m),D=i.memoizedState),(P=Is||Cg(i,c,P,m,ie,D,G))?(le||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(i.flags|=4194308)):(typeof C.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=m,i.memoizedState=D),C.props=m,C.state=D,C.context=G,m=P):(typeof C.componentDidMount=="function"&&(i.flags|=4194308),m=!1)}else{C=i.stateNode,ng(r,i),P=i.memoizedProps,G=i.type===i.elementType?P:kn(i.type,P),C.props=G,le=i.pendingProps,ie=C.context,D=c.contextType,typeof D=="object"&&D!==null?D=un(D):(D=Ht(c)?sr:Et.current,D=na(i,D));var fe=c.getDerivedStateFromProps;(oe=typeof fe=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(P!==le||ie!==D)&&Ag(i,C,m,D),Is=!1,ie=i.memoizedState,C.state=ie,fl(i,m,C,y);var ge=i.memoizedState;P!==le||ie!==ge||Wt.current||Is?(typeof fe=="function"&&(am(i,c,fe,m),ge=i.memoizedState),(G=Is||Cg(i,c,G,m,ie,ge,D)||!1)?(oe||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(m,ge,D),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(m,ge,D)),typeof C.componentDidUpdate=="function"&&(i.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof C.componentDidUpdate!="function"||P===r.memoizedProps&&ie===r.memoizedState||(i.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||P===r.memoizedProps&&ie===r.memoizedState||(i.flags|=1024),i.memoizedProps=m,i.memoizedState=ge),C.props=m,C.state=ge,C.context=D,m=G):(typeof C.componentDidUpdate!="function"||P===r.memoizedProps&&ie===r.memoizedState||(i.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||P===r.memoizedProps&&ie===r.memoizedState||(i.flags|=1024),m=!1)}return dm(r,i,c,m,j,y)}function dm(r,i,c,m,y,j){Mg(r,i);var C=(i.flags&128)!==0;if(!m&&!C)return y&&qx(i,c,!1),rs(r,i,j);m=i.stateNode,zN.current=i;var P=C&&typeof c.getDerivedStateFromError!="function"?null:m.render();return i.flags|=1,r!==null&&C?(i.child=ia(i,r.child,null,j),i.child=ia(i,null,P,j)):Ft(r,i,P,j),i.memoizedState=m.state,y&&qx(i,c,!0),i.child}function Ug(r){var i=r.stateNode;i.pendingContext?Wx(r,i.pendingContext,i.pendingContext!==i.context):i.context&&Wx(r,i.context,!1),Yu(r,i.containerInfo)}function zg(r,i,c,m,y){return aa(),Bu(y),i.flags|=256,Ft(r,i,c,m),i.child}var um={dehydrated:null,treeContext:null,retryLane:0};function mm(r){return{baseLanes:r,cachePool:null,transitions:null}}function Wg(r,i,c){var m=i.pendingProps,y=et.current,j=!1,C=(i.flags&128)!==0,P;if((P=C)||(P=r!==null&&r.memoizedState===null?!1:(y&2)!==0),P?(j=!0,i.flags&=-129):(r===null||r.memoizedState!==null)&&(y|=1),He(et,y&1),r===null)return Mu(i),r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((i.mode&1)===0?i.lanes=1:r.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(C=m.children,r=m.fallback,j?(m=i.mode,j=i.child,C={mode:"hidden",children:C},(m&1)===0&&j!==null?(j.childLanes=0,j.pendingProps=C):j=Fl(C,m,0,null),r=pr(r,m,c,null),j.return=i,r.return=i,j.sibling=r,i.child=j,i.child.memoizedState=mm(c),i.memoizedState=um,r):pm(i,C));if(y=r.memoizedState,y!==null&&(P=y.dehydrated,P!==null))return WN(r,i,C,m,P,y,c);if(j){j=m.fallback,C=i.mode,y=r.child,P=y.sibling;var D={mode:"hidden",children:m.children};return(C&1)===0&&i.child!==y?(m=i.child,m.childLanes=0,m.pendingProps=D,i.deletions=null):(m=Bs(y,D),m.subtreeFlags=y.subtreeFlags&14680064),P!==null?j=Bs(P,j):(j=pr(j,C,c,null),j.flags|=2),j.return=i,m.return=i,m.sibling=j,i.child=m,m=j,j=i.child,C=r.child.memoizedState,C=C===null?mm(c):{baseLanes:C.baseLanes|c,cachePool:null,transitions:C.transitions},j.memoizedState=C,j.childLanes=r.childLanes&~c,i.memoizedState=um,m}return j=r.child,r=j.sibling,m=Bs(j,{mode:"visible",children:m.children}),(i.mode&1)===0&&(m.lanes=c),m.return=i,m.sibling=null,r!==null&&(c=i.deletions,c===null?(i.deletions=[r],i.flags|=16):c.push(r)),i.child=m,i.memoizedState=null,m}function pm(r,i){return i=Fl({mode:"visible",children:i},r.mode,0,null),i.return=r,r.child=i}function wl(r,i,c,m){return m!==null&&Bu(m),ia(i,r.child,null,c),r=pm(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function WN(r,i,c,m,y,j,C){if(c)return i.flags&256?(i.flags&=-257,m=om(Error(s(422))),wl(r,i,C,m)):i.memoizedState!==null?(i.child=r.child,i.flags|=128,null):(j=m.fallback,y=i.mode,m=Fl({mode:"visible",children:m.children},y,0,null),j=pr(j,y,C,null),j.flags|=2,m.return=i,j.return=i,m.sibling=j,i.child=m,(i.mode&1)!==0&&ia(i,r.child,null,C),i.child.memoizedState=mm(C),i.memoizedState=um,j);if((i.mode&1)===0)return wl(r,i,C,null);if(y.data==="$!"){if(m=y.nextSibling&&y.nextSibling.dataset,m)var P=m.dgst;return m=P,j=Error(s(419)),m=om(j,m,void 0),wl(r,i,C,m)}if(P=(C&r.childLanes)!==0,qt||P){if(m=yt,m!==null){switch(C&-C){case 4:y=2;break;case 16:y=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:y=32;break;case 536870912:y=268435456;break;default:y=0}y=(y&(m.suspendedLanes|C))!==0?0:y,y!==0&&y!==j.retryLane&&(j.retryLane=y,ns(r,y),En(m,r,y,-1))}return Am(),m=om(Error(s(421))),wl(r,i,C,m)}return y.data==="$?"?(i.flags|=128,i.child=r.child,i=n5.bind(null,r),y._reactRetry=i,null):(r=j.treeContext,Zt=As(y.nextSibling),Xt=i,Qe=!0,_n=null,r!==null&&(cn[dn++]=es,cn[dn++]=ts,cn[dn++]=rr,es=r.id,ts=r.overflow,rr=i),i=pm(i,m.children),i.flags|=4096,i)}function Hg(r,i,c){r.lanes|=i;var m=r.alternate;m!==null&&(m.lanes|=i),Hu(r.return,i,c)}function fm(r,i,c,m,y){var j=r.memoizedState;j===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:m,tail:c,tailMode:y}:(j.isBackwards=i,j.rendering=null,j.renderingStartTime=0,j.last=m,j.tail=c,j.tailMode=y)}function qg(r,i,c){var m=i.pendingProps,y=m.revealOrder,j=m.tail;if(Ft(r,i,m.children,c),m=et.current,(m&2)!==0)m=m&1|2,i.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Hg(r,c,i);else if(r.tag===19)Hg(r,c,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}m&=1}if(He(et,m),(i.mode&1)===0)i.memoizedState=null;else switch(y){case"forwards":for(c=i.child,y=null;c!==null;)r=c.alternate,r!==null&&hl(r)===null&&(y=c),c=c.sibling;c=y,c===null?(y=i.child,i.child=null):(y=c.sibling,c.sibling=null),fm(i,!1,y,c,j);break;case"backwards":for(c=null,y=i.child,i.child=null;y!==null;){if(r=y.alternate,r!==null&&hl(r)===null){i.child=y;break}r=y.sibling,y.sibling=c,c=y,y=r}fm(i,!0,c,null,j);break;case"together":fm(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function Nl(r,i){(i.mode&1)===0&&r!==null&&(r.alternate=null,i.alternate=null,i.flags|=2)}function rs(r,i,c){if(r!==null&&(i.dependencies=r.dependencies),cr|=i.lanes,(c&i.childLanes)===0)return null;if(r!==null&&i.child!==r.child)throw Error(s(153));if(i.child!==null){for(r=i.child,c=Bs(r,r.pendingProps),i.child=c,c.return=i;r.sibling!==null;)r=r.sibling,c=c.sibling=Bs(r,r.pendingProps),c.return=i;c.sibling=null}return i.child}function HN(r,i,c){switch(i.tag){case 3:Ug(i),aa();break;case 5:ag(i);break;case 1:Ht(i.type)&&al(i);break;case 4:Yu(i,i.stateNode.containerInfo);break;case 10:var m=i.type._context,y=i.memoizedProps.value;He(ul,m._currentValue),m._currentValue=y;break;case 13:if(m=i.memoizedState,m!==null)return m.dehydrated!==null?(He(et,et.current&1),i.flags|=128,null):(c&i.child.childLanes)!==0?Wg(r,i,c):(He(et,et.current&1),r=rs(r,i,c),r!==null?r.sibling:null);He(et,et.current&1);break;case 19:if(m=(c&i.childLanes)!==0,(r.flags&128)!==0){if(m)return qg(r,i,c);i.flags|=128}if(y=i.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),He(et,et.current),m)break;return null;case 22:case 23:return i.lanes=0,$g(r,i,c)}return rs(r,i,c)}var Vg,hm,Yg,Gg;Vg=function(r,i){for(var c=i.child;c!==null;){if(c.tag===5||c.tag===6)r.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},hm=function(){},Yg=function(r,i,c,m){var y=r.memoizedProps;if(y!==m){r=i.stateNode,or(Hn.current);var j=null;switch(c){case"input":y=ae(r,y),m=ae(r,m),j=[];break;case"select":y=$({},y,{value:void 0}),m=$({},m,{value:void 0}),j=[];break;case"textarea":y=de(r,y),m=de(r,m),j=[];break;default:typeof y.onClick!="function"&&typeof m.onClick=="function"&&(r.onclick=nl)}Kd(c,m);var C;c=null;for(G in y)if(!m.hasOwnProperty(G)&&y.hasOwnProperty(G)&&y[G]!=null)if(G==="style"){var P=y[G];for(C in P)P.hasOwnProperty(C)&&(c||(c={}),c[C]="")}else G!=="dangerouslySetInnerHTML"&&G!=="children"&&G!=="suppressContentEditableWarning"&&G!=="suppressHydrationWarning"&&G!=="autoFocus"&&(o.hasOwnProperty(G)?j||(j=[]):(j=j||[]).push(G,null));for(G in m){var D=m[G];if(P=y!=null?y[G]:void 0,m.hasOwnProperty(G)&&D!==P&&(D!=null||P!=null))if(G==="style")if(P){for(C in P)!P.hasOwnProperty(C)||D&&D.hasOwnProperty(C)||(c||(c={}),c[C]="");for(C in D)D.hasOwnProperty(C)&&P[C]!==D[C]&&(c||(c={}),c[C]=D[C])}else c||(j||(j=[]),j.push(G,c)),c=D;else G==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,P=P?P.__html:void 0,D!=null&&P!==D&&(j=j||[]).push(G,D)):G==="children"?typeof D!="string"&&typeof D!="number"||(j=j||[]).push(G,""+D):G!=="suppressContentEditableWarning"&&G!=="suppressHydrationWarning"&&(o.hasOwnProperty(G)?(D!=null&&G==="onScroll"&&Ve("scroll",r),j||P===D||(j=[])):(j=j||[]).push(G,D))}c&&(j=j||[]).push("style",c);var G=j;(i.updateQueue=G)&&(i.flags|=4)}},Gg=function(r,i,c,m){c!==m&&(i.flags|=4)};function Ei(r,i){if(!Qe)switch(r.tailMode){case"hidden":i=r.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r.tail=null:c.sibling=null;break;case"collapsed":c=r.tail;for(var m=null;c!==null;)c.alternate!==null&&(m=c),c=c.sibling;m===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:m.sibling=null}}function Tt(r){var i=r.alternate!==null&&r.alternate.child===r.child,c=0,m=0;if(i)for(var y=r.child;y!==null;)c|=y.lanes|y.childLanes,m|=y.subtreeFlags&14680064,m|=y.flags&14680064,y.return=r,y=y.sibling;else for(y=r.child;y!==null;)c|=y.lanes|y.childLanes,m|=y.subtreeFlags,m|=y.flags,y.return=r,y=y.sibling;return r.subtreeFlags|=m,r.childLanes=c,i}function qN(r,i,c){var m=i.pendingProps;switch(Ou(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tt(i),null;case 1:return Ht(i.type)&&rl(),Tt(i),null;case 3:return m=i.stateNode,ca(),Ye(Wt),Ye(Et),Qu(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(r===null||r.child===null)&&(cl(i)?i.flags|=4:r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,_n!==null&&(Sm(_n),_n=null))),hm(r,i),Tt(i),null;case 5:Gu(i);var y=or(Ni.current);if(c=i.type,r!==null&&i.stateNode!=null)Yg(r,i,c,m,y),r.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!m){if(i.stateNode===null)throw Error(s(166));return Tt(i),null}if(r=or(Hn.current),cl(i)){m=i.stateNode,c=i.type;var j=i.memoizedProps;switch(m[Wn]=i,m[yi]=j,r=(i.mode&1)!==0,c){case"dialog":Ve("cancel",m),Ve("close",m);break;case"iframe":case"object":case"embed":Ve("load",m);break;case"video":case"audio":for(y=0;y<hi.length;y++)Ve(hi[y],m);break;case"source":Ve("error",m);break;case"img":case"image":case"link":Ve("error",m),Ve("load",m);break;case"details":Ve("toggle",m);break;case"input":J(m,j),Ve("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!j.multiple},Ve("invalid",m);break;case"textarea":Be(m,j),Ve("invalid",m)}Kd(c,j),y=null;for(var C in j)if(j.hasOwnProperty(C)){var P=j[C];C==="children"?typeof P=="string"?m.textContent!==P&&(j.suppressHydrationWarning!==!0&&tl(m.textContent,P,r),y=["children",P]):typeof P=="number"&&m.textContent!==""+P&&(j.suppressHydrationWarning!==!0&&tl(m.textContent,P,r),y=["children",""+P]):o.hasOwnProperty(C)&&P!=null&&C==="onScroll"&&Ve("scroll",m)}switch(c){case"input":mt(m),We(m,j,!0);break;case"textarea":mt(m),ws(m);break;case"select":case"option":break;default:typeof j.onClick=="function"&&(m.onclick=nl)}m=y,i.updateQueue=m,m!==null&&(i.flags|=4)}else{C=y.nodeType===9?y:y.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Ka(c)),r==="http://www.w3.org/1999/xhtml"?c==="script"?(r=C.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof m.is=="string"?r=C.createElement(c,{is:m.is}):(r=C.createElement(c),c==="select"&&(C=r,m.multiple?C.multiple=!0:m.size&&(C.size=m.size))):r=C.createElementNS(r,c),r[Wn]=i,r[yi]=m,Vg(r,i,!1,!1),i.stateNode=r;e:{switch(C=Qd(c,m),c){case"dialog":Ve("cancel",r),Ve("close",r),y=m;break;case"iframe":case"object":case"embed":Ve("load",r),y=m;break;case"video":case"audio":for(y=0;y<hi.length;y++)Ve(hi[y],r);y=m;break;case"source":Ve("error",r),y=m;break;case"img":case"image":case"link":Ve("error",r),Ve("load",r),y=m;break;case"details":Ve("toggle",r),y=m;break;case"input":J(r,m),y=ae(r,m),Ve("invalid",r);break;case"option":y=m;break;case"select":r._wrapperState={wasMultiple:!!m.multiple},y=$({},m,{value:void 0}),Ve("invalid",r);break;case"textarea":Be(r,m),y=de(r,m),Ve("invalid",r);break;default:y=m}Kd(c,y),P=y;for(j in P)if(P.hasOwnProperty(j)){var D=P[j];j==="style"?Oh(r,D):j==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,D!=null&&Fh(r,D)):j==="children"?typeof D=="str
40ing"?(c!=="textarea"||D!=="")&&Qa(r,D):typeof D=="number"&&Qa(r,""+D):j!=="suppressContentEditableWarning"&&j!=="suppressHydrationWarning"&&j!=="autoFocus"&&(o.hasOwnProperty(j)?D!=null&&j==="onScroll"&&Ve("scroll",r):D!=null&&T(r,j,D,C))}switch(c){case"input":mt(r),We(r,m,!1);break;case"textarea":mt(r),ws(r);break;case"option":m.value!=null&&r.setAttribute("value",""+me(m.value));break;case"select":r.multiple=!!m.multiple,j=m.value,j!=null?Un(r,!!m.multiple,j,!1):m.defaultValue!=null&&Un(r,!!m.multiple,m.defaultValue,!0);break;default:typeof y.onClick=="function"&&(r.onclick=nl)}switch(c){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return Tt(i),null;case 6:if(r&&i.stateNode!=null)Gg(r,i,r.memoizedProps,m);else{if(typeof m!="string"&&i.stateNode===null)throw Error(s(166));if(c=or(Ni.current),or(Hn.current),cl(i)){if(m=i.stateNode,c=i.memoizedProps,m[Wn]=i,(j=m.nodeValue!==c)&&(r=Xt,r!==null))switch(r.tag){case 3:tl(m.nodeValue,c,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&tl(m.nodeValue,c,(r.mode&1)!==0)}j&&(i.flags|=4)}else m=(c.nodeType===9?c:c.ownerDocument).createTextNode(m),m[Wn]=i,i.stateNode=m}return Tt(i),null;case 13:if(Ye(et),m=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Qe&&Zt!==null&&(i.mode&1)!==0&&(i.flags&128)===0)Jx(),aa(),i.flags|=98560,j=!1;else if(j=cl(i),m!==null&&m.dehydrated!==null){if(r===null){if(!j)throw Error(s(318));if(j=i.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(s(317));j[Wn]=i}else aa(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Tt(i),j=!1}else _n!==null&&(Sm(_n),_n=null),j=!0;if(!j)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=c,i):(m=m!==null,m!==(r!==null&&r.memoizedState!==null)&&m&&(i.child.flags|=8192,(i.mode&1)!==0&&(r===null||(et.current&1)!==0?ft===0&&(ft=3):Am())),i.updateQueue!==null&&(i.flags|=4),Tt(i),null);case 4:return ca(),hm(r,i),r===null&&xi(i.stateNode.containerInfo),Tt(i),null;case 10:return Wu(i.type._context),Tt(i),null;case 17:return Ht(i.type)&&rl(),Tt(i),null;case 19:if(Ye(et),j=i.memoizedState,j===null)return Tt(i),null;if(m=(i.flags&128)!==0,C=j.rendering,C===null)if(m)Ei(j,!1);else{if(ft!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(C=hl(r),C!==null){for(i.flags|=128,Ei(j,!1),m=C.updateQueue,m!==null&&(i.updateQueue=m,i.flags|=4),i.subtreeFlags=0,m=c,c=i.child;c!==null;)j=c,r=m,j.flags&=14680066,C=j.alternate,C===null?(j.childLanes=0,j.lanes=r,j.child=null,j.subtreeFlags=0,j.memoizedProps=null,j.memoizedState=null,j.updateQueue=null,j.dependencies=null,j.stateNode=null):(j.childLanes=C.childLanes,j.lanes=C.lanes,j.child=C.child,j.subtreeFlags=0,j.deletions=null,j.memoizedProps=C.memoizedProps,j.memoizedState=C.memoizedState,j.updateQueue=C.updateQueue,j.type=C.type,r=C.dependencies,j.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),c=c.sibling;return He(et,et.current&1|2),i.child}r=r.sibling}j.tail!==null&&rt()>pa&&(i.flags|=128,m=!0,Ei(j,!1),i.lanes=4194304)}else{if(!m)if(r=hl(C),r!==null){if(i.flags|=128,m=!0,c=r.updateQueue,c!==null&&(i.updateQueue=c,i.flags|=4),Ei(j,!0),j.tail===null&&j.tailMode==="hidden"&&!C.alternate&&!Qe)return Tt(i),null}else 2*rt()-j.renderingStartTime>pa&&c!==1073741824&&(i.flags|=128,m=!0,Ei(j,!1),i.lanes=4194304);j.isBackwards?(C.sibling=i.child,i.child=C):(c=j.last,c!==null?c.sibling=C:i.child=C,j.last=C)}return j.tail!==null?(i=j.tail,j.rendering=i,j.tail=i.sibling,j.renderingStartTime=rt(),i.sibling=null,c=et.current,He(et,m?c&1|2:c&1),i):(Tt(i),null);case 22:case 23:return Em(),m=i.memoizedState!==null,r!==null&&r.memoizedState!==null!==m&&(i.flags|=8192),m&&(i.mode&1)!==0?(en&1073741824)!==0&&(Tt(i),i.subtreeFlags&6&&(i.flags|=8192)):Tt(i),null;case 24:return null;case 25:return null}throw Error(s(156,i.tag))}function VN(r,i){switch(Ou(i),i.tag){case 1:return Ht(i.type)&&rl(),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return ca(),Ye(Wt),Ye(Et),Qu(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 5:return Gu(i),null;case 13:if(Ye(et),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(s(340));aa()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return Ye(et),null;case 4:return ca(),null;case 10:return Wu(i.type._context),null;case 22:case 23:return Em(),null;case 24:return null;default:return null}}var _l=!1,Lt=!1,YN=typeof WeakSet=="function"?WeakSet:Set,xe=null;function ua(r,i){var c=r.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(m){st(r,i,m)}else c.current=null}function xm(r,i,c){try{c()}catch(m){st(r,i,m)}}var Kg=!1;function GN(r,i){if(Eu=Ho,r=Cx(),vu(r)){if("selectionStart"in r)var c={start:r.selectionStart,end:r.selectionEnd};else e:{c=(c=r.ownerDocument)&&c.defaultView||window;var m=c.getSelection&&c.getSelection();if(m&&m.rangeCount!==0){c=m.anchorNode;var y=m.anchorOffset,j=m.focusNode;m=m.focusOffset;try{c.nodeType,j.nodeType}catch{c=null;break e}var C=0,P=-1,D=-1,G=0,oe=0,le=r,ie=null;t:for(;;){for(var fe;le!==c||y!==0&&le.nodeType!==3||(P=C+y),le!==j||m!==0&&le.nodeType!==3||(D=C+m),le.nodeType===3&&(C+=le.nodeValue.length),(fe=le.firstChild)!==null;)ie=le,le=fe;for(;;){if(le===r)break t;if(ie===c&&++G===y&&(P=C),ie===j&&++oe===m&&(D=C),(fe=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=fe}c=P===-1||D===-1?null:{start:P,end:D}}else c=null}c=c||{start:0,end:0}}else c=null;for(Au={focusedElem:r,selectionRange:c},Ho=!1,xe=i;xe!==null;)if(i=xe,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,xe=r;else for(;xe!==null;){i=xe;try{var ge=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(ge!==null){var we=ge.memoizedProps,at=ge.memoizedState,U=i.stateNode,O=U.getSnapshotBeforeUpdate(i.elementType===i.type?we:kn(i.type,we),at);U.__reactInternalSnapshotBeforeUpdate=O}break;case 3:var z=i.stateNode.containerInfo;z.nodeType===1?z.textContent="":z.nodeType===9&&z.documentElement&&z.removeChild(z.documentElement);break;
vendor: 17,477 bytes, line 40
40case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(ce){st(i,i.return,ce)}if(r=i.sibling,r!==null){r.return=i.return,xe=r;break}xe=i.return}return ge=Kg,Kg=!1,ge}function Ai(r,i,c){var m=i.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var y=m=m.next;do{if((y.tag&r)===r){var j=y.destroy;y.destroy=void 0,j!==void 0&&xm(i,c,j)}y=y.next}while(y!==m)}}function kl(r,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var c=i=i.next;do{if((c.tag&r)===r){var m=c.create;c.destroy=m()}c=c.next}while(c!==i)}}function gm(r){var i=r.ref;if(i!==null){var c=r.stateNode;switch(r.tag){case 5:r=c;break;default:r=c}typeof i=="function"?i(r):i.current=r}}function Qg(r){var i=r.alternate;i!==null&&(r.alternate=null,Qg(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&(delete i[Wn],delete i[yi],delete i[Iu],delete i[TN],delete i[LN])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Jg(r){return r.tag===5||r.tag===3||r.tag===4}function Xg(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Jg(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function ym(r,i,c){var m=r.tag;if(m===5||m===6)r=r.stateNode,i?c.nodeType===8?c.parentNode.insertBefore(r,i):c.insertBefore(r,i):(c.nodeType===8?(i=c.parentNode,i.insertBefore(r,c)):(i=c,i.appendChild(r)),c=c._reactRootContainer,c!=null||i.onclick!==null||(i.onclick=nl));else if(m!==4&&(r=r.child,r!==null))for(ym(r,i,c),r=r.sibling;r!==null;)ym(r,i,c),r=r.sibling}function bm(r,i,c){var m=r.tag;if(m===5||m===6)r=r.stateNode,i?c.insertBefore(r,i):c.appendChild(r);else if(m!==4&&(r=r.child,r!==null))for(bm(r,i,c),r=r.sibling;r!==null;)bm(r,i,c),r=r.sibling}var wt=null,Sn=!1;function Fs(r,i,c){for(c=c.child;c!==null;)Zg(r,i,c),c=c.sibling}function Zg(r,i,c){if(zn&&typeof zn.onCommitFiberUnmount=="function")try{zn.onCommitFiberUnmount($o,c)}catch{}switch(c.tag){case 5:Lt||ua(c,i);case 6:var m=wt,y=Sn;wt=null,Fs(r,i,c),wt=m,Sn=y,wt!==null&&(Sn?(r=wt,c=c.stateNode,r.nodeType===8?r.parentNode.removeChild(c):r.removeChild(c)):wt.removeChild(c.stateNode));break;case 18:wt!==null&&(Sn?(r=wt,c=c.stateNode,r.nodeType===8?Ru(r.parentNode,c):r.nodeType===1&&Ru(r,c),oi(r)):Ru(wt,c.stateNode));break;case 4:m=wt,y=Sn,wt=c.stateNode.containerInfo,Sn=!0,Fs(r,i,c),wt=m,Sn=y;break;case 0:case 11:case 14:case 15:if(!Lt&&(m=c.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){y=m=m.next;do{var j=y,C=j.destroy;j=j.tag,C!==void 0&&((j&2)!==0||(j&4)!==0)&&xm(c,i,C),y=y.next}while(y!==m)}Fs(r,i,c);break;case 1:if(!Lt&&(ua(c,i),m=c.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=c.memoizedProps,m.state=c.memoizedState,m.componentWillUnmount()}catch(P){st(c,i,P)}Fs(r,i,c);break;case 21:Fs(r,i,c);break;case 22:c.mode&1?(Lt=(m=Lt)||c.memoizedState!==null,Fs(r,i,c),Lt=m):Fs(r,i,c);break;default:Fs(r,i,c)}}function e0(r){var i=r.updateQueue;if(i!==null){r.updateQueue=null;var c=r.stateNode;c===null&&(c=r.stateNode=new YN),i.forEach(function(m){var y=s5.bind(null,r,m);c.has(m)||(c.add(m),m.then(y,y))})}}function Cn(r,i){var c=i.deletions;if(c!==null)for(var m=0;m<c.length;m++){var y=c[m];try{var j=r,C=i,P=C;e:for(;P!==null;){switch(P.tag){case 5:wt=P.stateNode,Sn=!1;break e;case 3:wt=P.stateNode.containerInfo,Sn=!0;break e;case 4:wt=P.stateNode.containerInfo,Sn=!0;break e}P=P.return}if(wt===null)throw Error(s(160));Zg(j,C,y),wt=null,Sn=!1;var D=y.alternate;D!==null&&(D.return=null),y.return=null}catch(G){st(y,i,G)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)t0(i,r),i=i.sibling}function t0(r,i){var c=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(Cn(i,r),Vn(r),m&4){try{Ai(3,r,r.return),kl(3,r)}catch(we){st(r,r.return,we)}try{Ai(5,r,r.return)}catch(we){st(r,r.return,we)}}break;case 1:Cn(i,r),Vn(r),m&512&&c!==null&&ua(c,c.return);break;case 5:if(Cn(i,r),Vn(r),m&512&&c!==null&&ua(c,c.return),r.flags&32){var y=r.stateNode;try{Qa(y,"")}catch(we){st(r,r.return,we)}}if(m&4&&(y=r.stateNode,y!=null)){var j=r.memoizedProps,C=c!==null?c.memoizedProps:j,P=r.type,D=r.updateQueue;if(r.updateQueue=null,D!==null)try{P==="input"&&j.type==="radio"&&j.name!=null&&pe(y,j),Qd(P,C);var G=Qd(P,j);for(C=0;C<D.length;C+=2){var oe=D[C],le=D[C+1];oe==="style"?Oh(y,le):oe==="dangerouslySetInnerHTML"?Fh(y,le):oe==="children"?Qa(y,le):T(y,oe,le,G)}switch(P){case"input":Re(y,j);break;case"textarea":Ze(y,j);break;case"select":var ie=y._wrapperState.wasMultiple;y._wrapperState.wasMultiple=!!j.multiple;var fe=j.value;fe!=null?Un(y,!!j.multiple,fe,!1):ie!==!!j.multiple&&(j.defaultValue!=null?Un(y,!!j.multiple,j.defaultValue,!0):Un(y,!!j.multiple,j.multiple?[]:"",!1))}y[yi]=j}catch(we){st(r,r.return,we)}}break;case 6:if(Cn(i,r),Vn(r),m&4){if(r.stateNode===null)throw Error(s(162));y=r.stateNode,j=r.memoizedProps;try{y.nodeValue=j}catch(we){st(r,r.return,we)}}break;case 3:if(Cn(i,r),Vn(r),m&4&&c!==null&&c.memoizedState.isDehydrated)try{oi(i.containerInfo)}catch(we){st(r,r.return,we)}break;case 4:Cn(i,r),Vn(r);break;case 13:Cn(i,r),Vn(r),y=r.child,y.flags&8192&&(j=y.memoizedState!==null,y.stateNode.isHidden=j,!j||y.alternate!==null&&y.alternate.memoizedState!==null||(wm=rt())),m&4&&e0(r);break;case 22:if(oe=c!==null&&c.memoizedState!==null,r.mode&1?(Lt=(G=Lt)||oe,Cn(i,r),Lt=G):Cn(i,r),Vn(r),m&8192){if(G=r.memoizedState!==null,(r.stateNode.isHidden=G)&&!oe&&(r.mode&1)!==0)for(xe=r,oe=r.child;oe!==null;){for(le=xe=oe;xe!==null;){switch(ie=xe,fe=ie.child,ie.tag){case 0:case 11:case 14:case 15:Ai(4,ie,ie.return);break;case 1:ua(ie,ie.return);var ge=ie.stateNode;if(typeof ge.componentWillUnmount=="function"){m=ie,c=ie.return;try{i=m,ge.props=i.memoizedProps,ge.state=i.memoizedState,ge.componentWillUnmount()}catch(we){st(m,c,we)}}break;case 5:ua(ie,ie.return);break;case 22:if(ie.memoizedState!==null){r0(le);continue}}fe!==null?(fe.return=ie,xe=fe):r0(le)}oe=oe.sibling}e:for(oe=null,le=r;;){if(le.tag===5){if(oe===null){oe=le;try{y=le.stateNode,G?(j=y.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none"):(P=le.stateNode,D=le.memoizedProps.style,C=D!=null&&D.hasOwnProperty("display")?D.display:null,P.style.display=Dh("display",C))}catch(we){st(r,r.return,we)}}}else if(le.tag===6){if(oe===null)try{le.stateNode.nodeValue=G?"":le.memoizedProps}catch(we){st(r,r.return,we)}}else if((le.tag!==22&&le.tag!==23||le.memoizedState===null||le===r)&&le.child!==null){le.child.return=le,le=le.child;continue}if(le===r)break e;for(;le.sibling===null;){if(le.return===null||le.return===r)break e;oe===le&&(oe=null),le=le.return}oe===le&&(oe=null),le.sibling.return=le.return,le=le.sibling}}break;case 19:Cn(i,r),Vn(r),m&4&&e0(r);break;case 21:break;default:Cn(i,r),Vn(r)}}function Vn(r){var i=r.flags;if(i&2){try{e:{for(var c=r.return;c!==null;){if(Jg(c)){var m=c;break e}c=c.return}throw Error(s(160))}switch(m.tag){case 5:var y=m.stateNode;m.flags&32&&(Qa(y,""),m.flags&=-33);var j=Xg(r);bm(r,j,y);break;case 3:case 4:var C=m.stateNode.containerInfo,P=Xg(r);ym(r,P,C);break;default:throw Error(s(161))}}catch(D){st(r,r.return,D)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function KN(r,i,c){xe=r,n0(r)}function n0(r,i,c){for(var m=(r.mode&1)!==0;xe!==null;){var y=xe,j=y.child;if(y.tag===22&&m){var C=y.memoizedState!==null||_l;if(!C){var P=y.alternate,D=P!==null&&P.memoizedState!==null||Lt;P=_l;var G=Lt;if(_l=C,(Lt=D)&&!G)for(xe=y;xe!==null;)C=xe,D=C.child,C.tag===22&&C.memoizedState!==null?a0(y):D!==null?(D.return=C,xe=D):a0(y);for(;j!==null;)xe=j,n0(j),j=j.sibling;xe=y,_l=P,Lt=G}s0(r)}else(y.subtreeFlags&8772)!==0&&j!==null?(j.return=y,xe=j):s0(r)}}function s0(r){for(;xe!==null;){var i=xe;if((i.flags&8772)!==0){var c=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:Lt||kl(5,i);break;case 1:var m=i.stateNode;if(i.flags&4&&!Lt)if(c===null)m.componentDidMount();else{var y=i.elementType===i.type?c.memoizedProps:kn(i.type,c.memoizedProps);m.componentDidUpdate(y,c.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var j=i.updateQueue;j!==null&&rg(i,j,m);break;case 3:var C=i.updateQueue;if(C!==null){if(c=null,i.child!==null)switch(i.child.tag){case 5:c=i.child.stateNode;break;case 1:c=i.child.stateNode}rg(i,C,c)}break;case 5:var P=i.stateNode;if(c===null&&i.flags&4){c=P;var D=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":D.autoFocus&&c.focus();break;case"img":D.src&&(c.src=D.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var G=i.alternate;if(G!==null){var oe=G.memoizedState;if(oe!==null){var le=oe.dehydrated;le!==null&&oi(le)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Lt||i.flags&512&&gm(i)}catch(ie){st(i,i.return,ie)}}if(i===r){xe=null;break}if(c=i.sibling,c!==null){c.return=i.return,xe=c;break}xe=i.return}}function r0(r){for(;xe!==null;){var i=xe;if(i===r){xe=null;break}var c=i.sibling;if(c!==null){c.return=i.return,xe=c;break}xe=i.return}}function a0(r){for(;xe!==null;){var i=xe;try{switch(i.tag){case 0:case 11:case 15:var c=i.return;try{kl(4,i)}catch(D){st(i,c,D)}break;case 1:var m=i.stateNode;if(typeof m.componentDidMount=="function"){var y=i.return;try{m.componentDidMount()}catch(D){st(i,y,D)}}var j=i.return;try{gm(i)}catch(D){st(i,j,D)}break;case 5:var C=i.return;try{gm(i)}catch(D){st(i,C,D)}}}catch(D){st(i,i.return,D)}if(i===r){xe=null;break}var P=i.sibling;if(P!==null){P.return=i.return,xe=P;break}xe=i.return}}var QN=Math.ceil,Sl=E.ReactCurrentDispatcher,vm=E.ReactCurrentOwner,pn=E.ReactCurrentBatchConfig,De=0,yt=null,it=null,Nt=0,en=0,ma=Ts(0),ft=0,Ti=null,cr=0,Cl=0,jm=0,Li=null,Vt=null,wm=0,pa=1/0,as=null,El=!1,Nm=null,Ds=null,Al=!1,Os=null,Tl=0,Ri=0,_m=null,Ll=-1,Rl=0;function Dt(){return(De&6)!==0?rt():Ll!==-1?Ll:Ll=rt()}function $s(r){return(r.mode&1)===0?1:(De&2)!==0&&Nt!==0?Nt&-Nt:IN.transition!==null?(Rl===0&&(Rl=Xh()),Rl):(r=ze,r!==0||(r=window.event,r=r===void 0?16:ox(r.type)),r)}function En(r,i,c,m){if(50<Ri)throw Ri=0,_m=null,Error(s(185));ni(r,c,m),((De&2)===0||r!==yt)&&(r===yt&&((De&2)===0&&(Cl|=c),ft===4&&Ms(r,Nt)),Yt(r,m),c===1&&De===0&&(i.mode&1)===0&&(pa=rt()+500,il&&Rs()))}function Yt(r,i){var c=r.callbackNode;I2(r,i);var m=Uo(r,r===yt?Nt:0);if(m===0)c!==null&&Kh(c),r.callbackNode=null,r.callbackPriority=0;else if(i=m&-m,r.callbackPriority!==i){if(c!=null&&Kh(c),i===1)r.tag===0?RN(o0.bind(null,r)):Vx(o0.bind(null,r)),EN(function(){(De&6)===0&&Rs()}),c=null;else{switch(Zh(m)){case 1:c=su;break;case 4:c=Qh;break;case 16:c=Oo;break;case 536870912:c=Jh;break;default:c=Oo}c=h0(c,i0.bind(null,r))}r.callbackPriority=i,r.callbackNode=c}}function i0(r,i){if(Ll=-1,Rl=0,(De&6)!==0)throw Error(s(327));var c=r.callbackNode;if(fa()&&r.callbackNode!==c)return null;var m=Uo(r,r===yt?Nt:0);if(m===0)return null;if((m&30)!==0||(m&r.expiredLanes)!==0||i)i=Il(r,m);else{i=m;var y=De;De|=2;var j=c0();(yt!==r||Nt!==i)&&(as=null,pa=rt()+500,ur(r,i));do try{ZN();break}catch(P){l0(r,P)}while(!0);zu(),Sl.current=j,De=y,it!==null?i=0:(yt=null,Nt=0,i=ft)}if(i!==0){if(i===2&&(y=ru(r),y!==0&&(m=y,i=km(r,y))),i===1)throw c=Ti,ur(r,0),Ms(r,m),Yt(r,rt()),c;if(i===6)Ms(r,m);else{if(y=r.current.alternate,(m&30)===0&&!JN(y)&&(i=Il(r,m),i===2&&(j=ru(r),j!==0&&(m=j,i=km(r,j))),i===1))throw c=Ti,ur(r,0),Ms(r,m),Yt(r,rt()),c;switch(r.finishedWork=y,r.finishedLanes=m,i){case 0:case 1:throw Error(s(345));case 2:mr(r,Vt,as);break;case 3:if(Ms(r,m),(m&130023424)===m&&(i=wm+500-rt(),10<i)){if(Uo(r,0)!==0)break;if(y=r.suspendedLanes,(y&m)!==m){Dt(),r.pingedLanes|=r.suspendedLanes&y;break}r.timeoutHandle=Lu(mr.bind(null,r,Vt,as),i);break}mr(r,Vt,as);break;case 4:if(Ms(r,m),(m&4194240)===m)break;for(i=r.eventTimes,y=-1;0<m;){var C=31-wn(m);j=1<<C,C=i[C],C>y&&(y=C),m&=~j}if(m=y,m=rt()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*QN(m/1960))-m,10<m){r.timeoutHandle=Lu(mr.bind(null,r,Vt,as),m);break}mr(r,Vt,as);break;case 5:mr(r,Vt,as);break;default:throw Error(s(329))}}}return Yt(r,rt()),r.callbackNode===c?i0.bind(null,r):null}function km(r,i){var c=Li;return r.current.memoizedState.isDehydrated&&(ur(r,i).flags|=256),r=Il(r,i),r!==2&&(i=Vt,Vt=c,i!==null&&Sm(i)),r}function Sm(r){Vt===null?Vt=r:Vt.push.apply(Vt,r)}function JN(r){for(var i=r;;){if(i.flags&16384){var c=i.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var m=0;m<c.length;m++){var y=c[m],j=y.getSnapshot;y=y.value;try{if(!Nn(j(),y))return!1}catch{return!1}}}if(c=i.child,i.subtreeFlags&16384&&c!==null)c.return=i,i=c;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Ms(r,i){for(i&=~jm,i&=~Cl,r.suspendedLanes|=i,r.pingedLanes&=~i,r=r.expirationTimes;0<i;){var c=31-wn(i),m=1<<c;r[c]=-1,i&=~m}}function o0(r){if((De&6)!==0)throw Error(s(327));fa();var i=Uo(r,0);if((i&1)===0)return Yt(r,rt()),null;var c=Il(r,i);if(r.tag!==0&&c===2){var m=ru(r);m!==0&&(i=m,c=km(r,m))}if(c===1)throw c=Ti,ur(r,0),Ms(r,i),Yt(r,rt()),c;if(c===6)throw Error(s(345));return r.finishedWork=r.current.alternate,r.finishedLanes=i,mr(r,Vt,as),Yt(r,rt()),null}function Cm(r,i){var c=De;De|=1;try{return r(i)}finally{De=c,De===0&&(pa=rt()+500,il&&Rs())}}function dr(r){Os!==null&&Os.tag===0&&(De&6)===0&&fa();var i=De;De|=1;var c=pn.transition,m=ze;try{if(pn.transition=null,ze=1,r)return r()}finally{ze=m,pn.transition=c,De=i,(De&6)===0&&Rs()}}function Em(){en=ma.current,Ye(ma)}function ur(r,i){r.finishedWork=null,r.finishedLanes=0;var c=r.timeoutHandle;if(c!==-1&&(r.timeoutHandle=-1,CN(c)),it!==null)for(c=it.return;c!==null;){var m=c;switch(Ou(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&rl();break;case 3:ca(),Ye(Wt),Ye(Et),Qu();break;case 5:Gu(m);break;case 4:ca();break;case 13:Ye(et);break;case 19:Ye(et);break;case 10:Wu(m.type._context);break;case 22:case 23:Em()}c=c.return}if(yt=r,it=r=Bs(r.current,null),Nt=en=i,ft=0,Ti=null,jm=Cl=cr=0,Vt=Li=null,ir!==null){for(i=0;i<ir.length;i++)if(c=ir[i],m=c.interleaved,m!==null){c.interleaved=null;var y=m.next,j=c.pending;if(j!==null){var C=j.next;j.next=y,m.next=C}c.pending=m}ir=null}return r}function l0(r,i){do{var c=it;try{if(zu(),xl.current=vl,gl){for(var m=tt.memoizedState;m!==null;){var y=m.queue;y!==null&&(y.pending=null),m=m.next}gl=!1}if(lr=0,gt=pt=tt=null,_i=!1,ki=0,vm.current=null,c===null||c.return===null){ft=1,Ti=i,it=null;break}e:{var j=r,C=c.return,P=c,D=i;if(i=Nt,P.flags|=32768,D!==null&&typeof D=="object"&&typeof D.then=="function"){var G=D,oe=P,le=oe.tag;if((oe.mode&1)===0&&(le===0||le===11||le===15)){var ie=oe.alternate;ie?(oe.updateQueue=ie.updateQueue,oe.memoizedState=ie.memoizedState,oe.lanes=ie.lanes):(oe.updateQueue=null,oe.memoizedState=null)}var fe=Ig(C);if(fe!==null){fe.flags&=-257,Pg(fe,C,P,j,i),fe.mode&1&&Rg(j,G,i),i=fe,D=G;var ge=i.updateQueue;if(ge===null){var we=new Set;we.add(D),i.updateQueue=we}else ge.add(D);break e}else{if((i&1)===0){Rg(j,G,i),Am();break e}D=Error(s(426))}}else if(Qe&&P.mode&1){var at=Ig(C);if(at!==null){(at.flags&65536)===0&&(at.flags|=256),Pg(at,C,P,j,i),Bu(da(D,P));break e}}j=D=da(D,P),ft!==4&&(ft=2),Li===null?Li=[j]:Li.push(j),j=C;do{switch(j.tag){case 3:j.flags|=65536,i&=-i,j.lanes|=i;var U=Tg(j,D,i);sg(j,U);break e;case 1:P=D;var O=j.type,z=j.stateNode;if((j.flags&128)===0&&(typeof O.getDerivedStateFromError=="function"||z!==null&&typeof z.componentDidCatch=="function"&&(Ds===null||!Ds.has(z)))){j.flags|=65536,i&=-i,j.lanes|=i;var ce=Lg(j,P,i);sg(j,ce);break e}}j=j.return}while(j!==null)}u0(c)}catch(_e){i=_e,it===c&&c!==null&&(it=c=c.return);continue}break}while(!0)}function c0(){var r=Sl.current;return Sl.current=vl,r===null?vl:r}function Am(){(ft===0||ft===3||ft===2)&&(ft=4),yt===null||(cr&268435455)===0&&(Cl&268435455)===0||Ms(yt,Nt)}function Il(r,i){var c=De;De|=2;var m=c0();(yt!==r||Nt!==i)&&(as=null,ur(r,i));do try{XN();break}catch(y){l0(r,y)}while(!0);if(zu(),De=c,Sl.current=m,it!==null)throw Error(s(261));return yt=null,Nt=0,ft}function XN(){for(;it!==null;)d0(it)}function ZN(){for(;it!==null&&!_2();)d0(it)}function d0(r){var i=f0(r.alternate,r,en);r.memoizedProps=r.pendingProps,i===null?u0(r):it=i,vm.current=null}function u0(r){var i=r;do{var c=i.alternate;if(r=i.return,(i.flags&32768)===0){if(c=qN(c,i,en),c!==null){it=c;return}}else{if(c=VN(c,i),c!==null){c.flags&=32767,it=c;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{ft=6,it=null;return}}if(i=i.sibling,i!==null){it=i;return}it=i=r}while(i!==null);ft===0&&(ft=5)}function mr(r,i,c){var m=ze,y=pn.transition;try{pn.transition=null,ze=1,e5(r,i,c,m)}finally{pn.transition=y,ze=m}return null}function e5(r,i,c,m){do fa();while(Os!==null);if((De&6)!==0)throw Error(s(327));c=r.finishedWork;var y=r.finishedLanes;if(c===null)return null;if(r.finishedWork=null,r.finishedLanes=0,c===r.current)throw Error(s(177));r.callbackNode=null,r.callbackPriority=0;var j=c.lanes|c.childLanes;if(P2(r,j),r===yt&&(it=yt=null,Nt=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||Al||(Al=!0,h0(Oo,function(){return fa(),null})),j=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||j){j=pn.transition,pn.transition=null;var C=ze;ze=1;var P=De;De|=4,vm.current=null,GN(r,c),t0(c,r),vN(Au),Ho=!!Eu,Au=Eu=null,r.current=c,KN(c),k2(),De=P,ze=C,pn.transition=j}else r.current=c;
vendor: 6,914 bytes, line 40
40if(Al&&(Al=!1,Os=r,Tl=y),j=r.pendingLanes,j===0&&(Ds=null),E2(c.stateNode),Yt(r,rt()),i!==null)for(m=r.onRecoverableError,c=0;c<i.length;c++)y=i[c],m(y.value,{componentStack:y.stack,digest:y.digest});if(El)throw El=!1,r=Nm,Nm=null,r;return(Tl&1)!==0&&r.tag!==0&&fa(),j=r.pendingLanes,(j&1)!==0?r===_m?Ri++:(Ri=0,_m=r):Ri=0,Rs(),null}function fa(){if(Os!==null){var r=Zh(Tl),i=pn.transition,c=ze;try{if(pn.transition=null,ze=16>r?16:r,Os===null)var m=!1;else{if(r=Os,Os=null,Tl=0,(De&6)!==0)throw Error(s(331));var y=De;for(De|=4,xe=r.current;xe!==null;){var j=xe,C=j.child;if((xe.flags&16)!==0){var P=j.deletions;if(P!==null){for(var D=0;D<P.length;D++){var G=P[D];for(xe=G;xe!==null;){var oe=xe;switch(oe.tag){case 0:case 11:case 15:Ai(8,oe,j)}var le=oe.child;if(le!==null)le.return=oe,xe=le;else for(;xe!==null;){oe=xe;var ie=oe.sibling,fe=oe.return;if(Qg(oe),oe===G){xe=null;break}if(ie!==null){ie.return=fe,xe=ie;break}xe=fe}}}var ge=j.alternate;if(ge!==null){var we=ge.child;if(we!==null){ge.child=null;do{var at=we.sibling;we.sibling=null,we=at}while(we!==null)}}xe=j}}if((j.subtreeFlags&2064)!==0&&C!==null)C.return=j,xe=C;else e:for(;xe!==null;){if(j=xe,(j.flags&2048)!==0)switch(j.tag){case 0:case 11:case 15:Ai(9,j,j.return)}var U=j.sibling;if(U!==null){U.return=j.return,xe=U;break e}xe=j.return}}var O=r.current;for(xe=O;xe!==null;){C=xe;var z=C.child;if((C.subtreeFlags&2064)!==0&&z!==null)z.return=C,xe=z;else e:for(C=O;xe!==null;){if(P=xe,(P.flags&2048)!==0)try{switch(P.tag){case 0:case 11:case 15:kl(9,P)}}catch(_e){st(P,P.return,_e)}if(P===C){xe=null;break e}var ce=P.sibling;if(ce!==null){ce.return=P.return,xe=ce;break e}xe=P.return}}if(De=y,Rs(),zn&&typeof zn.onPostCommitFiberRoot=="function")try{zn.onPostCommitFiberRoot($o,r)}catch{}m=!0}return m}finally{ze=c,pn.transition=i}}return!1}function m0(r,i,c){i=da(c,i),i=Tg(r,i,1),r=Ps(r,i,1),i=Dt(),r!==null&&(ni(r,1,i),Yt(r,i))}function st(r,i,c){if(r.tag===3)m0(r,r,c);else for(;i!==null;){if(i.tag===3){m0(i,r,c);break}else if(i.tag===1){var m=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Ds===null||!Ds.has(m))){r=da(c,r),r=Lg(i,r,1),i=Ps(i,r,1),r=Dt(),i!==null&&(ni(i,1,r),Yt(i,r));break}}i=i.return}}function t5(r,i,c){var m=r.pingCache;m!==null&&m.delete(i),i=Dt(),r.pingedLanes|=r.suspendedLanes&c,yt===r&&(Nt&c)===c&&(ft===4||ft===3&&(Nt&130023424)===Nt&&500>rt()-wm?ur(r,0):jm|=c),Yt(r,i)}function p0(r,i){i===0&&((r.mode&1)===0?i=1:(i=Bo,Bo<<=1,(Bo&130023424)===0&&(Bo=4194304)));var c=Dt();r=ns(r,i),r!==null&&(ni(r,i,c),Yt(r,c))}function n5(r){var i=r.memoizedState,c=0;i!==null&&(c=i.retryLane),p0(r,c)}function s5(r,i){var c=0;switch(r.tag){case 13:var m=r.stateNode,y=r.memoizedState;y!==null&&(c=y.retryLane);break;case 19:m=r.stateNode;break;default:throw Error(s(314))}m!==null&&m.delete(i),p0(r,c)}var f0;f0=function(r,i,c){if(r!==null)if(r.memoizedProps!==i.pendingProps||Wt.current)qt=!0;else{if((r.lanes&c)===0&&(i.flags&128)===0)return qt=!1,HN(r,i,c);qt=(r.flags&131072)!==0}else qt=!1,Qe&&(i.flags&1048576)!==0&&Yx(i,ll,i.index);switch(i.lanes=0,i.tag){case 2:var m=i.type;Nl(r,i),r=i.pendingProps;var y=na(i,Et.current);la(i,c),y=Zu(null,i,m,r,y,c);var j=em();return i.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,Ht(m)?(j=!0,al(i)):j=!1,i.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,Vu(i),y.updater=jl,i.stateNode=y,y._reactInternals=i,im(i,m,r,c),i=dm(null,i,m,!0,j,c)):(i.tag=0,Qe&&j&&Du(i),Ft(null,i,y,c),i=i.child),i;case 16:m=i.elementType;e:{switch(Nl(r,i),r=i.pendingProps,y=m._init,m=y(m._payload),i.type=m,y=i.tag=a5(m),r=kn(m,r),y){case 0:i=cm(null,i,m,r,c);break e;case 1:i=Bg(null,i,m,r,c);break e;case 11:i=Fg(null,i,m,r,c);break e;case 14:i=Dg(null,i,m,kn(m.type,r),c);break e}throw Error(s(306,m,""))}return i;case 0:return m=i.type,y=i.pendingProps,y=i.elementType===m?y:kn(m,y),cm(r,i,m,y,c);case 1:return m=i.type,y=i.pendingProps,y=i.elementType===m?y:kn(m,y),Bg(r,i,m,y,c);case 3:e:{if(Ug(i),r===null)throw Error(s(387));m=i.pendingProps,j=i.memoizedState,y=j.element,ng(r,i),fl(i,m,null,c);var C=i.memoizedState;if(m=C.element,j.isDehydrated)if(j={element:m,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},i.updateQueue.baseState=j,i.memoizedState=j,i.flags&256){y=da(Error(s(423)),i),i=zg(r,i,m,c,y);break e}else if(m!==y){y=da(Error(s(424)),i),i=zg(r,i,m,c,y);break e}else for(Zt=As(i.stateNode.containerInfo.firstChild),Xt=i,Qe=!0,_n=null,c=eg(i,null,m,c),i.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(aa(),m===y){i=rs(r,i,c);break e}Ft(r,i,m,c)}i=i.child}return i;case 5:return ag(i),r===null&&Mu(i),m=i.type,y=i.pendingProps,j=r!==null?r.memoizedProps:null,C=y.children,Tu(m,y)?C=null:j!==null&&Tu(m,j)&&(i.flags|=32),Mg(r,i),Ft(r,i,C,c),i.child;case 6:return r===null&&Mu(i),null;case 13:return Wg(r,i,c);case 4:return Yu(i,i.stateNode.containerInfo),m=i.pendingProps,r===null?i.child=ia(i,null,m,c):Ft(r,i,m,c),i.child;case 11:return m=i.type,y=i.pendingProps,y=i.elementType===m?y:kn(m,y),Fg(r,i,m,y,c);case 7:return Ft(r,i,i.pendingProps,c),i.child;case 8:return Ft(r,i,i.pendingProps.children,c),i.child;case 12:return Ft(r,i,i.pendingProps.children,c),i.child;case 10:e:{if(m=i.type._context,y=i.pendingProps,j=i.memoizedProps,C=y.value,He(ul,m._currentValue),m._currentValue=C,j!==null)if(Nn(j.value,C)){if(j.children===y.children&&!Wt.current){i=rs(r,i,c);break e}}else for(j=i.child,j!==null&&(j.return=i);j!==null;){var P=j.dependencies;if(P!==null){C=j.child;for(var D=P.firstContext;D!==null;){if(D.context===m){if(j.tag===1){D=ss(-1,c&-c),D.tag=2;var G=j.updateQueue;if(G!==null){G=G.shared;var oe=G.pending;oe===null?D.next=D:(D.next=oe.next,oe.next=D),G.pending=D}}j.lanes|=c,D=j.alternate,D!==null&&(D.lanes|=c),Hu(j.return,c,i),P.lanes|=c;break}D=D.next}}else if(j.tag===10)C=j.type===i.type?null:j.child;else if(j.tag===18){if(C=j.return,C===null)throw Error(s(341));C.lanes|=c,P=C.alternate,P!==null&&(P.lanes|=c),Hu(C,c,i),C=j.sibling}else C=j.child;if(C!==null)C.return=j;else for(C=j;C!==null;){if(C===i){C=null;break}if(j=C.sibling,j!==null){j.return=C.return,C=j;break}C=C.return}j=C}Ft(r,i,y.children,c),i=i.child}return i;case 9:return y=i.type,m=i.pendingProps.children,la(i,c),y=un(y),m=m(y),i.flags|=1,Ft(r,i,m,c),i.child;case 14:return m=i.type,y=kn(m,i.pendingProps),y=kn(m.type,y),Dg(r,i,m,y,c);case 15:return Og(r,i,i.type,i.pendingProps,c);case 17:return m=i.type,y=i.pendingProps,y=i.elementType===m?y:kn(m,y),Nl(r,i),i.tag=1,Ht(m)?(r=!0,al(i)):r=!1,la(i,c),Eg(i,m,y),im(i,m,y,c),dm(null,i,m,!0,r,c);case 19:return qg(r,i,c);case 22:return $g(r,i,c)}throw Error(s(156,i.tag))};function h0(r,i){return Gh(r,i)}function r5(r,i,c,m){this.tag=r,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.t
vendor: 10,867 bytes, lines 40-49
40ype=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fn(r,i,c,m){return new r5(r,i,c,m)}function Tm(r){return r=r.prototype,!(!r||!r.isReactComponent)}function a5(r){if(typeof r=="function")return Tm(r)?1:0;if(r!=null){if(r=r.$$typeof,r===se)return 11;if(r===ue)return 14}return 2}function Bs(r,i){var c=r.alternate;return c===null?(c=fn(r.tag,i,r.key,r.mode),c.elementType=r.elementType,c.type=r.type,c.stateNode=r.stateNode,c.alternate=r,r.alternate=c):(c.pendingProps=i,c.type=r.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=r.flags&14680064,c.childLanes=r.childLanes,c.lanes=r.lanes,c.child=r.child,c.memoizedProps=r.memoizedProps,c.memoizedState=r.memoizedState,c.updateQueue=r.updateQueue,i=r.dependencies,c.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},c.sibling=r.sibling,c.index=r.index,c.ref=r.ref,c}function Pl(r,i,c,m,y,j){var C=2;if(m=r,typeof r=="function")Tm(r)&&(C=1);else if(typeof r=="string")C=5;else e:switch(r){case R:return pr(c.children,y,j,i);case W:C=8,y|=8;break;case Y:return r=fn(12,c,i,y|2),r.elementType=Y,r.lanes=j,r;case ne:return r=fn(13,c,i,y),r.elementType=ne,r.lanes=j,r;case Z:return r=fn(19,c,i,y),r.elementType=Z,r.lanes=j,r;case H:return Fl(c,y,j,i);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case K:C=10;break e;case X:C=9;break e;case se:C=11;break e;case ue:C=14;break e;case re:C=16,m=null;break e}throw Error(s(130,r==null?r:typeof r,""))}return i=fn(C,c,i,y),i.elementType=r,i.type=m,i.lanes=j,i}function pr(r,i,c,m){return r=fn(7,r,m,i),r.lanes=c,r}function Fl(r,i,c,m){return r=fn(22,r,m,i),r.elementType=H,r.lanes=c,r.stateNode={isHidden:!1},r}function Lm(r,i,c){return r=fn(6,r,null,i),r.lanes=c,r}function Rm(r,i,c){return i=fn(4,r.children!==null?r.children:[],r.key,i),i.lanes=c,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}function i5(r,i,c,m,y){this.tag=i,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=au(0),this.expirationTimes=au(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=au(0),this.identifierPrefix=m,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function Im(r,i,c,m,y,j,C,P,D){return r=new i5(r,i,c,P,D),i===1?(i=1,j===!0&&(i|=8)):i=0,j=fn(3,null,null,i),r.current=j,j.stateNode=r,j.memoizedState={element:m,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vu(j),r}function o5(r,i,c){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:m==null?null:""+m,children:r,containerInfo:i,implementation:c}}function x0(r){if(!r)return Ls;r=r._reactInternals;e:{if(tr(r)!==r||r.tag!==1)throw Error(s(170));var i=r;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Ht(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(s(171))}if(r.tag===1){var c=r.type;if(Ht(c))return Hx(r,c,i)}return i}function g0(r,i,c,m,y,j,C,P,D){return r=Im(c,m,!0,r,y,j,C,P,D),r.context=x0(null),c=r.current,m=Dt(),y=$s(c),j=ss(m,y),j.callback=i??null,Ps(c,j,y),r.current.lanes=y,ni(r,y,m),Yt(r,m),r}function Dl(r,i,c,m){var y=i.current,j=Dt(),C=$s(y);return c=x0(c),i.context===null?i.context=c:i.pendingContext=c,i=ss(j,C),i.payload={element:r},m=m===void 0?null:m,m!==null&&(i.callback=m),r=Ps(y,i,C),r!==null&&(En(r,y,C,j),pl(r,y,C)),C}function Ol(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function y0(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var c=r.retryLane;r.retryLane=c!==0&&c<i?c:i}}function Pm(r,i){y0(r,i),(r=r.alternate)&&y0(r,i)}function l5(){return null}var b0=typeof reportError=="function"?reportError:function(r){console.error(r)};function Fm(r){this._internalRoot=r}$l.prototype.render=Fm.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));Dl(r,i,null,null)},$l.prototype.unmount=Fm.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;dr(function(){Dl(null,r,null,null)}),i[Xn]=null}};function $l(r){this._internalRoot=r}$l.prototype.unstable_scheduleHydration=function(r){if(r){var i=nx();r={blockedOn:null,target:r,priority:i};for(var c=0;c<Ss.length&&i!==0&&i<Ss[c].priority;c++);Ss.splice(c,0,r),c===0&&ax(r)}};function Dm(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Ml(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function v0(){}function c5(r,i,c,m,y){if(y){if(typeof m=="function"){var j=m;m=function(){var G=Ol(C);j.call(G)}}var C=g0(i,m,r,0,null,!1,!1,"",v0);return r._reactRootContainer=C,r[Xn]=C.current,xi(r.nodeType===8?r.parentNode:r),dr(),C}for(;y=r.lastChild;)r.removeChild(y);if(typeof m=="function"){var P=m;m=function(){var G=Ol(D);P.call(G)}}var D=Im(r,0,!1,null,null,!1,!1,"",v0);return r._reactRootContainer=D,r[Xn]=D.current,xi(r.nodeType===8?r.parentNode:r),dr(function(){Dl(i,D,c,m)}),D}function Bl(r,i,c,m,y){var j=c._reactRootContainer;if(j){var C=j;if(typeof y=="function"){var P=y;y=function(){var D=Ol(C);P.call(D)}}Dl(i,C,r,y)}else C=c5(c,i,r,y,m);return Ol(C)}ex=function(r){switch(r.tag){case 3:var i=r.stateNode;if(i.current.memoizedState.isDehydrated){var c=ti(i.pendingLanes);c!==0&&(iu(i,c|1),Yt(i,rt()),(De&6)===0&&(pa=rt()+500,Rs()))}break;case 13:dr(function(){var m=ns(r,1);if(m!==null){var y=Dt();En(m,r,1,y)}}),Pm(r,1)}},ou=function(r){if(r.tag===13){var i=ns(r,134217728);if(i!==null){var c=Dt();En(i,r,134217728,c)}Pm(r,134217728)}},tx=function(r){if(r.tag===13){var i=$s(r),c=ns(r,i);if(c!==null){var m=Dt();En(c,r,i,m)}Pm(r,i)}},nx=function(){return ze},sx=function(r,i){var c=ze;try{return ze=r,i()}finally{ze=c}},Zd=function(r,i,c){switch(i){case"input":if(Re(r,c),i=c.name,c.type==="radio"&&i!=null){for(c=r;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<c.length;i++){var m=c[i];if(m!==r&&m.form===r.form){var y=sl(m);if(!y)throw Error(s(90));he(m),Re(m,y)}}}break;case"textarea":Ze(r,c);break;case"select":i=c.value,i!=null&&Un(r,!!c.multiple,i,!1)}},Uh=Cm,zh=dr;var d5={usingClientEntryPoint:!1,Events:[bi,ea,sl,Mh,Bh,Cm]},Ii={findFiberByHostInstance:nr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},u5={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Vh(r),r===null?null:r.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||l5,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ul=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ul.isDisabled&&Ul.supportsFiber)try{$o=Ul.inject(u5),zn=Ul}catch{}}return Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=d5,Gt.createPortal=function(r,i){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dm(i))throw Error(s(200));return o5(r,i,null,c)},Gt.createRoot=function(r,i){if(!Dm(r))throw Error(s(299));var c=!1,m="",y=b0;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(y=i.onRecoverableError)),i=Im(r,1,!1,null,null,c,!1,m,y),r[Xn]=i.current,xi(r.nodeType===8?r.parentNode:r),new Fm(i)},Gt.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=Vh(i),r=r===null?null:r.stateNode,r},Gt.flushSync=function(r){return dr(r)},Gt.hydrate=function(r,i,c){if(!Ml(i))throw Error(s(200));return Bl(null,r,i,!0,c)},Gt.hydrateRoot=function(r,i,c){if(!Dm(r))throw Error(s(405));var m=c!=null&&c.hydratedSources||null,y=!1,j="",C=b0;if(c!=null&&(c.unstable_strictMode===!0&&(y=!0),c.identifierPrefix!==void 0&&(j=c.identifierPrefix),c.onRecoverableError!==void 0&&(C=c.onRecoverableError)),i=g0(i,null,r,1,c??null,y,!1,j,C),r[Xn]=i.current,xi(r),m)for(r=0;r<m.length;r++)c=m[r],y=c._getVersion,y=y(c._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[c,y]:i.mutableSourceEagerHydrationData.push(c,y);return new $l(i)},Gt.render=function(r,i,c){if(!Ml(i))throw Error(s(200));return Bl(null,r,i,!1,c)},Gt.unmountComponentAtNode=function(r){if(!Ml(r))throw Error(s(40));return r._reactRootContainer?(dr(function(){Bl(null,null,r,!1,function(){r._reactRootContainer=null,r[Xn]=null})}),!0):!1},Gt.unstable_batchedUpdates=Cm,Gt.unstable_renderSubtreeIntoContainer=function(r,i,c,m){if(!Ml(c))throw Error(s(200));if(r==null||r._reactInternals===void 0)throw Error(s(38));return Bl(r,i,c,!1,m)},Gt.version="18.3.1-next-f1338f8080-20240426",Gt}var E0;function zv(){if(E0)return Mm.exports;E0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Mm.exports=v5(),Mm.exports}var A0;function j5(){if(A0)return zl;A0=1;var e=zv();return zl.createRoot=e.createRoot,zl.hydrateRoot=e.hydrateRoot,zl}var w5=j5();const T0=Bv(w5);var N5=zv();/**
41 * @remix-run/router v1.23.3
42 *
43 * Copyright (c) Remix Software Inc.
44 *
45 * This source code is licensed under the MIT license found in the
46 * LICENSE.md file in the root directory of this source tree.
47 *
48 * @license MIT
49 */function Zi(){return Zi=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var a in s)({}).hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},Zi.apply(null,arguments)}var Ws;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Ws||(Ws={}));const L0="popstate";function _5(e){e===void 0&&(e={});function n(a,o){let{pathname:l,search:d,hash:u}=a.location;return $p("",{pathname:l,search:d,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}
vendor: 11,789 bytes, lines 49-58
49function s(a,o){return typeof o=="string"?o:Ac(o)}return S5(n,s,null,e)}function nt(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function Pf(e,n){if(!e){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function k5(){return Math.random().toString(36).substr(2,8)}function R0(e,n){return{usr:e.state,key:e.key,idx:n}}function $p(e,n,s,a){return s===void 0&&(s=null),Zi({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof n=="string"?$a(n):n,{state:s,key:n&&n.key||a||k5()})}function Ac(e){let{pathname:n="/",search:s="",hash:a=""}=e;return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(n+=a.charAt(0)==="#"?a:"#"+a),n}function $a(e){let n={};if(e){let s=e.indexOf("#");s>=0&&(n.hash=e.substr(s),e=e.substr(0,s));let a=e.indexOf("?");a>=0&&(n.search=e.substr(a),e=e.substr(0,a)),e&&(n.pathname=e)}return n}function S5(e,n,s,a){a===void 0&&(a={});let{window:o=document.defaultView,v5Compat:l=!1}=a,d=o.history,u=Ws.Pop,p=null,h=f();h==null&&(h=0,d.replaceState(Zi({},d.state,{idx:h}),""));function f(){return(d.state||{idx:null}).idx}function g(){u=Ws.Pop;let k=f(),_=k==null?null:k-h;h=k,p&&p({action:u,location:w.location,delta:_})}function b(k,_){u=Ws.Push;let S=$p(w.location,k,_);h=f()+1;let T=R0(S,h),E=w.createHref(S);try{d.pushState(T,"",E)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;o.location.assign(E)}l&&p&&p({action:u,location:w.location,delta:1})}function v(k,_){u=Ws.Replace;let S=$p(w.location,k,_);h=f();let T=R0(S,h),E=w.createHref(S);d.replaceState(T,"",E),l&&p&&p({action:u,location:w.location,delta:0})}function N(k){let _=o.location.origin!=="null"?o.location.origin:o.location.href,S=typeof k=="string"?k:Ac(k);return S=S.replace(/ $/,"%20"),nt(_,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,_)}let w={get action(){return u},get location(){return e(o,d)},listen(k){if(p)throw new Error("A history only accepts one active listener");return o.addEventListener(L0,g),p=k,()=>{o.removeEventListener(L0,g),p=null}},createHref(k){return n(o,k)},createURL:N,encodeLocation(k){let _=N(k);return{pathname:_.pathname,search:_.search,hash:_.hash}},push:b,replace:v,go(k){return d.go(k)}};return w}var I0;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(I0||(I0={}));function C5(e,n,s){return s===void 0&&(s="/"),E5(e,n,s)}function E5(e,n,s,a){let o=typeof n=="string"?$a(n):n,l=Ta(o.pathname||"/",s);if(l==null)return null;let d=Wv(e);A5(d);let u=null,p=B5(l);for(let h=0;u==null&&h<d.length;++h)u=$5(d[h],p);return u}function Wv(e,n,s,a){n===void 0&&(n=[]),s===void 0&&(s=[]),a===void 0&&(a="");let o=(l,d,u)=>{let p={relativePath:u===void 0?l.path||"":u,caseSensitive:l.caseSensitive===!0,childrenIndex:d,route:l};p.relativePath.startsWith("/")&&(nt(p.relativePath.startsWith(a),'Absolute route path "'+p.relativePath+'" nested under path '+('"'+a+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),p.relativePath=p.relativePath.slice(a.length));let h=Hs([a,p.relativePath]),f=s.concat(p);l.children&&l.children.length>0&&(nt(l.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Wv(l.children,n,f,h)),!(l.path==null&&!l.index)&&n.push({path:h,score:D5(h,l.index),routesMeta:f})};return e.forEach((l,d)=>{var u;if(l.path===""||!((u=l.path)!=null&&u.includes("?")))o(l,d);else for(let p of Hv(l.path))o(l,d,p)}),n}function Hv(e){let n=e.split("/");if(n.length===0)return[];let[s,...a]=n,o=s.endsWith("?"),l=s.replace(/\?$/,"");if(a.length===0)return o?[l,""]:[l];let d=Hv(a.join("/")),u=[];return u.push(...d.map(p=>p===""?l:[l,p].join("/"))),o&&u.push(...d),u.map(p=>e.startsWith("/")&&p===""?"/":p)}function A5(e){e.sort((n,s)=>n.score!==s.score?s.score-n.score:O5(n.routesMeta.map(a=>a.childrenIndex),s.routesMeta.map(a=>a.childrenIndex)))}const T5=/^:[\w-]+$/,L5=3,R5=2,I5=1,P5=10,F5=-2,P0=e=>e==="*";function D5(e,n){let s=e.split("/"),a=s.length;return s.some(P0)&&(a+=F5),n&&(a+=R5),s.filter(o=>!P0(o)).reduce((o,l)=>o+(T5.test(l)?L5:l===""?I5:P5),a)}function O5(e,n){return e.length===n.length&&e.slice(0,-1).every((a,o)=>a===n[o])?e[e.length-1]-n[n.length-1]:0}function $5(e,n,s){let{routesMeta:a}=e,o={},l="/",d=[];for(let u=0;u<a.length;++u){let p=a[u],h=u===a.length-1,f=l==="/"?n:n.slice(l.length)||"/",g=Mp({path:p.relativePath,caseSensitive:p.caseSensitive,end:h},f),b=p.route;if(!g)return null;Object.assign(o,g.params),d.push({params:o,pathname:Hs([l,g.pathname]),pathnameBase:q5(Hs([l,g.pathnameBase])),route:b}),g.pathnameBase!=="/"&&(l=Hs([l,g.pathnameBase]))}return d}function Mp(e,n){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[s,a]=M5(e.path,e.caseSensitive,e.end),o=n.match(s);if(!o)return null;let l=o[0],d=l.replace(/(.)\/+$/,"$1"),u=o.slice(1);return{params:a.reduce((h,f,g)=>{let{paramName:b,isOptional:v}=f;if(b==="*"){let w=u[g]||"";d=l.slice(0,l.length-w.length).replace(/(.)\/+$/,"$1")}const N=u[g];return v&&!N?h[b]=void 0:h[b]=(N||"").replace(/%2F/g,"/"),h},{}),pathname:l,pathnameBase:d,pattern:e}}function M5(e,n,s){n===void 0&&(n=!1),s===void 0&&(s=!0),Pf(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 a=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,u,p)=>(a.push({paramName:u,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(a.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,n?void 0:"i"),a]}function B5(e){try{return e.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return Pf(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+n+").")),e}}function Ta(e,n){if(n==="/")return e;if(!e.toLowerCase().startsWith(n.toLowerCase()))return null;let s=n.endsWith("/")?n.length-1:n.length,a=e.charAt(s);return a&&a!=="/"?null:e.slice(s)||"/"}const U5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,z5=e=>U5.test(e);function W5(e,n){n===void 0&&(n="/");let{pathname:s,search:a="",hash:o=""}=typeof e=="string"?$a(e):e,l;if(s)if(z5(s))l=s;else{if(s.includes("//")){let d=s;s=qv(s),Pf(!1,"Pathnames cannot have embedded double slashes - normalizing "+(d+" -> "+s))}s.startsWith("/")?l=F0(s.substring(1),"/"):l=F0(s,n)}else l=n;return{pathname:l,search:V5(a),hash:Y5(o)}}function F0(e,n){let s=n.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?s.length>1&&s.pop():o!=="."&&s.push(o)}),s.length>1?s.join("/"):"/"}function zm(e,n,s,a){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+n+"` field ["+JSON.stringify(a)+"].  Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function H5(e){return e.filter((n,s)=>s===0||n.route.path&&n.route.path.length>0)}function Ff(e,n){let s=H5(e);return n?s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase):s.map(a=>a.pathnameBase)}function Df(e,n,s,a){a===void 0&&(a=!1);let o;typeof e=="string"?o=$a(e):(o=Zi({},e),nt(!o.pathname||!o.pathname.includes("?"),zm("?","pathname","search",o)),nt(!o.pathname||!o.pathname.includes("#"),zm("#","pathname","hash",o)),nt(!o.search||!o.search.includes("#"),zm("#","search","hash",o)));let l=e===""||o.pathname==="",d=l?"/":o.pathname,u;if(d==null)u=s;else{let g=n.length-1;if(!a&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),g-=1;o.pathname=b.join("/")}u=g>=0?n[g]:"/"}let p=W5(o,u),h=d&&d!=="/"&&d.endsWith("/"),f=(l||d===".")&&s.endsWith("/");return!p.pathname.endsWith("/")&&(h||f)&&(p.pathname+="/"),p}const qv=e=>e.replace(/\/\/+/g,"/"),Hs=e=>qv(e.join("/")),q5=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),V5=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Y5=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function G5(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Vv=["post","put","patch","delete"];new Set(Vv);const K5=["get",...Vv];new Set(K5);/**
50 * React Router v6.30.4
51 *
52 * Copyright (c) Remix Software Inc.
53 *
54 * This source code is licensed under the MIT license found in the
55 * LICENSE.md file in the root directory of this source tree.
56 *
57 * @license MIT
58 */function eo(){return eo=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var a in s)({}).hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},eo.apply(null,arguments)}const id=x.createContext(null),Yv=x.createContext(null),bs=x.createContext(null),od=x.createContext(null),Qn=x.createContext({outlet:null,matches:[],isDataRoute:!1}),Gv=x.createContext(null);function Q5(e,n){let{relative:s}=n===void 0?{}:n;Ma()||nt(!1);let{basename:a,navigator:o}=x.useContext(bs),{hash:l,pathname:d,search:u}=ld(e,{relative:s}),p=d;return a!=="/"&&(p=d==="/"?a:Hs([a,d])),o.createHref({pathname:p,search:u,hash:l})}function Ma(){return x.useContext(od)!=null}function vn(){return Ma()||nt(!1),x.useContext(od).location}function Kv(e){x.useContext(bs).static||x.useLayoutEffect(e)}function Xe(){let{isDataRoute:e}=x.useContext(Qn);return e?u_():J5()}function J5(){Ma()||nt(!1);let e=x.useContext(id),{basename:n,future:s,navigator:a}=x.useContext(bs),{matches:o}=x.useContext(Qn),{pathname:l}=vn(),d=JSON.stringify(Ff(o,s.v7_relativeSplatPath)),u=x.useRef(!1);return Kv(()=>{u.current=!0}),x.useCallback(function(h,f){if(f===void 0&&(f={}),!u.current)return;if(typeof h=="number"){a.go(h);return}let g=Df(h,JSON.parse(d),l,f.relative==="path");e==null&&n!=="/"&&(g.pathname=g.pathname==="/"?n:Hs([n,g.pathname])),(f.replace?a.replace:a.push)(g,f.state,f)},[n,a,d,l,e])}const X5=x.createContext(null);function Z5(e){let n=x.useContext(Qn).outlet;return n&&x.createElement(X5.Provider,{value:e},n)}function Pr(){let{matches:e}=x.useContext(Qn),n=e[e.length-1];return n?n.params:{}}function ld(e,n){let{relative:s}=n===void 0?{}:n,{future:a}=x.useContext(bs),{matches:o}=x.useContext(Qn),{pathname:l}=vn(),d=JSON.stringify(Ff(o,a.v7_relativeSplatPath));return x.useMemo(()=>Df(e,JSON.parse(d),l,s==="path"),[e,d,l,s])}function e_(e,n){return t_(e,n)}function t_(e,n,s,a){Ma()||nt(!1);let{navigator:o}=x.useContext(bs),{matches:l}=x.useContext(Qn),d=l[l.length-1],u=d?d.params:{};d&&d.pathname;let p=d?d.pathnameBase:"/";d&&d.route;let h=vn(),f;if(n){var g;let k=typeof n=="string"?$a(n):n;p==="/"||(g=k.pathname)!=null&&g.startsWith(p)||nt(!1),f=k}else f=h;let b=f.pathname||"/",v=b;if(p!=="/"){let k=p.replace(/^\//,"").split("/");v="/"+b.replace(/^\//,"").split("/").slice(k.length).join("/")}let N=C5(e,{pathname:v}),w=i_(N&&N.map(k=>Object.assign({},k,{params:Object.assign({},u,k.params),pathname:Hs([p,o.encodeLocation?o.encodeLocation(k.pathname).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?p:Hs([p,o.encodeLocation?o.encodeLocation(k.pathnameBase).pathname:k.pathnameBase])})),l,s,a);return n&&w?x.createElement(od.Provider,{value:{location:eo({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:Ws.Pop}},w):w}function n_(){let e=d_(),n=G5(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),s=e instanceof Error?e.stack:null,o={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return x.createElement(x.Fragment,null,x.createElement("h2",null,"Unexpected Application 
58Error!"),x.createElement("h3",{style:{fontStyle:"italic"}},n),s?x.createElement("pre",{style:o},s):null,null)}const s_=x.createElement(n_,null);class r_ extends x.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){console.error("React Router caught the following error during render",n,s)}render(){return this.state.error!==void 0?x.createElement(Qn.Provider,{value:this.props.routeContext},x.createElement(Gv.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function a_(e){let{routeContext:n,match:s,children:a}=e,o=x.useContext(id);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),x.createElement(Qn.Provider,{value:n},a)}function i_(e,n,s,a){var o;if(n===void 0&&(n=[]),s===void 0&&(s=null),a===void 0&&(a=null),e==null){var l;if(!s)return null;if(s.errors)e=s.matches;else if((l=a)!=null&&l.v7_partialHydration&&n.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let d=e,u=(o=s)==null?void 0:o.errors;if(u!=null){let f=d.findIndex(g=>g.route.id&&(u==null?void 0:u[g.route.id])!==void 0);f>=0||nt(!1),d=d.slice(0,Math.min(d.length,f+1))}let p=!1,h=-1;if(s&&a&&a.v7_partialHydration)for(let f=0;f<d.length;f++){let g=d[f];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(h=f),g.route.id){let{loaderData:b,errors:v}=s,N=g.route.loader&&b[g.route.id]===void 0&&(!v||v[g.route.id]===void 0);if(g.route.lazy||N){p=!0,h>=0?d=d.slice(0,h+1):d=[d[0]];break}}}return d.reduceRight((f,g,b)=>{let v,N=!1,w=null,k=null;s&&(v=u&&g.route.id?u[g.route.id]:void 0,w=g.route.errorElement||s_,p&&(h<0&&b===0?(m_("route-fallback"),N=!0,k=null):h===b&&(N=!0,k=g.route.hydrateFallbackElement||null)));let _=n.concat(d.slice(0,b+1)),S=()=>{let T;return v?T=w:N?T=k:g.route.Component?T=x.createElement(g.route.Component,null):g.route.element?T=g.route.element:T=f,x.createElement(a_,{match:g,routeContext:{outlet:f,matches:_,isDataRoute:s!=null},children:T})};return s&&(g.route.ErrorBoundary||g.route.errorElement||b===0)?x.createElement(r_,{location:s.location,revalidation:s.revalidation,component:w,error:v,children:S(),routeC
58ontext:{outlet:null,matches:_,isDataRoute:!0}}):S()},null)}var Qv=(function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e})(Qv||{}),Jv=(function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e})(Jv||{});function o_(e){let n=x.useContext(id);return n||nt(!1),n}function l_(e){let n=x.useContext(Yv);return n||nt(!1),n}function c_(e){let n=x.useContext(Qn);return n||nt(!1),n}function Xv(e){let n=c_(),s=n.matches[n.matches.length-1];return s.route.id||nt(!1),s.route.id}function d_(){var e;let n=x.useContext(Gv),s=l_(),a=Xv();return n!==void 0?n:(e=s.errors)==null?void 0:e[a]}function u_(){let{router:e}=o_(Qv.UseNavigateStable),n=Xv(Jv.UseNavigateStable),s=x.useRef(!1);return Kv(()=>{s.current=!0}),x.useCallback(function(o,l){l===void 0&&(l={}),s.current&&(typeof o=="number"?e.navigate(o):e.navigate(o,eo({fromRouteId:n},l)))},[e,n])}const D0={};function m_(e,n,s){D0[e]||(D0[e]=!0)}function p_(e,n){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Pn(e){let{to:n,replace:s,state:a,relative:o}=e;Ma()||nt(!1);let{future:l,static:d}=x.useContext(bs),{matches:u}=x.useContext(Qn),{pathname:p}=vn(),h=Xe(),f=Df(n,Ff(u,l.v7_relativeSplatPath),p,o==="path"),g=JSON.stringify(f);return x.useEffect(()=>h(JSON.parse(g),{replace:s,state:a,relative:o}),[h,g,o,s,a]),null}function Zv(e){return Z5(e.context)}function ye(e){nt(!1)}function f_(e){let{basename:n="/",children:s=null,location:a,navigationType:o=Ws.Pop,navigator:l,static:d=!1,future:u}=e;Ma()&&nt(!1);let p=n.replace(/^\/*/,"/"),h=x.useMemo(()=>({basename:p,navigator:l,static:d,future:eo({v7_relativeSplatPath:!1},u)}),[p,u,l,d]);typeof a=="string"&&(a=$a(a));let{pathname:f="/",search:g="",hash:b="",state:v=null,key:N="default"}=a,w=x.useMemo(()=>{let k=Ta(f,p);return k==null?null:{location:{pathname:k,search:g,hash:b,state:v,key:N},navigationType:o}},[p,f,g,b,v,N,o]);return w==null?null:x.createElement(bs.Provider,{value:h},x.createElement(od.Provider,{children:s,value:w}))}function h_(e){let{children:n,location:s}=e;return e_(Bp(n),s)}new Promise(()=>{});function Bp(e,n){n===void 0&&(n=[]);let s=[];return x.Children.forEach(e,(a,o)=>{if(!x.isValidElement(a))return;let l=[...n,o];if(a.type===x.Fragment){s.push.apply(s,Bp(a.props.children,l));return}a.type!==ye&&nt(!1),!a.props.index||!a.props.children||nt(!1);let d={id:a.props.id||l.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,loader:a.props.loader,action:a.props.action,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(d.children=Bp(a.props.children,l)),s.push(d)}),s}/**
59 * React Router DOM v6.30.4
60 *
61 * Copyright (c) Remix Software Inc.
62 *
63 * This source code is licensed under the MIT license found in the
64 * LICENSE.md file in the root directory of this source tree.
65 *
66 * @license MIT
67 */function Tc(){return Tc=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var a in s)({}).hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},Tc.apply(null,arguments)}function ej(e,n){if(e==null)return{};var s={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(n.indexOf(a)!==-1)continue;s[a]=e[a]}return s}function x_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function g_(e,n){return e.button===0&&(!n||n==="_self")&&!x_(e)}function Up(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((n,s)=>{let a=e[s];return n.concat(Array.isArray(a)?a.map(o=>[s,o]):[[s,a]])},[]))}function y_(e,n){let s=Up(e);
67return n&&n.forEach((a,o)=>{s.has(o)||n.getAll(o).forEach(l=>{s.append(o,l)})}),s}const b_=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],v_=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],j_="6";try{window.__reactRouterVersion=j_}catch{}const w_=x.createContext({isTransitioning:!1}),N_="startTransition",O0=g5[N_];function __(e){let{basename:n,children:s,future:a,window:o}=e,l=x.useRef();l.current==null&&(l.current=_5({window:o,v5Compat:!0}));let d=l.current,[u,p]=x.useState({action:d.action,location:d.location}),{v7_startTransition:h}=a||{},f=x.useCallback(g=>{h&&O0?O0(()=>p(g)):p(g)},[p,h]);return x.useLayoutEffect(()=>d.listen(f),[d,f]),x.useEffect(()=>p_(a),[a]),x.createElement(f_,{basename:n,children:s,location:u.location,navigationType:u.action,navigator:d,future:a})}const k_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",S_=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,be=x.forwardRef(function(n,s){let{onClick:a,relative:o,reloadDocument:l,replace:d,state:u,target:p,to:h,preventScrollReset:f,viewTransition:g}=n,b=ej(n,b_),{basename:v}=x.useContext(bs),N,w=!1;if(typeof h=="string"&&S_.test(h)&&(N=h,k_))try{let T=new URL(window.location.href),E=h.startsWith("//")?new URL(T.protocol+h):new URL(h),A=Ta(E.pathname,v);E.origin===T.origin&&A!=null?h=A+E.search+E.hash:w=!0}catch{}let k=Q5(h,{relative:o}),_=E_(h,{replace:d,state:u,target:p,preventScrollReset:f,relative:o,viewTransition:g});function S(T){a&&a(T),T.defaultPrevented||_(T)}return x.createElement("a",Tc({},b,{href:N||k,onClick:w||l?a:S,ref:s,target:p}))}),Fe=x.forwardRef(function(n,s){let{"aria-current":a="page",caseSensitive:o=!1,className:l="",end:d=!1,style:u,to:p,viewTransition:h,children:f}=n,g=ej(n,v_),b=ld(p,{relative:g.relative}),v=vn(),N=x.useContext(Yv),{navigator:w,basename:k}=x.useContext(bs),_=N!=null&&A_(b)&&h===!0,S=w.encodeLocation?w.encodeLocation(b).pathname:b.pathname,T=v.pathname,E=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;o||(T=T.toLowerCase(),E=E?E.toLowerCase():null,S=S.toLowerCase()),E&&k&&(E=Ta(E,k)||E);const A=S!=="/"&&S.endsWith("/")?S.length-1:S.length;let I=T===S||!d&&T.startsWith(S)&&T.charAt(A)==="/",R=E!=null&&(E===S||!d&&E.startsWith(S)&&E.charAt(S.length)==="/"),W={isActive:I,isPending:R,isTransitioning:_},Y=I?a:void 0,K;typeof l=="function"?K=l(W):K=[l,I?"active":null,R?"pending":null,_?"transitioning":null].filter(Boolean).join(" ");let X=typeof u=="function"?u(W):u;return x.createElement(be,Tc({},g,{"aria-current":Y,className:K,ref:s,style:X,to:p,viewTransition:h}),typeof f=="function"?f(W):f)});var zp;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(zp||(zp={}));var $0;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})($0||($0={}));function C_(e){let n=x.useContext(id);return n||nt(!1),n}function E_(e,n){let{target:s,replace:a,state:o,preventScrollReset:l,relative:d,viewTransition:u}=n===void 0?{}:n,p=Xe(),h=vn(),f=ld(e,{relative:d});return x.useCallback(g=>{if(g_(g,s)){g.preventDefault();let b=a!==void 0?a:Ac(h)===Ac(f);p(e,{replace:b,state:o,preventScrollReset:l,relative:d,viewTransition:u})}},[h,p,f,a,o,s,e,l,d,u])}function Jn(e){let n=x.useRef(Up(e)),s=x.useRef(!1),a=vn(),o=x.useMemo(()=>y_(a.search,s.current?null:n.current),[a.search]),l=Xe(),d=x.useCallback((u,p)=>{const h=Up(typeof u=="function"?u(o):u);s.current=!0,l("?"+h,p)},[l,o]);return[o,d]}function A_(e,n){n===void 0&&(n={});let s=x.useContext(w_);s==null&&nt(!1);let{basename:a}=C_(zp.useViewTransitionState),o=ld(e,{relative:n.relative});if(!s.isTransitioning)return!1;let l=Ta(s.currentLocation.pathname,a)||s.currentLocation.pathname,d=Ta(s.nextLocation.pathname,a)||s.nextLocation.pathname;return Mp(o.pathname,d)!=null||Mp(o.pathname,l)!=null}var Wm={exports:{}},Hm={};/**
68 * @license React
69 * use-sync-external-store-with-selector.production.js
70 *
71 * Copyright (c) Meta Platforms, Inc. and affiliates.
72 *
73 * This source code is licensed under the MIT license found in the
74 * LICENSE file in the root directory of this source tree.
75 */var M0;
75function T_(){if(M0)return Hm;M0=1;var e=ad();function n(p,h){return p===h&&(p!==0||1/p===1/h)||p!==p&&h!==h}var s=typeof Object.is=="function"?Object.is:n,a=e.useSyncExternalStore,o=e.useRef,l=e.useEffect,d=e.useMemo,u=e.useDebugValue;return Hm.useSyncExternalStoreWithSelector=function(p,h,f,g,b){var v=o(null);if(v.current===null){var N={hasValue:!1,value:null};v.current=N}else N=v.current;v=d(function(){function k(A){if(!_){if(_=!0,S=A,A=g(A),b!==void 0&&N.hasValue){var I=N.value;if(b(I,A))return T=I}return T=A}if(I=T,s(S,A))return I;var R=g(A);return b!==void 0&&b(I,R)?(S=A,I):(S=A,T=R)}var _=!1,S,T,E=f===void 0?null:f;return[function(){return k(h())},E===null?void 0:function(){return k(E())}]},[h,f,g,b]);var w=a(p,v[0],v[1]);return l(function(){N.hasValue=!0,N.value=w},[w]),u(w),w},Hm}var B0;function L_(){return B0||(B0=1,Wm.exports=T_()),Wm.exports}var R_=L_();function I_(e){e()}function P_(){let e=null,n=null;return{clear(){e=null,n=null},notify(){I_(()=>{let s=e;for(;s;)s.callback(),s=s.next})},get(){const s=[];let a=e;for(;a;)s.push(a),a=a.next;return s},subscribe(s){let a=!0;const o=n={callback:s,next:null,prev:n};return o.prev?o.prev.next=o:e=o,function(){!a||e===null||(a=!1,o.next?o.next.prev=o.prev:n=o.prev,o.prev?o.prev.next=o.next:e=o.next)}}}}var U0={notify(){},get:()=>[]};function F_(e,n){let s,a=U0,o=0,l=!1;function d(w){f();const k=a.subscribe(w);let _=!1;return()=>{_||(_=!0,k(),g())}}function u(){a.notify()}function p(){N.onStateChange&&N.onStateChange()}function h(){return l}function f(){o++,s||(s=e.subscribe(p),a=P_())}function g(){o--,s&&o===0&&(s(),s=void 0,a.clear(),a=U0)}function b(){l||(l=!0,f())}function v(){l&&(l=!1,g())}const N={addNestedSub:d,notifyNestedSubs:u,handleChangeWrapper:p,isSubscribed:h,trySubscribe:b,tryUnsubscribe:v,getListeners:()=>a};return N}var D_=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",O_=D_(),$_=()=>typeof navigator<"u"&&navigator.product==="ReactNative",M_=$_(),B_=()=>O_||M_?x.useLayoutEffect:x.useEffect,U_=B_(),qm=Symbol.for("react-redux-context"),Vm=typeof globalThis<"u"?globalThis:{};function z_(){if(!x.createContext)return{};const e=Vm[qm]??(Vm[qm]=new Map);let n=e.get(x.createContext);return n||(n=x.createContext(null),e.set(x.createContext,n)),n}var qs=z_();function W_(e){const{children:n,context:s,serverState:a,store:o}=e,l=x.useMemo(()=>{const p=F_(o);return{store:o,subscription:p,getServerState:a?()=>a:void 0}},[o,a]),d=x.useMemo(()=>o.getState(),[o]);U_(()=>{const{subscription:p}=l;return p.onStateChange=p.notifyNestedSubs,p.trySubscribe(),d!==o.getState()&&p.notifyNestedSubs(),()=>{p.tryUnsubscribe(),p.onStateChange=void 0}},[l,d]);const u=s||qs;return x.createElement(u.Provider,{value:l},n)}var H_=W_;function Of(e=qs){return function(){return x.useContext(e)}}var tj=Of();function nj(e=qs){const n=e===qs?tj:Of(e),s=()=>{const{store:a}=n();return a};return Object.assign(s,{withTypes:()=>s}),s}var q_=nj();function V_(e=qs){const n=e===qs?q_:nj(e),s=()=>n().dispatch;return Object.assign(s,{withTypes:()=>s}),s}var Ba=V_(),Y_=(e,n)=>e===n;function G_(e=qs){const n=e===qs?tj:Of(e),s=(a,o={})=>{const{equalityFn:l=Y_}=typeof o=="function"?{equalityFn:o}:o,d=n(),{store:u,subscription:p,getServerState:h}=d;x.useRef(!0);const f=x.useCallback({[a.name](b){return a(b)}}[a.name],[a]),g=R_.useSyncExternalStoreWithSelector(p.addNestedSub,u.getState,h||u.getState,f,l);return x.useDebugValue(g),g};return Object.assign(s,{withTypes:()=>s}),s}var ht=G_();const Ie=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Ue=globalThis,Nr="10.53.1";function cd(){return dd(Ue),Ue}function dd(e){const n=e.__SENTRY__=e.__SENTRY__||{};return n.version=n.version||Nr,n[Nr]=n[Nr]||{}}function Ua(e,n,s=Ue){const a=s.__SENTRY__=s.__SENTRY__||{},o=a[Nr]=a[Nr]||{};return o[e]||(o[e]=n())}const K_=["debug","info","warn","error","log","assert","trace"],Q_="Sentry Logger ",Lc={};function za(e){if(!("console"in Ue))return e();const n=Ue.console,s={},a=Object.keys(Lc);a.forEach(o=>{const l=Lc[o];s[o]=n[o],n[o]=l});try{return e()}finally{a.forEach(o=>{n[o]=s[o]})}}function J_(){Mf().enabled=!0}function X_(){Mf().enabled=!1}function sj(){return Mf().enabled}function Z_(...e){$f("log",...e)}function ek(...e){$f("warn",...e)}function tk(...e){$f("error",...e)}function $f(e,...n){Ie&&sj()&&za(()=>{Ue.console[e](`${Q_}[${e}]:`,...n)})}function Mf(){return Ie?Ua("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Ae={enable:J_,disable:X_,isEnabled:sj,log:Z_,warn:ek,error:tk},rj=50,Cr="?",z0=/\(error: (.*)\)/,W0=/captureMessage|captureException/;function aj(...e){const n=e.sort((s,a)=>s[0]-a[0]).map(s=>s[1]);return(s,a=0,o=0)=>{const l=[],d=s.split(`
76`);for(let u=a;u<d.length;u++){let p=d[u];p.length>1024&&(p=p.slice(0,1024));const h=z0.test(p)?p.replace(z0,"$1"):p;if(!h.includes("Error: ")){for(const f of n){const g=f(h);if(g){l.push(g);break}}if(l.length>=rj+o)break}}return sk(l.slice(o))}}function nk(e){return Array.isArray(e)?aj(...e):e}function sk(e){if(!e.length)return[];const n=Array.from(e);return/sentryWrapped/.test(Wl(n).function||"")&&n.pop(),n.reverse(),W0.test(Wl(n).function||"")&&(n.pop(),W0.test(Wl(n).function||"")&&n.pop()),n.slice(0,rj).map(s=>({...s,filename:s.filename||Wl(n).filename,function:s.function||Cr}))}function Wl(e){return e[e.length-1]||{}}const Ym="<anonymous>";function Vs(e){try{return!e||typeof e!="function"?Ym:e.name||Ym}catch{return Ym}}function H0(e){const n=e.exception;if(n){const s=[];
vendor: 4,588 bytes, lines 76-79
76try{return n.values.forEach(a=>{a.stacktrace.frames&&s.push(...a.stacktrace.frames)}),s}catch{return}}}function ij(e){return"__v_isVNode"in e&&e.__v_isVNode?"[VueVNode]":"[VueViewModel]"}const qi={},q0={};function Fr(e,n){return qi[e]=qi[e]||[],qi[e].push(n),()=>{const s=qi[e];if(s){const a=s.indexOf(n);a!==-1&&s.splice(a,1)}}}function Dr(e,n){if(!q0[e]){q0[e]=!0;try{n()}catch(s){Ie&&Ae.error(`Error while instrumenting ${e}`,s)}}}function Dn(e,n){const s=e&&qi[e];if(s)for(const a of s)try{a(n)}catch(o){Ie&&Ae.error(`Error while triggering instrumentation handler.
77Type: ${e}
78Name: ${Vs(a)}
79Error:`,o)}}let Gm=null;function rk(e){const n="error";Fr(n,e),Dr(n,ak)}function ak(){Gm=Ue.onerror,Ue.onerror=function(e,n,s,a,o){return Dn("error",{column:a,error:o,line:s,msg:e,url:n}),Gm?Gm.apply(this,arguments):!1},Ue.onerror.__SENTRY_INSTRUMENTED__=!0}let Km=null;function ik(e){const n="unhandledrejection";Fr(n,e),Dr(n,ok)}function ok(){Km=Ue.onunhandledrejection,Ue.onunhandledrejection=function(e){return Dn("unhandledrejection",e),Km?Km.apply(this,arguments):!0},Ue.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const oj=Object.prototype.toString;function ud(e){switch(oj.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return Ys(e,Error)}}function Wa(e,n){return oj.call(e)===`[object ${n}]`}function lj(e){return Wa(e,"ErrorEvent")}function V0(e){return Wa(e,"DOMError")}function lk(e){return Wa(e,"DOMException")}function ps(e){return Wa(e,"String")}function Bf(e){return typeof e=="object"&&e!==null&&"__sentry_template_string__"in e&&"__sentry_template_values__"in e}function md(e){return e===null||Bf(e)||typeof e!="object"&&typeof e!="function"}function to(e){return Wa(e,"Object")}function pd(e){return typeof Event<"u"&&Ys(e,Event)}function ck(e){return typeof Element<"u"&&Ys(e,Element)}function dk(e){return Wa(e,"RegExp")}function po(e){return!!(e!=null&&e.then&&typeof e.then=="function")}function uk(e){return to(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}function Ys(e,n){try{return e instanceof n}catch{return!1}}function cj(e){return!!(typeof e=="object"&&e!==null&&(e.__isVue||e._isVue||e.__v_isVNode))}function dj(e){return typeof Request<"u"&&Ys(e,Request)}const Uf=Ue,mk=80;function uj(e,n={}){if(!e)return"<unknown>";try{let s=e;const a=5,o=[];let l=0,d=0;const u=" > ",p=u.length;let h;const f=Array.isArray(n)?n:n.keyAttrs,g=!Array.isArray(n)&&n.maxStringLength||mk;for(;s&&l++<a&&(h=pk(s,f),!(h==="html"||l>1&&d+o.length*p+h.length>=g));)o.push(h),d+=h.length,s=s.parentNode;return o.reverse().join(u)}catch{return"<unknown>"}}function pk(e,n){const s=e,a=[];if(!(s!=null&&s.tagName))return"";if(Uf.HTMLElement&&s instanceof HTMLElement&&s.dataset){if(s.dataset.sentryComponent)return s.dataset.sentryComponent;if(s.dataset.sentryElement)return s.dataset.sentryElement}a.push(s.tagName.toLowerCase());const o=n!=null&&n.length?n.filter(l=>s.getAttribute(l)).map(l=>[l,s.getAttribute(l)]):null;if(o!=null&&o.length)o.forEach(l=>{a.push(`[${l[0]}="${l[1]}"]`)});else{s.id&&a.push(`#${s.id}`);const l=s.className;if(l&&ps(l)){const d=l.split(/\s+/);for(const u of d)a.push(`.${u}`)}}for(const l of["aria-label","type","name","title","alt"]){const d=s.getAttribute(l);d&&a.push(`[${l}="${d}"]`)}return a.join("")}function zf(){try{return Uf.document.location.href}catch{return""}}function fk(e,n=5){if(!Uf.HTMLElement)return null;let s=e;for(let a=0;a<n;a++){if(!s)return null;if(s instanceof HTMLElement){if(s.dataset.sentryComponent)return s.dataset.sentryComponent;if(s.dataset.sentryElement)return s.dataset.sentryElement}s=s.parentNode}return null}function sn(e,n,s){if(!(n in e))return;const a=e[n];if(typeof a!="function")return;const o=s(a);typeof o=="function"&&mj(o,a);try{e[n]=o}catch{Ie&&Ae.log(`Failed to replace method "${n}" in object`,e)}}function Gs(e,n,s){try{Object.defineProperty(e,n,{value:s,writable:!0,configurable:!0})}catch{Ie&&Ae.log(`Failed to add non-enumerable property "${String(n)}" to object`,e)}}function mj(e,n){try{const s=n.prototype||{};e.prototype=n.prototype=s,Gs(e,"__sentry_original__",n)}catch{}}function Wf(e){return e.__sentry_original__}function pj(e){if(ud(e))return{message:e.message,name:e.name,stack:e.stack,...G0(e)};if(pd(e)){const n={type:e.type,target:Y0(e.target),currentTarget:Y0(e.currentTarget),...G0(e)};return typeof CustomEvent<"u"&&Ys(e,CustomEvent)&&(n.detail=e.detail),n}else return e}function Y0(e){try{return ck(e)?uj(e):Object.prototype.toString.call(e)}catch{return"<unknown>"}}
79function G0(e){return typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e)):{}}function hk(e){const n=Object.keys(pj(e));return n.sort(),n[0]?n.join(", "):"[object has no keys]"}let ha;function fd(e){if(ha!==void 0)return ha?ha(e):e();const n=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),s=Ue;return n in s&&typeof s[n]=="function"?(ha=s[n],ha(e)):(ha=null,e())}function Rc(){return fd(()=>Math.random())}function hd(){return fd(()=>Date.now())}function Wp(e,n=0){return typeof e!="string"||n===0||e.length<=n?e:`${e.slice(0,n)}...`}function K0(e,n){if(!Array.isArray(e))return"";const s=[];for(let a=0;a<e.length;a++){const o=e[a];try{cj(o)?s.push(ij(o)):s.push(String(o))}catch{s.push("[value cannot be serialized]")}}return s.join(n)}function Ki(e,n,s=!1){return ps(e)?dk(n)?n.test(e):ps(n)?s?e===n:e.includes(n):typeof n=="function"?n(e):!1:!1}function fo(e,n=[],s=!1){for(const a of n)if(Ki(e,a,s))return!0;return!1}function xk(){const e=Ue;return e.crypto||e.msCrypto}let Qm;function gk(){return Rc()*16}function gn(e=xk()){try{if(e!=null&&e.randomUUID)return fd(()=>e.randomUUID()).replace(/-/g,"")}catch{}return Qm||(Qm="10000000100040008000"+1e11),Qm.replace(/[018]/g,n=>(n^(gk()&15)>>n/4).toString(16))}function fj(e){var n,s;return(s=(n=e.exception)==null?void 0:n.values)==null?void 0:s[0]}function yr(e){const{message:n,event_id:s}=e;if(n)return n;const a=fj(e);return a?a.type&&a.value?`${a.type}: ${a.value}`:a.type||a.value||s||"<unknown>":s||"<unknown>"}function Hp(e,n,s){const a=e.exception=e.exception||{},o=a.values=a.values||[],l=o[0]=o[0]||{};l.value||(l.value=n||""),l.type||(l.type="Error")}function La(e,n){const s=fj(e);if(!s)return;const a={type:"generic",handled:!0},o=s.mechanism;if(s.mechanism={...a,...o,...n},n&&"data"in n){const l={...o==null?void 0:o.data,...n.data};s.mechanism.data=l}}function Q0(e){if(yk(e))return!0;try{Gs(e,"__sentry_captured__",!0)}catch{}return!1}function yk(e){try{return e.__sentry_captured__}catch{}}const hj=1e3;function ho(){return hd()/hj}function bk(){const{performance:e}=Ue;if(!(e!=null&&e.now)||!e.timeOrigin)return ho;const n=e.timeOrigin;return()=>(n+fd(()=>e.now()))/hj}let J0;function fs(){return(J0??(J0=bk()))()}function vk(e){const n=fs(),s={sid:gn(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>wk(s)};return e&&Ra(s,e),s}function Ra(e,n={}){if(n.user&&(!e.ipAddress&&n.user.ip_address&&(e.ipAddress=n.user.ip_address),!e.did&&!n.did&&(e.did=n.user.id||n.user.email||n.user.username)),e.timestamp=n.timestamp||fs(),n.abnormal_mechanism&&(e.abnormal_mechanism=n.abnormal_mechanism),n.ignoreDuration&&(e.ignoreDuration=n.ignoreDuration),n.sid&&(e.sid=n.sid.length===32?n.sid:gn()),n.init!==void 0&&(e.init=n.init),!e.did&&n.did&&(e.did=`${n.did}`),typeof n.started=="number"&&(e.started=n.started),e.ignoreDuration)e.duration=void 0;else if(typeof n.duration=="number")e.duration=n.duration;else{const s=e.timestamp-e.started;e.duration=s>=0?s:0}n.release&&(e.release=n.release),n.environment&&(e.environment=n.environment),!e.ipAddress&&n.ipAddress&&(e.ipAddress=n.ipAddress),!e.userAgent&&n.userAgent&&(e.userAgent=n.userAgent),typeof n.errors=="number"&&(e.errors=n.errors),n.status&&(e.status=n.status)}function jk(e,n){let s={};e.status==="ok"&&(s={status:"exited"}),Ra(e,s)}function wk(e){return{sid:`${e.sid}`,init:e.init,started:new Date(e.started*1e3).toISOString(),timestamp:new Date(e.timestamp*1e3).toISOString(),status:e.status,errors:e.errors,did:typeof e.did=="number"||typeof e.did=="string"?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}function xo(e,n,s=2){if(!n||typeof n!="object"||s<=0)return n;if(e&&Object.keys(n).length===0)return e;const a={...e};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(a[o]=xo(a[o],n[o],s-1));return a}function X0(){return gn()}function xj(){return gn().substring(16)}const qp="_sentrySpan";function Z0(e,n){n?Gs(e,qp,n):delete e[qp]}function ey(e){return e[qp]}const Nk=100;class xs{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:X0(),sampleRand:Rc()}}clone(){const n=new xs;return n._breadcrumbs=[...this._breadcrumbs],n._tags={...this._tags},n._attributes={...this._attributes},n._extra={...this._extra},n._contexts={...this._contexts},this._contexts.flags&&(n._contexts.flags={values:[...this._contexts.flags.values]}),n._user=this._user,n._level=this._level,n._session=this._session,n._transactionName=this._transactionName,n._fingerprint=this._fingerprint,n._eventProcessors=[...this._eventProcessors],n._attachments=[...this._attachments],n._sdkProcessingMetadata={...this._sdkProcessingMetadata},n._propagationContext={...this._propagationContext},n._client=this._client,n._lastEventId=this._lastEventId,n._conversationId=this._conversationId,Z0(n,ey(this)),n}setClient(n){this._client=n}setLastEventId(n){this._lastEventId=n}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(n){this._scopeListeners.push(n)}addEventProcessor(n){return this._eventProcessors.push(n),this}setUser(n){return this._user=n||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&Ra(this._session,{user:n}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(n){return this._conversationId=n||void 0,this._notifyScopeListeners(),this}setTags(n){return this._tags={...this._tags,...n},this._notifyScopeListeners(),this}setTag(n,s){return this.setTags({[n]:s})}setAttributes(n){return this._attributes={...this._attributes,...n},this._notifyScopeListeners(),this}setAttribute(n,s){return this.setAttributes({[n]:s})}removeAttribute(n){return n in this._attributes&&(delete this._attributes[n],this._notifyScopeListeners()),this}setExtras(n){return this._extra={...this._extra,...n},this._notifyScopeListeners(),this}setExtra(n,s){return this._extra={...this._extra,[n]:s},this._notifyScopeListeners(),this}setFingerprint(n){return this._fingerprint=n,this._notifyScopeListeners(),this}setLevel(n){return this._level=n,this._notifyScopeListeners(),this}setTransactionName(n){return this._transactionName=n,this._notifyScopeListeners(),this}setContext(n,s){return s===null?delete this._contexts[n]:this._contexts[n]=s,this._notifyScopeListeners(),this}setSession(n){return n?this._session=n:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(n){if(!n)return this;const s=typeof n=="function"?n(this):n,a=s instanceof xs?s.getScopeData():to(s)?n:void 0,{tags:o,attributes:l,extra:d,user:u,contexts:p,level:h,fingerprint:f=[],propagationContext:g,conversationId:b}=a||{};return this._tags={...this._tags,...o},this._attributes={...this._attributes,...l},this._extra={...this._extra,...d},this._contexts={...this._contexts,...p},u&&Object.keys(u).length&&(this._user=u),h&&(this._level=h),f.length&&(this._fingerprint=f),g&&(this._propagationContext=g),b&&(this._conversationId=b),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,Z0(this,void 0),this._attachments=[],this.setPropagationContext({traceId:X0(),sampleRand:Rc()}),this._notifyScopeListeners(),this}addBreadcrumb(n,s){var l;const a=typeof s=="number"?s:Nk;if(a<=0)return this;const o={timestamp:ho(),...n,message:n.message?Wp(n.message,2048):n.message};return this._breadcrumbs.push(o),this._breadcrumbs.length>a&&(this._breadcrumbs=this._breadcrumbs.slice(-a),(l=this._client)==null||l.recordDroppedEvent("buffer_overflow","log_item")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(n){return this._attachments.push(n),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:ey(this),conversationId:this._conversationId}}setSDKProcessingMetadata(n){return this._sdkProcessingMetadata=xo(this._sdkProcessingMetadata,n,2),this}setPropagationContext(n){return this._propagationContext=n,this}getPropagationContext(){return this._propagationContext}captureException(n,s){const a=(s==null?void 0:s.event_id)||gn();if(!this._client)return Ie&&Ae.warn("No client configured on scope - will not capture exception!"),a;const o=new Error("Sentry syntheticException");return this._client.captureException(n,{originalException:n,syntheticException:o,...s,event_id:a},this),a}captureMessage(n,s,a){const o=(a==null?void 0:a.event_id)||gn();if(!this._client)return Ie&&Ae.warn("No client configured on scope - will not capture message!"),o;const l=(a==null?void 0:a.syntheticException)??new Error(n);return this._client.captureMessage(n,s,{originalException:n,syntheticException:l,...a,event_id:o},this),o}
79captureEvent(n,s){const a=n.event_id||(s==null?void 0:s.event_id)||gn();return this._client?(this._client.captureEvent(n,{...s,event_id:a},this),a):(Ie&&Ae.warn("No client configured on scope - will not capture event!"),a)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(n=>{n(this)}),this._notifyingListeners=!1)}}function _k(){return Ua("defaultCurrentScope",()=>new xs)}function kk(){return Ua("defaultIsolationScope",()=>new xs)}const ty=e=>e instanceof Promise&&!e[gj],gj=Symbol("chained PromiseLike"),Sk=(e,n,s)=>{const a=e.then(o=>(n(o),o),o=>{throw s(o),o});return ty(a)&&ty(e)?a:Ck(e,a)},Ck=(e,n)=>{if(!n)return e;let s=!1;for(const a in e){if(a in n)continue;s=!0;const o=e[a];typeof o=="function"?Object.defineProperty(n,a,{value:(...l)=>o.apply(e,l),enumerable:!0,configurable:!0,writable:!0}):n[a]=o}return s&&Object.assign(n,{[gj]:!0}),n};class Ek{constructor(n,s){let a;n?a=n:a=new xs;let o;s?o=s:o=new xs,this._stack=[{scope:a}],this._isolationScope=o}withScope(n){const s=this._pushScope();let a;try{a=n(s)}catch(o){throw this._popScope(),o}return po(a)?Sk(a,()=>this._popScope(),()=>this._popScope()):(this._popScope(),a)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const n=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:n}),n}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}}function Ia(){const e=cd(),n=dd(e);return n.stack=n.stack||new Ek(_k(),kk())}function Ak(e){return Ia().withScope(e)}function Tk(e,n){const s=Ia();return s.withScope(()=>(s.getStackTop().scope=e,n(e)))}function ny(e){return Ia().withScope(()=>e(Ia().getIsolationScope()))}function Lk(){return{withIsolationScope:ny,withScope:Ak,withSetScope:Tk,withSetIsolationScope:(e,n)=>ny(n),getCurrentScope:()=>Ia().getScope(),getIsolationScope:()=>Ia().getIsolationScope()}}function Hf(e){const n=dd(e);return n.acs?n.acs:Lk()}function Rk(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)&&Object.keys(e).includes("value")}function Ik(e,n){const{value:s,unit:a}=Rk(e)?e:{value:e,unit:void 0},o=Pk(s),l=a&&typeof a=="string"?{unit:a}:{};if(o)return{...o,...l};if(!n||n==="skip-undefined"&&s===void 0)return;let d="";try{d=JSON.stringify(s)??""}catch{}return{value:d,type:"string",...l}}function sy(e,n=!1){const s={};for(const[a,o]of Object.entries(e??{})){const l=Ik(o,n);l&&(s[a]=l)}return s}function Pk(e){const n=typeof e=="string"?"string":typeof e=="boolean"?"boolean":typeof e=="number"&&!Number.isNaN(e)?Number.isInteger(e)?"integer":"double":null;if(n)return{value:e,type:n}}function vs(){const e=cd();return Hf(e).getCurrentScope()}function Js(){const e=cd();return Hf(e).getIsolationScope()}function Fk(){return Ua("globalScope",()=>new xs)}function Dk(...e){const n=cd(),s=Hf(n);if(e.length===2){const[a,o]=e;return a?s.withSetScope(a,o):s.withScope(o)}return s.withScope(e[0])}function Pt(){return vs().getClient()}function Ok(e){const n=e.getPropagationContext(),{traceId:s,parentSpanId:a,propagationSpanId:o}=n,l={trace_id:s,span_id:o||xj()};return a&&(l.parent_span_id=a),l}const $k="sentry.source",Mk="sentry.sample_rate",Bk="sentry.previous_trace_sample_rate",Uk="sentry.op",zk="sentry.origin",yj="sentry.profile_id",bj="sentry.exclusive_time",Wk="gen_ai.conversation.id",Hk=0,qk=1;function Vk(e){if(e){if(typeof e=="object"&&"deref"in e&&typeof e.deref=="function")try{return e.deref()}catch{return}return e}}const Yk="_sentryScope",Gk="_sentryIsolationScope";function vj(e){const n=e;return{scope:n[Yk],isolationScope:Vk(n[Gk])}}const ry="sentry-";function Kk(e){const n=Qk(e);if(!n)return;const s=Object.entries(n).reduce((a,[o,l])=>{if(o.startsWith(ry)){const d=o.slice(ry.length);a[d]=l}return a},{});if(Object.keys(s).length>0)return s}function Qk(e){if(!(!e||!ps(e)&&!Array.isArray(e)))return Array.isArray(e)?e.reduce((n,s)=>{const a=ay(s);return Object.entries(a).forEach(([o,l])=>{n[o]=l}),n},{}):ay(e)}function ay(e){return e.split(",").map(n=>{const s=n.indexOf("=");if(s===-1)return[];const a=n.slice(0,s),o=n.slice(s+1);return[a,o].map(l=>{try{return decodeURIComponent(l.trim())}catch{return}})}).reduce((n,[s,a])=>(s&&a&&(n[s]=a),n),{})}const Jk=/^o(\d+)\./,Xk=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Zk(e){return e==="http"||e==="https"}function go(e,n=!1){const{host:s,path:a,pass:o,port:l,projectId:d,protocol:u,publicKey:p}=e;return`${u}://${p}${n&&o?`:${o}`:""}@${s}${l?`:${l}`:""}/${a&&`${a}/`}${d}`}function eS(e){const n=Xk.exec(e);if(!n){za(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});return}const[s,a,o="",l="",d="",u=""]=n.slice(1);let p="",h=u;const f=h.split("/");if(f.length>1&&(p=f.slice(0,-1).join("/"),h=f.pop()),h){const g=h.match(/^\d+/);g&&(h=g[0])}return jj({host:l,pass:o,path:p,projectId:h,port:d,protocol:s,publicKey:a})}function jj(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function tS(e){if(!Ie)return!0;const{port:n,projectId:s,protocol:a}=e;return["protocol","publicKey","host","projectId"].find(d=>e[d]?!1:(Ae.error(`Invalid Sentry Dsn: ${d} missing`),!0))?!1:s.match(/^\d+$/)?Zk(a)?n&&isNaN(parseInt(n,10))?(Ae.error(`Invalid Sentry Dsn: Invalid port ${n}`),!1):!0:(Ae.error(`Invalid Sentry Dsn: Invalid protocol ${a}`),!1):(Ae.error(`Invalid Sentry Dsn: Invalid projectId ${s}`),!1)}function nS(e){const n=e.match(Jk);return n==null?void 0:n[1]}function sS(e){const n=e.getOptions(),{host:s}=e.getDsn()||{};let a;return n.orgId?a=String(n.orgId):s&&(a=nS(s)),a}function rS(e){const n=typeof e=="string"?eS(e):jj(e);if(!(!n||!tS(n)))return n}function aS(e){if(typeof e=="boolean")return Number(e);const n=typeof e=="string"?parseFloat(e):e;if(!(typeof n!="number"||isNaN(n)||n<0||n>1))return n}const wj=1;let iy=!1;function iS(e){const{spanId:n,traceId:s,isRemote:a}=e.spanContext(),o=a?n:xd(e).parent_span_id,l=vj(e).scope,d=a?(l==null?void 0:l.getPropagationContext().propagationSpanId)||xj():n;return{parent_span_id:o,span_id:d,trace_id:s}}function oS(e){if(e&&e.length>0)return e.map(({context:{spanId:n,traceId:s,traceFlags:a,...o},attributes:l})=>({span_id:n,trace_id:s,sampled:a===wj,attributes:l,...o}))}function oy(e){return typeof e=="number"?ly(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?ly(e.getTime()):fs()}function ly(e){return e>9999999999?e/1e3:e}function xd(e){if(uS(e))return e.getSpanJSON();const{spanId:n,traceId:s}=e.spanContext();if(dS(e)){const{attributes:a,startTime:o,name:l,endTime:d,status:u,links:p}=e;return{span_id:n,trace_id:s,data:a,description:l,parent_span_id:lS(e),start_timestamp:oy(o),timestamp:oy(d)||void 0,status:pS(u),op:a[Uk],origin:a[zk],links:oS(p)}}return{span_id:n,trace_id:s,start_timestamp:0,data:{}}}function lS(e){var n;return"parentSpanId"in e?e.parentSpanId:"parentSpanContext"in e?(n=e.parentSpanContext)==null?void 0:n.spanId:void 0}function cS(e){var n;return{...e,attributes:sy(e.attributes),links:(n=e.links)==null?void 0:n.map(s=>({...s,attributes:sy(s.attributes)}))}}function dS(e){const n=e;return!!n.attributes&&!!n.startTime&&!!n.name&&!!n.endTime&&!!n.status}function uS(e){return typeof e.getSpanJSON=="function"}function mS(e){const{traceFlags:n}=e.spanContext();return n===wj}function pS(e){if(!(!e||e.code===Hk))return e.code===qk?"ok":e.message||"internal_error"}const fS="_sentryRootSpan",Nj=hS;function hS(e){return e[fS]||e}function cy(){iy||(za(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),iy=!0)}function xS(e){var s;if(typeof __SENTRY_TRACING__=="boolean"&&!__SENTRY_TRACING__)return!1;const n=(s=Pt())==null?void 0:s.getOptions();return!!n&&(n.tracesSampleRate!=null||!!n.tracesSampler)}function dy(e){Ae.log(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function uy(e,n){if(!(n!=null&&n.length))return!1;for(const s of n){if(bS(s)){if(e.description&&Ki(e.description,s))return Ie&&dy(e),!0;continue}const a=!!s.attributes&&Object.keys(s.attributes).length>0;if(!s.name&&!s.op&&!a)continue;const o=s.name?e.description&&Ki(e.description,s.name):!0,l=s.op?e.op&&Ki(e.op,s.op):!0,d=s.attributes?Object.entries(s.attributes).every(([u,p])=>{var h;return gS((h=e.attributes)==null?void 0:h[u],p)}):!0;if(o&&l&&d)return Ie&&dy(e),!0}return!1}function gS(e,n){return typeof e=="string"&&(typeof n=="string"||n instanceof RegExp)?
79Ki(e,n):Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every((s,a)=>s===n[a]):e===n}function yS(e,n){const s=n.parent_span_id,a=n.span_id;if(s)for(const o of e)o.parent_span_id===a&&(o.parent_span_id=s)}function bS(e){return typeof e=="string"||e instanceof RegExp}const qf="production",vS="_frozenDsc";function _j(e,n){const s=n.getOptions(),{publicKey:a}=n.getDsn()||{},o={environment:s.environment||qf,release:s.release,public_key:a,trace_id:e,org_id:sS(n)};return n.emit("createDsc",o),o}function jS(e,n){const s=n.getPropagationContext();return s.dsc||_j(s.traceId,e)}function wS(e){var N;const n=Pt();if(!n)return{};const s=Nj(e),a=xd(s),o=a.data,l=s.spanContext().traceState,d=(l==null?void 0:l.get("sentry.sample_rate"))??o[Mk]??o[Bk];function u(w){return(typeof d=="number"||typeof d=="string")&&(w.sample_rate=`${d}`),w}const p=s[vS];if(p)return u(p);const h=l==null?void 0:l.get("sentry.dsc"),f=h&&Kk(h);if(f)return u(f);const g=_j(e.spanContext().traceId,n),b=o[$k]??o["sentry.span.source"],v=a.description;return b!=="url"&&v&&(g.transaction=v),xS()&&(g.sampled=String(mS(s)),g.sample_rand=(l==null?void 0:l.get("sentry.sample_rand"))??((N=vj(s).scope)==null?void 0:N.getPropagationContext().sampleRand.toString())),u(g),n.emit("createDsc",g,s),g}function NS(e){return!!e&&typeof e=="function"&&"_streamed"in e&&!!e._streamed}const _S=Symbol.for("sentry.skipNormalization"),kS=Symbol.for("sentry.overrideNormalizationDepth");function SS(e){return!!e[_S]}function CS(e){const n=e[kS];return typeof n=="number"?n:void 0}function us(e,n=100,s=1/0){try{return Vp("",e,n,s)}catch(a){return{ERROR:`**non-serializable** (${a})`}}}function kj(e,n=3,s=100*1024){const a=us(e,n);return LS(a)>s?kj(e,n-1,s):a}function Vp(e,n,s=1/0,a=1/0,o=RS()){const[l,d]=o;if(n==null||["boolean","string"].includes(typeof n)||typeof n=="number"&&Number.isFinite(n))return n;const u=ES(e,n);if(!u.startsWith("[object "))return u;if(SS(n))return n;const p=CS(n),h=p!==void 0?p:s;if(h===0)return u.replace("object ","");if(l(n))return"[Circular ~]";const f=n;if(f&&typeof f.toJSON=="function")try{const N=f.toJSON();return Vp("",N,h-1,a,o)}catch{}const g=Array.isArray(n)?[]:{};let b=0;const v=pj(n);for(const N in v){if(!Object.prototype.hasOwnProperty.call(v,N))continue;if(b>=a){g[N]="[MaxProperties ~]";break}const w=v[N];g[N]=Vp(N,w,h-1,a,o),b++}return d(n),g}function ES(e,n){try{if(e==="domain"&&n&&typeof n=="object"&&n._events)return"[Domain]";if(e==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&n===global)return"[Global]";if(typeof window<"u"&&n===window)return"[Window]";if(typeof document<"u"&&n===document)return"[Document]";if(cj(n))return ij(n);if(uk(n))return"[SyntheticEvent]";if(typeof n=="number"&&!Number.isFinite(n))return`[${n}]`;if(typeof n=="function")return`[Function: ${Vs(n)}]`;if(typeof n=="symbol")return`[${String(n)}]`;if(typeof n=="bigint")return`[BigInt: ${String(n)}]`;const s=AS(n);return/^HTML(\w*)Element$/.test(s)?`[HTMLElement: ${s}]`:`[object ${s}]`}catch(s){return`**non-serializable** (${s})`}}function AS(e){const n=Object.getPrototypeOf(e);return n!=null&&n.constructor?n.constructor.name:"null prototype"}function TS(e){return~-encodeURI(e).split(/%..|./).length}function LS(e){return TS(JSON.stringify(e))}function RS(){const e=new WeakSet;function n(a){return e.has(a)?!0:(e.add(a),!1)}function s(a){e.delete(a)}return[n,s]}function Ha(e,n=[]){return[e,n]}function my(e,n){const[s,a]=e;return[s,[...a,n]]}function Yp(e,n){const s=e[1];for(const a of s){const o=a[0].type;if(n(a,o))return!0}return!1}function IS(e,n){return Yp(e,(s,a)=>n.includes(a))}function Gp(e){const n=dd(Ue);return n.encodePolyfill?n.encodePolyfill(e):new TextEncoder().encode(e)}function PS(e){const[n,s]=e;let a=JSON.stringify(n);function o(l){typeof a=="string"?a=typeof l=="string"?a+l:[Gp(a),l]:a.push(typeof l=="string"?Gp(l):l)}for(const l of s){const[d,u]=l;if(o(`
80${JSON.stringify(d)}
81`),typeof u=="string"||u instanceof Uint8Array)o(u);else{let p;try{p=JSON.stringify(u)}catch{p=JSON.stringify(us(u))}o(p)}}return typeof a=="string"?a:FS(a)}function FS(e){const n=e.reduce((o,l)=>o+l.length,0),s=new Uint8Array(n);let a=0;for(const o of e)s.set(o,a),a+=o.length;return s}
81function DS(e){const n=typeof e.data=="string"?Gp(e.data):e.data;return[{type:"attachment",length:n.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},n]}const Sj={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function OS(e){return e in Sj}function py(e){return OS(e)?Sj[e]:e}function Cj(e){if(!(e!=null&&e.sdk))return;const{name:n,version:s}=e.sdk;return{name:n,version:s}}function $S(e,n,s,a){var l;const o=(l=e.sdkProcessingMetadata)==null?void 0:l.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date().toISOString(),...n&&{sdk:n},...!!s&&a&&{dsn:go(a)},...o&&{trace:o}}}function MS(e,n){var a,o,l,d;if(!n)return e;const s=e.sdk||{};return e.sdk={...s,name:s.name||n.name,version:s.version||n.version,integrations:[...((a=e.sdk)==null?void 0:a.integrations)||[],...n.integrations||[]],packages:[...((o=e.sdk)==null?void 0:o.packages)||[],...n.packages||[]],settings:(l=e.sdk)!=null&&l.settings||n.settings?{...(d=e.sdk)==null?void 0:d.settings,...n.settings}:void 0},e}function BS(e,n,s,a){const o=Cj(s),l={sent_at:new Date().toISOString(),...o&&{sdk:o},...!!a&&n&&{dsn:go(n)}},d="aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()];return Ha(l,[d])}function US(e,n,s,a){const o=Cj(s),l=e.type&&e.type!=="replay_event"?e.type:"event";MS(e,s==null?void 0:s.sdk);const d=$S(e,o,a,n);return delete e.sdkProcessingMetadata,Ha(d,[[{type:l},e]])}function zS(e){return e.getOptions().traceLifecycle==="stream"}function WS(e,n){const{fingerprint:s,span:a,breadcrumbs:o,sdkProcessingMetadata:l}=n;HS(e,n),a&&YS(e,a),GS(e,s),qS(e,o),VS(e,l)}function fy(e,n){const{extra:s,tags:a,attributes:o,user:l,contexts:d,level:u,sdkProcessingMetadata:p,breadcrumbs:h,fingerprint:f,eventProcessors:g,attachments:b,propagationContext:v,transactionName:N,span:w}=n;Fi(e,"extra",s),Fi(e,"tags",a),Fi(e,"attributes",o),Fi(e,"user",l),Fi(e,"contexts",d),e.sdkProcessingMetadata=xo(e.sdkProcessingMetadata,p,2),u&&(e.level=u),N&&(e.transactionName=N),w&&(e.span=w),h.length&&(e.breadcrumbs=[...e.breadcrumbs,...h]),f.length&&(e.fingerprint=[...e.fingerprint,...f]),g.length&&(e.eventProcessors=[...e.eventProcessors,...g]),b.length&&(e.attachments=[...e.attachments,...b]),e.propagationContext={...e.propagationContext,...v}}function Fi(e,n,s){e[n]=xo(e[n],s,1)}function Ej(e,n){const s=Fk().getScopeData();return e&&fy(s,e.getScopeData()),n&&fy(s,n.getScopeData()),s}function HS(e,n){const{extra:s,tags:a,user:o,contexts:l,level:d,transactionName:u}=n;Object.keys(s).length&&(e.extra={...s,...e.extra}),Object.keys(a).length&&(e.tags={...a,...e.tags}),Object.keys(o).length&&(e.user={...o,...e.user}),Object.keys(l).length&&(e.contexts={...l,...e.contexts}),d&&(e.level=d),u&&e.type!=="transaction"&&(e.transaction=u)}function qS(e,n){const s=[...e.breadcrumbs||[],...n];e.breadcrumbs=s.length?s:void 0}function VS(e,n){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...n}}function YS(e,n){e.contexts={trace:iS(n),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:wS(n),...e.sdkProcessingMetadata};const s=Nj(n),a=xd(s).description;a&&!e.transaction&&e.type==="transaction"&&(e.transaction=a)}function GS(e,n){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],n&&(e.fingerprint=e.fingerprint.concat(n)),e.fingerprint.length||delete e.fingerprint}function Jm(e){if(!e)return{};const n=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!n)return{};const s=n[6]||"",a=n[8]||"";return{host:n[4],path:n[5],protocol:n[2],search:s,hash:a,relative:n[5]+s+a}}function KS(e,n=!0){if(e.startsWith("data:")){const s=e.match(/^data:([^;,]+)/),a=s?s[1]:"text/plain",o=e.includes(";base64,"),l=e.indexOf(",");let d="";if(n&&l!==-1){const u=e.slice(l+1);d=u.length>10?`${u.slice(0,10)}... [truncated]`:u}return`data:${a}${o?",base64":""}${d?`,${d}`:""}`}return e}function Aj(e,n){const s=e.attributes??(e.attributes={});
81Object.entries(n).forEach(([a,o])=>{o!=null&&!(a in s)&&(s[a]=o)})}const Xm=0,hy=1,xy=2;function yo(e){return new no(n=>{n(e)})}function Vf(e){return new no((n,s)=>{s(e)})}class no{constructor(n){this._state=Xm,this._handlers=[],this._runExecutor(n)}then(n,s){return new no((a,o)=>{this._handlers.push([!1,l=>{if(!n)a(l);else try{a(n(l))}catch(d){o(d)}},l=>{if(!s)o(l);else try{a(s(l))}catch(d){o(d)}}]),this._executeHandlers()})}catch(n){return this.then(s=>s,n)}finally(n){return new no((s,a)=>{let o,l;return this.then(d=>{l=!1,o=d,n&&n()},d=>{l=!0,o=d,n&&n()}).then(()=>{if(l){a(o);return}s(o)})})}_executeHandlers(){if(this._state===Xm)return;const n=this._handlers.slice();this._handlers=[],n.forEach(s=>{s[0]||(this._state===hy&&s[1](this._value),this._state===xy&&s[2](this._value),s[0]=!0)})}_runExecutor(n){const s=(l,d)=>{if(this._state===Xm){if(po(d)){d.then(a,o);return}this._state=l,this._value=d,this._executeHandlers()}},a=l=>{s(hy,l)},o=l=>{s(xy,l)};try{n(a,o)}catch(l){o(l)}}}function QS(e,n,s,a=0){try{const o=Kp(n,s,e,a);return po(o)?o:yo(o)}catch(o){return Vf(o)}}function Kp(e,n,s,a){const o=s[a];if(!e||!o)return e;const l=o({...e},n);return Ie&&l===null&&Ae.log(`Event processor "${o.id||"?"}" dropped event`),po(l)?l.then(d=>Kp(d,n,s,a+1)):Kp(l,n,s,a+1)}let is,gy,yy,zs;function JS(e){const n=Ue._sentryDebugIds,s=Ue._debugIds;if(!n&&!s)return{};const a=n?Object.keys(n):[],o=s?Object.keys(s):[];if(zs&&a.length===gy&&o.length===yy)return zs;gy=a.length,yy=o.length,zs={},is||(is={});const l=(d,u)=>{for(const p of d){const h=u[p],f=is==null?void 0:is[p];if(f&&zs&&h)zs[f[0]]=h,is&&(is[p]=[f[0],h]);else if(h){const g=e(p);for(let b=g.length-1;b>=0;b--){const v=g[b],N=v==null?void 0:v.filename;if(N&&zs&&is){zs[N]=h,is[p]=[N,h];break}}}}};return n&&l(a,n),s&&l(o,s),zs}function XS(e,n,s,a,o,l){const{normalizeDepth:d=3,normalizeMaxBreadth:u=1e3}=e,p={...n,event_id:n.event_id||s.event_id||gn(),timestamp:n.timestamp||ho()},h=s.integrations||e.integrations.map(_=>_.name);ZS(p,e),nC(p,h),o&&o.emit("applyFrameMetadata",n),n.type===void 0&&eC(p,e.stackParser);const f=rC(a,s.captureContext);s.mechanism&&La(p,s.mechanism);const g=o?o.getEventProcessors():[],b=Ej(l,f),v=[...s.attachments||[],...b.attachments];v.length&&(s.attachments=v),WS(p,b);const N=[...g,...b.eventProcessors];return(s.data&&s.data.__sentry__===!0?yo(p):QS(N,p,s)).then(_=>(_&&tC(_),typeof d=="number"&&d>0?sC(_,d,u):_))}function ZS(e,n){var u,p;const{environment:s,release:a,dist:o,maxValueLength:l}=n;e.environment=e.environment||s||qf,!e.release&&a&&(e.release=a),!e.dist&&o&&(e.dist=o);const d=e.request;d!=null&&d.url&&l&&(d.url=Wp(d.url,l)),l&&((p=(u=e.exception)==null?void 0:u.values)==null||p.forEach(h=>{h.value&&(h.value=Wp(h.value,l))}))}function eC(e,n){var a,o;const s=JS(n);(o=(a=e.exception)==null?void 0:a.values)==null||o.forEach(l=>{var d,u;(u=(d=l.stacktrace)==null?void 0:d.frames)==null||u.forEach(p=>{p.filename&&(p.debug_id=s[p.filename])})})}function tC(e){var a,o;const n={};if((o=(a=e.exception)==null?void 0:a.values)==null||o.forEach(l=>{var d,u;(u=(d=l.stacktrace)==null?void 0:d.frames)==null||u.forEach(p=>{p.debug_id&&(p.abs_path?n[p.abs_path]=p.debug_id:p.filename&&(n[p.filename]=p.debug_id),delete p.debug_id)})}),Object.keys(n).length===0)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const s=e.debug_meta.images;Object.entries(n).forEach(([l,d])=>{s.push({type:"sourcemap",code_file:l,debug_id:d})})}function nC(e,n){n.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...n])}function sC(e,n,s){var o,l;if(!e)return null;const a={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(d=>({...d,...d.data&&{data:us(d.data,n,s)}}))},...e.user&&{user:us(e.user,n,s)},...e.contexts&&{contexts:us(e.contexts,n,s)},...e.extra&&{extra:us(e.extra,n,s)}};return(o=e.contexts)!=null&&o.trace&&a.contexts&&(a.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(a.contexts.trace.data=us(e.contexts.trace.data,n,s))),e.spans&&(a.spans=e.spans.map(d=>({...d,...d.data&&{data:us(d.data,n,s)}}))),(l=e.contexts)!=null&&l.flags&&a.contexts&&(a.contexts.flags=us(e.contexts.flags,3,s)),a}function rC(e,n){if(!n)return e;const s=e?e.clone():new xs;return s.update(n),s}function aC(e,n){return vs().captureException(e,void 0)}function Tj(e,n){return vs().captureEvent(e,n)}function iC(e,n){Js().setContext(e,n)}function by(e){const n=Js(),{user:s}=Ej(n,vs()),{userAgent:a}=Ue.navigator||{},o=vk({user:s,...a&&{userAgent:a},...e}),l=n.getSession();return(l==null?void 0:l.status)==="ok"&&Ra(l,{status:"exited"}),Lj(),n.setSession(o),o}function Lj(){const e=Js(),s=vs().getSession()||e.getSession();s&&jk(s),Rj(),e.setSession()}function Rj(){const e=Js(),n=Pt(),s=e.getSession();s&&n&&n.captureSession(s)}function Zm(e=!1){if(e){Lj();return}Rj()}const oC="7";function lC(e){const n=e.protocol?`${e.protocol}:`:"",s=e.port?`:${e.port}`:"";return`${n}//${e.host}${s}${e.path?`/${e.path}`:""}/api/`}function cC(e){return`${lC(e)}${e.projectId}/envelope/`}function dC(e,n){const s={sentry_version:oC};return e.publicKey&&(s.sentry_key=e.publicKey),n&&(s.sentry_client=`${n.name}/${n.version}`),new URLSearchParams(s).toString()}function uC(e,n,s){return n||`${cC(e)}?${dC(e,s)}`}const vy=[];function mC(e){const n={};return e.forEach(s=>{const{name:a}=s,o=n[a];o&&!o.isDefaultInstance&&s.isDefaultInstance||(n[a]=s)}),Object.values(n)}function pC(e){const n=e.defaultIntegrations||[],s=e.integrations;
81n.forEach(o=>{o.isDefaultInstance=!0});let a;if(Array.isArray(s))a=[...n,...s];else if(typeof s=="function"){const o=s(n);a=Array.isArray(o)?o:[o]}else a=n;return mC(a)}function fC(e,n){const s={};return n.forEach(a=>{a!=null&&a.beforeSetup&&a.beforeSetup(e)}),n.forEach(a=>{a&&Ij(e,a,s)}),s}function jy(e,n){for(const s of n)s!=null&&s.afterAllSetup&&s.afterAllSetup(e)}function Ij(e,n,s){if(s[n.name]){Ie&&Ae.log(`Integration skipped because it was already installed: ${n.name}`);return}if(s[n.name]=n,!vy.includes(n.name)&&typeof n.setupOnce=="function"&&(n.setupOnce(),vy.push(n.name)),n.setup&&typeof n.setup=="function"&&n.setup(e),typeof n.preprocessEvent=="function"){const a=n.preprocessEvent.bind(n);e.on("preprocessEvent",(o,l)=>a(o,l,e))}if(typeof n.processEvent=="function"){const a=n.processEvent.bind(n),o=Object.assign((l,d)=>a(l,d,e),{id:n.name});e.addEventProcessor(o)}["processSpan","processSegmentSpan"].forEach(a=>{const o=n[a];typeof o=="function"&&e.on(a,l=>o.call(n,l,e))}),Ie&&Ae.log(`Integration installed: ${n.name}`)}function hC(){return typeof __SENTRY_BROWSER_BUNDLE__<"u"&&!!__SENTRY_BROWSER_BUNDLE__}function xC(){return"npm"}function gC(){return!hC()&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]"}function Yf(){return typeof window<"u"&&(!gC()||yC())}function yC(){const e=Ue.process;return(e==null?void 0:e.type)==="renderer"}function bC(e,n){const s=n?"auto":"never";return[{type:"log",item_count:e.length,content_type:"application/vnd.sentry.items.log+json"},{version:2,...Yf()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}},items:e}]}function vC(e,n,s,a,o){const l={};return n!=null&&n.sdk&&(l.sdk={name:n.sdk.name,version:n.sdk.version}),s&&a&&(l.dsn=go(a)),Ha(l,[bC(e,o)])}function Qp(e,n){const s=n??jC(e)??[];if(s.length===0)return;const a=e.getOptions(),o=vC(s,a._metadata,a.tunnel,e.getDsn(),a.sendDefaultPii);Pj().set(e,[]),e.emit("flushLogs"),e.sendEnvelope(o)}function jC(e){return Pj().get(e)}function Pj(){return Ua("clientToLogBufferMap",()=>new WeakMap)}function wC(e,n){const s=n?"auto":"never";return[{type:"trace_metric",item_count:e.length,content_type:"application/vnd.sentry.items.trace-metric+json"},{version:2,...Yf()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}},items:e}]}function NC(e,n,s,a,o){const l={};return n!=null&&n.sdk&&(l.sdk={name:n.sdk.name,version:n.sdk.version}),s&&a&&(l.dsn=go(a)),Ha(l,[wC(e,o)])}function Fj(e,n){const s=n??_C(e)??[];if(s.length===0)return;const a=e.getOptions(),o=NC(s,a._metadata,a.tunnel,e.getDsn(),a.sendDefaultPii);Dj().set(e,[]),e.emit("flushMetrics"),e.sendEnvelope(o)}function _C(e){return Dj().get(e)}function Dj(){return Ua("clientToMetricBufferMap",()=>new WeakMap)}function kC(e){const n={trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,name:e.description||"",start_timestamp:e.start_timestamp,end_timestamp:e.timestamp||e.start_timestamp,status:!e.status||e.status==="ok"||e.status==="cancelled"?"ok":"error",is_segment:!1,attributes:{...e.data},links:e.links};return cS(n)}function SC(e,n){var l,d,u;if(e.type!=="transaction"||!((l=e.spans)!=null&&l.length)||!((d=e.sdkProcessingMetadata)!=null&&d.hasGenAiSpans)||!n.getOptions().streamGenAiSpans||zS(n))return;const s=[],a=[];for(const p of e.spans)(u=p.op)!=null&&u.startsWith("gen_ai.")?s.push(kC(p)):a.push(p);if(s.length===0)return;e.spans=a;const o=n.getOptions().sendDefaultPii?"auto":"never";return[{type:"span",item_count:s.length,content_type:"application/vnd.sentry.items.span.v2+json"},{version:2,...Yf()&&{ingest_settings:{infer_ip:o,infer_user_agent:o}},items:s}]}function Oj(e){return typeof e=="object"&&typeof e.unref=="function"&&e.unref(),e}const Gf=Symbol.for("SentryBufferFullError");function Kf(e=100){const n=new Set;function s(){return n.size<e}function a(d){n.delete(d)}function o(d){if(!s())return Vf(Gf);const u=d();return n.add(u),u.then(()=>a(u),()=>a(u)),u}function l(d){if(!n.size)return yo(!0);const u=Promise.allSettled(Array.from(n)).then(()=>!0);if(!d)return u;const p=[u,new Promise(h=>Oj(setTimeout(()=>h(!1),d)))];return Promise.race(p)}return{get $(){return Array.from(n)},add:o,drain:l}}const CC=60*1e3;function EC(e,n=hd()){const s=parseInt(`${e}`,10);if(!isNaN(s))return s*1e3;const a=Date.parse(`${e}`);return isNaN(a)?CC:a-n}function AC(e,n){return e[n]||e.all||0}function TC(e,n,s=hd()){return AC(e,n)>s}function LC(e,{statusCode:n,headers:s},a=hd()){const o={...e},l=s==null?void 0:s["x-sentry-rate-limits"],d=s==null?void 0:s["retry-after"];if(l)for(const u of l.trim().split(",")){const[p,h,,,f]=u.split(":",5),g=parseInt(p,10),b=(isNaN(g)?60:g)*1e3;if(!h)o.all=a+b;else for(const v of h.split(";"))v==="metric_bucket"?(!f||f.split(";").includes("custom"))&&(o[v]=a+b):o[v]=a+b}else d?o.all=a+EC(d,a):n===429&&(o.all=a+60*1e3);return o}const $j=64;function RC(e,n,s=Kf(e.bufferSize||$j)){let a={};const o=d=>s.drain(d);function l(d){const u=[];
81if(Yp(d,(g,b)=>{const v=py(b);TC(a,v)?e.recordDroppedEvent("ratelimit_backoff",v):u.push(g)}),u.length===0)return Promise.resolve({});const p=Ha(d[0],u),h=g=>{if(IS(p,["client_report"])){Ie&&Ae.warn(`Dropping client report. Will not send outcomes (reason: ${g}).`);return}Yp(p,(b,v)=>{e.recordDroppedEvent(g,py(v))})},f=()=>n({body:PS(p)}).then(g=>g.statusCode===413?(Ie&&Ae.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),h("send_error"),g):(Ie&&g.statusCode!==void 0&&(g.statusCode<200||g.statusCode>=300)&&Ae.warn(`Sentry responded with status code ${g.statusCode} to sent event.`),a=LC(a,g),g),g=>{throw h("network_error"),Ie&&Ae.error("Encountered error running transport request:",g),g});return s.add(f).then(g=>g,g=>{if(g===Gf)return Ie&&Ae.error("Skipped sending event because buffer is full."),h("queue_overflow"),Promise.resolve({});throw g})}return{send:l,flush:o}}function IC(e,n,s){const a=[{type:"client_report"},{timestamp:ho(),discarded_events:e}];return Ha(n?{dsn:n}:{},[a])}function Mj(e){const n=[];e.message&&n.push(e.message);try{const s=e.exception.values[e.exception.values.length-1];s!=null&&s.value&&(n.push(s.value),s.type&&n.push(`${s.type}: ${s.value}`))}catch{}return n}function PC(e){var p;const{trace_id:n,parent_span_id:s,span_id:a,status:o,origin:l,data:d,op:u}=((p=e.contexts)==null?void 0:p.trace)??{};return{data:d??{},description:e.transaction,op:u,parent_span_id:s,span_id:a??"",start_timestamp:e.start_timestamp??0,status:o,timestamp:e.timestamp,trace_id:n??"",origin:l,profile_id:d==null?void 0:d[yj],exclusive_time:d==null?void 0:d[bj],measurements:e.measurements,is_segment:!0}}function FC(e){return{type:"transaction",timestamp:e.timestamp,start_timestamp:e.start_timestamp,transaction:e.description,contexts:{trace:{trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,op:e.op,status:e.status,origin:e.origin,data:{...e.data,...e.profile_id&&{[yj]:e.profile_id},...e.exclusive_time&&{[bj]:e.exclusive_time}}}},measurements:e.measurements}}const wy="Not capturing exception because it's already been captured.",Ny="Discarded session because of missing or non-string release",Bj=Symbol.for("SentryInternalError"),Uj=Symbol.for("SentryDoNotSendEventError"),DC=5e3;function gc(e){return{message:e,[Bj]:!0}}function ep(e){return{message:e,[Uj]:!0}}function _y(e){return!!e&&typeof e=="object"&&Bj in e}function ky(e){return!!e&&typeof e=="object"&&Uj in e}function Sy(e,n,s,a,o){let l=0,d,u=!1;e.on(s,()=>{l=0,clearTimeout(d),u=!1}),e.on(n,p=>{l+=a(p),l>=8e5?o(e):u||(u=!0,d=Oj(setTimeout(()=>{o(e)},DC)))}),e.on("flush",()=>{o(e)})}class OC{constructor(n){var a,o,l;if(this._options=n,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Kf(((a=n.transportOptions)==null?void 0:a.bufferSize)??$j),n.dsn?this._dsn=rS(n.dsn):Ie&&Ae.warn("No DSN provided, client will not send events."),this._dsn){const d=uC(this._dsn,n.tunnel,n._metadata?n._metadata.sdk:void 0);this._transport=n.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...n.transportOptions,url:d})}this._options.enableLogs=this._options.enableLogs??((o=this._options._experiments)==null?void 0:o.enableLogs),this._options.enableLogs&&Sy(this,"afterCaptureLog","flushLogs",UC,Qp),(this._options.enableMetrics??((l=this._options._experiments)==null?void 0:l.enableMetrics)??!0)&&Sy(this,"afterCaptureMetric","flushMetrics",BC,Fj)}captureException(n,s,a){const o=gn();if(Q0(n))return Ie&&Ae.log(wy),o;const l={event_id:o,...s};return this._process(()=>this.eventFromException(n,l).then(d=>this._captureEvent(d,l,a)).then(d=>d),"error"),l.event_id}captureMessage(n,s,a,o){const l={event_id:gn(),...a},d=Bf(n)?n:String(n),u=md(n),p=u?this.eventFromMessage(d,s,l):this.eventFromException(n,l);return this._process(()=>p.then(h=>this._captureEvent(h,l,o)),u?"unknown":"error"),l.event_id}captureEvent(n,s,a){const o=gn();if(s!=null&&s.originalException&&Q0(s.originalException))return Ie&&Ae.log(wy),o;const l={event_id:o,...s},d=n.sdkProcessingMetadata||{},u=d.capturedSpanScope,p=d.capturedSpanIsolationScope,h=Cy(n.type);return this._process(()=>this._captureEvent(n,l,u||a,p),h),l.event_id}captureSession(n){this.sendSession(n),Ra(n,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(n){const s=this._transport;
81if(this.emit("flush"),!s)return!0;const a=await this._isClientDoneProcessing(n),o=await s.flush(n);return a&&o}async close(n){Qp(this);const s=await this.flush(n);return this.getOptions().enabled=!1,this.emit("close"),s}getEventProcessors(){return this._eventProcessors}addEventProcessor(n){this._eventProcessors.push(n)}init(){(this._isEnabled()||this._options.integrations.some(({name:n})=>n.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(n){return this._integrations[n]}addIntegration(n){const s=this._integrations[n.name];!s&&n.beforeSetup&&n.beforeSetup(this),Ij(this,n,this._integrations),s||jy(this,[n])}sendEvent(n,s={}){this.emit("beforeSendEvent",n,s);const a=SC(n,this);let o=US(n,this._dsn,this._options._metadata,this._options.tunnel);for(const l of s.attachments||[])o=my(o,DS(l));a&&(o=my(o,a)),this.sendEnvelope(o).then(l=>this.emit("afterSendEvent",n,l))}sendSession(n){const{release:s,environment:a=qf}=this._options;if("aggregates"in n){const l=n.attrs||{};if(!l.release&&!s){Ie&&Ae.warn(Ny);return}l.release=l.release||s,l.environment=l.environment||a,n.attrs=l}else{if(!n.release&&!s){Ie&&Ae.warn(Ny);return}n.release=n.release||s,n.environment=n.environment||a}this.emit("beforeSendSession",n);const o=BS(n,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(o)}recordDroppedEvent(n,s,a=1){if(this._options.sendClientReports){const o=`${n}:${s}`;Ie&&Ae.log(`Recording outcome: "${o}"${a>1?` (${a} times)`:""}`),this._outcomes[o]=(this._outcomes[o]||0)+a}}on(n,s){const a=this._hooks[n]=this._hooks[n]||new Set,o=(...l)=>s(...l);return a.add(o),()=>{a.delete(o)}}emit(n,...s){const a=this._hooks[n];a&&a.forEach(o=>o(...s))}async sendEnvelope(n){if(this.emit("beforeEnvelope",n),this._isEnabled()&&this._transport)try{return await this._transport.send(n)}catch(s){return Ie&&Ae.error("Error while sending envelope:",s),{}}return Ie&&Ae.error("Transport disabled"),{}}registerCleanup(n){}dispose(){}_setupIntegrations(){const{integrations:n}=this._options;this._integrations=fC(this,n),jy(this,n)}_updateSessionFromEvent(n,s){var p,h;let a=s.level==="fatal",o=!1;const l=(p=s.exception)==null?void 0:p.values;if(l){o=!0,a=!1;for(const f of l)if(((h=f.mechanism)==null?void 0:h.handled)===!1){a=!0;break}}const d=n.status==="ok";(d&&n.errors===0||d&&a)&&(Ra(n,{...a&&{status:"crashed"},errors:n.errors||Number(o||a)}),this.captureSession(n))}async _isClientDoneProcessing(n){let s=0;for(;!n||s<n;){if(await new Promise(a=>setTimeout(a,1)),!this._numProcessing)return!0;s++}return!1}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(n,s,a,o){const l=this.getOptions(),d=Object.keys(this._integrations);return!s.integrations&&(d!=null&&d.length)&&(s.integrations=d),this.emit("preprocessEvent",n,s),n.type||o.setLastEventId(n.event_id||s.event_id),XS(l,n,s,a,this,o).then(u=>{var h;if(u===null)return u;this.emit("postprocessEvent",u,s),u.contexts={trace:{...(h=u.contexts)==null?void 0:h.trace,...Ok(a)},...u.contexts};const p=jS(this,a);return u.sdkProcessingMetadata={dynamicSamplingContext:p,...u.sdkProcessingMetadata},u})}_captureEvent(n,s={},a=vs(),o=Js()){return Ie&&Jp(n)&&Ae.log(`Captured error event \`${Mj(n)[0]||"<unknown>"}\``),this._processEvent(n,s,a,o).then(l=>l.event_id,l=>{Ie&&(ky(l)?Ae.log(l.message):_y(l)?Ae.warn(l.message):Ae.warn(l))})}_processEvent(n,s,a,o){const l=this.getOptions(),{sampleRate:d}=l,u=zj(n),p=Jp(n),f=`before send for type \`${n.type||"error"}\``,g=typeof d>"u"?void 0:aS(d);if(p&&typeof g=="number"&&Rc()>g)return this.recordDroppedEvent("sample_rate","error"),Vf(ep(`Discarding event because it's not included in the random sample (sampling rate = ${d})`));const b=Cy(n.type);return this._prepareEvent(n,s,a,o).then(v=>{var k;if(v===null)throw this.recordDroppedEvent("event_processor",b),ep("An event processor returned `null`, will not send event.");if(((k=s.data)==null?void 0:k.__sentry__)===!0)return v;const w=MC(this,l,v,s);return $C(w,f)}).then(v=>{var k;if(v===null){if(this.recordDroppedEvent("before_send",b),u){const S=1+(n.spans||[]).length;this.recordDroppedEvent("before_send","span",S)}throw ep(`${f} returned \`null\`, will not send event.`)}const N=a.getSession()||o.getSession();if(p&&N&&this._updateSessionFromEvent(N,v),u){const _=((k=v.sdkProcessingMetadata)==null?void 0:k.spanCountBeforeProcessing)||0,S=v.spans?v.spans.length:0,T=_-S;T>0&&this.recordDroppedEvent("before_send","span",T)}const w=v.transaction_info;if(u&&w&&v.transaction!==n.transaction){const _="custom";v.transaction_info={...w,source:_}}
81return this.sendEvent(v,s),v}).then(null,v=>{throw ky(v)||_y(v)?v:(this.captureException(v,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:v}),gc(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
82Reason: ${v}`))})}_process(n,s){this._numProcessing++,this._promiseBuffer.add(n).then(a=>(this._numProcessing--,a),a=>(this._numProcessing--,a===Gf&&this.recordDroppedEvent("queue_overflow",s),a))}_clearOutcomes(){const n=this._outcomes;return this._outcomes={},Object.entries(n).map(([s,a])=>{const[o,l]=s.split(":");return{reason:o,category:l,quantity:a}})}_flushOutcomes(){Ie&&Ae.log("Flushing outcomes...");const n=this._clearOutcomes();if(n.length===0){Ie&&Ae.log("No outcomes to send");return}if(!this._dsn){Ie&&Ae.log("No dsn provided, will not send outcomes");return}Ie&&Ae.log("Sending outcomes:",n);const s=IC(n,this._options.tunnel&&go(this._dsn));this.sendEnvelope(s)}}function Cy(e){return e==="replay_event"?"replay":e||"error"}function $C(e,n){const s=`${n} must return \`null\` or a valid event.`;if(po(e))return e.then(a=>{if(!to(a)&&a!==null)throw gc(s);return a},a=>{throw gc(`${n} rejected with ${a}`)});if(!to(e)&&e!==null)throw gc(s);return e}function MC(e,n,s,a){const{beforeSend:o,beforeSendTransaction:l,ignoreSpans:d}=n,u=!NS(n.beforeSendSpan)&&n.beforeSendSpan;let p=s;if(Jp(p)&&o)return o(p,a);
82if(zj(p)){if(u||d){const h=PC(p);if(d!=null&&d.length&&uy({description:h.description,op:h.op,attributes:h.data},d))return null;if(u){const f=u(h);f?p=xo(s,FC(f)):cy()}if(p.spans){const f=[],g=p.spans;for(const v of g){if(d!=null&&d.length&&uy({description:v.description,op:v.op,attributes:v.data},d)){yS(g,v);continue}if(u){const N=u(v);N?f.push(N):(cy(),f.push(v))}else f.push(v)}const b=p.spans.length-f.length;b&&e.recordDroppedEvent("before_send","span",b),p.spans=f}}if(l){if(p.spans){const h=p.spans.length;p.sdkProcessingMetadata={...s.sdkProcessingMetadata,spanCountBeforeProcessing:h}}return l(p,a)}}return p}function Jp(e){return e.type===void 0}function zj(e){return e.type==="transaction"}function BC(e){let n=0;return e.name&&(n+=e.name.length*2),n+=8,n+Wj(e.attributes)}function UC(e){let n=0;return e.message&&(n+=e.message.length*2),n+Wj(e.attributes)}function Wj(e){if(!e)return 0;let n=0;return Object.values(e).forEach(s=>{Array.isArray(s)?n+=s.length*Ey(s[0]):md(s)?n+=Ey(s):n+=100}),n}function Ey(e){return typeof e=="string"?e.length*2:typeof e=="number"?8:typeof e=="boolean"?4:0}function zC(e,n){n.debug===!0&&(Ie?Ae.enable():za(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),vs().update(n.initialScope);const a=new e(n);return WC(a),a.init(),a}function WC(e){vs().setClient(e)}function HC(e){var n;"aggregates"in e?((n=e.attrs)==null?void 0:n.ip_address)===void 0&&(e.attrs={...e.attrs,ip_address:"{{auto}}"}):e.ipAddress===void 0&&(e.ipAddress="{{auto}}")}function Hj(e,n,s=[n],a="npm"){const o=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};o.name||(o.name=`sentry.javascript.${n}`,o.packages=s.map(l=>({name:`${a}:@sentry/${l}`,version:Nr})),o.version=Nr)}const qC=100;function Er(e,n){const s=Pt(),a=Js();if(!s)return;const{beforeBreadcrumb:o=null,maxBreadcrumbs:l=qC}=s.getOptions();if(l<=0)return;const u={timestamp:ho(),...e},p=o?za(()=>o(u,n)):u;p!==null&&(s.emit&&s.emit("beforeAddBreadcrumb",p,n),a.addBreadcrumb(p,l))}let Ay;const VC="FunctionToString",Ty=new WeakMap,YC=(()=>({name:VC,setupOnce(){Ay=Function.prototype.toString;try{Function.prototype.toString=function(...e){const n=Wf(this),s=Ty.has(Pt())&&n!==void 0?n:this;return Ay.apply(s,e)}}catch{}},setup(e){Ty.set(e,!0)}})),GC=YC,KC=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],QC="EventFilters",JC=(e={})=>{let n;return{name:QC,setup(s){const a=s.getOptions();n=Ly(e,a)},processEvent(s,a,o){if(!n){const l=o.getOptions();n=Ly(e,l)}return ZC(s,n)?null:s}}},XC=((e={})=>({...JC(e),name:"InboundFilters"}));function Ly(e={},n={}){return{allowUrls:[...e.allowUrls||[],...n.allowUrls||[]],denyUrls:[...e.denyUrls||[],...n.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...n.ignoreErrors||[],...e.disableErrorDefaults?[]:KC],ignoreTransactions:[...e.ignoreTransactions||[],...n.ignoreTransactions||[]]}}function ZC(e,n){if(e.type){if(e.type==="transaction"&&t3(e,n.ignoreTransactions))return Ie&&Ae.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
83Event: ${yr(e)}`),!0}else{if(e3(e,n.ignoreErrors))return Ie&&Ae.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
84Event: ${yr(e)}`),!0;if(a3(e))return Ie&&Ae.warn(`Event dropped due to not having an error message, error type or stacktrace.
85Event: ${yr(e)}`),!0;if(n3(e,n.denyUrls))return Ie&&Ae.warn(`Event dropped due to being matched by \`denyUrls\` option.
86Event: ${yr(e)}.
87Url: ${Ic(e)}`),!0;if(!s3(e,n.allowUrls))return Ie&&Ae.warn(`Event dropped due to not being matched by \`allowUrls\` option.
88Event: ${yr(e)}.
89Url: ${Ic(e)}`),!0}return!1}function e3(e,n){return n!=null&&n.length?Mj(e).some(s=>fo(s,n)):!1}function t3(e,n){if(!(n!=null&&n.length))return!1;const s=e.transaction;return s?fo(s,n):!1}function n3(e,n){if(!(n!=null&&n.length))return!1;const s=Ic(e);return s?fo(s,n):!1}function s3(e,n){if(!(n!=null&&n.length))return!0;const s=Ic(e);return s?fo(s,n):!0}function r3(e=[]){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s&&s.filename!=="<anonymous>"&&s.filename!=="[native code]")return s.filename||null}return null}function Ic(e){var n,s;try{const a=[...((n=e.exception)==null?void 0:n.values)??[]].reverse().find(l=>{var d,u,p;
89return((d=l.mechanism)==null?void 0:d.parent_id)===void 0&&((p=(u=l.stacktrace)==null?void 0:u.frames)==null?void 0:p.length)}),o=(s=a==null?void 0:a.stacktrace)==null?void 0:s.frames;return o?r3(o):null}catch{return Ie&&Ae.error(`Cannot extract url for event ${yr(e)}`),null}}function a3(e){var n,s;return(s=(n=e.exception)==null?void 0:n.values)!=null&&s.length?!e.message&&!e.exception.values.some(a=>a.stacktrace||a.type&&a.type!=="Error"||a.value):!1}function i3(e,n,s,a,o,l){var u;if(!((u=o.exception)!=null&&u.values)||!l||!Ys(l.originalException,Error))return;const d=o.exception.values.length>0?o.exception.values[o.exception.values.length-1]:void 0;d&&(o.exception.values=Xp(e,n,a,l.originalException,s,o.exception.values,d,0))}function Xp(e,n,s,a,o,l,d,u){if(l.length>=s+1)return l;let p=[...l];if(Ys(a[o],Error)){Ry(d,u,a);const h=e(n,a[o]),f=p.length;Iy(h,o,f,u),p=Xp(e,n,s,a[o],o,[h,...p],h,f)}return qj(a)&&a.errors.forEach((h,f)=>{if(Ys(h,Error)){Ry(d,u,a);const g=e(n,h),b=p.length;Iy(g,`errors[${f}]`,b,u),p=Xp(e,n,s,h,o,[g,...p],g,b)}}),p}function qj(e){return Array.isArray(e.errors)}function Ry(e,n,s){e.mechanism={handled:!0,type:"auto.core.linked_errors",...qj(s)&&{is_exception_group:!0},...e.mechanism,exception_id:n}}function Iy(e,n,s,a){e.mechanism={handled:!0,...e.mechanism,type:"chained",source:n,exception_id:s,parent_id:a}}function o3(e){return ud(e)&&"__sentry_fetch_url_host__"in e&&typeof e.__sentry_fetch_url_host__=="string"}function Py(e){return o3(e)?`${e.message} (${e.__sentry_fetch_url_host__})`:e.message}const Fy=new Set([]);function l3(e){const n="console",s=Fr(n,e);return Dr(n,c3),s}function c3(){"console"in Ue&&K_.forEach(function(e){e in Ue.console&&sn(Ue.console,e,function(n){return Lc[e]=n,function(...s){const a=s[0],o=Lc[e],l=Fy.size&&typeof a=="string"&&fo(a,Fy);l||Dn("console",{args:s,level:e}),(!l||Ie&&Ae.isEnabled())&&(o==null||o.apply(Ue.console,s))}})})}function d3(e){return e==="warn"?"warning":["fatal","error","warning","log","info","debug"].includes(e)?e:"log"}const u3="Dedupe",m3=(()=>{let e;return{name:u3,processEvent(n){if(n.type)return n;try{if(f3(n,e))return Ie&&Ae.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=n}}}),p3=m3;function f3(e,n){return n?!!(h3(e,n)||x3(e,n)):!1}function h3(e,n){const s=e.message,a=n.message;return!(!s&&!a||s&&!a||!s&&a||s!==a||!Yj(e,n)||!Vj(e,n))}function x3(e,n){const s=Dy(n),a=Dy(e);return!(!s||!a||s.type!==a.type||s.value!==a.value||!Yj(e,n)||!Vj(e,n))}function Vj(e,n){let s=H0(e),a=H0(n);if(!s&&!a)return!0;if(s&&!a||!s&&a||(s=s,a=a,a.length!==s.length))return!1;for(let o=0;o<a.length;o++){const l=a[o],d=s[o];if(l.filename!==d.filename||l.lineno!==d.lineno||l.colno!==d.colno||l.function!==d.function)return!1}return!0}function Yj(e,n){let s=e.fingerprint,a=n.fingerprint;if(!s&&!a)return!0;if(s&&!a||!s&&a)return!1;s=s,a=a;try{return s.join("")===a.join("")}catch{return!1}}function Dy(e){var n,s;return(s=(n=e.exception)==null?void 0:n.values)==null?void 0:s[0]}const g3="ConversationId",y3=(()=>({name:g3,setup(e){e.on("spanStart",n=>{const s=vs().getScopeData(),a=Js().getScopeData(),o=s.conversationId||a.conversationId;if(o){const{op:l,data:d,description:u}=xd(n);if(!(l!=null&&l.startsWith("gen_ai."))&&!d["ai.operationId"]&&!(u!=null&&u.startsWith("ai.")))return;n.setAttribute(Wk,o)}})}})),b3=y3;function Gj(e){if(e!==void 0)return e>=400&&e<500?"warning":e>=500?"error":void 0}const so=Ue;function v3(){return"history"in so&&!!so.history}function j3(){if(!("fetch"in so))return!1;try{return new Headers,new Request("data:,"),new Response,!0}catch{return!1}}function Zp(e){return e&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function w3(){var s;if(typeof EdgeRuntime=="string")return!0;if(!j3())return!1;if(Zp(so.fetch))return!0;let e=!1;const n=so.document;if(n&&typeof n.createElement=="function")try{const a=n.createElement("iframe");a.hidden=!0,n.head.appendChild(a),(s=a.contentWindow)!=null&&s.fetch&&(e=Zp(a.contentWindow.fetch)),n.head.removeChild(a)}catch(a){Ie&&Ae.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",a)}return e}function N3(e,n){const s="fetch",a=Fr(s,e);return Dr(s,()=>_3(void 0,n)),a}function _3(e,n=!1){n&&!w3()||sn(Ue,"fetch",function(s){return function(...a){const o=new Error,{method:l,url:d}=k3(a),u={args:a,fetchData:{method:l,url:d},startTimestamp:fs()*1e3,virtualError:o,headers:S3(a)};return Dn("fetch",{...u}),s.apply(Ue,a).then(async p=>(Dn("fetch",{...u,endTimestamp:fs()*1e3,response:p}),p),p=>{Dn("fetch",{...u,endTimestamp:fs()*1e3,error:p}),ud(p)&&p.stack===void 0&&(p.stack=o.stack,Gs(p,"framesToPop",1));const h=Pt(),f=(h==null?void 0:h.getOptions().enhanceFetchErrorMessages)??"always";if(f!==!1&&p instanceof TypeError&&(p.message==="Failed to fetch"||p.message==="Load failed"||p.message==="NetworkError when attempting to fetch resource."))try{const v=new URL(u.fetchData.url).host;f==="always"?p.message=`${p.message} (${v})`:Gs(p,"__sentry_fetch_url_host__",v)}catch{}throw p}
vendor: 16,584 bytes, line 89
89)}})}function yc(e,n){return!!e&&typeof e=="object"&&!!e[n]}function Oy(e){return typeof e=="string"?e:e?yc(e,"url")?e.url:e.toString?e.toString():"":""}function k3(e){if(e.length===0)return{method:"GET",url:""};if(e.length===2){const[s,a]=e;return{url:Oy(s),method:yc(a,"method")?String(a.method).toUpperCase():dj(s)&&yc(s,"method")?String(s.method).toUpperCase():"GET"}}const n=e[0];return{url:Oy(n),method:yc(n,"method")?String(n.method).toUpperCase():"GET"}}function S3(e){const[n,s]=e;try{if(typeof s=="object"&&s!==null&&"headers"in s&&s.headers)return new Headers(s.headers);if(dj(n))return new Headers(n.headers)}catch{}}const Ge=Ue;let ef=0;function Kj(){return ef>0}function C3(){ef++,setTimeout(()=>{ef--})}function Pa(e,n={}){function s(o){return typeof o=="function"}if(!s(e))return e;try{const o=e.__sentry_wrapped__;if(o)return typeof o=="function"?o:e;if(Wf(e))return e}catch{return e}const a=function(...o){try{const l=o.map(d=>Pa(d,n));return e.apply(this,l)}catch(l){throw C3(),Dk(d=>{d.addEventProcessor(u=>(n.mechanism&&(Hp(u,void 0),La(u,n.mechanism)),u.extra={...u.extra,arguments:o},u)),aC(l)}),l}};try{for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(a[o]=e[o])}catch{}mj(a,e),Gs(e,"__sentry_wrapped__",a);try{Object.getOwnPropertyDescriptor(a,"name").configurable&&Object.defineProperty(a,"name",{get(){return e.name}})}catch{}return a}function $y(){const e=zf(),{referrer:n}=Ge.document||{},{userAgent:s}=Ge.navigator||{},a={...n&&{Referer:n},...s&&{"User-Agent":s}};return{url:e,headers:a}}function Qf(e,n){const s=Jf(e,n),a={type:R3(n),value:I3(n)};return s.length&&(a.stacktrace={frames:s}),a.type===void 0&&a.value===""&&(a.value="Unrecoverable error caught"),a}function E3(e,n,s,a){const o=Pt(),l=o==null?void 0:o.getOptions().normalizeDepth,d=$3(n),u={__serialized__:kj(n,l)};if(d)return{exception:{values:[Qf(e,d)]},extra:u};const p={exception:{values:[{type:pd(n)?n.constructor.name:a?"UnhandledRejection":"Error",value:D3(n,{isUnhandledRejection:a})}]},extra:u};if(s){const h=Jf(e,s);h.length&&(p.exception.values[0].stacktrace={frames:h})}return p}function tp(e,n){return{exception:{values:[Qf(e,n)]}}}function Jf(e,n){const s=n.stacktrace||n.stack||"",a=T3(n),o=L3(n);try{return e(s,a,o)}catch{}return[]}const A3=/Minified React error #\d+;/i;function T3(e){return e&&A3.test(e.message)?1:0}function L3(e){return typeof e.framesToPop=="number"?e.framesToPop:0}function Qj(e){return typeof WebAssembly<"u"&&typeof WebAssembly.Exception<"u"?e instanceof WebAssembly.Exception:!1}function R3(e){const n=e==null?void 0:e.name;return!n&&Qj(e)?e.message&&Array.isArray(e.message)&&e.message.length==2?e.message[0]:"WebAssembly.Exception":n}function I3(e){const n=e==null?void 0:e.message;return Qj(e)?Array.isArray(e.message)&&e.message.length==2?e.message[1]:"wasm exception":n?n.error&&typeof n.error.message=="string"?Py(n.error):Py(e):"No error message"}function P3(e,n,s,a){const o=(s==null?void 0:s.syntheticException)||void 0,l=Xf(e,n,o,a);return La(l),l.level="error",s!=null&&s.event_id&&(l.event_id=s.event_id),yo(l)}function F3(e,n,s="info",a,o){const l=(a==null?void 0:a.syntheticException)||void 0,d=tf(e,n,l,o);return d.level=s,a!=null&&a.event_id&&(d.event_id=a.event_id),yo(d)}function Xf(e,n,s,a,o){let l;if(lj(n)&&n.error)return tp(e,n.error);if(V0(n)||lk(n)){const d=n;if("stack"in n)l=tp(e,n);else{const u=d.name||(V0(d)?"DOMError":"DOMException"),p=d.message?`${u}: ${d.message}`:u;l=tf(e,p,s,a),Hp(l,p)}return"code"in d&&(l.tags={...l.tags,"DOMException.code":`${d.code}`}),l}return ud(n)?tp(e,n):to(n)||pd(n)?(l=E3(e,n,s,o),La(l,{synthetic:!0}),l):(l=tf(e,n,s,a),Hp(l,`${n}`),La(l,{synthetic:!0}),l)}function tf(e,n,s,a){const o={};if(a&&s){const l=Jf(e,s);l.length&&(o.exception={values:[{value:n,stacktrace:{frames:l}}]}),La(o,{synthetic:!0})}if(Bf(n)){const{__sentry_template_string__:l,__sentry_template_values__:d}=n;return o.logentry={message:l,params:d},o}return o.message=n,o}function D3(e,{isUnhandledRejection:n}){const s=hk(e),a=n?"promise rejection":"exception";return lj(e)?`Event \`ErrorEvent\` captured as ${a} with message \`${e.message}\``:pd(e)?`Event \`${O3(e)}\` (type=${e.type}) captured as ${a}`:`Object captured as ${a} with keys: ${s}`}function O3(e){try{const n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{}}function $3(e){return Object.values(e).find(n=>n instanceof Error)}class M3 extends OC{constructor(n){var f;const s=B3(n),a=Ge.SENTRY_SDK_SOURCE||xC();Hj(s,"browser",["browser"],a),(f=s._metadata)!=null&&f.sdk&&(s._metadata.sdk.settings={infer_ip:s.sendDefaultPii?"auto":"never",...s._metadata.sdk.settings}),super(s);const{sendDefaultPii:o,sendClientReports:l,enableLogs:d,_experiments:u,enableMetrics:p}=this._options,h=p??(u==null?void 0:u.enableMetrics)??!0;Ge.document&&(l||d||h)&&Ge.document.addEventListener("visibilitychange",()=>{Ge.document.visibilityState==="hidden"&&(l&&this._flushOutcomes(),d&&Qp(this),h&&Fj(this))}),o&&this.on("beforeSendSession",HC)}eventFromException(n,s){return P3(this._options.stackParser,n,s,this._options.attachStacktrace)}eventFromMessage(n,s="info",a){return F3(this._options.stackParser,n,s,a,this._options.attachStacktrace)}_prepareEvent(n,s,a,o){return n.platform=n.platform||"javascript",super._prepareEvent(n,s,a,o)}}function B3(e){var n;return{release:typeof __SENTRY_RELEASE__=="string"?__SENTRY_RELEASE__:(n=Ge.SENTRY_RELEASE)==null?void 0:n.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...e}}const U3=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Mt=Ue,z3=1e3;let My,nf,sf;function W3(e){Fr("dom",e),Dr("dom",H3)}function H3(){if(!Mt.document)return;const e=Dn.bind(null,"dom"),n=By(e,!0);Mt.document.addEventListener("click",n,!1),Mt.document.addEventListener("keypress",n,!1),["EventTarget","Node"].forEach(s=>{var l,d;const o=(l=Mt[s])==null?void 0:l.prototype;(d=o==null?void 0:o.hasOwnProperty)!=null&&d.call(o,"addEventListener")&&(sn(o,"addEventListener",function(u){return function(p,h,f){if(p==="click"||p=="keypress")try{const g=this.__sentry_instrumentation_handlers__=this.__sentry_instrumentation_handlers__||{},b=g[p]=g[p]||{refCount:0};if(!b.handler){const v=By(e);b.handler=v,u.call(this,p,v,f)}b.refCount++}catch{}return u.call(this,p,h,f)}}),sn(o,"removeEventListener",function(u){return function(p,h,f){if(p==="click"||p=="keypress")try{const g=this.__sentry_instrumentation_handlers__||{},b=g[p];b&&(b.refCount--,b.refCount<=0&&(u.call(this,p,b.handler,f),b.handler=void 0,delete g[p]),Object.keys(g).length===0&&delete this.__sentry_instrumentation_handlers__)}catch{}return u.call(this,p,h,f)}}))})}function q3(e){if(e.type!==nf)return!1;try{if(!e.target||e.target._sentryId!==sf)return!1}catch{}return!0}function V3(e,n){return e!=="keypress"?!1:n!=null&&n.tagName?!(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable):!0}function By(e,n=!1){return s=>{if(!s||s._sentryCaptured)return;const a=Y3(s);if(V3(s.type,a))return;Gs(s,"_sentryCaptured",!0),a&&!a._sentryId&&Gs(a,"_sentryId",gn());const o=s.type==="keypress"?"input":s.type;q3(s)||(e({event:s,name:o,global:n}),nf=s.type,sf=a?a._sentryId:void 0),clearTimeout(My),My=Mt.setTimeout(()=>{sf=void 0,nf=void 0},z3)}}function Y3(e){try{return e.target}catch{return null}}let Hl;function Jj(e){const n="history";Fr(n,e),Dr(n,G3)}function G3(){if(Mt.addEventListener("popstate",()=>{const n=Mt.location.href,s=Hl;if(Hl=n,s===n)return;Dn("history",{from:s,to:n})}),!v3())return;function e(n){return function(...s){const a=s.length>2?s[2]:void 0;if(a){const o=Hl,l=K3(String(a));if(Hl=l,o===l)return n.apply(this,s);Dn("history",{from:o,to:l})}return n.apply(this,s)}}sn(Mt.history,"pushState",e),sn(Mt.history,"replaceState",e)}function K3(e){try{return new URL(e,Mt.location.origin).toString()}catch{return e}}const bc={};function Q3(e){const n=bc[e];if(n)return n;let s=Mt[e];if(Zp(s))return bc[e]=s.bind(Mt);const a=Mt.document;if(a&&typeof a.createElement=="function")try{const o=a.createElement("iframe");o.hidden=!0,a.head.appendChild(o);const l=o.contentWindow;l!=null&&l[e]&&(s=l[e]),a.head.removeChild(o)}catch(o){U3&&Ae.warn(`Could not create sandbox iframe for ${e} check, bailing to window.${e}: `,o)}return s&&(bc[e]=s.bind(Mt))}function J3(e){bc[e]=void 0}const Vi="__sentry_xhr_v3__";function X3(e){Fr("xhr",e),Dr("xhr",Z3)}function Z3(){if(!Mt.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;e.open=new Proxy(e.open,{apply(n,s,a){const o=new Error,l=fs()*1e3,d=ps(a[0])?a[0].toUpperCase():void 0,u=e4(a[1]);if(!d||!u)return n.apply(s,a);s[Vi]={method:d,url:u,request_headers:{}},d==="POST"&&u.match(/sentry_key/)&&(s.__sentry_own_request__=!0);const p=()=>{const h=s[Vi];if(h&&s.readyState===4){try{h.status_code=s.status}catch{}const f={endTimestamp:fs()*1e3,startTimestamp:l,xhr:s,virtualError:o};Dn("xhr",f)}};return"onreadystatechange"in s&&typeof s.onreadystatechange=="function"?s.onreadystatechange=new Proxy(s.onreadystatechange,{apply(h,f,g){return p(),h.apply(f,g)}}):s.addEventListener("readystatechange",p),s.setRequestHeader=new Proxy(s.setRequestHeader,{apply(h,f,g){const[b,v]=g,N=f[Vi];return N&&ps(b)&&ps(v)&&(N.request_headers[b.toLowerCase()]=v),h.apply(f,g)}}),n.apply(s,a)}}),e.send=new Proxy(e.send,{apply(n,s,a){const o=s[Vi];if(!o)return n.apply(s,a);a[0]!==void 0&&(o.body=a[0]);const l={startTimestamp:fs()*1e3,xhr:s};return Dn("xhr",l),n.apply(s,a)}})}function e4(e){if(ps(e))return e;try{return e.toString()}catch{}}const t4=40;function n4(e,n=Q3("fetch")){let s=0,a=0;async function o(l){const d=l.body.length;s+=d,a++;const u={body:l.body,method:"POST",referrerPolicy:"strict-origin",headers:e.headers,keepalive:s<=6e4&&a<15,...e.fetchOptions};try{const p=await n(e.url,u);return{statusCode:p.status,headers:{"x-sentry-rate-limits":p.headers.get("X-Sentry-Rate-Limits"),"retry-after":p.headers.get("Retry-After")}}}catch(p){throw J3("fetch"),p}finally{s-=d,a--}}return RC(e,o,Kf(e.bufferSize||t4))}const gd=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,s4=30,r4=50;function rf(e,n,s,a){const o={filename:e,function:n==="<anonymous>"?Cr:n,in_app:!0};return s!==void 0&&(o.lineno=s),a!==void 0&&(o.colno=a),o}const a4=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,i4=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,o4=/\((\S*)(?::(\d+))(?::(\d+))\)/,l4=/at (.+?) ?\(data:(.+?),/,c4=e=>{var o;const n=e.match(l4);if(n)return{filename:`<data:${n[2]}>`,function:n[1]};const s=a4.exec(e);if(s){const[,l,d,u]=s;return rf(l,Cr,+d,+u)}const a=i4.exec(e);if(a){if(((o=a[2])==null?void 0:o.indexOf("eval"))===0){const p=o4.exec(a[2]);p&&(a[2]=p[1],a[3]=p[2],a[4]=p[3])}const[d,u]=Xj(a[1]||Cr,a[2]);return rf(u,d,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},d4=[s4,c4],u4=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,m4=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,p4=e=>{const n=u4.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const l=m4.exec(n[3]);l&&(n[1]=n[1]||"eval",n[3]=l[1],n[4]=l[2],n[5]="")}let a=n[3],o=n[1]||Cr;return[o,a]=Xj(o,a),rf(a,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},f4=[r4,p4],h4=[d4,f4],x4=aj(...h4),Xj=(e,n)=>{const s=e.indexOf("safari-extension")!==-1,a=e.indexOf("safari-web-extension")!==-1;return s||a?[e.indexOf("@")!==-1?e.split("@")[0]:Cr,s?`safari-extension:${n}`:`safari-web-extension:${n}`]:[e,n]},ql=1024,g4="Breadcrumbs",y4=((e={})=>{const n={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:g4,setup(s){n.console&&l3(w4(s)),n.dom&&W3(j4(s,n.dom)),n.xhr&&X3(N4(s)),n.fetch&&N3(_4(s)),n.history&&Jj(k4(s)),n.sentry&&s.on("beforeSendEvent",v4(s))}}}),b4=y4;function v4(e){return function(s){Pt()===e&&Er({category:`sentry.${s.type==="transaction"?"transaction":"event"}`,event_id:s.event_id,level:s.level,message:yr(s)},{event:s})}}function j4(e,n){return function(a){if(Pt()!==e)return;let o,l,d=typeof n=="object"?n.serializeAttribute:void 0,u=typeof n=="object"&&typeof n.maxStringLength=="number"?n.maxStringLength:void 0;u&&u>ql&&(gd&&Ae.warn(`\`dom.maxStringLength\` cannot exceed ${ql}, but a value of ${u} was configured. Sentry will use ${ql} instead.`),u=ql),typeof d=="string"&&(d=[d]);try{const h=a.event,f=S4(h)?h.target:h;o=uj(f,{keyAttrs:d,maxStringLength:u}),l=fk(f)}catch{o="<unknown>"}if(o.length===0)return;const p={category:`ui.${a.name}`,message:o};l&&(p.data={"ui.component_name":l}),Er(p,{event:a.event,name:a.name,global:a.global})}}function w4(e){return function(s){if(Pt()!==e)return;const a={category:"console",data:{arguments:s.args,logger:"console"},level:d3(s.level),message:K0(s.args," ")};if(s.level==="assert")if(s.args[0]===!1)a.message=`Assertion failed: ${K0(s.args.slice(1)," ")||"console.assert"}`,a.data.arguments=s.args.slice(1);else return;Er(a,{input:s.args,level:s.level})}}function N4(e){return function(s){if(Pt()!==e)return;const{startTimestamp:a,endTimestamp:o}=s,l=s.xhr[Vi];if(!a||!o||!l)return;const{method:d,url:u,status_code:p,body:h}=l,f={method:d,url:u,status_code:p},g={xhr:s.xhr,input:h,startTimestamp:a,endTimestamp:o},b={category:"xhr",data:f,type:"http",level:Gj(p)};e.emit("beforeOutgoingRequestBreadcrumb",b,g),Er(b,g)}}function _4(e){return function(s){if(Pt()!==e)return;const{startTimestamp:a,endTimestamp:o}=s;if(o&&!(s.fetchData.url.match(/sentry_key/)&&s.fetchData.method==="POST"))if(s.error){const l={data:s.error,input:s.args,startTimestamp:a,endTimestamp:o},d={category:"fetch",data:s.fetchData,level:"error",type:"http"};e.emit("beforeOutgoingRequestBreadcrumb",d,l),Er(d,l)}else{const l=s.response,d={...s.fetchData,status_code:l==null?void 0:l.status},u={input:s.args,response:l,startTimestamp:a,endTimestamp:o},p={category:"fetch",data:d,type:"http",level:Gj(d.status_code)};e.emit("beforeOutgoingRequestBreadcrumb",p,u),Er(p,u)}}}function k4(e){return function(s){if(Pt()!==e)return;let a=s.from,o=s.to;const l=Jm(Ge.location.href);let d=a?Jm(a):void 0;const u=Jm(o);d!=null&&d.path||(d=l),l.protocol===u.protocol&&l.host===u.host&&(o=u.relative),l.protocol===d.protocol&&l.host===d.host&&(a=d.relative),Er({category:"navigation",data:{from:a,to:o}})}}function S4(e){return!!e&&!!e.target}const C4="EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(","),E4="BrowserApiErrors",A4=((e={})=>{const n={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...e};return{name:E4,setupOnce(){n.setTimeout&&sn(Ge,"setTimeout",Uy),n.setInterval&&sn(Ge,"setInterval",Uy),n.requestAnimationFrame&&sn(Ge,"requestAnimationFrame",L4),n.XMLHttpRequest&&"XMLHttpRequest"in Ge&&sn(XMLHttpRequest.prototype,"send",R4);const s=n.eventTarget;s&&(Array.isArray(s)?s:C4).forEach(o=>I4(o,n))}}}),T4=A4;function Uy(e){return function(...n){const s=n[0];return n[0]=Pa(s,{mechanism:{handled:!1,type:`auto.browser.browserapierrors.${Vs(e)}`}}),e.apply(this,n)}}function L4(e){return function(n){return e.apply(this,[Pa(n,{mechanism:{data:{handler:Vs(e)},handled:!1,type:"auto.browser.browserapierrors.requestAnimationFrame"}})])}}function R4(e){return function(...n){const s=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(o=>{o in s&&typeof s[o]=="function"&&sn(s,o,function(l){const d={mechanism:{data:{handler:Vs(l)},handled:!1,type:`auto.browser.browserapierrors.xhr.${o}`}},u=Wf(l);return u&&(d.mechanism.data.handler=Vs(u)),Pa(l,d)})}),e.apply(this,n)}}function I4(e,n){var o,l;const a=(o=Ge[e])==null?void 0:o.prototype;(l=a==null?void 0:a.hasOwnProperty)!=null&&l.call(a,"addEventListener")&&(sn(a,"addEventListener",function(d){return function(u,p,h){try{P4(p)&&(p.handleEvent=Pa(p.handleEvent,{mechanism:{data:{handler:Vs(p),target:e},handled:!1,type:"auto.browser.browserapierrors.handleEvent"}}))}catch{}return n.unregisterOriginalCallbacks&&F4(this,u,p),d.apply(this,[u,Pa(p,{mechanism:{data:{handler:Vs(p),target:e},handled:!1,type:"auto.browser.browserapierrors.addEventListener"}}),h])}}),sn(a,"removeEventListener",function(d){return function(u,p,h){try{const f=p.__sentry_wrapped__;f&&d.call(this,u,f,h)}catch{}return d.call(this,u,p,h)}}))}function P4(e){return typeof e.handleEvent=="function"}
89function F4(e,n,s){e&&typeof e=="object"&&"removeEventListener"in e&&typeof e.removeEventListener=="function"&&e.removeEventListener(n,s)}const D4=(e={})=>{const n=e.lifecycle??"route";return{name:"BrowserSession",setupOnce(){if(typeof Ge.document>"u"){gd&&Ae.warn("Using the `browserSessionIntegration` in non-browser environments is not supported.");return}by({ignoreDuration:!0}),Zm();const s=Js();let a=s.getUser();s.addScopeListener(o=>{const l=o.getUser();((a==null?void 0:a.id)!==(l==null?void 0:l.id)||(a==null?void 0:a.ip_address)!==(l==null?void 0:l.ip_address))&&(Zm(),a=l)}),n==="route"&&Jj(({from:o,to:l})=>{o!==l&&(by({ignoreDuration:!0}),Zm())})}}},O4="CultureContext",$4=(()=>({name:O4,preprocessEvent(e){var s;const n=zy();n&&(e.contexts={...e.contexts,culture:{...n,...(s=e.contexts)==null?void 0:s.culture}})},processSegmentSpan(e){const n=zy();n&&Aj(e,{"culture.locale":n.locale,"culture.timezone":n.timezone,"culture.calendar":n.calendar})}})),M4=$4;function zy(){try{const e=Ge.Intl;if(!e)return;const n=e.DateTimeFormat().resolvedOptions();return{locale:n.locale,timezone:n.timeZone,calendar:n.calendar}}catch{return}}const B4="GlobalHandlers",U4=((e={})=>{const n={onerror:!0,onunhandledrejection:!0,...e};return{name:B4,setupOnce(){Error.stackTraceLimit=50},setup(s){n.onerror&&(W4(s),Wy("onerror")),n.onunhandledrejection&&(H4(s),Wy("onunhandledrejection"))}}}),z4=U4;function W4(e){rk(n=>{const{stackParser:s,attachStacktrace:a}=Zj();if(Pt()!==e||Kj())return;const{msg:o,url:l,line:d,column:u,error:p}=n,h=Y4(Xf(s,p||o,void 0,a,!1),l,d,u);h.level="error",Tj(h,{originalException:p,mechanism:{handled:!1,type:"auto.browser.global_handlers.onerror"}})})}function H4(e){ik(n=>{const{stackParser:s,attachStacktrace:a}=Zj();if(Pt()!==e||Kj())return;const o=q4(n),l=md(o)?V4(o):Xf(s,o,void 0,a,!0);l.level="error",Tj(l,{originalException:o,mechanism:{handled:!1,type:"auto.browser.global_handlers.onunhandledrejection"}})})}function q4(e){if(md(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}function V4(e){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(e)}`}]}}}function Y4(e,n,s,a){const o=e.exception=e.exception||{},l=o.values=o.values||[],d=l[0]=l[0]||{},u=d.stacktrace=d.stacktrace||{},p=u.frames=u.frames||[];return p.length===0&&p.push({colno:a,lineno:s,filename:G4(n)??zf(),function:Cr,in_app:!0}),e}function Wy(e){gd&&Ae.log(`Global Handler attached: ${e}`)}function Zj(){const e=Pt();return(e==null?void 0:e.getOptions())||{stackParser:()=>[],attachStacktrace:!1}}function G4(e){if(!(!ps(e)||e.length===0))return e.startsWith("data:")?`<${KS(e,!1)}>`:e}const K4=()=>({name:"HttpContext",preprocessEvent(e){var a;if(!Ge.navigator&&!Ge.location&&!Ge.document)return;const n=$y(),s={...n.headers,...(a=e.request)==null?void 0:a.headers};e.request={...n,...e.request,headers:s}},processSegmentSpan(e){if(!Ge.navigator&&!Ge.location&&!Ge.document)return;const n=$y();Aj(e,{"url.full":n.url||void 0,"http.request.header.user_agent":n.headers["User-Agent"],"http.request.header.referer":n.headers.Referer})}}),Q4="cause",J4=5,X4="LinkedErrors",Z4=((e={})=>{const n=e.limit||J4,s=e.key||Q4;return{name:X4,preprocessEvent(a,o,l){const d=l.getOptions();i3(Qf,d.stackParser,s,n,a,o)}}}),eE=Z4;function tE(){return nE()?(gd&&za(()=>{console.error("[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/")}),!0):!1}function nE(){var o;if(typeof Ge.window>"u")return!1;const e=Ge;if(e.nw)return!1;const n=e.chrome||e.browser;if(!((o=n==null?void 0:n.runtime)!=null&&o.id))return!1;const s=zf();return!(Ge===Ge.top&&/^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\/\//.test(s))}function sE(e){return[XC(),GC(),b3(),T4(),b4(),z4(),eE(),p3(),K4(),M4(),D4()]}function rE(e={}){const n=!e.skipBrowserExtensionCheck&&tE();let s=e.defaultIntegrations==null?sE():e.defaultIntegrations;const a={...e,enabled:n?!1:e.enabled,stackParser:nk(e.stackParser||x4),integrations:pC({integrations:e.integrations,defaultIntegrations:s}),transport:e.transport||n4};return zC(M3,a)}function aE(e){const n={...e};return Hj(n,"react"),iC("react",{version:x.version}),rE(n)}function kt(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var iE=typeof Symbol=="function"&&Symbol.observable||"@@observable",Hy=iE,np=()=>Math.random().toString(36).substring(7).split("").join("."),oE={INIT:`@@redux/INIT${np()}`,REPLACE:`@@redux/REPLACE${np()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${np()}`},Pc=oE;function Zf(e){if(typeof e!="object"||e===null)return!1;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n||Object.getPrototypeOf(e)===null}function e1(e,n,s){if(typeof e!="function")throw new Error(kt(2));if(typeof n=="function"&&typeof s=="function"||typeof s=="function"&&typeof arguments[3]=="function")throw new Error(kt(0));if(typeof n=="function"&&typeof s>"u"&&(s=n,n=void 0),typeof s<"u"){if(typeof s!="function")throw new Error(kt(1));return s(e1)(e,n)}let a=e,o=n,l=new Map,d=l,u=0,p=!1;function h(){d===l&&(d=new Map,l.forEach((k,_)=>{d.set(_,k)}))}function f(){if(p)throw new Error(kt(3));return o}function g(k){if(typeof k!="function")throw new Error(kt(4));if(p)throw new Error(kt(5));let _=!0;h();const S=u++;return d.set(S,k),function(){if(_){if(p)throw new Error(kt(6));_=!1,h(),d.delete(S),l=null}}}function b(k){if(!Zf(k))throw new Error(kt(7));if(typeof k.type>"u")throw new Error(kt(8));if(typeof k.type!="string")throw new Error(kt(17));if(p)throw new Error(kt(9));try{p=!0,o=a(o,k)}finally{p=!1}
89return(l=d).forEach(S=>{S()}),k}function v(k){if(typeof k!="function")throw new Error(kt(10));a=k,b({type:Pc.REPLACE})}function N(){const k=g;return{subscribe(_){if(typeof _!="object"||_===null)throw new Error(kt(11));function S(){const E=_;E.next&&E.next(f())}return S(),{unsubscribe:k(S)}},[Hy](){return this}}}return b({type:Pc.INIT}),{dispatch:b,subscribe:g,getState:f,replaceReducer:v,[Hy]:N}}function lE(e){Object.keys(e).forEach(n=>{const s=e[n];if(typeof s(void 0,{type:Pc.INIT})>"u")throw new Error(kt(12));if(typeof s(void 0,{type:Pc.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(kt(13))})}function cE(e){const n=Object.keys(e),s={};for(let l=0;l<n.length;l++){const d=n[l];typeof e[d]=="function"&&(s[d]=e[d])}const a=Object.keys(s);let o;try{lE(s)}catch(l){o=l}return function(d={},u){if(o)throw o;let p=!1;const h={};for(let f=0;f<a.length;f++){const g=a[f],b=s[g],v=d[g],N=b(v,u);if(typeof N>"u")throw u&&u.type,new Error(kt(14));h[g]=N,p=p||N!==v}return p=p||a.length!==Object.keys(d).length,p?h:d}}function Fc(...e){return e.length===0?n=>n:e.length===1?e[0]:e.reduce((n,s)=>(...a)=>n(s(...a)))}function dE(...e){return n=>(s,a)=>{const o=n(s,a);let l=()=>{throw new Error(kt(15))};const d={getState:o.getState,dispatch:(p,...h)=>l(p,...h)},u=e.map(p=>p(d));return l=Fc(...u)(o.dispatch),{...o,dispatch:l}}}function uE(e){return Zf(e)&&"type"in e&&typeof e.type=="string"}var t1=Symbol.for("immer-nothing"),qy=Symbol.for("immer-draftable"),Ut=Symbol.for("immer-state");function Fn(e,...n){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var rn=Object,Fa=rn.getPrototypeOf,Dc="constructor",yd="prototype",af="configurable",Oc="enumerable",vc="writable",ro="value",gs=e=>!!e&&!!e[Ut];function $n(e){var n;return e?n1(e)||vd(e)||!!e[qy]||!!((n=e[Dc])!=null&&n[qy])||jd(e)||wd(e):!1}var mE=rn[yd][Dc].toString(),Vy=new WeakMap;function n1(e){if(!e||!eh(e))return!1;const n=Fa(e);if(n===null||n===rn[yd])return!0;const s=rn.hasOwnProperty.call(n,Dc)&&n[Dc];if(s===Object)return!0;if(!_a(s))return!1;let a=Vy.get(s);return a===void 0&&(a=Function.toString.call(s),Vy.set(s,a)),a===mE}function bd(e,n,s=!0){bo(e)===0?(s?Reflect.ownKeys(e):rn.keys(e)).forEach(o=>{n(o,e[o],e)}):e.forEach((a,o)=>n(o,a,e))}function bo(e){const n=e[Ut];return n?n.type_:vd(e)?1:jd(e)?2:wd(e)?3:0}var Yy=(e,n,s=bo(e))=>s===2?e.has(n):rn[yd].hasOwnProperty.call(e,n),of=(e,n,s=bo(e))=>s===2?e.get(n):e[n],$c=(e,n,s,a=bo(e))=>{a===2?e.set(n,s):a===3?e.add(s):e[n]=s};function pE(e,n){return e===n?e!==0||1/e===1/n:e!==e&&n!==n}var vd=Array.isArray,jd=e=>e instanceof Map,wd=e=>e instanceof Set,eh=e=>typeof e=="object",_a=e=>typeof e=="function",sp=e=>typeof e=="boolean";function fE(e){const n=+e;return Number.isInteger(n)&&String(n)===e}var ms=e=>e.copy_||e.base_,th=e=>e.modified_?e.copy_:e.base_;function lf(e,n){if(jd(e))return new Map(e);if(wd(e))return new Set(e);if(vd(e))return Array[yd].slice.call(e);const s=n1(e);if(n===!0||n==="class_only"&&!s){const a=rn.getOwnPropertyDescriptors(e);delete a[Ut];let o=Reflect.ownKeys(a);for(let l=0;l<o.length;l++){const d=o[l],u=a[d];u[vc]===!1&&(u[vc]=!0,u[af]=!0),(u.get||u.set)&&(a[d]={[af]:!0,[vc]:!0,[Oc]:u[Oc],[ro]:e[d]})}return rn.create(Fa(e),a)}else{const a=Fa(e);if(a!==null&&s)return{...e};const o=rn.create(a);return rn.assign(o,e)}}function nh(e,n=!1){return Nd(e)||gs(e)||!$n(e)||(bo(e)>1&&rn.defineProperties(e,{set:Vl,add:Vl,clear:Vl,delete:Vl}),rn.freeze(e),n&&bd(e,(s,a)=>{nh(a,!0)},!1)),e}function hE(){Fn(2)}var Vl={[ro]:hE};function Nd(e){return e===null||!eh(e)?!0:rn.isFrozen(e)}var Mc="MapSet",cf="Patches",Gy="ArrayMethods",s1={};function Ar(e){const n=s1[e];return n||Fn(0,e),n}var Ky=e=>!!s1[e],ao,r1=()=>ao,xE=(e,n)=>({drafts_:[],parent_:e,immer_:n,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ky(Mc)?Ar(Mc):void 0,arrayMethodsPlugin_:Ky(Gy)?Ar(Gy):void 0});function Qy(e,n){n&&(e.patchPlugin_=Ar(cf),e.patches_=[],e.inversePatches_=[],e.patchListener_=n)}function df(e){uf(e),e.drafts_.forEach(gE),e.drafts_=null}function uf(e){e===ao&&(ao=e.parent_)}var Jy=e=>ao=xE(ao,e);function gE(e){const n=e[Ut];n.type_===0||n.type_===1?n.revoke_():n.revoked_=!0}
89function Xy(e,n){n.unfinalizedDrafts_=n.drafts_.length;const s=n.drafts_[0];if(e!==void 0&&e!==s){s[Ut].modified_&&(df(n),Fn(4)),$n(e)&&(e=Zy(n,e));const{patchPlugin_:o}=n;o&&o.generateReplacementPatches_(s[Ut].base_,e,n)}else e=Zy(n,s);return yE(n,e,!0),df(n),n.patches_&&n.patchListener_(n.patches_,n.inversePatches_),e!==t1?e:void 0}function Zy(e,n){if(Nd(n))return n;const s=n[Ut];if(!s)return Bc(n,e.handledSet_,e);if(!_d(s,e))return n;if(!s.modified_)return s.base_;if(!s.finalized_){const{callbacks_:a}=s;if(a)for(;a.length>0;)a.pop()(e);o1(s,e)}return s.copy_}function yE(e,n,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&nh(n,s)}function a1(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var _d=(e,n)=>e.scope_===n,bE=[];function i1(e,n,s,a){const o=ms(e),l=e.type_;if(a!==void 0&&of(o,a,l)===n){$c(o,a,s,l);return}if(!e.draftLocations_){const u=e.draftLocations_=new Map;bd(o,(p,h)=>{if(gs(h)){const f=u.get(h)||[];f.push(p),u.set(h,f)}})}const d=e.draftLocations_.get(n)??bE;for(const u of d)$c(o,u,s,l)}function vE(e,n,s){e.callbacks_.push(function(o){var u;const l=n;if(!l||!_d(l,o))return;(u=o.mapSetPlugin_)==null||u.fixSetContents(l);const d=th(l);i1(e,l.draft_??l,d,s),o1(l,o)})}function o1(e,n){var a;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((a=e.assigned_)==null?void 0:a.size)??0)>0)){const{patchPlugin_:o}=n;if(o){const l=o.getPath(e);l&&o.generatePatches_(e,l,n)}a1(e)}}function jE(e,n,s){const{scope_:a}=e;if(gs(s)){const o=s[Ut];_d(o,a)&&o.callbacks_.push(function(){jc(e);const d=th(o);i1(e,s,d,n)})}else $n(s)&&e.callbacks_.push(function(){const l=ms(e);e.type_===3?l.has(s)&&Bc(s,a.handledSet_,a):of(l,n,e.type_)===s&&a.drafts_.length>1&&(e.assigned_.get(n)??!1)===!0&&e.copy_&&Bc(of(e.copy_,n,e.type_),a.handledSet_,a)})}function Bc(e,n,s){return!s.immer_.autoFreeze_&&s.unfinalizedDrafts_<1||gs(e)||n.has(e)||!$n(e)||Nd(e)||(n.add(e),bd(e,(a,o)=>{if(gs(o)){const l=o[Ut];if(_d(l,s)){const d=th(l);$c(e,a,d,e.type_),a1(l)}}else $n(o)&&Bc(o,n,s)})),e}function wE(e,n){const s=vd(e),a={type_:s?1:0,scope_:n?n.scope_:r1(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:n,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=a,l=Uc;s&&(o=[a],l=io);const{revoke:d,proxy:u}=Proxy.revocable(o,l);return a.draft_=u,a.revoke_=d,[u,a]}var Uc={get(e,n){if(n===Ut)return e;let s=e.scope_.arrayMethodsPlugin_;const a=e.type_===1&&typeof n=="string";if(a&&s!=null&&s.isArrayOperationMethod(n))return s.createMethodInterceptor(e,n);const o=ms(e);if(!Yy(o,n,e.type_))return NE(e,o,n);const l=o[n];if(e.finalized_||!$n(l)||a&&e.operationMethod&&(s!=null&&s.isMutatingArrayMethod(e.operationMethod))&&fE(n))return l;if(l===rp(e.base_,n)){jc(e);const d=e.type_===1?+n:n,u=pf(e.scope_,l,e,d);return e.copy_[d]=u}return l},has(e,n){return n in ms(e)},ownKeys(e){return Reflect.ownKeys(ms(e))},set(e,n,s){const a=l1(ms(e),n);if(a!=null&&a.set)return a.set.call(e.draft_,s),!0;if(!e.modified_){const o=rp(ms(e),n),l=o==null?void 0:o[Ut];if(l&&l.base_===s)return e.copy_[n]=s,e.assigned_.set(n,!1),!0;if(pE(s,o)&&(s!==void 0||Yy(e.base_,n,e.type_)))return!0;jc(e),mf(e)}return e.copy_[n]===s&&(s!==void 0||n in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[n])||(e.copy_[n]=s,e.assigned_.set(n,!0),jE(e,n,s)),!0},deleteProperty(e,n){return jc(e),rp(e.base_,n)!==void 0||n in e.base_?(e.assigned_.set(n,!1),mf(e)):e.assigned_.delete(n),e.copy_&&delete e.copy_[n],!0},getOwnPropertyDescriptor(e,n){const s=ms(e),a=Reflect.getOwnPropertyDescriptor(s,n);return a&&{[vc]:!0,[af]:e.type_!==1||n!=="length",[Oc]:a[Oc],[ro]:s[n]}},defineProperty(){Fn(11)},getPrototypeOf(e){return Fa(e.base_)},setPrototypeOf(){Fn(12)}},io={};for(let e in Uc){let n=Uc[e];io[e]=function(){const s=arguments;return s[0]=s[0][0],n.apply(this,s)}}io.deleteProperty=function(e,n){return io.set.call(this,e,n,void 0)};io.set=function(e,n,s){return Uc.set.call(this,e[0],n,s,e[0])};function rp(e,n){const s=e[Ut];return(s?ms(s):e)[n]}function NE(e,n,s){var o;const a=l1(n,s);return a?ro in a?a[ro]:(o=a.get)==null?void 0:o.call(e.draft_):void 0}function l1(e,n){if(!(n in e))return;let s=Fa(e);for(;s;){const a=Object.getOwnPropertyDescriptor(s,n);if(a)return a;s=Fa(s)}}function mf(e){e.modified_||(e.modified_=!0,e.parent_&&mf(e.parent_))}function jc(e){e.copy_||(e.assigned_=new Map,e.copy_=lf(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var _E=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,s,a)=>
89{if(_a(n)&&!_a(s)){const l=s;s=n;const d=this;return function(p=l,...h){return d.produce(p,f=>s.call(this,f,...h))}}_a(s)||Fn(6),a!==void 0&&!_a(a)&&Fn(7);let o;if($n(n)){const l=Jy(this),d=pf(l,n,void 0);let u=!0;try{o=s(d),u=!1}finally{u?df(l):uf(l)}return Qy(l,a),Xy(o,l)}else if(!n||!eh(n)){if(o=s(n),o===void 0&&(o=n),o===t1&&(o=void 0),this.autoFreeze_&&nh(o,!0),a){const l=[],d=[];Ar(cf).generateReplacementPatches_(n,o,{patches_:l,inversePatches_:d}),a(l,d)}return o}else Fn(1,n)},this.produceWithPatches=(n,s)=>{if(_a(n))return(d,...u)=>this.produceWithPatches(d,p=>n(p,...u));let a,o;return[this.produce(n,s,(d,u)=>{a=d,o=u}),a,o]},sp(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),sp(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),sp(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){$n(e)||Fn(8),gs(e)&&(e=kE(e));const n=Jy(this),s=pf(n,e,void 0);return s[Ut].isManual_=!0,uf(n),s}finishDraft(e,n){const s=e&&e[Ut];(!s||!s.isManual_)&&Fn(9);const{scope_:a}=s;return Qy(a,n),Xy(void 0,a)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let s;for(s=n.length-1;s>=0;s--){const o=n[s];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}s>-1&&(n=n.slice(s+1));const a=Ar(cf).applyPatches_;return gs(e)?a(e,n):this.produce(e,o=>a(o,n))}};function pf(e,n,s,a){const[o,l]=jd(n)?Ar(Mc).proxyMap_(n,s):wd(n)?Ar(Mc).proxySet_(n,s):wE(n,s);return((s==null?void 0:s.scope_)??r1()).drafts_.push(o),l.callbacks_=(s==null?void 0:s.callbacks_)??[],l.key_=a,s&&a!==void 0?vE(s,l,a):l.callbacks_.push(function(p){var f;(f=p.mapSetPlugin_)==null||f.fixSetContents(l);const{patchPlugin_:h}=p;l.modified_&&h&&h.generatePatches_(l,[],p)}),o}function kE(e){return gs(e)||Fn(10,e),c1(e)}function c1(e){if(!$n(e)||Nd(e))return e;const n=e[Ut];let s,a=!0;if(n){if(!n.modified_)return n.base_;n.finalized_=!0,s=lf(e,n.scope_.immer_.useStrictShallowCopy_),a=n.scope_.immer_.shouldUseStrictIteration()}else s=lf(e,!0);return bd(s,(o,l)=>{$c(s,o,c1(l))},a),n&&(n.finalized_=!1),s}var SE=new _E,d1=SE.produce;function u1(e){return({dispatch:s,getState:a})=>o=>l=>typeof l=="function"?l(s,a,e):o(l)}var CE=u1(),EE=u1,AE=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Fc:Fc.apply(null,arguments)};function eb(e,n){function s(...a){if(n){let o=n(...a);if(!o)throw new Error(hs(0));return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:a[0]}}return s.toString=()=>`${e}`,s.type=e,s.match=a=>uE(a)&&a.type===e,s}var m1=class Yi extends Array{constructor(...n){super(...n),Object.setPrototypeOf(this,Yi.prototype)}static get[Symbol.species](){return Yi}concat(...n){return super.concat.apply(this,n)}prepend(...n){return n.length===1&&Array.isArray(n[0])?new Yi(...n[0].concat(this)):new Yi(...n.concat(this))}};function tb(e){return $n(e)?d1(e,()=>{}):e}function Yl(e,n,s){return e.has(n)?e.get(n):e.set(n,s(n)).get(n)}function TE(e){return typeof e=="boolean"}var LE=()=>function(n){const{thunk:s=!0,immutableCheck:a=!0,serializableCheck:o=!0,actionCreatorCheck:l=!0}=n??{};let d=new m1;return s&&(TE(s)?d.push(CE):d.push(EE(s.extraArgument))),d},RE="RTK_autoBatch",nb=e=>n=>{setTimeout(n,e)},IE=(e,n)=>s=>{let a=!1;const o=()=>{a||(a=!0,cancelAnimationFrame(l),clearTimeout(d),s())},l=e(o),d=setTimeout(o,n)},PE=(e={type:"raf"})=>n=>(...s)=>{const a=n(...s);let o=!0,l=!1,d=!1;const u=new Set,p=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?IE(window.requestAnimationFrame,100):nb(10):e.type==="callback"?e.queueNotification:nb(e.timeout),h=()=>{d=!1,l&&(l=!1,u.forEach(f=>f()))};return Object.assign({},a,{subscribe(f){const g=()=>o&&f(),b=a.subscribe(g);return u.add(f),()=>{b(),u.delete(f)}},dispatch(f){var g;try{return o=!((g=f==null?void 0:f.meta)!=null&&g[RE]),l=!o,l&&(d||(d=!0,p(h))),a.dispatch(f)}finally{o=!0}}})},FE=e=>function(s){const{autoBatch:a=!0}=s??{};let o=new m1(e);return a&&o.push(PE(typeof a=="object"?a:void 0)),o};function DE(e){const n=LE(),{reducer:s=void 0,middleware:a,devTools:o=!0,preloadedState:l=void 0,enhancers:d=void 0}=e||{};let u;if(typeof s=="function")u=s;else if(Zf(s))u=cE(s);else throw new Error(hs(1));let p;typeof a=="function"?p=a(n):p=n();let h=Fc;o&&(h=AE({trace:!1,...typeof o=="object"&&o}));const f=dE(...p),g=FE(f);let b=typeof d=="function"?d(g):g();const v=h(...b);return e1(u,l,v)}function p1(e){const n={},s=[];let a;const o={addCase(l,d){const u=typeof l=="string"?l:l.type;if(!u)throw new Error(hs(28));if(u in n)throw new Error(hs(29));return n[u]=d,o},addAsyncThunk(l,d){return d.pending&&(n[l.pending.type]=d.pending),d.rejected&&(n[l.rejected.type]=d.rejected),d.fulfilled&&(n[l.fulfilled.type]=d.fulfilled),d.settled&&s.push({matcher:l.settled,reducer:d.settled}),o},addMatcher(l,d){return s.push({matcher:l,reducer:d}),o},addDefaultCase(l){return a=l,o}};return e(o),[n,s,a]}function OE(e){return typeof e=="function"}function $E(e,n){let[s,a,o]=p1(n),l;if(OE(e))l=()=>tb(e());else{const u=tb(e);l=()=>u}function d(u=l(),p){let h=[s[p.type],...a.filter(({matcher:f})=>f(p)).map(({reducer:f})=>f)];return h.filter(f=>!!f).length===0&&(h=[o]),h.reduce((f,g)=>{if(g)if(gs(f)){const v=g(f,p);return v===void 0?f:v}else{if($n(f))return d1(f,b=>g(b,p));{const b=g(f,p);if(b===void 0){if(f===null)return f;throw Error("A case reducer on a non-draftable value must not return undefined")}return b}}return f},u)}return d.getInitialState=l,d}var ME=Symbol.for("rtk-slice-createasyncthunk");function BE(e,n){return`${e}/${n}`}function UE({creators:e}={}){var s;const n=(s=e==null?void 0:e.asyncThunk)==null?void 0:s[ME];return function(o){const{name:l,reducerPath:d=l}=o;if(!l)throw new Error(hs(11));const u=(typeof o.reducers=="function"?o.reducers(WE()):o.reducers)||{},p=Object.keys(u),h={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},f={addCase(E,A){const I=typeof E=="string"?E:E.type;if(!I)throw new Error(hs(12));if(I in h.sliceCaseReducersByType)throw new Error(hs(13));return h.sliceCaseReducersByType[I]=A,f},addMatcher(E,A){return h.sliceMatchers.push({matcher:E,reducer:A}),f},exposeAction(E,A){return h.actionCreators[E]=A,f},exposeCaseReducer(E,A){return h.sliceCaseReducersByName[E]=A,f}};p.forEach(E=>{const A=u[E],I={reducerName:E,type:BE(l,E),createNotation:typeof o.reducers=="function"};qE(A)?YE(I,A,f,n):HE(I,A,f)});function g(){const[E={},A=[],I=void 0]=typeof o.extraReducers=="function"?p1(o.extraReducers):[o.extraReducers],R={...E,...h.sliceCaseReducersByType};return $E(o.initialState,W=>{for(let Y in R)W.addCase(Y,R[Y]);for(let Y of h.sliceMatchers)W.addMatcher(Y.matcher,Y.reducer);for(let Y of A)W.addMatcher(Y.matcher,Y.reducer);I&&W.addDefaultCase(I)})}const b=E=>E,v=new Map,N=new WeakMap;let w;function k(E,A){return w||(w=g()),w(E,A)}function _(){return w||(w=g()),w.getInitialState()}function S(E,A=!1){function I(W){let Y=W[E];return typeof Y>"u"&&A&&(Y=Yl(N,I,_)),Y}function R(W=b){const Y=Yl(v,A,()=>new WeakMap);return Yl(Y,W,()=>{const K={};for(const[X,se]of Object.entries(o.selectors??{}))K[X]=zE(se,W,()=>Yl(N,W,_),A);return K})}return{reducerPath:E,getSelectors:R,get selectors(){return R(I)},selectSlice:I}}const T={name:l,reducer:k,actions:h.actionCreators,caseReducers:h.sliceCaseReducersByName,getInitialState:_,...S(d),injectInto(E,{reducerPath:A,...I}={}){const R=A??d;return E.inject({reducerPath:R,reducer:k},I),{...T,...S(R,!0)}}};return T}}function zE(e,n,s,a){function o(l,...d){let u=n(l);return typeof u>"u"&&a&&(u=s()),e(u,...d)}return o.unwrapped=e,o}var qa=UE();function WE(){function e(n,s){return{_reducerDefinitionType:"asyncThunk",payloadCreator:n,...s}}return e.withTypes=()=>e,{reducer(n){return Object.assign({[n.name](...s){return n(...s)}}[n.name],{_reducerDefinitionType:"reducer"})},preparedReducer(n,s){return{_reducerDefinitionType:"reducerWithPrepare",prepare:n,reducer:s}},asyncThunk:e}}function HE({type:e,reducerName:n,createNotation:s},a,o){let l,d;
89if("reducer"in a){if(s&&!VE(a))throw new Error(hs(17));l=a.reducer,d=a.prepare}else l=a;o.addCase(e,l).exposeCaseReducer(n,l).exposeAction(n,d?eb(e,d):eb(e))}function qE(e){return e._reducerDefinitionType==="asyncThunk"}function VE(e){return e._reducerDefinitionType==="reducerWithPrepare"}function YE({type:e,reducerName:n},s,a,o){if(!o)throw new Error(hs(18));const{payloadCreator:l,fulfilled:d,pending:u,rejected:p,settled:h,options:f}=s,g=o(e,l,f);a.exposeAction(n,g),d&&a.addCase(g.fulfilled,d),u&&a.addCase(g.pending,u),p&&a.addCase(g.rejected,p),h&&a.addMatcher(g.settled,h),a.exposeCaseReducer(n,{fulfilled:d||Gl,pending:u||Gl,rejected:p||Gl,settled:h||Gl})}function Gl(){}function hs(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const GE={user:null,inProgress:!0},f1=qa({name:"auth",initialState:GE,reducers:{setUser:(e,n)=>{e.user=n.payload},setInProgress:(e,n)=>{e.inProgress=n.payload}}}),{setUser:vo,setInProgress:br}=f1.actions,KE=f1.reducer,QE={showToast:!1,toastValue:{message:"",title:"",variant:""}},h1=qa({name:"layout",initialState:QE,reducers:{updateShow:(e,n)=>{e.showToast=n.payload,e.toastValue={variant:"",message:"",title:""}},showMessage:(e,n)=>{e.showToast=!0,e.toastValue=n.payload}}}),{updateShow:z8,showMessage:JE}=h1.actions,XE=h1.reducer,ZE={profile:null,inProgress:!0},x1=qa({name:"Profile",initialState:ZE,reducers:{setProfile:(e,n)=>{e.profile=n.payload},setInProgress:(e,n)=>{e.inProgress=n.payload}}}),{setProfile:W8,setInProgress:H8}=x1.actions,e6=x1.reducer,t6={number_of_documents:0,storage_space:0,packages:[]},g1=qa({name:"package",initialState:t6,reducers:{setPackageValues:(e,n)=>{e.number_of_documents=n.payload.number_of_documents,e.storage_space=n.payload.storage_space},setPackages:(e,n)=>{e.packages=n.payload.packages}}}),{setPackageValues:q8,setPackages:V8}=g1.actions,n6=g1.reducer,s6={paymentsMethods:null},y1=qa({name:"package",initialState:s6,reducers:{setPaymentsMethodsValues:(e,n)=>{e.paymentsMethods=n.payload.payments}}}),{setPaymentsMethodsValues:Y8}=y1.actions,r6=y1.reducer,a6={invoices:null},b1=qa({name:"billing",initialState:a6,reducers:{setInvoices:(e,n)=>{e.invoices=n.payload}}}),{setInvoices:G8}=b1.actions,i6=b1.reducer,o6=()=>DE({reducer:{auth:KE,layout:XE,profile:e6,package:n6,payments:r6,billing:i6}}),l6=o6(),v1=typeof document<"u"?document.location.protocol:"https:";let _r="";v1==="https:"&&!_r.includes("https:")&&(_r=_r.replace("http","https"));v1==="http:"&&_r.includes("https:")&&(_r=_r.replace("https","http"));const yn=_r,sh="ai-bk-token",rh="ai-bk-refresh",oo=()=>localStorage.getItem(sh)??void 0,j1=()=>localStorage.getItem(rh)??void 0,w1=e=>localStorage.setItem(sh,e),N1=e=>localStorage.setItem(rh,e),kd=()=>{localStorage.removeItem(sh),localStorage.removeItem(rh)};function _1(e,n){return function(){return e.apply(n,arguments)}}const{toString:c6}=Object.prototype,{getPrototypeOf:Sd}=Object,{iterator:Cd,toStringTag:k1}=Symbol,Ed=(e=>n=>{const s=c6.call(n);return e[s]||(e[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Bn=e=>(e=e.toLowerCase(),n=>Ed(n)===e),Ad=e=>n=>typeof n===e,{isArray:Va}=Array,Da=Ad("undefined");function jo(e){return e!==null&&!Da(e)&&e.constructor!==null&&!Da(e.constructor)&&Kt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const S1=Bn("ArrayBuffer");function d6(e){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(e):n=e&&e.buffer&&S1(e.buffer),n}const u6=Ad("string"),Kt=Ad("function"),C1=Ad("number"),wo=e=>e!==null&&typeof e=="object",m6=e=>e===!0||e===!1,wc=e=>{if(Ed(e)!=="object")return!1;const n=Sd(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(k1 in e)&&!(Cd in e)},p6=e=>{if(!wo(e)||jo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},f6=Bn("Date"),h6=Bn("File"),x6=e=>!!(e&&typeof e.uri<"u"),g6=e=>e&&typeof e.getParts<"u",y6=Bn("Blob"),b6=Bn("FileList"),v6=e=>wo(e)&&Kt(e.pipe);function j6(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}
vendor: 4,610 bytes, line 89
89const sb=j6(),rb=typeof sb.FormData<"u"?sb.FormData:void 0,w6=e=>{if(!e)return!1;if(rb&&e instanceof rb)return!0;const n=Sd(e);if(!n||n===Object.prototype||!Kt(e.append))return!1;const s=Ed(e);return s==="formdata"||s==="object"&&Kt(e.toString)&&e.toString()==="[object FormData]"},N6=Bn("URLSearchParams"),[_6,k6,S6,C6]=["ReadableStream","Request","Response","Headers"].map(Bn),E6=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function No(e,n,{allOwnKeys:s=!1}={}){if(e===null||typeof e>"u")return;let a,o;if(typeof e!="object"&&(e=[e]),Va(e))for(a=0,o=e.length;a<o;a++)n.call(null,e[a],a,e);else{if(jo(e))return;const l=s?Object.getOwnPropertyNames(e):Object.keys(e),d=l.length;let u;for(a=0;a<d;a++)u=l[a],n.call(null,e[u],u,e)}}function E1(e,n){if(jo(e))return null;n=n.toLowerCase();const s=Object.keys(e);let a=s.length,o;for(;a-- >0;)if(o=s[a],n===o.toLowerCase())return o;return null}const vr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,A1=e=>!Da(e)&&e!==vr;function ff(...e){const{caseless:n,skipUndefined:s}=A1(this)&&this||{},a={},o=(l,d)=>{if(d==="__proto__"||d==="constructor"||d==="prototype")return;const u=n&&E1(a,d)||d,p=hf(a,u)?a[u]:void 0;wc(p)&&wc(l)?a[u]=ff(p,l):wc(l)?a[u]=ff({},l):Va(l)?a[u]=l.slice():(!s||!Da(l))&&(a[u]=l)};for(let l=0,d=e.length;l<d;l++)e[l]&&No(e[l],o);return a}const A6=(e,n,s,{allOwnKeys:a}={})=>(No(n,(o,l)=>{s&&Kt(o)?Object.defineProperty(e,l,{__proto__:null,value:_1(o,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,l,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:a}),e),T6=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),L6=(e,n,s,a)=>{e.prototype=Object.create(n.prototype,a),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:n.prototype}),s&&Object.assign(e.prototype,s)},R6=(e,n,s,a)=>{let o,l,d;const u={};if(n=n||{},e==null)return n;do{for(o=Object.getOwnPropertyNames(e),l=o.length;l-- >0;)d=o[l],(!a||a(d,e,n))&&!u[d]&&(n[d]=e[d],u[d]=!0);e=s!==!1&&Sd(e)}while(e&&(!s||s(e,n))&&e!==Object.prototype);return n},I6=(e,n,s)=>{e=String(e),(s===void 0||s>e.length)&&(s=e.length),s-=n.length;const a=e.indexOf(n,s);return a!==-1&&a===s},P6=e=>{if(!e)return null;if(Va(e))return e;let n=e.length;if(!C1(n))return null;const s=new Array(n);for(;n-- >0;)s[n]=e[n];return s},F6=(e=>n=>e&&n instanceof e)(typeof Uint8Array<"u"&&Sd(Uint8Array)),D6=(e,n)=>{const a=(e&&e[Cd]).call(e);let o;for(;(o=a.next())&&!o.done;){const l=o.value;n.call(e,l[0],l[1])}},O6=(e,n)=>{let s;const a=[];for(;(s=e.exec(n))!==null;)a.push(s);return a},$6=Bn("HTMLFormElement"),M6=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,a,o){return a.toUpperCase()+o}),hf=(({hasOwnProperty:e})=>(n,s)=>e.call(n,s))(Object.prototype),B6=Bn("RegExp"),T1=(e,n)=>{const s=Object.getOwnPropertyDescriptors(e),a={};No(s,(o,l)=>{let d;(d=n(o,l,e))!==!1&&(a[l]=d||o)}),Object.defineProperties(e,a)},U6=e=>{T1(e,(n,s)=>{if(Kt(e)&&["arguments","caller","callee"].includes(s))return!1;const a=e[s];if(Kt(a)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},z6=(e,n)=>{const s={},a=o=>{o.forEach(l=>{s[l]=!0})};return Va(e)?a(e):a(String(e).split(n)),s},W6=()=>{},H6=(e,n)=>e!=null&&Number.isFinite(e=+e)?e:n;function q6(e){return!!(e&&Kt(e.append)&&e[k1]==="FormData"&&e[Cd])}const V6=e=>{const n=new WeakSet,s=a=>{if(wo(a)){if(n.has(a))return;if(jo(a))return a;if(!("toJSON"in a)){n.add(a);const o=Va(a)?[]:{};return No(a,(l,d)=>{const u=s(l);!Da(u)&&(o[d]=u)}),n.delete(a),o}}return a};return s(e)},Y6=Bn("AsyncFunction"),G6=e=>e&&(wo(e)||Kt(e))&&Kt(e.then)&&Kt(e.catch),L1=((e,n)=>e?setImmediate:n?((s,a)=>(vr.addEventListener("message",({source:o,data:l})=>{o===vr&&l===s&&a.length&&a.shift()()},!1),o=>{a.push(o),vr.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",Kt(vr.postMessage)),K6=typeof queueMicrotask<"u"?queueMicrotask.bind(vr):typeof process<"u"&&process.nextTick||L1,Q6=e=>e!=null&&Kt(e[Cd]),B={isArray:Va,isArrayBuffer:S1,isBuffer:jo,isFormData:w6,isArrayBufferView:d6,isString:u6,isNumber:C1,isBoolean:m6,isObject:wo,isPlainObject:wc,isEmptyObject:p6,isReadableStream:_6,isRequest:k6,isResponse:S6,isHeaders:C6,isUndefined:Da,isDate:f6,isFile:h6,isReactNativeBlob:x6,isReactNative:g6,isBlob:y6,isRegExp:B6,isFunction:Kt,isStream:v6,isURLSearchParams:N6,isTypedArray:F6,isFileList:b6,forEac
vendor: 33,907 bytes, lines 89-97
89h:No,merge:ff,extend:A6,trim:E6,stripBOM:T6,inherits:L6,toFlatObject:R6,kindOf:Ed,kindOfTest:Bn,endsWith:I6,toArray:P6,forEachEntry:D6,matchAll:O6,isHTMLForm:$6,hasOwnProperty:hf,hasOwnProp:hf,reduceDescriptors:T1,freezeMethods:U6,toObjectSet:z6,toCamelCase:M6,noop:W6,toFiniteNumber:H6,findKey:E1,global:vr,isContextDefined:A1,isSpecCompliantForm:q6,toJSONObject:V6,isAsyncFn:Y6,isThenable:G6,setImmediate:L1,asap:K6,isIterable:Q6},J6=B.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),X6=e=>{const n={};let s,a,o;return e&&e.split(`
90`).forEach(function(d){o=d.indexOf(":"),s=d.substring(0,o).trim().toLowerCase(),a=d.substring(o+1).trim(),!(!s||n[s]&&J6[s])&&(s==="set-cookie"?n[s]?n[s].push(a):n[s]=[a]:n[s]=n[s]?n[s]+", "+a:a)}),n};function Z6(e){let n=0,s=e.length;for(;n<s;){const a=e.charCodeAt(n);if(a!==9&&a!==32)break;n+=1}for(;s>n;){const a=e.charCodeAt(s-1);if(a!==9&&a!==32)break;s-=1}return n===0&&s===e.length?e:e.slice(n,s)}const eA=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),tA=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function ah(e,n){return B.isArray(e)?e.map(s=>ah(s,n)):Z6(String(e).replace(n,""))}const nA=e=>ah(e,eA),sA=e=>ah(e,tA);function R1(e){const n=Object.create(null);return B.forEach(e.toJSON(),(s,a)=>{n[a]=sA(s)}),n}const ab=Symbol("internals");function Di(e){return e&&String(e).trim().toLowerCase()}function Nc(e){return e===!1||e==null?e:B.isArray(e)?e.map(Nc):nA(String(e))}function rA(e){const n=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=s.exec(e);)n[a[1]]=a[2];return n}const aA=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ap(e,n,s,a,o){if(B.isFunction(a))return a.call(this,n,s);if(o&&(n=s),!!B.isString(n)){if(B.isString(a))return n.indexOf(a)!==-1;if(B.isRegExp(a))return a.test(n)}}function iA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,s,a)=>s.toUpperCase()+a)}function oA(e,n){const s=B.toCamelCase(" "+n);["get","set","has"].forEach(a=>{Object.defineProperty(e,a+s,{__proto__:null,value:function(o,l,d){return this[a].call(this,n,o,l,d)},configurable:!0})})}let Bt=class{constructor(n){n&&this.set(n)}set(n,s,a){const o=this;function l(u,p,h){const f=Di(p);if(!f)throw new Error("header name must be a non-empty string");const g=B.findKey(o,f);(!g||o[g]===void 0||h===!0||h===void 0&&o[g]!==!1)&&(o[g||p]=Nc(u))}const d=(u,p)=>B.forEach(u,(h,f)=>l(h,f,p));if(B.isPlainObject(n)||n instanceof this.constructor)d(n,s);else if(B.isString(n)&&(n=n.trim())&&!aA(n))d(X6(n),s);else if(B.isObject(n)&&B.isIterable(n)){let u={},p,h;for(const f of n){if(!B.isArray(f))throw TypeError("Object iterator must return a key-value pair");u[h=f[0]]=(p=u[h])?B.isArray(p)?[...p,f[1]]:[p,f[1]]:f[1]}d(u,s)}else n!=null&&l(s,n,a);return this}get(n,s){if(n=Di(n),n){const a=B.findKey(this,n);if(a){const o=this[a];if(!s)return o;if(s===!0)return rA(o);if(B.isFunction(s))return s.call(this,o,a);if(B.isRegExp(s))return s.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,s){if(n=Di(n),n){const a=B.findKey(this,n);return!!(a&&this[a]!==void 0&&(!s||ap(this,this[a],a,s)))}return!1}delete(n,s){const a=this;let o=!1;function l(d){if(d=Di(d),d){const u=B.findKey(a,d);u&&(!s||ap(a,a[u],u,s))&&(delete a[u],o=!0)}}return B.isArray(n)?n.forEach(l):l(n),o}clear(n){const s=Object.keys(this);let a=s.length,o=!1;for(;a--;){const l=s[a];(!n||ap(this,this[l],l,n,!0))&&(delete this[l],o=!0)}return o}normalize(n){const s=this,a={};return B.forEach(this,(o,l)=>{const d=B.findKey(a,l);if(d){s[d]=Nc(o),delete s[l];return}const u=n?iA(l):String(l).trim();u!==l&&delete s[l],s[u]=Nc(o),a[u]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const s=Object.create(null);return B.forEach(this,(a,o)=>{a!=null&&a!==!1&&(s[o]=n&&B.isArray(a)?a.join(", "):a)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,s])=>n+": "+s).join(`
91`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...s){const a=new this(n);return s.forEach(o=>a.set(o)),a}static accessor(n){const a=(this[ab]=this[ab]={accessors:{}}).accessors,o=this.prototype;function l(d){const u=Di(d);a[u]||(oA(o,d),a[u]=!0)}return B.isArray(n)?n.forEach(l):l(n),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);B.reduceDescriptors(Bt.prototype,({value:e},n)=>{let s=n[0].toUpperCase()+n.slice(1);return{get:()=>e,set(a){this[s]=a}}});B.freezeMethods(Bt);const lA="[REDACTED ****]";function cA(e){if(B.hasOwnProp(e,"toJSON"))return!0;let n=Object.getPrototypeOf(e);for(;n&&n!==Object.prototype;){if(B.hasOwnProp(n,"toJSON"))return!0;n=Object.getPrototypeOf(n)}return!1}function dA(e,n){const s=new Set(n.map(l=>String(l).toLowerCase())),a=[],o=l=>{if(l===null||typeof l!="object"||B.isBuffer(l))return l;if(a.indexOf(l)!==-1)return;l instanceof Bt&&(l=l.toJSON()),a.push(l);let d;if(B.isArray(l))d=[],l.forEach((u,p)=>{const h=o(u);B.isUndefined(h)||(d[p]=h)});else{if(!B.isPlainObject(l)&&cA(l))return a.pop(),l;d=Object.create(null);for(const[u,p]of Object.entries(l)){const h=s.has(u.toLowerCase())?lA:o(p);B.isUndefined(h)||(d[u]=h)}}return a.pop(),d};return o(e)}let ve=class I1 extends Error{static from(n,s,a,o,l,d){const u=new I1(n.message,s||n.code,a,o,l);return u.cause=n,u.name=n.name,n.status!=null&&u.status==null&&(u.status=n.status),d&&Object.assign(u,d),u}constructor(n,s,a,o,l){super(n),Object.defineProperty(this,"message",{__proto__:null,value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),a&&(this.config=a),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){const n=this.config,s=n&&B.hasOwnProp(n,"redact")?n.redact:void 0,a=B.isArray(s)&&s.length>0?dA(n,s):B.toJSONObject(n);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a,code:this.code,status:this.status}}};ve.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ve.ERR_BAD_OPTION="ERR_BAD_OPTION";ve.ECONNABORTED="ECONNABORTED";ve.ETIMEDOUT="ETIMEDOUT";ve.ECONNREFUSED="ECONNREFUSED";ve.ERR_NETWORK="ERR_NETWORK";ve.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ve.ERR_DEPRECATED="ERR_DEPRECATED";ve.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ve.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ve.ERR_CANCELED="ERR_CANCELED";ve.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ve.ERR_INVALID_URL="ERR_INVALID_URL";ve.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const uA=null;function xf(e){return B.isPlainObject(e)||B.isArray(e)}function P1(e){return B.endsWith(e,"[]")?e.slice(0,-2):e}function ip(e,n,s){return e?e.concat(n).map(function(o,l){return o=P1(o),!s&&l?"["+o+"]":o}).join(s?".":""):n}function mA(e){return B.isArray(e)&&!e.some(xf)}const pA=B.toFlatObject(B,{},null,function(n){return/^is[A-Z]/.test(n)});function Td(e,n,s){if(!B.isObject(e))throw new TypeError("target must be an object");n=n||new FormData,s=B.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(k,_){return!B.isUndefined(_[k])});const a=s.metaTokens,o=s.visitor||g,l=s.dots,d=s.indexes,u=s.Blob||typeof Blob<"u"&&Blob,p=s.maxDepth===void 0?100:s.maxDepth,h=u&&B.isSpecCompliantForm(n);if(!B.isFunction(o))throw new TypeError("visitor must be a function");function f(w){if(w===null)return"";if(B.isDate(w))return w.toISOString();if(B.isBoolean(w))return w.toString();if(!h&&B.isBlob(w))throw new ve("Blob is not supported. Use a Buffer instead.");return B.isArrayBuffer(w)||B.isTypedArray(w)?h&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function g(w,k,_){let S=w;if(B.isReactNative(n)&&B.isReactNativeBlob(w))return n.append(ip(_,k,l),f(w)),!1;if(w&&!_&&typeof w=="object"){if(B.endsWith(k,"{}"))k=a?k:k.slice(0,-2),w=JSON.stringify(w);else if(B.isArray(w)&&mA(w)||(B.isFileList(w)||B.endsWith(k,"[]"))&&(S=B.toArray(w)))return k=P1(k),S.forEach(function(E,A){!(B.isUndefined(E)||E===null)&&n.append(d===!0?ip([k],A,l):d===null?k:k+"[]",f(E))}),!1}return xf(w)?!0:(n.append(ip(_,k,l),f(w)),!1)}const b=[],v=Object.assign(pA,{defaultVisitor:g,convertValue:f,isVisitable:xf});function N(w,k,_=0){if(!B.isUndefined(w)){if(_>p)throw new ve("Object is too deeply nested ("+_+" levels). Max depth: "+p,ve.ERR_FORM_DATA_DEPTH_EXCEEDED);if(b.indexOf(w)!==-1)throw Error("Circular reference detected in "+k.join("."));b.push(w),B.forEach(w,function(T,E){(!(B.isUndefined(T)||T===null)&&o.call(n,T,B.isString(E)?E.trim():E,k,v))===!0&&N(T,k?k.concat(E):[E],_+1)}),b.pop()}}if(!B.isObject(e))throw new TypeError("data must be an object");return N(e),n}function ib(e){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(a){return n[a]})}function ih(e,n){this._pairs=[],e&&Td(e,this,n)}const F1=ih.prototype;F1.append=function(n,s){this._pairs.push([n,s])};F1.toString=function(n){const s=n?function(a){return n.call(this,a,ib)}:ib;return this._pairs.map(function(o){return s(o[0])+"="+s(o[1])},"").join("&")};function fA(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function D1(e,n,s){if(!n)return e;const a=s&&s.encode||fA,o=B.isFunction(s)?{serialize:s}:s,l=o&&o.serialize;let d;if(l?d=l(n,o):d=B.isURLSearchParams(n)?n.toString():new ih(n,o).toString(a),d){const u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+d}return e}class ob{constructor(){this.handlers=[]}use(n,s,a){return this.handlers.push({fulfilled:n,rejected:s,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){B.forEach(this.handlers,function(a){a!==null&&n(a)})}}const oh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},hA=typeof URLSearchParams<"u"?URLSearchParams:ih,xA=typeof FormData<"u"?FormData:null,gA=typeof Blob<"u"?Blob:null,yA={isBrowser:!0,classes:{URLSearchParams:hA,FormData:xA,Blob:gA},protocols:["http","https","file","blob","url","data"]},lh=typeof window<"u"&&typeof document<"u",gf=typeof navigator=="object"&&navigator||void 0,bA=lh&&(!gf||["ReactNative","NativeScript","NS"].indexOf(gf.product)<0),vA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",jA=lh&&window.location.href||"http://localhost",wA=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:lh,hasStandardBrowserEnv:bA,hasStandardBrowserWebWorkerEnv:vA,navigator:gf,origin:jA},Symbol.toStringTag,{value:"Module"})),It={...wA,...yA};function NA(e,n){return Td(e,new It.classes.URLSearchParams,{visitor:function(s,a,o,l){return It.isNode&&B.isBuffer(s)?(this.append(a,s.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function _A(e){return B.matchAll(/\w+|\[(\w*)]/g,e).map(n=>n[0]==="[]"?"":n[1]||n[0])}function kA(e){const n={},s=Object.keys(e);let a;const o=s.length;let l;for(a=0;a<o;a++)l=s[a],n[l]=e[l];return n}function O1(e){function n(s,a,o,l){let d=s[l++];if(d==="__proto__")return!0;const u=Number.isFinite(+d),p=l>=s.length;return d=!d&&B.isArray(o)?o.length:d,p?(B.hasOwnProp(o,d)?o[d]=B.isArray(o[d])?o[d].concat(a):[o[d],a]:o[d]=a,!u):((!B.hasOwnProp(o,d)||!B.isObject(o[d]))&&(o[d]=[]),n(s,a,o[d],l)&&B.isArray(o[d])&&(o[d]=kA(o[d])),!u)}if(B.isFormData(e)&&B.isFunction(e.entries)){const s={};return B.forEachEntry(e,(a,o)=>{n(_A(a),o,s,0)}),s}return null}const xa=(e,n)=>e!=null&&B.hasOwnProp(e,n)?e[n]:void 0;function SA(e,n,s){if(B.isString(e))try{return(n||JSON.parse)(e),B.trim(e)}catch(a){if(a.name!=="SyntaxError")throw a}return(s||JSON.stringify)(e)}const _o={transitional:oh,adapter:["xhr","http","fetch"],transformRequest:[function(n,s){const a=s.getContentType()||"",o=a.indexOf("application/json")>-1,l=B.isObject(n);if(l&&B.isHTMLForm(n)&&(n=new FormData(n)),B.isFormData(n))return o?JSON.stringify(O1(n)):n;if(B.isArrayBuffer(n)||B.isBuffer(n)||B.isStream(n)||B.isFile(n)||B.isBlob(n)||B.isReadableStream(n))return n;if(B.isArrayBufferView(n))return n.buffer;if(B.isURLSearchParams(n))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let u;if(l){const p=xa(this,"formSerializer");if(a.indexOf("application/x-www-form-urlencoded")>-1)return NA(n,p).toString();if((u=B.isFileList(n))||a.indexOf("multipart/form-data")>-1){const h=xa(this,"env"),f=h&&h.FormData;return Td(u?{"files[]":n}:n,f&&new f,p)}}return l||o?(s.setContentType("application/json",!1),SA(n)):n}],transformResponse:[function(n){const s=xa(this,"transitional")||_o.transitional,a=s&&s.forcedJSONParsing,o=xa(this,"responseType"),l=o==="json";if(B.isResponse(n)||B.isReadableStream(n))return n;if(n&&B.isString(n)&&(a&&!o||l)){const u=!(s&&s.silentJSONParsing)&&l;try{return JSON.parse(n,xa(this,"parseReviver"))}catch(p){if(u)throw p.name==="SyntaxError"?ve.from(p,ve.ERR_BAD_RESPONSE,this,null,xa(this,"response")):p}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};B.forEach(["delete","get","head","post","put","patch","query"],e=>{_o.headers[e]={}});function op(e,n){const s=this||_o,a=n||s,o=Bt.from(a.headers);let l=a.data;return B.forEach(e,function(u){l=u.call(s,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function $1(e){return!!(e&&e.__CANCEL__)}let ko=class extends ve{constructor(n,s,a){super(n??"canceled",ve.ERR_CANCELED,s,a),this.name="CanceledError",this.__CANCEL__=!0}};function M1(e,n,s){const a=s.config.validateStatus;!s.status||!a||a(s.status)?e(s):n(new ve("Request failed with status code "+s.status,s.status>=400&&s.status<500?ve.ERR_BAD_REQUEST:ve.ERR_BAD_RESPONSE,s.config,s.request,s))}function CA(e){const n=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return n&&n[1]||""}function EA(e,n){e=e||10;const s=new Array(e),a=new Array(e);let o=0,l=0,d;return n=n!==void 0?n:1e3,function(p){const h=Date.now(),f=a[l];d||(d=h),s[o]=p,a[o]=h;let g=l,b=0;for(;g!==o;)b+=s[g++],g=g%e;if(o=(o+1)%e,o===l&&(l=(l+1)%e),h-d<n)return;const v=f&&h-f;return v?Math.round(b*1e3/v):void 0}}function AA(e,n){let s=0,a=1e3/n,o,l;const d=(h,f=Date.now())=>{s=f,o=null,l&&(clearTimeout(l),l=null),e(...h)};return[(...h)=>{const f=Date.now(),g=f-s;g>=a?d(h,f):(o=h,l||(l=setTimeout(()=>{l=null,d(o)},a-g)))},()=>o&&d(o)]}const zc=(e,n,s=3)=>{let a=0;const o=EA(50,250);return AA(l=>{if(!l||typeof l.loaded!="number")return;const d=l.loaded,u=l.lengthComputable?l.total:void 0,p=u!=null?Math.min(d,u):d,h=Math.max(0,p-a),f=o(h);a=Math.max(a,p);const g={loaded:p,total:u,progress:u?p/u:void 0,bytes:h,rate:f||void 0,estimated:f&&u?(u-p)/f:void 0,event:l,lengthComputable:u!=null,[n?"download":"upload"]:!0};e(g)},s)},lb=(e,n)=>{const s=e!=null;return[a=>n[0]({lengthComputable:s,total:e,loaded:a}),n[1]]},cb=e=>(...n)=>B.asap(()=>e(...n)),TA=It.hasStandardBrowserEnv?((e,n)=>s=>(s=new URL(s,It.origin),e.protocol===s.protocol&&e.host===s.host&&(n||e.port===s.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,LA=It.hasStandardBrowserEnv?{write(e,n,s,a,o,l,d){if(typeof document>"u")return;const u=[`${e}=${encodeURIComponent(n)}`];B.isNumber(s)&&u.push(`expires=${new Date(s).toUTCString()}`),B.isString(a)&&u.push(`path=${a}`),B.isString(o)&&u.push(`domain=${o}`),l===!0&&u.push("secure"),B.isString(d)&&u.push(`SameSite=${d}`),document.cookie=u.join("; ")},read(e){if(typeof document>"u")return null;const n=document.cookie.split(";");for(let s=0;s<n.length;s++){const a=n[s].replace(/^\s+/,""),o=a.indexOf("=");if(o!==-1&&a.slice(0,o)===e)return decodeURIComponent(a.slice(o+1))}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function RA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function IA(e,n){return n?e.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):e}function B1(e,n,s){let a=!RA(n);return e&&(a||s===!1)?IA(e,n):n}const db=e=>e instanceof Bt?{...e}:e;function Tr(e,n){n=n||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function a(h,f,g,b){return B.isPlainObject(h)&&B.isPlainObject(f)?B.merge.call({caseless:b},h,f):B.isPlainObject(f)?B.merge({},f):B.isArray(f)?f.slice():f}function o(h,f,g,b){if(B.isUndefined(f)){if(!B.isUndefined(h))return a(void 0,h,g,b)}else return a(h,f,g,b)}function l(h,f){if(!B.isUndefined(f))return a(void 0,f)}function d(h,f){if(B.isUndefined(f)){if(!B.isUndefined(h))return a(void 0,h)}else return a(void 0,f)}function u(h,f,g){if(B.hasOwnProp(n,g))return a(h,f);if(B.hasOwnProp(e,g))return a(void 0,h)}const p={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:u,headers:(h,f,g)=>o(db(h),db(f),g,!0)};return B.forEach(Object.keys({...e,...n}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const g=B.hasOwnProp(p,f)?p[f]:o,b=B.hasOwnProp(e,f)?e[f]:void 0,v=B.hasOwnProp(n,f)?n[f]:void 0,N=g(b,v,f);B.isUndefined(N)&&g!==u||(s[f]=N)}),s}const PA=["content-type","content-length"];function FA(e,n,s){if(s!=="content-only"){e.set(n);return}Object.entries(n).forEach(([a,o])=>{PA.includes(a.toLowerCase())&&e.set(a,o)})}const DA=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(n,s)=>String.fromCharCode(parseInt(s,16))),U1=e=>{const n=Tr({},e),s=b=>B.hasOwnProp(n,b)?n[b]:void 0,a=s("data");let o=s("withXSRFToken");const l=s("xsrfHeaderName"),d=s("xsrfCookieName");let u=s("headers");const p=s("auth"),h=s("baseURL"),f=s("allowAbsoluteUrls"),g=s("url");if(n.headers=u=Bt.from(u),n.url=D1(B1(h,g,f),e.params,e.paramsSerializer),p&&u.set("Authorization","Basic "+btoa((p.username||"")+":"+(p.password?DA(p.password):""))),B.isFormData(a)&&(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv?u.setContentType(void 0):B.isFunction(a.getHeaders)&&FA(u,a.getHeaders(),s("formDataHeaderPolicy"))),It.hasStandardBrowserEnv&&(B.isFunction(o)&&(o=o(n)),o===!0||o==null&&TA(n.url))){const v=l&&d&&LA.read(d);v&&u.set(l,v)}return n},OA=typeof XMLHttpRequest<"u",$A=OA&&function(e){return new Promise(function(s,a){const o=U1(e);let l=o.data;const d=Bt.from(o.headers).normalize();let{responseType:u,onUploadProgress:p,onDownloadProgress:h}=o,f,g,b,v,N;function w(){v&&v(),N&&N(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let k=new XMLHttpRequest;k.open(o.method.toUpperCase(),o.url,!0),k.timeout=o.timeout;function _(){if(!k)return;const T=Bt.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),A={data:!u||u==="text"||u==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:T,config:e,request:k};M1(function(R){s(R),w()},function(R){a(R),w()},A),k=null}"onloadend"in k?k.onloadend=_:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.startsWith("file:"))||setTimeout(_)},k.onabort=function(){k&&(a(new ve("Request aborted",ve.ECONNABORTED,e,k)),w(),k=null)},k.onerror=function(E){const A=E&&E.message?E.message:"Network Error",I=new ve(A,ve.ERR_NETWORK,e,k);I.event=E||null,a(I),w(),k=null},k.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const A=o.transitional||oh;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),a(new ve(E,A.clarifyTimeoutError?ve.ETIMEDOUT:ve.ECONNABORTED,e,k)),w(),k=null},l===void 0&&d.setContentType(null),"setRequestHeader"in k&&B.forEach(R1(d),function(E,A){k.setRequestHeader(A,E)}),B.isUndefined(o.withCredentials)||(k.withCredentials=!!o.withCredentials),u&&u!=="json"&&(k.responseType=o.responseType),h&&([b,N]=zc(h,!0),k.addEventListener("progress",b)),p&&k.upload&&([g,v]=zc(p),k.upload.addEventListener("progress",g),k.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(f=T=>{k&&(a(!T||T.type?new ko(null,e,k):T),k.abort(),w(),k=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const S=CA(o.url);if(S&&!It.protocols.includes(S)){a(new ve("Unsupported protocol "+S+":",ve.ERR_BAD_REQUEST,e));return}k.send(l||null)})},MA=(e,n)=>{if(e=e?e.filter(Boolean):[],!n&&!e.length)return;const s=new AbortController;let a=!1;const o=function(p){if(!a){a=!0,d();const h=p instanceof Error?p:this.reason;s.abort(h instanceof ve?h:new ko(h instanceof Error?h.message:h))}};let l=n&&setTimeout(()=>{l=null,o(new ve(`timeout of ${n}ms exceeded`,ve.ETIMEDOUT))},n);const d=()=>{e&&(l&&clearTimeout(l),l=null,e.forEach(p=>{p.unsubscribe?p.unsubscribe(o):p.removeEventListener("abort",o)}),e=null)};e.forEach(p=>p.addEventListener("abort",o));const{signal:u}=s;return u.unsubscribe=()=>B.asap(d),u},BA=function*(e,n){let s=e.byteLength;if(s<n){yield e;return}let a=0,o;for(;a<s;)o=a+n,yield e.slice(a,o),a=o},UA=async function*(e,n){for await(const s of zA(e))yield*BA(s,n)},zA=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const n=e.getReader();try{for(;;){const{done:s,value:a}=await n.read();if(s)break;yield a}}finally{await n.cancel()}},ub=(e,n,s,a)=>{const o=UA(e,n);let l=0,d,u=p=>{d||(d=!0,a&&a(p))};return new ReadableStream({async pull(p){try{const{done:h,value:f}=await o.next();if(h){u(),p.close();return}let g=f.byteLength;if(s){let b=l+=g;s(b)}p.enqueue(new Uint8Array(f))}catch(h){throw u(h),h}},cancel(p){return u(p),o.return()}},{highWaterMark:2})};function WA(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const n=e.indexOf(",");if(n<0)return 0;const s=e.slice(5,n),a=e.slice(n+1);if(/;base64/i.test(s)){let d=a.length;const u=a.length;for(let v=0;v<u;v++)if(a.charCodeAt(v)===37&&v+2<u){const N=a.charCodeAt(v+1),w=a.charCodeAt(v+2);(N>=48&&N<=57||N>=65&&N<=70||N>=97&&N<=102)&&(w>=48&&w<=57||w>=65&&w<=70||w>=97&&w<=102)&&(d-=2,v+=2)}let p=0,h=u-1;const f=v=>v>=2&&a.charCodeAt(v-2)===37&&a.charCodeAt(v-1)===51&&(a.charCodeAt(v)===68||a.charCodeAt(v)===100);h>=0&&(a.charCodeAt(h)===61?(p++,h--):f(h)&&(p++,h-=3)),p===1&&h>=0&&(a.charCodeAt(h)===61||f(h))&&p++;const b=Math.floor(d/4)*3-(p||0);return b>0?b:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(a,"utf8");let l=0;for(let d=0,u=a.length;d<u;d++){const p=a.charCodeAt(d);if(p<128)l+=1;else if(p<2048)l+=2;else if(p>=55296&&p<=56319&&d+1<u){const h=a.charCodeAt(d+1);h>=56320&&h<=57343?(l+=4,d++):l+=3}else l+=3}return l}const ch="1.16.1",mb=64*1024,{isFunction:Kl}=B,pb=(e,...n)=>{try{return!!e(...n)}catch{return!1}},HA=e=>{const n=B.global!==void 0&&B.global!==null?B.global:globalThis,{ReadableStream:s,TextEncoder:a}=n;e=B.merge.call({skipUndefined:!0},{Request:n.Request,Response:n.Response},e);const{fetch:o,Request:l,Response:d}=e,u=o?Kl(o):typeof fetch=="function",p=Kl(l),h=Kl(d);if(!u)return!1;const f=u&&Kl(s),g=u&&(typeof a=="function"?(_=>S=>_.encode(S))(new a):async _=>new Uint8Array(await new l(_).arrayBuffer())),b=p&&f&&pb(()=>{let _=!1;const S=new l(It.origin,{body:new s,method:"POST",get duplex(){return _=!0,"half"}}),T=S.headers.has("Content-Type");return S.body!=null&&S.body.cancel(),_&&!T}),v=h&&f&&pb(()=>B.isReadableStream(new d("").body)),N={stream:v&&(_=>_.body)};u&&["text","arrayBuffer","blob","formData","stream"].forEach(_=>{!N[_]&&(N[_]=(S,T)=>{let E=S&&S[_];if(E)return E.call(S);throw new ve(`Response type '${_}' is not supported`,ve.ERR_NOT_SUPPORT,T)})});const w=async _=>{if(_==null)return 0;if(B.isBlob(_))return _.size;if(B.isSpecCompliantForm(_))return(await new l(It.origin,{method:"POST",body:_}).arrayBuffer()).byteLength;if(B.isArrayBufferView(_)||B.isArrayBuffer(_))return _.byteLength;if(B.isURLSearchParams(_)&&(_=_+""),B.isString(_))return(await g(_)).byteLength},k=async(_,S)=>{const T=B.toFiniteNumber(_.getContentLength());return T??w(S)};return async _=>{let{url:S,method:T,data:E,signal:A,cancelToken:I,timeout:R,onDownloadProgress:W,onUploadProgress:Y,responseType:K,headers:X,withCredentials:se="same-origin",fetchOptions:ne,maxContentLength:Z,maxBodyLength:ue}=U1(_);const re=B.isNumber(Z)&&Z>-1,H=B.isNumber(ue)&&ue>-1;let M=o||fetch;K=K?(K+"").toLowerCase():"text";let Q=MA([A,I&&I.toAbortSignal()],R),$=null;const L=Q&&Q.unsubscribe&&(()=>{Q.unsubscribe()});let F;try{if(re&&typeof S=="string"&&S.startsWith("data:")&&WA(S)>Z)throw new ve("maxContentLength size of "+Z+" exceeded",ve.ERR_BAD_RESPONSE,_,$);if(H&&T!=="get"&&T!=="head"){const me=await k(X,E);if(typeof me=="number"&&isFinite(me)&&me>ue)throw new ve("Request body larger than maxBodyLength limit",ve.ERR_BAD_REQUEST,_,$)}if(Y&&b&&T!=="get"&&T!=="head"&&(F=await k(X,E))!==0){let me=new l(S,{method:"POST",body:E,duplex:"half"}),Ne;if(B.isFormData(E)&&(Ne=me.headers.get("content-type"))&&X.setContentType(Ne),me.body){const[Oe,mt]=lb(F,zc(cb(Y)));E=ub(me.body,mb,Oe,mt)}}B.isString(se)||(se=se?"include":"omit");const V=p&&"credentials"in l.prototype;if(B.isFormData(E)){const me=X.getContentType();me&&/^multipart\/form-data/i.test(me)&&!/boundary=/i.test(me)&&X.delete("content-type")}X.set("User-Agent","axios/"+ch,!1);const q={...ne,signal:Q,method:T.toUpperCase(),headers:R1(X.normalize()),body:E,duplex:"half",credentials:V?se:void 0};$=p&&new l(S,q);let ee=await(p?M($,ne):M(S,q));if(re){const me=B.toFiniteNumber(ee.headers.get("content-length"));if(me!=null&&me>Z)throw new ve("maxContentLength size of "+Z+" exceeded",ve.ERR_BAD_RESPONSE,_,$)}const je=v&&(K==="stream"||K==="response");if(v&&ee.body&&(W||re||je&&L)){const me={};["status","statusText","headers"].forEach(ae=>{me[ae]=ee[ae]});const Ne=B.toFiniteNumber(ee.headers.get("content-length")),[Oe,mt]=W&&lb(Ne,zc(cb(W),!0))||[];let he=0;const Se=ae=>{if(re&&(he=ae,he>Z))throw new ve("maxContentLength size of "+Z+" exceeded",ve.ERR_BAD_RESPONSE,_,$);Oe&&Oe(ae)};ee=new d(ub(ee.body,mb,Se,()=>{mt&&mt(),L&&L()}),me)}K=K||"text";let ke=await N[B.findKey(N,K)||"text"](ee,_);if(re&&!v&&!je){let me;if(ke!=null&&(typeof ke.byteLength=="number"?me=ke.byteLength:typeof ke.size=="number"?me=ke.size:typeof ke=="string"&&(me=typeof a=="function"?new a().encode(ke).byteLength:ke.length)),typeof me=="number"&&me>Z)throw new ve("maxContentLength size of "+Z+" exceeded",ve.ERR_BAD_RESPONSE,_,$)}return!je&&L&&L(),await new Promise((me,Ne)=>{M1(me,Ne,{data:ke,headers:Bt.from(ee.headers),status:ee.status,statusText:ee.statusText,config:_,request:$})})}catch(V){if(L&&L(),Q&&Q.aborted&&Q.reason instanceof ve){const q=Q.reason;throw q.config=_,$&&(q.request=$),V!==q&&(q.cause=V),q}throw V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new ve("Network Error",ve.ERR_NETWORK,_,$,V&&V.response),{cause:V.cause||V}):ve.from(V,V&&V.code,_,$,V&&V.response)}}},qA=new Map,z1=e=>{let n=e&&e.env||{};const{fetch:s,Request:a,Response:o}=n,l=[a,o,s];let d=l.length,u=d,p,h,f=qA;for(;u--;)p=l[u],h=f.get(p),h===void 0&&f.set(p,h=u?new Map:HA(n)),f=h;return h};z1();const dh={http:uA,xhr:$A,fetch:{get:z1}};B.forEach(dh,(e,n)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:n})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:n})}});const fb=e=>`- ${e}`,VA=e=>B.isFunction(e)||e===null||e===!1;function YA(e,n){e=B.isArray(e)?e:[e];const{length:s}=e;let a,o;const l={};for(let d=0;d<s;d++){a=e[d];let u;if(o=a,!VA(a)&&(o=dh[(u=String(a)).toLowerCase()],o===void 0))throw new ve(`Unknown adapter '${u}'`);if(o&&(B.isFunction(o)||(o=o.get(n))))break;l[u||"#"+d]=o}if(!o){const d=Object.entries(l).map(([p,h])=>`adapter ${p} `+(h===!1?"is not supported by the environment":"is not available in the build"));let u=s?d.length>1?`since :
92`+d.map(fb).join(`
93`):" "+fb(d[0]):"as no adapter specified";throw new ve("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return o}const W1={getAdapter:YA,adapters:dh};function lp(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ko(null,e)}function hb(e){return lp(e),e.headers=Bt.from(e.headers),e.data=op.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),W1.getAdapter(e.adapter||_o.adapter,e)(e).then(function(a){lp(e),e.response=a;try{a.data=op.call(e,e.transformResponse,a)}finally{delete e.response}return a.headers=Bt.from(a.headers),a},function(a){if(!$1(a)&&(lp(e),a&&a.response)){e.response=a.response;try{a.response.data=op.call(e,e.transformResponse,a.response)}finally{delete e.response}a.response.headers=Bt.from(a.response.headers)}return Promise.reject(a)})}const Ld={};["object","boolean","number","function","string","symbol"].forEach((e,n)=>{Ld[e]=function(a){return typeof a===e||"a"+(n<1?"n ":" ")+e}});const xb={};Ld.transitional=function(n,s,a){function o(l,d){return"[Axios v"+ch+"] Transitional option '"+l+"'"+d+(a?". "+a:"")}return(l,d,u)=>{if(n===!1)throw new ve(o(d," has been removed"+(s?" in "+s:"")),ve.ERR_DEPRECATED);return s&&!xb[d]&&(xb[d]=!0,console.warn(o(d," has been deprecated since v"+s+" and will be removed in the near future"))),n?n(l,d,u):!0}};Ld.spelling=function(n){return(s,a)=>(console.warn(`${a} is likely a misspelling of ${n}`),!0)};function GA(e,n,s){if(typeof e!="object")throw new ve("options must be an object",ve.ERR_BAD_OPTION_VALUE);const a=Object.keys(e);let o=a.length;for(;o-- >0;){const l=a[o],d=Object.prototype.hasOwnProperty.call(n,l)?n[l]:void 0;if(d){const u=e[l],p=u===void 0||d(u,l,e);if(p!==!0)throw new ve("option "+l+" must be "+p,ve.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new ve("Unknown option "+l,ve.ERR_BAD_OPTION)}}const _c={assertOptions:GA,validators:Ld},hn=_c.validators;let kr=class{constructor(n){this.defaults=n||{},this.interceptors={request:new ob,response:new ob}}async request(n,s){try{return await this._request(n,s)}catch(a){if(a instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
94`);return d===-1?"":o.stack.slice(d+1)})();try{if(!a.stack)a.stack=l;else if(l){const d=l.indexOf(`
95`),u=d===-1?-1:l.indexOf(`
96`,d+1),p=u===-1?"":l.slice(u+1);String(a.stack).endsWith(p)||(a.stack+=`
97`+l)}}catch{}}throw a}}_request(n,s){typeof n=="string"?(s=s||{},s.url=n):s=n||{},s=Tr(this.defaults,s);const{transitional:a,paramsSerializer:o,headers:l}=s;a!==void 0&&_c.assertOptions(a,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean),legacyInterceptorReqResOrdering:hn.transitional(hn.boolean)},!1),o!=null&&(B.isFunction(o)?s.paramsSerializer={serialize:o}:_c.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),_c.assertOptions(s,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=l&&B.merge(l.common,l[s.method]);l&&B.forEach(["delete","get","head","post","put","patch","query","common"],N=>{delete l[N]}),s.headers=Bt.concat(d,l);const u=[];let p=!0;this.interceptors.request.forEach(function(w){if(typeof w.runWhen=="function"&&w.runWhen(s)===!1)return;p=p&&w.synchronous;const k=s.transitional||oh;k&&k.legacyInterceptorReqResOrdering?u.unshift(w.fulfilled,w.rejected):u.push(w.fulfilled,w.rejected)});const h=[];this.interceptors.response.forEach(function(w){h.push(w.fulfilled,w.rejected)});let f,g=0,b;if(!p){const N=[hb.bind(this),void 0];for(N.unshift(...u),N.push(...h),b=N.length,f=Promise.resolve(s);g<b;)f=f.then(N[g++],N[g++]);return f}b=u.length;let v=s;for(;g<b;){const N=u[g++],w=u[g++];try{v=N(v)}catch(k){w.call(this,k);break}}try{f=hb.call(this,v)}catch(N){return Promise.reject(N)}for(g=0,b=h.length;g<b;)f=f.then(h[g++],h[g++]);return f}getUri(n){n=Tr(this.defaults,n);const s=B1(n.baseURL,n.url,n.allowAbsoluteUrls);return D1(s,n.params,n.paramsSerializer)}};B.forEach(["delete","get","head","options"],function(n){kr.prototype[n]=function(s,a){return this.request(Tr(a||{},{method:n,url:s,data:(a||{}).data}))}});B.forEach(["post","put","patch","query"],function(n){function s(a){return function(l,d,u){return this.request(Tr(u||{},{method:n,headers:a?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}kr.prototype[n]=s(),n!=="query"&&(kr.prototype[n+"Form"]=s(!0))});let KA=class H1{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(l){s=l});const a=this;this.promise.then(o=>{if(!a._listeners)return;let l=a._listeners.length;for(;l-- >0;)a._listeners[l](o);a._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(u=>{a.subscribe(u),l=u}).then(o);return d.cancel=function(){a.unsubscribe(l)},d},n(function(l,d,u){a.reason||(a.reason=new ko(l,d,u),s(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}
97subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const s=this._listeners.indexOf(n);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const n=new AbortController,s=a=>{n.abort(a)};return this.subscribe(s),n.signal.unsubscribe=()=>this.unsubscribe(s),n.signal}static source(){let n;return{token:new H1(function(o){n=o}),cancel:n}}};function QA(e){return function(s){return e.apply(null,s)}}function JA(e){return B.isObject(e)&&e.isAxiosError===!0}const yf={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(yf).forEach(([e,n])=>{yf[n]=e});function q1(e){const n=new kr(e),s=_1(kr.prototype.request,n);return B.extend(s,kr.prototype,n,{allOwnKeys:!0}),B.extend(s,n,null,{allOwnKeys:!0}),s.create=function(o){return q1(Tr(e,o))},s}const Me=q1(_o);Me.Axios=kr;Me.CanceledError=ko;Me.CancelToken=KA;Me.isCancel=$1;Me.VERSION=ch;Me.toFormData=Td;Me.AxiosError=ve;Me.Cancel=Me.CanceledError;Me.all=function(n){return Promise.all(n)};Me.spread=QA;Me.isAxiosError=JA;Me.mergeConfig=Tr;Me.AxiosHeaders=Bt;Me.formToJSON=e=>O1(B.isHTMLForm(e)?new FormData(e):e);Me.getAdapter=W1.getAdapter;Me.HttpStatusCode=yf;Me.default=Me;const{Axios:X8,AxiosError:Z8,CanceledError:eO,isCancel:tO,CancelToken:nO,VERSION:sO,all:rO,Cancel:aO,isAxiosError:iO,spread:oO,toFormData:lO,AxiosHeaders:cO,HttpStatusCode:dO,formToJSON:uO,getAdapter:mO,mergeConfig:pO,create:fO}=Me;let V1=null;const XA=()=>V1,gb=e=>{V1=e},Y1=e=>`t2.activeOrg.${e}`,ZA=e=>{if(!e)return null;try{return window.localStorage.getItem(Y1(e))}catch{return null}}
97,eT=(e,n)=>{if(e)try{window.localStorage.setItem(Y1(e),n)}catch{}},G1=(e,n)=>{const s=e??[];if(s.length===0)return null;if(s.length===1)return s[0].org_id;const a=ZA(n);return a&&s.some(o=>o.org_id===a)?a:null},K1=(e,n)=>n?(e??[]).find(s=>s.org_id===n)??null:null,bf=e=>{var n;return((n=e==null?void 0:e.user)==null?void 0:n.memberships)??(e==null?void 0:e.memberships)??[]},Q1=e=>{var n;return((n=e==null?void 0:e.user)==null?void 0:n.email)??(e==null?void 0:e.email)??null},J1=e=>{var n;return((n=e==null?void 0:e.user)==null?void 0:n.has_tier2)??(e==null?void 0:e.has_tier2)??!1},uh=(e,n)=>{var l;const s=J1(e),a=G1(bf(e),Q1(e)),o=((l=K1(bf(e),a))==null?void 0:l.role)??null;return s&&o==="accountant"?"/accountant/ledger":s?"/accounting/dashboard":n},tT=e=>{var n;return(e==null?void 0:e.is_internal_staff)??((n=e==null?void 0:e.user)==null?void 0:n.is_internal_staff)??!1},mh=(e,n)=>tT(e)?"/internal/queue":uh(e,n);let cp=!1,vf=[];const te=Me.create({baseURL:yn,headers:{"Content-Type":"application/json"}}),yb=(e,n=null)=>{vf.forEach(s=>{e?s.reject(e):s.resolve(n)}),vf=[]};te.interceptors.request.use(e=>{const n={...e};n.headers.Authorization=`Bearer ${oo()}`;const s=XA();return s&&typeof n.url=="string"&&n.url.includes("/api/accounting/")&&(n.headers["X-Org-Id"]=s),n});te.interceptors.response.use(e=>e,e=>{var n;if(!Me.isCancel(e)){const s=e.config,a=()=>{(window.location.pathname.includes("curso")||window.location.pathname.includes("prueba"))&&(window.location.href="/login")};return!s._retry&&((n=e==null?void 0:e.response)==null?void 0:n.status)===401?cp?new Promise((o,l)=>{vf.push({resolve:o,reject:l})}).then(async o=>(s.headers.Authorization=`Bearer ${o}`,await te(s))).catch(async o=>await Promise.reject(o)):(s._retry=!0,cp=!0,new Promise((o,l)=>{Me.post(`${yn}/api/auth/refresh/`,{refresh:j1()}).then(d=>{s.headers.Authorization=`Bearer ${d.data.access}`,w1(d.data.access),d.data.refresh&&N1(d.data.refresh),yb(null,d.data.access),o(te(s))}).catch(d=>{console.log("~~~ERROR API_DOMAIN",d.response.data.code),d.response.data.code==="token_not_valid"&&(kd(),window.location.href="/login"),yb(d,null),a(),l(d)}).finally(()=>{cp=!1})})):e==null?void 0:e.response}return null});const ph=async()=>{const e=j1();if(e)try{await te.post("/api/auth/logout/",{refresh:e})}catch{}},X1=e=>{const{inProgress:n,user:s}=ht(u=>u.auth),a=Ba(),[o,l]=x.useState(0),d=x.useCallback(()=>o>=3?Promise.resolve(void 0):oo()?(n||a(br(!0)),Promise.all([te.get(`${yn}/api/user/me`),te.get(`${yn}/api/accounting/staff/me/`).catch(()=>null)]).then(([u,p])=>{var g;const h=!!(p&&p.status===200&&((g=p.data)!=null&&g.is_staff_member)),f={...u.data,is_internal_staff:h,staff_role_type:h?p.data.role_type??null:null};return a(vo(f)),a(br(!1)),f}).catch(()=>{l(u=>u+1)}).finally(()=>{a(br(!1))})):(a(br(!1)),Promise.resolve(void 0)),[a,n,o]);return x.useEffect(()=>{if(!s&&e&&o<3){const u=setTimeout(d,5e3*o);return()=>clearTimeout(u)}},[s,d,e,o]),{getUser:d,user:s}},Z1=x.createContext(void 0),nT=({children:e})=>{const n=ht(f=>f.auth.user),s=x.useMemo(()=>bf(n),[n]),a=x.useMemo(()=>Q1(n),[n]),[o,l]=x.useState(void 0),d=x.useMemo(()=>o&&s.some(f=>f.org_id===o)?o:G1(s,a),[o,s,a]);x.useEffect(()=>{gb(d)},[d]);const u=x.useCallback(f=>{gb(f),eT(a,f),l(f)},[a]),p=K1(s,d),h=x.useMemo(()=>({memberships:s,activeOrgId:d,activeOrg:p,activeRole:(p==null?void 0:p.role)??null,needsSelection:s.length>1&&d===null,otherClientCount:d?Math.max(0,s.length-1):s.length,setActiveOrgId:u}),[s,d,p,u]);return t.jsx(Z1.Provider,{value:h,children:e})},zt=()=>{const e=x.useContext(Z1);if(e===void 0)throw new Error("useOrgContext must be used within an OrgProvider");return e},ew=e=>{const n=new URLSearchParams(e).get("next");return n&&n.startsWith("/")&&!n.startsWith("//")&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n)?n:null},tw=()=>t.jsx("div",{className:"inline-block w-5 h-5 border-2 border-current border-t-transparent rounded-full animate-spin"}),js=()=>t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 border-3 border-[#0066FF] border-t-transparent roun
97ded-full animate-spin"}),t.jsx("span",{className:"text-sm text-gray-500",children:"Loading…"})]})}),jf=({children:e,privatePath:n=!1})=>{const{user:s,inProgress:a}=ht(p=>p.auth),o=vn(),l=x.useMemo(()=>n?!!s:!s,[s,n]);if(a)return t.jsx(js,{});if(l)return t.jsx(t.Fragment,{children:e});const d=mh(s,"/dashboard"),u=ew(o.search)??d;return t.jsx(Pn,{to:n?"/login":u,replace:!0})},dt="/assets/logo-DgP1sjlD.svg",Rd=()=>{const[e,n]=x.useState({loading:!0,staff:null});return x.useEffect(()=>{let s=!1;return n({loading:!0,staff:null}),te.get("/api/accounting/staff/me/").then(a=>{var o;s||a!=null&&(a.status===200&&((o=a.data)!=null&&o.is_staff_member)?n({loading:!1,staff:{isSuperUser:!!a.data.is_super_user,roleType:String(a.data.role_type??"")}}):n({loading:!1,staff:null}))}).catch(()=>{s||n({loading:!1,staff:null})}),()=>{s=!0}},[]),e},Id=({path:e})=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",className:"w-[18px] h-[18px] shrink-0",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),vt={faq:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z",dashboard:"M3 3h7v7H3V3zm11 0h7v7h-7V3zM3 14h7v7H3v-7zm11 0h7v7h-7v-7z",documents:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",ledger:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25",workbook:"M3 10h18M3 14h18M10 3v18M6 3h12a3 3 0 013 3v12a3 3 0 01-3 3H6a3 3 0 01-3-3V6a3 3 0 013-3z",reports:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z",settings:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065zM15 12a3 3 0 11-6 0 3 3 0 016 0z",bank:"M12 21v-8.25M15.75 21v-8.25M8.25 21v-8.25M3 9l9-6 9 6m-1.5 12V10.332A48.36 48.36 0 0012 9.75c-2.551 0-5.056.2-7.5.582V21M3 21h18M12 6.75h.008v.008H12V6.75z",support:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",feedback:"M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.
97123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z",logout:"M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9",internalConsole:"M6.75 7.5l3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0021 18V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v12a2.25 2.25 0 002.25 2.25z"},sT=[{to:"/dashboard",label:"Dashboard",icon:vt.dashboard},{to:"/documents",label:"Documents",icon:vt.documents},{to:"/workbook",label:"Workbook",icon:vt.workbook},{to:"/reports",label:"Reports",icon:vt.reports},{to:"/settings",label:"Settings",icon:vt.settings}],nw=[{to:"/feedback",label:"Feedback",icon:vt.feedback},{to:"/support",label:"Support",icon:vt.support}],Ot=({to:e,label:n,icon:s,end:a=!1})=>t.jsxs(Fe,{to:e,end:a,className:({isActive:o})=>`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors ${o?"bg-[#0066FF] text-white":"text-white/60 hover:text-white hover:bg-white/8"}`,children:[t.jsx(Id,{path:s}),n]}),sw=()=>{const{staff:e}=Rd();return e?t.jsx(Ot,{to:"/internal/queue",label:"Internal console",icon:vt.internalConsole}):null},rw=({onConfirm:e,onCancel:n})=>t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/50 z-50",onClick:n}),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:t.jsxs("div",{className:"bg-[#0A1628] border border-white/10 rounded-xl shadow-2xl w-full max-w-xs p-6",onClick:s=>s.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-9 h-9 rounded-lg bg-white/8 flex items-center justify-center shrink-0",children:t.jsx(Id,{path:vt.logout})}),t.jsx("h3",{className:"text-sm font-semibold text-white",children:"Log out"})]}),t.jsx("p",{className:"text-sm text-white/60 mb-6 leading-relaxed",children:"Are you sure you want to log out?"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:n,className:"flex-1 rounded-lg border border-white/15 px-4 py-2 text-sm font-medium text-white/70 hover:text-white hover:border-white/30 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:e,className:"flex-1 rounded-lg bg-white/10 hover:bg-white/15 px-4 py-2 text-sm font-semibold text-white transition-colors",children:"Log out"})]})]})})]}),rT="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z",aT="M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z",iT=[{to:"/accountant/ledger",label:"Ledger",icon:vt.ledger},{to:"/accountant/adjustments/new",label:"New adjustment",icon:rT},{to:"/accountant/reports",label:"Reports",icon:vt.reports},{to:"/accountant/close",label:"Period close",icon:aT}],oT=()=>{const{memberships:e,activeOrg:n,setActiveOrgId:s}=zt(),[a,o]=x.useState(!1),l=e.length-1,d=e.length>1;return t.jsxs("div",{className:"px-3 pt-4",children:[t.jsx("p",{className:"px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-widest text-white/30",children:"Client"}),t.jsxs("button",{type:"button",onClick:()=>d&&o(u=>!u),className:`w-full rounded-lg border border-white/10 bg-white/5 px-3 py-2.5 text-left transition-colors ${d?"hover:bg-white/10 cursor-pointer":"cursor-default"}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-sm font-semibold text-white",children:(n==null?void 0:n.org_name)??"Select a client"}),d&&t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:`h-4 w-4 shrink-0 text-white/50 transition-transform ${a?"rotate-180":""}`,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),l>0&&t.jsxs("span",{className:"mt-0.5 block text-[11px] text-white/40",children:["+",l," other client",l===1?"":"s"]})]}),a&&d&&t.jsx("div",{className:"mt-1 space-y-0.5 rounded-lg border border-white/10 bg-[#0A1628] p-1",children:e.map(u=>t.jsxs("button",{type:"button",onClick:()=>{s(u.org_id),o(!1)},className:`flex w-full items-center justify-between gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors ${u.org_id===(n==null?void 0:n.org_id)?"bg-white/10 text-white":"text-white/60 hover:bg-white/8 hover:text-white"}`,children:[t.jsx("span",{className:"truncate",children:u.org_name}),u.org_id===(n==null?void 0:n.org_id)&&t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4 shrink-0",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},u.org_id))})]})},lT=()=>{const e=Xe(),n=Ba(),[s,a]=x.useState(!1),o=async()=>{try{await ph()}finally{kd(),n(vo(null)),n(br(!1)),e("/login",{replace:!0})}};return t.jsxs(t.Fragment,{children:[t.jsxs("aside",{className:"flex flex-col w-60 h-screen bg-[#0A1628] shrink-0",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 px-5 py-4 border-b border-white/10",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[30px] w-auto"}),t.jsx("span",{className:"self-start bg-amber-500 text-white text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded",children:"Beta"})]}),t.jsx(oT,{}),t.jsx("nav",{className:"flex-1 px-3 py-4 space-y-0.5",children:iT.map(({to:l,label:d,icon:u})=>t.jsx(Ot,{to:l,label:d,icon:u},l))}),t.jsxs("div",{className:"px-3 pb-4 border-t border-white/10 pt-3 space-y-0.5",children:[t.jsx(sw,{}),nw.map(({to:l,label:d,icon:u})=>t.jsx(Ot,{to:l,label:d,icon:u},l)),t.jsxs("button",{onClick:()=>a(!0),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium text-white/60 hover:text-white hover:bg-white/8 transition-colors",children:[t.jsx(Id,{path:vt.logout}),"Log out"]})]})]}),s&&t.jsx(rw,{onConfirm:o,onCancel:()=>a(!1)})]})},cT=()=>{var f,g,b;const e=Xe(),n=Ba(),s=ht(v=>v.auth),{activeRole:a,memberships:o}=zt(),l=a==="accountant"||o.length>0&&o.every(v=>v.role==="accountant"),d=((g=(f=s.user)==null?void 0:f.user)==null?void 0:g.has_tier2)??((b=s.user)==null?void 0:b.has_tier2)??!1,[u,p]=x.useState(!1),h=async()=>{try{await ph()}finally{kd(),n(vo(null)),n(br(!1)),e("/login",{replace:!0})}};return l?t.jsx(lT,{}):t.jsxs(t.Fragment,{children:[t.jsxs("aside",{className:"flex flex-col w-60 h-screen bg-[#0A1628] shrink-0",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 px-5 py-4 border-b border-white/10",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[30px] w-auto"}),t.jsx("span",{className:"self-start bg-amber-500 text-white text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded",children:"Beta"})]}),t.jsxs("nav",{className:"flex-1 px-3 py-4 space-y-0.5",children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(Ot,{to:"/accounting/dashboard",label:"Dashboard",icon:vt.dashboard}),t.jsx(Ot,{to:"/accounting/documents",label:"Documents",icon:vt.documents}),t.jsx(Ot,{to:"/accounting/ledger",label:"Ledger",icon:vt.ledger}),t.jsx(Ot,{to:"/accounting/clients",label:"Clients",icon:"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"}),t.jsx(Ot,{to:"/accounting/suppliers",label:"Suppliers",icon:"M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0l-3-3m3 3l3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z"}),t.jsx(Ot,{to:"/accounting/invoices",label:"Invoices",icon:"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"}),t.jsx(Ot,{to:"/accounting/reports",label:"Reports",icon:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"}),t.jsx(Ot,{to:"/accounting/taxes",label:"Taxes",icon:"M9 14.25l6-6m4.5-3.493V21.75l-3.75-1.5-3.75 1.5-3.7
975-1.5-3.75 1.5V4.757c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0c1.1.128 1.907 1.077 1.907 2.185zM9.75 9h.008v.008H9.75V9zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm4.125 4.5h.008v.008h-.008V13.5zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"}),t.jsx(Ot,{to:"/accounting/bank-connections",label:"Bank Transactions",icon:vt.bank})]}),sT.filter(v=>!(d&&(v.to==="/documents"||v.to==="/dashboard"||v.to==="/reports"||v.to==="/workbook"))).map(({to:v,label:N,icon:w})=>t.jsx(Ot,{to:v,label:N,icon:w},v))]}),t.jsxs("div",{className:"px-3 py-2 border-t border-white/10",children:[t.jsx("p",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-widest text-white/30",children:"Resources"}),t.jsx(Ot,{to:"/faq",label:"FAQ",icon:vt.faq})]}),t.jsxs("div",{className:"px-3 pb-4 border-t border-white/10 pt-3 space-y-0.5",children:[t.jsx(sw,{}),nw.map(({to:v,label:N,icon:w})=>t.jsx(Ot,{to:v,label:N,icon:w},v)),t.jsxs("button",{onClick:()=>p(!0),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium text-white/60 hover:text-white hover:bg-white/8 transition-colors",children:[t.jsx(Id,{path:vt.logout}),"Log out"]})]})]}),u&&t.jsx(rw,{onConfirm:h,onCancel:()=>p(!1)})]})},dT=({children:e})=>t.jsxs("div",{className:"flex h-screen bg-gray-50",children:[t.jsx(cT,{}),t.jsx("main",{className:"flex-1 overflow-y-auto",children:e})]}),uT=()=>{const[e,n]=x.useState({success:!1,error:"",errorCode:"",inProgress:!1,completed:!1});return{login:a=>{n(o=>({...o,inProgress:!0,success:!1,error:"",errorCode:""})),Me.post(`${yn}/api/auth/token/`,a).then(o=>{w1(o.data.access),N1(o.data.refresh),n(l=>({...l,success:!0,error:"",errorCode:""}))}).catch(o=>{var p;const l=((p=o.response)==null?void 0:p.data)??{},d=l.detail||l.error||"Something went wrong. Please try again.",u=l.error_code||"";n(h=>({...h,error:d,errorCode:u}))}).finally(()=>{n(o=>({...o,inProgress:!1,completed:!0}))})},...e}},mT=({visible:e})=>t.jsx("svg",{className:"w-[18px] h-[18px]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:e?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"}):t.jsxs(t.Fragment,{children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),pT=({className:e="",...n})=>{const[s,a]=x.useState(!1);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{...n,type:s?"text":"password",className:`pr-10 ${e}`}),t.jsx("button",{type:"button",tabIndex:-1,"aria-label":s?"Hide password":"Show password",onClick:()=>a(o=>!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors",children:t.jsx(mT,{visible:s})})]})},fT=({getUser:e})=>{const n=Xe(),[s]=Jn(),{login:a,success:o,error:l,errorCode:d,inProgress:u}=uT(),[p,h]=x.useState(""),[f,g]=x.useState(""),[b,v]=x.useState(!1),N=ew(s.toString());x.useEffect(()=>{if(!o)return;let k=!1;return v(!0),Promise.resolve(e==null?void 0:e()).then(_=>{k||n(N??mh(_,"/dashboard"))}),()=>{k=!0}},[o,e,n,N]);const w=k=>{k.preventDefault(),a({email:p,password:f})};return t.jsxs("div",{className:"flex h-screen overflow-hidden",children:[t.jsxs("div",{className:"hidden lg:flex flex-col justify-between w-[440px] shrink-0 bg-[#0A1628] px-12 py-12",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[53px] w-auto"}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-4xl font-bold text-white leading-tight",children:["Smart bookkeeping,",t.jsx("br",{}),"powered by AI."]}),t.jsx("p",{className:"mt-4 text-white/60 text-base leading-relaxed",children:"Upload receipts and invoices. We extract, categorize, and organize your expenses — be always ready for tax time."})]}),t.jsxs("div",{className:"text-white/30 text-xs space-y-1",children:[t.jsx("p",{children:"© 2026 Time2Win Inc."}),t.jsxs("p",{className:"flex items-center gap-2",children:[t.jsx(Fe,{to:"/privacy-policy",className:"hover:text-white/50 transition-colors",children:"Privacy Policy"}),t.jsx("span",{children:"·"}),t.jsx(Fe,{to:"/terms-of-service",className:"hover:text-white/50 transition-colors",children:"Terms of Service"})]})]})]}),t.jsx("div",{className:"flex-1 bg-white overflow-y-auto",children:t.jsx("div",{className:"flex min-h-full items-center justify-center px-6 py-8",children:t.jsxs("div",{className:"w-full max-w-sm",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mb-10 lg:hidden"}),t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Welcome back"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Sign in to your account"}),l&&t.jsxs("div",{className:"mt-4 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:[l,d==="email_not_verified"&&t.jsx(Fe,{to:"/check-email",state:{email:p},className:"ml-2 underline font-medium hover:text-red-900",children:"Resend verification email"})]}),t.jsxs("form",{onSubmit:w,className:"mt-8 space-y-5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Email address"}),t.jsx("input",{type:"email",required:!0,autoComplete:"email",value:p,onChange:k=>h(k.target.value),placeholder:"[email protected]",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Password"}),t.jsx(Fe,{to:"/forgot-password",className:"text-xs text-[#0066FF] hover:underline",children:"Forgot password?"})]}),t.jsx(pT,{required:!0,autoComplete:"current-password",value:f,onChange:k=>
97g(k.target.value),placeholder:"••••••••",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsx("button",{type:"submit",disabled:u||b,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:u||b?t.jsxs(t.Fragment,{children:[t.jsx(tw,{})," Signing in…"]}):"Sign in"})]}),t.jsxs("p",{className:"mt-6 text-center text-sm text-gray-500",children:["Don't have an account?"," ",t.jsx(Fe,{to:"/register",className:"font-medium text-[#0066FF] hover:underline",children:"Create one"})]}),t.jsxs("p",{className:"mt-4 text-center text-xs text-gray-400",children:["By continuing, you agree to our"," ",t.jsx(Fe,{to:"/terms-of-service",className:"underline hover:text-gray-600 transition-colors",children:"Terms of Service"})," ","and"," ",t.jsx(Fe,{to:"/privacy-policy",className:"underline hover:text-gray-600 transition-colors",children:"Privacy Policy"})]})]})})})]})},wf={email:[],first_name:[],last_name:[],phone_number:[],password:[],confirm:[],province:[]},hT=e=>{const n={...wf};return!e||typeof e!="object"||Object.keys(n).forEach(s=>{const a=e[s];if(a){if(Array.isArray(a))n[s]=a.map(String);else if(typeof a=="string")n[s]=[a];else if(typeof a=="object"){const o=a[s];o&&(n[s]=Array.isArray(o)?o.map(String):[String(o)])}}}),n},xT=()=>{const[e,n]=x.useState({success:!1,requiresVerification:!1,registeredEmail:"",error:"",inProgress:!1,completed:!1}),[s,a]=x.useState(wf);return{register:async l=>{n(d=>({...d,inProgress:!0,success:!1,requiresVerification:!1,error:""})),a(wf),Me.post(`${yn}/api/auth/register/`,l).then(d=>{var u;(u=d.data)!=null&&u.requires_verification?n(p=>({...p,requiresVerification:!0,registeredEmail:d.data.email??l.email,error:""})):n(p=>({...p,success:!0,error:""}))}).catch(d=>{var h,f,g;const u=(h=d.response)==null?void 0:h.status,p=(f=d.response)==null?void 0:f.data;if(console.error("[register] API error",{status:u,data:p}),u===400&&p){const b=hT(p);if(a(b),!Object.values(b).some(N=>N.length>0)){const N=p.detail||((g=p.non_field_errors)==null?void 0:g[0])||"Registration failed. Please check your details and try again.";n(w=>({...w,error:String(N)}))}}else n(b=>({...b,error:"Something went wrong. Please try again."}))}).finally(()=>{n(d=>({...d,inProgress:!1,completed:!0}))})},errors:s,...e}},gT=[{code:"CA",name:"Canada"},{code:"US",name:"United States"}],Ya=[{code:"AB",name:"Alberta"},{code:"BC",name:"British Columbia"},{code:"MB",name:"Manitoba"},{code:"NB",name:"New Brunswick"},{code:"NL",name:"Newfoundland and Labrador"},{code:"NS",name:"Nova Scotia"},{code:"NT",name:"Northwest Territories"},{code:"NU",name:"Nunavut"},{code:"ON",name:"Ontario"},{code:"PE",name:"Prince Edward Island"},{code:"QC",name:"Quebec"},{code:"SK",name:"Saskatchewan"},{code:"YT",name:"Yukon"}],fh=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"DC",name:"District of Columbia"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PA",name:"Pennsylvania"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}],yT={CA:Ya,US:fh};Ya.map(({code:e,name:n})=>({value:e,label:n}));const bT=({visible:e})=>t.jsx("svg",{className:"w-[18px] h-[18px]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:e?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"}):t.jsxs(t.Fragment,{children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),vT=({className:e="",...n})=>{const[s,a]=x.useState(!1);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{...n,type:s?"text":"password",className:`pr-10 ${e}`}),t.jsx("button",{type:"button",tabIndex:-1,"aria-label":s?"Hide password":"Show password",onClick:()=>a(o=>!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors",children:t.jsx(bT,{visible:s})})]})};function jT(e){const n=[/[A-Z]/,/[a-z]/,/[0-9]/,/[^A-Za-z0-9]/].filter(s=>s.test(e)).length;return e.length<8||n<2?{level:1,label:"Weak",bar:"bg-red-500",text:"text-red-500"}:n===2?{level:2,label:"Fair",bar:"bg-orange-400",text:"text-orange-500"}:n===3?{level:3,label:"Good",bar:"bg-yellow-400",text:"text-yellow-600"}:{level:4,label:"Strong",bar:"bg-emerald-500",text:"text-emerald-600"}}const wT=({password:e})=>{const{level:n,label:s,bar:a,text:o}=jT(e);return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("div",{className:"flex gap-1 flex-1",children:[1,2,3,4].map(l=>t.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-colors duration-200 ${l<=n?a:"bg-gray-200"}`},l))}),t.jsx("span",{className:`text-[11px] font-semibold w-12 text-right shrink-0 ${o}`,children:s})]})},NT=()=>{const e=Xe(),{register:n,success:s,requiresVerification:a,registeredEmail
97:o,error:l,inProgress:d,errors:u}=xT(),[p,h]=x.useState({first_name:"",last_name:"",email:"",confirm_email:"",password:"",confirm:"",country:"CA",province:""}),[f,g]=x.useState(!1),[b,v]=x.useState(!1);x.useEffect(()=>{a&&o&&e("/check-email",{state:{email:o},replace:!0})},[a,o,e]),x.useEffect(()=>{s&&e("/dashboard")},[s,e]);const N=_=>S=>h(T=>({...T,[_]:S.target.value})),w=_=>{if(_.preventDefault(),p.email!==p.confirm_email){g(!0);return}if(g(!1),!p.province.trim()){v(!0);return}v(!1),n(p)},k=_=>{var S;return(S=u==null?void 0:u[_])==null?void 0:S[0]};return t.jsxs("div",{className:"flex min-h-screen",children:[t.jsxs("div",{className:"hidden lg:flex flex-col justify-between w-[440px] shrink-0 bg-[#0A1628] px-12 py-12",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-8 w-auto"}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-4xl font-bold text-white leading-tight",children:["Start organizing",t.jsx("br",{}),"your finances today."]}),t.jsx("p",{className:"mt-4 text-white/60 text-base leading-relaxed",children:"Join thousands of freelancers and small businesses who let AI handle their bookkeeping."})]}),t.jsxs("div",{className:"text-white/30 text-xs space-y-1",children:[t.jsx("p",{children:"© 2026 Time2Win Inc."}),t.jsxs("p",{className:"flex items-center gap-2",children:[t.jsx(Fe,{to:"/privacy-policy",className:"hover:text-white/50 transition-colors",children:"Privacy Policy"}),t.jsx("span",{children:"·"}),t.jsx(Fe,{to:"/terms-of-service",className:"hover:text-white/50 transition-colors",children:"Terms of Service"})]})]})]}),t.jsx("div",{className:"flex flex-1 items-center justify-center bg-white px-6 py-12",children:t.jsxs("div",{className:"w-full max-w-sm",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mb-10 lg:hidden"}),t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Create account"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Free trial — no credit card required"}),l&&!Object.values(u??{}).some(_=>Array.isArray(_)&&_.length>0)&&t.jsx("div",{className:"mt-4 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:l}),t.jsxs("form",{onSubmit:w,className:"mt-8 space-y-4",children:[t.jsx("div",{className:"grid grid-cols-2 gap-3",children:["first_name","last_name"].map(_=>t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5 capitalize",children:_==="first_name"?"First name":"Last name"}),t.jsx("input",{type:"text",required:!0,value:p[_],onChange:N(_),placeholder:_==="first_name"?"Jane":"Smith",className:`w-full rounded-lg border px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition ${k(_)?"border-red-400":"border-gray-300"}`}),k(_)&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:k(_)})]},_))}),[{field:"email",label:"Email address",type:"email",placeholder:"[email protected]"},{field:"confirm_email",label:"Confirm email address",type:"email",placeholder:"[email protected]"}].map(({field:_,label:S,type:T,placeholder:E})=>t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:S}),t.jsx("input",{type:T,required:!0,value:p[_],onChange:N(_),placeholder:E,className:`w-full rounded-lg border px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition ${k(_)?"border-red-400":"border-gray-300"}`}),k(_)&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:k(_)}),_==="confirm_email"&&f&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Email addresses do not match."})]},_)),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Country"}),t.jsx("select",{value:p.country,onChange:_=>{h(S=>({...S,country:_.target.value,province:""})),v(!1)},className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition",children:gT.map(_=>t.jsx("option",{value:_.code,children:_.name},_.code))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:p.country==="CA"?"Province":"State"}),t.jsxs("select",{value:p.province,onChange:_=>{h(S=>
97({...S,province:_.target.value})),v(!1)},className:`w-full rounded-lg border px-3.5 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition ${b||k("province")?"border-red-400":"border-gray-300"}`,children:[t.jsx("option",{value:"",children:p.country==="CA"?"Select province…":"Select state…"}),yT[p.country].map(_=>t.jsx("option",{value:_.code,children:_.name},_.code))]}),b&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Province/State is required."}),k("province")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:k("province")})]}),[{field:"password",label:"Password",placeholder:"Min. 8 characters"},{field:"confirm",label:"Confirm password",placeholder:"Repeat password"}].map(({field:_,label:S,placeholder:T})=>t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:S}),t.jsx(vT,{required:!0,value:p[_],onChange:N(_),placeholder:T,autoComplete:"new-password",className:`w-full rounded-lg border px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition ${k(_)?"border-red-400":"border-gray-300"}`}),_==="password"&&p.password&&t.jsx(wT,{password:p.password}),k(_)&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:k(_)})]},_)),t.jsx("button",{type:"submit",disabled:d,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors mt-2",children:d?t.jsxs(t.Fragment,{children:[t.jsx(tw,{})," Creating account…"]}):"Create account"})]}),t.jsxs("p",{className:"mt-6 text-center text-sm text-gray-500",children:["Already have an account?"," ",t.jsx(Fe,{to:"/login",className:"font-medium text-[#0066FF] hover:underline",children:"Sign in"})]}),t.jsxs("p",{className:"mt-4 text-center text-xs text-gray-400",children:["By continuing, you agree to our"," ",t.jsx(Fe,{to:"/terms-of-service",className:"underline hover:text-gray-600 transition-colors",children:"Terms of Service"})," ","and"," ",t.jsx(Fe,{to:"/privacy-policy",className:"underline hover:text-gray-600 transition-colors",children:"Privacy Policy"})]})]})})]})},_T=()=>{var h;const n=((h=vn().state)==null?void 0:h.email)??"",[s,a]=x.useState(!1),[o,l]=x.useState(!1),[d,u]=x.useState(""),p=async()=>{a(!0),l(!1),u("");try{await Me.post(`${yn}/api/auth/resend-verification/`,{email:n}),l(!0)}catch{u("Could not resend. Please try again.")}finally{a(!1)}};return t.jsxs("div",{className:"flex min-h-screen",children:[t.jsxs("div",{className:"hidden lg:flex flex-col justify-between w-[440px] shrink-0 bg-[#0A1628] px-12 py-12",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-8 w-auto"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-4xl font-bold text-white leading-tight",children:"One last step."}),t.jsx("p",{className:"mt-4 text-white/60 text-base leading-relaxed",children:"Check your inbox and verify your email to activate your account."})]}),t.jsx("p",{className:"text-white/30 text-sm",children:"© 2026 Time2Win Inc."})]}),t.jsx("div",{className:"flex-1 bg-white overflow-y-auto",children:t.jsx("div",{className:"flex min-h-full items-center justify-center px-6 py-8",children:t.jsxs("div",{className:"w-full max-w-sm text-center",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mb-10 mx-auto lg:hidden"}),t.jsx("div",{className:"w-16 h-16 rounded-2xl bg-blue-50 flex items-center justify-center mx-auto mb-6",children:t.jsx("svg",{className:"w-8 h-8 text-[#0066FF]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",children:t.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"})})}),t.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Check your email"}),t.jsxs("p",{className:"text-sm text-gray-500 leading-relaxed",children:["We sent a confirmation link to"," ",t.jsx("span",{className:"font-semibold text-gray-800",children:n||"your email address"}),". Please verify your email to activate your account."]}),t.jsxs("div",{className:"mt-8 space-y-3",children:[o&&t.jsx("p",{className:"text-sm text-emerald-600 font-medium",children:"Verification email resent!"}),d&&t.jsx("p",{className:"text-sm text-red-600",children:d}),t.jsxs("button",{onClick:p,disabled:s,className:"w-full flex items-center justify-center gap-2 rounded-lg border border-gray-200 hover:bg-gray-50 disabled:opacity-60 px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors",children:[s&&t.jsx("div",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent roun
97ded-full animate-spin"}),s?"Resending…":"Resend email"]}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Already verified?"," ",t.jsx("a",{href:"/login",className:"text-[#0066FF] hover:underline font-medium",children:"Sign in"})]})]})]})})})]})},kT=()=>{const[e]=Jn(),n=e.get("token")??"",[s,a]=x.useState("loading"),[o,l]=x.useState("");return x.useEffect(()=>{if(!n){a("error"),l("No verification token found.");return}Me.get(`${yn}/api/auth/verify-email/?token=${encodeURIComponent(n)}`).then(d=>{var u;(u=d.data)!=null&&u.already_verified?a("already"):a("success")}).catch(d=>{var u,p;a("error"),l(((p=(u=d.response)==null?void 0:u.data)==null?void 0:p.error)??"This link is invalid or has expired.")})},[n]),t.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-50 px-6",children:t.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-10 max-w-sm w-full text-center",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mx-auto mb-8"}),s==="loading"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-8 h-8 border-3 border-[#0066FF] border-t-transparent rounded-full animate-spin mx-auto mb-4"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Verifying your email…"})]}),(s==="success"||s==="already")&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-7 h-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:s==="already"?"Already verified":"Email verified!"}),t.jsx("p",{className:"text-sm text-gray-500 mb-6",children:s==="already"?"Your email was already verified. You can sign in.":"Your account is now active. You can sign in."}),t.jsx(be,{to:"/login",className:"inline-flex rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-6 py-2.5 text-sm font-semibold text-white transition-colors",children:"Sign in →"})]}),s==="error"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-red-50 flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-7 h-7 text-red-500",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),t.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Verification failed"}),t.jsx("p",{className:"text-sm text-gray-500 mb-6",children:o}),t.jsx(be,{to:"/register",className:"text-sm text-[#0066FF] hover:underline font-medium",children:"Back to registration"})]})]})})},ST=()=>{const[e,n]=x.useState(""),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[d,u]=x.useState(""),p=async h=>{h.preventDefault(),a(!0),u("");try{await Me.post(`${yn}/api/auth/forgot-password/`,{email:e}),l(!0)}catch{u("Something went wrong. Please try again.")}finally{a(!1)}};return t.jsxs("div",{className:"flex h-screen overflow-hidden",children:[t.jsxs("div",{className:"hidden lg:flex flex-col justify-between w-[440px] shrink-0 bg-[#0A1628] px-12 py-12",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[53px] w-auto"}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-4xl font-bold text-white leading-tight",children:["Forgot your",t.jsx("br",{}),"password?"]}),t.jsx("p",{className:"mt-4 text-white/60 text-base leading-relaxed",children:"No problem. Enter your email and we'll send you a secure reset link."})]}),t.jsx("p",{className:"text-white/30 text-sm",children:"© 2026 Time2Win Inc."})]}),t.jsx("div",{className:"flex-1 bg-white overflow-y-auto",children:t.jsx("div",{className:"flex min-h-full items-center justify-center px-6 py-8",children:t.jsxs("div",{className:"w-full max-w-sm",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mb-10 lg:hidden"}),t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Reset your password"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Enter your account email and we'll send a reset link."}),o?t.jsx("div",{className:"mt-6 rounded-lg bg-emerald-50 border border-emerald-200 px-4 py-4 text-sm text-emerald-800",children:"If that email is registered, you'll receive a reset link shortly. Check your inbox — the link expires in 24 hours."}):t.jsxs(t.Fragment,{children:[d&&t.jsx("div",{className:"mt-4 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:d}),t.jsxs("form",{onSubmit:p,className:"mt-8 space-y-5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Email address"}),t.jsx("input",{type:"email",required:!0,autoComplete:"email",value:e,onCh
97ange:h=>n(h.target.value),placeholder:"[email protected]",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("button",{type:"submit",disabled:s,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:[s&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),s?"Sending…":"Send reset link"]})]})]}),t.jsxs("p",{className:"mt-6 text-center text-sm text-gray-500",children:["Remember your password?"," ",t.jsx(Fe,{to:"/login",className:"font-medium text-[#0066FF] hover:underline",children:"Sign in"})]})]})})})]})},CT=({visible:e})=>t.jsx("svg",{className:"w-[18px] h-[18px]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:e?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"}):t.jsxs(t.Fragment,{children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),bb=({className:e="",...n})=>{const[s,a]=x.useState(!1);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{...n,type:s?"text":"password",className:`pr-10 ${e}`}),t.jsx("button",{type:"button",tabIndex:-1,"aria-label":s?"Hide password":"Show password",onClick:()=>a(o=>!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors",children:t.jsx(CT,{visible:s})})]})},vb="w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition",ET=()=>{const[e]=Jn(),n=e.get("token")??"",[s,a]=x.useState(""),[o,l]=x.useState(""),[d,u]=x.useState(!1),[p,h]=x.useState(!1),[f,g]=x.useState(""),b=async v=>{var N,w;if(v.preventDefault(),s!==o){g("Passwords do not match.");return}u(!0),g("");try{await Me.post(`${yn}/api/auth/reset-password/`,{token:n,password:s,confirm_password:o}),h(!0)}catch(k){g(((w=(N=k.response)==null?void 0:N.data)==null?void 0:w.error)??"Something went wrong. Please try again.")}finally{u(!1)}};return t.jsxs("div",{className:"flex h-screen overflow-hidden",children:[t.jsxs("div",{className:"hidden lg:flex flex-col justify-between w-[440px] shrink-0 bg-[#0A1628] px-12 py-12",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[53px] w-auto"}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-4xl font-bold text-white leading-tight",children:["Choose a new",t.jsx("br",{}),"password."]}),t.jsx("p",{className:"mt-4 text-white/60 text-base leading-relaxed",children:"Pick something strong — at least 8 characters."})]}),t.jsx("p",{className:"text-white/30 text-sm",children:"© 2026 Time2Win Inc."})]}),t.jsx("div",{className:"flex-1 bg-white overflow-y-auto",children:t.jsx("div",{className:"flex min-h-full items-center justify-center px-6 py-8",children:t.jsxs("div",{className:"w-full max-w-sm",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mb-10 lg:hidden"}),p?t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-7 h-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsx("h2",{className:"text-2xl font-semibold text-gray-900 mb-2",children:"Password reset!"}),t.jsx("p",{className:"text-sm text-gray-500 mb-6",children:"Your password has been updated. You can now sign in with your new password."}),t.jsx(Fe,{to:"/login",className:"inline-flex rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-6 py-2.5 text-sm font-semibold text-white transition-colors",children:"Sign in →"})]}):n?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Set new password"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Enter and confirm your new password."}),f&&t.jsxs("div",{className:"mt-4 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:[f,f.toLowerCase().includes("invalid or has expired")&&t.jsxs("span",{children:[" ",t.jsx(Fe,{to:"/forgot-password",className:"underline font-medium hover:text-red-900",children:"Request a new one"})]})]}),t.jsxs("form",{onSubmit:b,className:"mt-8 space-y-5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"New password"}),t.jsx(bb,{required:!0,value:s,onChange:v=>a(v.target.value),placeholder:"Min. 8 characters",autoComplete:"new-password",className:vb})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Confirm new password"}),t.jsx(bb,{required:!0,value:o,onChange:v=>l(v.target.value),placeholder:"Repeat new password",autoComplete:"new-password",className:vb})]}),t.jsxs("button",{type:"submit",disabled:d,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:[d&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),d?"Resetting…":"Reset password"]})]})]}):t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Invalid link"}),t.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"No reset token found in this URL."}),t.jsx(Fe,{to:"/forgot-password",className:"text-sm font-medium text-[#0066FF] hover:underline",children:"Request a new one"})]})]})})})]})},AT=({visible:e})=>t.jsx("svg",{className:"w-[18px] h-[18px]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:e?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"}):t.jsxs(t.Fragment,{children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),jb=({className:e="",...n})=>{const[s,a]=x.useState(!1);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{...n,type:s?"text":"password",className:`pr-10 ${e}`}),t.jsx("button",{type:"button",tabIndex:-1,"aria-label":s?"Hide password":"Show password",onClick:()=>a(o=>!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors",children:t.jsx(AT,{visible:s})})]})},Ql="w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition",TT=()=>{const[e]=Jn(),n=e.get("token")??"",[s,a]=x.useState(""),[o,l]=x.useState(""),[d,u]=x.useState(""),[p,h]=x.useState(""),[f,g]=x.useState(!1),[b,v]=x.useState(!1),[N,w]=x.useState(""),k=async _=>{var S,T;if(_.preventDefault(),d!==p){w("Passwords do not match.");return}if(d.length<10){w("Password must be at least 10 characters.");return}g(!0),w("");try{await Me.post(`${yn}/api/accounting/staff/invite/accept/`,{token:n,password:d,first_name:s,last_name:o}),v(!0)}catch(E){w(((T=(S=E.response)==null?void 0:S.data)==null?void 0:T.detail)??"This link is invalid or has expired.")}finally{g(!1)}};return t.jsxs("div",{className:"flex h-screen overflow-hidden",children:[t.jsxs("div",{className:"hidden lg:flex flex-col justify-between w-[440px] shrink-0 bg-[#0A1628] px-12 py-12",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[53px] w-auto"}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-4xl font-bold text-white leading-tight",children:["Accept your",t.jsx("br",{}),"invitation."]}),t.jsx("p",{className:"mt-4 text-white/60 text-base leading-relaxed",children:"Set your password to join AI Bookkeeping as an internal reviewer."})]}),t.jsx("p",{className:"text-white/30 text-sm",children:"© 2026 Time2Win Inc."})]}),t.jsx("div",{className:"flex-1 bg-white overflow-y-auto",children:t.jsx("div",{className:"flex min-h-full items-center justify-center px-6 py-8",children:t.jsxs("div",{className:"w-full max-w-sm",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 mb-10 lg:hidden"}),b?t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-7 h-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsx("h2",{className:"text-2xl font-semibold text-gray-900 mb-2",children:"Invitation accepted!"}),t.jsx("p",{className:"text-sm text-gray-500 mb-6",children:"Your account is ready. You can now sign in."}),t.jsx(Fe,{to:"/login",className:"inline-flex rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-6 py-2.5 text-sm font-semibold text-white transition-colors",children:"Sign in →"})]}):n?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Set up your account"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Choose a password to accept your invitation."}),N&&t.jsx("div",{className:"mt-4 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:N}),t.jsxs("form",{onSubmit:k,className:"mt-8 space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"First name"}),t.jsx("input",{value:s,onChange:_=>a(_.target.value),placeholder:"Optional",autoComplete:"given-name",className:Ql})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Last name"}),t.jsx("input",{value:o,onChange:_=>l(_.target.value),placeholder:"Optional",autoComplete:"family-name",className:Ql})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Password"}),t.jsx(jb,{required:!0,value:d,onChange:_=>u(_.target.value),placeholder:"Min. 10 characters",autoComplete:"new-password",className:Ql})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Confirm password"}),t.jsx(jb,{required:!0,value:p,onChange:_=>h(_.target.value),placeholder:"Repeat password",autoComplete:"new-password",className:Ql})]}),t.jsxs("button",{type:"submit",disabled:f,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:[f&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),f?"Accepting…":"Accept invitation"]})]})]}):t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Invalid link"}),t.jsx("p",{className:"text-sm text-gray-500",children:"This invite link is invalid or has expired."})]})]})})})]})},Jl="w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[color:var(--color-primary)] focus:border-transparent transition",LT=({visible:e})=>t.jsx("svg",{className:"h-[18px] w-[18px]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:e?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"}):t.jsxs(t.Fragment,{children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),wb=({className:e="",...n})=>{const[s,a]=x.useState(!1);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{...n,type:s?"text":"password",className:`pr-10 ${e}`}),t.jsx("button",{type:"button",tabIndex:-1,"aria-label":s?"Hide password":"Show password",onClick:()=>a(o=>!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 transition-colors hover:text-gray-600",children:t.jsx(LT,{visible:s})})]})},Oi=({children:e})=>t.jsxs("div",{className:"flex h-screen overflow-hidden",children:[t.jsxs("div",{className:"hidden w-[440px] shrink-0 flex-col justify-between bg-[var(--color-navy)] px-12 py-12 lg:flex",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-[53px] w-auto"}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-4xl font-bold leading-tight text-white",children:["Join the",t.jsx("br",{}),"team."]}),t.jsx("p",{className:"mt-4 text-base leading-relaxed text-white/60",children:"Accept your invitation to help manage the books on AI Bookkeeping."})]}),t.jsx("p",{className:"text-sm text-white/30",children:"© 2026 Time2Win Inc."})]}),t.jsx("div",{className:"flex-1 overflow-y-auto bg-white",children:t.jsx("div",{className:"flex min-h-full items-center justify-center px-6 py-8",children:t.jsxs("div",{className:"w-full max-w-sm",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"mb-10 h-7 lg:hidden"}),e]})})})]}),Nb=({loading:e,children:n,...s})=>t.jsxs("button",{...s,className:"flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-60",children:[e&&t.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),n]}),RT=()=>{var re;const[e]=Jn(),n=e.get("token")??"",s=!!oo(),{user:a}=ht(H=>H.auth),o=((re=a==null?void 0:a.user)==null?void 0:re.email)??(a==null?void 0:a.email)??"",{getUser:l}=X1(!1),{setActiveOrgId:d}=zt(),[u,p]=x.useState("/accounting/dashboard"),[h,f]=x.useState(""),[g,b]=x.useState(""),[v,N]=x.useState(""),[w,k]=x.useState(""),[_,S]=x.useState(!1),[T,E]=x.useState(""),[A,I]=x.useState(""),[R,W]=x.useState(null),[Y,K]=x.useState(!1),X=`${yn}/api/accounting/invite/accept/`,se=`/login?next=${encodeURIComponent(`/invite/accept?token=${n}`)}`,ne=async()=>{var H,M,Q,$,L;S(!0),E("");try{const F=await Me.post(X,{token:n},{headers:{Authorization:`Bearer ${oo()}`}}),V=await(l==null?void 0:l()),q=((H=V==null?void 0:V.user)==null?void 0:H.memberships)??(V==null?void 0:V.memberships)??[],ee=((M=F.data)==null?void 0:M.org_id)??null,je=ee&&q.find(ke=>ke.org_id===ee)||(q.length?q[q.length-1]:null);je&&(d(je.org_id),p(je.role==="accountant"?"/accountant/ledger":"/accounting/dashboard")),W(((Q=F.data)==null?void 0:Q.org_name)??"")}catch(F){E(((L=($=F.response)==null?void 0:$.data)==null?void 0:L.detail)??"This invite link is invali
97d or has expired.")}finally{S(!1)}},Z=async H=>{var M,Q,$;if(H.preventDefault(),I(""),v!==w){I("Passwords do not match.");return}S(!0),E("");try{const L=await Me.post(X,{token:n,first_name:h,last_name:g,password:v});W(((M=L.data)==null?void 0:M.org_name)??"")}catch(L){const F=(Q=L.response)==null?void 0:Q.status,V=($=L.response)==null?void 0:$.data;if(F===409&&(V==null?void 0:V.code)==="account_exists"){K(!0);return}if(V!=null&&V.password){I(Array.isArray(V.password)?V.password[0]:String(V.password));return}E((V==null?void 0:V.detail)??"This invite link is invalid or has expired.")}finally{S(!1)}};if(R!==null)return t.jsx(Oi,{children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-emerald-50",children:t.jsx("svg",{className:"h-7 w-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsxs("h2",{className:"mb-2 text-2xl font-semibold text-gray-900",children:["You’ve joined",R?` ${R}`:""," as an accountant"]}),t.jsx("p",{className:"mb-6 text-sm text-gray-500",children:"Your access is ready."}),t.jsx(Fe,{to:s?u:"/login",className:"inline-flex rounded-lg bg-[var(--color-primary)] px-6 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:"Continue →"})]})});if(Y)return t.jsx(Oi,{children:t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"mb-2 text-2xl font-semibold text-gray-900",children:"You already have an account"}),t.jsx("p",{className:"mb-6 text-sm text-gray-500",children:"An account with the invited email already exists. Log in and reopen this link to accept the invitation."}),t.jsx(Fe,{to:se,className:"inline-flex rounded-lg bg-[var(--color-primary)] px-6 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:"Log in to accept →"})]})});if(!n)return t.jsx(Oi,{children:t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"mb-2 text-xl font-semibold text-gray-900",children:"Invalid link"}),t.jsx("p",{className:"text-sm text-gray-500",children:"This invite link is invalid or has expired."})]})});const ue=T?t.jsx("div",{className:"mt-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:T}):null;return s?t.jsxs(Oi,{children:[t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Accept invitation"}),t.jsxs("p",{className:"mt-1 text-sm text-gray-500",children:["Accept this invitation",o?t.jsxs(t.Fragment,{children:[" as ",t.jsx("span",{className:"font-medium text-gray-700",children:o})]}):"","."]}),ue,t.jsx("div",{className:"mt-8",children:t.jsx(Nb,{onClick:ne,disabled:_,loading:_,children:_?"Accepting…":"Accept invitation"})})]}):t.jsxs(Oi,{children:[t.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:"Set up your account"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Choose a password to accept your invitation."}),ue,t.jsxs("form",{onSubmit:Z,className:"mt-8 space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:"First name"}),t.jsx("input",{value:h,onChange:H=>f(H.target.value),placeholder:"Jane",autoComplete:"given-name",className:Jl})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:"Last name"}),t.jsx("input",{value:g,onChange:H=>b(H.target.value),placeholder:"Optional",autoComplete:"family-name",className:Jl})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:"Password"}),t.jsx(wb,{required:!0,value:v,onChange:H=>N(H.target.value),placeholder:"Min. 10 characters",autoComplete:"new-password",className:Jl})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:"Confirm password"}),t.jsx(wb,{required:!0,value:w,onChange:H=>k(H.target.value),placeholder:"Repeat password",autoComplete:"new-password",className:Jl})]}),A&&t.jsx("p",{className:"text-sm text-red-600",children:A}),t.jsx(Nb,{type:"submit",disabled:_,loading:_,children:_?"Accepting…":"Accept invitation"})]})]})},dp=e=>
97new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",maximumFractionDigits:2}).format(e),up=e=>{const n=e.extracted_data??[],s=n.find(a=>a.description==="_total");return s&&typeof s.amount=="number"?s.amount:n.filter(a=>a.description!=="_total").reduce((a,o)=>a+(typeof o.amount=="number"?o.amount:0),0)},IT=e=>(e.extracted_data??[]).reduce((n,s)=>n+(typeof s.tax_amount=="number"?s.tax_amount:0),0),PT=e=>{var a,o;const n=(o=(a=e.extracted_data)==null?void 0:a[0])==null?void 0:o.date;return(n?new Date(n):new Date(e.created_at)).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"})},FT=e=>{var n,s,a;return((a=(s=(n=e.extracted_data)==null?void 0:n[0])==null?void 0:s.vendor)==null?void 0:a.trim())||e.name.replace(/\.[^.]+$/,"").replace(/_/g," ")},DT=e=>{var n,s;return((s=(n=e.extracted_data)==null?void 0:n[0])==null?void 0:s.category)??"—"},OT=e=>{const n=e*2.5;if(n<60)return`${Math.floor(n)} min`;const s=Math.floor(n/60),a=Math.round(n%60);return a>0?`${s}h ${a}min`:`${s}h`},$T=()=>{const e=new Date().getHours();return e<12?"Good morning":e<17?"Good afternoon":"Good evening"},MT=e=>{const n=new Date(e),s=new Date;return n.getMonth()===s.getMonth()&&n.getFullYear()===s.getFullYear()},BT=()=>t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Xl=({label:e,value:n,sub:s,icon:a,accent:o="bg-blue-50 text-[#0066FF]"})=>t.jsx("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm px-6 py-5",children:t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide",children:e}),t.jsx("p",{className:"mt-2 text-2xl font-bold text-gray-900",children:n}),s&&t.jsx("p",{className:"mt-1 text-xs text-gray-400",children:s})]}),t.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${o}`,children:a})]})}),UT=({status:e})=>{const n={done:{label:"Categorized",cls:"bg-emerald-50 text-emerald-700"},failed:{label:"Failed",cls:"bg-red-50 text-red-700"},pending:{label:"Processing",cls:"bg-amber-50 text-amber-700"},needs_clarification:{label:"Needs review",cls:"bg-blue-50 text-blue-700"},unreadable:{label:"Unreadable",cls:"bg-orange-50 text-orange-700"}},{label:s,cls:a}=n[e]??{label:e,cls:"bg-gray-100 text-gray-600"};return t.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${a}`,children:s})},zT=()=>t.jsx("tr",{children:[60,120,100,80,90].map((e,n)=>t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-3.5 bg-gray-100 rounded animate-pulse",style:{width:e}})},n))}),WT=()=>{var f,g,b;const e=ht(v=>v.auth),n=((g=(f=e.user)==null?void 0:f.user)==null?void 0:g.first_name)??((b=e.user)==null?void 0:b.first_name)??"",[s,a]=x.useState([]),[o,l]=x.useState(!0);x.useEffect(()=>{te.get("/api/documents/").then(v=>{Array.isArray(v==null?void 0:v.data)&&a(v.data)}).finally(()=>l(!1))},[]);const d=s.filter(v=>MT(v.created_at)),u=s.reduce((v,N)=>
97v+up(N),0),p=s.reduce((v,N)=>v+IT(N),0),h=[...s].sort((v,N)=>new Date(N.created_at).getTime()-new Date(v.created_at).getTime()).slice(0,8);return t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-8",children:[t.jsxs("div",{className:"flex items-start justify-between mb-8",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-900",children:[$T(),n?`, ${n}`:""," 👋"]}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Here's your financial overview"})]}),t.jsxs(be,{to:"/documents",className:"flex items-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-4 py-2.5 text-sm font-semibold text-white transition-colors shadow-sm",children:[t.jsx(BT,{}),"Upload document"]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-5 mb-8",children:[t.jsx(Xl,{label:"Documents this month",value:o?"—":String(d.length),sub:o?"":`${s.length} total`,accent:"bg-blue-50 text-[#0066FF]",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),t.jsx(Xl,{label:"Total expenses",value:o?"—":dp(u),sub:"All documents",accent:"bg-violet-50 text-violet-600",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),t.jsx(Xl,{label:"ITC / Tax claimable",value:o?"—":p>0?dp(p):"See Reports",sub:p>0?"From extracted receipts":"Run a tax report",accent:"bg-emerald-50 text-emerald-600",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 14.25l6-6m4.5-3.493V21.75l-3.75-1.5-3.75 1.5-3.75-1.5-3.75 1.5V4.757c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0c1.1.128 1.907 1.077 1.907 2.185z"})})}),t.jsx(Xl,{label:"Time saved",value:o?"—":OT(s.length),sub:"vs. manual data entry",accent:"bg-amber-50 text-amber-600",icon:t.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7v5l3 3"})]})})]}),t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Recent Documents"}),t.jsx(be,{to:"/documents",className:"text-sm text-[#0066FF] hover:underline font-medium",children:"View all"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-100",children:["Date","Vendor","Category","Amount","Status"].map(v=>t.jsx("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wide",children:v},v))})}),t.jsx("tbody",{className:"divide-y divide-gray-50",children:o?Array.from({length:5}).map((v,N)=>t.jsx(zT,{},N)):h.length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:5,className:"px-6 py-12 text-center text-sm text-gray-400",children:["No documents yet."," ",t.jsx(be,{to:"/documents",className:"text-[#0066FF] hover:underline",children:"Upload your first one →"})]})}):h.map(v=>t.jsxs("tr",{className:"hover:bg-gray-50 transition-colors",children:[t.jsx("td",{className:"px-6 py-4 text-gray-500 whitespace-nowrap",children:PT(v)}),t.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 max-w-[180px] truncate",children:FT(v)}),t.jsx("td",{className:"px-6 py-4 text-gray-500",children:DT(v)}),t.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 tabular-nums whitespace-nowrap",children:up(v)>0?dp(up(v)):"—"}),t.jsx("td",{className:"px-6 py-4",children:t.jsx(UT,{status:v.extraction_status})})]},v.id))})]})})]})]})})},HT=["image/jpeg","image/png","image/webp","application/pdf","image/heic","image/heif"],qT=10*1024*1024,VT=e=>new Promise((n,s)=>{const a=new FileReader;a.onload=()=>n(a.result.split(",")[1]),a.onerror=s,a.readAsDataURL(e)}),kc=e=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD"}).format(e),YT=e=>e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:`${(e/1024**2).toFixed(1)} MB`,aw=e=>{var a,o;const n=(o=(a=e.extracted_data)==null?void 0:a[0])==null?void 0:o.date;return(n?new Date(n):new Date(e.created_at)).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"})},Pd=e=>{var n,s,a;return((a=(s=(n=e.extracted_data)==null?void 0:n[0])==null?void 0:s.vendor)==null?void 0:a.trim())||e.name.replace(/\.[^.]+$/,"").replace(/[_-]/g," ")},Nf=e=>{var n,s;return((s=(n=e.extracted_data)==null?void 0:n[0])==null?void 0:s.category)??"—"},lo=e=>{const n=e.extracted_data??[],s=n.find(a=>a.description==="_total");return s&&typeof s.amount=="number"?s.amount:n.filter(a=>a.description!=="_total").reduce((a,o)=>a+(typeof o.amount=="number"?o.amount:0),0)},GT={done:{label:"Categorized",cls:"bg-emerald-50 text-emerald-700"},failed:{label:"Failed",cls:"bg-red-50 text-red-700"},pending:{label:"Processing",cls:"bg-amber-50 text-amber-700"},needs_clarification:{label:"Needs review",cls:"bg-blue-50 text-blue-700"},unreadable:{label:"Unreadable",cls:"bg-orange-50 text-orange-700"}},iw=({status:e})=>{const{label:n,cls:s}=GT[e]??{label:e,cls:"bg-gray-100 text-gray-600"};return t.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${s}`,children:n})},KT=({doc:e,onClose:n,onEdit:s})=>{if(!e)return null;const o=(e.extracted_data??[]).filter(d=>d.description!=="_total"),l=lo(e);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/30 z-40 transition-opacity",onClick:n}),t.jsxs("div",{className:"fixed right-0 top-0 h-full w-full max-w-md bg-white shadow-2xl z-50 flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900 truncate max-w-[280px]",children:Pd(e)}),t.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:[aw(e)," · ",YT(e.size)]})]}),t.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Close",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-gray-50 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(iw,{status:e.extraction_status}),o.length>0&&t.jsxs("span",{className:"text-xs text-gray-400",children:[o.length," line item",o.length!==1?"s":""]})]}),e.file&&t.jsxs("a",{href:e.file,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 text-xs font-medium text-[#0066FF] hover:underline",children:[t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"})}),"View original"]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[e.extraction_status==="failed"&&t.jsxs("div",{className:"text-sm bg-red-50 rounded-lg px-4 py-3",children:[t.jsx("p",{className:"text-red-600",children:"AI extraction failed for this document. You can re-upload it or enter the data manually."}),s&&t.jsx("button",{onClick:()=>{n(),s(e)},className:"mt-3 w-full rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:"Enter data manually →"})]}),e.extraction_status==="pending"&&t.jsx("p",{className:"text-sm text-amber-700 bg-amber-50 rounded-lg px-4 py-3",children:"This document is still being processed."}),e.extraction_status==="needs_clarification"&&t.jsx("p",{className:"text-sm text-blue-700 bg-blue-50 rounded-lg px-4 py-3",children:"The AI needs clarification on the category. Check Telegram for a follow-up."}),o.length>0&&t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3",children:"Extracted line items"}),t.jsx("div",{className:"space-y-2",children:o.map((d,u)=>t.jsxs("div",{className:"flex items-start justify-between bg-gray-50 rounded-lg px-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:d.description??"—"}),t.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:[d.category??"—"," ",d.date?`· ${d.date}`:""]})]}),t.jsxs("div",{className:"ml-4 text-right shrink-0",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900",children:typeof d.amount=="number"?kc(d.amount):"—"}),typeof d.tax_amount=="number"&&d.tax_amount>0&&t.jsxs("p",{className:"text-xs text-gray-400",children:["Tax ",kc(d.tax_amount)]})]})]},u))}),t.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-gray-100",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-600",children:"Total"}),t.jsx("span",{className:"text-sm font-bold text-gray-900",children:kc(l)})]})]}),o.length===0&&e.extraction_status==="done"&&t.jsx("p",{className:"text-sm text-gray-400",children:"No line items were extracted."})]})]})]})},QT=({onFile:e,uploading:n,error:s})=>{const a=x.useRef(null),[o,l]=x.useState(!1),d=p=>{p.preventDefault(),l(!1);const h=p.dataTransfer.files[0];h&&e(h)},u=p=>{var f;const h=(f=p.target.files)==null?void 0:f[0];h&&e(h),p.target.value=""};return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{onClick:()=>{var p;return!n&&((p=a.current)==null?void 0:p.click())},onDragOver:p=>{p.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:d,className:`relative flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-8 py-12 transition-colors cursor-pointer ${o?"border-[#0066FF] bg-blue-50":n?"border-gray-200 bg-gray-50 cursor-wait":"border-gray-200 bg-white hover:border-[#0066FF] hover:bg-blue-50/40"}`,children:n?t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 border-3 border-[#0066FF] border-t-transparent roun
97ded-full animate-spin"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Uploading and extracting data…"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-50 flex items-center justify-center mb-4",children:t.jsx("svg",{className:"w-6 h-6 text-[#0066FF]",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.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.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),t.jsxs("p",{className:"text-sm font-medium text-gray-700",children:["Drag & drop a receipt or invoice, or"," ",t.jsx("span",{className:"text-[#0066FF]",children:"browse"})]}),t.jsx("p",{className:"mt-1 text-xs text-gray-400",children:"JPEG, PNG, WebP, HEIC or PDF · Max 10 MB"})]})}),s==="__trial_expired__"?t.jsxs("div",{className:"mt-3 rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800 flex items-center justify-between gap-4",children:[t.jsx("span",{children:"You've used your 5 free trial documents — choose a plan to continue."}),t.jsx(be,{to:"/subscription",className:"shrink-0 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-4 py-2 text-xs font-semibold text-white transition-colors",children:"Upgrade now →"})]}):s==="__quota_docs__"?t.jsxs("div",{className:"mt-3 rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800 flex items-center justify-between gap-4",children:[t.jsx("span",{children:"You've reached your document quota."}),t.jsx(be,{to:"/subscription",className:"shrink-0 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-4 py-2 text-xs font-semibold text-white transition-colors",children:"Upgrade now →"})]}):s==="__quota_storage__"?t.jsxs("div",{className:"mt-3 rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800 flex items-center justify-between gap-4",children:[t.jsx("span",{children:"You've run out of storage space."}),t.jsx(be,{to:"/subscription",className:"shrink-0 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-4 py-2 text-xs font-semibold text-white transition-colors",children:"Upgrade now →"})]}):s?t.jsx("div",{className:"mt-3 rounded-lg bg-red-50 border border-red-200 px-4 py-2.5 text-sm text-red-700",children:s}):null,t.jsx("input",{ref:a,type:"file",accept:"image/jpeg,image/png,image/webp,application/pdf,image/heic,image/heif,.heic,.heif",className:"hidden",onChange:u})]})},JT=()=>t.jsx("tr",{children:[72,140,110,80,90,40].map((e,n)=>t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-3.5 bg-gray-100 rounded animate-pulse",style:{width:e}})},n))}),XT=["Groceries","Meals & Entertainment","Office Supplies","Travel & Transportation","Fuel & Vehicle","Software & Subscriptions","Professional Services","Utilities & Communications","Advertising & Marketing","Insurance","Other Business Expenses"],ZT=({doc:e,onSave:n,onClose:s,saving:a})=>{var h,f;const o=(e.extracted_data??[]).find(g=>g.description==="_notes"),[l,d]=x.useState({vendor:Pd(e),category:Nf(e)==="—"?"":Nf(e),amount:lo(e)>0?String(lo(e)):"",date:((f=(h=e.extracted_data)==null?void 0:h[0])==null?void 0:f.date)??"",notes:(o==null?void 0:o.notes)??""}),u=g=>b=>d(v=>({...v,[g]:b.target.value})),p=g=>{g.preventDefault(),n(e.id,l)};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/30 z-40",onClick:s}),t.jsxs("div",{className:"fixed right-0 top-0 h-full w-full max-w-md bg-white shadow-2xl z-50 flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Edit document"}),t.jsx("p",{className:"text-xs text-gray-400 mt-0.5 truncate max-w-[280px]",children:e.name})]}),t.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Close",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("form",{onSubmit:p,className:"flex-1 overflow-y-auto px-6 py-6 space-y-5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Vendor"}
97),t.jsx("input",{type:"text",value:l.vendor,onChange:u("vendor"),placeholder:"Store or business name",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Category"}),t.jsxs("select",{value:l.category,onChange:u("category"),className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition bg-white",children:[t.jsx("option",{value:"",children:"— Select category —"}),XT.map(g=>t.jsx("option",{value:g,children:g},g))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Total amount"}),t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-sm text-gray-400",children:"$"}),t.jsx("input",{type:"number",step:"0.01",min:"0",value:l.amount,onChange:u("amount"),placeholder:"0.00",className:"w-full rounded-lg border border-gray-300 pl-8 pr-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]})]}),l.category==="Meals & Entertainment"&&t.jsx("p",{className:"text-xs text-gray-400 italic -mt-2",children:"Include any gratuity in the total amount paid."}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Date"}),t.jsx("input",{type:"date",value:l.date,onChange:u("date"),className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["Notes ",t.jsx("span",{className:"font-normal text-gray-400",children:"(optional)"})]}),t.jsx("textarea",{value:l.notes??"",onChange:u("notes"),placeholder:"e.g. Business lunch with client, includes tip",maxLength:500,rows:3,className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition resize-none"})]})]}),t.jsxs("div",{className:"flex gap-3 px-6 py-4 border-t border-gray-100",children:[t.jsx("button",{type:"button",onClick:s,disabled:a,className:"flex-1 rounded-lg border border-gray-200 px-4 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:a,onClick:g=>{g.preventDefault(),n(e.id,l)},className:"flex-1 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors flex items-center justify-center gap-2",children:a?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Saving…"]}):"Save changes"})]})]})]})},eL=({doc:e,deleting:n,onConfirm:s,onCancel:a})=>t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/40 z-50",onClick:a}),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:t.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-sm p-6",onClick:o=>o.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-50 flex items-center justify-center shrink-0",children:t.jsx("svg",{className:"w-5 h-5 text-red-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.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"})})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Delete document?"}),t.jsx("p",{className:"text-sm text-gray-500 mt-0.5 truncate max-w-[220px]",children:Pd(e)})]})]}),t.jsx("p",{className:"text-sm text-gray-500 mb-6",children:"This will permanently remove the document and restore your upload quota. This cannot be undone."}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:a,disabled:n,className:"flex-1 rounded-lg border border-gray-200 px-4 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:s,disabled:n,className:"flex-1 rounded-lg bg-red-600 hover:bg-red-700 px-4 py-2.5 text-sm font-semibold text-white transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"})," Deleting…"]}):"Delete"})]})]})})]}),tL=()=>{const[e,n]=x.useState([]),[s,a]=x.useState(!0),[o,l]=x.useState(!1),[d,u]=x.useState(""),[p,h]=x.useState(null),[f,g]=x.useState(null),[b,v]=x.useState(null),[N,w]=x.useState(null),[k,_]=x.useState(!1),S=x.useCallback(()=>{te.get("/api/documents/").then(R=>{Array.isArray(R==null?void 0:R.data)&&n(R.data)}).finally(()=>a(!1))},[]);x.useEffect(()=>{S()},[S]);const T=async R=>{var K,X;const W=R.type===""&&/\.(heic|heif)$/i.test(R.name);if(!HT.includes(R.type)&&!W){u("Only JPEG, PNG, WebP, HEIC images and PDFs are accepted.");return}if(R.size>qT){u("File must be under 10 MB.");return}l(!0),u("");const Y=oo();console.log("[upload] cookie token present:",!!Y),console.log("[upload] Authorization header will be:",`Bearer ${Y}`),console.log("[upload] posting to: /api/documents/upload"),console.log("[upload] file:",{name:R.name,type:R.type,size:R.size});try{const se=await VT(R),ne=await te.post("/api/documents/upload",{image:se,type:R.type,name:R.name});if(console.log("[upload] response status:",ne==null?void 0:ne.status),console.log("[upload] response data:",ne==null?void 0:ne.data),(ne==null?void 0:ne.status)===201)S();else{const Z=(K=ne==null?void 0:ne.data)==null?void 0:K.error_code,ue=(X=ne==null?void 0:ne.data)==null?void 0:X.error;console.warn("[upload] non-201 response — error_code:",Z,"| error:",ue),u(Z==="trial_expired"?"__trial_expired__":Z==="not_enough_documents"?"__quota_docs__":Z==="not_enough_storage"?"__quota_storage__":ue??"Upload failed. Please try again.")}}catch(se){console.error("[upload] caught exception:",se),u("Upload failed. Please try again.")}finally{l(!1)}},E=async(R,W)=>{_(!0);try{const Y=await te.patch(`/api/documents/${R}/`,{vendor:W.vendor||void 0,category:W.category||void 0,amount:W.amount?parseFloat(W.amount):void 0,date:W.date||void 0,notes:W.notes??""});Y!=null&&Y.data&&n(K=>K.map(X=>X.id===R?Y.data:X)),w(null)}finally{_(!1)}},A=async R=>{v(R.id);try{await te.delete(`/api/documents/${R.id}/`),n(W=>W.filter(Y=>Y.id!==R.id))}finally{v(null),g(null)}},I=[...e].sort((R,W)=>new Date(W.created_at).getTime()-new Date(R.created_at).getTime());return t.jsxs("div",{className:"flex flex-col h-full bg-gray-50",children:[t.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Documents"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Upload receipts and invoices — AI extracts and categorizes them automatically."})]}),t.jsx(QT,{onFile:T,uploading:o,error:d}),t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm",children:[t.jsx("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100",children:t.jsxs("h2",{className:"text-base font-semibold text-gray-900",children:["All Documents",!s&&e.length>0&&t.jsxs("span",{className:"ml-2 text-xs font-normal text-gray-400",children:[e.length," total"]})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-100",children:["Date","Vendor","Category","Amount","Status","",""].map(R=>t.jsx("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wide",children:R},R))})}),t.jsx("tbody",{className:"divide-y divide-gray-50",children:s?Array.from({length:5}).map((R,W)=>t.jsx(JT,{},W)):I.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-6 py-16 text-center",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl bg-gray-100 flex items-center justify-center",children:t.jsx("svg",{className:"w-6 h-6 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.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"})})}),t.jsx("p",{className:"text-sm font-medium text-gray-600",children:"No documents yet"}),t.jsx("p",{className:"text-xs text-gray-400",children:"Upload your first receipt or invoice above."})]})})}):I.map(R=>t.jsxs("tr",{className:"group hover:bg-gray-50 transition-colors",children:[t.jsx("td",{className:"px-6 py-4 text-gray-500 whitespace-nowrap",children:aw(R)}),t.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 max-w-[180px] truncate",children:Pd(R)}),t.jsx("td",{className:"px-6 py-4 text-gray-500",children:Nf(R)}),t.jsx("td",{className:"px-6 py-4 font-medium text-gray-900 tabular-nums whitespace-nowrap",children:lo(R)>0?kc(lo(R)):"—"}),t.jsx("td",{className:"px-6 py-4",children:t.jsx(iw,{status:R.extraction_status})}),t.jsx("td",{className:"px-6 py-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>h(R),className:"text-xs font-medium text-[#0066FF] hover:underline",children:"Details"}),R.file&&t.jsx("a",{href:R.file,target:"_blank",rel:"noreferrer",className:"text-xs font-medium text-gray-400 hover:text-gray-700 transition-colors",title:"View original file",children:"View"})]})}),t.jsx("td",{className:"px-4 py-4 w-20",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>w(R),title:"Edit document",className:"p-1.5 rounded-lg text-gray-400 hover:text-[#0066FF] hover:bg-blue-50 transition-colors",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"})})}),t.jsx("button",{onClick:()=>g(R),title:"Delete document",className:"p-1.5 rounded-lg text-gray-400 hover:text-red-600 hover:bg-red-50 transition-colors",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})})]})})]},R.id))})]})})]})]}),t.jsx(KT,{doc:p,onClose:()=>h(null),onEdit:R=>{h(null),w(R)}}),N&&t.jsx(ZT,{doc:N,saving:k,onSave:E,onClose:()=>w(null)}
97),f&&t.jsx(eL,{doc:f,deleting:b===f.id,onConfirm:()=>A(f),onCancel:()=>g(null)})]})},mp=new Date().getFullYear(),nL=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],sL=({className:e="w-4 h-4"})=>t.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),rL=()=>t.jsx("svg",{className:"w-6 h-6 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 01-1.125-1.125M3.375 19.5h7.5c.621 0 1.125-.504 1.125-1.125m-9.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-7.5A1.125 1.125 0 0112 18.375m9.75-12.75c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125m19.5 0v1.5c0 .621-.504 1.125-1.125 1.125M2.25 5.625v1.5c0 .621.504 1.125 1.125 1.125m0 0h17.25m-17.25 0h7.5c.621 0 1.125.504 1.125 1.125M3.375 8.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m17.25-3.75h-7.5c-.621 0-1.125.504-1.125 1.125m7.5-1.125c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M12 10.875v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M13.125 12h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125M20.625 12c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5M12 14.625v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 14.625c0 .621.504 1.125 1.125 1.125m-2.25 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m13.5-9.75h-7.5c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125h7.5c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125z"})}),aL=()=>{const[e,n]=x.useState(mp),[s,a]=x.useState([]),[o,l]=x.useState(!0),[d,u]=x.useState(!1),[p,h]=x.useState("");x.useEffect(()=>{te.get("/api/documents/").then(w=>{Array.isArray(w==null?void 0:w.data)&&a(w.data)}).finally(()=>l(!1))},[]);const f=s.filter(w=>new Date(w.created_at).getFullYear()===e),g=f.length===0,b=[...new Set(f.map(w=>new Date(w.created_at).getMonth()))].sort((w,k)=>w-k),v=async()=>{u(!0),h("");try{const w=await te.get(`/api/documents/workbook/?year=${e}`,{responseType:"blob"}),k=new Blob([w.data],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),_=URL.createObjectURL(k),S=document.createElement("a");S.href=_,S.download=`bookkeeping-${e}.xlsx`,document.body.appendChild(S),S.click(),document.body.removeChild(S),URL.revokeObjectURL(_)}catch{h("Download failed. Please try again.")}finally{u(!1)}},N=Array.from({length:mp-2022},(w,k)=>mp-k);return t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-8 max-w-3xl",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Workbook"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Download your annual bookkeeping workbook as an Excel file."})]}),t.jsxs("div",{className:"flex gap-4 bg-white rounded-xl border border-gray-100 shadow-sm px-6 py-5 mb-6",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-50 flex items-center justify-center shrink-0",children:t.jsx(rL,{})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Master workbook"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 leading-relaxed",children:"Your master workbook is an Excel file with one tab per month and a Year Summary tab, updated automatically every time you upload a document. Download it at any time to review your expenses in Excel."})]})]}),t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm px-6 py-5 mb-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-5",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Select year"}),t.jsx("div",{className:"flex gap-1.5",children:N.map(w=>t.jsx("button",{onClick:()=>n(w),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${w===e?"bg-[#0066FF] text-white":"text-gray-600 hover:bg-gray-100"}`,children:w}
97,w))})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{className:"bg-gray-50 rounded-lg px-4 py-3",children:[t.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wide",children:"Documents"}),t.jsx("p",{className:"mt-1 text-2xl font-bold text-gray-900",children:o?"—":f.length})]}),t.jsxs("div",{className:"bg-gray-50 rounded-lg px-4 py-3",children:[t.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wide",children:"Months active"}),t.jsx("p",{className:"mt-1 text-2xl font-bold text-gray-900",children:o?"—":b.length}),b.length>0&&t.jsx("p",{className:"mt-0.5 text-xs text-gray-400",children:b.map(w=>nL[w]).join(", ")})]}),t.jsxs("div",{className:"bg-gray-50 rounded-lg px-4 py-3",children:[t.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wide",children:"Workbook tabs"}),t.jsx("p",{className:"mt-1 text-2xl font-bold text-gray-900",children:o?"—":b.length+(b.length>0?1:0)}),b.length>0&&t.jsx("p",{className:"mt-0.5 text-xs text-gray-400",children:"+ Year Summary"})]})]}),!o&&g&&t.jsxs("div",{className:"mt-4 flex items-start gap-2.5 rounded-lg bg-amber-50 border border-amber-100 px-4 py-3",children:[t.jsx("svg",{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),t.jsxs("p",{className:"text-sm text-amber-700",children:["No documents for ",e," yet — upload your first receipt to populate the workbook. You can still download an empty workbook with headers."]})]})]}),t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm px-6 py-5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-sm font-semibold text-gray-900",children:["bookkeeping-",e,".xlsx"]}),t.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:g?"Header-only workbook — ready for your first upload":`${f.length} document${f.length!==1?"s":""} · ${b.length} month${b.length!==1?"s":""} of data`})]}),t.jsx("button",{onClick:v,disabled:d,className:"flex items-center gap-2 rounded-lg bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 px-5 py-2.5 text-sm font-semibold text-white transition-colors shadow-sm",children:d?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Downloading…"]}):t.jsxs(t.Fragment,{children:[t.jsx(sL,{}),"Download Excel"]})})]}),p&&t.jsx("p",{className:"mt-3 text-sm text-red-600 bg-red-50 rounded-lg px-4 py-2.5",children:p})]})]})})},_f=new Date().getFullYear(),iL=new Set(Ya.map(e=>e.code)),oL=Array.from({length:_f-2022},(e,n)=>_f-n),lL=async(e,n)=>{const s=await te.get(e,{responseType:"blob"}),a=new Blob([s.data],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=n,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)},cL=({value:e,onChange:n})=>t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:oL.map(s=>t.jsx("button",{onClick:()=>n(s),className:`px-3 py-1 rounded-lg text-sm font-medium transition-colors ${s===e?"bg-[#0066FF] text-white":"text-gray-600 hover:bg-gray-100"}`,children:s},s))}),_b=({title:e,description:n,endpoint:s,filename:a,docsByYear:o,loadingDocs:l})=>{const[d,u]=x.useState(_f),[p,h]=x.useState(!1),[f,g]=x.useState(""),b=o[d]??0,v=!l&&b===0,N=async()=>{h(!0),g("");try{await lL(`${s}?year=${d}`,a(d))}catch{g("Download failed. Please try again.")}finally{h(!1)}};return t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm flex flex-col",children:[t.jsx("div",{className:"px-6 py-5 border-b border-gray-100",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-9 h-9 rounded-lg bg-emerald-50 flex items-center justify-center shrink-0 mt-0.5",children:t.jsx("svg",{className:"w-5 h-5 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.7,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"})})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900",children:e}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 leading-relaxed",children:n})]})]})}),t.jsxs("div",{className:"flex-1 px-6 py-5 space-y-5",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2",children:"Year"}),t.jsx(cL,{value:d,onChange:u})]}),v&&t.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg bg-amber-50 border border-amber-100 px-4 py-3",children:[t.jsx("svg",{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),t.jsxs("p",{className:"text-sm text-amber-700",children:["No data for ",d," yet — upload your first receipt to generate this report."]})]}),!v&&!l&&t.jsxs("p",{className:"text-xs text-gray-400",children:["Based on ",b," document",b!==1?"s":""," in ",d]}),f&&t.jsx("p",{className:"text-sm text-red-600 bg-red-50 rounded-lg px-4 py-2.5",children:f})]}),t.jsx("div",{className:"px-6 pb-6",children:t.jsx("button",{onClick:N,disabled:p||l,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:p?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),"Downloading…"]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),"Download Excel"]})})})]})},dL=()=>{const[e,n]=x.useState([]),[s,a]=x.useState(!0),[o,l]=x.useState(!0);x.useEffect(()=>{te.get("/api/documents/").then(h=>{Array.isArray(h==null?void 0:h.data)&&n(h.data)}).finally(()=>a(!1)),te.get("/api/user/profile").then(h=>{var g,b;const f=((b=(g=h==null?void 0:h.data)==null?void 0:g.company)==null?void 0:b.province)??"";l(iL.has(f)||f==="")})},[]);const d=e.filter(h=>h.extraction_status==="done").reduce((h,f)=>{const g=new Date(f.created_at).getFullYear();return h[g]=(h[g]??0)+1,h},{}),u=o?"GST/HST Input Tax Credit Summary":"Expense Deduction Summary",p=o?"Input tax credits claimable on your GST/HST return, broken down by document and reporting period.":"Deductible expenses organized by Schedule C category, ready for your US tax return.";return t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-8",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Reports"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Generated on demand from your uploaded documents. Download as Excel at any time."})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 items-start",children:[t.jsx(_b,{title:"Expense by Category",description:"Total spending grouped by bookkeeping category for the year, with deductibility flags highlighted.",endpoint:"/api/reports/expense-summary/",filename:h=>`expense-by-category-${h}.xlsx`,docsByYear:d,loadingDocs:s}),t.jsx(_b,{title:u,description:p,endpoint:"/api/reports/tax-summary/",filename:h=>`tax-summary-${h}.xlsx`,docsByYear:d,loadingDocs:s})]})]})})},ut=({title:e,subtitle:n,right:s})=>t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-[26px] font-semibold tracking-[-0.025em] text-gray-900",children:e}),n&&t.jsx("p",{className:"mt-1 text-[14.5px] text-gray-500",children:n})]}),s&&t.jsx("div",{className:"shrink-0",children:s})]}),Te=({children:e,className:n="",padding:s=!1})=>t.jsx("div",{className:`bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden ${s?"p-6":""} ${n}`,children:e}),jt=({light:e})=>t.jsx("div",{className:`h-4 w-4 animate-spin rounded-full border-2 border-t-transparent ${e?"border-white":"border-[var(--color-primary)]"}`});function hh(){const[e,n]=x.useState(null),s=x.useRef(null),a=(o,l)=>{s.current&&clearTimeout(s.current),n({message:o,type:l}),s.current=setTimeout(()=>n(null),3500)};return{toast:e,showSuccess:o=>a(o,"success"),showError:o=>a(o,"error")}}const xh=({toast:e})=>e?t.jsxs("div",{className:`fixed right-5 top-5 z-50 flex items-center gap-3 rounded-xl px-5 py-3.5 text-sm font-medium text-white shadow-lg transition-all ${e.type==="success"?"bg-emerald-600":"bg-red-600"}`,children:[e.type==="success"?t.jsx("svg",{className:"h-4 w-4 shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}):t.jsx("svg",{className:"h-4 w-4 shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),e.message]}):null,uL=({tabs:e,active:n,onChange:s})=>{const a=x.useRef(null);return x.useEffect(()=>{var o;(o=a.current)==null||o.scrollIntoView({inline:"center",block:"nearest"})},[n]),t.jsx("div",{className:"border-b border-gray-200",children:t.jsx("nav",{className:"-mb-px flex gap-5 overflow-x-auto",children:e.map(o=>t.jsx("button",{ref:n===o.id?a:void 0,type:"button",onClick:()=>s(o.id),className:`whitespace-nowrap border-b-2 px-1 pb-3 pt-1 text-sm font-medium transition-colors ${n===o.id?"border-[var(--color-primary)] text-[var(--color-primary)]":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-800"}`,children:o.label},o.id))})})},Qt=({title:e,description:n,children:s})=>t.jsxs(Te,{children:[t.jsxs("div",{className:"border-b border-gray-100 px-6 py-5",children:[t.jsx("h2",{className:"text-[15px] font-semibold text-gray-900",children:e}),n&&t.jsx("p",{className:"mt-1 text-[13.5px] text-gray-500",children:n})]}),t.jsx("div",{className:"px-6 py-6",children:s})]}),$t=({label:e,required:n,children:s})=>t.jsxs("div",{children:[t.jsxs("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:[e,n&&t.jsx("span",{className:"ml-0.5 text-red-500",children:"*"})]}),s]}),ow="h-[42px] w-full rounded-lg border border-gray-300 px-3.5 text-sm text-gray-900 transition placeholder:text-gray-400 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-[color:var(--color-primary)] disabled:bg-gray-50 disabled:text-gray-400",In=({className:e="",...n})=>t.jsx("input",{...n,className:`${ow} ${e}`}),Ca=({className:e="",children:n,...s})=>t.jsx("select",{...s,className:`${ow} bg-white ${e}`,children:n}),gh=({saving:e,label:n="Save changes"})=>t.jsxs("button",{type:"submit",disabled:e,className:"inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-60",children:[e&&t.jsx(jt,{light:!0}),e?"Saving…":n]}),lw=({title:e,onClose:n,children:s})=>t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:n,children:t.jsxs("div",{className:"w-full max-w-lg rounded-2xl bg-white p-6 shadow-xl",onClick:a=>a.stopPropagation(),children:[t.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900",children:e}),t.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),s]})}),cw=({busy:e,confirmLabel:n,onCancel:s,onConfirm:a})=>t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx("button",{className:"rounded-lg border border-gray-200 px-4 py-2 text-sm font-semibold text-gray-700 hover:bg-gray-50 disabled:opacity-60",onClick:s,disabled:e,children:"Cancel"}),t.jsx("button",{className:"rounded-lg bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-700 disabled:opacity-60",onClick:a,disabled:e,children:e?"Working…":n})]}),ln=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get("/api/accounting/me/").then(f=>{var g;h||f!=null&&(f.status===200?n(f.data):(n(null),l(((g=f.data)==null?void 0:g.detail)??"Failed to load org info")))}).catch(f=>{var g,b;h||l(((b=(g=f==null?void 0:f.response)==null?void 0:g.data)==null?void 0:b.detail)??"Failed to load org info")}).finally(()=>{h||a(!1)}),()=>{h=!0}},[d]),{orgId:e==null?void 0:e.org_id,orgName:e==null?void 0:e.org_name,role:e==null?void 0:e.role,baseCurrency:e==null?void 0:e.base_currency,hasTaxProfile:e==null?void 0:e.has_tax_profile,openingBalanceChoice:e==null?void 0:e.opening_balance_choice,booksStartDate:e==null?void 0:e.books_start_date,isLoading:s,error:o,refetch:p}},mL=e=>{const[n,s]=x.useState([]),[a,o]=x.useState(!0),[l,d]=x.useState(null),[u,p]=x.useState(0),h=x.useCallback(()=>p(f=>f+1),[]);return x.useEffect(()=>{let f=!1;o(!0),d(null);const g={};return e!=null&&e.type&&(g.type=e.type),(e==null?void 0:e.active)!==void 0&&(g.active=String(e.active)),e!=null&&e.search&&(g.search=e.search),g.page_size="200",te.get("/api/accounting/accounts/",{params:g}).then(b=>{const v=b==null?void 0:b.data;f||s(Array.isArray(v)?v:(v==null?void 0:v.results)??[])}).catch(b=>{var v,N;f||d(((N=(v=b==null?void 0:b.response)==null?void 0:v.data)==null?void 0:N.detail)??"Failed to load accounts")}).finally(()=>{f||o(!1)}),()=>{f=!0}},[e==null?void 0:e.type,e==null?void 0:e.active,e==null?void 0:e.search,u]),{accounts:n,isLoading:a,error:l,refetch:h}},pL=e=>{const[n,s]=x.useState(!1),[a,o]=x.useState(null);return{createAccount:x.useCallback(async d=>{var u;s(!0),o(null);try{const p=await te.post("/api/accounting/accounts/create/",d);return(p==null?void 0:p.status)===201?(e(),{ok:!0,data:p.data}):{ok:!1,data:null}}catch(p){const h=(u=p==null?void 0:p.response)==null?void 0:u.data;
97return h&&typeof h=="object"&&o(h),{ok:!1,data:null}}finally{s(!1)}},[e]),isSubmitting:n,errors:a,clearErrors:()=>o(null)}},fL=(e,n)=>{const[s,a]=x.useState(!1),[o,l]=x.useState(null);return{updateAccount:x.useCallback(async u=>{var p,h;a(!0),l(null);try{const f=await te.patch(`/api/accounting/accounts/${e}/`,u);if((f==null?void 0:f.status)===200)return n(),{ok:!0,data:f.data};if((f==null?void 0:f.status)===400){const g=(p=f.data)==null?void 0:p.detail;g?l({detail:[g]}):f.data&&l(f.data)}return{ok:!1,data:null}}catch(f){const g=(h=f==null?void 0:f.response)==null?void 0:h.data;return g&&typeof g=="object"&&l(g),{ok:!1,data:null}}finally{a(!1)}},[e,n]),isSubmitting:s,errors:o,clearErrors:()=>l(null)}},yh=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get("/api/accounting/tax-profile/").then(f=>{h||n((f==null?void 0:f.data)??null)}).catch(f=>{var g,b,v;if(!h){if(((g=f==null?void 0:f.response)==null?void 0:g.status)===404){n(null);return}l(((v=(b=f==null?void 0:f.response)==null?void 0:b.data)==null?void 0:v.detail)??"Failed to load tax profile")}}).finally(()=>{h||a(!1)}),()=>{h=!0}},[d]),{profile:e,isLoading:s,error:o,refetch:p}},hL=()=>{const[e,n]=x.useState(!1),[s,a]=x.useState(null);return{saveTaxProfile:x.useCallback(async l=>{var d;n(!0),a(null);try{const u=await te.put("/api/accounting/tax-profile/",l);return(u==null?void 0:u.status)===200||(u==null?void 0:u.status)===201?{ok:!0,data:u.data}:{ok:!1,data:null}}catch(u){const p=(d=u==null?void 0:u.response)==null?void 0:d.data;return p&&typeof p=="object"&&a(p),{ok:!1,data:null}}finally{n(!1)}},[]),isSubmitting:e,errors:s,clearErrors:()=>a(null)}},xL=[{value:"monthly",label:"Monthly"},{value:"quarterly",label:"Quarterly"},{value:"annual",label:"Annual"}],gL={country:"CA",gst_hst_registered:!1,gst_hst_number:"",filing_frequency:"",province:"",fiscal_year_end:"",home_currency:"CAD"},ga="w-full rounded-lg border border-gray-300 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition disabled:opacity-60 disabled:cursor-not-allowed",ya=({label:e,hint:n,children:s})=>t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1.5",children:e}),s,n&&t.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:n})]}),bh=({profile:e,isOwner:n,onSaved:s})=>{var w,k;const{saveTaxProfile:a,isSubmitting:o,errors:l,clearErrors:d}=hL(),[u,p]=x.useState(gL);x.useEffect(()=>{e&&p({country:e.country,gst_hst_registered:e.gst_hst_registered,gst_hst_number:e.gst_hst_number??"",filing_frequency:e.filing_frequency??"",province:e.province??"",fiscal_year_end:e.fiscal_year_end??"",home_currency:e.home_currency})},[e]);const h=_=>{p(S=>_===S.country?S:_==="US"?{...S,country:"US",gst_hst_registered:!1,home_currency:"USD"}:{...S,country:"CA"})},f=async _=>{_.preventDefault(),d();const S=u.country==="CA",T={country:u.country,gst_hst_registered:S?u.gst_hst_registered:!1,gst_hst_number:S&&u.gst_hst_registered?u.gst_hst_number:"",filing_frequency:S&&u.gst_hst_registered?u.filing_frequency:"",province:S?u.province:"",fiscal_year_end:u.fiscal_year_end?u.fiscal_year_end:null,home_currency:u.home_currency},E=await a(T);E.ok&&E.data&&s(E.data)},g=u.country==="CA",b=g&&u.gst_hst_registered,v=_=>{var S;return(S=l==null?void 0:l[_])==null?void 0:S[0]},N=((w=l==null?void 0:l.detail)==null?void 0:w[0])??((k=l==null?void 0:l.non_field_errors)==null?void 0:k[0]);return t.jsxs("form",{onSubmit:f,className:"rounded-2xl bg-white border border-gray-100 shadow-sm p-6 space-y-5",children:[N&&t.jsx("div",{className:"rounded-lg bg-red-50 border border-red-200 px-4 py-2.5 text-sm text-red-700",children:N}),t.jsxs(ya,{label:"Country",children:[t.jsxs("select",{value:u.country,disabled:!n,onChange:_=>h(_.target.value),className:ga,children:[t.jsx("option",{value:"CA",children:"Canada"}),t.jsx("option",{value:"US",children:"United States"})]}),v("country")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("country")})]}),g&&t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:u.gst_hst_registered,disabled:!n,onChange:_=>p(S=>({...S,gst_hst_registered:_.target.checked}
97)),className:"h-4 w-4 rounded border-gray-300 text-[#0066FF] focus:ring-[#0066FF] disabled:opacity-60"}),t.jsx("span",{className:"text-sm text-gray-700",children:"Registered for GST/HST"})]}),v("gst_hst_registered")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("gst_hst_registered")})]}),b&&t.jsxs(t.Fragment,{children:[t.jsxs(ya,{label:"GST/HST number",children:[t.jsx("input",{type:"text",value:u.gst_hst_number,disabled:!n,onChange:_=>p(S=>({...S,gst_hst_number:_.target.value})),placeholder:"e.g. 123456789RT0001",className:ga}),v("gst_hst_number")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("gst_hst_number")})]}),t.jsxs(ya,{label:"Filing frequency",children:[t.jsxs("select",{value:u.filing_frequency,disabled:!n,onChange:_=>p(S=>({...S,filing_frequency:_.target.value})),className:ga,children:[t.jsx("option",{value:"",children:"— Not set —"}),xL.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))]}),v("filing_frequency")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("filing_frequency")})]})]}),g&&t.jsxs(ya,{label:"Province",hint:"BC, SK, MB and QC have provincial sales tax (PST) that affects tax treatment.",children:[t.jsxs("select",{value:u.province,disabled:!n,onChange:_=>p(S=>({...S,province:_.target.value})),className:ga,children:[t.jsx("option",{value:"",children:"— Select province —"}),Ya.map(_=>t.jsx("option",{value:_.code,children:_.name},_.code))]}),v("province")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("province")})]}),t.jsxs(ya,{label:"Fiscal year end (month & day)",hint:"Only the month and day matter — the year is ignored.",children:[t.jsx("input",{type:"date",value:u.fiscal_year_end,disabled:!n,onChange:_=>p(S=>({...S,fiscal_year_end:_.target.value})),className:ga}),v("fiscal_year_end")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("fiscal_year_end")})]}),t.jsxs(ya,{label:"Home currency",children:[t.jsxs("select",{value:u.home_currency,disabled:!n,onChange:_=>p(S=>({...S,home_currency:_.target.value})),className:ga,children:[t.jsx("option",{value:"CAD",children:"CAD — Canadian Dollar"}),t.jsx("option",{value:"USD",children:"USD — US Dollar"})]}),v("home_currency")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:v("home_currency")})]}),n&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{type:"submit",disabled:o,className:"flex items-center justify-center gap-2 rounded-xl bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:[o&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),o?"Saving…":"Save tax profile"]})})]})},yL=({onSaved:e})=>{const{role:n,isLoading:s}=ln(),a=n==="owner",{profile:o,isLoading:l,error:d,refetch:u}=yh(),p=h=>{let g=o==null?"Tax profile created.":"Tax profile updated.";h.chart_reseeded&&(g+=" — chart of accounts was reseeded for the new country."),e(g),u()};return t.jsx(Qt,{title:"Tax profile",description:"Your tax registration and fiscal settings — these drive how the accounting agent treats tax on every document.",children:s||l?t.jsx("div",{className:"flex h-40 items-center justify-center",children:t.jsx(jt,{})}):t.jsxs(t.Fragment,{children:[d&&t.jsx("p",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:d}),!a&&t.jsx("p",{className:"mb-4 rounded-lg border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600",children:"Only the account owner can edit the tax profile. You can view the current settings below."}),t.jsx(bh,{profile:o,isOwner:a,onSaved:p})]})})},Ea="plaid_link_token",Wc="plaid_link_mode",Hc="plaid_reconnect_item_id",dw=(e,n)=>{var s,a;return{public_token:e,metadata:{institution:{institution_id:((s=n.institution)==null?void 0:s.institution_id)??"",name:((a=n.institution)==null?void 0:a.name)??""},accounts:n.accounts.map(o=>({id:o.id,name:o.name??"",mask:o.mask??"",type:o.type??"",subtype:o.subtype??""}))}}},So=e=>{var n;return(e==null?void 0:e.status)===403?"Only the organization owner can manage bank connections.":(e==null?void 0:e.status)===503?"Bank connections are not configured.":typeof((n=e==null?void 0:e.data)==null?void 0:n.detail)=="string"?e.data.detail:"Something went wrong. Please try again."},bL=()=>({createLinkToken:async()=>{var s;const n=await te.post("/api/accounting/plaid/link-token/");return(n==null?void 0:n.status)===200&&((s=n.data)!=null&&s.link_token)?{ok:!0,data:n.data}:{ok:!1,status:n==null?void 0:n.status,error:So(n)}}}),uw=()=>({exchange:async n=>{const s=await te.post("/api/accounting/plaid/exchange/",n);return(s==null?void 0:s.status)===201?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,error:So(s)}}}),vL=()=>({createReconnectLinkToken:async n=>{var a;const s=await te.post("/api/accounting/plaid/reconnect/link-token/",{item_id:n});return(s==null?void 0:s.status)===200&&((a=s.data)!=null&&a.link_token)?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,error:So(s)}}}),mw=()=>({completeReconnect:async n=>{const s=await te.post("/api/accounting/plaid/reconnect/complete/",{item_id:n});return(s==null?void 0:s.status)===200?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,error:So(s)}}}),pw=()=>{const[e,n]=x.useState([]),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get("/api/accounting/plaid/items/").then(f=>{var g;h||((f==null?void 0:f.status)===200?n(((g=f.data)==null?void 0:g.items)??[]):l(So(f)))}).finally(()=>{h||a(!1)}),()=>{h=!0}},[d]),{items:e,isLoading:s,error:o,refetch:p}},jL=e=>new Date(e).toLocaleDateString("en-CA",{year:"numeric",month:"short",day:"numeric"}),wL=({status:e})=>{const n=e==="active"||e==="good"||e==="connected";return t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium ${n?"text-emerald-600":"text-amber-600"}`,children:[t.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${n?"bg-emerald-500":"bg-amber-500"}`}
97),e.replace(/_/g," ")]})},NL=({item:e})=>t.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 p-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:e.institution_name}),t.jsx(wL,{status:e.status})]}),t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.accounts.map((n,s)=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-gray-100 px-2 py-0.5 text-xs text-gray-600",children:[n.name,t.jsxs("span",{className:"font-[var(--font-family-mono)] text-gray-400",children:["••",n.mask]})]},s))})]}),t.jsxs("p",{className:"shrink-0 text-xs text-gray-400",children:["Connected ",jL(e.created_at)]})]}),_L=()=>{const{items:e,isLoading:n,error:s}=pw();return t.jsxs(Qt,{title:"Bank Transactions",description:"Connected bank and card accounts feeding your books automatically.",children:[t.jsx("div",{className:"mb-4 flex justify-end",children:t.jsxs(be,{to:"/accounting/bank-connections",title:"Connect from your bank feed setup",className:"inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:[t.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Connect"]})}),n?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(jt,{})}):s?t.jsx("p",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:s}):e.length===0?t.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 px-6 py-10 text-center",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"No bank accounts connected yet."}),t.jsx("p",{className:"mt-1 text-xs text-gray-400",children:"Connect a chequing, savings, or credit card account to start the automatic feed."})]}):t.jsx("div",{className:"space-y-3",children:e.map(a=>t.jsx(NL,{item:a},a.id))})]})},kL="/api/accounting/stripe/connect/account/",SL="/api/accounting/stripe/connect/authorize/",CL="/api/accounting/stripe/connect/disconnect/",co={state:"That connection attempt expired or was already used. Please try again.",denied:"Stripe access was declined. No changes were made.",exchange:"Stripe didn't complete the connection. Please try again.",account_in_use:"That Stripe account is already connected to a different organization.",already_connected:"This organization already has a Stripe account connected.",config:"Stripe Connect isn't available yet."},fw="Stripe connection failed. Please try again.",EL=e=>e&&co[e]||fw,vh=e=>{var n;return(e==null?void 0:e.status)===403?"Only the organization owner can manage the Stripe connection.":(e==null?void 0:e.status)===503?co.config:(e==null?void 0:e.status)===502?"Stripe couldn't be reached. No changes were made. Please try again.":typeof((n=e==null?void 0:e.data)==null?void 0:n.detail)=="string"?e.data.detail:fw},AL=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get(kL).then(f=>{h||((f==null?void 0:f.status)===200&&f.data?n(f.data):l(vh(f)),a(!1))}),()=>{h=!0}},[d]),{summary:e,isLoading:s,error:o,refetch:p}},TL=()=>{const[e,n]=x.useState(!1);return{authorize:x.useCallback(async()=>{var l;n(!0);const a=await te.post(SL),o=(a==null?void 0:a.status)??0;
97return o===200&&typeof((l=a.data)==null?void 0:l.url)=="string"?{ok:!0,url:a.data.url}:(n(!1),o===409?{ok:!1,status:o,message:co.already_connected}:o===503?{ok:!1,status:o,message:co.config}:{ok:!1,status:o,message:vh(a)})},[]),busy:e}},LL=()=>{const[e,n]=x.useState(!1);return{disconnect:x.useCallback(async()=>{n(!0);const a=await te.post(CL);n(!1);const o=(a==null?void 0:a.status)??0;return o===200&&a.data?{ok:!0,summary:a.data}:{ok:!1,status:o,message:vh(a)}},[]),busy:e}},RL=e=>new Date(e).toLocaleDateString("en-CA",{year:"numeric",month:"short",day:"numeric"}),IL=({livemode:e})=>t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium ${e?"text-emerald-600":"text-amber-600"}`,children:[t.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${e?"bg-emerald-500":"bg-amber-500"}`}),e?"Live":"Test"]}),PL=co.config,FL="Connect your Stripe account to post payouts, fees and sales automatically.",kb=({busy:e,onClick:n})=>t.jsxs("button",{type:"button",onClick:n,disabled:e,className:"inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-60",children:[e&&t.jsx(jt,{light:!0}),e?"Redirecting…":"Connect Stripe"]}),Sb=({account:e,children:n})=>{const s=e.status==="connected",a=s?e.connected_at:e.disconnected_at,o=s?"Connected":e.status==="deauthorized"?"Access revoked":"Disconnected";return t.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-100 p-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:e.display_name||e.stripe_account_id}),s&&t.jsx(IL,{livemode:e.livemode})]}),t.jsx("p",{className:"mt-1 font-[var(--font-family-mono)] text-xs text-gray-400",children:e.stripe_account_id}),t.jsxs("p",{className:"mt-2 text-xs text-gray-400",children:[o,a?` ${RL(a)}`:""]})]}),t.jsx("div",{className:"shrink-0",children:n})]})},DL=()=>{const{summary:e,isLoading:n,error:s,refetch:a}=AL(),{authorize:o,busy:l}=TL(),{disconnect:d,busy:u}=LL(),{toast:p,showSuccess:h,showError:f}=hh(),[g,b]=x.useState(!1),[v,N]=x.useState(!1),[w,k]=Jn(),_=x.useRef(!1);x.useEffect(()=>{if(_.current)return;_.current=!0;const I=w.get("connected"),R=w.get("error");if(I==="1"?(h("Stripe connected"),a()):R&&f(EL(R)),I!==null||R!==null){const W=new URLSearchParams(w);W.delete("connected"),W.delete("error"),k(W,{replace:!0})}},[]);const S=async()=>{const I=await o();if(I.ok){window.location.assign(I.url);return}if(I.status===409){a();return}if(I.status===503){b(!0);return}f(I.message)},T=async()=>{const I=await d();if(N(!1),I.ok){a(),h("Stripe disconnected");return}if(I.status===502){f("Stripe is unavailable right now — nothing was changed.");return}f(I.message)},E=(e==null?void 0:e.configured)&&!g,A=(e==null?void 0:e.account)??null;return t.jsxs(Qt,{title:"Stripe",description:"Payments received through your Stripe account, posted to your books automatically.",children:[n?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(jt,{})}):s?t.jsx("p",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:s}):E?e!=null&&e.connected&&A?t.jsx(Sb,{account:A,children:t.jsx("button",{type:"button",onClick:()=>N(!0),disabled:u,className:"rounded-lg border border-red-200 px-4 py-2 text-sm font-semibold text-red-600 hover:bg-red-50 disabled:opacity-60",children:"Disconnect"})}):A?t.jsx(Sb,{account:A,children:t.jsx(kb,{busy:l,onClick:S})}
97):t.jsxs("div",{className:"flex flex-col gap-4 rounded-xl border border-dashed border-gray-200 px-6 py-8 text-center sm:flex-row sm:items-center sm:justify-between sm:text-left",children:[t.jsx("p",{className:"text-sm text-gray-500",children:FL}),t.jsx("div",{className:"shrink-0",children:t.jsx(kb,{busy:l,onClick:S})})]}):t.jsx("p",{className:"text-sm text-gray-500",children:PL}),v&&t.jsxs(lw,{title:"Disconnect Stripe?",onClose:()=>!u&&N(!1),children:[t.jsx("p",{className:"text-sm text-gray-600",children:"New Stripe payments will stop posting to your books. Existing entries are not changed. You can reconnect at any time."}),t.jsx(cw,{busy:u,confirmLabel:"Disconnect",onCancel:()=>N(!1),onConfirm:T})]}),t.jsx(xh,{toast:p})]})},Fd={asset:"Assets",liability:"Liabilities",equity:"Equity",revenue:"Revenue",expense:"Expenses"},Sc=["asset","liability","equity","revenue","expense"],OL={asset:"bg-blue-50 text-blue-700 border-blue-200",liability:"bg-red-50 text-red-700 border-red-200",equity:"bg-purple-50 text-purple-700 border-purple-200",revenue:"bg-emerald-50 text-emerald-700 border-emerald-200",expense:"bg-amber-50 text-amber-700 border-amber-200"},Cb={asset:"debit",expense:"debit",liability:"credit",equity:"credit",revenue:"credit"},pp=e=>`h-[42px] w-full rounded-lg border px-3.5 text-sm text-gray-900 placeholder:text-gray-400 transition focus:border-transparent focus:outline-none focus:ring-2 focus:ring-[color:var(--color-primary)] ${e?"border-red-400":"border-gray-300"}`,$L=({type:e})=>t.jsx("span",{className:`inline-flex items-center rounded border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${OL[e]}`,children:Fd[e].slice(0,-1)}),ML=({balance:e})=>t.jsx("span",{className:`inline-flex items-center rounded border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${e==="debit"?"bg-sky-50 text-sky-700 border-sky-200":"bg-indigo-50 text-indigo-700 border-indigo-200"}`,children:e}),Eb=({mode:e,initial:n,accounts:s,onClose:a,onSave:o,isSubmitting:l,serverErrors:d})=>{const[u,p]=x.useState((n==null?void 0:n.code)??""),[h,f]=x.useState((n==null?void 0:n.name)??""),[g,b]=x.useState((n==null?void 0:n.type)??"expense"),[v,N]=x.useState((n==null?void 0:n.normal_balance)??Cb.expense),[w,k]=x.useState((n==null?void 0:n.is_active)??!0);x.useEffect(()=>{N(Cb[g])},[g]);const _=A=>{var I,R;return((I=d==null?void 0:d[A])==null?void 0:I[0])??((R=d==null?void 0:d.detail)==null?void 0:R[0])},S=n!=null&&n.parent_account_id?s.find(A=>A.id===n.parent_account_id):void 0,T=(S==null?void 0:S.full_name)??(n==null?void 0:n.parent_account_code)??null,E=async A=>{A.preventDefault(),(await o({code:u,name:h,type:g,normal_balance:v,is_active:w})).ok&&a()};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:a}),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:t.jsxs("div",{className:"flex max-h-[90vh] w-full max-w-md flex-col rounded-2xl border border-gray-100 bg-white shadow-2xl",onClick:A=>A.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-6 py-5",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-900",children:e==="create"?"Add account":"Edit account"}),t.jsx("button",{onClick:a,className:"text-gray-400 transition-colors hover:text-gray-700","aria-label":"Close",children:t.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("form",{onSubmit:E,className:"flex-1 space-y-4 overflow-y-auto px-6 py-5",children:[_("detail")&&t.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-2.5 text-sm text-red-700",children:_("detail")}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-xs font-medium text-gray-500",children:"Code *"}),t.jsx("input",{required:!0,value:u,onChange:A=>p(A.target.value),placeholder:"e.g. 5999",className:pp(!!_("code"))}),_("code")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:_("code")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-xs font-medium text-gray-500",children:"Name *"}),t.jsx("input",{required:!0,value:h,onChange:A=>f(A.target.value),placeholder:"Account name",className:pp(!!_("name"))}),_("name")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:_("name")}
97)]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-xs font-medium text-gray-500",children:"Type *"}),t.jsx("select",{value:g,onChange:A=>b(A.target.value),className:`${pp()} bg-white`,children:Sc.map(A=>t.jsx("option",{value:A,children:Fd[A]},A))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-xs font-medium text-gray-500",children:"Normal balance"}),t.jsx("div",{className:"flex gap-4",children:["debit","credit"].map(A=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[t.jsx("input",{type:"radio",name:"normal_balance",value:A,checked:v===A,onChange:()=>N(A),className:"accent-[var(--color-primary)]"}),t.jsx("span",{className:"text-sm capitalize text-gray-700",children:A})]},A))})]}),T&&t.jsxs("div",{children:[t.jsx("p",{className:"mb-1.5 block text-xs font-medium text-gray-500",children:"Parent account"}),t.jsx("p",{className:"text-sm text-gray-700",children:T})]}),e==="edit"&&t.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5",children:[t.jsx("input",{type:"checkbox",checked:w,onChange:A=>k(A.target.checked),className:"h-4 w-4 rounded border-gray-300 accent-[var(--color-primary)]"}),t.jsx("span",{className:"text-sm text-gray-700",children:"Active"})]}),t.jsxs("div",{className:"flex gap-3 pt-2",children:[t.jsx("button",{type:"button",onClick:a,className:"flex-1 rounded-lg border border-gray-200 px-4 py-2.5 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-50",children:"Cancel"}),t.jsxs("button",{type:"submit",disabled:l,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-[var(--color-primary)] py-2.5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-60",children:[l&&t.jsx(jt,{light:!0}),e==="create"?"Create account":"Save changes"]})]})]})]})})]})},BL=({type:e,count:n,isOpen:s,onToggle:a})=>t.jsx("tr",{children:t.jsx("td",{colSpan:6,children:t.jsxs("button",{onClick:a,className:"flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-gray-50",children:[t.jsx("svg",{className:`h-3.5 w-3.5 text-gray-400 transition-transform duration-150 ${s?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),t.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-gray-500",children:Fd[e]}),t.jsx("span",{className:"text-xs text-gray-400",children:n})]})})}),UL=({account:e,depth:n,canEdit:s,onEdit:a})=>t.jsxs("tr",{className:"group border-b border-gray-50 transition-colors hover:bg-gray-50",children:[t.jsx("td",{className:"px-4 py-2.5",children:t.jsx("span",{className:"font-[var(--font-family-mono)] text-xs text-gray-500",children:e.code})}),t.jsx("td",{className:"px-4 py-2.5",children:t.jsxs("div",{className:"flex items-center",style:{paddingLeft:n*24},children:[n>0&&t.jsx("div",{className:"mr-2 h-3.5 w-px shrink-0 bg-gray-200"}),t.jsx("span",{className:`text-sm ${e.is_active?"text-gray-900":"text-gray-400 line-through"}`,children:e.name})]})}),t.jsx("td",{className:"px-4 py-2.5",children:t.jsx($L,{type:e.type})}),t.jsx("td",{className:"px-4 py-2.5",children:t.jsx(ML,{balance:e.normal_balance})}),t.jsx("td",{className:"px-4 py-2.5",children:t.jsxs("span",{className:`flex items-center gap-1.5 text-xs font-medium ${e.is_active?"text-emerald-600":"text-gray-400"}`,children:[t.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${e.is_active?"bg-emerald-500":"bg-gray-300"}`}),e.is_active?"Active":"Inactive"]})}),t.jsx("td",{className:"w-10 px-4 py-2.5",children:s&&t.jsx("button",{onClick:()=>a(e),className:"rounded p-1 text-gray-400 opacity-0 transition-all hover:bg-gray-100 hover:text-gray-700 group-hover:opacity-100","aria-label":`Edit ${e.name}`,children:t.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.7,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125"})})})})]}),zL=()=>{const{role:e}=ln(),n=e==="owner"||e==="accountant",[s,a]=x.useState(""),[o,l]=x.useState(""),[d,u]=x.useState(""),[p,h]=x.useState(new Set(Sc)),[f,g]=x.use
97State(null),[b,v]=x.useState(null),{accounts:N,isLoading:w,error:k,refetch:_}=mL(d||o?{type:d||void 0,search:o||void 0}:void 0),{createAccount:S,isSubmitting:T,errors:E,clearErrors:A}=pL(_),{updateAccount:I,isSubmitting:R,errors:W,clearErrors:Y}=fL((b==null?void 0:b.id)??"",_);x.useEffect(()=>{const H=setTimeout(()=>l(s),300);return()=>clearTimeout(H)},[s]);const K=H=>{h(M=>{const Q=new Set(M);return Q.has(H)?Q.delete(H):Q.add(H),Q})},X=()=>{v(null),A(),g("create")},se=H=>{v(H),Y(),g("edit")},ne=()=>g(null),Z=x.useMemo(()=>{const H=new Map,M=new Map(N.map($=>[$.id,$])),Q=$=>{if(!$.parent_account_id)return 0;const L=M.get($.parent_account_id);return L?1+Q(L):1};return N.forEach($=>H.set($.id,Q($))),H},[N]),ue=x.useMemo(()=>{const H={asset:[],liability:[],equity:[],revenue:[],expense:[]};return N.forEach(M=>H[M.type].push(M)),H},[N]),re=N.length;return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{className:"relative min-w-[220px] max-w-sm flex-1",children:[t.jsx("svg",{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),t.jsx("input",{type:"text",placeholder:"Search code or name…",value:s,onChange:H=>a(H.target.value),className:"h-[42px] w-full rounded-lg border border-gray-300 pl-9 pr-3.5 text-sm text-gray-900 placeholder:text-gray-400 transition focus:border-transparent focus:outline-none focus:ring-2 focus:ring-[color:var(--color-primary)]"})]}),t.jsxs("select",{value:d,onChange:H=>u(H.target.value),className:"h-[42px] rounded-lg border border-gray-300 bg-white px-3.5 text-sm text-gray-900 transition focus:border-transparent focus:outline-none focus:ring-2 focus:ring-[color:var(--color-primary)]",children:[t.jsx("option",{value:"",children:"All types"}),Sc.map(H=>t.jsx("option",{value:H,children:Fd[H]},H))]}),n&&t.jsxs("button",{onClick:X,className:"ml-auto inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:[t.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Add account"]})]}),k&&t.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-red-200 bg-red-50 px-5 py-4",children:[t.jsx("p",{className:"flex-1 text-sm text-red-700",children:k}),t.jsx("button",{onClick:_,className:"text-xs text-red-700 underline hover:text-red-800",children:"Retry"})]}),t.jsx(Te,{children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-100",children:[t.jsx("th",{className:"w-24 px-4 py-3 text-xs font-semibold uppercase tracking-wider text-gray-500",children:"Code"}),t.jsx("th",{className:"px-4 py-3 text-xs font-semibold uppercase tracking-wider text-gray-500",children:"Name"}),t.jsx("th",{className:"w-28 px-4 py-3 text-xs font-semibold uppercase tracking-wider text-gray-500",children:"Type"}),t.jsx("th",{className:"w-24 px-4 py-3 text-xs font-semibold uppercase tracking-wider text-gray-500",children:"Balance"}),t.jsx("th",{className:"w-20 px-4 py-3 text-xs font-semibold uppercase tracking-wider text-gray-500",children:"Status"}),t.jsx("th",{className:"w-10 px-4 py-3"})]})}),t.jsxs("tbody",{children:[w&&Array.from({length:8}).map((H,M)=>t.jsx("tr",{className:"border-b border-gray-50",children:[130,220,80,80,60,40].map((Q,$)=>t.jsx("td",{className:"px-4 py-3",children:t.jsx("div",{className:"h-3 animate-pulse rounded bg-gray-100",style:{width:Q}})},$))},M)),!w&&!k&&re===0&&t.jsx("tr",{children:t.jsxs("td",{colSpan:6,className:"px-6 py-16 text-center text-sm text-gray-400",children:["No accounts found."," ",!o&&!d?"Your chart of accounts is seeded automatically when your organization is set up.":"Try a different search or filter."]})}),!w&&!k&&Sc.map(H=>{const M=ue[H];if(M.length===0)return null;const Q=p.has(H);return t.jsxs(t.Fragment,{children:[t.jsx(BL,{type:H,count:M.length,isOpen:Q,onToggle:()=>K(H)},`header-${H}`),Q&&M.map($=>t.jsx(UL,{account:$,depth:Z.get($.id)??0,canEdit:n,onEdit:se},$.id))]})})]})]})})}),f==="create"&&t.jsx(Eb,{mode:"create",accounts:N,onClose:ne,onSave:S,isSubmitting:T,serverErrors:E}),f==="edit"&&b&&t.jsx(Eb,{mode:"edit",initial:b,accounts:N,onClose:ne,onSave:H=>I(H),isSubmitting:R,serverErrors:W})]})},Ab=e=>new Date(e).toLocaleDateString("en-CA",{year:"numeric",month:"short",day:"numeric"}),WL=e=>{var a,o,l;const n=(((a=e.first_name)==null?void 0:a[0])??"").toUpperCase(),s=(((o=e.last_name)==null?void 0:o[0])??"").toUpperCase();return n+s||((l=e.email[0])==null?void 0:l.toUpperCase())||"?"},HL=({role:e})=>e==="owner"?t.jsx("span",{className:"rounded-md bg-[var(--color-primary-light)] px-2 py-0.5 text-[11px] font-semibold text-[var(--color-primary)]",children:"Owner"}):t.jsx("span",{className:"rounded-md bg-gray-100 px-2 py-0.5 text-[11px] font-semibold text-gray-600",children:"Accountant"}),qL=({showSuccess:e,showError:n})=>{var ne;const{role:s}=ln(),a=s==="owner",{user:o}=ht(Z=>Z.auth),l=(((ne=o==null?void 0:o.user)==null?void 0:ne.email)??(o==null?void 0:o.email)??"").toLowerCase(),[d,u]=x.useState(null),[p,h]=x.useState(!0),[f,g]=x.use
97State(null),[b,v]=x.useState(!1),[N,w]=x.useState(""),[k,_]=x.useState(!1),[S,T]=x.useState(null),[E,A]=x.useState(new Set),[I,R]=x.useState(null),W=x.useCallback(()=>{h(!0),te.get("/api/accounting/team/").then(Z=>{var ue;Z!=null&&(Z.status===200?(u(Z.data),g(null)):(u(null),g(((ue=Z.data)==null?void 0:ue.detail)??"Failed to load team.")))}).finally(()=>h(!1))},[]);x.useEffect(()=>{W()},[W]);const Y=async Z=>{var ue,re,H;Z.preventDefault(),_(!0),T(null);try{const M=await te.post("/api/accounting/invite/",{email:N});(M==null?void 0:M.status)===201?(w(""),v(!1),e("Invitation sent."),W()):T(((re=(ue=M==null?void 0:M.data)==null?void 0:ue.email)==null?void 0:re[0])??((H=M==null?void 0:M.data)==null?void 0:H.detail)??"Could not send the invite.")}catch{T("Could not send the invite.")}finally{_(!1)}},K=async(Z,ue,re)=>{var H;A(M=>new Set(M).add(Z));try{const M=await te.post(ue);(M==null?void 0:M.status)===200?(e(re),W()):n(((H=M==null?void 0:M.data)==null?void 0:H.detail)??"That action could not be completed.")}catch{n("That action could not be completed.")}finally{A(M=>{const Q=new Set(M);return Q.delete(Z),Q}),R(null)}},X=(d==null?void 0:d.members)??[],se=(d==null?void 0:d.invites)??[];return t.jsx(Qt,{title:"Team & access",description:"Invite your accountant to review the books. They join as an accountant — you stay the owner.",children:p?t.jsx("div",{className:"flex h-40 items-center justify-center",children:t.jsx(jt,{})}):f?t.jsx("p",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:f}):t.jsxs("div",{className:"space-y-6",children:[a&&t.jsx("div",{children:b?t.jsxs("form",{onSubmit:Y,className:"rounded-xl border border-gray-100 bg-gray-50 p-4",children:[t.jsx("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:"Accountant’s email"}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx("input",{type:"email",required:!0,autoFocus:!0,value:N,onChange:Z=>w(Z.target.value),placeholder:"[email protected]",className:"h-[42px] flex-1 rounded-lg border border-gray-300 px-3.5 text-sm text-gray-900 placeholder:text-gray-400 transition focus:border-transparent focus:outline-none focus:ring-2 focus:ring-[color:var(--color-primary)]"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{type:"submit",disabled:k,className:"inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-60",children:[k&&t.jsx(jt,{light:!0}),"Send invite"]}),t.jsx("button",{type:"button",onClick:()=>{v(!1),T(null)},className:"h-[42px] rounded-lg border border-gray-200 px-4 text-sm font-medium text-gray-600 transition-colors hover:bg-white",children:"Cancel"})]})]}),S&&t.jsx("p",{className:"mt-2 text-sm text-red-600",children:S})]}):t.jsxs("button",{onClick:()=>v(!0),className:"inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:[t.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Invite accountant"]})}),t.jsxs("div",{children:[t.jsx("h3",{className:"mb-2 text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Members"}),t.jsx("div",{className:"space-y-2",children:X.map(Z=>{const ue=Z.email.toLowerCase()===l,re=a&&Z.role==="accountant"&&!ue,H=`${Z.first_name} ${Z.last_name??""}`.trim()||Z.email;return t.jsxs("div",{className:"rounded-xl border border-gray-100 p-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--color-primary-light)] text-xs font-semibold text-[var(--color-primary)]",children:WL(Z)}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-gray-900",children:[H,ue&&t.jsx("span",{className:"ml-1 text-gray-400",children:"(you)"})]}),t.jsx("p",{className:"truncate text-xs text-gray-500",children:Z.email})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[t.jsx(HL,{role:Z.role}),re&&I!==Z.id&&t.jsx("button",{onClick:()=>R(Z.id),className:"text-sm font-medium text-red-600 transition-colors hover:text-red-700",children:"Revoke"})]})]}),re&&I===Z.id&&t.jsxs("div",{className:"mt-3 flex flex-col gap-2 rounded-lg bg-red-50 px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("p",{className:"text-xs text-red-700",children:"Their access ends immediately; posted work remains."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>K(`revoke-${Z.id}`,`/api/accounting/membership/${Z.id}/revoke/`,"Access revoked."),disabled:E.has(`revoke-${Z.id}`),className:"rounded-lg bg-red-600 px-3 py-1.5 text-xs font-semibold text-white transition-colors hover:bg-red-700 disabled:opacity-60",children:"Revoke access"}),t.jsx("button",{onClick:()=>R(null),className:"rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-xs font-medium text-gray-600 hover:bg-gray-50",children:"Keep"})]})]})]}
97,Z.id)})})]}),se.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"mb-2 text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Pending invites"}),t.jsx("div",{className:"space-y-2",children:se.map(Z=>t.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-gray-100 p-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-gray-900",children:Z.email}),t.jsx("span",{className:"rounded-md bg-amber-50 px-2 py-0.5 text-[11px] font-semibold text-amber-700 capitalize",children:Z.status})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Invited ",Ab(Z.created_at)," · expires ",Ab(Z.expires_at)]})]}),a&&t.jsxs("div",{className:"flex shrink-0 gap-2",children:[t.jsx("button",{onClick:()=>K(`resend-${Z.id}`,`/api/accounting/invite/${Z.id}/resend/`,"Invite resent."),disabled:E.has(`resend-${Z.id}`),className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50",children:"Resend"}),t.jsx("button",{onClick:()=>K(`cancel-${Z.id}`,`/api/accounting/invite/${Z.id}/cancel/`,"Invite cancelled."),disabled:E.has(`cancel-${Z.id}`),className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-red-600 transition-colors hover:bg-red-50 disabled:opacity-50",children:"Cancel"})]})]},Z.id))})]})]})})},hw="/api/accounting/org-profile/",xw=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get(hw).then(f=>{var g;h||f==null||(f.status===200?n(f.data):(n(null),l(((g=f.data)==null?void 0:g.detail)??"Failed to load business identity")))}).finally(()=>{h||a(!1)}),()=>{h=!0}},[d]),{profile:e,isLoading:s,error:o,refetch:p}},VL=()=>{const[e,n]=x.useState(!1),[s,a]=x.useState(null);return{saveOrgProfile:x.useCallback(async l=>{n(!0),a(null);try{const d=await te.patch(hw,l);if(d==null)return a({detail:["Request was cancelled — please retry."]}),{ok:!1,data:null};if(d.status===200)return{ok:!0,data:d.data};const u=d.data;
97return a(u&&typeof u=="object"?u:{detail:["Could not save business identity."]}),{ok:!1,data:null}}finally{n(!1)}},[]),isSubmitting:e,errors:s,clearErrors:()=>a(null)}};function YL(e){const n=(e.legal_name||e.name||"").trim()!=="",s=[];n||s.push("legal/display name"),(e.street_address||"").trim()||s.push("street address"),(e.city||"").trim()||s.push("city"),(e.postal_code||"").trim()||s.push("postal code");const a=!(e.province_state||"").trim();return{isComplete:s.length===0&&!a,editableMissing:s,provinceMissing:a}}const $i="w-full rounded-lg border border-gray-300 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition disabled:opacity-60 disabled:cursor-not-allowed",Mi=({label:e,hint:n,children:s})=>t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1.5",children:e}),s,n&&t.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:n})]}),GL={legal_name:"",street_address:"",city:"",postal_code:""},KL=({profile:e,isOwner:n,onSaved:s})=>{var N,w;const{saveOrgProfile:a,isSubmitting:o,errors:l,clearErrors:d}=VL(),[u,p]=x.useState(GL);x.useEffect(()=>{e&&p({legal_name:e.legal_name??"",street_address:e.street_address??"",city:e.city??"",postal_code:e.postal_code??""})},[e]);const h=async k=>{k.preventDefault(),d();const _={legal_name:u.legal_name,street_address:u.street_address,city:u.city,postal_code:u.postal_code},S=await a(_);S.ok&&S.data&&s(S.data)},f=k=>{var _;return(_=l==null?void 0:l[k])==null?void 0:_[0]},g=((N=l==null?void 0:l.detail)==null?void 0:N[0])??((w=l==null?void 0:l.non_field_errors)==null?void 0:w[0]),b=((e==null?void 0:e.legal_name)||(e==null?void 0:e.name)||"").trim(),v=((e==null?void 0:e.province_state)||"").trim();return t.jsxs("form",{onSubmit:h,className:"rounded-2xl bg-white border border-gray-100 shadow-sm p-6 space-y-5",children:[g&&t.jsx("div",{className:"rounded-lg bg-red-50 border border-red-200 px-4 py-2.5 text-sm text-red-700",children:g}),t.jsxs(Mi,{label:"Legal / business name",hint:b?void 0:`Falls back to your organization name (“${(e==null?void 0:e.name)??""}”) until set.`,children:[t.jsx("input",{type:"text",value:u.legal_name,disabled:!n,onChange:k=>p(_=>({..._,legal_name:k.target.value})),placeholder:(e==null?void 0:e.name)??"e.g. Acme Widgets Inc.",className:$i}),f("legal_name")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:f("legal_name")})]}),t.jsxs(Mi,{label:"Street address",children:[t.jsx("input",{type:"text",value:u.street_address,disabled:!n,onChange:k=>p(_=>({..._,street_address:k.target.value})),placeholder:"e.g. 100 Bank St",className:$i}),f("street_address")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:f("street_address")})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5",children:[t.jsxs(Mi,{label:"City",children:[t.jsx("input",{type:"text",value:u.city,disabled:!n,onChange:k=>p(_=>({..._,city:k.target.value})),placeholder:"e.g. Ottawa",className:$i}),f("city")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:f("city")})]}),t.jsxs(Mi,{label:"Postal / ZIP code",children:[t.jsx("input",{type:"text",value:u.postal_code,disabled:!n,onChange:k=>p(_=>({..._,postal_code:k.target.value})),placeholder:"e.g. K1P 1J1",className:$i}),f("postal_code")&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:f("postal_code")})]})]}),t.jsx(Mi,{label:"Province / state",hint:"Set as part of your tax jurisdiction — not editable here.",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"text",value:v||"—",disabled:!0,readOnly:!0,className:$i}),t.jsx(be,{to:"/accounting/tax-profile",className:"whitespace-nowrap text-sm font-medium text-[#0066FF] hover:underline",children:"Tax Profile →"})]})}),n&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{type:"submit",disabled:o,className:"flex items-center justify-center gap-2 rounded-xl bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:[o&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),o?"Saving…":"Save business identity"]})})]})},QL=({showSuccess:e,showError:n})=>{const[s,a]=x.useState(!0),[o,l]=x.useState(!1),[d,u]=x.useState("CA"),[p,h]=x.useState({phone_number:"",company_name:"",business_number:"",address:"",number:"",city:"",province:"",postal_code:""});x.useEffect(()=>{te.get("/api/user/profile").then(b=>{if(b!=null&&b.data){const v=b.data.company??{};h({phone_number:b.data.phone_number??"",company_name:v.company_name??"",business_number:v.business_number??"",address:v.address??"",number:v.number??"",city:v.city??"",province:v.province??"",postal_code:v.postal_code??""})}}).finally(()=>a(!1))},[]);const f=b=>v=>h(N=>({...N,[b]:v.target.value})),g=async b=>{b.preventDefault(),l(!0);try{const{phone_number:v,...N}=p,w=await te.put("/api/user/profile",{phone_number:v,company:N});(w==null?void 0:w.status)===200?e("Subscription billing saved."):n("Failed to save. Please try again.")}catch{n("Failed to save. Please try again.")}finally{l(!1)}};return s?t.jsx(Qt,{title:"Subscription billing",description:"The name and province on your subscription invoices.",children:t.jsx("div",{className:"flex h-32 items-center justify-center",children:t.jsx(jt,{})})}):t.jsx(Qt,{title:"Subscription billing",description:"The name and province used on your subscription invoices and for tax calculations.",children:t.jsxs("form",{onSubmit:g,className:"space-y-5",children:[t.jsx($t,{label:"Billing name",children:t.jsx(In,{value:p.company_name,onChange:f("company_name"),placeholder:"Acme Corp"})}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx($t,{label:"Country",children:t.jsxs(Ca,{value:d,onChange:b=>u(b.target.value),children:[t.jsx("option",{value:"CA",children:"Canada"}),t.jsx("option",{value:"US",children:"United States"})]})}),t.jsx($t,{label:d==="CA"?"Province":"State",children:d==="CA"?t.jsxs(Ca,{value:p.province,onChange:f("province"),children:[t.jsx("option",{value:"",children:"Select…"}),Ya.map(b=>t.jsx("option",{value:b.code,children:b.name},b.code))]}):t.jsxs(Ca,{value:p.province,onChange:f("province"),children:[t.jsx("option",{value:"",children:"Select…"}),fh.map(b=>t.jsx("option",{value:b.code,children:b.name},b.code))]})})]}),t.jsx("div",{className:"pt-1",children:t.jsx(gh,{saving:o})})]})})},JL=({showSuccess:e})=>{const{role:n,isLoading:s}=ln(),a=n==="owner",{profile:o,isLoading:l,error:d,refetch:u}=xw(),p=h=>{e("Business identity updated."),u()};return s||l?t.jsx(Qt,{title:"Business Identity",description:"The name and address that appear as the “bill from” on every invoice and credit note you issue.",children:t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx(jt,{})})}):t.jsxs(Qt,{title:"Business Identity",description:"The name and address that appear as the “bill from” on every invoice and credit note you issue. Complete this before issuing.",children:[d&&t.jsxs("div",{className:"mb-5 flex items-center gap-3 rounded-xl border border-red-200 bg-red-50 px-5 py-4",children:[t.jsx("svg",{className:"h-5 w-5 shrink-0 text-red-500",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),t.jsx("p",{className:"flex-1 text-sm text-red-700",children:d}),t.jsx("button",{onClick:u,className:"text-xs text-red-700 underline hover:text-red-800",children:"Retry"})]}),!a&&t.jsx("div",{className:"mb-5 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600",children:"Only the account owner can edit the business identity. You can view the current details below."}),t.jsx(KL,{profile:o,isOwner:a,onSaved:p})]})},XL=({showSuccess:e,showError:n})=>t.jsxs("div",{className:"space-y-6",children:[t.jsx(JL,{showSuccess:e,showError:n}),t.jsx(QL,{showSuccess:e,showError:n})]}),ZL=({showSuccess:e,showError:n})=>{const[s,a]=x.useState(!0),[o,l]=x.useState(!1),[d,u]=x.useState("CA"),[p,h]=x.useState({phone_number:"",company_name:"",business_number:"",address:"",number:"",city:"",province:"",postal_code:""});x.useEffect(()=>{te.get("/api/user/profile").then(b=>{if(b!=null&&b.data){const v=b.data.company??{};h({phone_number:b.data.phone_number??"",company_name:v.company_name??"",business_number:v.business_number??"",address:v.address??"",number:v.number??"",city:v.city??"",province:v.province??"",postal_code:v.postal_code??""})}}).finally(()=>a(!1))},[]);const f=b=>v=>h(N=>({...N,[b]:v.target.value})),g=async b=>{b.preventDefault(),l(!0);try{const{phone_number:v,...N}=p,w=await te.put("/api/user/profile",{phone_number:v,company:N});(w==null?void 0:w.status)===200?e("Business profile saved."):n("Failed to save. Please try again.")}catch{n("Failed to save. Please try again.")}finally{l(!1)}};return s?t.jsx(Qt,{title:"Business Profile",children:t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx(jt,{})})}):t.jsx(Qt,{title:"Business Profile",description:"Used on your Excel reports and for tax calculations.",children:t.jsxs("form",{onSubmit:g,className:"space-y-5",children:[t.jsx($t,{label:"Business name",children:t.jsx(In,{value:p.company_name,onChange:f("company_name"),placeholder:"Acme Corp"})}),t.jsx($t,{label:"Phone number",children:t.jsx(In,{type:"tel",value:p.phone_number,onChange:f("phone_number"),placeholder:"+1 604 555 1234"})}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx($t,{label:"Street address",children:t.jsx(In,{value:p.address,onChange:f("address"),placeholder:"123 Main St"})}),t.jsx($t,{label:"Unit / suite",children:t.jsx(In,{value:p.number,onChange:f("number"),placeholder:"Suite 400"})})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[t.jsx($t,{label:"City",children:t.jsx(In,{value:p.city,onChange:f("city"),placeholder:"Toronto"})}),t.jsx($t,{label:"Country",children:t.jsxs(Ca,{value:d,onChange:b=>u(b.target.value),children:[t.jsx("option",{value:"CA",children:"Canada"}),t.jsx("option",{value:"US",children:"United States"})]})}),t.jsx($t,{label:d==="CA"?"Province":"State",children:d==="CA"?t.jsxs(Ca,{value:p.province,onChange:f("province"),children:[t.jsx("option",{value:"",children:"Select…"}),Ya.map(b=>t.jsx("option",{value:b.code,children:b.name},b.code))]}):t.jsxs(Ca,{value:p.province,onChange:f("province"),children:[t.jsx("option",{value:"",children:"Select…"}),fh.map(b=>t.jsx("option",{value:b.code,children:b.name},b.code))]})})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx($t,{label:"Postal / ZIP code",children:t.jsx(In,{value:p.postal_code,onChange:f("postal_code"),placeholder:d==="CA"?"M5H 1A1":"10001"})}),d==="CA"&&t.jsx($t,{label:"GST / HST registration number",children:t.jsx(In,{value:p.business_number,onChange:f("business_number"),placeholder:"123456789 RT 0001"})})]}),t.jsx("div",{className:"pt-1",children:t.jsx(gh,{saving:o})})]})})},eR=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(0);return x.useEffect(()=>{let o=!1;return te.get("/api/accounting/cards/",{params:{page_size:200}}).then(l=>{var u,p;if(o||l==null||l.status!==200)return;const d=Array.isArray((u=l.data)==null?void 0:u.results)?l.data.results:[];n(d.filter(h=>h.classification==="unidentified").length),a(typeof((p=l.data)==null?void 0:p.count)=="number"?l.data.count:d.length)}).catch(()=>{}),()=>{o=!0}}
97,[]),t.jsx(Qt,{title:"Cards",description:"Cards detected in your bank activity, and who they belong to.",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("p",{className:"text-[13.5px] text-gray-600",children:e===null?"Cards appear here automatically when card payments show up in your bank activity.":e>0?`${e} card${e===1?"":"s"} still ${e===1?"needs":"need"} identifying — payments to ${e===1?"it":"them"} wait for review until then.`:s>0?`All ${s} card${s===1?"":"s"} identified — payments to them file automatically.`:"No cards detected yet."}),t.jsx(be,{to:"/accounting/cards",className:"shrink-0 text-[13px] font-semibold text-[var(--color-primary)] hover:underline",children:"Manage cards"})]})})},tR=({showSuccess:e,showError:n})=>{const[s,a]=x.useState(!0),[o,l]=x.useState(!1),[d,u]=x.useState(null),[p,h]=x.useState(null),[f,g]=x.useState(!1),[b,v]=x.useState(!1);x.useEffect(()=>{te.get("/api/telegram/status/").then(_=>{_!=null&&_.data&&(l(_.data.linked),u(_.data.chat_id))}).finally(()=>a(!1))},[]);const N=async()=>{var _;g(!0),h(null);try{const S=await te.post("/api/telegram/link-token/");(_=S==null?void 0:S.data)!=null&&_.token?h(S.data.token):n("Could not generate link token.")}catch{n("Could not generate link token.")}finally{g(!1)}},w=async()=>{v(!0);try{await te.delete("/api/telegram/unlink/"),l(!1),u(null),h(null),e("Telegram account unlinked.")}catch{n("Failed to unlink. Please try again.")}finally{v(!1)}},k=({n:_})=>t.jsx("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[var(--color-primary-light)] text-[10px] font-bold text-[var(--color-primary)]",children:_});return t.jsx(Qt,{title:"Telegram",description:"Link your Telegram account to upload documents directly from the bot.",children:s?t.jsx("div",{className:"flex h-20 items-center",children:t.jsx(jt,{})}):o?t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-[var(--color-primary-light)]",children:t.jsx("svg",{className:"h-5 w-5 text-[var(--color-primary)]",fill:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.447 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.12l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.461c.537-.194 1.006.131.833.941z"})})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Telegram connected"}),t.jsxs("p",{className:"text-xs text-gray-400",children:["Chat ID: ",d]})]})]}),t.jsx("button",{onClick:w,disabled:b,className:"text-sm font-medium text-red-600 transition-colors hover:text-red-700 disabled:opacity-50",children:b?"Unlinking…":"Unlink"})]}):t.jsxs("div",{className:"space-y-5 rounded-xl border border-[var(--color-primary-light)] bg-[var(--color-primary-light)]/40 p-5",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white shadow-sm",children:t.jsx("svg",{className:"h-4 w-4 text-[var(--color-primary)]",fill:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.447 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.12l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.461c.537-.194 1.006.131.833.941z"})})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900",children:"Connect Telegram Bot"}),t.jsx("p",{className:"mt-0.5 text-xs text-gray-500",children:"Upload receipts directly from your phone"})]})]}),t.jsxs("div",{className:"flex flex-col gap-5 sm:flex-row",children:[t.jsxs("ol",{className:"flex-1 space-y-3 text-sm text-gray-700",children:[t.jsxs("li",{className:"flex items-start gap-2.5",children:[t.jsx(k,{n:1}),t.jsx("span",{children:"Download Telegram on your phone"})]}),t.jsxs("li",{className:"flex items-start gap-2.5",children:[t.jsx(k,{n:2}),t.jsxs("span",{children:["Scan the QR code or tap"," ",t.jsx("a",{href:"https://t.me/Accuratebooks_bot",target:"_blank",rel:"noreferrer",className:"font-medium text-[var(--color-primary)] hover:underline",children:"@Accuratebooks_bot"})]})]}),t.jsxs("li",{className:"flex items-start gap-2.5",children:[t.jsx(k,{n:3}),t.jsxs("span",{children:["Send ",t.jsx("code",{className:"rounded border border-[var(--color-primary-light)] bg-white px-1.5 py-0.5 font-[var(--font-family-mono)] text-xs",children:"/start"})," to the bot"]})]}),t.jsxs("li",{className:"flex items-start gap-2.5",children:[t.jsx(k,{n:4}),t.jsxs("span",{children:["Generate your link token below and send"," ",t.jsx("code",{className:"rounded border border-[var(--color-primary-light)] bg-white px-1.5 py-0.5 font-[var(--font-family-mono)] text-xs",children:"/link <token>"})," to the bot"]})]})]}),t.jsx("div",{className:"flex justify-center sm:shrink-0",children:t.jsx("img",{src:"/t_me-Accuratebooks_bot.jpg",alt:"Scan to open @Accuratebooks_bot on Telegram",className:"rounded-lg border border-[var(--color-primary-light)] object-contain",style:{width:180,height:180}})})]}),p&&t.jsxs("div",{className:"rounded-lg border border-[var(--color-primary-light)] bg-white px-4 py-3",children:[t.jsx("p",{className:"mb-1.5 text-xs font-medium text-[var(--color-primary)]",children:"Your link token (valid 15 minutes)"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("code",{className:"flex-1 break-all font-[var(--font-family-mono)] text-sm text-gray-900",children:["/link ",p]}),t.jsx("button",{onClick:()=>navigator.clipboard.writeText(`/link ${p}`),className:"shrink-0 text-xs font-medium text-[var(--color-primary)] hover:underline",children:"Copy"})]})]}),t.jsxs("button",{onClick:N,disabled:f,className:"inline-flex h-[42px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-60",children:[f&&t.jsx(jt,{light:!0}),f?"Generating…":"Generate link token"]})]})})},nR=({showError:e})=>{const[n,s]=x.useState(null),[a,o]=x.useState(!0),[l,d]=x.useState(!1);x.useEffect(()=>{te.get("/api/packages/user_package").then(b=>{b!=null&&b.data&&s(b.data)}).finally(()=>o(!1))},[]);const u=async()=>{var b,v;d(!0);try{const N=await te.post("/api/stripe/create-portal-session/");(b=N==null?void 0:N.data)!=null&&b.url?window.location.href=N.data.url:e(((v=N==null?void 0:N.data)==null?void 0:v.error)??"Could not open billing portal. Please try again.")}catch{e("Could not open billing portal. Please try again.")}finally{d(!1)}},p=(n==null?void 0:n.number_of_documents_uploaded)??0,h=(n==null?void 0:n.number_of_documents_to_upload_total)??0,f=p+h,g=f>0?Math.min(100,Math.round(p/f*100)):0;return t.jsx(Qt,{title:"Subscription",description:"Your current plan and document quota.",children:a?t.jsx("div",{className:"flex h-16 items-center",children:t.jsx(jt,{})}):n?t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900",children:n.plan_name}),t.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:[h," document",h!==1?"s":""," remaining"," · ",p," used"]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:u,disabled:l,className:"text-sm font-medium text-gray-600 transition-colors hover:text-gray-900 disabled:opacity-50",children:l?"Opening…":"Manage billing"}),t.jsx(be,{to:"/subscription",className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:"Upgrade plan"})]})]}),t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-gray-100",children:t.jsx("div",{className:"h-full rounded-full bg-[var(--color-primary)] transition-all",style:{width:`${g}%`}})})]}):t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"No active plan."}),t.jsx(be,{to:"/subscription",className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:"View plans"})]})})},sR=({showSuccess:e,showError:n})=>{const[s,a]=x.useState(!1),[o,l]=x.useState({old_password:"",new_password:"",new_password2:""}),d=p=>h=>l(f=>({...f,[p]:h.target.value})),u=async p=>{var h,f,g,b,v;if(p.preventDefault(),o.new_password!==o.new_password2){n("New passwords do not match.");return}a(!0);try{const N=await te.put("/api/user/password",o);if((N==null?void 0:N.status)===200)e("Password updated successfully."),l({old_password:"",new_password:"",new_password2:""});else{const w=((f=(h=N==null?void 0:N.data)==null?void 0:h.old_password)==null?void 0:f[0])||((b=(g=N==null?void 0:N.data)==null?void 0:g.new_password)==null?void 0:b[0])||((v=N==null?void 0:N.data)==null?void 0:v.detail)||"Password change failed.";n(w)}}catch{n("Password change failed. Please try again.")}finally{a(!1)}};return t.jsx(Qt,{title:"Security",description:"Change your account password.",children:t.jsxs("form",{onSubmit:u,className:"max-w-sm space-y-5",children:[t.jsx($t,{label:"Current password",required:!0,children:t.jsx(In,{type:"password",value:o.old_password,onChange:d("old_password"),autoComplete:"current-password",placeholder:"••••••••",required:!0})}),t.jsx($t,{label:"New password",required:!0,children:t.jsx(In,{type:"password",value:o.new_password,onChange:d("new_password"),autoComplete:"new-password",placeholder:"Min. 8 characters",required:!0})}),t.jsx($t,{label:"Confirm new password",required:!0,children:t.jsx(In,{type:"password",value:o.new_password2,onChange:d("new_password2"),autoComplete:"new-password",placeholder:"Repeat new password",required:!0})}),t.jsx("div",{className:"pt-1",children:t.jsx(gh,{saving:s,label:"Update password"})})]})})},An={business:{id:"business",label:"Business profile"},tax:{id:"tax",label:"Tax profile"},integrations:{id:"integrations",label:"Bank & integrations"},chart:{id:"chart",label:"Chart of accounts"},subscription:{id:"subscription",label:"Subscription"},security:{id:"security",label:"Security"},team:{id:"team",label:"Team & access"}},rR=()=>{var f;const{toast:e,showSuccess:n,showError:s}=hh(),{user:a}=ht(g=>g.auth),o=((f=a==null?void 0:a.user)==null?void 0:f.has_tier2)??(a==null?void 0:a.has_tier2)??!1,l=o?[An.business,An.tax,An.integrations,An.chart,An.subscription,An.security,An.team]:[An.business,An.integrations,An.subscription,An.security],[d]=Jn(),u=d.get("tab"),[p,h]=x.useState(l.some(g=>g.id===u)?u:"business");return t.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:[t.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8",children:[t.jsx(ut,{title:"Settings",subtitle:"Manage your business profile, integrations, and account security."}),t.jsx("div",{className:"mt-2",children:t.jsxs(be,{to:"/accounting/subscription",className:"text-sm font-semibold text-[var(--color-primary)] hover:underline",children:[o?"Manage subscription":"Upgrade to Bookkeeping Service"," →"]})}),t.jsx("div",{className:"mt-6",children:t.jsx(uL,{tabs:l,active:p,onChange:h})}),t.jsxs("div",{className:"mt-6",children:[p==="business"&&(o?t.jsx(XL,{showSuccess:n,showError:s}):t.jsx(ZL,{showSuccess:n,showError:s})),p==="tax"&&o&&t.jsx(yL,{onSaved:n}),p==="integrations"&&t.jsxs("div",{className:"space-y-6",children:[o&&t.jsx(_L,{}),o&&t.jsx(DL,{}),o&&t.jsx(eR,{}),t.jsx(tR,{showSuccess:n,showError:s})]}),p==="chart"&&o&&t.jsx(zL,{}),p==="subscription"&&t.jsx(nR,{showError:s}),p==="security"&&t.jsx(sR,{showSuccess:n,showError:s}),p==="team"&&o&&t.jsx(qL,{showSuccess:n,showError:s})]})]}),t.jsx(xh,{toast:e})]})},aR=()=>{var v,N,w,k,_,S,T,E,A;const e=ht(I=>I.auth),n=((N=(v=e.user)==null?void 0:v.user)==null?void 0:N.email)??((w=e.user)==null?void 0:w.email)??"",s=[(_=(k=e.user)==null?void 0:k.user)==null?void 0:_.first_name,(T=(S=e.user)==null?void 0:S.user)==null?void 0:T.last_name].filter(
97Boolean).join(" ")||[(E=e.user)==null?void 0:E.first_name,(A=e.user)==null?void 0:A.last_name].filter(Boolean).join(" ")||"",[a,o]=x.useState({name:s,email:n,subject:"",message:""}),[l,d]=x.useState(!1),[u,p]=x.useState(null),[h,f]=x.useState(""),g=I=>R=>o(W=>({...W,[I]:R.target.value})),b=async I=>{var R,W;I.preventDefault(),d(!0),f("");try{const Y=await te.post("/api/support/",a);(R=Y==null?void 0:Y.data)!=null&&R.ticket_number?p(Y.data.ticket_number):f(((W=Y==null?void 0:Y.data)==null?void 0:W.error)??"Submission failed. Please try again.")}catch{f("Something went wrong. Please try again.")}finally{d(!1)}};return u?t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-8 max-w-2xl",children:t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm p-8 text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-7 h-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Message received!"}),t.jsxs("p",{className:"text-sm text-gray-600 leading-relaxed",children:["Your message has been received. Your ticket number is"," ",t.jsx("span",{className:"font-mono font-semibold text-[#0066FF]",children:u}),". We'll get back to you within 24 hours."]}),t.jsxs("p",{className:"mt-3 text-xs text-gray-400",children:["A confirmation has been sent to ",a.email,"."]}),t.jsx("button",{onClick:()=>{p(null),o({name:s,email:n,subject:"",message:""})},className:"mt-6 text-sm font-medium text-[#0066FF] hover:underline",children:"Send another message"})]})})}):t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-8 max-w-2xl",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Support"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Send us a message and we'll get back to you within 24 hours."})]}),t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm px-6 py-6",children:[h&&t.jsx("div",{className:"mb-5 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:h}),t.jsxs("form",{onSubmit:b,className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Name"}),t.jsx("input",{type:"text",required:!0,value:a.name,onChange:g("name"),placeholder:"Your name",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Email"}),t.jsx("input",{type:"email",required:!0,value:a.email,onChange:g("email"),placeholder:"[email protected]",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Subject"}),t.jsx("input",{type:"text",required:!0,value:a.subject,onChange:g("subject"),placeholder:"Brief summary of your issue",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Message"}),t.jsx("textarea",{required:!0,value:a.message,onChange:g("message"),rows:6,placeholder:"Describe your issue or question in detail…",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition resize-none"})]}),t.jsxs("button",{type:"submit",disabled:l,className:"flex items-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:[l&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),l?"Sending…":"Send message"]})]})]})]})})},iR=["Bug","Suggestion","Compliment"],oR=({value:e,onChange:n})=>{const[s,a]=x.useState(0);return t.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(o=>t.jsx("button",{type:"button",onClick:()=>n(o),onMouseEnter:()=>a(o),onMouseLeave:()=>a(0),className:"focus:outline-none","aria-label":`${o} star`,children:t.jsx("svg",{className:`w-8 h-8 transition-colors ${o<=(s||e)?"text-amber-400":"text-gray-200"}`,fill:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},o))})},lR=()=>{const[e,n]=x.useState(5),[s,a]=x.useState("Suggestion"),[o,l]=x.useState(""),[d,u]=x.useState(""),[p,h]=x.useState(!1),[f,g]=x.useState(!1),[b,v]=x.useState(""),N=async w=>{var k;if(w.preventDefault(),!o.trim()){v("Please add a comment.");return}h(!0),v("");try{const _=await te.post("/api/feedback/",{feedback:o,rating:e,category:s,email_address:d||void 0});(_==null?void 0:_.status)===201?g(!0):v(((k=_==null?void 0:_.data)==null?void 0:k.error)??"Submission failed. Please try again.")}catch{v("Something went wrong. Please try again.")}finally{h(!1)}};return f?t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-8 max-w-2xl",children:t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm p-8 text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-7 h-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Thank you!"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Your feedback has been received. We read every submission."}),t.jsx("button",{onClick:()=>{g(!1),l(""),u(""),n(5),a("Suggestion")},className:"mt-6 text-sm font-medium text-[#0066FF] hover:underline",children:"Send more feedback"})]})})}):t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-8 max-w-2xl",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Feedback"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Help us improve AI Bookkeeping — every submission is read by the team."})]}),t.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm px-6 py-6",children:[b&&t.jsx("div",{className:"mb-5 rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:b}),t.jsxs("form",{onSubmit:N,className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"How would you rate your experience?"}),t.jsx(oR,{value:e,onChange:n})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Category"}),t.jsx("select",{value:s,onChange:w=>a(w.target.value),className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition bg-white",children:iR.map(w=>t.jsx("option",{value:w,children:w},w))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Comment"}),t.jsx("textarea",{required:!0,value:o,onChange:w=>l(w.target.value),rows:5,placeholder:"Tell us what you think…",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition resize-none"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["Email ",t.jsx("span",{className:"text-gray-400 font-normal",children:"(optional — if you'd like us to follow up)"})]}),t.jsx("input",{type:"email",value:d,onChange:w=>u(w.target.value),placeholder:"[email protected]",className:"w-full rounded-lg border border-gray-300 px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition"})]}),t.jsxs("button",{type:"submit",disabled:p,className:"flex items-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:[p&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),p?"Submitting…":"Submit feedback"]})]})]})]})})},fp=["AI extraction & categorization","Annual Excel workbook","Expense & tax reports","Telegram bot intake","GST/HST ITC reports","Full manual control over every field","Email support"],cR=[{id:"starter",name:"Starter",price:29,priceId:"price_1TYXBZDJi9AqAMUzHjzs1Vgw",docs:"100 receipts / month",storage:"1 GB storage",features:fp,highlight:!1},{id:"growth",name:"Growth",price:49,priceId:"price_1TYXGGDJi9AqAMUzLXwKkzGb",docs:"300 receipts / month",storage:"5 GB storage",features:fp,highlight:!0,badge:"Most popular"},{id:"pro",name:"Pro",price:69,priceId:"price_1TYXGsDJi9AqAMUzD0KcUoPk",docs:"500 receipts / month",storage:"20 GB storage",features:fp,highlight:!1}],dR=()=>{const e=Xe();return t.jsx("div",{className:"flex flex-col h-full bg-gray-50 items-center justify-center px-6",children:t.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-10 max-w-md w-full text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center mx-auto mb-5",children:t.jsx("svg",{className:"w-7 h-7 text-emerald-600",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})}),t.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"You're subscribed!"}),t.jsx("p",{className:"text-sm text-gray-500 mb-6",children:"Your subscription is now active. Your document quota has been updated — you're ready to upload."}),t.jsx("button",{onClick:()=>e("/documents"),className:"rounded-lg bg-[#0066FF] hover:bg-[#0052cc] px-6 py-2.5 text-sm font-semibold text-white transition-colors",children:"Start uploading →"})]})})},uR=()=>{const e=Xe(),[n,s]=x.useState(null),[a,o]=x.useState(""),l=async u=>{var p,h;if(!u.priceId){o("Stripe price ID not configured. Check VITE_STRIPE_*_PRICE_ID env vars.");return}s(u.id),o("");try{const f=await te.post("/api/stripe/create-checkout-session/",{price_id:u.priceId});(p=f==null?void 0:f.data)!=null&&p.url?window.location.href=f.data.url:o(((h=f==null?void 0:f.data)==null?void 0:h.error)??"Could not create checkout session. Please try again.")}catch{o("Could not connect to Stripe. Please try again.")}finally{s(null)}},d=()=>t.jsx("svg",{className:"w-4 h-4 text-emerald-500 shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})});return t.jsx(t.Fragment,{children:t.jsx("div",{className:"flex flex-col h-full bg-gray-50",children:t.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-10",children:[t.jsx("div",{className:"max-w-6xl mx-auto mb-10",children:t.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-xl bg-[#0A1628] px-6 py-4 text-sm text-white/80",children:[t.jsx("svg",{className:"w-4 h-4 text-[#4DA6FF] shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z"})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-semibold text-white",children:"Upgrade your plan"})," · ","Cancel anytime"," · ","Secure payment via Stripe"]})]})}),t.jsxs("div",{className:"max-w-6xl mx-auto text-center mb-10",children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Simple, transparent pricing"}),t.jsx("p",{className:"mt-3 text-gray-500",children:"All plans include AI extraction, Excel workbooks, and expense reports. Cancel anytime."})]}),a&&t.jsx("div",{className:"max-w-6xl mx-auto mb-6",children:t.jsx("div",{className:"rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:a})}),t.jsx("div",{className:"max-w-6xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-6",children:cR.map(u=>t.jsxs("div",{className:`relative bg-white rounded-2xl flex flex-col ${u.highlight?"border-2 border-[#0066FF] shadow-lg shadow-blue-100":"border border-gray-100 shadow-sm"}`,children:["badge"in u&&t.jsx("div",{className:"absolute -top-3.5 inset-x-0 flex justify-center",children:t.jsx("span",{className:"bg-[#0066FF] text-white text-xs font-semibold px-3 py-1 rounded-full",children:u.badge})}),t.jsxs("div",{className:"px-6 pt-8 pb-6 flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide",children:u.name}),t.jsxs("div",{className:"mt-3 flex items-end gap-1",children:[t.jsxs("span",{className:"text-4xl font-bold text-gray-900",children:["$",u.price]}),t.jsx("span",{className:"text-sm text-gray-400 mb-1.5",children:"CAD / mo"})]}),t.jsxs("div",{className:"mt-4 space-y-1.5",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700",children:u.docs}),t.jsx("p",{className:"text-sm text-gray-500",children:u.storage})]}),t.jsx("ul",{className:"mt-6 space-y-2.5",children:u.features.map(p=>t.jsxs("li",{className:"flex items-start gap-2.5 text-sm text-gray-600",children:[t.jsx(d,{}),p]},p))})]}),t.jsx("div",{className:"px-6 pb-6",children:t.jsx("button",{onClick:()=>l(u),disabled:n!==null,className:`w-full flex items-center justify-center gap-2 rounded-xl py-3 text-sm font-semibold transition-colors disabled:opacity-60 ${u.highlight?"bg-[#0066FF] hover:bg-[#0052cc] text-white":"bg-gray-900 hover:bg-gray-700 text-white"}`,children:n===u.id?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}),"Redirecting…"]}):"Choose this plan"})})]},u.id))}),t.jsx("div",{className:"max-w-6xl mx-auto mt-10",children:t.jsxs("div",{className:"rounded-2xl bg-[#0A1628] px-8 py-8 flex flex-col md:flex-row items-center justify-between gap-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-bold text-white",children:"Bookkeeping Service"}),t.jsx("p",{className:"mt-1.5 text-sm text-white/70 max-w-xl",children:"Complete double-entry books — bank and card connections, supplier and customer invoices, reconciliation, and financial statements. Plans at $99, $199, or $399 CAD per month for 150, 250, or 500 documents. 15-day free trial."})]}),t.jsx("button",{onClick:()=>e("/accounting/subscription"),className:"shrink-0 rounded-xl bg-white px-6 py-3 text-sm font-semibold text-[#0A1628] transition-colors hover:bg-gray-100",children:"View plans →"})]})}),t.jsx("p",{className:"max-w-6xl mx-auto mt-8 text-center text-xs text-gray-400",children:"Prices in CAD. GST/HST may apply. Cancel anytime from your billing portal. By subscribing you agree to our Terms of Service."})]})})})},gw=[{path:"/services",label:"Services"},{path:"/services/bookkeeping-services",label:"Bookkeeping Services"},{path:"/services/bookkeeping-services-canada",label:"Bookkeeping Services in Canada"},{path:"/services/online-bookkeeping-services",label:"Online Bookkeeping Services"},{path:"/services/outsourced-bookkeeping-services",label:"Outsourced Bookkeeping Services"},{path:"/services/bookkeeping-services/toronto",label:"Toronto"},{path:"/services/bookkeeping-services/vancouver",label:"Vancouver"},{path:"/services/bookkeeping-services/calgary",label:"Calgary"}],Dd=()=>t.jsxs("footer",{className:"border-t border-gray-100 bg-white mt-auto",children:[t.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 py-8 flex flex-col sm:flex-row items-center justify-between gap-4",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"© 2026 Time2Win Inc."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-6 gap-y-2 text-sm text-gray-400",children:[t.jsx("span",{className:"font-medium text-gray-500",children:"Resources"}),t.jsx(Fe,{to:"/pricing",className:"hover:text-gray-700 transition-colors",children:"Pricing"}),t.jsx("a",{href:"/blog",className:"hover:text-gray-700 transition-colors",children:"Blog"}),t.jsx(Fe,{to:"/faq",className:"hover:text-gray-700 transition-colors",children:"FAQ"}),t.jsx(Fe,{to:"/privacy-policy",className:"hover:text-gray-700 transition-colors",children:"Privacy"}),t.jsx(Fe,{to:"/terms-of-service",className:"hover:text-gray-700 transition-colors",children:"Terms"})]})]}),t.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 pb-8 flex flex-wrap items-center justify-center gap-x-5 gap-y-2 text-sm text-gray-400 sm:justify-start",children:[t.jsx("span",{className:"font-medium text-gray-500",children:"Services"}),gw.map(e=>t.jsx("a",{href:e.path,className:"hover:text-gray-700 transition-colors",children:e.label},e.path))]})]}),hp=["AI extraction & categorization","Annual Excel workbook","Expense & tax reports","Telegram bot intake","GST/HST ITC reports","Email support"],mR=["Human bookkeeper review included","Everything in Pro","Supplier invoice recording","Supplier payment tracking","Customer invoice recording","Customer payment tracking","Bank & credit card connection (via Plaid)","Bank reconciliation","Profit & Loss reports","Accounts Payable balance","Accounts Receivable balance","Tax reports (CA & US)"],pR=[{id:"starter",name:"Starter",price:29,docs:"100 receipts / month",storage:"1 GB storage",features:hp,highlight:!1},{id:"growth",name:"Growth",price:49,docs:"300 receipts / month",storage:"5 GB storage",features:hp,highlight:!0,badge:"Most popular"},{id:"pro",name:"Pro",price:69,docs:"500 receipts / month",storage:"20 GB storage",features:hp,highlight:!1}],fR=[{id:"bs-starter",name:"Starter",price:99,docs:"150 docs",highlight:!1},{id:"bs-growth",name:"Growth",price:199,docs:"250 docs",highlight:!0,badge:"Most chosen"},{id:"bs-pro",name:"Pro",price:399,docs:"500 docs",highlight:!1}],hR=()=>{const e=Xe(),{user:n}=ht(o=>o.auth),s=()=>e(n?"/accounting/subscription":"/register"),a=()=>t.jsx("svg",{className:"w-4 h-4 text-emerald-500 shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[t.jsxs("nav",{className:"bg-white border-b border-gray-100 px-6 py-4 flex items-center justify-between",children:[t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-8 w-auto"}),t.jsx(Fe,{to:"/login",className:"text-sm font-medium text-[#0066FF] hover:underline",children:"Sign in →"})]}),t.jsxs("main",{className:"flex-1 overflow-y-auto px-6 py-10",children:[t.jsx("div",{className:"max-w-6xl mx-auto mb-10",children:t.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-xl bg-[#0A1628] px-6 py-4 text-sm text-white/80",children:[t.jsx("svg",{className:"w-4 h-4 text-[#4DA6FF] shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09
97L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z"})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-semibold text-white",children:"Free trial"})," — ","5 receipts included"," · ","no credit card required"]})]})}),t.jsxs("div",{className:"max-w-6xl mx-auto text-center mb-10",children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Simple, transparent pricing"}),t.jsx("p",{className:"mt-3 text-gray-500",children:"All plans include AI extraction, Excel workbooks, and expense reports. Cancel anytime."})]}),t.jsx("div",{className:"max-w-6xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-6",children:pR.map(o=>t.jsxs("div",{className:`relative bg-white rounded-2xl flex flex-col ${o.highlight?"border-2 border-[#0066FF] shadow-lg shadow-blue-100":"border border-gray-100 shadow-sm"}`,children:["badge"in o&&t.jsx("div",{className:"absolute -top-3.5 inset-x-0 flex justify-center",children:t.jsx("span",{className:"bg-[#0066FF] text-white text-xs font-semibold px-3 py-1 rounded-full",children:o.badge})}),t.jsxs("div",{className:"px-6 pt-8 pb-6 flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide",children:o.name}),t.jsxs("div",{className:"mt-3 flex items-end gap-1",children:[t.jsxs("span",{className:"text-4xl font-bold text-gray-900",children:["$",o.price]}),t.jsx("span",{className:"text-sm text-gray-400 mb-1.5",children:"CAD / mo"})]}),t.jsxs("div",{className:"mt-4 space-y-1.5",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700",children:o.docs}),t.jsx("p",{className:"text-sm text-gray-500",children:o.storage})]}),t.jsx("ul",{className:"mt-6 space-y-2.5",children:o.features.map(l=>t.jsxs("li",{className:"flex items-start gap-2.5 text-sm text-gray-600",children:[t.jsx(a,{}),l]},l))})]}),t.jsx("div",{className:"px-6 pb-6",children:t.jsx("button",{onClick:()=>e("/register"),className:`w-full flex items-center justify-center gap-2 rounded-xl py-3 text-sm font-semibold transition-colors ${o.highlight?"bg-[#0066FF] hover:bg-[#0052cc] text-white":"bg-gray-900 hover:bg-gray-700 text-white"}`,children:"Start Free Trial"})})]},o.id))}),t.jsxs("div",{className:"max-w-6xl mx-auto mt-14",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Bookkeeping Service"}),t.jsx("p",{className:"mt-2 text-gray-500",children:"Complete double-entry books — bank and card connections, invoices, reconciliation, and financial statements — with a human bookkeeper reviewing every uncertain entry. 15-day free trial."})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:fR.map(o=>t.jsxs("div",{className:`relative bg-white rounded-2xl flex flex-col ${o.highlight?"border-2 border-[#0A1628] shadow-lg":"border border-gray-100 shadow-sm"}`,children:["badge"in o&&t.jsx("div",{className:"absolute -top-3.5 inset-x-0 flex justify-center",children:t.jsx("span",{className:"bg-[#0A1628] text-white text-xs font-semibold px-3 py-1 rounded-full",children:o.badge})}),t.jsxs("div",{className:"px-6 pt-8 pb-6 flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide",children:o.name}),t.jsxs("div",{className:"mt-3 flex items-end gap-1",children:[t.jsxs("span",{className:"text-4xl font-bold text-gray-900",children:["$",o.price]}),t.jsx("span",{className:"text-sm text-gray-400 mb-1.5",children:"CAD / mo"})]}),t.jsxs("div",{className:"mt-4 space-y-1.5",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700",children:o.docs}),t.jsx("p",{className:"text-sm text-gray-500",children:"15-day free trial"})]})]}),t.jsx("div",{className:"px-6 pb-6",children:t.jsx("button",{onClick:s,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-[#0A1628] hover:bg-[#112040] py-3 text-sm font-semibold text-white transition-colors",children:"Start 15-Day Free Trial"})})]},o.id))}),t.jsx("ul",{className:"mt-8 max-w-3xl mx-auto grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-2.5",children:mR.map(o=>t.jsxs("li",{className:"flex items-start gap-2.5 text-sm text-gray-600",children:[t.jsx(a,{}),o]},o))})]}),t.jsxs("p",{className:"max-w-6xl mx-auto mt-8 text-center text-xs text-gray-400",children:["Prices in CAD. GST/HST may apply. Cancel anytime from your billing portal. By subscribing you agree to our"," ",t.jsx(Fe,{to:"/terms-of-service",className:"underline hover:text-gray-600 transition-colors",children:"Terms of Service"}),"."]})]})]}),t.jsx(Dd,{})]})},tn=({title:e,children:n})=>t.jsxs("section",{className:"mb-10",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:e}),t.jsx("div",{className:"space-y-3 text-gray-600 leading-relaxed",children:n})]}),xR=()=>t.jsxs("div",{className:"min-h-screen bg-gray-50 py-10 px-4",children:[t.jsxs("div",{className:"max-w-3xl mx-auto",children:[t.jsxs(Fe,{to:"/login",className:"inline-flex items-center gap-1.5 text-sm text-[#0066FF] hover:underline mb-8",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Back to sign in"]}),t.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm px-8 py-10 mb-6",children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Privacy Policy"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Effective date: July 14, 2026 · Time2Win Inc."})]}),t.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm px-8 py-10",children:[t.jsxs(tn,{title:"1. Who we are",children:[t.jsxs("p",{children:["AI Bookkeeping (ai-bookkeeping.ai) is operated by ",t.jsx("strong",{children:"Time2Win Inc., a corporation organized under the laws of British Columbia, Canada"}),". Time2Win Inc. is responsible for the personal information handled through the service and is accountable for it under the Personal Information Protection and Electronic Documents Act (PIPEDA). If you have questions about this policy or how your information is handled, contact us at"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-[#0066FF] hover:underline",children:"[email protected]"}),"."]}),t.jsx("p",{children:"This policy applies to the AI Bookkeeping website and application at ai-bookkeeping.ai, our API, and our Telegram bot."})]}),t.jsx(tn,{title:"2. Your records and our role",children:t.jsx("p",{children:"You and your business decide which financial records to upload to AI Bookkeeping. Those records belong to your business. Time2Win Inc. processes them for one purpose: to provide the bookkeeping service you signed up for — organizing, categorizing, and preparing your financial documents and transactions. We do not sell your information, and we do not use it for advertising."})}),t.jsxs(tn,{title:"3. Information we collect",children:[t.jsxs("p",{children:[t.jsx("strong",{children:"Account information."}
97)," Your name, email address, password (stored in hashed form), and business details you provide, such as your business name and province."]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Financial records you upload or connect."})," This is the core of the service and includes:"]}),t.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[t.jsx("li",{children:"receipts and invoices,"}),t.jsx("li",{children:"bank and credit card transaction data (through our banking connection provider, Plaid),"}),t.jsx("li",{children:"supplier and vendor details that appear on your documents,"}),t.jsx("li",{children:"the accounting records the service produces from them (categorizations, journal entries, reconciliations)."})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Bank connection information."})," When you connect a bank account through Plaid, we receive transaction and account data. ",t.jsx("strong",{children:"We never see or store your online banking username or password"})," — the connection is established directly between you and Plaid. The access credentials Plaid issues to us are stored encrypted."]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Payment information."})," Payments are processed by Stripe. Your card details go directly to Stripe and are never stored on our servers."]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Service and technical information."})," Log data needed to operate and secure the service (such as request logs and error reports), and operational metadata about your bank connection (such as when it last synced and whether syncs are failing) so we can keep it healthy."]})]}),t.jsx(tn,{title:"4. How we use your information",children:t.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[t.jsx("li",{children:"To provide the service: reading your documents, extracting their contents, categorizing transactions, drafting accounting entries, and keeping your books."}),t.jsx("li",{children:"To operate, secure, and improve the service, including monitoring for errors and outages."}),t.jsx("li",{children:"To communicate with you: account verification, receipts, service and security notices."}),t.jsx("li",{children:"To meet our legal obligations."})]})}),t.jsxs(tn,{title:"5. AI processing",children:[t.jsx("p",{children:"AI Bookkeeping is an AI-powered service, and we want to be precise about what that means:"}),t.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[t.jsxs("li",{children:["When you upload a document or connect transactions, the relevant text and images are processed by",t.jsx("strong",{children:" Anthropic's Claude models"})," to extract and categorize the information."]}),t.jsxs("li",{children:["This processing happens under Anthropic's commercial API terms. ",t.jsx("strong",{children:"Your documents and data are not used to train AI models."})]}),t.jsx("li",{children:"Anthropic is the only AI provider that receives your documents. No other AI company has access to your data."}),t.jsx("li",{children:"AI output is subject to review controls inside the service; the AI does not move your money and cannot access your bank accounts."})]})]}),t.jsxs(tn,{title:"6. Third-party service providers",children:[t.jsx("p",{children:"We rely on a small number of service providers, each for a specific job:"}),t.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[t.jsxs("li",{children:[t.jsx("strong",{children:"Hosting:"})," Railway (application and database hosting)"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Document storage:"})," Cloudflare R2"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"AI processing:"})," Anthropic"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Bank connections:"})," Plaid"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Payments:"})," Stripe"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Email delivery:"})," SendGrid"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Error monitoring:"})," Sentry"]})]}),t.jsx("p",{children:"Each provider receives only the information needed for its role, under contractual terms that restrict how it may use that information."})]}),t.jsx(tn,{title:"7. Where your information is stored (cross-border transfers)",children:t.jsxs("p",{children:["Our servers and several of our service providers are located in the ",t.jsx("strong",{children:"United States"}),". This means your information, including your financial records, is stored and processed outside Canada. While it is outside Canada, it is subject to the laws of the jurisdiction where it is held, and may be accessible to authorities there under those laws. We use contractual and security safeguards with all of our providers to protect your information wherever it is processed. By using the service, you acknowledge this transfer."]})}),t.jsxs(tn,{title:"8. How we protect your information",children:[t.jsx("p",{children:"We treat your financial records as highly sensitive and protect them with safeguards that include:"}),t.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[t.jsxs("li",{children:[t.jsx("strong",{children:"Encryption in transit."})," All connections to the service use TLS (HTTPS), enforced across the site."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Encryption at rest for bank credentials."})," The access tokens for your bank connections are stored encrypted."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Private document storage."})," Your uploaded documents are held in private cloud storage. They are never publicly accessible; documents are served only through signed links that expire after a short time."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Role-based access."})," Access inside the service is limited by role, and reviewer access is scoped to the specific businesses a reviewer is assigned to."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Audit logging."})," Changes to your accounting records are written to append-only audit logs."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Monitoring and alerting."})," The service is continuously monitored for errors and downtime, with daily operational checks that alert us to problems such as failing bank syncs or unreviewed items aging in queues."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Deletion that actually deletes."})," When you delete a document or your account, the stored files themselves are erased from storage — not just the database records pointing to them (see Section 9)."]})]}),t.jsx("p",{children:"No system can be guaranteed 100% secure, but security review and hardening of the service is a continuous, ongoing program."})]}),t.jsx(tn,{title:"9. Data retention and deletion",children:t.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[t.jsx("li",{children:"We retain your information while your account is active, so the service can do its job."}),t.jsxs("li",{children:[t.jsx("strong",{children:"When you delete a document, the stored file is deleted from our cloud storage,"}),"along with its data in the service."]}),t.jsxs("li",{children:[t.jsx("strong",{children:"When you delete your account, your documents and data are erased,"})," including the underlying files in storage."]}),t.jsx("li",{children:"Where a law requires us to retain specific records, we will retain them for the peri
97od the law requires and no longer."}),t.jsxs("li",{children:["You may request erasure of your personal information at any time by contacting"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-[#0066FF] hover:underline",children:"[email protected]"}),"."]})]})}),t.jsx(tn,{title:"10. Security incidents",children:t.jsx("p",{children:"We maintain documented procedures to detect, investigate, contain, and recover from security incidents. If a breach of security safeguards creates a real risk of significant harm to you, we will notify you and report to the Office of the Privacy Commissioner of Canada, as required by PIPEDA, as soon as feasible. We also keep records of security incidents as PIPEDA requires."})}),t.jsx(tn,{title:"11. Cookies and tracking",children:t.jsx("p",{children:"We do not use advertising cookies, analytics services, or tracking technologies. When you sign in, the service uses authentication tokens stored on your device solely to keep you signed in; they are removed when you sign out."})}),t.jsxs(tn,{title:"12. Your rights",children:[t.jsx("p",{children:"Under PIPEDA, you have the right to:"}),t.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[t.jsxs("li",{children:[t.jsx("strong",{children:"access"})," the personal information we hold about you,"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"correct"})," it if it is inaccurate,"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"withdraw consent"})," to our handling of your information (which may mean we can no longer provide the service),"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"request deletion"})," as described in Section 9,"]}),t.jsxs("li",{children:["and ",t.jsx("strong",{children:"complain"})," to us, or to the Office of the Privacy Commissioner of Canada, about our information-handling practices."]})]}),t.jsxs("p",{children:["To exercise any of these rights, contact"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-[#0066FF] hover:underline",children:"[email protected]"}),"."]})]}),t.jsx(tn,{title:"13. Changes to this policy",children:t.jsx("p",{children:"When we make material changes to this policy, we will update the effective date at the top and, where the change is significant, notify you through the service or by email. Prior versions are available on request."})})]}),t.jsxs("p",{className:"text-center text-xs text-gray-400 mt-8",children:["Time2Win Inc. · British Columbia, Canada ·"," ",t.jsx("a",{href:"mailto:[email protected]",className:"hover:underline",children:"[email protected]"})]}),t.jsx("p",{className:"text-center text-xs text-gray-400 mt-2",children:t.jsx(Fe,{to:"/terms-of-service",className:"hover:underline",children:"Terms of Service"})})]}),t.jsx(Dd,{})]}),_t=({n:e,title:n,children:s})=>t.jsxs("section",{className:"mb-10",children:[t.jsxs("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:[e,". ",n]}),t.jsx("div",{className:"space-y-3 text-gray-600 leading-relaxed",children:s})]}),os=({title:e,children:n})=>t.jsxs("div",{className:"mt-4",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-800 mb-2",children:e}),t.jsx("div",{className:"space-y-2",children:n})]}),gR=()=>t.jsxs("div",{className:"min-h-screen bg-gray-50 py-10 px-4",children:[t.jsxs("div",{className:"max-w-3xl mx-auto",children:[t.jsxs(Fe,{to:"/login",className:"inline-flex items-center gap-1.5 text-sm text-[#0066FF] hover:underline mb-8",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Back to sign in"]}),t.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm px-8 py-10 mb-6",children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Terms of Service"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Effective date: May 21, 2026 · Time2Win Inc."}),t.jsx("p",{className:"mt-4 text-gray-600 leading-relaxed",children:'These Terms of Service ("Terms") govern your use of AI Bookkeeping, a service operated by Time2Win Inc. ("Company", "we", "us", or "our"). By creating an account or using our service, you agree to be bound by these Terms. Please read them carefully.'})]}),t.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm px-8 py-10",children:[t.jsxs(_t,{n:1,title:"Description of Service",children:[t.jsx("p",{children:"AI Bookkeeping is a cloud-based bookkeeping and financial document management service that uses artificial intelligence to extract, categorize, and organize financial data from uploaded receipts, invoices, and other financial documents. The service generates Excel workbooks, expense reports, and tax summaries for small businesses and freelancers."}),t.jsx("p",{children:"The service is intended for informational and organizational purposes. It does not constitute professional accounting, tax, or legal advice."})]}),t.jsxs(_t,{n:2,title:"Eligibility",children:[t.jsx("p",{children:"You must be at least 18 years old and capable of entering into a binding contract to use this service. By using AI Bookkeeping, you represent and warrant that you meet these requirements."}),t.jsx("p",{children:"The service is primarily intended for use by businesses and individuals in Canada and the United States. Use of the service from other jurisdictions is at your own risk and subject to applicable local laws."})]}),t.jsxs(_t,{n:3,title:"Account Registration",children:[t.jsx("p",{children:"You must create an account with a valid email address. You are responsible for maintaining the confidentiality of your account credentials and for all activity that occurs under your account."}),t.jsx("p",{children:"You agree to provide accurate and complete information when creating your account and to keep that information up to date. Time2Win Inc. reserves the right to suspend or terminate accounts that provide false or misleading information."}),t.jsx("p",{children:"You must verify your email address to activate your account. Unverified accounts may have limited functionality."})]}),t.jsxs(_t,{n:4,title:"Subscription and Billing",children:[t.jsx(os,{title:"Plans",children:t.jsx("p",{children:"AI Bookkeeping offers paid subscription plans (Starter, Growth, Pro) with different document upload limits and storage quotas. Plan details and pricing are displayed at app.ai-bookkeeping.ai/subscription and are subject to change with notice."})}),t.jsx(os,{title:"Free Trial",children:t.jsx("p",{children:"New accounts receive a free trial with access to 5 document uploads. No credit card is required to start the trial. You will not be charged unless you choose a paid plan."})}),t.jsx(os,{title:"Billing",children:t.jsx("p",{children:"Subscriptions are billed monthly. Payments are processed by Stripe. By providing payment information, you authorize Time2Win Inc. to charge your payment method for all subscription fees and applicable taxes. All prices are in Canadian dollars (CAD) and exclusive of applicable taxes."})}),t.jsx(os,{title:"Cancellation",children:t.jsx("p",{children:"You may cancel your subscription at any time through the billing portal in Settings. Cancellation takes effect at the end of the current billing period. No refunds are provided for unused portions of a billing period."})}),t.jsx(os,{title:"Price Changes",children:t.jsx("p",{children:"We may change subscription prices. We will provide at least 30 days' notice of any price increase via email. Your continued use of the service after the price change takes effect constitutes acceptance of the new price."})})]}),t.jsxs(_t,{n:5,title:"Acceptable Use",children:[t.jsx("p",{children:"You agree not to use AI Bookkeeping to:"}),t.jsxs("ul",{className:"list-disc pl-5 space-y-1.5",children:[t.jsx("li",{children:"Upload documents you do not own or have no right to process"}),t.jsx("li",{children:"Upload illegal, fraudulent, or falsified financial documents"}),t.jsx("li",{children:"Attempt to reverse-engineer, decompile, or extract source code from our service"}),t.jsx("li",{children:"Use automated bots or scripts to upload documents at a rate that exceeds normal human use"}),t.jsx("li",{children:"Attempt to gain unauthorized access to other users' accounts or our systems"}),t.jsx("li",{children:"Resell or sublicense access to the service without our written consent"}),t.jsx("li",{children:"Violate any applicable law or regulation"})]})]}),t.jsxs(_t,{n:6,title:"Your Content",children:[t.jsx(os,{title:"Ownership",children:t.jsx("p",{children:"You retain full ownership of all documents and data you upload to AI Bookkeeping. We do not claim any ownership rights over your content."})}),t.jsx(os,{title:"License",children:t.jsx("p",{children:"By uploading content to AI Bookkeeping, you grant Time2Win Inc. a limited, non-exclusive, royalty-free license to process, store, and display your content solely for the purpose of providing the service to you."})}),t.jsx(os,{title:"AI Processing",children:t.jsx("p",{children:"Your uploaded documents are transmitted to Anthropic's Claude API for AI-assisted data extraction. By using our service, you consent to this processing. We do not use your documents to train AI models. Anthropic's data processing is governed by their terms of service."})}),t.jsx(os,{title:"Human Review",children:t.jsx("p",{children:"We do not have human staff review your financial documents as part of normal service operations. However, in limited cases (e.g., investigating reported errors or legal requests), authorized Time2Win Inc. personnel may review relevant content."})})]}),t.jsx(_t,{n:7,title:"Intellectual Property",children:t.jsx("p",{children:"AI Bookkeeping, including its software, design, logos, and content (excluding your uploaded documents), is owned by Time2Win Inc. and protected by intellectual property laws. You may not copy, modify, distribute, or create derivative works of our service or content without our express written consent."})}),t.jsxs(_t,{n:8,title:"Disclaimer of Warranties",children:[t.jsx("p",{children:'AI Bookkeeping is provided "as is" and "as available" without warranties of any kind, either express or implied. We do not warrant that the service will be error-free, uninterrupted, or that AI-extracted data will be accurate or complete.'}),t.jsx("p",{children:"The service does not constitute professional accounting, tax, legal, or financial advice. You should consult a qualified professional for advice specific to your situation."})]}),t.jsxs(_t,{n:9,title:"Limitation of Liability",children:[t.jsx("p",{children:"To the maximum extent permitted by applicable law, Time2Win Inc. shall not be liable for any indirect, incidental, special, consequential, or punitive damages, including loss of profits, data, or business opportunities, arising from your use of or inability to use the service."}),t.jsx("p",{children:"Our total liability to you for any claim arising from these Terms or your use of the service shall not exceed the amount you paid to us in the 12 months preceding the claim."})]}),t.jsx(_t,{n:10,title:"Indemnification",children:t.jsx("p",{children:"You agree to indemnify, defend, and hold harmless Time2Win Inc. and its officers, directors, employees, and agents from and against any claims, liabilities, damages, losses, and expenses (including reasonable legal fees) arising out of or in any way connected with your use of the service, your violation of these Terms, or your violation of any third-party right."})}),t.jsx(_t,{n:11,title:"Third-Party Services",children:t.jsx("p",{children:"AI Bookkeeping integrates with third-party services including Stripe, Anthropic, SendGrid, and Telegram. These services are governed by their own terms of service and privacy policies. Time2Win Inc. is not responsible for the practices of third-party services."})}),t.jsx(_t,{n:12,title:"Service Availability",children:t.jsx("p",{children:"We aim to provide a reliable service but do not guarantee 100% uptime. We may suspend or discontinue the service or features at any time, with or without notice, for maintenance, updates, or other operational reasons. We will make reasonable efforts to provide advance notice of planned downtime."})}),t.jsxs(_t,{n:13,title:"Termination",children:[t.jsx("p",{children:"You may close your account at any time. We may suspend or terminate your account if you violate these Terms, engage in fraudulent activity, or for any other reason at our discretion with reasonable notice where practicable."}),t.jsx("p",{children:"Upon termination, your right to use the service ceases immediately. We will delete or anonymize your data within 30 days, except where we are required by law to retain it."})]}),t.jsxs(_t,{n:14,title:"Governing Law and Dispute Resolution",children:[t.jsx("p",{children:"These Terms are governed by the laws of the Province of Ontario and the federal laws of Canada applicable therein, without regard to conflict of law principles."}),t.jsx("p",{children:"Any dispute arising from these Terms or your use of the service shall first be addressed through good-faith negotiation. If unresolved, disputes shall be submitted to binding arbitration in accordance with the Arbitration Act (Ontario). Class actions and jury trials are waived to the extent permitted by law."})]}),t.jsx(_t,{n:15,title:"Changes to These Terms",children:t.jsx("p",{children:"We may update these Terms from time to time. We will notify you of material changes via email and/or a notice within the app at least 14 days before the changes take effect. Your continued use of the service after the effective date constitutes your acceptance of the updated Terms."})}),t.jsx(_t,{n:16,title:"Miscellaneous",children:t.jsx("p",{children:"These Terms constitute the entire agreement between you and Time2Win Inc. regarding your use of the service. If any provision is found unenforceable, the remaining provisions will remain in full force. Our failure to enforce any right or provision does not constitute a waiver. You may not assign your rights under these Terms without our written consent."})}),t.jsxs(_t,{n:17,title:"Contact Us",children:[t.jsx("p",{children:"If you have questions about these Terms, please contact us:"}),t.jsxs("div",{className:"mt-3 bg-gray-50 rounded-lg px-5 py-4 text-sm",children:[t.jsx("p",{className:"font-semibold text-gray-900",children:"Time2Win Inc."}),t.jsxs("p",{className:"mt-1",children:["Email:"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-[#0066FF] hover:underline",children:"[email protected]"})]})]})]})]}),t.jsxs("p",{className:"text-center text-xs text-gray-400 mt-8",children:["© 2026 Time2Win Inc. ·"," ",t.jsx(Fe,{to:"/privacy-policy",className:"hover:underline",children:"Privacy Policy"})]})]}),t.jsx(Dd,{})]}),yR=["Groceries","Meals & Entertainment","Office Supplies","Travel & Transportation","Fuel & Vehicle","S
97oftware & Subscriptions","Professional Services","Utilities & Communications","Advertising & Marketing","Insurance","Other Business Expenses"],bR=[".jpg",".jpeg",".png",".gif",".webp"];function vR(e){if(!e)return!1;const n=e.split("?")[0].toLowerCase();return bR.some(s=>n.endsWith(s))}function jR(e){return(e.extracted_data??[]).find(n=>n.description!=="_total")??null}function wR(e){return(e.extracted_data??[]).find(n=>n.description==="_total")??null}function NR(e){if(e.corrected_data){const l=e.corrected_data;return{vendor:l.vendor??"",date:l.date??"",category:l.category??"",currency:l.currency??"CAD",description:l.description??"",subtotal:l.subtotal!=null?String(l.subtotal):"",taxes:l.taxes!=null?String(l.taxes):"",tip:l.tip!=null?String(l.tip):"",total:l.total!=null?String(l.total):"",reviewer_notes:e.reviewer_notes??""}}const n=jR(e),s=wR(e),o=(e.extracted_data??[]).filter(l=>l.description!=="_total").reduce((l,d)=>l+(typeof d.amount=="number"?d.amount:0),0);return{vendor:(n==null?void 0:n.vendor)??"",date:(n==null?void 0:n.date)??"",category:(n==null?void 0:n.category)??"",currency:(n==null?void 0:n.currency)??"CAD",description:(n==null?void 0:n.description)??"",subtotal:o>0?o.toFixed(2):"",taxes:"0.00",tip:"0.00",total:(s==null?void 0:s.amount)!=null?String(s.amount):o>0?o.toFixed(2):"",reviewer_notes:e.reviewer_notes??""}}function yw(e){const n=new Date(e);return isNaN(n.getTime())?e:n.toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"})}const _R={pending_review:{label:"Pending",cls:"bg-amber-50 text-amber-700 ring-amber-200"},approved:{label:"Approved",cls:"bg-emerald-50 text-emerald-700 ring-emerald-200"},corrected:{label:"Corrected",cls:"bg-blue-50 text-blue-700 ring-blue-200"}},bw=({status:e})=>{const{label:n,cls:s}=_R[e]??{label:e,cls:"bg-gray-100 text-gray-600 ring-gray-200"};return t.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium ring-1 ring-inset ${s}`,children:n})},Yn=({children:e})=>t.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1",children:e}),Gn="w-full rounded-lg border border-gray-200 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition bg-white",kR=({doc:e})=>e?e.file_url?vR(e.file_url)?t.jsx("div",{className:"flex-1 overflow-hidden bg-gray-100 flex items-center justify-center",children:t.jsx("img",{src:e.file_url,alt:e.name,className:"max-h-full max-w-full object-contain"})}):t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx("iframe",{src:e.file_url,title:e.name,className:"w-full h-full border-0"})}):t.jsx("div",{className:"flex-1 flex items-center justify-center bg-gray-100",children:t.jsx("p",{className:"text-sm text-gray-400",children:"No file attached"})}):t.jsx("div",{className:"flex-1 flex items-center justify-center bg-gray-100",children:t.jsx("p",{className:"text-sm text-gray-400",children:"Select a document to preview"})}),SR=({doc:e,onApprove:n,onCorrect:s,saving:a})=>{const[o,l]=x.useState(null);x.useEffect(()=>{l(e?NR(e):null)},[e==null?void 0:e.id]),x.useEffect(()=>{if(!o)return;const u=parseFloat(o.subtotal)||0,p=parseFloat(o.taxes)||0,h=parseFloat(o.tip)||0,f=(u+p+h).toFixed(2);o.total!==f&&l(g=>g&&{...g,total:f})},[o==null?void 0:o.subtotal,o==null?void 0:o.taxes,o==null?void 0:o.tip]);const d=u=>p=>l(h=>h&&{...h,[u]:p.target.value});return!e||!o?t.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 flex items-center justify-center bg-gray-50",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:t.jsx("svg",{className:"w-8 h-8 text-gray-300",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.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"})})}),t.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Select a document from the queue"})]})})}):t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 border-b border-gray-100 bg-white shrink-0 flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:e.name}),t.jsxs("p",{className:"text-xs text-gray-400",children:[e.owner_email," · ",yw(e.created_at)]})]}),t.jsx(bw,{status:e.review_status})]}),t.jsx("div",{className:"h-[45%] shrink-0 flex flex-col overflow-hidden border-b border-gray-100",children:t.jsx(kR,{doc:e})}),t.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:t.jsxs("div",{className:"px-6 py-5 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Yn,{children:"Vendor"}),t.jsx("input",{type:"text",value:o.vendor,onChange:d("vendor"),placeholder:"Store or business name",className:Gn})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Date"}),t.jsx("input",{type:"date",value:o.date,onChange:d("date"),className:Gn})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(Yn,{children:"Category"}),t.jsxs("select",{value:o.category,onChange:d("category"),className:Gn,children:[t.jsx("option",{value:"",children:"— Select category —"}),yR.map(u=>t.jsx("option",{value:u,children:u},u))]})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Currency"}),t.jsx("input",{type:"text",value:o.currency,onChange:d("currency"),placeholder:"CAD",maxLength:3,className:Gn})]})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Description"}),t.jsx("input",{type:"text",value:o.description,onChange:d("description"),placeholder:"Brief description",className:Gn})]}),t.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx(Yn,{children:"Subtotal"}),t.jsx("input",{type:"number",step:"0.01",min:"0",value:o.subtotal,onChange:d("subtotal"),placeholder:"0.00",className:Gn})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Taxes"}),t.jsx("input",{type:"number",step:"0.01",min:"0",value:o.taxes,onChange:d("taxes"),placeholder:"0.00",className:Gn})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Tip"}),t.jsx("input",{type:"number",step:"0.01",min:"0",value:o.tip,onChange:d("tip"),placeholder:"0.00",className:Gn})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Total"}),t.jsx("input",{type:"number",step:"0.01",min:"0",value:o.total,onChange:d("total"),placeholder:"0.00",className:`${Gn} font-semibold`})]})]}),t.jsxs("div",{children:[t.jsx(Yn,{children:"Reviewer Notes"}),t.jsx("textarea",{value:o.reviewer_notes,onChange:d("reviewer_notes"),rows:2,placeholder:"Optional notes about this document…",className:`${Gn} resize-none`})]})]})}),t.jsxs("div",{className:"shrink-0 px-6 py-4 border-t border-gray-100 bg-white flex gap-3",children:[t.jsxs("button",{onClick:()=>n(e.id),disabled:a,className:"flex-1 flex items-center justify-center gap-2 rounded-lg bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:[a?t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
97ded-full animate-spin"}):"✓","Approve"]}),t.jsxs("button",{onClick:()=>s(e.id,o),disabled:a,className:"flex-1 flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-4 py-2.5 text-sm font-semibold text-white transition-colors",children:[a?t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):"💾","Save Corrections"]})]})]})},CR=()=>{var S,T,E;const e=Xe(),n=ht(A=>A.auth),s=((T=(S=n.user)==null?void 0:S.user)==null?void 0:T.is_staff)??((E=n.user)==null?void 0:E.is_staff)??!1,[a,o]=x.useState([]),[l,d]=x.useState(null),[u,p]=x.useState("pending"),[h,f]=x.useState(!0),[g,b]=x.useState(!1);x.useEffect(()=>{!n.inProgress&&!s&&e("/dashboard",{replace:!0})},[n.inProgress,s,e]);const v=x.useCallback(()=>{const A=u==="pending"?"/api/reviewer/queue/":"/api/reviewer/queue/all/";f(!0),te.get(A).then(I=>{Array.isArray(I==null?void 0:I.data)&&(o(I.data),d(R=>R?I.data.find(W=>W.id===R.id)??null:null))}).finally(()=>f(!1))},[u]);x.useEffect(()=>{v()},[v]);const N=A=>{if(o(I=>I.map(R=>R.id===A.id?A:R)),u==="pending"){const I=a.filter(R=>R.id!==A.id);d(I[0]??null),o(I)}else d(A)},w=async A=>{b(!0);try{const I=await te.post(`/api/reviewer/documents/${A}/approve/`);I!=null&&I.data&&N(I.data)}finally{b(!1)}},k=async(A,I)=>{b(!0);try{const R={vendor:I.vendor||void 0,date:I.date||void 0,category:I.category||void 0,currency:I.currency||"CAD",description:I.description||void 0,subtotal:parseFloat(I.subtotal)||0,taxes:parseFloat(I.taxes)||0,tip:parseFloat(I.tip)||0,total:parseFloat(I.total)||0},W=await te.post(`/api/reviewer/documents/${A}/correct/`,{corrected_data:R,reviewer_notes:I.reviewer_notes||null});W!=null&&W.data&&N(W.data)}finally{b(!1)}},_=a.filter(A=>A.review_status==="pending_review").length;return n.inProgress?null:t.jsxs("div",{className:"flex h-full overflow-hidden bg-white",children:[t.jsxs("div",{className:"w-[30%] shrink-0 border-r border-gray-100 flex flex-col overflow-hidden bg-white",children:[t.jsxs("div",{className:"px-5 pt-5 pb-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900",children:"Review Queue"}),_>0&&t.jsx("span",{className:"inline-flex items-center justify-center rounded-full bg-[#0066FF] text-white text-xs font-bold px-2 py-0.5 min-w-[22px]",children:_})]}),t.jsx("div",{className:"flex rounded-lg border border-gray-200 p-0.5 bg-gray-50",children:["pending","all"].map(A=>t.jsx("button",{onClick:()=>p(A),className:`flex-1 rounded-md py-1.5 text-xs font-semibold transition-colors ${u===A?"bg-white text-gray-900 shadow-sm":"text-gray-400 hover:text-gray-700"}`,children:A==="pending"?"Pending":"All"},A))})]}),t.jsx("div",{className:"flex-1 overflow-y-auto px-3 pb-4 space-y-1",children:h?Array.from({length:5}).map((A,I)=>t.jsxs("div",{className:"rounded-xl p-4 space-y-2",children:[t.jsx("div",{className:"h-3.5 w-3/4 bg-gray-100 rounded animate-pulse"}),t.jsx("div",{className:"h-3 w-1/2 bg-gray-100 rounded animate-pulse"})]},I)):a.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-48 gap-3",children:[t.jsx("div",{className:"text-3xl",children:"🎉"}),t.jsx("p",{className:"text-sm font-medium text-gray-600",children:"All caught up!"}),t.jsx("p",{className:"text-xs text-gray-400",children:"No documents to review."})]}):a.map(A=>t.jsxs("button",{onClick:()=>d(A),className:`w-full text-left rounded-xl px-4 py-3.5 transition-colors ${(l==null?void 0:l.id)===A.id?"bg-[#0066FF]/8 ring-1 ring-[#0066FF]/30":"hover:bg-gray-50"}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate leading-tight",children:A.name}),t.jsx(bw,{status:A.review_status})]}),t.jsx("p",{className:"text-xs text-gray-400 truncate",children:A.owner_email}),t.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:yw(A.created_at)})]},A.id))})]}),t.jsx(SR,{doc:l,onApprove:w,onCorrect:k,saving:g})]})},ER="/assets/dashboard-illustrative-CkGSUsMR.webp",kf=1,vw=4,Zl=.5,Bi=e=>Math.min(vw,Math.max(kf,e)),AR=({src:e,alt:n,caption:s,onClose:a})=>{const[o,l]=x.useState(kf),d=x.useRef(null),u=x.useRef(null),p=x.useRef(null);x.useEffect(()=>{var N;p.current=document.activeElement,(N=u.current)==null||N.focus();const{body:f}=document,g=f.style.overflow,b=f.style.paddingRight,v=window.innerWidth-document.documentElement.clientWidth;return f.style.overflow="hidden",v>0&&(f.style.paddingRight=`${v}px`),()=>{var w,k;f.style.overflow=g,f.style.paddingRight=b,(k=(w=p.current)==null?void 0:w.focus)==null||k.call(w)}},[]),x.useEffect(()=>{const f=g=>{var w,k;if(g.key==="Escape"){g.preventDefault(),a();return}if(g.key==="+"||g.key==="="){g.preventDefault(),l(_=>Bi(_+Zl));return}if(g.key==="-"){g.preventDefault(),l(_=>Bi(_-Zl));return}if(g.key!=="Tab")return;const b=(w=d.current)==null?void 0:w.querySelectorAll("button");if(!b||b.length===0)return;const v=b[0],N=b[b.length-1];g.shiftKey&&document.activeElement===v?(g.preventDefault(),N.focus()):!g.shiftKey&&document.activeElement===N?(g.preventDefault(),v.focus()):(k=d.current)!=null&&k.contains(document.activeElement)||(g.preventDefault(),v.focus())};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)}
97,[a]),x.useEffect(()=>{const f=d.current;if(!f)return;const g=b=>{b.preventDefault(),l(v=>Bi(v-Math.sign(b.deltaY)*.25))};return f.addEventListener("wheel",g,{passive:!1}),()=>f.removeEventListener("wheel",g)},[]);const h=f=>f.stopPropagation();return t.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-label":n,onClick:a,className:"fixed inset-0 z-[100] flex flex-col items-center justify-center bg-black/85 p-4 backdrop-blur-sm",children:[t.jsxs("div",{className:"absolute right-4 top-4 flex items-center gap-2",onClick:h,children:[t.jsx("button",{type:"button","aria-label":"Zoom out",onClick:()=>l(f=>Bi(f-Zl)),disabled:o<=kf,className:"h-10 w-10 rounded-lg bg-white/10 text-xl font-semibold text-white transition hover:bg-white/20 disabled:opacity-40",children:"−"}),t.jsx("button",{type:"button","aria-label":"Zoom in",onClick:()=>l(f=>Bi(f+Zl)),disabled:o>=vw,className:"h-10 w-10 rounded-lg bg-white/10 text-xl font-semibold text-white transition hover:bg-white/20 disabled:opacity-40",children:"+"}),t.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,className:"h-10 w-10 rounded-lg bg-white/10 text-xl font-semibold text-white transition hover:bg-white/20",children:"×"})]}),t.jsx("div",{className:"max-h-full max-w-full overflow-auto",onClick:h,children:t.jsx("img",{src:e,alt:n,style:{transform:`scale(${o})`,transformOrigin:"center center"},className:"max-h-[80vh] w-auto max-w-full rounded-lg transition-transform duration-150"})}),s&&t.jsx("p",{className:"mt-4 text-center text-sm text-white/70",onClick:h,children:s})]})},TR=({src:e,alt:n,width:s,height:a,caption:o,className:l="",imgClassName:d="",loading:u="lazy"})=>{const[p,h]=x.useState(!1),[f,g]=x.useState(!1);x.useEffect(()=>g(!0),[]);const b=x.useCallback(()=>h(!1),[]),v=t.jsx("img",{src:e,alt:n,width:s,height:a,loading:u,decoding:"async",className:d});return t.jsxs("figure",{className:l,children:[f?t.jsx("button",{type:"button",onClick:()=>h(!0),"aria-label":`${n} — click to enlarge`,className:"block h-full w-full cursor-zoom-in",children:v}):v,o&&t.jsx("figcaption",{className:"mt-3 text-center text-sm text-gray-500",children:o}),f&&p&&t.jsx(AR,{src:e,alt:n,caption:o,onClose:b})]})},ls="#F9FAFB",LR=JSON.stringify({"@context":"https://schema.org","@type":"SoftwareApplication",name:"AI Bookkeeping",applicationCategory:"BusinessApplication",operatingSystem:"Web",url:"https://www.ai-bookkeeping.ai/",description:"Bookkeeping done for you. Receipt Automation reads and categorizes your documents; the Bookkeeping Service maintains real double-entry books with bank and card connections, financial statements, and human bookkeeper review of every uncertain entry.",offers:[{"@type":"Offer",name:"Receipt Automation — Starter",price:"29",priceCurrency:"CAD"},{"@type":"Offer",name:"Receipt Automation — Growth",price:"49",priceCurrency:"CAD"},{"@type":"Offer",name:"Receipt Automation — Pro",price:"69",priceCurrency:"CAD"},{"@type":"Offer",name:"Bookkeeping Service — Starter",price:"99",priceCurrency:"CAD"},{"@type":"Offer",name:"Bookkeeping Service — Growth",price:"199",priceCurrency:"CAD"},{"@type":"Offer",name:"Bookkeeping Service — Pro",price:"399",priceCurrency:"CAD"}]}),ec="#1A1F36",qe="#111827",fr="#0066FF",jw="'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace",ww="You run the business.",Nw="We keep the books.",RR=`${ww} ${Nw}`,IR=`AI Bookkeeping — ${RR}`,Rt="mx-auto w-full max-w-[1200px] px-5 sm:px-8",Tn="pt-14 sm:pt-[88px]",PR=["Upload from the web app or send to the Telegram bot","AI extracts vendor, date, totals, taxes, and line items","Automatic business expense categorization and GST/HST tracking","Reports and a full-year Excel workbook for your accountant"],FR=["Everything in Receipt Automation, plus complete books","Bank, card, and Stripe connections, with reconciliation","Human reviewer resolves anything the AI cannot settle","Profit & Loss, Balance Sheet, tax and cash-flow views","Invite your accountant, or hand them the reports"],DR=[{title:"Any photo quality",body:"Crumpled, dim, angled — the AI reads it. JPEG, PNG, WebP, HEIC, and PDF."},{title:"Vendor names cleaned",body:'"COSTCO WHSE #556" becomes Costco Wholesale, consistently across reports.'},{title:"Tax amounts separated",body:"Recoverable GST/HST is split out on each receipt, so credits aren't missed."},{title:"CRA-aligned categories",body:"Expenses land in categories that map to CRA expense reporting."},{title:"Reports and Excel",body:"Expense-by-category and GST/HST summaries, plus an annual .xlsx workbook."},{title:"Full manual control",body:"Edit any extracted record in the edit drawer or workbook view. Nothing is a black box."}],OR=[{n:"01",who:"You",bg:"rgba(255,255,255,0.1)",fg:"#E5E7EB",title:"Upload and connect",body:"Send receipts, supplier invoices, and client invoices from the web app or the Telegram bot — and connect your bank, cards, and Stripe so transactions arrive on their own."},{n:"02",who:"AI",bg:"rgba(251,191,36,0.14)",fg:"#FCD34D",title:"AI bookkeeping",body:"The AI extracts the information, determines the accounting treatment, and prepares the bookkeeping records."},{n:"03",who:"Platform",bg:"rgba(0,102,255,0.18)",fg:"#93C5FD",title:"Accounting rules",body:"Deterministic controls validate the proposed treatment. Debits must equal credits, accounts must be real. Anything that fails does not post."},{n:"04",who:"Our staff",bg:"rgba(16,185,129,0.16)",fg:"#6EE7B7",title:"Human review when needed",body:"Transactions the system cannot confidently resolve are checked against the source document and corrected by a human bookkeeping reviewer."},{n:"05",who:"Platform",bg:"rgba(0,102,255,0.18)",fg:"#93C5FD",title:"Books stay current",body:"Records, reports, tax information, receivables, and payables stay organized throughout the year — not rebuilt in March."},{n:"06",who:"You + accountant",bg:"rgba(255,255,255,0.1)",fg:"#E5E7EB",title:"Accountant ready",body:"Invite your accountant to their own workspace, or download the completed reports and hand them over at tax time."}],Tb=[{label:"Document arrives",sub:"Receipt, invoice, or connected transaction"},{label:"AI prepares the entry",sub:"Extraction, treatment, and a confidence assessment"},{label:"Accounting rules validate",sub:"Deterministic checks, not a model"},{label:"Posted to your books",sub:"Balanced, with the source document attached"}],Lb=[{label:"Document arrives",sub:"Or a large-value transaction of any confidence",bg:"rgba(255,255,255,0.05)",border:"rgba(255,255,255,0.12)"},{label:"AI prepares the entry",sub:"The AI is built to escalate rather than guess",bg:"rgba(255,255,255,0.05)",border:"rgba(255,255,255,0.12)"},{label:"Accounting rules flag it",sub:"Uncertain, ambiguous, or rule-flagged — it does not post",bg:"rgba(255,255,255,0.05)",border:"rgba(255,255,255,0.12)"},{label:"Human reviewer takes it",sub:"Trained platform staff open the source document and decide",bg:"rgba(251,191,36,0.12)",border:"rgba(251,191,36,0.35)"},{label:"Corrected entry posts",sub:"Through the same accounting engine — nobody bypasses the rules",bg:"rgba(0,102,255,0.14)",border:"rgba(59,130,246,0.4)"}
97],$R=[{title:"Cash",body:"What you actually have across your connected business accounts."},{title:"Revenue",body:"What the business has earned, period over period."},{title:"Expenses",body:"Where the money went, grouped the way your accountant expects."},{title:"Profit",body:"Profit to date and by fiscal quarter, from real books."},{title:"Money customers owe you",body:"Client balances and aging, with statements of account."},{title:"Money you owe",body:"Supplier balances and aging, so nothing is a surprise."},{title:"Taxes",body:"Tax collected against credits for the current filing period, with CRA GST/HST deadlines tracked."},{title:"Reports",body:"Profit & Loss and Balance Sheet as of any date, downloadable and printable."}],MR=[{title:"Secure document handling",body:"Financial documents are held in private storage reached only through expiring signed links. No public file URLs."},{title:"AI output is validated",body:"No AI-proposed entry reaches your books without passing deterministic accounting rules first."},{title:"Human review of uncertainty",body:"Entries the system can't confidently resolve are decided by trained staff, not posted on a guess."},{title:"Immutable audit trail",body:"Nothing is edited in place. Corrections post as new linked entries, and every financial action is logged with who and when."},{title:"Account permissions",body:"Owner, external accountant, and internal reviewer roles each see exactly what they should — no more."},{title:"Data isolation",body:"Every organization's data is walled off, with permission rules covered by deny-path testing."},{title:"Secure bank connections",body:"Bank and credit-card connections run through Plaid. The platform never sees your banking credentials."},{title:"Deletion and retention",body:"When you delete a document or your account, the underlying files are erased from storage. Where the law requires specific records to be kept, they are retained for that period and no longer."}],BR=[{name:"Starter",price:"$99",docs:"150 docs",note:"For owner-operated businesses with steady, modest volume.",tag:"",dark:!1},{name:"Growth",price:"$199",docs:"250 docs",note:"For growing businesses with suppliers, clients, and regular invoicing.",tag:"Most chosen",dark:!0},{name:"Pro",price:"$399",docs:"500 docs",note:"For higher-volume businesses that want everything maintained.",tag:"",dark:!1}],UR=[{name:"Starter",price:"$29",docs:"100 documents per month",storage:"1 GB storage"},{name:"Growth",price:"$49",docs:"300 documents per month",storage:"5 GB storage"},{name:"Pro",price:"$69",docs:"500 documents per month",storage:"20 GB storage"}],zR=[{label:"AI document processing",a:"Included",b:"Included"},{label:"Automatic categorization",a:"Expense categories",b:"Full accounting treatment"},{label:"GST/HST tracking",a:"Input tax credits on receipts",b:"Tax collected, credits, and filing periods"},{label:"Full double-entry books",a:"Not included",b:"Included",aMuted:!0},{label:"Human review of uncertain entries",a:"Not included",b:"Trained reviewers on our staff",aMuted:!0},{label:"Bank and credit-card connections",a:"Not included",b:"Included, via Plaid",aMuted:!0},{label:"Stripe connection",a:"Not included",b:"Revenue and processing fees posted automatically",aMuted:!0},{label:"Reconciliation",a:"Not included",b:"Handled for you",aMuted:!0},{label:"Financial statements",a:"Expense and tax reports",b:"Profit & Loss and Balance Sheet"},{label:"Receivables and payables",a:"Not included",b:"Client and supplier balances with aging",aMuted:!0},{label:"Financial visibility dashboard",a:"Expense summaries",b:"Cash, profit, taxes, and cash flow"},{label:"Accountant access",a:"Share exported files",b:"Their own workspace, by invitation"},{label:"Tax-time reporting",a:"Annual Excel workbook",b:"Full report package, plus workspace access"},{label:"Excel export",a:"Included",b:"Included"},{label:"Free trial",a:"5 documents, no credit card",b:"15 days, no credit card"},{label:"Monthly price",a:"$29 – $69 CAD/USD",b:"$99 – $399 CAD/USD"}],WR=[{title:"Contractors and trades",body:"Receipts from the lumber yard, the gas station, and the supply house — handled without an evening of typing."},{title:"Small businesses",body:"Real books maintained during the year instead of reconstructed under deadline."},{title:"Startups",body:"A clean, auditable history from day one, for the diligence conversation later."},{title:"Owner-operated companies",body:"Incorporated, mixing personal and business cards, and short on time for any of it."},{title:"Already have an accountant",body:"Keep them. We keep the books current so their work starts from finished records."}],Rb=[["What is the difference between Receipt Automation and the Bookkeeping Service?","Receipt Automation processes your documents: it extracts, categorizes, and organizes receipts and supplier invoices, then gives you expense records, tax summaries, and Excel exports. The Bookkeeping Service goes further and maintains your books — double-entry records, reconciliation, financial statements, tax information, receivables and payables — with human review of anything the AI cannot resolve confidently."],["Do I need to know bookkeeping?","No. The Bookkeeping Service is designed so you never choose accounts, write journal entries, or reconcile anything. You send documents and read the results in plain business language."],["Do I have to categorize my own expenses?","No. The AI determines the accounting treatment and our accounting rules validate it. On Receipt Automation you can edit any extracted record if you want to, but nothing requires it."],["What happens if the AI isn't sure?","The entry does not post. It goes to a review queue where a human bookkeeping reviewer on our staff opens the source document, decides the correct treatment, and posts it through the same accounting engine. Large-value entries are routed to review regardless of confidence."],["Is a human involved?","Yes, on the Bookkeeping Service. Trained reviewers on our staff work the review queue. You never see that queue, and you are never asked to resolve an entry yourself."],["Can I keep my existing accountant?","Yes, and you should. The platform keeps your books organized during the year; your accountant does the accountant work. It does not replace them."],["Can I invite my accountant?","Yes. On the Bookkeeping Service you invite your accountant by email and they get their own workspace with access to your records and reports. Invites are single-use, matched to their email address, and expire after seven days."],["What do I give my accountant at tax time?","Either access or a package. Invite them to the platform, or generate, download, and print the financial reports and tax information they need. Receipt Automation customers hand over categorized expense reports and the annual Excel workbook."],["Does the platform prepare my tax return?","No. AI Bookkeeping prepares bookkeeping records and the reports behind them. It does not file returns and does not provide tax, legal, or financial advice."],["What happens when I exceed my document allowance?","Each plan includes a document allowance. If your volume regularly runs past it, move up a plan — contact support and we'll help you pick the right one."],["Do I need to connect my bank?","Bank and credit-card connections are part of the Bookkeeping Service and run through Plaid, so we never see your banking credentials. You can also connect Stripe, and your revenue and processing fees are posted into your books automatically."],["Is a credit card required for the trial?","No. The Bookkeeping Service tri
97al runs 15 days with no credit card. Receipt Automation's free trial covers 5 documents, also with no credit card."]],cs=({children:e,tone:n="muted"})=>t.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.1em]",style:{color:n==="muted"?"#6B7280":"#93C5FD"},children:e}),Ln=({children:e,bg:n="transparent",color:s,border:a,size:o="sm",className:l=""})=>t.jsx("span",{className:`inline-flex items-center rounded-full font-semibold uppercase ${o==="sm"?"px-3 py-[5px] text-[11px] tracking-[0.1em]":"px-[10px] py-[3px] text-[10.5px] tracking-[0.08em]"} ${l}`,style:{background:n,color:s,border:a?`1px solid ${a}`:void 0},children:e}),tc=({children:e,color:n,className:s=""})=>t.jsx("div",{className:`text-[11px] tracking-[0.06em] ${s}`,style:{fontFamily:jw,color:n},children:e}),Ib=({dark:e=!1})=>t.jsx("img",{src:dt,alt:"AI Bookkeeping",width:140,height:32,className:`h-8 w-auto${e?" brightness-0 invert":""}`}),Pb=({color:e})=>t.jsx("span",{className:"flex-none",style:{color:e},"aria-hidden":"true",children:"✓"}),HR=()=>{const[e,n]=x.useState(!1),[s,a]=x.useState(0);x.useEffect(()=>{const d=document.title;return document.title=IR,()=>{document.title=d}},[]);const o=d=>{var u;(u=document.getElementById(d))==null||u.scrollIntoView({behavior:"smooth"}),n(!1)},l=[{label:"Receipt Automation",id:"receipts"},{label:"Bookkeeping Service",id:"bookkeeping"},{label:"How it works",id:"how"},{label:"Pricing",id:"pricing"},{label:"Security",id:"security"}];return t.jsxs("div",{className:"min-h-screen font-sans",style:{background:ls,color:qe},children:[t.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:LR}}),t.jsxs("header",{className:"sticky top-0 z-50 border-b backdrop-blur-md",style:{background:"rgba(249,250,251,0.9)",borderColor:"#E5E7EB"},children:[t.jsxs("div",{className:`${Rt} flex items-center justify-between gap-6 py-3.5`,children:[t.jsx(be,{to:"/","aria-label":"AI Bookkeeping — home",children:t.jsx(Ib,{})}),t.jsxs("nav",{className:"hidden items-center gap-[22px] lg:flex",children:[l.map(d=>t.jsx("button",{type:"button",onClick:()=>o(d.id),className:"text-[13.5px] font-medium transition hover:text-gray-900",style:{color:"#4B5563"},children:d.label},d.label)),t.jsx(be,{to:"/login",className:"text-[13.5px] font-medium transition hover:text-gray-900",style:{color:"#4B5563"},children:"Login"}),t.jsx(be,{to:"/register",className:"rounded-full px-[18px] py-[9px] text-[13.5px] font-semibold text-white transition hover:bg-black",style:{background:qe},children:"Start free trial"})]}),t.jsx("button",{type:"button",className:"lg:hidden","aria-label":"Toggle menu","aria-expanded":e,onClick:()=>n(d=>!d),children:t.jsx("svg",{className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})})]}),e&&t.jsx("div",{className:"border-t px-5 py-4 lg:hidden",style:{borderColor:"#E5E7EB",background:ls},children:t.jsxs("div",{className:"flex flex-col gap-3",children:[l.map(d=>t.jsx("button",{type:"button",onClick:()=>o(d.id),className:"text-left text-sm font-medium",style:{color:"#374151"},children:d.label},d.label)),t.jsx(be,{to:"/login",className:"text-left text-sm font-medium",style:{color:"#374151"},children:"Login"}),t.jsx(be,{to:"/register",className:"rounded-full px-4 py-2.5 text-center text-sm font-semibold text-white",style:{background:qe},children:"Start free trial"})]})})]}),t.jsxs("main",{children:[t.jsx("section",{className:"text-white",style:{background:ec},children:t.jsxs("div",{className:`${Rt} grid items-center gap-10 pb-16 pt-14 sm:pb-[92px] sm:pt-[84px] lg:grid-cols-[1.02fr_0.98fr] lg:gap-[60px]`,children:[t.jsxs("div",{children:[t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full px-3.5 py-1.5 text-[12px] font-semibold uppercase tracking-[0.06em]",style:{background:"rgba(0,102,255,0.16)",border:"1px solid rgba(59,130,246,0.45)",color:"#93C5FD"},children:[t.jsx("span",{className:"block h-1.5 w-1.5 rounded-full",style:{background:"#3B82F6"},"aria-hidden":"true"}),"Two products, one platform"]}),t.jsxs("h1",{className:"mt-[22px] text-[36px] font-bold leading-[1.06] tracking-[-0.035em] text-balance sm:text-[46px] lg:text-[58px] lg:leading-[1.04]",children:[ww,t.jsx("br",{}),t.jsx("span",{style:{color:"#93C5FD"},children:Nw})]}),t.jsx("p",{className:"mt-[22px] max-w-[560px] text-[17px] leading-[1.6] sm:text-[19px]",style:{color:"#C7CBD8"},children:"Our AI reads your receipts and invoices, prepares the accounting, and keeps your books current. Deterministic accounting rules check every entry, and anything the AI cannot resolve confidently goes to a human bookkeeping reviewer on our staff. You never categorize a transaction."}),t.jsxs("div",{className:"mt-[34px] flex flex-wrap gap-3",children:[t.jsx(be,{to:"/register",className:"inline-flex items-center rounded-xl px-7 py-4 text-[16px] font-semibold text-white transition hover:opacity-90",style:{background:fr},children:"Start your 15-day free trial"}),t.jsx("button",{type:"button",onClick:()=>o("compare"),className:"inline-flex items-center rounded-xl px-6 py-4 text-[16px] font-medium text-white transition hover:border-white/55",style:{border:"1px solid rgba(255,255,255,0.24)"},children:"Compare the two products"})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-x-6 gap-y-2 text-[14px]",style:{color:"#8C93A8"},children:[t.jsx("span",{children:"15-day free trial on the Bookkeeping Service"}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:"No credit card required"}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:"Canada and United States"})]})]}),t.jsxs("div",{className:"rounded-[20px] p-3.5",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)"},children:[t.jsx("div",{className:"flex gap-1.5 px-2 pb-3 pt-1.5","aria-hidden":"true",children:[0,1,2].map(d=>t.jsx("span",{className:"block h-[9px] w-[9px] rounded-full",style:{background:"rgba(255,255,255,0.22)"}},d))}),t.jsx("div",{className:"relative h-[240px] overflow-hidden rounded-xl sm:h-[340px] lg:h-[430px]",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.12)"},children:t.jsx(TR,{src:ER,alt:"Bookkeeping Service dashboard",width:1120,height:798,loading:"eager",className:"absolute inset-0",imgClassName:"h-full w-full object-cover object-top"})}),t.jsx("div",{className:"px-2 pb-1 pt-3 text-[12px]",style:{color:"#8C93A8"},children:"Illustrative — demonstration data"})]})]})}),t.jsxs("section",{id:"products",className:`${Rt} ${Tn}`,children:[t.jsxs("div",{className:"max-w-[740px]",children:[t.jsx(cs,{children:"Choose the right product"}),t.jsx("h2",{className:"mt-3.5 text-[30px] font-bold leading-[1.12] tracking-[-0.03em] text-balance sm:text-[34px] lg:text-[40px]",children:"Two ways to stop doing data entry."}),t.jsx("p",{className:"mt-4 text-[17px] leading-[1.65] sm:text-[18px]",style:{color:"#4B5563"},children:"Both products read your documents with the same AI. The difference is where the work stops: one gives you organized records, the other maintains your books."})]}),t.jsxs("div",{className:"mt-10 grid gap-[22px] lg:grid-cols-2",children:[t.jsxs("div",{className:"flex flex-col rounded-[18px] bg-white p-7 sm:p-[34px]",style:{border:"1px solid #E5E7EB"},children:[t.jsx("div",{children:t.jsx(Ln,{bg:"#ECFDF5",color:"#047857",children:"Receipt Automation"})}),t.jsx("h3",{className:"mb-2.5 mt-5 text-[23px] font-bold tracking-[-0.025em] sm:text-[26px]",children:"Documents in, organized records out."}),t.jsx("p",{className:"mb-[22px] text-[16px] leading-[1.6]",style:{color:"#4B5563"},children:"Best for businesses that primarily want receipts and invoices extracted, categorized, and organized — with reports they can hand to their accountant."}),t.jsx("div",{className:"flex flex-col gap-3 py-5",style:{borderTop:"1px solid #F3F4F6"},children:PR.map(d=>t.jsxs("div",{className:"flex items-start gap-2.5 text-[15px] leading-[1.5]",style:{color:"#374151"},children:[t.jsx(Pb,{color:"#047857"}),t.jsx("span",{children:d})]},d))}),t.jsxs("div",{className:"mt-auto flex items-baseline gap-2 pt-4",style:{borderTop:"1px solid #F3F4F6"},children:[t.jsx("span",{className:"text-[15px]",style:{color:"#6B7280"},children:"From"}),t.jsx("span",{className:"text-[28px] font-bold tracking-[-0.03em]",children:"$29"}),t.jsx("span",{className:"text-[14px]",style:{color:"#6B7280"},children:"CAD/USD per month"})]}),t.jsx("button",{type:"button",onClick:()=>o("receipts"),className:"mt-[18px] w-full rounded-[11px] px-5 py-3.5 text-[15px] font-semibold transition hover:border-gray-900",style:{border:"1px solid #D1D5DB",color:qe},children:"Explore Receipt Automation"})]}),t.jsxs("div",{className:"flex flex-col rounded-[18px] p-7 text-white sm:p-[34px]",style:{background:qe},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[t.jsx(Ln,{bg:"rgba(0,102,255,0.18)",color:"#93C5FD",children:"Bookkeeping Service"}),t.jsx(Ln,{color:"#D1D5DB",border:"rgba(255,255,255,0.22)",size:"xs",children:"AI + human review"})]}),t.jsx("h3",{className:"mb-2.5 mt-5 text-[23px] font-bold tracking-[-0.025em] sm:text-[26px]",children:"We maintain your books all year."}),t.jsx("p",{className:"mb-[22px] text-[16px] leading-[1.6]",style:{color:"#C7CBD8"},children:"Best for businesses that want the platform to keep their books current using AI automation plus human review — so tax season is a handoff, not a rebuild."}),t.jsx("div",{className:"flex flex-col gap-3 py-5",style:{borderTop:"1px solid rgba(255,255,255,0.1)"},children:FR.map(d=>t.jsxs("div",{className:"flex items-start gap-2.5 text-[15px] leading-[1.5]",style:{color:"#E5E7EB"},children:[t.jsx(Pb,{color:"#3B82F6"}),t.jsx("span",{children:d})]},d))}),t.jsxs("div",{className:"mt-auto flex items-baseline gap-2 pt-4",style:{borderTop:"1px solid rgba(255,255,255,0.1)"},children:[t.jsx("span",{className:"text-[15px]",style:{color:"#9
97CA3AF"},children:"From"}),t.jsx("span",{className:"text-[28px] font-bold tracking-[-0.03em]",children:"$99"}),t.jsx("span",{className:"text-[14px]",style:{color:"#9CA3AF"},children:"CAD/USD per month"})]}),t.jsx("button",{type:"button",onClick:()=>o("bookkeeping"),className:"mt-[18px] w-full rounded-[11px] px-5 py-3.5 text-[15px] font-semibold text-white transition hover:opacity-90",style:{background:fr},children:"Explore the Bookkeeping Service"})]})]}),t.jsxs("div",{className:"mt-[22px] flex flex-wrap items-center gap-x-[18px] gap-y-2.5 rounded-[14px] bg-white px-[26px] py-5 text-[15px]",style:{border:"1px solid #F3F4F6",color:"#4B5563"},children:[t.jsx("strong",{className:"font-semibold",style:{color:qe},children:"In one line:"}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-semibold",style:{color:qe},children:"Receipt Automation"})," automates document processing."]}),t.jsx("span",{"aria-hidden":"true",style:{color:"#D1D5DB"},children:"|"}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-semibold",style:{color:qe},children:"Bookkeeping Service"})," maintains your books using AI plus human review."]})]})]}),t.jsx("section",{id:"receipts",className:`${Rt} ${Tn} scroll-mt-20`,children:t.jsx("div",{className:"rounded-[20px] bg-white p-6 shadow-sm sm:p-11",style:{border:"1px solid #F3F4F6"},children:t.jsxs("div",{className:"grid items-start gap-10 lg:grid-cols-[0.85fr_1.15fr] lg:gap-[52px]",children:[t.jsxs("div",{children:[t.jsx("div",{children:t.jsx(Ln,{bg:"#ECFDF5",color:"#047857",children:"Receipt Automation"})}),t.jsxs("h2",{className:"mt-[18px] text-[27px] font-bold leading-[1.14] tracking-[-0.03em] sm:text-[30px] lg:text-[34px]",children:["Photograph it once.",t.jsx("br",{}),"Never type it again."]}),t.jsx("p",{className:"mt-4 text-[16px] leading-[1.65] sm:text-[17px]",style:{color:"#4B5563"},children:"Upload a receipt or supplier invoice from the web app, or send it to the Telegram bot. The AI reads the vendor, date, totals, taxes, and line items — including from poor-quality phone photos — and assigns a business expense category. You get records and reports, not a data-entry task."}),t.jsxs("div",{className:"mt-[26px] grid gap-3.5 sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-xl p-4",style:{background:ls,border:"1px solid #F3F4F6"},children:[t.jsx(tc,{color:"#6B7280",children:"YOU UPLOAD"}),t.jsx("div",{className:"mt-2 text-[14px] leading-[1.55]",style:{color:"#374151"},children:"Receipts and supplier invoices as JPEG, PNG, WebP, HEIC, or PDF"})]}),t.jsxs("div",{className:"rounded-xl p-4",style:{background:ls,border:"1px solid #F3F4F6"},children:[t.jsx(tc,{color:"#6B7280",children:"YOU RECEIVE"}),t.jsx("div",{className:"mt-2 text-[14px] leading-[1.55]",style:{color:"#374151"},children:"Categorized expense records, tax summaries, and an Excel workbook"})]})]}),t.jsx(be,{to:"/pricing",className:"mt-[26px] inline-flex items-center rounded-[11px] px-6 py-3.5 text-[15px] font-semibold text-white transition hover:bg-black",style:{background:qe},children:"See Receipt Automation plans"}),t.jsx("p",{className:"mt-3 text-[13px]",style:{color:"#6B7280"},children:"Free trial — 5 documents, no credit card required."})]}),t.jsx("div",{children:t.jsx("div",{className:"grid gap-3.5 sm:grid-cols-2",children:DR.map(d=>t.jsxs("div",{className:"rounded-xl p-[18px]",style:{background:ls,border:"1px solid #F3F4F6"},children:[t.jsx("h3",{className:"mb-[7px] text-[15px] font-semibold tracking-[-0.01em]",children:d.title}),t.jsx("p",{className:"text-[13.5px] leading-[1.55]",style:{color:"#6B7280"},children:d.body})]},d.title))})})]})})}),t.jsx("section",{id:"bookkeeping",className:"mt-14 scroll-mt-20 py-14 text-white sm:mt-[88px] sm:py-[88px]",style:{background:qe},children:t.jsxs("div",{className:Rt,children:[t.jsxs("div",{className:"max-w-[760px]",children:[t.jsx("div",{children:t.jsx(Ln,{bg:"rgba(0,102,255,0.18)",color:"#93C5FD",children:"Bookkeeping Service"})}),t.jsxs("h2",{id:"how",className:"mt-5 scroll-mt-24 text-[31px] font-bold leading-[1.1] tracking-[-0.033em] sm:text-[36px] lg:text-[42px]",children:["You are not expected",t.jsx("br",{}),"to do the bookkeeping."]}),t.jsx("p",{className:"mt-[18px] text-[17px] leading-[1.65] sm:text-[18px]",style:{color:"#C7CBD8"},children:"This is a bookkeeping service delivered through software. Send documents; the platform and our reviewers do the rest. Here is the whole workflow."})]}),t.jsx("div",{className:"mt-11 grid gap-5 sm:grid-cols-2 lg:grid-cols-3",children:OR.map(d=>t.jsxs("div",{className:"rounded-2xl p-[26px]",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-[12px]",style:{fontFamily:jw,color:"#8C93A8"},children:d.n}),t.jsx(Ln,{bg:d.bg,color:d.fg,size:"xs",children:d.who})]}),t.jsx("h3",{className:"mb-2.5 mt-4 text-[19px] font-semibold tracking-[-0.02em] sm:text-[20px]",children:d.title}),t.jsx("p",{className:"text-[15px] leading-[1.6]",style:{color:"#9
97CA3AF"},children:d.body})]},d.n))}),t.jsxs("div",{className:"mt-[22px] rounded-2xl px-7 py-6",style:{background:"rgba(0,102,255,0.1)",border:"1px solid rgba(59,130,246,0.35)"},children:[t.jsx("strong",{className:"block text-[16px] font-semibold text-white",children:"One thing you never do:"}),t.jsx("span",{className:"mt-2 block text-[16px] leading-[1.6]",style:{color:"#C7CBD8"},children:"pick accounts, categorize transactions, write journal entries, or reconcile. That work belongs to the platform and our reviewers."})]})]})}),t.jsxs("section",{className:`${Rt} ${Tn}`,children:[t.jsxs("div",{className:"max-w-[740px]",children:[t.jsx(cs,{children:"AI + human review"}),t.jsxs("h2",{className:"mt-3.5 text-[30px] font-bold leading-[1.12] tracking-[-0.03em] text-balance sm:text-[34px] lg:text-[40px]",children:["Automation where it's reliable.",t.jsx("br",{}),"Human judgment where it's needed."]}),t.jsx("p",{className:"mt-4 text-[17px] leading-[1.65] sm:text-[18px]",style:{color:"#4B5563"},children:"The AI does not post uncertain accounting entries. Every proposed entry passes a deterministic rules layer first, and anything the system cannot resolve confidently goes to a human bookkeeping reviewer on our staff, who checks the source document and corrects the treatment before it reaches your books."})]}),t.jsxs("div",{className:"mt-10 grid gap-[22px] lg:grid-cols-2",children:[t.jsxs("div",{className:"rounded-[18px] bg-white p-7 shadow-sm sm:p-8",style:{border:"1px solid #F3F4F6"},children:[t.jsx(Ln,{bg:"#ECFDF5",color:"#047857",size:"xs",children:"High-confidence transaction"}),t.jsx("div",{className:"mt-6 flex flex-col",children:Tb.map((d,u)=>t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"rounded-xl px-[18px] py-4",style:{background:ls,border:"1px solid #E5E7EB"},children:[t.jsx("div",{className:"text-[15px] font-semibold",style:{color:qe},children:d.label}),t.jsx("div",{className:"mt-1 text-[13.5px] leading-[1.5]",style:{color:"#6B7280"},children:d.sub})]}),u<Tb.length-1&&t.jsx("div",{className:"flex h-[18px] items-center justify-center text-[13px]",style:{color:"#D1D5DB"},"aria-hidden":"true",children:"↓"})]},d.label))}),t.jsx("p",{className:"mt-2 text-[14px] leading-[1.6]",style:{color:"#6B7280"},children:"Clean, balanced records with no involvement from you."})]}),t.jsxs("div",{className:"rounded-[18px] p-7 text-white sm:p-8",style:{background:ec},children:[t.jsx(Ln,{bg:"rgba(251,191,36,0.14)",color:"#FCD34D",size:"xs",children:"Uncertain transaction"}),t.jsx("div",{className:"mt-6 flex flex-col",children:Lb.map((d,u)=>t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"rounded-xl px-[18px] py-4",style:{background:d.bg,border:`1px solid ${d.border}`},children:[t.jsx("div",{className:"text-[15px] font-semibold text-white",children:d.label}),t.jsx("div",{className:"mt-1 text-[13.5px] leading-[1.5]",style:{color:"#9CA3AF"},children:d.sub})]}),u<Lb.length-1&&t.jsx("div",{className:"flex h-[18px] items-center justify-center text-[13px]",style:{color:"#4B5563"},"aria-hidden":"true",children:"↓"})]},d.label))}),t.jsx("p",{className:"mt-2 text-[14px] leading-[1.6]",style:{color:"#9CA3AF"},children:"The review queue is ours to work. It never reaches you."})]})]})]}),t.jsx("section",{className:`${Rt} ${Tn}`,children:t.jsxs("div",{className:"rounded-[20px] bg-white p-6 shadow-sm sm:p-11",style:{border:"1px solid #F3F4F6"},children:[t.jsxs("div",{className:"max-w-[720px]",children:[t.jsx(cs,{children:"Your accountant, at tax time"}),t.jsxs("h2",{className:"mt-3.5 text-[27px] font-bold leading-[1.13] tracking-[-0.03em] text-balance sm:text-[31px] lg:text-[36px]",children:["Your accountant shouldn't have to",t.jsx("br",{}),"rebuild your books every tax season."]}),t.jsx("p",{className:"mt-4 text-[16px] leading-[1.65] sm:text-[17px]",style:{color:"#4B5563"},children:"The Bookkeeping Service keeps your financial records organized throughout the year, so tax preparation starts from finished books. It does not replace your accountant or tax professional, and it does not file returns — it makes their work faster."})]}),t.jsxs("div",{className:"mt-9 grid items-stretch gap-[26px] lg:grid-cols-[0.9fr_1.1fr]",children:[t.jsxs("div",{className:"rounded-2xl p-7",style:{background:ls,border:"1px solid #F3F4F6"},children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.09em]",style:{color:"#6B7280"},children:"During the year"}),t.jsx("h3",{className:"mb-2.5 mt-3.5 text-[20px] font-semibold tracking-[-0.02em] sm:text-[21px]",children:"The books stay current"}),t.jsx("p",{className:"text-[15px] leading-[1.6]",style:{color:"#4B5563"},children:"Documents are processed as they arrive. Records, reports, receivables, payables, and tax information stay organized — no year-end shoebox of receipts."})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-3.5 text-[11px] font-semibold uppercase tracking-[0.09em]",style:{color:"#6B7280"},children:"At tax time, choose either"}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-2xl p-[26px] text-white",style:{background:qe}
97,children:[t.jsx(tc,{color:"#93C5FD",children:"OPTION 1"}),t.jsx("h3",{className:"mb-2.5 mt-3 text-[19px] font-semibold tracking-[-0.02em]",children:"Invite your accountant"}),t.jsx("p",{className:"text-[14.5px] leading-[1.6]",style:{color:"#9CA3AF"},children:"Invite them by email and they get their own workspace with access to your records and reports. Invites are single-use, matched to their email address, and expire after seven days."})]}),t.jsxs("div",{className:"rounded-2xl p-[26px]",style:{background:ls,border:"1px solid #E5E7EB"},children:[t.jsx(tc,{color:"#6B7280",children:"OPTION 2"}),t.jsx("h3",{className:"mb-2.5 mt-3 text-[19px] font-semibold tracking-[-0.02em]",children:"Send them the reports"}),t.jsx("p",{className:"text-[14.5px] leading-[1.6]",style:{color:"#4B5563"},children:"Prefer to keep the platform to yourself? Generate, download, or print the financial reports and tax information your accountant needs and hand the package over."})]})]})]})]}),t.jsx("p",{className:"mt-[22px] text-[13px] leading-[1.6]",style:{color:"#6B7280"},children:"AI Bookkeeping prepares bookkeeping records. It does not file tax returns and does not provide tax, legal, or financial advice."})]})}),t.jsxs("section",{className:`${Rt} ${Tn}`,children:[t.jsxs("div",{className:"max-w-[740px]",children:[t.jsx(cs,{children:"Financial visibility"}),t.jsxs("h2",{className:"mt-3.5 text-[30px] font-bold leading-[1.12] tracking-[-0.03em] text-balance sm:text-[34px] lg:text-[40px]",children:["Plain answers to the questions",t.jsx("br",{}),"owners actually ask."]}),t.jsx("p",{className:"mt-4 text-[17px] leading-[1.65] sm:text-[18px]",style:{color:"#4B5563"},children:"The Bookkeeping Service turns finished books into views you can read without knowing any accounting."})]}),t.jsx("div",{className:"mt-10 grid gap-[18px] sm:grid-cols-2 lg:grid-cols-4",children:$R.map(d=>t.jsxs("div",{className:"rounded-[14px] bg-white p-[22px] shadow-sm",style:{border:"1px solid #F3F4F6"},children:[t.jsx("h3",{className:"mb-2 text-[16px] font-semibold tracking-[-0.01em]",children:d.title}),t.jsx("p",{className:"text-[14px] leading-[1.55]",style:{color:"#6B7280"},children:d.body})]},d.title))})]}),t.jsx("section",{id:"security",className:`${Rt} ${Tn} scroll-mt-20`,children:t.jsxs("div",{className:"rounded-[20px] p-7 text-white sm:p-12",style:{background:ec},children:[t.jsxs("div",{className:"max-w-[720px]",children:[t.jsx(cs,{tone:"onDark",children:"Security and trust"}),t.jsx("h2",{className:"mt-3.5 text-[27px] font-bold leading-[1.13] tracking-[-0.03em] text-balance sm:text-[31px] lg:text-[36px]",children:"Controls we can describe specifically."}),t.jsx("p",{className:"mt-4 text-[16px] leading-[1.65] sm:text-[17px]",style:{color:"#C7CBD8"},children:"Your financial records deserve more than a padlock icon. Here is what actually protects them."})]}),t.jsx("div",{className:"mt-10 grid gap-[18px] sm:grid-cols-2 lg:grid-cols-4",children:MR.map(d=>t.jsxs("div",{className:"rounded-[14px] p-[22px]",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)"},children:[t.jsx("h3",{className:"mb-2 text-[15px] font-semibold text-white",children:d.title}),t.jsx("p",{className:"text-[14px] leading-[1.55]",style:{color:"#9CA3AF"},children:d.body})]},d.title))}),t.jsx("p",{className:"mt-6 max-w-[820px] text-[13px] leading-[1.6]",style:{color:"#8C93A8"},children:"Time2Win Inc. is a Canadian corporation and handles personal information under PIPEDA. Payments are processed by Stripe; we never touch card data."})]})}),t.jsxs("section",{id:"pricing",className:`${Rt} ${Tn} scroll-mt-20`,children:[t.jsxs("div",{className:"max-w-[740px]",children:[t.jsx(cs,{children:"Pricing"}),t.jsx("h2",{className:"mt-3.5 text-[30px] font-bold leading-[1.12] tracking-[-0.03em] sm:text-[34px] lg:text-[40px]",children:"Software prices. Bookkeeper outcomes."})]}),t.jsxs("div",{className:"mt-10",children:[t.jsxs("div",{className:"mb-[18px] flex flex-wrap items-baseline justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h3",{className:"text-[20px] font-bold tracking-[-0.025em] sm:text-[22px]",children:"Bookkeeping Service"}),t.jsx(Ln,{bg:"#EFF6FF",color:"#1D4ED8",border:"#BFDBFE",size:"xs",children:"AI + human review"})]}),t.jsx("div",{className:"text-[14px] font-medium",style:{color:qe},children:"15-day free trial · No credit card required"})]}),t.jsx("div",{className:"grid gap-5 lg:grid-cols-3",children:BR.map(d=>
97t.jsxs("div",{className:"flex flex-col gap-4 rounded-[18px] p-7 sm:p-[30px]",style:{background:d.dark?qe:"#FFFFFF",border:`1px solid ${d.dark?qe:"#E5E7EB"}`,color:d.dark?"#FFFFFF":qe},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2.5",children:[t.jsx("span",{className:"text-[16px] font-semibold",children:d.name}),d.tag&&t.jsx(Ln,{bg:"rgba(0,102,255,0.22)",color:"#93C5FD",size:"xs",children:d.tag})]}),t.jsxs("div",{className:"flex items-baseline gap-[7px]",children:[t.jsx("span",{className:"text-[36px] font-bold tracking-[-0.035em] sm:text-[40px]",children:d.price}),t.jsx("span",{className:"text-[13.5px]",style:{color:d.dark?"#9CA3AF":"#6B7280"},children:"CAD/USD per month"})]}),t.jsx("div",{className:"text-[15px] font-medium",children:d.docs}),t.jsx("div",{className:"text-[14px] leading-[1.55]",style:{color:d.dark?"#9CA3AF":"#6B7280"},children:d.note}),t.jsx(be,{to:"/register",className:"mt-auto inline-flex justify-center rounded-[11px] px-5 py-3.5 text-[15px] font-semibold transition hover:opacity-90",style:d.dark?{background:fr,color:"#FFFFFF",border:`1px solid ${fr}`}:{background:"#FFFFFF",color:qe,border:"1px solid #D1D5DB"},children:"Start 15-day free trial"})]},d.name))}),t.jsx("p",{className:"mt-3.5 text-[13px] leading-[1.6]",style:{color:"#6B7280"},children:"Every Bookkeeping Service plan includes the full workflow: AI processing, accounting-rule validation, human review when needed, reports, tax information, and accountant access."})]}),t.jsxs("div",{className:"mt-11",children:[t.jsxs("div",{className:"mb-[18px] flex flex-wrap items-baseline justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h3",{className:"text-[20px] font-bold tracking-[-0.025em] sm:text-[22px]",children:"Receipt Automation"}),t.jsx(Ln,{bg:"#ECFDF5",color:"#047857",border:"#A7F3D0",size:"xs",children:"Document processing"})]}),t.jsx("div",{className:"text-[14px] font-medium",style:{color:qe},children:"Free trial · 5 documents · No credit card required"})]}),t.jsx("div",{className:"grid gap-5 lg:grid-cols-3",children:UR.map(d=>t.jsxs("div",{className:"flex flex-col gap-3.5 rounded-[18px] bg-white p-7 sm:p-[28px]",style:{border:"1px solid #E5E7EB"},children:[t.jsx("span",{className:"text-[16px] font-semibold",children:d.name}),t.jsxs("div",{className:"flex items-baseline gap-[7px]",children:[t.jsx("span",{className:"text-[31px] font-bold tracking-[-0.035em] sm:text-[34px]",children:d.price}),t.jsx("span",{className:"text-[13.5px]",style:{color:"#6B7280"},children:"CAD/USD per month"})]}),t.jsx("div",{className:"text-[15px] font-medium",style:{color:"#374151"},children:d.docs}),t.jsx("div",{className:"text-[14px]",style:{color:"#6B7280"},children:d.storage}),t.jsx(be,{to:"/register",className:"mt-auto inline-flex justify-center rounded-[11px] px-5 py-3 text-[15px] font-semibold transition hover:border-gray-900",style:{border:"1px solid #D1D5DB",color:qe},children:"Start free trial"})]},d.name))}),t.jsx("p",{className:"mt-3.5 text-[13px] leading-[1.6]",style:{color:"#6B7280"},children:"Prices in CAD/USD. Taxes may apply. Cancel anytime — no cancellation fee, access to the end of the period."})]})]}),t.jsxs("section",{id:"compare",className:`${Rt} ${Tn} scroll-mt-20`,children:[t.jsxs("div",{className:"max-w-[740px]",children:[t.jsx(cs,{children:"Detailed comparison"}),t.jsx("h2",{className:"mt-3.5 text-[30px] font-bold leading-[1.12] tracking-[-0.03em] sm:text-[34px] lg:text-[40px]",children:"Side by side."})]}),t.jsx("div",{className:"mt-9 overflow-x-auto rounded-[18px] bg-white",style:{border:"1px solid #E5E7EB"},children:t.jsxs("table",{className:"w-full min-w-[680px] border-collapse text-left",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"44.4%"}}),t.jsx("col",{style:{width:"27.8%"}}),t.jsx("col",{style:{width:"27.8%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{style:{background:ls,borderBottom:"1px solid #E5E7EB"},children:[t.jsx("th",{className:"px-[26px] py-[18px] text-[12px] font-semibold uppercase tracking-[0.08em]",style:{color:"#6B7280"},children:"Capability"}),t.jsx("th",{className:"px-5 py-[18px] text-[14px] font-semibold",style:{color:qe,borderLeft:"1px solid #E5E7EB"},children:"Receipt Automation"}),t.jsx("th",{className:"px-5 py-[18px] text-[14px] font-semibold",style:{color:qe,borderLeft:"1px solid #E5E7EB",background:"#EFF6FF"},children:"Bookkeeping Service"})]})}),t.jsx("tbody",{children:zR.map(d=>t.jsxs("tr",{style:{borderBottom:"1px solid #F3F4F6"},children:[t.jsx("td",{className:"px-[26px] py-[18px] text-[15px] font-medium",style:{color:qe},children:d.label}),t.jsx("td",{className:"px-5 py-[18px] text-[14.5px] leading-[1.5]",style:{color:d.aMuted?"#6B7280":qe,borderLeft:"1px solid #F3F4F6"},children:d.a}),t.jsx("td",{className:"px-5 py-[18px] text-[14.5px] leading-[1.5]",style:{color:qe,borderLeft:"1px solid #F3F4F6",background:"#F8FBFF"},children:d.b})]},d.label))})]})})]}),t.jsxs("section",{className:`${Rt} ${Tn}`,children:[t.jsxs("div",{className:"max-w-[740px]",children:[t.jsx(cs,{children:"Who it's for"}),t.jsxs("h2",{className:"mt-3.5 text-[30px] font-bold leading-[1.12] tracking-[-0.03em] text-balance sm:text-[34px] lg:text-[40px]",children:["Built for owners whose time is",t.jsx("br",{}),"worth more than data entry."]})]}),t.jsx("div",{className:"mt-10 grid gap-[18px] sm:grid-cols-2 lg:grid-cols-5",children:WR.map(d=>t.jsxs("div",{className:"rounded-[14px] bg-white p-6",style:{border:"1px solid #F3F4F6"},children:[t.jsx("h3",{className:"mb-[9px] text-[16px] font-semibold tracking-[-0.01em]",children:d.title}),t.jsx("p",{className:"text-[14px] leading-[1.55]",style:{color:"#6B7280"},children:d.body})]},d.title))})]}),t.jsx("section",{id:"faq",className:`${Rt} ${Tn} scroll-mt-20`,children:t.jsxs("div",{className:"grid items-start gap-10 lg:grid-cols-[0.7fr_1.3fr] lg:gap-[52px]",children:[t.jsxs("div",{children:[t.jsx(cs,{children:"FAQ"}),t.jsxs("h2",{className:"mt-3.5 text-[27px] font-bold leading-[1.13] tracking-[-0.03em] text-balance sm:text-[31px] lg:text-[36px]",children:["Questions owners ask",t.jsx("br",{}),"before signing up."]}),t.jsxs("p",{className:"mt-4 text-[16px] leading-[1.65]",style:{color:"#4B5563"},children:["Something not covered here?"," ",t.jsx("a",{href:"mailto:[email protected]",className:"font-semibold",style:{color:fr},children:"Email support"})," ","and a person will answer."]}
97)]}),t.jsx("div",{className:"overflow-hidden rounded-[18px] bg-white",style:{border:"1px solid #E5E7EB"},children:Rb.map(([d,u],p)=>t.jsxs("div",{style:{borderBottom:p<Rb.length-1?"1px solid #F3F4F6":void 0},children:[t.jsxs("button",{type:"button",onClick:()=>a(h=>h===p?-1:p),"aria-expanded":s===p,className:"flex w-full items-center justify-between gap-5 px-[26px] py-5 text-left text-[16px] font-semibold",style:{color:qe},children:[t.jsx("span",{children:d}),t.jsx("span",{className:"shrink-0 text-[20px] font-normal leading-none",style:{color:"#9CA3AF"},"aria-hidden":"true",children:s===p?"–":"+"})]}),s===p&&t.jsx("div",{className:"max-w-[760px] px-[26px] pb-[22px] text-[15px] leading-[1.65]",style:{color:"#4B5563"},children:u})]},d))})]})}),t.jsx("section",{className:`${Rt} ${Tn}`,children:t.jsxs("div",{className:"rounded-[20px] px-6 py-12 text-center text-white sm:px-12 sm:py-16",style:{background:ec},children:[t.jsx("h2",{className:"mx-auto max-w-[760px] text-[30px] font-bold leading-[1.08] tracking-[-0.035em] text-balance sm:text-[36px] lg:text-[44px]",children:"Upload your documents. Let the platform handle the bookkeeping."}),t.jsx("p",{className:"mx-auto mt-5 max-w-[600px] text-[16px] leading-[1.6] sm:text-[18px]",style:{color:"#C7CBD8"},children:"Start with the Bookkeeping Service and see your books stay current — or begin with Receipt Automation and move up when you're ready."}),t.jsxs("div",{className:"mt-[34px] flex flex-wrap justify-center gap-3",children:[t.jsx(be,{to:"/register",className:"inline-flex items-center rounded-xl px-8 py-4 text-[16px] font-semibold text-white transition hover:opacity-90 sm:text-[17px]",style:{background:fr},children:"Start your 15-day free trial"}),t.jsx("button",{type:"button",onClick:()=>o("compare"),className:"inline-flex items-center rounded-xl px-7 py-4 text-[16px] font-medium text-white transition hover:border-white/55 sm:text-[17px]",style:{border:"1px solid rgba(255,255,255,0.24)"},children:"Compare products"})]}),t.jsx("p",{className:"mt-5 text-[14px]",style:{color:"#8C93A8"},children:"No credit card required. Cancel anytime."})]})})]}),t.jsxs("footer",{className:"mt-14 pb-10 pt-14 sm:mt-[88px]",style:{background:qe,color:"#9CA3AF"},children:[t.jsxs("div",{className:`${Rt} grid gap-9 sm:grid-cols-2 lg:grid-cols-[1.5fr_1fr_1fr_1fr_1fr_1fr]`,children:[t.jsxs("div",{children:[t.jsx("div",{className:"mb-3.5",children:t.jsx(Ib,{dark:!0})}),t.jsx("p",{className:"max-w-[290px] text-[14px] leading-[1.6]",children:"Bookkeeping done for you, by Time2Win Inc. — a Canadian corporation serving small businesses in Canada and the United States."})]}),t.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px]",children:[t.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.08em]",style:{color:"#9CA3AF"},children:"Product"}),t.jsx("button",{type:"button",onClick:()=>o("receipts"),className:"text-left transition hover:text-white",style:{color:"#D1D5DB"},children:"Receipt Automation"}),t.jsx("button",{type:"button",onClick:()=>o("bookkeeping"),className:"text-left transition hover:text-white",style:{color:"#D1D5DB"},children:"Bookkeeping Service"}),t.jsx("button",{type:"button",onClick:()=>o("how"),className:"text-left transition hover:text-white",style:{color:"#D1D5DB"},children:"How it works"}),t.jsx("button",{type:"button",onClick:()=>o("compare"),className:"text-left transition hover:text-white",style:{color:"#D1D5DB"},children:"Compare"})]}),t.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px]",children:[t.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.08em]",style:{color:"#9CA3AF"},children:"Services"}),gw.map(d=>t.jsx("a",{href:d.path,className:"transition hover:text-white",style:{color:"#D1D5DB"},children:d.label},d.path))]}),t.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px]",children:[t.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.08em]",style:{color:"#9CA3AF"},children:"Learn"}),t.jsx(be,{to:"/pricing",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"Pricing"}),t.jsx("button",{type:"button",onClick:()=>o("security"),className:"text-left transition hover:text-white",style:{color:"#D1D5DB"},children:"Security"}),t.jsx(be,{to:"/faq",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"FAQ"}),t.jsx("a",{href:"/blog",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"Blog"})]}),t.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px]",children:[t.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.08em]",style:{color:"#9
97CA3AF"},children:"Company"}),t.jsx("a",{href:"mailto:[email protected]",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"Support"}),t.jsx(be,{to:"/privacy-policy",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"Privacy"}),t.jsx(be,{to:"/terms-of-service",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"Terms"})]}),t.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px]",children:[t.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-[0.08em]",style:{color:"#9CA3AF"},children:"Get started"}),t.jsx(be,{to:"/login",className:"transition hover:text-white",style:{color:"#D1D5DB"},children:"Login"}),t.jsx(be,{to:"/register",className:"mt-1 inline-flex justify-center rounded-[10px] px-4 py-2.5 text-[14px] font-semibold text-white transition hover:opacity-90",style:{background:fr},children:"Start free trial"})]})]}),t.jsxs("div",{className:`${Rt} mt-9 pt-6`,style:{borderTop:"1px solid rgba(255,255,255,0.08)"},children:[t.jsx("p",{className:"text-[12.5px] leading-[1.7]",children:"AI Bookkeeping prepares bookkeeping records. It does not file tax returns and does not provide tax, legal, or financial advice — work with your accountant. Prices in CAD/USD; taxes may apply. © 2026 Time2Win Inc."}),t.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-4",children:[t.jsx("a",{href:"https://launchbuff.com",target:"_blank",rel:"noopener noreferrer",title:"Featured on LaunchBuff",children:t.jsx("img",{src:"https://launchbuff.com/badge-featured-dark.svg",alt:"Featured on LaunchBuff",width:128,height:40,loading:"lazy",className:"h-10 w-auto"})}),t.jsx("a",{href:"https://tools.cafe",target:"_blank",rel:"noopener noreferrer",title:"Featured on tools.cafe",children:t.jsx("img",{src:"https://tools.cafe/b/dark.svg",alt:"Featured on tools.cafe",width:128,height:40,loading:"lazy",className:"h-10 w-auto"})})]})]})]})]})};function Fb(e,n){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),s.push.apply(s,a)}return s}function qc(e){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Fb(Object(s),!0).forEach(function(a){_w(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Fb(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function _w(e,n,s){return n in e?Object.defineProperty(e,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[n]=s,e}function qR(e,n){if(e==null)return{};var s={},a=Object.keys(e),o,l;for(l=0;l<a.length;l++)o=a[l],!(n.indexOf(o)>=0)&&(s[o]=e[o]);return s}function VR(e,n){if(e==null)return{};var s=qR(e,n),a,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)a=l[o],!(n.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(s[a]=e[a])}return s}function Aa(e,n){return YR(e)||GR(e,n)||KR(e,n)||QR()}function YR(e){if(Array.isArray(e))return e}function GR(e,n){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var a=[],o=!0,l=!1,d,u;try{for(s=s.call(e);!(o=(d=s.next()).done)&&(a.push(d.value),!(n&&a.length===n));o=!0);}catch(p){l=!0,u=p}finally{try{!o&&s.return!=null&&s.return()}finally{if(l)throw u}}return a}}function KR(e,n){if(e){if(typeof e=="string")return Db(e,n);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Db(e,n)}}function Db(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,a=new Array(n);s<n;s++)a[s]=e[s];return a}function QR(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
98In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var JR=["src","checkForExisting"],Gi={},Ob=function(n){var s=document.querySelector('script[src="'.concat(n,'"]'));if(s)return Gi[n]={loading:!1,error:null,scriptEl:s}},$b=typeof window<"u"&&typeof window.document<"u";function XR(e){var n=e.src,s=e.checkForExisting,a=s===void 0?!1:s,o=VR(e,JR),l=n?Gi[n]:void 0;!l&&a&&n&&$b&&(l=Ob(n));
98var d=x.useState(l?l.loading:!!n),u=Aa(d,2),p=u[0],h=u[1],f=x.useState(l?l.error:null),g=Aa(f,2),b=g[0],v=g[1],N=x.useState(!1),w=Aa(N,2),k=w[0],_=w[1];return x.useEffect(function(){if(!(!$b||!n||k||b)){l=Gi[n],!l&&a&&(l=Ob(n));var S;l?S=l.scriptEl:(S=document.createElement("script"),S.src=n,Object.keys(o).forEach(function(A){S[A]===void 0?S.setAttribute(A,o[A]):S[A]=o[A]}),l=Gi[n]={loading:!0,error:null,scriptEl:S});var T=function(){l&&(l.loading=!1),h(!1),_(!0)},E=function(I){l&&(l.error=I),v(I)};return S.addEventListener("load",T),S.addEventListener("error",E),document.body.appendChild(S),function(){S.removeEventListener("load",T),S.removeEventListener("error",E),l&&l.loading&&(S.remove(),delete Gi[n])}}},[n]),[p,b]}var ZR=function(n,s,a){var o={};return delete Object.assign(o,n,_w({},a,n[s]))[s],o},eI=function(n,s){var a={plaid:null,open:!1,onExitCallback:null};if(typeof window>"u"||!window.Plaid)throw new Error("Plaid not loaded");a.plaid=s(qc(qc({},n),{},{onExit:function(h,f){a.open=!1,n.onExit&&n.onExit(h,f),a.onExitCallback&&a.onExitCallback()}}));var o=function(){a.plaid&&(a.open=!0,a.onExitCallback=null,a.plaid.open())},l=function(h){a.plaid&&a.plaid.submit(h)},d=function(h,f){if(!a.open||!a.plaid){f&&f();return}a.onExitCallback=f,a.plaid.exit(h),h&&h.force&&(a.open=!1)},u=function(){a.plaid&&(a.plaid.destroy(),a.plaid=null)};return{open:o,submit:l,exit:d,destroy:u}},tI=function(n,s){var a=ZR(n,"publicKey","key");return eI(a,s)},nI="https://cdn.plaid.com/link/v2/stable/link-initialize.js",Mb=function(){},kw=function(n){var s=XR({src:nI,checkForExisting:!0}),a=Aa(s,2),o=a[0],l=a[1],d=x.useState(null),u=Aa(d,2),p=u[0],h=u[1],f=x.useState(!1),g=Aa(f,2),b=g[0],v=g[1],N=(n.product||[]).slice().sort().join(",");x.useEffect(function(){if(!o&&!(!n.token&&!n.publicKey&&!n.receivedRedirectUri)){if(l||!window.Plaid){console.error("Error loading Plaid",l);return}p!=null&&p.exit({force:!0},function(){return p.destroy()});var _=tI(qc(qc({},n),{},{onLoad:function(){v(!0),n.onLoad&&n.onLoad()}}),window.Plaid.create);return h(_),function(){return _.exit({force:!0},function(){return _.destroy()})}}},[o,l,n.publicKey,n.token,N]);var w=p!=null&&(!o||b),k=function(){n.token||console.warn("react-plaid-link: You cannot call open() without a valid token supplied to usePlaidLink. This is a no-op.")};return{error:l,ready:w,submit:p?p.submit:Mb,exit:p?p.exit:Mb,open:p?p.open:k}},Bb;(function(e){e.OPEN="OPEN",e.EXIT="EXIT",e.HANDOFF="HANDOFF",e.SELECT_INSTITUTION="SELECT_INSTITUTION",e.ERROR="ERROR",e.BANK_INCOME_INSIGHTS_COMPLETED="BANK_INCOME_INSIGHTS_COMPLETED",e.IDENTITY_VERIFICATION_PASS_SESSION="IDENTITY_VERIFICATION_PASS_SESSION",e.IDENTITY_VERIFICATION_FAIL_SESSION="IDENTITY_VERIFICATION_FAIL_SESSION"})(Bb||(Bb={}));const sI=["Imported","Matched","Posted","Excluded"],Co=e=>{var n;return(e==null?void 0:e.status)===403?"Only the account owner can manage bank transactions.":typeof((n=e==null?void 0:e.data)==null?void 0:n.detail)=="string"?e.data.detail:"Something went wrong. Please try again."},jh=(e,n)=>{const s=new URLSearchParams;e.bank_account&&s.set("bank_account",e.bank_account),e.date_from&&s.set("date_from",e.date_from),e.date_to&&s.set("date_to",e.date_to),e.status&&s.set("status",e.status),n&&n>1&&s.set("page",String(n));const a=s.toString();return a?`?${a}`:""},rI=(e,n)=>{const[s,a]=x.useState(null),[o,l]=x.useState(!0),[d,u]=x.useState(null),[p,h]=x.useState(0),f=x.useCallback(()=>h(b=>b+1),[]),g=jh(e,n);return x.useEffect(()=>{let b=!1;return l(!0),u(null),te.get(`/api/accounting/transactions/${g}`).then(v=>{b||((v==null?void 0:v.status)===200?a(v.data):u(Co(v)))}).finally(()=>{b||l(!1)}),()=>{b=!0}},[g,p]),{data:s,isLoading:o,error:d,refetch:f}},aI=e=>{const[n,s]=x.useState(null),[a,o]=x.useState(!0),[l,d]=x.useState(null),[u,p]=x.useState(0),h=x.useCallback(()=>p(g=>g+1),[]),f=jh(e);return x.useEffect(()=>{let g=!1;return o(!0),d(null),te.get(`/api/accounting/transactions/balance/${f}`).then(b=>{g||((b==null?void 0:b.status)===200?s(b.data):d(Co(b)))}).finally(()=>{g||o(!1)}),()=>{g=!0}},[f,u]),{balance:n,isLoading:a,error:l,refetch:h}},iI=()=>({loadDetail:async n=>{const s=await te.get(`/api/accounting/transactions/${n}/`);return(s==null?void 0:s.status)===200?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,error:Co(s)}}}),oI=()=>({disconnect:async n=>{const s=await te.post("/api/accounting/plaid/disconnect/",{item_id:n});return(s==null?void 0:s.status)===200?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,error:Co(s)}}}),lI=()=>({exportPdf:async n=>{const s=await te.get(`/api/accounting/transactions/export/pdf/${jh(n)}`,{responseType:"blob"});return(s==null?void 0:s.status)===200?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,error:Co(s)}}}),cI={success:"bg-emerald-500",error:"bg-red-600",info:"bg-[#0066FF]"},dI=({toast:e})=>e?t.jsx("div",{className:`fixed top-5 right-5 z-50 max-w-md rounded-xl px-5 py-3.5 text-sm font-medium text-white shadow-lg ${cI[e.variant]}`,children:e.message}):null,uI=({status:e})=>{const n=e==="active";return t.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${n?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-amber-50 text-amber-700 border border-amber-200"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-emerald-500":"bg-amber-500"}`}
98),n?"Active":e.replace(/_/g," ")]})},mI={Imported:"bg-gray-50 text-gray-600 border-gray-200",Matched:"bg-blue-50 text-blue-700 border-blue-200",Posted:"bg-emerald-50 text-emerald-700 border-emerald-200",Excluded:"bg-amber-50 text-amber-700 border-amber-200"},pI=({status:e,pending:n})=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium ${mI[e]}`,children:[e,n&&e==="Imported"?t.jsx("span",{className:"ml-1 text-gray-400",children:"(pending)"}):null]}),fI=new Set(["login_required","pending_expiration"]),hI=({item:e,onReconnect:n,onDisconnect:s})=>{const a=e.status==="revoked";return t.jsxs("div",{className:"rounded-2xl bg-white border border-gray-100 shadow-sm p-5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900",children:e.institution_name}),t.jsxs("p",{className:"mt-0.5 text-xs text-gray-400",children:["Connected ",new Date(e.created_at).toLocaleDateString()]})]}),t.jsx("div",{className:"flex items-center gap-2",children:a?t.jsx("span",{className:"inline-flex items-center rounded-full border border-gray-200 bg-gray-50 px-2.5 py-0.5 text-xs font-medium text-gray-500",children:"Disconnected — history retained"}):t.jsxs(t.Fragment,{children:[t.jsx(uI,{status:e.status}),n&&fI.has(e.status)&&t.jsx("button",{onClick:()=>n(e),className:"rounded-lg bg-amber-50 border border-amber-200 text-amber-700 hover:bg-amber-100 px-3 py-1 text-xs font-semibold transition-colors",children:"Reconnect"}),s&&t.jsx("button",{onClick:()=>s(e),className:"rounded-lg bg-white border border-red-200 text-red-600 hover:bg-red-50 px-3 py-1 text-xs font-semibold transition-colors",children:"Disconnect"})]})})]}),t.jsx("ul",{className:"mt-4 space-y-1.5",children:e.accounts.map(o=>t.jsxs("li",{className:"flex items-center gap-2 text-sm text-gray-700",children:[t.jsx("span",{children:o.name}),o.mask&&t.jsxs("span",{className:"text-gray-400",children:["····",o.mask]}),o.ledger_account_code&&t.jsxs("span",{className:"text-gray-400",children:["→ ",o.ledger_account_code]})]},`${o.name}-${o.mask}`))})]})},nc="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-700 focus:border-[#0066FF] focus:outline-none",xI=({loading:e,detail:n})=>e?t.jsx("div",{className:"px-4 py-3 text-xs text-gray-400",children:"Loading details…"}):n?n.journal_entries.length===0?t.jsx("div",{className:"px-4 py-3 text-xs text-gray-400",children:"No posted entries for this transaction yet."}):t.jsx("div",{className:"space-y-3 px-4 py-3",children:n.journal_entries.map((s,a)=>t.jsxs("div",{className:"rounded-lg border border-gray-100 bg-gray-50 p-3",children:[t.jsxs("p",{className:"text-xs font-semibold text-gray-700",children:[s.entry_number!=null?`Entry #${s.entry_number}`:"Entry"," · ",s.entry_date]}),s.description&&t.jsx("p",{className:"mt-0.5 text-xs text-gray-500",children:s.description}),t.jsx("table",{className:"mt-2 w-full text-xs",children:t.jsx("tbody",{children:s.lines.map((o,l)=>t.jsxs("tr",{className:"text-gray-600",children:[t.jsxs("td",{className:"py-0.5 pr-3",children:[o.account_code," ",o.account_name]}),t.jsx("td",{className:"py-0.5 pr-3 text-right",children:o.debit?`Dr ${o.debit}`:""}),t.jsx("td",{className:"py-0.5 text-right",children:o.credit?`Cr ${o.credit}`:""})]},l))})})]},a))}):null,gI=()=>{const{role:e,isLoading:n}=ln(),s=e==="owner",{items:a,isLoading:o,error:l,refetch:d}=pw(),{createLinkToken:u}=bL(),{exchange:p}=uw(),{createReconnectLinkToken:h}=vL(),{completeReconnect:f}=mw(),{disconnect:g}=oI(),[b,v]=x.useState(null),[N,w]=x.useState(!1),[k,_]=x.useState(null),S=x.useRef(null),[T,E]=x.useState({}),[A,I]=x.useState(1),{data:R,isLoading:W,error:Y,refetch:K}=rI(T,A),{balance:X}=aI(T),{loadDetail:se}=iI(),{exportPdf:ne}=lI(),[Z,ue]=x.useState(null),[re,H]=x.useState(null),[M,Q]=x.useState(!1),[$,L]=x.useState(!1),[F,V]=x.useState({}),[q,ee]=x.useState(null),[je,ke]=x.useState(!1),me=()=>{localStorage.removeItem(Ea),localStorage.removeItem(Wc),localStorage.removeItem(Hc)},Ne=x.useCallback((de,Be)=>{S.current&&clearTimeout(S.current),_({message:de,variant:Be}),S.current=setTimeout(()=>_(null),5e3)},[]);x.useEffect(()=>{R&&V(de=>{const Be={...de};for(const Ze of R.results)Ze.bank_account_id&&!Be[Ze.bank_account_id]&&(Be[Ze.bank_account_id]=Ze.bank_account_mask?`${Ze.bank_account_name??"Account"} ····${Ze.bank_account_mask}`:Ze.bank_account_name??Ze.bank_account_id);return Be})},[R]);const Oe=de=>{E(Be=>({...Be,...de})),I(1),ue(null)},mt=async de=>{if(Z===de){ue(null),H(null);return}ue(de),H(null),Q(!0);const Be=await se(de);Q(!1),Be.ok?H(Be.data):Ne(Be.error,"error")},he=async()=>{L(!0);const de=await ne(T);if(L(!1),!de.ok){Ne(de.error,"error");return}
98const Be=URL.createObjectURL(de.data),Ze=document.createElement("a");Ze.href=Be,Ze.download="bank-transactions.pdf",document.body.appendChild(Ze),Ze.click(),Ze.remove(),URL.revokeObjectURL(Be)},Se=async()=>{if(!q)return;ke(!0);const de=await g(q.id);ke(!1),ee(null),de.ok?(Ne(`${de.data.institution_name} disconnected — history retained.`,"success"),d(),K()):Ne(de.error,"error")},ae=x.useCallback(async(de,Be)=>{if((b==null?void 0:b.mode)==="reconnect"&&b.itemId){const ws=await f(b.itemId);me(),v(null),w(!1),ws.ok?(Ne(`${ws.data.institution_name} reconnected.`,"success"),d()):Ne(ws.error,"error");return}const Ze=await p(dw(de,Be));if(me(),v(null),w(!1),Ze.ok){if(Ne(`${Ze.data.institution_name} connected.`,"success"),Ze.data.skipped.length>0){const ws=Ze.data.skipped.map(Ka=>`${Ka.name} (${Ka.type})`).join(", ");Ne(`Connected — but some accounts are not supported and were skipped: ${ws}`,"info")}d()}else Ne(Ze.error,"error")},[b,f,p,d,Ne]),J=x.useCallback(de=>{me(),v(null),w(!1),de&&Ne("The bank connection was interrupted. Please try again.","error")},[Ne]),{open:pe,ready:Re}=kw({token:(b==null?void 0:b.token)??null,onSuccess:ae,onExit:J});x.useEffect(()=>{b&&Re&&pe()},[b,Re,pe]);const We=async()=>{w(!0);const de=await u();de.ok?(me(),localStorage.setItem(Ea,de.data.link_token),v({token:de.data.link_token,mode:"connect"})):(w(!1),Ne(de.error,"error"))},xt=async de=>{w(!0);const Be=await h(de.id);Be.ok?(localStorage.setItem(Ea,Be.data.link_token),localStorage.setItem(Wc,"reconnect"),localStorage.setItem(Hc,de.id),v({token:Be.data.link_token,mode:"reconnect",itemId:de.id})):(w(!1),Ne(Be.error,"error"))};if(n||o)return t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-8",children:[t.jsx("div",{className:"h-7 w-56 bg-gray-200 rounded animate-pulse mb-2"}),t.jsx("div",{className:"h-4 w-72 bg-gray-200 rounded animate-pulse mb-8"}),Array.from({length:2}).map((de,Be)=>t.jsxs("div",{className:"rounded-2xl bg-white border border-gray-100 shadow-sm p-5 mb-4",children:[t.jsx("div",{className:"h-4 w-40 bg-gray-100 rounded animate-pulse mb-3"}),t.jsx("div",{className:"h-3 w-64 bg-gray-100 rounded animate-pulse"})]},Be))]})});const Ct=(R==null?void 0:R.results)??[],Un=Object.entries(F);return t.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:[t.jsx(dI,{toast:k}),t.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-8",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Bank Transactions"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Connect your bank so transactions flow into your books automatically."})]}),s?t.jsxs(t.Fragment,{children:[l&&t.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 px-5 py-4 flex items-center gap-3 mb-6",children:[t.jsx("svg",{className:"w-5 h-5 text-red-500 shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),t.jsx("p",{className:"flex-1 text-sm text-red-700",children:l}),t.jsx("button",{onClick:d,className:"text-xs text-red-700 hover:text-red-800 underline",children:"Retry"})]}),a.length>0?t.jsx("div",{className:"space-y-4 mb-6",children:a.map(de=>t.jsx(hI,{item:de,onReconnect:xt,onDisconnect:ee},de.id))}):!l&&t.jsxs("div",{className:"rounded-2xl bg-white border border-gray-200 border-dashed p-10 text-center mb-6",children:[t.jsx("svg",{className:"w-10 h-10 mx-auto text-gray-300 mb-3",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 21v-8.25M15.75 21v-8.25M8.25 21v-8.25M3 9l9-6 9 6m-1.5 12V10.332A48.36 48.36 0 0012 9.75c-2.551 0-5.056.2-7.5.582V21M3 21h18M12 6.75h.008v.008H12V6.75z"})}),t.jsx("p",{className:"text-sm font-medium text-gray-700",children:"No banks connected yet"}),t.jsx("p",{className:"mt-1 text-xs text-gray-400",children:"Connect a chequing, savings, or credit card account to start the automatic feed."})]}),t.jsxs("button",{onClick:We,disabled:N,className:"flex items-center justify-center gap-2 rounded-xl bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:[N&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
98ded-full animate-spin"}),N?"Opening…":"Connect a bank account"]}),t.jsxs("div",{className:"mt-10",children:[t.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 flex-wrap",children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Imported transactions"}),t.jsx("button",{onClick:he,disabled:$||Ct.length===0,className:"rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm font-semibold text-gray-700 hover:bg-gray-50 disabled:opacity-60",children:$?"Exporting…":"Export PDF"})]}),t.jsxs("div",{className:"mb-4 flex flex-wrap items-end gap-3",children:[t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Account"}),t.jsxs("select",{className:nc,value:T.bank_account??"",onChange:de=>Oe({bank_account:de.target.value||void 0}),children:[t.jsx("option",{value:"",children:"All accounts"}),Un.map(([de,Be])=>t.jsx("option",{value:de,children:Be},de))]})]}),t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"From"}),t.jsx("input",{type:"date",className:nc,value:T.date_from??"",onChange:de=>Oe({date_from:de.target.value||void 0})})]}),t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"To"}),t.jsx("input",{type:"date",className:nc,value:T.date_to??"",onChange:de=>Oe({date_to:de.target.value||void 0})})]}),t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Status"}),t.jsxs("select",{className:nc,value:T.status??"",onChange:de=>Oe({status:de.target.value||void 0}),children:[t.jsx("option",{value:"",children:"All statuses"}),sI.map(de=>t.jsx("option",{value:de,children:de},de))]})]})]}),X&&t.jsxs("div",{className:"mb-4 flex flex-wrap gap-6 rounded-xl border border-gray-100 bg-white px-5 py-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-400",children:"Opening balance (imported activity)"}),t.jsx("p",{className:"font-semibold text-gray-900",children:X.opening_balance})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-400",children:"Closing balance"}),t.jsx("p",{className:"font-semibold text-gray-900",children:X.closing_balance})]})]}),t.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-100 bg-white",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-100 text-left text-xs font-medium text-gray-400",children:[t.jsx("th",{className:"px-4 py-2.5",children:"Date"}),t.jsx("th",{className:"px-4 py-2.5",children:"Account"}),t.jsx("th",{className:"px-4 py-2.5",children:"Description"}),t.jsx("th",{className:"px-4 py-2.5",children:"Status"}),t.jsx("th",{className:"px-4 py-2.5 text-right",children:"Amount"})]})}),t.jsx("tbody",{children:W?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"px-4 py-6 text-center text-xs text-gray-400",children:"Loading transactions…"})}):Y?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"px-4 py-6 text-center text-xs text-red-600",children:Y})}):Ct.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"px-4 py-6 text-center text-xs text-gray-400",children:"No transactions for this filter."})}):Ct.map(de=>{const Be=de.signed_amount.startsWith("-");return t.jsxs(x.Fragment,{children:[t.jsxs("tr",{onClick:()=>mt(de.id),className:"cursor-pointer border-b border-gray-50 hover:bg-gray-50",children:[t.jsx("td",{className:"px-4 py-2.5 text-gray-700",children:de.date}),t.jsxs("td",{className:"px-4 py-2.5 text-gray-500",children:[de.bank_account_name,de.bank_account_mask&&t.jsxs("span",{className:"text-gray-400",children:[" ····",de.bank_account_mask]})]}),t.jsxs("td",{className:"px-4 py-2.5 text-gray-700",children:[de.description||de.counterparty_name||"—",de.description&&de.counterparty_name&&t.jsx("span",{className:"block text-xs text-gray-400",children:de.counterparty_name})]}),t.jsx("td",{className:"px-4 py-2.5",children:t.jsx(pI,{status:de.public_status,pending:de.pending})}),t.jsx("td",{className:`px-4 py-2.5 text-right font-medium ${Be?"text-red-600":"text-emerald-700"}`,children:de.signed_amount})]}),Z===de.id&&t.jsx("tr",{className:"border-b border-gray-50 bg-gray-50/50",children:t.jsx("td",{colSpan:5,children:t.jsx(xI,{loading:M,detail:re})})})]},de.id)})})]})}),R&&(R.next||R.previous)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between text-sm",children:[t.jsxs("span",{className:"text-xs text-gray-400",children:[R.count," transaction(s)"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{I(de=>Math.max(1,de-1)),ue(null)},disabled:!R.previous,className:"rounded-lg border border-gray-200 px-3 py-1 text-xs font-semibold text-gray-700 hover:bg-gray-50 disabled:opacity-40",children:"Previous"}),t.jsx("button",{onClick:()=>{I(de=>de+1),ue(null)},disabled:!R.next,className:"rounded-lg border border-gray-200 px-3 py-1 text-xs font-semibold text-gray-700 hover:bg-gray-50 disabled:opacity-40",children:"Next"})]})]})]})]}):t.jsx("div",{className:"rounded-xl bg-gray-50 border border-gray-200 px-4 py-3 text-sm text-gray-600",children:"Only the account owner can manage bank connections."})]}),q&&t.jsxs(lw,{title:"Disconnect bank connection",onClose:()=>ee(null),children:[t.jsxs("p",{className:"text-sm text-gray-600",children:["Disconnecting ",t.jsx("span",{className:"font-semibold text-gray-900",children:q.institution_name})," stops the automatic feed and removes this connection at your bank. All imported transactions and their history are kept. This can’t be undone — you’d reconnect to resume the feed."]}),t.jsx(cw,{busy:je,confirmLabel:"Disconnect",onCancel:()=>ee(null),onConfirm:Se})]})]})},yI=200,bI=50,Or=(e,n)=>{const[s,a]=x.useState([]),[o,l]=x.useState(0),[d,u]=x.useState(1),[p,h]=x.useState(bI),[f,g]=x.use
98State(!0),[b,v]=x.useState(null),[N,w]=x.useState(0),k=x.useCallback(()=>w(T=>T+1),[]),_=x.useCallback(T=>{h(Math.max(1,Math.min(T,yI)))},[]),S=JSON.stringify(n??{});return x.useEffect(()=>{let T=!1;return g(!0),v(null),te.get(e,{params:{...n??{},page:d,page_size:p}}).then(E=>{var A;if(!T&&E!=null)if(E.status===200){const I=E.data;a(Array.isArray(I==null?void 0:I.results)?I.results:[]),l(typeof(I==null?void 0:I.count)=="number"?I.count:0)}else a([]),l(0),v(((A=E.data)==null?void 0:A.detail)??"Failed to load list")}).catch(E=>{var A,I;T||v(((I=(A=E==null?void 0:E.response)==null?void 0:A.data)==null?void 0:I.detail)??"Failed to load list")}).finally(()=>{T||g(!1)}),()=>{T=!0}},[e,S,d,p,N]),{items:s,count:o,page:d,setPage:u,pageSize:p,setPageSize:_,isLoading:f,error:b,refetch:k}},vI={default:"text-gray-500",success:"text-emerald-600",warning:"text-amber-600",danger:"text-red-600"},ka=({label:e,value:n,tone:s="default"})=>t.jsxs(Te,{padding:!0,children:[t.jsx("div",{className:`text-[11.5px] font-semibold uppercase tracking-wider ${vI[s]}`,children:e}),t.jsx("div",{className:"mt-1.5 text-[19px] font-semibold text-gray-900 font-[var(--font-family-mono)]",children:n})]}),On=({active:e=!1,onClick:n,children:s})=>t.jsx("button",{type:"button",onClick:n,className:`h-8 rounded-lg px-3 text-[13px] font-medium transition-colors ${e?"bg-[var(--color-navy)] text-white":"bg-white border border-gray-200 text-gray-600 hover:bg-gray-50"}`,children:s}),jI="image/jpeg,image/png,image/webp,application/pdf,image/heic,image/heif,.heic,.heif",wI=10*1024*1024,NI=e=>new Promise((n,s)=>{const a=new FileReader;a.onload=()=>n(a.result.split(",")[1]),a.onerror=s,a.readAsDataURL(e)}),Rn={uploading:"Uploading…",uploaded:"Uploaded",throttled:"Uploaded — daily processing limit reached, resumes tomorrow",delayed:"Uploaded — processing delayed",oversize:"File exceeds 10 MB",errDocs:"Document limit reached for your plan",errStorage:"Storage limit reached for your plan",errUnsupported:"This file type isn't supported",errUpload:"Upload failed — please try again"},_I=({onUploaded:e})=>{const n=x.useRef(null),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[d,u]=x.useState([]),p=x.useRef(0),h=x.useRef(!1),f=(E,A,I,R)=>{const W=p.current++;return u(Y=>[{id:W,name:E,state:A,message:I,tone:R},...Y]),W},g=(E,A,I)=>{u(R=>R.map(W=>W.id===E?{...W,state:"done",message:A,tone:I}:W))},b=async(E,A)=>{try{return await te.post(E,A)}catch{return null}},v=E=>{var I;if((E==null?void 0:E.status)===201)return null;const A=(I=E==null?void 0:E.data)==null?void 0:I.error_code;return A==="not_enough_documents"?Rn.errDocs:A==="not_enough_storage"?Rn.errStorage:(E==null?void 0:E.status)===400?Rn.errUnsupported:Rn.errUpload},N=async E=>{if(h.current)return"throttled";const A=`/api/accounting/documents/${E}/extract/`;let I=await b(A,{});return(I==null?void 0:I.status)===429?(h.current=!0,"throttled"):(I==null?void 0:I.status)>=200&&(I==null?void 0:I.status)<300?"ok":(I=await b(A,{}),(I==null?void 0:I.status)===429?(h.current=!0,"throttled"):(I==null?void 0:I.status)>=200&&(I==null?void 0:I.status)<300?"ok":"failed")},w=async E=>{var X;if(E.size>wI){f(E.name,"done",Rn.oversize,"error");return}const A=f(E.name,"uploading",Rn.uploading,"pending");let I;try{I=await NI(E)}catch{g(A,Rn.errUpload,"error");return}const R=await b("/api/documents/upload",{image:I,type:E.type,name:E.name}),W=v(R);if(W){g(A,W,"error");return}const Y=(X=R==null?void 0:R.data)==null?void 0:X.document_id;if(Y==null){g(A,Rn.delayed,"warn"),e==null||e();return}const K=await N(Y);K==="ok"?g(A,Rn.uploaded,"ok"):K==="throttled"?g(A,Rn.throttled,"warn"):g(A,Rn.delayed,"warn"),e==null||e()},k=async E=>{l(!0);for(const A of Array.from(E))await w(A);l(!1)},_=E=>{var A;E.preventDefault(),a(!1),!o&&(A=E.dataTransfer.files)!=null&&A.length&&k(E.dataTransfer.files)},S=E=>{var A;if(o){E.target.value="";return}(A=E.target.files)!=null&&A.length&&k(E.target.files),E.target.value=""},T={pending:"text-gray-500",ok:"text-emerald-600",warn:"text-amber-600",error:"text-red-600"};return t.jsxs("div",{children:[t.jsx("div",{onClick:()=>{var E;
98return!o&&((E=n.current)==null?void 0:E.click())},onDragOver:E=>{E.preventDefault(),a(!0)},onDragLeave:()=>a(!1),onDrop:_,className:`relative flex flex-col items-center justify-center rounded-2xl border-2 border-dashed px-8 py-14 text-center transition-colors ${o?"border-gray-200 bg-gray-50 cursor-wait":s?"border-[var(--color-primary)] bg-[var(--color-primary-light)] cursor-pointer":"border-gray-300 bg-white hover:border-[var(--color-primary)] hover:bg-gray-50 cursor-pointer"}`,children:o?t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-[var(--color-primary)] border-t-transparent"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Uploading and processing…"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[var(--color-primary)]",children:t.jsx("svg",{className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",children:t.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.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),t.jsxs("p",{className:"text-[15px] font-medium text-gray-800",children:["Drag & drop, or ",t.jsx("span",{className:"text-[var(--color-primary)]",children:"browse files"})]}),t.jsx("p",{className:"mt-1 text-xs text-gray-400",children:"JPEG, PNG, WebP, HEIC or PDF · Max 10 MB · multiple files welcome"})]})}),d.length>0&&t.jsx("ul",{className:"mt-4 space-y-2",children:d.map(E=>t.jsxs("li",{className:"flex items-center justify-between gap-4 rounded-lg border border-gray-100 bg-white px-4 py-3",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-gray-800",children:E.name}),t.jsxs("span",{className:`flex shrink-0 items-center gap-2 text-xs font-medium ${T[E.tone]}`,children:[E.state==="uploading"&&t.jsx("span",{className:"w-3.5 h-3.5 border-2 border-current border-t-transparent rounded-full animate-spin"}),E.message]})]},E.id))}),t.jsx("input",{ref:n,type:"file",accept:jI,multiple:!0,className:"hidden",onChange:S})]})},Od=()=>{const e=Ba();return{showToast:s=>{e(JE(s))}}},kI=new Set(["not_source_document","rejected","failed"]),SI=e=>{if(e.routing_reason==="no_tax_profile")return{label:"Waiting for setup",cls:"bg-amber-50 text-amber-700"};if(e.routing_reason==="bank_statement"||e.accounting_status==="not_source_document")return{label:"Not a source document",cls:"bg-amber-50 text-amber-700"};switch(e.accounting_status){case"pending":case"processing":return{label:"Processing",cls:"bg-gray-100 text-gray-600"};case"posted":return{label:"Posted",cls:"bg-emerald-50 text-emerald-700"};case"needs_review":case"failed":return{label:"In review",cls:"bg-blue-50 text-blue-700"};case"rejected":return{label:"Rejected",cls:"bg-red-50 text-red-700"};default:return{label:"Processing",cls:"bg-gray-100 text-gray-600"}}},CI=e=>new Date(e).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"}),EI=({row:e})=>{const{label:n,cls:s}=SI(e);return t.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${s}`,children:n})},AI=()=>t.jsx("tr",{children:[160,90,70,40].map((e,n)=>t.jsx("td",{className:"px-6 py-4",children:t.jsx("div",{className:"h-3.5 animate-pulse rounded bg-gray-100",style:{width:e}})},n))}),TI=["Document","Uploaded","Status",""],LI=({items:e,count:n,page:s,setPage:a,pageSize:o,isLoading:l,error:d,emptyMessage:u,onDeleted:p})=>{const{showToast:h}=Od(),[f,g]=x.useState(new Set),[b,v]=x.useState(null),N=e.filter(E=>!f.has(E.document_id)),w=n>o,k=n===0?0:(s-1)*o+1,_=Math.min(s*o,n),S=async E=>{var A,I,R,W;if(b===null&&window.confirm(`Delete "${E.name}"? This cannot be undone.`)){v(E.document_id);try{const Y=await te.delete(`/api/accounting/documents/${E.document_id}/`);if((Y==null?void 0:Y.status)===204)g(K=>new Set(K).add(E.document_id)),p==null||p();else{const K=(A=Y==null?void 0:Y.data)==null?void 0:A.code,X=K==="document_has_entry"?"This document has a linked journal entry and can’t be deleted.":K==="document_not_terminal"?"This document can’t be deleted in its current status.":((I=Y==null?void 0:Y.data)==null?void 0:I.detail)??"Please try again in a moment.";h({title:"Could not delete document",message:X,variant:"danger"})}}catch(Y){h({title:"Could not delete document",message:((W=(R=Y==null?void 0:Y.response)==null?void 0:R.data)==null?void 0:W.detail)??"Please try again in a moment.",variant:"danger"})}finally{v(null)}}},T=async E=>{var I,R,W,Y;const A=window.open("about:blank","_blank");A&&(A.opener=null);try{const K=await te.get(`/api/accounting/documents/${E}/file-url/`),X=(K==null?void 0:K.status)===200?(I=K.data)==null?void 0:I.url:null;X?A?A.location.href=X:window.open(X,"_blank","noopener,noreferrer"):(A&&A.close(),h({title:"Could not open document",message:((R=K==null?void 0:K.data)==null?void 0:R.detail)??"Please try again in a moment.",variant:"danger"}))}catch(K){A&&A.close(),h({title:"Could not open document",message:((Y=(W=K==null?void 0:K.response)==null?void 0:W.data)==null?void 0:Y.detail)??"Please try again in a moment.",variant:"danger"})}};return t.jsxs(Te,{children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-100",children:TI.map(E=>t.jsx("th",{className:"px-6 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-gray-500",children:E},E))})}),t.jsx("tbody",{className:"divide-y divide-gray-50",children:l?Array.from({length:4}).map((E,A)=>t.jsx(AI,{},A)):d?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-sm text-gray-500",children:"Couldn't load document status — retrying shortly."})}):N.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-sm text-gray-500",children:u??"No documents yet — upload your first receipt above."})}):N.map(E=>t.jsxs("tr",{className:"transition-colors hover:bg-gray-50",children:[t.jsx("td",{className:"max-w-[320px] truncate px-6 py-4 font-medium text-gray-900",children:E.name}),t.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-gray-500",children:CI(E.created_at)}),t.jsx("td",{className:"px-6 py-4",children:t.jsx(EI,{row:E})}),t.jsx("td",{className:"px-6 py-4 text-right",children:t.jsxs("div",{className:"flex items-center justify-end gap-4",children:[t.jsx("button",{type:"button",onClick:()=>T(E.document_id),className:"text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:"View"}
98),kI.has(E.accounting_status)&&t.jsx("button",{type:"button",onClick:()=>S(E),disabled:b===E.document_id,className:"text-[13px] font-medium text-red-600 hover:underline disabled:opacity-50",children:b===E.document_id?"Deleting…":"Delete"})]})})]},E.document_id))})]})}),w&&!l&&!d&&t.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-3",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[k,"–",_," of ",n]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>a(s-1),disabled:s<=1,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent",children:"Prev"}),t.jsx("button",{onClick:()=>a(s+1),disabled:s*o>=n,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent",children:"Next"})]})]})]})},RI=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(0),o=x.useCallback(()=>a(l=>l+1),[]);return x.useEffect(()=>{let l=!1;return te.get("/api/accounting/documents/status/",{params:{page_size:1}}).then(d=>{var u;l||d==null||(d.status===200?n(((u=d.data)==null?void 0:u.counts)??null):n(null))}).catch(()=>{l||n(null)}),()=>{l=!0}},[s]),{counts:e,refetch:o}},II=["Drop in a receipt or invoice.","The accounting agent reads and books it.","Track each document’s status below."],PI=3e4,wh=[{value:"pending",label:"Pending"},{value:"processing",label:"Processing"},{value:"posted",label:"Posted"},{value:"needs_review",label:"Needs review"},{value:"failed",label:"Failed"},{value:"rejected",label:"Rejected"},{value:"not_source_document",label:"Not source docs"}],FI={pending:0,processing:0,posted:0,needs_review:0,failed:0,rejected:0,not_source_document:0,total:0},Ub=({label:e,value:n,selected:s,onClick:a})=>t.jsx("button",{type:"button",onClick:a,"aria-pressed":s,className:`block w-full rounded-2xl text-left transition-shadow focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)] ${s?"ring-2 ring-[var(--color-primary)]":"hover:ring-1 hover:ring-gray-300"}`,children:t.jsx(ka,{label:e,value:n})}),DI=({counts:e,active:n,onToggle:s,onClear:a})=>t.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-4",children:[t.jsx(Ub,{label:"Total",value:String(e.total),selected:n===null,onClick:a}),wh.map(o=>t.jsx(Ub,{label:o.label,value:String(e[o.value]),selected:n===o.value,onClick:()=>s(o.value)},o.value))]}),OI=({active:e,onToggle:n})=>t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:wh.map(s=>t.jsx(On,{active:e===s.value,onClick:()=>n(s.value),children:s.label},s.value))}),$I=()=>{var E;const e=Xe(),{role:n,isLoading:s}=ln(),a=n==="owner"||n==="accountant",[o,l]=x.useState(null),{items:d,count:u,page:p,setPage:h,pageSize:f,isLoading:g,error:b,refetch:v}=Or("/api/accounting/documents/status/",o?{status:o}:void 0),{counts:N,refetch:w}=RI(),k=x.useCallback(()=>{v(),w()},[v,w]),_=x.useCallback(A=>{l(I=>I===A?null:A),h(1)},[h]),S=x.useCallback(()=>{l(null),h(1)},[h]),T=((E=wh.find(A=>A.value===o))==null?void 0:E.label)??null;return x.useEffect(()=>{!s&&!a&&e("/dashboard",{replace:!0})},[s,a,e]),x.useEffect(()=>{const A=setInterval(k,PI);return()=>clearInterval(A)},[k]),s?t.jsx(js,{}):a?t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8",children:[t.jsx(ut,{title:"Documents",subtitle:"Drop in a receipt or invoice — the accounting agent reads it, books it, and tracks it here."}),t.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[t.jsx("div",{className:"lg:col-span-2",children:t.jsx(_I,{onUploaded:k})}),t.jsxs(Te,{padding:!0,className:"lg:col-span-1",children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"How it works"}),t.jsx("ol",{className:"mt-3 space-y-3",children:II.map((A,I)=>t.jsxs("li",{className:"flex items-start gap-2.5 text-[13.5px] text-gray-600",children:[t.jsx("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[var(--color-primary-light)] text-[11px] font-semibold text-[var(--color-primary)]",children:I+1}),A]},I))})]})]}),t.jsx("div",{className:"mt-6",children:t.jsx(DI,{counts:N??FI,active:o,onToggle:_,onClear:S})}),((N==null?void 0:N.not_source_document)??0)>0&&t.jsxs("div",{className:"mt-6 flex items-center gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-2.5 text-sm text-amber-800",children:[t.jsx("span",{className:"flex-1",children:"Bank statements aren't source documents — the agent doesn't book them. Connect your bank or add these transactions in Bank Transactions."}),t.jsx(be,{to:"/accounting/bank-connections",className:"shrink-0 font-semibold text-amber-900 underline hover:text-amber-700",children:"Bank Transactions"})]}),t.jsxs("section",{className:"mt-8",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold uppercase tracking-wider text-gray-500",children:"Document status"}),t.jsx(OI,{active:o,onToggle:_})]}),t.jsx(LI,{items:d,count:u,page:p,setPage:h,pageSize:f,isLoading:g,error:b,emptyMessage:T?`No ${T.toLowerCase()} documents.`:void 0,onDeleted:k})]})]})}):null},Nh="/api/accounting/cards/",MI=()=>Or(Nh),Vc=e=>{if(typeof e=="string")return e;if(e&&typeof e=="object"){const n=e;if(typeof n.detail=="string")return n.detail;const s=Object.keys(n)[0],a=s?n[s]:void 0;if(Array.isArray(a)&&typeof a[0]=="string")return a[0];
98if(typeof a=="string")return a}return"Could not save the card. Please try again."},BI=()=>{const[e,n]=x.useState(null);return{classify:x.useCallback(async(a,o)=>{n(a);try{const l=await te.patch(`${Nh}${a}/`,o);return l==null?{ok:!1,error:"Request cancelled."}:l.status===200?{ok:!0,data:l.data}:{ok:!1,error:Vc(l.data)}}catch(l){const d=l==null?void 0:l.response;return{ok:!1,error:Vc(d==null?void 0:d.data)}}finally{n(null)}},[]),savingId:e}},zb=e=>{const n={};if(e&&typeof e=="object"&&!Array.isArray(e))for(const[s,a]of Object.entries(e))s!=="detail"&&(Array.isArray(a)&&typeof a[0]=="string"?n[s]=a[0]:typeof a=="string"&&(n[s]=a));return n},UI=()=>{const[e,n]=x.useState(!1);return{create:x.useCallback(async a=>{n(!0);try{const o=await te.post(Nh,a);return o==null?{ok:!1,error:"Request cancelled.",fieldErrors:{}}:o.status===201?{ok:!0,data:o.data}:o.status===429?{ok:!1,error:"Too many cards added just now. Please try again later.",fieldErrors:{}}:{ok:!1,error:Vc(o.data),fieldErrors:zb(o.data)}}catch(o){const l=o==null?void 0:o.response;return{ok:!1,error:Vc(l==null?void 0:l.data),fieldErrors:zb(l==null?void 0:l.data)}}finally{n(!1)}},[]),saving:e}},Sf={visa:"Visa",mastercard:"Mastercard",amex:"American Express",other:"Card"},Wb={unidentified:{label:"Needs identifying",cls:"bg-amber-50 text-amber-700"},business:{label:"Business",cls:"bg-emerald-50 text-emerald-700"},personal:{label:"Personal",cls:"bg-gray-100 text-gray-600"}},zI=e=>new Date(e).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"}),WI=({classification:e})=>{const{label:n,cls:s}=Wb[e]??Wb.unidentified;return t.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${s}`,children:n})},HI="Business cards get their own card account automatically; personal card payments are routed for review.",qI=({card:e,onDone:n,onCancel:s})=>{const{classify:a,savingId:o}=BI(),[l,d]=x.useState(null),[u,p]=x.useState(null),h=async()=>{if(!l)return;p(null);const g=await a(e.id,{classification:l});g.ok?n(l):p(g.error)},f=o===e.id;return t.jsxs("div",{className:"mt-4 rounded-xl border border-gray-200 bg-gray-50 p-4",children:[t.jsx("p",{className:"text-[13.5px] font-medium text-gray-700",children:"Whose card is this?"}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:["business","personal"].map(g=>t.jsx("button",{type:"button",onClick:()=>{d(g),p(null)},"aria-pressed":l===g,className:`rounded-lg border px-4 py-2 text-sm font-semibold capitalize transition-colors ${l===g?"border-[var(--color-primary)] bg-[var(--color-primary-light)] text-[var(--color-primary)]":"border-gray-300 bg-white text-gray-700 hover:border-gray-400"}`,children:g},g))}),t.jsx("p",{className:"mt-3 text-[12.5px] text-gray-500",children:HI}),u&&t.jsx("p",{className:"mt-3 rounded-lg bg-red-50 px-3 py-2 text-[13px] text-red-700",children:u}),t.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[t.jsxs("button",{type:"button",onClick:h,disabled:!l||f,className:"inline-flex h-[38px] items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-50",children:[f&&t.jsx(jt,{light:!0}),f?"Saving…":"Confirm"]}),t.jsx("button",{type:"button",onClick:s,disabled:f,className:"text-[13px] font-medium text-gray-500 hover:text-gray-800 disabled:opacity-50",children:"Cancel"})]})]})},VI=({card:e,onClassified:n})=>{const[s,a]=x.useState(!1),o=e.classification==="unidentified";return t.jsxs("div",{className:"px-6 py-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-900",children:Sf[e.network]??Sf.other}),t.jsxs("span",{className:"font-[var(--font-family-mono)] text-sm text-gray-500",children:["····",e.last4]}),t.jsx(WI,{classification:e.classification})]}),e.label&&t.jsx("p",{className:"mt-1 max-w-[46ch] truncate text-[13px] text-gray-600",children:e.label}),t.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["Detected ",zI(e.created_at),e.mapped_account_code&&t.jsxs(t.Fragment,{children:[" · Posts to ",e.mapped_account_code,e.mapped_account_name?` ${e.mapped_account_name}`:""]})]})]}),o&&!s&&t.jsx("button",{type:"button",onClick:()=>a(!0),className:"shrink-0 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-[13px] font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:"Identify card"})]}),o&&s&&t.jsx(qI,{card:e,onDone:l=>{a(!1),n(l)},onCancel:()=>a(!1)})]})},YI=[{value:"visa",label:"Visa"},{value:"mastercard",label:"Mastercard"},{value:"amex",label:"American Express"},{value:"other",label:"Other"}],GI=100,xp="w-full rounded-lg border border-gray-200 px-3 py-2 text-sm text-gray-900 focus:border-[#0066FF] focus:outline-none focus:ring-1 focus:ring-[#0066FF]",sc=({message:e})=>e?t.jsx("p",{className:"mt-1 text-xs text-red-600",children:e}):null,KI=({open:e,onClose:n,onAdded:s})=>{const{create:a,saving:o}
98=UI(),[l,d]=x.useState("visa"),[u,p]=x.useState(""),[h,f]=x.useState(""),[g,b]=x.useState(null),[v,N]=x.useState({}),[w,k]=x.useState(""),_=()=>{d("visa"),p(""),f(""),b(null),N({}),k("")},S=()=>{_(),n()},T=async()=>{if(k(""),!/^\d{4}$/.test(u)){N({last4:"Enter the last four digits of the card number."});return}if(g===null){N({classification:"Choose whose card this is."});return}N({});const E={network:l,last4:u,classification:g};h.trim()&&(E.label=h.trim());const A=await a(E);if(A.ok){const I=`${Sf[A.data.network]??"Card"} ····${A.data.last4}`;S(),s(I);return}N(A.fieldErrors),Object.keys(A.fieldErrors).length===0&&k(A.error)};return e?t.jsx("section",{className:"mt-6",children:t.jsx(Te,{children:t.jsxs("form",{onSubmit:E=>{E.preventDefault(),T()},className:"px-6 py-5",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-900",children:"Add a card"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Tell us the card and whose it is. We handle how it is recorded."}),t.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"card-network",className:"block text-xs font-medium text-gray-700",children:"Card network"}),t.jsx("select",{id:"card-network",value:l,onChange:E=>d(E.target.value),className:`mt-1 ${xp}`,children:YI.map(E=>t.jsx("option",{value:E.value,children:E.label},E.value))}),t.jsx(sc,{message:v.network})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"card-last4",className:"block text-xs font-medium text-gray-700",children:"Last four digits"}),t.jsx("input",{id:"card-last4",value:u,onChange:E=>p(E.target.value.replace(/\D/g,"").slice(0,4)),inputMode:"numeric",autoComplete:"off",maxLength:4,placeholder:"1234","aria-invalid":!!v.last4,className:`mt-1 ${xp}`}),t.jsx(sc,{message:v.last4})]}),t.jsxs("div",{className:"sm:col-span-2",children:[t.jsxs("label",{htmlFor:"card-label",className:"block text-xs font-medium text-gray-700",children:["Name it ",t.jsx("span",{className:"font-normal text-gray-400",children:"(optional)"})]}),t.jsx("input",{id:"card-label",value:h,onChange:E=>f(E.target.value),maxLength:GI,autoComplete:"off",placeholder:"Shop card",className:`mt-1 ${xp}`}),t.jsx(sc,{message:v.label})]})]}),t.jsxs("fieldset",{className:"mt-4",children:[t.jsx("legend",{className:"text-xs font-medium text-gray-700",children:"Whose card is this?"}),t.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:["business","personal"].map(E=>t.jsx("button",{type:"button",onClick:()=>b(E),"aria-pressed":g===E,className:`rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${g===E?"border-[#0066FF] bg-blue-50 text-[#0066FF]":"border-gray-200 text-gray-700 hover:bg-gray-50"}`,children:E==="business"?"Business card":"Personal card"},E))}),t.jsx(sc,{message:v.classification})]}),w&&t.jsx("p",{className:"mt-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:w}),t.jsxs("div",{className:"mt-5 flex items-center gap-2",children:[t.jsxs("button",{type:"submit",disabled:o,className:"inline-flex items-center gap-2 rounded-lg bg-[#0066FF] px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-[#0052cc] disabled:opacity-60",children:[o&&t.jsx(jt,{}),"Add card"]}),t.jsx("button",{type:"button",onClick:S,disabled:o,className:"rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-60",children:"Cancel"})]})]})})}):null},QI=()=>{const e=Xe(),{role:n,isLoading:s}=ln(),a=n==="owner"||n==="accountant",{items:o,count:l,page:d,setPage:u,pageSize:p,isLoading:h,error:f,refetch:g}=MI(),{toast:b,showSuccess:v}=hh(),[N,w]=x.useState(!1),[k,_]=x.useState(!1),S=I=>{v(`${I} added.`),g()},T=x.useMemo(()=>{const I=R=>R==="unidentified"?0:1;return[...o].sort((R,W)=>I(R.classification)-I(W.classification))},[o]),E=I=>{v(I==="business"?"Card saved. Future payments to it will post automatically.":"Card saved. Payments to it will be routed for review."),I==="business"&&w(!0),g()};if(x.useEffect(()=>{!s&&!a&&e("/dashboard",{replace:!0})},[s,a,e]),s)return t.jsx(js,{});if(!a)return null;const A=l>p;return t.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:[t.jsx(xh,{toast:b}),t.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8",children:[t.jsxs(be,{to:"/settings?tab=integrations",className:"inline-flex items-center gap-1.5 text-sm font-medium text-gray-500 transition-colors hover:text-gray-900",children:[t.jsx("span",{"aria-hidden":"true",children:"←"})," Settings"]}),t.jsx("div",{className:"mt-4",children:t.jsx(ut,{title:"Cards",subtitle:"Tell us whose card is whose, and payments to it file themselves from then on.",right:k?void 0:t.jsx("button",{type:"button",onClick:()=>_(!0),className:"rounded-lg bg-[#0066FF] px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-[#0052cc]",children:"Add a card"})})}),t.jsx(KI,{open:k,onClose:()=>_(!1),onAdded:S}),N&&t.jsxs("div",{className:"mt-6 flex items-start gap-3 rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800",children:[t.jsx("span",{className:"flex-1",children:"Connect this card’s account under Bank Transactions and its own transactions flow in automatically — the same way your bank account does."}),t.jsx(be,{to:"/accounting/bank-connections",className:"shrink-0 font-semibold text-emerald-900 underline hover:text-emerald-700",children:"Bank Transactions"}),t.jsx("button",{type:"button",onClick:()=>w(!1),"aria-label":"Dismiss",className:"shrink-0 text-emerald-700 hover:text-emerald-900",children:"✕"})]}),t.jsx("section",{className:"mt-6",children:t.jsxs(Te,{children:[h?t.jsx("div",{className:"divide-y divide-gray-50",children:Array.from({length:3}).map((I,R)=>t.jsxs("div",{className:"px-6 py-5",children:[t.jsx("div",{className:"h-3.5 w-48 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"mt-2 h-3 w-32 animate-pulse rounded bg-gray-100"})]},R))}):f?t.jsx("p",{className:"px-6 py-12 text-center text-sm text-gray-500",children:"Couldn’t load your cards — retrying shortly."}):T.length===0?t.jsx("p",{className:"px-6 py-12 text-center text-sm text-gray-500",children:"No cards detected yet — cards appear automatically when card payments show up in your bank activity."}):t.jsx("div",{className:"divide-y divide-gray-50",children:T.map(I=>t.jsx(VI,{card:I,onClassified:E},I.id))}),A&&!h&&!f&&t.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-3",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[(d-1)
98*p+1,"–",Math.min(d*p,l)," of ",l]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>u(d-1),disabled:d<=1,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40",children:"Prev"}),t.jsx("button",{onClick:()=>u(d+1),disabled:d*p>=l,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40",children:"Next"})]})]})]})})]})]})},JI=/^\d{4}-\d{2}-\d{2}/;function Cf(e){if(typeof e!="string"||!JI.test(e))throw new Error(`parseIsoDate: not an ISO calendar date: ${String(e)}`);const[n,s,a]=e.slice(0,10).split("-").map(Number),o=new Date(n,s-1,a);if(Number.isNaN(o.getTime()))throw new Error(`parseIsoDate: invalid calendar date: ${e}`);return o}const XI={year:"numeric",month:"short",day:"numeric"};function jn(e,n){return Cf(e).toLocaleDateString("en-CA",n??XI)}const ZI=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get("/api/accounting/dashboard/").then(f=>{var g;h||f!=null&&(f.status===200?n(f.data):(n(null),l(((g=f.data)==null?void 0:g.detail)??"Failed to load dashboard")))}).catch(f=>{var g,b;h||l(((b=(g=f==null?void 0:f.response)==null?void 0:g.data)==null?void 0:b.detail)??"Failed to load dashboard")}).finally(()=>{h||a(!1)}),()=>{h=!0}},[d]),{data:e,isLoading:s,error:o,refetch:p}},Yc="font-[var(--font-family-mono)]",Sa=e=>{const n=Number(e);return Number.isFinite(n)?n:0},rc=140,gp=40,eP=({values:e})=>{const n=e.length;if(n===0)return null;const s=Math.max(...e,0),a=Math.min(...e,0),o=s-a||1,l=h=>n===1?rc/2:h/(n-1)*rc,d=h=>gp-(h-a)/o*gp,u=e.map((h,f)=>`${l(f).toFixed(1)},${d(h).toFixed(1)}`).join(" "),p=d(0).toFixed(1);return t.jsxs("svg",{viewBox:`0 0 ${rc} ${gp}`,className:"h-10 w-full text-white/70",preserveAspectRatio:"none","aria-hidden":!0,children:[t.jsx("line",{x1:"0",y1:p,x2:rc,y2:p,className:"text-white/25",stroke:"currentColor",strokeWidth:"1",strokeDasharray:"3 3"}),t.jsx("polyline",{points:u,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})]})},tP=({label:e,value:n,months:s,connectedAccounts:a})=>{const o=s.map(l=>Sa(l.inflow)-Sa(l.outflow));return t.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-[var(--color-navy)] p-6 shadow-sm",children:[t.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute -right-8 -top-10 h-40 w-40 rounded-full bg-[var(--color-primary)] opacity-25 blur-3xl"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-white/60",children:e}),t.jsx("div",{className:`mt-2 text-[28px] font-semibold text-white ${Yc}`,children:n}),a>0&&t.jsxs("div",{className:"mt-1 text-[13px] text-white/50",children:["Across ",a," connected account",a===1?"":"s"]}),t.jsx("div",{className:"mt-3",children:t.jsx(eP,{values:o})})]})]})},nP=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],sP=e=>{const n=Number(e.slice(5,7));return nP[n-1]??e},yp=96,rP=({months:e})=>{const n=e.map(d=>Sa(d.inflow)),s=e.map(d=>Sa(d.outflow)),a=Math.max(0,...n,...s),o=a===0,l=d=>o?0:Math.round(d/a*yp);return t.jsxs(Te,{padding:!0,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Cash flow · last 6 months"}),t.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-gray-500",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500","aria-hidden":!0})," In"]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500","aria-hidden":!0})," Out"]})]})]}),t.jsx("div",{className:"mt-5 flex items-end gap-2",style:{height:yp},children:e.map(d=>t.jsxs("div",{className:"flex flex-1 items-end justify-center gap-1",style:{height:yp},children:[t.jsx("div",{className:"w-3 rounded-t bg-emerald-500",style:{height:l(Sa(d.inflow))},"aria-hidden":!0}),t.jsx("div",{className:"w-3 rounded-t bg-amber-500",style:{height:l(Sa(d.outflow))},"aria-hidden":!0})]},d.month))}),t.jsx("div",{className:"mt-2 flex gap-2",children:e.map(d=>t.jsx("div",{className:"flex-1 text-center text-[11px] text-gray-400",children:sP(d.month)},d.month))}),o&&t.jsx("div",{className:"mt-3 text-center text-[12.5px] text-gray-400",children:"No cash activity in the last 6 months"})]})},aP=({attention:e})=>{const n=[{count:e.entries_needs_review,label:"entries need review",to:"/accounting/ledger"},{count:e.entries_unassigned,label:"unassigned entries",to:"/accounting/ledger"},{count:e.documents_processing,label:"documents processing",to:"/accounting/documents"}].filter(s=>s.count>0);return t.jsxs(Te,{padding:!0,children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Needs attention"}),n.length===0?t.jsx("p",{className:"mt-3 text-[13.5px] text-gray-400",children:"Nothing needs your attention."}):t.jsx("ul",{className:"mt-3 space-y-1",children:n.map(s=>t.jsx("li",{children:t.jsxs(be,{to:s.to,className:"group -mx-2 flex items-center justify-between rounded-lg px-2 py-2 transition-colors hover:bg-gray-50",children:[t.jsxs("span",{className:"flex items-center gap-2.5 text-[13.5px] text-gray-700",children:[t.jsx("span",{className:`inline-flex min-w-[22px] justify-center rounded-md bg-gray-100 px-1.5 py-0.5 text-[12px] font-semibold text-gray-700 ${Yc}`,children:s.count}),s.label]}),t.jsx("span",{className:"text-[13px] text-[var(--color-primary)] group-hover:underline",children:"View"})]})},s.label))})]})},iP=({rows:e,fmtAmount:n,fmtDate:s})=>t.jsxs(Te,{padding:!0,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Recent activity"}),t.jsx(be,{to:"/accounting/ledger",className:"text-[13px] text-[var(--color-primary)] hover:underline",children:"View ledger"})]}),e.length===0?t.jsx("p",{className:"mt-3 text-[13.5px] text-gray-400",children:"No recent activity yet."}):t.jsx("ul",{className:"mt-3 divide-y divide-gray-50",children:e.map(a=>t.jsxs("li",{className:"flex items-center gap-3 py-2.5",children:[t.jsxs("span",{className:`shrink-0 text-[12px] text-gray-400 ${Yc}`,children:["#",a.entry_number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[13.5px] text-gray-800",children:a.description}),t.jsx("div",{className:"text-[12px] text-gray-400",children:s(a.entry_date)})]}),t.jsx("span",{className:`shrink-0 text-[13.5px] text-gray-900 ${Yc}`,children:n(a.amount)})]},a.entry_number))})]}),ba=(e,n)=>new Intl.NumberFormat("en-CA",{style:"currency",currency:n??"CAD"}).format(Number(e)),ac=e=>jn(e,{year:"numeric",month:"long",day:"numeric"}),Sw="font-[var(--font-family-mono)]",Hb=({label:e,value:n,sub:s,chip:a})=>t.jsxs(Te,{padding:!0,children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:e}),t.jsx("div",{className:`mt-2 text-[22px] font-semibold text-gray-900 ${Sw}`,children:n}),s&&t.jsx("div",{className:"mt-1 text-[13px] text-gray-500",children:s}),a&&t.jsx("div",{className:"mt-2 inline-flex items-center rounded-md bg-[var(--color-primary-light)] px-2 py-1 text-[11.5px] font-medium text-[var(--color-primary)]",children:a})]}),qb=({label:e,value:n,sub:s,dot:a})=>t.jsxs(Te,{padding:!0,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`h-2 w-2 rounded-full ${a}`,"aria-hidden":!0}),t.jsx("span",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:e})]}),t.jsx("div",{className:`mt-2 text-[22px] font-semibold text-gray-900 ${Sw}`,children:n}),s&&t.jsx("div",{className:"mt-1 text-[13px] text-gray-500",children:s})]}),oP=({children:e})=>t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-5xl px-6 py-8",children:e})}),lP={ca_registered:"Net GST/HST & PST collected minus credits",us:"Sales tax collected"},cP=e=>e<12?"Good morning":e<18?"Good afternoon":"Good evening",dP=({data:e,name:n})=>{const s=e.currency,a=e.fiscal_year,o=`${cP(new Date().getHours())}${n?`, ${n}`:""}`,l=a?`Fiscal year ${ac(a.start)} – ${ac(a.end)}`:"Your financial overview";return t.jsxs(t.Fragment,{children:[t.jsx(ut,{title:o,subtitle:l,right:t.jsxs("span",{className:"whitespace-nowrap text-[13px] text-gray-400",children:["As of ",ac(e.as_of)]})}),t.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[t.jsx(tP,{label:"Cash on hand",value:ba(e.cash_on_hand,s),months:e.monthly_cash_flow,connectedAccounts:e.connected_accounts}),t.jsx(Hb,{label:"Profit · YTD",value:ba(e.profit_to_date,s),sub:a?"This fiscal year":"Since books start"}),e.tax_net!==null&&t.jsx(Hb,{label:"Tax set aside",value:ba(e.tax_net,s),sub:e.tax_mode?lP[e.tax_mode]:void 0,chip:e.filing_deadline?`GST/HST filing due ${e.filing_deadline}`:void 0})]}),t.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(qb,{label:"Money coming in",value:ba(e.receivables,s),sub:"Accounts receivable",dot:"bg-emerald-500"}),t.jsx(qb,{label:"Money going out",value:ba(e.payables,s),sub:"Accounts payable",dot:"bg-
98amber-500"})]}),t.jsx("div",{className:"mt-4",children:t.jsx(rP,{months:e.monthly_cash_flow})}),t.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[t.jsx(aP,{attention:e.attention}),t.jsx(iP,{rows:e.recent_activity,fmtAmount:d=>ba(d,s),fmtDate:ac})]})]})},uP=()=>t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-8 w-40 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"mt-2 h-4 w-56 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[0,1,2,3,4].map(e=>t.jsxs("div",{className:"rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:[t.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"mt-3 h-7 w-32 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"mt-2 h-3 w-28 animate-pulse rounded bg-gray-100"})]},e))})]}),mP=({error:e,onRetry:n})=>t.jsxs("div",{className:"max-w-md rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:[t.jsx("p",{className:"text-sm text-gray-700",children:e}),t.jsx("button",{type:"button",onClick:n,className:"mt-4 inline-flex items-center rounded-lg bg-gray-900 px-4 py-2 text-sm font-medium text-white hover:bg-gray-800",children:"Try again"})]}),pP=()=>{var d,u,p;const{data:e,isLoading:n,error:s,refetch:a}=ZI(),o=ht(h=>h.auth),l=((u=(d=o.user)==null?void 0:d.user)==null?void 0:u.first_name)??((p=o.user)==null?void 0:p.first_name)??"";return t.jsx(oP,{children:n?t.jsx(uP,{}):s?t.jsx(mP,{error:s,onRetry:a}):e?t.jsx(dP,{data:e,name:l}):null})},fP=[{value:"revenue",label:"Revenue"},{value:"expenses",label:"Expenses"},{value:"payable",label:"Payable"},{value:"receivable",label:"Receivable"},{value:"cash",label:"Cash"}],hP=e=>{const n={};return e.tab&&(n.tab=e.tab),e.status&&(n.status=e.status),e.date_from&&(n.date_from=e.date_from),e.date_to&&(n.date_to=e.date_to),e.unattributed&&(n.unattributed="true"),Or("/api/accounting/entries/",n)},xP=(e,n)=>te.post(`/api/accounting/entries/${e}/attribute/`,{counterparty_id:n}),gP=e=>{const n={};return e.role&&(n.role=e.role),n.archived="false",e.search&&(n.search=e.search),Or("/api/accounting/counterparties/",n)},yP=e=>te.post("/api/accounting/counterparties/",e),bP=e=>te.post(`/api/accounting/counterparties/${e}/archive/`),vP=e=>te.post(`/api/accounting/counterparties/${e}/unarchive/`),Lr=e=>e.display_status??e.status,Vb={posted:"Posted",corrected:"Corrected",reversed:"Reversed",reversal:"Reversal",draft:"Draft",replaced:"Replaced",voided:"Voided"},Ks=e=>{const n=String(Lr(e)??"");if(Vb[n])return Vb[n];const s=n.replace(/_/g," ").trim();return s?s.charAt(0).toUpperCase()+s.slice(1):"—"},_h=[{value:"",label:"Posted"},{value:"live",label:"Live"},{value:"corrected",label:"Corrected"},{value:"reversed",label:"Reversed"},{value:"reversals",label:"Reversal entries"},{value:"all",label:"All"}],Cw=e=>{switch(e.display_status){case"reversal":return"reversal";case"corrected":return"corrected";case"reversed":return"reversed";case"posted":return e.live_entry!=null&&e.live_entry.id===e.id?"live":"other";default:return"other"}},Ga=e=>Cw(e)==="live",jP={owner:["assign_counterparty"],staff:["correct","change_counterparty","reverse","merge","attach_document"],accountant:["adjust","void"]},Ew=(e,n)=>Ga(n)?[...jP[e]]:[],Gc=(e,n,s)=>Ew(e,n).includes(s),wP=e=>{var n;switch(Cw(e)){case"corrected":return`Corrected by ${((n=e.corrected_by)==null?void 0:n.number)??"a later entry"}`;case"reversed":return`Reversed by ${e.reversed_by_entry_number_display??"a reversal entry"}`;case"reversal":return`Reversal of ${e.reverses_entry_number_display??"an earlier entry"}`;default:return null}},Aw=e=>e.live_entry!=null&&e.live_entry.id!==e.id?e.live_entry:null,Eo=e=>{if(Ga(e))return null;const n=[],s=wP(e);s&&n.push(`${s}.`);const a=Aw(e);return a&&n.push(`Changes are made on the live entry${a.number?`, ${a.number}`:""}.`),n.length>0?n.join(" "):null},Tw=e=>typeof e.reverses_line_id=="string"&&e.reverses_line_id!=="",Lw=e=>e.reverses_line_id===null,NP=/^(\d+)(?:\.(\d{1,2}))?$/,Yb=e=>{if(e==null||e==="")return 0;const n=NP.exec(String(e).trim());if(!n)return null;const s=Number(n[1])*100+Number((n[2]??"").padEnd(2,"0")||"0");return Number.isSafeInteger(s)?s:null},Gb=e=>`${Math.floor(e/100)}.${String(e%100).padStart(2,"0")}`,$d=e=>{const n={debits:e.total_debits??null,credits:e.total_credits??null,effective:!1},s=e.lines??[],a=s.filter(d=>
98!Tw(d));if(a.length===0||a.length===s.length)return n;let o=0,l=0;for(const d of a){const u=Yb(d.debit),p=Yb(d.credit);if(u===null||p===null)return n;o+=u,l+=p}return!Number.isSafeInteger(o)||!Number.isSafeInteger(l)?n:{debits:Gb(o),credits:Gb(l),effective:!0}},kh=e=>$d(e).debits,Rr=e=>e==null?null:`JE-${String(e).padStart(4,"0")}`,_P={original:"Original",correction:"Correction",reversal:"Reversal",restore:"Restore"},kP=e=>{const n=e.replace(/_/g," ").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):"—"},SP=e=>_P[e]??kP(e),CP=e=>{try{return jn(e)}catch{return e}},EP={light:{box:"rounded-xl border border-gray-100 bg-white",title:"border-b border-gray-100 px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400",row:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-gray-50 px-4 py-2 text-[13px] text-gray-700",current:"bg-gray-50",number:"font-[var(--font-family-mono)] tabular-nums font-semibold text-gray-900",muted:"text-gray-500",tag:"rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",liveTag:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700",foot:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-2.5 text-[12.5px] text-gray-600",button:"rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-50"},dark:{box:"rounded-lg border border-white/10 bg-white/[0.02]",title:"border-b border-white/10 px-3 py-2 text-[11px] font-medium uppercase tracking-wide text-white/30",row:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-white/5 px-3 py-2 text-sm text-white/70",current:"bg-white/5",number:"font-mono font-semibold text-white/90",muted:"text-white/50",tag:"rounded-full bg-white/10 px-2 py-0.5 text-[11px] font-medium text-white/70",liveTag:"rounded-full bg-emerald-500/15 px-2 py-0.5 text-[11px] font-medium text-emerald-300",foot:"flex flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2.5 text-sm text-white/60",button:"rounded-md border border-white/15 px-3 py-1.5 text-sm text-white/80 transition-colors hover:bg-white/5"}},Sh=({chain:e,currentId:n,liveEntry:s=null,truncated:a=!1,onOpenEntry:o,tone:l="light",className:d=""})=>{if(!e||e.length===0||e.length===1&&!a)return null;const u=EP[l],p=s!=null&&s.id===n,h=(s==null?void 0:s.number)??"the live entry";return t.jsxs("section",{"aria-label":"Entry history",className:`${u.box} ${d}`,children:[t.jsx("div",{className:u.title,children:"Entry history"}),t.jsx("ol",{children:e.map(f=>{const g=f.id===n,b=s!=null&&f.id===s.id,v=SP(f.role),N=Ks({status:f.display_status,display_status:f.display_status});return t.jsxs("li",{"aria-current":g?"true":void 0,className:`${u.row} ${g?u.current:""}`,children:[t.jsx("span",{className:u.number,children:f.number??"—"}),t.jsx("span",{className:u.muted,children:CP(f.date)}),t.jsx("span",{children:v}),N!==v&&t.jsx("span",{className:u.muted,children:N}),b&&t.jsx("span",{className:u.liveTag,children:"Live"}),g&&t.jsx("span",{className:u.tag,children:"This entry"})]},f.id)})}),t.jsxs("div",{className:u.foot,children:[a&&t.jsx("span",{role:"note",children:"This chain is longer than what is shown here."}),s==null?!a&&t.jsx("span",{children:"This chain has no live entry."}):p?t.jsx("span",{children:"This is the live entry."}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["The live entry is ",h,"."]}),o&&t.jsxs("button",{type:"button",onClick:()=>o(s),className:u.button,children:["Open ",h]})]})]})]})},Rw=e=>({id:e.id,entry_number:e.entry_number??null,entry_number_display:e.entry_number_display??null,entry_date:e.entry_date,description:e.description??"",source:e.source,status:e.status,created_by:e.created_by,voided_at:e.voided_at??null,voided_by:e.voided_by??null,void_reason:e.void_reason??"",source_document_id:e.source_document_id??null,total_debits:e.total_debits,total_credits:e.total_credits,counterparty:e.counterparty??null,reverses_entry_id:e.reverses_entry_id??null,reversed_by_entry_id:e.reversed_by_entry_id??null,corrects_entry_id:e.corrects_entry_id??null,reverses_entry_number_display:e.reverses_entry_number_display??null,reversed_by_entry_number_display:e.reversed_by_entry_number_display??null,corrects_entry_number_display:e.corrects_entry_number_display??null,display_status:e.display_status,corrected_by:e.corrected_by,live_entry:e.live_entry,chain_root:e.chain_root,chain:e.chain,chain_truncated:e.chain_truncated,lines:(e.lines??[]).map(n=>({id:n.id,account_id:n.account_id,account_code:n.account_code??null,account_name:n.account_name??null,debit:n.debit??null,credit:n.credit??null,description:n.description??"",tax_code:n.tax_code??"",line_order:n.line_order,reverses_line_id:n.reverses_line_id}))}),Ch=e=>{const[n,s]=x.useState(null),[a,o]=x.useState(0),l=x.useCallback(()=>o(d=>d+1),[]);return x.useEffect(()=>{if(!e){s(null);return}let d=!1;return s({kind:"loading"}),te.get(`/api/accounting/entries/${encodeURIComponent(e)}/`).then(u=>{var p;d||((u==null?void 0:u.status)===200&&u.data?s({kind:"ready",row:Rw(u.data)}):s({kind:"error",message:((p=u==null?void 0:u.data)==null?void 0:p.detail)??"Could not load this entry."}))}).catch(()=>{d||s({kind:"error",message:"Could not load this entry."})}),()=>{d=!0}},[e,a]),{entry:n,refetch:l}},Kb=50,AP=(e="")=>{const[n,s]=x.useState([]),[a,o]=x.useState(0),[l,d]=x.useState(1),[u,p]=x.useState(!0),[h,f]=x.use
98State(null),[g,b]=x.useState(0),v=x.useCallback(()=>b(N=>N+1),[]);return x.useEffect(()=>{let N=!1;p(!0),f(null);const w={page:l,page_size:Kb};return e&&(w.status=e),te.get("/api/accounting/entries/",{params:w}).then(k=>{var _;if(!(N||k==null))if(k.status===200){const S=k.data;s(Array.isArray(S==null?void 0:S.results)?S.results:[]),o(typeof(S==null?void 0:S.count)=="number"?S.count:0)}else s([]),o(0),f(((_=k.data)==null?void 0:_.detail)??"Failed to load the ledger.")}).catch(k=>{var _,S;N||f(((S=(_=k==null?void 0:k.response)==null?void 0:_.data)==null?void 0:S.detail)??"Failed to load the ledger.")}).finally(()=>{N||p(!1)}),()=>{N=!0}},[l,g,e]),{items:n,count:a,page:l,setPage:d,pageSize:Kb,isLoading:u,error:h,refetch:v}},TP=new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD"}),Kc=e=>e==null||e===""?"":TP.format(Number(e)),Qb=e=>jn(e),jr="font-[var(--font-family-mono)]",Cc="rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition",LP=({children:e})=>t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-5xl px-6 py-8",children:e})}),RP=e=>{const n=Ks(e);switch(Lr(e)){case"posted":return{label:n,cls:"bg-emerald-50 text-emerald-700"};case"reversed":return{label:n,cls:"bg-blue-50 text-blue-700"};default:return{label:n,cls:"bg-gray-100 text-gray-600"}}},Jb=({row:e})=>{const{label:n,cls:s}=RP(e);return t.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${s}`,children:n})},IP=({open:e})=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:`h-4 w-4 text-gray-400 transition-transform ${e?"rotate-90":""}`,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),PP=({lines:e})=>{const n=[...e].sort((s,a)=>s.line_order-a.line_order);return t.jsx("div",{className:"border-t border-gray-100 bg-gray-50 px-4 py-3",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:[t.jsx("th",{className:"py-1 pr-3 text-left",children:"Acct"}),t.jsx("th",{className:"py-1 pr-3 text-left",children:"Account"}),t.jsx("th",{className:"py-1 pl-3 text-right",children:"Debit"}),t.jsx("th",{className:"py-1 pl-3 text-right",children:"Credit"})]})}),t.jsx("tbody",{children:n.map(s=>t.jsxs("tr",{className:"text-gray-600",children:[t.jsx("td",{className:`whitespace-nowrap py-1 pr-3 text-gray-500 ${jr}`,children:s.account_code??""}),t.jsx("td",{className:"py-1 pr-3",children:s.account_name??""}),t.jsx("td",{className:`whitespace-nowrap py-1 pl-3 text-right tabular-nums ${jr}`,children:Kc(s.debit)}),t.jsx("td",{className:`whitespace-nowrap py-1 pl-3 text-right tabular-nums ${jr}`,children:Kc(s.credit)})]},s.id))})]})})},Iw=({name:e})=>t.jsx("span",{className:"inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600",children:e}),FP=({entryId:e,onAssigned:n})=>{const s=gP({}),[a,o]=x.useState(""),[l,d]=x.useState(!1),[u,p]=x.useState(null);x.useEffect(()=>{s.setPageSize(200)},[]);const h=async()=>{var f,g,b;if(a){d(!0),p(null);try{const v=await xP(e,a);(v==null?void 0:v.status)===200?n():p(((f=v==null?void 0:v.data)==null?void 0:f.detail)??"Could not assign counterparty.")}catch(v){p(((b=(g=v==null?void 0:v.response)==null?void 0:g.data)==null?void 0:b.detail)??"Could not assign counterparty.")}finally{d(!1)}}};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Assign counterparty"}),t.jsxs("select",{value:a,onChange:f=>o(f.target.value),className:`${Cc} py-1.5`,"aria-label":"Select counterparty",children:[t.jsx("option",{value:"",children:"Select…"}),s.items.map(f=>t.jsx("option",{value:f.id,children:f.name},f.id))]}),t.jsx("button",{type:"button",disabled:!a||l,onClick:h,className:"rounded-lg bg-[var(--color-navy)] px-3 py-1.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-40",children:l?"Assigning…":"Assign"}),u&&t.jsx("span",{className:"text-xs text-red-600",children:u})]})},Xb=({entry:e,onAssigned:n,onOpenEntry:s})=>{const a=Eo(e);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2 bg-gray-50 px-4 py-3",children:[e.counterparty?t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"text-gray-500",children:"Counterparty"}),t.jsx(Iw,{name:e.counterparty.name})]}):Gc("owner",e,"assign_counterparty")?t.jsx(FP,{entryId:e.id,onAssigned:n}):t.jsx("div",{className:"text-xs text-gray-500",children:"No counterparty assigned."}),a&&t.jsx("p",{className:"text-xs text-gray-500",children:a})]}),t.jsx(PP,{lines:e.lines}),t.jsx(Sh,{className:"mx-4 my-3",chain:e.chain,currentId:e.id,liveEntry:e.live_entry,truncated:e.chain_truncated,onOpenEntry:s})]})},DP=()=>t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-8 w-40 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"mt-4 flex gap-2",children:[0,1,2,3,4,5].map(e=>t.jsx("div",{className:"h-8 w-20 animate-pulse rounded-full bg-gray-100"},e))}),t.jsx("div",{className:"mt-6 overflow-hidden rounded-2xl border border-gray-100 bg-white shadow-sm",children:[0,1,2,3,4,5,6,7].map(e=>t.jsxs("div",{className:"flex items-center gap-4 border-b border-gray-50 px-4 py-3 last:border-0",children:[t.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-4 w-16 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-4 flex-1 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-4 w-20 animate-pulse rounded bg-gray-100"})]},e))})]}),OP=({error:e,onRetry:n})=>t.jsxs("div",{className:"max-w-md rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:[t.jsx("p",{className:"text-sm text-gray-700",children:e}),t.jsx("button",{type:"button",onClick:n,className:"mt-4 inline-flex items-center rounded-lg bg-gray-900 px-4 py-2 text-sm font-medium text-white hover:bg-gray-800",children:"Try again"})]}),$P=({filtered:e,onClear:n})=>t.jsxs("div",{className:"rounded-2xl border border-gray-100 bg-white p-10 text-center shadow-sm",children:[t.jsx("p",{className:"text-sm text-gray-500",children:e?"No entries match these filters.":"No entries yet."}),e&&t.jsx("button",{type:"button",onClick:n,className:"mt-4 inline-flex items-center rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-50",children:"Clear filters"})]}),MP=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(null),[o,l]=x.useState(null),[d,u]=x.useState(null),[p,h]=x.useState(!1),[f,g]=x.use
98State(null),[b,v]=x.useState(null),{entry:N}=Ch(b),w=q=>{g(q),v(null)},[k,_]=x.useState(null),{items:S,count:T,page:E,setPage:A,pageSize:I,isLoading:R,error:W,refetch:Y}=hP({tab:e??void 0,status:s??void 0,date_from:o??void 0,date_to:d??void 0,unattributed:p}),K=e!==null||s!==null||!!o||!!d||p,X=q=>{n(q),A(1),w(null)},se=q=>{a(q||null),A(1),w(null)},ne=q=>{l(q||null),A(1),w(null)},Z=q=>{u(q||null),A(1),w(null)},ue=()=>{h(q=>!q),A(1),w(null)},re=()=>{n(null),a(null),l(null),u(null),h(!1),A(1),w(null)},H=k??{key:"date",dir:"desc"},M=x.useMemo(()=>{if(k===null)return S;const q=k.dir==="asc"?1:-1;return[...S].sort((ee,je)=>{if(k.key==="entry_number"){const me=ee.entry_number,Ne=je.entry_number;return me===null&&Ne===null?0:me===null?1:Ne===null?-1:(me-Ne)*q}return(ee.entry_date<je.entry_date?-1:ee.entry_date>je.entry_date?1:0)*q})},[S,k]),Q=q=>{w(null),_(ee=>{const je=ee??{key:"date",dir:"desc"};return je.key===q?{key:q,dir:je.dir==="asc"?"desc":"asc"}:{key:q,dir:q==="date"?"desc":"asc"}})},$=q=>H.key===q?H.dir==="asc"?"ascending":"descending":"none",L=T>I,F=T===0?0:(E-1)*I+1,V=Math.min(E*I,T);return t.jsxs(LP,{children:[t.jsx(ut,{title:"Ledger",subtitle:"Every transaction, posted by the AI bookkeeper. Read-only — corrections post as new entries."}),t.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[t.jsx(On,{active:e===null,onClick:()=>X(null),children:"All"}),fP.map(q=>t.jsx(On,{active:e===q.value,onClick:()=>X(q.value),children:q.label},q.value))]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx("select",{value:s??"",onChange:q=>se(q.target.value),className:Cc,"aria-label":"Filter by status",children:_h.map(q=>t.jsx("option",{value:q.value,children:q.label},q.value||"posted"))}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-500",children:["From",t.jsx("input",{type:"date",value:o??"",onChange:q=>ne(q.target.value),className:Cc})]}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-500",children:["To",t.jsx("input",{type:"date",value:d??"",onChange:q=>Z(q.target.value),className:Cc})]}),t.jsx(On,{active:p,onClick:ue,children:"Unassigned"}),K&&t.jsx("button",{type:"button",onClick:re,className:"text-sm font-medium text-[var(--color-primary)] hover:underline",children:"Clear filters"})]}),t.jsx("div",{className:"mt-6",children:R?t.jsx(DP,{}):W?t.jsx(OP,{error:W,onRetry:Y}):T===0?t.jsx($P,{filtered:K,onClear:re}):t.jsxs(Te,{children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-100 text-left text-[11px] font-semibold uppercase tracking-wider text-gray-500",children:[t.jsx("th",{className:"w-6 px-4 py-3"}),t.jsx("th",{className:"px-4 py-3","aria-sort":$("date"),children:t.jsxs("button",{type:"button",onClick:()=>Q("date"),className:"inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-gray-700",children:["Date",H.key==="date"&&t.jsx("span",{"aria-hidden":"true",children:H.dir==="asc"?"▲":"▼"})]})}),t.jsx("th",{className:"px-4 py-3","aria-sort":$("entry_number"),children:t.jsxs("button",{type:"button",onClick:()=>Q("entry_number"),className:"inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-gray-700",children:["Entry #",H.key==="entry_number"&&t.jsx("span",{"aria-hidden":"true",children:H.dir==="asc"?"▲":"▼"})]})}),t.jsx("th",{className:"px-4 py-3",children:"Description"}),t.jsx("th",{className:"px-4 py-3 text-right",children:"Debits"}),t.jsx("th",{className:"px-4 py-3 text-right",children:"Credits"}),t.jsx("th",{className:"px-4 py-3",children:"Status"})]})}),t.jsx("tbody",{children:M.map(q=>{const ee=f===q.id,je=$d(q);return t.jsxs(x.Fragment,{children:[t.jsxs("tr",{onClick:()=>w(ee?null:q.id),className:"cursor-pointer border-b border-gray-50 transition-colors last:border-0 hover:bg-gray-50/60",children:[t.jsx("td",{className:"px-4 py-3",children:t.jsx(IP,{open:ee})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-gray-700",children:Qb
98(q.entry_date)}),t.jsx("td",{className:`whitespace-nowrap px-4 py-3 text-xs text-gray-500 ${jr}`,children:q.entry_number_display??""}),t.jsx("td",{className:"px-4 py-3 text-gray-900",children:t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsx("span",{children:q.description}),q.counterparty&&t.jsx(Iw,{name:q.counterparty.name})]})}),t.jsx("td",{className:`whitespace-nowrap px-4 py-3 text-right tabular-nums text-gray-700 ${jr}`,children:Kc(je.debits)}),t.jsx("td",{className:`whitespace-nowrap px-4 py-3 text-right tabular-nums text-gray-700 ${jr}`,children:Kc(je.credits)}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(Jb,{row:q})})]}),ee&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"p-0",children:b===null?t.jsx(Xb,{entry:q,onAssigned:()=>{w(null),Y()},onOpenEntry:ke=>v(ke.id)}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-gray-100 bg-gray-50 px-4 py-2 text-xs text-gray-600",children:[(N==null?void 0:N.kind)==="ready"&&N.row.id===b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:`font-semibold text-gray-900 ${jr}`,children:N.row.entry_number_display??"—"}),t.jsx("span",{children:Qb(N.row.entry_date)}),t.jsx(Jb,{row:N.row})]}):(N==null?void 0:N.kind)==="error"?t.jsx("span",{className:"text-red-600",children:N.message}):t.jsx("span",{className:"text-gray-400",children:"Loading entry…"}),t.jsxs("button",{type:"button",onClick:()=>v(null),className:"font-medium text-[var(--color-primary)] hover:underline",children:["Back to ",q.entry_number_display??"this entry"]})]}),(N==null?void 0:N.kind)==="ready"&&N.row.id===b&&t.jsx(Xb,{entry:N.row,onAssigned:()=>{w(null),Y()},onOpenEntry:ke=>v(ke.id)})]})})})]},q.id)})})]})}),L&&t.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-4 py-3",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[F,"–",V," of ",T]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>A(E-1),disabled:E<=1,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent",children:"Previous"}),t.jsx("button",{type:"button",onClick:()=>A(E+1),disabled:E*I>=T,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent",children:"Next"})]})]})]})})]})},BP={blue:"bg-blue-50 text-blue-700",red:"bg-red-50 text-red-700",green:"bg-emerald-50 text-emerald-700"},UP=({initials:e,tint:n="blue"})=>t.jsx("span",{className:`inline-flex h-[34px] w-[34px] items-center justify-center rounded-[9px] text-[13px] font-semibold ${BP[n]}`,children:e}),Pw=e=>e==="right"?"text-right":e==="center"?"text-center":"text-left",Fw=e=>e.map(n=>`${n.fr??1}fr`).join(" "),Qc=({columns:e,children:n,empty:s,isEmpty:a=!1})=>t.jsxs("div",{className:"overflow-hidden",children:[t.jsx("div",{className:"grid gap-4 px-4 py-2.5 bg-gray-50 border-b border-gray-100",style:{gridTemplateColumns:Fw(e)},children:e.map((o,l)=>t.jsx("div",{className:`text-[11px] uppercase font-semibold text-gray-400 tracking-[0.06em] ${Pw(o.align)}`,children:o.label},l))}),a?t.jsx("div",{className:"px-4 py-10 text-center text-[13.5px] text-gray-400",children:s}):n]}),Jc=({columns:e,cells:n,onClick:s})=>t.jsx("div",{className:`grid gap-4 px-4 py-3 border-b border-gray-50 last:border-0 hover:bg-gray-50/60 ${s?"cursor-pointer":""}`,style:{gridTemplateColumns:Fw(e)},onClick:s,children:n.map((a,o)=>{var l;return t.jsx("div",{className:`text-[13.5px] text-gray-700 min-w-0 ${Pw((l=e[o])==null?void 0:l.align)}`,children:a},o)})}),Xs="/api/accounting/sales-invoices/",Dw=e=>{const[n,s]=x.useState(null),[a,o]=x.useState(!0),[l,d]=x.useState(null),[u,p]=x.useState(0),h=x.useCallback(()=>p(f=>f+1),[]);return x.useEffect(()=>{if(!e)return;let f=!1;return o(!0),d(null),te.get(`${Xs}${e}/`).then(g=>{var b;f||g==null||(g.status===200?s(g.data):(s(null),d(((b=g.data)==null?void 0:b.detail)??"Failed to load invoice")))}).catch(g=>{var b,v;f||d(((v=(b=g==null?void 0:g.response)==null?void 0:b.data)==null?void 0:v.detail)??"Failed to load invoice")}).finally(()=>{f||o(!1)}),()=>{f=!0}},[e,u]),{invoice:n,isLoading:a,error:l,refetch:h}},Eh=()=>{const[e,n]=x.useState([]),[s,a]=x.useState({}),[o,l]=x.useState(!0),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return l(!0),te.get("/api/accounting/counterparties/",{params:{page_size:200}}).then(f=>{var b;if(h||f==null||f.status!==200)return;const g=Array.isArray((b=f.data)==null?void 0:b.results)?f.data.results:[];n(g),a(Object.fromEntries(g.map(v=>[v.id,v])))}).finally(()=>{h||l(!1)}),()=>{h=!0}},[d]),{options:e,byId:s,isLoading:o,refetch:p}},zP=e=>
98te.post(Xs,e),WP=(e,n)=>te.patch(`${Xs}${e}/`,n),HP=e=>te.post(`${Xs}${e}/issue/`,{}),qP=(e,n)=>te.post(`${Xs}${e}/void/`,{reason:n}),VP=(e,n)=>te.post(`${Xs}${e}/payments/`,n),YP=(e,n)=>te.post(`${Xs}${e}/credit-notes/`,{lines:n}),GP=(e,n)=>te.post(`${Xs}${e}/send/`,n?{recipient:n}:{}),KP=new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD"}),gr=(e,n)=>{if(e==null||e==="")return"—";const s=Number(e);return Number.isNaN(s)?`$${e}`:n&&n!=="CAD"?new Intl.NumberFormat("en-CA",{style:"currency",currency:n}).format(s):KP.format(s)},Ow=e=>e.invoice_number!=null?`INV-${String(e.invoice_number).padStart(5,"0")}`:e.kind==="credit_note"?"Credit note (draft)":"Draft",$w=(e,n=!1)=>{if(n&&(e==="issued"||e==="sent"||e==="partial"))return{variant:"danger",label:"Overdue"};switch(e){case"draft":return{variant:"neutral",label:"Draft"};case"issued":return{variant:"info",label:"Issued"};case"sent":return{variant:"info",label:"Sent"};case"partial":return{variant:"warning",label:"Partial"};case"paid":return{variant:"success",label:"Paid"};case"voided":return{variant:"voided",label:"Voided"};default:return{variant:"neutral",label:e}}},Je="rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition",Md="inline-flex items-center justify-center rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-[var(--color-primary-hover)] disabled:opacity-40 disabled:cursor-not-allowed",nn="inline-flex items-center justify-center rounded-lg border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed",QP=[{value:"due_on_receipt",label:"Due on receipt"},{value:"net_15",label:"Net 15"},{value:"net_30",label:"Net 30"},{value:"net_60",label:"Net 60"}],Zb={name:"",contact_name:"",email:"",city:"",province:"",payment_terms:""},Mw=({role:e,noun:n,onCreated:s,onCancel:a})=>{const[o,l]=x.useState(Zb),[d,u]=x.useState(null),[p,h]=x.useState(!1),f=async()=>{var g;h(!0),u(null);try{const v=await yP({...o,...e==="client"?{is_client:!0}:{is_supplier:!0}});if((v==null?void 0:v.status)===201)l(Zb),s(v.data);else if((v==null?void 0:v.status)===400){const N=v.data;u(N!=null&&N.detail?{detail:[N.detail]}:N??{detail:["Could not create."]})}else u({detail:["Could not create."]})}catch(b){const v=(g=b==null?void 0:b.response)==null?void 0:g.data;u(v&&typeof v=="object"?v:{detail:["Could not create."]})}finally{h(!1)}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:[t.jsxs("div",{className:"md:col-span-1",children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:["Business name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{value:o.name,onChange:g=>l({...o,name:g.target.value}),className:`${Je} w-full`})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Contact name"}),t.jsx("input",{value:o.contact_name,onChange:g=>l({...o,contact_name:g.target.value}),className:`${Je} w-full`})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Email"}),t.jsx("input",{value:o.email,onChange:g=>l({...o,email:g.target.value}),className:`${Je} w-full`})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"City"}),t.jsx("input",{value:o.city,onChange:g=>l({...o,city:g.target.value}),className:`${Je} w-full`})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Province"}),t.jsx("input",{value:o.province,onChange:g=>l({...o,province:g.target.value}),className:`${Je} w-full`})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Payment terms"}),t.jsxs("select",{value:o.payment_terms,onChange:g=>l({...o,payment_terms:g.target.value}),className:`${Je} w-full`,children:[t.jsx("option",{value:"",children:"—"}),QP.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]}),d&&t.jsx("div",{className:"mt-3 text-sm text-red-600 space-y-0.5",children:Object.entries(d).map(([g,b])=>t.jsxs("div",{children:[g==="detail"?"":`${g}: `,b.join(" ")]},g))}),t.jsxs("div",{className:"mt-3 flex gap-2",children:[t.jsx("button",{type:"button",disabled:p||!o.name.trim(),onClick:f,className:"rounded-lg bg-[var(--color-navy)] px-4 py-2 text-sm font-medium text-white hover:opacity-90 disabled:opacity-40 transition",children:p?"Saving…":`Save ${n}`}),t.jsx("button",{type:"button",onClick:a,className:"rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-50 transition",children:"Cancel"})]})]})},Bw=({role:e="client",onCreated:n,onClose:s})=>t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:s,children:t.jsx("div",{className:"w-full max-w-2xl",onClick:a=>a.stopPropagation(),children:t.jsxs(Te,{padding:!0,children:[t.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"New client"}),t.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),t.jsx(Mw,{role:e,noun:"client",onCreated:n,onCancel:s})]})})}),JP=50,XP={current:"0.00",d31_60:"0.00",d61_90:"0.00",d90_plus:"0.00"},bp={balance:"0.00",aging:XP},ev=({role:e,archived:n,search:s}
98)=>{const[a,o]=x.useState([]),[l,d]=x.useState(bp),[u,p]=x.useState(0),[h,f]=x.useState(1),g=JP,[b,v]=x.useState(!0),[N,w]=x.useState(null),[k,_]=x.useState(0),S=x.useCallback(()=>_(T=>T+1),[]);return x.useEffect(()=>{let T=!1;v(!0),w(null);const E={role:e,archived:n,page:h,page_size:g};return s&&(E.search=s),te.get("/api/accounting/counterparties/balances/",{params:E}).then(A=>{var I;if(!T&&A!=null)if(A.status===200){const R=A.data;o(Array.isArray(R==null?void 0:R.results)?R.results:[]),p(typeof(R==null?void 0:R.count)=="number"?R.count:0),d((R==null?void 0:R.summary)??bp)}else o([]),p(0),d(bp),w(((I=A.data)==null?void 0:I.detail)??"Failed to load balances")}).catch(A=>{var I,R;T||w(((R=(I=A==null?void 0:A.response)==null?void 0:I.data)==null?void 0:R.detail)??"Failed to load balances")}).finally(()=>{T||v(!1)}),()=>{T=!0}},[e,n,s,h,k]),{summary:l,items:a,count:u,page:h,setPage:f,pageSize:g,isLoading:b,error:N,refetch:S}},ZP=[{value:"due_on_receipt",label:"Due on receipt"},{value:"net_15",label:"Net 15"},{value:"net_30",label:"Net 30"},{value:"net_60",label:"Net 60"}],e7=Object.fromEntries(ZP.map(e=>[e.value,e.label])),ic=e=>{const n=Number(e);return Number.isNaN(n)?0:n},va=e=>{const n=Number(e);return Number.isNaN(n)?`$${e}`:`$${n.toLocaleString("en-CA",{minimumFractionDigits:2,maximumFractionDigits:2})}`},t7=e=>e.trim().split(/\s+/).slice(0,2).map(n=>{var s;return((s=n[0])==null?void 0:s.toUpperCase())??""}).join("")||"?",n7="rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition",s7=({children:e})=>t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"max-w-6xl mx-auto px-6 py-8",children:e})}),r7=({aging:e})=>{const n=[Math.max(0,ic(e.current)),Math.max(0,ic(e.d31_60)),Math.max(0,ic(e.d61_90)),Math.max(0,ic(e.d90_plus))],s=n.reduce((o,l)=>o+l,0),a=["bg-emerald-500","bg-blue-400","bg-amber-500","bg-red-500"];return t.jsx("div",{className:"h-1.5 w-[120px] rounded-full bg-gray-100 overflow-hidden flex",children:s>0&&n.map((o,l)=>o>0?t.jsx("div",{className:a[l],style:{width:`${o/s*100}%`}},l):null)})},Uw=({config:e})=>{const[n,s]=x.useState(!1),[a,o]=x.useState(""),[l,d]=x.useState(""),[u,p]=x.useState(!1),h=ev({role:e.role,archived:!1,search:l}),f=ev({role:e.role,archived:!0,search:l}),g=n?f:h,{items:b,count:v,page:N,setPage:w,pageSize:k,isLoading:_,error:S}=g,T=()=>{h.refetch(),f.refetch()};x.useEffect(()=>{const se=setTimeout(()=>{d(a),h.setPage(1),f.setPage(1)},300);return()=>clearTimeout(se)},[a]);const E=se=>{s(se),(se?f:h).setPage(1)},A=async se=>{await bP(se),T()},I=async se=>{await vP(se),T()},R=[{label:e.columnLabel,fr:2.2},{label:"Contact",fr:2},{label:"Terms",fr:1},{label:"Balance",align:"right",fr:1.2},{label:"Aging",fr:1.4},{label:"Action",align:"right",fr:1}],W=v===0?0:(N-1)*k+1,Y=Math.min(N*k,v),K=v>k,X=g.summary;return t.jsxs(s7,{children:[t.jsx(ut,{title:e.title,subtitle:e.subtitle}),t.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-3 md:grid-cols-5",children:[t.jsx(ka,{label:e.totalLabel,value:va(X.balance)}),t.jsx(ka,{label:"Current (0–30)",value:va(X.aging.current),tone:"success"}),t.jsx(ka,{label:"31–60 days",value:va(X.aging.d31_60)}),t.jsx(ka,{label:"61–90 days",value:va(X.aging.d61_90),tone:"warning"}),t.jsx(ka,{label:"90+ days",value:va(X.aging.d90_plus),tone:"danger"})]}),t.jsx("div",{className:"mt-6",children:t.jsxs(Te,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 border-b border-gray-100",children:[t.jsxs(On,{active:!n,onClick:()=>E(!1),children:["Active · ",h.count]}),t.jsxs(On,{active:n,onClick:()=>E(!0),children:["Archived · ",f.count]}),t.jsx("input",{type:"text",value:a,onChange:se=>o(se.target.value),placeholder:`Search ${e.noun}s…`,className:`${n7} ml-auto w-56`}),t.jsx("button",{type:"button",onClick:()=>p(se=>!se),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:bg-[var(--color-primary-hover)] transition-colors",children:e.addLabel})]}),u&&t.jsx("div",{className:"px-4 py-4 border-b border-gray-100 bg-gray-50/60",children:t.jsx(Mw,{role:e.role,noun:e.noun,onCreated:()=>{p(!1),T()},onCancel:()=>p(!1)})}),n&&t.jsxs("div",{className:"flex items-start gap-2 border-b border-gray-100 bg-gray-50 px-4 py-2.5 text-[12.5px] text-gray-600",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.6,stroke:"currentColor",className:"mt-0.5 h-4 w-4 shrink-0 text-gray-400","aria-hidden":!0,
98children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),t.jsx("span",{children:e.archivedExplainer})]}),S?t.jsx("div",{className:"px-4 py-6 text-sm text-red-600",children:S}):t.jsx(Qc,{columns:R,isEmpty:!_&&b.length===0,empty:n?e.emptyArchived:e.emptyActive,children:_&&b.length===0?t.jsx("div",{className:"px-4 py-10 text-center text-[13.5px] text-gray-400",children:"Loading…"}):b.map(se=>t.jsx(Jc,{columns:R,cells:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(UP,{initials:t7(se.name),tint:e.avatarTint}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:`truncate font-medium ${se.archived?"text-gray-400":"text-gray-900"}`,children:se.name}),se.city&&t.jsx("div",{className:"truncate text-[12px] text-gray-400",children:se.city})]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-gray-700",children:se.contact_name||"—"}),se.email&&t.jsx("div",{className:"truncate text-[12px] text-gray-400",children:se.email})]}),t.jsx("span",{className:"text-gray-600",children:e7[se.payment_terms]??"—"}),t.jsx("span",{className:"font-[var(--font-family-mono)] text-gray-900",children:va(se.balance)}),t.jsx(r7,{aging:se.aging}),se.archived?t.jsx("button",{type:"button",onClick:()=>I(se.id),className:"text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:"Unarchive"}):t.jsx("button",{type:"button",onClick:()=>A(se.id),className:"text-[13px] font-medium text-gray-500 hover:text-gray-800 hover:underline",children:"Archive"})]},se.id))}),K&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[W,"–",Y," of ",v]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>w(N-1),disabled:N<=1,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent transition-colors",children:"Previous"}),t.jsx("button",{type:"button",onClick:()=>w(N+1),disabled:N*k>=v,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent transition-colors",children:"Next"})]})]})]})})]})},a7={role:"client",title:"Clients",subtitle:"Who owes you money, and how long it's been outstanding.",totalLabel:"Total receivable",columnLabel:"Client",noun:"client",addLabel:"Add client",emptyActive:"No clients yet. Add your first client to start tracking receivables.",emptyArchived:"No archived clients.",archivedExplainer:"Archiving keeps all history intact — it only removes the client from new-invoice pickers.",avatarTint:"blue"},i7=()=>t.jsx(Uw,{config:a7}),o7={role:"supplier",title:"Suppliers",subtitle:"Who you owe, and how long it's been outstanding.",totalLabel:"Total payable",columnLabel:"Supplier",noun:"supplier",addLabel:"Add supplier",emptyActive:"No suppliers yet. Add your first supplier to start tracking payables.",emptyArchived:"No archived suppliers.",archivedExplainer:"Archiving keeps all history intact — it only removes the supplier from pickers.",avatarTint:"green"},l7=()=>t.jsx(Uw,{config:o7}),c7={neutral:"bg-gray-100 text-gray-600",info:"bg-blue-50 text-blue-700",success:"bg-emerald-50 text-emerald-700",warning:"bg-amber-50 text-amber-700",danger:"bg-red-50 text-red-700",voided:"bg-gray-100 text-gray-400"},on=({variant:e="neutral",children:n})=>t.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${c7[e]}`,children:n}),tv=["asset","liability","equity","revenue","expense"],d7={asset:"Assets",liability:"Liabilities",equity:"Equity",revenue:"Revenue",expense:"Expenses"},u7="other",m7="current",zw=e=>`${e.code} — ${e.name}`,p7=e=>{const n=new Set,s=[];for(const a of e)n.has(a.id)||(n.add(a.id),s.push(a));return s},f7=/^\d+$/,nv=(e,n)=>{const s=n.trim();return s?f7.test(s)?e.code.startsWith(s):zw(e).toLowerCase().includes(s.toLowerCase()):!0},h7=(e,n)=>{const s=n.trim();return s!==""&&e.code.toLowerCase()===s.toLowerCase()},sv=(e,n)=>e.code.localeCompare(n.code)||e.name.localeCompare(n.name),vp=e=>({key:e.id,account:e,label:zw(e)}),rv=({accounts:e,query:n,allowedTypes:s,filter:a,currentAccount:o})=>{const l=p7(e).filter(g=>(!s||s.includes(g.type))&&(!a||a(g))),d=l.filter(g=>nv(g,n)),u=[];for(const g of tv){const b=d.filter(v=>v.type===g).sort(sv);b.length&&u.push({key:g,label:d7[g],options:b.map(vp)})}const p=d.filter(g=>
98!tv.includes(g.type)).sort(sv);p.length&&u.push({key:u7,label:"Other",options:p.map(vp)}),o&&!l.some(g=>g.id===o.id)&&nv(o,n)&&u.push({key:m7,label:"Current",options:[vp(o)]});const h=u.flatMap(g=>g.options),f=h.find(g=>h7(g.account,n))??null;return{groups:u,options:h,exact:f}},x7=(e,n,s)=>{var a;return e.exact?e.exact.key:n.trim()?((a=e.options[0])==null?void 0:a.key)??null:s!==null&&e.options.some(o=>o.key===s)?s:null},g7={dark:{label:"block text-xs font-medium text-white/60 mb-1",star:"text-red-400",input:"w-full rounded-md bg-[#0f172a] border border-white/15 px-2 py-1.5 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF] disabled:opacity-50",status:"mt-1 text-xs text-white/40",error:"mt-1 text-xs text-red-300",list:"rounded-lg border border-white/10 bg-[#0A1628] p-1 shadow-2xl overflow-y-auto",header:"px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white/40",option:"cursor-pointer rounded-md px-2.5 py-1.5 text-sm text-white/70",optionActive:"cursor-pointer rounded-md px-2.5 py-1.5 text-sm bg-white/10 text-white",empty:"px-2.5 py-1.5 text-xs text-white/40"},light:{label:"mb-1.5 block text-sm font-medium text-gray-700",star:"text-red-500",input:"w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition disabled:bg-gray-50 disabled:text-gray-400",inputLg:"w-full rounded-lg border border-gray-300 bg-white px-3.5 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition disabled:bg-gray-50 disabled:text-gray-400",status:"mt-1 text-xs text-gray-500",error:"mt-1 text-xs text-red-600",list:"rounded-lg border border-gray-200 bg-white p-1 shadow-2xl overflow-y-auto",header:"px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wider text-gray-500",option:"cursor-pointer rounded-md px-2.5 py-1.5 text-sm text-gray-700",optionActive:"cursor-pointer rounded-md px-2.5 py-1.5 text-sm bg-gray-100 text-gray-900",empty:"px-2.5 py-1.5 text-xs text-gray-500"}},jp="__clear__",oc=4,Ui=8,y7=280,av=120,b7=288,v7=1e3,$r=({id:e,label:n,ariaLabel:s,value:a,onChange:o,accounts:l,loading:d=!1,error:u=null,valueKey:p="id",allowedTypes:h,filter:f,currentAccount:g=null,disabled:b=!1,required:v=!1,clearable:N=!1,placeholder:w,tone:k="light",size:_="md",hideError:S=!1})=>{const T=g7[k],E=x.useRef(null),A=x.useRef(null),I=x.useRef(null),[R,W]=x.useState(!1),[Y,K]=x.useState(null),[X,se]=x.useState(null),[ne,Z]=x.useState(null),ue=x.useMemo(()=>rv({accounts:l,query:"",allowedTypes:h,filter:f,currentAccount:g}),[l,h,f,g]),re=Y??"",H=re.trim()!=="",M=x.useMemo(()=>H?rv({accounts:l,query:re,allowedTypes:h,filter:f,currentAccount:g}):ue,[H,re,ue,l,h,f,g]),Q=a===""?null:ue.options.find(J=>J.account[p]===a)??null,$=N&&!H,L=x.useMemo(()=>[...$?[jp]:[],...M.options.map(J=>J.key)],[$,M]),F=x7(M,re,(Q==null?void 0:Q.key)??null),V=X!==null&&L.includes(X)?X:F,q=b||!!u,ee=R&&!q&&!(d&&L.length===0),je=`${e}-listbox`,ke=`${e}-error`,me=J=>`${e}-opt-${J}`,Ne=x.useCallback(()=>{W(!1),K(null),se(null)},[]),Oe=J=>{if(J===jp)a!==""&&o("",null);else{const pe=M.options.find(Re=>Re.key===J);if(pe){const Re=pe.account[p];Re!==a&&o(Re,pe.account)}}Ne()},mt=(Q==null?void 0:Q.label)??"";x.useEffect(()=>{const J=A.current;Y===null&&J&&document.activeElement===J&&J.select()},[Y,mt]);const he=x.useCallback(()=>{const J=A.current;if(!J)return;const pe=J.getBoundingClientRect(),Re=window.innerHeight-pe.bottom-oc-Ui,We=pe.top-oc-Ui,xt=Re<av&&We>Re,Ct=Math.min(Math.max(pe.width,y7),window.innerWidth-2*Ui),Un=Math.max(Ui,Math.min(pe.left,window.innerWidth-Ct-Ui)),de=Math.max(av,Math.min(b7,xt?We:Re));Z({position:"fixed",zIndex:v7,left:Un,width:Ct,maxHeight:de,...xt?{bottom:window.innerHeight-pe.top+oc}:{top:pe.bottom+oc}})},[]);x.useLayoutEffect(()=>{if(ee)return he(),window.addEventListener("scroll",he,!0),window.addEventListener("resize",he),()=>{window.removeEventListener("scroll",he,!0),window.removeEventListener("resize",he)}},[ee,he]),x.useEffect(()=>{if(!ee)return;const J=pe=>{var We,xt;const Re=pe.target;(We=E.current)!=null&&We.contains(Re)||(xt=I.current)!=null&&xt.contains(Re)||Ne()};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[ee,Ne]),x.useEffect(()=>{var pe;if(!ee||V===null)return;
98const J=document.getElementById(`${e}-opt-${V}`);(pe=J==null?void 0:J.scrollIntoView)==null||pe.call(J,{block:"nearest"})},[ee,V,e]);const Se=J=>{switch(J.key){case"ArrowDown":case"ArrowUp":{if(J.preventDefault(),q)return;const pe=L.length-1,Re=J.key==="ArrowDown";if(!ee){W(!0),V===null&&pe>=0&&se(L[Re?0:pe]);return}if(pe<0)return;const We=V===null?-1:L.indexOf(V),xt=We===-1?Re?0:pe:Math.max(0,Math.min(pe,We+(Re?1:-1)));se(L[xt]);return}case"Enter":J.preventDefault(),ee&&V!==null&&!J.nativeEvent.isComposing&&Oe(V);return;case"Tab":ee&&Y!==null&&M.exact!==null&&V===M.exact.key&&Oe(M.exact.key);return;case"Escape":ee&&(J.stopPropagation(),Ne());return}},ae=(J,pe)=>{const Re=J===V;return t.jsx("div",{id:me(J),role:"option","aria-selected":Re,className:Re?T.optionActive:T.option,onMouseEnter:()=>se(J),onClick:()=>Oe(J),children:pe},J)};return t.jsxs("div",{ref:E,children:[n&&t.jsxs("label",{htmlFor:e,className:T.label,children:[n,v&&t.jsx("span",{className:T.star,children:" *"})]}),t.jsx("input",{ref:A,id:e,type:"text",role:"combobox","aria-label":s,"aria-expanded":ee,"aria-controls":je,"aria-autocomplete":"list","aria-activedescendant":ee&&V!==null?me(V):void 0,"aria-required":v||void 0,"aria-invalid":u?!0:void 0,"aria-describedby":u&&!S?ke:void 0,autoComplete:"off",spellCheck:!1,disabled:b,placeholder:w,value:Y??mt,className:_==="lg"&&T.inputLg||T.input,onChange:J=>{K(J.target.value),se(null),W(!0)},onFocus:J=>{Y===null&&J.currentTarget.select()},onClick:J=>{q||(Y===null&&J.currentTarget.select(),W(!0))},onBlur:Ne,onKeyDown:Se}),d&&!u&&t.jsx("p",{role:"status",className:T.status,children:"Loading accounts…"}),u&&!S&&t.jsx("p",{id:ke,role:"alert",className:T.error,children:u}),ee&&ne&&N5.createPortal(t.jsxs("div",{ref:I,id:je,role:"listbox","aria-label":n??s,style:ne,className:T.list,onMouseDown:J=>J.preventDefault(),children:[$&&ae(jp,w??"None"),M.groups.map(J=>t.jsxs("div",{role:"group","aria-labelledby":`${e}-grp-${J.key}`,children:[t.jsx("div",{id:`${e}-grp-${J.key}`,role:"presentation",className:T.header,children:J.label}),J.options.map(pe=>ae(pe.key,pe.label))]},J.key)),L.length===0&&t.jsx("div",{className:T.empty,children:"No matching accounts"})]}),document.body)]})},Ef=200,iv=10,Xc="Failed to load accounts.";class wr extends Error{}const j7=(e,n)=>e==="staff"?`/api/accounting/staff/orgs/${n}/accounts/`:"/api/accounting/accounts/",w7=(e,n)=>e==="staff"?{page:n,page_size:Ef}:{page:n,page_size:Ef,active:!0},N7=(e,n)=>{if(e==null||typeof e.id!="string"||typeof e.code!="string"||typeof e.name!="string")throw new wr(Xc);if(e.org_id!==n)throw new wr("The server returned accounts for a different organization. Reload the page and try again.");return{id:e.id,org_id:e.org_id,code:e.code,name:e.name,type:e.type,is_active:e.is_active}},_7=async(e,n,s)=>{var l;const a=j7(e,n),o=[];for(let d=1;d<=iv;d+=1){const u=await te.get(a,{params:w7(e,d),signal:s});if(s.aborted||u===null)return null;if(u===void 0||u.status!==200){const h=(l=u==null?void 0:u.data)==null?void 0:l.detail;throw new wr(typeof h=="string"&&h?h:Xc)}const p=u.data;if(p==null||!Array.isArray(p.results)||typeof p.count!="number")throw new wr(Xc);for(const h of p.results)o.push(N7(h,n));if(p.next==null){const h=new Set(o.map(f=>f.id)).size;if(o.length!==p.count||h!==o.length)throw new wr("The account list changed while it was loading. Please try again.");return o}}throw new wr(`Too many accounts to load (more than ${(iv*Ef).toLocaleString("en-CA")}).`)},lc=[],Mr=(e,n)=>{const s=n?`${e}:${n}`:null,[a,o]=x.useState({key:null,status:"loading",accounts:lc,error:null}),[l,d]=x.useState(0),u=x.useCallback(()=>d(h=>h+1),[]);x.useEffect(()=>{if(!s||!n)return;const h=new AbortController;return o(f=>f.key===s&&f.status==="ready"?{...f,status:"loading"}:{key:s,status:"loading",accounts:lc,error:null}),_7(e,n,h.signal).then(f=>{f===null||h.signal.aborted||o({key:s,status:"ready",accounts:f,error:null})}).catch(f=>{h.signal.aborted||o({key:s,status:"error",accounts:lc,error:f instanceof wr?f.message:Xc})}),()=>h.abort()},[s,e,n,l]);const p=s!==null&&a.key===s?a:null;return{accounts:(p==null?void 0:p.accounts)??lc,loading:s!==null&&(p===null||p.status==="loading"),error:(p==null?void 0:p.status)==="error"?p.error:null,refetch:u}},k7="/api/accounting/sales-invoices/",S7=()=>{const[e,n]=x.useState(!1);return{openPdf:x.useCallback(async a=>{var o;n(!0);try{const l=await te.get(`${k7}${a}/pdf/`,{responseType:"blob"});if(l==null)return{ok:!1};if(l.status!==200){let p="Could not generate the PDF.";try{const h=await l.data.text();p=((o=JSON.parse(h))==null?void 0:o.detail)??p}catch{}return{ok:!1,detail:p}}const d=new Blob([l.data],{type:"application/pdf"}),u=URL.createObjectURL(d);return window.open(u,"_blank","noopener"),setTimeout(()=>URL.revokeObjectURL(u),6e4),{ok:!0}}finally{n(!1)}},[]),isOpening:e}},C7=["revenue"],ov=(e,n="That action could not be completed.")=>{var s;return((s=e==null?void 0:e.data)==null?void 0:s.detail)??n},E7={success:"bg-emerald-500",error:"bg-red-600",info:"bg-[#0066FF]"},Ww=({toast:e})=>e?t.jsx("div",{className:`fixed top-5 right-5 z-[60] max-w-md rounded-xl px-5 py-3.5 text-sm font-medium text-white shadow-lg ${E7[e.variant]}`,children:e.message}):null,Ao=({error:e})=>e?t.jsx("div",{className:"mt-3 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:e}
98):null,A7=({invoice:e,canWrite:n,counterpartyEmail:s,onChanged:a})=>{const o=Xe(),{openPdf:l,isOpening:d}=S7(),[u,p]=x.useState(null),[h,f]=x.useState(null),[g,b]=x.useState(null),[v,N]=x.useState(!1),w=x.useRef(null),k=x.useCallback((X,se)=>{w.current&&window.clearTimeout(w.current),b({message:X,variant:se}),w.current=window.setTimeout(()=>b(null),5e3)},[]),_=X=>{f(null),p(X)},S=()=>{f(null),p(null)},T=e.status==="draft",E=e.status==="voided",A=["issued","sent","partial","paid"].includes(e.status),I=e.status==="issued"||e.status==="sent",R=["issued","sent","partial"].includes(e.status),W=T?"Preview (draft)":"PDF",Y=async(X,se,ne)=>{N(!0),f(null);try{const Z=await X();if(Z==null){f("Request was cancelled — please retry.");return}Z.status>=200&&Z.status<300?(p(null),k(se,"success"),ne?ne(Z.data):a()):f(ov(Z))}catch(Z){f(ov(Z==null?void 0:Z.response))}finally{N(!1)}},K=async()=>{const X=await l(e.id);X.ok||k(X.detail??"Could not open the PDF.","error")};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{className:nn,onClick:K,disabled:d,children:W}),n&&T&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:nn,onClick:()=>o(`/accounting/invoices/${e.id}/edit`),children:"Edit"}),t.jsx("button",{className:Md,onClick:()=>_("issue"),children:"Issue"})]}),n&&A&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:nn,onClick:()=>_("send"),children:"Send"}),R&&t.jsx("button",{className:nn,onClick:()=>_("payment"),children:"Record payment"}),t.jsx("button",{className:nn,onClick:()=>_("credit"),children:"Credit note"}),I&&t.jsx("button",{className:nn,onClick:()=>_("void"),children:"Void"})]}),E&&t.jsx("span",{className:"text-sm text-gray-400",children:"Voided — no further actions."}),u==="issue"&&t.jsxs(To,{title:"Issue invoice",onClose:S,children:[t.jsx("p",{className:"text-sm text-gray-600",children:"Issuing assigns a permanent invoice number and posts the entry. This cannot be undone (corrections are made with a credit note). Continue?"}),t.jsx(Ao,{error:h}),t.jsx(Lo,{busy:v,confirmLabel:"Issue",onCancel:S,onConfirm:()=>Y(()=>HP(e.id),"Invoice issued.")})]}),u==="void"&&t.jsx(T7,{busy:v,error:h,onClose:S,onConfirm:X=>Y(()=>qP(e.id,X),"Invoice voided.")}),u==="payment"&&t.jsx(L7,{busy:v,error:h,onClose:S,onConfirm:X=>Y(()=>VP(e.id,X),"Payment recorded.")}),u==="credit"&&t.jsx(I7,{busy:v,error:h,onClose:S,onConfirm:X=>Y(()=>YP(e.id,X),"Credit note created.",se=>{p(null),k("Credit note created.","success"),o(`/accounting/invoices/${se==null?void 0:se.id}`)})}),u==="send"&&t.jsx(R7,{busy:v,error:h,placeholder:s,onClose:S,onConfirm:X=>Y(()=>GP(e.id,X||void 0),"Send queued.")})]}),t.jsx(Ww,{toast:g})]})},To=({title:e,onClose:n,children:s})=>t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:n,children:t.jsx("div",{className:"w-full max-w-lg",onClick:a=>a.stopPropagation(),children:t.jsxs(Te,{padding:!0,children:[t.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900",children:e}),t.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),s]})})}),Lo=({busy:e,confirmLabel:n,onCancel:s,onConfirm:a,disabled:o})=>t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx("button",{className:nn,onClick:s,disabled:e,children:"Cancel"}),t.jsx("button",{className:Md,onClick:a,disabled:e||o,children:e?"Working…":n})]}),T7=({busy:e,error:n,onClose:s,onConfirm:a})=>{const[o,l]=x.useState("");return t.jsxs(To,{title:"Void invoice",onClose:s,children:[t.jsx("p",{className:"mb-2 text-sm text-gray-600",children:"Voiding requires a reason. An invoice with recorded payments cannot be voided."}),t.jsx("textarea",{className:`${Je} min-h-[80px] w-full`,placeholder:"Reason",value:o,onChange:d=>l(d.target.value)}),t.jsx(Ao,{error:n}),t.jsx(Lo,{busy:e,confirmLabel:"Void",disabled:!o.trim(),onCancel:s,onConfirm:()=>a(o.trim())})]})},L7=({busy:e,error:n,onClose:s,onConfirm:a})=>{const[o,l]=x.useState(""),[d,u]=x.useState(""),[p,h]=x.useState("");return t.jsxs(To,{title:"Record payment",onClose:s,children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Amount"}),t.jsx("input",{className:Je,inputMode:"decimal",value:o,onChange:f=>l(f.target.value)})]}),t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Date"}),t.jsx("input",{type:"date",className:Je,value:d,onChange:f=>u(f.target.value)})]}),t.jsxs("label",{className:"col-span-2 flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Method (optional)"}),t.jsx("input",{className:Je,value:p,onChange:f=>h(f.target.value)})]})]}),t.jsx(Ao,{error:n}),t.jsx(Lo,{busy:e,confirmLabel:"Record",disabled:!o||!d,onCancel:s,onConfirm:()=>a({amount:o,payment_date:d,method:p||void 0})})]})},R7=({busy:e,error:n,placeholder:s,onClose:a,onConfirm:o})=>{const[l,d]=x.useState("");return t.jsxs(To,{title:"Send invoice",onClose:a,children:[t.jsx("p",{className:"mb-2 text-sm text-gray-600",children:"The issued PDF is emailed to the customer. Leave blank to use the customer's invoice email; or enter a different address to change the delivery route (the PDF is unchanged)."}),t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Recipient (optional override)"}),t.jsx("input",{className:Je,type:"email",placeholder:s||"[email protected]",value:l,onCh
98ange:u=>d(u.target.value)})]}),t.jsx(Ao,{error:n}),t.jsx(Lo,{busy:e,confirmLabel:"Send",onCancel:a,onConfirm:()=>o(l.trim())})]})},lv=()=>({description:"",quantity:"1",unit_price:"",account:"",tax_treatment:"taxable"}),I7=({busy:e,error:n,onClose:s,onConfirm:a})=>{const{activeOrgId:o}=zt(),{accounts:l,loading:d,error:u}=Mr("owner",o),[p,h]=x.useState([lv()]),f=(b,v)=>h(N=>N.map((w,k)=>k===b?{...w,...v}:w)),g=p.every(b=>b.description&&b.unit_price&&b.account);return t.jsxs(To,{title:"Create credit note",onClose:s,children:[t.jsx("p",{className:"mb-3 text-sm text-gray-600",children:"Enter the lines to credit. A linked credit note is issued immediately."}),t.jsx("div",{className:"space-y-2",children:p.map((b,v)=>t.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[t.jsx("input",{className:`${Je} col-span-4`,placeholder:"Description",value:b.description,onChange:N=>f(v,{description:N.target.value})}),t.jsx("div",{className:"col-span-4",children:t.jsx($r,{id:`credit-note-line-account-${v}`,ariaLabel:"Revenue account",required:!0,value:b.account,onChange:N=>f(v,{account:N}),accounts:l,loading:d,error:u,allowedTypes:C7,placeholder:"Revenue account…"})}),t.jsx("input",{className:`${Je} col-span-2 text-right tabular-nums`,placeholder:"Qty",value:b.quantity,onChange:N=>f(v,{quantity:N.target.value})}),t.jsx("input",{className:`${Je} col-span-2 text-right tabular-nums`,placeholder:"Price",value:b.unit_price,onChange:N=>f(v,{unit_price:N.target.value})})]},v))}),t.jsx("button",{className:nn+" mt-2",onClick:()=>h(b=>[...b,lv()]),children:"Add line"}),t.jsx(Ao,{error:n}),t.jsx(Lo,{busy:e,confirmLabel:"Create credit note",disabled:!g,onCancel:s,onConfirm:()=>a(p)})]})},P7=[{value:"",label:"All"},{value:"draft",label:"Draft"},{value:"issued",label:"Issued"},{value:"sent",label:"Sent"},{value:"partial",label:"Partial"},{value:"paid",label:"Paid"},{value:"voided",label:"Voided"}],F7=[{value:"",label:"All"},{value:"invoice",label:"Invoices"},{value:"credit_note",label:"Credit notes"}],cv=[{label:"Number",fr:1.1},{label:"Customer",fr:1.6},{label:"Issued",fr:1},{label:"Due",fr:1},{label:"Status",fr:1},{label:"Total",fr:1,align:"right"}],D7=()=>{const e=Xe(),{role:n}=ln(),s=n==="owner"||n==="accountant",{byId:a}=Eh(),[o,l]=x.useState(!1),[d,u]=x.useState(null),[p,h]=x.useState(""),[f,g]=x.useState(""),[b,v]=x.useState(""),[N,w]=x.useState(""),k=x.useMemo(()=>{const K={};return p&&(K.status=p),f&&(K.kind=f),N&&(K.search=N),K},[p,f,N]),{items:_,count:S,page:T,setPage:E,pageSize:A,isLoading:I,error:R}=Or("/api/accounting/sales-invoices/",k);x.useEffect(()=>{const K=setTimeout(()=>w(b.trim()),300);return()=>clearTimeout(K)},[b]),x.useEffect(()=>{E(1)},[p,f,N,E]);const W=S===0?0:(T-1)*A+1,Y=Math.min(T*A,S);return t.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:[t.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8",children:[t.jsx(ut,{title:"Invoices",subtitle:"Sales invoices and credit notes",right:s?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{className:nn,onClick:()=>l(!0),children:"Add client"}),t.jsx("button",{className:Md,onClick:()=>e("/accounting/invoices/new"),children:"New invoice"})]}):void 0}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-2",children:[P7.map(K=>t.jsx(On,{active:p===K.value,onClick:()=>h(K.value),children:K.label},K.value||"all")),t.jsx("span",{className:"mx-1 h-6 w-px bg-gray-200"}),F7.map(K=>t.jsx(On,{active:f===K.value,onClick:()=>g(K.value),children:K.label},K.value||"allkind"))]}),t.jsx("div",{className:"mt-3",children:t.jsx("input",{className:`${Je} w-full max-w-sm`,placeholder:"Search by customer name…",value:b,onChange:K=>v(K.target.value)})}),R&&t.jsx("div",{className:"mt-4 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700",children:R}),t.jsx(Te,{className:"mt-4",children:t.jsx(Qc,{columns:cv,isEmpty:!I&&_.length===0,empty:I?"Loading…":"No invoices yet.",children:_.map(K=>{var se;const X=$w(K.status,K.is_overdue);return t.jsx(Jc,{columns:cv,onClick:()=>e(`/accounting/invoices/${K.id}`),cells:[t.jsx("span",{className:"font-medium text-gray-900",children:Ow(K)}),t.jsx("span",{className:"truncate",children:((se=a[K.counterparty])==null?void 0:se.name)??"—"}),K.issue_date??"—",K.due_date??"—",t.jsx(on,{variant:X.variant,children:X.label}),t.jsx("span",{className:"tabular-nums",children:gr(K.total,K.currency)})]},K.id)})})}),t.jsxs("div",{className:"mt-3 flex items-center justify-between text-[13px] text-gray-500",children:[t.jsx("span",{children:S===0?"N
98o results":`${W}–${Y} of ${S}`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{className:"rounded-lg border border-gray-200 px-3 py-1.5 disabled:opacity-40",onClick:()=>E(T-1),disabled:T<=1,children:"Previous"}),t.jsx("button",{className:"rounded-lg border border-gray-200 px-3 py-1.5 disabled:opacity-40",onClick:()=>E(T+1),disabled:T*A>=S,children:"Next"})]})]})]}),o&&t.jsx(Bw,{onCreated:()=>{l(!1),u({message:"Client added — now available.",variant:"success"}),window.setTimeout(()=>u(null),5e3)},onClose:()=>l(!1)}),t.jsx(Ww,{toast:d})]})},Hw=({isOwner:e})=>{const{profile:n,isLoading:s,error:a}=xw();if(s||a||!n)return null;const{isComplete:o,editableMissing:l,provinceMissing:d}=YL(n);return o?null:t.jsx("div",{className:"mt-4 rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800",children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx("svg",{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),t.jsxs("div",{className:"flex-1 space-y-1.5",children:[t.jsx("p",{className:"font-medium",children:"Complete your business identity before issuing."}),l.length>0&&t.jsxs("p",{children:["Missing: ",l.join(", "),"."," ",e?t.jsx(be,{to:"/settings",className:"font-medium underline hover:text-amber-900",children:"Set business identity →"}):t.jsx("span",{children:"Ask the account owner to complete the business identity in Settings."})]}),d&&t.jsxs("p",{children:["Your province/state isn’t set. This is part of your tax jurisdiction —"," ",t.jsx(be,{to:"/accounting/tax-profile",className:"font-medium underline hover:text-amber-900",children:"review your Tax Profile →"})]})]})]})})},O7=["revenue"],$7=[{value:"",label:"None"},{value:"due_on_receipt",label:"Due on receipt"},{value:"net_15",label:"Net 15"},{value:"net_30",label:"Net 30"},{value:"net_60",label:"Net 60"}],M7=[{value:"taxable",label:"Taxable"},{value:"zero_rated",label:"Zero-rated"},{value:"exempt",label:"Exempt"}],wp=()=>({description:"",quantity:"1",unit_price:"",account:"",tax_treatment:"taxable"}),dv=()=>{const e=Xe(),{id:n}=Pr(),s=!!n,{role:a}=ln(),o=a==="owner"||a==="accountant",{options:l,refetch:d}=Eh(),{activeOrgId:u}=zt(),{accounts:p,loading:h,error:f}=Mr("owner",u),[g,b]=x.useState(!1),{invoice:v,isLoading:N}=Dw(s?n:void 0),w=x.useMemo(()=>{const F=new Map;for(const V of(v==null?void 0:v.lines)??[])F.set(V.account,{id:V.account,code:V.account_code,name:V.account_name});return F},[v]),[k,_]=x.useState(""),[S,T]=x.useState(""),[E,A]=x.useState(""),[I,R]=x.useState(""),[W,Y]=x.useState(""),[K,X]=x.useState([wp()]),[se,ne]=x.useState([]),[Z,ue]=x.useState(!1);x.useEffect(()=>{!s||!v||(_(v.counterparty),T(v.payment_terms??""),A(v.issue_date??""),R(v.notes??""),Y(v.payment_instructions??""),X(v.lines.length?v.lines.map(F=>({description:F.description,quantity:F.quantity,unit_price:F.unit_price,account:F.account,tax_treatment:F.tax_treatment})):[wp()]))},[s,v]);const re=s&&v!=null&&v.status!=="draft",H=(F,V)=>X(q=>q.map((ee,je)=>je===F?{...ee,...V}:ee)),M=()=>X(F=>[...F,wp()]),Q=F=>X(V=>V.filter((q,ee)=>ee!==F)),$=x.useMemo(()=>!!k&&K.every(F=>F.description&&F.unit_price&&F.account),[k,K]),L=async()=>{var F;ne([]),ue(!0);try{const V={counterparty:k,payment_terms:S||"",issue_date:E||null,notes:I,payment_instructions:W,lines:K},q=s?await WP(n,V):await zP(V);if(q==null){ne(["Request was cancelled — please retry."]);return}
98if(q.status===201||q.status===200){const ee=((F=q.data)==null?void 0:F.id)??n;e(`/accounting/invoices/${ee}`)}else{const ee=q.data;ne(ee!=null&&ee.detail?[ee.detail]:["Could not save the draft."])}}finally{ue(!1)}};return o?s&&N?t.jsx("div",{className:"min-h-screen bg-gray-50 px-6 py-8 text-gray-500",children:"Loading…"}):re?t.jsx(uv,{message:"This invoice has been issued and can no longer be edited.",onBack:()=>e(`/accounting/invoices/${n}`)}):t.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:[t.jsxs("div",{className:"mx-auto max-w-4xl px-6 py-8",children:[t.jsx(ut,{title:s?"Edit draft invoice":"New invoice"}),t.jsx(Hw,{isOwner:a==="owner"}),se.length>0&&t.jsx("div",{className:"mt-4 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700",children:se.map((F,V)=>t.jsx("div",{children:F},V))}),t.jsx(Te,{padding:!0,className:"mt-6",children:t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(zi,{label:"Customer",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("select",{className:`${Je} flex-1`,value:k,onChange:F=>_(F.target.value),children:[t.jsx("option",{value:"",children:"Select a customer…"}),l.map(F=>t.jsx("option",{value:F.id,children:F.name},F.id))]}),t.jsx("button",{type:"button",className:"whitespace-nowrap rounded-lg border border-gray-200 px-3 py-2 text-sm font-medium text-[var(--color-primary)] hover:bg-gray-50",onClick:()=>b(!0),children:"+ New client"})]})}),t.jsx(zi,{label:"Payment terms",children:t.jsx("select",{className:Je,value:S,onChange:F=>T(F.target.value),children:$7.map(F=>t.jsx("option",{value:F.value,children:F.label},F.value))})}),t.jsx(zi,{label:"Issue date (optional; defaults to today at issue)",children:t.jsx("input",{type:"date",className:Je,value:E,onChange:F=>A(F.target.value)})})]})}),t.jsxs(Te,{padding:!0,className:"mt-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-700",children:"Line items"}),t.jsx("button",{className:nn,onClick:M,children:"Add line"})]}),t.jsx("div",{className:"space-y-3",children:K.map((F,V)=>t.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[t.jsx("input",{className:`${Je} col-span-4`,placeholder:"Description",value:F.description,onChange:q=>H(V,{description:q.target.value})}),t.jsx("div",{className:"col-span-3",children:t.jsx($r,{id:`invoice-line-account-${V}`,ariaLabel:"Revenue account",required:!0,value:F.account,onChange:q=>H(V,{account:q}),accounts:p,loading:h,error:f,allowedTypes:O7,currentAccount:w.get(F.account)??null,placeholder:"Revenue account…"})}),t.jsx("input",{className:`${Je} col-span-1 text-right tabular-nums`,placeholder:"Qty",inputMode:"decimal",value:F.quantity,onChange:q=>H(V,{quantity:q.target.value})}),t.jsx("input",{className:`${Je} col-span-2 text-right tabular-nums`,placeholder:"Unit price",inputMode:"decimal",value:F.unit_price,onChange:q=>H(V,{unit_price:q.target.value})}),t.jsx("select",{className:`${Je} col-span-1`,value:F.tax_treatment,onChange:q=>H(V,{tax_treatment:q.target.value}),children:M7.map(q=>t.jsx("option",{value:q.value,children:q.label},q.value))}),t.jsx("button",{className:"col-span-1 rounded-lg border border-gray-200 text-gray-500 hover:bg-gray-50 disabled:opacity-30",onClick:()=>Q(V),disabled:K.length<=1,title:"Remove line",children:"✕"})]},V))}),t.jsx("p",{className:"mt-3 text-xs text-gray-400",children:"Totals and taxes are computed by the server when the invoice is issued."})]}),t.jsx(Te,{padding:!0,className:"mt-4",children:t.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[t.jsx(zi,{label:"Notes (optional)",children:t.jsx("textarea",{className:`${Je} min-h-[70px]`,value:I,onChange:F=>R(F.target.value)})}),t.jsx(zi,{label:"Payment instructions (optional)",children:t.jsx("textarea",{className:`${Je} min-h-[70px]`,value:W,onChange:F=>Y(F.target.value)})})]})}),t.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[t.jsx("button",{className:Md,onClick:L,disabled:!$||Z,children:Z?"Saving…":"Save draft"}),t.jsx("button",{className:nn,onClick:()=>e(s?`/accounting/invoices/${n}`:"/accounting/invoices"),children:"Cancel"})]})]}),g&&t.jsx(Bw,{onCreated:F=>{b(!1),d(),_(F.id)},onClose:()=>b(!1)})]}):t.jsx(uv,{message:"You do not have permission to create invoices.",onBack:()=>e("/accounting/invoices")})},zi=({label:e,children:n})=>t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-500",children:e}),n]}),uv=({message:e,onBack:n})=>t.jsx("div",{className:"min-h-screen bg-gray-50 px-6 py-8",children:t.jsxs("div",{className:"mx-auto max-w-2xl",children:[t.jsx("div",{className:"rounded-lg bg-amber-50 px-4 py-3 text-sm text-amber-800",children:e}),t.jsx("button",{className:nn+" mt-4",onClick:n,children:"Back"})]})}),mv=[{label:"Description",fr:2.2},{label:"Account",fr:1.6},{label:"Qty",fr:.6,align:"right"},{label:"Unit price",fr:1,align:"right"},{label:"Tax",fr:1,align:"right"}],pv=[{label:"Date",fr:1},{label:"Method",fr:1},{label:"Amount",fr:1,align:"right"}],B7=()=>{const{id:e}=Pr(),n=Xe(),{role:s}=ln(),a=s==="owner"||s==="accountant",{invoice:o,isLoading:l,error:d,refetch:u}=Dw(e),{byId:p}=Eh();if(l)return t.jsx("div",{className:"min-h-screen bg-gray-50 px-6 py-8 text-gray-500",children:"Loading…"});if(d||!o)return t.jsx("div",{className:"min-h-screen bg-gray-50 px-6 py-8",children:t.jsxs("div",{className:"mx-auto max-w-3xl",children:[t.jsx("div",{className:"rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700",children:d??"Invoice not found."}),t.jsx("button",{className:nn+" mt-4",onClick:()=>n("/accounting/invoices"),children:"Back to invoices"})]})});const h=p[o.counterparty],f=$w(o.status,o.is_overdue),g=o.kind==="credit_note",b=o.currency;return t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-4xl px-6 py-8",children:[t.jsx("button",{className:"mb-4 text-sm text-gray-500 hover:text-gray-700",onClick:()=>n("/accounting/invoices"),children:"← Invoices"}),t.jsx(ut,{title:`${g?"Credit note":"Invoice"} ${Ow(o)}
98`,subtitle:h==null?void 0:h.name,right:t.jsx(A7,{invoice:o,canWrite:a,counterpartyEmail:h==null?void 0:h.email,onChanged:u})}),t.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[t.jsx(on,{variant:f.variant,children:f.label}),o.related_invoice&&t.jsx("button",{className:"text-xs text-blue-600 hover:underline",onClick:()=>n(`/accounting/invoices/${o.related_invoice}`),children:"View related invoice"})]}),o.status==="draft"&&t.jsx(Hw,{isOwner:s==="owner"}),t.jsx(Te,{padding:!0,className:"mt-5",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm sm:grid-cols-4",children:[t.jsx(cc,{label:"Customer",value:(h==null?void 0:h.name)??"—"}),t.jsx(cc,{label:"Issue date",value:o.issue_date??"—"}),t.jsx(cc,{label:"Due date",value:o.due_date??"—"}),t.jsx(cc,{label:"Terms",value:o.payment_terms||"—"})]})}),t.jsxs(Te,{className:"mt-4",children:[t.jsx(Qc,{columns:mv,isEmpty:o.lines.length===0,empty:"No lines.",children:o.lines.map(v=>t.jsx(Jc,{columns:mv,cells:[v.description,t.jsxs("span",{className:"text-gray-500",children:[v.account_code," ",v.account_name]}),t.jsx("span",{className:"tabular-nums",children:v.quantity}),t.jsx("span",{className:"tabular-nums",children:gr(v.unit_price,b)}),t.jsx("span",{className:"tabular-nums",children:v.tax_amount!=null?gr(v.tax_amount,b):v.tax_treatment==="taxable"?"—":v.tax_treatment.replace("_","-")})]},v.id))}),t.jsx("div",{className:"flex justify-end border-t border-gray-100 px-4 py-4",children:t.jsxs("div",{className:"w-64 space-y-1 text-sm",children:[t.jsx(Np,{label:"Subtotal",value:gr(o.subtotal,b)}),t.jsx(Np,{label:"Tax",value:gr(o.tax_total,b)}),t.jsx("div",{className:"border-t border-gray-100 pt-1"}),t.jsx(Np,{label:"Total",value:gr(o.total,b),bold:!0})]})})]}),o.payments.length>0&&t.jsxs(Te,{className:"mt-4",children:[t.jsx("div",{className:"px-4 pt-3 text-sm font-semibold text-gray-700",children:"Payments"}),t.jsx(Qc,{columns:pv,children:o.payments.map(v=>t.jsx(Jc,{columns:pv,cells:[v.payment_date,v.method||"—",t.jsx("span",{className:"tabular-nums",children:gr(v.amount,b)})]},v.id))})]}),(o.notes||o.payment_instructions)&&t.jsxs(Te,{padding:!0,className:"mt-4 text-sm text-gray-600",children:[o.notes&&t.jsx("p",{className:"whitespace-pre-wrap",children:o.notes}),o.payment_instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-gray-500",children:o.payment_instructions})]})]})})},cc=({label:e,value:n})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-medium text-gray-400",children:e}),t.jsx("div",{className:"mt-0.5 text-gray-800",children:n})]}),Np=({label:e,value:n,bold:s})=>t.jsxs("div",{className:`flex justify-between ${s?"font-semibold text-gray-900":"text-gray-600"}`,children:[t.jsx("span",{children:e}),t.jsx("span",{className:"tabular-nums",children:n})]}),xn=e=>{if(e==null||e==="")return"";const n=Number(e);if(Number.isNaN(n))return`$${e}`;const s=Math.abs(n).toLocaleString("en-CA",{minimumFractionDigits:2,maximumFractionDigits:2});return n<0?`-$${s}`:`$${s}`},Qs="font-[var(--font-family-mono)] tabular-nums",U7=()=>t.jsx("svg",{className:"h-3.5 w-3.5 shrink-0 text-gray-400 opacity-0 transition-opacity group-hover:opacity-100",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),qw=({rows:e,accountHref:n})=>e.length===0?t.jsx("div",{className:"py-2 text-[13px] text-gray-400",children:"No activity in this period."}):t.jsx(t.Fragment,{children:e.map(s=>s.code!==null&&n?t.jsxs(be,{to:n(s.code),className:"group flex cursor-pointer items-center justify-between py-1.5",children:[t.jsx("span",{className:"text-[14px] text-gray-700",children:s.name}),t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`text-[14px] text-gray-900 ${Qs}`,children:xn(s.amount)}),t.jsx(U7,{})]})]},s.code):t.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[t.jsx("span",{className:"text-[14px] text-gray-700",children:s.name}),t.jsx("span",{className:`text-[14px] text-gray-900 ${Qs}`,children:xn(s.amount)})]},s.code??s.name))}),fv={period:"ytd"},Br=e=>e.period==="custom"&&e.date_from&&e.date_to?{period:"custom",date_from:e.date_from,date_to:e.date_to}:{period:e.period},Ur=e=>new URLSearchParams(Br(e)).toString();function Bd(e,n,s){const[a,o]=x.useState(null),[l,d]=x.useState(!0),[u,p]=x.useState(null),[h,f]=x.use
98State(null),[g,b]=x.useState(0),v=x.useCallback(()=>b(N=>N+1),[]);return x.useEffect(()=>{let N=!1;return d(!0),p(null),f(null),te.get(e,n?{params:n}:void 0).then(w=>{var k;N||w==null||(f(w.status??null),w.status===200?o(w.data):(o(null),p(((k=w.data)==null?void 0:k.detail)??"Failed to load report")))}).catch(w=>{var k,_,S;N||(f(((k=w==null?void 0:w.response)==null?void 0:k.status)??null),p(((S=(_=w==null?void 0:w.response)==null?void 0:_.data)==null?void 0:S.detail)??"Failed to load report"))}).finally(()=>{N||d(!1)}),()=>{N=!0}},[...s,g]),{data:a,isLoading:l,error:u,status:h,refetch:v}}const z7=e=>Bd("/api/accounting/reports/pnl/",Br(e),[Ur(e)]),W7=e=>Bd("/api/accounting/reports/balance-sheet/",Br(e),[Ur(e)]),H7=()=>Bd("/api/accounting/reports/taxes/",void 0,[]),q7=(e,n,s,a=100)=>Bd(`/api/accounting/reports/account/${encodeURIComponent(e)}/ledger/`,{...Br(n),page:String(s),page_size:String(a)},[e,Ur(n),s,a]),V7=["ytd","quarter","month","custom"],hv=/^\d{4}-\d{2}-\d{2}$/,xv=366,Y7=e=>e!==null&&V7.includes(e);function Af(e,n){if(!e||!n)return"Choose both a start and an end date.";if(!hv.test(e)||!hv.test(n))return"Dates must be YYYY-MM-DD.";let s,a;try{s=Cf(e),a=Cf(n)}catch{return"Dates must be YYYY-MM-DD."}return s>a?"The start date must be on or before the end date.":Math.round((a.getTime()-s.getTime())/864e5)>xv?`A custom range may span at most ${xv} days.`:null}function G7(e){const n=e.get("period");if(!Y7(n))return fv;if(n!=="custom")return{period:n};const s=e.get("from")??void 0,a=e.get("to")??void 0;return Af(s,a)!==null?fv:{period:"custom",date_from:s,date_to:a}}function Oa(e){const n=new URLSearchParams({period:e.period});return e.period==="custom"&&e.date_from&&e.date_to&&(n.set("from",e.date_from),n.set("to",e.date_to)),n.toString()}function Ud(){const[e,n]=Jn(),s=x.useMemo(()=>G7(e),[e]),a=x.useCallback(o=>{const l=new URLSearchParams(e);l.set("period",o.period),o.period==="custom"&&o.date_from&&o.date_to?(l.set("from",o.date_from),l.set("to",o.date_to)):(l.delete("from"),l.delete("to")),n(l,{replace:!0})},[e,n]);return[s,a]}const K7=[{kind:"ytd",label:"Year to date"},{kind:"quarter",label:"This quarter"},{kind:"month",label:"This month"},{kind:"custom",label:"Custom"}],gv="rounded-lg border border-gray-300 bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition",zd=({period:e,setPeriod:n})=>{const[s,a]=x.useState(e.period==="custom"),[o,l]=x.useState(e.date_from??""),[d,u]=x.useState(e.date_to??""),p=Af(o||void 0,d||void 0),h=b=>{if(b==="custom"){a(!0),p===null&&n({period:"custom",date_from:o,date_to:d});return}a(!1),n({period:b})},f=(b,v)=>{const N=b==="from"?v:o,w=b==="to"?v:d;b==="from"?l(v):u(v),Af(N||void 0,w||void 0)===null&&n({period:"custom",date_from:N,date_to:w})},g=e.period==="custom"||s;return t.jsxs("div",{className:"no-print flex flex-col items-end gap-2",children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:K7.map(({kind:b,label:v})=>t.jsx(On,{active:b==="custom"?g:e.period===b&&!s,onClick:()=>h(b),children:v},b))}),g&&t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[t.jsxs("label",{className:"text-[12px] text-gray-500",children:["From"," ",t.jsx("input",{type:"date",value:o,onChange:b=>f("from",b.target.value),className:gv})]}),t.jsxs("label",{className:"text-[12px] text-gray-500",children:["To"," ",t.jsx("input",{type:"date",value:d,onChange:b=>f("to",b.target.value),className:gv})]}),p&&(o||d)&&t.jsx("span",{className:"text-[12px] text-red-600",children:p})]})]})},Vw={pnl:"pnl",balance_sheet:"balance-sheet",taxes:"taxes"},Q7=(e,n)=>e==="account"?`/api/accounting/reports/account/${encodeURIComponent(n??"")}/export/`:`/api/accounting/reports/${Vw[e]}/export/`,J7=(e,n,s)=>e==="taxes"?`format=${n}`:`format=${n}&${Ur(s)}`,X7=(e,n)=>{if(!e)return n;const s=/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(e);return s!=null&&s[1]?decodeURIComponent(s[1]):n},Z7=async(e,n)=>{try{if(e instanceof Blob){const s=JSON.parse(await e.text());if(typeof(s==null?void 0:s.detail)=="string")return s.detail}}catch{}return n},eF=async(e,n)=>
98e===413?"This export is too large. Narrow the period and try again.":e===429?"Too many exports — please wait a minute.":e===403?"You do not have access to this report.":e===404?"Account not found.":Z7(n,"The export could not be generated. Please try again.");async function tF(e,n,s,a,o=Q7){var v,N;const l=`${o(e,a)}?${J7(e,n,s)}`,d=await te.get(l,{responseType:"blob"});if(d==null)return{ok:!1,status:0,message:"The export could not be generated. Please try again."};if(d.status!==200)return{ok:!1,status:d.status,message:await eF(d.status,d.data)};const u=`${e==="account"&&a?`account_${a}`:e}.${n}`,p=w=>typeof w=="string"?w:void 0,h=X7(p((v=d.headers)==null?void 0:v["content-disposition"]),u),f=new Blob([d.data],{type:p((N=d.headers)==null?void 0:N["content-type"])||"application/octet-stream"}),g=URL.createObjectURL(f),b=document.createElement("a");return b.href=g,b.download=h,b.rel="noopener",document.body.appendChild(b),b.click(),b.remove(),setTimeout(()=>URL.revokeObjectURL(g),1e4),{ok:!0}}const nF=()=>{const[e,n]=x.useState(null);return{exportReport:x.useCallback(async(a,o,l,d,u)=>{n(o);try{return await tF(a,o,l,d,u)}finally{n(null)}},[]),busy:e}},_p="inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-[13px] font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-60",Ir=({kind:e,period:n,code:s,exportUrl:a})=>{const{exportReport:o,busy:l}=nF(),[d,u]=x.useState(null),p=async h=>{u(null);const f=await o(e,h,n,s,a);f.ok||u(f.message)};return t.jsxs("div",{className:"no-print flex flex-col items-end gap-1",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx("button",{type:"button",className:_p,disabled:l!==null,onClick:()=>p("pdf"),children:l==="pdf"?"Preparing…":"Export PDF"}),t.jsx("button",{type:"button",className:_p,disabled:l!==null,onClick:()=>p("xlsx"),children:l==="xlsx"?"Preparing…":"Export Excel"}),t.jsx("button",{type:"button",className:_p,onClick:()=>window.print(),children:"Print"})]}),d&&t.jsx("span",{className:"text-[12px] text-red-600",children:d})]})},Yw=(e,n,s)=>`/accounting/reports/account/${encodeURIComponent(e)}?${Oa(n)}&from_report=${s}`,sF=e=>e===null?"—":jn(e,{year:"numeric",month:"long",day:"numeric"}),Zc=({children:e,tone:n="muted"})=>t.jsx("div",{className:`text-[13.5px] ${n==="error"?"text-red-600":"text-gray-400"}`,children:e}),Qi=({title:e,section:n,totalLabel:s,linkTo:a})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:e}),t.jsx("div",{className:"mt-2 divide-y divide-gray-100",children:t.jsx(qw,{rows:n.rows,accountHref:a})}),t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2",children:[t.jsx("span",{className:"text-[13px] font-medium text-gray-600",children:s}),t.jsx("span",{className:`text-[14px] font-semibold text-gray-900 ${Qs}`,children:xn(n.total)})]})]}),rF=({period:e,setPeriod:n})=>{const{data:s,isLoading:a,error:o}=z7(e),l=d=>Yw(d,e,"pnl");return t.jsxs(Te,{padding:!0,className:"space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-[17px] font-semibold text-gray-900",children:"Profit & Loss"}),s&&t.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500",children:s.period.label})]}),t.jsxs("div",{className:"flex flex-col items-end gap-2",children:[t.jsx(Ir,{kind:"pnl",period:e}),t.jsx(zd,{period:e,setPeriod:n})]})]}),a&&t.jsx(Zc,{children:"Loading…"}),o&&t.jsx(Zc,{tone:"error",children:o}),s&&!o&&t.jsxs("div",{className:"space-y-5",children:[t.jsx(Qi,{title:"Revenue",section:s.revenue,totalLabel:"Total revenue",linkTo:l}),t.jsx(Qi,{title:"Expenses",section:s.expenses,totalLabel:"Total expenses",linkTo:l}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[var(--color-navy)] px-4 py-3 text-white",children:[t.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wider",children:"Net profit"}),t.jsx("span",{className:`text-[17px] font-semibold ${Qs}`,children:xn(s.net)})]})]})]})},aF=({period:e})=>{const{data:n,isLoading:s,error:a}=W7(e),o=l=>Yw(l,e,"balance_sheet");return t.jsxs(Te,{padding:!0,className:"space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-[17px] font-semibold text-gray-900",children:"Balance Sheet"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n&&t.jsxs("div",{className:"flex items-center gap-2",children:[!n.balances&&t.jsx(on,{variant:"warning",children:"Out of balance"}),t.jsxs("span",{className:"text-[13px] text-gray-500",children:["As of ",sF(n.as_of)]})]}),t.jsx(Ir,{kind:"balance_sheet",period:e})]})]}),s&&t.jsx(Zc,{children:"Loading…"}),a&&t.jsx(Zc,{tone:"error",children:a}),n&&!a&&t.jsxs("div",{className:"space-y-5",children:[t.jsx(Qi,{title:"Assets",section:n.assets,totalLabel:"Total assets",linkTo:o}),t.jsx(Qi,{title:"Liabilities",section:n.liabilities,totalLabel:"Total liabilities",linkTo:o}),t.jsx(Qi,{title:"Equity",section:n.equity,totalLabel:"Total equity",linkTo:o})]})]})},iF=()=>{const[e,n]=Ud();return t.jsx("div",{className:"reports-print min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-6 py-8",children:[t.jsx(ut,{title:"Reports",subtitle:"Your profit & loss and balance sheet, straight from the ledger."}),t.jsx(rF,{period:e,setPeriod:n}),t.jsx(aF,{period:e}),t.jsx(be,{to:"/accounting/taxes",className:"block",children:t.jsxs(Te,{padding:!0,className:"flex items-center justify-between transition hover:shadow-md",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[15px] font-semibold text-gray-900",children:"GST/HST summary"}),t.jsx("div",{className:"mt-0.5 text-[13px] text-gray-500",children:"What you've collected, what you can claim, and when it's due."})]}),t.jsx("span",{className:"text-[13px] font-medium text-[var(--color-primary)]",children:"View taxes →"})]})})]})})},yv=e=>e===null?"—":jn(e),hr=({label:e,value:n,mono:s=!0})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-gray-500",children:e}),t.jsx("div",{className:`mt-0.5 text-[14px] text-gray-900 ${s?Qs:""}`,children:n})]}
98),Gw=({data:e,exportSlot:n=null})=>t.jsxs(Te,{padding:!0,children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("span",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Summary"}),n]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-4 lg:grid-cols-7",children:[t.jsx(hr,{label:"Account",value:`${e.account.code} · ${e.account.name}`,mono:!1}),t.jsx(hr,{label:"Period",value:`${yv(e.period.start)} → ${yv(e.period.end)}`,mono:!1}),t.jsx(hr,{label:"Opening balance",value:e.opening_balance===null?"—":xn(e.opening_balance)}),t.jsx(hr,{label:"Total debits",value:xn(e.total_debits)}),t.jsx(hr,{label:"Total credits",value:xn(e.total_credits)}),t.jsx(hr,{label:"Net change",value:xn(e.net_change)}),t.jsx(hr,{label:"Closing balance",value:xn(e.closing_balance)})]})]}),oF=e=>te.post("/api/accounting/adjustments/",e),lF=(e,n)=>te.post(`/api/accounting/adjustments/${e}/void/`,{reason:n}),cF=new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD"}),bv="font-[var(--font-family-mono)] tabular-nums",ed=e=>{const n=e.trim();if(!/^\d+(\.\d{1,2})?$/.test(n))return null;const s=Math.round(Number(n)*100);return s>0?s:null},dc=e=>cF.format(e/100),Kw=()=>{const e=new Date,n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${n}-${s}`},uc="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition",dF=e=>{if(!e.account_id)return!1;const n=ed(e.debit),s=ed(e.credit);return n!==null&&e.credit.trim()===""||s!==null&&e.debit.trim()===""},uF=e=>{const n=(e??[]).map((s,a)=>({key:a,account_id:s.id,debit:"",credit:""}));for(;n.length<2;)n.push({key:n.length,account_id:"",debit:"",credit:""});return n},Qw=({seedAccounts:e,initialMemo:n,initialDate:s,onPosted:a,onCancel:o})=>{const{showToast:l}=Od(),{activeOrgId:d}=zt(),{accounts:u,loading:p,error:h}=Mr("accountant",d),[f,g]=x.useState(s??Kw()),[b,v]=x.useState(n??""),N=x.useMemo(()=>uF(e),[e]),[w,k]=x.useState(N),[_,S]=x.useState(N.length),[T,E]=x.useState(!1),[A,I]=x.useState(null),R=(L,F)=>k(V=>V.map(q=>q.key===L?{...q,...F}:q)),W=(L,F)=>R(L,{debit:F,credit:""}),Y=(L,F)=>R(L,{credit:F,debit:""}),K=()=>{k(L=>[...L,{key:_,account_id:"",debit:"",credit:""}]),S(L=>L+1)},X=L=>k(F=>F.length<=2?F:F.filter(V=>V.key!==L)),{debitCents:se,creditCents:ne}=x.useMemo(()=>{let L=0,F=0;for(const V of w){const q=ed(V.debit),ee=ed(V.credit);q!==null&&V.credit.trim()===""?L+=q:ee!==null&&V.debit.trim()===""&&(F+=ee)}return{debitCents:L,creditCents:F}},[w]),Z=x.useMemo(()=>new Set(u.filter(L=>L.is_active).map(L=>L.id)),[u]),ue=L=>!h&&!!L.account_id&&!Z.has(L.account_id),re=w.some(ue),H=se>0&&se===ne,M=w.every(dF),Q=H&&b.trim().length>0&&w.length>=2&&M&&!re&&!T,$=async()=>{var F,V,q;if(!Q)return;E(!0),I(null);const L={date:f,memo:b.trim(),lines:w.map(ee=>({account_id:ee.account_id,side:ee.debit.trim()!==""?"debit":"credit",amount:(ee.debit.trim()!==""?ee.debit:ee.credit).trim()}))};try{const ee=await oF(L);(ee==null?void 0:ee.status)===201?(l({title:"Adjustment posted",message:"The correcting entry is on the ledger.",variant:"success"}),a()):I(((F=ee==null?void 0:ee.data)==null?void 0:F.detail)??"The adjustment could not be posted.")}catch(ee){I(((q=(V=ee==null?void 0:ee.response)==null?void 0:V.data)==null?void 0:q.detail)??"The adjustment could not be posted.")}finally{E(!1)}};return p?t.jsx(Te,{padding:!0,children:t.jsx("p",{className:"text-[13.5px] text-gray-400",children:"Loading accounts…"})}):t.jsxs(t.Fragment,{children:[h&&t.jsx(Te,{padding:!0,className:"mb-4",children:t.jsx("p",{className:"text-sm text-red-600",children:h})}),t.jsxs(Te,{padding:!0,className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:"Date"}),t.jsx("input",{type:"date",value:f,onChange:L=>g(L.target.value),className:uc})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"mb-1.5 block text-sm font-medium text-gray-700",children:["Memo ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:b,onChange:L=>v(L.target.value),placeholder:"Reason for the adjustment",className:uc})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"grid grid-cols-[1fr_140px_140px_36px] items-center gap-3 px-1 pb-2 text-[11px] font-semibold uppercase tracking-wider text-gray-500",children:[t.jsx("span",{children:"Account"}),t.jsx("span",{className:"justify-self-end",children:"Debit"}),t.jsx("span",{className:"justify-self-end",children:"Credit"}),t.jsx("span",{})]}),t.jsx("div",{className:"space-y-2",children:w.map(L=>t.jsxs("div",{className:"grid grid-cols-[1fr_140px_140px_36px] items-center gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx($r,{id:`adjustment-account-${L.key}`,ariaLabel:"Account",required:!0,value:L.account_id,onChange:F=>R(L.key,{account_id:F}),accounts:u,error:h,currentAccount:(e==null?void 0:e[L.key])??null,placeholder:"Select account…"}),ue(L)&&t.jsx("span",{className:"mt-1 inline-block rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700",children:"inactive"})]}),t.jsx("input",{inputMode:"decimal",value:L.debit,onChange:F=>W(L.key,F.target.value),placeholder:"0.00",className:`${uc} text-right ${bv}`,"aria-label":"Debit amount"}),t.jsx("input",{inputMode:"decimal",value:L.credit,onChange:F=>Y(L.key,F.target.value),placeholder:"0.00",className:`${uc} text-right ${bv}`,"aria-label":"Credit amount"}),t.jsx("button",{type:"button",onClick:()=>X(L.key),disabled:w.length<=2,"aria-label":"Remove line",className:"flex h-9 w-9 items-center justify-center rounded-lg text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:opacity-30 disabled:hover:bg-transparent",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:"h-4 w-4",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},L.key))}),t.jsxs("button",{type:"button",onClick:K,className:"mt-3 inline-flex items-center gap-1.5 text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Add line"]})]}),t.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 pt-5",children:[t.jsx("span",{className:`inline-flex items-center rounded-lg px-3 py-1.5 text-[13px] font-semibold ${H?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:H?`Balanced · ${dc(se)} = ${dc(ne)}`:`Out of balance · ${dc(se)} ≠ ${dc(ne)}`}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:o,className:"rounded-lg border border-gray-200 px-4 py-2 text-[13px] font-medium text-gray-600 transition-colors hover:bg-gray-50",children:"Cancel"}),t.jsx("button",{type:"button",onClick:$,disabled:!Q,className:"rounded-lg bg-[var(--color-navy)] px-5 py-2 text-[13px] font-semibold text-white transition-opacity hover:opacity-90 disabled:opacity-40",children:T?"Posting…":"Post adjustment"})]})]}),re&&t.jsx("p",{className:"text-[12.5px] text-amber-700",children:"A line uses an inactive account — choose an active account to post."}),A&&t.jsx("p",{className:"text-sm text-red-600",children:A})]}),t.jsx("p",{className:"mt-4 text-[12.5px] text-gray-400",children:"Adjustments post as new balanced entries and pass the posting engine — nothing existing is edited or deleted."})]})},mF=new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD"}),mc=e=>e==null||e===""?"":mF.format(Number(e)),pF=e=>jn(e),fF=e=>
98new Date(e).toLocaleString("en-CA",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),ja="font-[var(--font-family-mono)] tabular-nums",hF=e=>{const n=e.replace(/_/g," ").trim();return n.length===0?"—":n.charAt(0).toUpperCase()+n.slice(1)},xF=e=>e==="posted"?"success":e==="reversed"?"info":e==="voided"?"voided":"neutral",gF=e=>`/api/accounting/documents/${e}/file-url/`,Tf=({row:e,adjustOpen:n,onToggleAdjust:s,onPosted:a,onVoided:o,readOnly:l=!1,documentUrl:d=gF,onOpenEntry:u})=>{const p=e.source_document_id==null?null:d(String(e.source_document_id)),{showToast:h}=Od(),f=ht(H=>{var M,Q,$;return((Q=(M=H.auth.user)==null?void 0:M.user)==null?void 0:Q.id)??(($=H.auth.user)==null?void 0:$.id)??null}),g=[...e.lines].sort((H,M)=>H.line_order-M.line_order),b=$d(e),[v,N]=x.useState(null),w=e.status==="voided"||v!==null,k=(v==null?void 0:v.voided_at)??e.voided_at??null,_=(v==null?void 0:v.void_reason)??e.void_reason??"",S=!l&&!w&&Gc("accountant",e,"adjust"),T=w?null:Eo(e),E=!l&&!w&&Gc("accountant",e,"void")&&e.status==="posted"&&e.source==="accountant_adjustment"&&f!=null&&e.created_by===f,[A,I]=x.useState(!1),[R,W]=x.useState(""),[Y,K]=x.useState(!1),[X,se]=x.useState(null),ne=async()=>{var H,M,Q,$,L;if(!(!R.trim()||Y)){K(!0),se(null);try{const F=await lF(e.id,R.trim());(F==null?void 0:F.status)===200?(N({voided_at:((H=F.data)==null?void 0:H.voided_at)??null,void_reason:((M=F.data)==null?void 0:M.void_reason)??R.trim()}),I(!1),h({title:"Entry voided",message:"It no longer affects balances or reports.",variant:"success"}),o==null||o()):se(((Q=F==null?void 0:F.data)==null?void 0:Q.detail)??"The entry could not be voided.")}catch(F){se(((L=($=F==null?void 0:F.response)==null?void 0:$.data)==null?void 0:L.detail)??"The entry could not be voided.")}finally{K(!1)}}},Z=async()=>{var M,Q,$,L;if(p==null)return;const H=window.open("about:blank","_blank");H&&(H.opener=null);try{const F=await te.get(p),V=(F==null?void 0:F.status)===200?(M=F.data)==null?void 0:M.url:null;V?H?H.location.href=V:window.open(V,"_blank","noopener,noreferrer"):(H&&H.close(),h({title:"Could not open document",message:((Q=F==null?void 0:F.data)==null?void 0:Q.detail)??"Please try again in a moment.",variant:"danger"}))}catch(F){H&&H.close(),h({title:"Could not open document",message:((L=($=F==null?void 0:F.response)==null?void 0:$.data)==null?void 0:L.detail)??"Please try again in a moment.",variant:"danger"})}},ue=g.filter(Lw).map(H=>({id:H.account_id,code:H.account_code??"—",name:H.account_name??""})),re=`Adjustment re ${e.entry_number_display??"entry"}`;return t.jsxs("div",{className:"border-b border-gray-100 bg-gray-50 px-5 py-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[t.jsx("span",{className:`text-[13px] font-semibold text-gray-900 ${ja} ${w?"line-through text-gray-400":""}`,children:e.entry_number_display??"—"}),t.jsx("span",{className:"text-gray-300",children:"·"}),t.jsx("span",{className:"text-[13px] text-gray-600",children:pF(e.entry_date)}),t.jsx("span",{className:"text-gray-300",children:"·"}),t.jsx(on,{variant:"neutral",children:hF(e.source)}),t.jsx(on,{variant:xF(w?"voided":Lr(e)),children:w?"Voided":Ks(e)})]}),w&&t.jsxs("div",{className:"mt-3 rounded-xl bg-gray-100 px-4 py-3 text-[12.5px] text-gray-500",children:["Voided",k?` on ${fF(k)}`:"",". Removed from balances and reports; retained in the audit trail.",_?t.jsxs("span",{className:"mt-1 block text-gray-600",children:["Reason: ",_]}):null]}),t.jsxs("div",{className:"mt-3 overflow-hidden rounded-xl border border-gray-100 bg-white",children:[t.jsxs("div",{className:"grid grid-cols-[1fr_140px_140px] gap-3 border-b border-gray-100 px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:[t.jsx("span",{children:"Account"}),t.jsx("span",{className:"justify-self-end",children:"Debit"}),t.jsx("span",{className:"justify-self-end",children:"Credit"})]}),t.jsx("div",{className:"divide-y divide-gray-50",children:g.map(H=>t.jsxs("div",{className:"grid grid-cols-[1fr_140px_140px] items-start gap-3 px-4 py-2.5",children:[t.jsxs("span",{className:"text-[13px] text-gray-800",children:[t.jsx("span",{className:`text-gray-500 ${ja}`,children:H.account_code??""}),H.account_code?" · ":"",H.account_name??"",Tw(H)&&t.jsx("span",{className:"ml-2 roun
98ded-full bg-gray-100 px-1.5 py-0.5 text-[10.5px] font-medium text-gray-500",children:"reversing"}),H.description?t.jsx("span",{className:"mt-0.5 block text-[11.5px] text-gray-400",children:H.description}):null]}),t.jsx("span",{className:`justify-self-end text-[13px] text-gray-800 ${ja}`,children:mc(H.debit)}),t.jsx("span",{className:`justify-self-end text-[13px] text-gray-800 ${ja}`,children:mc(H.credit)})]},H.id))}),t.jsxs("div",{className:"grid grid-cols-[1fr_140px_140px] gap-3 border-t border-gray-100 bg-gray-50 px-4 py-2.5 text-[12px] font-semibold text-gray-600",children:[t.jsx("span",{className:"justify-self-start",children:b.effective?"Total (excluding reversing lines)":"Total"}),t.jsx("span",{className:`justify-self-end text-gray-900 ${ja}`,children:mc(b.debits)}),t.jsx("span",{className:`justify-self-end text-gray-900 ${ja}`,children:mc(b.credits)})]})]}),e.description?t.jsx("p",{className:"mt-2 text-[13px] text-gray-600",children:e.description}):null,T&&t.jsx("p",{className:"mt-2 text-[12.5px] text-gray-500",children:T}),t.jsx(Sh,{className:"mt-3",chain:e.chain,currentId:e.id,liveEntry:e.live_entry,truncated:e.chain_truncated,onOpenEntry:u}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[p!=null&&t.jsxs("button",{type:"button",onClick:Z,className:"inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-50",children:[t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.7,stroke:"currentColor",className:"h-4 w-4",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),"View document"]}),S&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1.5 rounded-lg bg-[var(--color-navy)] px-3 py-1.5 text-[13px] font-semibold text-white transition-opacity hover:opacity-90",children:n?"Hide adjustment":"Adjust this entry"}),E&&!A&&t.jsx("button",{type:"button",onClick:()=>{I(!0),se(null)},className:"inline-flex items-center gap-1.5 rounded-lg border border-red-200 bg-white px-3 py-1.5 text-[13px] font-semibold text-red-600 transition-colors hover:bg-red-50",children:"Void entry"})]}),A&&t.jsxs("div",{className:"mt-3 rounded-xl border border-red-200 bg-red-50/60 p-4",children:[t.jsxs("div",{className:"text-[13px] font-semibold text-gray-900",children:["Void ",e.entry_number_display??"this entry"]}),t.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-gray-600",children:"Voiding removes this entry from balances and reports and from this list. It stays in the audit trail. This cannot be undone."}),t.jsx("label",{className:"mt-3 block text-[12px] font-medium text-gray-700",children:"Reason"}),t.jsx("textarea",{value:R,onChange:H=>W(H.target.value),maxLength:500,rows:3,placeholder:"Why is this entry being voided?",className:"mt-1 w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition"}),t.jsxs("div",{className:"mt-1 text-right text-[11px] text-gray-400",children:[R.length,"/500"]}),X&&t.jsx("p",{className:"mt-1 text-sm text-red-600",children:X}),t.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{I(!1),se(null)},className:"rounded-lg border border-gray-200 bg-white px-4 py-2 text-[13px] font-medium text-gray-600 transition-colors hover:bg-gray-50",children:"Cancel"}),t.jsx("button",{type:"button",onClick:ne,disabled:!R.trim()||Y,className:"rounded-lg bg-red-600 px-5 py-2 text-[13px] font-semibold text-white transition-opacity hover:opacity-90 disabled:opacity-40",children:Y?"Voiding…":"Void entry"})]})]}),n&&S&&t.jsxs("div",{className:"mt-4",children:[t.jsx("div",{className:"mb-2 text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"New adjusting entry"}),t.jsx(Qw,{seedAccounts:ue,initialMemo:re,initialDate:Kw(),onPosted:a,onCancel:s},e.id)]})]})},td=e=>{const n=e.replace(/_/g," ").trim();return n.length===0?"—":n.charAt(0).toUpperCase()+n.slice(1)},pc="whitespace-nowrap px-4 py-3 text-gray-700",kp=`whitespace-nowrap px-4 py-3 text-right text-gray-900 ${Qs}`,Jw=({lines:e,expandedId:n,onRowToggle:s,entry:a,readOnly:o,count:l,first:d,last:u,hasPrevious:p,hasNext:h,onPrevious:f,onNext:g,drawerActions:b=null,documentUrl:v,onOpenEntry:N})=>t.jsxs(Te,{children:[e.length===0?t.jsx("div",{className:"px-6 py-10 text-center text-[13px] text-gray-400",children:"No posted transactions in this period."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full table-fixed min-w-[64rem] text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-100 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:[t.jsx("th",{className:"w-28 px-4 py-2 text-left",children:"Date"}),t.jsx("th",{className:"w-20 px-4 py-2 text-left",children:"Entry"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Description"}),t.jsx("th",{className:"w-44 px-4 py-2 text-left",children:"Counterparty"}),t.jsx("th",{className:"w-40 px-4 py-2 text-left",children:"Source"}),t.jsx("th",{className:"w-32 px-4 py-2 text-right",children:"Debit"}),t.jsx("th",{className:"w-32 px-4 py-2 text-right",children:"Credit"}),t.jsx("th",{className:"w-32 px-4 py-2 text-right",children:"Balance"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-50",children:e.map((w,k)=>{var S,T;const _=n===w.entry_id;return t.jsxs(x.Fragment,{children:[t.jsxs("tr",{className:`curs
98or-pointer transition-colors hover:bg-gray-50 ${_?"bg-gray-50":""}`,onClick:()=>s(_?null:w.entry_id),children:[t.jsx("td",{className:pc,children:jn(w.entry_date)}),t.jsx("td",{className:`${pc} ${Qs}`,children:w.entry_number!=null?`#${w.entry_number}`:"—"}),t.jsx("td",{className:"truncate px-4 py-3 text-gray-700",title:w.description,children:w.description||"—"}),t.jsx("td",{className:`${pc} truncate`,title:((S=w.counterparty)==null?void 0:S.name)??"—",children:((T=w.counterparty)==null?void 0:T.name)??"—"}),t.jsx("td",{className:`${pc} truncate`,title:td(w.source),children:td(w.source)}),t.jsx("td",{className:kp,children:xn(w.debit)}),t.jsx("td",{className:kp,children:xn(w.credit)}),t.jsx("td",{className:`${kp} font-semibold`,children:xn(w.running_balance)})]}),_&&t.jsx("tr",{children:t.jsxs("td",{colSpan:8,className:"p-0",children:[(a==null?void 0:a.kind)==="loading"&&t.jsx("div",{className:"flex h-16 items-center justify-center bg-gray-50",children:t.jsx(jt,{})}),(a==null?void 0:a.kind)==="error"&&t.jsx("div",{className:"bg-gray-50 px-5 py-3 text-[13px] text-red-600",children:a.message}),(a==null?void 0:a.kind)==="ready"&&t.jsx(Tf,{row:a.row,readOnly:o,documentUrl:v,onOpenEntry:N,adjustOpen:!1,onToggleAdjust:()=>{},onPosted:()=>{}},a.row.id),b]})})]},`${w.entry_id}-${k}`)})})]})}),l>0&&t.jsxs("div",{className:"no-print flex items-center justify-between border-t border-gray-100 px-4 py-3 text-[13px] text-gray-500",children:[t.jsxs("span",{children:[d,"–",u," of ",l]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",disabled:!p,onClick:f,className:"rounded-lg border border-gray-200 px-3 py-1.5 font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-40",children:"Previous"}),t.jsx("button",{type:"button",disabled:!h,onClick:g,className:"rounded-lg border border-gray-200 px-3 py-1.5 font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-40",children:"Next"})]})]})]}),vv=100,yF=()=>{const{code:e=""}=Pr(),[n]=Ud(),[s,a]=Jn(),o=s.get("from_report")==="balance_sheet"?"Balance Sheet":"Profit & Loss",l=Math.max(1,Number(s.get("page")??"1")||1),d=W=>{const Y=new URLSearchParams(s);Y.set("period",W.period),W.period==="custom"&&W.date_from&&W.date_to?(Y.set("from",W.date_from),Y.set("to",W.date_to)):(Y.delete("from"),Y.delete("to")),Y.delete("page"),a(Y,{replace:!0})},u=W=>{const Y=new URLSearchParams(s);W<=1?Y.delete("page"):Y.set("page",String(W)),a(Y,{replace:!0})},{data:p,isLoading:h,error:f,status:g}=q7(e,n,l,vv),[b,v]=x.useState(null),[N,w]=x.useState(null),{entry:k}=Ch(N??b),_=W=>{v(W),w(null)};x.useEffect(()=>{v(null),w(null)},[e,l,Oa(n)]);const S=`/accounting/reports?${Oa(n)}`,T=p?`${p.account.code} · ${p.account.name}`:e,E=(p==null?void 0:p.lines.results)??[],A=(p==null?void 0:p.lines.count)??0,I=A===0?0:(l-1)*vv+1,R=A===0?0:I+E.length-1;return t.jsx("div",{className:"reports-print min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-none space-y-6 px-6 py-8",children:[t.jsxs("nav",{"aria-label":"Breadcrumb",className:"no-print text-[13px] text-gray-500",children:[t.jsx(be,{to:S,className:"font-medium text-[var(--color-primary)] hover:underline",children:"Reports"}),t.jsx("span",{className:"mx-1.5 text-gray-300",children:"›"}),t.jsx(be,{to:S,className:"hover:underline",children:o}),t.jsx("span",{className:"mx-1.5 text-gray-300",children:"›"}),t.jsx("span",{className:`text-gray-700 ${Qs}`,children:T})]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsx(ut,{title:T,subtitle:p?`${td(p.account.type)} · ${p.period.label}`:"Account ledger"}),t.jsx(zd,{period:n,setPeriod:d})]}),h&&t.jsx(Te,{padding:!0,children:t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(jt,{})})}),!h&&g===404&&t.jsxs(Te,{padding:!0,className:"space-y-3",children:[t.jsx("p",{className:"text-[14px] text-gray-700",children:"Account not found."}),t.jsx(be,{to:S,className:"text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:"← Back to Reports"})]}),!h&&f&&g!==404&&t.jsx("p",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:f}),!h&&p&&!f&&t.jsxs(t.Fragment,{children:[t.jsx(Gw,{data:p,exportSlot:t.jsx(Ir,{kind:"account",code:p.account.code,period:n})}),t.jsx(Jw,{lines:E,expandedId:b,onRowToggle:_,entry:k,onOpenEntry:W=>w(W.id),readOnly:!0,count:A,first:I,last:R,hasPrevious:!!p.lines.previous,hasNext:!!p.lines.next,onPrevious:()=>u(l-1),onNext:()=>u(l+1)}),t.jsx(be,{to:S,className:"no-print inline-block text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:"← Back to Reports"})]})]})})},Sp=e=>{const n=Number(e);if(Number.isNaN(n))return`$${e}`;
98const s=Math.abs(n).toLocaleString("en-CA",{minimumFractionDigits:2,maximumFractionDigits:2});return n<0?`-$${s}`:`$${s}`},bF=e=>jn(e,{year:"numeric",month:"long",day:"numeric"}),Cp="font-[var(--font-family-mono)] tabular-nums",jv=({children:e,tone:n="muted"})=>t.jsx("div",{className:`text-[13.5px] ${n==="error"?"text-red-600":"text-gray-400"}`,children:e}),wv=e=>{const[n,s,a]=e.split("-").map(Number),o=new Date(n,s-1,a),l=new Date,d=new Date(l.getFullYear(),l.getMonth(),l.getDate());return Math.round((o.getTime()-d.getTime())/864e5)},vF=e=>e>0?`${e} days away`:e===0?"Due today":`${-e} days overdue`,jF=e=>e<0?"danger":e<=14?"warning":"neutral",wF=({data:e})=>{const n=e.period;return t.jsxs("div",{className:"space-y-6",children:[t.jsxs(Te,{padding:!0,className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Net GST/HST owing"}),n&&t.jsx(on,{variant:"info",children:n.period_label})]}),t.jsx("div",{className:`text-[34px] font-semibold text-gray-900 ${Cp}`,children:Sp(e.net)}),t.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-1 text-[13.5px] text-gray-600",children:[t.jsxs("span",{children:["Collected on sales"," ",t.jsx("span",{className:`text-gray-900 ${Cp}`,children:Sp(e.collected)})]}),t.jsxs("span",{children:["Input tax credits"," ",t.jsxs("span",{className:`text-gray-900 ${Cp}`,children:["−",Sp(e.itc)]})]})]})]}),n&&n.deadline&&t.jsxs(Te,{padding:!0,className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Next filing due"}),t.jsx("div",{className:"mt-1 text-[16px] font-medium text-gray-900",children:bF(n.deadline)})]}),t.jsx(on,{variant:jF(wv(n.deadline)),children:vF(wv(n.deadline))})]})]})},NF=()=>{const{data:e,isLoading:n,error:s}=H7();return t.jsx("div",{className:"reports-print min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-6 py-8",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsx(ut,{title:"Taxes",subtitle:e&&!s&&e.registered?"What you've collected and what you can claim back.":void 0}),t.jsx(Ir,{kind:"taxes",period:{period:"ytd"}})]}),n&&t.jsx(Te,{padding:!0,children:t.jsx(jv,{children:"Loading…"})}),s&&t.jsx(Te,{padding:!0,children:t.jsx(jv,{tone:"error",children:s})}),e&&!s&&!e.registered&&t.jsx(Te,{padding:!0,children:t.jsx("p",{className:"text-[14.5px] text-gray-600",children:"This business isn't registered for GST/HST, so there's nothing owing to track here."})}),e&&!s&&e.registered&&t.jsx(wF,{data:e})]})})},_F=e=>{const n=Array.isArray(e)?e:(e==null?void 0:e.results)??[],s=[];for(const a of n){s.push({id:a.id,code:a.code,name:a.name,type:a.type,is_active:a.is_active,full_name:a.full_name});for(const o of a.children??[])s.push({id:o.id,code:o.code,name:o.name,type:o.type,is_active:o.is_active,full_name:o.full_name})}return s},kF=()=>{const[e,n]=x.useState([]),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(g=>g+1),[]);x.useEffect(()=>{let g=!1;return a(!0),l(null),te.get("/api/accounting/accounts/",{params:{page_size:200}}).then(b=>{var v;g||b==null||(b.status===200?n(_F(b.data)):(n([]),l(((v=b.data)==null?void 0:v.detail)??"Failed to load the chart of accounts.")))}).catch(b=>{var v,N;g||l(((N=(v=b==null?void 0:b.response)==null?void 0:v.data)==null?void 0:N.detail)??"Failed to load the chart of accounts.")}).finally(()=>{g||a(!1)}),()=>{g=!0}},[d]);const h=x.useMemo(()=>e.filter(g=>g.is_active).sort((g,b)=>g.code.localeCompare(b.code)),[e]),f=x.useMemo(()=>new Set(e.filter(g=>g.type==="revenue"||g.type==="expense").map(g=>g.id)),[e]);return{accounts:e,activeAccounts:h,revenueExpenseIds:f,isLoading:s,error:o,refetch:p}},SF=new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD"}),CF=e=>e==null||e===""?"":SF.format(Number(e)),EF=e=>jn(e),Nv="font-[var(--font-family-mono)] tabular-nums",Lf="grid grid-cols-[1fr_0.8fr_2.6fr_1fr_0.9fr_1.1fr] items-center gap-4",AF=e=>{const n=e.replace(/_/g," ").trim();return n.length===0?"—":n.charAt(0).toUpperCase()+n.slice(1)},Xw=({children:e})=>t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-5xl px-6 py-8",children:e})}),TF=()=>t.jsxs(be,{to:"/accountant/adjustments/new",className:"inline-flex items-center gap-1.5 rounded-lg bg-[var(--color-navy)] px-4 py-2 text-[13px] font-semibold text-white transition-opacity hover:opacity-90",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New adjustment"]}),LF="Posted entries are immutable. Corrections post as new adjusting entries — nothing is ever edited or deleted.",RF=()=>t.jsx(Te,{children:t.jsx("div",{className:"divide-y divide-gray-50",children:[0,1,2,3,4,5].map(e=>t.jsxs("div",{className:`${Lf} px-5 py-3.5`,children:[t.jsx("div",{className:"h-3.5 w-24 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-3.5 w-14 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-3.5 w-48 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-3.5 w-16 animate-pulse rounded bg-gray-100 justify-self-end"}),t.jsx("div",{className:"h-5 w-16 animate-pulse rounded-full bg-gray-100"}),t.jsx("div",{className:"h-3.5 w-12 animate-pulse rounded bg-gray-100"})]},e))})}
98),IF="rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition",PF=()=>{const{activeOrg:e}=zt(),[n,s]=x.useState(""),{items:a,count:o,page:l,setPage:d,pageSize:u,isLoading:p,error:h,refetch:f}=AP(n),{revenueExpenseIds:g}=kF(),b=(e==null?void 0:e.org_name)??"This client",v=o>u,N=o===0?0:(l-1)*u+1,w=Math.min(l*u,o),k=ne=>ne.lines.some(Z=>g.has(Z.account_id)),[_,S]=x.useState(null),[T,E]=x.useState(!1),[A,I]=x.useState(null),{entry:R}=Ch(A),W=ne=>{I(null),_===ne?(S(null),E(!1)):(S(ne),E(!1))},Y=ne=>{I(null),S(ne),E(!0)},K=ne=>{I(ne),E(!1)},X=ne=>{s(ne),d(1),S(null),I(null)},se=()=>{S(null),E(!1),I(null),f()};return t.jsxs(Xw,{children:[t.jsx(ut,{title:"Ledger",subtitle:`${b} · already posted & clean. Post adjustments where needed.`,right:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("select",{value:n,onChange:ne=>X(ne.target.value),className:IF,"aria-label":"Filter by status",children:_h.map(ne=>t.jsx("option",{value:ne.value,children:ne.label},ne.value||"posted"))}),t.jsx(TF,{})]})}),t.jsxs("div",{className:"mt-6",children:[p?t.jsx(RF,{}):h?t.jsxs(Te,{padding:!0,className:"max-w-md",children:[t.jsx("p",{className:"text-sm text-gray-700",children:h}),t.jsx("button",{type:"button",onClick:f,className:"mt-4 inline-flex items-center rounded-lg bg-gray-900 px-4 py-2 text-sm font-medium text-white hover:bg-gray-800",children:"Try again"})]}):o===0?t.jsx(Te,{padding:!0,className:"text-center",children:t.jsx("p",{className:"text-sm text-gray-500",children:n?"No entries match this filter.":"No posted entries yet."})}):t.jsxs(Te,{children:[t.jsxs("div",{className:`${Lf} border-b border-gray-100 px-5 py-3 text-[11px] font-semibold uppercase tracking-wider text-gray-500`,children:[t.jsx("span",{children:"Date"}),t.jsx("span",{children:"Entry"}),t.jsx("span",{children:"Description"}),t.jsx("span",{className:"justify-self-end",children:"Amount"}),t.jsx("span",{children:"Source"}),t.jsx("span",{className:"justify-self-end",children:"Action"})]}),t.jsx("div",{className:"divide-y divide-gray-50",children:a.map(ne=>{const Z=ne.status==="voided",ue=Z?"line-through":"";return t.jsxs(x.Fragment,{children:[t.jsxs("div",{onClick:()=>W(ne.id),className:`${Lf} cursor-pointer px-5 py-3.5 transition-colors hover:bg-gray-50 ${_===ne.id?"bg-gray-50":""} ${Z?"opacity-60":""}`,children:[t.jsx("span",{className:`whitespace-nowrap text-[13.5px] text-gray-700 ${ue}`,children:EF(ne.entry_date)}),t.jsx("span",{className:`whitespace-nowrap text-[12.5px] text-gray-500 ${Nv} ${ue}`,children:ne.entry_number_display??""}),t.jsx("span",{className:`truncate text-[13.5px] text-gray-900 ${ue}`,title:ne.description,children:ne.description}),t.jsx("span",{className:`justify-self-end whitespace-nowrap text-[13.5px] text-gray-900 ${Nv} ${ue}`,children:CF(kh(ne))}),t.jsx("span",{children:Z?t.jsx(on,{variant:"voided",children:"Voided"}):t.jsxs(t.Fragment,{children:[t.jsx(on,{variant:"neutral",children:AF(ne.source)}),Lr(ne)!=="posted"&&t.jsx(on,{variant:Lr(ne)==="reversed"?"info":"neutral",children:Ks(ne)})]})}),t.jsx("span",{className:"justify-self-end",children:!Z&&k(ne)&&Gc("accountant",ne,"adjust")?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),Y(ne.id)},className:"text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:"Adjust"}):t.jsx("span",{className:"text-[13px] text-gray-300",children:"—"})})]}),_===ne.id&&(A===null?t.jsx(Tf,{row:ne,adjustOpen:T,onToggleAdjust:()=>E(re=>!re),onPosted:se,onVoided:f,onOpenEntry:re=>K(re.id)},ne.id):(R==null?void 0:R.kind)==="ready"&&R.row.id===A?t.jsx(Tf,{row:R.row,adjustOpen:T,onToggleAdjust:()=>E(re=>!re),onPosted:se,onVoided:f,onOpenEntry:re=>K(re.id)},R.row.id):(R==null?void 0:R.kind)==="error"?t.jsx("div",{className:"border-b border-gray-100 bg-gray-50 px-5 py-3 text-[13px] text-red-600",children:R.message}):t.jsx("div",{className:"border-b border-gray-100 bg-gray-50 px-5 py-4 text-[13px] text-gray-400",children:"Loading entry…"}))]},ne.id)})}),v&&t.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-5 py-3",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[N,"–",w," of ",o]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>d(l-1),disabled:l<=1,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent",children:"Previous"}),t.jsx("button",{type:"button",onClick:()=>d(l+1),disabled:l*u>=o,className:"rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-40 disabled:hover:bg-transparent",children:"Next"})]})]})]}),t.jsx("p",{className:"mt-4 text-[12.5px] text-gray-400",children:LF})]})]})},FF=()=>{const{activeOrgId:e,needsSelection:n}=zt();return n?t.jsx(Xw,{children:t.jsx(ut,{title:"Ledger",subtitle:"Cho
98ose a client from the sidebar to view their ledger."})}):t.jsx(PF,{},e??"none")},Zw=({children:e})=>t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-[860px] px-6 py-8",children:e})}),DF=()=>{const e=Xe(),{activeOrg:n}=zt(),s=()=>e("/accountant/ledger");return t.jsxs(Zw,{children:[t.jsx(ut,{title:"New adjustment",subtitle:`${(n==null?void 0:n.org_name)??"This client"} · post a balanced correcting entry.`}),t.jsx("div",{className:"mt-6",children:t.jsx(Qw,{onPosted:s,onCancel:s})})]})},OF=()=>{const{activeOrgId:e,needsSelection:n}=zt();return n?t.jsx(Zw,{children:t.jsx(ut,{title:"New adjustment",subtitle:"Choose a client from the sidebar first."})}):t.jsx(DF,{},e??"none")};function Ah(e,n,s){const[a,o]=x.useState(null),[l,d]=x.useState(!0),[u,p]=x.useState(null),h=JSON.stringify(n??{}),f=x.useCallback(()=>{let g=!1;return d(!0),p(null),te.get(e,n?{params:n}:void 0).then(b=>{var v;g||b==null||(b.status===200?o(b.data):(o(null),p(((v=b.data)==null?void 0:v.detail)??"Failed to load report.")))}).catch(b=>{var v,N;g||p(((N=(v=b==null?void 0:b.response)==null?void 0:v.data)==null?void 0:N.detail)??"Failed to load report.")}).finally(()=>{g||d(!1)}),()=>{g=!0}},[e,h]);return x.useEffect(f,[f,...s]),{data:a,isLoading:l,error:u}}const $F=e=>Ah("/api/accounting/reports/pnl/",{period:e},[e]),MF=()=>Ah("/api/accounting/reports/balance-sheet/",void 0,[]),BF=()=>Ah("/api/accounting/reports/taxes/",void 0,[]),Ro=e=>{const n=Number(e);if(Number.isNaN(n))return`$${e}`;const s=Math.abs(n).toLocaleString("en-CA",{minimumFractionDigits:2,maximumFractionDigits:2});return n<0?`-$${s}`:`$${s}`},e2=e=>e===null?"—":jn(e,{year:"numeric",month:"long",day:"numeric"}),Io="font-[var(--font-family-mono)] tabular-nums",Sr=({children:e,tone:n="muted"})=>t.jsx("div",{className:`text-[13.5px] ${n==="error"?"text-red-600":"text-gray-400"}`,children:e}),UF=({rows:e})=>e.length===0?t.jsx("div",{className:"py-2 text-[13px] text-gray-400",children:"No activity in this period."}):t.jsx(t.Fragment,{children:e.map(n=>t.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[t.jsx("span",{className:"text-[14px] text-gray-700",children:n.name}),t.jsx("span",{className:`text-[14px] text-gray-900 ${Io}`,children:Ro(n.amount)})]},n.code??n.name))}),Ji=({title:e,section:n,totalLabel:s})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:e}),t.jsx("div",{className:"mt-2 divide-y divide-gray-100",children:t.jsx(UF,{rows:n.rows})}),t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2",children:[t.jsx("span",{className:"text-[13px] font-medium text-gray-600",children:s}),t.jsx("span",{className:`text-[14px] font-semibold text-gray-900 ${Io}`,children:Ro(n.total)})]})]}),zF=()=>{const[e,n]=x.useState("ytd"),{data:s,isLoading:a,error:o}=$F(e);return t.jsxs(Te,{padding:!0,className:"space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-[17px] font-semibold text-gray-900",children:"Profit & Loss"}),s&&t.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500",children:s.period.label})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(On,{active:e==="ytd",onClick:()=>n("ytd"),children:"Year to date"}),t.jsx(On,{active:e==="quarter",onClick:()=>n("quarter"),children:"This quarter"})]})]}),a&&t.jsx(Sr,{children:"Loading…"}),o&&t.jsx(Sr,{tone:"error",children:o}),s&&!o&&t.jsxs("div",{className:"space-y-5",children:[t.jsx(Ji,{title:"Revenue",section:s.revenue,totalLabel:"Total revenue"}),t.jsx(Ji,{title:"Expenses",section:s.expenses,totalLabel:"Total expenses"}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[var(--color-navy)] px-4 py-3 text-white",children:[t.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wider",children:"Net profit"}),t.jsx("span",{className:`text-[17px] font-semibold ${Io}`,children:Ro(s.net)})]})]})]})},WF=()=>{const{data:e,isLoading:n,error:s}=MF();return t.jsxs(Te,{padding:!0,className:"space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-[17px] font-semibold text-gray-900",children:"Balance Sheet"}),e&&t.jsxs("div",{className:"flex items-center gap-2",children:[!e.balances&&t.jsx(on,{variant:"warning",children:"Out of balance"}),t.jsxs("span",{className:"text-[13px] text-gray-500",children:["As of ",e2(e.as_of)]})]})]}),n&&t.jsx(Sr,{children:"Loading…"}),s&&t.jsx(Sr,{tone:"error",children:s}),e&&!s&&t.jsxs("div",{className:"space-y-5",children:[t.jsx(Ji,{title:"Assets",section:e.assets,totalLabel:"Total assets"}),t.jsx(Ji,{title:"Liabilities",section:e.liabilities,totalLabel:"Total liabilities"}),t.jsx(Ji,{title:"Equity",section:e.equity,totalLabel:"Total equity"})]})]})},_v=({label:e,value:n})=>t.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[t.jsx("span",{className:"text-[14px] text-gray-700",children:e}),t.jsx("span",{className:`text-[14px] text-gray-900 ${Io}`,children:Ro(n)})]}),HF=()=>{const{data:e,isLoading:n,error:s}=BF();return t.jsxs(Te,{padding:!0,className:"space-y-4",children:[t.jsx("h2",{className:"text-[17px] font-semibold text-gray-900",children:"GST/HST summary"}),n&&t.jsx(Sr,{children:"Loading…"}),s&&t.jsx(Sr,{tone:"error",children:s}),e&&!s&&!e.registered&&t.jsx(Sr,{children:"Not registered for GST/HST — nothing to file."}),e&&!s&&e.registered&&t.jsxs("div",{className:"space-y-4",children:[e.period&&t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[13px] text-gray-500",children:e.period.period_label}),e.period.deadline&&t.jsxs("span",{className:"text-[13px] text-gray-500",children:["Due ",e2(e.period.deadline)]})]}),t.jsxs("div",{className:"divide-y divide-gray-100",children:[t.jsx(_v,{label:"Collected",value:e.collected}),t.jsx(_v,{label:"Input tax credits",value:e.itc})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[var(--color-navy)] px-4 py-3 text-white",children:[t.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wider",children:"Net tax"}),t.jsx("span",{className:`text-[17px] font-semibold ${Io}`,children:Ro(e.net)})]})]})]})},qF=()=>{const{activeOrg:e}=zt();return t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8",children:[t.jsx(ut,{title:"Reports",subtitle:`${(e==null?void 0:e.org_name)??"This client"} · profit & loss, balance sheet, and GST/HST — straight from the ledger.`}),t.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2",children:[t.jsx(zF,{}),t.jsx(WF,{}),t.jsx(HF,{})]})]})})},VF=()=>{const{activeOrgId:e,needsSelection:n}=zt();return n?t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-5xl px-6 py-8",children:t.jsx(ut,{title:"Reports",subtitle:"Cho
98ose a client from the sidebar to view their reports."})})}):t.jsx(qF,{},e??"none")},YF=()=>{const[e,n]=x.useState(null),[s,a]=x.useState(!0),[o,l]=x.useState(null),[d,u]=x.useState(0),p=x.useCallback(()=>u(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return a(!0),l(null),te.get("/api/accounting/year-end-close/").then(f=>{var g;h||f==null||(f.status===200?n(f.data):(n(null),l(((g=f.data)==null?void 0:g.detail)??"Failed to load close status.")))}).catch(f=>{var g,b;h||l(((b=(g=f==null?void 0:f.response)==null?void 0:g.data)==null?void 0:b.detail)??"Failed to load close status.")}).finally(()=>{h||a(!1)}),()=>{h=!0}},[d]),{status:e,isLoading:s,error:o,refetch:p}},GF=e=>te.post("/api/accounting/year-end-close/",{fiscal_year_end:e}),kv=e=>jn(e,{year:"numeric",month:"long",day:"numeric"}),Rf=({children:e})=>t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-3xl px-6 py-8",children:e})}),KF=({detail:e})=>t.jsxs("li",{className:"flex items-start gap-2.5 text-[13.5px] text-gray-700",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:"mt-0.5 h-4 w-4 shrink-0 text-amber-500",children:t.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"})}),e]}),QF=()=>{const{activeOrg:e}=zt(),{showToast:n}=Od(),{status:s,isLoading:a,error:o,refetch:l}=YF(),[d,u]=x.useState(!1),[p,h]=x.useState(null),[f,g]=x.useState(null);if(a)return t.jsx(js,{});const b=t.jsx(ut,{title:"Period close",subtitle:`${(e==null?void 0:e.org_name)??"This client"} · close the oldest open fiscal year.`});if(o)return t.jsxs(Rf,{children:[b,t.jsx(Te,{padding:!0,className:"mt-6",children:t.jsx("p",{className:"text-sm text-red-600",children:o})})]});const v=(s==null?void 0:s.fiscal_year)??null,N=f??(s==null?void 0:s.blockers)??[],w=!!(s!=null&&s.closable)&&N.length===0,k=v?v.end.slice(0,4):"",_=async()=>{var S,T,E,A,I;if(v){u(!0),h(null),g(null);try{const R=await GF(v.end);(R==null?void 0:R.status)===201?(n({title:"Fiscal year closed",message:"The closing entry is posted and the year is locked.",variant:"success"}),l()):(R==null?void 0:R.status)===422?(g(((S=R.data)==null?void 0:S.blockers)??[]),h("This year can’t be closed yet — see the checklist.")):(R==null?void 0:R.status)===409?(h(((T=R.data)==null?void 0:T.detail)??"This year’s close state changed — refreshing."),l()):h(((E=R==null?void 0:R.data)==null?void 0:E.detail)??"The year could not be closed.")}catch(R){h(((I=(A=R==null?void 0:R.response)==null?void 0:A.data)==null?void 0:I.detail)??"The year could not be closed.")}finally{u(!1)}}};return t.jsxs(Rf,{children:[b,v?t.jsxs(Te,{padding:!0,className:"mt-6 space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Oldest open fiscal year"}),t.jsxs("div",{className:"mt-1 text-[18px] font-semibold text-gray-900",children:[kv(v.start)," – ",kv(v.end)]})]}),w?t.jsx(on,{variant:"success",children:"Ready to close"}):t.jsx(on,{variant:"warning",children:"Not ready"})]}),w?t.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl bg-emerald-50 px-4 py-3 text-[13.5px] text-emerald-700",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4 shrink-0",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),"All preconditions met — this year is ready to close."]}):t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"Before closing"}),t.jsx("ul",{className:"mt-2 space-y-2",children:N.map(S=>t.jsx(KF,{detail:S.detail},S.code))})]}),p&&t.jsx("p",{className:"text-sm text-red-600",children:p}),t.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 pt-5",children:[t.jsx("p",{className:"text-[12.5px] text-gray-400",children:"Closing posts a locking entry — it can’t be undone."}),t.jsx("button",{type:"button",onClick:_,disabled:!w||d,className:"rounded-lg bg-[var(--color-navy)] px-5 py-2 text-[13px] font-semibold text-white transition-opacity hover:opacity-90 disabled:opacity-40",children:d?"Closing…":`Close fiscal year ${k}`})]})]}):t.jsx(Te,{padding:!0,className:"mt-6",children:t.jsx("p",{className:"text-sm text-gray-500",children:"No fiscal year is open to close right now."})}),t.jsxs(Te,{padding:!0,className:"mt-4 bg-gray-50",children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-gray-500",children:"How closing works"}),t.jsx("p",{className:"mt-2 text-[13.5px] leading-relaxed text-gray-600",children:"Closing locks this fiscal year — new entries post to the next year, which opens automatically. Any fiscal year left open is closed automatically 90 days after it ends."})]})]})},JF=()=>{const{activeOrgId:e,needsSelection:n}=zt();return n?t.jsx(Rf,{children:t.jsx(ut,{title:"Period close",subtitle:"Cho
98ose a client from the sidebar first."})}):t.jsx(QF,{},e??"none")},Ep=()=>{localStorage.removeItem(Ea),localStorage.removeItem(Wc),localStorage.removeItem(Hc)},Ap=({children:e})=>t.jsx("div",{className:"min-h-screen bg-[#0f172a] text-white flex items-center justify-center px-6",children:e}),XF=()=>{const e=Xe(),{exchange:n}=uw(),{completeReconnect:s}=mw(),[a]=x.useState(()=>localStorage.getItem(Ea)||null),[o]=x.useState(()=>localStorage.getItem(Wc)),[l]=x.useState(()=>localStorage.getItem(Hc)),[d,u]=x.useState(null),p=x.useCallback(async(b,v)=>{if(o==="reconnect"){if(!l){Ep(),u("This bank connection session has expired.");return}const w=await s(l);Ep(),w.ok?e("/accounting/bank-connections"):u(w.error);return}const N=await n(dw(b,v));localStorage.removeItem(Ea),N.ok?e("/accounting/bank-connections"):u(N.error)},[o,l,s,n,e]),h=x.useCallback(()=>{Ep(),e("/accounting/bank-connections")},[e]),{open:f,ready:g}=kw({token:a,receivedRedirectUri:window.location.href,onSuccess:p,onExit:h});return x.useEffect(()=>{a&&g&&f()},[a,g,f]),a?d?t.jsx(Ap,{children:t.jsxs("div",{className:"rounded-2xl bg-[#0A1628] border border-red-500/20 p-8 max-w-sm text-center",children:[t.jsx("p",{className:"text-sm text-red-400",children:d}),t.jsx("button",{onClick:()=>e("/accounting/bank-connections"),className:"mt-5 rounded-xl bg-[#0066FF] hover:bg-[#0052cc] px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:"Back to Bank Transactions"})]})}):t.jsx(Ap,{children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx("div",{className:"w-8 h-8 border-2 border-[#0066FF] border-t-transparent rounded-full animate-spin"}),t.jsx("p",{className:"text-sm text-white/60",children:"Resuming your bank connection…"})]})}):t.jsx(Ap,{children:t.jsxs("div",{className:"rounded-2xl bg-[#0A1628] border border-white/10 p-8 max-w-sm text-center",children:[t.jsx("p",{className:"text-sm font-medium text-white/80",children:"This bank connection session has expired."}),t.jsx("button",{onClick:()=>e("/accounting/bank-connections"),className:"mt-5 rounded-xl bg-[#0066FF] hover:bg-[#0052cc] px-5 py-2.5 text-sm font-semibold text-white transition-colors",children:"Start again"})]})})},ZF=({message:e})=>e?t.jsxs("div",{className:"fixed top-5 right-5 z-50 flex items-center gap-3 rounded-xl bg-emerald-500 px-5 py-3.5 text-sm font-medium text-white shadow-lg",children:[t.jsx("svg",{className:"w-4 h-4 shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),e]}):null,eD=()=>{const{role:e,isLoading:n}=ln(),s=e==="owner",{profile:a,isLoading:o,error:l,refetch:d}=yh(),[u,p]=x.useState(null),h=g=>{p(g),setTimeout(()=>p(null),4e3)},f=g=>{let v=a==null?"Tax profile created.":"Tax profile updated.";g.chart_reseeded&&(v+=" — chart of accounts was reseeded for the new country."),h(v),d()};return n||o?t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"max-w-2xl mx-auto px-6 py-8",children:[t.jsx("div",{className:"h-7 w-48 bg-gray-200 rounded animate-pulse mb-2"}),t.jsx("div",{className:"h-4 w-72 bg-gray-200 rounded animate-pulse mb-8"}),t.jsx("div",{className:"rounded-2xl bg-white border border-gray-100 shadow-sm p-6 space-y-5",children:Array.from({length:5}).map((g,b)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-3 w-28 bg-gray-100 rounded animate-pulse"}),t.jsx("div",{className:"h-10 w-full bg-gray-100 rounded animate-pulse"})]},b))})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:[t.jsx(ZF,{message:u}),t.jsxs("div",{className:"max-w-2xl mx-auto px-6 py-8",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Tax Profile"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Your tax registration and fiscal settings. These drive how the accounting agent treats tax on every document."})]}),l&&t.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 px-5 py-4 flex items-center gap-3 mb-6",children:[t.jsx("svg",{className:"w-5 h-5 text-red-500 shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:t.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"})}),t.jsx("p",{className:"flex-1 text-sm text-red-700",children:l}),t.jsx("button",{onClick:d,className:"text-xs text-red-700 hover:text-red-800 underline",children:"Retry"})]}),!s&&t.jsx("div",{className:"rounded-xl bg-gray-50 border border-gray-200 px-4 py-3 text-sm text-gray-600 mb-6",children:"Only the account owner can edit the tax profile. You can view the current settings below."}),t.jsx(bh,{profile:a,isOwner:s,onSaved:f})]})]})};function tD(){const e=x.useCallback(async s=>{var o,l;const a=await te.post("/api/accounting/stripe/create-checkout-session/",{price_id:s});return a==null?{kind:"error",message:"Request was cancelled — please try again."}:a.status===200&&((o=a.data)!=null&&o.url)?(window.location.href=a.data.url,{kind:"redirect"}):a.status===409?{kind:"already_active"}:a.status===503?{kind:"not_configured"}:{kind:"error",message:((l=a.data)==null?void 0:l.error)??"Could not start checkout. Please try again."}},[]),n=x.useCallback(async()=>{var a,o;const s=await te.post("/api/accounting/stripe/create-portal-session/");return s==null?{kind:"error",message:"Request was cancelled — please try again."}:s.status===200&&((a=s.data)!=null&&a.url)?(window.location.href=s.data.url,{kind:"redirect"}):s.status===400?{kind:"never_subscribed"}:{kind:"error",message:((o=s.data)==null?void 0:o.error)??"Could not open the billing portal. Please try again."}},[]);return{createCheckout:e,openPortal:n}}const nD=[{key:"starter",name:"Starter",price:"$99 CAD / month",docs:"Up to 150 documents per month",note:"For owner-operated businesses with steady, modest volume.",tag:null,highlight:!1,priceId:"price_1U2cXgDJi9AqAMUzTSl10ck6"},{key:"growth",name:"Growth",price:"$199 CAD / month",docs:"Up to 250 documents per month",note:"For growing businesses with suppliers, clients, and regular invoicing.",tag:"Most chosen",highlight:!0,priceId:"price_1U2caMDJi9AqAMUz0Y5CYMsG"},{key:"pro",name:"Pro",price:"$399 CAD / month",docs:"Up to 500 documents per month",note:"For higher-volume businesses that want everything maintained.",tag:null,highlight:!1,priceId:"price_1U2cbWDJi9AqAMUzjM2hKeJh"}],sD=[["AI document processing","Included","Included"],["Automatic categorization","Expense categories","Full accounting treatment"],["GST/HST tracking","Input tax credits on receipts","Tax collected, credits, and filing periods"],["Full double-entry books","Not included","Included"],["Human review of uncertain entries","Not included","Trained reviewers on our staff"],["Bank and credit-card connections","Not included","Included, via Plaid"],["Reconciliation","Not included","Handled for you"],["Financial statements","Expense and tax reports","Profit & Loss and Balance Sheet"],["Receivables and payables","Not included","Client and supplier balances with aging"],["Financial visibility dashboard","Expense summaries","Cash, profit, taxes, and cash flow"],["Accountant access","Share exported files","Their own workspace, by invitation"],["Tax-time reporting","Annual Excel workbook","Full report package, plus workspace access"]],rD=({plan:e,busy:n,onSubscribe:s})=>{const a=!e.priceId||n,o=e.highlight?"bg-gray-900 text-white border border-gray-900":"bg-white text-gray-900 border border-gray-200",l=e.highlight?"text-gray-400":"text-gray-500",d=e.highlight?"bg-[var(--color-primary)] text-white hover:bg-[var(--color-primary-hover)]":"bg-white text-gray-900 border border-gray-300 hover:bg-gray-50";return t.jsxs("div",{className:`flex flex-col rounded-2xl p-6 shadow-sm ${o}`,children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[t.jsx("h3",{className:"text-lg font-semibold",children:e.name}),e.tag&&t.jsx("span",{className:"rounded-full bg-[var(--color-primary)]/20 px-3 py-1 text-xs font-semibold text-blue-300",children:e.tag})]}),t.jsx("div",{className:"mb-1 text-2xl font-bold",children:e.price}),t.jsx("div",{className:`mb-4 text-sm ${l}`,children:e.docs}),t.jsx("p",{className:`mb-6 flex-1 text-sm ${l}`,children:e.note}),t.jsx("button",{type:"button",disabled:a,onClick:()=>s(e),className:`inline-flex h-11 items-center justify-center rounded-lg px-5 text-sm font-semibold transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${d}`,children:n?"Starting…":"Start Free Trial"}),t.jsx("p",{className:`mt-2 text-center text-xs ${l}`,children:"15-day free trial · cancel anytime"})]})},aD=()=>{const{createCheckout:e,openPortal:n}=tD(),[s,a]=x.useState(null),[o,l]=x.useState(null),[d,u]=x.useState(!1),[p,h]=x.useState(!1),[f,g]=x.use
98State(!1),[b,v]=x.useState(null),N=async _=>{if(_.priceId){l(null),a(_.key);try{const S=await e(_.priceId);S.kind==="already_active"?u(!0):S.kind==="not_configured"?l({kind:"info",text:"Billing is not configured yet — please contact support."}):S.kind==="error"&&l({kind:"error",text:S.message})}finally{a(null)}}},w=async()=>{v(null),g(!0);try{const _=await n();_.kind==="never_subscribed"?h(!0):_.kind==="error"&&v(_.message)}finally{g(!1)}},k=()=>p?null:t.jsxs("div",{className:"mt-8 rounded-2xl border border-gray-200 bg-white p-6",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Manage subscription"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Update your payment method, view invoices, or cancel from the billing portal."}),b&&t.jsx("p",{className:"mt-3 text-sm text-red-600",children:b}),t.jsx("button",{type:"button",disabled:f,onClick:w,className:"mt-4 inline-flex h-11 items-center justify-center rounded-lg border border-gray-300 bg-white px-5 text-sm font-semibold text-gray-900 transition-colors hover:bg-gray-50 disabled:opacity-50",children:f?"Opening…":"Open billing portal"})]});return t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Bookkeeping Service"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Full double-entry books, human review, and tax-ready reports — kept current for you."})]}),d?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-6",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"You already have an active subscription"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Manage your plan, payment method, or cancellation from the billing portal below."})]}),t.jsx("div",{className:"mt-2",children:k()})]}):t.jsxs(t.Fragment,{children:[o&&t.jsx("div",{className:`mb-6 rounded-xl border px-4 py-3 text-sm ${o.kind==="error"?"border-red-200 bg-red-50 text-red-700":"border-gray-200 bg-white text-gray-700"}`,children:o.text}),t.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-3",children:nD.map(_=>t.jsx(rD,{plan:_,busy:s===_.key,onSubscribe:N},_.key))}),k(),t.jsx("div",{className:"mt-12 overflow-x-auto rounded-2xl border border-gray-200 bg-white",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500",children:[t.jsx("th",{className:"px-5 py-3 font-medium",children:"What you get"}),t.jsx("th",{className:"px-5 py-3 font-medium",children:"Receipt Automation"}),t.jsx("th",{className:"px-5 py-3 font-medium text-gray-900",children:"Bookkeeping Service"})]})}),t.jsx("tbody",{children:sD.map(([_,S,T])=>t.jsxs("tr",{className:"border-b border-gray-100 last:border-0",children:[t.jsx("td",{className:"px-5 py-3 text-gray-700",children:_}),t.jsx("td",{className:"px-5 py-3 text-gray-500",children:S}),t.jsx("td",{className:"px-5 py-3 font-medium text-gray-900",children:T})]},_))})]})}),t.jsxs("p",{className:"mt-6 text-center text-xs text-gray-400",children:["Questions? ",t.jsx(be,{to:"/support",className:"font-medium text-[var(--color-primary)] hover:underline",children:"Contact support"})]})]})]})})},iD=2e3,oD=30,lD=()=>{const e=Xe(),n=Ba(),s=ht(f=>f.auth.user),a=x.useRef(s);a.current=s;const[o,l]=x.useState("polling"),d=x.useRef(0),u=x.useRef(!1),p=x.useCallback(async()=>{const f=await te.get("/api/user/me");if(f==null||f.status!==200)return!1;const g=f.data;if(J1(g)){const b=a.current??{},v={...b,...g,user:{...b.user??{},...g.user??{}}};return n(vo(v)),!0}return!1},[n]);x.useEffect(()=>{const f=setInterval(async()=>{if(u.current)return;if(d.current+=1,await p()){u.current=!0,clearInterval(f),e("/onboarding");return}d.current>
98=oD&&(u.current=!0,clearInterval(f),l("timeout"))},iD);return()=>clearInterval(f)},[p,e]);const h=async()=>{await p()&&e("/onboarding")};return t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsx("div",{className:"mx-auto max-w-2xl px-6 py-8",children:o==="polling"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Activating your subscription…"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Payment received. We’re turning on your Bookkeeping Service — this takes a few seconds."})]}),t.jsx("div",{className:"space-y-5 rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:Array.from({length:3}).map((f,g)=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-gray-100"}),t.jsx("div",{className:"h-10 w-full animate-pulse rounded bg-gray-100"})]},g))})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Your subscription is being activated"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"This can take a moment. You can check again, or come back shortly — your access will be ready soon."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("button",{type:"button",onClick:h,className:"inline-flex h-11 items-center justify-center rounded-lg bg-[var(--color-primary)] px-5 text-sm font-semibold text-white transition-colors hover:bg-[var(--color-primary-hover)]",children:"Check again"}),t.jsx("button",{type:"button",onClick:()=>e("/accounting/subscription"),className:"inline-flex h-11 items-center justify-center rounded-lg border border-gray-300 bg-white px-5 text-sm font-semibold text-gray-900 transition-colors hover:bg-gray-50",children:"Back to plans"})]})]})})})},Tp="3500",wa=e=>{const n=e.trim();if(!n)return null;if(!/^\d{1,13}(\.\d{1,2})?$/.test(n))return Number.NaN;const[s,a=""]=n.split(".");return parseInt(s,10)*100+parseInt((a+"00").slice(0,2),10)},cD=e=>{const n=Math.abs(e);return`${e<0?"-":""}${Math.floor(n/100)}.${String(n%100).padStart(2,"0")}`},dD=e=>{const n=new Date,s=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`;return e>s},Lp="w-full rounded-lg border border-gray-300 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-[#0066FF] focus:border-transparent transition disabled:opacity-60 disabled:cursor-not-allowed",fc="rounded-2xl bg-white border border-gray-100 shadow-sm p-6",hc="flex items-center justify-center gap-2 rounded-xl bg-[#0066FF] hover:bg-[#0052cc] disabled:opacity-60 disabled:cursor-not-allowed px-5 py-2.5 text-sm font-semibold text-white transition-colors",uD=({current:e,taxDone:n,obDone:s,onGo:a})=>{const o=[{n:1,label:"Tax profile",done:n},{n:2,label:"Opening balance",done:s},{n:3,label:"Connect a bank",done:!1}];return t.jsx("div",{className:"flex items-center gap-3 mb-8",children:o.map((l,d)=>{const u=l.n<=e||l.done,p=l.done?"bg-emerald-500 text-white":l.n===e?"bg-[#0066FF] text-white":"bg-gray-200 text-gray-500";return t.jsxs(x.Fragment,{children:[d>0&&t.jsx("div",{className:"flex-1 h-px bg-gray-200"}),t.jsxs("button",{type:"button",onClick:()=>u&&a(l.n),disabled:!u,className:`flex items-center gap-2 ${u?"cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-semibold ${p}`,children:l.done?t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:3,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}):l.n}),t.jsx("span",{className:`text-sm font-medium ${l.n===e?"text-gray-900":"text-gray-500"}`,children:l.label})]})]},l.n)})})},mD=()=>{var mt;const e=Xe(),n=ln(),s=n.role==="owner",{profile:a,isLoading:o,refetch:l}=yh(),{activeOrgId:d}=zt(),{accounts:u,loading:p,error:h}
98=Mr("owner",d),[f,g]=x.useState(null),[b,v]=x.useState(!1),[N,w]=x.useState(!1),[k,_]=x.useState(null),[S,T]=x.useState(""),[E,A]=x.useState([{key:0,account_code:"",debit:"",credit:""}]),[I,R]=x.useState(1),[W,Y]=x.useState(!1),[K,X]=x.useState(!1),[se,ne]=x.useState(null),[Z,ue]=x.useState(null),[re,H]=x.useState({}),[M,Q]=x.useState(null);x.useEffect(()=>{!n.isLoading&&f===null&&g(n.hasTaxProfile?2:1)},[n.isLoading,n.hasTaxProfile,f]);const $=x.useMemo(()=>u.filter(he=>he.is_active&&he.code!==Tp),[u]),L=((mt=u.find(he=>he.code===Tp))==null?void 0:mt.name)??"Opening Balance Equity",F=x.useMemo(()=>{let he=0;for(const Se of E){const ae=wa(Se.debit),J=wa(Se.credit);typeof ae=="number"&&!Number.isNaN(ae)&&(he+=ae),typeof J=="number"&&!Number.isNaN(J)&&(he-=J)}return he},[E]),V=()=>{A(he=>[...he,{key:I,account_code:"",debit:"",credit:""}]),R(he=>he+1)},q=he=>A(Se=>Se.filter(ae=>ae.key!==he)),ee=(he,Se)=>A(ae=>ae.map(J=>J.key===he?{...J,...Se}:J)),je=he=>{he.chart_reseeded&&w(!0),n.refetch(),l(),v(!1),g(2)},ke=()=>{let he=!0;if(ue(null),H({}),ne(null),S?dD(S)&&(ue("books_start_date cannot be in the future."),he=!1):(ue("books_start_date is required."),he=!1),k==="opening_balances"){E.length===0&&(ne("Add at least one line."),he=!1);const Se={};E.forEach(ae=>{const J=wa(ae.debit),pe=wa(ae.credit);if(!ae.account_code)Se[ae.key]="Select an account.";else if(Number.isNaN(J)||Number.isNaN(pe))Se[ae.key]="Amounts must be numbers with up to 2 decimals, e.g. 1234.56.";else{const Re=J!==null&&J>0,We=pe!==null&&pe>0;(J!==null&&J===0||pe!==null&&pe===0||Re===We)&&(Se[ae.key]="Exactly one of debit/credit must be a positive amount.")}}),Object.keys(Se).length&&(H(Se),he=!1)}return he},me=he=>{const Se=he;if(typeof(Se==null?void 0:Se.detail)=="string"){ne(Se.detail);return}if(Se&&typeof Se=="object"){const ae=[],J=Se.books_start_date;J&&ue(Array.isArray(J)?String(J[0]):String(J)),Se.mode&&ae.push(Array.isArray(Se.mode)?String(Se.mode[0]):String(Se.mode)),Se.lines&&ae.push(JSON.stringify(Se.lines)),!J&&!Se.mode&&!Se.lines&&ae.push(String(Se.message??Se.error??Se.code??JSON.stringify(Se))),ae.length&&ne(ae.join(" "));return}ne("Request failed — please try again.")},Ne=async he=>{var Se,ae,J;if(he.preventDefault(),!(!k||!W||K)&&ke()){X(!0);try{const pe={mode:k,books_start_date:S};k==="opening_balances"&&(pe.lines=E.map(We=>{const xt=wa(We.debit),Ct=wa(We.credit);return{account_code:We.account_code,debit:typeof xt=="number"&&!Number.isNaN(xt)&&xt>0?We.debit.trim():null,credit:typeof Ct=="number"&&!Number.isNaN(Ct)&&Ct>0?We.credit.trim():null}}));const Re=await te.post("/api/accounting/opening-balance/",pe);if(Re==null)return;if(Re.status===201){Q(Re.data),n.refetch(),g(3);return}if(Re.status===409){ne(typeof((Se=Re.data)==null?void 0:Se.detail)=="string"?String(Re.data.detail):"Opening-balance choice already recorded."),n.refetch();return}me(Re.data)}catch(pe){const Re=(J=(ae=pe==null?void 0:pe.response)==null?void 0:ae.data)==null?void 0:J.detail;ne(Re??"Request failed — please check your connection and try again.")}finally{X(!1)}}};if(n.isLoading||o||f===null)return t.jsx(js,{});const Oe=!!n.openingBalanceChoice;return t.jsx("div",{className:"min-h-screen bg-gray-50 text-gray-900",children:t.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Set up your books"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Three quick steps so the accounting agent can treat every document correctly."})]}),!s&&t.jsx("div",{className:"rounded-xl bg-gray-50 border border-gray-200 px-4 py-3 text-sm text-gray-600 mb-6",children:"Only the account owner can edit these settings. You can view the current setup below."}),t.jsx(uD,{current:f,taxDone:!!n.hasTaxProfile,obDone:Oe,onGo:he=>g(he)}),f===1&&t.jsx("section",{children:n.hasTaxProfile&&!b?t.jsxs("div",{className:fc,children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Tax profile complete"}),a&&t.jsxs("dl",{className:"mt-3 space-y-1.5 text-sm text-gray-600",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"inline text-gray-400",children:"Country: "}),t.jsx("dd",{className:"inline",children:a.country==="CA"?"Canada":"United States"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"inline text-gray-400",children:"GST/HST registered: "}),t.jsx("dd",{className:"inline",children:a.gst_hst_registered?`Yes${a.gst_hst_number?` (${a.gst_hst_number})`:""}`:"No"})]}),a.province&&t.jsxs("div",{children:[t.jsx("dt",{className:"inline text-gray-400",children:"Province/State: "}),t.jsx("dd",{className:"inline",children:a.province})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"inline text-gray-400",children:"Home currency: "}),t.jsx("dd",{className:"inline",children:a.home_currency})]})]})]}),t.jsx("button",{type:"button",onClick:()=>v(!0),className:"shrink-0 rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors",children:"Edit"})]}),t.jsx("div",{className:"mt-5",children:t.jsx("button",{type:"button",onClick:()=>g(2),className:hc,children:"Continue"})})]}):t.jsx(bh,{profile:a,isOwner:s,onSaved:je})}),f===2&&t.jsxs("section",{className:"space-y-4",children:[N&&t.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800",children:"Your chart of accounts was reseeded for the new country."}),se&&t.jsx("div",{className:"rounded-xl bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700",children:se}),Oe?t.jsxs("div",{className:fc,children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Opening balance recorded"}),t.jsxs("dl",{className:"mt-3 space-y-1.5 text-sm text-gray-600",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"inline text-gray-400",children:"Choice: "}),t.jsx("dd",{className:"inline",children:n.openingBalanceChoice==="starting_fresh"?"Starting fresh":"Opening balances entered"})]}),n.booksStartDate&&t.jsxs("div",{children:[t.jsx("dt",{className:"inline text-gray-400",children:"Books 
98start date: "}),t.jsx("dd",{className:"inline",children:n.booksStartDate})]})]}),t.jsx("p",{className:"mt-3 text-xs text-gray-400",children:"This choice is recorded once and cannot be changed."}),t.jsx("div",{className:"mt-5",children:t.jsx("button",{type:"button",onClick:()=>g(3),className:hc,children:"Continue"})})]}):t.jsxs("form",{onSubmit:Ne,className:`${fc} space-y-5`,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Opening balance"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Tell us where your books begin. This is recorded once."})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[{value:"starting_fresh",title:"Starting fresh",body:"New business or no prior books — begin at zero from your start date."},{value:"opening_balances",title:"Enter opening balances",body:"Carry over account balances from your previous bookkeeping."}].map(he=>t.jsxs("button",{type:"button",disabled:!s,onClick:()=>_(he.value),className:`text-left rounded-xl border p-4 transition-colors disabled:opacity-60 disabled:cursor-not-allowed ${k===he.value?"border-[#0066FF] ring-1 ring-[#0066FF] bg-blue-50/40":"border-gray-200 bg-white hover:border-gray-300"}`,children:[t.jsx("p",{className:"text-sm font-semibold text-gray-900",children:he.title}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:he.body})]},he.value))}),k&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1.5",children:"Books start date"}),t.jsx("input",{type:"date",value:S,disabled:!s,onChange:he=>T(he.target.value),className:Lp}),Z&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:Z}),t.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:k==="starting_fresh"?"Nothing can ever be posted before this date.":"Your opening-balance entry is posted on this date; everything else must come after it."})]}),k==="opening_balances"&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500",children:"Opening balances by account"}),E.map(he=>t.jsxs("div",{children:[t.jsxs("div",{className:"flex gap-2 items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx($r,{id:`opening-balance-account-${he.key}`,ariaLabel:"Account",size:"lg",required:!0,valueKey:"code",value:he.account_code,onChange:Se=>ee(he.key,{account_code:Se}),accounts:$,loading:p,error:h,disabled:!s,placeholder:"— Select account —"})}),t.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Debit",value:he.debit,disabled:!s,onChange:Se=>ee(he.key,{debit:Se.target.value}),className:`${Lp} w-28`}),t.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Credit",value:he.credit,disabled:!s,onChange:Se=>ee(he.key,{credit:Se.target.value}),className:`${Lp} w-28`}),t.jsx("button",{type:"button",disabled:!s||E.length===1,onClick:()=>q(he.key),className:"shrink-0 rounded-lg border border-gray-200 px-3 py-2.5 text-sm text-gray-500 hover:text-red-600 hover:border-red-200 transition-colors disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Remove line",children:"✕"})]}),re[he.key]&&t.jsx("p",{className:"mt-1 text-xs text-red-600",children:re[he.key]})]},he.key)),t.jsx("button",{type:"button",disabled:!s,onClick:V,className:"rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors disabled:opacity-60",children:"+ Add line"}),t.jsx("div",{className:"rounded-xl bg-gray-50 border border-gray-200 px-4 py-3 text-sm",children:F===0?t.jsx("p",{className:"text-gray-600",children:"Entry is balanced — no balancing line needed."}):t.jsxs("p",{className:"text-gray-600",children:[t.jsxs("span",{className:"font-medium text-gray-900",children:[Tp," — ",L]})," ","· ",F>0?"credit":"debit"," ",cD(Math.abs(F)),t.jsx("span",{className:"ml-2 inline-flex items-center rounded-full bg-gray-200 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-600",children:"added automatically"})]})})]}),s&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:W,onChange:he=>
98Y(he.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-[#0066FF] focus:ring-[#0066FF]"}),t.jsx("span",{className:"text-sm text-gray-700",children:"I understand this choice is recorded once and cannot be changed"})]}),t.jsx("div",{className:"pt-1",children:t.jsxs("button",{type:"submit",disabled:!W||K,className:hc,children:[K&&t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),K?"Recording…":"Record opening balance"]})})]})]})]})]}),f===3&&t.jsxs("section",{className:"space-y-4",children:[M&&t.jsxs("div",{className:"rounded-xl bg-emerald-50 border border-emerald-200 px-5 py-4",children:[t.jsx("p",{className:"text-sm font-semibold text-emerald-800",children:"Opening balance recorded"}),t.jsxs("dl",{className:"mt-2 space-y-1 text-sm text-emerald-700",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"inline",children:"Choice: "}),t.jsx("dd",{className:"inline",children:M.choice==="starting_fresh"?"Starting fresh":"Opening balances entered"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"inline",children:"Books start date: "}),t.jsx("dd",{className:"inline",children:M.books_start_date})]})]}),t.jsxs("p",{className:"mt-2 text-xs text-emerald-700",children:["Nothing can be posted on or before ",M.locked_through_date,"."]})]}),t.jsxs("div",{className:fc,children:[t.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"Connect a bank (optional)"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Connect a chequing, savings, or credit card account and transactions flow into your books automatically. You can do this any time."}),t.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[t.jsx(be,{to:"/accounting/bank-connections",className:hc,children:"Go to Bank Transactions"}),t.jsx("button",{type:"button",onClick:()=>e("/dashboard"),className:"rounded-xl border border-gray-200 px-5 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors",children:"Finish"})]})]})]})]})})},Sv="onboarding_redirect_done",pD=({children:e})=>{const n=Xe(),{pathname:s}=vn(),{hasTaxProfile:a,openingBalanceChoice:o,isLoading:l,refetch:d}=ln(),u=x.useRef(!0);x.useEffect(()=>{if(u.current){u.current=!1;return}d()},[s,d]),x.useEffect(()=>{l||a===!1&&s!=="/onboarding"&&(sessionStorage.getItem(Sv)||(sessionStorage.setItem(Sv,"1"),n("/onboarding")))},[l,a,s,n]);const p=!l&&s!=="/onboarding"&&(a===!1||a===!0&&o==null);return t.jsxs(t.Fragment,{children:[p&&t.jsxs("div",{className:"flex items-center gap-3 bg-amber-50 border-b border-amber-200 px-6 py-2.5 text-sm text-amber-800",children:[t.jsx("span",{className:"flex-1",children:"Finish setting up your books — the accounting agent can't post documents until setup is complete."}),t.jsx(be,{to:"/onboarding",className:"shrink-0 font-semibold text-amber-900 underline hover:text-amber-700",children:"Finish setup"})]}),e]})},fD=({children:e})=>{var a,o,l;const n=ht(d=>d.auth);return((o=(a=n.user)==null?void 0:a.user)==null?void 0:o.has_tier2)??((l=n.user)==null?void 0:l.has_tier2)??!1?t.jsx(pD,{children:e}):t.jsx(t.Fragment,{children:e})},t2=({children:e})=>t.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[t.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:t.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 h-14 flex items-center justify-between",children:[t.jsx(Fe,{to:"/",className:"flex items-center shrink-0",children:t.jsx("img",{src:dt,alt:"AI Bookkeeping",className:"h-7 w-auto"})}),t.jsxs("nav",{className:"flex items-center gap-1 sm:gap-3",children:[t.jsx("a",{href:"/blog",className:"text-sm px-3 py-1.5 rounded-lg transition-colors text-gray-500 hover:text-gray-900",children:"Blog"}),t.jsx(Fe,{to:"/faq",className:({isActive:n})=>`text-sm px-3 py-1.5 rounded-lg transition-colors ${n?"text-[#0066FF] font-medium":"text-gray-500 hover:text-gray-900"}`,children:"FAQ"}),t.jsx(Fe,{to:"/login",className:"ml-1 text-sm font-medium bg-[#0066FF] text-white px-4 py-1.5 rounded-lg hover:bg-[#0052cc] transition-colors",children:"Sign in"})]})]})}),t.jsx("main",{className:"flex-1",children:e}),t.jsx(Dd,{})]}),n2=[{title:"Getting Started",items:[{question:"What is AI Bookkeeping?",answer:"AI Bookkeeping is an automated bookkeeping service for small business owners in Canada and the United States. You upload receipts and invoices — our AI extracts and categorizes every transaction, generates your annual Excel workbook, and produces GST/HST ITC and expense reports. Connected bank feeds are part of the Bookkeeping Service. No accounting experience required."},{question:"How do I upload my receipts?",answer:"You can upload receipts directly in the Documents section of the app (drag-and-drop or file picker), or send them to @Accuratebooks_bot on Telegram. Both methods support batch uploads so you can send multiple files at once."},{question:"What file formats are supported?",answer:"We accept JPG, PNG, PDF, and HEIC files. Phone photos, scanned PDFs, and digital invoices all work. For best results, make sure the document is legible and well-lit."},{question:"How quickly are receipts processed?",answer:"Most receipts are extracted within a few seconds. The AI reads vendor name, date, total amount, tax amount, and assigns a business expense category automatically."},{question:"Do I need an accountant to use this?",answer:"No. AI Bookkeeping handles the day-to-day data entry and categorization automatically. Your accountant (if you have one) can review the clean Excel workbook we produce — it saves them hours of data entry at year-end."}]},{title:"Pricing",items:[{question:"What plans are available?",answer:"We offer three active plans: Starter (ideal for sole proprietors with light receipt volume), Growth (for growing businesses with higher volume and reporting needs), and Pro (for businesses that need advanced reporting and priority support). The Bookkeeping Service adds full double-entry bookkeeping, bank and card connections, and financial statements, and is available to purchase."},{question:"Is there a free trial?",answer:"Free trial — 5 documents included, no credit card required. That lets you try the upload and extraction features before committing. Paid plans are billed monthly and you can cancel at any time."},{question:"Can I upgrade or downgrade my plan?",answer:"Yes. You can change your plan at any time from the Subscription page in y
98our account. Upgrades take effect immediately; downgrades apply at the start of your next billing cycle."},{question:"Do you offer refunds?",answer:"We handle refund requests on a case-by-case basis. If you have an issue with a charge, contact us at [email protected] and we will work with you to make it right."},{question:"Are prices in Canadian dollars?",answer:"Yes. All prices are in CAD or USD and exclude taxes."}]},{title:"Canadian Tax",items:[{question:"Does it track GST/HST input tax credits (ITCs)?",answer:"Yes. The AI extracts the GST/HST amount from each receipt and tags it as an ITC. Your GST/HST ITC report shows a clean breakdown by period so you can file your return or hand it to your accountant with confidence."},{question:"Which provinces are supported?",answer:"All Canadian provinces and territories are supported. GST and HST amounts are extracted from your receipts and tracked for input tax credits, and provincial sales tax is treated according to the rules that apply in your province."},{question:"Can I use the export for my T2125 (business income tax)?",answer:"Yes. The annual Excel workbook organizes expenses by CRA-recognized categories (advertising, office, travel, meals, etc.) that map directly to the T2125 Statement of Business Activities. Your accountant or tax preparer can use it to file your return."},{question:"Does the AI classify expenses to CRA categories?",answer:"Yes. Every expense is automatically assigned a category aligned with CRA business expense categories. You can review and correct any categorization in the Workbook view before exporting."}]},{title:"Security",items:[{question:"Where is my data stored?",answer:"Your account data is held in a private database, and your financial documents are stored privately and served through expiring signed links rather than public file URLs. Each organization’s data is isolated from every other, and the permission rules are covered by deny-path tests."},{question:"Is my data encrypted?",answer:"All data in transit is protected by TLS/HTTPS. Passwords are hashed and never stored in plaintext, and sensitive credentials such as bank connection tokens are encrypted at rest. No system can be guaranteed 100% secure, but a formal security review program is in place and independent assessment is planned as the platform scales."},{question:"Do you sell or share my financial data?",answer:"No. We do not sell your personal or financial data. We share it only with the service providers needed to operate the app — for example Stripe for payments and SendGrid for email. See our Privacy Policy for the full list."},{question:"Are my documents used to train AI models?",answer:"No. Documents are processed by our AI provider under commercial API terms that do not permit your data to be used for model training."},{question:"What happens to my data if I cancel?",answer:"When you delete a document or your account, the underlying files are erased from storage — not just the records pointing to them. Where the law requires specific records to be kept, they are retained for that period and no longer. You can request erasure of your personal information at any time by emailing [email protected]."}]},{title:"Account",items:[{question:"How do I link my Telegram account?",answer:"Go to Settings → Telegram Integration. You will see a unique link token. Open @Accuratebooks_bot on Telegram and send the command shown on the Settings page. Your account links instantly."},{question:"Can I export my bookkeeping data?",answer:"Yes. From the Reports section, download your annual Excel workbook (.xlsx) with all transactions, expense summaries, and GST/HST ITC details. Individual reports can also be exported on demand."},{question:"Can I have multiple businesses on one account?",answer:"Each account manages a single business. If you run more than one, get in touch and we will tell you honestly whether we are a fit today."},{question:"How do I cancel my subscription?",answer:'Go to Subscription in your account and click "Cancel Plan". Your access continues until the end of your current billing period. There are no cancellation fees.'},{question:"How do I contact support?",answer:"Use the Support page inside the app to submit a ticket, or email [email protected]. We typically respond within one business day."}]}],hD=({question:e,answer:n})=>{const[s,a]=x.useState(!1);return t.jsxs("div",{className:"border-b border-gray-100 last:border-b-0",children:[t.jsxs("button",{onClick:()=>a(o=>!o),"aria-expanded":s,className:"w-full flex items-center justify-between gap-4 py-4 text-left text-sm font-medium text-gray-900 hover:text-[#0066FF] transition-colors",children:[t.jsx("span",{children:e}),t.jsx("svg",{className:`w-5 h-5 shrink-0 text-gray-400 transition-transform duration-200 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),s&&t.jsx("p",{className:"pb-4 pr-8 text-sm text-gray-500 leading-relaxed",children:n})]})},xD=n2.flatMap(e=>e.items),gD=()=>(x.useEffect(()=>{const e=document.title;document.title="FAQ | AI Bookkeeping";let n=document.querySelector('meta[name="description"]');const s=!n;n||(n=document.createElement("meta"),n.name="description",document.head.appendChild(n)),n.content="Answers to common questions about AI Bookkeeping — pricing, GST/HST tracking, receipt upload, security, and account management.";const a=document.createElement("script");return a.type="application/ld+json",a.id="ld-faq",a.textContent=JSON.stringify({"@context":"https://schema.org","@type":"FAQPage",mainEntity:xD.map(({question:o,answer:l})=>
98({"@type":"Question",name:o,acceptedAnswer:{"@type":"Answer",text:l}}))}),document.head.appendChild(a),()=>{var o;document.title=e,s&&(n==null||n.remove()),(o=document.getElementById("ld-faq"))==null||o.remove()}},[]),t.jsx(t2,{children:t.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-12",children:[t.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-6 text-sm text-gray-400",children:t.jsxs("ol",{className:"flex items-center gap-1.5",children:[t.jsx("li",{children:t.jsx(be,{to:"/",className:"hover:text-gray-700 transition-colors",children:"Home"})}),t.jsx("li",{"aria-hidden":"true",children:"/"}),t.jsx("li",{className:"text-gray-700 font-medium",children:"FAQ"})]})}),t.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Frequently Asked Questions"}),t.jsxs("p",{className:"text-gray-500 mb-10",children:["Everything you need to know about AI Bookkeeping."," ",t.jsx("a",{href:"/blog",className:"text-[#0066FF] hover:underline",children:"Visit our blog"})," ","for in-depth guides."]}),t.jsx("div",{className:"space-y-6",children:n2.map(e=>t.jsxs("section",{"aria-labelledby":`faq-${e.title}`,children:[t.jsx("h2",{id:`faq-${e.title}`,className:"text-xs font-semibold text-gray-400 uppercase tracking-widest mb-3 px-1",children:e.title}),t.jsx("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm px-6",children:e.items.map(n=>t.jsx(hD,{question:n.question,answer:n.answer},n.question))})]},e.title))}),t.jsxs("div",{className:"mt-12 bg-blue-50 rounded-2xl p-6 text-center",children:[t.jsx("p",{className:"text-sm font-semibold text-gray-800 mb-1",children:"Still have questions?"}),t.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Our team responds within one business day."}),t.jsx("a",{href:"mailto:[email protected]",className:"inline-block text-sm font-medium bg-[#0066FF] text-white px-5 py-2 rounded-lg hover:bg-[#0052cc] transition-colors",children:"Contact Support"})]})]})})),yD=()=>(x.useEffect(()=>{const e=document.title;return document.title="Page not found",()=>{document.title=e}},[]),t.jsx(t2,{children:t.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-12 text-center",children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Page not found"}),t.jsx("p",{className:"text-gray-500 mb-8",children:"This page doesn't exist or may have moved."}),t.jsx(be,{to:"/",className:"text-[#0066FF] hover:underline",children:"Back to home"})]})})),bD=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 5.25h16.5m-16.5 4.5h16.5m-16.5 4.5h16.5m-16.5 4.5h16.5"})}),vD=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z"})}),jD=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})}),wD=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})}),ND=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"})}),Cv=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 9V5.25A2.25 2.25 0 0 0 13.5 3h-6a2.25 2.25 0 0 0-2.25 2.25v13.5A2.25 2.25 0 0 0 7.5 21h6a2.25 2.25 0 0 0 2.25-2.25V15m3 0 3-3m0 0-3-3m3 3H9"})}),_D=t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"})}),Rp="flex items-center gap-3 w-full rounded-lg px-3 py-2 text-sm font-medium text-white/60 hover:bg-white/5 hover:text-white transition-colors",xc=({to:e,icon:n,label:s})=>t.jsxs(Fe,{to:e,className:({isActive:a})=>`flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${a?"bg-[#0066FF] text-white":"text-white/60 hover:bg-white/5 hover:text-white"}`,children:[n,t.jsx("span",{children:s})]}),kD=()=>{const{loading:e,staff:n}=Rd(),s=Xe(),a=Ba(),[o,l]=x.useState(!1),d=async()=>{try{await ph()}finally{kd(),a(vo(null)),a(br(!1)),s("/login",{replace:!0})}};return e?t.jsx(js,{}):n?t.jsxs("div",{className:"min-h-screen bg-[#0f172a] text-white flex",children:[t.jsxs("aside",{className:"w-60 shrink-0 border-r border-white/10 bg-[#0A1628] flex flex-col",children:[t.jsxs("div",{className:"px-5 py-5 border-b border-white/10",children:[t.jsx("div",{className:"text-sm font-bold text-white",children:"Internal Console"}),t.jsx("div",{className:"text-xs text-white/40 mt-0.5",children:n.isSuperUser?"Super user":"Reviewer"})]}),t.jsxs("nav",{className:"flex-1 px-3 py-4 space-y-1",children:[t.jsx(xc,{to:"/internal/queue",icon:bD,label:"Pending queue"}),t.jsx(xc,{to:"/internal/clients",icon:vD,label:"Assigned clients"}),n.isSuperUser&&t.jsxs("div",{className:"pt-4 mt-3 border-t border-white/10 space-y-1",children:[t.jsx("div",{className:"px-3 pb-1 text-[11px] font-semibold uppercase tracking-wide text-white/30",children:"Administration"}),t.jsx(xc,{to:"/internal/staff",icon:jD,label:"Staff"}),t.jsx(xc,{to:"/internal/assignments",icon:wD,label:"Assignments"})]})]}),t.jsxs("div",{className:"px-3 py-4 border-t border-white/10 space-y-1",children:[n.isSuperUser&&t.jsxs(be,{to:"/dashboard",className:Rp,children:[_D,t.jsx("span",{children:"Back to client app"})]}),t.jsxs(be,{to:"/forgot-password",className:Rp,children:[ND,t.jsx("span",{children:"Change password"})]}),t.jsxs("button",{type:"button",onClick:()=>l(!0),className:Rp,children:[Cv,t.jsx("span",{children:"Log out"})]})]})]}),t.jsx("main",{className:"flex-1 min-w-0",children:t.jsx(Zv,{})}),o&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black/50 z-50",onClick:()=>l(!1)}),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:t.jsxs("div",{className:"bg-[#0A1628] border border-white/10 rounded-xl shadow-2xl w-full max-w-xs p-6",onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-9 h-9 rounded-lg bg-white/8 flex items-center justify-center shrink-0 text-white/70",children:Cv}),t.jsx("h3",{className:"text-sm font-semibold text-white",children:"Log out"})]}),t.jsx("p",{className:"text-sm text-white/60 mb-6 leading-relaxed",children:"Are you sure you want to log out?"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>l(!1),className:"flex-1 rounded-lg border border-white/15 px-4 py-2 text-sm font-medium text-white/70 hover:text-white hover:border-white/30 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:d,className:"flex-1 rounded-lg bg-white/10 hover:bg-white/15 px-4 py-2 text-sm font-semibold text-white transition-colors",children:"Log out"})]})]})})]})]}):t.jsx(Pn,{to:"/dashboard",replace:!0})},Na=({children:e})=>{const{loading:n,staff:s}=Rd(),{user:a}=ht(o=>o.auth);return n?t.jsx(js,{}):s?t.jsx(t.Fragment,{children:e}):t.jsx(Pn,{to:uh(a,"/dashboard"),replace:!0})},Ev=({children:e})=>{const{loading:n,staff:s}=Rd(),{user:a}=ht(o=>o.auth);return n?t.jsx(js,{}):!s||!s.isSuperUser?t.jsx(Pn,{to:uh(a,"/dashboard"),replace:!0}):t.jsx(t.Fragment,{children:e})},Th=(e,n)=>{const s=e==null?void 0:e.data;if(s==null||typeof s!="object")return n;const a=s;if(typeof a.detail=="string"&&a.detail)return a.detail;const o=[];for(const[l,d]of Object.entries(a))l!=="code"&&(Array.isArray(d)?o.push(d.map(u=>
98String(u)).join(" ")):typeof d=="string"&&o.push(d));return o.length?o.join(" "):n},SD=()=>{const[e,n]=x.useState([]),[s,a]=x.useState(0),[o,l]=x.useState(!0),[d,u]=x.useState(null),[p,h]=x.useState(0),f=x.useCallback(()=>h(g=>g+1),[]);return x.useEffect(()=>{let g=!1;return l(!0),u(null),te.get("/api/accounting/review/",{params:{page_size:200}}).then(b=>{if(!(g||b==null))if(b.status===200){const v=b.data,N=Array.isArray(v)?v:Array.isArray(v==null?void 0:v.results)?v.results:[];n(N),a(typeof(v==null?void 0:v.count)=="number"?v.count:N.length)}else n([]),u(Th(b,"Failed to load the review queue."))}).catch(()=>{g||u("Failed to load the review queue.")}).finally(()=>{g||l(!1)}),()=>{g=!0}},[p]),{entries:e,count:s,isLoading:o,error:d,refetch:f}},CD=async e=>{try{const n=await te.post(`/api/accounting/review/${e}/approve/`,{});return n&&(n.status===200||n.status===201)?{ok:!0}:{ok:!1,errorDetail:Th(n,"Approval failed.")}}catch{return{ok:!1,errorDetail:"Approval failed."}}},ED=async(e,n)=>{try{const s=await te.post(`/api/accounting/review/${e}/reject-correct/`,n);return s&&(s.status===200||s.status===201)?{ok:!0}:{ok:!1,errorDetail:Th(s,"Reject & correct failed.")}}catch{return{ok:!1,errorDetail:"Reject & correct failed."}}},Zs=({title:e,subtitle:n,actions:s,children:a})=>t.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-8",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-white",children:e}),n&&t.jsx("p",{className:"text-sm text-white/50 mt-1",children:n})]}),s&&t.jsx("div",{className:"shrink-0",children:s})]}),t.jsx("div",{className:"space-y-6",children:a})]}),lt=({title:e,description:n,actions:s,className:a,children:o})=>t.jsxs("div",{className:`bg-[#0A1628] border border-white/10 rounded-xl ${a??""}`,children:[(e||s)&&t.jsxs("div",{className:"flex items-center justify-between gap-4 px-5 py-4 border-b border-white/10",children:[t.jsxs("div",{children:[e&&t.jsx("h2",{className:"text-sm font-semibold text-white",children:e}),n&&t.jsx("p",{className:"text-xs text-white/40 mt-0.5",children:n})]}),s]}),t.jsx("div",{className:"p-5",children:o})]}),AD={neutral:"bg-white/10 text-white/70",info:"bg-[#0066FF]/20 text-[#4DA6FF]",success:"bg-emerald-500/15 text-emerald-300",warning:"bg-amber-500/15 text-amber-300",danger:"bg-red-500/15 text-red-300"},an=({tone:e="neutral",children:n})=>t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${AD[e]}`,children:n}),Lh=({className:e})=>t.jsx("div",{className:`inline-block border-2 border-current border-t-transparent rounded-full animate-spin ${e??"w-5 h-5"}`}),ys=({label:e})=>t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-white/50",children:[t.jsx(Lh,{className:"w-6 h-6 text-[#0066FF]"}),e&&t.jsx("span",{className:"text-sm",children:e})]}),bn=({title:e,description:n,children:s})=>t.jsxs("div",{className:"flex flex-col items-center justify-center text-center gap-2 py-16",children:[t.jsx("svg",{className:"w-8 h-8 text-white/20",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})}),t.jsx("p",{className:"text-sm font-medium text-white/70",children:e}),n&&t.jsx("p",{className:"text-xs text-white/40 max-w-md",children:n}),s]}),Mn=({message:e,onRetry:n})=>t.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3",children:[t.jsx("p",{className:"text-sm text-red-200",children:e}),n&&t.jsx("button",{type:"button",onClick:n,className:"text-xs font-medium text-red-100 underline underline-offset-2 hover:text-white",children:"Retry"})]}),s2=({message:e})=>t.jsx(lt,{children:t.jsxs("div",{className:"flex flex-col items-center justify-center text-center gap-2 py-12",children:[t.jsx("svg",{className:"w-8 h-8 text-white/20",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z"})}),t.jsx("p",{className:"text-sm font-medium text-white/70",children:"Not permitted"}),t.jsx("p",{className:"text-xs text-white/40 max-w-md",children:e??"This area is limited to super users."})]})}),ct=({onClick:e,disabled:n,type:s="button",busy:a,children:o})=>t.jsxs("button",{type:s,onClick:e,disabled:n||a,className:"inline-flex items-center justify-center gap-2 rounded-lg bg-[#0066FF] px-4 py-2 text-sm font-semibold text-white hover:bg-[#0052cc] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[a&&t.jsx(Lh,{className:"w-4 h-4"}),o]}),Ke=({onClick:e,disabled:n,tone:s="default",children:a})=>t.jsx("button",{type:"button",onClick:e,disabled:n,className:`inline-flex items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-semibold border transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${s==="danger"?"border-red-500/40 text-red-200 hover:bg-red-500/10":"border-white/15 text-white/80 hover:bg-white/5"}`,children:a}),zr=()=>{const[e,n]=x.useState(null),s=x.useCallback((a,o)=>{n({message:a,type:o}),setTimeout(()=>n(null),4e3)},[]);return{toast:e,showToast:s}},Wr=({toast:e})=>e?t.jsx("div",{className:`fixed top-5 right-5 z-50 rounded-lg px-4 py-3 text-sm font-medium text-white shadow-lg ${e.type==="success"?"bg-emerald-600":"bg-red-600"}`,children:e.message}):null,Hr=({title:e,onClose:n,children:s})=>t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:n,children:t.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[#0A1628] p-6 shadow-xl",onClick:a=>a.stopPropagation(),children:[t.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[t.jsx("h3",{className:"text-base font-semibold text-white",children:e}),t.jsx("button",{type:"button",onClick:n,className:"text-white/40 hover:text-white",children:"✕"})]}),s]})}),St=e=>{if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);
98return Number.isNaN(n)?String(e):n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})},TD=e=>{if(!e)return"—";const n=new Date(e).getTime();if(Number.isNaN(n))return"—";const s=Math.max(0,Math.floor((Date.now()-n)/1e3));if(s<60)return`${s}s`;const a=Math.floor(s/60);if(a<60)return`${a}m`;const o=Math.floor(a/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`},Xi=e=>e?e.split("_").map(n=>n.length?n[0].toUpperCase()+n.slice(1):n).join(" "):"—",Rh=e=>{var s;const n=(s=e==null?void 0:e.data)==null?void 0:s.code;return typeof n=="string"&&n?n:void 0},er=(e,n)=>{const s=e==null?void 0:e.data;if(s==null||typeof s!="object")return n;const a=s;if(typeof a.detail=="string"&&a.detail)return a.detail;const o=[];for(const[l,d]of Object.entries(a))l!=="code"&&(Array.isArray(d)?o.push(d.map(u=>String(u)).join(" ")):typeof d=="string"&&o.push(d));return o.length?o.join(" "):n},LD=async(e,n)=>{const s=await te.get(e,{params:{...n??{},page_size:200}});if(s==null||s.status!==200)return[];const a=s.data;return Array.isArray(a)?a:Array.isArray(a==null?void 0:a.results)?a.results:[]},RD=async(e,n)=>{try{const s=await te.post(`/api/accounting/staff/orgs/${e}/accounts/`,n);return s&&s.status===201?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,errorDetail:er(s,"Failed to create account.")}}catch{return{ok:!1,errorDetail:"Failed to create account."}}},r2=(e,n)=>{const s=n!=null&&n.archived?"true":"false",[a,o]=x.useState([]),[l,d]=x.useState(!1),[u,p]=x.useState(null),[h,f]=x.useState(0),g=x.useCallback(()=>f(b=>b+1),[]);return x.useEffect(()=>{if(!e){o([]);return}let b=!1;return d(!0),p(null),LD(`/api/accounting/staff/orgs/${e}/counterparties/`,{archived:s}).then(v=>{b||o(v)}).catch(()=>{b||p("Failed to load counterparties.")}).finally(()=>{b||d(!1)}),()=>{b=!0}},[e,s,h]),{counterparties:a,isLoading:l,error:u,refetch:g}},ID=async(e,n)=>{try{const s=await te.post(`/api/accounting/staff/orgs/${e}/counterparties/`,n);return s&&s.status===201?{ok:!0,data:s.data}:{ok:!1,status:s==null?void 0:s.status,errorDetail:er(s,"Failed to create counterparty.")}}catch{return{ok:!1,errorDetail:"Failed to create counterparty."}}},PD=async(e,n,s)=>{var a;try{const o=await te.post(`/api/accounting/staff/entries/${e}/attribute/`,{counterparty:n,...s?{reason:s}:{}});return o&&o.status===200?{ok:!0,status:200,data:{changed:((a=o.data)==null?void 0:a.changed)!==!1}}:{ok:!1,status:o==null?void 0:o.status,code:Rh(o),errorDetail:er(o,"Attribution failed.")}}catch{return{ok:!1,errorDetail:"Attribution failed."}}},FD=async(e,n)=>{try{const s=await te.post(`/api/accounting/staff/entries/${e}/correct/`,n);if(s&&s.status===201&&s.data)return{ok:!0,entry:s.data};const a=s==null?void 0:s.status;return a===404?{ok:!1,status:a,errorDetail:"Not found"}:a===429?{ok:!1,status:a,errorDetail:"Rate limit — try again in a minute"}:{ok:!1,status:a,code:Rh(s),errorDetail:er(s,"Correction failed.")}}catch{return{ok:!1,errorDetail:"Correction failed."}}},Wd=500,Hd=async(e,n,s)=>{try{const a=await te.post(e,n);if(a&&a.status===201&&a.data){const u=a.data;return{ok:!0,result:{...u,action:u.action??"",entries_created:Array.isArray(u.entries_created)?u.entries_created:[],moved:u.moved??{}}}}const o=a==null?void 0:a.status,l=a==null?void 0:a.data,d=l!=null&&typeof l=="object"&&!Array.isArray(l)?l:{};return o===404?{ok:!1,refusal:{status:o,detail:"Not found",context:d}}:o===429?{ok:!1,refusal:{status:o,detail:"The hourly limit for these actions has been reached. Try again later.",context:d}}:{ok:!1,refusal:{status:o,code:Rh(a),detail:er(a,s),context:d}}}catch{return{ok:!1,refusal:{detail:s,context:{}}}}},DD=(e,n)=>Hd(`/api/accounting/staff/entries/${e}/reverse/`,{reason:n},"Reversal failed."),OD=(e,n,s)=>Hd(`/api/accounting/staff/entries/${e}/merge-into/`,{survivor_entry_id:n,reason:s},"Merge failed."),$D=(e,n,s)=>Hd(`/api/accounting/staff/entries/${e}/attach-document/`,{document_id:n,reason:s},"Attaching the document failed."),MD=(e,n)=>Hd(`/api/accounting/staff/documents/${e}/dismiss-duplicate/`,{reason:n},"Dismissing the document failed."),BD=e=>`${Rr(e.entry_number)??"an entry"} (${e.kind.replace(/_/g," ")})`,qd=e=>{var p,h;const n=Rr((p=e.entry)==null?void 0:p.entry_number)??"The entry",s=e.entries_created.map(BD),a=s.length>0?` Created ${s.join(", ")}.`:"",o=e.moved,l=f=>Array.isArray(f)?f.length:typeof f=="number"?f:0,u=(Array.isArray(o.documents)?o.documents:[]).map(f=>`document ${f.document_id??"—"}${f.mode?` (${f.mode.replace(/_/g," ")})`:""}`).join(", ");switch(e.action){case"reverse":return`${n} reversed.${a}`;case"merge":{const f=Rr((h=e.survivor)==null?void 0:h.entry_number)??"the surviving entry",g=[`${l(o.bank_state_ids)} bank link(s)`,`${l(o.matches_carried)} match(es) carried`,`${l(o.matches_unmatched)} match(es) left unmatched`,u||"no documents"];return`${n} merged into ${f}.${a} Moved: ${g.join("; ")}.`}case"attach_document":return`Attached to ${n}: ${u||"the document"}.${a}`;case"dismiss_duplicate":return e.document_id!=null?`Document ${e.document_id} dismissed as a duplicate.`:"Document dismissed as a duplicate.";default:return`Done.${a}`}},UD=(e,n)=>{const s={};return n.status&&(s.status=n.status),n.unattributed&&(s.unattributed="true"),Or(`/api/accounting/staff/orgs/${e}/entries/`,s)},zD=e=>Or(`/api/accounting/staff/orgs/${e}/cards/`),WD=async(e,n)=>{try{const s=await te.post(`/api/accounting/staff/orgs/${e}/cards/`,n);return s&&s.status===201?{ok:!0,status:201,data:s.data}:{ok:!1,status:s==null?void 0:s.status,errorDetail:er(s,"Failed to add card.")}}catch{return{ok:!1,errorDetail:"Failed to add card."}}},a2=async(e,n)=>{try{const s=await te.patch(`/api/accounting/staff/cards/${e}/`,n);return s&&s.status===200?{ok:!0,status:200,data:s.data}:{ok:!1,status:s==null?void 0:s.status,errorDetail:er(s,"Failed to save card.")}}catch{return{ok:!1,errorDetail:"Failed to save card."}}},HD=async e=>{var n,s;try{const a=await te.post(`/api/accounting/staff/cards/${e}/resend-notification/`);if(a&&a.status===200){const l=(n=a.data)==null?void 0:n.sent_to_count;return{ok:!0,status:200,sentToCount:typeof l=="number"?l:0}}const o=(s=a==null?void 0:a.data)==null?void 0:s.code;return{ok:!1,status:a==null?void 0:a.status,code:o,errorDetail:er(a,"Could not re-send the notification.")}}catch{return{ok:!1,errorDetail:"Could not re-send the notification."}}},Ip="w-full rounded-md bg-[#0f172a] border border-white/15 px-2 py-1.5 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF]",i2=({orgId:e,value:n,onChange:s,disabled:a,allowCreate:o=!0})=>{const{counterparties:l,isLoading:d,refetch:u}=r2(e,{archived:!1}
98),[p,h]=x.useState(!1),[f,g]=x.useState(""),[b,v]=x.useState("supplier"),[N,w]=x.useState(!1),[k,_]=x.useState(null),S=async()=>{if(!f.trim()||N)return;w(!0),_(null);const T=b==="client"?{is_client:!0}:{is_supplier:!0},E=await ID(e,{name:f.trim(),...T});w(!1),E.ok&&E.data?(s(E.data.id),h(!1),g(""),u()):_(E.errorDetail??"Failed to create counterparty.")};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("select",{value:n,onChange:T=>s(T.target.value),disabled:a||d,className:Ip,children:[t.jsx("option",{value:"",children:d?"Loading…":"Select a counterparty…"}),l.map(T=>t.jsxs("option",{value:T.id,children:[T.name,T.is_client&&T.is_supplier?" (client · supplier)":T.is_client?" (client)":T.is_supplier?" (supplier)":""]},T.id))]}),o&&t.jsx("button",{type:"button",onClick:()=>h(T=>!T),disabled:a,className:"shrink-0 text-xs font-medium text-[#4DA6FF] hover:text-white disabled:opacity-40",children:"+ New"})]}),o&&p&&t.jsxs("div",{className:"rounded-md border border-white/10 bg-white/5 p-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:f,onChange:T=>g(T.target.value),placeholder:"Business name",className:Ip}),t.jsxs("select",{value:b,onChange:T=>v(T.target.value),className:`${Ip} w-32`,children:[t.jsx("option",{value:"supplier",children:"Supplier"}),t.jsx("option",{value:"client",children:"Client"})]})]}),k&&t.jsx("p",{className:"text-xs text-red-300",children:k}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:S,disabled:!f.trim()||N,className:"rounded-md bg-[#0066FF] px-3 py-1.5 text-xs font-semibold text-white hover:bg-[#0052cc] disabled:opacity-50",children:N?"Creating…":"Create & select"}),t.jsx("button",{type:"button",onClick:()=>{h(!1),_(null)},className:"rounded-md border border-white/15 px-3 py-1.5 text-xs font-medium text-white/70 hover:text-white",children:"Cancel"})]})]})]})},uo=e=>`/api/accounting/staff/orgs/${encodeURIComponent(e)}`;function Ih(e,n,s){const[a,o]=x.useState(null),[l,d]=x.useState(!0),[u,p]=x.useState(null),[h,f]=x.useState(null),[g,b]=x.useState(0),v=x.useCallback(()=>b(N=>N+1),[]);return x.useEffect(()=>{let N=!1;return d(!0),p(null),f(null),te.get(e,n?{params:n}:void 0).then(w=>{var k;N||w==null||(f(w.status??null),w.status===200?o(w.data):(o(null),p(((k=w.data)==null?void 0:k.detail)??"Failed to load report")))}).catch(w=>{var k,_,S;N||(f(((k=w==null?void 0:w.response)==null?void 0:k.status)??null),p(((S=(_=w==null?void 0:w.response)==null?void 0:_.data)==null?void 0:S.detail)??"Failed to load report"))}).finally(()=>{N||d(!1)}),()=>{N=!0}},[...s,g]),{data:a,isLoading:l,error:u,status:h,refetch:v}}const qD=(e,n)=>Ih(`${uo(e)}/reports/pnl/`,Br(n),[e,Ur(n)]),VD=(e,n)=>Ih(`${uo(e)}/reports/balance-sheet/`,Br(n),[e,Ur(n)]),YD=(e,n,s,a,o=100)=>Ih(`${uo(e)}/reports/account/${encodeURIComponent(n)}/ledger/`,{...Br(s),page:String(a),page_size:String(o)},[e,n,Ur(s),a,o]),o2=e=>(n,s)=>n==="account"?`${uo(e)}/reports/account/${encodeURIComponent(s??"")}/export/`:`${uo(e)}/reports/${Vw[n]}/export/`,nd=e=>{const[n,s]=x.useState(null),[a,o]=x.useState(0),l=x.useCallback(()=>o(d=>d+1),[]);return x.useEffect(()=>{if(!e){s(null);return}let d=!1;return s({kind:"loading"}),te.get(`/api/accounting/staff/entries/${encodeURIComponent(e)}/`).then(u=>{var p;d||((u==null?void 0:u.status)===200&&u.data?s({kind:"ready",row:Rw(u.data)}):s({kind:"error",message:((p=u==null?void 0:u.data)==null?void 0:p.detail)??"Could not load this entry."}))}),()=>{d=!0}},[e,a]),{entry:n,refetch:l}},GD=/^\d+(\.\d{1,2})?$/,ds=e=>{const n=e.trim();if(!GD.test(n))return null;const[s,a=""]=n.split(".");return Number(s)*100+Number((a+"00").slice(0,2))},xr=e=>`${Math.floor(e/100)}.${String(e%100).padStart(2,"0")}`,Av=e=>`${e.account_id}|${e.side}|${e.amount}`,KD=new Set(["already_corrected","already_reversed"]),Tv="w-full rounded-md bg-[#0f172a] border border-white/15 px-2 py-1.5 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF]",QD=({orgId:e,entry:n,onClose:s,onChanged:a,notify:o,onOpenEntry:l})=>{const{entry:d,refetch:u}=nd(n.id),{accounts:p,loading:h,error:f}
98=Mr("staff",e),[g,b]=x.useState([]),[v,N]=x.useState(null),[w,k]=x.useState(""),[_,S]=x.useState(!1),[T,E]=x.useState(!1),[A,I]=x.useState(null),R=(d==null?void 0:d.kind)==="ready"?d.row:null,W=(R==null?void 0:R.entry_number_display)??Rr(n.entry_number)??"this entry",Y=x.useMemo(()=>(d==null?void 0:d.kind)==="ready"?d.row.lines.filter(Lw):[],[d]),K=x.useMemo(()=>(d==null?void 0:d.kind)!=="ready"?[]:Y.map(ae=>{const J=ds(ae.debit??"")??0,pe=ds(ae.credit??"")??0,Re=J>0?"debit":"credit",We=xr(Re==="debit"?J:pe);return Av({account_id:ae.account_id,side:Re,amount:We})}).sort(),[d,Y]);x.useEffect(()=>{(d==null?void 0:d.kind)!=="ready"||v===d.row.id||(b(Y.map((ae,J)=>{const pe=ds(ae.debit??"")??0,Re=ds(ae.credit??"")??0,We=pe>0?"debit":"credit";return{key:`orig-${ae.id??J}`,account_id:ae.account_id,side:We,amount:xr(We==="debit"?pe:Re),description:ae.description??"",tax_code:ae.tax_code??""}})),N(d.row.id))},[d,Y,v]),x.useEffect(()=>{const ae=J=>{J.key!=="Escape"||T||(_?S(!1):s())};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[_,T,s]);const X=R!==null&&Ga(R),se=R!==null?Aw(R):null,ne=R===null||X?null:Eo(R)??`Only the live entry of a chain can be corrected (status: ${Ks(R)}).`,Z=x.useMemo(()=>{const ae=new Map;return(d==null?void 0:d.kind)==="ready"&&d.row.lines.forEach((J,pe)=>{J.account_id&&ae.set(`orig-${J.id??pe}`,{id:J.account_id,code:J.account_code??"—",name:J.account_name??""})}),ae},[d]),ue=x.useMemo(()=>new Set(p.map(ae=>ae.id)),[p]),re=!h&&!f,H=ae=>re&&!!ae.account_id&&!ue.has(ae.account_id),M=g.some(H),Q=(ae,J)=>b(pe=>pe.map(Re=>Re.key===ae?{...Re,...J}:Re)),$=()=>b(ae=>[...ae,{key:`new-${Date.now()}-${ae.length}`,account_id:"",side:"debit",amount:"",description:"",tax_code:""}]),L=ae=>b(J=>J.filter(pe=>pe.key!==ae)),F=(ae,J)=>{const pe=ds(J);pe!==null&&Q(ae,{amount:xr(pe)})},V=g.map(ae=>ds(ae.amount)),q=g.length>=2&&g.every((ae,J)=>!!ae.account_id&&V[J]!==null&&V[J]>0),ee=g.reduce((ae,J,pe)=>ae+(J.side==="debit"?V[pe]??0:0),0),je=g.reduce((ae,J,pe)=>ae+(J.side==="credit"?V[pe]??0:0),0),ke=q&&ee===je&&ee>0,me=q?g.map(ae=>Av({...ae,amount:xr(ds(ae.amount))})).sort():[],Ne=me.length!==K.length||me.some((ae,J)=>ae!==K[J]),Oe=X&&!!w.trim()&&ke&&Ne&&!T&&re&&!M,mt=async()=>{E(!0),I(null);const ae=g.map(pe=>({account_id:pe.account_id,side:pe.side,amount:xr(ds(pe.amount)),description:pe.description,tax_code:pe.tax_code})),J=await FD(n.id,{reason:w.trim(),lines:ae});if(E(!1),S(!1),J.ok){const pe=J.entry.entry_number_display??Rr(J.entry.entry_number)??"a new entry";o(`Correction posted — ${pe} corrects ${W}.`,"success"),a(),s()}else I({status:J.status,code:J.code,detail:J.errorDetail}),J.code&&KD.has(J.code)&&u()},he=()=>{!se||!l||(a(),l(se))},Se=ae=>t.jsx("div",{className:"inline-flex rounded-md border border-white/15 overflow-hidden text-xs",children:["debit","credit"].map(J=>t.jsx("button",{type:"button",onClick:()=>Q(ae.key,{side:J}),disabled:T,className:`px-2 py-1 font-medium ${ae.side===J?"bg-[#0066FF] text-white":"text-white/60 hover:text-white"}`,children:J==="debit"?"Dr":"Cr"},J))});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:["Correct ",W]}),R&&t.jsx(an,{tone:X?"success":"warning",children:Ks(R)})]}),(d==null?void 0:d.kind)==="loading"&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/50",children:[t.jsx(Lh,{className:"w-4 h-4"})," Loading entry…"]}),(d==null?void 0:d.kind)==="error"&&t.jsx(bn,{title:"Not found",description:d.message}),f&&t.jsx(Mn,{message:f}),A&&(A.status===404?t.jsx(bn,{title:"Not found",description:"This entry is not on a client assigned to you, or it no longer exists."}):t.jsx(Mn,{message:A.detail})),R&&!X&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm text-amber-200/80",children:ne}),se&&l&&t.jsxs(Ke,{onClick:he,children:["Open ",se.number??"the live entry"]})]}),R&&X&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-white/60 mb-1",children:["Reason ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("input",{value:w,onChange:ae=>k(ae.target.value),disabled:T,maxLength:500,placeholder:"Why this entry is wrong (carried into the correction's description)",className:Tv})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-medium text-white/60",children:"Corrected lines"}),t.jsx("button",{type:"button",onClick:$,disabled:T,className:"text-xs font-medium text-[#4DA6FF] hover:text-white",children:"+ Add line"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30",children:[t.jsx("th",{className:"py-1 pr-2 font-medium",children:"Account"}),t.jsx("th",{className:"py-1 px-2 font-medium",children:"Side"}),t.jsx("th",{className:"py-1 px-2 font-medium text-right",children:"Amount"}),t.jsx("th",{className:"py-1 px-2 font-medium",children:"Description"}),t.jsx("th",{className:"py-1 px-2 font-medium",children:"Tax"}),t.jsx("th",{className:"py-1 pl-2"})]})}),t.jsx("tbody",{children:g.map(ae=>t.jsxs("tr",{className:"border-t border-white/5 align-top",children:[t.jsxs("td",{className:"py-1.5 pr-2 min-w-[14rem]",children:[t.jsx($r,{id:`correction-account-${ae.key}`,ariaLabel:"Account",tone:"dark",required:!0,value:ae.account_id,onChange:J=>Q(ae.key,{account_id:J}
98),accounts:p,loading:h,error:f,hideError:!0,currentAccount:Z.get(ae.key)??null,disabled:T||!!f,placeholder:"Select…"}),H(ae)&&t.jsx("span",{className:"mt-1 inline-block rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-200",children:"inactive"})]}),t.jsx("td",{className:"py-1.5 px-2",children:Se(ae)}),t.jsx("td",{className:"py-1.5 px-2 w-32",children:t.jsx("input",{inputMode:"decimal",value:ae.amount,onChange:J=>Q(ae.key,{amount:J.target.value}),onBlur:J=>F(ae.key,J.target.value),disabled:T,className:`${Tv} text-right ${ae.amount&&ds(ae.amount)===null?"border-red-500/60":""}`,placeholder:"0.00"})}),t.jsx("td",{className:"py-1.5 px-2 min-w-[8rem] pt-3 text-xs text-white/60",children:ae.description||"—"}),t.jsx("td",{className:"py-1.5 px-2 w-16 pt-3 text-xs text-white/60",children:ae.tax_code||"—"}),t.jsx("td",{className:"py-1.5 pl-2 text-right",children:t.jsx("button",{type:"button",onClick:()=>L(ae.key),disabled:T||g.length<=2,className:"text-white/40 hover:text-red-300 disabled:opacity-30 text-xs",title:g.length<=2?"At least 2 lines required":"Remove line",children:"✕"})})]},ae.key))})]})}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-4 text-[11px] text-white/40",children:[t.jsxs("span",{children:["Dr ",xr(ee)," / Cr ",xr(je),q&&t.jsx("span",{className:ke?"text-emerald-300/80":"text-red-300/80",children:ke?" — balanced":" — must balance"})]}),q&&ke&&!Ne&&t.jsx("span",{className:"text-amber-200/70",children:"Identical to the original — nothing to correct."}),M&&t.jsx("span",{className:"text-amber-200/70",children:"A line uses an inactive account — choose an active account to post."})]})]})]}),(R||(d==null?void 0:d.kind)==="error")&&t.jsxs("div",{className:"flex items-center gap-3",children:[X&&t.jsx(ct,{onClick:()=>S(!0),disabled:!Oe,busy:T,children:"Post correction"}),t.jsx(Ke,{onClick:s,disabled:T,children:X?"Cancel":"Close"})]}),_&&t.jsxs(Hr,{title:"Post correction?",onClose:()=>!T&&S(!1),children:[t.jsxs("p",{className:"text-sm text-white/70",children:["Posts one new entry that corrects ",W,". Audited; cannot be undone."]}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>S(!1),disabled:T,children:"Cancel"}),t.jsx(ct,{onClick:()=>void mt(),disabled:T,busy:T,children:"Confirm"})]})]})]})},JD=500,mo="w-full rounded-md bg-[#0f172a] border border-white/15 px-2 py-1.5 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF]",Wi="rounded-md border border-white/15 px-3 py-1.5 text-xs font-medium text-white/70 hover:text-white disabled:opacity-50",sd="text-xs font-medium text-[#4DA6FF] underline underline-offset-2 hover:text-white",XD={bank_state:"a bank transaction is recorded against it",active_match:"a bank match is active on one of its lines",document_state:"a document is attached to it"},ZD=new Set(["document_has_open_draft","document_attached_to_live_entry"]),Hi=e=>typeof e=="string"&&e?e:null,Vd=({refusal:e,entryLabel:n,survivorLabel:s,onOpenEntry:a,children:o})=>{if(e.status===404)return t.jsx(bn,{title:"Not found",description:"This is not on a client assigned to you, or it no longer exists."});const l=e.context,d=Hi(l.field),u=d==="entry"?n:d==="survivor_entry_id"?s:void 0,p=Array.isArray(l.links)?l.links.map(v=>String(v)):[],h=e.code&&ZD.has(e.code)?Hi(l.entry_id):null,f=Hi(l.adjustment_entry_id),g=Hi(l.duplicate_total),b=Hi(l.survivor_total);return t.jsxs("div",{role:"alert",className:"space-y-2 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-200",children:[t.jsx("p",{children:e.detail}),u&&t.jsxs("p",{className:"text-xs",children:["Refused entry: ",t.jsx("span",{className:"font-semibold text-white",children:u})]}),p.length>0&&t.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-xs",children:p.map(v=>t.jsx("li",{children:XD[v]??v.replace(/_/g," ")},v))}),e.code==="amount_mismatch"&&g&&b&&t.jsxs("p",{className:"text-xs",children:["Duplicate total ",St(g)," · surviving entry total"," ",St(b)]}),h&&a&&t.jsx("button",{type:"button",onClick:()=>a({id:h,number:null}),className:sd,children:"Open that entry"}),f&&a&&t.jsx("button",{type:"button",onClick:()=>a({id:f,number:null}),className:sd,children:"Open the adjustment entry"}),o]})},e8=({orgId:e,entry:n,entryNo:s,onClose:a,onChanged:o,notify:l})=>{var R,W,Y,K;const d=((R=n.counterparty)==null?void 0:R.id)??"",u=((W=n.counterparty)==null?void 0:W.name)??"",[p,h]=x.useState(d),[f,g]=x.use
98State(""),[b,v]=x.useState(!1),[N,w]=x.useState(!1),[k,_]=x.useState(null),{counterparties:S}=r2(e,{archived:!1}),T=((Y=S.find(X=>X.id===p))==null?void 0:Y.name)??"the selected counterparty",E=p!==d,A=p===""?"clear":d===""?"set":"replace",I=async()=>{var se;w(!0),_(null);const X=await PD(n.id,p===""?null:p,f.trim()||void 0);w(!1),v(!1),X.ok?(l(((se=X.data)==null?void 0:se.changed)===!1?"No change":"Counterparty updated","success"),o(),a()):_({status:X.status,code:X.code,detail:X.errorDetail??"Attribution failed."})};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:["Change counterparty · ",s]}),t.jsxs("div",{className:"text-sm text-white/80",children:["Current: ",t.jsx("span",{className:"text-white",children:((K=n.counterparty)==null?void 0:K.name)??"—"})]}),t.jsx(i2,{orgId:e,value:p,onChange:h,disabled:N,allowCreate:!1}),t.jsx("p",{className:"text-[11px] text-white/40",children:"Leave the picker on “Select a counterparty…” to remove the current one."}),t.jsx("input",{value:f,onChange:X=>g(X.target.value),maxLength:JD,placeholder:"Reason (optional)",disabled:N,className:mo}),k&&(k.status===404?t.jsx(bn,{title:"Not found",description:"This entry is not on a client assigned to you, or it no longer exists."}):t.jsx(Mn,{message:k.detail})),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:()=>v(!0),disabled:!E||N,busy:N,children:"Save"}),t.jsx(Ke,{onClick:a,disabled:N,children:"Cancel"})]}),b&&t.jsxs(Hr,{title:A==="clear"?"Remove counterparty?":A==="set"?"Set counterparty?":"Replace counterparty?",onClose:()=>!N&&v(!1),children:[t.jsxs("p",{className:"text-sm text-white/70",children:[A==="clear"&&t.jsxs(t.Fragment,{children:["Removes ",u," from ",s,". "]}),A==="set"&&t.jsxs(t.Fragment,{children:["Sets the counterparty of ",s," to ",T,". "]}),A==="replace"&&t.jsxs(t.Fragment,{children:["Replaces the counterparty of ",s,": ",u," → ",T,". "]}),"The entry keeps its lines and amounts; only the attribution changes, and the change is audited."]}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>v(!1),disabled:N,children:"Cancel"}),t.jsx(ct,{onClick:()=>void I(),disabled:N,busy:N,children:"Confirm"})]})]})]})},t8=({entry:e,entryNo:n,onClose:s,onChanged:a,notify:o,onCorrect:l,onMerge:d})=>{const[u,p]=x.useState(""),[h,f]=x.useState(!1),[g,b]=x.useState(!1),[v,N]=x.useState(null),w=async()=>{b(!0),N(null);const k=await DD(e.id,u.trim());b(!1),f(!1),k.ok?(o(qd(k.result),"success"),a(),s()):N(k.refusal)};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:["Reverse ",n]}),t.jsxs("p",{className:"text-[11px] text-white/40",children:["Posts a reversal entry that offsets ",n,". Only for an entry that no bank transaction or document is linked to."]}),t.jsx("input",{value:u,onChange:k=>p(k.target.value),maxLength:Wd,placeholder:"Reason (required)","aria-label":"Reason",disabled:g,className:mo}),v&&t.jsx(Vd,{refusal:v,entryLabel:n,children:v.code==="entry_has_links"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[t.jsx("span",{children:"Use instead:"}),d&&t.jsx("button",{type:"button",onClick:d,className:sd,children:"Merge into…"}),t.jsx("button",{type:"button",onClick:l,className:sd,children:"Correct"})]})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:()=>f(!0),disabled:!u.trim()||g,busy:g,children:"Reverse"}),t.jsx(Ke,{onClick:s,disabled:g,children:"Cancel"})]}),h&&t.jsxs(Hr,{title:`Reverse ${n}?`,onClose:()=>!g&&f(!1),children:[t.jsxs("p",{className:"text-sm text-white/70",children:["Posts a reversal entry that offsets ",n,". Audited; cannot be undone."]}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>f(!1),disabled:g,children:"Cancel"}),t.jsx(ct,{onClick:()=>void w(),disabled:g,busy:g,children:"Confirm"})]})]})]})},n8=({entry:e,entryNo:n,onClose:s,onChanged:a,notify:o,onOpenEntry:l})=>
98{const[d,u]=x.useState(""),[p,h]=x.useState(""),[f,g]=x.useState(!1),[b,v]=x.useState(!1),[N,w]=x.useState(null),k=d.trim(),_=/^\d+$/.test(k)&&Number(k)>=1,S=_&&!!p.trim()&&!b,T=async()=>{v(!0),w(null);const E=await $D(e.id,Number(k),p.trim());v(!1),g(!1),E.ok?(o(qd(E.result),"success"),a(),s()):w(E.refusal)};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:["Attach document · ",n]}),t.jsx("input",{value:d,onChange:E=>u(E.target.value),inputMode:"numeric",placeholder:"Document id","aria-label":"Document id",disabled:b,className:`${mo} ${k&&!_?"border-red-500/60":""}`}),t.jsx("input",{value:p,onChange:E=>h(E.target.value),maxLength:Wd,placeholder:"Reason (required)","aria-label":"Reason",disabled:b,className:mo}),N&&t.jsx(Vd,{refusal:N,entryLabel:n,onOpenEntry:l}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:()=>g(!0),disabled:!S,busy:b,children:"Attach"}),t.jsx(Ke,{onClick:s,disabled:b,children:"Cancel"})]}),f&&t.jsxs(Hr,{title:"Attach document?",onClose:()=>!b&&g(!1),children:[t.jsxs("p",{className:"text-sm text-white/70",children:["Attaches document ",k," to ",n,". Audited; cannot be undone."]}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>g(!1),disabled:b,children:"Cancel"}),t.jsx(ct,{onClick:()=>void T(),disabled:b,busy:b,children:"Confirm"})]})]})]})},s8=({duplicate:e,survivor:n,onCancel:s,onMerged:a,onOpenEntry:o})=>{const[l,d]=x.useState(""),[u,p]=x.useState(!1),[h,f]=x.useState(!1),[g,b]=x.useState(null);x.useEffect(()=>{b(null)},[n==null?void 0:n.id]);const v=typeof(g==null?void 0:g.context.field)=="string"?g.context.field:null,N=k=>`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border px-3 py-2 text-sm ${k?"border-red-500/60 bg-red-500/10":"border-white/10 bg-white/5"}`,w=async()=>{if(!n)return;f(!0),b(null);const k=await OD(e.id,n.id,l.trim());f(!1),p(!1),k.ok?a(qd(k.result)):b(k.refusal)};return t.jsxs("div",{className:"space-y-3 rounded-md border border-[#0066FF]/40 bg-[#0066FF]/10 p-4",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/50",children:["Merge ",e.number," into…"]}),t.jsxs("div",{className:N(v==="entry"),children:[t.jsx("span",{className:"text-white/50",children:"Duplicate"}),t.jsx("span",{className:"font-mono font-semibold text-white",children:e.number}),t.jsxs("span",{className:"text-white/70",children:["total ",St(e.total)]})]}),n?t.jsxs("div",{className:N(v==="survivor_entry_id"),children:[t.jsx("span",{className:"text-white/50",children:"Surviving entry"}),t.jsx("span",{className:"font-mono font-semibold text-white",children:n.number}),t.jsxs("span",{className:"text-white/70",children:["total ",St(n.total)]})]}):t.jsx("p",{className:"text-sm text-white/70",children:"Click the entry that should survive in the list below."}),t.jsx("input",{value:l,onChange:k=>d(k.target.value),maxLength:Wd,placeholder:"Reason (required)","aria-label":"Reason",disabled:h,className:mo}),g&&t.jsx(Vd,{refusal:g,entryLabel:e.number,survivorLabel:n==null?void 0:n.number,onOpenEntry:o}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:()=>p(!0),disabled:!n||!l.trim()||h,busy:h,children:"Merge"}),t.jsx(Ke,{onClick:s,disabled:h,children:"Cancel"})]}),u&&n&&t.jsxs(Hr,{title:`Merge ${e.number} into ${n.number}?`,onClose:()=>!h&&p(!1),children:[t.jsxs("p",{className:"text-sm text-white/70",children:[e.number," (total ",St(e.total),") is reversed as a duplicate, and its bank links and documents move to ",n.number," (total"," ",St(n.total),"). Audited; cannot be undone."]}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>p(!1),disabled:h,children:"Cancel"}),t.jsx(ct,{onClick:()=>void w(),disabled:h,busy:h,children:"Confirm"})]})]})]})},l2=({orgId:e,entry:n,onChanged:s,onOpenEntry:a,onStartMerge:o,notify:l})=>{var w;const[d,u]=x.useState(null),{toast:p,showToast:h}=zr(),f=l??h;x.useEffect(()=>{u(null)},[n.id]);const g=n.entry_number_display??Rr(n.entry_number)??"this entry",b=Ew("staff",n),v=Eo(n),N=b.includes("merge")&&!!o;return t.jsxs("div",{className:"border-t border-white/10 bg-[#0f172a] px-5 py-4",children:[t.jsx("div",{className:`${d==="correct"?"max-w-4xl":"max-w-xl"} space-y-3 rounded-md border border-white/10 bg-white/5 p-3`,children:d==="correct"?t.jsx(QD,{orgId:e,entry:{id:n.id,entry_number:n.entry_number},onClose:()=>u(null),onChanged:s,notify:f,onOpenEntry:a}):d==="counterparty"?t.jsx(e8,{orgId:e,entry:n,entryNo:g,onClose:()=>u(null),onChanged:s,notify:f}):d==="reverse"?t.jsx(t8,{entry:n,entryNo:g,onClose:()=>u(null),onChanged:s,notify:f,onCorrect:()=>u("correct"),onMerge:N?o:void 0}):d==="attach"?t.jsx(n8,{entry:n,entryNo:g,onClose:()=>u(null),onChanged:s,notify:f,onOpenEntry:a}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:["Posted entry · ",g]}),t.jsxs("div",{className:"text-sm text-white/80",children:["Counterparty: ",t.jsx("span",{className:"text-white",children:((w=n.counterparty)==null?void 0:w.name)??"—"})]}),b.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b.includes("correct")&&t.jsx("button",{type:"button",onClick:()=>u("correct"),className:Wi,children:"Correct"}),b.includes("change_counterparty")&&t.jsx("button",{type:"button",onClick:()=>u("counterparty"),className:Wi,children:"Change counterparty"}),b.includes("reverse")&&t.jsx("button",{type:"button",onClick:()=>
98u("reverse"),className:Wi,children:"Reverse"}),N&&t.jsx("button",{type:"button",onClick:o,className:Wi,children:"Merge into…"}),b.includes("attach_document")&&t.jsx("button",{type:"button",onClick:()=>u("attach"),className:Wi,children:"Attach document"})]}),b.includes("correct")&&t.jsxs("p",{className:"text-[11px] text-white/40",children:["Posts one new entry that corrects ",g,". Audited; cannot be undone."]})]}):t.jsx("p",{className:"text-[11px] text-amber-200/80",children:v??"Changes are made on the live entry of this chain."})]})}),!l&&t.jsx(Wr,{toast:p})]})},r8=[{value:"wrong_account",label:"Wrong account"},{value:"wrong_amount",label:"Wrong amount"},{value:"wrong_template",label:"Wrong template"},{value:"wrong_tax_treatment",label:"Wrong tax treatment"},{value:"wrong_counterparty",label:"Wrong counterparty"},{value:"wrong_date",label:"Wrong date"},{value:"other",label:"Other"}],a8=[{type:"asset",label:"Assets"},{type:"liability",label:"Liabilities"},{type:"equity",label:"Equity"},{type:"revenue",label:"Revenue"},{type:"expense",label:"Expenses"}],Lv={asset:"debit",liability:"credit",equity:"credit",revenue:"credit",expense:"debit"},Kn="w-full rounded-md bg-[#0f172a] border border-white/15 px-2 py-1.5 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF]",i8=({orgId:e,onCreated:n,onCancel:s})=>{const[a,o]=x.useState(""),[l,d]=x.useState(""),[u,p]=x.useState("expense"),[h,f]=x.useState(Lv.expense),[g,b]=x.useState(!1),[v,N]=x.useState(null),w=_=>{p(_),f(Lv[_]??"debit")},k=async()=>{if(!a.trim()||!l.trim()||g)return;b(!0),N(null);const _=await RD(e,{code:a.trim(),name:l.trim(),type:u,normal_balance:h});b(!1),_.ok&&_.data?n(_.data.id):N(_.errorDetail??"Failed to create account.")};return t.jsxs("div",{className:"rounded-md border border-white/10 bg-white/5 p-3 space-y-2",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:"New account"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("input",{value:a,onChange:_=>o(_.target.value),placeholder:"Code",className:Kn}),t.jsx("input",{value:l,onChange:_=>d(_.target.value),placeholder:"Name",className:Kn}),t.jsx("select",{value:u,onChange:_=>w(_.target.value),className:Kn,children:a8.map(_=>t.jsx("option",{value:_.type,children:_.label},_.type))}),t.jsxs("select",{value:h,onChange:_=>f(_.target.value),className:Kn,children:[t.jsx("option",{value:"debit",children:"Debit"}),t.jsx("option",{value:"credit",children:"Credit"})]})]}),v&&t.jsx("p",{className:"text-xs text-red-300",children:v}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:k,disabled:!a.trim()||!l.trim()||g,className:"rounded-md bg-[#0066FF] px-3 py-1.5 text-xs font-semibold text-white hover:bg-[#0052cc] disabled:opacity-50",children:g?"Creating…":"Create & select"}),t.jsx("button",{type:"button",onClick:s,className:"rounded-md border border-white/15 px-3 py-1.5 text-xs font-medium text-white/70 hover:text-white",children:"Cancel"})]})]})},o8=({entry:e,submitting:n,errorDetail:s,onSubmit:a,onCancel:o})=>{const l=e.org_id??"",{accounts:d,loading:u,error:p,refetch:h}=Mr("staff",l||null),f=x.useMemo(()=>{const $=new Map;return e.lines.forEach((L,F)=>{L.account_id&&$.set(`orig-${L.id??F}`,{id:L.account_id,code:L.account_code??"—",name:L.account_name??""})}),$},[e.lines]),[g,b]=x.useState(""),[v,N]=x.useState(""),[w,k]=x.useState(()=>e.lines.map(($,L)=>({key:`orig-${$.id??L}`,account_id:$.account_id??"",debit:$.debit??"",credit:$.credit??"",description:$.description??"",tax_code:$.tax_code??""}))),[_,S]=x.useState(null),[T,E]=x.useState(!1),[A,I]=x.useState("keep"),[R,W]=x.useState(""),Y=($,L)=>k(F=>F.map(V=>V.key===$?{...V,...L}:V)),K=()=>k($=>[...$,{key:`new-${$.length}-${$.reduce((L,F)=>L+F.key.length,0)}`,account_id:"",debit:"",credit:"",description:"",tax_code:""}]),X=$=>k(L=>L.filter(F=>F.key!==$)),se=$=>{const L=$.debit.trim()!=="",F=$.credit.trim()!=="";return!!$.account_id&&L!==F},ne=x.useMemo(()=>new Set(d.map($=>$.id)),[d]),Z=!u&&!p,ue=$=>Z&&!!$.account_id&&!ne.has($.account_id),re=w.some(ue),H=!!g&&w.length>=2&&w.every(se)&&(A!=="set"||!!R)&&!u&&!re&&!n,M=()=>
98{if(!H)return;const $=w.map((F,V)=>({account_id:F.account_id,debit:F.debit.trim()===""?null:F.debit.trim(),credit:F.credit.trim()===""?null:F.credit.trim(),description:F.description,tax_code:F.tax_code,line_order:V})),L={reason_code:g,note:v,lines:$};A==="clear"?L.counterparty_id=null:A==="set"&&(L.counterparty_id=R),a(L)},Q=$=>t.jsx($r,{id:`reject-account-${$.key}`,ariaLabel:"Account",tone:"dark",required:!0,value:$.account_id,onChange:L=>Y($.key,{account_id:L}),accounts:d,loading:u,error:p,currentAccount:f.get($.key)??null,placeholder:"Select…"});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-white/60 mb-1",children:["Reason code ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsxs("select",{value:g,onChange:$=>b($.target.value),className:Kn,children:[t.jsx("option",{value:"",disabled:!0,children:"Select a reason…"}),r8.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-white/60 mb-1",children:"Note (optional)"}),t.jsx("textarea",{value:v,onChange:$=>N($.target.value),rows:2,className:Kn,placeholder:"Context for this correction…"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-medium text-white/60",children:"Corrected lines"}),t.jsx("button",{type:"button",onClick:K,className:"text-xs font-medium text-[#4DA6FF] hover:text-white",children:"+ Add line"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30",children:[t.jsx("th",{className:"py-1 pr-2 font-medium",children:"Account"}),t.jsx("th",{className:"py-1 px-2 font-medium text-right",children:"Debit"}),t.jsx("th",{className:"py-1 px-2 font-medium text-right",children:"Credit"}),t.jsx("th",{className:"py-1 px-2 font-medium",children:"Description"}),t.jsx("th",{className:"py-1 px-2 font-medium",children:"Tax"}),t.jsx("th",{className:"py-1 pl-2"})]})}),t.jsx("tbody",{children:w.map($=>t.jsxs("tr",{className:"border-t border-white/5 align-top",children:[t.jsxs("td",{className:"py-1.5 pr-2 min-w-[11rem]",children:[Q($),ue($)&&t.jsx("span",{className:"mt-1 mr-2 inline-block rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-200",children:"inactive"}),t.jsx("button",{type:"button",onClick:()=>S(_===$.key?null:$.key),className:"mt-1 text-[11px] font-medium text-[#4DA6FF] hover:text-white",children:"+ New account"})]}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:t.jsx("input",{inputMode:"decimal",value:$.debit,onChange:L=>Y($.key,{debit:L.target.value,credit:L.target.value?"":$.credit}),className:`${Kn} text-right`,placeholder:"0.00"})}),t.jsx("td",{className:"py-1.5 px-2 w-28",children:t.jsx("input",{inputMode:"decimal",value:$.credit,onChange:L=>Y($.key,{credit:L.target.value,debit:L.target.value?"":$.debit}),className:`${Kn} text-right`,placeholder:"0.00"})}),t.jsx("td",{className:"py-1.5 px-2 min-w-[10rem]",children:t.jsx("input",{value:$.description,onChange:L=>Y($.key,{description:L.target.value}),className:Kn})}),t.jsx("td",{className:"py-1.5 px-2 w-20",children:t.jsx("input",{value:$.tax_code,onChange:L=>Y($.key,{tax_code:L.target.value}),className:Kn})}),t.jsx("td",{className:"py-1.5 pl-2 text-right",children:t.jsx("button",{type:"button",onClick:()=>X($.key),disabled:w.length<=2,className:"text-white/40 hover:text-red-300 disabled:opacity-30 text-xs",title:w.length<=2?"At least 2 lines required":"Remove line",children:"✕"})})]},$.key))})]})}),_&&t.jsx("div",{className:"mt-2",children:t.jsx(i8,{orgId:l,onCreated:$=>{Y(_,{account_id:$}),S(null),h()},onCancel:()=>S(null)})}),t.jsx("p",{className:"mt-2 text-[11px] text-white/30",children:"Each line takes exactly one of debit / credit. The ledger engine validates the accounts and balance on submit."}),re&&t.jsx("p",{className:"mt-1 text-[11px] text-amber-200/70",children:"A line uses an inactive account — choose an active account to post."})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-white/60 mb-1",children:"Counterparty"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm text-white/70 mb-2",children:[t.jsxs("label",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"radio",checked:A==="keep",onChange:()=>I("keep")}),"Inherited from original"]}),t.jsxs("label",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"radio",checked:A==="clear",onChange:()=>I("clear")}),"None"]}),t.jsxs("label",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"radio",checked:A==="set",onChange:()=>I("set")}),"Set counterparty"]})]}),A==="set"&&l&&t.jsx(i2,{orgId:l,value:R,onChange:W})]}),s&&t.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-200",children:s}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:()=>E(!0),disabled:!H,busy:n,children:"Post correction"}),t.jsx(Ke,{onClick:o,disabled:n,children:"Cancel"})]}),T&&t.jsxs(Hr,{title:"Post correction?",onClose:()=>E(!1),children:[t.jsx("p",{className:"text-sm text-white/70",children:"Posts this entry with your corrected lines. Audited; cannot be undone."}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>E(!1),children:"Cancel"}),t.jsx(ct,{onClick:()=>{E(!1),M()},children:"Confirm"})]})]})]})},c2=e=>{if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isNaN(n)?String(e):`${Math.round(n*100)}%`},d2=e=>{var n;return((n=e.description)==null?void 0:n.trim())||e.entry_number||`Entry ${e.id.slice(0,8)}`},l8="w-full rounded-md bg-[#0f172a] border border-white/15 px-2 py-1.5 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF]",c8=({entry:e,onResolved:n,onClose:s,notify:a})=>{const[o,l]=x.useState("view"),[d,u]=x.useState(!1),[p,h]=x.useState(null),f=async()=>{u(!0),h(null);const I=await CD(e.id);u(!1),I.ok?(a("Entry approved and posted.","success"),n()):(h(I.errorDetail??"Approval failed."),l("view"))},g=async I=>{u(!0),h(null);const R=await ED(e.id,I);u(!1),R.ok?(a("Entry posted with your corrections.","success"),n()):h(R.errorDetail??"Reject & correct failed.")},b=e.suspected_duplicate_of_id!=null?e.source_document_id:null,v=e.source_document_name??`document ${e.source_document_id??""}`,N=e.suspected_duplicate_of_name??`document ${e.suspected_duplicate_of_id??""}`,[w,k]=x.useState(""),[_,S]=x.useState(!1),[T,E]=x.useState(null),A=async()=>
98{if(b==null)return;u(!0),E(null);const I=await MD(b,w.trim());u(!1),S(!1),I.ok?(a(qd(I.result),"success"),n()):E(I.refusal)};return t.jsx(lt,{title:d2(e),description:`${e.org_name??"—"} · ${e.entry_number??"—"} · ${e.entry_date??"—"}`,actions:t.jsx("button",{onClick:s,className:"text-white/40 hover:text-white text-sm",title:"Close",children:"✕"}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30",children:"Source"}),t.jsx("div",{className:"text-white/80",children:Xi(e.source)})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30",children:"Routing reason"}),t.jsx("div",{className:"text-white/80",children:Xi(e.routing_reason)})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30",children:"Confidence"}),t.jsx("div",{className:"text-white/80",children:c2(e.confidence)})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30",children:"Status"}),t.jsx("div",{className:"text-white/80",children:Xi(e.status)})]})]}),e.agent_rationale&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30 mb-1",children:"Agent rationale"}),t.jsx("p",{className:"text-sm text-white/70 whitespace-pre-wrap",children:e.agent_rationale})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30 mb-1",children:"Draft lines"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30",children:[t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Code"}),t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Account"}),t.jsx("th",{className:"py-1 px-3 font-medium text-right",children:"Debit"}),t.jsx("th",{className:"py-1 px-3 font-medium text-right",children:"Credit"})]})}),t.jsx("tbody",{children:e.lines.map(I=>t.jsxs("tr",{className:"border-t border-white/5",children:[t.jsx("td",{className:"py-1.5 pr-3 font-mono text-white/70",children:I.account_code??"—"}),t.jsx("td",{className:"py-1.5 pr-3 text-white/70",children:I.account_name??"—"}),t.jsx("td",{className:"py-1.5 px-3 text-right text-white/80",children:St(I.debit)}),t.jsx("td",{className:"py-1.5 px-3 text-right text-white/80",children:St(I.credit)})]},I.id))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-white/10 font-medium",children:[t.jsx("td",{className:"py-1.5 pr-3",colSpan:2,children:"Total"}),t.jsx("td",{className:"py-1.5 px-3 text-right",children:St(e.total_debits)}),t.jsx("td",{className:"py-1.5 px-3 text-right",children:St(e.total_credits)})]})})]})})]}),e.source_document_id&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30 mb-1",children:"Document"}),e.source_document_url?t.jsx("a",{href:e.source_document_url,target:"_blank",rel:"noreferrer",className:"text-sm text-[#4DA6FF] hover:text-white underline underline-offset-2",children:e.source_document_name??"View document"}):t.jsx("span",{className:"text-sm text-white/60",children:e.source_document_name??"—"})]}),b!=null&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-white/30 mb-1",children:"Suspected duplicate"}),t.jsxs("p",{className:"text-sm text-amber-200/80",children:["This document may be a duplicate of"," ",e.suspected_duplicate_of_url?t.jsx("a",{href:e.suspected_duplicate_of_url,target:"_blank",rel:"noreferrer",className:"text-[#4DA6FF] hover:text-white underline underline-offset-2",children:N}):N,"."]})]}),p&&o!=="reject"&&t.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-200",children:p}),o==="view"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[t.jsx(ct,{onClick:()=>l("confirmApprove"),children:"Approve"}),t.jsx(Ke,{onClick:()=>l("reject"),children:"Reject & correct"}),b!=null&&t.jsx(Ke,{tone:"danger",onClick:()=>l("dismiss"),children:"Dismiss duplicate"})]}
98),o==="dismiss"&&b!=null&&t.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/5 px-4 py-3 space-y-3",children:[t.jsxs("p",{className:"text-sm text-white/80",children:["Dismiss ",v," as a duplicate of ",N,"."]}),t.jsx("input",{value:w,onChange:I=>k(I.target.value),maxLength:Wd,placeholder:"Reason (required)","aria-label":"Reason",disabled:d,className:l8}),T&&t.jsx(Vd,{refusal:T}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:()=>S(!0),disabled:!w.trim()||d,busy:d,children:"Dismiss duplicate"}),t.jsx(Ke,{onClick:()=>{E(null),l("view")},disabled:d,children:"Cancel"})]})]}),_&&t.jsxs(Hr,{title:"Dismiss duplicate document?",onClose:()=>!d&&S(!1),children:[t.jsxs("p",{className:"text-sm text-white/70",children:["Rejects ",v," as a duplicate of ",N,". Its draft entry leaves the queue without being posted. Audited; cannot be undone."]}),t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(Ke,{onClick:()=>S(!1),disabled:d,children:"Cancel"}),t.jsx(ct,{onClick:()=>void A(),disabled:d,busy:d,children:"Confirm"})]})]}),o==="confirmApprove"&&t.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/5 px-4 py-3 space-y-3",children:[t.jsx("p",{className:"text-sm text-white/80",children:"Approve and post this entry through the ledger engine? This cannot be undone here."}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ct,{onClick:f,busy:d,children:"Confirm approve"}),t.jsx(Ke,{onClick:()=>l("view"),disabled:d,children:"Cancel"})]})]}),o==="reject"&&t.jsx("div",{className:"rounded-lg border border-white/10 bg-white/5 px-4 py-3",children:t.jsx(o8,{entry:e,submitting:d,errorDetail:p,onSubmit:g,onCancel:()=>{h(null),l("view")}})})]})})},d8=()=>{const{entries:e,count:n,isLoading:s,error:a,refetch:o}=SD(),[l,d]=x.useState(null),{toast:u,showToast:p}=zr(),h=e.find(g=>g.id===l)??null,f=()=>{d(null),o()};return t.jsxs(Zs,{title:"Pending queue",subtitle:s?"Loading…":`${n} ${n===1?"entry":"entries"} awaiting review (oldest first).`,children:[t.jsx(Wr,{toast:u}),a&&t.jsx(Mn,{message:a,onRetry:o}),s?t.jsx(lt,{children:t.jsx(ys,{label:"Loading review queue…"})}):e.length===0&&!a?t.jsx(lt,{children:t.jsx(bn,{title:"Nothing to review",description:"No journal entries are currently awaiting review in your assigned organizations."})}):t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-6",children:[t.jsx("div",{className:h?"lg:col-span-2":"lg:col-span-5",children:t.jsx(lt,{className:"overflow-hidden",title:`Queue (${e.length})`,children:t.jsx("div",{className:"overflow-x-auto -m-5",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30 border-b border-white/10",children:[t.jsx("th",{className:"py-2 px-5 font-medium",children:"Entry"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Client"}),t.jsx("th",{className:"py-2 px-3 font-medium text-right",children:"Amount"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Reason"}),t.jsx("th",{className:"py-2 px-3 font-medium text-right",children:"Conf."}),t.jsx("th",{className:"py-2 px-5 font-medium text-right",children:"Age"})]})}),t.jsx("tbody",{children:e.map(g=>t.jsxs("tr",{onClick:()=>d(g.id),className:`border-b border-white/5 cursor-pointer transition-colors ${g.id===l?"bg-[#0066FF]/10":"hover:bg-white/5"}`,children:[t.jsxs("td",{className:"py-2.5 px-5",children:[t.jsx("div",{className:"text-white/90 font-medium truncate max-w-[16rem]",children:d2(g)}),t.jsx("div",{className:"text-[11px] text-white/40",children:g.entry_number??"—"})]}),t.jsxs("td",{className:"py-2.5 px-3 text-white/70 truncate max-w-[10rem]",children:[g.org_name??"—",g.org_id&&t.jsx("span",{className:"ml-2 font-mono text-xs text-white/40",children:g.org_id.slice(0,8)})]}),t.jsx("td",{className:"py-2.5 px-3 text-right text-white/80",children:St(g.total_debits)}),t.jsx("td",{className:"py-2.5 px-3",children:t.jsx(an,{tone:"warning",children:Xi(g.routing_reason)})}),t.jsx("td",{className:"py-2.5 px-3 text-right text-white/70",children:c2(g.confidence)}),t.jsx("td",{className:"py-2.5 px-5 text-right text-white/50",children:TD(g.created_at)})]},g.id))})]})})})}),h&&t.jsx("div",{className:"lg:col-span-3",children:t.jsx(c8,{entry:h,onRes
98olved:f,onClose:()=>d(null),notify:p},h.id)})]})]})},u8=()=>{const e=Xe(),[n,s]=x.useState({kind:"loading"}),[a,o]=x.useState(0),l=()=>o(d=>d+1);return x.useEffect(()=>{let d=!1;return s({kind:"loading"}),te.get("/api/accounting/orgs/").then(u=>{var p;if(!(d||u==null))if(u.status===200){const h=Array.isArray(u.data)?u.data:[];s({kind:"orgs",rows:h})}else u.status===403?s({kind:"reviewer"}):s({kind:"error",message:((p=u.data)==null?void 0:p.detail)??"Failed to load clients."})}).catch(()=>{d||s({kind:"error",message:"Failed to load clients."})}),()=>{d=!0}},[a]),t.jsxs(Zs,{title:"Assigned clients",subtitle:"Client organizations under review.",children:[n.kind==="loading"&&t.jsx(lt,{children:t.jsx(ys,{label:"Loading clients…"})}),n.kind==="error"&&t.jsx(Mn,{message:n.message,onRetry:l}),n.kind==="reviewer"&&t.jsx(lt,{title:"Per-client breakdown unavailable",children:t.jsx("p",{className:"text-sm text-white/60",children:"The review queue does not expose per-client attribution, and there is no reviewer-scoped client list in the current backend contract. Your review scope is enforced server-side — the Pending queue already shows only entries from the organizations you are assigned to."})}),n.kind==="orgs"&&(n.rows.length===0?t.jsx(lt,{children:t.jsx(bn,{title:"No client organizations"})}):t.jsx(lt,{title:`Client organizations (${n.rows.length})`,children:t.jsx("div",{className:"overflow-x-auto -m-5",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30 border-b border-white/10",children:[t.jsx("th",{className:"py-2 px-5 font-medium",children:"Organization"}),t.jsx("th",{className:"py-2 px-5 font-medium text-right",children:"Entries"}),t.jsx("th",{className:"py-2 px-5 font-medium text-right",children:"Cards"})]})}),t.jsx("tbody",{children:n.rows.map(d=>t.jsxs("tr",{onClick:()=>e(`/internal/clients/${d.id}/entries`),className:"border-b border-white/5 cursor-pointer hover:bg-white/5 transition-colors",children:[t.jsxs("td",{className:"py-2.5 px-5 text-white/90",children:[d.name,t.jsx("span",{className:"ml-2 font-mono text-xs text-white/40",children:d.id.slice(0,8)})]}),t.jsx("td",{className:"py-2.5 px-5 text-right text-[#4DA6FF]",children:"View entries →"}),t.jsx("td",{className:"py-2.5 px-5 text-right",children:t.jsx(be,{to:`/internal/clients/${d.id}/reports`,state:{orgName:d.name},onClick:u=>u.stopPropagation(),className:"text-white/60 hover:text-white",children:"Reports →"})}),t.jsx("td",{className:"py-2.5 px-5 text-right",children:t.jsx(be,{to:`/internal/clients/${d.id}/cards`,onClick:u=>u.stopPropagation(),className:"text-white/60 hover:text-white",children:"Card registry →"})})]},d.id))})]})})}))]})},Rv=e=>e==="posted"?"success":e==="reversed"?"danger":"neutral",Ec=e=>e.entry_number_display||Rr(e.entry_number)||"—",m8=e=>Array.isArray(e.lines)&&e.lines.length>0,u2=e=>({id:e.id,number:Ec(e),total:kh(e)}),Iv=({orgId:e,entry:n,onChanged:s,onOpenEntry:a,onStartMerge:o,notify:l})=>{const d=Eo(n);return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30",children:[t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Code"}),t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Account"}),t.jsx("th",{className:"py-1 px-3 font-medium text-right",children:"Debit"}),t.jsx("th",{className:"py-1 px-3 font-medium text-right",children:"Credit"}),t.jsx("th",{className:"py-1 pl-3 font-medium",children:"Description"})]})}),t.jsx("tbody",{children:n.lines.map(u=>t.jsxs("tr",{className:"border-t border-white/5",children:[t.jsx("td",{className:"py-1 pr-3 font-mono text-white/70",children:u.account_code??"—"}),t.jsx("td",{className:"py-1 pr-3 text-white/70",children:u.account_name??"—"}),t.jsx("td",{className:"py-1 px-3 text-right text-white/80",children:St(u.debit)}),t.jsx("td",{className:"py-1 px-3 text-right text-white/80",children:St(u.credit)}),t.jsx("td",{className:"py-1 pl-3 text-white/60",children:u.description||"—"})]},u.id))})]})}),t.jsx(Sh,{tone:"dark",chain:n.chain,currentId:n.id,liveEntry:n.live_entry,truncated:n.chain_truncated,onOpenEntry:a}),Ga(n)?t.jsx(l2,{orgId:e,entry:{...n,entry_number:n.entry_number??null,counterparty:n.counterparty??null},onChanged:s,onOpenEntry:a,onStartMerge:()=>o(u2(n)),notify:l}):d&&t.jsx("p",{className:"text-xs text-amber-200/80",children:d})]})},p8=()=>{const{orgId:e=""}=Pr(),[n,s]=x.useState(""),[a,o]=x.useState(!1),{items:l,count:d,page:u,setPage:p,pageSize:h,isLoading:f,error:g,refetch:b}=UD(e,{status:n||void 0,unattributed:a}),[v,N]=x.useState(null),[w,k]=x.useState(null),{entry:_,refetch:S}=nd(w),T=re=>{N(re),k(null)},E=()=>{b(),S()},{toast:A,showToast:I}
98=zr(),[R,W]=x.useState(null),{entry:Y}=nd(R!=null&&R.survivor&&R.survivorNeedsLines?R.survivor.id:null),K=R!=null&&R.survivor&&R.survivorNeedsLines&&(Y==null?void 0:Y.kind)==="ready"&&Y.row.id===R.survivor.id?{...R.survivor,total:kh(Y.row)}:(R==null?void 0:R.survivor)??null,X=re=>{W({duplicate:re,survivor:null,survivorNeedsLines:!1}),T(null)},se=re=>R!==null&&re.id!==R.duplicate.id&&Ga(re),ne=re=>{I(re,"success"),W(null),E()},Z=re=>{R&&(N(R.duplicate.id),k(re.id),W(null))},ue=Math.max(1,Math.ceil(d/h));return t.jsxs(Zs,{title:"Client entries",subtitle:"Ledger entries for this organization (newest first).",actions:t.jsx(be,{to:"/internal/clients",className:"text-sm text-[#4DA6FF] hover:text-white underline underline-offset-2",children:"← All clients"}),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[t.jsx("select",{value:n,onChange:re=>{s(re.target.value),p(1),T(null)},"aria-label":"Filter by status",className:"rounded-lg bg-[#0A1628] border border-white/15 px-3 py-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-[#0066FF]",children:_h.map(re=>t.jsx("option",{value:re.value,children:re.label},re.value||"posted"))}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-white/70",children:[t.jsx("input",{type:"checkbox",checked:a,onChange:re=>{o(re.target.checked),p(1)}}),"Only unassigned"]})]}),g&&t.jsx(Mn,{message:g,onRetry:b}),R&&t.jsx(s8,{duplicate:R.duplicate,survivor:K,onCancel:()=>W(null),onMerged:ne,onOpenEntry:Z}
98),f?t.jsx(lt,{children:t.jsx(ys,{label:"Loading entries…"})}):l.length===0&&!g?t.jsx(lt,{children:t.jsx(bn,{title:"No entries",description:"No ledger entries match the current filters."})}):t.jsx(lt,{className:"overflow-hidden",title:`Entries (${d})`,children:t.jsx("div",{className:"overflow-x-auto -m-5",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30 border-b border-white/10",children:[t.jsx("th",{className:"py-2 px-5 font-medium",children:"Date"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Entry #"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Description"}),t.jsx("th",{className:"py-2 px-3 font-medium text-right",children:"Debits"}),t.jsx("th",{className:"py-2 px-3 font-medium text-right",children:"Credits"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Status"}),t.jsx("th",{className:"py-2 px-5 font-medium",children:"Counterparty"})]})}),t.jsx("tbody",{children:l.map(re=>{var F;const H=v===re.id,M=se(re),Q=((F=R==null?void 0:R.survivor)==null?void 0:F.id)===re.id,$=$d(re),L=R?`${M?"cursor-pointer hover:bg-[#0066FF]/10":"opacity-40"} ${Q?"bg-[#0066FF]/20":""}`:"cursor-pointer hover:bg-white/5";return t.jsxs(x.Fragment,{children:[t.jsxs("tr",{onClick:()=>{R?M&&W({...R,survivor:u2(re),survivorNeedsLines:!m8(re)}):T(H?null:re.id)},"aria-selected":R?Q:void 0,className:`border-b border-white/5 transition-colors align-top ${L}`,children:[t.jsx("td",{className:"py-2.5 px-5 text-white/70 whitespace-nowrap",children:re.entry_date}),t.jsx("td",{className:"py-2.5 px-3 text-white/60",children:Ec(re)}),t.jsx("td",{className:"py-2.5 px-3 text-white/90 max-w-[16rem] truncate",children:re.description||"—"}),t.jsx("td",{className:"py-2.5 px-3 text-right text-white/80",children:St($.debits)}),t.jsx("td",{className:"py-2.5 px-3 text-right text-white/80",children:St($.credits)}),t.jsx("td",{className:"py-2.5 px-3",children:t.jsx(an,{tone:Rv(Lr(re)),children:Ks(re)})}),t.jsx("td",{className:"py-2.5 px-5",children:re.counterparty?t.jsx("span",{className:"text-white/80",children:re.counterparty.name}):t.jsx("span",{className:"text-white/40",children:"Unassigned"})})]}),H&&t.jsx("tr",{className:"border-b border-white/5 bg-white/[0.02]",children:t.jsx("td",{colSpan:7,className:"px-5 py-3",children:w===null?t.jsx(Iv,{orgId:e,entry:re,onChanged:E,onOpenEntry:V=>k(V.id),onStartMerge:X,notify:I}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-white/60",children:[(_==null?void 0:_.kind)==="ready"&&_.row.id===w?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-mono font-semibold text-white/90",children:Ec(_.row)}),t.jsx("span",{children:_.row.entry_date}),t.jsx(an,{tone:Rv(Lr(_.row)),children:Ks(_.row)})]}):(_==null?void 0:_.kind)==="error"?t.jsx("span",{className:"text-red-300",children:_.message}):t.jsx("span",{className:"text-white/40",children:"Loading entry…"}),t.jsxs("button",{type:"button",onClick:()=>k(null),className:"text-[#4DA6FF] underline underline-offset-2 hover:text-white",children:["Back to ",Ec(re)]})]}),(_==null?void 0:_.kind)==="ready"&&_.row.id===w&&t.jsx(Iv,{orgId:e,entry:_.row,onChanged:E,onOpenEntry:V=>k(V.id),onStartMerge:X,notify:I})]})})})]},re.id)})})]})})}),d>h&&t.jsxs("div",{className:"flex items-center justify-between text-sm text-white/60",children:[t.jsxs("span",{children:["Page ",u," of ",ue]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>p(Math.max(1,u-1)),disabled:u<=1,className:"rounded-md border border-white/15 px-3 py-1.5 text-white/80 hover:bg-white/5 disabled:opacity-40",children:"Previous"}),t.jsx("button",{type:"button",onClick:()=>p(Math.min(ue,u+1)),disabled:u>=ue,className:"rounded-md border border-white/15 px-3 py-1.5 text-white/80 hover:bg-white/5 disabled:opacity-40",children:"Next"})]})]}),t.jsx(Wr,{toast:A})]})},If={visa:"Visa",mastercard:"Mastercard",amex:"American Express",other:"Card"},f8=["visa","mastercard","amex","other"],Pv={unidentified:{label:"Needs identifying",tone:"warning"},business:{label:"Business",tone:"success"},personal:{label:"Personal",tone:"neutral"}},h8={business:["liability"],personal:["liability","equity"]},x8="2140",g8="22",y8=e=>e===x8||e.startsWith(g8),b8={business:"A business card maps to a liability account — the card’s own payable.",personal:"A personal card maps to the org’s owner-loan or owner-equity account."},v8=e=>new Date(e).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"}),m2="w-full rounded-md border border-white/15 bg-[#0f172a] px-3 py-2 text-sm text-white/90 focus:border-[#0066FF] focus:outline-none disabled:opacity-50",Fv=m2,j8=({card:e,accounts:n,accountsLoading:s,accountsError:a,onDone:o,onCancel:l,notify:d})=>
98{const[u,p]=x.useState(null),[h,f]=x.useState(""),[g,b]=x.useState(!1),[v,N]=x.useState(null),w=x.useMemo(()=>{if(!u)return[];const S=h8[u];return n.filter(T=>T.is_active&&S.includes(T.type)&&!y8(T.code)).sort((T,E)=>T.code.localeCompare(E.code))},[u,n]),k=S=>{p(S),f(""),N(null)},_=async()=>{if(!u||!h||g)return;b(!0),N(null);const S=await a2(e.id,{classification:u,mapped_account:h});b(!1),S.ok?(d("Card classified.","success"),o()):N(S.errorDetail??"Failed to save card.")};return t.jsxs("div",{className:"mt-3 max-w-md space-y-3 rounded-md border border-white/10 bg-white/5 p-3",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-white/40",children:"Classify card"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:["business","personal"].map(S=>t.jsx("button",{type:"button",onClick:()=>k(S),"aria-pressed":u===S,className:`rounded-md border px-3 py-1.5 text-xs font-semibold capitalize transition-colors ${u===S?"border-[#0066FF] bg-[#0066FF]/20 text-[#4DA6FF]":"border-white/15 text-white/70 hover:bg-white/5"}`,children:S},S))}),u&&t.jsxs("div",{className:"space-y-1.5",children:[s?t.jsx("p",{className:"text-xs text-white/40",children:"Loading accounts…"}):a?t.jsx("p",{className:"text-xs text-red-300",children:a}):w.length===0?t.jsxs("p",{className:"text-xs text-amber-300",children:["This org’s chart has no suitable ",u==="business"?"liability":"liability or equity"," account."]}):t.jsx($r,{id:`card-account-${e.id}`,ariaLabel:"Account",tone:"dark",required:!0,value:h,onChange:S=>f(S),accounts:w,disabled:g,placeholder:"Select an account…"}),t.jsx("p",{className:"text-[11px] text-white/40",children:b8[u]})]}),v&&t.jsx("p",{className:"text-xs text-red-300",children:v}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ct,{onClick:_,disabled:!u||!h,busy:g,children:"Save"}),t.jsx(Ke,{onClick:l,disabled:g,children:"Cancel"})]})]})},w8=({orgId:e,onDone:n,onCancel:s,notify:a})=>{const[o,l]=x.useState(""),[d,u]=x.useState("other"),[p,h]=x.useState(""),[f,g]=x.useState(!1),[b,v]=x.useState(null),N=async()=>{if(!/^\d{3,4}$/.test(o)){v("Last 4 digits must be 3–4 numbers.");return}g(!0),v(null);const w=await WD(e,{last4:o,network:d,classification:"unidentified",label:p.trim()});g(!1),w.ok?(a("Card added.","success"),n()):v(w.errorDetail??"Failed to add card.")};return t.jsxs("div",{className:"max-w-md space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wide text-white/40",children:"Last 4 digits"}),t.jsx("input",{value:o,onChange:w=>l(w.target.value.replace(/\D/g,"").slice(0,4)),placeholder:"3277",inputMode:"numeric",disabled:f,className:Fv})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wide text-white/40",children:"Network"}),t.jsx("select",{value:d,onChange:w=>u(w.target.value),disabled:f,className:m2,children:f8.map(w=>t.jsx("option",{value:w,children:If[w]},w))})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wide text-white/40",children:"Label (optional)"}),t.jsx("input",{value:p,onChange:w=>h(w.target.value.slice(0,100)),placeholder:"Capital One M/C",disabled:f,className:Fv})]}),b&&t.jsx("p",{className:"text-xs text-red-300",children:b}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ct,{onClick:N,busy:f,children:"Add card"}),t.jsx(Ke,{onClick:s,disabled:f,children:"Cancel"})]}),t.jsx("p",{className:"text-[11px] text-white/40",children:"Added as unidentified — classify it below once you know whose card it is."})]})},N8=({card:e,accounts:n,accountsLoading:s,accountsError:a,onChanged:o,notify:l})=>{const[d,u]=x.useState(!1),[p,h]=x.useState(!1),[f,g]=x.useState(null),[b,v]=x.useState(!1),N=e.classification==="unidentified",w=Pv[e.classification]??Pv.unidentified,k=async()=>{if(p)return;h(!0),g(null);const S=await HD(e.id);if(h(!1),S.ok){l(`Notification re-sent (${S.sentToCount} recipient${S.sentToCount===1?"":"s"}).`,"success"),o();return}if(S.code==="notification_rate_limited"){g("Recently notified — try again later.");return}l(S.errorDetail??"Could not re-send the notification.","error")},_=async()=>
98{if(b||!window.confirm(`Retire the card ending ${e.last4}? It stops matching future settlements.`))return;v(!0);const S=await a2(e.id,{is_active:!1});v(!1),S.ok?(l("Card retired.","success"),o()):l(S.errorDetail??"Failed to retire card.","error")};return t.jsxs("div",{className:"border-b border-white/5 px-5 py-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-white/90",children:If[e.network]??If.other}),t.jsxs("span",{className:"text-sm text-white/50",children:["····",e.last4]}),t.jsx(an,{tone:w.tone,children:w.label}),!e.is_active&&t.jsx(an,{tone:"danger",children:"Retired"})]}),e.label&&t.jsx("p",{className:"mt-1 max-w-[46ch] truncate text-xs text-white/60",children:e.label}),t.jsxs("p",{className:"mt-1 text-[11px] text-white/35",children:["Detected ",v8(e.created_at)," · ",e.source,e.mapped_account_code&&t.jsxs(t.Fragment,{children:[" · Posts to ",e.mapped_account_code,e.mapped_account_name?` ${e.mapped_account_name}`:""]})]}),f&&t.jsx("p",{className:"mt-1.5 text-[11px] text-amber-300",children:f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[N&&e.is_active&&!d&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>u(!0),className:"text-xs font-semibold text-[#4DA6FF] hover:underline",children:"Classify"}),t.jsx("button",{type:"button",onClick:k,disabled:p,className:"text-xs font-medium text-white/60 hover:text-white disabled:opacity-50",children:p?"Sending…":"Re-send notification"})]}),e.is_active&&t.jsx("button",{type:"button",onClick:_,disabled:b,className:"text-xs font-medium text-red-300/80 hover:text-red-200 disabled:opacity-50",children:b?"Retiring…":"Retire"})]})]}),d&&t.jsx(j8,{card:e,accounts:n,accountsLoading:s,accountsError:a,onDone:()=>{u(!1),o()},onCancel:()=>u(!1),notify:l})]})},_8=()=>{const{orgId:e=""}=Pr(),{items:n,count:s,page:a,setPage:o,pageSize:l,isLoading:d,error:u,refetch:p}=zD(e),{accounts:h,loading:f,error:g}=Mr("staff",e||null),{toast:b,showToast:v}=zr(),[N,w]=x.useState(!1),k=x.useMemo(()=>{const T=E=>E==="unidentified"?0:1;return[...n].sort((E,A)=>T(E.classification)-T(A.classification))},[n]),_=k.filter(T=>T.classification==="unidentified"&&T.is_active).length,S=Math.max(1,Math.ceil(s/l));return t.jsxs(Zs,{title:"Card registry",subtitle:"Cards detected on this organization's bank activity. Classify one once and every future settlement posts by rule.",actions:t.jsx(be,{to:`/internal/clients/${e}/entries`,className:"text-xs font-medium text-white/60 hover:text-white",children:"View entries →"}),children:[t.jsx(Wr,{toast:b}),u&&t.jsx(Mn,{message:u,onRetry:p}),t.jsxs(lt,{title:d?"Cards":`Cards (${s})${_?` · ${_} need identifying`:""}`,actions:!N&&t.jsx(Ke,{onClick:()=>w(!0),children:"Add card"}),className:k.length?"pb-0":void 0,children:[N&&t.jsx("div",{className:"mb-5 border-b border-white/10 pb-5",children:t.jsx(w8,{orgId:e,onDone:()=>{w(!1),p()},onCancel:()=>w(!1),notify:v})}),d?t.jsx(ys,{label:"Loading cards…"}):k.length===0?t.jsx(bn,{title:"No cards on file",description:"Cards appear automatically when the recognizer meets a card payment on this org's bank feed."}):t.jsx("div",{className:"-mx-5 -mb-5",children:k.map(T=>t.jsx(N8,{card:T,accounts:h,accountsLoading:f,accountsError:g,onChanged:p,notify:v},T.id))})]}),S>1&&!d&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-xs text-white/40",children:["Page ",a," of ",S]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{onClick:()=>o(a-1),disabled:a<=1,children:"Prev"}),t.jsx(Ke,{onClick:()=>o(a+1),disabled:a>=S,children:"Next"})]})]})]})},p2="font-[var(--font-family-mono)] tabular-nums",Pp=(e,n,s,a)=>`/internal/clients/${e}/reports/account/${encodeURIComponent(n)}?${Oa(s)}&from_report=${a}`,k8=e=>e===null?"—":jn(e,{year:"numeric",month:"long",day:"numeric"}),rd=(e,n)=>n||e.slice(0,8),f2=({orgId:e,orgName:n})=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(an,{tone:"info",children:["Viewing ",rd(e,n)," as staff — read-only"]}),!n&&t.jsx("span",{className:"font-mono text-xs text-white/40",children:e.slice(0,8)})]}),Fp=({title:e,section:n,totalLabel:s,linkTo:a})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11.5px] font-semibold uppercase tracking-wider text-white/40",children:e}),t.jsx("div",{className:"mt-2 divide-y divide-gray-100 rounded-lg bg-white px-4",children:t.jsx(qw,{rows:n.rows,accountHref:a})}),t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-white/10 pt-2",children:[t.jsx("span",{className:"text-[13px] font-medium text-white/60",children:s}),t.jsx("span",{className:`text-[14px] font-semibold text-white ${p2}`,children:St(n.total)})]})]}),Dv=({status:e,error:n,onRetry:s})=>e===404?t.jsx(bn,{title:"Not found",description:"This client is not assigned to you, or the organization does not exist."}):t.jsx(Mn,{message:n??"Failed to load report",onRetry:s}),S8=()=>{var h,f;const{orgId:e=""}=Pr(),s=(h=vn().state)==null?void 0:h.orgName,[a,o]=Ud(),l=qD(e,a),d=VD(e,a),u=o2(e),p={orgName:s};return t.jsxs(Zs,{title:"Reports",subtitle:`Profit & loss and balance sheet for ${rd(e,s)}, straight from their ledger.`,actions:t.jsx(f2,{orgId:e,orgName:s}),children:[t.jsxs("nav",{"aria-label":"Breadcrumb",className:"text-[13px] text-white/50",children:[t.jsx(be,{to:"/internal/clients",className:"hover:text-white",children:"Assigned clients"}),t.jsx("span",{className:"mx-1.5 text-white/20",children:"›"}),t.jsx(be,{to:`/internal/clients/${e}/entries`,state:p,className:"hover:text-white",children:rd(e,s)}),t.jsx("span",{className:"mx-1.5 text-white/20",children:"›"}),t.jsx("span",{className:"text-white/80",children:"Reports"})]}),t.jsxs(lt,{title:"Profit & Loss",description:(f=l.data)==null?void 0:f.period.label,actions:t.jsxs("div",{className:"flex flex-col items-end gap-2",children:[t.jsx(Ir,{kind:"pnl",period:a,exportUrl:u}
98),t.jsx(zd,{period:a,setPeriod:o})]}),children:[l.isLoading&&t.jsx(ys,{label:"Loading…"}),!l.isLoading&&l.error&&t.jsx(Dv,{status:l.status,error:l.error,onRetry:l.refetch}),!l.isLoading&&l.data&&!l.error&&t.jsxs("div",{className:"space-y-5",children:[t.jsx(Fp,{title:"Revenue",section:l.data.revenue,totalLabel:"Total revenue",linkTo:g=>Pp(e,g,a,"pnl")}),t.jsx(Fp,{title:"Expenses",section:l.data.expenses,totalLabel:"Total expenses",linkTo:g=>Pp(e,g,a,"pnl")}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[#0066FF]/20 px-4 py-3 text-white",children:[t.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wider",children:"Net profit"}),t.jsx("span",{className:`text-[17px] font-semibold ${p2}`,children:St(l.data.net)})]})]})]}),t.jsxs(lt,{title:"Balance Sheet",description:d.data?`As of ${k8(d.data.as_of)}`:void 0,actions:t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[d.data&&!d.data.balances&&t.jsx(an,{tone:"warning",children:"Out of balance"}),t.jsx(Ir,{kind:"balance_sheet",period:a,exportUrl:u})]}),children:[d.isLoading&&t.jsx(ys,{label:"Loading…"}),!d.isLoading&&d.error&&t.jsx(Dv,{status:d.status,error:d.error,onRetry:d.refetch}),!d.isLoading&&d.data&&!d.error&&t.jsx("div",{className:"space-y-5",children:["assets","liabilities","equity"].map(g=>t.jsx(Fp,{title:g.charAt(0).toUpperCase()+g.slice(1),section:d.data[g],totalLabel:`Total ${g}`,linkTo:b=>Pp(e,b,a,"balance_sheet")},g))})]})]})},Ov=100,C8="font-[var(--font-family-mono)] tabular-nums",E8=()=>{var H;const{orgId:e="",code:n=""}=Pr(),a=(H=vn().state)==null?void 0:H.orgName,[o]=Ud(),[l,d]=Jn(),u=Math.max(1,Number(l.get("page")??"1")||1),p=M=>{const Q=new URLSearchParams(l);Q.set("period",M.period),M.period==="custom"&&M.date_from&&M.date_to?(Q.set("from",M.date_from),Q.set("to",M.date_to)):(Q.delete("from"),Q.delete("to")),Q.delete("page"),d(Q,{replace:!0})},h=M=>{const Q=new URLSearchParams(l);M<=1?Q.delete("page"):Q.set("page",String(M)),d(Q,{replace:!0})},{data:f,isLoading:g,error:b,status:v,refetch:N}=YD(e,n,o,u,Ov),[w,k]=x.useState(null),[_,S]=x.useState(null),{entry:T,refetch:E}=nd(_??w),A=M=>{k(M),S(null)};x.useEffect(()=>{k(null),S(null)},[n,u,Oa(o)]);const I={orgName:a},R=`/internal/clients/${e}/reports?${Oa(o)}`,W=f?`${f.account.code} · ${f.account.name}`:n,Y=(f==null?void 0:f.lines.results)??[],K=(T==null?void 0:T.kind)==="ready"?T.row:null,X=()=>{N(),E()},{toast:se,showToast:ne}=zr(),Z=(f==null?void 0:f.lines.count)??0,ue=Z===0?0:(u-1)*Ov+1,re=Z===0?0:ue+Y.length-1;return t.jsxs(Zs,{title:W,subtitle:f?`${td(f.account.type)} · ${f.period.label}`:"Account ledger",actions:t.jsx(f2,{orgId:e,orgName:a}),children:[t.jsxs("nav",{"aria-label":"Breadcrumb",className:"text-[13px] text-white/50",children:[t.jsx(be,{to:"/internal/clients",className:"hover:text-white",children:"Assigned clients"}),t.jsx("span",{className:"mx-1.5 text-white/20",children:"›"}),t.jsx(be,{to:`/internal/clients/${e}/entries`,state:I,className:"hover:text-white",children:rd(e,a)}),t.jsx("span",{className:"mx-1.5 text-white/20",children:"›"}),t.jsx(be,{to:R,state:I,className:"hover:text-white",children:"Reports"}),t.jsx("span",{className:"mx-1.5 text-white/20",children:"›"}),t.jsx("span",{className:`text-white/80 ${C8}`,children:W})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(zd,{period:o,setPeriod:p})}),g&&t.jsx(ys,{label:"Loading…"}),!g&&v===404&&t.jsx(bn,{title:"Account not found",description:"This account does not exist for this client, or the client is not assigned to you.",children:t.jsx(be,{to:R,state:I,className:"text-xs text-[#4DA6FF] hover:underline",children:"← Back to reports"})}),!g&&b&&v!==404&&t.jsx(Mn,{message:b,onRetry:N}),!g&&f&&!b&&t.jsxs(t.Fragment,{children:[t.jsx(Gw,{data:f,exportSlot:t.jsx(Ir,{kind:"account",code:f.account.code,period:o,exportUrl:o2(e)})}),t.jsx(Jw,{lines:Y,expandedId:w,onRowToggle:A,entry:T,onOpenEntry:M=>S(M.id),readOnly:!0,count:Z,first:ue,last:re,hasPrevious:!!f.lines.previous,hasNext:!!f.lines.next,onPrevious:()=>h(u-1),onNext:()=>h(u+1),drawerActions:K&&Ga(K)?t.jsx(l2,{orgId:e,entry:{...K,entry_number:K.entry_number??null,counterparty:K.counterparty??null},onChanged:X,onOpenEntry:M=>S(M.id),notify:ne}):null,documentUrl:()=>null}),t.jsx(be,{to:R,state:I,className:"inline-block text-[13px] font-medium text-[#4DA6FF] hover:underline",children:"← Back to reports"})]}),t.jsx(Wr,{toast:se})]})}
98,h2=(e,n)=>{const s=e==null?void 0:e.data;if(s==null||typeof s!="object")return n;const a=s;if(typeof a.detail=="string"&&a.detail)return a.detail;const o=[];for(const[l,d]of Object.entries(a))l!=="code"&&(Array.isArray(d)?o.push(d.map(u=>String(u)).join(" ")):typeof d=="string"&&o.push(d));return o.length?o.join(" "):n},Ph=(e,n)=>{const[s,a]=x.useState([]),[o,l]=x.useState(!0),[d,u]=x.useState(null),[p,h]=x.useState(!1),[f,g]=x.useState(0),b=x.useCallback(()=>g(v=>v+1),[]);return x.useEffect(()=>{let v=!1;return l(!0),u(null),h(!1),te.get(e).then(N=>{v||N==null||(N.status===200?a(Array.isArray(N.data)?N.data:[]):N.status===403?(h(!0),a([])):(a([]),u(h2(N,n))))}).catch(()=>{v||u(n)}).finally(()=>{v||l(!1)}),()=>{v=!0}},[e,n,f]),{data:s,isLoading:o,error:d,forbidden:p,refetch:b}},x2=()=>Ph("/api/accounting/staff/list/","Failed to load staff."),A8=()=>Ph("/api/accounting/assignments/list/","Failed to load assignments."),T8=()=>Ph("/api/accounting/orgs/","Failed to load organizations."),Yd=async(e,n,s)=>{try{const a=await te.post(e,n);return a&&(a.status===200||a.status===201)?{ok:!0}:{ok:!1,errorDetail:h2(a,s)}}catch{return{ok:!1,errorDetail:s}}},L8=e=>Yd("/api/accounting/staff/invite/",{email:e},"Failed to send invite."),R8=e=>Yd("/api/accounting/staff/deactivate/",{staff_user_id:e},"Failed to deactivate staff."),I8=(e,n)=>Yd("/api/accounting/assignments/",{staff_user_id:e,org_id:n},"Failed to assign reviewer."),P8=(e,n)=>Yd("/api/accounting/assignments/deactivate/",{staff_user_id:e,org_id:n},"Failed to revoke assignment."),F8="rounded-lg bg-[#0f172a] border border-white/15 px-3 py-2 text-sm text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-[#0066FF]",D8=e=>{var n,s;return((n=e.staff_user_name)==null?void 0:n.trim())||((s=e.staff_user_email)==null?void 0:s.trim())||e.staff_user},O8=()=>{const e=x2(),{toast:n,showToast:s}=zr(),[a,o]=x.useState(""),[l,d]=x.useState(!1),[u,p]=x.useState(null),h=async()=>{const g=a.trim();if(!g||l)return;d(!0);const b=await L8(g);d(!1),b.ok?(s("Invite sent.","success"),o(""),e.refetch()):s(b.errorDetail??"Failed to send invite.","error")},f=async g=>{if(u||!window.confirm("Deactivate this staff account? This revokes all their access."))return;p(g.id);const b=await R8(g.staff_user);p(null),b.ok?(s("Staff account deactivated.","success"),e.refetch()):s(b.errorDetail??"Failed to deactivate staff.","error")};return t.jsxs(Zs,{title:"Staff",subtitle:"Internal reviewer and super-user accounts.",children:[t.jsx(Wr,{toast:n}),e.forbidden?t.jsx(s2,{message:"Staff administration is limited to super users."}):t.jsxs(t.Fragment,{children:[t.jsx(lt,{title:"Invite a reviewer",description:"Emails a single-use invite link.",children:t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-[16rem]",children:[t.jsx("label",{className:"block text-xs font-medium text-white/60 mb-1",children:"Email"}),t.jsx("input",{type:"email",value:a,onChange:g=>o(g.target.value),onKeyDown:g=>g.key==="Enter"&&h(),placeholder:"[email protected]",className:`${F8} w-full`})]}),t.jsx(ct,{onClick:h,disabled:!a.trim(),busy:l,children:"Send invite"})]})}),e.error&&t.jsx(Mn,{message:e.error,onRetry:e.refetch}),t.jsx(lt,{title:e.isLoading?"Staff":`Staff (${e.data.length})`,className:"overflow-hidden",children:e.isLoading?t.jsx(ys,{label:"Loading staff…"}):e.data.length===0&&!e.error?t.jsx(bn,{title:"No staff accounts yet"}):t.jsx("div",{className:"overflow-x-auto -m-5",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30 border-b border-white/10",children:[t.jsx("th",{className:"py-2 px-5 font-medium",children:"Name"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Email"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Role"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Capability"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Status"}),t.jsx("th",{className:"py-2 px-5 font-medium text-right",children:"Actions"})]})}),t.jsx("tbody",{children:e.data.map(g=>t.jsxs("tr",{className:`border-b border-white/5 ${g.is_active?"":"opacity-50"}`,children:[t.jsx("td",{className:"py-2.5 px-5 text-white/90",children:D8(g)}),t.jsx("td",{className:"py-2.5 px-3 text-white/60",children:g.staff_user_email||"—"}),t.jsx("td",{className:"py-2.5 px-3 text-white/70",children:Xi(g.role_type)}),t.jsx("td",{className:"py-2.5 px-3",children:g.is_super_user?t.jsx(an,{tone:"info",children:"Super user"}):t.jsx(an,{children:"Reviewer"})}),t.jsx("td",{className:"py-2.5 px-3",children:g.is_active?t.jsx(an,{tone:"success",children:"Active"}):t.jsx(an,{tone:"danger",children:"Inactive"})}),t.jsx("td",{className:"py-2.5 px-5 text-right",children:g.is_active?t.jsx(Ke,{tone:"danger",onClick:()=>f(g),disabled:u===g.id,children:"Deactivate"}):t.jsx("span",{className:"text-xs text-white/30",children:"—"})})]},g.id))})]})})})]})]})},$v="rounded-lg bg-[#0f172a] border border-white/15 px-3 py-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-[#0066FF]",Dp=e=>{var n,s;return((n=e.staff_user_name)==null?void 0:n.trim())||((s=e.staff_user_email)==null?void 0:s.trim())||e.staff_user},$8=()=>
98{const e=A8(),n=x2(),s=T8(),{toast:a,showToast:o}=zr(),[l,d]=x.useState(""),[u,p]=x.useState(""),[h,f]=x.useState(!1),[g,b]=x.useState(null),v=x.useMemo(()=>n.data.filter(S=>S.is_active&&!S.is_super_user),[n.data]),N=e.data.filter(S=>S.is_active),w=e.data.filter(S=>!S.is_active),k=async()=>{if(!l||!u||h)return;f(!0);const S=await I8(l,u);f(!1),S.ok?(o("Reviewer assigned.","success"),d(""),p(""),e.refetch()):o(S.errorDetail??"Failed to assign reviewer.","error")},_=async S=>{if(g||!window.confirm(`Revoke ${Dp(S)}'s access to ${S.org_name||S.org_id}?`))return;b(S.id);const T=await P8(S.staff_user,S.org_id);b(null),T.ok?(o("Assignment revoked.","success"),e.refetch()):o(T.errorDetail??"Failed to revoke assignment.","error")};return t.jsxs(Zs,{title:"Assignments",subtitle:"Reviewer access to client organizations.",children:[t.jsx(Wr,{toast:a}),e.forbidden?t.jsx(s2,{message:"Assignment administration is limited to super users."}):t.jsxs(t.Fragment,{children:[t.jsxs(lt,{title:"Assign a reviewer",description:"Grants a reviewer access to one client org.",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-[14rem]",children:[t.jsx("label",{className:"block text-xs font-medium text-white/60 mb-1",children:"Reviewer"}),t.jsxs("select",{value:l,onChange:S=>d(S.target.value),className:`${$v} w-full`,children:[t.jsx("option",{value:"",children:n.isLoading?"Loading…":"Select a reviewer…"}),v.map(S=>{var T;return t.jsx("option",{value:S.staff_user,children:((T=S.staff_user_name)==null?void 0:T.trim())||S.staff_user_email||S.staff_user},S.id)})]})]}),t.jsxs("div",{className:"flex-1 min-w-[14rem]",children:[t.jsx("label",{className:"block text-xs font-medium text-white/60 mb-1",children:"Organization"}),t.jsxs("select",{value:u,onChange:S=>p(S.target.value),className:`${$v} w-full`,children:[t.jsx("option",{value:"",children:s.isLoading?"Loading…":"Select an organization…"}),s.data.map(S=>t.jsx("option",{value:S.id,children:S.name},S.id))]})]}),t.jsx(ct,{onClick:k,disabled:!l||!u,busy:h,children:"Assign"})]}),(n.error||s.error)&&t.jsx("p",{className:"mt-2 text-xs text-red-300",children:n.error??s.error})]}),e.error&&t.jsx(Mn,{message:e.error,onRetry:e.refetch}),t.jsx(lt,{title:e.isLoading?"Active assignments":`Active assignments (${N.length})`,className:"overflow-hidden",children:e.isLoading?t.jsx(ys,{label:"Loading assignments…"}):N.length===0&&!e.error?t.jsx(bn,{title:"No active assignments"}):t.jsx("div",{className:"overflow-x-auto -m-5",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30 border-b border-white/10",children:[t.jsx("th",{className:"py-2 px-5 font-medium",children:"Reviewer"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Organization"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Assigned"}),t.jsx("th",{className:"py-2 px-5 font-medium text-right",children:"Actions"})]})}),t.jsx("tbody",{children:N.map(S=>{var T;return t.jsxs("tr",{className:"border-b border-white/5",children:[t.jsx("td",{className:"py-2.5 px-5 text-white/90",children:Dp(S)}),t.jsxs("td",{className:"py-2.5 px-3 text-white/70",children:[S.org_name||S.org_id,t.jsx("span",{className:"ml-2 font-mono text-xs text-white/40",children:S.org_id.slice(0,8)})]}),t.jsx("td",{className:"py-2.5 px-3 text-white/50",children:((T=S.assigned_at)==null?void 0:T.slice(0,10))??"—"}),t.jsx("td",{className:"py-2.5 px-5 text-right",children:t.jsx(Ke,{tone:"danger",onClick:()=>_(S),disabled:g===S.id,children:"Revoke"})})]},S.id)})})]})})}),w.length>0&&t.jsx(lt,{title:`History (${w.length})`,className:"overflow-hidden",children:t.jsx("div",{className:"overflow-x-auto -m-5",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-wide text-white/30 border-b border-white/10",children:[t.jsx("th",{className:"py-2 px-5 font-medium",children:"Reviewer"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Organization"}),t.jsx("th",{className:"py-2 px-3 font-medium",children:"Revoked"}),t.jsx("th",{className:"py-2 px-5 font-medium text-right",children:"Status"})]})}),t.jsx("tbody",{children:w.map(S=>{var T;return t.jsxs("tr",{className:"border-b border-white/5 opacity-50",children:[t.jsx("td",{className:"py-2.5 px-5 text-white/80",children:Dp(S)}),t.jsxs("td",{className:"py-2.5 px-3 text-white/60",children:[S.org_name||S.org_id,t.jsx("span",{className:"ml-2 font-mono text-xs text-white/40",children:S.org_id.slice(0,8)})]}),t.jsx("td",{className:"py-2.5 px-3 text-white/40",children:((T=S.deactivated_at)==null?void 0:T.slice(0,10))??"—"}),t.jsx("td",{className:"py-2.5 px-5 text-right",children:t.jsx(an,{tone:"danger",children:"Inactive"})})]},S.id)})})]})})})]})]})}
98,M8=()=>t.jsx(jf,{privatePath:!0,children:t.jsx(dT,{children:t.jsx(fD,{children:t.jsx(Zv,{})})})}),B8=()=>{const{user:e}=ht(n=>n.auth);return e?t.jsx(Pn,{to:mh(e,"/documents"),replace:!0}):t.jsx(HR,{})},ot=({children:e})=>{var o;const{user:n,inProgress:s}=ht(l=>l.auth),a=((o=n==null?void 0:n.user)==null?void 0:o.has_tier2)??(n==null?void 0:n.has_tier2)??!1;return s?t.jsx(js,{}):a?t.jsx(t.Fragment,{children:e}):t.jsx(Pn,{to:"/dashboard",replace:!0})},U8=()=>{const{getUser:e}=X1(!0);return t.jsx(nT,{children:t.jsxs(h_,{children:[t.jsx(ye,{path:"/",element:t.jsx(B8,{})}),t.jsx(ye,{path:"/pricing",element:t.jsx(hR,{})}),t.jsx(ye,{path:"/login",element:t.jsx(jf,{children:t.jsx(fT,{getUser:e})})}),t.jsx(ye,{path:"/register",element:t.jsx(jf,{children:t.jsx(NT,{})})}),t.jsx(ye,{path:"/check-email",element:t.jsx(_T,{})}),t.jsx(ye,{path:"/verify-email",element:t.jsx(kT,{})}),t.jsx(ye,{path:"/forgot-password",element:t.jsx(ST,{})}),t.jsx(ye,{path:"/reset-password",element:t.jsx(ET,{})}),t.jsx(ye,{path:"/staff-invite/accept",element:t.jsx(TT,{})}),t.jsx(ye,{path:"/invite/accept",element:t.jsx(RT,{})}),t.jsx(ye,{path:"/privacy-policy",element:t.jsx(xR,{})}),t.jsx(ye,{path:"/terms-of-service",element:t.jsx(gR,{})}),t.jsx(ye,{path:"/faq",element:t.jsx(gD,{})}),t.jsxs(ye,{element:t.jsx(M8,{}),children:[t.jsx(ye,{path:"/dashboard",element:t.jsx(WT,{})}),t.jsx(ye,{path:"/documents",element:t.jsx(tL,{})}),t.jsx(ye,{path:"/workbook",element:t.jsx(aL,{})}),t.jsx(ye,{path:"/reports",element:t.jsx(dL,{})}),t.jsx(ye,{path:"/settings",element:t.jsx(rR,{})}),t.jsx(ye,{path:"/accounting/dashboard",element:t.jsx(ot,{children:t.jsx(pP,{})})}),t.jsx(ye,{path:"/accounting/ledger",element:t.jsx(ot,{children:t.jsx(MP,{})})}),t.jsx(ye,{path:"/accounting/clients",element:t.jsx(ot,{children:t.jsx(i7,{})})}),t.jsx(ye,{path:"/accounting/suppliers",element:t.jsx(ot,{children:t.jsx(l7,{})})}),t.jsx(ye,{path:"/accounting/invoices",element:t.jsx(ot,{children:t.jsx(D7,{})})}),t.jsx(ye,{path:"/accounting/invoices/new",element:t.jsx(ot,{children:t.jsx(dv,{})})}),t.jsx(ye,{path:"/accounting/invoices/:id/edit",element:t.jsx(ot,{children:t.jsx(dv,{})})}),t.jsx(ye,{path:"/accounting/invoices/:id",element:t.jsx(ot,{children:t.jsx(B7,{})})}),t.jsx(ye,{path:"/accounting/reports",element:t.jsx(ot,{children:t.jsx(iF,{})})}),t.jsx(ye,{path:"/accounting/reports/account/:code",element:t.jsx(ot,{children:t.jsx(yF,{})})}),t.jsx(ye,{path:"/accounting/taxes",element:t.jsx(ot,{children:t.jsx(NF,{})})}),t.jsx(ye,{path:"/accounting/tax-profile",element:t.jsx(ot,{children:t.jsx(eD,{})})}),t.jsx(ye,{path:"/accounting/business-identity",element:t.jsx(Pn,{to:"/settings",replace:!0})}),t.jsx(ye,{path:"/accounting/bank-connections",element:t.jsx(ot,{children:t.jsx(gI,{})})}),t.jsx(ye,{path:"/accounting/documents",element:t.jsx(ot,{children:t.jsx($I,{})})}),t.jsx(ye,{path:"/accounting/cards",element:t.jsx(ot,{children:t.jsx(QI,{})})}),t.jsx(ye,{path:"/accountant/ledger",element:t.jsx(ot,{children:t.jsx(FF,{})})}),t.jsx(ye,{path:"/accountant/adjustments/new",element:t.jsx(ot,{children:t.jsx(OF,{})})}),t.jsx(ye,{path:"/accountant/reports",element:t.jsx(ot,{children:t.jsx(VF,{})})}),t.jsx(ye,{path:"/accountant/close",element:t.jsx(ot,{children:t.jsx(JF,{})})}),t.jsx(ye,{path:"/onboarding",element:t.jsx(ot,{children:t.jsx(mD,{})})}),t.jsx(ye,{path:"/plaid/oauth-callback",element:t.jsx(XF,{})}),t.jsx(ye,{path:"/support",element:t.jsx(aR,{})}),t.jsx(ye,{path:"/feedback",element:t.jsx(lR,{})}),t.jsx(ye,{path:"/subscription",element:t.jsx(uR,{})}),t.jsx(ye,{path:"/subscription/success",element:t.jsx(dR,{})}),t.jsx(ye,{path:"/accounting/subscription",element:t.jsx(aD,{})}),t.jsx(ye,{path:"/accounting/subscription/success",element:t.jsx(lD,{})}),t.jsx(ye,{path:"/reviewer",element:t.jsx(CR,{})}),t.jsx(ye,{path:"/accounts",element:t.jsx(Pn,{to:"/settings?tab=chart",replace:!0})}),t.jsx(ye,{path:"/reviewer-management",element:t.jsx(Pn,{to:"/internal/staff",replace:!0})}),t.jsx(ye,{path:"/accounting-review",element:t.jsx(Pn,{to:"/internal/queue",replace:!0})})]}),t.jsx(ye,{path:"/internal",element:t.jsx(Pn,{to:"/internal/queue",replace:!0})}),t.jsxs(ye,{element:t.jsx(kD,{}),children:[t.jsx(ye,{path:"/internal/queue",element:t.jsx(Na,{children:t.jsx(d8,{})})}),t.jsx(ye,{path:"/internal/clients",element:t.jsx(Na,{children:t.jsx(u8,{})})}),t.jsx(ye,{path:"/internal/clients/:orgId/entries",element:t.jsx(Na,{children:t.jsx(p8,{})})}),t.jsx(ye,{path:"/internal/clients/:orgId/cards",element:t.jsx(Na,{children:t.jsx(_8,{})})}),t.jsx(ye,{path:"/internal/clients/:orgId/reports",element:t.jsx(Na,{children:t.jsx(S8,{})})}),t.jsx(ye,{path:"/internal/clients/:orgId/reports/account/:code",element:t.jsx(Na,{children:t.jsx(E8,{})})}),t.jsx(ye,{path:"/internal/staff",element:t.jsx(Ev,{children:t.jsx(O8,{})})}),t.jsx(ye,{path:"/internal/assignments",element:t.jsx(Ev,{children:t.jsx($8,{})})})]}),t.jsx(ye,{path:"*",element:t.jsx(yD,{})})]})})};aE({dsn:"",environment:"development",tracesSampleRate:.1,enabled:!1});const Op=document.getElementById("root"),Mv=t.jsx(Uv.StrictMode,{children:t.jsx(H_,{store:l6,children:t.jsx(__,{children:t.jsx(U8,{})})})});Op.hasChildNodes()?T0.hydrateRoot(Op,Mv):T0.createRoot(Op).render(Mv);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.