@openparachute/app 0.22.15-rc.10 → 0.22.15-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.parachute/info +1 -1
- package/dist/assets/{Account-swGtRHMG.js → Account-DEYVoMoJ.js} +1 -1
- package/dist/assets/{Activity-DqATw0MI.js → Activity-mwytxPNJ.js} +1 -1
- package/dist/assets/{AddVault-DzWUz455.js → AddVault-BC71qUe3.js} +1 -1
- package/dist/assets/{AddVaultChooser-B1jzKG-t.js → AddVaultChooser-D-LzqkAN.js} +1 -1
- package/dist/assets/{AddVaultCreate-B-j5LVp9.js → AddVaultCreate-cUJzJon_.js} +1 -1
- package/dist/assets/{AttachmentDropZone-CzgcMV7T.js → AttachmentDropZone-r67Wn9ZU.js} +1 -1
- package/dist/assets/{Calendar-zQafWugR.js → Calendar-BZiRxWki.js} +1 -1
- package/dist/assets/{CheckEmail-D4TCxZd7.js → CheckEmail-Bw9wXkVS.js} +1 -1
- package/dist/assets/{CodeMirrorEditor-BnznJpMz.js → CodeMirrorEditor-_eWRBxXN.js} +1 -1
- package/dist/assets/{ConnectAI-KGoTTsXp.js → ConnectAI-BmhVusz5.js} +1 -1
- package/dist/assets/{DayView-Ug9egl72.js → DayView-GPiVliec.js} +1 -1
- package/dist/assets/{Export-B6wbB97C.js → Export-9D1zURrv.js} +1 -1
- package/dist/assets/{Import-Dy-8gPze.js → Import-BDTtRgEn.js} +1 -1
- package/dist/assets/{NoteEditor-D2oey5kr.js → NoteEditor-ASh32-CL.js} +1 -1
- package/dist/assets/{NoteNew-DFMQqrED.js → NoteNew-BaOqPDVW.js} +1 -1
- package/dist/assets/{NoteView-YO--Ct_W.js → NoteView-g7deWvHN.js} +2 -2
- package/dist/assets/{OAuthCallback-6-Ru25uL.js → OAuthCallback-urWNIti8.js} +1 -1
- package/dist/assets/{PinArchiveButtons-DMk8dR6_.js → PinArchiveButtons-DTlqcgy0.js} +1 -1
- package/dist/assets/Settings-dg5_eEea.js +1 -0
- package/dist/assets/{TagPage-TurksmHr.js → TagPage-Bnv4e0W-.js} +1 -1
- package/dist/assets/{TagSchemaEditor-d8Gt9M7O.js → TagSchemaEditor-C8BTBwE4.js} +1 -1
- package/dist/assets/{Tags-DSAIBoMC.js → Tags-D04DnSWr.js} +1 -1
- package/dist/assets/{VaultGraph-DRSd7Fof.js → VaultGraph-BF7wEVTJ.js} +2 -2
- package/dist/assets/{Vaults-4Zo7WC0E.js → Vaults-DV9IgHfW.js} +1 -1
- package/dist/assets/{ViewNew-Cf3YCCTn.js → ViewNew-CZg-wYOy.js} +1 -1
- package/dist/assets/{ViewSurface-CM7X_iqR.js → ViewSurface-DDodj1af.js} +1 -1
- package/dist/assets/{Welcome-DIKfY5s1.js → Welcome-pAh2PeSb.js} +1 -1
- package/dist/assets/{WizardShell-BYKUWpUi.js → WizardShell-BBYxknp4.js} +1 -1
- package/dist/assets/{attachment-upload-DLDY4BEF.js → attachment-upload-DmLh-U0Q.js} +1 -1
- package/dist/assets/{history-B8p5wZFj.js → history-B0uaXgK5.js} +1 -1
- package/dist/assets/index-DFrgKlHJ.js +66 -0
- package/dist/assets/{provenance-D15pfwZ8.js → provenance-D3sV-zhJ.js} +1 -1
- package/dist/assets/{react-force-graph-2d-DkyGio7A.js → react-force-graph-2d-f0d26obG.js} +1 -1
- package/dist/assets/{transcribe-default-Dnuz0XK2.js → transcribe-default-hcnFAy9n.js} +1 -1
- package/dist/assets/{useAttachmentUploader-D7cwbDHc.js → useAttachmentUploader-t93QVRf6.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/meta.json +1 -1
- package/package.json +1 -1
- package/dist/assets/Settings-qu96onYA.js +0 -1
- package/dist/assets/index-CRiaLzYD.js +0 -66
package/dist/.parachute/info
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as d,L as j,d as G,u as N,c as C,a as H,l as _,b as E,v as W,i as J,e as A,g as Q,f as z,s as K,m as X,h as Z,I as D,k as ee,n as te,o as ne,p as L,q as se,t as T,O as ae,w as re,x as le,y as ie,z as O,S as R,A as oe,B as ce}from"./index-CRiaLzYD.js";import{f as ue,a as $}from"./provenance-D15pfwZ8.js";function de(t,n){return t.trim().toLowerCase()===n.trim().toLowerCase()}const me={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"};function B(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,me)}const he={byCode:{confirm_mismatch:"That doesn't match your account email.",already_deleting:"This account is already being deleted. Check your email for the undo link."},sessionEnded:"Your sign-in has ended. Sign in again, then come back here to delete your account.",fallback:"Couldn't delete your account. Nothing has changed. Try again."};function xe(t){return typeof t=="string"&&(/^https?:\/\//i.test(t)||t.startsWith("/"))}function fe(t){const{vaults:n,removeVault:s}=E.getState();for(const a of Object.values(n)){const r=W(a.url)??a.name;J(a)&&t.has(r)&&s(a.id)}}async function ge(){try{const t=await _();return new Set((Array.isArray(t==null?void 0:t.vaults)?t.vaults:[]).map(n=>n.name))}catch{return new Set}}function pe({email:t,descriptor:n,onDeleted:s}){var a;return((a=n==null?void 0:n.capabilities)==null?void 0:a.account_delete)!==!0||!t?null:e.jsx(ye,{email:t,onDeleted:s})}function ye({email:t,onDeleted:n}){const s=d.useId(),[a,r]=d.useState(""),[l,u]=d.useState(!1),[i,m]=d.useState(null),x=de(a,t);async function y(o){if(o.preventDefault(),!(!x||l)){u(!0),m(null);try{const c=await ge(),g=await G(a.trim());N.getState().markClosed(),C(),fe(c),n(g)}catch(c){m(H(c,he))}finally{u(!1)}}}return e.jsxs("section",{"aria-label":"Delete account",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Delete account"}),e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mt-2 text-sm text-fg-muted",children:["Your account closes now and you're signed out everywhere. Everything is erased after 24 hours: your vaults, notes, files, snapshots and exports. Until then the email we send has an undo link."," ",e.jsx(j,{to:"/export",className:"focus-ring text-accent underline",children:"Export first"})," ","if you want a copy."]}),e.jsxs("form",{onSubmit:y,className:"mt-4 space-y-3",children:[e.jsx("label",{htmlFor:s,className:"block text-sm font-medium text-fg",children:"Type your account email to confirm"}),e.jsx("input",{id:s,type:"email",value:a,onChange:o=>r(o.target.value),autoComplete:"off",spellCheck:!1,placeholder:t,className:"input"}),e.jsx("button",{type:"submit",disabled:!x||l,className:"btn btn-danger-solid btn-touch",children:l?"Deleting…":"Delete my account"})]}),i?e.jsx("p",{role:"alert",className:"mt-4 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:i}):null]})]})}function be({done:t,onDone:n}){return e.jsxs("section",{"aria-label":"Account closed",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Account closed"}),e.jsxs("div",{className:"mt-2 space-y-4",children:[t.notice_sent===!1&&xe(t.undo_url)?e.jsxs("output",{className:"block text-sm text-fg-muted",children:["Your account is closed. We couldn't send the email with the undo link, so here it is:"," ",e.jsx("a",{href:t.undo_url,className:"focus-ring text-accent underline",children:"undo the deletion"}),". It works for 24 hours, until ",B(t.undo_expires_at),"."]}):e.jsxs("output",{className:"block text-sm text-fg-muted",children:["Your account is closed. We sent an email with an undo link; it works for 24 hours, until"," ",B(t.undo_expires_at),"."]}),e.jsx("button",{type:"button",onClick:n,className:"btn btn-primary btn-touch",children:"Done"})]})]})}const S="lens:account_deleted";function je(){try{const t=sessionStorage.getItem(S),n=t?JSON.parse(t):null;return n&&typeof n.undo_expires_at=="string"?n:null}catch{return null}}function ve(t){try{if(t){const{undo_token:n,...s}=t;sessionStorage.setItem(S,JSON.stringify(s))}else sessionStorage.removeItem(S)}catch{}}function Ye(){const[t,n]=d.useState({kind:"loading"}),[s,a]=d.useState(je),r=d.useCallback(i=>{ve(i),a(i)},[]),l=A(),u=N(i=>i.identityEpoch);return d.useEffect(()=>{let i=!0;return(async()=>{let m;try{m=await Q()}catch{i&&n({kind:"device"});return}i&&n(m.signed_in?{kind:"manager",email:m.email,username:m.username,csrf:m.csrf}:{kind:"device"})})(),()=>{i=!1}},[u]),e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"page-title",children:"Your parachute"}),e.jsx("p",{className:"mt-2 max-w-prose text-fg-muted",children:"Your account, plan, vaults, and connections — managed here."})]}),s?e.jsx(be,{done:s,onDone:()=>{r(null),C(),l("/",{replace:!0})}}):t.kind==="loading"?e.jsx("output",{"aria-live":"polite",className:"block py-10 text-center text-sm text-fg-dim",children:e.jsx("span",{className:"animate-pulse",children:"Loading your account…"})}):t.kind==="device"?e.jsx(Re,{}):e.jsx(Ne,{email:t.email,username:t.username,csrf:t.csrf,onDeleted:r})]})}function Ne({email:t,username:n,csrf:s,onDeleted:a}){const r=A(),l=E(f=>f.getActiveVault()),u=N(f=>f.identityEpoch),i=z(),m=i.isPending?"loading":i.data??null,x=K(i.data),y=d.useCallback(()=>i.refetch(),[i.refetch]),[o,c]=d.useState("loading"),[g,h]=d.useState(null);d.useEffect(()=>{let f=!0;return _().then(v=>{f&&c(v.vaults)}).catch(v=>{X(v),f&&c("error")}),Z().then(v=>{f&&h(v)}),()=>{f=!1}},[u]);const p=d.useCallback(async()=>{try{const{vaults:f}=await _();c(f)}catch{c("error")}},[]);async function b(){try{await ne(s)}finally{C(),r("/",{replace:!0})}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx(we,{email:t,username:n,summary:x,onSignOut:b}),e.jsx(_e,{state:m,descriptor:g,onRetry:y,retrying:i.isFetching}),e.jsx(Le,{vaults:o,summary:x,onReload:p}),e.jsx(U,{hasActiveVault:!!l}),e.jsx(pe,{email:t,descriptor:g,onDeleted:a})]})}function we({email:t,username:n,summary:s,onSignOut:a}){return e.jsx("section",{"aria-label":"Account",className:"card p-6 shadow-soft",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"eyebrow mb-1",children:"Signed in as"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("p",{className:"break-words font-serif text-xl text-fg",children:t??n??"your account"}),e.jsx(ke,{summary:s})]})]}),e.jsx("button",{type:"button",onClick:a,className:"focus-ring shrink-0 text-sm text-fg-dim hover:text-accent",children:"Sign out"})]})})}function ke({summary:t}){if(!t)return null;const n=T(t);return typeof n=="number"?e.jsxs("span",{className:"chip border-transparent bg-sun-soft font-medium text-sun-ink",children:["Free trial · ",n===0?"ends today":`${n} day${n===1?"":"s"} left`]}):e.jsx("span",{className:"chip",children:t.plan.label})}function _e({state:t,descriptor:n,onRetry:s,retrying:a}){if(t===null)return null;const r=t!=="loading"&&t!=="error"&&L(t);if(t!=="loading"&&t!=="error"&&!t.billing_enabled&&!r)return null;const u=t!=="loading"&&t!=="error"&&(r?P(t):t.billing_enabled)?"Plan & billing":"Your plan";return e.jsxs("section",{"aria-label":u,className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:u}),t==="loading"?e.jsxs("div",{"aria-busy":"true",className:"mt-4 space-y-2.5",children:[e.jsx("div",{className:"skeleton h-4 w-3/5 rounded-md"}),e.jsx("div",{className:"skeleton h-4 w-2/5 rounded-md"})]}):t==="error"?e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"Couldn't load your plan."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"A hiccup reaching your account — your plan hasn't changed."}),e.jsx("button",{type:"button",onClick:s,disabled:a,className:"btn btn-primary btn-touch",children:a?"Retrying…":"Retry"})]}):r?e.jsx(Se,{summary:t}):t.has_billing_customer?e.jsx(Ee,{summary:t}):e.jsx(Ve,{summary:t,plans:(n==null?void 0:n.plans)??[]})]})}function Se({summary:t}){const n=P(t);return e.jsxs("div",{className:"mt-4","data-testid":"open-beta-plan",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),e.jsx("p",{className:"mt-3 text-sm text-fg",children:ae}),n?e.jsx(M,{}):null]})}const Ce=new Set(["entry","standard","plus","power"]);function P(t){return t.has_billing_customer&&Ce.has(t.plan.tier)}function Ee({summary:t}){return e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),e.jsx(M,{})]})}function M(){const[t,n]=d.useState(!1),[s,a]=d.useState(null);async function r(){n(!0),a(null);try{const{url:l}=await oe();window.location.assign(l)}catch(l){if(n(!1),l instanceof R){N.getState().markExpired();return}a("Billing isn't available right now.")}}return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:r,disabled:t,className:"btn btn-primary btn-touch mt-4",children:t?"Opening…":"Manage plan & billing ↗"}),s?e.jsx(F,{text:s}):null]})}const w=["monthly","quarterly","yearly"],V={monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly"},Ae={monthly:"/mo",quarterly:"/quarter",yearly:"/yr"},Ie={monthly:1,quarterly:3,yearly:12};function De(t){var s,a;const n=new Set;for(const r of t)for(const l of w)(a=(s=r.intervals)==null?void 0:s[l])!=null&&a.available&&n.add(l);return w.filter(r=>n.has(r))}function Y(t,n){return t.label?t.label:typeof t.price=="number"?`$${t.price}${Ae[n]}`:null}function Oe(t){var n;for(const s of w){const a=(n=t.intervals)==null?void 0:n[s];if(a!=null&&a.available)return{interval:s,entry:a}}return null}function $e(t,n){if(!n||!t.intervals)return typeof t.price_month=="number"?`$${t.price_month}/mo`:null;const s=[];let a=!1,r=null;for(const u of w){const i=t.intervals[u];if(!(i!=null&&i.available))continue;u==="monthly"&&(a=!0);const m=Y(i,u);if(m&&s.push(m),typeof i.price=="number"){const x=i.price/Ie[u];r=r===null?x:Math.min(r,x)}}if(s.length===0)return null;const l=s.join(" · ");return a||r===null?l:`${l} — about $${Math.max(1,Math.round(r))}/mo`}function Be(t){if(t instanceof ce)switch(t.code){case"already_subscribed":return"You're already subscribed — refresh to see your plan.";case"invalid_plan":case"invalid_interval":case"invalid_tier":return"That plan isn't offered on this cycle — pick another."}return"Billing isn't available right now."}function F({text:t}){return e.jsx("p",{className:"mt-3 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:t})}function Ve({summary:t,plans:n}){const s=De(n),[a,r]=d.useState(null),l=a!==null&&s.includes(a)?a:s[0]??null,[u,i]=d.useState(null),[m,x]=d.useState(null);async function y(o){if(!u){i(o),x(null);try{const{url:c}=l?await O(o,l):await O(o);window.location.assign(c)}catch(c){if(i(null),c instanceof R){N.getState().markExpired();return}x(Be(c))}}}return e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),l&&s.length>1?e.jsxs("fieldset",{className:"mt-4 flex flex-wrap items-center gap-1.5",children:[e.jsx("legend",{className:"sr-only",children:"Billing interval"}),s.map(o=>{const c=o===l;return e.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":c,className:`chip focus-ring ${c?"chip-tag-active font-medium":"chip-tag"}`,children:V[o]},o)})]}):null,n.length>0?e.jsx("ul",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:n.map(o=>{var f;const c=o.id===t.plan.tier,g=l?(f=o.intervals)==null?void 0:f[l]:void 0,h=s.length===0||(g==null?void 0:g.available)===!0,p=$e(o,s.length>0),b=h?null:Oe(o);return e.jsxs("li",{className:"rounded-xl border border-border bg-bg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:o.name}),c?e.jsx("span",{className:"chip",children:"Current"}):null]}),p?e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:p}):null,typeof o.vaults=="number"?e.jsxs("p",{className:"mt-0.5 text-xs text-fg-dim",children:[o.vaults," vault",o.vaults===1?"":"s"]}):null,c?null:h?e.jsx("button",{type:"button",onClick:()=>y(o.id),disabled:u!==null,className:"btn btn-primary btn-sm btn-touch mt-3 w-full",children:u===o.id?"Starting…":`Upgrade to ${o.name}`}):e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",disabled:!0,className:"btn btn-secondary btn-sm btn-touch w-full",children:["Not available"," ",V[l].toLowerCase()]}),b?e.jsxs("p",{className:"mt-1 text-xs text-fg-dim",children:["Available from ",Y(b.entry,b.interval)]}):null]})]},o.id)})}):null,m?e.jsx(F,{text:m}):null]})}function I(t){const{plan:n}=t,s=[n.label],a=T(t);a!==null?s.push(`${a} day${a===1?"":"s"} left`):typeof n.price_monthly_usd=="number"&&n.price_monthly_usd>0&&s.push(`$${n.price_monthly_usd}/mo`),typeof n.vault_limit=="number"&&typeof n.vaults_used=="number"&&s.push(`${n.vaults_used} of ${n.vault_limit} vaults`);const r=$(n.storage_used_bytes??0);if(r){const l=n.storage_limit_bytes?$(n.storage_limit_bytes):null;s.push(l?`${r} of ${l}`:r)}return s.join(" · ")}function Le({vaults:t,summary:n,onReload:s}){const a=A(),[r,l]=d.useState(null),[u,i]=d.useState(null),[m,x]=d.useState(!1);async function y(h){if(!r){l(h.name),i(null);try{await re(h.name),le(h.name),a("/")}catch(p){l(null),i(ie(p,"Couldn't open that vault."))}}}async function o(){x(!0);try{await s()}finally{x(!1)}}const c=n==null?void 0:n.plan,g=c&&typeof c.vault_limit=="number"&&typeof c.vaults_used=="number"?`${c.vaults_used} of ${c.vault_limit} ${L(n)?"in the open beta":"on your plan"}`:null;return e.jsxs("section",{"aria-label":"Your vaults",className:"card p-6 shadow-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Your vaults"}),g?e.jsx("span",{className:"text-xs text-fg-muted",children:g}):null]}),t==="loading"?e.jsxs("div",{"aria-busy":"true",className:"mt-4 space-y-2.5",children:[e.jsx("div",{className:"skeleton h-9 rounded-lg"}),e.jsx("div",{className:"skeleton h-9 w-4/5 rounded-lg"})]}):t==="error"?e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"Couldn't load your vaults."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"A hiccup reaching your account — nothing's lost, your vaults are safe."}),e.jsx("button",{type:"button",onClick:o,disabled:m,className:"btn btn-primary btn-touch",children:m?"Retrying…":"Retry"})]}):t.length===0?e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Create your first — a private home for your notes, always yours to export."}),e.jsx(j,{to:"/add-vault/create",className:"btn btn-primary btn-touch",children:"Create a vault"})]}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"mt-3 divide-y divide-border-light",children:t.map(h=>{const p=ue(h.usage),b=se(h.name).replace(/^https?:\/\//,"");return e.jsxs("li",{className:"flex items-center gap-3 py-3",children:[e.jsx(Te,{name:h.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-serif text-lg leading-snug text-fg",children:h.name}),e.jsx("p",{className:"mt-0.5 truncate note-id",children:b}),p?e.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:p}):null]}),e.jsx("button",{type:"button",onClick:()=>y(h),disabled:r===h.name,className:"btn btn-primary btn-sm btn-touch shrink-0",children:r===h.name?"Opening…":"Open →"})]},h.name)})}),e.jsx("p",{className:"mt-3 border-t border-border-light pt-3 text-sm",children:e.jsx(j,{to:"/add-vault",className:"focus-ring font-semibold text-accent hover:underline",children:"+ Add a vault"})})]}),u?e.jsx("p",{className:"mt-4 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:u}):null]})}function Te({name:t}){const n=(t.trim()[0]??"?").toUpperCase();return e.jsx("span",{"aria-hidden":!0,className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-grass-soft text-sm font-semibold text-grass-ink",children:n})}function U({hasActiveVault:t}){return e.jsxs("section",{"aria-label":"Connections",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Connections"}),e.jsxs("div",{className:"mt-2 divide-y divide-border-light",children:[t?e.jsx(k,{to:"/connect",tone:"sky",icon:e.jsx(D,{width:18,height:18}),title:"Connect your AI",description:"Claude, ChatGPT, or any MCP client — one memory, shared."}):e.jsxs("div",{className:"-mx-2 flex items-center gap-3 px-2 py-3 opacity-60",children:[e.jsx(q,{tone:"sky",children:e.jsx(D,{width:18,height:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-fg",children:"Connect your AI"}),e.jsx("p",{className:"mt-0.5 text-sm text-fg-muted",children:"Open a vault above to connect an AI to it."})]})]}),e.jsx(k,{to:"/import",tone:"grass",icon:e.jsx(ee,{width:18,height:18}),title:"Import notes",description:"Bring your notes over from anywhere markdown lives."}),e.jsx(k,{to:"/export",tone:"sun",icon:e.jsx(te,{width:18,height:18}),title:"Export notes",description:"Download your vault as open Markdown — yours to keep."})]})]})}function k({to:t,tone:n,icon:s,title:a,description:r}){return e.jsxs(j,{to:t,className:"focus-ring -mx-2 flex items-center gap-3 rounded-lg px-2 py-3 hover:bg-bg-soft",children:[e.jsx(q,{tone:n,children:s}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium text-fg",children:a}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:r})]}),e.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-lg text-fg-dim",children:"›"})]})}function q({tone:t,children:n}){const s=t==="grass"?"bg-grass-soft text-grass-ink":t==="sun"?"bg-sun-soft text-sun-ink":"bg-bg-soft";return e.jsx("span",{"aria-hidden":!0,className:`grid h-10 w-10 shrink-0 place-items-center rounded-full ${s}`,style:t==="sky"?{color:"var(--color-sky)"}:void 0,children:n})}function Re(){const t=E(s=>s.vaults),n=Object.values(t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"This device"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"You're managing the vaults connected on this device. Sign in to your account to manage your plan and hosted vaults from anywhere."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsx(j,{to:"/",className:"btn btn-primary btn-touch",children:"Sign in"}),e.jsx(j,{to:"/vaults",className:"btn btn-ghost btn-touch",children:n.length>0?`${n.length} connected`:"Connect a vault"})]})]}),e.jsx(U,{hasActiveVault:n.length>0})]})}export{Ye as Account};
|
|
1
|
+
import{j as e,r as d,L as j,d as G,u as N,c as C,a as H,l as _,b as E,v as W,i as J,e as A,g as Q,f as z,s as K,m as X,h as Z,I as D,k as ee,n as te,o as ne,p as L,q as se,t as T,O as ae,w as re,x as le,y as ie,z as O,S as R,A as oe,B as ce}from"./index-DFrgKlHJ.js";import{f as ue,a as $}from"./provenance-D3sV-zhJ.js";function de(t,n){return t.trim().toLowerCase()===n.trim().toLowerCase()}const me={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"};function B(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,me)}const he={byCode:{confirm_mismatch:"That doesn't match your account email.",already_deleting:"This account is already being deleted. Check your email for the undo link."},sessionEnded:"Your sign-in has ended. Sign in again, then come back here to delete your account.",fallback:"Couldn't delete your account. Nothing has changed. Try again."};function xe(t){return typeof t=="string"&&(/^https?:\/\//i.test(t)||t.startsWith("/"))}function fe(t){const{vaults:n,removeVault:s}=E.getState();for(const a of Object.values(n)){const r=W(a.url)??a.name;J(a)&&t.has(r)&&s(a.id)}}async function ge(){try{const t=await _();return new Set((Array.isArray(t==null?void 0:t.vaults)?t.vaults:[]).map(n=>n.name))}catch{return new Set}}function pe({email:t,descriptor:n,onDeleted:s}){var a;return((a=n==null?void 0:n.capabilities)==null?void 0:a.account_delete)!==!0||!t?null:e.jsx(ye,{email:t,onDeleted:s})}function ye({email:t,onDeleted:n}){const s=d.useId(),[a,r]=d.useState(""),[l,u]=d.useState(!1),[i,m]=d.useState(null),x=de(a,t);async function y(o){if(o.preventDefault(),!(!x||l)){u(!0),m(null);try{const c=await ge(),g=await G(a.trim());N.getState().markClosed(),C(),fe(c),n(g)}catch(c){m(H(c,he))}finally{u(!1)}}}return e.jsxs("section",{"aria-label":"Delete account",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Delete account"}),e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mt-2 text-sm text-fg-muted",children:["Your account closes now and you're signed out everywhere. Everything is erased after 24 hours: your vaults, notes, files, snapshots and exports. Until then the email we send has an undo link."," ",e.jsx(j,{to:"/export",className:"focus-ring text-accent underline",children:"Export first"})," ","if you want a copy."]}),e.jsxs("form",{onSubmit:y,className:"mt-4 space-y-3",children:[e.jsx("label",{htmlFor:s,className:"block text-sm font-medium text-fg",children:"Type your account email to confirm"}),e.jsx("input",{id:s,type:"email",value:a,onChange:o=>r(o.target.value),autoComplete:"off",spellCheck:!1,placeholder:t,className:"input"}),e.jsx("button",{type:"submit",disabled:!x||l,className:"btn btn-danger-solid btn-touch",children:l?"Deleting…":"Delete my account"})]}),i?e.jsx("p",{role:"alert",className:"mt-4 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:i}):null]})]})}function be({done:t,onDone:n}){return e.jsxs("section",{"aria-label":"Account closed",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Account closed"}),e.jsxs("div",{className:"mt-2 space-y-4",children:[t.notice_sent===!1&&xe(t.undo_url)?e.jsxs("output",{className:"block text-sm text-fg-muted",children:["Your account is closed. We couldn't send the email with the undo link, so here it is:"," ",e.jsx("a",{href:t.undo_url,className:"focus-ring text-accent underline",children:"undo the deletion"}),". It works for 24 hours, until ",B(t.undo_expires_at),"."]}):e.jsxs("output",{className:"block text-sm text-fg-muted",children:["Your account is closed. We sent an email with an undo link; it works for 24 hours, until"," ",B(t.undo_expires_at),"."]}),e.jsx("button",{type:"button",onClick:n,className:"btn btn-primary btn-touch",children:"Done"})]})]})}const S="lens:account_deleted";function je(){try{const t=sessionStorage.getItem(S),n=t?JSON.parse(t):null;return n&&typeof n.undo_expires_at=="string"?n:null}catch{return null}}function ve(t){try{if(t){const{undo_token:n,...s}=t;sessionStorage.setItem(S,JSON.stringify(s))}else sessionStorage.removeItem(S)}catch{}}function Ye(){const[t,n]=d.useState({kind:"loading"}),[s,a]=d.useState(je),r=d.useCallback(i=>{ve(i),a(i)},[]),l=A(),u=N(i=>i.identityEpoch);return d.useEffect(()=>{let i=!0;return(async()=>{let m;try{m=await Q()}catch{i&&n({kind:"device"});return}i&&n(m.signed_in?{kind:"manager",email:m.email,username:m.username,csrf:m.csrf}:{kind:"device"})})(),()=>{i=!1}},[u]),e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"page-title",children:"Your parachute"}),e.jsx("p",{className:"mt-2 max-w-prose text-fg-muted",children:"Your account, plan, vaults, and connections — managed here."})]}),s?e.jsx(be,{done:s,onDone:()=>{r(null),C(),l("/",{replace:!0})}}):t.kind==="loading"?e.jsx("output",{"aria-live":"polite",className:"block py-10 text-center text-sm text-fg-dim",children:e.jsx("span",{className:"animate-pulse",children:"Loading your account…"})}):t.kind==="device"?e.jsx(Re,{}):e.jsx(Ne,{email:t.email,username:t.username,csrf:t.csrf,onDeleted:r})]})}function Ne({email:t,username:n,csrf:s,onDeleted:a}){const r=A(),l=E(f=>f.getActiveVault()),u=N(f=>f.identityEpoch),i=z(),m=i.isPending?"loading":i.data??null,x=K(i.data),y=d.useCallback(()=>i.refetch(),[i.refetch]),[o,c]=d.useState("loading"),[g,h]=d.useState(null);d.useEffect(()=>{let f=!0;return _().then(v=>{f&&c(v.vaults)}).catch(v=>{X(v),f&&c("error")}),Z().then(v=>{f&&h(v)}),()=>{f=!1}},[u]);const p=d.useCallback(async()=>{try{const{vaults:f}=await _();c(f)}catch{c("error")}},[]);async function b(){try{await ne(s)}finally{C(),r("/",{replace:!0})}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx(we,{email:t,username:n,summary:x,onSignOut:b}),e.jsx(_e,{state:m,descriptor:g,onRetry:y,retrying:i.isFetching}),e.jsx(Le,{vaults:o,summary:x,onReload:p}),e.jsx(U,{hasActiveVault:!!l}),e.jsx(pe,{email:t,descriptor:g,onDeleted:a})]})}function we({email:t,username:n,summary:s,onSignOut:a}){return e.jsx("section",{"aria-label":"Account",className:"card p-6 shadow-soft",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"eyebrow mb-1",children:"Signed in as"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("p",{className:"break-words font-serif text-xl text-fg",children:t??n??"your account"}),e.jsx(ke,{summary:s})]})]}),e.jsx("button",{type:"button",onClick:a,className:"focus-ring shrink-0 text-sm text-fg-dim hover:text-accent",children:"Sign out"})]})})}function ke({summary:t}){if(!t)return null;const n=T(t);return typeof n=="number"?e.jsxs("span",{className:"chip border-transparent bg-sun-soft font-medium text-sun-ink",children:["Free trial · ",n===0?"ends today":`${n} day${n===1?"":"s"} left`]}):e.jsx("span",{className:"chip",children:t.plan.label})}function _e({state:t,descriptor:n,onRetry:s,retrying:a}){if(t===null)return null;const r=t!=="loading"&&t!=="error"&&L(t);if(t!=="loading"&&t!=="error"&&!t.billing_enabled&&!r)return null;const u=t!=="loading"&&t!=="error"&&(r?P(t):t.billing_enabled)?"Plan & billing":"Your plan";return e.jsxs("section",{"aria-label":u,className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:u}),t==="loading"?e.jsxs("div",{"aria-busy":"true",className:"mt-4 space-y-2.5",children:[e.jsx("div",{className:"skeleton h-4 w-3/5 rounded-md"}),e.jsx("div",{className:"skeleton h-4 w-2/5 rounded-md"})]}):t==="error"?e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"Couldn't load your plan."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"A hiccup reaching your account — your plan hasn't changed."}),e.jsx("button",{type:"button",onClick:s,disabled:a,className:"btn btn-primary btn-touch",children:a?"Retrying…":"Retry"})]}):r?e.jsx(Se,{summary:t}):t.has_billing_customer?e.jsx(Ee,{summary:t}):e.jsx(Ve,{summary:t,plans:(n==null?void 0:n.plans)??[]})]})}function Se({summary:t}){const n=P(t);return e.jsxs("div",{className:"mt-4","data-testid":"open-beta-plan",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),e.jsx("p",{className:"mt-3 text-sm text-fg",children:ae}),n?e.jsx(M,{}):null]})}const Ce=new Set(["entry","standard","plus","power"]);function P(t){return t.has_billing_customer&&Ce.has(t.plan.tier)}function Ee({summary:t}){return e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),e.jsx(M,{})]})}function M(){const[t,n]=d.useState(!1),[s,a]=d.useState(null);async function r(){n(!0),a(null);try{const{url:l}=await oe();window.location.assign(l)}catch(l){if(n(!1),l instanceof R){N.getState().markExpired();return}a("Billing isn't available right now.")}}return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:r,disabled:t,className:"btn btn-primary btn-touch mt-4",children:t?"Opening…":"Manage plan & billing ↗"}),s?e.jsx(F,{text:s}):null]})}const w=["monthly","quarterly","yearly"],V={monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly"},Ae={monthly:"/mo",quarterly:"/quarter",yearly:"/yr"},Ie={monthly:1,quarterly:3,yearly:12};function De(t){var s,a;const n=new Set;for(const r of t)for(const l of w)(a=(s=r.intervals)==null?void 0:s[l])!=null&&a.available&&n.add(l);return w.filter(r=>n.has(r))}function Y(t,n){return t.label?t.label:typeof t.price=="number"?`$${t.price}${Ae[n]}`:null}function Oe(t){var n;for(const s of w){const a=(n=t.intervals)==null?void 0:n[s];if(a!=null&&a.available)return{interval:s,entry:a}}return null}function $e(t,n){if(!n||!t.intervals)return typeof t.price_month=="number"?`$${t.price_month}/mo`:null;const s=[];let a=!1,r=null;for(const u of w){const i=t.intervals[u];if(!(i!=null&&i.available))continue;u==="monthly"&&(a=!0);const m=Y(i,u);if(m&&s.push(m),typeof i.price=="number"){const x=i.price/Ie[u];r=r===null?x:Math.min(r,x)}}if(s.length===0)return null;const l=s.join(" · ");return a||r===null?l:`${l} — about $${Math.max(1,Math.round(r))}/mo`}function Be(t){if(t instanceof ce)switch(t.code){case"already_subscribed":return"You're already subscribed — refresh to see your plan.";case"invalid_plan":case"invalid_interval":case"invalid_tier":return"That plan isn't offered on this cycle — pick another."}return"Billing isn't available right now."}function F({text:t}){return e.jsx("p",{className:"mt-3 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:t})}function Ve({summary:t,plans:n}){const s=De(n),[a,r]=d.useState(null),l=a!==null&&s.includes(a)?a:s[0]??null,[u,i]=d.useState(null),[m,x]=d.useState(null);async function y(o){if(!u){i(o),x(null);try{const{url:c}=l?await O(o,l):await O(o);window.location.assign(c)}catch(c){if(i(null),c instanceof R){N.getState().markExpired();return}x(Be(c))}}}return e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),l&&s.length>1?e.jsxs("fieldset",{className:"mt-4 flex flex-wrap items-center gap-1.5",children:[e.jsx("legend",{className:"sr-only",children:"Billing interval"}),s.map(o=>{const c=o===l;return e.jsx("button",{type:"button",onClick:()=>r(o),"aria-pressed":c,className:`chip focus-ring ${c?"chip-tag-active font-medium":"chip-tag"}`,children:V[o]},o)})]}):null,n.length>0?e.jsx("ul",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:n.map(o=>{var f;const c=o.id===t.plan.tier,g=l?(f=o.intervals)==null?void 0:f[l]:void 0,h=s.length===0||(g==null?void 0:g.available)===!0,p=$e(o,s.length>0),b=h?null:Oe(o);return e.jsxs("li",{className:"rounded-xl border border-border bg-bg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:o.name}),c?e.jsx("span",{className:"chip",children:"Current"}):null]}),p?e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:p}):null,typeof o.vaults=="number"?e.jsxs("p",{className:"mt-0.5 text-xs text-fg-dim",children:[o.vaults," vault",o.vaults===1?"":"s"]}):null,c?null:h?e.jsx("button",{type:"button",onClick:()=>y(o.id),disabled:u!==null,className:"btn btn-primary btn-sm btn-touch mt-3 w-full",children:u===o.id?"Starting…":`Upgrade to ${o.name}`}):e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",disabled:!0,className:"btn btn-secondary btn-sm btn-touch w-full",children:["Not available"," ",V[l].toLowerCase()]}),b?e.jsxs("p",{className:"mt-1 text-xs text-fg-dim",children:["Available from ",Y(b.entry,b.interval)]}):null]})]},o.id)})}):null,m?e.jsx(F,{text:m}):null]})}function I(t){const{plan:n}=t,s=[n.label],a=T(t);a!==null?s.push(`${a} day${a===1?"":"s"} left`):typeof n.price_monthly_usd=="number"&&n.price_monthly_usd>0&&s.push(`$${n.price_monthly_usd}/mo`),typeof n.vault_limit=="number"&&typeof n.vaults_used=="number"&&s.push(`${n.vaults_used} of ${n.vault_limit} vaults`);const r=$(n.storage_used_bytes??0);if(r){const l=n.storage_limit_bytes?$(n.storage_limit_bytes):null;s.push(l?`${r} of ${l}`:r)}return s.join(" · ")}function Le({vaults:t,summary:n,onReload:s}){const a=A(),[r,l]=d.useState(null),[u,i]=d.useState(null),[m,x]=d.useState(!1);async function y(h){if(!r){l(h.name),i(null);try{await re(h.name),le(h.name),a("/")}catch(p){l(null),i(ie(p,"Couldn't open that vault."))}}}async function o(){x(!0);try{await s()}finally{x(!1)}}const c=n==null?void 0:n.plan,g=c&&typeof c.vault_limit=="number"&&typeof c.vaults_used=="number"?`${c.vaults_used} of ${c.vault_limit} ${L(n)?"in the open beta":"on your plan"}`:null;return e.jsxs("section",{"aria-label":"Your vaults",className:"card p-6 shadow-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Your vaults"}),g?e.jsx("span",{className:"text-xs text-fg-muted",children:g}):null]}),t==="loading"?e.jsxs("div",{"aria-busy":"true",className:"mt-4 space-y-2.5",children:[e.jsx("div",{className:"skeleton h-9 rounded-lg"}),e.jsx("div",{className:"skeleton h-9 w-4/5 rounded-lg"})]}):t==="error"?e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"Couldn't load your vaults."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"A hiccup reaching your account — nothing's lost, your vaults are safe."}),e.jsx("button",{type:"button",onClick:o,disabled:m,className:"btn btn-primary btn-touch",children:m?"Retrying…":"Retry"})]}):t.length===0?e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Create your first — a private home for your notes, always yours to export."}),e.jsx(j,{to:"/add-vault/create",className:"btn btn-primary btn-touch",children:"Create a vault"})]}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"mt-3 divide-y divide-border-light",children:t.map(h=>{const p=ue(h.usage),b=se(h.name).replace(/^https?:\/\//,"");return e.jsxs("li",{className:"flex items-center gap-3 py-3",children:[e.jsx(Te,{name:h.name}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-serif text-lg leading-snug text-fg",children:h.name}),e.jsx("p",{className:"mt-0.5 truncate note-id",children:b}),p?e.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:p}):null]}),e.jsx("button",{type:"button",onClick:()=>y(h),disabled:r===h.name,className:"btn btn-primary btn-sm btn-touch shrink-0",children:r===h.name?"Opening…":"Open →"})]},h.name)})}),e.jsx("p",{className:"mt-3 border-t border-border-light pt-3 text-sm",children:e.jsx(j,{to:"/add-vault",className:"focus-ring font-semibold text-accent hover:underline",children:"+ Add a vault"})})]}),u?e.jsx("p",{className:"mt-4 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:u}):null]})}function Te({name:t}){const n=(t.trim()[0]??"?").toUpperCase();return e.jsx("span",{"aria-hidden":!0,className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-grass-soft text-sm font-semibold text-grass-ink",children:n})}function U({hasActiveVault:t}){return e.jsxs("section",{"aria-label":"Connections",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Connections"}),e.jsxs("div",{className:"mt-2 divide-y divide-border-light",children:[t?e.jsx(k,{to:"/connect",tone:"sky",icon:e.jsx(D,{width:18,height:18}),title:"Connect your AI",description:"Claude, ChatGPT, or any MCP client — one memory, shared."}):e.jsxs("div",{className:"-mx-2 flex items-center gap-3 px-2 py-3 opacity-60",children:[e.jsx(q,{tone:"sky",children:e.jsx(D,{width:18,height:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-fg",children:"Connect your AI"}),e.jsx("p",{className:"mt-0.5 text-sm text-fg-muted",children:"Open a vault above to connect an AI to it."})]})]}),e.jsx(k,{to:"/import",tone:"grass",icon:e.jsx(ee,{width:18,height:18}),title:"Import notes",description:"Bring your notes over from anywhere markdown lives."}),e.jsx(k,{to:"/export",tone:"sun",icon:e.jsx(te,{width:18,height:18}),title:"Export notes",description:"Download your vault as open Markdown — yours to keep."})]})]})}function k({to:t,tone:n,icon:s,title:a,description:r}){return e.jsxs(j,{to:t,className:"focus-ring -mx-2 flex items-center gap-3 rounded-lg px-2 py-3 hover:bg-bg-soft",children:[e.jsx(q,{tone:n,children:s}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium text-fg",children:a}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:r})]}),e.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-lg text-fg-dim",children:"›"})]})}function q({tone:t,children:n}){const s=t==="grass"?"bg-grass-soft text-grass-ink":t==="sun"?"bg-sun-soft text-sun-ink":"bg-bg-soft";return e.jsx("span",{"aria-hidden":!0,className:`grid h-10 w-10 shrink-0 place-items-center rounded-full ${s}`,style:t==="sky"?{color:"var(--color-sky)"}:void 0,children:n})}function Re(){const t=E(s=>s.vaults),n=Object.values(t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"This device"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"You're managing the vaults connected on this device. Sign in to your account to manage your plan and hosted vaults from anywhere."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsx(j,{to:"/",className:"btn btn-primary btn-touch",children:"Sign in"}),e.jsx(j,{to:"/vaults",className:"btn btn-ghost btn-touch",children:n.length>0?`${n.length} connected`:"Connect a vault"})]})]}),e.jsx(U,{hasActiveVault:n.length>0})]})}export{Ye as Account};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as f,C as y,D as g,E as j,F as N,r as u,j as e,N as b,G as v,H as D,J as E,L as m,K as w,M as k,V as A}from"./index-
|
|
1
|
+
import{b as f,C as y,D as g,E as j,F as N,r as u,j as e,N as b,G as v,H as D,J as E,L as m,K as w,M as k,V as A}from"./index-DFrgKlHJ.js";const x=1440*60*1e3,S=5e3;function T(a,i=30,t=new Date){const n=t.getTime()-i*x,r=[];for(const s of a){const o=s.path??s.id,d=Date.parse(s.createdAt);if(Number.isFinite(d)&&d>=n&&r.push({id:`${s.id}:created`,noteId:s.id,noteName:o,kind:"created",at:s.createdAt,preview:s.preview,tags:s.tags}),s.updatedAt){const l=Date.parse(s.updatedAt);Number.isFinite(l)&&l>=n&&Number.isFinite(d)&&l-d>S&&r.push({id:`${s.id}:updated`,noteId:s.id,noteName:o,kind:"updated",at:s.updatedAt,preview:s.preview,tags:s.tags})}}return r.sort((s,o)=>Date.parse(o.at)-Date.parse(s.at)),r}const C=["today","yesterday","thisWeek","older"],_={today:"Today",yesterday:"Yesterday",thisWeek:"This week",older:"Older"};function B(a,i=new Date){const t=Date.parse(a);if(!Number.isFinite(t))return null;const n=p(i),r=p(new Date(t)),s=Math.round((n.getTime()-r.getTime())/x);return s<0||s===0?"today":s===1?"yesterday":s<7?"thisWeek":"older"}function p(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())}function I(a,i=new Date){const t={today:[],yesterday:[],thisWeek:[],older:[]};for(const n of a){const r=B(n.at,i);r&&t[r].push(n)}return t}const h=50;function O(){const a=f(c=>c.getActiveVault()),i=y(g(),-29),t=j({field:"updated_at",from:N(i),limit:v}),[n,r]=u.useState(h),s=u.useMemo(()=>t.data?T(t.data):[],[t.data]),o=u.useMemo(()=>s.slice(0,n),[s,n]),d=u.useMemo(()=>I(o),[o]),l=s.length-o.length;return a?e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("p",{className:"eyebrow mb-1",children:"Activity"}),e.jsx("h1",{className:"page-title",children:"Recent changes"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Last 30 days, newest first. Deletions aren't tracked yet."})]}),t.isPending?e.jsx(L,{}):t.isError?e.jsx(V,{error:t.error,retry:()=>t.refetch()}):s.length===0?e.jsx(F,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-8",children:C.map(c=>d[c].length>0?e.jsx(M,{title:_[c],events:d[c]},c):null)}),l>0?e.jsx("div",{className:"mt-8 flex justify-center",children:e.jsxs("button",{type:"button",onClick:()=>r(c=>c+h),className:"btn btn-secondary btn-touch",children:["Load more (",l," remaining)"]})}):null]})]}):e.jsx(b,{to:"/",replace:!0})}function M({title:a,events:i}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"eyebrow mb-3",children:[a," (",i.length,")"]}),e.jsx("ol",{className:"card shadow-soft divide-y divide-border rounded-xl",children:i.map(t=>e.jsx("li",{children:e.jsxs(m,{to:`/n/${encodeURIComponent(t.noteId)}`,className:"focus-ring block px-5 py-4 transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(R,{kind:t.kind}),e.jsx("span",{className:"truncate font-mono text-sm text-fg",children:t.noteName})]}),e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:k(t.at)})]}),t.preview?e.jsx("p",{className:"mt-1 truncate text-sm text-fg-muted",children:t.preview}):null,t.tags&&t.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tags.map(n=>e.jsxs("span",{className:"chip chip-tag max-w-full break-all",children:["#",n]},n))}):null]})},t.id))})]})}function R({kind:a}){return a==="created"?e.jsx("span",{className:"chip chip-tag shrink-0",children:"Created"}):e.jsx("span",{className:"chip shrink-0",children:"Edited"})}function F(){return e.jsx(w,{title:"No activity in the last 30 days.",action:e.jsx(m,{to:"/new",className:"btn btn-primary",children:"New note"})})}function L(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3,4].map(a=>e.jsx(D,{className:"h-16 rounded-xl"},a))})}function V({error:a,retry:i}){const t=a instanceof A;return e.jsx(E,{title:t?"Session expired":"Could not load activity",message:a.message,action:t?e.jsx(m,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):e.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary",children:"Retry"})})}export{O as Activity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as E,Q as I,R as z,r as s,T as V,U as g,W as A,X as F,b as H,Y as W,Z as q,_ as B,j as e,$ as L,a0 as M}from"./index-
|
|
1
|
+
import{P as E,Q as I,R as z,r as s,T as V,U as g,W as A,X as F,b as H,Y as W,Z as q,_ as B,j as e,$ as L,a0 as M}from"./index-DFrgKlHJ.js";import{W as O}from"./WizardShell-BBYxknp4.js";import"./history-B0uaXgK5.js";function T(r){const o=r.trim();if(!o)return null;try{return new URL(g(o)).host}catch{return null}}function X(){const[r,o]=E(),p=I(),m=r.get("url")??"",u=r.get("add")??"",f=/^https?:\/\//i.test(u),v=m||(f?u:""),i=z(r.get("redirect")),[a,j]=s.useState(v),[y,x]=s.useState(null),[P,w]=s.useState(!1),[h,N]=s.useState(!1),S=s.useRef(null),U=s.useRef(v.length>0),C=s.useRef(!1),c=V();s.useEffect(()=>{var t;(t=S.current)==null||t.focus()},[]),s.useEffect(()=>{U.current||c.status==="found"&&c.origin&&a===""&&(j(c.origin),U.current=!0)},[c.status,c.origin,a]);const b=s.useCallback(async t=>{x(null),w(!1);let l;try{l=g(t)}catch(n){x(n.message);return}N(!0);try{const{authorizeUrl:n}=await A(l,void 0,void 0,{...i?{redirect:i}:{}});window.location.assign(n)}catch(n){n instanceof F?w(!0):x(n.message),N(!1)}},[i]);s.useEffect(()=>{if(C.current||!u)return;C.current=!0;const t=new URLSearchParams(r);if(t.delete("add"),o(t,{replace:!0}),m||!f)return;let l;try{l=g(u)}catch{return}const R=H.getState().vaults[W(l)];if(R){q(R.id,{toast:!0}),p(B(i??"/"),{replace:!0});return}b(l)},[u,f,m,i,r,o,p,b]);function k(t){t.preventDefault(),b(a)}const d=T(a);return e.jsxs(O,{escape:{kind:"back",to:"/"},children:[e.jsx(L,{size:60,className:"mx-auto mb-6 drop-in"}),e.jsx("p",{className:"eyebrow mb-3",children:"Self-hosted"}),e.jsxs("h1",{className:"hero-title mb-4",children:["Connect your ",e.jsx("span",{className:"accent-word",children:"own"})," vault."]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-lg leading-relaxed text-fg-muted",children:"Point Parachute at a vault running on your own server."}),e.jsxs("form",{onSubmit:k,className:"mx-auto w-full max-w-sm text-left",children:[e.jsx("label",{htmlFor:"vault-url",className:"eyebrow mb-2 block",children:"Vault address"}),e.jsx("input",{id:"vault-url",ref:S,type:"url",required:!0,placeholder:"hub.your-domain.com",value:a,onChange:t=>j(t.target.value),disabled:h,className:"input input-on-bg font-mono"}),e.jsxs("p",{className:"mt-1.5 text-xs text-fg-dim",children:["A local install lives at ",e.jsx("code",{className:"note-id",children:"http://localhost:1939"}),"."]}),P?e.jsx("div",{className:"mt-3",children:e.jsx(M,{})}):null,y?e.jsx("p",{className:"mt-3 rounded-xl border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:y}):null,d?e.jsxs("div",{className:"mt-5 rounded-2xl border border-sun bg-sun-soft px-4 py-3 text-left font-round text-sm leading-relaxed text-sun-ink",children:["Next, ",e.jsx("b",{className:"font-semibold text-fg",children:d})," — your server, not ours — will ask you to sign in and approve this app. Then you land right back here."]}):null,e.jsx("button",{type:"submit",disabled:h||!a,className:"btn btn-primary btn-lg mt-5 w-full justify-center rounded-full shadow-soft",children:h?"Continuing…":d?`Continue to ${d} →`:"Continue"})]})]})}export{X as AddVault};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o,a1 as c,b as d,j as e,$ as m}from"./index-
|
|
1
|
+
import{e as o,a1 as c,b as d,j as e,$ as m}from"./index-DFrgKlHJ.js";import{W as x}from"./WizardShell-BBYxknp4.js";import"./history-B0uaXgK5.js";function f(){const s=o(),a=c(),t=d(l=>l.getActiveVault()),n=null,r=t?"/vaults":"/";return e.jsxs(x,{wide:!0,escape:{kind:"back",to:r},children:[e.jsx(m,{size:56,className:"mx-auto mb-6"}),a?e.jsxs("p",{className:"chip mb-4 inline-flex border-grass/40 bg-grass-soft text-grass-ink",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"})," Signed in as ",a]}):null,e.jsx("p",{className:"eyebrow mb-3",children:"Add a vault"}),e.jsxs("h1",{className:"hero-title mb-8",style:{fontSize:"clamp(1.8rem, 4vw, 2.4rem)"},children:["Bring another ",e.jsx("span",{className:"accent-word",children:"vault"})," in."]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(i,{icon:"📂",verb:"Open",description:"One of your account's vaults not on this device.",onClick:()=>s("/welcome?pick=1")}),e.jsx(i,{icon:"✦",verb:"Create",description:t?e.jsxs(e.Fragment,{children:["Brand-new and empty — separate from"," ",e.jsx("b",{className:"font-semibold text-fg",children:t.name}),"."]}):"Brand-new and empty — its own private space, nothing shared.",foot:n,onClick:()=>s("/add-vault/create")}),e.jsx(i,{icon:"⌂",verb:"Connect",description:"A self-hosted vault on your own server.",onClick:()=>s("/add")})]})]})}function i({icon:s,verb:a,description:t,foot:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,"aria-label":a,className:"tile flex flex-col items-center gap-2 p-6 text-center",children:[e.jsx("span",{"aria-hidden":"true",className:"text-xl",children:s}),e.jsx("span",{"aria-hidden":"true",className:"font-round text-base font-bold text-fg",children:a}),e.jsx("span",{className:"font-round text-xs leading-relaxed text-fg-muted",children:t}),n?e.jsx("span",{className:"mt-1 font-round text-xs text-fg-dim",children:n}):null]})}export{f as AddVaultChooser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as y,P as j,r as u,a2 as v,y as N,j as e,N as w,$ as f,a1 as k,b as S,q as C,w as E,x as A}from"./index-
|
|
1
|
+
import{e as y,P as j,r as u,a2 as v,y as N,j as e,N as w,$ as f,a1 as k,b as S,q as C,w as E,x as A}from"./index-DFrgKlHJ.js";import{W as p}from"./WizardShell-BBYxknp4.js";import"./history-B0uaXgK5.js";const g=["Name","Making it","Ready"];function b(t){return t.toLowerCase().replace(/[^a-z0-9\s-]/g,"")}function R(t){return t.trim().replace(/[\s-]*\s[\s-]*/g,"-")}function O(){const t=y(),[l]=j(),a=l.get("first")==="1",[s,r]=u.useState({kind:"naming"}),i=u.useRef(null);return u.useEffect(()=>{if(s.kind!=="creating"||i.current===s.name)return;i.current=s.name;const{name:o}=s;(async()=>{try{const c=await v(o),n=new URLSearchParams({vault:c});a&&n.set("first","1"),t(`/add-vault/ready?${n.toString()}`,{replace:!0})}catch(c){i.current=null,r({kind:"naming",attemptedName:o,error:N(c,"Couldn't create your vault. Try a different name.")})}})()},[s,t,a]),s.kind==="creating"?e.jsx(p,{escape:{kind:"none"},progress:{labels:g,current:1},children:e.jsx(z,{name:s.name})}):e.jsx(p,{escape:{kind:"back",to:a?"/":"/add-vault"},progress:{labels:g,current:0},children:e.jsx(V,{first:a,initialName:s.attemptedName,error:s.error,onCreate:o=>r({kind:"creating",name:o})})})}function T({email:t}){return t?e.jsxs("p",{className:"chip mb-4 inline-flex border-grass/40 bg-grass-soft text-grass-ink",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"})," Signed in as ",t]}):null}function V({first:t,initialName:l,error:a,onCreate:s}){const[r,i]=u.useState(()=>b(l??"")),o=k(),c=S(m=>{var h;return((h=m.getActiveVault())==null?void 0:h.name)??null}),n=R(r);function d(m){m.preventDefault(),n&&s(n)}return e.jsxs(e.Fragment,{children:[e.jsx(f,{size:60,className:"mx-auto mb-6 drop-in"}),e.jsx(T,{email:o}),e.jsx("p",{className:"eyebrow mb-3",children:t?"Account created ✓":"Adding a vault"}),e.jsxs("h1",{className:"hero-title mb-4",children:[t?"Let's make your first":"Let's make your new"," ",e.jsx("span",{className:"accent-word",children:"vault."})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-md text-lg leading-relaxed text-fg-muted",children:t?e.jsxs(e.Fragment,{children:["A vault is the private home for your notes — any AI you invite can read it, always yours to export. ",e.jsx("b",{className:"font-semibold text-fg",children:"This creates a brand-new, empty one."})]}):e.jsxs(e.Fragment,{children:["This one's separate from"," ",e.jsx("b",{className:"font-semibold text-fg",children:c??"your other vault"})," — its own private space, nothing shared."]})}),e.jsxs("form",{onSubmit:d,children:[e.jsx("input",{autoFocus:!0,value:r,onChange:m=>i(b(m.target.value)),placeholder:"moss",autoComplete:"off",spellCheck:!1,"aria-label":"Vault name",className:"mx-auto mb-2 block w-full max-w-sm border-0 border-b-2 border-border bg-transparent pb-2 text-center font-serif text-3xl text-fg outline-none transition-colors focus:border-accent-light"}),e.jsx("p",{className:"mb-6 min-h-6 font-round text-sm text-fg-muted",children:n?e.jsxs("span",{children:["Your vault:"," ",e.jsx("b",{className:"rounded-md bg-grass-soft px-2 py-0.5 text-grass-ink",children:n})," — you'll find it at ",e.jsx("span",{className:"font-mono text-xs",children:C(n)})]}):null}),e.jsxs("p",{className:"mx-auto mb-8 max-w-sm font-round text-xs text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg-muted",children:"The address is permanent"}),", so pick a word you like. Letters, numbers, hyphens."]}),a?e.jsx("p",{className:"mx-auto mb-6 max-w-sm rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:a}):null,e.jsx("button",{type:"submit",disabled:!n,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:n?`Create ${n} →`:"Create →"})]})]})}const x=["Setting up your vault…","Preparing your keys…","Almost there…"];function P(){const[t,l]=u.useState(0);return u.useEffect(()=>{if(t>=x.length-1)return;const a=setTimeout(()=>l(s=>Math.min(s+1,x.length-1)),650);return()=>clearTimeout(a)},[t]),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:x[t]})}function z({name:t}){return e.jsxs(e.Fragment,{children:[e.jsx(f,{size:96,className:"mx-auto mb-6 animate-pulse"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.6rem, 3.5vw, 1.9rem)"},children:["Making a place for ",e.jsxs("span",{className:"accent-word",children:[t,"…"]})]}),e.jsx(P,{})]})}function M(){const t=y(),[l]=j(),a=l.get("vault")??"",s=l.get("first")==="1",[r,i]=u.useState(!1),[o,c]=u.useState(null);if(!a)return e.jsx(w,{to:"/add-vault",replace:!0});async function n(){if(!r){i(!0),c(null);try{await E(a),A(a),t("/")}catch(d){i(!1),c(N(d,"Couldn't open your vault. Try again."))}}}return e.jsxs(p,{escape:s?{kind:"none"}:{kind:"maybe-later",to:"/"},progress:{labels:g,current:2},children:[e.jsx(f,{size:90,className:"mx-auto mb-6 fade-up"}),e.jsx("p",{className:"eyebrow mb-3",children:"Ready"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.3rem)"},children:[a," is ",e.jsx("span",{className:"accent-word",children:"ready."})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:"Everything inside is yours. Open format. Export anytime."}),o?e.jsx("p",{className:"mx-auto mb-6 max-w-sm rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:o}):null,e.jsx("button",{type:"button",onClick:n,disabled:r,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:r?"Opening…":`Open ${a} →`})]})}export{O as AddVaultCreate,M as AddVaultReady};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as c}from"./index-
|
|
1
|
+
import{r,j as c}from"./index-DFrgKlHJ.js";function v({onDropFiles:t,children:s,className:a,hint:o}){const[i,f]=r.useState(!1),n=r.useRef(0),d=r.useCallback(e=>{l(e.dataTransfer)&&(e.preventDefault(),n.current+=1,f(!0))},[]),p=r.useCallback(e=>{l(e.dataTransfer)&&(e.preventDefault(),n.current=Math.max(0,n.current-1),n.current===0&&f(!1))},[]),m=r.useCallback(e=>{l(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]),x=r.useCallback(e=>{if(!l(e.dataTransfer))return;e.preventDefault(),f(!1),n.current=0;const u=Array.from(e.dataTransfer.files);u.length>0&&t(u)},[t]);return c.jsxs("div",{className:`relative ${a??""}`,onDragEnter:d,onDragLeave:p,onDragOver:m,onDrop:x,children:[s,i?c.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-md border-2 border-dashed border-accent bg-accent/10 text-sm text-accent",children:c.jsxs("div",{className:"rounded-md bg-bg/80 px-4 py-2 font-medium shadow",children:["Drop to attach",o?c.jsxs("span",{className:"ml-2 text-fg-dim",children:["— ",o]}):null]})}):null]})}function l(t){if(!t)return!1;const s=t.types;for(let a=0;a<s.length;a++)if(s[a]==="Files")return!0;return!1}export{v as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as S,P as k,a3 as j,a4 as N,D as A,r as u,a5 as K,E as T,a6 as _,j as e,N as P,a7 as v,a8 as m,a9 as V,L as c,G as C,V as I}from"./index-
|
|
1
|
+
import{b as S,P as k,a3 as j,a4 as N,D as A,r as u,a5 as K,E as T,a6 as _,j as e,N as P,a7 as v,a8 as m,a9 as V,L as c,G as C,V as I}from"./index-DFrgKlHJ.js";const R=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g=5;function O(){const s=S(t=>t.getActiveVault()),[d]=k(),n=d.get("month"),r=j(n)??j(N()),x=A(),l=u.useMemo(()=>K(r.year,r.month),[r.year,r.month]),$=u.useMemo(()=>{const t=l[0],a=l[l.length-1];return{from:t.toISOString(),to:new Date(a.getFullYear(),a.getMonth(),a.getDate()+1).toISOString()}},[l]),o=T({field:"created_at",...$,limit:C}),M=u.useMemo(()=>{const t=new Map;if(!o.data)return t;for(const a of o.data){const i=_(a.createdAt);i&&t.set(i,(t.get(i)??0)+1)}return t},[o.data]);if(!s)return e.jsx(P,{to:"/",replace:!0});const b=v(r.year,r.month,-1),p=v(r.year,r.month,1),y=`${b.year}-${m(b.month)}`,f=`${p.year}-${m(p.month)}`,D=N(),E=`${r.year}-${m(r.month)}`===D;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Calendar"}),e.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:V(r.year,r.month)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(c,{to:`/calendar?month=${y}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous month",children:["← ",y]}),E?null:e.jsx(c,{to:"/calendar",className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"This month"}),e.jsxs(c,{to:`/calendar?month=${f}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next month",children:[f," →"]}),e.jsx(c,{to:`/today?date=${x}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"})]})]}),o.isError?e.jsx(F,{error:o.error,retry:()=>o.refetch()}):e.jsxs("div",{className:"rounded-md border border-border bg-card","aria-busy":o.isPending,children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-border text-xs uppercase tracking-wider text-fg-dim",children:R.map(t=>e.jsx("div",{className:"px-2 py-2 text-center",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7",children:l.map(t=>{const a=`${t.getFullYear()}-${m(t.getMonth()+1)}-${m(t.getDate())}`,i=t.getMonth()+1===r.month,h=M.get(a)??0,w=a===x;return e.jsxs(c,{to:`/today?date=${a}`,className:`flex min-h-20 flex-col border-b border-r border-border p-1.5 text-xs hover:bg-bg/60 focus:bg-bg/60 focus:outline-none ${i?"":"opacity-40"}`,"aria-label":`${a} — ${h} notes`,children:[e.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full tabular-nums ${w?"bg-accent text-(--color-on-accent)":"text-fg"}`,children:t.getDate()}),h>0?e.jsx(Y,{count:h}):e.jsx("span",{className:"sr-only",children:"no notes"})]},a)})})]}),e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:"Each dot is a note created on that day. Click any day to open /today."})]})}function Y({count:s}){const d=Math.min(s,g),n=s>g?s-g:0;return e.jsxs("span",{className:"flex flex-wrap items-center gap-0.5",children:[Array.from({length:d}).map((r,x)=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent","aria-hidden":"true"},x)),n>0?e.jsxs("span",{className:"ml-0.5 text-[10px] text-fg-dim",children:["+",n]}):null]})}function F({error:s,retry:d}){const n=s instanceof I;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:n?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:s.message}),n?e.jsx(c,{to:"/add",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Reconnect vault"}):e.jsx("button",{type:"button",onClick:d,className:"btn btn-secondary",children:"Retry"})]})}export{O as Calendar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as R,P as I,bd as v,r as s,a1 as L,j as e,N as M,$ as O,g as h,c4 as P,c5 as T,c6 as W}from"./index-
|
|
1
|
+
import{e as R,P as I,bd as v,r as s,a1 as L,j as e,N as M,$ as O,g as h,c4 as P,c5 as T,c6 as W}from"./index-DFrgKlHJ.js";import{W as _}from"./WizardShell-BBYxknp4.js";import"./history-B0uaXgK5.js";const z="/welcome",D=3e3,j="That code didn't work — check it and try again.";function G(){const o=R(),[g]=I(),c=v(z,g.get("redirect")),[n,w]=s.useState(()=>L()??""),[r,i]=s.useState("idle"),[p,C]=s.useState(""),[S,d]=s.useState(""),[l,u]=s.useState(null),[b,y]=s.useState(!1),m=s.useRef(!1),x=s.useRef(!1);if(s.useEffect(()=>{let t=!1;const f=setInterval(async()=>{try{const N=await h();!t&&N.signed_in&&o(c,{replace:!0})}catch{}},D);return()=>{t=!0,clearInterval(f)}},[o,c]),!n)return e.jsx(M,{to:v("/",g.get("redirect")),replace:!0});async function k(t=n){if(!m.current){m.current=!0;try{const a=await h();await P(t,a.csrf,c),t!==n&&(T(t),w(t)),i("resent")}catch{i("idle")}finally{m.current=!1}}}async function E(t){const a=t.replace(/\D/g,"").slice(0,6);if(d(a),u(null),!(a.length<6||x.current)){x.current=!0,y(!0);try{const f=await h();if(await W(n,a,f.csrf)){o(c,{replace:!0});return}u(j),d("")}catch{u(j),d("")}finally{x.current=!1,y(!1)}}}return e.jsxs(_,{escape:{kind:"back",to:"/",label:"← Back to sign in"},children:[e.jsx(O,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Check your email"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["We sent a sign-in link to ",e.jsx("span",{className:"accent-word",children:n})]}),e.jsx("p",{className:"text-fg-muted",children:"Works once, expires in 10 min."}),e.jsx("p",{className:"mx-auto mt-3 mb-6 max-w-sm font-round text-sm text-fg-muted",children:"New here? That same link creates your account — the email says which."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[e.jsx("button",{type:"button",onClick:()=>k(),className:"btn btn-secondary btn-touch rounded-full",children:"Resend the link"}),e.jsx("button",{type:"button",onClick:()=>i(r==="code"?"idle":"code"),className:"font-round text-sm font-semibold text-link hover:underline",style:{color:"var(--color-sky)"},children:r==="code"?"Hide the code field":"Or type the code from the email"}),e.jsx("button",{type:"button",onClick:()=>i("changeemail"),className:"font-round text-sm font-semibold text-link hover:underline",style:{color:"var(--color-sky)"},children:"Use a different email"})]}),r==="resent"?e.jsx("p",{className:"mx-auto mt-4 max-w-sm rounded-xl border border-grass bg-grass-soft px-4 py-3 text-sm text-grass-ink",children:"✓ Sent again — check your inbox."}):null,r==="code"?e.jsxs("div",{className:"mx-auto mt-4 max-w-xs",children:[e.jsx("label",{htmlFor:"signin-code",className:"mb-2 block font-round text-sm text-fg-muted",children:"6-digit code"}),e.jsx("input",{id:"signin-code",value:S,onChange:t=>{E(t.target.value)},inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",placeholder:"123456",disabled:b,"aria-invalid":l?!0:void 0,"aria-describedby":l?"signin-code-error":void 0,autoFocus:!0,className:"input w-full text-center text-2xl tracking-[0.4em]"}),e.jsx("output",{"aria-live":"polite",className:"mt-2 block text-center text-xs text-fg-dim",children:b?"Checking…":" "}),l?e.jsx("p",{id:"signin-code-error",role:"alert",className:"rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-center text-sm text-danger",children:l}):null]}):null,r==="changeemail"?e.jsxs("div",{className:"mx-auto mt-4 max-w-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:p,onChange:t=>C(t.target.value),placeholder:"you@example.com","aria-label":"Email address",type:"email",className:"input"}),e.jsx("button",{type:"button",onClick:()=>{const t=p.trim();/.+@.+\..+/.test(t)&&k(t)},className:"btn btn-primary btn-touch shrink-0 rounded-full",children:"Send link"})]}),e.jsx("button",{type:"button",onClick:()=>i("idle"),className:"mt-2 font-round text-sm text-fg-dim hover:text-accent",children:"Cancel"})]}):null]})}export{G as CheckEmail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var iO=Object.defineProperty;var nO=(n,e,t)=>e in n?iO(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var mi=(n,e,t)=>nO(n,typeof e!="symbol"?e+"":e,t);import{r as Ee,j as rO}from"./index-
|
|
1
|
+
var iO=Object.defineProperty;var nO=(n,e,t)=>e in n?iO(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var mi=(n,e,t)=>nO(n,typeof e!="symbol"?e+"":e,t);import{r as Ee,j as rO}from"./index-DFrgKlHJ.js";import{W as sO}from"./useAttachmentUploader-t93QVRf6.js";let ms=[],vh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?vh:ms).push(t=t+n[e])})();function oO(n){if(n<768)return!1;for(let e=0,t=ms.length;;){let i=e+t>>1;if(n<ms[i])t=i;else if(n>=vh[i])e=i+1;else return!0;if(e==t)return!1}}function ul(n){return n>=127462&&n<=127487}const Ol=8205;function lO(n,e,t=!0,i=!0){return(t?Ph:aO)(n,e,i)}function Ph(n,e,t){if(e==n.length)return e;e&&Th(n.charCodeAt(e))&&Ch(n.charCodeAt(e-1))&&e--;let i=Xr(n,e);for(e+=dl(i);e<n.length;){let r=Xr(n,e);if(i==Ol||r==Ol||t&&oO(r))e+=dl(r),i=r;else if(ul(r)){let s=0,o=e-2;for(;o>=0&&ul(Xr(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function aO(n,e,t){for(;e>1;){let i=Ph(n,e-2,t);if(i<e)return i;e--}return 0}function Xr(n,e){let t=n.charCodeAt(e);if(!Ch(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Th(i)?(t-55296<<10)+(i-56320)+65536:t}function Th(n){return n>=56320&&n<57344}function Ch(n){return n>=55296&&n<56320}function dl(n){return n<65536?1:2}class z{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=ti(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),Ge.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ti(this,e,t);let i=[];return this.decompose(e,t,i,0),Ge.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Ti(this),s=new Ti(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Ti(this,e)}iterRange(e,t=this.length){return new Zh(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Xh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?z.empty:e.length<=32?new J(e):Ge.from(J.split(e,[]))}}class J extends z{constructor(e,t=hO(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new cO(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new J(pl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Rn(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new J(l,o.length+s.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof J))return super.replace(e,t,i);[e,t]=ti(this,e,t);let r=Rn(this.text,Rn(i.text,pl(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new J(r,s):Ge.from(J.split(r,[]),s)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){[e,t]=ti(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new J(i,r)),i=[],r=-1);return r>-1&&t.push(new J(i,r)),t}}class Ge extends z{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=ti(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new Ge(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=ti(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ge))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let O of e)i+=O.lines;if(i<32){let O=[];for(let d of e)d.flatten(O);return new J(O,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(O){let d;if(O.lines>s&&O instanceof Ge)for(let p of O.children)f(p);else O.lines>o&&(a>o||!a)?(u(),l.push(O)):O instanceof J&&a&&(d=c[c.length-1])instanceof J&&O.lines+d.lines<=32?(a+=O.lines,h+=O.length+1,c[c.length-1]=new J(d.text.concat(O.text),d.length+1+O.length)):(a+O.lines>r&&u(),a+=O.lines,h+=O.length+1,c.push(O))}function u(){a!=0&&(l.push(c.length==1?c[0]:Ge.from(c,h)),h=-1,a=c.length=0)}for(let O of e)f(O);return u(),l.length==1?l[0]:new Ge(l,t)}}z.empty=new J([""],0);function hO(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Rn(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function pl(n,e,t){return Rn(n,[""],e,t)}class Ti{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof J?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof J?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(r instanceof J){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Zh{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ti(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Xh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(z.prototype[Symbol.iterator]=function(){return this.iter()},Ti.prototype[Symbol.iterator]=Zh.prototype[Symbol.iterator]=Xh.prototype[Symbol.iterator]=function(){return this});let cO=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function ti(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function ae(n,e,t=!0,i=!0){return lO(n,e,t,i)}function fO(n){return n>=56320&&n<57344}function uO(n){return n>=55296&&n<56320}function Ct(n,e){let t=n.charCodeAt(e);if(!uO(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return fO(i)?(t-55296<<10)+(i-56320)+65536:t}function OO(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Vt(n){return n<65536?1:2}const gs=/\r\n?|\n/;var ue=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(ue||(ue={}));class Je{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Ss(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new Je(e)}composeDesc(e){return this.empty?e:e.empty?this:Ah(this,e)}mapDesc(e,t=!1){return e.empty?this:bs(this,e,t)}mapPos(e,t=-1,i=ue.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=ue.Simple&&h>=e&&(i==ue.TrackDel&&r<e&&h>e||i==ue.TrackBefore&&r<e||i==ue.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Je(e)}static create(e){return new Je(e)}}class te extends Je{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Ss(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return bs(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(z.empty);i.push(o?e.slice(s,s+o):z.empty)}s+=o}return new te(t,i)}compose(e){return this.empty?e:e.empty?this:Ah(this,e,!0)}map(e,t=!1){return e.empty?this:bs(this,e,t,!0)}iterChanges(e,t=!1){Ss(this,e,t)}get desc(){return Je.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Ei(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);le(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;le(t,c,f),f>0&&St(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);le(t,c,-1),le(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new te(t,i),filtered:Je.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&le(r,t-o,-1);let f=new te(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof te){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:O}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let d=O?typeof O=="string"?z.of(O.split(i||gs)):O:z.empty,p=d.length;if(f==u&&p==0)return;f<o&&a(),f>o&&le(r,f-o,-1),le(r,u-f,p),St(s,r,d),o=u}}return h(e),a(!l),l}static empty(e){return new te(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(z.empty);i[r]=z.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new te(t,i)}static createSet(e,t){return new te(e,t)}}function le(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function St(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(z.empty);n.push(t)}}function Ss(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=z.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function bs(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Ei(n),l=new Ei(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);le(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(le(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(le(r,0,o.ins),s&&St(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;le(r,h,a<o.i?o.ins:0),s&&a<o.i&&St(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?te.createSet(r,s):Je.create(r);throw new Error("Mismatched change set lengths")}}}function Ah(n,e,t=!1){let i=[],r=t?[]:null,s=new Ei(n),o=new Ei(e);for(let l=!1;;){if(s.done&&o.done)return r?te.createSet(i,r):Je.create(i);if(s.ins==0)le(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)le(i,0,o.ins,l),r&&St(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;le(i,a,c,l),r&&c&&St(r,i,o.text)}else o.ins==-1?(le(i,s.off?0:s.len,a,l),r&&St(r,i,s.textBit(a))):(le(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&St(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}class Ei{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?z.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?z.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class mt{constructor(e,t,i,r){this.from=e,this.to=t,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new mt(i,r,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return k.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return k.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return k.range(e.anchor,e.head)}static create(e,t,i,r){return new mt(e,t,i,r)}}class k{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:k.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new k([this.main],0)}addRange(e,t=!0){return k.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,k.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new k(e.ranges.map(t=>mt.fromJSON(t)),e.main)}static single(e,t=e){return new k([k.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return k.normalized(e.slice(),t);i=s.to}return new k(e,t)}static cursor(e,t=0,i,r){return mt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),r)}static range(e,t,i,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=t&&(s=t<e?1:-1),s&&(o|=s<0?8:16),t<e?mt.create(t,e,o|32,i):mt.create(e,t,o,i)}static undirectionalRange(e,t){return mt.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?k.range(a,l):k.range(l,a))}}return new k(e,t)}}function Mh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let uo=0;class X{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=uo++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new X(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Oo),!!e.static,e.enables)}of(e){return new Ln([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ln(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ln(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Oo(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Ln{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=uo++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Qs(f,c)){let O=i(f);if(l?!ml(O,f.values[o],r):!r(O,f.values[o]))return f.values[o]=O,1}return 0},reconfigure:(f,u)=>{let O,d=u.config.address[s];if(d!=null){let p=Dn(u,d);if(this.dependencies.every(g=>g instanceof X?u.facet(g)===f.facet(g):g instanceof _e?u.field(g,!1)==f.field(g,!1):!0)||(l?ml(O=i(f),p,r):r(O=i(f),p)))return f.values[o]=p,0}else O=i(f);return f.values[o]=O,1}}}get extension(){return this}}function ml(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function Qs(n,e){let t=!1;for(let i of e)Ci(n,i)&1&&(t=!0);return t}function dO(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Dn(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Ci(a,h);return a.values[o]=l(a),1},update(a,h){if(!Qs(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Qs(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Oo(t,f))return a.values[o]=u,0;let O=l(a);return e.compare(O,u)?(a.values[o]=u,0):(a.values[o]=O,1)}}}const dn=X.define({static:!0});class _e{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new _e(uo++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(dn).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(dn),o=r.facet(dn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,dn.of({field:this,create:e})]}get extension(){return this}}const Xt={lowest:4,low:3,default:2,high:1,highest:0};function gi(n){return e=>new Rh(e,n)}const _t={highest:gi(Xt.highest),high:gi(Xt.high),default:gi(Xt.default),low:gi(Xt.low),lowest:gi(Xt.lowest)};class Rh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class mr{of(e){return new ys(this,e)}reconfigure(e){return mr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ys{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class qn{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of pO(e,t,o))u instanceof _e?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(O=>u.slot(O));let c=i==null?void 0:i.config.facets;for(let u in s){let O=s[u],d=O[0].facet,p=c&&c[u]||[];if(O.every(g=>g.type==0))if(l[d.id]=a.length<<1|1,Oo(p,O))a.push(i.facet(d));else{let g=d.combine(O.map(S=>S.value));a.push(i&&d.compare(g,i.facet(d))?i.facet(d):g)}else{for(let g of O)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(S=>g.dynamicSlot(S)));l[d.id]=h.length<<1,h.push(g=>dO(g,d,O))}}let f=h.map(u=>u(l));return new qn(e,o,f,l,a,s)}}function pO(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof ys&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof ys){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Rh)s(o.inner,o.prec);else if(o instanceof _e)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Ln)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Xt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,Xt.default),i.reduce((o,l)=>o.concat(l))}function Ci(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Dn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Lh=X.define(),ks=X.define({combine:n=>n.some(e=>e),static:!0}),Eh=X.define({combine:n=>n.length?n[0]:void 0,static:!0}),jh=X.define(),Yh=X.define(),zh=X.define(),_h=X.define({combine:n=>n.length?n[0]:!1});class ft{constructor(e,t){this.type=e,this.value=t}static define(){return new mO}}class mO{of(e){return new ft(this,e)}}class gO{constructor(e){this.map=e}of(e){return new I(this,e)}}class I{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new I(this.type,t)}is(e){return this.type==e}static define(e={}){return new gO(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}I.reconfigure=I.define();I.appendConfig=I.define();class ee{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Mh(i,t.newLength),s.some(l=>l.type==ee.time)||(this.annotations=s.concat(ee.time.of(Date.now())))}static create(e,t,i,r,s,o){return new ee(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ee.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}ee.time=ft.define();ee.userEvent=ft.define();ee.addToHistory=ft.define();ee.remote=ft.define();function SO(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Wh(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=te.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:I.mapEffects(n.effects,r).concat(I.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function xs(n,e,t){let i=e.selection,r=Gt(e.annotations);return e.userEvent&&(r=r.concat(ee.userEvent.of(e.userEvent))),{changes:e.changes instanceof te?e.changes:te.of(e.changes||[],t,n.facet(Eh)),selection:i&&(i instanceof k?i:k.single(i.anchor,i.head)),effects:Gt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Vh(n,e,t){let i=xs(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Wh(i,xs(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=ee.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return QO(t?bO(r):r)}function bO(n){let e=n.startState,t=!0;for(let r of e.facet(jh)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:SO(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=te.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=ee.create(e,r,n.selection&&n.selection.map(s),I.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Yh);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof ee?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ee?n=s[0]:n=Vh(e,Gt(s),!1)}return n}function QO(n){let e=n.startState,t=e.facet(zh),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Wh(i,xs(e,s,n.changes.newLength),!0))}return i==n?n:ee.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const yO=[];function Gt(n){return n==null?yO:Array.isArray(n)?n:[n]}var ot=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ot||(ot={}));const kO=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ws;try{ws=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function xO(n){if(ws)return ws.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||kO.test(t)))return!0}return!1}function wO(n){return e=>{if(!/\S/.test(e))return ot.Space;if(xO(e))return ot.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return ot.Word;return ot.Other}}class V{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Ci(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Ci(this,i),Dn(this,i)}update(...e){return Vh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(mr.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(I.reconfigure)?(t=null,i=l.value):l.is(I.appendConfig)&&(t=null,i=Gt(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=qn.resolve(i,r,this),s=new V(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(ks)?e.newSelection:e.newSelection.asSingle();new V(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:k.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=Gt(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=I.mapEffects(o,c).concat(I.mapEffects(Gt(a.effects),f))}return{changes:r,selection:k.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof te?e:te.of(e,this.doc.length,this.facet(V.lineSeparator))}toText(e){return z.of(e.split(this.facet(V.lineSeparator)||gs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ci(this,t),Dn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof _e&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return V.create({doc:e.doc,selection:k.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=qn.resolve(e.extensions||[],new Map),i=e.doc instanceof z?e.doc:z.of((e.doc||"").split(t.staticFacet(V.lineSeparator)||gs)),r=e.selection?e.selection instanceof k?e.selection:k.single(e.selection.anchor,e.selection.head):k.single(0);return Mh(r,i.length),t.staticFacet(ks)||(r=r.asSingle()),new V(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aa as N,v,r as p,ab as k,l as w,h as A,b as P,j as e,N as T,L as m,ac as g}from"./index-
|
|
1
|
+
import{aa as N,v,r as p,ab as k,l as w,h as A,b as P,j as e,N as T,L as m,ac as g}from"./index-DFrgKlHJ.js";function b(t){return`${t.replace(/\/+$/,"")}/mcp`}function U(t){return`parachute-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"vault"}`}function M(t,a){return`claude mcp add --transport http ${U(t)} ${a}`}function S(t,a){const s=t.find(r=>(r==null?void 0:r.name)===a),n=s==null?void 0:s.mcp_url;if(typeof n!="string")return null;try{const r=new URL(n);return r.protocol==="https:"||r.protocol==="http:"?n:null}catch{return null}}function f(t,a){const s=t==null?void 0:t.vault_url_template;if(typeof s!="string"||!s.includes("{name}"))return null;try{const n=new URL(s.replace("{name}",encodeURIComponent(a)));return n.protocol==="https:"||n.protocol==="http:"?b(n.href):null}catch{return null}}const I=4e3;function L(t,a){const s=b(t.url),n=N(t.clientId),r=v(t.url)??t.name,[i,l]=p.useState({url:s,settled:!n});return p.useEffect(()=>{if(!n){l({url:s,settled:!0});return}let c=!0;l({url:s,settled:!1});const d=setTimeout(()=>{c&&l({url:f(k(),r)??s,settled:!0}),c=!1},I),h=async()=>f(await A(a),r)??s;return w(a).then(async o=>{if(!c)return;const x=Array.isArray(o==null?void 0:o.vaults)?o.vaults:[],j=x.some(u=>(u==null?void 0:u.name)===r),C=S(x,r)??(j?await h():s);clearTimeout(d),c&&l({url:C,settled:!0})}).catch(async()=>{const o=await h();clearTimeout(d),c&&l({url:o,settled:!0})}),()=>{c=!1,clearTimeout(d)}},[n,s,r,a]),i}function $(){const t=P(a=>a.getActiveVault());return t?e.jsx(D,{vault:t}):e.jsx(T,{to:"/",replace:!0})}function D({vault:t}){const{url:a,settled:s}=L(t),n=M(t.name,a);return e.jsxs("div",{className:"page-prose",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(m,{to:"/",className:"focus-ring hover:text-accent",children:"← Home"})}),e.jsxs("header",{className:"mb-8",children:[e.jsx("p",{className:"eyebrow mb-1",children:t.name}),e.jsx("h1",{className:"page-title",children:"Connect your AI"}),e.jsx("p",{className:"mt-3 text-fg-muted",children:"Your vault speaks MCP — an open standard — so any AI can read and write it: Claude, ChatGPT, Claude Code, Cursor, or an agent you build. One memory, shared with every assistant you choose to connect."})]}),e.jsxs("section",{"aria-labelledby":"mcp-url-heading",className:"mb-8",children:[e.jsx("h2",{id:"mcp-url-heading",className:"eyebrow mb-2",children:"Your vault address"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Paste this wherever an AI asks for an MCP server. The"," ",e.jsx("code",{className:"rounded bg-bg-soft px-1 font-mono text-fg",children:"/mcp"})," suffix matters — it's the connection endpoint, not a page to open."]}),s?e.jsx(g,{value:a,label:"vault MCP URL"}):e.jsx("p",{className:"text-sm text-fg-dim","aria-live":"polite",children:"Finding your vault address…"}),e.jsxs("p",{className:"mt-3 text-sm text-fg-muted",children:["It reads and writes only inside"," ",e.jsx("b",{className:"rounded-md bg-grass-soft px-2 py-0.5 font-medium text-grass-ink",children:t.name})," ","— never anywhere else. Disconnect anytime from your vault's"," ",e.jsx(m,{to:"/settings",className:"text-accent hover:underline",children:"settings"}),"."]})]}),e.jsx("h2",{className:"eyebrow mb-3",children:"Bring your AI in"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(y,{title:"Claude",initial:"C",tone:"coral",steps:E,note:"On Claude's free plan you can add one custom connector."}),e.jsx(y,{title:"ChatGPT",initial:"G",tone:"grass",steps:F,note:"ChatGPT moves these menus often; the shape stays the same — add a connector, paste the address."})]}),e.jsxs("section",{"aria-labelledby":"other-clients-heading",className:"mt-8",children:[e.jsx("h2",{id:"other-clients-heading",className:"eyebrow mb-2",children:"Other AIs & the command line"}),e.jsx("p",{className:"mb-3 text-sm text-fg-muted",children:"That same URL works in any MCP-compatible client — Cursor, an agent you build, anywhere an AI asks for an MCP server. For Claude Code:"}),s?e.jsx(g,{value:n,label:"Claude Code command"}):null]}),e.jsx("div",{className:"mt-10 flex flex-wrap items-center gap-3 border-t border-border pt-6",children:e.jsx(m,{to:"/",className:"btn btn-primary btn-touch",children:"Done — back to your vault"})})]})}const E=[{key:"settings",body:e.jsxs(e.Fragment,{children:["Open"," ",e.jsx("a",{href:"https://claude.ai",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"claude.ai"})," ","and go to ",e.jsx("strong",{className:"text-fg",children:"Customize → Connectors"}),"."]})},{key:"add",body:e.jsxs(e.Fragment,{children:["Click ",e.jsx("strong",{className:"text-fg",children:"+ Add"}),", then"," ",e.jsx("strong",{className:"text-fg",children:"Add custom connector"}),"."]})},{key:"paste",body:e.jsxs(e.Fragment,{children:["Paste your vault address above, click ",e.jsx("strong",{className:"text-fg",children:"Continue"}),", and allow access when Parachute asks."]})}],F=[{key:"settings",body:e.jsxs(e.Fragment,{children:["Open ChatGPT's ",e.jsx("strong",{className:"text-fg",children:"Settings"})," and find"," ",e.jsx("strong",{className:"text-fg",children:"Apps & Connectors"})," (custom connectors need a paid plan, and may need Developer mode turned on)."]})},{key:"add",body:"Create a custom connector (an MCP server)."},{key:"paste",body:"Paste the same vault address and connect."}];function y({title:t,initial:a,tone:s,steps:n,note:r}){const i=s==="coral"?"bg-coral-soft text-coral-ink":"bg-grass-soft text-grass-ink";return e.jsxs("section",{className:"tile p-5","aria-label":`Connect ${t}`,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[e.jsx("span",{"aria-hidden":"true",className:`grid h-9 w-9 shrink-0 place-items-center rounded-full font-round text-sm font-semibold ${i}`,children:a}),e.jsx("h2",{className:"font-serif text-xl text-fg",children:t})]}),e.jsx("ol",{className:"list-decimal space-y-2 pl-5 text-sm text-fg-muted",children:n.map(l=>e.jsx("li",{children:l.body},l.key))}),r?e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:r}):null]})}export{$ as ConnectAI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as P,P as C,j as e,N as v,D as L,ad as B,F as k,C as y,E as w,G as E,r as S,a6 as D,L as o,ae as K,af as $,H as I,J as _,K as M,ag as F,ah as H,ai as O,aj as U,V as G}from"./index-
|
|
1
|
+
import{b as P,P as C,j as e,N as v,D as L,ad as B,F as k,C as y,E as w,G as E,r as S,a6 as D,L as o,ae as K,af as $,H as I,J as _,K as M,ag as F,ah as H,ai as O,aj as U,V as G}from"./index-DFrgKlHJ.js";import{u as J}from"./history-B0uaXgK5.js";function Z(){const a=P(t=>t.getActiveVault()),[n]=C(),s=n.get("date");return a?s===null?e.jsx(v,{to:"/",replace:!0}):e.jsx(Q,{dateParam:s}):e.jsx(v,{to:"/",replace:!0})}function Q({dateParam:a}){const n=J("/"),s=L(),t=a||s,r=B(t),b=k(t)??"",j=k(y(t,1))??"",c=w({field:"created_at",from:b,to:j,limit:E,enabled:!!r}),i=w({field:"updated_at",from:b,to:j,limit:E,enabled:!!r}),x=S.useMemo(()=>{if(!(!c.data||!i.data))return[...new Map([...c.data,...i.data].map(l=>[l.id,l])).values()]},[c.data,i.data]),R=c.isPending||i.isPending,h=c.error??i.error,d=S.useMemo(()=>{const l=[],p=[];if(!x||!r)return{created:l,edited:p};for(const m of x){const g=D(m.createdAt),V=D(m.updatedAt??m.createdAt);g===t&&l.push(m),V===t&&g!==t&&p.push(m)}return{created:l,edited:p}},[x,r,t]);if(!r)return e.jsxs("div",{className:"page-prose",children:[e.jsxs("p",{className:"text-sm text-danger",children:["Invalid date in URL: ",t]}),e.jsx(o,{to:"/",className:"text-sm text-accent hover:underline",children:"Back to today"})]});const u=t===s,f=y(t,-1),N=y(t,1),T=t.slice(0,7);return e.jsxs("div",{className:"page-prose",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx("button",{type:"button",onClick:n,className:"hover:text-accent",children:"← Back"})}),e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:u?"Today":"On"}),e.jsx("h1",{className:"page-title",children:K(t)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(o,{to:`/today?date=${f}`,className:"btn btn-secondary btn-sm","aria-label":"Previous day",children:["← ",f]}),u?null:e.jsx(o,{to:"/",className:"btn btn-secondary btn-sm",children:"Today"}),e.jsxs(o,{to:`/today?date=${N}`,className:"btn btn-secondary btn-sm","aria-label":"Next day",children:[N," →"]}),e.jsx(o,{to:`/calendar?month=${T}`,className:"btn btn-secondary btn-sm",children:"Calendar"}),e.jsx(o,{to:"/new",className:"btn btn-primary btn-sm",children:"+ New note"})]})]}),R?e.jsx(Y,{}):h&&!x?e.jsx(q,{error:h,retry:()=>{Promise.all([c.refetch(),i.refetch()])}}):d.created.length===0&&d.edited.length===0?e.jsx(W,{isToday:u,targetKey:t}):e.jsxs("div",{className:"space-y-8",children:[h?e.jsx($,{}):null,d.created.length>0?e.jsx(A,{title:u?"Created today":`Created on ${t}`,notes:d.created}):null,d.edited.length>0?e.jsx(A,{title:u?"Edited today":`Edited on ${t}`,notes:d.edited}):null]})]})}function A({title:a,notes:n}){const s=P(r=>r.getActiveVault()),{roles:t}=F((s==null?void 0:s.id)??null);return e.jsxs("section",{children:[e.jsxs(H,{children:[a," (",n.length,")"]}),e.jsx(O,{children:n.map(r=>e.jsx(U,{note:r,pinnedTag:t.pinned,archivedTag:t.archived},r.id))})]})}function W({isToday:a,targetKey:n}){return e.jsx(M,{title:a?"Nothing yet today — start capturing.":`Nothing on ${n}.`,action:a?e.jsx(o,{to:"/new",className:"btn btn-primary",children:"New note"}):void 0})}function Y(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3].map(a=>e.jsx(I,{className:"h-14 rounded-xl"},a))})}function q({error:a,retry:n}){const s=a instanceof G;return e.jsx(_,{title:s?"Session expired":"Could not load notes",message:a.message,action:s?e.jsx(o,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):e.jsx("button",{type:"button",onClick:n,className:"btn btn-secondary",children:"Retry"})})}export{Z as DayView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as u,ak as m,al as p,r as d,j as e,N as x,am as h,L as g}from"./index-
|
|
1
|
+
import{b as u,ak as m,al as p,r as d,j as e,N as x,am as h,L as g}from"./index-DFrgKlHJ.js";function j(){const s=u(a=>a.getActiveVault()),n=m(),r=p(a=>a.push),[t,o]=d.useState({kind:"idle"});if(!s)return e.jsx(x,{to:"/",replace:!0});const i=d.useCallback(async()=>{if(!n){r("Vault session unavailable — reconnect first","error");return}o({kind:"preparing"});try{const a=await n.exportVault(),c=new Date().toISOString().slice(0,10);f(a,`${s.name}-export-${c}.tar`),o({kind:"idle"}),r("Export downloaded.","success")}catch(a){if(a instanceof h){o({kind:"unsupported"});return}o({kind:"error",message:"Couldn't reach your vault — try again."})}},[n,s.name,r]),l=t.kind==="preparing";return e.jsxs("div",{className:"page-prose",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(g,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})}),e.jsxs("header",{className:"mb-8",children:[e.jsxs("h1",{className:"page-title",children:["Export notes from ",e.jsx("span",{className:"text-accent",children:s.name})]}),e.jsx("p",{className:"mt-3 text-fg-muted",children:"A portable folder of your notes — plain Markdown, with your tags, links, and attachments included. Yours to keep, no matter what happens to Parachute."})]}),e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-lg text-fg",children:"What's in the download"}),e.jsxs("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-fg-muted",children:[e.jsx("li",{children:"One markdown file per note, with tags, metadata, and links as frontmatter."}),e.jsx("li",{children:"Your tag definitions, so an import elsewhere keeps their structure."}),e.jsx("li",{children:"Attachment files (images, audio, PDF, video), in a .parachute/attachments folder."})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",onClick:i,disabled:l,className:"btn btn-primary btn-touch",children:l?"Preparing your export…":"Export my vault"}),l?e.jsx("span",{className:"text-sm text-fg-dim",children:"This can take a moment."}):null]}),t.kind==="error"?e.jsx("p",{className:"rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:t.message}):null,t.kind==="unsupported"?e.jsxs("div",{className:"rounded-lg border border-border bg-bg-soft px-3 py-2 text-sm text-fg-muted",children:[e.jsx("p",{children:"Export over the web isn't available on this vault yet — self-hosted vaults don't carry this door today."}),e.jsxs("p",{className:"mt-1",children:["From the vault's command line, run"," ",e.jsx("code",{className:"rounded bg-card px-1 font-mono text-fg",children:"parachute-vault export <dir>"})," ","to get the same portable folder."]})]}):null]})]})}function f(s,n){const r=URL.createObjectURL(s),t=document.createElement("a");t.href=r,t.download=n,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(r)}export{j as Export};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{an as te,ao as ee,V as re,ap as Mt,aq as kt,ar as ne,b as se,ak as ie,e as ae,P as oe,al as le,r as gt,j as D,N as Tt,L as ce}from"./index-
|
|
1
|
+
import{an as te,ao as ee,V as re,ap as Mt,aq as kt,ar as ne,b as se,ak as ie,e as ae,P as oe,al as le,r as gt,j as D,N as Tt,L as ce}from"./index-DFrgKlHJ.js";import{A as ue}from"./AttachmentDropZone-r67Wn9ZU.js";import{f as he}from"./attachment-upload-DmLh-U0Q.js";const de=new Set(["png","jpg","jpeg","gif","webp"]),fe=new Set(["wav","mp3","m4a","ogg","webm"]),pe=new Set(["mp4"]),me=new Set(["txt","json","csv","yaml","yml","svg","tsv","log"]);function ge(y){const S=y.toLowerCase();return de.has(S)?"image":S==="pdf"?"pdf":fe.has(S)?"audio":pe.has(S)?"video":me.has(S)?"text":"unsupported"}function _e(y){return ge(he(y))}function be(y){return y==="image"||y==="pdf"||y==="audio"||y==="video"}function $t(y){return typeof y.text=="function"?y.text():new Promise((S,o)=>{const b=new FileReader;b.onload=()=>S(b.result),b.onerror=()=>o(b.error??new Error("FileReader failed")),b.readAsText(y)})}function ye(y){const S=new Map,o=new Map;for(const b of y){const h=b.filename.toLowerCase();S.has(h)||S.set(h,b),o.set(Nt(b.sourcePath),b)}return{byBasename:S,byPath:o}}function Nt(y){let S=y.trim();try{S=decodeURIComponent(S)}catch{}return S=S.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""),S.toLowerCase()}function Ct(y){const S=Nt(y),o=S.lastIndexOf("/");return o>=0?S.slice(o+1):S}function Bt(y){return/\.[a-z0-9]+$/i.test(Ct(y))}function Dt(y,S){const o=Nt(S),b=y.byPath.get(o);if(b)return b;for(const[h,i]of y.byPath)if(h===o||h.endsWith(`/${o}`))return i;return y.byBasename.get(Ct(S))??null}function Ft(y,S){const o=`/api/storage/${y.storagePath}`,b=S||y.filename;return y.isImage?``:`[${b}](${o})`}function ve(y,S){let o=0;const b=new Set,h=/(!?)\[\[([^\]|#]+)(?:[#|][^\]]*)?\]\]/g,i=y.replace(h,(c,m,v)=>{if(!Bt(v))return c;const _=Dt(S,v);return _?(o++,b.add(_.sourcePath),Ft(_,Ct(v))):c}),n=/(!?)\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)(\s+[^)]*)?\)/g;return{content:i.replace(n,(c,m,v,_,w)=>{const s=_.startsWith("<")&&_.endsWith(">")?_.slice(1,-1):_;if(/^(https?:|mailto:|tel:|#|\/api\/storage\/)/i.test(s.trim())||!Bt(s))return c;const d=Dt(S,s);if(!d)return c;o++,b.add(d.sourcePath);const a=v.trim()||Ct(s);return Ft(d,a)}),rewritten:o,referenced:b}}const we=5,ke=500;async function It(y){const{client:S,notes:o,onProgress:b,signal:h}=y,i=Math.max(1,y.concurrency??we),n=[];let r=0,c=0,m=!1;const v=o.map(ze);async function _(){for(;;){if(h!=null&&h.aborted||m)return;const l=r++;if(l>=o.length)return;const u=o[l],p=v[l],x=await xe(S,u,p,h);n[l]=x,c++,x.status==="errored"&&x.reason.startsWith("auth:")&&(m=!0),b==null||b({done:c,total:o.length})}}const w=Array.from({length:Math.min(i,o.length)},()=>_());await Promise.all(w);for(let l=0;l<o.length;l++)n[l]||(n[l]={status:"errored",sourcePath:o[l].sourcePath,reason:m?"Skipped — vault session ended before this note was reached.":"Skipped — import was cancelled."});let s=0,d=0,a=0;for(const l of n)l.status==="created"?s++:l.status==="skipped"?d++:a++;return{created:s,skipped:d,errored:a,outcomes:n}}async function xe(y,S,o,b){try{const h=await Se(y,o,b);return{status:"created",sourcePath:S.sourcePath,noteId:h.id}}catch(h){return h instanceof te||h instanceof ee?{status:"skipped",sourcePath:S.sourcePath,reason:h.message||"Already exists in vault"}:h instanceof re?{status:"errored",sourcePath:S.sourcePath,reason:`auth: ${h.message}`}:h instanceof Mt?{status:"errored",sourcePath:S.sourcePath,reason:`vault unreachable (${h.status}): ${h.message}`}:{status:"errored",sourcePath:S.sourcePath,reason:h instanceof Error?h.message:String(h)}}}async function Se(y,S,o){const b={};o&&(b.signal=o);try{return await y.createNote(S,b)}catch(h){if(!Ce(h)||o!=null&&o.aborted)throw h;return await Ee(ke,o),await y.createNote(S,b)}}function Ce(y){return y instanceof Mt}function Ee(y,S){return new Promise(o=>{const b=setTimeout(()=>{S==null||S.removeEventListener("abort",h),o()},y),h=()=>{clearTimeout(b),o()};S&&S.addEventListener("abort",h,{once:!0})})}function ze(y){const S={content:y.content};y.path&&(S.path=y.path),y.tags.length>0&&(S.tags=y.tags),Object.keys(y.metadata).length>0&&(S.metadata=y.metadata);const o=S;return y.id&&(o.id=y.id),y.createdAt&&(o.created_at=y.createdAt),S}const Lt="Imported files",Ae=20;async function Ie(y){const{client:S,parsed:o,signal:b}=y,h=[],i=[],n=[],r=[];for(const l of o.attachments)be(l.kind)?i.push(l):l.kind==="text"?n.push(l):r.push(l);const c=new Map;for(const l of i){if(b!=null&&b.aborted){h.push({status:"skipped",sourcePath:l.sourcePath,reason:"Skipped — import was cancelled."});continue}try{const u=new File([l.blob],l.filename,{type:l.blob.type||void 0}),p=await S.uploadStorageFile(u,{signal:b});c.set(l.sourcePath,{attachment:l,storagePath:p.path,mimeType:p.mimeType,isImage:p.mimeType.startsWith("image/")})}catch(u){h.push({status:"errored",sourcePath:l.sourcePath,reason:`Upload failed: ${u instanceof Error?u.message:String(u)}`})}}const m=Ne(c),v=new Map,_=o.notes.map(l=>{const{content:u,referenced:p}=ve(l.content,m);return v.set(l.sourcePath,p),{...l,content:u}}),w=await It({client:S,notes:_,...y.concurrency!==void 0?{concurrency:y.concurrency}:{},...y.onProgress?{onProgress:y.onProgress}:{},...b?{signal:b}:{}}),s=new Map;for(const l of w.outcomes)l.status==="created"&&s.set(l.sourcePath,l.noteId);const d=new Map;for(const[l,u]of v){const p=s.get(l);if(p)for(const x of u){let E=d.get(x);E||(E=new Set,d.set(x,E)),E.add(p)}}for(const[l,u]of c){const p=d.get(l);if(!p||p.size===0)continue;let x=0;for(const E of p){if(b!=null&&b.aborted)break;try{await S.linkAttachment(E,{path:u.storagePath,mimeType:u.mimeType}),x++}catch{}}h.push({status:"uploaded",sourcePath:l,storagePath:u.storagePath,references:x})}if(n.length>0&&!(b!=null&&b.aborted)){const l=[];for(const p of n)l.push(await je(p));const u=await It({client:S,notes:l,...y.concurrency!==void 0?{concurrency:y.concurrency}:{},...b?{signal:b}:{}});for(let p=0;p<n.length;p++){const x=n[p],E=u.outcomes[p];(E==null?void 0:E.status)==="created"?h.push({status:"uploaded",sourcePath:x.sourcePath,storagePath:`note:${E.noteId}`,references:1,asNote:!0}):h.push({status:"skipped",sourcePath:x.sourcePath,reason:(E==null?void 0:E.status)==="skipped"?`Imported as note, but ${E.reason}`:`Could not import as note: ${(E==null?void 0:E.status)==="errored"?E.reason:"unknown"}`})}}else if(n.length>0)for(const l of n)h.push({status:"skipped",sourcePath:l.sourcePath,reason:"Skipped — import was cancelled."});const a=[...c.entries()].filter(([l])=>{var u;return!(((u=d.get(l))==null?void 0:u.size)??0)}).map(([,l])=>l);if(a.length>0)if(b!=null&&b.aborted)for(const l of a)h.push({status:"uploaded",sourcePath:l.attachment.sourcePath,storagePath:l.storagePath,references:0});else await Re(S,a,h,y.concurrency,b);for(const l of r)h.push({status:"skipped",sourcePath:l.sourcePath,reason:`.${l.ext||"?"} is not a vault storage type — not imported. (Re-save it in a supported format to bring it across.)`});return Te(w,h)}function Ne(y){return ye([...y.values()].map(S=>({sourcePath:S.attachment.sourcePath,storagePath:S.storagePath,isImage:S.isImage,filename:S.attachment.filename})))}async function je(y){let S="";try{S=await $t(y.blob)}catch{S=""}const o=Pe(y.ext)?`\`\`\`${Oe(y.ext)}
|
|
2
2
|
${S}
|
|
3
3
|
\`\`\`
|
|
4
4
|
`:`${S}
|