ownledger 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +45 -0
- package/CHANGELOG.md +21 -0
- package/README.md +13 -0
- package/assets/index.html +11 -11
- package/assets/static/{Account-DEBzshne.js → Account-sw3qGLbB.js} +1 -1
- package/assets/static/{Accounts-C1iNsQsy.js → Accounts-DWyzX3qB.js} +1 -1
- package/assets/static/{Attention-qo4v70P1.js → Attention-DxV-4qdY.js} +1 -1
- package/assets/static/{ByCategory-33P2zSs-.js → ByCategory-B4P3ikmE.js} +1 -1
- package/assets/static/CardDetail-CayBXBm-.js +1 -0
- package/assets/static/{Cards-C3AdusmT.js → Cards-CVuOP8Bt.js} +1 -1
- package/assets/static/{Cards-DuqZFxkQ.js → Cards-XUBdWxyo.js} +1 -1
- package/assets/static/{CardsValue-BM9WUQmy.js → CardsValue-EoW2jG_0.js} +1 -1
- package/assets/static/{Cashback-DsWyjgRr.js → Cashback-BibVYHf_.js} +1 -1
- package/assets/static/{CategoryIcon-E6EWIpbr.js → CategoryIcon-HfjYhH1l.js} +1 -1
- package/assets/static/{CategoryPicker-BPeJNSuM.js → CategoryPicker-BkmvzX2I.js} +1 -1
- package/assets/static/{ChartWidget-Bk1TAvJM.js → ChartWidget-u09-whUU.js} +1 -1
- package/assets/static/{Combobox-lRNTmjKR.js → Combobox-xXeyjGgK.js} +1 -1
- package/assets/static/{Deposits-CgEFypxb.js → Deposits-CLAda4dj.js} +1 -1
- package/assets/static/{DrillLink-pa6s17Xu.js → DrillLink-Bvfam9FA.js} +1 -1
- package/assets/static/{Field-OkPhoYM1.js → Field-tKFmKDEF.js} +1 -1
- package/assets/static/{HomeEditor-DdrzEPe2.js → HomeEditor-4vxj5LMD.js} +1 -1
- package/assets/static/{Import-DrhHmL65.js → Import-DwaaFpRJ.js} +1 -1
- package/assets/static/{IncomeSpending-Cveqr3xt.js → IncomeSpending-RVDSxAK4.js} +1 -1
- package/assets/static/{KV-CKGyL0p7.js → KV-DMA1AlP-.js} +1 -1
- package/assets/static/{Left-Bs_oKU19.js → Left-C_4gTGSX.js} +1 -1
- package/assets/static/{Money-DCMKf898.js → Money-PfFNNDOw.js} +1 -1
- package/assets/static/{NetWorth-Cjd13J56.js → NetWorth-BSoseczC.js} +1 -1
- package/assets/static/{Pace-CBUDNxzH.js → Pace-B8p-9174.js} +1 -1
- package/assets/static/{Panel-CXjnsEN0.js → Panel-BnfWrw9R.js} +1 -1
- package/assets/static/{PinDialog-DoGuAyi4.js → PinDialog-BqAU9Vh4.js} +1 -1
- package/assets/static/{Plans-EWJdPCJ3.js → Plans-2KuQH2_I.js} +1 -1
- package/assets/static/{Recent-BmJjA5dK.js → Recent-Ccmb34bq.js} +1 -1
- package/assets/static/{Reports-DSrLn_wC.js → Reports-Dd-dhclr.js} +1 -1
- package/assets/static/{Settings-DdiEp2Qi.js → Settings-BR8WBlen.js} +1 -1
- package/assets/static/{Transactions-Cy0kgcLE.js → Transactions-BAuQ-6Eb.js} +1 -1
- package/assets/static/{TxRow-IqjFXpya.js → TxRow-EKIIMQKa.js} +1 -1
- package/assets/static/{Unusual-D5-L9ZOy.js → Unusual-CwFp8aA5.js} +1 -1
- package/assets/static/{Upcoming-CCqPol8c.js → Upcoming-B28roT9r.js} +1 -1
- package/assets/static/{WhichCard-Butdi7AN.js → WhichCard-B3kLc842.js} +1 -1
- package/assets/static/{arrow-up-C8D_7x_H.js → arrow-up-D3gxUKLo.js} +1 -1
- package/assets/static/{bits-BoWPOwTB.js → bits-Dr2E0ObC.js} +1 -1
- package/assets/static/{button-Cj0k8AtB.js → button-rfwMVz0i.js} +1 -1
- package/assets/static/{cards-AZlSJQ0z.js → cards-Bb5zjzRG.js} +1 -1
- package/assets/static/{charts-Cj_hTR4h.js → charts-BqP7HKwP.js} +1 -1
- package/assets/static/chevron-down-Co1w7ApZ.js +1 -0
- package/assets/static/chevron-right-Dqh3vs9Y.js +1 -0
- package/assets/static/{createLucideIcon-DUW9Fpzj.js → createLucideIcon-flJrJK2p.js} +1 -1
- package/assets/static/{dialog-BIbLA-XP.js → dialog-BuRqO4sc.js} +1 -1
- package/assets/static/{dist-CbNfxqbd.js → dist-B4_eGtNj.js} +1 -1
- package/assets/static/{dist-DYP_TYPy.js → dist-B7PR2b0C.js} +1 -1
- package/assets/static/{dist-CetESl7K.js → dist-BDn7ydjn.js} +1 -1
- package/assets/static/{dist-DaSyQKU7.js → dist-Dl-m8cc2.js} +1 -1
- package/assets/static/{es2015-BgAh-EkH.js → es2015-DJh4h8NX.js} +1 -1
- package/assets/static/{index-DYyIpxqK.js → index-eR1GkdC_.js} +4 -4
- package/assets/static/index-iYMxgw-7.css +1 -0
- package/assets/static/{queries-C_4ufx4u.js → queries-DZIMMe4i.js} +1 -1
- package/assets/static/{react-dom-CI34djkT.js → react-dom-wK_7mEjs.js} +1 -1
- package/assets/static/{select-2EwEpMf_.js → select-eaSi9K-d.js} +1 -1
- package/assets/static/{shared-CR-hvb-r.js → shared-Box7on3B.js} +1 -1
- package/assets/static/{triangle-exclamation-point-C6padEUM.js → triangle-exclamation-point-CuL0XSJl.js} +1 -1
- package/assets/static/{useMutation-BWtHiYPX.js → useMutation-_Lw8xXWa.js} +1 -1
- package/dist/cli/check.js +7 -1
- package/dist/cli/dev.js +22 -2
- package/dist/cli/index.js +3 -0
- package/dist/cli/statements.d.ts +1 -0
- package/dist/cli/statements.js +231 -0
- package/dist/modules/api.d.ts +3 -0
- package/dist/modules/cards/api.d.ts +1 -1
- package/dist/modules/cards/api.js +34 -2
- package/dist/modules/cards/files.d.ts +11 -0
- package/dist/modules/cards/files.js +17 -0
- package/dist/node/statements.d.ts +64 -0
- package/dist/node/statements.js +218 -0
- package/dist/worker/api.js +2 -0
- package/dist/worker/github.d.ts +3 -1
- package/dist/worker/github.js +13 -2
- package/dist/worker/store.d.ts +2 -0
- package/dist/worker/store.js +7 -2
- package/dist/worker/tar.d.ts +2 -1
- package/dist/worker/tar.js +4 -1
- package/dist/worker/version.d.ts +1 -1
- package/dist/worker/version.js +1 -1
- package/package.json +3 -1
- package/assets/static/CardDetail-CvRo7JPt.js +0 -1
- package/assets/static/chevron-down-BLodeu9a.js +0 -1
- package/assets/static/chevron-right-BetctQ6k.js +0 -1
- package/assets/static/index-CBsgYTMJ.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,R as t}from"./queries-
|
|
1
|
+
import{I as e,R as t}from"./queries-DZIMMe4i.js";var n=t((t=>{var n=e();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,t.browser=function(e){return{$$typeof:s,_reason:e}},t.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return l(e,t,null,n)},t.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},t.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},t.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},t.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},t.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},t.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},t.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},t.requestFormReset=function(e){a.d.r(e)},t.unstable_batchedUpdates=function(e,t){return e(t)},t.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},t.useFormStatus=function(){return u.H.useHostTransitionStatus()},t.version=`19.3.1`})),r=t(((e,t)=>{function r(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}r(),t.exports=n()}));export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,T as r}from"./queries-C_4ufx4u.js";import{t as i}from"./react-dom-CI34djkT.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CetESl7K.js";import{n as f,t as p}from"./dist-DaSyQKU7.js";import{i as m,s as h}from"./button-Cj0k8AtB.js";import{a as g,i as _,l as v,n as y,r as b,t as x}from"./es2015-BgAh-EkH.js";import{_t as S,at as C,ct as w,ot as T,st as E,tt as D}from"./index-DYyIpxqK.js";import{t as O}from"./dist-DYP_TYPy.js";import{t as k}from"./chevron-down-BLodeu9a.js";import{t as A}from"./createLucideIcon-DUW9Fpzj.js";var j=e(t(),1),M=e(i(),1),N=Object.defineProperty,P=(e,t)=>N(e,`name`,{value:t,configurable:!0});function F(e,[t,n]){return Math.min(n,Math.max(t,e))}P(F,`clamp`);var I=n(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),ee={ItemAligned:`item-aligned`,Popper:`popper`},z={LTR:`ltr`,RTL:`rtl`},te=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=f(V),[G,K]=c(V,[W,w]),q=w(),[ne,J]=G(V),[re,Y]=G(V);function ie(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:d,name:f,autoComplete:m,disabled:h,required:g,form:_,internal_do_not_use_render:v}=e,y=q(t),[b,x]=j.useState(null),[S,w]=j.useState(null),[T,E]=j.useState(!1),D=p(d),[O,k]=l({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,M]=l({prop:o,defaultProp:c,onChange:u,caller:V}),N=j.useRef(null),P=j.useRef(!1),[F,L]=j.useState(null),ee=R(e=>{L({value:e,hasConsumerStoppedPropagation:P.current}),M(e)},`handleUserSelect`),z=j.useRef(A);j.useEffect(()=>{let e=_?b?.ownerDocument.getElementById(_):b?.form;if(e instanceof HTMLFormElement){let t=R(()=>M(z.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[_,b,M]);let te=!b||!!_||!!b.closest(`form`),[B,U]=j.useState(new Set),W=s(),G=Array.from(B).map(e=>e.props.value).join(`;`),K=j.useCallback(e=>{U(t=>new Set(t).add(e))},[]),J=j.useCallback(e=>{U(t=>{let n=new Set(t);return n.delete(e),n})},[]),Y={required:g,trigger:b,onTriggerChange:x,valueNode:S,onValueNodeChange:w,valueNodeHasChildren:T,onValueNodeHasChildrenChange:E,contentId:W,value:A,onValueChange:M,hasConsumerStoppedPropagationRef:P,userSelection:F,onUserSelect:ee,open:O,onOpenChange:k,dir:D,triggerPointerDownPosRef:N,disabled:h,name:f,autoComplete:m,form:_,nativeOptions:B,nativeSelectKey:G,isFormControl:te};return(0,I.jsx)(C,{...y,children:(0,I.jsx)(ne,{scope:t,...Y,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:K,onNativeOptionRemove:J,children:He(v)?v(Y):n})})})})}R(ie,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(ie,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Ve,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=j.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=q(n),s=J(oe,n),c=s.disabled||r,l=h(t,s.onTriggerChange),d=U(n),f=j.useRef(`touch`),[p,m,g]=Ue(e=>{let t=d().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onUserSelect(n.value)}),_=R(e=>{c||(s.onOpenChange(!0),g()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(T,{asChild:!0,...a,children:(0,I.jsx)(u.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...i,ref:l,onClick:o(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&_(e)}),onPointerDown:o(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:o(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),m(e.key)),t&&e.key===` `||te.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:o,placeholder:s=``,...c}=e,l=J(ce,n),{onValueNodeHasChildrenChange:d}=l,f=o!==void 0,p=h(t,l.onValueNodeChange);a(()=>{d(f)},[d,f]);let m=$(l.value);return(0,I.jsx)(u.span,{...c,asChild:!m&&c.asChild,ref:p,style:{pointerEvents:`none`},children:(0,I.jsx)(j.Fragment,{children:m?s:o},m?`placeholder`:`value`)})},`SelectValue`)),ue=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(u.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(_,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,me=j.forwardRef(R(function(e,t){let n=fe(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,o=J(X,e.__scopeSelect),[s,c]=j.useState();return a(()=>{c(new DocumentFragment)},[]),(0,I.jsx)(O,{present:r||o.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:s})})},`SelectContent`)),he=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[ge,Q]=G(X),_e=m(`SelectContent.RemoveScroll`),ve=j.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=ee.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=J(X,n),[E,D]=j.useState(null),[O,k]=j.useState(null),A=h(t,D),[M,N]=j.useState(null),[P,F]=j.useState(null),L=U(n),[z,te]=j.useState(!1),B=j.useRef(!1),V=j.useRef(!1),H=j.useRef(!1);j.useEffect(()=>{if(E)return x(E)},[E]),b();let W=j.useCallback(e=>{let[t,...n]=L().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[L,O]),G=j.useCallback(()=>W([M,E]),[W,M,E]);j.useEffect(()=>{z&&G()},[z,G]);let{onOpenChange:K,triggerPointerDownPosRef:q}=T;j.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||K(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,K,q]),j.useEffect(()=>{let e=R(()=>K(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[K]);let[ne,re]=Ue(e=>{let t=L().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),Y=j.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!B.current&&!n;T.value!==void 0&&T.value===t||i?(N(e),i&&(B.current=!0)):r&&N(e)},[T.value]),ie=j.useCallback(()=>E?.focus(),[E]),ae=j.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!B.current&&!n;(T.value!==void 0&&T.value===t||i||r)&&F(e)},[T.value]),oe=r===ee.Popper?be:ye,se=oe===be?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:Y,selectedItem:M,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:G,selectedItemText:P,position:r,isPositioned:z,searchRef:ne,children:(0,I.jsx)(y,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(g,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:o(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(oe,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...se,onPlaced:()=>te(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:o(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=L().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>W(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,o=J(X,n),s=Q(X,n),[c,l]=j.useState(null),[d,f]=j.useState(null),p=h(t,f),m=U(n),g=j.useRef(!1),_=j.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=j.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&d&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(o.dir!==z.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let a=m(),s=window.innerHeight-Z*2,l=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),h=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+l+_+h,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,D=s-E,O=y.offsetHeight/2,k=y.offsetTop+O,A=f+p+k,j=x-A;if(A<=E){let e=a.length>0&&y===a[a.length-1].ref.current;c.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+h);c.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+v.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,v.scrollTop=A-E+v.offsetTop}c.style.margin=`${Z}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[m,o.trigger,o.valueNode,c,d,v,y,b,o.dir,r]);a(()=>S(),[S]);let[C,w]=j.useState();a(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let T=j.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,I.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(u.div,{...i,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=j.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=q(n);return(0,I.jsx)(E,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(X,{}),Ce=`SelectViewport`,we=j.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(Ce,n),s=Se(Ce,n),c=h(t,a.onViewportChange),l=j.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(u.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:o(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=j.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...c}=e,l=J(De,n),f=Q(De,n),p=l.value===r,[m,g]=j.useState(a??``),[_,v]=j.useState(!1),y=d(e=>f.itemRefCallback?.(e,r,i)),b=h(t,y),x=s(),S=j.useRef(`touch`);function C(e){l.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),l.onUserSelect(r),l.onOpenChange(!1)}return R(C,`handleSelect`),(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:x,isSelected:p,onItemTextChange:j.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:m,children:(0,I.jsx)(u.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":p&&_,"data-state":p?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:b,onFocus:o(c.onFocus,()=>v(!0)),onBlur:o(c.onBlur,()=>v(!1)),onClick:o(c.onClick,e=>{i||S.current!==`mouse`&&C(e)}),onPointerUp:o(c.onPointerUp,e=>{i||S.current===`mouse`&&C(e)}),onPointerDown:o(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:o(c.onPointerMove,e=>{S.current=e.pointerType,i?f.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:o(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:o(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(f.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),je=`SelectItemText`,Me=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...o}=e,s=J(je,n),c=Q(je,n),l=ke(je,n),f=Y(je,n),[p,m]=j.useState(null),g=d(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),_=h(t,m,l.onItemTextChange,g),v=p?.textContent,y=j.useMemo(()=>(0,I.jsx)(`option`,{value:l.value,disabled:l.disabled,children:v},l.value),[l.disabled,l.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=f;return a(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u.span,{id:l.textId,...o,ref:_}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren&&!$(s.value)?M.createPortal(o.children,s.valueNode):null]})},`SelectItemText`)),Ne=`SelectItemIndicator`,Pe=j.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Ne,n).isSelected?(0,I.jsx)(u.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Fe=`SelectScrollUpButton`,Ie=j.forwardRef(R(function(e,t){let n=Q(Fe,e.__scopeSelect),r=Se(Fe,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Le=`SelectScrollDownButton`,Re=j.forwardRef(R(function(e,t){let n=Q(Le,e.__scopeSelect),r=Se(Le,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),ze=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,s=Q(`SelectScrollButton`,n),c=j.useRef(null),l=U(n),d=j.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return j.useEffect(()=>()=>d(),[d]),a(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,I.jsx)(u.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:o(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(r,50))}),onPointerMove:o(i.onPointerMove,()=>{s.onItemLeave?.(),c.current===null&&(c.current=window.setInterval(r,50))}),onPointerLeave:o(i.onPointerLeave,()=>{d()})})},`SelectScrollButtonImpl`)),Be=`SelectBubbleInput`,Ve=j.forwardRef(R(function({__scopeSelect:e,...t},n){let r=J(Be,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d,userSelection:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,g=j.useRef(null),_=h(n,g),v=i??``,y=j.useRef(v),b=j.useRef(f),x=j.useRef(!1),C=Array.from(p).some(e=>(e.props.value??``)===``);return j.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=f!==null&&f!==b.current;b.current=f;let i=y.current!==v;y.current=v;let a=r&&i;if(r&&!i&&f.value!==v&&!f.hasConsumerStoppedPropagation&&n){x.current=!0;try{n.call(e,f.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{x.current=!1,n.call(e,v)}return}let o=a&&!f.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,v),e.dispatchEvent(t)}},[v,f]),(0,I.jsxs)(u.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>{x.current||a(e.target.value)},...t,style:{...S,...t.style},ref:_,defaultValue:v,children:[$(i)&&!C?(0,I.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function He(e){return typeof e==`function`}R(He,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function Ue(e){let t=d(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}R(a,`updateSearch`),a(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(Ue,`useTypeaheadSearch`);function We(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ge(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(We,`findNextItem`);function Ge(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(Ge,`wrapArray`);var Ke={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};Ke.node;var qe=A(Ke);function Je({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ye({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function Xe({className:e,size:t=`default`,children:n,...i}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:r(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(k,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Ze({className:e,children:t,position:n=`item-aligned`,align:i=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:r(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:i,...a,children:[(0,I.jsx)($e,{}),(0,I.jsx)(we,{"data-position":n,className:r(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(et,{})]})})}function Qe({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:r(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(Pe,{children:(0,I.jsx)(D,{className:`pointer-events-none`})})}),(0,I.jsx)(Me,{children:t})]})}function $e({className:e,...t}){return(0,I.jsx)(Ie,{"data-slot":`select-scroll-up-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(qe,{})})}function et({className:e,...t}){return(0,I.jsx)(Re,{"data-slot":`select-scroll-down-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(k,{})})}export{Ye as a,Xe as i,Ze as n,Qe as r,Je as t};
|
|
1
|
+
import{B as e,I as t,L as n,T as r}from"./queries-DZIMMe4i.js";import{t as i}from"./react-dom-wK_7mEjs.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-BDn7ydjn.js";import{n as f,t as p}from"./dist-Dl-m8cc2.js";import{i as m,s as h}from"./button-rfwMVz0i.js";import{a as g,i as _,l as v,n as y,r as b,t as x}from"./es2015-DJh4h8NX.js";import{_t as S,at as C,ct as w,ot as T,st as E,tt as D}from"./index-eR1GkdC_.js";import{t as O}from"./dist-B7PR2b0C.js";import{t as k}from"./chevron-down-Co1w7ApZ.js";import{t as A}from"./createLucideIcon-flJrJK2p.js";var j=e(t(),1),M=e(i(),1),N=Object.defineProperty,P=(e,t)=>N(e,`name`,{value:t,configurable:!0});function F(e,[t,n]){return Math.min(n,Math.max(t,e))}P(F,`clamp`);var I=n(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),ee={ItemAligned:`item-aligned`,Popper:`popper`},z={LTR:`ltr`,RTL:`rtl`},te=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=f(V),[G,K]=c(V,[W,w]),q=w(),[ne,J]=G(V),[re,Y]=G(V);function ie(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:d,name:f,autoComplete:m,disabled:h,required:g,form:_,internal_do_not_use_render:v}=e,y=q(t),[b,x]=j.useState(null),[S,w]=j.useState(null),[T,E]=j.useState(!1),D=p(d),[O,k]=l({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,M]=l({prop:o,defaultProp:c,onChange:u,caller:V}),N=j.useRef(null),P=j.useRef(!1),[F,L]=j.useState(null),ee=R(e=>{L({value:e,hasConsumerStoppedPropagation:P.current}),M(e)},`handleUserSelect`),z=j.useRef(A);j.useEffect(()=>{let e=_?b?.ownerDocument.getElementById(_):b?.form;if(e instanceof HTMLFormElement){let t=R(()=>M(z.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[_,b,M]);let te=!b||!!_||!!b.closest(`form`),[B,U]=j.useState(new Set),W=s(),G=Array.from(B).map(e=>e.props.value).join(`;`),K=j.useCallback(e=>{U(t=>new Set(t).add(e))},[]),J=j.useCallback(e=>{U(t=>{let n=new Set(t);return n.delete(e),n})},[]),Y={required:g,trigger:b,onTriggerChange:x,valueNode:S,onValueNodeChange:w,valueNodeHasChildren:T,onValueNodeHasChildrenChange:E,contentId:W,value:A,onValueChange:M,hasConsumerStoppedPropagationRef:P,userSelection:F,onUserSelect:ee,open:O,onOpenChange:k,dir:D,triggerPointerDownPosRef:N,disabled:h,name:f,autoComplete:m,form:_,nativeOptions:B,nativeSelectKey:G,isFormControl:te};return(0,I.jsx)(C,{...y,children:(0,I.jsx)(ne,{scope:t,...Y,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:K,onNativeOptionRemove:J,children:He(v)?v(Y):n})})})})}R(ie,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(ie,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Ve,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=j.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=q(n),s=J(oe,n),c=s.disabled||r,l=h(t,s.onTriggerChange),d=U(n),f=j.useRef(`touch`),[p,m,g]=Ue(e=>{let t=d().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onUserSelect(n.value)}),_=R(e=>{c||(s.onOpenChange(!0),g()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(T,{asChild:!0,...a,children:(0,I.jsx)(u.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...i,ref:l,onClick:o(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&_(e)}),onPointerDown:o(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:o(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),m(e.key)),t&&e.key===` `||te.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:o,placeholder:s=``,...c}=e,l=J(ce,n),{onValueNodeHasChildrenChange:d}=l,f=o!==void 0,p=h(t,l.onValueNodeChange);a(()=>{d(f)},[d,f]);let m=$(l.value);return(0,I.jsx)(u.span,{...c,asChild:!m&&c.asChild,ref:p,style:{pointerEvents:`none`},children:(0,I.jsx)(j.Fragment,{children:m?s:o},m?`placeholder`:`value`)})},`SelectValue`)),ue=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(u.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(_,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,me=j.forwardRef(R(function(e,t){let n=fe(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,o=J(X,e.__scopeSelect),[s,c]=j.useState();return a(()=>{c(new DocumentFragment)},[]),(0,I.jsx)(O,{present:r||o.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:s})})},`SelectContent`)),he=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[ge,Q]=G(X),_e=m(`SelectContent.RemoveScroll`),ve=j.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=ee.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=J(X,n),[E,D]=j.useState(null),[O,k]=j.useState(null),A=h(t,D),[M,N]=j.useState(null),[P,F]=j.useState(null),L=U(n),[z,te]=j.useState(!1),B=j.useRef(!1),V=j.useRef(!1),H=j.useRef(!1);j.useEffect(()=>{if(E)return x(E)},[E]),b();let W=j.useCallback(e=>{let[t,...n]=L().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[L,O]),G=j.useCallback(()=>W([M,E]),[W,M,E]);j.useEffect(()=>{z&&G()},[z,G]);let{onOpenChange:K,triggerPointerDownPosRef:q}=T;j.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||K(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,K,q]),j.useEffect(()=>{let e=R(()=>K(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[K]);let[ne,re]=Ue(e=>{let t=L().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),Y=j.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!B.current&&!n;T.value!==void 0&&T.value===t||i?(N(e),i&&(B.current=!0)):r&&N(e)},[T.value]),ie=j.useCallback(()=>E?.focus(),[E]),ae=j.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!B.current&&!n;(T.value!==void 0&&T.value===t||i||r)&&F(e)},[T.value]),oe=r===ee.Popper?be:ye,se=oe===be?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:Y,selectedItem:M,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:G,selectedItemText:P,position:r,isPositioned:z,searchRef:ne,children:(0,I.jsx)(y,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(g,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:o(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(oe,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...se,onPlaced:()=>te(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:o(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=L().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>W(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,o=J(X,n),s=Q(X,n),[c,l]=j.useState(null),[d,f]=j.useState(null),p=h(t,f),m=U(n),g=j.useRef(!1),_=j.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=j.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&d&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(o.dir!==z.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let a=m(),s=window.innerHeight-Z*2,l=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),h=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+l+_+h,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,D=s-E,O=y.offsetHeight/2,k=y.offsetTop+O,A=f+p+k,j=x-A;if(A<=E){let e=a.length>0&&y===a[a.length-1].ref.current;c.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+h);c.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+v.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,v.scrollTop=A-E+v.offsetTop}c.style.margin=`${Z}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[m,o.trigger,o.valueNode,c,d,v,y,b,o.dir,r]);a(()=>S(),[S]);let[C,w]=j.useState();a(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let T=j.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,I.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(u.div,{...i,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=j.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=q(n);return(0,I.jsx)(E,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(X,{}),Ce=`SelectViewport`,we=j.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(Ce,n),s=Se(Ce,n),c=h(t,a.onViewportChange),l=j.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(u.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:o(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=j.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...c}=e,l=J(De,n),f=Q(De,n),p=l.value===r,[m,g]=j.useState(a??``),[_,v]=j.useState(!1),y=d(e=>f.itemRefCallback?.(e,r,i)),b=h(t,y),x=s(),S=j.useRef(`touch`);function C(e){l.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),l.onUserSelect(r),l.onOpenChange(!1)}return R(C,`handleSelect`),(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:x,isSelected:p,onItemTextChange:j.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:m,children:(0,I.jsx)(u.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":p&&_,"data-state":p?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:b,onFocus:o(c.onFocus,()=>v(!0)),onBlur:o(c.onBlur,()=>v(!1)),onClick:o(c.onClick,e=>{i||S.current!==`mouse`&&C(e)}),onPointerUp:o(c.onPointerUp,e=>{i||S.current===`mouse`&&C(e)}),onPointerDown:o(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:o(c.onPointerMove,e=>{S.current=e.pointerType,i?f.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:o(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:o(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(f.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),je=`SelectItemText`,Me=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...o}=e,s=J(je,n),c=Q(je,n),l=ke(je,n),f=Y(je,n),[p,m]=j.useState(null),g=d(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),_=h(t,m,l.onItemTextChange,g),v=p?.textContent,y=j.useMemo(()=>(0,I.jsx)(`option`,{value:l.value,disabled:l.disabled,children:v},l.value),[l.disabled,l.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=f;return a(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u.span,{id:l.textId,...o,ref:_}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren&&!$(s.value)?M.createPortal(o.children,s.valueNode):null]})},`SelectItemText`)),Ne=`SelectItemIndicator`,Pe=j.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Ne,n).isSelected?(0,I.jsx)(u.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Fe=`SelectScrollUpButton`,Ie=j.forwardRef(R(function(e,t){let n=Q(Fe,e.__scopeSelect),r=Se(Fe,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Le=`SelectScrollDownButton`,Re=j.forwardRef(R(function(e,t){let n=Q(Le,e.__scopeSelect),r=Se(Le,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),ze=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,s=Q(`SelectScrollButton`,n),c=j.useRef(null),l=U(n),d=j.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return j.useEffect(()=>()=>d(),[d]),a(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,I.jsx)(u.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:o(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(r,50))}),onPointerMove:o(i.onPointerMove,()=>{s.onItemLeave?.(),c.current===null&&(c.current=window.setInterval(r,50))}),onPointerLeave:o(i.onPointerLeave,()=>{d()})})},`SelectScrollButtonImpl`)),Be=`SelectBubbleInput`,Ve=j.forwardRef(R(function({__scopeSelect:e,...t},n){let r=J(Be,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d,userSelection:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,g=j.useRef(null),_=h(n,g),v=i??``,y=j.useRef(v),b=j.useRef(f),x=j.useRef(!1),C=Array.from(p).some(e=>(e.props.value??``)===``);return j.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=f!==null&&f!==b.current;b.current=f;let i=y.current!==v;y.current=v;let a=r&&i;if(r&&!i&&f.value!==v&&!f.hasConsumerStoppedPropagation&&n){x.current=!0;try{n.call(e,f.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{x.current=!1,n.call(e,v)}return}let o=a&&!f.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,v),e.dispatchEvent(t)}},[v,f]),(0,I.jsxs)(u.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>{x.current||a(e.target.value)},...t,style:{...S,...t.style},ref:_,defaultValue:v,children:[$(i)&&!C?(0,I.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function He(e){return typeof e==`function`}R(He,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function Ue(e){let t=d(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}R(a,`updateSearch`),a(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(Ue,`useTypeaheadSearch`);function We(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ge(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(We,`findNextItem`);function Ge(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(Ge,`wrapArray`);var Ke={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};Ke.node;var qe=A(Ke);function Je({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ye({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function Xe({className:e,size:t=`default`,children:n,...i}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:r(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(k,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Ze({className:e,children:t,position:n=`item-aligned`,align:i=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:r(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:i,...a,children:[(0,I.jsx)($e,{}),(0,I.jsx)(we,{"data-position":n,className:r(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(et,{})]})})}function Qe({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:r(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(Pe,{children:(0,I.jsx)(D,{className:`pointer-events-none`})})}),(0,I.jsx)(Me,{children:t})]})}function $e({className:e,...t}){return(0,I.jsx)(Ie,{"data-slot":`select-scroll-up-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(qe,{})})}function et({className:e,...t}){return(0,I.jsx)(Re,{"data-slot":`select-scroll-down-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(k,{})})}export{Ye as a,Xe as i,Ze as n,Qe as r,Je as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./arrow-up-
|
|
1
|
+
import{n as e,t}from"./arrow-up-D3gxUKLo.js";import{L as n,T as r,w as i}from"./queries-DZIMMe4i.js";var a=n();function o(e,t){let{t:n}=i();return e.title?.trim()||n(t)}function s({pct:n,goodWhenDown:o=!0,className:s}){let{t:c}=i(),l=n>0,u=l!==o,d=l?t:e;return(0,a.jsxs)(`span`,{className:r(`inline-flex items-center gap-0.5 whitespace-nowrap text-sm font-medium tabular-nums`,n===0?`text-muted-foreground`:u?`text-positive`:`text-critical`,s),children:[n!==0&&(0,a.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),(0,a.jsx)(`span`,{className:`sr-only`,children:l?c(`delta.up`):n<0?c(`delta.down`):``}),Math.abs(Math.round(n)),`%`]})}export{o as n,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-
|
|
1
|
+
import{t as e}from"./createLucideIcon-flJrJK2p.js";var t={name:`triangle-exclamation-point`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`,`triangle-alert`]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,D as n,F as r,I as i,M as a,N as o,O as s,j as c,k as l}from"./queries-
|
|
1
|
+
import{A as e,B as t,D as n,F as r,I as i,M as a,N as o,O as s,j as c,k as l}from"./queries-DZIMMe4i.js";var u=class extends o{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),c(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&l(t.mutationKey)!==l(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??n();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){s.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},d=t(i(),1);function f(t,n){let i=r(n),[o]=d.useState(()=>new u(i,t));d.useEffect(()=>{o.setOptions(t)},[o,t]);let c=d.useSyncExternalStore(d.useCallback(e=>o.subscribe(s.batchCalls(e)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),l=d.useCallback((...t)=>{o.mutate(t[0],t[1]).catch(e)},[o]);if(c.error&&a(o.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:l,mutateAsync:c.mutate}}export{f as t};
|
package/dist/cli/check.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { checkFiles } from "../engine/check.js";
|
|
3
3
|
import { readDataDir } from "../node/files.js";
|
|
4
|
+
import { statementWarnings } from "../node/statements.js";
|
|
4
5
|
export function fmtIssue(i) {
|
|
5
6
|
return `${i.level === "error" ? "✗" : "!"} ${i.file ?? ""}${i.where ? ` [${i.where}]` : ""}: ${i.message}`;
|
|
6
7
|
}
|
|
@@ -13,9 +14,14 @@ export async function cmdCheck(args) {
|
|
|
13
14
|
if (!quiet)
|
|
14
15
|
for (const w of r.warnings)
|
|
15
16
|
console.log(fmtIssue(w));
|
|
17
|
+
const stmtWarnings = await statementWarnings(root, new Set(r.ledger.accounts.map((a) => a.id)));
|
|
18
|
+
if (!quiet)
|
|
19
|
+
for (const w of stmtWarnings)
|
|
20
|
+
console.log(`! ${w}`);
|
|
21
|
+
const warned = r.warnings.length + stmtWarnings.length;
|
|
16
22
|
const live = r.ledger.transactions.filter((t) => !t.void).length;
|
|
17
23
|
console.log(r.ok
|
|
18
|
-
? `✓ ok: ${r.ledger.accounts.length} accounts, ${live} transactions${
|
|
24
|
+
? `✓ ok: ${r.ledger.accounts.length} accounts, ${live} transactions${warned ? `, ${warned} warning(s)` : ""}`
|
|
19
25
|
: `✗ ${r.errors.length} error(s)`);
|
|
20
26
|
return r.ok ? 0 : 1;
|
|
21
27
|
}
|
package/dist/cli/dev.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { execFileSync, spawn } from "node:child_process";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { createServer } from "node:http";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { STATEMENT_PDF_RE, STATEMENTS_DIR } from "../modules/cards/files.js";
|
|
6
7
|
import { readDataDir } from "../node/files.js";
|
|
7
8
|
import { pkgPath } from "../node/scaffold.js";
|
|
8
9
|
import { openwalletFlag } from "./deploy.js";
|
|
@@ -10,7 +11,7 @@ function opt(args, name) {
|
|
|
10
11
|
const i = args.indexOf(name);
|
|
11
12
|
return i >= 0 ? args[i + 1] : undefined;
|
|
12
13
|
}
|
|
13
|
-
/** data/ + imports/*.mapping.yaml, as the Worker would read them from GitHub. */
|
|
14
|
+
/** data/ + imports/*.mapping.yaml, and statement PDFs by path only (""), as the Worker would read them from GitHub. */
|
|
14
15
|
function localFiles(root) {
|
|
15
16
|
const files = readDataDir(root);
|
|
16
17
|
const imp = join(root, "imports");
|
|
@@ -18,6 +19,15 @@ function localFiles(root) {
|
|
|
18
19
|
for (const f of readdirSync(imp))
|
|
19
20
|
if (f.endsWith(".mapping.yaml"))
|
|
20
21
|
files[`imports/${f}`] = readFileSync(join(imp, f), "utf8");
|
|
22
|
+
const st = join(root, STATEMENTS_DIR);
|
|
23
|
+
if (existsSync(st))
|
|
24
|
+
for (const acc of readdirSync(st)) {
|
|
25
|
+
if (!statSync(join(st, acc)).isDirectory())
|
|
26
|
+
continue;
|
|
27
|
+
for (const f of readdirSync(join(st, acc)))
|
|
28
|
+
if (STATEMENT_PDF_RE.test(`${STATEMENTS_DIR}/${acc}/${f}`))
|
|
29
|
+
files[`${STATEMENTS_DIR}/${acc}/${f}`] = "";
|
|
30
|
+
}
|
|
21
31
|
return files;
|
|
22
32
|
}
|
|
23
33
|
function headOf(files) {
|
|
@@ -32,6 +42,16 @@ export function startDataServer(root, port) {
|
|
|
32
42
|
const files = localFiles(root);
|
|
33
43
|
if (req.url === "/head")
|
|
34
44
|
return res.end(headOf(files));
|
|
45
|
+
if (req.url?.startsWith("/blob?")) {
|
|
46
|
+
// statement PDFs only: the path must be one the listing above has
|
|
47
|
+
const path = new URL(req.url, "http://x").searchParams.get("path") ?? "";
|
|
48
|
+
if (!STATEMENT_PDF_RE.test(path) || files[path] === undefined) {
|
|
49
|
+
res.statusCode = 404;
|
|
50
|
+
return res.end();
|
|
51
|
+
}
|
|
52
|
+
res.setHeader("Content-Type", "application/pdf");
|
|
53
|
+
return res.end(readFileSync(join(root, path)));
|
|
54
|
+
}
|
|
35
55
|
if (req.url === "/files") {
|
|
36
56
|
res.setHeader("Content-Type", "application/json");
|
|
37
57
|
return res.end(JSON.stringify(files));
|
package/dist/cli/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { cmdDeploy } from "./deploy.js";
|
|
|
6
6
|
import { cmdDev } from "./dev.js";
|
|
7
7
|
import { cmdImport } from "./import.js";
|
|
8
8
|
import { cmdInit } from "./init.js";
|
|
9
|
+
import { cmdStatements } from "./statements.js";
|
|
9
10
|
const pkg = { version: pkgVersion() };
|
|
10
11
|
const HELP = `ownledger ${pkg.version}
|
|
11
12
|
|
|
@@ -17,6 +18,7 @@ Usage: ownledger <command> [options]
|
|
|
17
18
|
cards load <csv> Load a card tracker (CSV) into data/cards.yaml and the cards' limits (preview; --yes writes)
|
|
18
19
|
deploy Deploy your Worker to your Cloudflare (GitHub App, secrets, KV); prints the connector URL
|
|
19
20
|
--openwallet[=<url>] turns on the OpenWallet card catalog (best_card), --no-openwallet off
|
|
21
|
+
statements add|list|check Bank statement PDFs in imports/statements/ (unlock and file, list months, compare with the ledger)
|
|
20
22
|
dev [dir] Run your Worker locally against the local data/ (fake sign-in); --openwallet[=<url>] as above
|
|
21
23
|
--version Print the version
|
|
22
24
|
`;
|
|
@@ -25,6 +27,7 @@ const commands = {
|
|
|
25
27
|
check: cmdCheck,
|
|
26
28
|
import: cmdImport,
|
|
27
29
|
cards: cmdCards,
|
|
30
|
+
statements: cmdStatements,
|
|
28
31
|
dev: cmdDev,
|
|
29
32
|
deploy: cmdDeploy,
|
|
30
33
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cmdStatements(args: string[]): Promise<number>;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
import { todayIn } from "../engine/dates.js";
|
|
5
|
+
import { loadLedger } from "../engine/load.js";
|
|
6
|
+
import { statements } from "../modules/cards/statements.js";
|
|
7
|
+
import { recordFor, termsOf } from "../modules/cards/terms.js";
|
|
8
|
+
import { readDataDir } from "../node/files.js";
|
|
9
|
+
import { ENV_FILE, missingMonths, monthFromText, passwordVars, PdfPasswordError, pdfText, readEnvFile, readSources, scanStatements, STATEMENTS_DIR, unlockPdf, } from "../node/statements.js";
|
|
10
|
+
const USAGE = `Usage:
|
|
11
|
+
ownledger statements add <account-id> <file.pdf>... [--month YYYY-MM] [--dir <repo>] [--yes] [--no-commit]
|
|
12
|
+
Unlock (password from ${ENV_FILE}) and file the bank's statement PDFs as ${STATEMENTS_DIR}/<account-id>/<YYYY-MM>.pdf.
|
|
13
|
+
YYYY-MM is the month of the statement's close date, read from the PDF unless --month is given. Preview unless --yes.
|
|
14
|
+
ownledger statements list [<account-id>] [--dir <repo>]
|
|
15
|
+
Which months each card has, and which are missing between the first and the last.
|
|
16
|
+
ownledger statements check <account-id> <YYYY-MM> [--dir <repo>] [--json]
|
|
17
|
+
The statement's text next to ownledger's figures and transactions for the same period, to compare.`;
|
|
18
|
+
function opt(args, name) {
|
|
19
|
+
const i = args.indexOf(name);
|
|
20
|
+
return i >= 0 ? args[i + 1] : args.find((a) => a.startsWith(name + "="))?.slice(name.length + 1);
|
|
21
|
+
}
|
|
22
|
+
const positional = (args) => args.filter((a, i) => !a.startsWith("-") && !["--month", "--dir"].includes(args[i - 1] ?? ""));
|
|
23
|
+
function ledgerAt(root) {
|
|
24
|
+
return loadLedger(readDataDir(root)).ledger;
|
|
25
|
+
}
|
|
26
|
+
function statementDayOf(l, id) {
|
|
27
|
+
const a = l.accounts.find((x) => x.id === id);
|
|
28
|
+
return a ? termsOf(a, recordFor(l, id)).statementDay : null;
|
|
29
|
+
}
|
|
30
|
+
const fmt = (n) => Math.round(n).toLocaleString("en-US");
|
|
31
|
+
export async function cmdStatements(args) {
|
|
32
|
+
const [sub, ...rest] = args;
|
|
33
|
+
const root = resolve(opt(rest, "--dir") ?? ".");
|
|
34
|
+
if (sub === "add")
|
|
35
|
+
return add(root, rest);
|
|
36
|
+
if (sub === "list")
|
|
37
|
+
return list(root, positional(rest)[0]);
|
|
38
|
+
if (sub === "check")
|
|
39
|
+
return check(root, rest);
|
|
40
|
+
console.log(USAGE);
|
|
41
|
+
return 2;
|
|
42
|
+
}
|
|
43
|
+
async function add(root, args) {
|
|
44
|
+
const [account, ...files] = positional(args);
|
|
45
|
+
if (!account || !files.length) {
|
|
46
|
+
console.log(USAGE);
|
|
47
|
+
return 2;
|
|
48
|
+
}
|
|
49
|
+
const month = opt(args, "--month");
|
|
50
|
+
if (month && !/^\d{4}-(0[1-9]|1[0-2])$/.test(month)) {
|
|
51
|
+
console.error(`--month must be YYYY-MM (got "${month}")`);
|
|
52
|
+
return 2;
|
|
53
|
+
}
|
|
54
|
+
if (month && files.length > 1) {
|
|
55
|
+
console.error("--month goes with one file at a time");
|
|
56
|
+
return 2;
|
|
57
|
+
}
|
|
58
|
+
const l = ledgerAt(root);
|
|
59
|
+
if (!l.accounts.some((a) => a.id === account)) {
|
|
60
|
+
console.error(`No account "${account}" in data/accounts.yaml.`);
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
const sd = statementDayOf(l, account);
|
|
64
|
+
const sources = readSources(root);
|
|
65
|
+
const env = readEnvFile(root);
|
|
66
|
+
const vars = passwordVars(account, sources[account]);
|
|
67
|
+
const password = vars.map((v) => env[v]).find((v) => v);
|
|
68
|
+
const planned = [];
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
const p = { file, month: month ?? null, status: "error", note: "" };
|
|
71
|
+
planned.push(p);
|
|
72
|
+
let unlocked;
|
|
73
|
+
try {
|
|
74
|
+
unlocked = (await unlockPdf(new Uint8Array(readFileSync(file)), password)).bytes;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
if (e instanceof PdfPasswordError) {
|
|
78
|
+
const hint = sources[account]?.password_hint;
|
|
79
|
+
p.note = password
|
|
80
|
+
? `wrong password (from ${vars.find((v) => env[v])} in ${ENV_FILE})`
|
|
81
|
+
: `needs a password: set ${vars.join(" or ")} in ${ENV_FILE}${hint ? ` (${hint})` : ""}`;
|
|
82
|
+
}
|
|
83
|
+
else
|
|
84
|
+
p.note = e instanceof Error ? e.message : String(e);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!month) {
|
|
88
|
+
const g = monthFromText(await pdfText(unlocked), sd);
|
|
89
|
+
if (!g.month) {
|
|
90
|
+
p.note = `can't tell the month (${g.why}): pass --month YYYY-MM`;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
p.month = g.month;
|
|
94
|
+
p.period = `${g.from} … ${g.close}`;
|
|
95
|
+
}
|
|
96
|
+
if (planned.some((o) => o !== p && o.month === p.month && o.status !== "error")) {
|
|
97
|
+
p.note = `another file in this run is also ${p.month}`;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const target = join(root, STATEMENTS_DIR, account, `${p.month}.pdf`);
|
|
101
|
+
if (existsSync(target)) {
|
|
102
|
+
// same bytes, or the same text (a copy unlocked by another tool differs in bytes only)
|
|
103
|
+
const had = readFileSync(target);
|
|
104
|
+
const same = Buffer.compare(had, Buffer.from(unlocked)) === 0 || (await pdfText(new Uint8Array(had)).catch(() => null)) === (await pdfText(unlocked));
|
|
105
|
+
p.status = same ? "same" : "different";
|
|
106
|
+
p.note = same ? "already filed" : `a different file is already filed for ${p.month}: delete it first if this one replaces it`;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
p.status = "new";
|
|
110
|
+
p.bytes = unlocked;
|
|
111
|
+
}
|
|
112
|
+
console.log(`Statements for ${account}:\n`);
|
|
113
|
+
console.log("| file | month | period | |\n|---|---|---|---|");
|
|
114
|
+
for (const p of planned)
|
|
115
|
+
console.log(`| ${basename(p.file)} | ${p.month ?? "?"} | ${p.period ?? ""} | ${p.status === "new" ? "✓ new" : p.status === "same" ? "= " + p.note : "✗ " + p.note} |`);
|
|
116
|
+
const news = planned.filter((p) => p.status === "new");
|
|
117
|
+
const failed = planned.some((p) => p.status === "error" || p.status === "different");
|
|
118
|
+
if (!news.length) {
|
|
119
|
+
console.log("\nNothing to file.");
|
|
120
|
+
return failed ? 1 : 0;
|
|
121
|
+
}
|
|
122
|
+
if (!args.includes("--yes")) {
|
|
123
|
+
console.log(`\nPreview only: nothing written. Run again with --yes to file ${news.length} statement(s)${existsSync(join(root, ".git")) ? " and commit" : ""}.`);
|
|
124
|
+
return failed ? 1 : 0;
|
|
125
|
+
}
|
|
126
|
+
const paths = [];
|
|
127
|
+
for (const p of news) {
|
|
128
|
+
const rel = `${STATEMENTS_DIR}/${account}/${p.month}.pdf`;
|
|
129
|
+
mkdirSync(dirname(join(root, rel)), { recursive: true });
|
|
130
|
+
writeFileSync(join(root, rel), p.bytes);
|
|
131
|
+
paths.push(rel);
|
|
132
|
+
}
|
|
133
|
+
console.log(`\n✓ Filed: ${paths.join(", ")}`);
|
|
134
|
+
if (existsSync(join(root, ".git")) && !args.includes("--no-commit")) {
|
|
135
|
+
const msg = `Statements: ${account} ${news.map((p) => p.month).sort().reverse().join(", ")}`;
|
|
136
|
+
execFileSync("git", ["add", ...paths], { cwd: root });
|
|
137
|
+
execFileSync("git", ["commit", "-q", "-m", msg], { cwd: root, stdio: "inherit" });
|
|
138
|
+
console.log(`✓ Committed: ${msg}`);
|
|
139
|
+
}
|
|
140
|
+
return failed ? 1 : 0;
|
|
141
|
+
}
|
|
142
|
+
/* ------------------------------------------------------------------ list */
|
|
143
|
+
async function list(root, only) {
|
|
144
|
+
const l = ledgerAt(root);
|
|
145
|
+
const { files, warnings } = scanStatements(root, new Set(l.accounts.map((a) => a.id)));
|
|
146
|
+
const by = new Map();
|
|
147
|
+
for (const f of files)
|
|
148
|
+
if (!only || f.account === only)
|
|
149
|
+
(by.get(f.account) ?? by.set(f.account, []).get(f.account)).push(f.month);
|
|
150
|
+
if (!by.size) {
|
|
151
|
+
console.log(only ? `No statements filed for ${only}.` : `No statements filed (${STATEMENTS_DIR}/<account-id>/<YYYY-MM>.pdf).`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.log("| account | statements | from | to | missing |\n|---|---|---|---|---|");
|
|
155
|
+
for (const [acc, months] of [...by].sort()) {
|
|
156
|
+
const s = months.sort();
|
|
157
|
+
const miss = missingMonths(s);
|
|
158
|
+
console.log(`| ${acc} | ${s.length} | ${s[0]} | ${s[s.length - 1]} | ${miss.join(", ") || "—"} |`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const w of warnings)
|
|
162
|
+
console.log(`! ${w}`);
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
/* ------------------------------------------------------------------ check */
|
|
166
|
+
async function check(root, args) {
|
|
167
|
+
const [account, month] = positional(args);
|
|
168
|
+
if (!account || !month || !/^\d{4}-(0[1-9]|1[0-2])$/.test(month)) {
|
|
169
|
+
console.log(USAGE);
|
|
170
|
+
return 2;
|
|
171
|
+
}
|
|
172
|
+
const rel = `${STATEMENTS_DIR}/${account}/${month}.pdf`;
|
|
173
|
+
if (!existsSync(join(root, rel))) {
|
|
174
|
+
console.error(`No statement filed at ${rel}.`);
|
|
175
|
+
return 1;
|
|
176
|
+
}
|
|
177
|
+
const l = ledgerAt(root);
|
|
178
|
+
if (!l.accounts.some((a) => a.id === account)) {
|
|
179
|
+
console.error(`No account "${account}" in data/accounts.yaml.`);
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
let stmt;
|
|
183
|
+
try {
|
|
184
|
+
stmt = statements(l, account, todayIn()).find((s) => !s.open && s.close.slice(0, 7) === month);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
stmt = undefined;
|
|
188
|
+
}
|
|
189
|
+
const txs = stmt
|
|
190
|
+
? l.transactions
|
|
191
|
+
.filter((t) => !t.void && t.date >= stmt.from && t.date <= stmt.close && t.lines.some((ln) => ln.account === account))
|
|
192
|
+
.sort((a, b) => (a.date + (a.time ?? "")).localeCompare(b.date + (b.time ?? "")))
|
|
193
|
+
.map((t) => {
|
|
194
|
+
const own = t.lines.filter((ln) => ln.account === account);
|
|
195
|
+
const other = t.lines.filter((ln) => ln.account !== account);
|
|
196
|
+
return {
|
|
197
|
+
id: t.id,
|
|
198
|
+
date: t.date,
|
|
199
|
+
amount: own.reduce((s, ln) => s + ln.amount, 0),
|
|
200
|
+
note: [t.note, ...own.map((ln) => ln.note)].filter(Boolean).join(" · "),
|
|
201
|
+
against: other.map((ln) => ln.category ?? ln.account).filter(Boolean).join(", "),
|
|
202
|
+
};
|
|
203
|
+
})
|
|
204
|
+
: [];
|
|
205
|
+
let text;
|
|
206
|
+
try {
|
|
207
|
+
text = await pdfText(new Uint8Array(readFileSync(join(root, rel))));
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
console.error(`${rel}: can't read the PDF's text (${e instanceof Error ? e.message : e}). Is it still locked? File it with \`ownledger statements add\`.`);
|
|
211
|
+
return 1;
|
|
212
|
+
}
|
|
213
|
+
if (args.includes("--json")) {
|
|
214
|
+
console.log(JSON.stringify({ account, month, file: rel, statement: stmt ?? null, transactions: txs, text }, null, 2));
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
console.log(`# ${account} statement ${month} (${rel})\n`);
|
|
218
|
+
if (!stmt)
|
|
219
|
+
console.log(`ownledger has no closed statement period for ${account} closing in ${month} (no statement_day, or no transactions then).\n`);
|
|
220
|
+
else {
|
|
221
|
+
console.log(`Period ${stmt.from} … ${stmt.close}${stmt.due ? `, due ${stmt.due}` : ""}. Amounts as owed (positive = you owe).\n`);
|
|
222
|
+
console.log("| opening | purchases | refunds | cashback | fees | charges | payments | adjust | closing | deferred | amount due | bank's amount |\n|---|---|---|---|---|---|---|---|---|---|---|---|");
|
|
223
|
+
console.log(`| ${[stmt.opening, stmt.purchases, stmt.refunds, stmt.cashback, stmt.fees, stmt.charges, stmt.payments, stmt.adjust, stmt.closing, stmt.deferred, stmt.amountDue].map(fmt).join(" | ")} | ${stmt.bank === null ? "—" : fmt(stmt.bank)} |`);
|
|
224
|
+
console.log(`\n## ownledger's transactions on ${account} (${txs.length}; amount on the card: negative = spent, positive = paid/refunded)\n`);
|
|
225
|
+
console.log("| date | amount | note | against | id |\n|---|---|---|---|---|");
|
|
226
|
+
for (const t of txs)
|
|
227
|
+
console.log(`| ${t.date} | ${fmt(t.amount)} | ${t.note.replace(/\|/g, "/")} | ${t.against} | ${t.id} |`);
|
|
228
|
+
}
|
|
229
|
+
console.log(`\n## Statement text (as extracted from the PDF)\n\n${text}`);
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
package/dist/modules/api.d.ts
CHANGED
|
@@ -9,9 +9,12 @@ export interface ModuleApiCtx {
|
|
|
9
9
|
asOf: string;
|
|
10
10
|
q: URLSearchParams;
|
|
11
11
|
}
|
|
12
|
+
/** JSON (`body`), or a ready response (e.g. a PDF). */
|
|
12
13
|
export type ModuleApiResult = {
|
|
13
14
|
body: unknown;
|
|
14
15
|
status?: number;
|
|
16
|
+
} | {
|
|
17
|
+
response: Response;
|
|
15
18
|
} | null;
|
|
16
19
|
type Handler = (path: string, c: ModuleApiCtx) => Promise<ModuleApiResult> | ModuleApiResult;
|
|
17
20
|
export declare function registerModuleApi(name: string, h: Handler): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ModuleApiCtx, ModuleApiResult } from "../api.js";
|
|
2
2
|
/** /api/m/cards/… */
|
|
3
|
-
export declare function cardsApi(path: string, c: ModuleApiCtx): ModuleApiResult
|
|
3
|
+
export declare function cardsApi(path: string, c: ModuleApiCtx): ModuleApiResult | Promise<ModuleApiResult>;
|
|
@@ -4,8 +4,40 @@ import { cardList } from "./index.js";
|
|
|
4
4
|
import { bestCard, cardValues, cashback, feeWaiver, interestFreeUntil, lineKind, statements } from "./statements.js";
|
|
5
5
|
import { cardsData, recordFor, termsOf } from "./terms.js";
|
|
6
6
|
import { flattenCategories } from "../../engine/categories.js";
|
|
7
|
+
import { statementPdf } from "./files.js";
|
|
8
|
+
/** GET /api/m/cards/statement-pdf?account=<id>&close=<YYYY-MM-DD>: the bank's PDF for one closed statement, streamed. */
|
|
9
|
+
async function statementPdfResponse(c) {
|
|
10
|
+
const L = c.snap.ledger;
|
|
11
|
+
const id = c.q.get("account") ?? "";
|
|
12
|
+
const close = c.q.get("close") ?? "";
|
|
13
|
+
if (!id || !/^\d{4}-\d{2}-\d{2}$/.test(close))
|
|
14
|
+
return { body: { error: "account and close (YYYY-MM-DD)" }, status: 400 };
|
|
15
|
+
const a = L.accounts.find((x) => x.id === id && x.type === "credit_card");
|
|
16
|
+
if (!a)
|
|
17
|
+
return { body: { error: `no card ${id}` }, status: 404 };
|
|
18
|
+
// the path is built from the ledger's own card and close date, never taken from the request
|
|
19
|
+
const st = statements(L, a.id, c.asOf).find((s) => !s.open && s.close === close);
|
|
20
|
+
const path = st ? statementPdf(c.snap.files, a.id, st.close) : null;
|
|
21
|
+
if (!path)
|
|
22
|
+
return { body: { error: "no statement PDF" }, status: 404 };
|
|
23
|
+
const blob = await c.src.blob(c.snap.sha, path);
|
|
24
|
+
if (!blob?.body)
|
|
25
|
+
return { body: { error: "no statement PDF" }, status: 404 };
|
|
26
|
+
return {
|
|
27
|
+
response: new Response(blob.body, {
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/pdf",
|
|
30
|
+
"Content-Disposition": `inline; filename="${a.id}-${close.slice(0, 7)}.pdf"`,
|
|
31
|
+
"Cache-Control": "private, no-store",
|
|
32
|
+
"X-Content-Type-Options": "nosniff",
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
7
37
|
/** /api/m/cards/… */
|
|
8
38
|
export function cardsApi(path, c) {
|
|
39
|
+
if (path === "statement-pdf")
|
|
40
|
+
return statementPdfResponse(c);
|
|
9
41
|
const L = c.snap.ledger;
|
|
10
42
|
const asOf = c.asOf;
|
|
11
43
|
if (path === "") {
|
|
@@ -50,7 +82,7 @@ export function cardsApi(path, c) {
|
|
|
50
82
|
.filter((t) => !t.void && t.date >= st.from && t.date <= st.close && t.lines.some((ln) => ln.account === a.id))
|
|
51
83
|
.map((t) => ({ ...t, kind: lineKind(t, a.id, map)?.kind ?? null }))
|
|
52
84
|
.reverse();
|
|
53
|
-
return { body: { statement: st, transactions: txs } };
|
|
85
|
+
return { body: { statement: { ...st, pdf: !st.open && !!statementPdf(c.snap.files, a.id, st.close) }, transactions: txs } };
|
|
54
86
|
}
|
|
55
87
|
const summary = cardList(L, asOf, { includeClosed: true }).find((x) => x.account === a.id) ?? null;
|
|
56
88
|
const terms = termsOf(a, rec);
|
|
@@ -61,7 +93,7 @@ export function cardsApi(path, c) {
|
|
|
61
93
|
record: rec ?? null,
|
|
62
94
|
terms,
|
|
63
95
|
summary,
|
|
64
|
-
statements: statements(L, a.id, asOf).reverse(),
|
|
96
|
+
statements: statements(L, a.id, asOf).reverse().map((s) => ({ ...s, pdf: !s.open && !!statementPdf(c.snap.files, a.id, s.close) })),
|
|
65
97
|
cashback: cashback(L, a.id, asOf).reverse().slice(0, 13),
|
|
66
98
|
feeWaiver: feeWaiver(L, a.id, asOf),
|
|
67
99
|
instalments: planStatus(L, asOf).filter((p) => p.kind === "instalment" && p.account === a.id),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileMap } from "../../engine/load.js";
|
|
2
|
+
/**
|
|
3
|
+
* Bank statement PDFs (plan 004): imports/statements/<account-id>/<YYYY-MM>.pdf, YYYY-MM = the month of the close date.
|
|
4
|
+
* The Worker only knows their paths (from the tarball, contents not read) and streams one to the signed-in dashboard;
|
|
5
|
+
* it never parses them. Reading them is the CLI's job, on the user's computer.
|
|
6
|
+
*/
|
|
7
|
+
export declare const STATEMENTS_DIR = "imports/statements";
|
|
8
|
+
export declare const STATEMENT_PDF_RE: RegExp;
|
|
9
|
+
export declare function statementPdfPath(account: string, close: string): string;
|
|
10
|
+
/** The statement PDF filed for this card's statement closing on `close`, or null. */
|
|
11
|
+
export declare function statementPdf(files: FileMap, account: string, close: string): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank statement PDFs (plan 004): imports/statements/<account-id>/<YYYY-MM>.pdf, YYYY-MM = the month of the close date.
|
|
3
|
+
* The Worker only knows their paths (from the tarball, contents not read) and streams one to the signed-in dashboard;
|
|
4
|
+
* it never parses them. Reading them is the CLI's job, on the user's computer.
|
|
5
|
+
*/
|
|
6
|
+
export const STATEMENTS_DIR = "imports/statements";
|
|
7
|
+
export const STATEMENT_PDF_RE = /^imports\/statements\/[^/]+\/\d{4}-(0[1-9]|1[0-2])\.pdf$/;
|
|
8
|
+
export function statementPdfPath(account, close) {
|
|
9
|
+
return `${STATEMENTS_DIR}/${account}/${close.slice(0, 7)}.pdf`;
|
|
10
|
+
}
|
|
11
|
+
/** The statement PDF filed for this card's statement closing on `close`, or null. */
|
|
12
|
+
export function statementPdf(files, account, close) {
|
|
13
|
+
if (!account || account.includes("/") || account.startsWith("."))
|
|
14
|
+
return null;
|
|
15
|
+
const p = statementPdfPath(account, close);
|
|
16
|
+
return STATEMENT_PDF_RE.test(p) && files[p] !== undefined ? p : null;
|
|
17
|
+
}
|