1import{j as e}from"./ui-vendor-oOQYPoO_.js";import{r as h}from"./react-vendor-w9sjr_jx.js";import{u as A,g as z}from"./useVault-DbJ3Q7c7.js";import{b as J,B as m}from"./index-C8RfnG7S.js";import{I as d}from"./input-Cht4tBSW.js";import{L as v}from"./label-Ddm0KSUh.js";import{T as C}from"./textarea-BoGPzbas.js";import{C as X}from"./card-BPImL93T.js";import{B as Q}from"./badge-B0nDBwCJ.js";import{D as q,a as B,b as U,c as V,d as F}from"./dialog-Bkt4UNX1.js";import{T as Z,a as ee,b as k,c as se}from"./tabs-C0JuIkck.js";import{u}from"./toast-vendor-DgqQvEHx.js";import{S as R}from"./shield-CVXMa_ip.js";import{P as _}from"./plus-BsegXrII.js";import{L as ae}from"./lock-Dur41FLU.js";import{K as Y}from"./key-round-OQRVmCFf.js";import{S as G}from"./sticky-note-B7yZG3Sz.js";import{C as H}from"./credit-card-BFPo6U5u.js";import{G as te}from"./globe-BtdXOjVb.js";import{E as re}from"./eye-off-Mq34uRSc.js";import{E as le}from"./eye-Cd_L_6p1.js";import{C as E}from"./copy-i-dxjZXx.js";import{T as ne}from"./timer-BJ6iDpGh.js";import{T as ce}from"./trash-2-Bh5y78l8.js";import"./supabase-vendor-Dv1i-10A.js";import"./chart-vendor-0aofaHHw.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const W=J("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]),w={login:{icon:Y,label:"Login"},note:{icon:G,label:"Secure note"},card:{icon:H,label:"Card"}};function ze(){const t=A(),[l,y]=h.useState("login"),[n,a]=h.useState({open:!1,type:"login",payload:{}}),[x,N]=h.useState(null),[c,S]=h.useState(null),[T,I]=h.useState(!1),[b,M]=h.useState(null);h.useEffect(()=>{if(!(c!=null&&c.totpSecret)){M(null);return}let s=!1;const r=async()=>{const j=await z(c.totpSecret);s||M(j)};r();const i=setInterval(r,1e3);return()=>{s=!0,clearInterval(i)}},[c==null?void 0:c.totpSecret]),h.useEffect(()=>{if(!t.unlocked)return;const s=new BroadcastChannel("bakuscribe-vault"),r=async i=>{var O;if(((O=i.data)==null?void 0:O.type)!=="get-otp")return;const j=String(i.data.host||""),D=t.items.find(g=>g.item_type==="login"&&g.host&&j.endsWith(g.host));if(!D){s.postMessage({type:"otp-result",requestId:i.data.requestId,code:null});return}try{const g=await t.decryptItem(D);if(!g.totpSecret){s.postMessage({type:"otp-result",requestId:i.data.requestId,code:null});return}const{code:$}=await z(g.totpSecret);s.postMessage({type:"otp-result",requestId:i.data.requestId,code:$})}catch{s.postMessage({type:"otp-result",requestId:i.data.requestId,code:null})}};return s.addEventListener("message",r),()=>{s.removeEventListener("message",r),s.close()}},[t.unlocked,t.items,t.decryptItem]);const L=h.useMemo(()=>t.items.filter(s=>s.item_type===l),[t.items,l]),p=async(s,r)=>{await navigator.clipboard.writeText(s),u.success(`${r} copied`)},P=(s,r)=>{a({open:!0,type:s,id:r==null?void 0:r.id,payload:{}}),r&&t.decryptItem(r).then(i=>a(j=>({...j,payload:i}))).catch(i=>u.error(i.message))},K=async()=>{try{await t.saveItem(n.type,n.payload,n.id),u.success("Saved to vault"),a(s=>({...s,open:!1}))}catch(s){u.error(s.message||"Save failed")}};if(t.loading)return e.jsx("div",{className:"flex min-h-[60vh] items-center justify-center text-muted-foreground",children:"Loading vaultâ¦"});if(!t.unlocked){const s=t.passkeys.length>0;return e.jsxs("div",{className:"mx-auto flex min-h-[70vh] max-w-md flex-col items-center justify-center px-6 text-center",children:[e.jsx("div",{className:"mb-6 flex h-20 w-20 items-center justify-center rounded-2xl bg-primary/10 ring-1 ring-primary/30",children:e.jsx(R,{className:"h-10 w-10 text-primary"})}),e.jsx("h1",{className:"text-2xl font-semibold",children:"Hyper-secure vault"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"End-to-end encrypted with your device passkey. Even Baku Scribe administrators cannot read what's inside."}),e.jsxs("div",{className:"mt-8 w-full space-y-3",children:[s?e.jsxs(m,{size:"lg",className:"w-full gap-2",onClick:()=>t.unlock().catch(r=>u.error(r.message||"Unlock failed")),disabled:t.unlocking,children:[e.jsx(W,{className:"h-5 w-5"}
6),t.unlocking?"Waiting for passkeyâ¦":"Unlock with passkey"]}):e.jsxs(m,{size:"lg",className:"w-full gap-2",onClick:()=>t.enroll().then(()=>t.unlock()).catch(r=>u.error(r.message||"Enrollment failed")),children:[e.jsx(W,{className:"h-5 w-5"}),"Set up this device"]}),s&&e.jsxs(m,{variant:"ghost",className:"w-full gap-2 text-xs",onClick:()=>t.enroll(`Device ${t.passkeys.length+1}`).catch(r=>u.error(r.message||"Enrollment failed")),children:[e.jsx(_,{className:"h-3 w-3"})," Enroll another device"]})]})]})}return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"h-6 w-6 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Vault"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.items.length," encrypted items · auto-locks after 5 min idle"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(m,{variant:"outline",size:"sm",onClick:t.lock,className:"gap-1",children:[e.jsx(ae,{className:"h-3.5 w-3.5"})," Lock"]}),e.jsxs(m,{size:"sm",className:"gap-1",onClick:()=>P(l),children:[e.jsx(_,{className:"h-3.5 w-3.5"})," New ",w[l].label.toLowerCase()]})]})]}),e.jsxs(Z,{value:l,onValueChange:s=>y(s),children:[e.jsxs(ee,{children:[e.jsxs(k,{value:"login",className:"gap-1.5",children:[e.jsx(Y,{className:"h-3.5 w-3.5"})," Logins"]}),e.jsxs(k,{value:"note",className:"gap-1.5",children:[e.jsx(G,{className:"h-3.5 w-3.5"})," Notes"]}),e.jsxs(k,{value:"card",className:"gap-1.5",children:[e.jsx(H,{className:"h-3.5 w-3.5"})," Cards"]})]}),["login","note","card"].map(s=>e.jsx(se,{value:s,className:"mt-4 space-y-2",children:L.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-10 text-center text-sm text-muted-foreground",children:["No ",w[s].label.toLowerCase(),"s yet."]}):L.map(r=>{const i=w[r.item_type].icon;return e.jsxs(X,{className:"flex cursor-pointer items-center gap-3 p-3 transition hover:bg-accent",onClick:async()=>{N(r),S(null),I(!1);try{S(await t.decryptItem(r))}catch(j){u.error(j.message||"Decrypt failed")}},children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-md bg-muted",children:e.jsx(i,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:r.label||"Untitled"}),r.host&&e.jsxs("div",{className:"flex items-center gap-1 truncate text-xs text-muted-foreground",children:[e.jsx(te,{className:"h-3 w-3"}),r.host]})]}),e.jsx(Q,{variant:"secondary",className:"text-[10px]",children:"Encrypted"})]},r.id)})},s))]}),e.jsx(q,{open:!!x,onOpenChange:s=>!s&&N(null),children:e.jsxs(B,{className:"max-w-md",children:[e.jsx(U,{children:e.jsx(V,{className:"truncate",children:(x==null?void 0:x.label)||"Item"})}),c?e.jsxs("div",{className:"space-y-3 text-sm",children:[c.url&&e.jsx(f,{label:"URL",value:c.url,onCopy:p}),c.username&&e.jsx(f,{label:"Username",value:c.username,onCopy:p}),c.email&&e.jsx(f,{label:"Email",value:c.email,onCopy:p}),c.password&&e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Password"}),e.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[e.jsx(d,{readOnly:!0,value:c.password,type:T?"text":"password",className:"font-mono"}),e.jsx(m,{size:"icon",variant:"ghost",onClick:()=>I(s=>!s),children:T?e.jsx(re,{className:"h-4 w-4"}):e.jsx(le,{className:"h-4 w-4"})}),e.jsx(m,{size:"icon",variant:"ghost",onClick:()=>p(c.password,"Password"),children:e.jsx(E,{className:"h-4 w-4"})})]})]}),b&&e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"One-time code"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 rounded-md border bg-muted/40 p-2",children:[e.jsx(ne,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-mono text-2xl tracking-[0.3em]",children:b.code}),e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[Math.ceil(b.remainingMs/1e3),"s"]}),e.jsx(m,{size:"icon",variant:"ghost",onClick:()=>p(b.code,"OTP"),children:e.jsx(E,{className:"h-4 w-4"})})]})]}),c.notes&&e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx(C,{readOnly:!0,value:c.notes,className:"mt-1"})]}),c.cardNumber&&e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Card number",value:c.cardNumber,onCopy:p,mono:!0}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.cardExpiry&&e.jsx(f,{label:"Expiry",value:c.cardExpiry,onCopy:p}),c.cardCvc&&e.jsx(f,{label:"CVC",value:c.cardCvc,onCopy:p})]})]})]}):e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Decryptingâ¦"}),e.jsxs(F,{className:"flex-row justify-between sm:justify-between",children:[e.jsxs(m,{variant:"ghost",size:"sm",className:"text-destructive",onClick:async()=>{x&&confirm("Delete this item permanently?")&&(await t.deleteItem(x.id),N(null),u.success("Deleted"))},children:[e.jsx(ce,{className:"mr-1 h-4 w-4"})," Delete"]}),e.jsx(m,{size:"sm",onClick:()=>{x&&P(x.item_type,x),N(null)},children:"Edit"})]})]})}),e.jsx(q,{open:n.open,onOpenChange:s=>a(r=>({...r,open:s})),children:e.jsxs(B,{className:"max-w-md",children:[e.jsx(U,{children:e.jsxs(V,{children:[n.id?"Edit":"New"," ",w[n.type].label.toLowerCase()]})}),e.jsx(oe,{type:n.type,value:n.payload,onChange:s=>a(r=>({...r,payload:s}))}),e.jsxs(F,{children:[e.jsx(m,{variant:"ghost",onClick:()=>a(s=>({...s,open:!1})),children:"Cancel"}),e.jsx(m,{onClick:K,children:"Save securely"})]})]})})]})}function f({label:t,value:l,onCopy:y,mono:n}){return e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[e.jsx(d,{readOnly:!0,value:l,className:n?"font-mono":""}),e.jsx(m,{size:"icon",variant:"ghost",onClick:()=>y(l,t),children:e.jsx(E,{className:"h-4 w-4"})})]})]})}
6function oe({type:t,value:l,onChange:y}){const n=(a,x)=>y({...l,[a]:x});return t==="note"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(o,{label:"Title",children:e.jsx(d,{value:l.title||"",onChange:a=>n("title",a.target.value)})}),e.jsx(o,{label:"Notes",children:e.jsx(C,{rows:8,value:l.notes||"",onChange:a=>n("notes",a.target.value)})})]}):t==="card"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(o,{label:"Label",children:e.jsx(d,{value:l.title||"",onChange:a=>n("title",a.target.value),placeholder:"Visa personal"})}),e.jsx(o,{label:"Cardholder",children:e.jsx(d,{value:l.cardholder||"",onChange:a=>n("cardholder",a.target.value)})}),e.jsx(o,{label:"Card number",children:e.jsx(d,{value:l.cardNumber||"",onChange:a=>n("cardNumber",a.target.value),inputMode:"numeric",className:"font-mono"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(o,{label:"Expiry (MM/YY)",children:e.jsx(d,{value:l.cardExpiry||"",onChange:a=>n("cardExpiry",a.target.value)})}),e.jsx(o,{label:"CVC",children:e.jsx(d,{value:l.cardCvc||"",onChange:a=>n("cardCvc",a.target.value),className:"font-mono"})})]}),e.jsx(o,{label:"Notes",children:e.jsx(C,{value:l.notes||"",onChange:a=>n("notes",a.target.value)})})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(o,{label:"Title",children:e.jsx(d,{value:l.title||"",onChange:a=>n("title",a.target.value),placeholder:"Gmail"})}),e.jsx(o,{label:"Website / URL",children:e.jsx(d,{value:l.url||"",onChange:a=>n("url",a.target.value),placeholder:"https://gmail.com"})}),e.jsx(o,{label:"Username",children:e.jsx(d,{value:l.username||"",onChange:a=>n("username",a.target.value)})}),e.jsx(o,{label:"Email",children:e.jsx(d,{value:l.email||"",onChange:a=>n("email",a.target.value),type:"email"})}),e.jsx(o,{label:"Password",children:e.jsx(d,{value:l.password||"",onChange:a=>n("password",a.target.value),type:"password",className:"font-mono"})}),e.jsx(o,{label:"TOTP secret (base32)",children:e.jsx(d,{value:l.totpSecret||"",onChange:a=>n("totpSecret",a.target.value),placeholder:"JBSWY3DPEHPK3PXP",className:"font-mono"})}),e.jsx(o,{label:"Notes",children:e.jsx(C,{value:l.notes||"",onChange:a=>n("notes",a.target.value)})})]})}function o({label:t,children:l}){return e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1",children:l})]})}export{ze as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.