@openparachute/notes-ui 0.1.6-rc.2 → 0.1.6

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.
Files changed (24) hide show
  1. package/dist/.parachute/info +1 -1
  2. package/dist/assets/{Activity-DJhKtRnz.js → Activity-B_Je-lCL.js} +1 -1
  3. package/dist/assets/{AddVault-DX-7VPHH.js → AddVault-D0ySEVNg.js} +1 -1
  4. package/dist/assets/{AttachmentDropZone-DrZXEO9k.js → AttachmentDropZone-CqhzolLE.js} +1 -1
  5. package/dist/assets/{Calendar-CfbphZhF.js → Calendar-CoPaqJQB.js} +1 -1
  6. package/dist/assets/Import-CrWr1lWO.js +14 -0
  7. package/dist/assets/{NoteEditor-ZdIpS6QN.js → NoteEditor-D-bt-d63.js} +1 -1
  8. package/dist/assets/{NoteNew-Crzh0iYo.js → NoteNew-Dw7l1rjo.js} +1 -1
  9. package/dist/assets/{NoteRenderer-BGWbYFIT.js → NoteRenderer-uc1hZU0j.js} +1 -1
  10. package/dist/assets/{NoteView-LNlromHS.js → NoteView-CGGge5Bp.js} +2 -2
  11. package/dist/assets/{OAuthCallback-D1kmhUQA.js → OAuthCallback-D1ql8sDc.js} +1 -1
  12. package/dist/assets/{PinArchiveButtons-HkysJJPl.js → PinArchiveButtons-DAjOG3J2.js} +1 -1
  13. package/dist/assets/{Settings-DpHNB3Wj.js → Settings-DTa8sOyo.js} +1 -1
  14. package/dist/assets/{Tags-5UgiMjud.js → Tags-F1LzSPLy.js} +1 -1
  15. package/dist/assets/{Today-MgBcz9I5.js → Today-HA6so2M2.js} +1 -1
  16. package/dist/assets/{VaultGraph-CHtHQpMd.js → VaultGraph-XMhBSHMZ.js} +2 -2
  17. package/dist/assets/{Vaults-RFwi9oID.js → Vaults-N_zHHUue.js} +1 -1
  18. package/dist/assets/{index-D27iivhA.js → index-953EjlvE.js} +2 -2
  19. package/dist/assets/{react-force-graph-2d-DBfJJN1_.js → react-force-graph-2d-BhR6Ke_0.js} +1 -1
  20. package/dist/assets/{useAttachmentUploader-CoOJv16s.js → useAttachmentUploader-BQ3_bJ9p.js} +1 -1
  21. package/dist/index.html +1 -1
  22. package/dist/sw.js +1 -1
  23. package/package.json +2 -2
  24. package/dist/assets/Import-BOoIUF34.js +0 -12
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Calendar-CfbphZhF.js","./dates-BGZoWpL2.js","./Import-BOoIUF34.js","./AttachmentDropZone-DrZXEO9k.js","./NoteEditor-ZdIpS6QN.js","./useAttachmentUploader-CoOJv16s.js","./PinArchiveButtons-HkysJJPl.js","./NoteRenderer-BGWbYFIT.js","./NoteNew-Crzh0iYo.js","./NoteView-LNlromHS.js","./Today-MgBcz9I5.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Calendar-CoPaqJQB.js","./dates-BGZoWpL2.js","./Import-CrWr1lWO.js","./AttachmentDropZone-CqhzolLE.js","./NoteEditor-D-bt-d63.js","./useAttachmentUploader-BQ3_bJ9p.js","./PinArchiveButtons-DAjOG3J2.js","./NoteRenderer-uc1hZU0j.js","./NoteNew-Dw7l1rjo.js","./NoteView-CGGge5Bp.js","./Today-HA6so2M2.js"])))=>i.map(i=>d[i]);
2
2
  var Zx=Object.defineProperty;var Yy=a=>{throw TypeError(a)};var Fx=(a,l,s)=>l in a?Zx(a,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[l]=s;var xe=(a,l,s)=>Fx(a,typeof l!="symbol"?l+"":l,s),bf=(a,l,s)=>l.has(a)||Yy("Cannot "+s);var T=(a,l,s)=>(bf(a,l,"read from private field"),s?s.call(a):l.get(a)),ne=(a,l,s)=>l.has(a)?Yy("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(a):l.set(a,s),Z=(a,l,s,r)=>(bf(a,l,"write to private field"),r?r.call(a,s):l.set(a,s),s),me=(a,l,s)=>(bf(a,l,"access private method"),s);var du=(a,l,s,r)=>({set _(c){Z(a,l,c,s)},get _(){return T(a,l,r)}});(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const f of c)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function s(c){const f={};return c.integrity&&(f.integrity=c.integrity),c.referrerPolicy&&(f.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?f.credentials="include":c.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function r(c){if(c.ep)return;c.ep=!0;const f=s(c);fetch(c.href,f)}})();var tN=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jx(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var xf={exports:{}},Es={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -27,7 +27,7 @@ var Zx=Object.defineProperty;var Yy=a=>{throw TypeError(a)};var Fx=(a,l,s)=>l in
27
27
  */var Ag="popstate";function Ng(a){return typeof a=="object"&&a!=null&&"pathname"in a&&"search"in a&&"hash"in a&&"state"in a&&"key"in a}function WE(a={}){function l(r,c){var g;let f=(g=c.state)==null?void 0:g.masked,{pathname:h,search:y,hash:p}=f||r.location;return dd("",{pathname:h,search:y,hash:p},c.state&&c.state.usr||null,c.state&&c.state.key||"default",f?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function s(r,c){return typeof c=="string"?c:Ds(c)}return tw(l,s,null,a)}function Ke(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function ln(a,l){if(!a){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function ew(){return Math.random().toString(36).substring(2,10)}function jg(a,l){return{usr:a.state,key:a.key,idx:l,masked:a.mask?{pathname:a.pathname,search:a.search,hash:a.hash}:void 0}}function dd(a,l,s=null,r,c){return{pathname:typeof a=="string"?a:a.pathname,search:"",hash:"",...typeof l=="string"?Si(l):l,state:s,key:l&&l.key||r||ew(),mask:c}}function Ds({pathname:a="/",search:l="",hash:s=""}){return l&&l!=="?"&&(a+=l.charAt(0)==="?"?l:"?"+l),s&&s!=="#"&&(a+=s.charAt(0)==="#"?s:"#"+s),a}function Si(a){let l={};if(a){let s=a.indexOf("#");s>=0&&(l.hash=a.substring(s),a=a.substring(0,s));let r=a.indexOf("?");r>=0&&(l.search=a.substring(r),a=a.substring(0,r)),a&&(l.pathname=a)}return l}function tw(a,l,s,r={}){let{window:c=document.defaultView,v5Compat:f=!1}=r,h=c.history,y="POP",p=null,g=x();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function x(){return(h.state||{idx:null}).idx}function v(){y="POP";let z=x(),C=z==null?null:z-g;g=z,p&&p({action:y,location:_.location,delta:C})}function E(z,C){y="PUSH";let Y=Ng(z)?z:dd(_.location,z,C);g=x()+1;let G=jg(Y,g),V=_.createHref(Y.mask||Y);try{h.pushState(G,"",V)}catch(K){if(K instanceof DOMException&&K.name==="DataCloneError")throw K;c.location.assign(V)}f&&p&&p({action:y,location:_.location,delta:1})}function A(z,C){y="REPLACE";let Y=Ng(z)?z:dd(_.location,z,C);g=x();let G=jg(Y,g),V=_.createHref(Y.mask||Y);h.replaceState(G,"",V),f&&p&&p({action:y,location:_.location,delta:0})}function D(z){return nw(z)}let _={get action(){return y},get location(){return a(c,h)},listen(z){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(Ag,v),p=z,()=>{c.removeEventListener(Ag,v),p=null}},createHref(z){return l(c,z)},createURL:D,encodeLocation(z){let C=D(z);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:E,replace:A,go(z){return h.go(z)}};return _}function nw(a,l=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Ke(s,"No window.location.(origin|href) available to create URL");let r=typeof a=="string"?a:Ds(a);return r=r.replace(/ $/,"%20"),!l&&r.startsWith("//")&&(r=s+r),new URL(r,s)}function Wv(a,l,s="/"){return aw(a,l,s,!1)}function aw(a,l,s,r,c){let f=typeof l=="string"?Si(l):l,h=In(f.pathname||"/",s);if(h==null)return null;let y=lw(a),p=null,g=yw(h);for(let x=0;p==null&&x<y.length;++x)p=mw(y[x],g,r);return p}function lw(a){let l=eb(a);return iw(l),l}function eb(a,l=[],s=[],r="",c=!1){let f=(h,y,p=c,g)=>{let x={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:y,route:h};if(x.relativePath.startsWith("/")){if(!x.relativePath.startsWith(r)&&p)return;Ke(x.relativePath.startsWith(r),`Absolute route path "${x.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),x.relativePath=x.relativePath.slice(r.length)}let v=on([r,x.relativePath]),E=s.concat(x);h.children&&h.children.length>0&&(Ke(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),eb(h.children,l,E,v,p)),!(h.path==null&&!h.index)&&l.push({path:v,score:dw(v,h.index),routesMeta:E})};return a.forEach((h,y)=>{var p;if(h.path===""||!((p=h.path)!=null&&p.includes("?")))f(h,y);else for(let g of tb(h.path))f(h,y,!0,g)}),l}function tb(a){let l=a.split("/");if(l.length===0)return[];let[s,...r]=l,c=s.endsWith("?"),f=s.replace(/\?$/,"");if(r.length===0)return c?[f,""]:[f];let h=tb(r.join("/")),y=[];return y.push(...h.map(p=>p===""?f:[f,p].join("/"))),c&&y.push(...h),y.map(p=>a.startsWith("/")&&p===""?"/":p)}function iw(a){a.sort((l,s)=>l.score!==s.score?s.score-l.score:hw(l.routesMeta.map(r=>r.childrenIndex),s.routesMeta.map(r=>r.childrenIndex)))}var sw=/^:[\w-]+$/,rw=3,uw=2,cw=1,ow=10,fw=-2,Rg=a=>a==="*";function dw(a,l){let s=a.split("/"),r=s.length;return s.some(Rg)&&(r+=fw),l&&(r+=uw),s.filter(c=>!Rg(c)).reduce((c,f)=>c+(sw.test(f)?rw:f===""?cw:ow),r)}function hw(a,l){return a.length===l.length&&a.slice(0,-1).every((r,c)=>r===l[c])?a[a.length-1]-l[l.length-1]:0}function mw(a,l,s=!1){let{routesMeta:r}=a,c={},f="/",h=[];for(let y=0;y<r.length;++y){let p=r[y],g=y===r.length-1,x=f==="/"?l:l.slice(f.length)||"/",v=Hu({path:p.relativePath,caseSensitive:p.caseSensitive,end:g},x),E=p.route;if(!v&&g&&s&&!r[r.length-1].route.index&&(v=Hu({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},x)),!v)return null;Object.assign(c,v.params),h.push({params:c,pathname:on([f,v.pathname]),pathnameBase:xw(on([f,v.pathnameBase])),route:E}),v.pathnameBase!=="/"&&(f=on([f,v.pathnameBase]))}return h}function Hu(a,l){typeof a=="string"&&(a={path:a,caseSensitive:!1,end:!0});let[s,r]=pw(a.path,a.caseSensitive,a.end),c=l.match(s);if(!c)return null;let f=c[0],h=f.replace(/(.)\/+$/,"$1"),y=c.slice(1);return{params:r.reduce((g,{paramName:x,isOptional:v},E)=>{if(x==="*"){let D=y[E]||"";h=f.slice(0,f.length-D.length).replace(/(.)\/+$/,"$1")}const A=y[E];return v&&!A?g[x]=void 0:g[x]=(A||"").replace(/%2F/g,"/"),g},{}),pathname:f,pathnameBase:h,pattern:a}}function pw(a,l=!1,s=!0){ln(a==="*"||!a.endsWith("*")||a.endsWith("/*"),`Route path "${a}" will be treated as if it were "${a.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${a.replace(/\*$/,"/*")}".`);let r=[],c="^"+a.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,y,p,g,x)=>{if(r.push({paramName:y,isOptional:p!=null}),p){let v=x.charAt(g+h.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return a.endsWith("*")?(r.push({paramName:"*"}),c+=a==="*"||a==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":a!==""&&a!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,l?void 0:"i"),r]}function yw(a){try{return a.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return ln(!1,`The URL path "${a}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),a}}function In(a,l){if(l==="/")return a;if(!a.toLowerCase().startsWith(l.toLowerCase()))return null;let s=l.endsWith("/")?l.length-1:l.length,r=a.charAt(s);return r&&r!=="/"?null:a.slice(s)||"/"}var gw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function vw(a,l="/"){let{pathname:s,search:r="",hash:c=""}=typeof a=="string"?Si(a):a,f;return s?(s=nb(s),s.startsWith("/")?f=Cg(s.substring(1),"/"):f=Cg(s,l)):f=l,{pathname:f,search:Sw(r),hash:Ew(c)}}function Cg(a,l){let s=ku(l).split("/");return a.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function Mf(a,l,s,r){return`Cannot include a '${a}' character in a manually specified \`to.${l}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function bw(a){return a.filter((l,s)=>s===0||l.route.path&&l.route.path.length>0)}function Hd(a){let l=bw(a);return l.map((s,r)=>r===l.length-1?s.pathname:s.pathnameBase)}function Fu(a,l,s,r=!1){let c;typeof a=="string"?c=Si(a):(c={...a},Ke(!c.pathname||!c.pathname.includes("?"),Mf("?","pathname","search",c)),Ke(!c.pathname||!c.pathname.includes("#"),Mf("#","pathname","hash",c)),Ke(!c.search||!c.search.includes("#"),Mf("#","search","hash",c)));let f=a===""||c.pathname==="",h=f?"/":c.pathname,y;if(h==null)y=s;else{let v=l.length-1;if(!r&&h.startsWith("..")){let E=h.split("/");for(;E[0]==="..";)E.shift(),v-=1;c.pathname=E.join("/")}y=v>=0?l[v]:"/"}let p=vw(c,y),g=h&&h!=="/"&&h.endsWith("/"),x=(f||h===".")&&s.endsWith("/");return!p.pathname.endsWith("/")&&(g||x)&&(p.pathname+="/"),p}var nb=a=>a.replace(/\/\/+/g,"/"),on=a=>nb(a.join("/")),ku=a=>a.replace(/\/+$/,""),xw=a=>ku(a).replace(/^\/*/,"/"),Sw=a=>!a||a==="?"?"":a.startsWith("?")?a:"?"+a,Ew=a=>!a||a==="#"?"":a.startsWith("#")?a:"#"+a,ww=class{constructor(a,l,s,r=!1){this.status=a,this.statusText=l||"",this.internal=r,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function Tw(a){return a!=null&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.internal=="boolean"&&"data"in a}function Aw(a){let l=a.map(s=>s.route.path).filter(Boolean);return on(l)||"/"}var ab=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function lb(a,l){let s=a;if(typeof s!="string"||!gw.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let r=s,c=!1;if(ab)try{let f=new URL(window.location.href),h=s.startsWith("//")?new URL(f.protocol+s):new URL(s),y=In(h.pathname,l);h.origin===f.origin&&y!=null?s=y+h.search+h.hash:c=!0}catch{ln(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ib=["POST","PUT","PATCH","DELETE"];new Set(ib);var Nw=["GET",...ib];new Set(Nw);var Ei=S.createContext(null);Ei.displayName="DataRouter";var Ju=S.createContext(null);Ju.displayName="DataRouterState";var sb=S.createContext(!1);function jw(){return S.useContext(sb)}var rb=S.createContext({isTransitioning:!1});rb.displayName="ViewTransition";var Rw=S.createContext(new Map);Rw.displayName="Fetchers";var Cw=S.createContext(null);Cw.displayName="Await";var Kt=S.createContext(null);Kt.displayName="Navigation";var Ks=S.createContext(null);Ks.displayName="Location";var dn=S.createContext({outlet:null,matches:[],isDataRoute:!1});dn.displayName="Route";var kd=S.createContext(null);kd.displayName="RouteError";var ub="REACT_ROUTER_ERROR",_w="REDIRECT",Ow="ROUTE_ERROR_RESPONSE";function Mw(a){if(a.startsWith(`${ub}:${_w}:{`))try{let l=JSON.parse(a.slice(28));if(typeof l=="object"&&l&&typeof l.status=="number"&&typeof l.statusText=="string"&&typeof l.location=="string"&&typeof l.reloadDocument=="boolean"&&typeof l.replace=="boolean")return l}catch{}}function Dw(a){if(a.startsWith(`${ub}:${Ow}:{`))try{let l=JSON.parse(a.slice(40));if(typeof l=="object"&&l&&typeof l.status=="number"&&typeof l.statusText=="string")return new ww(l.status,l.statusText,l.data)}catch{}}function Uw(a,{relative:l}={}){Ke(wi(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:r}=S.useContext(Kt),{hash:c,pathname:f,search:h}=$s(a,{relative:l}),y=f;return s!=="/"&&(y=f==="/"?s:on([s,f])),r.createHref({pathname:y,search:h,hash:c})}function wi(){return S.useContext(Ks)!=null}function Xt(){return Ke(wi(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(Ks).location}var cb="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ob(a){S.useContext(Kt).static||S.useLayoutEffect(a)}function Xs(){let{isDataRoute:a}=S.useContext(dn);return a?Zw():zw()}function zw(){Ke(wi(),"useNavigate() may be used only in the context of a <Router> component.");let a=S.useContext(Ei),{basename:l,navigator:s}=S.useContext(Kt),{matches:r}=S.useContext(dn),{pathname:c}=Xt(),f=JSON.stringify(Hd(r)),h=S.useRef(!1);return ob(()=>{h.current=!0}),S.useCallback((p,g={})=>{if(ln(h.current,cb),!h.current)return;if(typeof p=="number"){s.go(p);return}let x=Fu(p,JSON.parse(f),c,g.relative==="path");a==null&&l!=="/"&&(x.pathname=x.pathname==="/"?l:on([l,x.pathname])),(g.replace?s.replace:s.push)(x,g.state,g)},[l,s,f,c,a])}S.createContext(null);function Lw(){let{matches:a}=S.useContext(dn),l=a[a.length-1];return(l==null?void 0:l.params)??{}}function $s(a,{relative:l}={}){let{matches:s}=S.useContext(dn),{pathname:r}=Xt(),c=JSON.stringify(Hd(s));return S.useMemo(()=>Fu(a,JSON.parse(c),r,l==="path"),[a,c,r,l])}function Vw(a,l){return fb(a,l)}function fb(a,l,s){var z;Ke(wi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=S.useContext(Kt),{matches:c}=S.useContext(dn),f=c[c.length-1],h=f?f.params:{},y=f?f.pathname:"/",p=f?f.pathnameBase:"/",g=f&&f.route;{let C=g&&g.path||"";hb(y,!g||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${y}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
28
28
 
29
29
  Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let x=Xt(),v;if(l){let C=typeof l=="string"?Si(l):l;Ke(p==="/"||((z=C.pathname)==null?void 0:z.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${C.pathname}" was given in the \`location\` prop.`),v=C}else v=x;let E=v.pathname||"/",A=E;if(p!=="/"){let C=p.replace(/^\//,"").split("/");A="/"+E.replace(/^\//,"").split("/").slice(C.length).join("/")}let D=s&&s.state.matches.length?s.state.matches.map(C=>Object.assign(C,{route:s.manifest[C.route.id]||C.route})):Wv(a,{pathname:A});ln(g||D!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),ln(D==null||D[D.length-1].route.element!==void 0||D[D.length-1].route.Component!==void 0||D[D.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=Qw(D&&D.map(C=>Object.assign({},C,{params:Object.assign({},h,C.params),pathname:on([p,r.encodeLocation?r.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?p:on([p,r.encodeLocation?r.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s);return l&&_?S.createElement(Ks.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...v},navigationType:"POP"}},_):_}function qw(){let a=$w(),l=Tw(a)?`${a.status} ${a.statusText}`:a instanceof Error?a.message:JSON.stringify(a),s=a instanceof Error?a.stack:null,r="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:r},f={padding:"2px 4px",backgroundColor:r},h=null;return console.error("Error handled by React Router default ErrorBoundary:",a),h=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),S.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",S.createElement("code",{style:f},"ErrorBoundary")," or"," ",S.createElement("code",{style:f},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},l),s?S.createElement("pre",{style:c},s):null,h)}var Hw=S.createElement(qw,null),db=class extends S.Component{constructor(a){super(a),this.state={location:a.location,revalidation:a.revalidation,error:a.error}}static getDerivedStateFromError(a){return{error:a}}static getDerivedStateFromProps(a,l){return l.location!==a.location||l.revalidation!=="idle"&&a.revalidation==="idle"?{error:a.error,location:a.location,revalidation:a.revalidation}:{error:a.error!==void 0?a.error:l.error,location:l.location,revalidation:a.revalidation||l.revalidation}}componentDidCatch(a,l){this.props.onError?this.props.onError(a,l):console.error("React Router caught the following error during render",a)}render(){let a=this.state.error;if(this.context&&typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){const s=Dw(a.digest);s&&(a=s)}let l=a!==void 0?S.createElement(dn.Provider,{value:this.props.routeContext},S.createElement(kd.Provider,{value:a,children:this.props.component})):this.props.children;return this.context?S.createElement(kw,{error:a},l):l}};db.contextType=sb;var Df=new WeakMap;function kw({children:a,error:l}){let{basename:s}=S.useContext(Kt);if(typeof l=="object"&&l&&"digest"in l&&typeof l.digest=="string"){let r=Mw(l.digest);if(r){let c=Df.get(l);if(c)throw c;let f=lb(r.location,s);if(ab&&!Df.get(l))if(f.isExternal||r.reloadDocument)window.location.href=f.absoluteURL||f.to;else{const h=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:r.replace}));throw Df.set(l,h),h}return S.createElement("meta",{httpEquiv:"refresh",content:`0;url=${f.absoluteURL||f.to}`})}}return a}function Bw({routeContext:a,match:l,children:s}){let r=S.useContext(Ei);return r&&r.static&&r.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=l.route.id),S.createElement(dn.Provider,{value:a},s)}function Qw(a,l=[],s){let r=s==null?void 0:s.state;if(a==null){if(!r)return null;if(r.errors)a=r.matches;else if(l.length===0&&!r.initialized&&r.matches.length>0)a=r.matches;else return null}let c=a,f=r==null?void 0:r.errors;if(f!=null){let x=c.findIndex(v=>v.route.id&&(f==null?void 0:f[v.route.id])!==void 0);Ke(x>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(f).join(",")}`),c=c.slice(0,Math.min(c.length,x+1))}let h=!1,y=-1;if(s&&r){h=r.renderFallback;for(let x=0;x<c.length;x++){let v=c[x];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(y=x),v.route.id){let{loaderData:E,errors:A}=r,D=v.route.loader&&!E.hasOwnProperty(v.route.id)&&(!A||A[v.route.id]===void 0);if(v.route.lazy||D){s.isStatic&&(h=!0),y>=0?c=c.slice(0,y+1):c=[c[0]];break}}}}let p=s==null?void 0:s.onError,g=r&&p?(x,v)=>{var E,A;p(x,{location:r.location,params:((A=(E=r.matches)==null?void 0:E[0])==null?void 0:A.params)??{},pattern:Aw(r.matches),errorInfo:v})}:void 0;return c.reduceRight((x,v,E)=>{let A,D=!1,_=null,z=null;r&&(A=f&&v.route.id?f[v.route.id]:void 0,_=v.route.errorElement||Hw,h&&(y<0&&E===0?(hb("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),D=!0,z=null):y===E&&(D=!0,z=v.route.hydrateFallbackElement||null)));let C=l.concat(c.slice(0,E+1)),Y=()=>{let G;return A?G=_:D?G=z:v.route.Component?G=S.createElement(v.route.Component,null):v.route.element?G=v.route.element:G=x,S.createElement(Bw,{match:v,routeContext:{outlet:x,matches:C,isDataRoute:r!=null},children:G})};return r&&(v.route.ErrorBoundary||v.route.errorElement||E===0)?S.createElement(db,{location:r.location,revalidation:r.revalidation,component:_,error:A,children:Y(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:g}):Y()},null)}function Bd(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Gw(a){let l=S.useContext(Ei);return Ke(l,Bd(a)),l}function Yw(a){let l=S.useContext(Ju);return Ke(l,Bd(a)),l}function Kw(a){let l=S.useContext(dn);return Ke(l,Bd(a)),l}function Qd(a){let l=Kw(a),s=l.matches[l.matches.length-1];return Ke(s.route.id,`${a} can only be used on routes that contain a unique "id"`),s.route.id}function Xw(){return Qd("useRouteId")}function $w(){var r;let a=S.useContext(kd),l=Yw("useRouteError"),s=Qd("useRouteError");return a!==void 0?a:(r=l.errors)==null?void 0:r[s]}function Zw(){let{router:a}=Gw("useNavigate"),l=Qd("useNavigate"),s=S.useRef(!1);return ob(()=>{s.current=!0}),S.useCallback(async(c,f={})=>{ln(s.current,cb),s.current&&(typeof c=="number"?await a.navigate(c):await a.navigate(c,{fromRouteId:l,...f}))},[a,l])}var _g={};function hb(a,l,s){!l&&!_g[a]&&(_g[a]=!0,ln(!1,s))}S.memo(Fw);function Fw({routes:a,manifest:l,future:s,state:r,isStatic:c,onError:f}){return fb(a,void 0,{manifest:l,state:r,isStatic:c,onError:f})}function Us({to:a,replace:l,state:s,relative:r}){Ke(wi(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c}=S.useContext(Kt);ln(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:f}=S.useContext(dn),{pathname:h}=Xt(),y=Xs(),p=Fu(a,Hd(f),h,r==="path"),g=JSON.stringify(p);return S.useEffect(()=>{y(JSON.parse(g),{replace:l,state:s,relative:r})},[y,g,r,l,s]),null}function Xe(a){Ke(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Jw({basename:a="/",children:l=null,location:s,navigationType:r="POP",navigator:c,static:f=!1,useTransitions:h}){Ke(!wi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let y=a.replace(/^\/*/,"/"),p=S.useMemo(()=>({basename:y,navigator:c,static:f,useTransitions:h,future:{}}),[y,c,f,h]);typeof s=="string"&&(s=Si(s));let{pathname:g="/",search:x="",hash:v="",state:E=null,key:A="default",mask:D}=s,_=S.useMemo(()=>{let z=In(g,y);return z==null?null:{location:{pathname:z,search:x,hash:v,state:E,key:A,mask:D},navigationType:r}},[y,g,x,v,E,A,r,D]);return ln(_!=null,`<Router basename="${y}"> is not able to match the URL "${g}${x}${v}" because it does not start with the basename, so the <Router> won't render anything.`),_==null?null:S.createElement(Kt.Provider,{value:p},S.createElement(Ks.Provider,{children:l,value:_}))}function Iw({children:a,location:l}){return Vw(hd(a),l)}function hd(a,l=[]){let s=[];return S.Children.forEach(a,(r,c)=>{if(!S.isValidElement(r))return;let f=[...l,c];if(r.type===S.Fragment){s.push.apply(s,hd(r.props.children,f));return}Ke(r.type===Xe,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ke(!r.props.index||!r.props.children,"An index route cannot have child routes.");let h={id:r.props.id||f.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(h.children=hd(r.props.children,f)),s.push(h)}),s}var Ru="get",Cu="application/x-www-form-urlencoded";function Iu(a){return typeof HTMLElement<"u"&&a instanceof HTMLElement}function Pw(a){return Iu(a)&&a.tagName.toLowerCase()==="button"}function Ww(a){return Iu(a)&&a.tagName.toLowerCase()==="form"}function eT(a){return Iu(a)&&a.tagName.toLowerCase()==="input"}function tT(a){return!!(a.metaKey||a.altKey||a.ctrlKey||a.shiftKey)}function nT(a,l){return a.button===0&&(!l||l==="_self")&&!tT(a)}function md(a=""){return new URLSearchParams(typeof a=="string"||Array.isArray(a)||a instanceof URLSearchParams?a:Object.keys(a).reduce((l,s)=>{let r=a[s];return l.concat(Array.isArray(r)?r.map(c=>[s,c]):[[s,r]])},[]))}function aT(a,l){let s=md(a);return l&&l.forEach((r,c)=>{s.has(c)||l.getAll(c).forEach(f=>{s.append(c,f)})}),s}var bu=null;function lT(){if(bu===null)try{new FormData(document.createElement("form"),0),bu=!1}catch{bu=!0}return bu}var iT=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Uf(a){return a!=null&&!iT.has(a)?(ln(!1,`"${a}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Cu}"`),null):a}function sT(a,l){let s,r,c,f,h;if(Ww(a)){let y=a.getAttribute("action");r=y?In(y,l):null,s=a.getAttribute("method")||Ru,c=Uf(a.getAttribute("enctype"))||Cu,f=new FormData(a)}else if(Pw(a)||eT(a)&&(a.type==="submit"||a.type==="image")){let y=a.form;if(y==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=a.getAttribute("formaction")||y.getAttribute("action");if(r=p?In(p,l):null,s=a.getAttribute("formmethod")||y.getAttribute("method")||Ru,c=Uf(a.getAttribute("formenctype"))||Uf(y.getAttribute("enctype"))||Cu,f=new FormData(y,a),!lT()){let{name:g,type:x,value:v}=a;if(x==="image"){let E=g?`${g}.`:"";f.append(`${E}x`,"0"),f.append(`${E}y`,"0")}else g&&f.append(g,v)}}else{if(Iu(a))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Ru,r=null,c=Cu,h=a}return f&&c==="text/plain"&&(h=f,f=void 0),{action:r,method:s.toLowerCase(),encType:c,formData:f,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Gd(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function mb(a,l,s,r){let c=typeof a=="string"?new URL(a,typeof window>"u"?"server://singlefetch/":window.location.origin):a;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${r}`:c.pathname=`${c.pathname}.${r}`:c.pathname==="/"?c.pathname=`_root.${r}`:l&&In(c.pathname,l)==="/"?c.pathname=`${ku(l)}/_root.${r}`:c.pathname=`${ku(c.pathname)}.${r}`,c}async function rT(a,l){if(a.id in l)return l[a.id];try{let s=await import(a.module);return l[a.id]=s,s}catch(s){return console.error(`Error loading route module \`${a.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function uT(a){return a==null?!1:a.href==null?a.rel==="preload"&&typeof a.imageSrcSet=="string"&&typeof a.imageSizes=="string":typeof a.rel=="string"&&typeof a.href=="string"}async function cT(a,l,s){let r=await Promise.all(a.map(async c=>{let f=l.routes[c.route.id];if(f){let h=await rT(f,s);return h.links?h.links():[]}return[]}));return hT(r.flat(1).filter(uT).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Og(a,l,s,r,c,f){let h=(p,g)=>s[g]?p.route.id!==s[g].route.id:!0,y=(p,g)=>{var x;return s[g].pathname!==p.pathname||((x=s[g].route.path)==null?void 0:x.endsWith("*"))&&s[g].params["*"]!==p.params["*"]};return f==="assets"?l.filter((p,g)=>h(p,g)||y(p,g)):f==="data"?l.filter((p,g)=>{var v;let x=r.routes[p.route.id];if(!x||!x.hasLoader)return!1;if(h(p,g)||y(p,g))return!0;if(p.route.shouldRevalidate){let E=p.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(a,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof E=="boolean")return E}return!0}):[]}function oT(a,l,{includeHydrateFallback:s}={}){return fT(a.map(r=>{let c=l.routes[r.route.id];if(!c)return[];let f=[c.module];return c.clientActionModule&&(f=f.concat(c.clientActionModule)),c.clientLoaderModule&&(f=f.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(f=f.concat(c.hydrateFallbackModule)),c.imports&&(f=f.concat(c.imports)),f}).flat(1))}function fT(a){return[...new Set(a)]}function dT(a){let l={},s=Object.keys(a).sort();for(let r of s)l[r]=a[r];return l}function hT(a,l){let s=new Set;return new Set(l),a.reduce((r,c)=>{let f=JSON.stringify(dT(c));return s.has(f)||(s.add(f),r.push({key:f,link:c})),r},[])}function Yd(){let a=S.useContext(Ei);return Gd(a,"You must render this element inside a <DataRouterContext.Provider> element"),a}function mT(){let a=S.useContext(Ju);return Gd(a,"You must render this element inside a <DataRouterStateContext.Provider> element"),a}var Kd=S.createContext(void 0);Kd.displayName="FrameworkContext";function Xd(){let a=S.useContext(Kd);return Gd(a,"You must render this element inside a <HydratedRouter> element"),a}function pT(a,l){let s=S.useContext(Kd),[r,c]=S.useState(!1),[f,h]=S.useState(!1),{onFocus:y,onBlur:p,onMouseEnter:g,onMouseLeave:x,onTouchStart:v}=l,E=S.useRef(null);S.useEffect(()=>{if(a==="render"&&h(!0),a==="viewport"){let _=C=>{C.forEach(Y=>{h(Y.isIntersecting)})},z=new IntersectionObserver(_,{threshold:.5});return E.current&&z.observe(E.current),()=>{z.disconnect()}}},[a]),S.useEffect(()=>{if(r){let _=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(_)}}},[r]);let A=()=>{c(!0)},D=()=>{c(!1),h(!1)};return s?a!=="intent"?[f,E,{}]:[f,E,{onFocus:Ts(y,A),onBlur:Ts(p,D),onMouseEnter:Ts(g,A),onMouseLeave:Ts(x,D),onTouchStart:Ts(v,A)}]:[!1,E,{}]}function Ts(a,l){return s=>{a&&a(s),s.defaultPrevented||l(s)}}function yT({page:a,...l}){let s=jw(),{router:r}=Yd(),c=S.useMemo(()=>Wv(r.routes,a,r.basename),[r.routes,a,r.basename]);return c?s?S.createElement(vT,{page:a,matches:c,...l}):S.createElement(bT,{page:a,matches:c,...l}):null}function gT(a){let{manifest:l,routeModules:s}=Xd(),[r,c]=S.useState([]);return S.useEffect(()=>{let f=!1;return cT(a,l,s).then(h=>{f||c(h)}),()=>{f=!0}},[a,l,s]),r}function vT({page:a,matches:l,...s}){let r=Xt(),{future:c}=Xd(),{basename:f}=Yd(),h=S.useMemo(()=>{if(a===r.pathname+r.search+r.hash)return[];let y=mb(a,f,c.unstable_trailingSlashAwareDataRequests,"rsc"),p=!1,g=[];for(let x of l)typeof x.route.shouldRevalidate=="function"?p=!0:g.push(x.route.id);return p&&g.length>0&&y.searchParams.set("_routes",g.join(",")),[y.pathname+y.search]},[f,c.unstable_trailingSlashAwareDataRequests,a,r,l]);return S.createElement(S.Fragment,null,h.map(y=>S.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...s})))}function bT({page:a,matches:l,...s}){let r=Xt(),{future:c,manifest:f,routeModules:h}=Xd(),{basename:y}=Yd(),{loaderData:p,matches:g}=mT(),x=S.useMemo(()=>Og(a,l,g,f,r,"data"),[a,l,g,f,r]),v=S.useMemo(()=>Og(a,l,g,f,r,"assets"),[a,l,g,f,r]),E=S.useMemo(()=>{if(a===r.pathname+r.search+r.hash)return[];let _=new Set,z=!1;if(l.forEach(Y=>{var V;let G=f.routes[Y.route.id];!G||!G.hasLoader||(!x.some(K=>K.route.id===Y.route.id)&&Y.route.id in p&&((V=h[Y.route.id])!=null&&V.shouldRevalidate)||G.hasClientLoader?z=!0:_.add(Y.route.id))}),_.size===0)return[];let C=mb(a,y,c.unstable_trailingSlashAwareDataRequests,"data");return z&&_.size>0&&C.searchParams.set("_routes",l.filter(Y=>_.has(Y.route.id)).map(Y=>Y.route.id).join(",")),[C.pathname+C.search]},[y,c.unstable_trailingSlashAwareDataRequests,p,r,f,x,l,a,h]),A=S.useMemo(()=>oT(v,f),[v,f]),D=gT(v);return S.createElement(S.Fragment,null,E.map(_=>S.createElement("link",{key:_,rel:"prefetch",as:"fetch",href:_,...s})),A.map(_=>S.createElement("link",{key:_,rel:"modulepreload",href:_,...s})),D.map(({key:_,link:z})=>S.createElement("link",{key:_,nonce:s.nonce,...z,crossOrigin:z.crossOrigin??s.crossOrigin})))}function xT(...a){return l=>{a.forEach(s=>{typeof s=="function"?s(l):s!=null&&(s.current=l)})}}var ST=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ST&&(window.__reactRouterVersion="7.15.1")}catch{}function ET({basename:a,children:l,useTransitions:s,window:r}){let c=S.useRef();c.current==null&&(c.current=WE({window:r,v5Compat:!0}));let f=c.current,[h,y]=S.useState({action:f.action,location:f.location}),p=S.useCallback(g=>{s===!1?y(g):S.startTransition(()=>y(g))},[s]);return S.useLayoutEffect(()=>f.listen(p),[f,p]),S.createElement(Jw,{basename:a,children:l,location:h.location,navigationType:h.action,navigator:f,useTransitions:s})}var pb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qe=S.forwardRef(function({onClick:l,discover:s="render",prefetch:r="none",relative:c,reloadDocument:f,replace:h,mask:y,state:p,target:g,to:x,preventScrollReset:v,viewTransition:E,defaultShouldRevalidate:A,...D},_){let{basename:z,navigator:C,useTransitions:Y}=S.useContext(Kt),G=typeof x=="string"&&pb.test(x),V=lb(x,z);x=V.to;let K=Uw(x,{relative:c}),ie=Xt(),W=null;if(y){let Me=Fu(y,[],ie.mask?ie.mask.pathname:"/",!0);z!=="/"&&(Me.pathname=Me.pathname==="/"?z:on([z,Me.pathname])),W=C.createHref(Me)}let[le,de,J]=pT(r,D),oe=NT(x,{replace:h,mask:y,state:p,target:g,preventScrollReset:v,relative:c,viewTransition:E,defaultShouldRevalidate:A,useTransitions:Y});function Ne(Me){l&&l(Me),Me.defaultPrevented||oe(Me)}let at=!(V.isExternal||f),Je=S.createElement("a",{...D,...J,href:(at?W:void 0)||V.absoluteURL||K,onClick:at?Ne:l,ref:xT(_,de),target:g,"data-discover":!G&&s==="render"?"true":void 0});return le&&!G?S.createElement(S.Fragment,null,Je,S.createElement(yT,{page:K})):Je});Qe.displayName="Link";var wT=S.forwardRef(function({"aria-current":l="page",caseSensitive:s=!1,className:r="",end:c=!1,style:f,to:h,viewTransition:y,children:p,...g},x){let v=$s(h,{relative:g.relative}),E=Xt(),A=S.useContext(Ju),{navigator:D,basename:_}=S.useContext(Kt),z=A!=null&&MT(v)&&y===!0,C=D.encodeLocation?D.encodeLocation(v).pathname:v.pathname,Y=E.pathname,G=A&&A.navigation&&A.navigation.location?A.navigation.location.pathname:null;s||(Y=Y.toLowerCase(),G=G?G.toLowerCase():null,C=C.toLowerCase()),G&&_&&(G=In(G,_)||G);const V=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let K=Y===C||!c&&Y.startsWith(C)&&Y.charAt(V)==="/",ie=G!=null&&(G===C||!c&&G.startsWith(C)&&G.charAt(C.length)==="/"),W={isActive:K,isPending:ie,isTransitioning:z},le=K?l:void 0,de;typeof r=="function"?de=r(W):de=[r,K?"active":null,ie?"pending":null,z?"transitioning":null].filter(Boolean).join(" ");let J=typeof f=="function"?f(W):f;return S.createElement(Qe,{...g,"aria-current":le,className:de,ref:x,style:J,to:h,viewTransition:y},typeof p=="function"?p(W):p)});wT.displayName="NavLink";var TT=S.forwardRef(({discover:a="render",fetcherKey:l,navigate:s,reloadDocument:r,replace:c,state:f,method:h=Ru,action:y,onSubmit:p,relative:g,preventScrollReset:x,viewTransition:v,defaultShouldRevalidate:E,...A},D)=>{let{useTransitions:_}=S.useContext(Kt),z=_T(),C=OT(y,{relative:g}),Y=h.toLowerCase()==="get"?"get":"post",G=typeof y=="string"&&pb.test(y),V=K=>{if(p&&p(K),K.defaultPrevented)return;K.preventDefault();let ie=K.nativeEvent.submitter,W=(ie==null?void 0:ie.getAttribute("formmethod"))||h,le=()=>z(ie||K.currentTarget,{fetcherKey:l,method:W,navigate:s,replace:c,state:f,relative:g,preventScrollReset:x,viewTransition:v,defaultShouldRevalidate:E});_&&s!==!1?S.startTransition(()=>le()):le()};return S.createElement("form",{ref:D,method:Y,action:C,onSubmit:r?p:V,...A,"data-discover":!G&&a==="render"?"true":void 0})});TT.displayName="Form";function AT(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yb(a){let l=S.useContext(Ei);return Ke(l,AT(a)),l}function NT(a,{target:l,replace:s,mask:r,state:c,preventScrollReset:f,relative:h,viewTransition:y,defaultShouldRevalidate:p,useTransitions:g}={}){let x=Xs(),v=Xt(),E=$s(a,{relative:h});return S.useCallback(A=>{if(nT(A,l)){A.preventDefault();let D=s!==void 0?s:Ds(v)===Ds(E),_=()=>x(a,{replace:D,mask:r,state:c,preventScrollReset:f,relative:h,viewTransition:y,defaultShouldRevalidate:p});g?S.startTransition(()=>_()):_()}},[v,x,E,s,r,c,l,a,f,h,y,p,g])}function jT(a){ln(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let l=S.useRef(md(a)),s=S.useRef(!1),r=Xt(),c=S.useMemo(()=>aT(r.search,s.current?null:l.current),[r.search]),f=Xs(),h=S.useCallback((y,p)=>{const g=md(typeof y=="function"?y(new URLSearchParams(c)):y);s.current=!0,f("?"+g,p)},[f,c]);return[c,h]}var RT=0,CT=()=>`__${String(++RT)}__`;function _T(){let{router:a}=yb("useSubmit"),{basename:l}=S.useContext(Kt),s=Xw(),r=a.fetch,c=a.navigate;return S.useCallback(async(f,h={})=>{let{action:y,method:p,encType:g,formData:x,body:v}=sT(f,l);if(h.navigate===!1){let E=h.fetcherKey||CT();await r(E,s,h.action||y,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:x,body:v,formMethod:h.method||p,formEncType:h.encType||g,flushSync:h.flushSync})}else await c(h.action||y,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:x,body:v,formMethod:h.method||p,formEncType:h.encType||g,replace:h.replace,state:h.state,fromRouteId:s,flushSync:h.flushSync,viewTransition:h.viewTransition})},[r,c,l,s])}function OT(a,{relative:l}={}){let{basename:s}=S.useContext(Kt),r=S.useContext(dn);Ke(r,"useFormAction must be used inside a RouteContext");let[c]=r.matches.slice(-1),f={...$s(a||".",{relative:l})},h=Xt();if(a==null){f.search=h.search;let y=new URLSearchParams(f.search),p=y.getAll("index");if(p.some(x=>x==="")){y.delete("index"),p.filter(v=>v).forEach(v=>y.append("index",v));let x=y.toString();f.search=x?`?${x}`:""}}return(!a||a===".")&&c.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(f.pathname=f.pathname==="/"?s:on([s,f.pathname])),Ds(f)}function MT(a,{relative:l}={}){let s=S.useContext(rb);Ke(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=yb("useViewTransitionState"),c=$s(a,{relative:l});if(!s.isTransitioning)return!1;let f=In(s.currentLocation.pathname,r)||s.currentLocation.pathname,h=In(s.nextLocation.pathname,r)||s.nextLocation.pathname;return Hu(c.pathname,h)!=null||Hu(c.pathname,f)!=null}function DT(){const a=re(p=>p.activeVaultId!==null),l=Au(p=>p.setOpen),s=Xt();if(!a)return null;const r=s.pathname,c=r==="/"||r.startsWith("/n/")||r==="/pinned"||r==="/archived",f=r==="/tags",h=r==="/new"||r==="/capture",y=r==="/settings";return d.jsx("nav",{"aria-label":"Primary",className:"fixed inset-x-0 bottom-0 z-20 border-t border-border bg-bg/95 backdrop-blur lg:hidden",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:d.jsxs("ul",{className:"mx-auto flex max-w-5xl items-stretch justify-around",children:[d.jsx(xu,{to:"/",label:"Home",active:c,icon:d.jsx(zT,{})}),d.jsx(xu,{to:"/tags",label:"Tags",active:f,icon:d.jsx(LT,{})}),d.jsx(xu,{to:"/new",label:"New",active:h,icon:d.jsx(VT,{})}),d.jsx(UT,{label:"Search",icon:d.jsx(qT,{}),onClick:()=>l(!0)}),d.jsx(xu,{to:"/settings",label:"Settings",active:y,icon:d.jsx(HT,{})})]})})}function xu({to:a,label:l,icon:s,active:r}){return d.jsx("li",{className:"flex-1",children:d.jsxs(Qe,{to:a,"aria-label":l,"aria-current":r?"page":void 0,className:`flex h-14 flex-col items-center justify-center gap-0.5 text-[11px] ${r?"text-accent":"text-fg-muted hover:text-accent"}`,children:[d.jsx("span",{"aria-hidden":"true",children:s}),d.jsx("span",{children:l})]})})}function UT({label:a,icon:l,onClick:s}){return d.jsx("li",{className:"flex-1",children:d.jsxs("button",{type:"button",onClick:s,"aria-label":a,className:"flex h-14 w-full flex-col items-center justify-center gap-0.5 text-[11px] text-fg-muted hover:text-accent",children:[d.jsx("span",{"aria-hidden":"true",children:l}),d.jsx("span",{children:a})]})})}const Zs={width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round"};function zT(){return d.jsxs("svg",{...Zs,"aria-hidden":"true",children:[d.jsx("path",{d:"M3 10.5 12 3l9 7.5"}),d.jsx("path",{d:"M5 9.5V21h14V9.5"}),d.jsx("path",{d:"M10 21v-6h4v6"})]})}function LT(){return d.jsxs("svg",{...Zs,"aria-hidden":"true",children:[d.jsx("path",{d:"M20.5 12.5 12.5 20.5a2 2 0 0 1-2.83 0L3 13.83V3h10.83L20.5 9.67a2 2 0 0 1 0 2.83Z"}),d.jsx("circle",{cx:"7.5",cy:"7.5",r:"1.25",fill:"currentColor"})]})}function VT(){return d.jsxs("svg",{...Zs,"aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"9"}),d.jsx("path",{d:"M12 8v8M8 12h8"})]})}function qT(){return d.jsxs("svg",{...Zs,"aria-hidden":"true",children:[d.jsx("circle",{cx:"11",cy:"11",r:"7"}),d.jsx("path",{d:"m20 20-3.5-3.5"})]})}function HT(){return d.jsxs("svg",{...Zs,"aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"3"}),d.jsx("path",{d:"M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1.03 1.56V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1.11-1.56 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.56-1.03H3a2 2 0 1 1 0-4h.09A1.7 1.7 0 0 0 4.6 9 1.7 1.7 0 0 0 4.26 7.13L4.2 7.07A2 2 0 1 1 7.03 4.24l.06.06A1.7 1.7 0 0 0 9 4.64 1.7 1.7 0 0 0 10 3.09V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.55 1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.7 1.7 0 0 0 19.4 9a1.7 1.7 0 0 0 1.56 1h.04a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.51 1Z"})]})}function kT(a=navigator,l=window){var s;return(s=l.matchMedia)!=null&&s.call(l,"(display-mode: standalone)").matches?!0:a.standalone===!0}function BT(a=navigator.userAgent,l=typeof document<"u"&&navigator.maxTouchPoints>1){return/iPad|iPhone|iPod/.test(a)?!0:/Macintosh/.test(a)&&l}function Su(){const[a,l]=S.useState(null),[s,r]=S.useState(!0),[c,f]=S.useState(!1),[h,y]=S.useState(!1);if(S.useEffect(()=>{r(kT()),f(BT());const x=E=>{E.preventDefault(),l(E)},v=()=>{l(null),r(!0)};return window.addEventListener("beforeinstallprompt",x),window.addEventListener("appinstalled",v),()=>{window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",v)}},[]),s)return null;const p=async()=>{if(a){await a.prompt(),(await a.userChoice).outcome==="accepted"&&l(null);return}c&&y(!0)};return a!==null||c?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",onClick:p,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-accent",children:"Install app"}),h?d.jsxs("dialog",{open:!0,"aria-labelledby":"ios-install-title",className:"fixed inset-0 z-50 m-auto max-w-sm rounded-md border border-border bg-card p-6 text-fg shadow-lg backdrop:bg-black/40",children:[d.jsx("h2",{id:"ios-install-title",className:"mb-3 font-serif text-xl",children:"Add Parachute Notes to your home screen"}),d.jsxs("ol",{className:"mb-5 list-decimal space-y-2 pl-5 text-sm text-fg-muted",children:[d.jsx("li",{children:"Tap the Share icon in Safari's toolbar."}),d.jsxs("li",{children:["Choose ",d.jsx("strong",{className:"text-fg",children:"Add to Home Screen"}),"."]}),d.jsx("li",{children:"Tap Add. Parachute Notes will open standalone from your home screen."})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx("button",{type:"button",onClick:()=>y(!1),className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover",children:"Got it"})})]}):null]}):null}const Mg={rows:[],byKind:{},total:0,pendingCount:0,needsHumanCount:0,authHalt:null};function gb(a,l,s=2e3){const[r,c]=S.useState(Mg),f=S.useRef(!1);return S.useEffect(()=>{if(f.current=!1,!a||!l){c(Mg);return}let h=null;const y=async()=>{try{const[p,g]=await Promise.all([Iv(a,l),T1(a,Jv)]);if(f.current)return;const x={};let v=0,E=0;for(const D of p){const _=D.mutation.kind;x[_]=(x[_]??0)+1,D.status==="needs-human"?E+=1:v+=1}const A=g&&g.vaultId===l?g:null;c({rows:p,byKind:x,total:p.length,pendingCount:v,needsHumanCount:E,authHalt:A})}catch{}};return y(),h=setInterval(y,s),()=>{f.current=!0,h&&clearInterval(h)}},[a,l,s]),r}const QT=[["y",365*24*60*60*1e3],["mo",720*60*60*1e3],["w",10080*60*1e3],["d",1440*60*1e3],["h",3600*1e3],["m",60*1e3]];function vb(a,l=new Date){if(!a)return"";const r=new Date(a).getTime();if(Number.isNaN(r))return"";const c=l.getTime()-r,f=Math.abs(c);for(const[h,y]of QT)if(f>=y){const p=Math.floor(f/y);return c>=0?`${p}${h} ago`:`in ${p}${h}`}return"just now"}let GT=1;const zs=pl(a=>({toasts:[],push(l,s="info"){const r=GT++;return a(c=>({toasts:[...c.toasts,{id:r,message:l,tone:s}]})),r},dismiss(l){a(s=>({toasts:s.toasts.filter(r=>r.id!==l)}))},clear(){a({toasts:[]})}})),YT={"create-note":"new notes","update-note":"note edits","delete-note":"deletions","upload-attachment":"uploads","link-attachment":"attachment links","delete-attachment":"attachment removals"},KT=.8;function XT({onDismiss:a}){const{db:l,isOnline:s,isDraining:r,lastSyncedAt:c}=yl(),f=re(C=>C.activeVaultId),h=zs(C=>C.push),y=gb(l,f),[p,g]=S.useState(null),x=gl(C=>f?C.byVault[f]??null:null),[,v]=S.useState(0);S.useEffect(()=>{const C=setInterval(()=>v(Y=>Y+1),15e3);return()=>clearInterval(C)},[]),S.useEffect(()=>{let C=!1;return _1().then(Y=>{C||Y.supported&&typeof Y.usage=="number"&&typeof Y.quota=="number"&&g({usage:Y.usage,quota:Y.quota})}),()=>{C=!0}},[]);const E=(x==null?void 0:x.state)==="down",A=y.authHalt?"Reconnect needed":E?"Vault not reachable":s?r?"Syncing…":y.total>0?"Sync pending":"All caught up":"Offline — changes queued",D=async C=>{l&&(await UE(l,C),h("Retrying…","success"))},_=async(C,Y)=>{l&&confirm(`Discard this ${Dg(Y.mutation)}? It cannot be recovered.`)&&(await zE(l,C),h("Row discarded.","success"))},z=async()=>{if(!l||!f||!confirm(`Clear every pending row for this vault (${y.total} total)? Destructive.`))return;const C=await qE(l,f);h(`Cleared ${C} pending row${C===1?"":"s"}.`,"success")};return d.jsxs("div",{className:"space-y-4",children:[d.jsxs("header",{className:"flex items-baseline justify-between",children:[d.jsx("h3",{className:"font-serif text-base text-fg",children:A}),a?d.jsx("button",{type:"button",onClick:a,"aria-label":"Close sync status",className:"text-xs text-fg-dim hover:text-accent",children:"×"}):null]}),y.authHalt?d.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3 text-xs text-red-300",children:[d.jsx("p",{className:"mb-2",children:y.authHalt.message||"Vault rejected the current session."}),d.jsx(Qe,{to:"/add",onClick:a,className:"inline-block rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-hover",children:"Reconnect to resume sync"})]}):null,y.total===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"Nothing pending in this vault."}):d.jsxs("section",{children:[d.jsx("h4",{className:"mb-1 text-xs uppercase tracking-wider text-fg-dim",children:"Queue"}),d.jsx("ul",{className:"space-y-0.5 text-xs",children:Object.entries(y.byKind).map(([C,Y])=>d.jsxs("li",{className:"flex justify-between",children:[d.jsx("span",{className:"text-fg-muted",children:YT[C]??C}),d.jsx("span",{className:"tabular-nums text-fg-dim",children:Y})]},C))})]}),y.needsHumanCount>0?d.jsxs("section",{children:[d.jsx("h4",{className:"mb-1 text-xs uppercase tracking-wider text-fg-dim",children:"Needs your help"}),d.jsx("ul",{className:"space-y-1.5",children:y.rows.filter(C=>C.status==="needs-human").map(C=>d.jsxs("li",{className:"rounded border border-amber-500/30 bg-amber-500/5 p-2 text-xs",children:[d.jsx("p",{className:"font-medium text-amber-200",children:Dg(C.mutation)}),C.lastError?d.jsx("p",{className:"mt-0.5 break-words text-amber-100/70",children:C.lastError}):null,d.jsxs("div",{className:"mt-1 flex gap-2",children:[d.jsx("button",{type:"button",onClick:()=>D(C.seq),className:"text-accent hover:underline",children:"Retry"}),d.jsx("button",{type:"button",onClick:()=>_(C.seq,C),className:"text-red-300 hover:underline",children:"Discard"})]})]},C.seq))})]}):null,d.jsx("section",{className:"text-xs text-fg-dim",children:d.jsxs("p",{children:["Last synced:"," ",d.jsx("span",{className:"text-fg-muted",children:c?vb(new Date(c).toISOString()):"never"})]})}),p?d.jsx($T,{usage:p.usage,quota:p.quota}):null,y.total>0?d.jsx("div",{className:"flex justify-end border-t border-border pt-3",children:d.jsx("button",{type:"button",onClick:z,className:"text-xs text-red-400 hover:underline",children:"Clear all pending"})}):null]})}function Dg(a){switch(a.kind){case"create-note":return`Create note (${a.payload.path??"untitled"})`;case"update-note":return`Update note ${a.targetId}`;case"update-settings":return`Update settings (${a.notePath})`;case"delete-note":return`Delete note ${a.targetId}`;case"upload-attachment":return`Upload ${a.filename}`;case"link-attachment":return`Link attachment to ${a.noteId}`;case"delete-attachment":return`Remove attachment from ${a.noteId}`}}function $T({usage:a,quota:l}){const s=l>0?a/l:0,r=s>=KT;return d.jsxs("section",{className:"text-xs",children:[d.jsxs("div",{className:"mb-1 flex justify-between text-fg-dim",children:[d.jsx("span",{children:"Storage"}),d.jsxs("span",{className:r?"text-amber-300":"text-fg-muted",children:[Ug(a)," / ",Ug(l)]})]}),d.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-border/40",children:d.jsx("div",{className:`h-full ${r?"bg-amber-400":"bg-accent"}`,style:{width:`${Math.min(100,Math.round(s*100))}%`}})}),r?d.jsx("p",{className:"mt-1 text-amber-300",children:"Nearly full. Sync what you can and consider clearing stuck rows."}):null]})}function Ug(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)} MB`:`${(a/(1024*1024*1024)).toFixed(2)} GB`}function ZT(a){return a.authHalt?"halted":a.unreachable?"unreachable":a.isOnline?a.isDraining?"syncing":"online":"offline"}function zg(){const{db:a,isOnline:l,isDraining:s}=yl(),r=re(E=>E.activeVaultId),c=gb(a,r),f=gl(E=>r?E.byVault[r]??null:null),[h,y]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{if(!h)return;const E=A=>{p.current&&(p.current.contains(A.target)||y(!1))};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[h]);const g=ZT({isOnline:l,isDraining:s,authHalt:c.authHalt!==null,unreachable:(f==null?void 0:f.state)==="down"}),x=FT(g),v=c.total>0?c.total:null;return d.jsxs("div",{ref:p,className:"relative",children:[d.jsxs("button",{type:"button","aria-label":`Sync status: ${x}${v?`, ${v} pending`:""}`,"aria-expanded":h,onClick:()=>y(E=>!E),className:"flex min-h-11 min-w-11 items-center justify-center gap-1.5 rounded-md border border-border bg-card px-2 py-1.5 text-sm text-fg-muted hover:text-accent",children:[d.jsx(JT,{tone:g}),d.jsx("span",{className:"hidden text-xs sm:inline",children:x}),v!==null?d.jsx("span",{"aria-label":`${v} pending`,className:"rounded-full bg-accent/20 px-1.5 text-[10px] font-medium tabular-nums text-accent",children:v}):null]}),h?d.jsx("div",{role:"dialog","aria-label":"Sync status details",className:"absolute right-0 z-30 mt-2 w-80 rounded-md border border-border bg-card p-4 text-sm shadow-lg",children:d.jsx(XT,{onDismiss:()=>y(!1)})}):null]})}function FT(a){switch(a){case"online":return"Online";case"offline":return"Offline";case"syncing":return"Syncing…";case"halted":return"Reconnect";case"unreachable":return"Vault down"}}function JT({tone:a}){const l=a==="online"?"bg-emerald-400":a==="offline"?"bg-amber-400":a==="syncing"?"bg-sky-400 animate-pulse":a==="unreachable"?"bg-red-400":"bg-red-500";return d.jsx("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 rounded-full ${l}`})}const pd="notes:textSize",hl=["default","larger","largest"];function IT(a){return a==="default"||a==="larger"||a==="largest"}function li(){try{const a=localStorage.getItem(pd);return IT(a)?a:"default"}catch{return"default"}}function PT(a){try{a==="default"?localStorage.removeItem(pd):localStorage.setItem(pd,a)}catch{}}function bb(a,l=document.documentElement){a==="default"?l.removeAttribute("data-text-size"):l.setAttribute("data-text-size",a)}function zf(a){return a==="larger"?"Larger":a==="largest"?"Largest":"Default"}function WT(a){const l=hl.indexOf(a);return hl[(l+1)%hl.length]??"default"}function e2(a){const l=hl.indexOf(a),s=hl.length;return hl[(l-1+s)%s]??"default"}const yd="notes:text-size-change";function _u(a){PT(a),bb(a),typeof window<"u"&&window.dispatchEvent(new CustomEvent(yd,{detail:a}))}function t2(){return S.useEffect(()=>{const a=l=>{if((l.metaKey||l.ctrlKey)&&!(l.altKey||l.shiftKey)){if(l.key==="="||l.key==="+"){l.preventDefault(),_u(WT(li()));return}if(l.key==="-"||l.key==="_"){l.preventDefault(),_u(e2(li()));return}if(l.key==="0"){l.preventDefault(),_u("default");return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),null}function Eu(){const[a,l]=S.useState(()=>li()),[s,r]=S.useState(!1),c=S.useRef(null),f=S.useCallback(h=>{l(h),_u(h)},[]);return S.useEffect(()=>{const h=p=>{p.key==="notes:textSize"&&l(li())},y=p=>{const g=p.detail;l(g||li())};return window.addEventListener("storage",h),window.addEventListener(yd,y),()=>{window.removeEventListener("storage",h),window.removeEventListener(yd,y)}},[]),S.useEffect(()=>{if(!s)return;const h=y=>{c.current&&(c.current.contains(y.target)||r(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]),d.jsxs("div",{ref:c,className:"relative",children:[d.jsx("button",{type:"button","aria-label":`Text size: ${zf(a)}. Click to change.`,"aria-expanded":s,title:`Text size: ${zf(a)}`,onClick:()=>r(h=>!h),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md border border-border bg-card px-2 py-1.5 text-sm text-fg-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-accent",children:d.jsxs("span",{"aria-hidden":"true",className:"font-serif",children:["A",d.jsx("span",{className:"text-xs",children:"a"})]})}),s?d.jsx("div",{role:"dialog","aria-label":"Text size",className:"absolute right-0 z-30 mt-2 w-40 rounded-md border border-border bg-card p-2 text-sm shadow-lg",children:d.jsx("ul",{className:"flex flex-col gap-0.5",children:hl.map(h=>{const y=h===a;return d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>{f(h),r(!1)},"aria-pressed":y,className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left hover:bg-bg/60 ${y?"text-accent":"text-fg-muted"}`,children:[d.jsx("span",{children:zf(h)}),y?d.jsx("span",{"aria-hidden":"true",className:"text-xs",children:"✓"}):null]})},h)})})}):null]})}const gd="lens:theme",Lf=["system","light","dark"];function n2(a){return a==="system"||a==="light"||a==="dark"}function a2(){try{const a=localStorage.getItem(gd);return n2(a)?a:"system"}catch{return"system"}}function l2(a){try{a==="system"?localStorage.removeItem(gd):localStorage.setItem(gd,a)}catch{}}function Lg(a,l=document.documentElement){a==="system"?l.removeAttribute("data-theme"):l.setAttribute("data-theme",a)}function i2(a){const l=Lf.indexOf(a);return Lf[(l+1)%Lf.length]}function s2(a){return a==="light"?"Light":a==="dark"?"Dark":"System"}function wu(){const[a,l]=S.useState("system");S.useEffect(()=>{const c=a2();l(c),Lg(c)},[]);const s=()=>{const c=i2(a);l(c),l2(c),Lg(c)},r=s2(a);return d.jsx("button",{type:"button",onClick:s,"aria-label":`Theme: ${r}. Click to cycle.`,title:`Theme: ${r}`,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md border border-border bg-card px-2 py-1.5 text-sm text-fg-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-accent",children:d.jsx(r2,{theme:a})})}function r2({theme:a}){return a==="light"?d.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:[d.jsx("circle",{cx:"10",cy:"10",r:"3.5"}),d.jsx("path",{d:"M10 2v2M10 16v2M2 10h2M16 10h2M4.2 4.2l1.4 1.4M14.4 14.4l1.4 1.4M4.2 15.8l1.4-1.4M14.4 5.6l1.4-1.4"})]}):a==="dark"?d.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4",fill:"currentColor",children:d.jsx("path",{d:"M15.5 11.8a6 6 0 0 1-7.3-7.3 6 6 0 1 0 7.3 7.3z"})}):d.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[d.jsx("circle",{cx:"10",cy:"10",r:"6"}),d.jsx("path",{d:"M10 4v12",fill:"currentColor",stroke:"none"}),d.jsx("path",{d:"M10 4a6 6 0 0 1 0 12",fill:"currentColor",stroke:"none"})]})}function xb(){const a=typeof window<"u"&&window.location?window.location.origin:"(unknown origin)";return d.jsxs("div",{role:"alert","aria-live":"assertive","data-testid":"insecure-context-banner",className:"rounded-md border border-amber-400/40 bg-amber-400/10 px-3 py-3 text-sm text-amber-100",children:[d.jsxs("p",{className:"mb-2 flex items-center gap-2 font-medium text-amber-100",children:[d.jsx("span",{"aria-hidden":!0,children:"⚠"}),"Insecure context — OAuth unavailable"]}),d.jsxs("p",{className:"mb-2 text-xs text-amber-100/90",children:["Your hub URL must be served over HTTPS or accessed at ",d.jsx("code",{children:"http://localhost"}),". This page is at ",d.jsx("code",{className:"font-mono",children:a}),", which the browser treats as insecure for Web Crypto. To connect:"]}),d.jsxs("ul",{className:"ml-4 list-disc space-y-1 text-xs text-amber-100/90",children:[d.jsxs("li",{children:["Use ",d.jsx("code",{children:"http://localhost"})," or ",d.jsx("code",{children:"http://127.0.0.1"})," directly (replace your hub URL with the localhost form), ",d.jsx("strong",{children:"or"})]}),d.jsx("li",{children:"Serve your hub over HTTPS via Tailscale Serve, Cloudflare Tunnel, or a reverse proxy."})]})]})}function Ou(a){if(a.name)return a.name;try{return new URL(a.url).host}catch{return a.url}}function Tu(a){try{return yv(a)}catch{return a.replace(/\/$/,"")}}function u2(a,l,s,r){const c=new Set(s.map(p=>Tu(p.url))),f=new Set(a.map(p=>Tu(p.url))),h=[...a].sort((p,g)=>Ou(p).localeCompare(Ou(g))).map(p=>({kind:"connected",id:p.id,label:Ou(p),isActive:p.id===l,hubKnown:c.has(Tu(p.url)),vault:p})),y=r===null?[]:s.filter(p=>!f.has(Tu(p.url))).sort((p,g)=>p.name.localeCompare(g.name)).map(p=>({kind:"available",name:p.name,url:p.url,hubOrigin:r}));return[...h,...y]}function Vg({variant:a="header"}){const l=Xs(),s=re(J=>J.vaults),r=re(J=>J.activeVaultId),c=re(J=>J.setActiveVault),f=r?s[r]??null:null,[h,y]=S.useState(!1),[p,g]=S.useState(null),[x,v]=S.useState(null),[E,A]=S.useState(null),[D,_]=S.useState(!1),z=S.useRef(null),C=S.useMemo(()=>f?MS(f):null,[f]);S.useEffect(()=>{if(!h)return;const J=Ne=>{z.current&&(z.current.contains(Ne.target)||y(!1))},oe=Ne=>{Ne.key==="Escape"&&y(!1)};return document.addEventListener("mousedown",J),document.addEventListener("keydown",oe),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",oe)}},[h]),S.useEffect(()=>{if(!h||!C)return;const J=new AbortController;return US(C,fetch.bind(globalThis),J.signal).then(oe=>{J.signal.aborted||g(oe)}),()=>J.abort()},[h,C]);const Y=S.useMemo(()=>u2(Object.values(s),r,p??[],C),[s,r,p,C]),G=Y.filter(J=>J.kind==="connected"),V=Y.filter(J=>J.kind==="available"),K=f?Ou(f):"Choose vault",ie=S.useCallback(J=>{c(J),y(!1)},[c]),W=S.useCallback(async J=>{v(J.name),A(null),_(!1);try{const{authorizeUrl:oe}=await Tv(J.hubOrigin,void 0,void 0,{params:{vault:J.name}});window.location.assign(oe)}catch(oe){v(null),oe instanceof Qu?_(!0):A(oe.message)}},[]),le=S.useCallback(()=>{y(!1),l("/vaults")},[l]),de=d.jsxs("div",{role:"dialog","aria-label":"Vaults",className:a==="header"?"absolute right-0 z-30 mt-2 w-72 rounded-md border border-border bg-card text-sm shadow-lg":"mt-2 w-full rounded-md border border-border bg-card text-sm",children:[G.length>0?d.jsxs("div",{className:"border-b border-border",children:[d.jsx("div",{className:"px-3 pt-3 pb-1.5 text-[10px] font-medium uppercase tracking-wider text-fg-dim",children:"Connected"}),d.jsx("ul",{className:"pb-2",children:G.map(J=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>ie(J.id),className:"flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-accent/5",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[d.jsx("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${J.isActive?"bg-accent":"border border-border bg-transparent"}`}),d.jsx("span",{className:"truncate text-fg",children:J.label})]}),J.isActive?d.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wider text-accent",children:"current"}):null]})},J.id))})]}):null,V.length>0?d.jsxs("div",{className:"border-b border-border",children:[d.jsx("div",{className:"px-3 pt-3 pb-1.5 text-[10px] font-medium uppercase tracking-wider text-fg-dim",children:"Available from your hub"}),d.jsx("ul",{className:"pb-2",children:V.map(J=>d.jsx("li",{children:d.jsxs("div",{className:"flex w-full items-center justify-between gap-3 px-3 py-2",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[d.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 shrink-0 rounded-full border border-border"}),d.jsx("span",{className:"truncate text-fg-muted",children:J.name})]}),d.jsx("button",{type:"button",onClick:()=>W(J),disabled:x===J.name,className:"shrink-0 rounded border border-accent/40 px-2 py-1 text-xs font-medium text-accent hover:bg-accent/10 disabled:opacity-60",children:x===J.name?"Connecting…":"Connect"})]})},J.url))})]}):null,D?d.jsx("div",{className:"border-b border-border px-3 py-2",children:d.jsx(xb,{})}):null,E?d.jsx("div",{className:"border-b border-border px-3 py-2 text-xs text-red-400",children:E}):null,d.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[d.jsx("button",{type:"button",onClick:le,className:"text-xs text-fg-muted hover:text-accent",children:"Manage vaults →"}),C&&p===null&&h?d.jsx("span",{className:"text-[10px] text-fg-dim",children:"Loading hub vaults…"}):null]})]});return d.jsxs("div",{ref:z,className:a==="header"?"relative max-w-full":"",children:[d.jsxs("button",{type:"button","aria-label":`Active vault: ${K}`,"aria-expanded":h,"aria-haspopup":"dialog",onClick:()=>y(J=>!J),title:a==="header"?K:void 0,className:a==="header"?"flex min-w-0 max-w-[12rem] items-center gap-1.5 rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-fg hover:border-accent/50":"flex w-full items-center justify-between rounded-md border border-border bg-card px-3 py-2 text-sm text-fg",children:[d.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 shrink-0 rounded-full bg-accent"}),d.jsx("span",{className:"min-w-0 truncate",children:K}),d.jsx("span",{"aria-hidden":!0,className:"ml-1 shrink-0 text-xs text-fg-dim",children:"▾"})]}),h?de:null]})}function c2(){const a=Xt(),l=re(c=>Object.keys(c.vaults).length>0),[s,r]=S.useState(!1);return S.useEffect(()=>{r(!1)},[a.pathname]),d.jsxs("header",{className:"sticky top-0 z-10 border-b border-border bg-bg/90 backdrop-blur",style:{paddingTop:"env(safe-area-inset-top)"},children:[d.jsxs("nav",{className:"mx-auto flex max-w-5xl items-center justify-between gap-3 px-4 py-3 lg:px-6 lg:py-5",children:[d.jsx(Qe,{to:"/",className:"min-w-0 shrink truncate font-serif text-lg tracking-tight text-fg hover:text-accent lg:text-xl",children:"Parachute Notes"}),d.jsx("div",{className:"hidden min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-2 lg:flex",children:l?d.jsxs(d.Fragment,{children:[d.jsx(Qe,{to:"/",className:"text-sm text-fg-muted hover:text-accent",children:"Notes"}),d.jsx(Qe,{to:"/tags",className:"text-sm text-fg-muted hover:text-accent",children:"Tags"}),d.jsx(Qe,{to:"/graph",className:"text-sm text-fg-muted hover:text-accent",children:"Graph"}),d.jsx(Qe,{to:"/activity",className:"text-sm text-fg-muted hover:text-accent",children:"Activity"}),d.jsx(Qe,{to:"/new",className:"text-sm text-fg-muted hover:text-accent",children:"+ New"}),d.jsx(Vg,{}),d.jsx(Qe,{to:"/settings",className:"text-sm text-fg-muted hover:text-accent",children:"Settings"}),d.jsx(zg,{}),d.jsx(Su,{}),d.jsx(Eu,{}),d.jsx(wu,{})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-sm text-fg-dim",children:"No vault connected"}),d.jsx(Su,{}),d.jsx(Eu,{}),d.jsx(wu,{})]})}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 lg:hidden",children:[l?d.jsx(zg,{}):null,d.jsx("button",{type:"button",onClick:()=>r(c=>!c),"aria-label":s?"Close menu":"Open menu","aria-expanded":s,"aria-controls":"mobile-menu",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-border bg-card text-fg-muted hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-base leading-none",children:s?"✕":"☰"})})]})]}),s?d.jsx("div",{id:"mobile-menu",className:"border-t border-border bg-bg/95 px-4 py-4 lg:hidden",children:l?d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsx(Qe,{to:"/graph",className:"py-1 text-sm text-fg hover:text-accent",children:"Graph"}),d.jsx(Qe,{to:"/activity",className:"py-1 text-sm text-fg hover:text-accent",children:"Activity"}),d.jsx(Qe,{to:"/import",className:"py-1 text-sm text-fg hover:text-accent",children:"Import"}),d.jsxs("div",{className:"mt-1",children:[d.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Active vault"}),d.jsx(Vg,{variant:"inline"})]}),d.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[d.jsx(Su,{}),d.jsx(Eu,{}),d.jsx(wu,{})]})]}):d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsx("p",{className:"text-sm text-fg-dim",children:"No vault connected"}),d.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[d.jsx(Su,{}),d.jsx(Eu,{}),d.jsx(wu,{})]})]})}):null]})}const Sb=10,o2="lens:recents:";function Eb(a){return o2+a}function wb(a){try{const l=localStorage.getItem(Eb(a));if(!l)return[];const s=JSON.parse(l);return Array.isArray(s)?s.filter(r=>typeof r=="object"&&r!==null&&typeof r.id=="string"&&typeof r.viewedAt=="number").slice(0,Sb):[]}catch{return[]}}function CN(a,l,s=Date.now()){try{const r=wb(a).filter(f=>f.id!==l),c=[{id:l,viewedAt:s},...r].slice(0,Sb);localStorage.setItem(Eb(a),JSON.stringify(c))}catch{}}const f2=new Set([" ","/","-","_",".","\\"]);function Rs(a,l){if(!a)return{score:0,indices:[]};if(!l)return null;const s=a.toLowerCase(),r=l.toLowerCase();let c=0,f=0,h=-2,y=!0;const p=[];for(let g=0;g<r.length&&c<s.length;g+=1){const x=r[g]??"";if(x===s[c]){p.push(g);let v=1;g===0?v+=4:y&&(v+=2),h===g-1&&(v+=3),f+=v,h=g,c+=1}y=f2.has(x)}return c<s.length?null:(f-=Math.floor(r.length/20),{score:f,indices:p})}function vd(a){const l=a.content;if(typeof l=="string")for(const s of l.split(`
30
- `)){const r=s.trim().replace(/^#+\s*/,"");if(r.length>0)return r}if(a.path){const s=a.path.split("/");return(s[s.length-1]??a.path).replace(/\.md$/i,"")}return a.id}const Vf=20,qg=[{id:"new",label:"New note",description:"Open the unified create surface (text + voice)",keywords:["new","create","compose","capture","voice","memo"],action:{type:"navigate",to:"/new"}},{id:"graph",label:"Graph",description:"Full-vault graph view",keywords:["graph","map","visualize"],action:{type:"navigate",to:"/graph"}},{id:"today",label:"Today",description:"Notes created or edited today",keywords:["today","now","daily"],action:{type:"navigate",to:"/today"}},{id:"calendar",label:"Calendar",description:"Month grid of note activity",keywords:["calendar","month","date"],action:{type:"navigate",to:"/calendar"}},{id:"tags",label:"Tags",description:"Browse all tags",keywords:["tags"],action:{type:"navigate",to:"/tags"}},{id:"notes",label:"Notes",description:"All notes list",keywords:["notes","all"],action:{type:"navigate",to:"/"}},{id:"pinned",label:"Pinned",description:"Notes tagged as pinned",keywords:["pinned","star","favorites"],action:{type:"navigate",to:"/pinned"}},{id:"archived",label:"Archived",description:"Notes tagged as archived",keywords:["archived","archive"],action:{type:"navigate",to:"/archived"}},{id:"untagged",label:"Untagged",description:"Notes with no tags — quick-tag inline",keywords:["untagged","unfiled","inbox"],action:{type:"navigate",to:"/untagged"}},{id:"orphaned",label:"Orphaned",description:"Notes with no inbound or outbound links",keywords:["orphaned","orphans","isolated","unlinked"],action:{type:"navigate",to:"/orphaned"}}];function d2(a,l){let s=null;for(const r of a){const c=Rs(l,r);c&&(s===null||c.score>s)&&(s=c.score)}return s}function h2(a,l){const s=vd(a),r=Rs(l,s),c=a.path?Rs(l,a.path):null;let f=null;r&&(f=r.score+2),c&&(f===null||c.score>f)&&(f=c.score);for(const h of a.tags??[]){const y=Rs(l,h);y&&(f===null||y.score>f)&&(f=y.score)}return f}function m2(a){const l=a.query.trim(),s=l.startsWith(">"),r=(s?l.slice(1):l).trim();if(l.length===0){const g=new Map(a.notes.map(E=>[E.id,E])),x=[];for(const E of a.recents){const A=g.get(E.id);A&&x.push({kind:"note",id:A.id,title:vd(A),path:A.path,score:0})}const v=qg.map(E=>({kind:"command",id:E.id,label:E.label,description:E.description,action:E.action,score:0}));return[...x,...v].slice(0,Vf)}const c=qg.flatMap(g=>{const x=d2([g.label,...g.keywords],r);return x===null?[]:[{kind:"command",id:g.id,label:g.label,description:g.description,action:g.action,score:x+(s?1e3:0)}]});if(s)return c.sort((g,x)=>x.score-g.score).slice(0,Vf);const f=a.notes.flatMap(g=>{const x=h2(g,r);return x===null?[]:[{kind:"note",id:g.id,title:vd(g),path:g.path,score:x}]}),y=[...a.tags.flatMap(g=>{const x=Rs(r,g.name);return x?[{kind:"tag",name:g.name,count:g.count,score:x.score}]:[]})].sort((g,x)=>x.score-g.score),p=[...c,...f].sort((g,x)=>x.score-g.score);return[...y,...p].slice(0,Vf)}const p2=150;function y2({onClose:a}){const l=re(V=>V.activeVaultId),s=Xs(),r=S.useRef(null),c=S.useRef(null),f=S.useId(),h=S.useId(),[y,p]=S.useState(""),[g,x]=S.useState(""),[v,E]=S.useState(0),A=KE(!0),D=Pv(),_=S.useMemo(()=>l?wb(l):[],[l]);S.useEffect(()=>{const V=setTimeout(()=>x(y),p2);return()=>clearTimeout(V)},[y]);const z=S.useMemo(()=>m2({query:g,notes:A.data??[],tags:D.data??[],recents:_}),[g,A.data,D.data,_]);S.useEffect(()=>{E(0)},[z.length]),S.useEffect(()=>{var V;(V=r.current)==null||V.focus()},[]);const C=S.useCallback(V=>{V.kind==="note"?s(`/n/${encodeURIComponent(V.id)}`):V.kind==="tag"?s(`/?tag=${encodeURIComponent(V.name)}`):s(V.action.to),a()},[s,a]),Y=S.useCallback(V=>{if(V.key==="Escape"){V.preventDefault(),a();return}if(V.key==="ArrowDown"){V.preventDefault(),E(K=>Math.min(z.length-1,K+1));return}if(V.key==="ArrowUp"){V.preventDefault(),E(K=>Math.max(0,K-1));return}if(V.key==="Enter"){V.preventDefault();const K=z[v];K&&C(K);return}},[z,v,C,a]);S.useEffect(()=>{var K,ie;const V=(K=c.current)==null?void 0:K.querySelector(`[data-qs-idx="${v}"]`);(ie=V==null?void 0:V.scrollIntoView)==null||ie.call(V,{block:"nearest"})},[v]);const G=A.isPending;return d.jsx("dialog",{open:!0,"aria-labelledby":f,className:"fixed inset-0 z-50 m-0 flex h-full max-h-full w-full max-w-full items-start justify-center bg-black/60 p-4 pt-[10vh]",onMouseDown:V=>{V.target===V.currentTarget&&a()},children:d.jsxs("div",{className:"w-full max-w-xl rounded-md border border-border bg-card shadow-xl",children:[d.jsx("input",{id:f,ref:r,type:"text",value:y,onChange:V=>p(V.target.value),onKeyDown:Y,placeholder:"Jump to… (type > for commands)","aria-label":"Quick switch query","aria-controls":h,"aria-activedescendant":z[v]?`qs-opt-${v}`:void 0,autoComplete:"off",spellCheck:!1,className:"w-full rounded-t-md border-b border-border bg-transparent px-4 py-3 text-base text-fg placeholder:text-fg-dim focus:outline-none"}),d.jsx("div",{id:h,ref:c,role:"listbox",tabIndex:-1,"aria-label":"Quick switch results","aria-live":"polite",className:"max-h-[50vh] overflow-y-auto",children:G&&z.length===0?d.jsx("div",{className:"px-4 py-3 text-sm text-fg-dim",children:"Loading notes…"}):z.length===0?d.jsx("div",{className:"px-4 py-3 text-sm text-fg-dim",children:y.trim().length===0?"Start typing to search.":"No matches."}):z.map((V,K)=>d.jsx(v2,{entry:V,index:K,selected:K===v,onPick:()=>C(V),onHover:()=>E(K)},g2(V)))}),d.jsxs("div",{className:"flex items-center justify-between border-t border-border px-4 py-2 text-xs text-fg-dim",children:[d.jsxs("span",{children:[d.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"↑↓"})," navigate"," ",d.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"↵"})," open"," ",d.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"esc"})," close"]}),d.jsx("span",{children:z.length>0?`${z.length} result${z.length===1?"":"s"}`:""})]})]})})}function g2(a){return a.kind==="note"?`note:${a.id}`:a.kind==="tag"?`tag:${a.name}`:`cmd:${a.id}`}function v2({entry:a,index:l,selected:s,onPick:r,onHover:c}){const f=s?"bg-accent/10 text-fg":"text-fg-muted";return d.jsx("div",{id:`qs-opt-${l}`,role:"option",tabIndex:-1,"aria-selected":s,"data-qs-idx":l,onMouseEnter:c,onMouseDown:h=>{h.preventDefault(),r()},className:`flex cursor-pointer items-center gap-3 px-4 py-2 text-sm ${f}`,children:a.kind==="note"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"note"}),d.jsx("span",{className:"truncate font-medium",children:a.title}),a.path?d.jsx("span",{className:"ml-auto truncate font-mono text-xs text-fg-dim",children:a.path}):null]}):a.kind==="tag"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"tag"}),d.jsxs("span",{className:"font-mono",children:["#",a.name]}),d.jsx("span",{className:"ml-auto text-xs text-fg-dim",children:a.count})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-accent",children:"cmd"}),d.jsx("span",{className:"font-medium",children:a.label}),d.jsx("span",{className:"ml-auto text-xs text-fg-dim",children:a.description})]})})}function b2(){const a=Au(f=>f.open),l=Au(f=>f.setOpen),s=Au(f=>f.toggle),r=re(f=>f.activeVaultId);S.useEffect(()=>{const f=h=>{h.key==="k"&&(h.metaKey||h.ctrlKey)&&!h.altKey&&!h.shiftKey&&(h.preventDefault(),s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s]);const c=S.useRef(r);return S.useEffect(()=>{c.current!==r&&(c.current=r,l(!1))},[r,l]),!a||r===null?null:d.jsx(y2,{onClose:()=>l(!1)})}const $d={tags:[{name:"capture",description:"Notes captured directly by the user (text or voice)."},{name:"capture/text",parent_names:["capture"],description:"Text capture."},{name:"capture/voice",parent_names:["capture"],description:"Voice capture."}]};function x2(a,l){const s=a??[],r=l??[];if(s.length!==r.length)return!1;for(let c=0;c<s.length;c++)if(s[c]!==r[c])return!1;return!0}function S2(a,l){if(!l)return{name:a.name,status:"missing",expected:a,actual:null,differences:[]};const s=[];(l.description??"")!==a.description&&s.push("description");const r=a.parent_names??null;return x2(l.parent_names,r)||s.push("parent_names"),{name:a.name,status:s.length===0?"ok":"misaligned",expected:a,actual:l,differences:s}}async function E2(a){const l=await a.listTagsWithSchema(),s=new Map(l.map(h=>[h.name,h])),r=$d.tags.map(h=>S2(h,s.get(h.name))),c=r.filter(h=>h.status==="missing"),f=r.filter(h=>h.status==="misaligned");return{ok:c.length===0&&f.length===0,missing:c,misaligned:f,rows:r}}const w2=300*1e3;function bd(a,l){return{vaultId:l,result:(a==null?void 0:a.result)??null,loading:!0,error:null,lastCheckedAt:(a==null?void 0:a.lastCheckedAt)??null}}async function Hg(a,l,s){try{const r=await E2(l);s(c=>({byVault:{...c.byVault,[a]:{vaultId:a,result:r,loading:!1,error:null,lastCheckedAt:Date.now()}}}))}catch(r){const c=r instanceof Error?r.message:String(r);s(f=>({byVault:{...f.byVault,[a]:{...f.byVault[a]??bd(void 0,a),loading:!1,error:c}}}))}}const xd=pl((a,l)=>({byVault:{},async ensure(s,r){const c=l().byVault[s];c!=null&&c.result&&c.lastCheckedAt&&Date.now()-c.lastCheckedAt<w2||c!=null&&c.loading||(a(f=>({byVault:{...f.byVault,[s]:bd(c,s)}})),await Hg(s,r,a))},async refresh(s,r){const c=l().byVault[s];c!=null&&c.loading||(a(f=>({byVault:{...f.byVault,[s]:bd(c,s)}})),await Hg(s,r,a))},clear(s){a(r=>{if(!(s in r.byVault))return r;const{[s]:c,...f}=r.byVault;return{byVault:f}})},set(s,r){a(c=>({byVault:{...c.byVault,[s]:{vaultId:s,result:r,loading:!1,error:null,lastCheckedAt:Date.now()}}}))}})),Mu=new Set;async function _N(a,l){if(!Mu.has(a)){Mu.add(a);try{for(const s of $d.tags)await l.updateTag(s.name,{description:s.description,...s.parent_names?{parent_names:s.parent_names}:{}})}catch(s){Mu.delete(a),typeof console<"u"&&console.warn(`[schema-ensure] failed to ensure required schema for vault ${a}:`,s)}}}async function T2(a,l){for(const s of $d.tags)await l.updateTag(s.name,{description:s.description,...s.parent_names?{parent_names:s.parent_names}:{}});Mu.add(a)}function A2(){const a=re(A=>A.activeVaultId),l=xd(A=>a?A.byVault[a]??null:null),s=xd(A=>A.set),r=Uu(A=>a?!!A.dismissedByVault[a]:!1),c=Uu(A=>A.dismiss),f=ze(),[h,y]=S.useState(!1),[p,g]=S.useState(null);if(!a||!(l!=null&&l.result)||l.result.ok||r)return null;const x=l.result.missing.length,v=l.result.misaligned.length;async function E(){var A;if(!(!f||!a)){y(!0),g(null);try{await T2(a,f),s(a,{ok:!0,missing:[],misaligned:[],rows:((A=l==null?void 0:l.result)==null?void 0:A.rows.map(D=>({...D,status:"ok",differences:[]})))??[]})}catch(D){g(D instanceof Error?D.message:String(D))}finally{y(!1)}}}return d.jsx("output",{"aria-live":"polite",className:"block border-b border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-amber-200 md:px-6",children:d.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-medium text-amber-100",children:"Vault schema needs setup"}),d.jsxs("p",{className:"text-xs text-amber-200/80",children:[x>0&&v>0?`${x} missing, ${v} misaligned`:x>0?`${x} missing tag${x===1?"":"s"} Notes uses`:`${v} tag${v===1?"":"s"} need realignment`," ","(capture / capture/text / capture/voice)."," ",d.jsx(Qe,{to:"/settings",className:"underline hover:text-amber-100",children:"Review in Settings"}),"."]}),p?d.jsx("p",{className:"mt-1 text-xs text-red-300",children:p}):null]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:()=>void E(),disabled:h||!f,className:"min-h-11 self-start rounded-md bg-amber-500/30 px-3 py-1.5 text-xs font-medium text-amber-50 hover:bg-amber-500/50 disabled:cursor-not-allowed disabled:opacity-60 md:self-auto",children:h?"Setting up…":"Set up"}),d.jsx("button",{type:"button",onClick:()=>c(a),className:"min-h-11 self-start rounded-md px-3 py-1.5 text-xs text-amber-200/80 hover:text-amber-100 md:self-auto","aria-label":"Dismiss schema setup banner",children:"Dismiss"})]})]})})}const N2=4e3;function j2(){const a=zs(s=>s.toasts),l=zs(s=>s.dismiss);return S.useEffect(()=>{if(a.length===0)return;const s=a.map(r=>window.setTimeout(()=>l(r.id),N2));return()=>{for(const r of s)window.clearTimeout(r)}},[a,l]),a.length===0?null:d.jsx("output",{"aria-live":"polite",className:"pointer-events-none fixed bottom-6 left-1/2 z-50 flex -translate-x-1/2 flex-col items-center gap-2",children:a.map(s=>d.jsxs("div",{className:`pointer-events-auto flex max-w-md items-center gap-3 rounded-md border px-4 py-2 text-sm shadow-lg backdrop-blur ${s.tone==="error"?"border-red-500/40 bg-red-500/10 text-red-400":s.tone==="success"?"border-accent/40 bg-accent/10 text-accent":"border-border bg-card text-fg-muted"}`,children:[d.jsx("span",{children:s.message}),d.jsx("button",{type:"button",onClick:()=>l(s.id),"aria-label":"Dismiss",className:"text-fg-dim hover:text-fg",children:"×"})]},s.id))})}function R2(a={}){const{immediate:l=!1,onNeedReload:s,onNeedRefresh:r,onOfflineReady:c,onRegistered:f,onRegisteredSW:h,onRegisterError:y}=a;let p,g,x;const v=async(A=!0)=>{await g,x==null||x()};async function E(){if("serviceWorker"in navigator){if(p=await Mt(async()=>{const{Workbox:A}=await import("./workbox-window.prod.es5-BBnX5xw4.js");return{Workbox:A}},[],import.meta.url).then(({Workbox:A})=>new A("./sw.js",{scope:"./",type:"classic"})).catch(A=>{y==null||y(A)}),!p)return;x=()=>{p==null||p.messageSkipWaiting()};{let A=!1;const D=()=>{A=!0,p==null||p.addEventListener("controlling",_=>{_.isUpdate&&(s?s():window.location.reload())}),r==null||r()};p.addEventListener("installed",_=>{typeof _.isUpdate>"u"?typeof _.isExternal<"u"&&_.isExternal?D():!A&&(c==null||c()):_.isUpdate||c==null||c()}),p.addEventListener("waiting",D)}p.register({immediate:l}).then(A=>{h?h("./sw.js",A):f==null||f(A)}).catch(A=>{y==null||y(A)})}}return g=E(),v}function C2(a={}){const{immediate:l=!0,onNeedReload:s,onNeedRefresh:r,onOfflineReady:c,onRegistered:f,onRegisteredSW:h,onRegisterError:y}=a,[p,g]=S.useState(!1),[x,v]=S.useState(!1),[E]=S.useState(()=>R2({immediate:l,onNeedReload:s,onOfflineReady(){v(!0),c==null||c()},onNeedRefresh(){g(!0),r==null||r()},onRegistered:f,onRegisteredSW:h,onRegisterError:y}));return{needRefresh:[p,g],offlineReady:[x,v],updateServiceWorker:E}}const _2={};function O2(){const l=typeof import.meta<"u"&&_2?"./":void 0;return(!l||l===""||l==="/"?"/notes/":l).replace(/\/$/,"")||"/notes"}const M2=O2();function D2(a){return Yu()===M2}async function U2(a=typeof navigator>"u"?void 0:navigator,l){if(!a||!("serviceWorker"in a))return 0;const s=a.serviceWorker;if(!s||typeof s.getRegistrations!="function")return 0;const r=Yu(),c=await s.getRegistrations();let f=0;for(const h of c)try{const p=new URL(h.scope).pathname.replace(/\/$/,"")||"/";if(p===r||!(/^\/notes$/.test(p)||/^\/surface\/[a-z0-9][a-z0-9_-]*$/.test(p)))continue;await h.unregister(),f+=1,typeof console<"u"&&console.info(`[notes-ui] unregistered stale service worker at scope ${h.scope} (runtime mount is ${r})`)}catch(y){typeof console<"u"&&console.warn(`[notes-ui] failed to inspect/unregister SW: ${String(y)}`)}return f}function z2(){const{needRefresh:[a,l],updateServiceWorker:s}=C2({onRegisteredSW(c,f){if(!f)return;const h=3600*1e3;setInterval(()=>{f.update().catch(()=>{})},h)}});if(!a)return null;async function r(){gS(),await s(!0)}return d.jsxs("output",{className:"fixed inset-x-0 bottom-4 z-40 mx-auto flex max-w-sm items-center justify-between gap-3 rounded-md border border-border bg-card px-4 py-3 shadow-lg",children:[d.jsx("p",{className:"text-sm text-fg",children:"A new version of Parachute Notes is available."}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-sm text-fg-muted hover:text-accent",children:"Later"}),d.jsx("button",{type:"button",onClick:r,className:"rounded-md bg-accent px-3 py-1 text-sm font-medium text-white hover:bg-accent-hover",children:"Reload"})]})]})}function L2(){return D2()?d.jsx(z2,{}):null}function V2(){const a=re(c=>c.activeVaultId),l=re(c=>c.getActiveVault()),s=vi(c=>a?c.byVault[a]??null:null),r=gl(c=>a?c.byVault[a]??null:null);return!l||!a?null:s?d.jsx(q2,{reason:s.reason,vaultIssuer:l.issuer??l.url,vaultScope:l.scope,vaultId:a}):r&&r.state==="down"?d.jsx(H2,{vaultUrl:l.url,vaultId:a}):null}function q2({reason:a,vaultIssuer:l,vaultScope:s,vaultId:r}){const[c,f]=S.useState(!1),[h,y]=S.useState(null),[p,g]=S.useState(!1);async function x(){y(null),g(!1),f(!0);try{const{authorizeUrl:v}=await Tv(l,s,void 0,{priorHaltedVaultId:r});window.location.assign(v)}catch(v){v instanceof Qu?g(!0):y(v instanceof Error?v.message:String(v))}finally{f(!1)}}return d.jsxs("div",{role:"alert","aria-live":"assertive",className:"border-b border-red-500/40 bg-red-500/10 px-4 py-3 text-sm text-red-200 md:px-6",children:[d.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-medium text-red-100",children:"Vault session expired"}),d.jsx("p",{className:"text-xs text-red-200/80",children:a}),h?d.jsx("p",{className:"mt-1 text-xs text-red-300",children:h}):null]}),d.jsx("button",{type:"button",onClick:x,disabled:c,className:"self-start rounded-md bg-red-500/30 px-3 py-1.5 text-xs font-medium text-red-50 hover:bg-red-500/50 disabled:cursor-not-allowed disabled:opacity-60 md:self-auto",children:c?"Starting OAuth…":"Reconnect to vault"})]}),p?d.jsx("div",{className:"mx-auto mt-2 max-w-5xl",children:d.jsx(xb,{})}):null]})}function H2({vaultUrl:a,vaultId:l}){const s=ze(),r=ot(),c=gl(g=>g.resetToHealthy),[f,h]=S.useState(!1);async function y(){if(s){h(!0);try{await s.vaultInfo(!1),r.invalidateQueries({queryKey:["notes",l]}),r.invalidateQueries({queryKey:["tags",l]}),r.invalidateQueries({queryKey:["vaultInfo",l]}),r.invalidateQueries({queryKey:["note",l]})}catch{}finally{h(!1)}}}const p=B2(a)?"Try `parachute start vault` in a terminal.":null;return d.jsx("div",{role:"alert","aria-live":"polite",className:"border-b border-red-500/30 bg-red-500/5 px-4 py-3 text-sm text-red-200 md:px-6",children:d.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-medium text-red-100",children:"Vault not reachable"}),d.jsxs("p",{className:"text-xs text-red-200/80",children:["Notes can't sync until it's back online.",p?` ${p}`:""]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:y,disabled:f||!s,className:"self-start rounded-md bg-red-500/20 px-3 py-1.5 text-xs font-medium text-red-50 hover:bg-red-500/40 disabled:cursor-not-allowed disabled:opacity-60 md:self-auto",children:f?"Retrying…":"Retry now"}),d.jsx("button",{type:"button",onClick:()=>c(l),className:"self-start rounded-md px-3 py-1.5 text-xs text-red-200/80 hover:text-red-100 md:self-auto","aria-label":"Dismiss banner",title:"Dismiss",children:"Dismiss"})]})]})})}const k2=/^(10|192\.168|172\.(1[6-9]|2\d|3[0-1]))\./;function B2(a){try{const s=new URL(a).hostname.replace(/^\[/,"").replace(/\]$/,"");return!!(s==="localhost"||s==="127.0.0.1"||s==="::1"||s.endsWith(".local")||k2.test(s))}catch{return!1}}function Q2(){const a=re(r=>r.activeVaultId),l=ze(),s=xd(r=>r.ensure);S.useEffect(()=>{!a||!l||s(a,l)},[a,l,s])}function G2(){return Q2(),null}function Y2({children:a}){const[l]=S.useState(()=>new aE({defaultOptions:{queries:{retry:(s,r)=>{var c;if(!(r instanceof Error))return s<2;if(r instanceof ai)return!1;if(r instanceof Cs){const f=re.getState().activeVaultId;return(f?(c=gl.getState().byVault[f])==null?void 0:c.state:void 0)==="down"?!1:s<1}return s<2},refetchOnWindowFocus:!1,staleTime:1e4}}}));return d.jsx(lE,{client:l,children:a})}function K2(){const a=IS(),l=a.status==="found"?a.origin:null,s=a.status==="probing";return d.jsxs("div",{className:"mx-auto max-w-2xl px-6 py-20 text-center",children:[d.jsx("p",{className:"mb-8 font-serif text-xl italic text-fg-muted",children:"The default frontend for Parachute."}),d.jsx("h1",{className:"mb-4 font-serif text-5xl tracking-tight",children:"Notes"}),s?d.jsx("div",{className:"h-28","aria-hidden":"true"}):l?d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"mb-8 text-fg tracking-wide",children:["Looks like there's a vault at"," ",d.jsx("code",{className:"rounded bg-bg/60 px-1.5 py-0.5 font-mono text-sm",children:l}),"."]}),d.jsx(Qe,{to:`/add?url=${encodeURIComponent(l)}`,className:"inline-block rounded-md bg-accent px-6 py-3 text-sm font-medium text-white hover:bg-accent-hover",children:"Connect"}),d.jsx("div",{className:"mt-4",children:d.jsx(Qe,{to:"/add",className:"text-sm text-fg-dim hover:text-accent",children:"Or connect to a different vault"})})]}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"mb-10 text-fg-dim tracking-wide",children:"Point it at a vault. Sign in. Browse, edit, visualize."}),d.jsx(Qe,{to:"/add",className:"inline-block rounded-md bg-accent px-6 py-3 text-sm font-medium text-white hover:bg-accent-hover",children:"Connect a vault"})]})]})}const X2="lens:path-tree-expanded:";function Tb(a){return X2+a}function kg(a){try{const l=localStorage.getItem(Tb(a));if(!l)return new Set;const s=JSON.parse(l);return Array.isArray(s)?new Set(s.filter(r=>typeof r=="string")):new Set}catch{return new Set}}function $2(a,l){try{localStorage.setItem(Tb(a),JSON.stringify([...l].sort()))}catch{}}function Z2(a){const[l,s]=S.useState(()=>a?kg(a):new Set);S.useEffect(()=>{s(a?kg(a):new Set)},[a]);const r=S.useCallback(c=>{a&&s(f=>{const h=new Set(f);return h.has(c)?h.delete(c):h.add(c),$2(a,h),h})},[a]);return{expanded:l,toggle:r}}function F2(a,l){return{name:a,fullPath:l,count:0,children:[],childMap:new Map}}function Ab(a){const l=a.split("/").filter(s=>s.length>0);return l.length<=1?[]:l.slice(0,-1)}function J2(a){const l=new Map;for(const r of a){if(!r)continue;const c=Ab(r);if(c.length===0)continue;let f=l,h="";for(const y of c){h=h?`${h}/${y}`:y;let p=f.get(y);p||(p=F2(y,h),f.set(y,p)),p.count+=1,f=p.childMap}}const s=r=>r.map(c=>({name:c.name,fullPath:c.fullPath,count:c.count,children:s([...c.childMap.values()])})).sort((c,f)=>c.name.localeCompare(f.name));return s([...l.values()])}const I2=5,P2=20;function W2(a){const l=new Set;let s=0;for(const r of a){if(!r)continue;const c=Ab(r);if(c.length!==0&&(s+=1,l.add(c[0]),l.size>=I2||s>=P2))return!0}return!1}function eA({paths:a,vaultId:l,currentPrefix:s,onSelect:r}){const c=S.useMemo(()=>J2(a),[a]),{expanded:f,toggle:h}=Z2(l),y=S.useMemo(()=>tA(s),[s]);return c.length===0?d.jsxs("aside",{"aria-label":"Path tree",children:[d.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Folders"}),d.jsx("p",{className:"text-xs text-fg-dim",children:"No folders yet."})]}):d.jsxs("aside",{"aria-label":"Path tree",className:"md:sticky md:top-6 md:self-start",children:[d.jsxs("div",{className:"mb-2 flex items-baseline justify-between",children:[d.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Folders"}),s?d.jsx("button",{type:"button",onClick:()=>r(""),className:"text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]}),d.jsx("ul",{className:"space-y-0.5",children:c.map(p=>d.jsx(Nb,{node:p,depth:0,expanded:f,forcedOpen:y,currentPrefix:s,onToggle:h,onSelect:r},p.fullPath))})]})}function Nb({node:a,depth:l,expanded:s,forcedOpen:r,currentPrefix:c,onToggle:f,onSelect:h}){const y=a.children.length>0,p=s.has(a.fullPath)||r.has(a.fullPath),g=c===a.fullPath;return d.jsxs("li",{children:[d.jsxs("div",{className:`flex items-center gap-1 rounded-md px-1 py-0.5 text-sm ${g?"bg-accent/10 text-accent":"text-fg-muted hover:text-accent"}`,style:{paddingLeft:`${l*.75+.25}rem`},children:[y?d.jsx("button",{type:"button",onClick:()=>f(a.fullPath),"aria-label":`${p?"Collapse":"Expand"} ${a.fullPath}`,"aria-expanded":p,className:"flex h-4 w-4 items-center justify-center text-fg-dim hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:p?"▾":"▸"})}):d.jsx("span",{"aria-hidden":"true",className:"inline-block h-4 w-4"}),d.jsxs("button",{type:"button",onClick:()=>h(a.fullPath),"aria-current":g?"true":void 0,className:"flex flex-1 items-baseline gap-1.5 truncate text-left",children:[d.jsx("span",{className:"truncate",children:a.name}),d.jsx("span",{className:"text-xs text-fg-dim",children:a.count})]})]}),y&&p?d.jsx("ul",{className:"space-y-0.5",children:a.children.map(x=>d.jsx(Nb,{node:x,depth:l+1,expanded:s,forcedOpen:r,currentPrefix:c,onToggle:f,onSelect:h},x.fullPath))}):null]})}function tA(a){const l=new Set;if(!a)return l;const s=a.split("/").filter(c=>c.length>0);let r="";for(const c of s)r=r?`${r}/${c}`:c,l.add(r);return l}function nA(a,l){const s=new Map;for(const p of a){const g=p.name.indexOf("/");if(g>0){const x=p.name.slice(0,g),v=s.get(x)??[];v.push(p),s.set(x,v)}}const r=new Set;for(const[p,g]of s)g.length>=2&&r.add(p);const c=new Map,f=[];for(const p of a){const g=p.name.indexOf("/"),x=g>0?p.name.slice(0,g):p.name;if(g>0&&r.has(x)){let E=c.get(x);E||(E={kind:"group",prefix:x,totalCount:0,children:[]},c.set(x,E)),E.children.push({...p,pinned:l.has(p.name)}),E.totalCount+=p.count}else if(r.has(p.name)){let E=c.get(p.name);E||(E={kind:"group",prefix:p.name,totalCount:0,children:[]},c.set(p.name,E)),E.selfTag={...p,pinned:l.has(p.name)},E.totalCount+=p.count}else f.push({kind:"leaf",name:p.name,label:p.name,count:p.count,pinned:l.has(p.name)})}for(const p of c.values())p.children.sort((g,x)=>g.pinned!==x.pinned?g.pinned?-1:1:x.count-g.count||g.name.localeCompare(x.name));const h=[...f,...Array.from(c.values())],y=p=>{var v,E;if(p.kind==="leaf")return{pinned:p.pinned,count:p.count,label:p.label};const g=(((v=p.selfTag)==null?void 0:v.pinned)??!1)||p.children.some(A=>A.pinned),x=Math.max(((E=p.selfTag)==null?void 0:E.count)??0,...p.children.map(A=>A.count))||0;return{pinned:g,count:x,label:p.prefix}};return h.sort((p,g)=>{const x=y(p),v=y(g);return x.pinned!==v.pinned?x.pinned?-1:1:v.count-x.count||x.label.localeCompare(v.label)}),h}function aA({tags:a,pinnedTags:l,selected:s,onToggle:r,onClear:c,isLoading:f}){const h=S.useMemo(()=>new Set(l.map(E=>E.toLowerCase())),[l]),y=S.useMemo(()=>new Set(s.map(E=>E.toLowerCase())),[s]),p=S.useMemo(()=>nA(a,h),[a,h]),[g,x]=S.useState(new Set),v=E=>{x(A=>{const D=new Set(A);return D.has(E)?D.delete(E):D.add(E),D})};return d.jsxs("nav",{"aria-label":"Browse by tag",children:[d.jsxs("div",{className:"mb-2 flex items-baseline justify-between",children:[d.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Tags"}),s.length>0?d.jsx("button",{type:"button",onClick:c,className:"text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]}),f?d.jsx("p",{className:"text-xs text-fg-dim",children:"Loading…"}):p.length===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"No tags in this vault."}):d.jsx("ul",{className:"max-h-[60vh] space-y-0.5 overflow-y-auto pr-1",children:p.map(E=>E.kind==="leaf"?d.jsx("li",{children:d.jsx(Sd,{name:E.name,label:E.label,count:E.count,pinned:E.pinned,active:y.has(E.name.toLowerCase()),onToggle:()=>r(E.name)})},E.name):d.jsx("li",{children:d.jsx(lA,{group:E,isOpen:g.has(E.prefix),onToggleOpen:()=>v(E.prefix),selectedSet:y,onToggleTag:r})},E.prefix))})]})}function Sd({name:a,label:l,count:s,pinned:r,active:c,onToggle:f}){return d.jsxs("button",{type:"button",onClick:f,"aria-pressed":c,title:`#${a}`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-sm ${c?"bg-accent/15 text-accent":"text-fg-muted hover:bg-bg/60 hover:text-accent"}`,children:[r?d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-accent",children:"★"}):null,d.jsxs("span",{className:"flex-1 truncate",children:["#",l]}),d.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:s})]})}function lA({group:a,isOpen:l,onToggleOpen:s,selectedSet:r,onToggleTag:c}){var g;const f=a.children.some(x=>r.has(x.name.toLowerCase())),h=a.selfTag?r.has(a.selfTag.name.toLowerCase()):!1,y=l||f||h,p=(((g=a.selfTag)==null?void 0:g.pinned)??!1)||a.children.some(x=>x.pinned);return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-1 rounded-md px-1 py-0.5",children:[d.jsx("button",{type:"button",onClick:s,"aria-expanded":y,"aria-label":`${y?"Collapse":"Expand"} ${a.prefix}`,className:"flex h-5 w-5 shrink-0 items-center justify-center text-fg-dim hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:y?"▾":"▸"})}),a.selfTag?d.jsx(Sd,{name:a.selfTag.name,label:a.prefix,count:a.selfTag.count,pinned:a.selfTag.pinned,active:h,onToggle:()=>c(a.selfTag.name)}):d.jsxs("button",{type:"button",onClick:s,className:"flex flex-1 items-center gap-1.5 truncate rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-bg/60 hover:text-accent",children:[p?d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-accent",children:"★"}):null,d.jsxs("span",{className:"flex-1 truncate",children:["#",a.prefix,"/"]}),d.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:a.totalCount})]})]}),y?d.jsx("ul",{className:"ml-4 space-y-0.5 border-l border-border pl-2",children:a.children.map(x=>{const v=x.name.slice(a.prefix.length+1)||x.name;return d.jsx("li",{children:d.jsx(Sd,{name:x.name,label:v,count:x.count,pinned:x.pinned,active:r.has(x.name.toLowerCase()),onToggle:()=>c(x.name)})},x.name)})}):null]})}function ON({tags:a,input:l,onInputChange:s,onAdd:r,onRemove:c}){return d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-sm",children:[d.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Tags"}),a.map(f=>d.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-bg/60 px-2 py-0.5 text-xs text-fg-muted",children:[d.jsx("span",{className:"min-w-0 break-all",children:f}),d.jsx("button",{type:"button",onClick:()=>c(f),"aria-label":`Remove tag ${f}`,className:"text-fg-dim hover:text-red-400",children:"×"})]},f)),d.jsx("input",{type:"text",value:l,onChange:f=>s(f.target.value),onKeyDown:f=>{f.key==="Enter"||f.key===","?(f.preventDefault(),r(l)):f.key==="Backspace"&&l===""&&a.length>0&&c(a[a.length-1])},onBlur:()=>{l.trim()&&r(l)},placeholder:"add tag…",className:"min-w-24 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-xs text-fg focus:border-border focus:outline-none","aria-label":"Add tag"})]})}function Bg(a){return a.trim().replace(/^#/,"")}function Qg(a,l){const[s,r]=S.useState(a);return S.useEffect(()=>{const c=setTimeout(()=>r(a),l);return()=>clearTimeout(c)},[a,l]),s}const iA=["auto","always","never"],Ls="auto",sA="lens:path-tree:";function jb(a){return sA+a}function rA(a){return typeof a=="string"&&iA.includes(a)?a:Ls}function Gg(a){try{const l=localStorage.getItem(jb(a));if(!l)return Ls;const s=JSON.parse(l);return rA(s.mode)}catch{return Ls}}function uA(a,l){try{localStorage.setItem(jb(a),JSON.stringify({mode:l}))}catch{}}function cA(a){const[l,s]=S.useState(()=>a?Gg(a):Ls);S.useEffect(()=>{s(a?Gg(a):Ls)},[a]);const r=S.useCallback(c=>{a&&(uA(a,c),s(c))},[a]);return{mode:l,setMode:r}}const Bu="UI/Views/",Rb="saved-view";function Cb(a){var s,r;const l={};return(s=a.search)!=null&&s.trim()&&(l.search=a.search.trim()),a.tags&&a.tags.length>0&&(l.tags=[...a.tags]),a.tags&&a.tags.length>1&&a.tagMatch&&(l.tagMatch=a.tagMatch),(r=a.pathPrefix)!=null&&r.trim()&&(l.pathPrefix=a.pathPrefix.trim()),a.sort&&(l.sort=a.sort),a.showArchived&&(l.showArchived=!0),{kind:Rb,filters:l}}function oA(a){const l=a.metadata;if(!l||l.kind!==Rb)return null;const s=l.filters??{},r=fA(a.path)??a.id;return{id:a.id,name:r,filters:{search:typeof s.search=="string"?s.search:void 0,tags:Array.isArray(s.tags)?s.tags.filter(c=>typeof c=="string"):void 0,tagMatch:s.tagMatch==="all"?"all":s.tagMatch==="any"?"any":void 0,pathPrefix:typeof s.pathPrefix=="string"?s.pathPrefix:void 0,sort:s.sort==="asc"?"asc":s.sort==="desc"?"desc":void 0,showArchived:s.showArchived===!0},updatedAt:a.updatedAt}}function fA(a){return!a||!a.startsWith(Bu)?null:a.slice(Bu.length).replace(/\.md$/i,"")||null}function _b(a){const l=a.trim().replace(/[/\\]/g,"-");return`${Bu}${l}`}function Ed(a){var s,r;const l=new URLSearchParams;(s=a.search)!=null&&s.trim()&&l.set("search",a.search.trim());for(const c of a.tags??[])l.append("tag",c);return a.tagMatch&&l.set("tag_match",a.tagMatch),(r=a.pathPrefix)!=null&&r.trim()&&l.set("path_prefix",a.pathPrefix.trim()),a.sort&&l.set("sort",a.sort),a.showArchived&&l.set("show_archived","1"),l}function Yg(a){const l=a.getAll("tag"),s=a.get("tag_match"),r=a.get("sort");return{search:a.get("search")??void 0,tags:l.length>0?l:void 0,tagMatch:s==="all"?"all":s==="any"?"any":void 0,pathPrefix:a.get("path_prefix")??void 0,sort:r==="asc"?"asc":r==="desc"?"desc":void 0,showArchived:a.get("show_archived")==="1"}}function Kg(a){var l,s;return!!((l=a.search)!=null&&l.trim()||a.tags&&a.tags.length>0||(s=a.pathPrefix)!=null&&s.trim())}function Pu(a,l){a.invalidateQueries({queryKey:["savedViews",l]}),a.invalidateQueries({queryKey:["notes",l]}),a.invalidateQueries({queryKey:["tags",l]}),a.invalidateQueries({queryKey:["vaultInfo",l]})}function dA(a){const l=ze(),s=re(r=>r.activeVaultId);return fn({queryKey:["savedViews",s,a],enabled:!!l&&!!a,queryFn:async()=>{const r=new URLSearchParams;return r.set("tag",a),r.set("path_prefix",Bu),r.set("sort","asc"),(await l.queryNotes(r)).map(f=>oA(f)).filter(f=>f!==null).sort((f,h)=>f.name.localeCompare(h.name))},staleTime:3e4})}function hA(a){const l=ze(),s=re(c=>c.activeVaultId),r=ot();return Yt({mutationFn:async c=>{if(!l)throw new Error("No active vault");return l.createNote({path:_b(c.name),content:c.description??"",tags:[a],metadata:Cb(c.filters)})},onSuccess:()=>Pu(r,s)})}function mA(){const a=ze(),l=re(r=>r.activeVaultId),s=ot();return Yt({mutationFn:async({view:r,newName:c})=>{if(!a)throw new Error("No active vault");return a.updateNote(r.id,{path:_b(c),...r.updatedAt?{if_updated_at:r.updatedAt}:{force:!0}})},onSuccess:()=>Pu(s,l)})}function pA(){const a=ze(),l=re(r=>r.activeVaultId),s=ot();return Yt({mutationFn:async({view:r,filters:c})=>{if(!a)throw new Error("No active vault");return a.updateNote(r.id,{metadata:Cb(c),...r.updatedAt?{if_updated_at:r.updatedAt}:{force:!0}})},onSuccess:()=>Pu(s,l)})}function yA(){const a=ze(),l=re(r=>r.activeVaultId),s=ot();return Yt({mutationFn:async r=>{if(!a)throw new Error("No active vault");await a.deleteNote(r.id)},onSuccess:()=>Pu(s,l)})}const gA={pinned:"Pinned",archived:"Archived",untagged:"Untagged",orphaned:"Orphaned"},vA={untagged:"Notes without any tags. Add a tag inline to file them.",orphaned:"Notes with no inbound or outbound links."};function js({preset:a}={}){var Ci;const l=re(F=>F.getActiveVault()),{roles:s}=RE((l==null?void 0:l.id)??null),{pinnedTags:r}=$S((l==null?void 0:l.id)??null),[c,f]=jT(),h=S.useMemo(()=>Yg(c),[c]),[y,p]=S.useState(h.search??""),[g,x]=S.useState(h.pathPrefix??""),[v,E]=S.useState(h.tags??[]),[A,D]=S.useState(h.tagMatch??"any"),[_,z]=S.useState(h.sort??"desc"),[C,Y]=S.useState(h.showArchived??!1),[G,V]=S.useState(0),K=S.useMemo(()=>c.toString(),[c]);S.useEffect(()=>{const F=Yg(new URLSearchParams(K));p(F.search??""),x(F.pathPrefix??""),E(F.tags??[]),D(F.tagMatch??"any"),z(F.sort??"desc"),Y(F.showArchived??!1)},[K]);const ie=Qg(y,300),W=Qg(g,300);S.useEffect(()=>{if(a)return;const F={search:ie,tags:v,tagMatch:A,pathPrefix:W,sort:_,showArchived:C};Ed(F).toString()!==K&&f(Ed(F),{replace:!0})},[a,ie,W,v,A,_,C]);const le=S.useMemo(()=>a==="pinned"?Array.from(new Set([s.pinned,...v])):a==="archived"?Array.from(new Set([s.archived,...v])):v,[a,s.pinned,s.archived,v]),de=a==="pinned"||a==="archived"?"all":A;S.useEffect(()=>{V(0)},[ie,W,le,de,_,C]);const J=S.useMemo(()=>({...zS,search:ie,pathPrefix:W,tags:le,tagMatch:de,sort:_,offset:G,...a==="untagged"?{hasTags:!1}:{},...a==="orphaned"?{hasLinks:!1}:{}}),[ie,W,le,de,_,G,a]),oe=YE(J),Ne=Pv(),at=dA(s.view),Je=hA(s.view),Me=mA(),H=pA(),X=yA(),ee=zs(F=>F.push),[Ce,je]=S.useState(!1),[j,B]=S.useState(null),[$,P]=S.useState(!1),{mode:ue}=cA((l==null?void 0:l.id)??null),[pe,we]=S.useState(!1),st=!a&&ue!=="never",Ge=st&&pe,xn=XE(Ge),za=S.useMemo(()=>(xn.data??[]).map(F=>F.path),[xn.data]),Ti=Ge&&(ue==="always"||ue==="auto"&&W2(za)),Sn=S.useMemo(()=>({search:ie,tags:v,tagMatch:A,pathPrefix:W,sort:_,showArchived:C}),[ie,W,v,A,_,C]),En=S.useCallback(async F=>{try{await Je.mutateAsync({name:F,filters:Sn}),ee(`Saved view "${F}".`,"success"),je(!1)}catch(_e){ee(`Could not save view: ${_e.message}`,"error")}},[Je,Sn,ee]),Ai=S.useCallback(async(F,_e)=>{try{await Me.mutateAsync({view:F,newName:_e}),ee(`Renamed to "${_e}".`,"success"),B(null)}catch(Tn){ee(`Could not rename: ${Tn.message}`,"error")}},[Me,ee]),Ni=S.useCallback(async F=>{try{await H.mutateAsync({view:F,filters:Sn}),ee(`Updated "${F.name}".`,"success")}catch(_e){ee(`Could not update: ${_e.message}`,"error")}},[H,Sn,ee]),Wu=S.useCallback(async F=>{if(confirm(`Delete saved view "${F.name}"? This can't be undone.`))try{await X.mutateAsync(F),ee(`Deleted "${F.name}".`,"success")}catch(_e){ee(`Could not delete: ${_e.message}`,"error")}},[X,ee]),wn=S.useMemo(()=>{if(!oe.data)return oe.data;let F=oe.data;if(!a&&!C&&(F=F.filter(_e=>!(_e.tags??[]).includes(s.archived))),!a){const _e=s.pinned;F=[...F].sort((Tn,Fs)=>{const ac=(Tn.tags??[]).includes(_e)?0:1,lc=(Fs.tags??[]).includes(_e)?0:1;return ac-lc})}return F},[oe.data,a,C,s.archived,s.pinned]);if(!l)return d.jsx(Us,{to:"/",replace:!0});const ji=a?gA[a]:"Notes",vl=a?vA[a]:null,Ri=G+1,ec=G+((wn==null?void 0:wn.length)??0),tc=G>0,vt=(((Ci=oe.data)==null?void 0:Ci.length)??0)===Nu,nc=Kg(Sn);return d.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-6 md:py-10",children:[d.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:l.name}),d.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:ji}),vl?d.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:vl}):null]}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[a?null:d.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-fg-muted hover:text-accent",children:[d.jsx("input",{type:"checkbox",checked:C,onChange:F=>Y(F.target.checked)}),"Show archived"]}),d.jsxs("button",{type:"button",onClick:()=>z(F=>F==="desc"?"asc":"desc"),className:"text-sm text-fg-muted hover:text-accent","aria-label":"Toggle sort direction",children:["Sort: ",_==="desc"?"newest":"oldest"," first"]}),d.jsx(Qe,{to:"/new",className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover",children:"New note"})]})]}),a?null:d.jsx(TA,{pinnedTags:r,tagCounts:Ne.data??[],selected:v,onPick:F=>{x(""),E(_e=>_e.length===1&&_e[0]===F?[]:[F])}}),d.jsxs("div",{className:a?"":"grid gap-6 md:grid-cols-[14rem_1fr]",children:[a?null:d.jsxs("div",{className:"space-y-3 md:space-y-6",children:[d.jsxs("button",{type:"button",onClick:()=>P(F=>!F),className:"flex w-full items-center justify-between rounded-md border border-border bg-card px-3 py-1.5 text-left text-sm text-fg-muted hover:text-accent md:hidden","aria-expanded":$,"aria-controls":"notes-sidebar",children:[d.jsx("span",{children:"Folders & saved views"}),d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:$?"▾":"▸"})]}),d.jsxs("div",{id:"notes-sidebar",className:`space-y-6 md:sticky md:top-6 md:self-start ${$?"":"hidden md:block"}`,children:[d.jsx(aA,{tags:Ne.data??[],pinnedTags:r,selected:v,onToggle:F=>E(_e=>_e.includes(F)?_e.filter(Tn=>Tn!==F):[..._e,F]),onClear:()=>E([]),isLoading:Ne.isPending}),d.jsx(AA,{}),d.jsx(bA,{views:at.data,isPending:at.isPending,error:at.error,canUpdateWithCurrent:Kg(Sn),onRename:F=>B(F),onUpdate:Ni,onDelete:Wu}),st?d.jsxs("details",{className:"group",open:pe,onToggle:F=>we(F.currentTarget.open),children:[d.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between rounded-md px-1 py-1 text-xs uppercase tracking-wider text-fg-dim hover:text-accent",children:[d.jsx("span",{children:"Folders"}),d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs transition-transform group-open:rotate-90",children:"▸"})]}),d.jsx("div",{className:"mt-2",children:Ti?d.jsx(eA,{paths:za,vaultId:l.id,currentPrefix:g,onSelect:F=>x(F)}):xn.isLoading?d.jsx("p",{className:"px-1 text-xs text-fg-dim",children:"Loading…"}):d.jsx("p",{className:"px-1 text-xs text-fg-dim",children:"Not enough folder variety to show a tree yet."})})]}):null]})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"mb-6 space-y-3",children:[d.jsx("input",{type:"search",placeholder:"Search…",value:y,onChange:F=>p(F.target.value),className:"w-full rounded-md border border-border bg-card px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Search notes"}),d.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[d.jsx("input",{type:"text",placeholder:"Title starts with…",value:g,onChange:F=>x(F.target.value),className:"flex-1 min-w-48 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Filter by path prefix"}),a!=="untagged"?d.jsx(NA,{tags:Ne.data??[],selected:v,onToggle:F=>E(_e=>_e.includes(F)?_e.filter(Tn=>Tn!==F):[..._e,F]),tagMatch:A,onTagMatchChange:D,onClear:()=>E([])}):null,!a&&nc?d.jsx("button",{type:"button",onClick:()=>je(!0),className:"rounded-md border border-accent/60 bg-accent/10 px-3 py-2 text-sm text-accent hover:bg-accent/20",children:"Save view…"}):null]})]}),oe.isPending?d.jsx(jA,{}):oe.isError?d.jsx(RA,{error:oe.error}):wn&&wn.length>0?d.jsx("ol",{"aria-label":"Notes",className:"divide-y divide-border rounded-md border border-border bg-card",children:wn.map(F=>d.jsx(EA,{note:F,pinnedTag:s.pinned,archivedTag:s.archived,quickTagSuggestions:a==="untagged"?Ne.data??[]:void 0},F.id))}):d.jsx(CA,{filtering:VS(J)||!!a}),d.jsxs("div",{className:"mt-6 flex items-center justify-between text-sm text-fg-dim",children:[d.jsx("span",{children:oe.data&&oe.data.length>0?`Showing ${Ri}–${ec}`:oe.isFetching?"Loading…":""}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",disabled:!tc,onClick:()=>V(F=>Math.max(0,F-Nu)),className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted enabled:hover:text-accent disabled:opacity-40",children:"Previous"}),d.jsx("button",{type:"button",disabled:!vt,onClick:()=>V(F=>F+Nu),className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted enabled:hover:text-accent disabled:opacity-40",children:"Next"})]})]})]})]}),Ce?d.jsx(SA,{existing:at.data??[],isSaving:Je.isPending,onCancel:()=>je(!1),onSave:En}):null,j?d.jsx(xA,{view:j,existing:at.data??[],isSaving:Me.isPending,onCancel:()=>B(null),onSave:F=>Ai(j,F)}):null]})}function bA({views:a,isPending:l,error:s,canUpdateWithCurrent:r,onRename:c,onUpdate:f,onDelete:h}){const[y,p]=S.useState(null);return S.useEffect(()=>{if(!y)return;const g=v=>{const E=v.target;E!=null&&E.closest("[data-saved-view-menu]")||p(null)},x=v=>{v.key==="Escape"&&p(null)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[y]),d.jsxs("aside",{children:[d.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Saved views"}),l?d.jsx("p",{className:"text-xs text-fg-dim",children:"Loading…"}):s?d.jsx("p",{className:"text-xs text-red-400",children:"Could not load views."}):!a||a.length===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"None yet. Apply a filter and click “Save view” to add one."}):d.jsx("ul",{className:"space-y-1","aria-label":"Saved views",children:a.map(g=>d.jsxs("li",{className:"group flex items-center rounded-md border border-transparent hover:border-border hover:bg-card",children:[d.jsx(Qe,{to:`/?${Ed(g.filters).toString()}`,className:"block flex-1 truncate px-2 py-1 text-sm text-fg-muted hover:text-accent",children:g.name}),d.jsxs("div",{className:"relative","data-saved-view-menu":!0,children:[d.jsx("button",{type:"button",onClick:()=>p(x=>x===g.id?null:g.id),"aria-label":`Manage saved view ${g.name}`,"aria-haspopup":"menu","aria-expanded":y===g.id,className:"px-2 py-1 text-fg-dim hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:"⋯"})}),y===g.id?d.jsxs("div",{role:"menu",className:"absolute right-0 top-full z-30 mt-1 w-48 overflow-hidden rounded-md border border-border bg-card shadow-lg",children:[d.jsx("button",{type:"button",role:"menuitem",disabled:!r,onClick:()=>{p(null),f(g)},className:"block w-full px-3 py-2 text-left text-sm text-fg-muted hover:bg-bg hover:text-accent disabled:cursor-not-allowed disabled:opacity-40",title:r?void 0:"Apply some filters first to update this view.",children:"Update with current filters"}),d.jsx("button",{type:"button",role:"menuitem",onClick:()=>{p(null),c(g)},className:"block w-full px-3 py-2 text-left text-sm text-fg-muted hover:bg-bg hover:text-accent",children:"Rename…"}),d.jsx("button",{type:"button",role:"menuitem",onClick:()=>{p(null),h(g)},className:"block w-full border-t border-border px-3 py-2 text-left text-sm text-red-400 hover:bg-bg",children:"Delete"})]}):null]})]},g.id))})]})}function xA({view:a,existing:l,isSaving:s,onCancel:r,onSave:c}){const[f,h]=S.useState(a.name),y=f.trim(),p=l.some(v=>v.id!==a.id&&v.name.toLowerCase()===y.toLowerCase()),g=y===a.name,x=y.length>0&&!p&&!g&&!s;return d.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-label":"Rename view",children:d.jsxs("div",{className:"w-full max-w-sm rounded-md border border-border bg-card p-5",children:[d.jsx("h3",{className:"mb-3 font-serif text-lg text-fg",children:"Rename view"}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),d.jsx("input",{type:"text",value:f,autoFocus:!0,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&x&&c(y),v.key==="Escape"&&r()},"aria-label":"View name",className:"w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none"})]}),p?d.jsx("p",{className:"mt-2 text-xs text-red-400",children:"A view with that name already exists."}):null,d.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[d.jsx("button",{type:"button",onClick:r,className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),d.jsx("button",{type:"button",onClick:()=>x&&c(y),disabled:!x,className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:s?"Saving…":"Save"})]})]})})}function SA({existing:a,isSaving:l,onCancel:s,onSave:r}){const[c,f]=S.useState(""),h=c.trim(),y=a.some(g=>g.name.toLowerCase()===h.toLowerCase()),p=h.length>0&&!y&&!l;return d.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-label":"Save view",children:d.jsxs("div",{className:"w-full max-w-sm rounded-md border border-border bg-card p-5",children:[d.jsx("h3",{className:"mb-3 font-serif text-lg text-fg",children:"Save view"}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),d.jsx("input",{type:"text",value:c,autoFocus:!0,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&p&&r(h),g.key==="Escape"&&s()},placeholder:"e.g. Daily journal","aria-label":"View name",className:"w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none"})]}),y?d.jsx("p",{className:"mt-2 text-xs text-red-400",children:"A view with that name already exists."}):null,d.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[d.jsx("button",{type:"button",onClick:s,className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),d.jsx("button",{type:"button",onClick:()=>p&&r(h),disabled:!p,className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:l?"Saving…":"Save"})]})]})})}function EA({note:a,pinnedTag:l,archivedTag:s,quickTagSuggestions:r}){const c=a.path??a.id,f=a.updatedAt??a.createdAt,h=(a.tags??[]).includes(l),y=(a.tags??[]).includes(s);return d.jsx("li",{className:y?"opacity-60 italic":void 0,children:d.jsxs("div",{className:"flex items-stretch",children:[d.jsxs(Qe,{to:`/n/${encodeURIComponent(a.id)}`,className:"block flex-1 min-w-0 min-h-11 px-3 py-2.5 hover:bg-bg/60 focus:bg-bg/60 focus:outline-none md:min-h-0 md:px-4 md:py-3",children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[d.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[h?d.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,d.jsx("span",{className:"min-w-0 truncate font-mono text-sm text-fg",children:c})]}),d.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:vb(f)})]}),a.tags&&a.tags.length>0?d.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.tags.map(p=>d.jsxs("span",{className:"max-w-full break-all rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-xs text-accent",children:["#",p]},p))}):null,a.preview?d.jsx("p",{className:"mt-1.5 truncate text-sm text-fg-muted",children:a.preview}):null]}),r?d.jsx("div",{className:"shrink-0 px-3 py-3",children:d.jsx(wA,{noteId:a.id,existing:a.tags??[],suggestions:r})}):null]})})}function wA({noteId:a,existing:l,suggestions:s}){const[r,c]=S.useState(!1),[f,h]=S.useState(""),y=S.useRef(null),p=S.useRef(null),g=IE(a),x=zs(A=>A.push);S.useEffect(()=>{var _;if(!r)return;(_=p.current)==null||_.focus();const A=z=>{var C;(C=y.current)!=null&&C.contains(z.target)||c(!1)},D=z=>{z.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",D)}},[r]);const v=S.useMemo(()=>{const A=Bg(f).toLowerCase(),D=new Set(l.map(z=>z.toLowerCase())),_=s.filter(z=>!D.has(z.name.toLowerCase()));return A?_.filter(z=>z.name.toLowerCase().includes(A)).slice(0,8):_.slice(0,8)},[f,s,l]),E=S.useCallback(async A=>{const D=Bg(A);if(D)try{await g.mutateAsync({tags:{add:[D]}}),x(`Added #${D}`,"success"),h(""),c(!1)}catch(_){x(`Could not add tag: ${_.message}`,"error")}},[g,x]);return r?d.jsxs("div",{ref:y,className:"relative",children:[d.jsx("input",{ref:p,type:"text",value:f,onChange:A=>h(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),E(f))},placeholder:"tag…","aria-label":"Tag name",disabled:g.isPending,className:"w-32 rounded-md border border-border bg-card px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none disabled:opacity-50"}),v.length>0?d.jsx("ul",{className:"absolute right-0 z-20 mt-1 max-h-48 w-44 overflow-y-auto rounded-md border border-border bg-card text-xs shadow-lg","aria-label":"Tag suggestions",children:v.map(A=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:D=>{D.preventDefault(),E(A.name)},className:"flex w-full items-center justify-between px-2 py-1 text-left text-fg hover:bg-bg/60",children:[d.jsx("span",{className:"truncate",children:A.name}),d.jsx("span",{className:"ml-2 shrink-0 text-fg-dim",children:A.count})]})},A.name))}):null]}):d.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md border border-border bg-bg/60 px-2 py-1 text-xs text-fg-muted hover:border-accent hover:text-accent","aria-label":"Add tag",children:"+ tag"})}function TA({pinnedTags:a,tagCounts:l,selected:s,onPick:r}){const c=f=>{var h;return(h=l.find(y=>y.name.toLowerCase()===f.toLowerCase()))==null?void 0:h.count};return a.length===0?d.jsxs("nav",{"aria-label":"Pinned tags",className:"mb-6 flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Pinned tags"}),d.jsxs("span",{className:"text-xs text-fg-dim",children:["Pin tags here for quick access —"," ",d.jsx(Qe,{to:"/tags",className:"text-accent hover:underline",children:"open the tag browser"}),"."]})]}):d.jsxs("nav",{"aria-label":"Pinned tags",className:"mb-6 flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Pinned tags"}),a.map(f=>{const h=s.length===1&&s[0]===f,y=c(f);return d.jsxs("button",{type:"button",onClick:()=>r(f),className:h?"inline-flex max-w-full items-center gap-1 rounded-full border border-accent bg-accent px-2.5 py-1 text-xs font-medium text-white":"inline-flex max-w-full items-center gap-1 rounded-full border border-accent/40 bg-accent/10 px-2.5 py-1 text-xs text-accent hover:border-accent hover:bg-accent/20","aria-pressed":h,children:[d.jsxs("span",{className:"min-w-0 break-all",children:["#",f]}),y!==void 0?d.jsx("span",{className:h?"text-white/80":"text-accent/70",children:y}):null]},f)})]})}function AA(){const a=[{to:"/pinned",label:"Pinned",glyph:"★"},{to:"/archived",label:"Archived"},{to:"/untagged",label:"Untagged"},{to:"/orphaned",label:"Orphaned"}];return d.jsxs("aside",{children:[d.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Views"}),d.jsx("ul",{className:"space-y-1",children:a.map(l=>d.jsx("li",{children:d.jsxs(Qe,{to:l.to,className:"flex items-center gap-1.5 truncate rounded-md border border-transparent px-2 py-1 text-sm text-fg-muted hover:border-border hover:bg-card hover:text-accent",children:[l.glyph?d.jsx("span",{className:"shrink-0 text-accent","aria-hidden":"true",children:l.glyph}):null,d.jsx("span",{className:"truncate",children:l.label})]})},l.to))})]})}function NA({tags:a,selected:l,onToggle:s,tagMatch:r,onTagMatchChange:c,onClear:f}){return d.jsxs("details",{className:"rounded-md border border-border bg-card text-sm",children:[d.jsxs("summary",{className:"cursor-pointer list-none px-3 py-2 text-fg-muted hover:text-accent",children:["Tags",l.length>0?` (${l.length})`:""]}),d.jsxs("div",{className:"border-t border-border p-3",children:[l.length>1?d.jsxs("fieldset",{className:"mb-3 flex items-center gap-3 text-xs",children:[d.jsx("legend",{className:"sr-only",children:"Match mode"}),d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"radio",name:"tag-match",value:"any",checked:r==="any",onChange:()=>c("any")}),"Any"]}),d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"radio",name:"tag-match",value:"all",checked:r==="all",onChange:()=>c("all")}),"All"]}),d.jsx("button",{type:"button",onClick:f,className:"ml-auto text-xs text-fg-dim hover:text-accent",children:"Clear"})]}):null,a.length===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"No tags in this vault."}):d.jsx("ul",{className:"max-h-56 space-y-1 overflow-y-auto pr-1",children:a.map(h=>d.jsx("li",{children:d.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg hover:text-accent",children:[d.jsx("input",{type:"checkbox",checked:l.includes(h.name),onChange:()=>s(h.name)}),d.jsx("span",{className:"flex-1 truncate",children:h.name}),d.jsx("span",{className:"text-xs text-fg-dim",children:h.count})]})},h.name))})]})]})}function jA(){return d.jsx("ol",{className:"divide-y divide-border rounded-md border border-border bg-card","aria-busy":"true",children:[0,1,2,3,4].map(a=>d.jsxs("li",{className:"px-4 py-3",children:[d.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-border/60"}),d.jsx("div",{className:"mt-2 h-3 w-2/3 animate-pulse rounded bg-border/40"})]},a))})}function RA({error:a}){const l=a instanceof Nd;return d.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[d.jsx("p",{className:"mb-2 font-medium text-red-400",children:l?"Session expired":"Could not load notes"}),d.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),l?d.jsx(Qe,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}function CA({filtering:a}){return d.jsx("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:a?d.jsx("p",{className:"text-fg-muted",children:"No notes match these filters."}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"mb-3 text-fg-muted",children:"This vault has no notes yet."}),d.jsx(Qe,{to:"/new",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Create one"})]})})}const _A=S.lazy(()=>Mt(()=>import("./Activity-DJhKtRnz.js"),[],import.meta.url).then(a=>({default:a.Activity}))),OA=S.lazy(()=>Mt(()=>import("./AddVault-DX-7VPHH.js"),[],import.meta.url).then(a=>({default:a.AddVault}))),MA=S.lazy(()=>Mt(()=>import("./Calendar-CfbphZhF.js"),__vite__mapDeps([0,1]),import.meta.url).then(a=>({default:a.Calendar}))),DA=S.lazy(()=>Mt(()=>import("./Import-BOoIUF34.js"),__vite__mapDeps([2,3]),import.meta.url).then(a=>({default:a.Import}))),UA=S.lazy(()=>Mt(()=>import("./NoteEditor-ZdIpS6QN.js"),__vite__mapDeps([4,3,5,6,7]),import.meta.url).then(a=>({default:a.NoteEditor}))),zA=S.lazy(()=>Mt(()=>import("./NoteNew-Crzh0iYo.js"),__vite__mapDeps([8,3,5,7]),import.meta.url).then(a=>({default:a.NoteNew}))),LA=S.lazy(()=>Mt(()=>import("./NoteView-LNlromHS.js"),__vite__mapDeps([9,6,7]),import.meta.url).then(a=>({default:a.NoteView}))),VA=S.lazy(()=>Mt(()=>import("./OAuthCallback-D1kmhUQA.js"),[],import.meta.url).then(a=>({default:a.OAuthCallback}))),qA=S.lazy(()=>Mt(()=>import("./Settings-DpHNB3Wj.js"),[],import.meta.url).then(a=>({default:a.Settings}))),HA=S.lazy(()=>Mt(()=>import("./Tags-5UgiMjud.js"),[],import.meta.url).then(a=>({default:a.Tags}))),kA=S.lazy(()=>Mt(()=>import("./Today-MgBcz9I5.js"),__vite__mapDeps([10,1]),import.meta.url).then(a=>({default:a.Today}))),BA=S.lazy(()=>Mt(()=>import("./VaultGraph-CHtHQpMd.js"),[],import.meta.url).then(a=>({default:a.VaultGraph}))),QA=S.lazy(()=>Mt(()=>import("./Vaults-RFwi9oID.js"),[],import.meta.url).then(a=>({default:a.Vaults})));function GA(){return re(l=>l.getActiveVault())?d.jsx(js,{}):d.jsx(K2,{})}function YA(){return d.jsx("output",{"aria-live":"polite",className:"mx-auto block max-w-5xl px-6 py-10 text-center text-sm text-fg-dim",children:"Loading…"})}function Xg({suffix:a=""}){const{id:l}=Lw();return l?d.jsx(Us,{to:`/n/${encodeURIComponent(l)}${a}`,replace:!0}):d.jsx(Us,{to:"/",replace:!0})}function KA(){const a=re(s=>s.activeVaultId),l=ze();return PE(a,l),null}function XA(){return CS(),S.useEffect(()=>{bb(li())},[]),d.jsx(Y2,{children:d.jsxs(gE,{children:[d.jsx(KA,{}),d.jsx(G2,{}),d.jsx(t2,{}),d.jsx(ET,{basename:Yu(),children:d.jsxs("div",{className:"min-h-dvh overflow-x-hidden bg-bg text-fg pb-16 md:pb-0",children:[d.jsx(j2,{}),d.jsx(L2,{}),d.jsx(V2,{}),d.jsx(A2,{}),d.jsx(c2,{}),d.jsx(b2,{}),d.jsx("main",{children:d.jsx(S.Suspense,{fallback:d.jsx(YA,{}),children:d.jsxs(Iw,{children:[d.jsx(Xe,{path:"/",element:d.jsx(GA,{})}),d.jsx(Xe,{path:"/pinned",element:d.jsx(js,{preset:"pinned"})}),d.jsx(Xe,{path:"/archived",element:d.jsx(js,{preset:"archived"})}),d.jsx(Xe,{path:"/untagged",element:d.jsx(js,{preset:"untagged"})}),d.jsx(Xe,{path:"/orphaned",element:d.jsx(js,{preset:"orphaned"})}),d.jsx(Xe,{path:"/tags",element:d.jsx(HA,{})}),d.jsx(Xe,{path:"/new",element:d.jsx(zA,{})}),d.jsx(Xe,{path:"/capture",element:d.jsx(Us,{to:"/new",replace:!0})}),d.jsx(Xe,{path:"/import",element:d.jsx(DA,{})}),d.jsx(Xe,{path:"/graph",element:d.jsx(BA,{})}),d.jsx(Xe,{path:"/today",element:d.jsx(kA,{})}),d.jsx(Xe,{path:"/calendar",element:d.jsx(MA,{})}),d.jsx(Xe,{path:"/activity",element:d.jsx(_A,{})}),d.jsx(Xe,{path:"/n/:id",element:d.jsx(LA,{})}),d.jsx(Xe,{path:"/n/:id/edit",element:d.jsx(UA,{})}),d.jsx(Xe,{path:"/:id",element:d.jsx(Xg,{})}),d.jsx(Xe,{path:"/:id/edit",element:d.jsx(Xg,{suffix:"/edit"})}),d.jsx(Xe,{path:"/add",element:d.jsx(OA,{})}),d.jsx(Xe,{path:"/oauth/callback",element:d.jsx(VA,{})}),d.jsx(Xe,{path:"/vaults",element:d.jsx(QA,{})}),d.jsx(Xe,{path:"/settings",element:d.jsx(qA,{})}),d.jsx(Xe,{path:"*",element:d.jsx(Us,{to:"/",replace:!0})})]})})}),d.jsx(DT,{}),d.jsx("footer",{className:"mx-auto max-w-5xl px-6 py-10 text-center text-sm text-fg-dim",children:d.jsxs("p",{children:["Part of the"," ",d.jsx("a",{href:"https://parachute.computer",className:"text-accent hover:underline",children:"Parachute Computer"})," ","ecosystem. AGPL-3.0."]})})]})})]})})}var qf={exports:{}},As={},Hf={exports:{}},kf={};/**
30
+ `)){const r=s.trim().replace(/^#+\s*/,"");if(r.length>0)return r}if(a.path){const s=a.path.split("/");return(s[s.length-1]??a.path).replace(/\.md$/i,"")}return a.id}const Vf=20,qg=[{id:"new",label:"New note",description:"Open the unified create surface (text + voice)",keywords:["new","create","compose","capture","voice","memo"],action:{type:"navigate",to:"/new"}},{id:"graph",label:"Graph",description:"Full-vault graph view",keywords:["graph","map","visualize"],action:{type:"navigate",to:"/graph"}},{id:"today",label:"Today",description:"Notes created or edited today",keywords:["today","now","daily"],action:{type:"navigate",to:"/today"}},{id:"calendar",label:"Calendar",description:"Month grid of note activity",keywords:["calendar","month","date"],action:{type:"navigate",to:"/calendar"}},{id:"tags",label:"Tags",description:"Browse all tags",keywords:["tags"],action:{type:"navigate",to:"/tags"}},{id:"notes",label:"Notes",description:"All notes list",keywords:["notes","all"],action:{type:"navigate",to:"/"}},{id:"pinned",label:"Pinned",description:"Notes tagged as pinned",keywords:["pinned","star","favorites"],action:{type:"navigate",to:"/pinned"}},{id:"archived",label:"Archived",description:"Notes tagged as archived",keywords:["archived","archive"],action:{type:"navigate",to:"/archived"}},{id:"untagged",label:"Untagged",description:"Notes with no tags — quick-tag inline",keywords:["untagged","unfiled","inbox"],action:{type:"navigate",to:"/untagged"}},{id:"orphaned",label:"Orphaned",description:"Notes with no inbound or outbound links",keywords:["orphaned","orphans","isolated","unlinked"],action:{type:"navigate",to:"/orphaned"}}];function d2(a,l){let s=null;for(const r of a){const c=Rs(l,r);c&&(s===null||c.score>s)&&(s=c.score)}return s}function h2(a,l){const s=vd(a),r=Rs(l,s),c=a.path?Rs(l,a.path):null;let f=null;r&&(f=r.score+2),c&&(f===null||c.score>f)&&(f=c.score);for(const h of a.tags??[]){const y=Rs(l,h);y&&(f===null||y.score>f)&&(f=y.score)}return f}function m2(a){const l=a.query.trim(),s=l.startsWith(">"),r=(s?l.slice(1):l).trim();if(l.length===0){const g=new Map(a.notes.map(E=>[E.id,E])),x=[];for(const E of a.recents){const A=g.get(E.id);A&&x.push({kind:"note",id:A.id,title:vd(A),path:A.path,score:0})}const v=qg.map(E=>({kind:"command",id:E.id,label:E.label,description:E.description,action:E.action,score:0}));return[...x,...v].slice(0,Vf)}const c=qg.flatMap(g=>{const x=d2([g.label,...g.keywords],r);return x===null?[]:[{kind:"command",id:g.id,label:g.label,description:g.description,action:g.action,score:x+(s?1e3:0)}]});if(s)return c.sort((g,x)=>x.score-g.score).slice(0,Vf);const f=a.notes.flatMap(g=>{const x=h2(g,r);return x===null?[]:[{kind:"note",id:g.id,title:vd(g),path:g.path,score:x}]}),y=[...a.tags.flatMap(g=>{const x=Rs(r,g.name);return x?[{kind:"tag",name:g.name,count:g.count,score:x.score}]:[]})].sort((g,x)=>x.score-g.score),p=[...c,...f].sort((g,x)=>x.score-g.score);return[...y,...p].slice(0,Vf)}const p2=150;function y2({onClose:a}){const l=re(V=>V.activeVaultId),s=Xs(),r=S.useRef(null),c=S.useRef(null),f=S.useId(),h=S.useId(),[y,p]=S.useState(""),[g,x]=S.useState(""),[v,E]=S.useState(0),A=KE(!0),D=Pv(),_=S.useMemo(()=>l?wb(l):[],[l]);S.useEffect(()=>{const V=setTimeout(()=>x(y),p2);return()=>clearTimeout(V)},[y]);const z=S.useMemo(()=>m2({query:g,notes:A.data??[],tags:D.data??[],recents:_}),[g,A.data,D.data,_]);S.useEffect(()=>{E(0)},[z.length]),S.useEffect(()=>{var V;(V=r.current)==null||V.focus()},[]);const C=S.useCallback(V=>{V.kind==="note"?s(`/n/${encodeURIComponent(V.id)}`):V.kind==="tag"?s(`/?tag=${encodeURIComponent(V.name)}`):s(V.action.to),a()},[s,a]),Y=S.useCallback(V=>{if(V.key==="Escape"){V.preventDefault(),a();return}if(V.key==="ArrowDown"){V.preventDefault(),E(K=>Math.min(z.length-1,K+1));return}if(V.key==="ArrowUp"){V.preventDefault(),E(K=>Math.max(0,K-1));return}if(V.key==="Enter"){V.preventDefault();const K=z[v];K&&C(K);return}},[z,v,C,a]);S.useEffect(()=>{var K,ie;const V=(K=c.current)==null?void 0:K.querySelector(`[data-qs-idx="${v}"]`);(ie=V==null?void 0:V.scrollIntoView)==null||ie.call(V,{block:"nearest"})},[v]);const G=A.isPending;return d.jsx("dialog",{open:!0,"aria-labelledby":f,className:"fixed inset-0 z-50 m-0 flex h-full max-h-full w-full max-w-full items-start justify-center bg-black/60 p-4 pt-[10vh]",onMouseDown:V=>{V.target===V.currentTarget&&a()},children:d.jsxs("div",{className:"w-full max-w-xl rounded-md border border-border bg-card shadow-xl",children:[d.jsx("input",{id:f,ref:r,type:"text",value:y,onChange:V=>p(V.target.value),onKeyDown:Y,placeholder:"Jump to… (type > for commands)","aria-label":"Quick switch query","aria-controls":h,"aria-activedescendant":z[v]?`qs-opt-${v}`:void 0,autoComplete:"off",spellCheck:!1,className:"w-full rounded-t-md border-b border-border bg-transparent px-4 py-3 text-base text-fg placeholder:text-fg-dim focus:outline-none"}),d.jsx("div",{id:h,ref:c,role:"listbox",tabIndex:-1,"aria-label":"Quick switch results","aria-live":"polite",className:"max-h-[50vh] overflow-y-auto",children:G&&z.length===0?d.jsx("div",{className:"px-4 py-3 text-sm text-fg-dim",children:"Loading notes…"}):z.length===0?d.jsx("div",{className:"px-4 py-3 text-sm text-fg-dim",children:y.trim().length===0?"Start typing to search.":"No matches."}):z.map((V,K)=>d.jsx(v2,{entry:V,index:K,selected:K===v,onPick:()=>C(V),onHover:()=>E(K)},g2(V)))}),d.jsxs("div",{className:"flex items-center justify-between border-t border-border px-4 py-2 text-xs text-fg-dim",children:[d.jsxs("span",{children:[d.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"↑↓"})," navigate"," ",d.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"↵"})," open"," ",d.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"esc"})," close"]}),d.jsx("span",{children:z.length>0?`${z.length} result${z.length===1?"":"s"}`:""})]})]})})}function g2(a){return a.kind==="note"?`note:${a.id}`:a.kind==="tag"?`tag:${a.name}`:`cmd:${a.id}`}function v2({entry:a,index:l,selected:s,onPick:r,onHover:c}){const f=s?"bg-accent/10 text-fg":"text-fg-muted";return d.jsx("div",{id:`qs-opt-${l}`,role:"option",tabIndex:-1,"aria-selected":s,"data-qs-idx":l,onMouseEnter:c,onMouseDown:h=>{h.preventDefault(),r()},className:`flex cursor-pointer items-center gap-3 px-4 py-2 text-sm ${f}`,children:a.kind==="note"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"note"}),d.jsx("span",{className:"truncate font-medium",children:a.title}),a.path?d.jsx("span",{className:"ml-auto truncate font-mono text-xs text-fg-dim",children:a.path}):null]}):a.kind==="tag"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"tag"}),d.jsxs("span",{className:"font-mono",children:["#",a.name]}),d.jsx("span",{className:"ml-auto text-xs text-fg-dim",children:a.count})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-accent",children:"cmd"}),d.jsx("span",{className:"font-medium",children:a.label}),d.jsx("span",{className:"ml-auto text-xs text-fg-dim",children:a.description})]})})}function b2(){const a=Au(f=>f.open),l=Au(f=>f.setOpen),s=Au(f=>f.toggle),r=re(f=>f.activeVaultId);S.useEffect(()=>{const f=h=>{h.key==="k"&&(h.metaKey||h.ctrlKey)&&!h.altKey&&!h.shiftKey&&(h.preventDefault(),s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s]);const c=S.useRef(r);return S.useEffect(()=>{c.current!==r&&(c.current=r,l(!1))},[r,l]),!a||r===null?null:d.jsx(y2,{onClose:()=>l(!1)})}const $d={tags:[{name:"capture",description:"Notes captured directly by the user (text or voice)."},{name:"capture/text",parent_names:["capture"],description:"Text capture."},{name:"capture/voice",parent_names:["capture"],description:"Voice capture."}]};function x2(a,l){const s=a??[],r=l??[];if(s.length!==r.length)return!1;for(let c=0;c<s.length;c++)if(s[c]!==r[c])return!1;return!0}function S2(a,l){if(!l)return{name:a.name,status:"missing",expected:a,actual:null,differences:[]};const s=[];(l.description??"")!==a.description&&s.push("description");const r=a.parent_names??null;return x2(l.parent_names,r)||s.push("parent_names"),{name:a.name,status:s.length===0?"ok":"misaligned",expected:a,actual:l,differences:s}}async function E2(a){const l=await a.listTagsWithSchema(),s=new Map(l.map(h=>[h.name,h])),r=$d.tags.map(h=>S2(h,s.get(h.name))),c=r.filter(h=>h.status==="missing"),f=r.filter(h=>h.status==="misaligned");return{ok:c.length===0&&f.length===0,missing:c,misaligned:f,rows:r}}const w2=300*1e3;function bd(a,l){return{vaultId:l,result:(a==null?void 0:a.result)??null,loading:!0,error:null,lastCheckedAt:(a==null?void 0:a.lastCheckedAt)??null}}async function Hg(a,l,s){try{const r=await E2(l);s(c=>({byVault:{...c.byVault,[a]:{vaultId:a,result:r,loading:!1,error:null,lastCheckedAt:Date.now()}}}))}catch(r){const c=r instanceof Error?r.message:String(r);s(f=>({byVault:{...f.byVault,[a]:{...f.byVault[a]??bd(void 0,a),loading:!1,error:c}}}))}}const xd=pl((a,l)=>({byVault:{},async ensure(s,r){const c=l().byVault[s];c!=null&&c.result&&c.lastCheckedAt&&Date.now()-c.lastCheckedAt<w2||c!=null&&c.loading||(a(f=>({byVault:{...f.byVault,[s]:bd(c,s)}})),await Hg(s,r,a))},async refresh(s,r){const c=l().byVault[s];c!=null&&c.loading||(a(f=>({byVault:{...f.byVault,[s]:bd(c,s)}})),await Hg(s,r,a))},clear(s){a(r=>{if(!(s in r.byVault))return r;const{[s]:c,...f}=r.byVault;return{byVault:f}})},set(s,r){a(c=>({byVault:{...c.byVault,[s]:{vaultId:s,result:r,loading:!1,error:null,lastCheckedAt:Date.now()}}}))}})),Mu=new Set;async function _N(a,l){if(!Mu.has(a)){Mu.add(a);try{for(const s of $d.tags)await l.updateTag(s.name,{description:s.description,...s.parent_names?{parent_names:s.parent_names}:{}})}catch(s){Mu.delete(a),typeof console<"u"&&console.warn(`[schema-ensure] failed to ensure required schema for vault ${a}:`,s)}}}async function T2(a,l){for(const s of $d.tags)await l.updateTag(s.name,{description:s.description,...s.parent_names?{parent_names:s.parent_names}:{}});Mu.add(a)}function A2(){const a=re(A=>A.activeVaultId),l=xd(A=>a?A.byVault[a]??null:null),s=xd(A=>A.set),r=Uu(A=>a?!!A.dismissedByVault[a]:!1),c=Uu(A=>A.dismiss),f=ze(),[h,y]=S.useState(!1),[p,g]=S.useState(null);if(!a||!(l!=null&&l.result)||l.result.ok||r)return null;const x=l.result.missing.length,v=l.result.misaligned.length;async function E(){var A;if(!(!f||!a)){y(!0),g(null);try{await T2(a,f),s(a,{ok:!0,missing:[],misaligned:[],rows:((A=l==null?void 0:l.result)==null?void 0:A.rows.map(D=>({...D,status:"ok",differences:[]})))??[]})}catch(D){g(D instanceof Error?D.message:String(D))}finally{y(!1)}}}return d.jsx("output",{"aria-live":"polite",className:"block border-b border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-amber-200 md:px-6",children:d.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-medium text-amber-100",children:"Vault schema needs setup"}),d.jsxs("p",{className:"text-xs text-amber-200/80",children:[x>0&&v>0?`${x} missing, ${v} misaligned`:x>0?`${x} missing tag${x===1?"":"s"} Notes uses`:`${v} tag${v===1?"":"s"} need realignment`," ","(capture / capture/text / capture/voice)."," ",d.jsx(Qe,{to:"/settings",className:"underline hover:text-amber-100",children:"Review in Settings"}),"."]}),p?d.jsx("p",{className:"mt-1 text-xs text-red-300",children:p}):null]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:()=>void E(),disabled:h||!f,className:"min-h-11 self-start rounded-md bg-amber-500/30 px-3 py-1.5 text-xs font-medium text-amber-50 hover:bg-amber-500/50 disabled:cursor-not-allowed disabled:opacity-60 md:self-auto",children:h?"Setting up…":"Set up"}),d.jsx("button",{type:"button",onClick:()=>c(a),className:"min-h-11 self-start rounded-md px-3 py-1.5 text-xs text-amber-200/80 hover:text-amber-100 md:self-auto","aria-label":"Dismiss schema setup banner",children:"Dismiss"})]})]})})}const N2=4e3;function j2(){const a=zs(s=>s.toasts),l=zs(s=>s.dismiss);return S.useEffect(()=>{if(a.length===0)return;const s=a.map(r=>window.setTimeout(()=>l(r.id),N2));return()=>{for(const r of s)window.clearTimeout(r)}},[a,l]),a.length===0?null:d.jsx("output",{"aria-live":"polite",className:"pointer-events-none fixed bottom-6 left-1/2 z-50 flex -translate-x-1/2 flex-col items-center gap-2",children:a.map(s=>d.jsxs("div",{className:`pointer-events-auto flex max-w-md items-center gap-3 rounded-md border px-4 py-2 text-sm shadow-lg backdrop-blur ${s.tone==="error"?"border-red-500/40 bg-red-500/10 text-red-400":s.tone==="success"?"border-accent/40 bg-accent/10 text-accent":"border-border bg-card text-fg-muted"}`,children:[d.jsx("span",{children:s.message}),d.jsx("button",{type:"button",onClick:()=>l(s.id),"aria-label":"Dismiss",className:"text-fg-dim hover:text-fg",children:"×"})]},s.id))})}function R2(a={}){const{immediate:l=!1,onNeedReload:s,onNeedRefresh:r,onOfflineReady:c,onRegistered:f,onRegisteredSW:h,onRegisterError:y}=a;let p,g,x;const v=async(A=!0)=>{await g,x==null||x()};async function E(){if("serviceWorker"in navigator){if(p=await Mt(async()=>{const{Workbox:A}=await import("./workbox-window.prod.es5-BBnX5xw4.js");return{Workbox:A}},[],import.meta.url).then(({Workbox:A})=>new A("./sw.js",{scope:"./",type:"classic"})).catch(A=>{y==null||y(A)}),!p)return;x=()=>{p==null||p.messageSkipWaiting()};{let A=!1;const D=()=>{A=!0,p==null||p.addEventListener("controlling",_=>{_.isUpdate&&(s?s():window.location.reload())}),r==null||r()};p.addEventListener("installed",_=>{typeof _.isUpdate>"u"?typeof _.isExternal<"u"&&_.isExternal?D():!A&&(c==null||c()):_.isUpdate||c==null||c()}),p.addEventListener("waiting",D)}p.register({immediate:l}).then(A=>{h?h("./sw.js",A):f==null||f(A)}).catch(A=>{y==null||y(A)})}}return g=E(),v}function C2(a={}){const{immediate:l=!0,onNeedReload:s,onNeedRefresh:r,onOfflineReady:c,onRegistered:f,onRegisteredSW:h,onRegisterError:y}=a,[p,g]=S.useState(!1),[x,v]=S.useState(!1),[E]=S.useState(()=>R2({immediate:l,onNeedReload:s,onOfflineReady(){v(!0),c==null||c()},onNeedRefresh(){g(!0),r==null||r()},onRegistered:f,onRegisteredSW:h,onRegisterError:y}));return{needRefresh:[p,g],offlineReady:[x,v],updateServiceWorker:E}}const _2={};function O2(){const l=typeof import.meta<"u"&&_2?"./":void 0;return(!l||l===""||l==="/"?"/notes/":l).replace(/\/$/,"")||"/notes"}const M2=O2();function D2(a){return Yu()===M2}async function U2(a=typeof navigator>"u"?void 0:navigator,l){if(!a||!("serviceWorker"in a))return 0;const s=a.serviceWorker;if(!s||typeof s.getRegistrations!="function")return 0;const r=Yu(),c=await s.getRegistrations();let f=0;for(const h of c)try{const p=new URL(h.scope).pathname.replace(/\/$/,"")||"/";if(p===r||!(/^\/notes$/.test(p)||/^\/surface\/[a-z0-9][a-z0-9_-]*$/.test(p)))continue;await h.unregister(),f+=1,typeof console<"u"&&console.info(`[notes-ui] unregistered stale service worker at scope ${h.scope} (runtime mount is ${r})`)}catch(y){typeof console<"u"&&console.warn(`[notes-ui] failed to inspect/unregister SW: ${String(y)}`)}return f}function z2(){const{needRefresh:[a,l],updateServiceWorker:s}=C2({onRegisteredSW(c,f){if(!f)return;const h=3600*1e3;setInterval(()=>{f.update().catch(()=>{})},h)}});if(!a)return null;async function r(){gS(),await s(!0)}return d.jsxs("output",{className:"fixed inset-x-0 bottom-4 z-40 mx-auto flex max-w-sm items-center justify-between gap-3 rounded-md border border-border bg-card px-4 py-3 shadow-lg",children:[d.jsx("p",{className:"text-sm text-fg",children:"A new version of Parachute Notes is available."}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-sm text-fg-muted hover:text-accent",children:"Later"}),d.jsx("button",{type:"button",onClick:r,className:"rounded-md bg-accent px-3 py-1 text-sm font-medium text-white hover:bg-accent-hover",children:"Reload"})]})]})}function L2(){return D2()?d.jsx(z2,{}):null}function V2(){const a=re(c=>c.activeVaultId),l=re(c=>c.getActiveVault()),s=vi(c=>a?c.byVault[a]??null:null),r=gl(c=>a?c.byVault[a]??null:null);return!l||!a?null:s?d.jsx(q2,{reason:s.reason,vaultIssuer:l.issuer??l.url,vaultScope:l.scope,vaultId:a}):r&&r.state==="down"?d.jsx(H2,{vaultUrl:l.url,vaultId:a}):null}function q2({reason:a,vaultIssuer:l,vaultScope:s,vaultId:r}){const[c,f]=S.useState(!1),[h,y]=S.useState(null),[p,g]=S.useState(!1);async function x(){y(null),g(!1),f(!0);try{const{authorizeUrl:v}=await Tv(l,s,void 0,{priorHaltedVaultId:r});window.location.assign(v)}catch(v){v instanceof Qu?g(!0):y(v instanceof Error?v.message:String(v))}finally{f(!1)}}return d.jsxs("div",{role:"alert","aria-live":"assertive",className:"border-b border-red-500/40 bg-red-500/10 px-4 py-3 text-sm text-red-200 md:px-6",children:[d.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-medium text-red-100",children:"Vault session expired"}),d.jsx("p",{className:"text-xs text-red-200/80",children:a}),h?d.jsx("p",{className:"mt-1 text-xs text-red-300",children:h}):null]}),d.jsx("button",{type:"button",onClick:x,disabled:c,className:"self-start rounded-md bg-red-500/30 px-3 py-1.5 text-xs font-medium text-red-50 hover:bg-red-500/50 disabled:cursor-not-allowed disabled:opacity-60 md:self-auto",children:c?"Starting OAuth…":"Reconnect to vault"})]}),p?d.jsx("div",{className:"mx-auto mt-2 max-w-5xl",children:d.jsx(xb,{})}):null]})}function H2({vaultUrl:a,vaultId:l}){const s=ze(),r=ot(),c=gl(g=>g.resetToHealthy),[f,h]=S.useState(!1);async function y(){if(s){h(!0);try{await s.vaultInfo(!1),r.invalidateQueries({queryKey:["notes",l]}),r.invalidateQueries({queryKey:["tags",l]}),r.invalidateQueries({queryKey:["vaultInfo",l]}),r.invalidateQueries({queryKey:["note",l]})}catch{}finally{h(!1)}}}const p=B2(a)?"Try `parachute start vault` in a terminal.":null;return d.jsx("div",{role:"alert","aria-live":"polite",className:"border-b border-red-500/30 bg-red-500/5 px-4 py-3 text-sm text-red-200 md:px-6",children:d.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-medium text-red-100",children:"Vault not reachable"}),d.jsxs("p",{className:"text-xs text-red-200/80",children:["Notes can't sync until it's back online.",p?` ${p}`:""]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",onClick:y,disabled:f||!s,className:"self-start rounded-md bg-red-500/20 px-3 py-1.5 text-xs font-medium text-red-50 hover:bg-red-500/40 disabled:cursor-not-allowed disabled:opacity-60 md:self-auto",children:f?"Retrying…":"Retry now"}),d.jsx("button",{type:"button",onClick:()=>c(l),className:"self-start rounded-md px-3 py-1.5 text-xs text-red-200/80 hover:text-red-100 md:self-auto","aria-label":"Dismiss banner",title:"Dismiss",children:"Dismiss"})]})]})})}const k2=/^(10|192\.168|172\.(1[6-9]|2\d|3[0-1]))\./;function B2(a){try{const s=new URL(a).hostname.replace(/^\[/,"").replace(/\]$/,"");return!!(s==="localhost"||s==="127.0.0.1"||s==="::1"||s.endsWith(".local")||k2.test(s))}catch{return!1}}function Q2(){const a=re(r=>r.activeVaultId),l=ze(),s=xd(r=>r.ensure);S.useEffect(()=>{!a||!l||s(a,l)},[a,l,s])}function G2(){return Q2(),null}function Y2({children:a}){const[l]=S.useState(()=>new aE({defaultOptions:{queries:{retry:(s,r)=>{var c;if(!(r instanceof Error))return s<2;if(r instanceof ai)return!1;if(r instanceof Cs){const f=re.getState().activeVaultId;return(f?(c=gl.getState().byVault[f])==null?void 0:c.state:void 0)==="down"?!1:s<1}return s<2},refetchOnWindowFocus:!1,staleTime:1e4}}}));return d.jsx(lE,{client:l,children:a})}function K2(){const a=IS(),l=a.status==="found"?a.origin:null,s=a.status==="probing";return d.jsxs("div",{className:"mx-auto max-w-2xl px-6 py-20 text-center",children:[d.jsx("p",{className:"mb-8 font-serif text-xl italic text-fg-muted",children:"The default frontend for Parachute."}),d.jsx("h1",{className:"mb-4 font-serif text-5xl tracking-tight",children:"Notes"}),s?d.jsx("div",{className:"h-28","aria-hidden":"true"}):l?d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"mb-8 text-fg tracking-wide",children:["Looks like there's a vault at"," ",d.jsx("code",{className:"rounded bg-bg/60 px-1.5 py-0.5 font-mono text-sm",children:l}),"."]}),d.jsx(Qe,{to:`/add?url=${encodeURIComponent(l)}`,className:"inline-block rounded-md bg-accent px-6 py-3 text-sm font-medium text-white hover:bg-accent-hover",children:"Connect"}),d.jsx("div",{className:"mt-4",children:d.jsx(Qe,{to:"/add",className:"text-sm text-fg-dim hover:text-accent",children:"Or connect to a different vault"})})]}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"mb-10 text-fg-dim tracking-wide",children:"Point it at a vault. Sign in. Browse, edit, visualize."}),d.jsx(Qe,{to:"/add",className:"inline-block rounded-md bg-accent px-6 py-3 text-sm font-medium text-white hover:bg-accent-hover",children:"Connect a vault"})]})]})}const X2="lens:path-tree-expanded:";function Tb(a){return X2+a}function kg(a){try{const l=localStorage.getItem(Tb(a));if(!l)return new Set;const s=JSON.parse(l);return Array.isArray(s)?new Set(s.filter(r=>typeof r=="string")):new Set}catch{return new Set}}function $2(a,l){try{localStorage.setItem(Tb(a),JSON.stringify([...l].sort()))}catch{}}function Z2(a){const[l,s]=S.useState(()=>a?kg(a):new Set);S.useEffect(()=>{s(a?kg(a):new Set)},[a]);const r=S.useCallback(c=>{a&&s(f=>{const h=new Set(f);return h.has(c)?h.delete(c):h.add(c),$2(a,h),h})},[a]);return{expanded:l,toggle:r}}function F2(a,l){return{name:a,fullPath:l,count:0,children:[],childMap:new Map}}function Ab(a){const l=a.split("/").filter(s=>s.length>0);return l.length<=1?[]:l.slice(0,-1)}function J2(a){const l=new Map;for(const r of a){if(!r)continue;const c=Ab(r);if(c.length===0)continue;let f=l,h="";for(const y of c){h=h?`${h}/${y}`:y;let p=f.get(y);p||(p=F2(y,h),f.set(y,p)),p.count+=1,f=p.childMap}}const s=r=>r.map(c=>({name:c.name,fullPath:c.fullPath,count:c.count,children:s([...c.childMap.values()])})).sort((c,f)=>c.name.localeCompare(f.name));return s([...l.values()])}const I2=5,P2=20;function W2(a){const l=new Set;let s=0;for(const r of a){if(!r)continue;const c=Ab(r);if(c.length!==0&&(s+=1,l.add(c[0]),l.size>=I2||s>=P2))return!0}return!1}function eA({paths:a,vaultId:l,currentPrefix:s,onSelect:r}){const c=S.useMemo(()=>J2(a),[a]),{expanded:f,toggle:h}=Z2(l),y=S.useMemo(()=>tA(s),[s]);return c.length===0?d.jsxs("aside",{"aria-label":"Path tree",children:[d.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Folders"}),d.jsx("p",{className:"text-xs text-fg-dim",children:"No folders yet."})]}):d.jsxs("aside",{"aria-label":"Path tree",className:"md:sticky md:top-6 md:self-start",children:[d.jsxs("div",{className:"mb-2 flex items-baseline justify-between",children:[d.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Folders"}),s?d.jsx("button",{type:"button",onClick:()=>r(""),className:"text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]}),d.jsx("ul",{className:"space-y-0.5",children:c.map(p=>d.jsx(Nb,{node:p,depth:0,expanded:f,forcedOpen:y,currentPrefix:s,onToggle:h,onSelect:r},p.fullPath))})]})}function Nb({node:a,depth:l,expanded:s,forcedOpen:r,currentPrefix:c,onToggle:f,onSelect:h}){const y=a.children.length>0,p=s.has(a.fullPath)||r.has(a.fullPath),g=c===a.fullPath;return d.jsxs("li",{children:[d.jsxs("div",{className:`flex items-center gap-1 rounded-md px-1 py-0.5 text-sm ${g?"bg-accent/10 text-accent":"text-fg-muted hover:text-accent"}`,style:{paddingLeft:`${l*.75+.25}rem`},children:[y?d.jsx("button",{type:"button",onClick:()=>f(a.fullPath),"aria-label":`${p?"Collapse":"Expand"} ${a.fullPath}`,"aria-expanded":p,className:"flex h-4 w-4 items-center justify-center text-fg-dim hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:p?"▾":"▸"})}):d.jsx("span",{"aria-hidden":"true",className:"inline-block h-4 w-4"}),d.jsxs("button",{type:"button",onClick:()=>h(a.fullPath),"aria-current":g?"true":void 0,className:"flex flex-1 items-baseline gap-1.5 truncate text-left",children:[d.jsx("span",{className:"truncate",children:a.name}),d.jsx("span",{className:"text-xs text-fg-dim",children:a.count})]})]}),y&&p?d.jsx("ul",{className:"space-y-0.5",children:a.children.map(x=>d.jsx(Nb,{node:x,depth:l+1,expanded:s,forcedOpen:r,currentPrefix:c,onToggle:f,onSelect:h},x.fullPath))}):null]})}function tA(a){const l=new Set;if(!a)return l;const s=a.split("/").filter(c=>c.length>0);let r="";for(const c of s)r=r?`${r}/${c}`:c,l.add(r);return l}function nA(a,l){const s=new Map;for(const p of a){const g=p.name.indexOf("/");if(g>0){const x=p.name.slice(0,g),v=s.get(x)??[];v.push(p),s.set(x,v)}}const r=new Set;for(const[p,g]of s)g.length>=2&&r.add(p);const c=new Map,f=[];for(const p of a){const g=p.name.indexOf("/"),x=g>0?p.name.slice(0,g):p.name;if(g>0&&r.has(x)){let E=c.get(x);E||(E={kind:"group",prefix:x,totalCount:0,children:[]},c.set(x,E)),E.children.push({...p,pinned:l.has(p.name)}),E.totalCount+=p.count}else if(r.has(p.name)){let E=c.get(p.name);E||(E={kind:"group",prefix:p.name,totalCount:0,children:[]},c.set(p.name,E)),E.selfTag={...p,pinned:l.has(p.name)},E.totalCount+=p.count}else f.push({kind:"leaf",name:p.name,label:p.name,count:p.count,pinned:l.has(p.name)})}for(const p of c.values())p.children.sort((g,x)=>g.pinned!==x.pinned?g.pinned?-1:1:x.count-g.count||g.name.localeCompare(x.name));const h=[...f,...Array.from(c.values())],y=p=>{var v,E;if(p.kind==="leaf")return{pinned:p.pinned,count:p.count,label:p.label};const g=(((v=p.selfTag)==null?void 0:v.pinned)??!1)||p.children.some(A=>A.pinned),x=Math.max(((E=p.selfTag)==null?void 0:E.count)??0,...p.children.map(A=>A.count))||0;return{pinned:g,count:x,label:p.prefix}};return h.sort((p,g)=>{const x=y(p),v=y(g);return x.pinned!==v.pinned?x.pinned?-1:1:v.count-x.count||x.label.localeCompare(v.label)}),h}function aA({tags:a,pinnedTags:l,selected:s,onToggle:r,onClear:c,isLoading:f}){const h=S.useMemo(()=>new Set(l.map(E=>E.toLowerCase())),[l]),y=S.useMemo(()=>new Set(s.map(E=>E.toLowerCase())),[s]),p=S.useMemo(()=>nA(a,h),[a,h]),[g,x]=S.useState(new Set),v=E=>{x(A=>{const D=new Set(A);return D.has(E)?D.delete(E):D.add(E),D})};return d.jsxs("nav",{"aria-label":"Browse by tag",children:[d.jsxs("div",{className:"mb-2 flex items-baseline justify-between",children:[d.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Tags"}),s.length>0?d.jsx("button",{type:"button",onClick:c,className:"text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]}),f?d.jsx("p",{className:"text-xs text-fg-dim",children:"Loading…"}):p.length===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"No tags in this vault."}):d.jsx("ul",{className:"max-h-[60vh] space-y-0.5 overflow-y-auto pr-1",children:p.map(E=>E.kind==="leaf"?d.jsx("li",{children:d.jsx(Sd,{name:E.name,label:E.label,count:E.count,pinned:E.pinned,active:y.has(E.name.toLowerCase()),onToggle:()=>r(E.name)})},E.name):d.jsx("li",{children:d.jsx(lA,{group:E,isOpen:g.has(E.prefix),onToggleOpen:()=>v(E.prefix),selectedSet:y,onToggleTag:r})},E.prefix))})]})}function Sd({name:a,label:l,count:s,pinned:r,active:c,onToggle:f}){return d.jsxs("button",{type:"button",onClick:f,"aria-pressed":c,title:`#${a}`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-sm ${c?"bg-accent/15 text-accent":"text-fg-muted hover:bg-bg/60 hover:text-accent"}`,children:[r?d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-accent",children:"★"}):null,d.jsxs("span",{className:"flex-1 truncate",children:["#",l]}),d.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:s})]})}function lA({group:a,isOpen:l,onToggleOpen:s,selectedSet:r,onToggleTag:c}){var g;const f=a.children.some(x=>r.has(x.name.toLowerCase())),h=a.selfTag?r.has(a.selfTag.name.toLowerCase()):!1,y=l||f||h,p=(((g=a.selfTag)==null?void 0:g.pinned)??!1)||a.children.some(x=>x.pinned);return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-1 rounded-md px-1 py-0.5",children:[d.jsx("button",{type:"button",onClick:s,"aria-expanded":y,"aria-label":`${y?"Collapse":"Expand"} ${a.prefix}`,className:"flex h-5 w-5 shrink-0 items-center justify-center text-fg-dim hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:y?"▾":"▸"})}),a.selfTag?d.jsx(Sd,{name:a.selfTag.name,label:a.prefix,count:a.selfTag.count,pinned:a.selfTag.pinned,active:h,onToggle:()=>c(a.selfTag.name)}):d.jsxs("button",{type:"button",onClick:s,className:"flex flex-1 items-center gap-1.5 truncate rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-bg/60 hover:text-accent",children:[p?d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-accent",children:"★"}):null,d.jsxs("span",{className:"flex-1 truncate",children:["#",a.prefix,"/"]}),d.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:a.totalCount})]})]}),y?d.jsx("ul",{className:"ml-4 space-y-0.5 border-l border-border pl-2",children:a.children.map(x=>{const v=x.name.slice(a.prefix.length+1)||x.name;return d.jsx("li",{children:d.jsx(Sd,{name:x.name,label:v,count:x.count,pinned:x.pinned,active:r.has(x.name.toLowerCase()),onToggle:()=>c(x.name)})},x.name)})}):null]})}function ON({tags:a,input:l,onInputChange:s,onAdd:r,onRemove:c}){return d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-sm",children:[d.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Tags"}),a.map(f=>d.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-bg/60 px-2 py-0.5 text-xs text-fg-muted",children:[d.jsx("span",{className:"min-w-0 break-all",children:f}),d.jsx("button",{type:"button",onClick:()=>c(f),"aria-label":`Remove tag ${f}`,className:"text-fg-dim hover:text-red-400",children:"×"})]},f)),d.jsx("input",{type:"text",value:l,onChange:f=>s(f.target.value),onKeyDown:f=>{f.key==="Enter"||f.key===","?(f.preventDefault(),r(l)):f.key==="Backspace"&&l===""&&a.length>0&&c(a[a.length-1])},onBlur:()=>{l.trim()&&r(l)},placeholder:"add tag…",className:"min-w-24 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-xs text-fg focus:border-border focus:outline-none","aria-label":"Add tag"})]})}function Bg(a){return a.trim().replace(/^#/,"")}function Qg(a,l){const[s,r]=S.useState(a);return S.useEffect(()=>{const c=setTimeout(()=>r(a),l);return()=>clearTimeout(c)},[a,l]),s}const iA=["auto","always","never"],Ls="auto",sA="lens:path-tree:";function jb(a){return sA+a}function rA(a){return typeof a=="string"&&iA.includes(a)?a:Ls}function Gg(a){try{const l=localStorage.getItem(jb(a));if(!l)return Ls;const s=JSON.parse(l);return rA(s.mode)}catch{return Ls}}function uA(a,l){try{localStorage.setItem(jb(a),JSON.stringify({mode:l}))}catch{}}function cA(a){const[l,s]=S.useState(()=>a?Gg(a):Ls);S.useEffect(()=>{s(a?Gg(a):Ls)},[a]);const r=S.useCallback(c=>{a&&(uA(a,c),s(c))},[a]);return{mode:l,setMode:r}}const Bu="UI/Views/",Rb="saved-view";function Cb(a){var s,r;const l={};return(s=a.search)!=null&&s.trim()&&(l.search=a.search.trim()),a.tags&&a.tags.length>0&&(l.tags=[...a.tags]),a.tags&&a.tags.length>1&&a.tagMatch&&(l.tagMatch=a.tagMatch),(r=a.pathPrefix)!=null&&r.trim()&&(l.pathPrefix=a.pathPrefix.trim()),a.sort&&(l.sort=a.sort),a.showArchived&&(l.showArchived=!0),{kind:Rb,filters:l}}function oA(a){const l=a.metadata;if(!l||l.kind!==Rb)return null;const s=l.filters??{},r=fA(a.path)??a.id;return{id:a.id,name:r,filters:{search:typeof s.search=="string"?s.search:void 0,tags:Array.isArray(s.tags)?s.tags.filter(c=>typeof c=="string"):void 0,tagMatch:s.tagMatch==="all"?"all":s.tagMatch==="any"?"any":void 0,pathPrefix:typeof s.pathPrefix=="string"?s.pathPrefix:void 0,sort:s.sort==="asc"?"asc":s.sort==="desc"?"desc":void 0,showArchived:s.showArchived===!0},updatedAt:a.updatedAt}}function fA(a){return!a||!a.startsWith(Bu)?null:a.slice(Bu.length).replace(/\.md$/i,"")||null}function _b(a){const l=a.trim().replace(/[/\\]/g,"-");return`${Bu}${l}`}function Ed(a){var s,r;const l=new URLSearchParams;(s=a.search)!=null&&s.trim()&&l.set("search",a.search.trim());for(const c of a.tags??[])l.append("tag",c);return a.tagMatch&&l.set("tag_match",a.tagMatch),(r=a.pathPrefix)!=null&&r.trim()&&l.set("path_prefix",a.pathPrefix.trim()),a.sort&&l.set("sort",a.sort),a.showArchived&&l.set("show_archived","1"),l}function Yg(a){const l=a.getAll("tag"),s=a.get("tag_match"),r=a.get("sort");return{search:a.get("search")??void 0,tags:l.length>0?l:void 0,tagMatch:s==="all"?"all":s==="any"?"any":void 0,pathPrefix:a.get("path_prefix")??void 0,sort:r==="asc"?"asc":r==="desc"?"desc":void 0,showArchived:a.get("show_archived")==="1"}}function Kg(a){var l,s;return!!((l=a.search)!=null&&l.trim()||a.tags&&a.tags.length>0||(s=a.pathPrefix)!=null&&s.trim())}function Pu(a,l){a.invalidateQueries({queryKey:["savedViews",l]}),a.invalidateQueries({queryKey:["notes",l]}),a.invalidateQueries({queryKey:["tags",l]}),a.invalidateQueries({queryKey:["vaultInfo",l]})}function dA(a){const l=ze(),s=re(r=>r.activeVaultId);return fn({queryKey:["savedViews",s,a],enabled:!!l&&!!a,queryFn:async()=>{const r=new URLSearchParams;return r.set("tag",a),r.set("path_prefix",Bu),r.set("sort","asc"),(await l.queryNotes(r)).map(f=>oA(f)).filter(f=>f!==null).sort((f,h)=>f.name.localeCompare(h.name))},staleTime:3e4})}function hA(a){const l=ze(),s=re(c=>c.activeVaultId),r=ot();return Yt({mutationFn:async c=>{if(!l)throw new Error("No active vault");return l.createNote({path:_b(c.name),content:c.description??"",tags:[a],metadata:Cb(c.filters)})},onSuccess:()=>Pu(r,s)})}function mA(){const a=ze(),l=re(r=>r.activeVaultId),s=ot();return Yt({mutationFn:async({view:r,newName:c})=>{if(!a)throw new Error("No active vault");return a.updateNote(r.id,{path:_b(c),...r.updatedAt?{if_updated_at:r.updatedAt}:{force:!0}})},onSuccess:()=>Pu(s,l)})}function pA(){const a=ze(),l=re(r=>r.activeVaultId),s=ot();return Yt({mutationFn:async({view:r,filters:c})=>{if(!a)throw new Error("No active vault");return a.updateNote(r.id,{metadata:Cb(c),...r.updatedAt?{if_updated_at:r.updatedAt}:{force:!0}})},onSuccess:()=>Pu(s,l)})}function yA(){const a=ze(),l=re(r=>r.activeVaultId),s=ot();return Yt({mutationFn:async r=>{if(!a)throw new Error("No active vault");await a.deleteNote(r.id)},onSuccess:()=>Pu(s,l)})}const gA={pinned:"Pinned",archived:"Archived",untagged:"Untagged",orphaned:"Orphaned"},vA={untagged:"Notes without any tags. Add a tag inline to file them.",orphaned:"Notes with no inbound or outbound links."};function js({preset:a}={}){var Ci;const l=re(F=>F.getActiveVault()),{roles:s}=RE((l==null?void 0:l.id)??null),{pinnedTags:r}=$S((l==null?void 0:l.id)??null),[c,f]=jT(),h=S.useMemo(()=>Yg(c),[c]),[y,p]=S.useState(h.search??""),[g,x]=S.useState(h.pathPrefix??""),[v,E]=S.useState(h.tags??[]),[A,D]=S.useState(h.tagMatch??"any"),[_,z]=S.useState(h.sort??"desc"),[C,Y]=S.useState(h.showArchived??!1),[G,V]=S.useState(0),K=S.useMemo(()=>c.toString(),[c]);S.useEffect(()=>{const F=Yg(new URLSearchParams(K));p(F.search??""),x(F.pathPrefix??""),E(F.tags??[]),D(F.tagMatch??"any"),z(F.sort??"desc"),Y(F.showArchived??!1)},[K]);const ie=Qg(y,300),W=Qg(g,300);S.useEffect(()=>{if(a)return;const F={search:ie,tags:v,tagMatch:A,pathPrefix:W,sort:_,showArchived:C};Ed(F).toString()!==K&&f(Ed(F),{replace:!0})},[a,ie,W,v,A,_,C]);const le=S.useMemo(()=>a==="pinned"?Array.from(new Set([s.pinned,...v])):a==="archived"?Array.from(new Set([s.archived,...v])):v,[a,s.pinned,s.archived,v]),de=a==="pinned"||a==="archived"?"all":A;S.useEffect(()=>{V(0)},[ie,W,le,de,_,C]);const J=S.useMemo(()=>({...zS,search:ie,pathPrefix:W,tags:le,tagMatch:de,sort:_,offset:G,...a==="untagged"?{hasTags:!1}:{},...a==="orphaned"?{hasLinks:!1}:{}}),[ie,W,le,de,_,G,a]),oe=YE(J),Ne=Pv(),at=dA(s.view),Je=hA(s.view),Me=mA(),H=pA(),X=yA(),ee=zs(F=>F.push),[Ce,je]=S.useState(!1),[j,B]=S.useState(null),[$,P]=S.useState(!1),{mode:ue}=cA((l==null?void 0:l.id)??null),[pe,we]=S.useState(!1),st=!a&&ue!=="never",Ge=st&&pe,xn=XE(Ge),za=S.useMemo(()=>(xn.data??[]).map(F=>F.path),[xn.data]),Ti=Ge&&(ue==="always"||ue==="auto"&&W2(za)),Sn=S.useMemo(()=>({search:ie,tags:v,tagMatch:A,pathPrefix:W,sort:_,showArchived:C}),[ie,W,v,A,_,C]),En=S.useCallback(async F=>{try{await Je.mutateAsync({name:F,filters:Sn}),ee(`Saved view "${F}".`,"success"),je(!1)}catch(_e){ee(`Could not save view: ${_e.message}`,"error")}},[Je,Sn,ee]),Ai=S.useCallback(async(F,_e)=>{try{await Me.mutateAsync({view:F,newName:_e}),ee(`Renamed to "${_e}".`,"success"),B(null)}catch(Tn){ee(`Could not rename: ${Tn.message}`,"error")}},[Me,ee]),Ni=S.useCallback(async F=>{try{await H.mutateAsync({view:F,filters:Sn}),ee(`Updated "${F.name}".`,"success")}catch(_e){ee(`Could not update: ${_e.message}`,"error")}},[H,Sn,ee]),Wu=S.useCallback(async F=>{if(confirm(`Delete saved view "${F.name}"? This can't be undone.`))try{await X.mutateAsync(F),ee(`Deleted "${F.name}".`,"success")}catch(_e){ee(`Could not delete: ${_e.message}`,"error")}},[X,ee]),wn=S.useMemo(()=>{if(!oe.data)return oe.data;let F=oe.data;if(!a&&!C&&(F=F.filter(_e=>!(_e.tags??[]).includes(s.archived))),!a){const _e=s.pinned;F=[...F].sort((Tn,Fs)=>{const ac=(Tn.tags??[]).includes(_e)?0:1,lc=(Fs.tags??[]).includes(_e)?0:1;return ac-lc})}return F},[oe.data,a,C,s.archived,s.pinned]);if(!l)return d.jsx(Us,{to:"/",replace:!0});const ji=a?gA[a]:"Notes",vl=a?vA[a]:null,Ri=G+1,ec=G+((wn==null?void 0:wn.length)??0),tc=G>0,vt=(((Ci=oe.data)==null?void 0:Ci.length)??0)===Nu,nc=Kg(Sn);return d.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-6 md:py-10",children:[d.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:l.name}),d.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:ji}),vl?d.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:vl}):null]}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[a?null:d.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-fg-muted hover:text-accent",children:[d.jsx("input",{type:"checkbox",checked:C,onChange:F=>Y(F.target.checked)}),"Show archived"]}),d.jsxs("button",{type:"button",onClick:()=>z(F=>F==="desc"?"asc":"desc"),className:"text-sm text-fg-muted hover:text-accent","aria-label":"Toggle sort direction",children:["Sort: ",_==="desc"?"newest":"oldest"," first"]}),d.jsx(Qe,{to:"/new",className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover",children:"New note"})]})]}),a?null:d.jsx(TA,{pinnedTags:r,tagCounts:Ne.data??[],selected:v,onPick:F=>{x(""),E(_e=>_e.length===1&&_e[0]===F?[]:[F])}}),d.jsxs("div",{className:a?"":"grid gap-6 md:grid-cols-[14rem_1fr]",children:[a?null:d.jsxs("div",{className:"space-y-3 md:space-y-6",children:[d.jsxs("button",{type:"button",onClick:()=>P(F=>!F),className:"flex w-full items-center justify-between rounded-md border border-border bg-card px-3 py-1.5 text-left text-sm text-fg-muted hover:text-accent md:hidden","aria-expanded":$,"aria-controls":"notes-sidebar",children:[d.jsx("span",{children:"Folders & saved views"}),d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:$?"▾":"▸"})]}),d.jsxs("div",{id:"notes-sidebar",className:`space-y-6 md:sticky md:top-6 md:self-start ${$?"":"hidden md:block"}`,children:[d.jsx(aA,{tags:Ne.data??[],pinnedTags:r,selected:v,onToggle:F=>E(_e=>_e.includes(F)?_e.filter(Tn=>Tn!==F):[..._e,F]),onClear:()=>E([]),isLoading:Ne.isPending}),d.jsx(AA,{}),d.jsx(bA,{views:at.data,isPending:at.isPending,error:at.error,canUpdateWithCurrent:Kg(Sn),onRename:F=>B(F),onUpdate:Ni,onDelete:Wu}),st?d.jsxs("details",{className:"group",open:pe,onToggle:F=>we(F.currentTarget.open),children:[d.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between rounded-md px-1 py-1 text-xs uppercase tracking-wider text-fg-dim hover:text-accent",children:[d.jsx("span",{children:"Folders"}),d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs transition-transform group-open:rotate-90",children:"▸"})]}),d.jsx("div",{className:"mt-2",children:Ti?d.jsx(eA,{paths:za,vaultId:l.id,currentPrefix:g,onSelect:F=>x(F)}):xn.isLoading?d.jsx("p",{className:"px-1 text-xs text-fg-dim",children:"Loading…"}):d.jsx("p",{className:"px-1 text-xs text-fg-dim",children:"Not enough folder variety to show a tree yet."})})]}):null]})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"mb-6 space-y-3",children:[d.jsx("input",{type:"search",placeholder:"Search…",value:y,onChange:F=>p(F.target.value),className:"w-full rounded-md border border-border bg-card px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Search notes"}),d.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[d.jsx("input",{type:"text",placeholder:"Title starts with…",value:g,onChange:F=>x(F.target.value),className:"flex-1 min-w-48 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Filter by path prefix"}),a!=="untagged"?d.jsx(NA,{tags:Ne.data??[],selected:v,onToggle:F=>E(_e=>_e.includes(F)?_e.filter(Tn=>Tn!==F):[..._e,F]),tagMatch:A,onTagMatchChange:D,onClear:()=>E([])}):null,!a&&nc?d.jsx("button",{type:"button",onClick:()=>je(!0),className:"rounded-md border border-accent/60 bg-accent/10 px-3 py-2 text-sm text-accent hover:bg-accent/20",children:"Save view…"}):null]})]}),oe.isPending?d.jsx(jA,{}):oe.isError?d.jsx(RA,{error:oe.error}):wn&&wn.length>0?d.jsx("ol",{"aria-label":"Notes",className:"divide-y divide-border rounded-md border border-border bg-card",children:wn.map(F=>d.jsx(EA,{note:F,pinnedTag:s.pinned,archivedTag:s.archived,quickTagSuggestions:a==="untagged"?Ne.data??[]:void 0},F.id))}):d.jsx(CA,{filtering:VS(J)||!!a}),d.jsxs("div",{className:"mt-6 flex items-center justify-between text-sm text-fg-dim",children:[d.jsx("span",{children:oe.data&&oe.data.length>0?`Showing ${Ri}–${ec}`:oe.isFetching?"Loading…":""}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",disabled:!tc,onClick:()=>V(F=>Math.max(0,F-Nu)),className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted enabled:hover:text-accent disabled:opacity-40",children:"Previous"}),d.jsx("button",{type:"button",disabled:!vt,onClick:()=>V(F=>F+Nu),className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted enabled:hover:text-accent disabled:opacity-40",children:"Next"})]})]})]})]}),Ce?d.jsx(SA,{existing:at.data??[],isSaving:Je.isPending,onCancel:()=>je(!1),onSave:En}):null,j?d.jsx(xA,{view:j,existing:at.data??[],isSaving:Me.isPending,onCancel:()=>B(null),onSave:F=>Ai(j,F)}):null]})}function bA({views:a,isPending:l,error:s,canUpdateWithCurrent:r,onRename:c,onUpdate:f,onDelete:h}){const[y,p]=S.useState(null);return S.useEffect(()=>{if(!y)return;const g=v=>{const E=v.target;E!=null&&E.closest("[data-saved-view-menu]")||p(null)},x=v=>{v.key==="Escape"&&p(null)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[y]),d.jsxs("aside",{children:[d.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Saved views"}),l?d.jsx("p",{className:"text-xs text-fg-dim",children:"Loading…"}):s?d.jsx("p",{className:"text-xs text-red-400",children:"Could not load views."}):!a||a.length===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"None yet. Apply a filter and click “Save view” to add one."}):d.jsx("ul",{className:"space-y-1","aria-label":"Saved views",children:a.map(g=>d.jsxs("li",{className:"group flex items-center rounded-md border border-transparent hover:border-border hover:bg-card",children:[d.jsx(Qe,{to:`/?${Ed(g.filters).toString()}`,className:"block flex-1 truncate px-2 py-1 text-sm text-fg-muted hover:text-accent",children:g.name}),d.jsxs("div",{className:"relative","data-saved-view-menu":!0,children:[d.jsx("button",{type:"button",onClick:()=>p(x=>x===g.id?null:g.id),"aria-label":`Manage saved view ${g.name}`,"aria-haspopup":"menu","aria-expanded":y===g.id,className:"px-2 py-1 text-fg-dim hover:text-accent",children:d.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs",children:"⋯"})}),y===g.id?d.jsxs("div",{role:"menu",className:"absolute right-0 top-full z-30 mt-1 w-48 overflow-hidden rounded-md border border-border bg-card shadow-lg",children:[d.jsx("button",{type:"button",role:"menuitem",disabled:!r,onClick:()=>{p(null),f(g)},className:"block w-full px-3 py-2 text-left text-sm text-fg-muted hover:bg-bg hover:text-accent disabled:cursor-not-allowed disabled:opacity-40",title:r?void 0:"Apply some filters first to update this view.",children:"Update with current filters"}),d.jsx("button",{type:"button",role:"menuitem",onClick:()=>{p(null),c(g)},className:"block w-full px-3 py-2 text-left text-sm text-fg-muted hover:bg-bg hover:text-accent",children:"Rename…"}),d.jsx("button",{type:"button",role:"menuitem",onClick:()=>{p(null),h(g)},className:"block w-full border-t border-border px-3 py-2 text-left text-sm text-red-400 hover:bg-bg",children:"Delete"})]}):null]})]},g.id))})]})}function xA({view:a,existing:l,isSaving:s,onCancel:r,onSave:c}){const[f,h]=S.useState(a.name),y=f.trim(),p=l.some(v=>v.id!==a.id&&v.name.toLowerCase()===y.toLowerCase()),g=y===a.name,x=y.length>0&&!p&&!g&&!s;return d.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-label":"Rename view",children:d.jsxs("div",{className:"w-full max-w-sm rounded-md border border-border bg-card p-5",children:[d.jsx("h3",{className:"mb-3 font-serif text-lg text-fg",children:"Rename view"}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),d.jsx("input",{type:"text",value:f,autoFocus:!0,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&x&&c(y),v.key==="Escape"&&r()},"aria-label":"View name",className:"w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none"})]}),p?d.jsx("p",{className:"mt-2 text-xs text-red-400",children:"A view with that name already exists."}):null,d.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[d.jsx("button",{type:"button",onClick:r,className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),d.jsx("button",{type:"button",onClick:()=>x&&c(y),disabled:!x,className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:s?"Saving…":"Save"})]})]})})}function SA({existing:a,isSaving:l,onCancel:s,onSave:r}){const[c,f]=S.useState(""),h=c.trim(),y=a.some(g=>g.name.toLowerCase()===h.toLowerCase()),p=h.length>0&&!y&&!l;return d.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-label":"Save view",children:d.jsxs("div",{className:"w-full max-w-sm rounded-md border border-border bg-card p-5",children:[d.jsx("h3",{className:"mb-3 font-serif text-lg text-fg",children:"Save view"}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),d.jsx("input",{type:"text",value:c,autoFocus:!0,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&p&&r(h),g.key==="Escape"&&s()},placeholder:"e.g. Daily journal","aria-label":"View name",className:"w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none"})]}),y?d.jsx("p",{className:"mt-2 text-xs text-red-400",children:"A view with that name already exists."}):null,d.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[d.jsx("button",{type:"button",onClick:s,className:"min-h-11 rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),d.jsx("button",{type:"button",onClick:()=>p&&r(h),disabled:!p,className:"min-h-11 rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:l?"Saving…":"Save"})]})]})})}function EA({note:a,pinnedTag:l,archivedTag:s,quickTagSuggestions:r}){const c=a.path??a.id,f=a.updatedAt??a.createdAt,h=(a.tags??[]).includes(l),y=(a.tags??[]).includes(s);return d.jsx("li",{className:y?"opacity-60 italic":void 0,children:d.jsxs("div",{className:"flex items-stretch",children:[d.jsxs(Qe,{to:`/n/${encodeURIComponent(a.id)}`,className:"block flex-1 min-w-0 min-h-11 px-3 py-2.5 hover:bg-bg/60 focus:bg-bg/60 focus:outline-none md:min-h-0 md:px-4 md:py-3",children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[d.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[h?d.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,d.jsx("span",{className:"min-w-0 truncate font-mono text-sm text-fg",children:c})]}),d.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:vb(f)})]}),a.tags&&a.tags.length>0?d.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.tags.map(p=>d.jsxs("span",{className:"max-w-full break-all rounded-full border border-accent/30 bg-accent/10 px-2 py-0.5 text-xs text-accent",children:["#",p]},p))}):null,a.preview?d.jsx("p",{className:"mt-1.5 truncate text-sm text-fg-muted",children:a.preview}):null]}),r?d.jsx("div",{className:"shrink-0 px-3 py-3",children:d.jsx(wA,{noteId:a.id,existing:a.tags??[],suggestions:r})}):null]})})}function wA({noteId:a,existing:l,suggestions:s}){const[r,c]=S.useState(!1),[f,h]=S.useState(""),y=S.useRef(null),p=S.useRef(null),g=IE(a),x=zs(A=>A.push);S.useEffect(()=>{var _;if(!r)return;(_=p.current)==null||_.focus();const A=z=>{var C;(C=y.current)!=null&&C.contains(z.target)||c(!1)},D=z=>{z.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",D)}},[r]);const v=S.useMemo(()=>{const A=Bg(f).toLowerCase(),D=new Set(l.map(z=>z.toLowerCase())),_=s.filter(z=>!D.has(z.name.toLowerCase()));return A?_.filter(z=>z.name.toLowerCase().includes(A)).slice(0,8):_.slice(0,8)},[f,s,l]),E=S.useCallback(async A=>{const D=Bg(A);if(D)try{await g.mutateAsync({tags:{add:[D]}}),x(`Added #${D}`,"success"),h(""),c(!1)}catch(_){x(`Could not add tag: ${_.message}`,"error")}},[g,x]);return r?d.jsxs("div",{ref:y,className:"relative",children:[d.jsx("input",{ref:p,type:"text",value:f,onChange:A=>h(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),E(f))},placeholder:"tag…","aria-label":"Tag name",disabled:g.isPending,className:"w-32 rounded-md border border-border bg-card px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none disabled:opacity-50"}),v.length>0?d.jsx("ul",{className:"absolute right-0 z-20 mt-1 max-h-48 w-44 overflow-y-auto rounded-md border border-border bg-card text-xs shadow-lg","aria-label":"Tag suggestions",children:v.map(A=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:D=>{D.preventDefault(),E(A.name)},className:"flex w-full items-center justify-between px-2 py-1 text-left text-fg hover:bg-bg/60",children:[d.jsx("span",{className:"truncate",children:A.name}),d.jsx("span",{className:"ml-2 shrink-0 text-fg-dim",children:A.count})]})},A.name))}):null]}):d.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md border border-border bg-bg/60 px-2 py-1 text-xs text-fg-muted hover:border-accent hover:text-accent","aria-label":"Add tag",children:"+ tag"})}function TA({pinnedTags:a,tagCounts:l,selected:s,onPick:r}){const c=f=>{var h;return(h=l.find(y=>y.name.toLowerCase()===f.toLowerCase()))==null?void 0:h.count};return a.length===0?d.jsxs("nav",{"aria-label":"Pinned tags",className:"mb-6 flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Pinned tags"}),d.jsxs("span",{className:"text-xs text-fg-dim",children:["Pin tags here for quick access —"," ",d.jsx(Qe,{to:"/tags",className:"text-accent hover:underline",children:"open the tag browser"}),"."]})]}):d.jsxs("nav",{"aria-label":"Pinned tags",className:"mb-6 flex flex-wrap items-center gap-2",children:[d.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Pinned tags"}),a.map(f=>{const h=s.length===1&&s[0]===f,y=c(f);return d.jsxs("button",{type:"button",onClick:()=>r(f),className:h?"inline-flex max-w-full items-center gap-1 rounded-full border border-accent bg-accent px-2.5 py-1 text-xs font-medium text-white":"inline-flex max-w-full items-center gap-1 rounded-full border border-accent/40 bg-accent/10 px-2.5 py-1 text-xs text-accent hover:border-accent hover:bg-accent/20","aria-pressed":h,children:[d.jsxs("span",{className:"min-w-0 break-all",children:["#",f]}),y!==void 0?d.jsx("span",{className:h?"text-white/80":"text-accent/70",children:y}):null]},f)})]})}function AA(){const a=[{to:"/pinned",label:"Pinned",glyph:"★"},{to:"/archived",label:"Archived"},{to:"/untagged",label:"Untagged"},{to:"/orphaned",label:"Orphaned"}];return d.jsxs("aside",{children:[d.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Views"}),d.jsx("ul",{className:"space-y-1",children:a.map(l=>d.jsx("li",{children:d.jsxs(Qe,{to:l.to,className:"flex items-center gap-1.5 truncate rounded-md border border-transparent px-2 py-1 text-sm text-fg-muted hover:border-border hover:bg-card hover:text-accent",children:[l.glyph?d.jsx("span",{className:"shrink-0 text-accent","aria-hidden":"true",children:l.glyph}):null,d.jsx("span",{className:"truncate",children:l.label})]})},l.to))})]})}function NA({tags:a,selected:l,onToggle:s,tagMatch:r,onTagMatchChange:c,onClear:f}){return d.jsxs("details",{className:"rounded-md border border-border bg-card text-sm",children:[d.jsxs("summary",{className:"cursor-pointer list-none px-3 py-2 text-fg-muted hover:text-accent",children:["Tags",l.length>0?` (${l.length})`:""]}),d.jsxs("div",{className:"border-t border-border p-3",children:[l.length>1?d.jsxs("fieldset",{className:"mb-3 flex items-center gap-3 text-xs",children:[d.jsx("legend",{className:"sr-only",children:"Match mode"}),d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"radio",name:"tag-match",value:"any",checked:r==="any",onChange:()=>c("any")}),"Any"]}),d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"radio",name:"tag-match",value:"all",checked:r==="all",onChange:()=>c("all")}),"All"]}),d.jsx("button",{type:"button",onClick:f,className:"ml-auto text-xs text-fg-dim hover:text-accent",children:"Clear"})]}):null,a.length===0?d.jsx("p",{className:"text-xs text-fg-dim",children:"No tags in this vault."}):d.jsx("ul",{className:"max-h-56 space-y-1 overflow-y-auto pr-1",children:a.map(h=>d.jsx("li",{children:d.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg hover:text-accent",children:[d.jsx("input",{type:"checkbox",checked:l.includes(h.name),onChange:()=>s(h.name)}),d.jsx("span",{className:"flex-1 truncate",children:h.name}),d.jsx("span",{className:"text-xs text-fg-dim",children:h.count})]})},h.name))})]})]})}function jA(){return d.jsx("ol",{className:"divide-y divide-border rounded-md border border-border bg-card","aria-busy":"true",children:[0,1,2,3,4].map(a=>d.jsxs("li",{className:"px-4 py-3",children:[d.jsx("div",{className:"h-4 w-1/3 animate-pulse rounded bg-border/60"}),d.jsx("div",{className:"mt-2 h-3 w-2/3 animate-pulse rounded bg-border/40"})]},a))})}function RA({error:a}){const l=a instanceof Nd;return d.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[d.jsx("p",{className:"mb-2 font-medium text-red-400",children:l?"Session expired":"Could not load notes"}),d.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),l?d.jsx(Qe,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}function CA({filtering:a}){return d.jsx("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:a?d.jsx("p",{className:"text-fg-muted",children:"No notes match these filters."}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"mb-3 text-fg-muted",children:"This vault has no notes yet."}),d.jsx(Qe,{to:"/new",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Create one"})]})})}const _A=S.lazy(()=>Mt(()=>import("./Activity-B_Je-lCL.js"),[],import.meta.url).then(a=>({default:a.Activity}))),OA=S.lazy(()=>Mt(()=>import("./AddVault-D0ySEVNg.js"),[],import.meta.url).then(a=>({default:a.AddVault}))),MA=S.lazy(()=>Mt(()=>import("./Calendar-CoPaqJQB.js"),__vite__mapDeps([0,1]),import.meta.url).then(a=>({default:a.Calendar}))),DA=S.lazy(()=>Mt(()=>import("./Import-CrWr1lWO.js"),__vite__mapDeps([2,3]),import.meta.url).then(a=>({default:a.Import}))),UA=S.lazy(()=>Mt(()=>import("./NoteEditor-D-bt-d63.js"),__vite__mapDeps([4,3,5,6,7]),import.meta.url).then(a=>({default:a.NoteEditor}))),zA=S.lazy(()=>Mt(()=>import("./NoteNew-Dw7l1rjo.js"),__vite__mapDeps([8,3,5,7]),import.meta.url).then(a=>({default:a.NoteNew}))),LA=S.lazy(()=>Mt(()=>import("./NoteView-CGGge5Bp.js"),__vite__mapDeps([9,6,7]),import.meta.url).then(a=>({default:a.NoteView}))),VA=S.lazy(()=>Mt(()=>import("./OAuthCallback-D1ql8sDc.js"),[],import.meta.url).then(a=>({default:a.OAuthCallback}))),qA=S.lazy(()=>Mt(()=>import("./Settings-DTa8sOyo.js"),[],import.meta.url).then(a=>({default:a.Settings}))),HA=S.lazy(()=>Mt(()=>import("./Tags-F1LzSPLy.js"),[],import.meta.url).then(a=>({default:a.Tags}))),kA=S.lazy(()=>Mt(()=>import("./Today-HA6so2M2.js"),__vite__mapDeps([10,1]),import.meta.url).then(a=>({default:a.Today}))),BA=S.lazy(()=>Mt(()=>import("./VaultGraph-XMhBSHMZ.js"),[],import.meta.url).then(a=>({default:a.VaultGraph}))),QA=S.lazy(()=>Mt(()=>import("./Vaults-N_zHHUue.js"),[],import.meta.url).then(a=>({default:a.Vaults})));function GA(){return re(l=>l.getActiveVault())?d.jsx(js,{}):d.jsx(K2,{})}function YA(){return d.jsx("output",{"aria-live":"polite",className:"mx-auto block max-w-5xl px-6 py-10 text-center text-sm text-fg-dim",children:"Loading…"})}function Xg({suffix:a=""}){const{id:l}=Lw();return l?d.jsx(Us,{to:`/n/${encodeURIComponent(l)}${a}`,replace:!0}):d.jsx(Us,{to:"/",replace:!0})}function KA(){const a=re(s=>s.activeVaultId),l=ze();return PE(a,l),null}function XA(){return CS(),S.useEffect(()=>{bb(li())},[]),d.jsx(Y2,{children:d.jsxs(gE,{children:[d.jsx(KA,{}),d.jsx(G2,{}),d.jsx(t2,{}),d.jsx(ET,{basename:Yu(),children:d.jsxs("div",{className:"min-h-dvh overflow-x-hidden bg-bg text-fg pb-16 md:pb-0",children:[d.jsx(j2,{}),d.jsx(L2,{}),d.jsx(V2,{}),d.jsx(A2,{}),d.jsx(c2,{}),d.jsx(b2,{}),d.jsx("main",{children:d.jsx(S.Suspense,{fallback:d.jsx(YA,{}),children:d.jsxs(Iw,{children:[d.jsx(Xe,{path:"/",element:d.jsx(GA,{})}),d.jsx(Xe,{path:"/pinned",element:d.jsx(js,{preset:"pinned"})}),d.jsx(Xe,{path:"/archived",element:d.jsx(js,{preset:"archived"})}),d.jsx(Xe,{path:"/untagged",element:d.jsx(js,{preset:"untagged"})}),d.jsx(Xe,{path:"/orphaned",element:d.jsx(js,{preset:"orphaned"})}),d.jsx(Xe,{path:"/tags",element:d.jsx(HA,{})}),d.jsx(Xe,{path:"/new",element:d.jsx(zA,{})}),d.jsx(Xe,{path:"/capture",element:d.jsx(Us,{to:"/new",replace:!0})}),d.jsx(Xe,{path:"/import",element:d.jsx(DA,{})}),d.jsx(Xe,{path:"/graph",element:d.jsx(BA,{})}),d.jsx(Xe,{path:"/today",element:d.jsx(kA,{})}),d.jsx(Xe,{path:"/calendar",element:d.jsx(MA,{})}),d.jsx(Xe,{path:"/activity",element:d.jsx(_A,{})}),d.jsx(Xe,{path:"/n/:id",element:d.jsx(LA,{})}),d.jsx(Xe,{path:"/n/:id/edit",element:d.jsx(UA,{})}),d.jsx(Xe,{path:"/:id",element:d.jsx(Xg,{})}),d.jsx(Xe,{path:"/:id/edit",element:d.jsx(Xg,{suffix:"/edit"})}),d.jsx(Xe,{path:"/add",element:d.jsx(OA,{})}),d.jsx(Xe,{path:"/oauth/callback",element:d.jsx(VA,{})}),d.jsx(Xe,{path:"/vaults",element:d.jsx(QA,{})}),d.jsx(Xe,{path:"/settings",element:d.jsx(qA,{})}),d.jsx(Xe,{path:"*",element:d.jsx(Us,{to:"/",replace:!0})})]})})}),d.jsx(DT,{}),d.jsx("footer",{className:"mx-auto max-w-5xl px-6 py-10 text-center text-sm text-fg-dim",children:d.jsxs("p",{children:["Part of the"," ",d.jsx("a",{href:"https://parachute.computer",className:"text-accent hover:underline",children:"Parachute Computer"})," ","ecosystem. AGPL-3.0."]})})]})})]})})}var qf={exports:{}},As={},Hf={exports:{}},kf={};/**
31
31
  * @license React
32
32
  * scheduler.production.js
33
33
  *
@@ -1,4 +1,4 @@
1
- import{z as at,R as xo,r as bo}from"./index-D27iivhA.js";function wo(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function ko(e,n,r){return n=Eo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Jn(e,n){return So(e)||wo(e,n)||ui(e,n)||Po()}function Ao(e){return Co(e)||Mo(e)||ui(e)||To()}function Co(e){if(Array.isArray(e))return gn(e)}function So(e){if(Array.isArray(e))return e}function Mo(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ui(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function To(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{z as at,R as xo,r as bo}from"./index-953EjlvE.js";function wo(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function ko(e,n,r){return n=Eo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Jn(e,n){return So(e)||wo(e,n)||ui(e,n)||Po()}function Ao(e){return Co(e)||Mo(e)||ui(e)||To()}function Co(e){if(Array.isArray(e))return gn(e)}function So(e){if(Array.isArray(e))return e}function Mo(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ui(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function To(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Po(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oo(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Eo(e){var n=Oo(e,"string");return typeof n=="symbol"?n:String(n)}var zo=function(n,r){var i=new Set(r);return Object.assign.apply(Object,[{}].concat(Ao(Object.entries(n).filter(function(o){var a=Jn(o,1),s=a[0];return!i.has(s)}).map(function(o){var a=Jn(o,2),s=a[0],u=a[1];return ko({},s,u)}))))};function yn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Ro(e){if(Array.isArray(e))return e}function No(e){if(Array.isArray(e))return yn(e)}function Io(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $o(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n!==0)for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Do(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.