@openparachute/app 0.22.15-rc.5 → 0.22.15-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.parachute/info +1 -1
- package/dist/assets/{Account-DhHWGGka.js → Account-K_xK2X9B.js} +1 -1
- package/dist/assets/{Activity-Bu5PxSEh.js → Activity-BL33NLB_.js} +1 -1
- package/dist/assets/{AddVault-CPBix09t.js → AddVault-CTe-mwRH.js} +1 -1
- package/dist/assets/{AddVaultChooser-DF1MAtCD.js → AddVaultChooser-BPJV1MeI.js} +1 -1
- package/dist/assets/{AddVaultCreate-CqvEha9g.js → AddVaultCreate-DI73o6uE.js} +1 -1
- package/dist/assets/{Calendar-CbFffAVC.js → Calendar-CaIuHTLe.js} +1 -1
- package/dist/assets/CheckEmail-CqFmFCks.js +1 -0
- package/dist/assets/{ConnectAI-UhLUS2cH.js → ConnectAI-DHagDo44.js} +1 -1
- package/dist/assets/{DayView-CeEyN0Fg.js → DayView-GOUuDzfi.js} +1 -1
- package/dist/assets/{Export-h28s7FaV.js → Export-YCQBcJkP.js} +1 -1
- package/dist/assets/{Import-CANJ9G4o.js → Import-kCFoVM-8.js} +1 -1
- package/dist/assets/{NoteEditor-CKNod4MI.js → NoteEditor-BcJb5-4o.js} +1 -1
- package/dist/assets/{NoteNew-CMrSHsl6.js → NoteNew-BHjrbBq2.js} +1 -1
- package/dist/assets/{NoteRenderer-BY-KEnKv.js → NoteRenderer-CN_XExeX.js} +1 -1
- package/dist/assets/{NoteView-DsUwfwI8.js → NoteView-DtbLplBa.js} +2 -2
- package/dist/assets/{OAuthCallback-IGh9STbH.js → OAuthCallback-BPLeIM87.js} +1 -1
- package/dist/assets/{PinArchiveButtons-RkXlPKAX.js → PinArchiveButtons-z6H_YGSc.js} +1 -1
- package/dist/assets/{Settings-DKxGA_mo.js → Settings-Ck3g9l6D.js} +1 -1
- package/dist/assets/{TagPage-CV_hUF6p.js → TagPage-oQqARXqf.js} +1 -1
- package/dist/assets/{TagSchemaEditor-DjP-tdxZ.js → TagSchemaEditor-D_LYDGRK.js} +1 -1
- package/dist/assets/{Tags-De2ZudK6.js → Tags-CyP_yKov.js} +1 -1
- package/dist/assets/{VaultGraph-mGgp1n2n.js → VaultGraph-Di0B4NaD.js} +2 -2
- package/dist/assets/{Vaults-Duy8pavb.js → Vaults-BMJUdDaM.js} +1 -1
- package/dist/assets/{ViewNew-DCQ_4tpk.js → ViewNew-Um87-wU2.js} +1 -1
- package/dist/assets/{ViewSurface-dA9zyBQ4.js → ViewSurface-D8xrFE_I.js} +1 -1
- package/dist/assets/Welcome-Cb7SFRmw.js +1 -0
- package/dist/assets/{WizardShell-m7tGZvBx.js → WizardShell-CDZWRkFh.js} +1 -1
- package/dist/assets/{attachment-upload-BIKFAeng.js → attachment-upload-B0biPzAc.js} +1 -1
- package/dist/assets/{history-BHnnhTbm.js → history-B2ZH4y8B.js} +1 -1
- package/dist/assets/index-CkXqzhj_.js +66 -0
- package/dist/assets/{provenance-D8J3QIkU.js → provenance-DnIXLZVC.js} +1 -1
- package/dist/assets/{react-force-graph-2d-CVKKfHmC.js → react-force-graph-2d-C179xgl7.js} +1 -1
- package/dist/assets/{transcribe-default-ClwrZr3h.js → transcribe-default-Z7qqgq1r.js} +1 -1
- package/dist/assets/{useAttachmentUploader-CYws-CIV.js → useAttachmentUploader-DNhr7cOE.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/CheckEmail-Aqcbnavn.js +0 -1
- package/dist/assets/Welcome-B0tCX_Yk.js +0 -1
- package/dist/assets/index-B8A8jdo2.js +0 -66
package/dist/.parachute/info
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as u,L as j,d as q,u as N,c as C,a as G,l as _,b as E,v as H,i as W,e as A,g as J,f as Q,s as z,m as K,h as X,I as D,k as Z,n as ee,o as te,p as L,q as ne,t as T,O as se,w as ae,x as re,y as le,z as O,S as R,A as ie,B as oe}from"./index-B8A8jdo2.js";import{f as ce,a as $}from"./provenance-D8J3QIkU.js";function ue(t,n){return t.trim().toLowerCase()===n.trim().toLowerCase()}const de={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,de)}const me={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 he(t){return typeof t=="string"&&(/^https?:\/\//i.test(t)||t.startsWith("/"))}function xe(t){const{vaults:n,removeVault:s}=E.getState();for(const a of Object.values(n)){const r=H(a.url)??a.name;W(a)&&t.has(r)&&s(a.id)}}async function fe(){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(ge,{email:t,onDeleted:s})}function ge({email:t,onDeleted:n}){const s=u.useId(),[a,r]=u.useState(""),[l,m]=u.useState(!1),[i,d]=u.useState(null),x=ue(a,t);async function y(o){if(o.preventDefault(),!(!x||l)){m(!0),d(null);try{const c=await fe(),p=await q(a.trim());N.getState().markClosed(),C(),xe(c),n(p)}catch(c){d(G(c,me))}finally{m(!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 ye({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&&he(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 be(){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 je(t){try{if(t){const{undo_token:n,...s}=t;sessionStorage.setItem(S,JSON.stringify(s))}else sessionStorage.removeItem(S)}catch{}}function Me(){const[t,n]=u.useState({kind:"loading"}),[s,a]=u.useState(be),r=u.useCallback(i=>{je(i),a(i)},[]),l=A(),m=N(i=>i.identityEpoch);return u.useEffect(()=>{let i=!0;return(async()=>{let d;try{d=await J()}catch{i&&n({kind:"device"});return}i&&n(d.signed_in?{kind:"manager",email:d.email,username:d.username,csrf:d.csrf}:{kind:"device"})})(),()=>{i=!1}},[m]),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(ye,{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(Te,{}):e.jsx(ve,{email:t.email,username:t.username,csrf:t.csrf,onDeleted:r})]})}function ve({email:t,username:n,csrf:s,onDeleted:a}){const r=A(),l=E(f=>f.getActiveVault()),m=N(f=>f.identityEpoch),i=Q(),d=i.isPending?"loading":i.data??null,x=z(i.data),y=u.useCallback(()=>i.refetch(),[i.refetch]),[o,c]=u.useState("loading"),[p,h]=u.useState(null);u.useEffect(()=>{let f=!0;return _().then(v=>{f&&c(v.vaults)}).catch(v=>{K(v),f&&c("error")}),X().then(v=>{f&&h(v)}),()=>{f=!1}},[m]);const g=u.useCallback(async()=>{try{const{vaults:f}=await _();c(f)}catch{c("error")}},[]);async function b(){try{await te(s)}finally{C(),r("/",{replace:!0})}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ne,{email:t,username:n,summary:x,onSignOut:b}),e.jsx(ke,{state:d,descriptor:p,onRetry:y,retrying:i.isFetching}),e.jsx(Ve,{vaults:o,summary:x,onReload:g}),e.jsx(F,{hasActiveVault:!!l}),e.jsx(pe,{email:t,descriptor:p,onDeleted:a})]})}function Ne({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(we,{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 we({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 ke({state:t,descriptor:n,onRetry:s,retrying:a}){if(t===null)return null;const r=t!=="loading"&&t!=="error"&&L(t);return t!=="loading"&&t!=="error"&&!t.billing_enabled&&!r?null:e.jsxs("section",{"aria-label":"Plan & billing",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Plan & billing"}),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(_e,{summary:t}):t.has_billing_customer?e.jsx(Ce,{summary:t}):e.jsx(Be,{summary:t,plans:(n==null?void 0:n.plans)??[]})]})}function _e({summary:t}){const n=t.has_billing_customer&&Se.has(t.plan.tier);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:se}),n?e.jsx(P,{}):null]})}const Se=new Set(["entry","standard","plus","power"]);function Ce({summary:t}){return e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),e.jsx(P,{})]})}function P(){const[t,n]=u.useState(!1),[s,a]=u.useState(null);async function r(){n(!0),a(null);try{const{url:l}=await ie();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(Y,{text:s}):null]})}const w=["monthly","quarterly","yearly"],V={monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly"},Ee={monthly:"/mo",quarterly:"/quarter",yearly:"/yr"},Ae={monthly:1,quarterly:3,yearly:12};function Ie(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 M(t,n){return t.label?t.label:typeof t.price=="number"?`$${t.price}${Ee[n]}`:null}function De(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 Oe(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 m of w){const i=t.intervals[m];if(!(i!=null&&i.available))continue;m==="monthly"&&(a=!0);const d=M(i,m);if(d&&s.push(d),typeof i.price=="number"){const x=i.price/Ae[m];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 $e(t){if(t instanceof oe)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 Y({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 Be({summary:t,plans:n}){const s=Ie(n),[a,r]=u.useState(null),l=a!==null&&s.includes(a)?a:s[0]??null,[m,i]=u.useState(null),[d,x]=u.useState(null);async function y(o){if(!m){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($e(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,p=l?(f=o.intervals)==null?void 0:f[l]:void 0,h=s.length===0||(p==null?void 0:p.available)===!0,g=Oe(o,s.length>0),b=h?null:De(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]}),g?e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:g}):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:m!==null,className:"btn btn-primary btn-sm btn-touch mt-3 w-full",children:m===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 ",M(b.entry,b.interval)]}):null]})]},o.id)})}):null,d?e.jsx(Y,{text:d}):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 Ve({vaults:t,summary:n,onReload:s}){const a=A(),[r,l]=u.useState(null),[m,i]=u.useState(null),[d,x]=u.useState(!1);async function y(h){if(!r){l(h.name),i(null);try{await ae(h.name),re(h.name),a("/")}catch(g){l(null),i(le(g,"Couldn't open that vault."))}}}async function o(){x(!0);try{await s()}finally{x(!1)}}const c=n==null?void 0:n.plan,p=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"}),p?e.jsx("span",{className:"text-xs text-fg-muted",children:p}):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:d,className:"btn btn-primary btn-touch",children:d?"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 g=ce(h.usage),b=ne(h.name).replace(/^https?:\/\//,"");return e.jsxs("li",{className:"flex items-center gap-3 py-3",children:[e.jsx(Le,{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}),g?e.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:g}):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"})})]}),m?e.jsx("p",{className:"mt-4 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:m}):null]})}function Le({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 F({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(U,{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(Z,{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(ee,{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(U,{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 U({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 Te(){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(F,{hasActiveVault:n.length>0})]})}export{Me as Account};
|
|
1
|
+
import{j as e,r as u,L as j,d as q,u as N,c as C,a as G,l as _,b as E,v as H,i as W,e as A,g as J,f as Q,s as z,m as K,h as X,I as D,k as Z,n as ee,o as te,p as L,q as ne,t as T,O as se,w as ae,x as re,y as le,z as O,S as R,A as ie,B as oe}from"./index-CkXqzhj_.js";import{f as ce,a as $}from"./provenance-DnIXLZVC.js";function ue(t,n){return t.trim().toLowerCase()===n.trim().toLowerCase()}const de={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,de)}const me={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 he(t){return typeof t=="string"&&(/^https?:\/\//i.test(t)||t.startsWith("/"))}function xe(t){const{vaults:n,removeVault:s}=E.getState();for(const a of Object.values(n)){const r=H(a.url)??a.name;W(a)&&t.has(r)&&s(a.id)}}async function fe(){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(ge,{email:t,onDeleted:s})}function ge({email:t,onDeleted:n}){const s=u.useId(),[a,r]=u.useState(""),[l,m]=u.useState(!1),[i,d]=u.useState(null),x=ue(a,t);async function y(o){if(o.preventDefault(),!(!x||l)){m(!0),d(null);try{const c=await fe(),p=await q(a.trim());N.getState().markClosed(),C(),xe(c),n(p)}catch(c){d(G(c,me))}finally{m(!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 ye({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&&he(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 be(){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 je(t){try{if(t){const{undo_token:n,...s}=t;sessionStorage.setItem(S,JSON.stringify(s))}else sessionStorage.removeItem(S)}catch{}}function Me(){const[t,n]=u.useState({kind:"loading"}),[s,a]=u.useState(be),r=u.useCallback(i=>{je(i),a(i)},[]),l=A(),m=N(i=>i.identityEpoch);return u.useEffect(()=>{let i=!0;return(async()=>{let d;try{d=await J()}catch{i&&n({kind:"device"});return}i&&n(d.signed_in?{kind:"manager",email:d.email,username:d.username,csrf:d.csrf}:{kind:"device"})})(),()=>{i=!1}},[m]),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(ye,{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(Te,{}):e.jsx(ve,{email:t.email,username:t.username,csrf:t.csrf,onDeleted:r})]})}function ve({email:t,username:n,csrf:s,onDeleted:a}){const r=A(),l=E(f=>f.getActiveVault()),m=N(f=>f.identityEpoch),i=Q(),d=i.isPending?"loading":i.data??null,x=z(i.data),y=u.useCallback(()=>i.refetch(),[i.refetch]),[o,c]=u.useState("loading"),[p,h]=u.useState(null);u.useEffect(()=>{let f=!0;return _().then(v=>{f&&c(v.vaults)}).catch(v=>{K(v),f&&c("error")}),X().then(v=>{f&&h(v)}),()=>{f=!1}},[m]);const g=u.useCallback(async()=>{try{const{vaults:f}=await _();c(f)}catch{c("error")}},[]);async function b(){try{await te(s)}finally{C(),r("/",{replace:!0})}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ne,{email:t,username:n,summary:x,onSignOut:b}),e.jsx(ke,{state:d,descriptor:p,onRetry:y,retrying:i.isFetching}),e.jsx(Ve,{vaults:o,summary:x,onReload:g}),e.jsx(F,{hasActiveVault:!!l}),e.jsx(pe,{email:t,descriptor:p,onDeleted:a})]})}function Ne({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(we,{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 we({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 ke({state:t,descriptor:n,onRetry:s,retrying:a}){if(t===null)return null;const r=t!=="loading"&&t!=="error"&&L(t);return t!=="loading"&&t!=="error"&&!t.billing_enabled&&!r?null:e.jsxs("section",{"aria-label":"Plan & billing",className:"card p-6 shadow-soft",children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Plan & billing"}),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(_e,{summary:t}):t.has_billing_customer?e.jsx(Ce,{summary:t}):e.jsx(Be,{summary:t,plans:(n==null?void 0:n.plans)??[]})]})}function _e({summary:t}){const n=t.has_billing_customer&&Se.has(t.plan.tier);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:se}),n?e.jsx(P,{}):null]})}const Se=new Set(["entry","standard","plus","power"]);function Ce({summary:t}){return e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:I(t)}),e.jsx(P,{})]})}function P(){const[t,n]=u.useState(!1),[s,a]=u.useState(null);async function r(){n(!0),a(null);try{const{url:l}=await ie();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(Y,{text:s}):null]})}const w=["monthly","quarterly","yearly"],V={monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly"},Ee={monthly:"/mo",quarterly:"/quarter",yearly:"/yr"},Ae={monthly:1,quarterly:3,yearly:12};function Ie(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 M(t,n){return t.label?t.label:typeof t.price=="number"?`$${t.price}${Ee[n]}`:null}function De(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 Oe(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 m of w){const i=t.intervals[m];if(!(i!=null&&i.available))continue;m==="monthly"&&(a=!0);const d=M(i,m);if(d&&s.push(d),typeof i.price=="number"){const x=i.price/Ae[m];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 $e(t){if(t instanceof oe)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 Y({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 Be({summary:t,plans:n}){const s=Ie(n),[a,r]=u.useState(null),l=a!==null&&s.includes(a)?a:s[0]??null,[m,i]=u.useState(null),[d,x]=u.useState(null);async function y(o){if(!m){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($e(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,p=l?(f=o.intervals)==null?void 0:f[l]:void 0,h=s.length===0||(p==null?void 0:p.available)===!0,g=Oe(o,s.length>0),b=h?null:De(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]}),g?e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:g}):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:m!==null,className:"btn btn-primary btn-sm btn-touch mt-3 w-full",children:m===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 ",M(b.entry,b.interval)]}):null]})]},o.id)})}):null,d?e.jsx(Y,{text:d}):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 Ve({vaults:t,summary:n,onReload:s}){const a=A(),[r,l]=u.useState(null),[m,i]=u.useState(null),[d,x]=u.useState(!1);async function y(h){if(!r){l(h.name),i(null);try{await ae(h.name),re(h.name),a("/")}catch(g){l(null),i(le(g,"Couldn't open that vault."))}}}async function o(){x(!0);try{await s()}finally{x(!1)}}const c=n==null?void 0:n.plan,p=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"}),p?e.jsx("span",{className:"text-xs text-fg-muted",children:p}):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:d,className:"btn btn-primary btn-touch",children:d?"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 g=ce(h.usage),b=ne(h.name).replace(/^https?:\/\//,"");return e.jsxs("li",{className:"flex items-center gap-3 py-3",children:[e.jsx(Le,{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}),g?e.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:g}):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"})})]}),m?e.jsx("p",{className:"mt-4 rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:m}):null]})}function Le({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 F({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(U,{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(Z,{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(ee,{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(U,{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 U({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 Te(){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(F,{hasActiveVault:n.length>0})]})}export{Me 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-CkXqzhj_.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-CkXqzhj_.js";import{W as O}from"./WizardShell-CDZWRkFh.js";import"./history-B2ZH4y8B.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-CkXqzhj_.js";import{W as x}from"./WizardShell-CDZWRkFh.js";import"./history-B2ZH4y8B.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-CkXqzhj_.js";import{W as p}from"./WizardShell-CDZWRkFh.js";import"./history-B2ZH4y8B.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{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-CkXqzhj_.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as R,P as I,bf as v,r as s,a1 as L,j as e,N as M,$ as O,g as h,c3 as P,c4 as T,c5 as W}from"./index-CkXqzhj_.js";import{W as _}from"./WizardShell-CDZWRkFh.js";import"./history-B2ZH4y8B.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 +1 @@
|
|
|
1
|
-
import{aa as p,r as m,l as g,v as f,b,j as e,N as j,L as i,ab as u}from"./index-
|
|
1
|
+
import{aa as p,r as m,l as g,v as f,b,j as e,N as j,L as i,ab as u}from"./index-CkXqzhj_.js";function y(t){return`${t.replace(/\/+$/,"")}/mcp`}function C(t){return`parachute-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"vault"}`}function N(t,a){return`claude mcp add --transport http ${C(t)} ${a}`}function v(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}}const k=4e3;function A(t,a){const s=y(t.url),n=p(t.clientId),[r,c]=m.useState({url:s,settled:!n});return m.useEffect(()=>{if(!n){c({url:s,settled:!0});return}let l=!0;c({url:s,settled:!1});const d=setTimeout(()=>{l&&c({url:s,settled:!0}),l=!1},k);return g(a).then(o=>{if(!l)return;clearTimeout(d);const x=v(Array.isArray(o==null?void 0:o.vaults)?o.vaults:[],f(t.url)??t.name);c({url:x??s,settled:!0})}).catch(()=>{clearTimeout(d),l&&c({url:s,settled:!0})}),()=>{l=!1,clearTimeout(d)}},[n,s,t.name,t.url,a]),r}function I(){const t=b(a=>a.getActiveVault());return t?e.jsx(P,{vault:t}):e.jsx(j,{to:"/",replace:!0})}function P({vault:t}){const{url:a,settled:s}=A(t),n=N(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(i,{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(u,{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(i,{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(h,{title:"Claude",initial:"C",tone:"coral",steps:w,note:"On Claude's free plan you can add one custom connector."}),e.jsx(h,{title:"ChatGPT",initial:"G",tone:"grass",steps:T,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(u,{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(i,{to:"/",className:"btn btn-primary btn-touch",children:"Done — back to your vault"})})]})}const w=[{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."]})}],T=[{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 h({title:t,initial:a,tone:s,steps:n,note:r}){const c=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 ${c}`,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{I as ConnectAI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as P,P as C,j as e,N as v,D as L,ac as B,F as k,C as y,E as w,G as E,r as S,a6 as D,L as o,ad as K,ae as $,H as I,J as _,K as M,af as F,ag as H,ah as O,ai as U,V as G}from"./index-
|
|
1
|
+
import{b as P,P as C,j as e,N as v,D as L,ac as B,F as k,C as y,E as w,G as E,r as S,a6 as D,L as o,ad as K,ae as $,H as I,J as _,K as M,af as F,ag as H,ah as O,ai as U,V as G}from"./index-CkXqzhj_.js";import{u as J}from"./history-B2ZH4y8B.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,aj as m,ak as p,r as d,j as e,N as x,al as h,L as g}from"./index-
|
|
1
|
+
import{b as u,aj as m,ak as p,r as d,j as e,N as x,al as h,L as g}from"./index-CkXqzhj_.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{am as te,an as ee,V as re,ao as Mt,ap as kt,aq as ne,b as se,aj as ie,e as ae,P as oe,ak as le,r as gt,j as D,N as Tt,L as ce}from"./index-
|
|
1
|
+
import{am as te,an as ee,V as re,ao as Mt,ap as kt,aq as ne,b as se,aj as ie,e as ae,P as oe,ak as le,r as gt,j as D,N as Tt,L as ce}from"./index-CkXqzhj_.js";import{f as ue,A as he}from"./attachment-upload-B0biPzAc.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(ue(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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,ak as H,ar as le,V as I,al as ce,as as de,b as J,at as ue,N as me,L as $,J as fe,K as he,e as xe,au as K,av as pe,aw as ge,ax as be,ay as ve,am as je,az as P,aA as Ne,aB as we,aC as ye,M as F,aD as Se}from"./index-B8A8jdo2.js";import{A as ke}from"./attachment-upload-BIKFAeng.js";import{u as Ce,C as Ee,A as Re,a as Ae}from"./useAttachmentUploader-CYws-CIV.js";import{P as De,D as Te}from"./PinArchiveButtons-RkXlPKAX.js";import{b as Pe,N as Ie}from"./NoteRenderer-BY-KEnKv.js";import{r as $e}from"./editor-mode-D9fveTEx.js";const Fe=250;function Le({noteId:t,attachment:a}){const[r,i]=n.useState(!1),x=Be(a);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>i(!0),"aria-label":`Remove attachment ${x}`,className:"shrink-0 rounded border border-transparent px-1.5 py-0.5 text-fg-dim hover:border-red-500/40 hover:text-red-400",children:"✕"}),r?e.jsx(Ve,{noteId:t,attachment:a,label:x,onClose:()=>i(!1)}):null]})}function Ve({noteId:t,attachment:a,label:r,onClose:i}){const x=H(c=>c.push),l=le(),[u,m]=n.useState(!1),[f,N]=n.useState(null),d=n.useRef(null);n.useEffect(()=>{const c=setTimeout(()=>m(!0),Fe);return()=>clearTimeout(c)},[]),n.useEffect(()=>{var c;(c=d.current)==null||c.focus()},[]),n.useEffect(()=>{const c=k=>{k.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]);const g=n.useCallback(()=>{!u||l.isPending||(N(null),l.mutate({noteId:t,attachmentId:a.id},{onSuccess:()=>{x(`Removed ${r}`,"success"),i()},onError:c=>{if(c instanceof I){N("Session expired. Reconnect to remove attachments.");return}if(c instanceof ce){x(`Already removed ${r}`,"info"),i();return}N(c instanceof Error?c.message:"Remove failed")}}))},[u,a.id,r,l,t,i,x]);return e.jsx("dialog",{open:!0,"aria-labelledby":"confirm-remove-attachment-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:c=>{c.target===c.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"confirm-remove-attachment-title",className:"mb-2 font-serif text-lg text-red-400",children:"Remove attachment?"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[e.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:r})," ","will be detached from this note. If no other note references the file, it will also be deleted from storage. Markdown referencing it will show a broken link until you update it."]}),f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{ref:d,type:"button",onClick:i,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:g,disabled:!u||l.isPending,className:"btn btn-danger-solid btn-touch",children:l.isPending?"Removing…":"Remove"})]})]})})}function Be(t){if(t.filename)return t.filename;if(t.path){const a=t.path.split("/").pop();return a||t.path}return t.id}function Xe(){const{id:t}=de(),a=J(i=>i.getActiveVault()),r=ue(t);return a?e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx($,{to:t?`/n/${encodeURIComponent(t)}`:"/",className:"focus-ring hover:text-accent",children:"← Back to note"})}),r.isPending?e.jsx(_e,{}):r.isError?e.jsx(We,{error:r.error}):r.data?e.jsx(Me,{note:r.data}):e.jsx(ze,{id:t??""})]}):e.jsx(me,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function Me({note:t}){const a=xe(),r=H(s=>s.push),i=K(s=>s.on),x=K(s=>s.setOn),l=n.useRef(J.getState().activeVaultId).current,u=n.useRef($e()).current,m=n.useMemo(()=>Pe(t),[t]),[f,N]=n.useState(()=>S(t)),[d,g]=n.useState(()=>S(t)),[c,k]=n.useState(()=>{if(!l)return null;const s=pe(l,t.id);return!s||ge(s.body,S(t))?null:s}),[G,L]=n.useState(""),[V,C]=n.useState(null),[B,E]=n.useState(null),[M,U]=n.useState(!1),w=n.useRef(null);n.useEffect(()=>()=>{w.current!==null&&window.clearTimeout(w.current)},[]);const[R,Q]=n.useState("edit"),j=be(t.id),A=n.useRef(t),D=n.useRef(null),O=n.useRef(null),v=Ce({noteId:t.id,onInsert:s=>{D.current?D.current.insertAtCursor(s):g(o=>({...o,content:`${o.content}${s}`}))},onLinked:()=>{r("Attachment added","success")},onError:s=>r(s,"error")});n.useEffect(()=>{A.current=t},[t]);const h=d.content!==f.content||d.path!==f.path||!qe(d.tags,f.tags);ve(l,t.id,d,h);const y=v.uploads.some(s=>s.status==="uploading"||s.status==="linking"),T=n.useCallback(({navigateToView:s})=>{if(!h||j.isPending||y)return;const o={};d.content!==f.content&&(o.content=d.content),d.path!==f.path&&(o.path=d.path);const b=Ke(f.tags,d.tags);(b.add.length||b.remove.length)&&(o.tags=b);const q=A.current.updatedAt??A.current.createdAt;q&&(o.if_updated_at=q),E(null),C(null),j.mutate(o,{onSuccess:p=>{N(S(p)),g(S(p)),A.current=p,l&&P(l,t.id),s?a(`/n/${encodeURIComponent(p.id)}`,{replace:!0}):p.id!==t.id&&a(`/n/${encodeURIComponent(p.id)}/edit`,{replace:!0}),s||(U(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>U(!1),1500))},onError:p=>{p instanceof je?C(p):p instanceof I?E("Session expired. Reconnect to save."):E(p instanceof Error?p.message:"Save failed")}})},[f,d,h,j,a,t.id,y,l]),X=n.useCallback(()=>{c&&g(c.body),k(null)},[c]),ee=n.useCallback(()=>{l&&P(l,t.id),k(null)},[l,t.id]),te=n.useCallback(()=>T({navigateToView:!0}),[T]),se=n.useCallback(()=>T({navigateToView:!1}),[T]),ne=n.useCallback(()=>{h&&confirm("Discard all edits and revert to last saved version?")&&(g(f),C(null),E(null))},[f,h]),_=n.useCallback(()=>{h&&!confirm("Discard unsaved changes?")||(l&&P(l,t.id),a(`/n/${encodeURIComponent(t.id)}`))},[h,a,t.id,l]);n.useEffect(()=>{if(!h)return;const s=o=>{o.preventDefault(),o.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[h]);const z=n.useRef(i);n.useEffect(()=>{var o;const s=i&&!z.current;z.current=i,s&&((o=D.current)==null||o.focus())},[i]);const ae=d.path!==f.path,re=s=>{const o=Se(s);o&&(d.tags.includes(o)||(g(b=>({...b,tags:[...b.tags,o]})),L("")))},ie=s=>{g(o=>({...o,tags:o.tags.filter(b=>b!==s)}))},oe=d.content,W=i?"h-[85dvh]":"h-[60dvh]";return e.jsxs("article",{children:[i?e.jsx("div",{className:"glass-panel enter-fade fixed top-4 left-4 z-30 rounded-full border border-border px-3 py-1.5 text-xs shadow-lift",style:{marginTop:"env(safe-area-inset-top)"},children:e.jsx(Y,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})}):e.jsxs("header",{className:"card mb-6 p-5 shadow-soft md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"eyebrow",children:"Editing"}),e.jsx(Y,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(De,{note:t}),e.jsx(Te,{note:t}),e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(Ne,{width:16,height:16}),"Focus"]}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",onClick:ne,disabled:!h||j.isPending,className:"btn btn-secondary btn-touch",children:"Revert"}),e.jsx("button",{type:"button",onClick:_,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:te,disabled:!h||j.isPending||y,className:"btn btn-primary btn-touch",title:y?"Waiting for upload…":"Save (⌘S)","aria-label":y?"Save — waiting for upload…":"Save",children:j.isPending?"Saving…":"Save"})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(we,{tags:d.tags,input:G,onInputChange:L,onAdd:re,onRemove:ie})}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-xs",children:"Path"}),e.jsx("input",{type:"text",value:d.path,onChange:s=>g(o=>({...o,path:s.target.value})),className:"focus-ring w-full min-w-0 truncate rounded border-0 bg-transparent font-mono text-xs text-fg-dim outline-none transition-colors hover:text-fg-muted focus:text-fg placeholder:text-fg-dim","aria-label":"Note path",placeholder:"(no path)",title:d.path||void 0})]}),ae?e.jsx("p",{className:"mt-1 text-xs text-accent",children:"Renaming moves the note — its id may change."}):null,ye(d.path)?e.jsx("p",{className:"mt-1 text-xs text-danger",children:"This path is reserved for a built-in view. Notes saved here will not appear in the Views rail."}):null]}),c?e.jsxs("div",{role:"status","data-testid":"draft-offer",className:"mb-4 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-accent/30 bg-accent/5 px-3 py-2 text-sm",children:[e.jsxs("span",{className:"text-fg-muted",children:["You have an unsaved draft from ",F(c.savedAt),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:X,className:"focus-ring font-medium text-accent hover:underline",children:"Restore"}),e.jsx("button",{type:"button",onClick:ee,className:"focus-ring text-fg-dim hover:text-danger",children:"Discard"})]})]}):null,V?e.jsx(Oe,{conflict:V,onReload:()=>{l&&P(l,t.id),window.location.reload()},onDismiss:()=>C(null)}):null,B?e.jsx("div",{className:"mb-4 rounded-xl border border-danger-border bg-danger-soft p-3 text-sm text-danger",children:B}):null,u?null:e.jsx("div",{role:"tablist","aria-label":"Editor view",className:"mb-3 inline-flex rounded-lg border border-border bg-card p-0.5 text-sm lg:hidden",children:["edit","preview"].map(s=>e.jsx("button",{type:"button",role:"tab","aria-selected":R===s,onClick:()=>Q(s),className:`rounded-sm px-3 py-1.5 capitalize ${R===s?"bg-accent text-on-accent":"text-fg-muted hover:text-accent"}`,children:s},s))}),e.jsxs("div",{className:`grid ${i?"min-h-[85dvh]":"min-h-[60dvh]"} gap-4 ${u?"":"lg:grid-cols-2"}`,children:[e.jsx(ke,{onDropFiles:v.start,className:`card min-h-0 ${W} min-w-0 ${u||R==="edit"?"":"hidden lg:block"}`,hint:Z,children:e.jsx(Ee,{ref:D,value:d.content,onChange:s=>g(o=>({...o,content:s})),onSave:se,onCancel:_,onPasteFile:s=>(v.start(s),!0),onRequestAttachment:()=>{var s;return(s=O.current)==null?void 0:s.open()},livePreview:u})}),u?null:e.jsx("div",{className:`card min-h-0 ${W} min-w-0 overflow-auto p-4 ${R==="preview"?"":"hidden lg:block"}`,children:e.jsx(Ie,{note:{path:d.path,content:oe},resolve:m})})]}),e.jsx(Ue,{noteId:t.id,pickerRef:O,attachments:t.attachments??[],uploads:v.uploads,onPickFiles:v.start,onCancel:v.cancel,onDismiss:v.dismiss})]})}const Z=e.jsxs(e.Fragment,{children:["Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"text-accent hover:underline",children:"PDF + mp4 coming"})]});function Ue({noteId:t,pickerRef:a,attachments:r,uploads:i,onPickFiles:x,onCancel:l,onDismiss:u}){return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-xl",children:"Attachments"}),e.jsx(Re,{ref:a,onPickFiles:x})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Max 100 MB each. ",Z,"."]}),e.jsx(Ae,{uploads:i,onCancel:l,onDismiss:u}),r.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:r.map(m=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card/50 px-3 py-1.5 font-mono text-xs",children:[e.jsx("span",{className:"truncate",title:m.path??m.id,children:m.filename??m.path??m.id}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.mimeType?e.jsx("span",{className:"text-fg-dim",children:m.mimeType}):null,e.jsx(Le,{noteId:t,attachment:m})]})]},m.id))}):null]})}function Oe({conflict:t,onReload:a,onDismiss:r}){return e.jsxs("div",{className:"mb-4 rounded-xl border border-warning bg-warning-soft p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-warning",children:"This note was edited elsewhere."}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Your save was rejected to avoid overwriting the other edit.",t.currentUpdatedAt?` Latest update ${F(t.currentUpdatedAt)}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-touch",children:"Reload latest (discard my edits)"}),e.jsx("button",{type:"button",onClick:r,className:"btn btn-secondary btn-touch",children:"Keep editing"})]})]})}function _e(){return e.jsxs("div",{className:"grid min-h-[60dvh] gap-4 lg:grid-cols-2","aria-busy":"true",children:[e.jsx("div",{className:"card animate-pulse"}),e.jsx("div",{className:"card animate-pulse"})]})}function ze({id:t}){return e.jsx(he,{title:e.jsx("span",{className:"font-serif text-xl text-fg",children:"Note not found"}),description:e.jsxs(e.Fragment,{children:["No note with id ",e.jsx("span",{className:"font-mono",children:t})," in this vault."]}),action:e.jsx($,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Y({isDirty:t,justSaved:a,updatedAt:r}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-accent","aria-label":"unsaved changes",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"unsaved"]}):a?e.jsx("span",{className:"text-xs text-accent","aria-label":"saved",children:"Saved ✓"}):e.jsxs("span",{className:"text-xs text-fg-dim",children:["saved ",F(r)]})}function We({error:t}){const a=t instanceof I;return e.jsx(fe,{title:a?"Session expired":"Could not load note",message:t.message,action:a?e.jsx($,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function qe(t,a){if(t.length!==a.length)return!1;const r=new Set(t);for(const i of a)if(!r.has(i))return!1;return!0}function Ke(t,a){const r=new Set(t),i=new Set(a),x=a.filter(u=>!r.has(u)),l=t.filter(u=>!i.has(u));return{add:x,remove:l}}export{Xe as NoteEditor};
|
|
1
|
+
import{r as n,j as e,ak as H,ar as le,V as I,al as ce,as as de,b as J,at as ue,N as me,L as $,J as fe,K as he,e as xe,au as K,av as pe,aw as ge,ax as be,ay as ve,am as je,az as P,aA as Ne,aB as we,aC as ye,M as F,aD as Se}from"./index-CkXqzhj_.js";import{A as ke}from"./attachment-upload-B0biPzAc.js";import{u as Ce,C as Ee,A as Re,a as Ae}from"./useAttachmentUploader-DNhr7cOE.js";import{P as De,D as Te}from"./PinArchiveButtons-z6H_YGSc.js";import{b as Pe,N as Ie}from"./NoteRenderer-CN_XExeX.js";import{r as $e}from"./editor-mode-D9fveTEx.js";const Fe=250;function Le({noteId:t,attachment:a}){const[r,i]=n.useState(!1),x=Be(a);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>i(!0),"aria-label":`Remove attachment ${x}`,className:"shrink-0 rounded border border-transparent px-1.5 py-0.5 text-fg-dim hover:border-red-500/40 hover:text-red-400",children:"✕"}),r?e.jsx(Ve,{noteId:t,attachment:a,label:x,onClose:()=>i(!1)}):null]})}function Ve({noteId:t,attachment:a,label:r,onClose:i}){const x=H(c=>c.push),l=le(),[u,m]=n.useState(!1),[f,N]=n.useState(null),d=n.useRef(null);n.useEffect(()=>{const c=setTimeout(()=>m(!0),Fe);return()=>clearTimeout(c)},[]),n.useEffect(()=>{var c;(c=d.current)==null||c.focus()},[]),n.useEffect(()=>{const c=k=>{k.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]);const g=n.useCallback(()=>{!u||l.isPending||(N(null),l.mutate({noteId:t,attachmentId:a.id},{onSuccess:()=>{x(`Removed ${r}`,"success"),i()},onError:c=>{if(c instanceof I){N("Session expired. Reconnect to remove attachments.");return}if(c instanceof ce){x(`Already removed ${r}`,"info"),i();return}N(c instanceof Error?c.message:"Remove failed")}}))},[u,a.id,r,l,t,i,x]);return e.jsx("dialog",{open:!0,"aria-labelledby":"confirm-remove-attachment-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:c=>{c.target===c.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"confirm-remove-attachment-title",className:"mb-2 font-serif text-lg text-red-400",children:"Remove attachment?"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[e.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:r})," ","will be detached from this note. If no other note references the file, it will also be deleted from storage. Markdown referencing it will show a broken link until you update it."]}),f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{ref:d,type:"button",onClick:i,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:g,disabled:!u||l.isPending,className:"btn btn-danger-solid btn-touch",children:l.isPending?"Removing…":"Remove"})]})]})})}function Be(t){if(t.filename)return t.filename;if(t.path){const a=t.path.split("/").pop();return a||t.path}return t.id}function Xe(){const{id:t}=de(),a=J(i=>i.getActiveVault()),r=ue(t);return a?e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx($,{to:t?`/n/${encodeURIComponent(t)}`:"/",className:"focus-ring hover:text-accent",children:"← Back to note"})}),r.isPending?e.jsx(_e,{}):r.isError?e.jsx(We,{error:r.error}):r.data?e.jsx(Me,{note:r.data}):e.jsx(ze,{id:t??""})]}):e.jsx(me,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function Me({note:t}){const a=xe(),r=H(s=>s.push),i=K(s=>s.on),x=K(s=>s.setOn),l=n.useRef(J.getState().activeVaultId).current,u=n.useRef($e()).current,m=n.useMemo(()=>Pe(t),[t]),[f,N]=n.useState(()=>S(t)),[d,g]=n.useState(()=>S(t)),[c,k]=n.useState(()=>{if(!l)return null;const s=pe(l,t.id);return!s||ge(s.body,S(t))?null:s}),[G,L]=n.useState(""),[V,C]=n.useState(null),[B,E]=n.useState(null),[M,U]=n.useState(!1),w=n.useRef(null);n.useEffect(()=>()=>{w.current!==null&&window.clearTimeout(w.current)},[]);const[R,Q]=n.useState("edit"),j=be(t.id),A=n.useRef(t),D=n.useRef(null),O=n.useRef(null),v=Ce({noteId:t.id,onInsert:s=>{D.current?D.current.insertAtCursor(s):g(o=>({...o,content:`${o.content}${s}`}))},onLinked:()=>{r("Attachment added","success")},onError:s=>r(s,"error")});n.useEffect(()=>{A.current=t},[t]);const h=d.content!==f.content||d.path!==f.path||!qe(d.tags,f.tags);ve(l,t.id,d,h);const y=v.uploads.some(s=>s.status==="uploading"||s.status==="linking"),T=n.useCallback(({navigateToView:s})=>{if(!h||j.isPending||y)return;const o={};d.content!==f.content&&(o.content=d.content),d.path!==f.path&&(o.path=d.path);const b=Ke(f.tags,d.tags);(b.add.length||b.remove.length)&&(o.tags=b);const q=A.current.updatedAt??A.current.createdAt;q&&(o.if_updated_at=q),E(null),C(null),j.mutate(o,{onSuccess:p=>{N(S(p)),g(S(p)),A.current=p,l&&P(l,t.id),s?a(`/n/${encodeURIComponent(p.id)}`,{replace:!0}):p.id!==t.id&&a(`/n/${encodeURIComponent(p.id)}/edit`,{replace:!0}),s||(U(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>U(!1),1500))},onError:p=>{p instanceof je?C(p):p instanceof I?E("Session expired. Reconnect to save."):E(p instanceof Error?p.message:"Save failed")}})},[f,d,h,j,a,t.id,y,l]),X=n.useCallback(()=>{c&&g(c.body),k(null)},[c]),ee=n.useCallback(()=>{l&&P(l,t.id),k(null)},[l,t.id]),te=n.useCallback(()=>T({navigateToView:!0}),[T]),se=n.useCallback(()=>T({navigateToView:!1}),[T]),ne=n.useCallback(()=>{h&&confirm("Discard all edits and revert to last saved version?")&&(g(f),C(null),E(null))},[f,h]),_=n.useCallback(()=>{h&&!confirm("Discard unsaved changes?")||(l&&P(l,t.id),a(`/n/${encodeURIComponent(t.id)}`))},[h,a,t.id,l]);n.useEffect(()=>{if(!h)return;const s=o=>{o.preventDefault(),o.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[h]);const z=n.useRef(i);n.useEffect(()=>{var o;const s=i&&!z.current;z.current=i,s&&((o=D.current)==null||o.focus())},[i]);const ae=d.path!==f.path,re=s=>{const o=Se(s);o&&(d.tags.includes(o)||(g(b=>({...b,tags:[...b.tags,o]})),L("")))},ie=s=>{g(o=>({...o,tags:o.tags.filter(b=>b!==s)}))},oe=d.content,W=i?"h-[85dvh]":"h-[60dvh]";return e.jsxs("article",{children:[i?e.jsx("div",{className:"glass-panel enter-fade fixed top-4 left-4 z-30 rounded-full border border-border px-3 py-1.5 text-xs shadow-lift",style:{marginTop:"env(safe-area-inset-top)"},children:e.jsx(Y,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})}):e.jsxs("header",{className:"card mb-6 p-5 shadow-soft md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"eyebrow",children:"Editing"}),e.jsx(Y,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(De,{note:t}),e.jsx(Te,{note:t}),e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(Ne,{width:16,height:16}),"Focus"]}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",onClick:ne,disabled:!h||j.isPending,className:"btn btn-secondary btn-touch",children:"Revert"}),e.jsx("button",{type:"button",onClick:_,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:te,disabled:!h||j.isPending||y,className:"btn btn-primary btn-touch",title:y?"Waiting for upload…":"Save (⌘S)","aria-label":y?"Save — waiting for upload…":"Save",children:j.isPending?"Saving…":"Save"})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(we,{tags:d.tags,input:G,onInputChange:L,onAdd:re,onRemove:ie})}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-xs",children:"Path"}),e.jsx("input",{type:"text",value:d.path,onChange:s=>g(o=>({...o,path:s.target.value})),className:"focus-ring w-full min-w-0 truncate rounded border-0 bg-transparent font-mono text-xs text-fg-dim outline-none transition-colors hover:text-fg-muted focus:text-fg placeholder:text-fg-dim","aria-label":"Note path",placeholder:"(no path)",title:d.path||void 0})]}),ae?e.jsx("p",{className:"mt-1 text-xs text-accent",children:"Renaming moves the note — its id may change."}):null,ye(d.path)?e.jsx("p",{className:"mt-1 text-xs text-danger",children:"This path is reserved for a built-in view. Notes saved here will not appear in the Views rail."}):null]}),c?e.jsxs("div",{role:"status","data-testid":"draft-offer",className:"mb-4 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-accent/30 bg-accent/5 px-3 py-2 text-sm",children:[e.jsxs("span",{className:"text-fg-muted",children:["You have an unsaved draft from ",F(c.savedAt),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:X,className:"focus-ring font-medium text-accent hover:underline",children:"Restore"}),e.jsx("button",{type:"button",onClick:ee,className:"focus-ring text-fg-dim hover:text-danger",children:"Discard"})]})]}):null,V?e.jsx(Oe,{conflict:V,onReload:()=>{l&&P(l,t.id),window.location.reload()},onDismiss:()=>C(null)}):null,B?e.jsx("div",{className:"mb-4 rounded-xl border border-danger-border bg-danger-soft p-3 text-sm text-danger",children:B}):null,u?null:e.jsx("div",{role:"tablist","aria-label":"Editor view",className:"mb-3 inline-flex rounded-lg border border-border bg-card p-0.5 text-sm lg:hidden",children:["edit","preview"].map(s=>e.jsx("button",{type:"button",role:"tab","aria-selected":R===s,onClick:()=>Q(s),className:`rounded-sm px-3 py-1.5 capitalize ${R===s?"bg-accent text-on-accent":"text-fg-muted hover:text-accent"}`,children:s},s))}),e.jsxs("div",{className:`grid ${i?"min-h-[85dvh]":"min-h-[60dvh]"} gap-4 ${u?"":"lg:grid-cols-2"}`,children:[e.jsx(ke,{onDropFiles:v.start,className:`card min-h-0 ${W} min-w-0 ${u||R==="edit"?"":"hidden lg:block"}`,hint:Z,children:e.jsx(Ee,{ref:D,value:d.content,onChange:s=>g(o=>({...o,content:s})),onSave:se,onCancel:_,onPasteFile:s=>(v.start(s),!0),onRequestAttachment:()=>{var s;return(s=O.current)==null?void 0:s.open()},livePreview:u})}),u?null:e.jsx("div",{className:`card min-h-0 ${W} min-w-0 overflow-auto p-4 ${R==="preview"?"":"hidden lg:block"}`,children:e.jsx(Ie,{note:{path:d.path,content:oe},resolve:m})})]}),e.jsx(Ue,{noteId:t.id,pickerRef:O,attachments:t.attachments??[],uploads:v.uploads,onPickFiles:v.start,onCancel:v.cancel,onDismiss:v.dismiss})]})}const Z=e.jsxs(e.Fragment,{children:["Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"text-accent hover:underline",children:"PDF + mp4 coming"})]});function Ue({noteId:t,pickerRef:a,attachments:r,uploads:i,onPickFiles:x,onCancel:l,onDismiss:u}){return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-xl",children:"Attachments"}),e.jsx(Re,{ref:a,onPickFiles:x})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Max 100 MB each. ",Z,"."]}),e.jsx(Ae,{uploads:i,onCancel:l,onDismiss:u}),r.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:r.map(m=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card/50 px-3 py-1.5 font-mono text-xs",children:[e.jsx("span",{className:"truncate",title:m.path??m.id,children:m.filename??m.path??m.id}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.mimeType?e.jsx("span",{className:"text-fg-dim",children:m.mimeType}):null,e.jsx(Le,{noteId:t,attachment:m})]})]},m.id))}):null]})}function Oe({conflict:t,onReload:a,onDismiss:r}){return e.jsxs("div",{className:"mb-4 rounded-xl border border-warning bg-warning-soft p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-warning",children:"This note was edited elsewhere."}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Your save was rejected to avoid overwriting the other edit.",t.currentUpdatedAt?` Latest update ${F(t.currentUpdatedAt)}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-touch",children:"Reload latest (discard my edits)"}),e.jsx("button",{type:"button",onClick:r,className:"btn btn-secondary btn-touch",children:"Keep editing"})]})]})}function _e(){return e.jsxs("div",{className:"grid min-h-[60dvh] gap-4 lg:grid-cols-2","aria-busy":"true",children:[e.jsx("div",{className:"card animate-pulse"}),e.jsx("div",{className:"card animate-pulse"})]})}function ze({id:t}){return e.jsx(he,{title:e.jsx("span",{className:"font-serif text-xl text-fg",children:"Note not found"}),description:e.jsxs(e.Fragment,{children:["No note with id ",e.jsx("span",{className:"font-mono",children:t})," in this vault."]}),action:e.jsx($,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Y({isDirty:t,justSaved:a,updatedAt:r}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-accent","aria-label":"unsaved changes",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"unsaved"]}):a?e.jsx("span",{className:"text-xs text-accent","aria-label":"saved",children:"Saved ✓"}):e.jsxs("span",{className:"text-xs text-fg-dim",children:["saved ",F(r)]})}function We({error:t}){const a=t instanceof I;return e.jsx(fe,{title:a?"Session expired":"Could not load note",message:t.message,action:a?e.jsx($,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function qe(t,a){if(t.length!==a.length)return!1;const r=new Set(t);for(const i of a)if(!r.has(i))return!1;return!0}function Ke(t,a){const r=new Set(t),i=new Set(a),x=a.filter(u=>!r.has(u)),l=t.filter(u=>!i.has(u));return{add:x,remove:l}}export{Xe as NoteEditor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aE as Le,r,aF as Ue,aG as Fe,aH as ge,b as Ve,e as qe,ak as Oe,aI as Be,aJ as Ge,aK as He,aL as We,af as Ye,aj as Ke,aM as Qe,av as Ze,aN as ze,P as Je,ay as Xe,j as e,N as et,aO as tt,aP as st,aQ as xe,V as nt,az as W,aR as at,aS as rt,aT as ot,aU as it,aV as ee,aW as ct,aX as lt,aY as D,L as dt,aB as ut,M as mt,aZ as pt,a_ as ht,aD as ft}from"./index-
|
|
1
|
+
import{aE as Le,r,aF as Ue,aG as Fe,aH as ge,b as Ve,e as qe,ak as Oe,aI as Be,aJ as Ge,aK as He,aL as We,af as Ye,aj as Ke,aM as Qe,av as Ze,aN as ze,P as Je,ay as Xe,j as e,N as et,aO as tt,aP as st,aQ as xe,V as nt,az as W,aR as at,aS as rt,aT as ot,aU as it,aV as ee,aW as ct,aX as lt,aY as D,L as dt,aB as ut,M as mt,aZ as pt,a_ as ht,aD as ft}from"./index-CkXqzhj_.js";import{v as gt,A as xt}from"./attachment-upload-B0biPzAc.js";import{u as bt,C as vt,A as yt,a as jt}from"./useAttachmentUploader-DNhr7cOE.js";import{b as kt,N as wt}from"./NoteRenderer-CN_XExeX.js";import{l as be,u as Nt,a as Rt,b as St}from"./transcribe-default-Z7qqgq1r.js";import{r as Tt}from"./editor-mode-D9fveTEx.js";import"./types-BaJkUfo6.js";const Ct=30*6e4,At=20*1024*1024,Et=1e4;function It(t){const i=t.segmentMs??Ct,c=t.setTimer??((m,C)=>setTimeout(m,C)),x=t.clearTimer??(m=>clearTimeout(m)),j=t.makeRecorder??(m=>Le({...m,releaseStreamOnStop:!1})),f=[];let a=null,d=null,p="idle",b=0,h=0,v=!1;const u=()=>{for(const m of t.stream.getTracks())m.stop()},g=()=>{d!==null&&(x(d),d=null)},n=()=>{d=c(()=>{d=null,o()},i)},R=()=>{h+=1;const m=h;a=j({stream:t.stream,mimeType:t.mimeType,releaseStreamOnStop:!1,now:t.now,MediaRecorderCtor:t.MediaRecorderCtor,dataIntervalMs:Et,onData:C=>{m===h&&C>=At&&o()}}),a.start(),b+=1,n()},o=()=>{var m;p!=="recording"||!a||v||(v=!0,g(),f.push(a.stop()),R(),(m=t.onRoll)==null||m.call(t,b),v=!1)};return{get state(){return p},get activePart(){return b},start(){if(p!=="idle")throw new Error(`Cannot start from ${p}`);p="recording",R()},async stop(){if(p!=="recording"||!a)throw new Error(`Cannot stop from ${p}`);p="stopped",g(),f.push(a.stop()),a=null;const m=await Promise.all(f);return u(),m},cancel(){g(),a&&a.cancel(),a=null,p="stopped",u()}}}function Pt(){const[t,i]=r.useState({kind:"idle"}),[c,x]=r.useState(0),[j,f]=r.useState(0),a=r.useRef(null),d=r.useRef(null);r.useEffect(()=>{if(t.kind!=="recording")return;const u=setInterval(()=>x(Date.now()-t.startedAt),250);return()=>clearInterval(u)},[t]),r.useEffect(()=>()=>{d.current&&URL.revokeObjectURL(d.current),a.current&&a.current.state==="recording"&&a.current.cancel()},[]);const p=r.useCallback(async()=>{if(!(t.kind==="recording"||t.kind==="requesting")){i({kind:"requesting"});try{const u=Ue();if(!u){i({kind:"denied",message:"This browser can't record audio in a format we can save."});return}const g=await Fe(),n=It({stream:g,mimeType:u,onRoll:R=>f(R)});a.current=n,n.start(),x(0),f(n.activePart),i({kind:"recording",startedAt:Date.now()})}catch(u){const g=u,n=g.kind==="permission-denied"?"Microphone access was denied. Update your browser's site settings to record.":g.kind==="no-device"?"No microphone was found on this device.":g instanceof Error?g.message:"Microphone is not available in this browser.";i({kind:"denied",message:n})}}},[t]),b=r.useCallback(async()=>{var g;const u=a.current;if(!(!u||t.kind!=="recording"))try{const n=await u.stop();a.current=null,f(0);const R=((g=n[0])==null?void 0:g.mimeType)??"",o=n.reduce((q,Y)=>q+Y.durationMs,0),m=n[0],C=m?URL.createObjectURL(new Blob([m.data],{type:m.mimeType})):"";d.current&&URL.revokeObjectURL(d.current),d.current=C||null,i({kind:"have-audio",segments:n,mimeType:R,url:C,durationMs:o})}catch(n){console.warn(n instanceof Error?`Recording failed: ${n.message}`:"Recording failed."),f(0),i({kind:"idle"})}},[t]),h=r.useCallback(()=>{d.current&&(URL.revokeObjectURL(d.current),d.current=null),i({kind:"idle"}),x(0),f(0)},[]),v=r.useCallback(()=>{h()},[h]);return{phase:t,elapsedMs:c,parts:j,startRecording:p,stopRecording:b,discardAudio:h,reset:v}}function Mt(t){const{segments:i,mimeType:c,recordedAt:x,willTranscribe:j}=t,f=i.length>1,a=t.typedText.trim(),d=i.map((v,u)=>({filename:f?ge(c,x,u+1):ge(c,x),transcribe:j,...j&&f?{segment_index:u}:{}})),p=j?f?i.map((v,u)=>`_Transcript pending (part ${u+1})._`).join(`
|
|
2
2
|
|
|
3
3
|
`):"_Transcript pending._":"",b=d.map(v=>`![[${v.filename}]]`).join(`
|
|
4
4
|
|