@dubusoft/toodo-linux-arm64 1.4.2-dev.86 → 1.4.2-dev.88

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.
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,s as r}from"./dist-ZmB2kPfR.js";import{at as i,on as a,t as o}from"./queries-Dt65Qzxx.js";import{d as s,f as c,h as l,m as u}from"./event-DMqRNLc_.js";import{vt as d}from"./index-DtWZQCfw.js";var f={name:`wifi-off`,size:24,node:[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};f.node;var p=t(f),m=r(e(),1),h=n();function g({children:e}){let t=(0,m.useSyncExternalStore)(u,s),n=t===`unreachable`||t===`retrying`;return(0,h.jsxs)(h.Fragment,{children:[n&&(0,h.jsx)(_,{retrying:t===`retrying`}),e,n&&(0,h.jsx)(`div`,{"aria-hidden":!0,className:`h-40`})]})}function _({retrying:e}){let t=navigator.onLine?l():`This device is offline.`,n=a().getQueryState(o.tasks)?.dataUpdatedAt;return(0,h.jsxs)(`div`,{role:`alert`,className:`fixed inset-x-2 bottom-2 z-50 mx-auto flex max-w-xl flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-amber-500 bg-amber-100 p-3 text-sm text-amber-950 shadow-md dark:bg-amber-950 dark:text-amber-100`,children:[(0,h.jsx)(p,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`font-medium`,children:`Can't reach the Toodo server`}),(0,h.jsxs)(`p`,{className:`text-xs`,children:[t,` `,n?(0,h.jsxs)(h.Fragment,{children:[`Read-only: the tasks shown were loaded `,(0,h.jsx)(d,{at:Math.floor(n/1e3)}),` and may be out of date.`]}):`What you see may be out of date.`,` `,`Changes are paused. Toodo reconnects on its own as soon as the server answers.`]})]}),(0,h.jsx)(i,{size:`sm`,variant:`outline`,disabled:e,onClick:c,children:e?`Trying...`:`Retry now`})]})}export{g as ConnectionGate};
1
+ import{i as e,n as t,r as n,s as r}from"./dist-ZmB2kPfR.js";import{at as i,on as a,t as o}from"./queries-usvG1nHU.js";import{d as s,f as c,h as l,m as u}from"./event-DMqRNLc_.js";import{vt as d}from"./index-DO2HCuk5.js";var f={name:`wifi-off`,size:24,node:[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};f.node;var p=t(f),m=r(e(),1),h=n();function g({children:e}){let t=(0,m.useSyncExternalStore)(u,s),n=t===`unreachable`||t===`retrying`;return(0,h.jsxs)(h.Fragment,{children:[n&&(0,h.jsx)(_,{retrying:t===`retrying`}),e,n&&(0,h.jsx)(`div`,{"aria-hidden":!0,className:`h-40`})]})}function _({retrying:e}){let t=navigator.onLine?l():`This device is offline.`,n=a().getQueryState(o.tasks)?.dataUpdatedAt;return(0,h.jsxs)(`div`,{role:`alert`,className:`fixed inset-x-2 bottom-2 z-50 mx-auto flex max-w-xl flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-amber-500 bg-amber-100 p-3 text-sm text-amber-950 shadow-md dark:bg-amber-950 dark:text-amber-100`,children:[(0,h.jsx)(p,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`font-medium`,children:`Can't reach the Toodo server`}),(0,h.jsxs)(`p`,{className:`text-xs`,children:[t,` `,n?(0,h.jsxs)(h.Fragment,{children:[`Read-only: the tasks shown were loaded `,(0,h.jsx)(d,{at:Math.floor(n/1e3)}),` and may be out of date.`]}):`What you see may be out of date.`,` `,`Changes are paused. Toodo reconnects on its own as soon as the server answers.`]})]}),(0,h.jsx)(i,{size:`sm`,variant:`outline`,disabled:e,onClick:c,children:e?`Trying...`:`Retry now`})]})}export{g as ConnectionGate};
@@ -1 +1 @@
1
- import{i as e,r as t,s as n,t as r}from"./dist-ZmB2kPfR.js";import{d as i,i as a,m as o,n as s,o as c,p as l,r as u,s as d}from"./event-DMqRNLc_.js";var f=n(e(),1),p=t(),m=f.createContext(void 0),h=e=>{let t=f.useContext(m);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},g=({client:e,children:t})=>(f.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,p.jsx)(m.Provider,{value:e,children:t})),_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function ee(e){setTimeout(e,0)}var te=typeof window>`u`||`Deno`in globalThis;function y(){}function ne(e,t){return typeof e==`function`?e(t):e}function re(e){return typeof e==`number`&&e>=0&&e!==1/0}function ie(e,t){return Math.max(e+(t||0)-Date.now(),0)}function b(e,t){return typeof e==`function`?e(t):e}function ae(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==se(o,t.options))return!1}else if(!S(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function oe(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(x(t.options.mutationKey)!==x(a))return!1}else if(!S(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function se(e,t){return(t?.queryKeyHashFn||x)(e)}function x(e){return JSON.stringify(e,(e,t)=>de(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function S(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!S(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!S(e[r],t[r]))return!1;return!0}return!1}var ce=Object.prototype.hasOwnProperty;function le(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ue(e)&&ue(t);if(!r&&!(de(e)&&de(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ce.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=le(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function C(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ue(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function de(e){if(!fe(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!fe(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function fe(e){return Object.prototype.toString.call(e)===`[object Object]`}function pe(e){return new Promise(t=>{v.setTimeout(t,e)})}function me(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:le(e,t)}function he(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function ge(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var _e=Symbol();function ve(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===_e?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ye(e,t){return typeof e==`function`?e(...t):!!e}function be(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var xe=()=>te,Se=()=>xe(),w=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ce=new class extends w{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},we=ee;function Te(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=we,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var T=Te(),Ee=new class extends w{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function De(e){return Math.min(1e3*2**e,3e4)}function Oe(e){return(e??`online`)!==`online`||Ee.isOnline()}var ke=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ae(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(y);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new ke(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Ce.isFocused()&&(e.networkMode===`always`||Ee.isOnline())&&e.canRun(),p=()=>Oe(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(Se()?0:3),a=e.retryDelay??De,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?h(r):(n++,e.onFail?.(n,r),pe(o).then(()=>f()?void 0:g(f)).then(()=>{t?h(r):_()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g(p).then(_),s)}}var je=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),re(this.gcTime)&&(this.#e=v.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Se()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(v.clearTimeout(this.#e),this.#e=void 0)}};function Me(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{be(e,()=>t.signal,()=>n=!0)},u=ve(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?ge:he;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Pe:Ne,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ne(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ne(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Pe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Fe(e,t){return t?Ne(e,t)!=null:!1}function Ie(e,t){return!t||!e.getPreviousPageParam?!1:Pe(e,t)!=null}var Le=class extends je{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Be(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Be(this.options);e.data!==void 0&&(this.setState(ze(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=me(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(y).catch(y):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_e||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>b(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!ie(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ve(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Me(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Ae({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ke&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ke){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Re(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...ze(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),T.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Re(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Oe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ze(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Be(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Ve=class extends w{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ue(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return We(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return We(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof b(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!C(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ge(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||b(this.options.staleTime,this.#t)!==b(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return C(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(y)),t}#h(e){return!Se()&&b(this.options.enabled,this.#t)!==!1&&re(e)}#g(){this.#b();let e=b(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=ie(this.#r.dataUpdatedAt,e)+1;this.#u=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return b(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=v.setInterval(()=>{(this.options.refetchIntervalInBackground||Ce.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(v.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(v.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ue(e,t),o=i&&Ge(e,n,t,r);(a||o)&&(l={...l,...Re(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=me(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=me(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,ee=_&&g,te=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:ee,isLoading:ee,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!te,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&te,isStale:E(e,t),refetch:this.refetch,isEnabled:b(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),C(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();T.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function He(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||b(t.retryOnMount,e)!==!1)}function Ue(e,t){return He(e,t)||e.state.data!==void 0&&We(e,t,t.refetchOnMount)}function We(e,t,n){if(b(t.enabled,e)!==!1&&b(t.staleTime,e)!==`static`){let r=b(n,e);return r===`always`||r!==!1&&E(e,t)}return!1}function Ge(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&E(e,n)}function E(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(b(t.staleTime,e))}var Ke=class extends Ve{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Fe(t,n.data),hasPreviousPage:Ie(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},qe=class extends je{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Je(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Ae({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),T.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Je(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ye=class extends w{#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&&x(t.mutationKey)!==x(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??Je();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){T.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)})})}},Xe=f.createContext(!1),Ze=()=>f.useContext(Xe);Xe.Provider;function Qe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $e=f.createContext(Qe()),et=()=>f.useContext($e),tt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ye(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},nt=e=>{f.useEffect(()=>{e.clearReset()},[e])},rt=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ye(n,[e.error,r])),it=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},at=(e,t)=>e?.suspense&&t.isPending,ot=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function st(e,t,n){let r=Ze(),i=et(),a=h(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,it(o),tt(o,i,s),nt(i);let[l]=f.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(f.useSyncExternalStore(f.useCallback(e=>{let t=d?l.subscribe(T.batchCalls(e)):y;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),f.useEffect(()=>{l.setOptions(o)},[o,l]),at(o,u))throw ot(o,l,i);if(rt({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function D(e,t){return st(e,Ve,t)}function O(e,t){let n=h(t),[r]=f.useState(()=>new Ye(n,e));f.useEffect(()=>{r.setOptions(e)},[r,e]);let i=f.useSyncExternalStore(f.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=f.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(y)},[r]);if(i.error&&ye(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function ct(e,t){return st(e,Ke,t)}function k(){return typeof window<`u`}function A(e){return ut(e)?(e.nodeName||``).toLowerCase():`#document`}function j(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lt(e){return((ut(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ut(e){return k()?e instanceof Node||e instanceof j(e).Node:!1}function dt(e){return k()?e instanceof Element||e instanceof j(e).Element:!1}function M(e){return k()?e instanceof HTMLElement||e instanceof j(e).HTMLElement:!1}function ft(e){return!k()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof j(e).ShadowRoot}function pt(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ct(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function mt(e){return/^(table|td|th)$/.test(A(e))}function ht(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var gt=/transform|translate|scale|rotate|perspective|filter/,_t=/paint|layout|strict|content/,N=e=>!!e&&e!==`none`,vt;function yt(e){let t=dt(e)?Ct(e):e;return N(t.transform)||N(t.translate)||N(t.scale)||N(t.rotate)||N(t.perspective)||!xt()&&(N(t.backdropFilter)||N(t.filter))||gt.test(t.willChange||``)||_t.test(t.contain||``)}function bt(e){let t=P(e);for(;M(t)&&!St(t);){if(yt(t))return t;if(ht(t))return null;t=P(t)}return null}function xt(){return vt??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),vt}function St(e){return/^(html|body|#document)$/.test(A(e))}function Ct(e){return j(e).getComputedStyle(e)}function wt(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function P(e){if(A(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ft(e)&&e.host||lt(e);return ft(t)?t.host:t}function Tt(e){let t=P(e);return St(t)?(e.ownerDocument||e).body:M(t)&&pt(t)?t:Tt(t)}function Et(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Tt(e),i=r===e.ownerDocument?.body,a=j(r);if(i){let e=Dt(a);return t.concat(a,a.visualViewport||[],pt(r)?r:[],e&&n?Et(e):[])}return t.concat(r,Et(r,[],n))}function Dt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var F={...f},Ot={};function I(e,t){let n=f.useRef(Ot);return n.current===Ot&&(n.current=e(t)),n}var kt=F.useInsertionEffect,At=kt&&kt!==F.useLayoutEffect?kt:e=>e();function jt(e){let t=I(Mt).current;return t.next=e,At(t.effect),t.trampoline}function Mt(){let e={next:void 0,callback:Nt,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Nt(){}var Pt=typeof document<`u`?f.useLayoutEffect:()=>{};function Ft(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var It={};function L(e,t,n,r,i){if(!n&&!r&&!i&&!e)return R(t);let a=R(e);return t&&(a=z(a,t)),n&&(a=z(a,n)),r&&(a=z(a,r)),i&&(a=z(a,i)),a}function Lt(e){if(e.length===0)return It;if(e.length===1)return R(e[0]);let t=R(e[0]);for(let n=1;n<e.length;n+=1)t=z(t,e[n]);return t}function R(e){return Vt(e)?{...e(It)}:Rt(e)}function z(e,t){return Vt(t)?t(e):zt(e,t)}function Rt(e){let t={...e};for(let e in t){let n=t[e];Bt(e,n)&&(t[e]=Ut(n))}return t}function zt(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Ft(e.style,r);break;case`className`:e[n]=Wt(e.className,r);break;default:e[n]=Bt(n,r)?Ht(e[n],r):r}}return e}function Bt(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Vt(e){return typeof e==`function`}function Ht(e,t){return t?e?(...n)=>{let r=n[0];if(Gt(r)){let i=r;B(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Ut(t):e}function Ut(e){return e&&((...t)=>{let n=t[0];return Gt(n)&&B(n),e(...t)})}function B(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Wt(e,t){return t?e?t+` `+e:t:e}function Gt(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Kt(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var qt=Kt(`https://base-ui.com/production-error`,`Base UI`),Jt=f.createContext(void 0);function Yt(e=!1){let t=f.useContext(Jt);if(t===void 0&&!e)throw Error(qt(16));return t}function Xt(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:f.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function V(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(j(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Zt(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=f.useRef(null),s=Yt(!0),c=a??s!==void 0,{props:l}=Xt({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=f.useCallback(()=>{let e=o.current;Qt(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Pt(u,[u]),{getButtonProps:f.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return L({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(B(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Qt(r),s=!i&&$t(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),V(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),V(r,e)))},onKeyUp(e){t||(B(e),a?.(e),e.target===e.currentTarget&&i&&c&&Qt(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),V(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:jt(e=>{o.current=e,u()})}}function Qt(e){return M(e)&&e.tagName===`BUTTON`}function $t(e){return M(e)&&e.tagName===`A`&&!!e.href}function en(e,t,n,r){let i=I(nn).current;return rn(i,e,t,n,r)&&on(i,[e,t,n,r]),i.callback}function tn(e){let t=I(nn).current;return an(t,e)&&on(t,e),t.callback}function nn(){return{callback:null,cleanup:null,refs:[]}}function rn(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function an(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function on(e,t){e.refs=t,e.callback=t.every(e=>e==null)?null:n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var sn=19;function cn(e){return sn>=e}function ln(e){if(!f.isValidElement(e))return null;let t=e,n=t.props;return(cn(19)?n?.ref:t.ref)??null}function un(){}var dn=Object.freeze([]),H=Object.freeze({});function fn(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e)}else i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function pn(e,t){return typeof e==`function`?e(t):e}function mn(e,t){return typeof e==`function`?e(t):e}function hn(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=yn(r));let i=gn(t,n,r);if(n.enabled===!1)return null;let a=n.state??H;return bn(e,r,i,a)}function gn(e,t,n){let{className:r,style:i}=e,{state:a=H,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?pn(r,a):void 0,d=l?mn(i,a):void 0,f=l?fn(a,c):H,p=l&&s?_n(s):void 0,m=l?Ft(f,p)??{}:H;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?tn([m.ref,ln(n),...o]):en(m.ref,ln(n),o):en(null,null)),l?(u!==void 0&&(m.className=Wt(m.className,u)),d!==void 0&&(m.style=Ft(m.style,d)),m):H}function _n(e){return Array.isArray(e)?Lt(e):L(void 0,e)}var vn=Symbol.for(`react.lazy`);function yn(e){if(e?.$$typeof!==vn)return e;let t=f.Children.toArray(e)[0];return f.isValidElement(t)?t:e}function bn(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=L(n,t.props);return e.ref=n.ref,f.cloneElement(t,e)}return xn(e,n)}function xn(e,t){return e===`button`?(0,f.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,f.createElement)(`img`,{alt:``,...t,key:t.key}):f.createElement(e,t)}var Sn=f.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=Zt({disabled:i,focusableWhenDisabled:a,native:o});return hn(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})});function Cn(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Cn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function wn(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Cn(e))&&(r&&(r+=` `),r+=t);return r}var Tn=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,En=wn,Dn=((e,t)=>n=>{if(t?.variants==null)return En(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Tn(t)||Tn(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return En(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 motion-safe:active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:text-muted-foreground aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 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 max-md:min-h-11 max-md:min-w-11`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80 disabled:bg-muted`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/10 dark:hover:bg-input/20`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground disabled:bg-muted`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 disabled:bg-muted focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] max-md:text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function On({className:e,variant:t=`default`,size:n=`default`,autoFocus:a,changesData:s,disabled:c,...l}){let u=(0,f.useSyncExternalStore)(o,i),d=u===`unreachable`||u===`retrying`,m=s??l.type===`submit`,h=(0,f.useRef)(null);return(0,f.useEffect)(()=>{a&&h.current?.focus()},[]),(0,p.jsx)(Sn,{ref:h,"data-slot":`button`,disabled:c||m&&d,className:r(Dn({variant:t,size:n,className:e})),...l})}function kn(e){return typeof e==`object`&&!!e&&typeof e.kind==`string`&&typeof e.code==`string`&&typeof e.message==`string`}async function U(e,t={}){let n=d();if(n===null)throw Error(`No access token for the Toodo server.`);let r=await l(`/api/rpc/${encodeURIComponent(e)}`,{method:`POST`,headers:{...a(n),"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.status===401)throw c(),Error(`The Toodo server did not accept the access token.`);let i=await r.text();if(r.ok)return i?JSON.parse(i):null;let o=null;try{o=JSON.parse(i)}catch{}throw kn(o)?o:Error(i||`${r.status} ${r.statusText}`)}var W={appInfo:()=>U(`app_info`),checkUpdate:()=>U(`check_update`),listWorkspaces:()=>G(U(`list_workspaces`)),getWorkspace:e=>G(U(`get_workspace`,{id:e})),createWorkspace:e=>G(U(`create_workspace`,{workspace:e})),updateWorkspace:e=>G(U(`update_workspace`,{workspace:e})),deleteWorkspace:e=>G(U(`delete_workspace`,{id:e})),restoreWorkspace:e=>G(U(`restore_workspace`,{id:e})),purgeWorkspace:e=>G(U(`purge_workspace`,{id:e})),listArchive:()=>G(U(`list_archive`)),listTasks:e=>G(U(`list_tasks`,{filter:e})),listTaskRelations:()=>G(U(`list_task_relations`)),addTaskRelation:(e,t)=>G(U(`add_task_relation`,{taskId:e,relatedId:t})),removeTaskRelation:(e,t)=>G(U(`remove_task_relation`,{taskId:e,relatedId:t})),getTask:e=>G(U(`get_task`,{id:e})),createTask:e=>G(U(`create_task`,{task:e})),updateTask:e=>G(U(`update_task`,{task:e})),pauseTask:e=>G(U(`pause_task`,{id:e})),setCompletionNote:(e,t)=>G(U(`set_completion_note`,{id:e,note:t})),reopenTask:(e,t)=>G(U(`reopen_task`,{id:e,reason:t})),setTaskOutcome:(e,t,n)=>G(U(`set_task_outcome`,{id:e,resolution:t,note:n})),checkCriterion:(e,t,n,r)=>G(U(`check_criterion`,{taskId:e,criterionId:t,met:n,evidence:r})),deleteTask:e=>G(U(`delete_task`,{id:e})),restoreTask:e=>G(U(`restore_task`,{id:e})),purgeTask:e=>G(U(`purge_task`,{id:e})),addDependency:(e,t,n)=>G(U(`add_dependency`,{taskId:e,dependsOn:t,confirmPause:n})),removeDependency:(e,t)=>G(U(`remove_dependency`,{taskId:e,dependsOn:t})),startTask:(e,t,n)=>G(U(`start_task`,{id:e,reason:t,refs:n})),completeTask:(e,t,n)=>G(U(`complete_task`,{id:e,note:t,refs:n})),concludeTask:(e,t,n,r)=>G(U(`conclude_task`,{id:e,note:t,outcome:n,shippedWith:r})),linkIssue:(e,t)=>G(U(`link_issue`,{id:e,reference:t})),mcpServerInfo:()=>U(`mcp_server_info`),listConnectedApps:()=>G(U(`list_connected_apps`)),revokeConnectedApp:e=>G(U(`revoke_connected_app`,{grantId:e})),reviewPeriod:(e,t)=>G(U(`review_period`,{from:e,to:t})),reviewReport:e=>G(U(`review_report`,{request:e})),getReviewTimeZone:()=>G(U(`get_review_time_zone`)),setReviewTimeZone:e=>G(U(`set_review_time_zone`,{timeZone:e})),saveReviewSnapshot:e=>G(U(`save_review_snapshot`,{request:e})),listReviewSnapshots:()=>G(U(`list_review_snapshots`)),getReviewSnapshot:e=>G(U(`get_review_snapshot`,{id:e})),deleteReviewSnapshot:e=>G(U(`delete_review_snapshot`,{id:e})),getBackupSettings:()=>U(`get_backup_settings`),getBackupStatus:()=>U(`get_backup_status`),saveBackupSettings:e=>G(U(`save_backup_settings`,{settings:e})),listBackups:()=>G(U(`list_backups`)),restoreBackup:e=>G(U(`restore_backup`,{name:e}))},An={tasksChanged:jn(`tasks-changed`),workspacesChanged:jn(`workspaces-changed`)};async function G(e){try{return{status:`ok`,data:await e}}catch(e){if(e instanceof Error)throw e;return{status:`error`,error:e}}}function jn(e){return{listen:t=>s(e,t)}}function Mn(e){switch(e.code){case`unknownCommand`:case`invalidArguments`:return`This page is out of date with the Toodo server. Reload the page, then try again.`;case`commandPanicked`:return`Something went wrong on the Toodo server. Try again; if it keeps failing, look for "a command panicked" in the toodo-server log.`;case`storageFailed`:return`The Toodo server could not use its database (${e.message}). Try again; if it keeps failing, check the toodo-server log.`;default:return e.message}}function Nn(e,t){return/filename="([^"]+)"/.exec(e.headers.get(`Content-Disposition`)??``)?.[1]??t}function Pn(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}async function Fn(){let e=await u(`/api/backups/export`),t=Nn(e,`toodo-backup.sqlite3`);return Pn(t,await e.blob()),t}async function In(e){return Pn(e,await(await u(`/api/backups/${encodeURIComponent(e)}`)).blob()),e}async function Ln(e){return await(await u(`/api/backups/restore`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e})).json()}var Rn=`toodo-install-dismissed`;function zn(){let{userAgent:e,maxTouchPoints:t}=navigator;return/iPhone|iPad|iPod/.test(e)||e.includes(`Macintosh`)&&t>1}function Bn(){return matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0}var K=null,Vn=!1,Hn=new Set;function q(){Hn.forEach(e=>e())}function Un(e){return Hn.add(e),()=>Hn.delete(e)}function Wn(){return Vn||Bn()||localStorage.getItem(Rn)!==null?`none`:K===null?zn()?`home-screen`:`none`:`prompt`}function Gn(){localStorage.setItem(Rn,`1`),q()}async function Kn(){let e=K;if(e===null)return;K=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`dismissed`?Gn():q()}function qn(){addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),K=e,q()}),addEventListener(`appinstalled`,()=>{K=null,Vn=!0,q()})}function Jn(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window?`supported`:zn()&&!Bn()?`needs-install`:`unsupported`}var J=null,Yn={agent:[`Agent needs input`,`Agent finished`],pullRequests:[`CI failed`,`CI passed`,`Changes requested`,`Pull request approved`],completion:[`Task awaiting completion`]};function Xn(e){return J!==null&&Object.keys(Yn).some(t=>J?.[t]===!0&&Yn[t].includes(e))}function Zn(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function Qn(e,t){let n=e.options.applicationServerKey;return n===null||n.byteLength===t.length&&new Uint8Array(n).every((e,n)=>e===t[n])}function $n(){return navigator.serviceWorker.getRegistration()}async function er(e){let t=await(await $n())?.pushManager.getSubscription()??null;return t===null||Qn(t,e)?t:(await t.unsubscribe(),null)}async function tr(e){return await(await u(`/api/push/subscription`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.toJSON())})).json()}async function nr(){let e=await(await u(`/api/push`)).json(),t=await er(Zn(e.publicKey)),n=t===null?null:t.endpoint===e.subscription?.endpoint?e.subscription:await tr(t);return J=n?.settings??null,{publicKey:e.publicKey,permission:Notification.permission,subscription:n}}async function rr(e,t){if(await e!==`granted`)throw Error(`Notifications were not allowed.`);if(await $n()===void 0)throw Error(`Notifications need the service worker, which only the built app installs.`);let{pushManager:n}=await navigator.serviceWorker.ready,r=Zn(t),i=await er(r)??await n.subscribe({userVisibleOnly:!0,applicationServerKey:r});try{let e=await tr(i);return J=e.settings,e}catch(e){throw await i.unsubscribe(),e}}async function ir(){await(await(await $n())?.pushManager.getSubscription())?.unsubscribe(),J=null,await u(`/api/push/subscription`,{method:`DELETE`})}async function ar(e){let t=await(await u(`/api/push/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();return J=t.settings,t}async function or(){await u(`/api/push/test`,{method:`POST`})}var sr=`toodo-open-task`;function cr(e){if(!(`serviceWorker`in navigator))return()=>{};let t=navigator.serviceWorker,n=({data:t})=>{typeof t==`object`&&t&&`type`in t&&t.type===sr&&`taskId`in t&&typeof t.taskId==`number`&&e(t.taskId)};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}async function lr(){return`Notification`in window&&Notification.permission===`granted`}async function ur(){return`Notification`in window?Notification.requestPermission():`denied`}function dr(e){Xn(e.title)||new Notification(e.title,{body:e.body})}var fr={planned:`Planned`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`};function pr(e){return e.status===`done`&&e.resolution===`completed`?`Completed`:e.status===`done`&&e.resolution===`not_adopted`?`Not adopted`:fr[e.status]}function mr(e,t){switch(t.status){case`in_progress`:return`Task started`;case`in_review`:return`Task awaiting completion`;case`done`:return t.resolution===`not_adopted`?`Task concluded without merging`:`Task done`;case`planned`:return e===`in_progress`?`Task paused`:`Task status changed`}}function hr(e,t){let n=new Map(e.map(e=>[e.id,e.status]));return t.flatMap(e=>{let t=n.get(e.id);return t===void 0||t===e.status?[]:[{title:mr(t,e),body:`#${e.id} ${e.title}: ${fr[t]} -> ${pr(e)}`}]})}async function gr(e){if(e.length!==0&&(await lr()||await ur()===`granted`))for(let t of e)dr(t)}var _r=class extends Error{kind;code;constructor(e){super(Mn(e)),this.name=`CommandFailure`,this.kind=e.kind,this.code=e.code}};async function Y(e){let t=await e;if(t.status===`error`)throw new _r(t.error);return t.data}var X={workspaces:[`workspaces`],tasks:[`task-list`,`pages`],taskRelations:[`tasks`,`relations`],archive:[`tasks`,`archive`],backups:[`backups`],backupSettings:[`backup-settings`],backupStatus:[`backup-status`],mcpServerInfo:[`mcp-server-info`],review:(e,t)=>[`review`,e,t],reviewTimeZone:[`review`,`time-zone`],reviewSnapshots:[`review-snapshots`],reviewSnapshot:e=>[`review-snapshots`,e]};function vr(){return D({queryKey:X.mcpServerInfo,queryFn:()=>W.mcpServerInfo(),refetchInterval:5e3})}function yr(){return D({queryKey:X.backups,queryFn:()=>Y(W.listBackups())})}function br(){return D({queryKey:X.backupSettings,queryFn:()=>W.getBackupSettings()})}function xr(){return D({queryKey:X.backupStatus,queryFn:()=>W.getBackupStatus(),refetchInterval:6e4})}function Sr(){let e=h();return O({mutationFn:e=>Y(W.saveBackupSettings(e)),onSuccess:t=>(e.setQueryData(X.backupSettings,t),Promise.all([e.invalidateQueries({queryKey:X.backups}),e.invalidateQueries({queryKey:X.backupStatus})]))})}function Cr(){let e=h();return O({mutationFn:e=>Y(W.restoreBackup(e)),onSuccess:()=>e.invalidateQueries()})}function wr(){return O({mutationFn:Fn})}function Tr(){return O({mutationFn:In})}function Er(){let e=h();return O({mutationFn:Ln,onSuccess:()=>e.invalidateQueries()})}function Dr(){return D({queryKey:X.workspaces,queryFn:()=>Y(W.listWorkspaces())})}function Or(){let e=h();return O({mutationFn:e=>Y(W.createWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.workspaces})})}function kr(){let e=h();return O({mutationFn:e=>Y(W.updateWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.workspaces,exact:!0})})}function Ar(){return Z(e=>Y(W.deleteWorkspace(e)))}function jr(){return D({queryKey:X.archive,queryFn:()=>Y(W.listArchive())})}function Z(e){let t=h();return O({mutationFn:e,onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:X.tasks}),t.invalidateQueries({queryKey:X.workspaces,exact:!0}),t.invalidateQueries({queryKey:X.archive}),t.invalidateQueries({queryKey:[`review`]})])})}function Mr(){return Z(e=>Y(W.restoreWorkspace(e)))}function Nr(){return Z(e=>Y(W.purgeWorkspace(e)))}function Pr(){return Z(e=>Y(W.restoreTask(e)))}function Fr(){return Z(e=>Y(W.purgeTask(e)))}var Ir=[`planned`,`in_progress`,`in_review`];function Q(e){return Y(W.listTasks(e))}async function Lr(e){let t=Q({statuses:[`done`],before:e,limit:100}),n=e=>e.length<100?null:Math.min(...e.map(e=>e.id));if(e!==null){let e=await t;return{tasks:e,olderBefore:n(e)}}let[r,i]=await Promise.all([Q({statuses:Ir}),t]),a=new Set([...r,...i].map(e=>e.id)),o=[...new Set(r.flatMap(e=>e.dependsOn))].filter(e=>!a.has(e)),s=[];for(let e=0;e<o.length;e+=100)s.push(o.slice(e,e+100));let c=await Promise.all(s.map(e=>Q({ids:e})));return{tasks:[...r,...i,...c.flat()],olderBefore:n(i)}}function Rr(e){let t=new Map;for(let n of e.pages)for(let e of n.tasks)t.set(e.id,e);return[...t.values()].sort((e,t)=>e.id-t.id)}function zr(e){let t=e.getQueryData(X.tasks);return t===void 0?void 0:Rr(t)}function Br(e=[]){let t=ct({queryKey:X.tasks,queryFn:({pageParam:e})=>Lr(e),initialPageParam:null,getNextPageParam:e=>e.olderBefore,select:Rr}),n=t.data,r=new Set(n?.map(e=>e.id)),i=[...new Set(e.filter(e=>e!=null&&!r.has(e)))].sort((e,t)=>e-t),a=D({queryKey:[...X.tasks,`by-id`,i],queryFn:()=>Q({ids:i}),enabled:n!==void 0&&i.length>0}),o=i.length===0?[]:a.data??[];return n===void 0||o.length===0?t:{...t,data:[...n,...o].sort((e,t)=>e.id-t.id)}}function Vr(e,t){return D({queryKey:X.review(e,t),queryFn:()=>Y(W.reviewPeriod(e,t))})}function Hr(){return D({queryKey:X.reviewTimeZone,queryFn:()=>Y(W.getReviewTimeZone())})}function Ur(){let e=h();return O({mutationFn:e=>Y(W.setReviewTimeZone(e)),onSuccess:()=>e.invalidateQueries({queryKey:[`review`]})})}function Wr(){return D({queryKey:X.reviewSnapshots,queryFn:()=>Y(W.listReviewSnapshots())})}function Gr(e){return D({queryKey:X.reviewSnapshot(e??0),queryFn:()=>Y(W.getReviewSnapshot(e??0)),enabled:e!==null,staleTime:1/0})}function Kr(){let e=h();return O({mutationFn:e=>Y(W.saveReviewSnapshot(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.reviewSnapshots})})}function qr(){let e=h();return O({mutationFn:e=>Y(W.deleteReviewSnapshot(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.reviewSnapshots})})}function Jr(){let e=h();(0,f.useEffect)(()=>{let t=[An.tasksChanged.listen(async()=>{let t=zr(e);await e.invalidateQueries({queryKey:X.tasks}),!(t===void 0||document.hasFocus())&&gr(hr(t,zr(e)??[])).catch(e=>console.error(`toodo: failed to show status notifications`,e))}),An.workspacesChanged.listen(()=>e.invalidateQueries({queryKey:X.workspaces,exact:!0}))];return()=>{for(let e of t)e.then(e=>e())}},[e])}function Yr(){let e=h();return O({mutationFn:e=>Y(W.startTask(e,null,null)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}function Xr(){let e=h();return O({mutationFn:e=>Y(W.completeTask(e,null,null)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Zr(){let e=h();return O({mutationFn:({id:e,note:t,shippedWith:n=null})=>Y(W.concludeTask(e,t,n===null?`not_adopted`:`shipped_with`,n)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Qr(){let e=h();return O({mutationFn:({id:e,note:t})=>Y(W.setCompletionNote(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function $r(){let e=h();return O({mutationFn:({id:e,reason:t})=>Y(W.reopenTask(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function ei(){let e=h();return O({mutationFn:({id:e,resolution:t,note:n})=>Y(W.setTaskOutcome(e,t,n)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function ti(){let e=h();return O({mutationFn:e=>Y(W.updateTask(e)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function $(e){let t=h();return O({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:X.tasks})})}function ni(){return $(e=>Y(W.pauseTask(e)))}function ri(){return $(({taskId:e,criterionId:t,met:n,evidence:r})=>Y(W.checkCriterion(e,t,n,r)))}function ii(){return Z(e=>Y(W.deleteTask(e)))}function ai(){return $(({id:e,dependsOn:t,confirmPause:n})=>Y(W.addDependency(e,t,n)))}function oi(){return $(({id:e,dependsOn:t})=>Y(W.removeDependency(e,t)))}function si(){return D({queryKey:X.taskRelations,queryFn:()=>Y(W.listTaskRelations())})}function ci(e){let t=h();return O({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:X.taskRelations})})}function li(){return ci(({taskId:e,relatedId:t})=>Y(W.addTaskRelation(e,t)))}function ui(){return ci(({taskId:e,relatedId:t})=>Y(W.removeTaskRelation(e,t)))}function di(){let e=h();return O({mutationFn:e=>Y(W.createTask(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}export{Gn as $,oe as $t,Gr as A,P as At,si as B,ht as Bt,oi as C,Ct,Pr as D,A as Dt,Cr as E,Dt as Et,Jr as F,St as Ft,Dr as G,Le as Gt,ti as H,O as Ht,Qr as I,ut as It,nr as J,Ce as Jt,ir as K,Ee as Kt,Ur as L,pt as Lt,Hr as M,yt as Mt,Sr as N,dt as Nt,Mr as O,wt as Ot,Kr as P,M as Pt,or as Q,se as Qt,ei as R,ft as Rt,Nr as S,F as St,$r as T,lt as Tt,kr as U,D as Ut,Br as V,xt as Vt,Er as W,qe as Wt,Jn as X,ne as Xt,cr as Y,w as Yt,ar as Z,x as Zt,Tr as _,qt as _t,jr as a,g as an,On as at,ni as b,jt as bt,yr as c,hn as ct,Zr as d,un as dt,ae as en,Kn as et,di as f,cn as ft,Ar as g,Yt as gt,ii as h,V as ht,li as i,_e as in,W as it,Wr as j,j as jt,Vr as k,Et as kt,ri as l,dn as lt,qr as m,Zt as mt,Y as n,S as nn,Un as nt,br as o,h as on,Dn as ot,Or as p,en as pt,rr as q,T as qt,ai as r,b as rn,qn as rt,xr as s,yn as st,X as t,y as tn,Wn as tt,Xr as u,H as ut,wr as v,L as vt,ui as w,bt as wt,Fr as x,I as xt,vr as y,Pt as yt,Yr as z,mt as zt};
1
+ import{i as e,r as t,s as n,t as r}from"./dist-ZmB2kPfR.js";import{d as i,i as a,m as o,n as s,o as c,p as l,r as u,s as d}from"./event-DMqRNLc_.js";var f=n(e(),1),p=t(),m=f.createContext(void 0),h=e=>{let t=f.useContext(m);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},g=({client:e,children:t})=>(f.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,p.jsx)(m.Provider,{value:e,children:t})),_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function ee(e){setTimeout(e,0)}var te=typeof window>`u`||`Deno`in globalThis;function y(){}function ne(e,t){return typeof e==`function`?e(t):e}function re(e){return typeof e==`number`&&e>=0&&e!==1/0}function ie(e,t){return Math.max(e+(t||0)-Date.now(),0)}function b(e,t){return typeof e==`function`?e(t):e}function ae(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==se(o,t.options))return!1}else if(!S(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function oe(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(x(t.options.mutationKey)!==x(a))return!1}else if(!S(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function se(e,t){return(t?.queryKeyHashFn||x)(e)}function x(e){return JSON.stringify(e,(e,t)=>de(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function S(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!S(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!S(e[r],t[r]))return!1;return!0}return!1}var ce=Object.prototype.hasOwnProperty;function le(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ue(e)&&ue(t);if(!r&&!(de(e)&&de(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ce.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=le(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function C(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ue(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function de(e){if(!fe(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!fe(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function fe(e){return Object.prototype.toString.call(e)===`[object Object]`}function pe(e){return new Promise(t=>{v.setTimeout(t,e)})}function me(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:le(e,t)}function he(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function ge(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var _e=Symbol();function ve(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===_e?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ye(e,t){return typeof e==`function`?e(...t):!!e}function be(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var xe=()=>te,Se=()=>xe(),w=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ce=new class extends w{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},we=ee;function Te(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=we,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var T=Te(),Ee=new class extends w{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function De(e){return Math.min(1e3*2**e,3e4)}function Oe(e){return(e??`online`)!==`online`||Ee.isOnline()}var ke=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ae(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(y);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new ke(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Ce.isFocused()&&(e.networkMode===`always`||Ee.isOnline())&&e.canRun(),p=()=>Oe(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(Se()?0:3),a=e.retryDelay??De,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?h(r):(n++,e.onFail?.(n,r),pe(o).then(()=>f()?void 0:g(f)).then(()=>{t?h(r):_()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g(p).then(_),s)}}var je=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),re(this.gcTime)&&(this.#e=v.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Se()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(v.clearTimeout(this.#e),this.#e=void 0)}};function Me(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{be(e,()=>t.signal,()=>n=!0)},u=ve(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?ge:he;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Pe:Ne,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ne(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ne(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Pe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Fe(e,t){return t?Ne(e,t)!=null:!1}function Ie(e,t){return!t||!e.getPreviousPageParam?!1:Pe(e,t)!=null}var Le=class extends je{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Be(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Be(this.options);e.data!==void 0&&(this.setState(ze(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=me(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(y).catch(y):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_e||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>b(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!ie(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ve(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Me(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Ae({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ke&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ke){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Re(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...ze(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),T.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Re(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Oe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ze(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Be(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Ve=class extends w{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ue(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return We(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return We(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof b(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!C(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ge(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||b(this.options.staleTime,this.#t)!==b(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return C(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(y)),t}#h(e){return!Se()&&b(this.options.enabled,this.#t)!==!1&&re(e)}#g(){this.#b();let e=b(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=ie(this.#r.dataUpdatedAt,e)+1;this.#u=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return b(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=v.setInterval(()=>{(this.options.refetchIntervalInBackground||Ce.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(v.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(v.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ue(e,t),o=i&&Ge(e,n,t,r);(a||o)&&(l={...l,...Re(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=me(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=me(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,ee=_&&g,te=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:ee,isLoading:ee,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!te,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&te,isStale:E(e,t),refetch:this.refetch,isEnabled:b(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),C(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();T.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function He(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||b(t.retryOnMount,e)!==!1)}function Ue(e,t){return He(e,t)||e.state.data!==void 0&&We(e,t,t.refetchOnMount)}function We(e,t,n){if(b(t.enabled,e)!==!1&&b(t.staleTime,e)!==`static`){let r=b(n,e);return r===`always`||r!==!1&&E(e,t)}return!1}function Ge(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&E(e,n)}function E(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(b(t.staleTime,e))}var Ke=class extends Ve{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Fe(t,n.data),hasPreviousPage:Ie(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},qe=class extends je{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Je(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Ae({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),T.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Je(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ye=class extends w{#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&&x(t.mutationKey)!==x(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??Je();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){T.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)})})}},Xe=f.createContext(!1),Ze=()=>f.useContext(Xe);Xe.Provider;function Qe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $e=f.createContext(Qe()),et=()=>f.useContext($e),tt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ye(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},nt=e=>{f.useEffect(()=>{e.clearReset()},[e])},rt=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ye(n,[e.error,r])),it=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},at=(e,t)=>e?.suspense&&t.isPending,ot=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function st(e,t,n){let r=Ze(),i=et(),a=h(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,it(o),tt(o,i,s),nt(i);let[l]=f.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(f.useSyncExternalStore(f.useCallback(e=>{let t=d?l.subscribe(T.batchCalls(e)):y;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),f.useEffect(()=>{l.setOptions(o)},[o,l]),at(o,u))throw ot(o,l,i);if(rt({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function D(e,t){return st(e,Ve,t)}function O(e,t){let n=h(t),[r]=f.useState(()=>new Ye(n,e));f.useEffect(()=>{r.setOptions(e)},[r,e]);let i=f.useSyncExternalStore(f.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=f.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(y)},[r]);if(i.error&&ye(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function ct(e,t){return st(e,Ke,t)}function k(){return typeof window<`u`}function A(e){return ut(e)?(e.nodeName||``).toLowerCase():`#document`}function j(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function lt(e){return((ut(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ut(e){return k()?e instanceof Node||e instanceof j(e).Node:!1}function dt(e){return k()?e instanceof Element||e instanceof j(e).Element:!1}function M(e){return k()?e instanceof HTMLElement||e instanceof j(e).HTMLElement:!1}function ft(e){return!k()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof j(e).ShadowRoot}function pt(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ct(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function mt(e){return/^(table|td|th)$/.test(A(e))}function ht(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var gt=/transform|translate|scale|rotate|perspective|filter/,_t=/paint|layout|strict|content/,N=e=>!!e&&e!==`none`,vt;function yt(e){let t=dt(e)?Ct(e):e;return N(t.transform)||N(t.translate)||N(t.scale)||N(t.rotate)||N(t.perspective)||!xt()&&(N(t.backdropFilter)||N(t.filter))||gt.test(t.willChange||``)||_t.test(t.contain||``)}function bt(e){let t=P(e);for(;M(t)&&!St(t);){if(yt(t))return t;if(ht(t))return null;t=P(t)}return null}function xt(){return vt??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),vt}function St(e){return/^(html|body|#document)$/.test(A(e))}function Ct(e){return j(e).getComputedStyle(e)}function wt(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function P(e){if(A(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ft(e)&&e.host||lt(e);return ft(t)?t.host:t}function Tt(e){let t=P(e);return St(t)?(e.ownerDocument||e).body:M(t)&&pt(t)?t:Tt(t)}function Et(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Tt(e),i=r===e.ownerDocument?.body,a=j(r);if(i){let e=Dt(a);return t.concat(a,a.visualViewport||[],pt(r)?r:[],e&&n?Et(e):[])}return t.concat(r,Et(r,[],n))}function Dt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var F={...f},Ot={};function I(e,t){let n=f.useRef(Ot);return n.current===Ot&&(n.current=e(t)),n}var kt=F.useInsertionEffect,At=kt&&kt!==F.useLayoutEffect?kt:e=>e();function jt(e){let t=I(Mt).current;return t.next=e,At(t.effect),t.trampoline}function Mt(){let e={next:void 0,callback:Nt,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Nt(){}var Pt=typeof document<`u`?f.useLayoutEffect:()=>{};function Ft(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var It={};function L(e,t,n,r,i){if(!n&&!r&&!i&&!e)return R(t);let a=R(e);return t&&(a=z(a,t)),n&&(a=z(a,n)),r&&(a=z(a,r)),i&&(a=z(a,i)),a}function Lt(e){if(e.length===0)return It;if(e.length===1)return R(e[0]);let t=R(e[0]);for(let n=1;n<e.length;n+=1)t=z(t,e[n]);return t}function R(e){return Vt(e)?{...e(It)}:Rt(e)}function z(e,t){return Vt(t)?t(e):zt(e,t)}function Rt(e){let t={...e};for(let e in t){let n=t[e];Bt(e,n)&&(t[e]=Ut(n))}return t}function zt(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Ft(e.style,r);break;case`className`:e[n]=Wt(e.className,r);break;default:e[n]=Bt(n,r)?Ht(e[n],r):r}}return e}function Bt(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Vt(e){return typeof e==`function`}function Ht(e,t){return t?e?(...n)=>{let r=n[0];if(Gt(r)){let i=r;B(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Ut(t):e}function Ut(e){return e&&((...t)=>{let n=t[0];return Gt(n)&&B(n),e(...t)})}function B(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Wt(e,t){return t?e?t+` `+e:t:e}function Gt(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Kt(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var qt=Kt(`https://base-ui.com/production-error`,`Base UI`),Jt=f.createContext(void 0);function Yt(e=!1){let t=f.useContext(Jt);if(t===void 0&&!e)throw Error(qt(16));return t}function Xt(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:f.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function V(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(j(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Zt(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=f.useRef(null),s=Yt(!0),c=a??s!==void 0,{props:l}=Xt({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=f.useCallback(()=>{let e=o.current;Qt(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Pt(u,[u]),{getButtonProps:f.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return L({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(B(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Qt(r),s=!i&&$t(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),V(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),V(r,e)))},onKeyUp(e){t||(B(e),a?.(e),e.target===e.currentTarget&&i&&c&&Qt(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),V(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:jt(e=>{o.current=e,u()})}}function Qt(e){return M(e)&&e.tagName===`BUTTON`}function $t(e){return M(e)&&e.tagName===`A`&&!!e.href}function en(e,t,n,r){let i=I(nn).current;return rn(i,e,t,n,r)&&on(i,[e,t,n,r]),i.callback}function tn(e){let t=I(nn).current;return an(t,e)&&on(t,e),t.callback}function nn(){return{callback:null,cleanup:null,refs:[]}}function rn(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function an(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function on(e,t){e.refs=t,e.callback=t.every(e=>e==null)?null:n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var sn=19;function cn(e){return sn>=e}function ln(e){if(!f.isValidElement(e))return null;let t=e,n=t.props;return(cn(19)?n?.ref:t.ref)??null}function un(){}var dn=Object.freeze([]),H=Object.freeze({});function fn(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e)}else i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function pn(e,t){return typeof e==`function`?e(t):e}function mn(e,t){return typeof e==`function`?e(t):e}function hn(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=yn(r));let i=gn(t,n,r);if(n.enabled===!1)return null;let a=n.state??H;return bn(e,r,i,a)}function gn(e,t,n){let{className:r,style:i}=e,{state:a=H,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?pn(r,a):void 0,d=l?mn(i,a):void 0,f=l?fn(a,c):H,p=l&&s?_n(s):void 0,m=l?Ft(f,p)??{}:H;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?tn([m.ref,ln(n),...o]):en(m.ref,ln(n),o):en(null,null)),l?(u!==void 0&&(m.className=Wt(m.className,u)),d!==void 0&&(m.style=Ft(m.style,d)),m):H}function _n(e){return Array.isArray(e)?Lt(e):L(void 0,e)}var vn=Symbol.for(`react.lazy`);function yn(e){if(e?.$$typeof!==vn)return e;let t=f.Children.toArray(e)[0];return f.isValidElement(t)?t:e}function bn(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=L(n,t.props);return e.ref=n.ref,f.cloneElement(t,e)}return xn(e,n)}function xn(e,t){return e===`button`?(0,f.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,f.createElement)(`img`,{alt:``,...t,key:t.key}):f.createElement(e,t)}var Sn=f.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=Zt({disabled:i,focusableWhenDisabled:a,native:o});return hn(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})});function Cn(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Cn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function wn(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Cn(e))&&(r&&(r+=` `),r+=t);return r}var Tn=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,En=wn,Dn=((e,t)=>n=>{if(t?.variants==null)return En(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Tn(t)||Tn(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return En(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 motion-safe:active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:text-muted-foreground aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 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 max-md:min-h-11 max-md:min-w-11`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80 disabled:bg-muted`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/10 dark:hover:bg-input/20`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground disabled:bg-muted`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 disabled:bg-muted focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] max-md:text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function On({className:e,variant:t=`default`,size:n=`default`,autoFocus:a,changesData:s,disabled:c,...l}){let u=(0,f.useSyncExternalStore)(o,i),d=u===`unreachable`||u===`retrying`,m=s??l.type===`submit`,h=(0,f.useRef)(null);return(0,f.useEffect)(()=>{a&&h.current?.focus()},[]),(0,p.jsx)(Sn,{ref:h,"data-slot":`button`,disabled:c||m&&d,className:r(Dn({variant:t,size:n,className:e})),...l})}function kn(e){return typeof e==`object`&&!!e&&typeof e.kind==`string`&&typeof e.code==`string`&&typeof e.message==`string`}async function U(e,t={}){let n=d();if(n===null)throw Error(`No access token for the Toodo server.`);let r=await l(`/api/rpc/${encodeURIComponent(e)}`,{method:`POST`,headers:{...a(n),"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.status===401)throw c(),Error(`The Toodo server did not accept the access token.`);let i=await r.text();if(r.ok)return i?JSON.parse(i):null;let o=null;try{o=JSON.parse(i)}catch{}throw kn(o)?o:Error(i||`${r.status} ${r.statusText}`)}var W={appInfo:()=>U(`app_info`),checkUpdate:()=>U(`check_update`),listWorkspaces:()=>G(U(`list_workspaces`)),getWorkspace:e=>G(U(`get_workspace`,{id:e})),createWorkspace:e=>G(U(`create_workspace`,{workspace:e})),updateWorkspace:e=>G(U(`update_workspace`,{workspace:e})),deleteWorkspace:e=>G(U(`delete_workspace`,{id:e})),restoreWorkspace:e=>G(U(`restore_workspace`,{id:e})),purgeWorkspace:e=>G(U(`purge_workspace`,{id:e})),listArchive:()=>G(U(`list_archive`)),listTasks:e=>G(U(`list_tasks`,{filter:e})),listTaskRelations:()=>G(U(`list_task_relations`)),addTaskRelation:(e,t)=>G(U(`add_task_relation`,{taskId:e,relatedId:t})),removeTaskRelation:(e,t)=>G(U(`remove_task_relation`,{taskId:e,relatedId:t})),getTask:e=>G(U(`get_task`,{id:e})),createTask:e=>G(U(`create_task`,{task:e})),updateTask:e=>G(U(`update_task`,{task:e})),pauseTask:e=>G(U(`pause_task`,{id:e})),setCompletionNote:(e,t)=>G(U(`set_completion_note`,{id:e,note:t})),reopenTask:(e,t)=>G(U(`reopen_task`,{id:e,reason:t})),setTaskOutcome:(e,t,n)=>G(U(`set_task_outcome`,{id:e,resolution:t,note:n})),checkCriterion:(e,t,n,r)=>G(U(`check_criterion`,{taskId:e,criterionId:t,met:n,evidence:r})),deleteTask:e=>G(U(`delete_task`,{id:e})),restoreTask:e=>G(U(`restore_task`,{id:e})),purgeTask:e=>G(U(`purge_task`,{id:e})),addDependency:(e,t,n)=>G(U(`add_dependency`,{taskId:e,dependsOn:t,confirmPause:n})),removeDependency:(e,t)=>G(U(`remove_dependency`,{taskId:e,dependsOn:t})),startTask:(e,t,n)=>G(U(`start_task`,{id:e,reason:t,refs:n})),completeTask:(e,t,n)=>G(U(`complete_task`,{id:e,note:t,refs:n})),concludeTask:(e,t,n,r)=>G(U(`conclude_task`,{id:e,note:t,outcome:n,shippedWith:r})),linkIssue:(e,t)=>G(U(`link_issue`,{id:e,reference:t})),mcpServerInfo:()=>U(`mcp_server_info`),listConnectedApps:()=>G(U(`list_connected_apps`)),revokeConnectedApp:e=>G(U(`revoke_connected_app`,{grantId:e})),reviewPeriod:(e,t)=>G(U(`review_period`,{from:e,to:t})),reviewReport:e=>G(U(`review_report`,{request:e})),getReviewTimeZone:()=>G(U(`get_review_time_zone`)),setReviewTimeZone:e=>G(U(`set_review_time_zone`,{timeZone:e})),saveReviewSnapshot:e=>G(U(`save_review_snapshot`,{request:e})),listReviewSnapshots:()=>G(U(`list_review_snapshots`)),getReviewSnapshot:e=>G(U(`get_review_snapshot`,{id:e})),deleteReviewSnapshot:e=>G(U(`delete_review_snapshot`,{id:e})),getBackupSettings:()=>U(`get_backup_settings`),getBackupStatus:()=>U(`get_backup_status`),saveBackupSettings:e=>G(U(`save_backup_settings`,{settings:e})),listBackups:()=>G(U(`list_backups`)),restoreBackup:e=>G(U(`restore_backup`,{name:e}))},An={tasksChanged:jn(`tasks-changed`),workspacesChanged:jn(`workspaces-changed`)};async function G(e){try{return{status:`ok`,data:await e}}catch(e){if(e instanceof Error)throw e;return{status:`error`,error:e}}}function jn(e){return{listen:t=>s(e,t)}}function Mn(e){switch(e.code){case`unknownCommand`:case`invalidArguments`:return`This page is out of date with the Toodo server. Reload the page, then try again.`;case`commandPanicked`:return`Something went wrong on the Toodo server. Try again; if it keeps failing, look for "a command panicked" in the toodo-server log.`;case`storageFailed`:return`The Toodo server could not use its database (${e.message}). Try again; if it keeps failing, check the toodo-server log.`;default:return e.message}}function Nn(e,t){return/filename="([^"]+)"/.exec(e.headers.get(`Content-Disposition`)??``)?.[1]??t}function Pn(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}async function Fn(){let e=await u(`/api/backups/export`),t=Nn(e,`toodo-backup.sqlite3`);return Pn(t,await e.blob()),t}async function In(e){return Pn(e,await(await u(`/api/backups/${encodeURIComponent(e)}`)).blob()),e}async function Ln(e){return await(await u(`/api/backups/restore`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e})).json()}var Rn=`toodo-install-dismissed`;function zn(){let{userAgent:e,maxTouchPoints:t}=navigator;return/iPhone|iPad|iPod/.test(e)||e.includes(`Macintosh`)&&t>1}function Bn(){return matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0}var K=null,Vn=!1,Hn=new Set;function q(){Hn.forEach(e=>e())}function Un(e){return Hn.add(e),()=>Hn.delete(e)}function Wn(){return Vn||Bn()||localStorage.getItem(Rn)!==null?`none`:K===null?zn()?`home-screen`:`none`:`prompt`}function Gn(){localStorage.setItem(Rn,`1`),q()}async function Kn(){let e=K;if(e===null)return;K=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`dismissed`?Gn():q()}function qn(){addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),K=e,q()}),addEventListener(`appinstalled`,()=>{K=null,Vn=!0,q()})}function Jn(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window?`supported`:zn()&&!Bn()?`needs-install`:`unsupported`}var J=null,Yn={agent:[],pullRequests:[],completion:[`Task awaiting completion`]};function Xn(e){return J!==null&&Object.keys(Yn).some(t=>J?.[t]===!0&&Yn[t].includes(e))}function Zn(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function Qn(e,t){let n=e.options.applicationServerKey;return n===null||n.byteLength===t.length&&new Uint8Array(n).every((e,n)=>e===t[n])}function $n(){return navigator.serviceWorker.getRegistration()}async function er(e){let t=await(await $n())?.pushManager.getSubscription()??null;return t===null||Qn(t,e)?t:(await t.unsubscribe(),null)}async function tr(e){return await(await u(`/api/push/subscription`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.toJSON())})).json()}async function nr(){let e=await(await u(`/api/push`)).json(),t=await er(Zn(e.publicKey)),n=t===null?null:t.endpoint===e.subscription?.endpoint?e.subscription:await tr(t);return J=n?.settings??null,{publicKey:e.publicKey,permission:Notification.permission,subscription:n}}async function rr(e,t){if(await e!==`granted`)throw Error(`Notifications were not allowed.`);if(await $n()===void 0)throw Error(`Notifications need the service worker, which only the built app installs.`);let{pushManager:n}=await navigator.serviceWorker.ready,r=Zn(t),i=await er(r)??await n.subscribe({userVisibleOnly:!0,applicationServerKey:r});try{let e=await tr(i);return J=e.settings,e}catch(e){throw await i.unsubscribe(),e}}async function ir(){await(await(await $n())?.pushManager.getSubscription())?.unsubscribe(),J=null,await u(`/api/push/subscription`,{method:`DELETE`})}async function ar(e){let t=await(await u(`/api/push/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();return J=t.settings,t}async function or(){await u(`/api/push/test`,{method:`POST`})}var sr=`toodo-open-task`;function cr(e){if(!(`serviceWorker`in navigator))return()=>{};let t=navigator.serviceWorker,n=({data:t})=>{typeof t==`object`&&t&&`type`in t&&t.type===sr&&`taskId`in t&&typeof t.taskId==`number`&&e(t.taskId)};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}async function lr(){return`Notification`in window&&Notification.permission===`granted`}async function ur(){return`Notification`in window?Notification.requestPermission():`denied`}function dr(e){Xn(e.title)||new Notification(e.title,{body:e.body})}var fr={planned:`Planned`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`};function pr(e){return e.status===`done`&&e.resolution===`completed`?`Completed`:e.status===`done`&&e.resolution===`not_adopted`?`Not adopted`:fr[e.status]}function mr(e,t){switch(t.status){case`in_progress`:return`Task started`;case`in_review`:return`Task awaiting completion`;case`done`:return t.resolution===`not_adopted`?`Task concluded without merging`:`Task done`;case`planned`:return e===`in_progress`?`Task paused`:`Task status changed`}}function hr(e,t){let n=new Map(e.map(e=>[e.id,e.status]));return t.flatMap(e=>{let t=n.get(e.id);return t===void 0||t===e.status?[]:[{title:mr(t,e),body:`#${e.id} ${e.title}: ${fr[t]} -> ${pr(e)}`}]})}async function gr(e){if(e.length!==0&&(await lr()||await ur()===`granted`))for(let t of e)dr(t)}var _r=class extends Error{kind;code;constructor(e){super(Mn(e)),this.name=`CommandFailure`,this.kind=e.kind,this.code=e.code}};async function Y(e){let t=await e;if(t.status===`error`)throw new _r(t.error);return t.data}var X={workspaces:[`workspaces`],tasks:[`task-list`,`pages`],taskRelations:[`tasks`,`relations`],archive:[`tasks`,`archive`],backups:[`backups`],backupSettings:[`backup-settings`],backupStatus:[`backup-status`],mcpServerInfo:[`mcp-server-info`],review:(e,t)=>[`review`,e,t],reviewTimeZone:[`review`,`time-zone`],reviewSnapshots:[`review-snapshots`],reviewSnapshot:e=>[`review-snapshots`,e]};function vr(){return D({queryKey:X.mcpServerInfo,queryFn:()=>W.mcpServerInfo(),refetchInterval:5e3})}function yr(){return D({queryKey:X.backups,queryFn:()=>Y(W.listBackups())})}function br(){return D({queryKey:X.backupSettings,queryFn:()=>W.getBackupSettings()})}function xr(){return D({queryKey:X.backupStatus,queryFn:()=>W.getBackupStatus(),refetchInterval:6e4})}function Sr(){let e=h();return O({mutationFn:e=>Y(W.saveBackupSettings(e)),onSuccess:t=>(e.setQueryData(X.backupSettings,t),Promise.all([e.invalidateQueries({queryKey:X.backups}),e.invalidateQueries({queryKey:X.backupStatus})]))})}function Cr(){let e=h();return O({mutationFn:e=>Y(W.restoreBackup(e)),onSuccess:()=>e.invalidateQueries()})}function wr(){return O({mutationFn:Fn})}function Tr(){return O({mutationFn:In})}function Er(){let e=h();return O({mutationFn:Ln,onSuccess:()=>e.invalidateQueries()})}function Dr(){return D({queryKey:X.workspaces,queryFn:()=>Y(W.listWorkspaces())})}function Or(){let e=h();return O({mutationFn:e=>Y(W.createWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.workspaces})})}function kr(){let e=h();return O({mutationFn:e=>Y(W.updateWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.workspaces,exact:!0})})}function Ar(){return Z(e=>Y(W.deleteWorkspace(e)))}function jr(){return D({queryKey:X.archive,queryFn:()=>Y(W.listArchive())})}function Z(e){let t=h();return O({mutationFn:e,onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:X.tasks}),t.invalidateQueries({queryKey:X.workspaces,exact:!0}),t.invalidateQueries({queryKey:X.archive}),t.invalidateQueries({queryKey:[`review`]})])})}function Mr(){return Z(e=>Y(W.restoreWorkspace(e)))}function Nr(){return Z(e=>Y(W.purgeWorkspace(e)))}function Pr(){return Z(e=>Y(W.restoreTask(e)))}function Fr(){return Z(e=>Y(W.purgeTask(e)))}var Ir=[`planned`,`in_progress`,`in_review`];function Q(e){return Y(W.listTasks(e))}async function Lr(e){let t=Q({statuses:[`done`],before:e,limit:100}),n=e=>e.length<100?null:Math.min(...e.map(e=>e.id));if(e!==null){let e=await t;return{tasks:e,olderBefore:n(e)}}let[r,i]=await Promise.all([Q({statuses:Ir}),t]),a=new Set([...r,...i].map(e=>e.id)),o=[...new Set(r.flatMap(e=>e.dependsOn))].filter(e=>!a.has(e)),s=[];for(let e=0;e<o.length;e+=100)s.push(o.slice(e,e+100));let c=await Promise.all(s.map(e=>Q({ids:e})));return{tasks:[...r,...i,...c.flat()],olderBefore:n(i)}}function Rr(e){let t=new Map;for(let n of e.pages)for(let e of n.tasks)t.set(e.id,e);return[...t.values()].sort((e,t)=>e.id-t.id)}function zr(e){let t=e.getQueryData(X.tasks);return t===void 0?void 0:Rr(t)}function Br(e=[]){let t=ct({queryKey:X.tasks,queryFn:({pageParam:e})=>Lr(e),initialPageParam:null,getNextPageParam:e=>e.olderBefore,select:Rr}),n=t.data,r=new Set(n?.map(e=>e.id)),i=[...new Set(e.filter(e=>e!=null&&!r.has(e)))].sort((e,t)=>e-t),a=D({queryKey:[...X.tasks,`by-id`,i],queryFn:()=>Q({ids:i}),enabled:n!==void 0&&i.length>0}),o=i.length===0?[]:a.data??[];return n===void 0||o.length===0?t:{...t,data:[...n,...o].sort((e,t)=>e.id-t.id)}}function Vr(e,t){return D({queryKey:X.review(e,t),queryFn:()=>Y(W.reviewPeriod(e,t))})}function Hr(){return D({queryKey:X.reviewTimeZone,queryFn:()=>Y(W.getReviewTimeZone())})}function Ur(){let e=h();return O({mutationFn:e=>Y(W.setReviewTimeZone(e)),onSuccess:()=>e.invalidateQueries({queryKey:[`review`]})})}function Wr(){return D({queryKey:X.reviewSnapshots,queryFn:()=>Y(W.listReviewSnapshots())})}function Gr(e){return D({queryKey:X.reviewSnapshot(e??0),queryFn:()=>Y(W.getReviewSnapshot(e??0)),enabled:e!==null,staleTime:1/0})}function Kr(){let e=h();return O({mutationFn:e=>Y(W.saveReviewSnapshot(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.reviewSnapshots})})}function qr(){let e=h();return O({mutationFn:e=>Y(W.deleteReviewSnapshot(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.reviewSnapshots})})}function Jr(){let e=h();(0,f.useEffect)(()=>{let t=[An.tasksChanged.listen(async()=>{let t=zr(e);await e.invalidateQueries({queryKey:X.tasks}),!(t===void 0||document.hasFocus())&&gr(hr(t,zr(e)??[])).catch(e=>console.error(`toodo: failed to show status notifications`,e))}),An.workspacesChanged.listen(()=>e.invalidateQueries({queryKey:X.workspaces,exact:!0}))];return()=>{for(let e of t)e.then(e=>e())}},[e])}function Yr(){let e=h();return O({mutationFn:e=>Y(W.startTask(e,null,null)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}function Xr(){let e=h();return O({mutationFn:e=>Y(W.completeTask(e,null,null)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Zr(){let e=h();return O({mutationFn:({id:e,note:t,shippedWith:n=null})=>Y(W.concludeTask(e,t,n===null?`not_adopted`:`shipped_with`,n)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Qr(){let e=h();return O({mutationFn:({id:e,note:t})=>Y(W.setCompletionNote(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function $r(){let e=h();return O({mutationFn:({id:e,reason:t})=>Y(W.reopenTask(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function ei(){let e=h();return O({mutationFn:({id:e,resolution:t,note:n})=>Y(W.setTaskOutcome(e,t,n)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function ti(){let e=h();return O({mutationFn:e=>Y(W.updateTask(e)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function $(e){let t=h();return O({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:X.tasks})})}function ni(){return $(e=>Y(W.pauseTask(e)))}function ri(){return $(({taskId:e,criterionId:t,met:n,evidence:r})=>Y(W.checkCriterion(e,t,n,r)))}function ii(){return Z(e=>Y(W.deleteTask(e)))}function ai(){return $(({id:e,dependsOn:t,confirmPause:n})=>Y(W.addDependency(e,t,n)))}function oi(){return $(({id:e,dependsOn:t})=>Y(W.removeDependency(e,t)))}function si(){return D({queryKey:X.taskRelations,queryFn:()=>Y(W.listTaskRelations())})}function ci(e){let t=h();return O({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:X.taskRelations})})}function li(){return ci(({taskId:e,relatedId:t})=>Y(W.addTaskRelation(e,t)))}function ui(){return ci(({taskId:e,relatedId:t})=>Y(W.removeTaskRelation(e,t)))}function di(){let e=h();return O({mutationFn:e=>Y(W.createTask(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}export{Gn as $,oe as $t,Gr as A,P as At,si as B,ht as Bt,oi as C,Ct,Pr as D,A as Dt,Cr as E,Dt as Et,Jr as F,St as Ft,Dr as G,Le as Gt,ti as H,O as Ht,Qr as I,ut as It,nr as J,Ce as Jt,ir as K,Ee as Kt,Ur as L,pt as Lt,Hr as M,yt as Mt,Sr as N,dt as Nt,Mr as O,wt as Ot,Kr as P,M as Pt,or as Q,se as Qt,ei as R,ft as Rt,Nr as S,F as St,$r as T,lt as Tt,kr as U,D as Ut,Br as V,xt as Vt,Er as W,qe as Wt,Jn as X,ne as Xt,cr as Y,w as Yt,ar as Z,x as Zt,Tr as _,qt as _t,jr as a,g as an,On as at,ni as b,jt as bt,yr as c,hn as ct,Zr as d,un as dt,ae as en,Kn as et,di as f,cn as ft,Ar as g,Yt as gt,ii as h,V as ht,li as i,_e as in,W as it,Wr as j,j as jt,Vr as k,Et as kt,ri as l,dn as lt,qr as m,Zt as mt,Y as n,S as nn,Un as nt,br as o,h as on,Dn as ot,Or as p,en as pt,rr as q,T as qt,ai as r,b as rn,qn as rt,xr as s,yn as st,X as t,y as tn,Wn as tt,Xr as u,H as ut,wr as v,L as vt,ui as w,bt as wt,Fr as x,I as xt,vr as y,Pt as yt,Yr as z,mt as zt};
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{A as a,G as o,L as s,M as c,P as l,a as u,at as d,it as f,j as p,k as m,m as h,n as ee}from"./queries-Dt65Qzxx.js";import{a as g}from"./workspace-list-BKJMXO3z.js";import{A as _,C as te,D as v,E as y,It as b,K as ne,Lt as re,M as ie,Mt as x,N as S,O as C,P as ae,Pt as w,Rt as oe,S as se,T,Tt as E,V as D,_ as ce,b as O,bt as k,c as le,d as ue,f as A,g as j,h as M,ht as N,j as de,jt as P,k as fe,l as F,m as I,p as L,q as pe,s as me,u as R,v as z,vt as B,w as he,wt as V,x as H,xt as ge,y as U,yt as W}from"./index-DtWZQCfw.js";import{t as G}from"./opener-DWhHPoCL.js";var K={name:`calendar-check`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m9 15 2 2 4-4`,key:`1grp1n`}]]};K.node;var _e=t(K),q=r(e(),1),J=n(),ve={completed:w.success,opened_for_review:w.review,started:w.progress,worked_on:w.progress,planned:w.neutral},ye=i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,P.neutral),be=[{kind:`week`,label:`Week`},{kind:`month`,label:`Month`},{kind:`quarter`,label:`Quarter`},{kind:`year`,label:`Year`},{kind:`custom`,label:`Custom`}];function xe(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function Se({disabled:e,children:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>e.key===`Escape`&&r(!1);return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,J.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,J.jsxs)(d,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":n,disabled:e,onClick:()=>r(!n),children:[(0,J.jsx)(b,{}),(0,J.jsx)(`span`,{className:`max-md:sr-only`,children:`Export`})]}),n&&(0,J.jsx)(`div`,{role:`menu`,"aria-label":`Export review`,className:`absolute right-0 z-10 mt-1 flex w-48 flex-col rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:t(()=>r(!1))})]})}function Y(e,t){return`${e} ${t}${e===1?``:`s`}`}function X({onSelect:e,children:t}){return(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:e,className:`rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted max-md:min-h-11`,children:t})}function Ce(){let e=c(),t=s(),[n,r]=(0,q.useState)(!1),[a,o]=(0,q.useState)(``),[l,u]=(0,q.useState)(null),f=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];async function p(e){u(null);try{await t.mutateAsync(e),r(!1)}catch(e){u(e instanceof Error?e.message:String(e))}}if(!e.data)return null;let{timeZone:m,configured:h}=e.data;return n?(0,J.jsxs)(`form`,{"aria-label":`Review time zone`,className:`flex flex-wrap items-center gap-2 print:hidden`,onSubmit:e=>{e.preventDefault(),p(a)},children:[(0,J.jsx)(`label`,{htmlFor:`review-time-zone`,className:`text-xs`,children:`Time zone for every device`}),(0,J.jsx)(`input`,{id:`review-time-zone`,list:`review-time-zones`,required:!0,className:i(g,`w-56`),value:a,onChange:e=>o(e.target.value)}),(0,J.jsx)(`datalist`,{id:`review-time-zones`,children:f.map(e=>(0,J.jsx)(`option`,{value:e},e))}),(0,J.jsx)(d,{size:`sm`,type:`submit`,disabled:t.isPending,children:`Save`}),h!==null&&(0,J.jsx)(d,{size:`sm`,type:`button`,variant:`outline`,onClick:()=>void p(null),children:`Use the server's`}),(0,J.jsx)(d,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>r(!1),children:`Cancel`}),l&&(0,J.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-destructive`,children:l})]}):(0,J.jsxs)(`span`,{children:[`Days are in `,m,h===null&&` (the server's time zone)`,`.`,` `,(0,J.jsx)(`button`,{type:`button`,className:`text-primary underline underline-offset-2 hover:no-underline print:hidden`,onClick:()=>{o(h??m),r(!0)},children:`Change time zone`})]})}function Z({onShowTask:e}){let[t,n]=(0,q.useState)(()=>H(`week`,k(Date.now()/1e3))),[r,s]=(0,q.useState)(null),[c,y]=(0,q.useState)(U),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),w=m(t.from,t.to),T=p(),E=a(S),A=l(),j=h(),M=S!==null,N=M?E:w,de=o(),F=u(),I=M?E.data?.workspaces??[]:[...de.data??[],...F.data?.workspaces??[]],L=new Map(I.map(e=>[e.id,e.name])),R=M?E.data&&{period:{kind:E.data.summary.period,from:E.data.summary.from,to:E.data.summary.to},entries:E.data.entries,start:E.data.summary.start,end:E.data.summary.end,timeZone:E.data.summary.timeZone,now:E.data.summary.savedAt}:w.data&&{period:t,entries:w.data.entries,start:w.data.start,end:w.data.end,timeZone:w.data.timeZone,now:Date.now()/1e3},z=R?.period??t,V=R&&ue(R.entries,c),W=fe(R?.entries??[]);c.label!==null&&!W.includes(c.label)&&W.push(c.label);let G=[c.workspaceId===null?`across all workspaces`:`in ${L.get(c.workspaceId)??`workspace ${c.workspaceId}`}`,c.label!==null&&`labelled ${c.label}`].filter(Boolean).join(`, `),K=te[z.kind];function Z(e){s(null),n(e)}function Q(e){s(null),x(null),C(e)}async function ke(){try{let e=await A.mutateAsync({period:t.kind,from:t.from,to:t.kind===`custom`?t.to:null,workspaceId:c.workspaceId,label:c.label,title:null});s(`Saved "${e.title}" with ${Y(e.entryCount,`task`)}; reopen it from Saved reviews.`)}catch(e){s(`Could not save the review: ${e instanceof Error?e.message:String(e)}`)}}async function Ae(e){try{await j.mutateAsync(e),Q(null),s(`Deleted the saved review.`)}catch(e){s(`Could not delete the saved review: ${e instanceof Error?e.message:String(e)}`)}}function je(e){e!==t.kind&&Z(e===`custom`?{...t,kind:e}:H(e,t.from))}function Me(e){return M?E.data?Promise.resolve(e===`csv`?E.data.csv:E.data.markdown):Promise.reject(Error(`the saved review is still loading`)):ee(f.reviewReport({period:t.kind,date:null,from:t.from,to:t.kind===`custom`?t.to:null,format:e,timeZone:null,workspaceId:c.workspaceId,label:c.label}))}async function Ne(){try{let e=Me(`markdown`);if(typeof ClipboardItem>`u`)await navigator.clipboard.writeText((await e).contents);else{let t=e.then(({contents:e})=>new Blob([e],{type:`text/plain`}));await navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}s(`Copied as Markdown.`)}catch(e){s(`Could not copy: ${String(e)}`)}}async function $(e){try{let t=await Me(e);xe(t.fileName,t.contents,t.mediaType),s(`Downloaded ${t.fileName}`)}catch(e){s(`Could not export: ${String(e)}`)}}return(0,J.jsxs)(`section`,{"aria-labelledby":`review-heading`,className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h2`,{id:`review-heading`,className:`text-xl font-semibold tracking-tight`,children:M&&E.data?E.data.summary.title:he[z.kind]}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Work recorded from `,z.from,` to `,z.to,` `,G,`.`,` `,M?E.data&&(0,J.jsxs)(`span`,{children:[`Saved `,ge(E.data.summary.savedAt),`, with days in `,E.data.summary.timeZone,`; it stays as it was when saved.`]}):(0,J.jsx)(Ce,{})]})]}),(M||(T.data?.length??0)>0)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 print:hidden`,children:[(0,J.jsxs)(`select`,{"aria-label":`Saved reviews`,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-auto max-md:min-w-0 max-md:flex-1`),value:S??``,onChange:e=>Q(e.target.value===``?null:Number(e.target.value)),children:[(0,J.jsx)(`option`,{value:``,children:`Live review`}),T.data?.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.title,` (saved `,k(e.savedAt),`)`]},e.id))]}),S!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(d,{size:`sm`,variant:`outline`,onClick:()=>Q(null),children:`Back to the live review`}),(0,J.jsx)(d,{size:`sm`,variant:`ghost`,disabled:j.isPending,onClick:()=>void Ae(S),children:`Delete saved review`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 print:hidden`,children:[!M&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`Review period`,className:`flex rounded-md border p-0.5 max-md:w-full`,children:be.map(({kind:e,label:n})=>(0,J.jsx)(d,{size:`sm`,variant:t.kind===e?`default`:`ghost`,"aria-pressed":t.kind===e,onClick:()=>je(e),children:n},e))}),t.kind===`week`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`label`,{htmlFor:`week-start`,className:`text-xs text-muted-foreground max-md:sr-only`,children:`Week starting`}),(0,J.jsx)(`input`,{id:`week-start`,type:`date`,required:!0,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-40 max-md:w-0 max-md:min-w-0 max-md:flex-1`),value:t.from,onChange:e=>e.target.value&&Z(ie(e.target.value))})]}),t.kind===`custom`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`label`,{htmlFor:`review-from`,className:`text-xs text-muted-foreground max-md:sr-only`,children:`From`}),(0,J.jsx)(`input`,{id:`review-from`,type:`date`,required:!0,max:t.to,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-40`),value:t.from,onChange:e=>e.target.value&&e.target.value<=t.to&&Z({...t,from:e.target.value})}),(0,J.jsx)(`label`,{htmlFor:`review-to`,className:`text-xs text-muted-foreground max-md:sr-only`,children:`To`}),(0,J.jsx)(`input`,{id:`review-to`,type:`date`,required:!0,min:t.from,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-40`),value:t.to,onChange:e=>e.target.value&&e.target.value>=t.from&&Z({...t,to:e.target.value})})]}),t.kind!==`week`&&t.kind!==`custom`&&(0,J.jsx)(`span`,{className:`px-1 text-sm font-medium`,children:se(t)}),(0,J.jsx)(d,{size:`icon-sm`,variant:`outline`,"aria-label":`Previous ${K}`,title:`Previous ${K}`,onClick:()=>Z(_(t,-1)),children:(0,J.jsx)(re,{})}),(0,J.jsx)(d,{size:`icon-sm`,variant:`outline`,"aria-label":`Next ${K}`,title:`Next ${K}`,onClick:()=>Z(_(t,1)),children:(0,J.jsx)(oe,{})}),t.kind!==`custom`&&(0,J.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>Z(H(t.kind,k(Date.now()/1e3))),children:[(0,J.jsx)(_e,{className:`md:hidden`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`max-md:sr-only`,children:[`This `,K]})]})]}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(Se,{disabled:!V,children:e=>(0,J.jsxs)(J.Fragment,{children:[!M&&(0,J.jsx)(X,{onSelect:()=>{e(),ke()},children:`Save as snapshot`}),(0,J.jsx)(X,{onSelect:()=>{e(),Ne()},children:`Copy as Markdown`}),(0,J.jsx)(X,{onSelect:()=>{e(),$(`markdown`)},children:`Save as Markdown`}),(0,J.jsx)(X,{onSelect:()=>{e(),$(`csv`)},children:`Save as CSV`}),(0,J.jsx)(X,{onSelect:()=>{e(),window.print()},children:`Print or save as PDF`})]})})})]}),(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Review filters`,className:`flex flex-wrap items-center gap-2 print:hidden`,children:[(0,J.jsxs)(`select`,{"aria-label":`Workspace`,className:i(g,`w-auto max-md:min-w-0 max-md:flex-1`),value:c.workspaceId??``,onChange:e=>y({...c,workspaceId:e.target.value===``?null:Number(e.target.value)}),children:[(0,J.jsx)(`option`,{value:``,children:`All workspaces`}),I.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,J.jsxs)(`select`,{"aria-label":`Label`,className:i(g,`w-auto max-md:min-w-0 max-md:flex-1`),value:c.label??``,onChange:e=>y({...c,label:e.target.value===``?null:e.target.value}),children:[(0,J.jsx)(`option`,{value:``,children:W.length===0?`No labels in this period`:`Any label`}),W.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]}),(c.workspaceId!==null||c.label!==null)&&(0,J.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>y(U),children:`Clear filters`})]}),r&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground print:hidden`,children:r}),(0,J.jsx)(`p`,{role:`status`,className:i(`text-sm text-muted-foreground`,!N.isPending&&`sr-only`),children:N.isPending?`Loading the review...`:V?`Showing ${V.length} ${V.length===1?`task`:`tasks`} with activity in this ${K}.`:``}),N.isError&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Failed to load the review: `,N.error.message]}),V?.length===0&&(0,J.jsx)(me,{title:R?.entries.length===0?`No recorded activity in this ${K}.`:`No recorded activity in this ${K} matches the filters.`,hint:M?`This saved review keeps the tasks it had when it was saved.`:R?.entries.length===0?`Toodo records each task as it is planned, started, moved to review, and completed, so reviews fill up as you work.`:`Pick another period or change the filters to look at other work.`,action:M?void 0:(0,J.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 print:hidden`,children:(0,J.jsxs)(d,{size:`sm`,variant:`outline`,onClick:()=>Z(_(t,-1)),children:[`Show the `,K,` before`]})})}),R&&V&&V.length>0&&(0,J.jsx)(Oe,{shown:R,entries:V,workspaces:I}),R&&V&&(0,J.jsx)(De,{shown:R,entries:V,editable:!M}),z.kind===`year`&&V&&(0,J.jsx)(Ee,{entries:V}),V&&ce(V).map(t=>(0,J.jsxs)(`section`,{"aria-label":O[t.outcome],className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`h3`,{className:i(`text-sm font-semibold`,ve[t.outcome]),children:[O[t.outcome],` `,(0,J.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.entries.length,`)`]})]}),(0,J.jsx)(`ul`,{className:`flex flex-col divide-y rounded-lg border`,children:t.entries.map(({task:t,at:n,commits:r,archived:a,pullRequest:o})=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-1 px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(D,{type:t.taskType}),(0,J.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`#`,t.id]}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Open #${t.id} ${t.title}`,title:t.title,onClick:()=>e?.(t.id),className:`min-w-0 flex-1 truncate text-left text-sm font-medium hover:underline max-md:min-h-11`,children:t.title}),t.resolution===`not_adopted`&&(0,J.jsx)(`span`,{className:ye,children:`Not adopted`}),a&&(0,J.jsx)(`span`,{className:ye,children:`Archived`}),t.resolution===`completed`&&(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,P.success),children:`Completed`}),v(t)&&(0,J.jsx)(Te,{url:v(t),stats:o}),(0,J.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground max-md:hidden print:inline`,children:[L.get(t.workspaceId)??`Workspace ${t.workspaceId}`,` · `,(0,J.jsx)(B,{at:n})]})]}),(0,J.jsx)(pe,{task:t}),a||M?null:b?.id===t.id?(0,J.jsx)(ae,{task:t,focusPlan:b.field,onDone:()=>x(null)}):(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground empty:hidden print:hidden`,children:(0,J.jsx)(ne,{task:t,onEdit:e=>x({id:t.id,field:e})})}),t.completionNote&&(0,J.jsx)(`p`,{"aria-label":`Completion note of #${t.id}`,className:`whitespace-pre-line break-words-keep text-xs`,children:t.completionNote}),R&&(0,J.jsx)(we,{task:t,shown:R}),r.length>0&&(0,J.jsx)(`ul`,{"aria-label":`Commits of #${t.id} this ${K}`,className:`flex flex-col gap-0.5`,children:r.map(e=>(0,J.jsxs)(`li`,{className:`flex gap-2 text-xs`,title:e.author,children:[(0,J.jsx)(`code`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}),(0,J.jsx)(`span`,{className:`truncate`,children:le(e.message)})]},e.sha))})]},t.id))})]},t.outcome))]})}function Q(e){return e===0?`0h`:I(e)}function we({task:e,shown:t}){let{start:n,end:r,now:i}=t,a=W(e.timeline,i),o=V(e.timeline,i);if(a===null||o===null)return null;let s=E(e.timeline).filter(e=>e.state===`paused`&&e.start<r&&(e.end??i)>n);return(0,J.jsxs)(`div`,{"aria-label":`Time of #${e.id}`,className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:[(0,J.jsxs)(`p`,{children:[Q(a),` active, `,Q(o),` waiting`]}),s.length>0&&(0,J.jsx)(`ul`,{"aria-label":`Waits of #${e.id}`,className:`flex flex-col gap-0.5`,children:s.map(e=>(0,J.jsxs)(`li`,{className:`break-words-keep`,children:[`Waiting `,Q(Math.max((e.end??i)-e.start,0)),` from `,k(e.start),e.end===null&&`, still waiting`,`: `,e.reason??`no reason recorded`]},e.start))})]})}function Te({url:e,stats:t}){let n=y(e),r=t=>{t.preventDefault(),G(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,J.jsx)(`a`,{href:e,title:t?`${e} \u00b7 ${C(t)}`:e,"aria-label":n?`Pull request #${n}`:`Pull request`,onClick:r,onAuxClick:r,className:`shrink-0 text-xs text-primary underline underline-offset-2 hover:no-underline max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:n?`#${n}`:`PR`})}function Ee({entries:e}){let t=S(e);return t===null?null:(0,J.jsxs)(`section`,{"aria-labelledby":`year-in-review-heading`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,J.jsx)(`h3`,{id:`year-in-review-heading`,className:`text-sm font-semibold`,children:`Year in review`}),t.pullRequests&&(0,J.jsxs)(`dl`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Merged pull requests`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:t.pullRequests.pullRequests})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Lines changed`}),(0,J.jsxs)(`dd`,{className:`text-lg font-semibold`,children:[(0,J.jsxs)(`span`,{children:[`+`,t.pullRequests.additions]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsxs)(`span`,{children:[`-`,t.pullRequests.deletions]})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Files changed`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:t.pullRequests.changedFiles})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Reviews`}),(0,J.jsxs)(`dd`,{className:`text-lg font-semibold`,title:j(t.pullRequests),children:[t.pullRequests.reviews,(0,J.jsxs)(`span`,{className:`ml-1 text-xs font-normal text-muted-foreground`,children:[`on `,t.pullRequests.reviewed,` of `,t.pullRequests.pullRequests]})]})]})]}),t.largest.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Largest pull requests`}),(0,J.jsx)(`ol`,{"aria-label":`Largest pull requests`,className:`flex flex-col gap-1`,children:t.largest.map(({task:e,pullRequest:t})=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsx)(D,{type:e.taskType}),(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:C(t)})]},e.id))})]}),t.research.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Research conclusions`}),(0,J.jsx)(`ul`,{"aria-label":`Research conclusions`,className:`flex flex-col divide-y rounded-md border`,children:t.research.map(({task:e,at:t,adopted:n})=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,n?P.success:P.neutral),children:n?`Adopted`:`Not adopted`}),(0,J.jsx)(B,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,at:t})]}),(0,J.jsx)(`p`,{"aria-label":`Research conclusion of #${e.id}`,className:`whitespace-pre-line break-words-keep text-xs`,children:e.completionNote??(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`No conclusion written.`})})]},e.id))})]}),t.overruns.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Largest estimate overruns`}),(0,J.jsx)(`ol`,{"aria-label":`Largest estimate overruns`,className:`flex flex-col gap-1`,children:t.overruns.map(({task:e,estimated:t,actual:n})=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsx)(D,{type:e.taskType}),(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:[`estimated `,I(t),`, `,I(n),` active`]})]},e.id))})]})]})}function De({shown:e,entries:t,editable:n}){let r=T(e.end,t,e.now),a=n?t.filter(({archived:e})=>!e).map(({task:e})=>N(e)):[],o=a.filter(e=>e.includes(`estimate`)).length,s=a.filter(e=>e.includes(`dueDate`)).length;if(r===null&&o+s===0)return null;let c=(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Missing plan`}),(0,J.jsxs)(`dd`,{children:[[o>0&&`${Y(o,`task`)} without an estimate`,s>0&&`${Y(s,`task`)} without a due date`].filter(Boolean).join(`, `),`; add them from the marks on the tasks below`]})]});return(0,J.jsxs)(`section`,{"aria-labelledby":`plan-heading`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,J.jsx)(`h3`,{id:`plan-heading`,className:`text-sm font-semibold`,children:`Plan vs actual`}),r===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`text-sm`,children:`No reviewed task has an estimate or a due date, so there is nothing to compare yet.`}),(0,J.jsx)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:c})]}):(0,J.jsxs)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:[(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Estimate vs active time`}),(0,J.jsx)(`dd`,{children:r.time?M(r.time):`No completed task had an estimate`})]}),(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Due dates met`}),(0,J.jsx)(`dd`,{children:r.dueDates?L(r.dueDates):`No completed task had a due date`})]}),o+s>0&&c]}),r!==null&&r.late.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Late tasks`}),(0,J.jsx)(`ul`,{"aria-label":`Late tasks`,className:`flex flex-col gap-1`,children:r.late.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[(0,J.jsx)(D,{type:e.task.taskType}),(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.task.title})]}),(0,J.jsx)(`span`,{className:i(`ml-auto shrink-0 text-xs`,w.danger),children:z(e)})]},e.task.id))})]})]})}function Oe({shown:e,entries:t,workspaces:n}){let r=de(e.period,t,n,e.timeZone),a=Math.max(1,...(r.completedPerMonth??[]).map(({count:e})=>e));return(0,J.jsxs)(`section`,{"aria-label":`Summary`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,J.jsxs)(`dl`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[r.outcomes.map(({outcome:e,count:t})=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:O[e]}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:t})]},e)),r.notAdopted>0&&(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Not adopted`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:r.notAdopted})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Commits`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:r.commits})]})]}),(0,J.jsxs)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:[F.map(e=>{let t=r[e];return(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:R[e]}),(0,J.jsx)(`dd`,{children:t===null?`No data`:`${I(t.median)} (${t.tasks} ${t.tasks===1?`task`:`tasks`})`})]},e)}),r.changes&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Changes in completed pull requests`}),(0,J.jsx)(`dd`,{children:A(r.changes)})]}),r.completedByType.length>0&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Completed by type`}),(0,J.jsx)(`dd`,{children:r.completedByType.map(({taskType:e,count:t})=>`${e} ${t}`).join(`, `)})]}),r.completedByWorkspace.length>0&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Completed by workspace`}),(0,J.jsx)(`dd`,{children:r.completedByWorkspace.map(({workspace:e,count:t})=>`${e} ${t}`).join(`, `)})]})]}),r.completedPerMonth&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Completed per month`}),(0,J.jsx)(`ul`,{"aria-label":`Completed per month`,className:`flex flex-col gap-0.5`,children:r.completedPerMonth.map(({month:e,count:t})=>(0,J.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,J.jsx)(`span`,{className:`w-16 shrink-0 font-mono text-muted-foreground`,children:e}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:i(`h-2 rounded-sm`,x.success),style:{width:`${t/a*60}%`,minWidth:t>0?4:0}}),(0,J.jsx)(`span`,{children:t})]},e))})]})]})}export{Z as Review};
1
+ import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{A as a,G as o,L as s,M as c,P as l,a as u,at as d,it as f,j as p,k as m,m as h,n as ee}from"./queries-usvG1nHU.js";import{a as g}from"./workspace-list-yRYeAvrx.js";import{A as _,C as te,D as v,E as y,It as b,K as ne,Lt as re,M as ie,Mt as x,N as S,O as C,P as ae,Pt as w,Rt as oe,S as se,T,Tt as E,V as D,_ as ce,b as O,bt as k,c as le,d as ue,f as A,g as j,h as M,ht as N,j as de,jt as P,k as fe,l as F,m as I,p as L,q as pe,s as me,u as R,v as z,vt as B,w as he,wt as V,x as H,xt as ge,y as U,yt as W}from"./index-DO2HCuk5.js";import{t as G}from"./opener-DWhHPoCL.js";var K={name:`calendar-check`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m9 15 2 2 4-4`,key:`1grp1n`}]]};K.node;var _e=t(K),q=r(e(),1),J=n(),ve={completed:w.success,opened_for_review:w.review,started:w.progress,worked_on:w.progress,planned:w.neutral},ye=i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,P.neutral),be=[{kind:`week`,label:`Week`},{kind:`month`,label:`Month`},{kind:`quarter`,label:`Quarter`},{kind:`year`,label:`Year`},{kind:`custom`,label:`Custom`}];function xe(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function Se({disabled:e,children:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>e.key===`Escape`&&r(!1);return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,J.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,J.jsxs)(d,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":n,disabled:e,onClick:()=>r(!n),children:[(0,J.jsx)(b,{}),(0,J.jsx)(`span`,{className:`max-md:sr-only`,children:`Export`})]}),n&&(0,J.jsx)(`div`,{role:`menu`,"aria-label":`Export review`,className:`absolute right-0 z-10 mt-1 flex w-48 flex-col rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:t(()=>r(!1))})]})}function Y(e,t){return`${e} ${t}${e===1?``:`s`}`}function X({onSelect:e,children:t}){return(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:e,className:`rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted max-md:min-h-11`,children:t})}function Ce(){let e=c(),t=s(),[n,r]=(0,q.useState)(!1),[a,o]=(0,q.useState)(``),[l,u]=(0,q.useState)(null),f=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];async function p(e){u(null);try{await t.mutateAsync(e),r(!1)}catch(e){u(e instanceof Error?e.message:String(e))}}if(!e.data)return null;let{timeZone:m,configured:h}=e.data;return n?(0,J.jsxs)(`form`,{"aria-label":`Review time zone`,className:`flex flex-wrap items-center gap-2 print:hidden`,onSubmit:e=>{e.preventDefault(),p(a)},children:[(0,J.jsx)(`label`,{htmlFor:`review-time-zone`,className:`text-xs`,children:`Time zone for every device`}),(0,J.jsx)(`input`,{id:`review-time-zone`,list:`review-time-zones`,required:!0,className:i(g,`w-56`),value:a,onChange:e=>o(e.target.value)}),(0,J.jsx)(`datalist`,{id:`review-time-zones`,children:f.map(e=>(0,J.jsx)(`option`,{value:e},e))}),(0,J.jsx)(d,{size:`sm`,type:`submit`,disabled:t.isPending,children:`Save`}),h!==null&&(0,J.jsx)(d,{size:`sm`,type:`button`,variant:`outline`,onClick:()=>void p(null),children:`Use the server's`}),(0,J.jsx)(d,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>r(!1),children:`Cancel`}),l&&(0,J.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-destructive`,children:l})]}):(0,J.jsxs)(`span`,{children:[`Days are in `,m,h===null&&` (the server's time zone)`,`.`,` `,(0,J.jsx)(`button`,{type:`button`,className:`text-primary underline underline-offset-2 hover:no-underline print:hidden`,onClick:()=>{o(h??m),r(!0)},children:`Change time zone`})]})}function Z({onShowTask:e}){let[t,n]=(0,q.useState)(()=>H(`week`,k(Date.now()/1e3))),[r,s]=(0,q.useState)(null),[c,y]=(0,q.useState)(U),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),w=m(t.from,t.to),T=p(),E=a(S),A=l(),j=h(),M=S!==null,N=M?E:w,de=o(),F=u(),I=M?E.data?.workspaces??[]:[...de.data??[],...F.data?.workspaces??[]],L=new Map(I.map(e=>[e.id,e.name])),R=M?E.data&&{period:{kind:E.data.summary.period,from:E.data.summary.from,to:E.data.summary.to},entries:E.data.entries,start:E.data.summary.start,end:E.data.summary.end,timeZone:E.data.summary.timeZone,now:E.data.summary.savedAt}:w.data&&{period:t,entries:w.data.entries,start:w.data.start,end:w.data.end,timeZone:w.data.timeZone,now:Date.now()/1e3},z=R?.period??t,V=R&&ue(R.entries,c),W=fe(R?.entries??[]);c.label!==null&&!W.includes(c.label)&&W.push(c.label);let G=[c.workspaceId===null?`across all workspaces`:`in ${L.get(c.workspaceId)??`workspace ${c.workspaceId}`}`,c.label!==null&&`labelled ${c.label}`].filter(Boolean).join(`, `),K=te[z.kind];function Z(e){s(null),n(e)}function Q(e){s(null),x(null),C(e)}async function ke(){try{let e=await A.mutateAsync({period:t.kind,from:t.from,to:t.kind===`custom`?t.to:null,workspaceId:c.workspaceId,label:c.label,title:null});s(`Saved "${e.title}" with ${Y(e.entryCount,`task`)}; reopen it from Saved reviews.`)}catch(e){s(`Could not save the review: ${e instanceof Error?e.message:String(e)}`)}}async function Ae(e){try{await j.mutateAsync(e),Q(null),s(`Deleted the saved review.`)}catch(e){s(`Could not delete the saved review: ${e instanceof Error?e.message:String(e)}`)}}function je(e){e!==t.kind&&Z(e===`custom`?{...t,kind:e}:H(e,t.from))}function Me(e){return M?E.data?Promise.resolve(e===`csv`?E.data.csv:E.data.markdown):Promise.reject(Error(`the saved review is still loading`)):ee(f.reviewReport({period:t.kind,date:null,from:t.from,to:t.kind===`custom`?t.to:null,format:e,timeZone:null,workspaceId:c.workspaceId,label:c.label}))}async function Ne(){try{let e=Me(`markdown`);if(typeof ClipboardItem>`u`)await navigator.clipboard.writeText((await e).contents);else{let t=e.then(({contents:e})=>new Blob([e],{type:`text/plain`}));await navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}s(`Copied as Markdown.`)}catch(e){s(`Could not copy: ${String(e)}`)}}async function $(e){try{let t=await Me(e);xe(t.fileName,t.contents,t.mediaType),s(`Downloaded ${t.fileName}`)}catch(e){s(`Could not export: ${String(e)}`)}}return(0,J.jsxs)(`section`,{"aria-labelledby":`review-heading`,className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h2`,{id:`review-heading`,className:`text-xl font-semibold tracking-tight`,children:M&&E.data?E.data.summary.title:he[z.kind]}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Work recorded from `,z.from,` to `,z.to,` `,G,`.`,` `,M?E.data&&(0,J.jsxs)(`span`,{children:[`Saved `,ge(E.data.summary.savedAt),`, with days in `,E.data.summary.timeZone,`; it stays as it was when saved.`]}):(0,J.jsx)(Ce,{})]})]}),(M||(T.data?.length??0)>0)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 print:hidden`,children:[(0,J.jsxs)(`select`,{"aria-label":`Saved reviews`,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-auto max-md:min-w-0 max-md:flex-1`),value:S??``,onChange:e=>Q(e.target.value===``?null:Number(e.target.value)),children:[(0,J.jsx)(`option`,{value:``,children:`Live review`}),T.data?.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.title,` (saved `,k(e.savedAt),`)`]},e.id))]}),S!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(d,{size:`sm`,variant:`outline`,onClick:()=>Q(null),children:`Back to the live review`}),(0,J.jsx)(d,{size:`sm`,variant:`ghost`,disabled:j.isPending,onClick:()=>void Ae(S),children:`Delete saved review`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 print:hidden`,children:[!M&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`Review period`,className:`flex rounded-md border p-0.5 max-md:w-full`,children:be.map(({kind:e,label:n})=>(0,J.jsx)(d,{size:`sm`,variant:t.kind===e?`default`:`ghost`,"aria-pressed":t.kind===e,onClick:()=>je(e),children:n},e))}),t.kind===`week`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`label`,{htmlFor:`week-start`,className:`text-xs text-muted-foreground max-md:sr-only`,children:`Week starting`}),(0,J.jsx)(`input`,{id:`week-start`,type:`date`,required:!0,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-40 max-md:w-0 max-md:min-w-0 max-md:flex-1`),value:t.from,onChange:e=>e.target.value&&Z(ie(e.target.value))})]}),t.kind===`custom`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`label`,{htmlFor:`review-from`,className:`text-xs text-muted-foreground max-md:sr-only`,children:`From`}),(0,J.jsx)(`input`,{id:`review-from`,type:`date`,required:!0,max:t.to,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-40`),value:t.from,onChange:e=>e.target.value&&e.target.value<=t.to&&Z({...t,from:e.target.value})}),(0,J.jsx)(`label`,{htmlFor:`review-to`,className:`text-xs text-muted-foreground max-md:sr-only`,children:`To`}),(0,J.jsx)(`input`,{id:`review-to`,type:`date`,required:!0,min:t.from,className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`w-40`),value:t.to,onChange:e=>e.target.value&&e.target.value>=t.from&&Z({...t,to:e.target.value})})]}),t.kind!==`week`&&t.kind!==`custom`&&(0,J.jsx)(`span`,{className:`px-1 text-sm font-medium`,children:se(t)}),(0,J.jsx)(d,{size:`icon-sm`,variant:`outline`,"aria-label":`Previous ${K}`,title:`Previous ${K}`,onClick:()=>Z(_(t,-1)),children:(0,J.jsx)(re,{})}),(0,J.jsx)(d,{size:`icon-sm`,variant:`outline`,"aria-label":`Next ${K}`,title:`Next ${K}`,onClick:()=>Z(_(t,1)),children:(0,J.jsx)(oe,{})}),t.kind!==`custom`&&(0,J.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>Z(H(t.kind,k(Date.now()/1e3))),children:[(0,J.jsx)(_e,{className:`md:hidden`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`max-md:sr-only`,children:[`This `,K]})]})]}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(Se,{disabled:!V,children:e=>(0,J.jsxs)(J.Fragment,{children:[!M&&(0,J.jsx)(X,{onSelect:()=>{e(),ke()},children:`Save as snapshot`}),(0,J.jsx)(X,{onSelect:()=>{e(),Ne()},children:`Copy as Markdown`}),(0,J.jsx)(X,{onSelect:()=>{e(),$(`markdown`)},children:`Save as Markdown`}),(0,J.jsx)(X,{onSelect:()=>{e(),$(`csv`)},children:`Save as CSV`}),(0,J.jsx)(X,{onSelect:()=>{e(),window.print()},children:`Print or save as PDF`})]})})})]}),(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Review filters`,className:`flex flex-wrap items-center gap-2 print:hidden`,children:[(0,J.jsxs)(`select`,{"aria-label":`Workspace`,className:i(g,`w-auto max-md:min-w-0 max-md:flex-1`),value:c.workspaceId??``,onChange:e=>y({...c,workspaceId:e.target.value===``?null:Number(e.target.value)}),children:[(0,J.jsx)(`option`,{value:``,children:`All workspaces`}),I.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,J.jsxs)(`select`,{"aria-label":`Label`,className:i(g,`w-auto max-md:min-w-0 max-md:flex-1`),value:c.label??``,onChange:e=>y({...c,label:e.target.value===``?null:e.target.value}),children:[(0,J.jsx)(`option`,{value:``,children:W.length===0?`No labels in this period`:`Any label`}),W.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]}),(c.workspaceId!==null||c.label!==null)&&(0,J.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>y(U),children:`Clear filters`})]}),r&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground print:hidden`,children:r}),(0,J.jsx)(`p`,{role:`status`,className:i(`text-sm text-muted-foreground`,!N.isPending&&`sr-only`),children:N.isPending?`Loading the review...`:V?`Showing ${V.length} ${V.length===1?`task`:`tasks`} with activity in this ${K}.`:``}),N.isError&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Failed to load the review: `,N.error.message]}),V?.length===0&&(0,J.jsx)(me,{title:R?.entries.length===0?`No recorded activity in this ${K}.`:`No recorded activity in this ${K} matches the filters.`,hint:M?`This saved review keeps the tasks it had when it was saved.`:R?.entries.length===0?`Toodo records each task as it is planned, started, moved to review, and completed, so reviews fill up as you work.`:`Pick another period or change the filters to look at other work.`,action:M?void 0:(0,J.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 print:hidden`,children:(0,J.jsxs)(d,{size:`sm`,variant:`outline`,onClick:()=>Z(_(t,-1)),children:[`Show the `,K,` before`]})})}),R&&V&&V.length>0&&(0,J.jsx)(Oe,{shown:R,entries:V,workspaces:I}),R&&V&&(0,J.jsx)(De,{shown:R,entries:V,editable:!M}),z.kind===`year`&&V&&(0,J.jsx)(Ee,{entries:V}),V&&ce(V).map(t=>(0,J.jsxs)(`section`,{"aria-label":O[t.outcome],className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`h3`,{className:i(`text-sm font-semibold`,ve[t.outcome]),children:[O[t.outcome],` `,(0,J.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.entries.length,`)`]})]}),(0,J.jsx)(`ul`,{className:`flex flex-col divide-y rounded-lg border`,children:t.entries.map(({task:t,at:n,commits:r,archived:a,pullRequest:o})=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-1 px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(D,{type:t.taskType}),(0,J.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`#`,t.id]}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Open #${t.id} ${t.title}`,title:t.title,onClick:()=>e?.(t.id),className:`min-w-0 flex-1 truncate text-left text-sm font-medium hover:underline max-md:min-h-11`,children:t.title}),t.resolution===`not_adopted`&&(0,J.jsx)(`span`,{className:ye,children:`Not adopted`}),a&&(0,J.jsx)(`span`,{className:ye,children:`Archived`}),t.resolution===`completed`&&(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,P.success),children:`Completed`}),v(t)&&(0,J.jsx)(Te,{url:v(t),stats:o}),(0,J.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground max-md:hidden print:inline`,children:[L.get(t.workspaceId)??`Workspace ${t.workspaceId}`,` · `,(0,J.jsx)(B,{at:n})]})]}),(0,J.jsx)(pe,{task:t}),a||M?null:b?.id===t.id?(0,J.jsx)(ae,{task:t,focusPlan:b.field,onDone:()=>x(null)}):(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground empty:hidden print:hidden`,children:(0,J.jsx)(ne,{task:t,onEdit:e=>x({id:t.id,field:e})})}),t.completionNote&&(0,J.jsx)(`p`,{"aria-label":`Completion note of #${t.id}`,className:`whitespace-pre-line break-words-keep text-xs`,children:t.completionNote}),R&&(0,J.jsx)(we,{task:t,shown:R}),r.length>0&&(0,J.jsx)(`ul`,{"aria-label":`Commits of #${t.id} this ${K}`,className:`flex flex-col gap-0.5`,children:r.map(e=>(0,J.jsxs)(`li`,{className:`flex gap-2 text-xs`,title:e.author,children:[(0,J.jsx)(`code`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}),(0,J.jsx)(`span`,{className:`truncate`,children:le(e.message)})]},e.sha))})]},t.id))})]},t.outcome))]})}function Q(e){return e===0?`0h`:I(e)}function we({task:e,shown:t}){let{start:n,end:r,now:i}=t,a=W(e.timeline,i),o=V(e.timeline,i);if(a===null||o===null)return null;let s=E(e.timeline).filter(e=>e.state===`paused`&&e.start<r&&(e.end??i)>n);return(0,J.jsxs)(`div`,{"aria-label":`Time of #${e.id}`,className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:[(0,J.jsxs)(`p`,{children:[Q(a),` active, `,Q(o),` waiting`]}),s.length>0&&(0,J.jsx)(`ul`,{"aria-label":`Waits of #${e.id}`,className:`flex flex-col gap-0.5`,children:s.map(e=>(0,J.jsxs)(`li`,{className:`break-words-keep`,children:[`Waiting `,Q(Math.max((e.end??i)-e.start,0)),` from `,k(e.start),e.end===null&&`, still waiting`,`: `,e.reason??`no reason recorded`]},e.start))})]})}function Te({url:e,stats:t}){let n=y(e),r=t=>{t.preventDefault(),G(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,J.jsx)(`a`,{href:e,title:t?`${e} \u00b7 ${C(t)}`:e,"aria-label":n?`Pull request #${n}`:`Pull request`,onClick:r,onAuxClick:r,className:`shrink-0 text-xs text-primary underline underline-offset-2 hover:no-underline max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:n?`#${n}`:`PR`})}function Ee({entries:e}){let t=S(e);return t===null?null:(0,J.jsxs)(`section`,{"aria-labelledby":`year-in-review-heading`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,J.jsx)(`h3`,{id:`year-in-review-heading`,className:`text-sm font-semibold`,children:`Year in review`}),t.pullRequests&&(0,J.jsxs)(`dl`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Merged pull requests`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:t.pullRequests.pullRequests})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Lines changed`}),(0,J.jsxs)(`dd`,{className:`text-lg font-semibold`,children:[(0,J.jsxs)(`span`,{children:[`+`,t.pullRequests.additions]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsxs)(`span`,{children:[`-`,t.pullRequests.deletions]})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Files changed`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:t.pullRequests.changedFiles})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Reviews`}),(0,J.jsxs)(`dd`,{className:`text-lg font-semibold`,title:j(t.pullRequests),children:[t.pullRequests.reviews,(0,J.jsxs)(`span`,{className:`ml-1 text-xs font-normal text-muted-foreground`,children:[`on `,t.pullRequests.reviewed,` of `,t.pullRequests.pullRequests]})]})]})]}),t.largest.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Largest pull requests`}),(0,J.jsx)(`ol`,{"aria-label":`Largest pull requests`,className:`flex flex-col gap-1`,children:t.largest.map(({task:e,pullRequest:t})=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsx)(D,{type:e.taskType}),(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:C(t)})]},e.id))})]}),t.research.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Research conclusions`}),(0,J.jsx)(`ul`,{"aria-label":`Research conclusions`,className:`flex flex-col divide-y rounded-md border`,children:t.research.map(({task:e,at:t,adopted:n})=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,n?P.success:P.neutral),children:n?`Adopted`:`Not adopted`}),(0,J.jsx)(B,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,at:t})]}),(0,J.jsx)(`p`,{"aria-label":`Research conclusion of #${e.id}`,className:`whitespace-pre-line break-words-keep text-xs`,children:e.completionNote??(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`No conclusion written.`})})]},e.id))})]}),t.overruns.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Largest estimate overruns`}),(0,J.jsx)(`ol`,{"aria-label":`Largest estimate overruns`,className:`flex flex-col gap-1`,children:t.overruns.map(({task:e,estimated:t,actual:n})=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsx)(D,{type:e.taskType}),(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:[`estimated `,I(t),`, `,I(n),` active`]})]},e.id))})]})]})}function De({shown:e,entries:t,editable:n}){let r=T(e.end,t,e.now),a=n?t.filter(({archived:e})=>!e).map(({task:e})=>N(e)):[],o=a.filter(e=>e.includes(`estimate`)).length,s=a.filter(e=>e.includes(`dueDate`)).length;if(r===null&&o+s===0)return null;let c=(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Missing plan`}),(0,J.jsxs)(`dd`,{children:[[o>0&&`${Y(o,`task`)} without an estimate`,s>0&&`${Y(s,`task`)} without a due date`].filter(Boolean).join(`, `),`; add them from the marks on the tasks below`]})]});return(0,J.jsxs)(`section`,{"aria-labelledby":`plan-heading`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,J.jsx)(`h3`,{id:`plan-heading`,className:`text-sm font-semibold`,children:`Plan vs actual`}),r===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`text-sm`,children:`No reviewed task has an estimate or a due date, so there is nothing to compare yet.`}),(0,J.jsx)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:c})]}):(0,J.jsxs)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:[(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Estimate vs active time`}),(0,J.jsx)(`dd`,{children:r.time?M(r.time):`No completed task had an estimate`})]}),(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Due dates met`}),(0,J.jsx)(`dd`,{children:r.dueDates?L(r.dueDates):`No completed task had a due date`})]}),o+s>0&&c]}),r!==null&&r.late.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Late tasks`}),(0,J.jsx)(`ul`,{"aria-label":`Late tasks`,className:`flex flex-col gap-1`,children:r.late.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[(0,J.jsx)(D,{type:e.task.taskType}),(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.task.title})]}),(0,J.jsx)(`span`,{className:i(`ml-auto shrink-0 text-xs`,w.danger),children:z(e)})]},e.task.id))})]})]})}function Oe({shown:e,entries:t,workspaces:n}){let r=de(e.period,t,n,e.timeZone),a=Math.max(1,...(r.completedPerMonth??[]).map(({count:e})=>e));return(0,J.jsxs)(`section`,{"aria-label":`Summary`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,J.jsxs)(`dl`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[r.outcomes.map(({outcome:e,count:t})=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:O[e]}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:t})]},e)),r.notAdopted>0&&(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Not adopted`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:r.notAdopted})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Commits`}),(0,J.jsx)(`dd`,{className:`text-lg font-semibold`,children:r.commits})]})]}),(0,J.jsxs)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:[F.map(e=>{let t=r[e];return(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:R[e]}),(0,J.jsx)(`dd`,{children:t===null?`No data`:`${I(t.median)} (${t.tasks} ${t.tasks===1?`task`:`tasks`})`})]},e)}),r.changes&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Changes in completed pull requests`}),(0,J.jsx)(`dd`,{children:A(r.changes)})]}),r.completedByType.length>0&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Completed by type`}),(0,J.jsx)(`dd`,{children:r.completedByType.map(({taskType:e,count:t})=>`${e} ${t}`).join(`, `)})]}),r.completedByWorkspace.length>0&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Completed by workspace`}),(0,J.jsx)(`dd`,{children:r.completedByWorkspace.map(({workspace:e,count:t})=>`${e} ${t}`).join(`, `)})]})]}),r.completedPerMonth&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Completed per month`}),(0,J.jsx)(`ul`,{"aria-label":`Completed per month`,className:`flex flex-col gap-0.5`,children:r.completedPerMonth.map(({month:e,count:t})=>(0,J.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,J.jsx)(`span`,{className:`w-16 shrink-0 font-mono text-muted-foreground`,children:e}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:i(`h-2 rounded-sm`,x.success),style:{width:`${t/a*60}%`,minWidth:t>0?4:0}}),(0,J.jsx)(`span`,{children:t})]},e))})]})]})}export{Z as Review};
@@ -1 +1 @@
1
- import{i as e,r as t,s as n}from"./dist-ZmB2kPfR.js";import{at as r}from"./queries-Dt65Qzxx.js";import{a as i}from"./workspace-list-BKJMXO3z.js";import{c as a,l as o,s}from"./event-DMqRNLc_.js";import{a as c,i as l,n as u,o as d,r as f}from"./index-DtWZQCfw.js";var p=n(e(),1),m=t();function h({children:e}){return(0,p.useSyncExternalStore)(o,s)===null?(0,m.jsx)(g,{}):e}function g(){let[e,t]=(0,p.useState)(``),[n,o]=(0,p.useState)(()=>c(navigator.userAgent)),[s,h]=(0,p.useState)(u.scope),[g,_]=(0,p.useState)(String(u.expiresInDays)),[v,y]=(0,p.useState)(null),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),w=(0,p.useRef)(null),T=(0,p.useId)(),E=`${T}-help`,D=`${T}-rejected`;async function O(t){t.preventDefault(),C(!0),y(null),x(!1);try{let t=g===`never`?null:Number(g);a(await d(e.trim(),n.trim(),{scope:s,expiresInDays:t}))}catch(e){e instanceof l?(x(!0),w.current?.focus(),w.current?.select()):e instanceof TypeError?y(`Could not reach the server: ${String(e)}`):y(e instanceof Error?e.message:String(e))}finally{C(!1)}}return(0,m.jsx)(`main`,{className:`flex min-h-svh flex-col items-center justify-center gap-4 p-6`,children:(0,m.jsxs)(`form`,{onSubmit:O,"aria-label":`Server access`,className:`flex w-full max-w-sm flex-col gap-3 rounded-lg border p-5`,children:[(0,m.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Toodo server`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Sign in with the server's access token. This browser then gets a token of its own, which you can revoke under Devices.`}),(0,m.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,m.jsx)(`label`,{htmlFor:`${T}-token`,className:`text-xs text-muted-foreground`,children:`Access token`}),(0,m.jsx)(`input`,{ref:w,id:`${T}-token`,className:`${i} aria-invalid:border-destructive`,type:`password`,autoComplete:`current-password`,value:e,onChange:e=>{t(e.target.value),x(!1)},"aria-invalid":b||void 0,"aria-describedby":b?`${D} ${E}`:E,required:!0}),b&&(0,m.jsxs)(`p`,{id:D,role:`alert`,className:`text-xs text-destructive`,children:[`The server did not accept this token. Paste the whole contents of`,` `,(0,m.jsx)(`code`,{className:`text-xs`,children:`web-token`}),` again; a device token stops working once it is revoked.`]}),(0,m.jsxs)(`p`,{id:E,className:`text-xs text-muted-foreground`,children:[`Copy it from `,(0,m.jsx)(`code`,{className:`text-xs`,children:`web-token`}),` in the server's data directory.`]})]}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Device name`,(0,m.jsx)(`input`,{className:i,maxLength:80,value:n,onChange:e=>o(e.target.value),required:!0})]}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,m.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Access`,(0,m.jsxs)(`select`,{className:i,value:s,onChange:e=>h(e.target.value),children:[(0,m.jsx)(`option`,{value:`full`,children:`Full access`}),(0,m.jsx)(`option`,{value:`read`,children:`Read-only`})]})]}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Token expires after`,(0,m.jsx)(`select`,{className:i,value:g,onChange:e=>_(e.target.value),children:f.map(({label:e,days:t})=>(0,m.jsx)(`option`,{value:t===null?`never`:String(t),children:e},e))})]})]}),(0,m.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies when you sign in with `,(0,m.jsx)(`code`,{className:`text-xs`,children:`web-token`}),`. When the token expires, sign in again.`]}),v&&(0,m.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:v}),(0,m.jsx)(r,{type:`submit`,disabled:S||!e.trim()||!n.trim(),children:S?`Checking...`:`Continue`})]})})}export{h as ServerAccess};
1
+ import{i as e,r as t,s as n}from"./dist-ZmB2kPfR.js";import{at as r}from"./queries-usvG1nHU.js";import{a as i}from"./workspace-list-yRYeAvrx.js";import{c as a,l as o,s}from"./event-DMqRNLc_.js";import{a as c,i as l,n as u,o as d,r as f}from"./index-DO2HCuk5.js";var p=n(e(),1),m=t();function h({children:e}){return(0,p.useSyncExternalStore)(o,s)===null?(0,m.jsx)(g,{}):e}function g(){let[e,t]=(0,p.useState)(``),[n,o]=(0,p.useState)(()=>c(navigator.userAgent)),[s,h]=(0,p.useState)(u.scope),[g,_]=(0,p.useState)(String(u.expiresInDays)),[v,y]=(0,p.useState)(null),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),w=(0,p.useRef)(null),T=(0,p.useId)(),E=`${T}-help`,D=`${T}-rejected`;async function O(t){t.preventDefault(),C(!0),y(null),x(!1);try{let t=g===`never`?null:Number(g);a(await d(e.trim(),n.trim(),{scope:s,expiresInDays:t}))}catch(e){e instanceof l?(x(!0),w.current?.focus(),w.current?.select()):e instanceof TypeError?y(`Could not reach the server: ${String(e)}`):y(e instanceof Error?e.message:String(e))}finally{C(!1)}}return(0,m.jsx)(`main`,{className:`flex min-h-svh flex-col items-center justify-center gap-4 p-6`,children:(0,m.jsxs)(`form`,{onSubmit:O,"aria-label":`Server access`,className:`flex w-full max-w-sm flex-col gap-3 rounded-lg border p-5`,children:[(0,m.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Toodo server`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Sign in with the server's access token. This browser then gets a token of its own, which you can revoke under Devices.`}),(0,m.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,m.jsx)(`label`,{htmlFor:`${T}-token`,className:`text-xs text-muted-foreground`,children:`Access token`}),(0,m.jsx)(`input`,{ref:w,id:`${T}-token`,className:`${i} aria-invalid:border-destructive`,type:`password`,autoComplete:`current-password`,value:e,onChange:e=>{t(e.target.value),x(!1)},"aria-invalid":b||void 0,"aria-describedby":b?`${D} ${E}`:E,required:!0}),b&&(0,m.jsxs)(`p`,{id:D,role:`alert`,className:`text-xs text-destructive`,children:[`The server did not accept this token. Paste the whole contents of`,` `,(0,m.jsx)(`code`,{className:`text-xs`,children:`web-token`}),` again; a device token stops working once it is revoked.`]}),(0,m.jsxs)(`p`,{id:E,className:`text-xs text-muted-foreground`,children:[`Copy it from `,(0,m.jsx)(`code`,{className:`text-xs`,children:`web-token`}),` in the server's data directory.`]})]}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Device name`,(0,m.jsx)(`input`,{className:i,maxLength:80,value:n,onChange:e=>o(e.target.value),required:!0})]}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,m.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Access`,(0,m.jsxs)(`select`,{className:i,value:s,onChange:e=>h(e.target.value),children:[(0,m.jsx)(`option`,{value:`full`,children:`Full access`}),(0,m.jsx)(`option`,{value:`read`,children:`Read-only`})]})]}),(0,m.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Token expires after`,(0,m.jsx)(`select`,{className:i,value:g,onChange:e=>_(e.target.value),children:f.map(({label:e,days:t})=>(0,m.jsx)(`option`,{value:t===null?`never`:String(t),children:e},e))})]})]}),(0,m.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies when you sign in with `,(0,m.jsx)(`code`,{className:`text-xs`,children:`web-token`}),`. When the token expires, sign in again.`]}),v&&(0,m.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:v}),(0,m.jsx)(r,{type:`submit`,disabled:S||!e.trim()||!n.trim(),children:S?`Checking...`:`Continue`})]})})}export{h as ServerAccess};
@@ -1,2 +1,2 @@
1
- import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{B as a,at as o,i as s,l as c,w as l}from"./queries-Dt65Qzxx.js";import{s as u}from"./workspace-list-BKJMXO3z.js";import{Ct as d,F as f,G as p,I as m,J as h,L as g,Pt as _,R as v,St as y,U as b,W as x,Y as S,jt as C,mt as w,q as T,vt as E,xt as ee,z as D}from"./index-DtWZQCfw.js";import{t as O}from"./opener-DWhHPoCL.js";import{t as k}from"./details-sheet--RxVyLdY.js";var A={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};A.node;var j=t(A),M={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};M.node;var te=t(M),N={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};N.node;var P=t(N),F=r(e(),1),I=n();function L({onClose:e,children:t}){let n=(0,F.useRef)(null),[r,i]=(0,F.useState)(!1);function a(){n.current?.querySelector(`form[data-dirty]`)?i(!0):e()}return(0,F.useEffect)(()=>{function e(e){e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role=menu]`)||(r?i(!1):e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select`)||a())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,I.jsx)(k,{ref:n,width:`min(480px, max(360px, 40vw), calc(100vw - 32px))`,onClose:a,banner:r&&(0,I.jsxs)(`div`,{role:`group`,"aria-label":`Unsaved changes`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted px-4 py-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Discard your unsaved changes?`}),(0,I.jsx)(o,{size:`xs`,variant:`outline`,autoFocus:!0,onClick:()=>i(!1),children:`Keep editing`}),(0,I.jsx)(o,{size:`xs`,variant:`destructive`,onClick:e,children:`Discard changes`})]}),children:t})}function R(e){switch(e.status){case`in_progress`:return`Started`;case`in_review`:return`In review`;case`done`:return`Completed`;case`planned`:return e.reopened?`Reopened`:`Paused`}}function z({task:e}){let t=e.timeline.filter(e=>e.reason!==null);return t.length===0?null:(0,I.jsx)(`ol`,{"aria-label":`Reasons of #${e.id}`,className:`mt-1 flex flex-col gap-0.5`,children:t.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 max-md:flex-wrap max-md:gap-y-0`,children:[(0,I.jsx)(E,{className:`shrink-0 text-muted-foreground`,at:e.at}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium`,children:R(e)}),(0,I.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words-keep max-md:basis-full`,children:e.reason})]},t))})}var B={lane:`Lane`,discord:`Discord`,pr:`PR`};function V({value:e}){if(/^https?:\/\//i.test(e)){let t=t=>{t.preventDefault(),O(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,I.jsx)(`a`,{href:e,onClick:t,onAuxClick:t,className:`min-w-0 break-all text-primary underline underline-offset-2 hover:no-underline`,children:e})}let t=e.indexOf(`:`),n=t>0?B[e.slice(0,t)]:void 0;return n===void 0?(0,I.jsx)(`code`,{className:`min-w-0 break-all`,children:e}):(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:n}),(0,I.jsx)(`code`,{className:`min-w-0 break-all`,children:e.slice(t+1)})]})}function H({task:e}){return e.refs.length===0?null:(0,I.jsx)(b,{label:`Refs`,children:(0,I.jsx)(`ul`,{"aria-label":`Refs of #${e.id}`,className:`flex flex-col gap-0.5`,children:e.refs.map(e=>(0,I.jsx)(`li`,{className:`flex min-w-0`,children:(0,I.jsx)(V,{value:e})},e))})})}function U({task:e,detailed:t}){let n=d(e.milestones);return n.length===0?null:t?(0,I.jsxs)(b,{label:`Timeline`,children:[(0,I.jsx)(`dl`,{"aria-label":`Timeline of #${e.id}`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:n.map(({label:e,at:t})=>(0,I.jsxs)(`div`,{className:`contents`,children:[(0,I.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,I.jsx)(`dd`,{children:(0,I.jsx)(E,{at:t})})]},e))}),(0,I.jsx)(z,{task:e})]}):(0,I.jsx)(`p`,{"aria-label":`Timeline of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:n.map(({label:e,at:t})=>(0,I.jsx)(E,{at:t,prefix:`${e} `},e))})}function W({task:e,tasks:t,context:n,navigation:r}){let o=a(),c=s(),d=l(),f=(o.data??[]).flatMap(({taskId:t,relatedId:n})=>t===e.id?[n]:n===e.id?[t]:[]).filter(e=>n.byId.has(e)),p=t.filter(t=>t.id!==e.id&&!f.includes(t.id)),m=[...new Set([e.workspaceId,...p.map(e=>e.workspaceId)])].map(e=>({workspaceId:e,tasks:p.filter(t=>t.workspaceId===e)})).filter(e=>e.tasks.length>0),g=S(),_=c.isPending||d.isPending||g,v=c.error??d.error;if(f.length===0&&m.length===0)return null;let y=m.length>0&&(0,I.jsxs)(`select`,{"aria-label":`Add related task to #${e.id}`,className:i(`h-6 rounded-md border border-input bg-background px-1.5 text-xs outline-none max-md:h-11 max-md:px-2.5 max-md:text-sm focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50`,`max-w-48`),value:``,disabled:_,onChange:t=>{t.target.value&&c.mutate({taskId:e.id,relatedId:Number(t.target.value)})},children:[(0,I.jsx)(`option`,{value:``,children:`Add related task...`}),m.map(e=>(0,I.jsx)(`optgroup`,{label:n.workspaceName(e.workspaceId),children:e.tasks.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[`#`,e.id,` `,e.title]},e.id))},e.workspaceId))]}),x=v&&(0,I.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:v.message});return f.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs`,children:[y,x]}):(0,I.jsxs)(b,{label:`Related`,children:[(0,I.jsxs)(`ul`,{"aria-label":`Related tasks of #${e.id}`,className:`flex flex-wrap items-center gap-1 max-md:gap-2`,children:[f.map(t=>{let i=n.byId.get(t),a=h(t,e.workspaceId,n);return(0,I.jsxs)(`li`,{className:`inline-flex h-6 min-w-0 items-center rounded-md border max-md:h-11 max-md:gap-2 max-md:border-0`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-label":`Open related task ${a}`,title:i?.title,className:`h-full min-w-0 max-w-56 truncate rounded-l-md px-1.5 tabular-nums hover:bg-muted max-md:rounded-md max-md:border max-md:px-3 disabled:cursor-default disabled:hover:bg-transparent`,disabled:r===void 0||!r.canOpen(t),onClick:()=>r?.open(t),children:[a,` `,i?.title]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Remove related task #${t} from #${e.id}`,title:`Remove related task`,className:`flex h-full items-center justify-center rounded-r-md p-1 text-muted-foreground hover:bg-muted max-md:w-11 max-md:rounded-md max-md:border hover:text-foreground disabled:opacity-50`,disabled:_,onClick:()=>d.mutate({taskId:e.id,relatedId:t}),children:(0,I.jsx)(u,{className:`size-3`})})]},t)}),y]}),x]})}function G({task:e}){return(0,I.jsxs)(I.Fragment,{children:[(e.estimate!==null||e.dueDate!==null)&&(0,I.jsxs)(`p`,{"aria-label":`Plan of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:[e.estimate!==null&&(0,I.jsxs)(`span`,{children:[`Estimate `,w(e.estimate)]}),e.dueDate!==null&&(0,I.jsx)(x,{task:e})]}),(0,I.jsx)(T,{task:e}),(0,I.jsx)(H,{task:e})]})}var K={progress:`Progress`,blocker:`Blocker`,decision:`Decision`},q={progress:`neutral`,blocker:`attention`,decision:`info`};function J({kind:e}){return(0,I.jsx)(`span`,{"data-note-kind":e,className:i(`shrink-0 rounded-md px-1.5 font-medium`,C[q[e]]),children:K[e]})}function Y({task:e,detailed:t}){let n=e.notes;if(n.length===0)return null;if(!t){let t=n[n.length-1];return(0,I.jsxs)(`p`,{"aria-label":`Latest note of #${e.id}`,className:`flex min-w-0 items-center gap-1.5 text-xs`,title:ee(t.at),children:[(0,I.jsx)(J,{kind:t.kind}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:D(t.body)}),n.length>1&&(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`+${n.length-1} more`})]})}return(0,I.jsx)(b,{label:`Notes (${n.length})`,children:(0,I.jsx)(`ol`,{"aria-label":`Notes of #${e.id}`,className:`flex flex-col gap-2`,children:n.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(J,{kind:e.kind}),(0,I.jsx)(E,{className:`text-muted-foreground`,at:e.at})]}),(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(`p`,{className:`whitespace-pre-line break-words-keep`,children:e.body}),children:(0,I.jsx)(p,{source:e.body})})]},t))})})}var X={pending:`Pending`,met:`Met`,failed:`Failed`},Z={pending:_.neutral,met:_.success,failed:_.danger},Q={user:`you`,agent:`an agent`,toodo:`Toodo`};function $({state:e}){let t=e===`met`?j:e===`failed`?te:P;return(0,I.jsx)(`span`,{role:`img`,"aria-label":X[e],className:i(`flex size-4 shrink-0 items-center justify-center`,Z[e]),children:(0,I.jsx)(t,{"aria-hidden":!0,className:`size-3.5`})})}function ne(e){if(e.checkedBy===null)return null;let t=e.checkedAt===null?``:` ${y(e.checkedAt)}`;return`Checked by ${Q[e.checkedBy]}${t}`}function re({task:e,detailed:t}){let n=e.criteria;if(n.length===0)return null;let r=(0,I.jsx)(`ul`,{"aria-label":`Criteria of #${e.id}`,className:`flex flex-col gap-0.5`,children:n.map(n=>(0,I.jsx)(ie,{task:e,criterion:n,detailed:t},n.id))});if(!t)return r;let i=n.filter(e=>e.state===`met`).length;return(0,I.jsx)(b,{label:`Criteria (${i} of ${n.length} met)`,children:r})}function ie({task:e,criterion:t,detailed:n}){let r=c(),a=S(),[s,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(``),p=t.kind===`manual`&&e.status!==`done`,h=ne(t),y=m(t.kind)?t.target:null;function b(){l(!1),d(``)}let x=v(u.trim()!==``,b,r.isPending);function C(n){s?b():n?(r.reset(),l(!0)):r.mutate({taskId:e.id,criterionId:t.id,met:!1,evidence:null})}function w(n){n.preventDefault(),r.mutate({taskId:e.id,criterionId:t.id,met:!0,evidence:u.trim()||null},{onSuccess:b})}return(0,I.jsxs)(`li`,{"data-criterion-state":t.state,className:`flex min-w-0 flex-col gap-0.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,title:n?void 0:[h,t.evidence,y].filter(Boolean).join(`
1
+ import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{B as a,at as o,i as s,l as c,w as l}from"./queries-usvG1nHU.js";import{s as u}from"./workspace-list-yRYeAvrx.js";import{Ct as d,F as f,G as p,I as m,J as h,L as g,Pt as _,R as v,St as y,U as b,W as x,Y as S,jt as C,mt as w,q as T,vt as E,xt as ee,z as D}from"./index-DO2HCuk5.js";import{t as O}from"./opener-DWhHPoCL.js";import{t as k}from"./details-sheet-BE43Y-et.js";var A={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};A.node;var j=t(A),M={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};M.node;var te=t(M),N={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};N.node;var P=t(N),F=r(e(),1),I=n();function L({onClose:e,children:t}){let n=(0,F.useRef)(null),[r,i]=(0,F.useState)(!1);function a(){n.current?.querySelector(`form[data-dirty]`)?i(!0):e()}return(0,F.useEffect)(()=>{function e(e){e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role=menu]`)||(r?i(!1):e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select`)||a())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,I.jsx)(k,{ref:n,width:`min(480px, max(360px, 40vw), calc(100vw - 32px))`,onClose:a,banner:r&&(0,I.jsxs)(`div`,{role:`group`,"aria-label":`Unsaved changes`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted px-4 py-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Discard your unsaved changes?`}),(0,I.jsx)(o,{size:`xs`,variant:`outline`,autoFocus:!0,onClick:()=>i(!1),children:`Keep editing`}),(0,I.jsx)(o,{size:`xs`,variant:`destructive`,onClick:e,children:`Discard changes`})]}),children:t})}function R(e){switch(e.status){case`in_progress`:return`Started`;case`in_review`:return`In review`;case`done`:return`Completed`;case`planned`:return e.reopened?`Reopened`:`Paused`}}function z({task:e}){let t=e.timeline.filter(e=>e.reason!==null);return t.length===0?null:(0,I.jsx)(`ol`,{"aria-label":`Reasons of #${e.id}`,className:`mt-1 flex flex-col gap-0.5`,children:t.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 max-md:flex-wrap max-md:gap-y-0`,children:[(0,I.jsx)(E,{className:`shrink-0 text-muted-foreground`,at:e.at}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium`,children:R(e)}),(0,I.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words-keep max-md:basis-full`,children:e.reason})]},t))})}var B={lane:`Lane`,discord:`Discord`,pr:`PR`};function V({value:e}){if(/^https?:\/\//i.test(e)){let t=t=>{t.preventDefault(),O(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,I.jsx)(`a`,{href:e,onClick:t,onAuxClick:t,className:`min-w-0 break-all text-primary underline underline-offset-2 hover:no-underline`,children:e})}let t=e.indexOf(`:`),n=t>0?B[e.slice(0,t)]:void 0;return n===void 0?(0,I.jsx)(`code`,{className:`min-w-0 break-all`,children:e}):(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:n}),(0,I.jsx)(`code`,{className:`min-w-0 break-all`,children:e.slice(t+1)})]})}function H({task:e}){return e.refs.length===0?null:(0,I.jsx)(b,{label:`Refs`,children:(0,I.jsx)(`ul`,{"aria-label":`Refs of #${e.id}`,className:`flex flex-col gap-0.5`,children:e.refs.map(e=>(0,I.jsx)(`li`,{className:`flex min-w-0`,children:(0,I.jsx)(V,{value:e})},e))})})}function U({task:e,detailed:t}){let n=d(e.milestones);return n.length===0?null:t?(0,I.jsxs)(b,{label:`Timeline`,children:[(0,I.jsx)(`dl`,{"aria-label":`Timeline of #${e.id}`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:n.map(({label:e,at:t})=>(0,I.jsxs)(`div`,{className:`contents`,children:[(0,I.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,I.jsx)(`dd`,{children:(0,I.jsx)(E,{at:t})})]},e))}),(0,I.jsx)(z,{task:e})]}):(0,I.jsx)(`p`,{"aria-label":`Timeline of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:n.map(({label:e,at:t})=>(0,I.jsx)(E,{at:t,prefix:`${e} `},e))})}function W({task:e,tasks:t,context:n,navigation:r}){let o=a(),c=s(),d=l(),f=(o.data??[]).flatMap(({taskId:t,relatedId:n})=>t===e.id?[n]:n===e.id?[t]:[]).filter(e=>n.byId.has(e)),p=t.filter(t=>t.id!==e.id&&!f.includes(t.id)),m=[...new Set([e.workspaceId,...p.map(e=>e.workspaceId)])].map(e=>({workspaceId:e,tasks:p.filter(t=>t.workspaceId===e)})).filter(e=>e.tasks.length>0),g=S(),_=c.isPending||d.isPending||g,v=c.error??d.error;if(f.length===0&&m.length===0)return null;let y=m.length>0&&(0,I.jsxs)(`select`,{"aria-label":`Add related task to #${e.id}`,className:i(`h-6 rounded-md border border-input bg-background px-1.5 text-xs outline-none max-md:h-11 max-md:px-2.5 max-md:text-sm focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50`,`max-w-48`),value:``,disabled:_,onChange:t=>{t.target.value&&c.mutate({taskId:e.id,relatedId:Number(t.target.value)})},children:[(0,I.jsx)(`option`,{value:``,children:`Add related task...`}),m.map(e=>(0,I.jsx)(`optgroup`,{label:n.workspaceName(e.workspaceId),children:e.tasks.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[`#`,e.id,` `,e.title]},e.id))},e.workspaceId))]}),x=v&&(0,I.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:v.message});return f.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs`,children:[y,x]}):(0,I.jsxs)(b,{label:`Related`,children:[(0,I.jsxs)(`ul`,{"aria-label":`Related tasks of #${e.id}`,className:`flex flex-wrap items-center gap-1 max-md:gap-2`,children:[f.map(t=>{let i=n.byId.get(t),a=h(t,e.workspaceId,n);return(0,I.jsxs)(`li`,{className:`inline-flex h-6 min-w-0 items-center rounded-md border max-md:h-11 max-md:gap-2 max-md:border-0`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-label":`Open related task ${a}`,title:i?.title,className:`h-full min-w-0 max-w-56 truncate rounded-l-md px-1.5 tabular-nums hover:bg-muted max-md:rounded-md max-md:border max-md:px-3 disabled:cursor-default disabled:hover:bg-transparent`,disabled:r===void 0||!r.canOpen(t),onClick:()=>r?.open(t),children:[a,` `,i?.title]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Remove related task #${t} from #${e.id}`,title:`Remove related task`,className:`flex h-full items-center justify-center rounded-r-md p-1 text-muted-foreground hover:bg-muted max-md:w-11 max-md:rounded-md max-md:border hover:text-foreground disabled:opacity-50`,disabled:_,onClick:()=>d.mutate({taskId:e.id,relatedId:t}),children:(0,I.jsx)(u,{className:`size-3`})})]},t)}),y]}),x]})}function G({task:e}){return(0,I.jsxs)(I.Fragment,{children:[(e.estimate!==null||e.dueDate!==null)&&(0,I.jsxs)(`p`,{"aria-label":`Plan of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:[e.estimate!==null&&(0,I.jsxs)(`span`,{children:[`Estimate `,w(e.estimate)]}),e.dueDate!==null&&(0,I.jsx)(x,{task:e})]}),(0,I.jsx)(T,{task:e}),(0,I.jsx)(H,{task:e})]})}var K={progress:`Progress`,blocker:`Blocker`,decision:`Decision`},q={progress:`neutral`,blocker:`attention`,decision:`info`};function J({kind:e}){return(0,I.jsx)(`span`,{"data-note-kind":e,className:i(`shrink-0 rounded-md px-1.5 font-medium`,C[q[e]]),children:K[e]})}function Y({task:e,detailed:t}){let n=e.notes;if(n.length===0)return null;if(!t){let t=n[n.length-1];return(0,I.jsxs)(`p`,{"aria-label":`Latest note of #${e.id}`,className:`flex min-w-0 items-center gap-1.5 text-xs`,title:ee(t.at),children:[(0,I.jsx)(J,{kind:t.kind}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:D(t.body)}),n.length>1&&(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`+${n.length-1} more`})]})}return(0,I.jsx)(b,{label:`Notes (${n.length})`,children:(0,I.jsx)(`ol`,{"aria-label":`Notes of #${e.id}`,className:`flex flex-col gap-2`,children:n.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(J,{kind:e.kind}),(0,I.jsx)(E,{className:`text-muted-foreground`,at:e.at})]}),(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(`p`,{className:`whitespace-pre-line break-words-keep`,children:e.body}),children:(0,I.jsx)(p,{source:e.body})})]},t))})})}var X={pending:`Pending`,met:`Met`,failed:`Failed`},Z={pending:_.neutral,met:_.success,failed:_.danger},Q={user:`you`,agent:`an agent`,toodo:`Toodo`};function $({state:e}){let t=e===`met`?j:e===`failed`?te:P;return(0,I.jsx)(`span`,{role:`img`,"aria-label":X[e],className:i(`flex size-4 shrink-0 items-center justify-center`,Z[e]),children:(0,I.jsx)(t,{"aria-hidden":!0,className:`size-3.5`})})}function ne(e){if(e.checkedBy===null)return null;let t=e.checkedAt===null?``:` ${y(e.checkedAt)}`;return`Checked by ${Q[e.checkedBy]}${t}`}function re({task:e,detailed:t}){let n=e.criteria;if(n.length===0)return null;let r=(0,I.jsx)(`ul`,{"aria-label":`Criteria of #${e.id}`,className:`flex flex-col gap-0.5`,children:n.map(n=>(0,I.jsx)(ie,{task:e,criterion:n,detailed:t},n.id))});if(!t)return r;let i=n.filter(e=>e.state===`met`).length;return(0,I.jsx)(b,{label:`Criteria (${i} of ${n.length} met)`,children:r})}function ie({task:e,criterion:t,detailed:n}){let r=c(),a=S(),[s,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(``),p=t.kind===`manual`&&e.status!==`done`,h=ne(t),y=m(t.kind)?t.target:null;function b(){l(!1),d(``)}let x=v(u.trim()!==``,b,r.isPending);function C(n){s?b():n?(r.reset(),l(!0)):r.mutate({taskId:e.id,criterionId:t.id,met:!1,evidence:null})}function w(n){n.preventDefault(),r.mutate({taskId:e.id,criterionId:t.id,met:!0,evidence:u.trim()||null},{onSuccess:b})}return(0,I.jsxs)(`li`,{"data-criterion-state":t.state,className:`flex min-w-0 flex-col gap-0.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,title:n?void 0:[h,t.evidence,y].filter(Boolean).join(`
2
2
  `)||void 0,children:[p?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`label`,{className:`flex size-4 shrink-0 items-center justify-center max-md:-mx-3.5 max-md:size-11`,children:(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`Check criterion ${t.id} of #${e.id}`,checked:t.state===`met`||s,disabled:r.isPending||a,onChange:e=>C(e.target.checked)})}),t.state===`failed`&&(0,I.jsx)($,{state:`failed`})]}):(0,I.jsx)($,{state:t.state}),(0,I.jsx)(`span`,{className:i(`min-w-0`,n?`break-words-keep`:`truncate`,t.state===`failed`&&_.danger),children:t.text}),t.kind!==`manual`&&(0,I.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-1.5 text-muted-foreground`,children:f[t.kind]}),!n&&t.evidence&&(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.evidence})]}),n&&y&&(0,I.jsx)(`code`,{className:`ml-5.5 break-all text-muted-foreground`,children:y}),n&&(t.evidence||h)&&(0,I.jsxs)(`p`,{className:`ml-5.5 whitespace-pre-line break-words-keep text-muted-foreground`,children:[t.evidence,t.evidence&&h&&` · `,t.checkedBy!==null&&(0,I.jsxs)(I.Fragment,{children:[`Checked by `,Q[t.checkedBy],t.checkedAt!==null&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(E,{at:t.checkedAt})]})]})]}),s&&(0,I.jsxs)(`form`,{onSubmit:w,className:`ml-5.5 flex flex-wrap items-center gap-1`,onKeyDown:x.onKeyDown,children:[(0,I.jsx)(`input`,{className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`h-7 flex-1 basis-48`),"aria-label":`Evidence for criterion ${t.id}`,placeholder:`Evidence (optional), e.g. a link or what you checked`,value:u,onChange:e=>d(e.target.value),autoFocus:!0}),x.asking?(0,I.jsx)(g,{label:`Discard evidence for criterion ${t.id}`,question:`Discard the evidence?`,onKeep:x.keep,onDiscard:x.discard}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{type:`submit`,size:`xs`,disabled:r.isPending,children:r.isPending?`Saving...`:`Save`}),(0,I.jsx)(o,{type:`button`,size:`xs`,variant:`ghost`,onClick:x.request,children:`Cancel`})]})]}),r.isError&&(0,I.jsx)(`p`,{role:`alert`,className:`ml-5.5 text-destructive`,children:r.error.message})]})}export{W as RelatedTasks,re as TaskCriteria,L as TaskDetailsSheet,Y as TaskNotes,G as TaskPlan,U as TaskTimeline};