auramaxx 0.0.7 → 0.0.9
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/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +75 -75
- package/.next/app-path-routes-manifest.json +7 -7
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +31 -31
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/[...doc]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent-requests/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/apps/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/apps/manifests/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/apps/static/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/docs/plain/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/version/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/apps/[wid]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/export/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/import/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/route_client-reference-manifest.js +1 -1
- package/.next/server/app/app-legacy-do-not-use/page_client-reference-manifest.js +1 -1
- package/.next/server/app/app-legacy-do-not-use.html +1 -1
- package/.next/server/app/app-legacy-do-not-use.rsc +2 -2
- package/.next/server/app/approve/[actionId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs/[...doc]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/health/page_client-reference-manifest.js +1 -1
- package/.next/server/app/health.html +1 -1
- package/.next/server/app/health.rsc +1 -1
- package/.next/server/app/hello/page_client-reference-manifest.js +1 -1
- package/.next/server/app/hello.html +1 -1
- package/.next/server/app/hello.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/.next/server/app/privacy.html +1 -1
- package/.next/server/app/privacy.rsc +1 -1
- package/.next/server/app/share/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/.next/server/app/terms.html +1 -1
- package/.next/server/app/terms.rsc +1 -1
- package/.next/server/app-paths-manifest.json +7 -7
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/2927.e7e9e2a1b8d2dc61.js +1 -0
- package/.next/static/chunks/7411-3ca797c21b722ccd.js +1 -0
- package/.next/static/chunks/8614-2b239837100108a8.js +59 -0
- package/.next/static/chunks/app/app-legacy-do-not-use/page-984b44219e827f20.js +1 -0
- package/.next/static/chunks/app/page-202668d41c2b1c70.js +1 -0
- package/.next/static/chunks/{webpack-d3f28b35c037373d.js → webpack-66e03877d6fdcbf0.js} +1 -1
- package/.next/trace +4 -4
- package/package.json +1 -1
- package/src/components/vault/CredentialVault.tsx +4 -3
- package/src/server/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/.next/static/chunks/2927.9f1b221489693fa6.js +0 -1
- package/.next/static/chunks/7411-2cdac9a42dad0323.js +0 -1
- package/.next/static/chunks/8614-946e68e30ed95636.js +0 -59
- package/.next/static/chunks/app/app-legacy-do-not-use/page-c38eba9a354eaf8c.js +0 -1
- package/.next/static/chunks/app/page-e5cf8222673d3bd9.js +0 -1
- /package/.next/static/{nAKFZuKu1HIUU3yPTafeu → D6gXZ612zYsWYHv6fu0JE}/_buildManifest.js +0 -0
- /package/.next/static/{nAKFZuKu1HIUU3yPTafeu → D6gXZ612zYsWYHv6fu0JE}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{1643:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>tO});var r=a(5155),l=a(2115),s=a(8677),o=a(2619),n=a.n(o),i=a(5870),c=a(8192),d=a(5867),u=a(5710),x=a(6191),p=a(5299),f=a(8314),m=a(6489),v=a(4901),h=a(960),b=a(9410),g=a(9540),y=a(9051),j=a(6651),N=a(3409),w=a(7993),k=a(3667),C=a(9397),S=a(5370),A=a(8519),E=a(9715),I=a(5882),T=a(9559),R=a(803),O=a(6907),L=a(1375),D=a(1360),P=a(318),z=a(9708),F=a(5795),M=a(9347),_=a(7726);let K=[{key:"all",label:"All Credentials",icon:C.A},{key:"login",label:"Logins",icon:S.A},{key:"card",label:"Cards",icon:A.A},{key:"plain_note",label:"Plain Notes",icon:E.A},{key:"note",label:"Secret Notes",icon:E.A},{key:"hot_wallet",label:"Hot Wallets",icon:I.A},{key:"oauth2",label:"OAuth2",icon:T.A},{key:"ssh",label:"SSH Keys",icon:R.A},{key:"gpg",label:"GPG Keys",icon:O.A}],U={login:"login",card:"card",plain_note:"plain_note",note:"note",hot_wallet:"hot_wallet",oauth2:"oauth2",ssh:"ssh",gpg:"gpg"},H=[{key:"archive",label:"Archived",icon:L.A},{key:"recently_deleted",label:"Recently Deleted",icon:D.A}],V=[{combo:"Cmd/Ctrl + K",action:"Focus search"},{combo:"/",action:"Focus search (while not typing)"},{combo:"Cmd/Ctrl + Alt + N",action:"Create new credential"},{combo:"↑ / ↓",action:"Navigate list selection"},{combo:"Enter",action:"Open selected credential"}],W="auramaxx:vault-sidebar-collapsible-sections",$="auramaxx:vault-sidebar-collapsed-vault-nodes",B={vaults:!1,categories:!0,favorites:!0,tags:!0,lifecycle:!0};function G(e){return e.parentVaultId||e.linkedTo}let Y=e=>{let{vaults:t,filters:a,categoryCounts:s,tags:o,favoritesCount:n,onFilterChange:i,onLock:c,onLockVault:d,onUnlockVault:u,onCreateCredential:p,onCreateVault:f,mode:m="desktop",onNavigate:v,notifications:h=[],onDismissNotification:b,pendingActionCount:g=0,surface:y="credentials",onSurfaceChange:j,onSettings:N,onDeleteVault:w}=e,A="tablet"===m,E="tablet"===m?"calc(48px * var(--ui-scale-factor, 1))":"mobile"===m?"calc(220px * var(--ui-scale-factor, 1))":"calc(200px * var(--ui-scale-factor, 1))",I="active"!==a.lifecycle,T=(0,l.useMemo)(()=>(function(e){let t=new Map(e.map(e=>[e.id,e])),a=new Map(e.map((e,t)=>[e.id,t])),r=new Map;for(let a of e){let e=G(a);if(!e||!t.has(e)||e===a.id)continue;let l=r.get(e)||[];l.push(a),r.set(e,l)}let l=(e,t)=>(a.get(e.id)||0)-(a.get(t.id)||0);for(let e of r.values())e.sort(l);let s=e.filter(e=>{let a=G(e);return!a||!t.has(a)||a===e.id}).sort(l),o=[],n=new Set,i=(e,t)=>{if(!n.has(e.id))for(let a of(n.add(e.id),o.push({vault:e,depth:t}),r.get(e.id)||[]))i(a,t+1)};for(let e of s)i(e,0);for(let t of[...e].sort(l))i(t,0);return o})(t),[t]),{parentByChild:R,childCountByParent:O}=(0,l.useMemo)(()=>(function(e){let t=new Map,a=new Map;for(let r of e){let e=G(r);e&&e!==r.id&&(t.set(r.id,e),a.set(e,(a.get(e)||0)+1))}return{parentByChild:t,childCountByParent:a}})(t),[t]),[L,Y]=(0,l.useState)(B),[X,q]=(0,l.useState)(!1),[J,Z]=(0,l.useState)({}),[Q,ee]=(0,l.useState)(!1),[et,ea]=(0,l.useState)(!1),er=(0,l.useRef)(null);(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(W);if(!e)return;let t=function(e){return e&&"object"==typeof e?{vaults:!!e.vaults,categories:!!e.categories,favorites:!!e.favorites,tags:!!e.tags,lifecycle:!!e.lifecycle}:null}(JSON.parse(e));if(!t)return;Y(t)}catch(e){}finally{q(!0)}},[]),(0,l.useEffect)(()=>{if(X)try{window.localStorage.setItem(W,JSON.stringify(L))}catch(e){}},[L,X]),(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem($);if(!e)return;let t=function(e){if(!e||"object"!=typeof e)return null;let t={};for(let[a,r]of Object.entries(e))a&&(t[a]=!!r);return t}(JSON.parse(e));if(!t)return;Z(t)}catch(e){}finally{ee(!0)}},[]),(0,l.useEffect)(()=>{if(Q)try{window.localStorage.setItem($,JSON.stringify(J))}catch(e){}},[J,Q]),(0,l.useEffect)(()=>{let e=a.vaultId;if(!e)return;let t=[],r=R.get(e);for(;r;)t.push(r),r=R.get(r);0!==t.length&&Z(e=>{let a=!1,r={...e};for(let e of t)r[e]&&(delete r[e],a=!0);return a?r:e})},[a.vaultId,R]),(0,l.useEffect)(()=>{if(!et)return;let e=e=>{let t=e.target;er.current&&!er.current.contains(t)&&ea(!1)},t=e=>{"Escape"===e.key&&ea(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[et]);let el=(0,l.useMemo)(()=>{let e=[],t=[];for(let a of T){for(;e.length>a.depth;)e.pop();!(e.length>0)&&(t.push(a),J[a.vault.id]&&e.push(a.vault.id))}return t},[T,J]),es=e=>{Y(t=>({...t,[e]:!t[e]}))},eo=e=>{null==j||j("credentials"),i(e),null==v||v()},en=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1?arguments[1]:void 0;null==j||j("credentials"),t?p(e,t):p(e),null==v||v()},ei=e=>{null==j||j("credentials"),f(e),null==v||v()},ec=()=>{c(),null==v||v()},ed=()=>{null==j||j("apiKeys"),null==v||v()},eu=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return(0,r.jsxs)("button",{type:"button",onClick:()=>es(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),es(e))},"aria-expanded":!L[e],"aria-controls":"vault-sidebar-section-".concat(e),"aria-label":"".concat(t," section"),className:"w-full flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(A?"justify-center py-1":"justify-between px-2 py-1"," ").concat(a),title:"".concat(t," section"),children:[!A&&(0,r.jsx)("span",{className:"text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] font-bold",children:t}),(0,r.jsx)(P.A,{size:10,className:"text-[var(--color-text-faint,#9ca3af)] transition-transform ".concat(L[e]?"":"rotate-90")})]})};return(0,r.jsxs)("div",{className:"h-full flex flex-col border-r border-[var(--color-border,#d4d4d8)] font-mono relative overflow-hidden shrink-0",style:{width:E,minWidth:E,background:"var(--color-surface, #f4f4f2)",fontSize:"var(--font-size-sm)"},children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none bg-[radial-gradient(var(--color-text,#000)_1px,transparent_1px)] bg-[size:4px_4px]"}),(0,r.jsx)("div",{className:"flex items-center justify-between border-b border-[var(--color-border,#d4d4d8)] relative z-10 ".concat(A?"px-2 py-2":"px-3 py-3"),children:(0,r.jsxs)("div",{className:"flex items-center ".concat(A?"justify-center w-full":"gap-2"),children:[(0,r.jsx)("img",{src:"/logo.webp",alt:"Aura",className:"w-[length:var(--font-size-sm)] h-[length:var(--font-size-sm)] object-contain"}),!A&&(0,r.jsx)("span",{"data-testid":"vault-sidebar-header-brand",className:"text-[length:var(--font-size-sm)] font-bold tracking-widest uppercase text-[var(--color-text,#0a0a0a)]",children:"AURAMAXX"})]})}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden relative z-10",children:[(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[eu("vaults","Vaults"),!L.vaults&&(0,r.jsxs)("div",{id:"vault-sidebar-section-vaults",className:"".concat(A?"px-1 pb-2":"px-2 pb-2"," overflow-x-hidden"),children:[(0,r.jsxs)("div",{className:"flex items-center ".concat(A?"gap-1":"gap-1.5"),style:{borderLeft:null===a.vaultId?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)("button",{onClick:()=>eo({vaultId:null,lifecycle:"active",tag:null}),className:"flex-1 flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(A?"justify-center px-1 py-1.5":"gap-2 px-2 py-1.5 text-left"),title:"All Vaults (Active)",children:A?(0,r.jsx)(C.A,{size:11,className:"text-[var(--color-text-muted,#6b7280)]"}):(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase text-[var(--color-text,#0a0a0a)] font-bold",children:"All Vaults"})}),(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:ec,className:A?"!px-0 !h-6 !w-6":"!px-1.5 !h-6",title:"Lock all vaults",children:(0,r.jsx)(z.A,{size:10})}),(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>ei(),className:A?"!px-0 !h-6 !w-6":"!px-1.5 !h-6",title:"Create vault",children:(0,r.jsx)(x.A,{size:10})})]}),el.map(e=>{var l,s,o;let{vault:n,depth:i}=e,c=n.name||(n.isPrimary?"Primary":"Vault ".concat(n.id.slice(0,6))),p=!G(n)&&!n.isPrimary&&n.isUnlocked&&!!d,f=(O.get(n.id)||0)>0,m=R.get(n.id),v=m?(null==(l=t.find(e=>e.id===m))?void 0:l.name)||m.slice(0,6):null,h=a.vaultId===n.id;return(0,r.jsxs)("div",{className:"w-full min-w-0 flex items-center group",style:{borderLeft:h?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)("div",{className:"ml-0.5 flex items-center",children:f?(0,r.jsx)("button",{type:"button","data-testid":"vault-toggle-".concat(n.id),"aria-label":"Toggle children for ".concat(c),onClick:e=>{e.stopPropagation(),(e=>{Z(t=>({...t,[e]:!t[e]}))})(n.id)},className:"w-5 h-5 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]",children:(0,r.jsx)(P.A,{size:9,className:"transition-transform ".concat(J[n.id]?"":"rotate-90")})}):(0,r.jsx)("span",{className:"w-5"})}),(0,r.jsx)("button",{"data-testid":"vault-item-".concat(n.id),"data-vault-depth":i,onClick:()=>{if(!n.isUnlocked){null==u||u(n);return}eo({vaultId:n.id})},className:"flex-1 min-w-0 flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(A?"justify-center py-1.5 pr-1":"gap-2 py-1.5 pr-2 text-left"),style:{paddingLeft:A?"".concat(Math.max(2,2+4*i),"px"):"".concat(8+12*i,"px")},title:c,children:A?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("div",{className:"w-4 h-4 border border-[var(--color-border,#d4d4d8)] rounded-full flex items-center justify-center text-[7px] uppercase text-[var(--color-text-muted,#6b7280)]",children:(n.name||"V").slice(0,1)}),n.isUnlocked?(0,r.jsx)(F.A,{size:8,className:"text-[var(--color-text-muted,#6b7280)]"}):(0,r.jsx)(z.A,{size:8,className:"text-[var(--color-text-faint,#9ca3af)]"})]}):(0,r.jsxs)(r.Fragment,{children:[i>0&&(0,r.jsx)("span",{"data-testid":"vault-lineage-".concat(n.id),className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",title:v?"Child of ".concat(v):"Child vault",children:"↳"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] truncate",children:c}),(0,r.jsx)("span",{className:"shrink-0 text-[8px] text-[var(--color-text-faint,#9ca3af)] tabular-nums",title:"".concat(null!=(s=n.credentialCount)?s:0," credentials"),children:null!=(o=n.credentialCount)?o:0})]})}),!A&&(0,r.jsxs)("div",{className:"mr-1 flex items-center gap-0.5",children:[p&&(0,r.jsx)("button",{type:"button","data-testid":"vault-status-lock-".concat(n.id),title:n.isPrimary?"Lock all vaults":"Lock vault ".concat(c),"aria-label":n.isPrimary?"Lock all vaults":"Lock vault ".concat(c),onClick:e=>{if(e.stopPropagation(),n.isPrimary)return void ec();null==d||d(n.id)},className:"w-5 h-5 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(z.A,{size:9})}),w&&(0,r.jsx)("button",{type:"button",title:"Delete vault ".concat(c),"aria-label":"Delete vault ".concat(c),onClick:e=>{e.stopPropagation(),w(n)},className:"w-5 h-5 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",children:(0,r.jsx)(D.A,{size:9})}),(0,r.jsx)("button",{type:"button",title:"Create child vault in ".concat(c),"aria-label":"Create child vault in ".concat(c),onClick:e=>{e.stopPropagation(),ei(n.id)},className:"w-5 h-5 shrink-0 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)]",children:(0,r.jsx)(x.A,{size:9})})]})]},n.id)})]})]}),(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[eu("categories","Categories"),!L.categories&&(0,r.jsx)("div",{id:"vault-sidebar-section-categories",className:A?"px-1 pb-2":"px-2 pb-2",children:K.map(e=>{let{key:t,label:l,icon:o}=e;return(0,r.jsxs)("div",{className:"w-full flex items-center gap-1 group",children:[(0,r.jsxs)("button",{onClick:()=>eo({category:t}),className:"".concat("flex-1 min-w-0"," flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ").concat(A?"justify-center px-1 py-1.5":"gap-2 px-2 py-1.5 text-left"),style:{borderLeft:a.category===t?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},title:l,children:[(0,r.jsx)(o,{size:11,className:a.category===t?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-muted,#6b7280)]"}),!A&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase flex-1 ".concat(a.category===t?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:l}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:s[t]})]})]}),(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>{let e=U[t];if(e)return void en("default",e);en("type-picker")},className:"".concat(A?"!px-0 !h-6 !w-6":"!px-1.5 !h-6"," opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity"),title:I?"Click All Credentials to return to Active and create ".concat(l):"Create ".concat(l),disabled:I,children:(0,r.jsx)(x.A,{size:10})})]},t)})})]}),(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[eu("favorites","Favorites"),!L.favorites&&(0,r.jsx)("div",{id:"vault-sidebar-section-favorites",className:A?"px-1 pb-2":"px-2 pb-2",children:(0,r.jsxs)("button",{onClick:()=>eo({favoritesOnly:!a.favoritesOnly}),className:"w-full flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(A?"justify-center px-1 py-1.5":"gap-2 px-2 py-1.5 text-left"),style:{borderLeft:a.favoritesOnly?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},title:"Favorites",children:[(0,r.jsx)(M.A,{size:11,className:a.favoritesOnly?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-muted,#6b7280)]",style:a.favoritesOnly?{fill:"var(--color-accent,#ccff00)",color:"var(--color-accent,#ccff00)"}:void 0}),!A&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase flex-1 ".concat(a.favoritesOnly?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:"Favorites"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:n})]})]})})]}),!A&&o.length>0&&(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[eu("tags","Tags"),!L.tags&&(0,r.jsx)("div",{id:"vault-sidebar-section-tags",className:"px-2 pb-2 overflow-y-auto",children:o.map(e=>(0,r.jsxs)("button",{onClick:()=>eo({tag:a.tag===e?null:e}),className:"w-full flex items-center gap-2 px-2 py-1 text-left transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)]",style:{borderLeft:a.tag===e?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)(_.A,{size:9,className:a.tag===e?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase truncate ".concat(a.tag===e?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:e})]},e))})]}),!A&&(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[eu("lifecycle","Lifecycle"),!L.lifecycle&&(0,r.jsx)("div",{id:"vault-sidebar-section-lifecycle",className:"px-2 pb-2",children:H.map(e=>{let{key:t,label:l,icon:s}=e;return(0,r.jsxs)("button",{onClick:()=>eo({lifecycle:t,tag:null}),className:"w-full flex items-center gap-2 px-2 py-1 text-left transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)]",style:{borderLeft:a.lifecycle===t?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)(s,{size:9,className:a.lifecycle===t?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase truncate ".concat(a.lifecycle===t?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:l})]},t)})})]})]}),(0,r.jsxs)("div",{className:"border-t border-[var(--color-border,#d4d4d8)] ".concat(A?"px-1 py-2":"px-3 py-3"),children:[g>0&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 ".concat(A?"justify-center":"px-1"),children:[(0,r.jsx)("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center px-1 font-mono text-[8px] font-bold",style:{background:"var(--color-danger, #ef4444)",color:"var(--color-danger-foreground, #ffffff)",borderRadius:"var(--radius-sm)"},children:g>9?"9+":g}),!A&&(0,r.jsx)("span",{className:"font-mono text-[8px] font-bold tracking-widest uppercase text-[var(--color-danger,#ef4444)]",children:"PENDING"})]}),A&&(0,r.jsxs)("div",{className:"mb-2 flex items-center gap-1",children:[(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:ed,icon:(0,r.jsx)(S.A,{size:10}),className:"flex-1 !px-0",title:"API Keys"}),(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:ec,icon:(0,r.jsx)(z.A,{size:10}),className:"flex-1 !px-0",title:"Lock"})]}),!A&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-2 justify-center",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{null==j||j("audit"),null==v||v()},className:"text-[8px] tracking-widest uppercase transition-colors ".concat("audit"===y?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]"),"aria-current":"audit"===y?"page":void 0,children:"AUDIT"}),(0,r.jsx)("button",{type:"button",onClick:ed,className:"text-[8px] tracking-widest uppercase transition-colors ".concat("apiKeys"===y?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]"),"aria-current":"apiKeys"===y?"page":void 0,children:"API KEYS"}),(0,r.jsx)("button",{type:"button",onClick:ec,className:"text-[8px] tracking-widest uppercase transition-colors text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]",children:"LOCK"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ".concat(A?"mt-2":"mt-3"),"data-testid":"vault-sidebar-footer-barcode",children:[(0,r.jsx)("div",{className:"h-4 flex-1 bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),!A&&(0,r.jsxs)("div",{className:"relative",ref:er,children:[(0,r.jsx)("button",{type:"button","data-testid":"shortcut-hint-trigger",onClick:()=>ea(e=>!e),className:"font-mono text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest hover:text-[var(--color-text-muted,#6b7280)] transition-colors","aria-expanded":et?"true":"false","aria-label":"Keyboard shortcuts",children:"Cmd/Ctrl+K"}),et&&(0,r.jsxs)("div",{"data-testid":"shortcut-hint-popover",className:"absolute bottom-full right-0 mb-1 border border-[var(--color-border-focus,#0a0a0a)] bg-[var(--color-surface,#ffffff)] shadow-mech z-30 p-2 w-[170px]",children:[(0,r.jsx)("div",{className:"text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"Keyboard Shortcuts"}),(0,r.jsx)("div",{className:"space-y-1",children:V.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-[8px] tracking-widest uppercase text-[var(--color-text,#0a0a0a)]",children:e.combo}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-muted,#6b7280)]",children:e.action})]},e.combo))})]})]})]})]})]})};var X=a(1786);let q={login:S.A,card:A.A,note:E.A,hot_wallet:I.A,plain_note:E.A,apikey:S.A,oauth2:T.A,ssh:R.A,gpg:O.A},J=e=>{let{credential:t,selected:a,onClick:l}=e,s=q[t.type]||E.A,o=function(e){switch(e.type){case"login":return e.meta.username||e.meta.url||"";case"card":return e.meta.last4?"•••• ".concat(e.meta.last4):"";case"note":return"Secure Note";case"hot_wallet":return e.meta.address||e.meta.chain||"Hot Wallet";case"plain_note":return e.meta.content||e.meta.value||"Plain Note";case"apikey":return e.meta.key||"API Key";case"oauth2":return e.meta.scopes||"OAuth2";case"ssh":return e.meta.fingerprint||e.meta.key_type||"SSH Key";case"gpg":return e.meta.key_id||e.meta.uid_email||"GPG Key";default:return""}}(t),n=t.meta.favorite;return(0,r.jsxs)("div",{onClick:l,className:"flex items-center cursor-pointer border-b border-[var(--color-credential-array-border,#8d8d95)] transition-all hover:bg-[var(--color-background-alt,#f4f4f5)] hover:shadow-mech-hover ".concat(a?"corner-marks":""),style:{gap:"var(--space-sm)",padding:"var(--space-sm) var(--space-md)",borderLeft:a?"2px solid var(--color-accent, #ccff00)":"2px solid transparent",background:a?"var(--color-background-alt, #f4f4f5)":void 0},children:[(0,r.jsx)(s,{size:14,className:"text-[var(--color-text-muted,#6b7280)] flex-shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-mono text-[11px] font-bold text-[var(--color-text,#0a0a0a)] truncate",children:t.name}),o&&(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate",children:o})]}),(()=>{let e=function(e){if("oauth2"!==e.type)return null;let t=e.meta.expires_at;if(!t)return{label:"No token",color:"var(--color-text-muted,#6b7280)",background:"var(--color-background-alt,#f4f4f5)"};let a=Math.floor(Date.now()/1e3);if(a>=t)return{label:"Expired",color:"var(--color-danger,#ef4444)",background:"color-mix(in srgb, var(--color-danger,#ef4444) 12%, transparent)"};let r=t-a;return r<300?{label:"<5m",color:"var(--color-warning,#ff4d00)",background:"color-mix(in srgb, var(--color-warning,#ff4d00) 12%, transparent)"}:{label:r<3600?"".concat(Math.floor(r/60),"m"):"".concat(Math.floor(r/3600),"h"),color:"var(--color-success,#00c853)",background:"color-mix(in srgb, var(--color-success,#00c853) 12%, transparent)"}}(t);return e?(0,r.jsx)("span",{className:"flex-shrink-0 font-mono text-[8px] font-bold px-1.5 py-0.5 rounded-sm",style:{color:e.color,background:e.background,borderRadius:"var(--radius-sm)"},children:e.label}):null})(),n&&(0,r.jsx)(M.A,{size:10,className:"flex-shrink-0",style:{fill:"var(--color-accent,#ccff00)",color:"var(--color-accent,#ccff00)"}})]})},Z=e=>e.trim().toLowerCase(),Q=(e,t)=>{let a=null==t?void 0:t[e.id];return"number"==typeof a&&Number.isFinite(a)&&a>0?a:(e=>{let t=Date.parse(e.createdAt);return Number.isFinite(t)?t:0})(e)},ee=(e,t)=>{let a=Z(t);if(!a)return 0;let r=Z(e.name),l=Z(String(e.meta.username||"")),s=Z(String(e.meta.url||""));return r===a?3:r.startsWith(a)||l.startsWith(a)||s.startsWith(a)?2:r.includes(a)||l.includes(a)||s.includes(a)?1:0};function et(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return[...e].sort((e,r)=>{let l=Q(e,t),s=Q(r,t);if(s!==l)return s-l;let o=ee(e,a),n=ee(r,a);if(n!==o)return n-o;let i=+!!e.meta.favorite,c=+!!r.meta.favorite;if(c!==i)return c-i;let d=Z(e.name),u=Z(r.name),x=d.localeCompare(u);return 0!==x?x:e.id.localeCompare(r.id)})}let ea=e=>{let{credentials:t,latestAccessById:a,selectedId:s,searchQuery:o,onSearchChange:n,onSelect:i,onAdd:c,canAdd:u=!0,onImport:p,canImport:f=!0,onOpenGenerator:m,canGenerate:v=!0,onClearFilters:h,onCreateWithFilter:b,hasActiveFilters:g=!1,showSearch:y=!0,fieldSearchSuggestions:N=[],onApplySearchSuggestion:w,searchInputRef:C,className:S="w-[300px] h-full flex flex-col border-r border-[var(--color-credential-array-border,#8d8d95)]",leadingAction:A}=e,E=(0,l.useMemo)(()=>et(t,a,o),[t,a,o]);return(0,r.jsxs)("div",{className:S,style:{fontSize:"var(--font-size-sm)"},children:[(0,r.jsx)("div",{className:"border-b border-[var(--color-credential-array-border,#8d8d95)] ".concat(y?"flex items-center":""),style:{gap:"var(--space-sm)",padding:"var(--space-md)"},children:y?(0,r.jsxs)(r.Fragment,{children:[A,(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(k.ks,{compact:!0,leftElement:(0,r.jsx)(j.A,{size:12}),placeholder:"Search...",value:o,onChange:e=>n(e.target.value),inputRef:C})}),m&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:m,icon:(0,r.jsx)(d.A,{size:10}),disabled:!v,title:"Generate password","aria-label":"Generate password",children:"GEN"}),p&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:p,icon:(0,r.jsx)(X.A,{size:10}),disabled:!f,title:f?"Import credentials":"Switch to Active to import credentials","aria-label":"Import credentials",children:"IMPORT"}),(0,r.jsx)(k.$n,{size:"sm",onClick:c,icon:(0,r.jsx)(x.A,{size:10}),disabled:!u,title:u?"Create credential":"Switch to Active to create credentials",children:"ADD"})]}):(0,r.jsxs)("div",{className:"w-full space-y-2",children:[A&&(0,r.jsx)("div",{className:"flex",children:A}),(0,r.jsxs)("div",{className:"flex w-full items-center gap-2 overflow-hidden",children:[m&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:m,icon:(0,r.jsx)(d.A,{size:10}),disabled:!v,title:"Generate password","aria-label":"Generate password",className:"flex-1 min-w-0",children:"GEN"}),p&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:p,icon:(0,r.jsx)(X.A,{size:10}),disabled:!f,title:f?"Import credentials":"Switch to Active to import credentials","aria-label":"Import credentials",className:"flex-1 min-w-0",children:"IMPORT"}),(0,r.jsx)(k.$n,{size:"sm",onClick:c,icon:(0,r.jsx)(x.A,{size:10}),disabled:!u,title:u?"Create credential":"Switch to Active to create credentials",className:"flex-1 min-w-0",children:"ADD"})]})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:0===E.length?(0,r.jsx)("div",{className:"flex items-center justify-center h-full px-4",children:(0,r.jsxs)("div",{className:"text-center tyvek-label corner-marks p-6",children:[(0,r.jsx)("span",{className:"label-specimen text-[var(--color-text-muted,#6b7280)] block",children:g?"NO SPECIMENS MATCH":"NO SPECIMENS FOUND"}),N.length>0&&w&&(0,r.jsx)("div",{className:"mt-3 flex flex-wrap items-center justify-center gap-2",children:N.map(e=>(0,r.jsx)("button",{type:"button",className:"font-mono text-[9px] px-2 py-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)] text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:border-[var(--color-border-focus,#0a0a0a)]",onClick:()=>w(e),title:"Search by ".concat(e),children:e},e))}),g&&h&&(0,r.jsxs)("div",{className:"mt-3 flex flex-col items-center gap-2",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:h,children:"CLEAR FILTERS"}),b&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:b,children:"CREATE WITH FILTER"})]})]})}):E.map(e=>(0,r.jsx)(J,{credential:e,selected:e.id===s,onClick:()=>i(e.id)},e.id))})]})};var er=a(5426),el=a(4033),es=a(7354),eo=a(7828),en=a(532),ei=a(4558);let ec=e=>{let{label:t,value:a,copyValue:s,trailingValue:o,credentialId:n,fieldKey:i,isSensitive:c,onShowLargeType:d,sensitiveInteractionMode:u="default",actionsPosition:x="left",showActionsInHoverCopyMode:f=!1,sensitiveClickBehavior:m="reveal",disableLargeType:v=!1,renderMarkdown:g=!1}=e,[y,j]=(0,l.useState)(!1),[N,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(null),[E,I]=(0,l.useState)(!1),[T,R]=(0,l.useState)(null),[O,L]=(0,l.useState)(!1),D=(0,l.useRef)(null),P=(0,l.useRef)(null),z=(0,l.useRef)(null),F="hover-copy"===u||"markdown-hover-copy"===u,M="markdown-hover-copy"===u,_="hover-copy"===u,K=!F&&"copy"===m,U=!F||f,H=(0,l.useMemo)(()=>{if(!M||null==S)return"";let e=S.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return ei.xI.parse(e,{async:!1,breaks:!0})},[M,S]),V=(0,l.useMemo)(()=>{if(!g||!a)return"";let e=a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return ei.xI.parse(e,{async:!1,breaks:!0})},[g,a]);(0,l.useEffect)(()=>()=>{P.current&&clearTimeout(P.current),z.current&&clearTimeout(z.current)},[]),(0,l.useEffect)(()=>{j(!1),C(!1),A(null),R(null),L(!1),P.current&&clearTimeout(P.current)},[n,i]);let W=(0,l.useCallback)(()=>{j(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>j(!1),2e3)},[]),$=(0,l.useCallback)(e=>{A(e),C(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{C(!1),A(null)},3e4)},[]),B=(0,l.useCallback)(async()=>{if(null!=S)return S;try{var e;let t=await h.FH.post(h.jI.Wallet,"/credentials/".concat(n,"/read")),a=await (0,b.DC)(t.encrypted),r=JSON.parse(a),l="string"==typeof r.type?r.type:"",s=(0,w.Dw)(l,i),o=null==(e=r.fields)?void 0:e.find(e=>(0,w.Dw)(l,e.key)===s||i===w.l3&&"value"===e.key);if(!o)return null;return o.value}catch(e){return null}},[n,i,S]),G=(0,l.useCallback)(async()=>{if(null!=S)return S;I(!0),R(null);try{let e=await B();return null==e&&R("Field not found"),e}catch(e){return R("Decryption failed -- try re-unlocking"),null}finally{I(!1)}},[B,S]),Y=(0,l.useCallback)(async()=>{if(E)return;L(!1);let e=await B();null!=e&&(navigator.clipboard.writeText(e),W())},[B,E,W]),X=(0,l.useCallback)(async()=>{if(E||N&&null!=S)return;L(!1);let e=await G();null!=e&&$(e)},[G,E,$,N,S]),q=(0,l.useCallback)(()=>{C(!1),A(null),P.current&&clearTimeout(P.current)},[]),J=(0,l.useCallback)(async()=>{L(!1);let e=await B();null!=e&&d(e)},[B,d]),Z=(0,l.useCallback)(()=>{let e=null!=s?s:a;e&&(navigator.clipboard.writeText(e),W())},[s,a,W]),Q=(0,l.useCallback)(()=>{a&&(L(!1),d(a))},[d,a]),ee=(0,l.useCallback)(async()=>{if(!F||E)return;let e=S;null==e&&null!=(e=await G())&&A(e),null!=e&&(_&&$(e),navigator.clipboard.writeText(e),W())},[G,E,F,_,W,$,S]),et=(0,l.useCallback)(e=>{if(!_&&!K){if(e.stopPropagation(),F)return void ee();X()}},[ee,X,F,_,K]);if(!c){let e=(0,r.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),Z()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,r.jsx)(er.A,{size:10}),y?"Copied":"Copy"]}),(0,r.jsx)("button",{ref:D,onClick:e=>{e.stopPropagation(),L(!O)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":"Field actions for ".concat(t),children:(0,r.jsx)(el.A,{size:12})}),(0,r.jsx)(k.AM,{isOpen:O,onClose:()=>L(!1),anchorEl:D.current,anchor:"right",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-[160px]",children:[(0,r.jsxs)("button",{onClick:Z,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(er.A,{size:10}),"Copy"]}),(0,r.jsxs)("button",{onClick:Q,disabled:!a||v,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors disabled:opacity-40",children:[(0,r.jsx)(es.A,{size:10}),"Show in large type"]})]})})]});return g&&a?(0,r.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group items-start",onClick:Z,children:["left"===x&&e,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:y?"Copied":t})}),(0,r.jsx)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:V}}),"right"===x&&e]}):(0,r.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap items-center gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group",onClick:Z,children:["left"===x&&e,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:t})}),(0,r.jsxs)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 min-h-[24px] flex items-center",children:[(0,r.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:y?"Copied":a||"--"}),o]}),"right"===x&&e]})}let ea=U?(0,r.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),Y()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,r.jsx)(er.A,{size:10}),y?"Copied":"Copy"]}),(0,r.jsx)("button",{ref:D,onClick:e=>{e.stopPropagation(),L(!O)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":"Field actions for ".concat(t),children:(0,r.jsx)(el.A,{size:12})}),(0,r.jsx)(k.AM,{isOpen:O,onClose:()=>L(!1),anchorEl:D.current,anchor:"right",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,r.jsxs)("button",{onClick:Y,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(er.A,{size:10}),"Copy"]}),!F&&!N&&(0,r.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(eo.A,{size:10}),"Reveal"]}),!F&&N&&(0,r.jsxs)("button",{onClick:q,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(en.A,{size:10}),"Hide"]}),!v&&(0,r.jsxs)("button",{onClick:J,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(es.A,{size:10}),"Show in large type"]})]})})]}):null;if(M){let e=(0,r.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),Y()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,r.jsx)(er.A,{size:10}),y?"Copied":"Copy"]}),(0,r.jsx)("button",{ref:D,onClick:e=>{e.stopPropagation(),L(!O)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":"Field actions for ".concat(t),children:(0,r.jsx)(el.A,{size:12})}),(0,r.jsx)(k.AM,{isOpen:O,onClose:()=>L(!1),anchorEl:D.current,anchor:"right",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,r.jsxs)("button",{onClick:Y,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(er.A,{size:10}),"Copy"]}),N?(0,r.jsxs)("button",{onClick:q,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(en.A,{size:10}),"Hide"]}):(0,r.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(eo.A,{size:10}),"Reveal"]})]})})]});return(0,r.jsxs)("div",{"data-testid":"credential-field-row-".concat(i),className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] items-start",onClick:()=>{N&&null!=S?Y():X()},children:["left"===x&&e,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:y?"Copied":t})}),(0,r.jsx)("div",{"data-testid":"credential-field-value-".concat(i),className:"basis-full lg:basis-auto lg:flex-1 min-w-0",children:T?(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:T}):E?(0,r.jsx)(p.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):N&&null!=S?(0,r.jsx)("div",{className:"prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:H}}):(0,r.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:"••••••••"})}),"right"===x&&e]})}return(0,r.jsxs)("div",{"data-testid":"credential-field-row-".concat(i),className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors rounded-sm items-center ".concat(_||K?"cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)]":""),onClick:()=>{if(_)return void ee();K&&Y()},children:["left"===x&&ea,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:t})}),(0,r.jsx)("div",{"data-testid":"credential-field-value-".concat(i),className:"basis-full lg:basis-auto lg:flex-1 min-w-0 transition-colors rounded-sm ".concat(F?"":"cursor-pointer"," ").concat("".concat(_||K?"min-h-[24px] flex items-center":"hover:bg-[var(--color-background-alt,#f4f4f5)] min-h-[24px] flex items-center"," px-1 py-0.5")),onClick:et,children:T?(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:T}):E?(0,r.jsx)(p.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):_?N&&null!=S?(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:S}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),q()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,r.jsx)(en.A,{size:12})})]}):(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsx)("div",{"data-testid":"credential-field-barcode-".concat(i),className:"h-4 w-full bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),(0,r.jsx)("div",{className:"mt-1 h-1.5 w-full",style:{backgroundImage:"repeating-linear-gradient(45deg, var(--color-text, #000), var(--color-text, #000) 5px, transparent 5px, transparent 10px)",opacity:.1}}),(0,r.jsx)("div",{className:"mt-1 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:y?"Copied":"Click to reveal and copy"})]}):F?(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:y?"Copied":null!=S?"Hover then click to copy":"Decrypting"}):N&&null!=S?(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:S}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),q()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,r.jsx)(en.A,{size:12})})]}):(0,r.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:y?"Copied":"••••••••"})}),"right"===x&&ea]})},ed=e=>{let{credentialId:t}=e,[a,s]=(0,l.useState)(null),[o,n]=(0,l.useState)(30),[i,c]=(0,l.useState)(null),d=(0,l.useCallback)(async()=>{try{let e=await h.FH.post(h.jI.Wallet,"/credentials/".concat(t,"/totp"));e.success&&e.code?(s(e.code),n(e.remaining),c(!0)):c(!1)}catch(e){c(!1)}},[t]);if((0,l.useEffect)(()=>{d()},[d]),(0,l.useEffect)(()=>{if(!0!==i)return;let e=setInterval(()=>{n(e=>e<=1?(d(),30):e-1)},1e3);return()=>clearInterval(e)},[i,d]),null===i||!1===i)return null;let u=o<=5,x=a?"".concat(a.slice(0,3)," ").concat(a.slice(3)):"--- ---",p=o/30;return(0,r.jsx)("div",{className:"space-y-0.5","data-testid":"totp-display",children:(0,r.jsx)(ec,{label:"2FA Code",value:x,copyValue:null!=a?a:void 0,credentialId:t,fieldKey:"totp_code",isSensitive:!1,trailingValue:(0,r.jsxs)("div",{className:"ml-2 flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 18 18",className:"shrink-0",style:{transform:"rotate(-90deg)"},children:[(0,r.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[var(--color-border,#d4d4d8)]",opacity:"0.3"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"".concat(43.98*p," 43.98"),strokeLinecap:"round",className:u?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-accent,#ccff00)]"})]}),(0,r.jsxs)("span",{className:"font-mono text-[9px] ".concat(u?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-text-faint,#9ca3af)]"),children:[o,"s"]})]}),disableLargeType:!0,onShowLargeType:()=>{}})})},eu=e=>{let{isOpen:t,onClose:a,value:s}=e,[o,n]=(0,l.useState)(!1),i=(0,l.useRef)(null),c=Array.from(null!=s?s:""),d=(0,l.useCallback)(async()=>{try{await navigator.clipboard.writeText(s),n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),2e3)}catch(e){}},[s]);return(0,l.useEffect)(()=>(t||n(!1),()=>{i.current&&clearTimeout(i.current)}),[t]),(0,r.jsx)(k.aF,{isOpen:t,onClose:a,title:"Expanded Value",size:"lg",contentClassName:"!p-0",footer:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:a,children:"Cancel"}),(0,r.jsx)(k.$n,{variant:"primary",size:"sm",onClick:()=>{d()},children:o?"COPIED":"COPY"})]}),children:(0,r.jsxs)("div",{className:"w-full min-h-[360px] px-6 py-8 flex flex-col items-center justify-center text-center",children:[(0,r.jsx)("div",{className:"w-full max-w-[900px] max-h-[70vh] overflow-auto px-1",children:(0,r.jsx)("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fit,minmax(56px,1fr))]",children:c.map((e,t)=>(0,r.jsxs)("div",{"data-testid":"large-type-char-".concat(t+1),className:"rounded-sm border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)] px-1 py-2",children:[(0,r.jsx)("div",{className:"font-mono text-3xl font-bold leading-none text-[var(--color-text,#0a0a0a)] select-all",children:(e=>" "===e?"␠":"\n"===e?"↵":" "===e?"⇥":e)(e)}),(0,r.jsx)("div",{"data-testid":"large-type-index-".concat(t+1),className:"mt-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:t+1})]},"".concat(t,"-").concat(e)))})}),(0,r.jsx)("div",{className:"mt-8 font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-faint,#9ca3af)]",children:"Use copy to move this value to clipboard"})]})})};var ex=a(4788),ep=a(5917);let ef=[{value:"15m",label:"15 Minutes"},{value:"1h",label:"1 Hour"},{value:"24h",label:"24 Hours"},{value:"7d",label:"7 Days"},{value:"30d",label:"30 Days"}],em=[{value:"anyone",label:"Anyone with link"},{value:"password",label:"Set password"}],ev=e=>{let{isOpen:t,onClose:a,credentialId:s,credentialName:o}=e,[n,i]=(0,l.useState)("24h"),[c,d]=(0,l.useState)("anyone"),[u,x]=(0,l.useState)(""),[p,f]=(0,l.useState)(!1),[m,v]=(0,l.useState)(!1),[b,g]=(0,l.useState)(!1),[y,j]=(0,l.useState)(null),[N,w]=(0,l.useState)(""),[C,S]=(0,l.useState)(!1),[A,E]=(0,l.useState)(!1),[I,T]=(0,l.useState)(null);(0,l.useEffect)(()=>{t&&(j(null),v(!1),w(""),T(null),S(!1))},[t]);let R=()=>"password"!==c||u.trim()?null:"Password is required when access mode is Set password",O=async()=>{j(null);let e=R();if(e)return void j(e);try{g(!0),v(!1);let e=await h.FH.post(h.jI.Wallet,"/credential-shares/gist",{credentialId:s,expiresAfter:n,accessMode:c,oneTimeOnly:p,shareBaseUrl:window.location.origin,..."password"===c?{password:u}:{}});w(e.gist.url),await navigator.clipboard.writeText(e.gist.url),v(!0),setTimeout(()=>v(!1),2e3)}catch(e){j('Failed to create secret gist. Check "gh auth status" in terminal. If needed, run "gh auth login".')}finally{g(!1)}},L=async()=>{T(null);let e=R();if(e)return void T(e);try{let e;E(!0);let t=(e=(await h.FH.post(h.jI.Wallet,"/credential-shares",{credentialId:s,expiresAfter:n,accessMode:c,oneTimeOnly:p,..."password"===c?{password:u}:{}})).share.token,"".concat(window.location.origin,"/share/").concat(e));await navigator.clipboard.writeText(t),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){T(e instanceof Error?e.message:"Failed to generate share link")}finally{E(!1)}},D=()=>{j(null),v(!1),g(!1),w(""),T(null),S(!1),E(!1),a()};return(0,r.jsx)(k.aF,{isOpen:t,onClose:D,title:"Sharing ".concat(o),icon:(0,r.jsx)(ex.A,{size:16,className:"text-[var(--color-text,#0a0a0a)]"}),size:"md",footer:(0,r.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:D,children:"CLOSE"})}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"GitHub Gist (Recommended)"}),(0,r.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["Check ",(0,r.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth status`"})," first; run ",(0,r.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth login`"})," only if needed."]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[N?(0,r.jsx)("a",{href:N,target:"_blank",rel:"noreferrer",className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate hover:underline",title:N,children:N}):(0,r.jsx)("div",{className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate",children:"Click SHARE GIST to generate a link."}),(0,r.jsxs)(k.$n,{variant:"primary",size:"sm",onClick:O,loading:b,className:"shrink-0 whitespace-nowrap",children:[m?(0,r.jsx)(ep.A,{size:10}):(0,r.jsx)(er.A,{size:10}),m?"COPIED":"SHARE GIST"]})]}),y&&(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:y})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"Share Link (Local)"}),(0,r.jsx)(k.UM,{label:"Link Expires After",options:ef,value:n,onChange:e=>i(e),compact:!0}),(0,r.jsx)(k.UM,{label:"Available To",options:em,value:c,onChange:e=>d(e),compact:!0}),"password"===c&&(0,r.jsx)(k.ks,{label:"Share Password",type:"password",value:u,onChange:e=>x(e.target.value),placeholder:"Enter password",compact:!0}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex flex-1 min-w-0 items-center gap-2 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:p,onChange:e=>f(e.target.checked),className:"accent-[var(--color-accent,#ccff00)]"}),(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text,#0a0a0a)] truncate",children:"Can only be viewed one time"})]}),(0,r.jsxs)(k.$n,{variant:"primary",size:"sm",onClick:L,loading:A,className:"shrink-0 whitespace-nowrap",children:[C?(0,r.jsx)(ep.A,{size:10}):(0,r.jsx)(er.A,{size:10}),C?"COPIED":"COPY LINK"]})]}),I&&(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:I})]})]})})};var eh=a(5880);let eb=e=>{let{walletLink:t}=e,[a,s]=(0,l.useState)(null),[o,n]=(0,l.useState)(!0),[i,c]=(0,l.useState)(!1),d=t.chain.toLowerCase();(0,l.useEffect)(()=>{let e=!0;return(async()=>{try{let a=((await h.FH.get(h.jI.Wallet,"/wallets")).wallets||[]).find(e=>e.address.toLowerCase()===t.walletAddress.toLowerCase()&&e.chain.toLowerCase()===d)||null;e&&s(a)}catch(t){e&&s(null)}finally{e&&n(!1)}})(),()=>{e=!1}},[t.walletAddress,d,t.chain]);let u=(0,l.useMemo)(()=>(null==a?void 0:a.name)||(null==a?void 0:a.label)||t.label||"Linked Wallet",[a,t.label]);return(0,r.jsxs)("div",{className:"mt-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background-alt,#f4f4f5)] p-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] inline-flex items-center gap-1",children:[(0,r.jsx)(I.A,{size:11})," Linked Wallet"]}),(0,r.jsxs)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:[t.tier," \xb7 ",t.chain]})]}),(0,r.jsx)("div",{className:"font-mono text-[11px] text-[var(--color-text,#0a0a0a)] mb-1",children:u}),(0,r.jsx)("div",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] mb-2 break-all",children:t.walletAddress}),o?(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Loading wallet state…"}):a?(0,r.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-success,#22c55e)] mb-2",children:["Wallet resolved",a.balance?" \xb7 Balance: ".concat(a.balance):""]}):(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-warning,#f59e0b)] mb-2",children:"Stale link: wallet not found in current wallet list"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",onClick:async()=>{await navigator.clipboard.writeText(t.walletAddress),c(!0),setTimeout(()=>c(!1),1200)},children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(er.A,{size:10})," ",i?"COPIED":(e=>"".concat(e.slice(0,6),"...").concat(e.slice(-4)))(t.walletAddress)]})}),(0,r.jsxs)("a",{href:function(e,t){return"solana"===e||"solana-devnet"===e?"https://solscan.io/account/".concat(t):"polygon"===e?"https://polygonscan.com/address/".concat(t):"ethereum"===e?"https://etherscan.io/address/".concat(t):"https://basescan.org/address/".concat(t)}(d,t.walletAddress),target:"_blank",rel:"noreferrer",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] inline-flex items-center gap-1",children:[(0,r.jsx)(eh.A,{size:10})," Explorer"]})]})]})};function eg(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}let ey=e=>{var t;let{credential:a,vaultName:s,lifecycle:o,onEdit:n,onDelete:i,onRestore:c,onDuplicate:d}=e,[u,x]=(0,l.useState)(null),[p,f]=(0,l.useState)(!1),[m,v]=(0,l.useState)(!1),[b,g]=(0,l.useState)(null),[y,j]=(0,l.useState)(!1),[N,C]=(0,l.useState)(null),[S,A]=(0,l.useState)(null),[E,I]=(0,l.useState)(""),T=e=>{x(e)};(0,l.useEffect)(()=>{g(null),j(!1),C(null),A(null),I("")},[a.id]);let R=(0,l.useCallback)(async()=>{j(!0),g(null);try{let e=await h.FH.post(h.jI.Wallet,"/credentials/".concat(a.id,"/reauth"));C(e.authorization_url||null),A(e.state||null),g(e.message||"Authorization URL generated. Complete provider consent, then paste code.")}catch(e){g(e instanceof Error?e.message:"Failed to start re-auth")}finally{j(!1)}},[a.id]),O=(0,l.useCallback)(async()=>{if(!E.trim()||!S)return void g("Enter authorization code after consent to complete re-auth.");j(!0);try{let e=await h.FH.post(h.jI.Wallet,"/credentials/".concat(a.id,"/reauth"),{code:E.trim(),state:S});g(e.message||"Re-auth complete. Refresh credential details."),I("")}catch(e){g(e instanceof Error?e.message:"Failed to complete re-auth")}finally{j(!1)}},[a.id,E,S]),L={login:"Login",card:"Card",note:"Note",plain_note:"Plain Note",hot_wallet:"Hot Wallet",apikey:"API Key",custom:"Key / Value",oauth2:"OAuth2",ssh:"SSH Key",gpg:"GPG Key"}[a.type]||a.type.charAt(0).toUpperCase()+a.type.slice(1),D=null!=(t=a.meta.sensitive_field_keys)?t:[],P=a.meta.walletLink,z="active"===o,F=z?"ARCHIVE":"archive"===o?"DELETE":"PURGE",M=z?"Archive Credential":"archive"===o?"Delete Credential":"Purge Credential",_=z?"This credential will be moved to Archive.":"archive"===o?"This credential will be moved to Recently Deleted.":"This credential will be permanently deleted now.",K={sensitiveClickBehavior:"copy"};return(0,r.jsxs)("div",{className:"p-6 flex flex-col relative",children:[(0,r.jsx)("div",{className:"absolute top-6 -left-1 text-vertical label-specimen-sm text-[var(--color-text-faint,#9ca3af)] select-none opacity-40 hidden lg:block",children:"CLASSIFIED"}),(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsx)("h2",{className:"font-mono font-bold text-lg text-[var(--color-text,#0a0a0a)]",children:a.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,r.jsx)("span",{className:"shard-start inline-block bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-[8px] font-bold uppercase tracking-widest px-2 py-0.5",children:L}),(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:s})]})]}),(0,r.jsxs)("div",{className:"flex-1 space-y-0.5",children:["login"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"URL",value:a.meta.url,credentialId:a.id,fieldKey:w.u.login.url,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Username",value:a.meta.username,credentialId:a.id,fieldKey:w.u.login.username,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Password",credentialId:a.id,fieldKey:w.u.login.password,isSensitive:!0,onShowLargeType:T,...K}),z&&(0,r.jsx)(ed,{credentialId:a.id}),D.includes(w.u.login.notes)&&(0,r.jsx)(ec,{label:"Notes",credentialId:a.id,fieldKey:w.u.login.notes,isSensitive:!0,onShowLargeType:T,...K})]}),"card"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Cardholder",value:a.meta.cardholder,credentialId:a.id,fieldKey:w.u.card.cardholder,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Brand",value:a.meta.brand,credentialId:a.id,fieldKey:w.u.card.brand,isSensitive:!1,onShowLargeType:T}),a.meta.last4&&(0,r.jsx)(ec,{label:"Card",value:"•••• ".concat(a.meta.last4),credentialId:a.id,fieldKey:w.u.card.last4,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Number",credentialId:a.id,fieldKey:w.u.card.number,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"Expiry",credentialId:a.id,fieldKey:w.u.card.expiry,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"CVV",credentialId:a.id,fieldKey:w.u.card.cvv,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"Billing ZIP",value:a.meta.billing_zip,credentialId:a.id,fieldKey:w.u.card.billingZip,isSensitive:!1,onShowLargeType:T}),D.includes(w.u.card.notes)&&(0,r.jsx)(ec,{label:"Notes",credentialId:a.id,fieldKey:w.u.card.notes,isSensitive:!0,onShowLargeType:T,...K})]}),"note"===a.type&&(0,r.jsx)(ec,{label:"Content",credentialId:a.id,fieldKey:w.l3,isSensitive:!0,onShowLargeType:T,sensitiveInteractionMode:"markdown-hover-copy",disableLargeType:!0}),"plain_note"===a.type&&(0,r.jsx)(ec,{label:"Content",value:a.meta[w.l3]||a.meta.value,credentialId:a.id,fieldKey:w.l3,isSensitive:!1,onShowLargeType:T,renderMarkdown:!0,disableLargeType:!0}),"apikey"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Key",value:a.meta.key,credentialId:a.id,fieldKey:w.u.apikey.key,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Value",credentialId:a.id,fieldKey:w.u.apikey.value,isSensitive:!0,onShowLargeType:T,sensitiveClickBehavior:"copy"})]}),"hot_wallet"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Address",value:a.meta.address||(null==P?void 0:P.walletAddress),credentialId:a.id,fieldKey:w.u.hot_wallet.address,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Chain",value:a.meta.chain||(null==P?void 0:P.chain),credentialId:a.id,fieldKey:w.u.hot_wallet.chain,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Private Key",credentialId:a.id,fieldKey:w.u.hot_wallet.privateKey,isSensitive:!0,onShowLargeType:T,...K})]}),"custom"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Key",value:a.meta.primaryKey||"value",credentialId:a.id,fieldKey:"primaryKey",isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Value",credentialId:a.id,fieldKey:a.meta.primaryKey||w.u.custom.value,isSensitive:!0,onShowLargeType:T,...K})]}),"ssh"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:w.u.ssh.fingerprint,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Key Type",value:a.meta.key_type,credentialId:a.id,fieldKey:w.u.ssh.keyType,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Hosts",value:Array.isArray(a.meta.hosts)?a.meta.hosts.join(", "):void 0,credentialId:a.id,fieldKey:w.u.ssh.hosts,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:w.u.ssh.publicKey,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Private Key",credentialId:a.id,fieldKey:w.u.ssh.privateKey,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"Passphrase",credentialId:a.id,fieldKey:w.u.ssh.passphrase,isSensitive:!0,onShowLargeType:T,...K})]}),"gpg"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:w.u.gpg.fingerprint,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Key ID",value:a.meta.key_id,credentialId:a.id,fieldKey:w.u.gpg.keyId,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"UID Email",value:a.meta.uid_email,credentialId:a.id,fieldKey:w.u.gpg.uidEmail,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Expires At",value:a.meta.expires_at,credentialId:a.id,fieldKey:w.u.gpg.expiresAt,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:w.u.gpg.publicKey,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Private Key",credentialId:a.id,fieldKey:w.u.gpg.privateKey,isSensitive:!0,onShowLargeType:T,...K})]}),"oauth2"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ec,{label:"Token Endpoint",value:a.meta.token_endpoint,credentialId:a.id,fieldKey:w.u.oauth2.tokenEndpoint,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Scopes",value:a.meta.scopes,credentialId:a.id,fieldKey:w.u.oauth2.scopes,isSensitive:!1,onShowLargeType:T}),(0,r.jsx)(ec,{label:"Auth Method",value:a.meta.auth_method,credentialId:a.id,fieldKey:w.u.oauth2.authMethod,isSensitive:!1,onShowLargeType:T}),(a.meta.needs_reauth||N)&&(0,r.jsxs)("div",{className:"px-2 py-2 my-1 border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 text-[var(--color-danger,#ef4444)] font-mono text-[10px]",children:["⚠️ Re-authentication required",!!a.meta.reauth_reason&&(0,r.jsx)("span",{className:"block text-[9px] text-[var(--color-danger,#ef4444)]/70 mt-0.5",children:String(a.meta.reauth_reason)}),(0,r.jsx)("button",{className:"mt-1 px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:R,disabled:y,children:y?"Loading…":"Start Re-auth"}),N&&(0,r.jsx)("a",{href:N,target:"_blank",rel:"noopener noreferrer",className:"mt-1 ml-2 inline-block px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider",children:"Open Consent"}),S&&(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("input",{value:E,onChange:e=>I(e.target.value),placeholder:"Paste authorization code",className:"flex-1 px-2 py-1 border border-[var(--color-danger,#ef4444)]/30 bg-transparent text-[9px]"}),(0,r.jsx)("button",{className:"px-2 py-1 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:O,disabled:y||!E.trim(),children:"Complete Re-auth"})]}),b&&(0,r.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-danger,#ef4444)]/90 break-words",children:b})]}),a.meta.last_refreshed&&(0,r.jsxs)("div",{className:"px-1 py-1",children:[(0,r.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Last Refreshed:"," "]}),(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:new Date(String(a.meta.last_refreshed)).toLocaleString()})]}),(()=>{let e=a.meta.expires_at,t=Math.floor(Date.now()/1e3),l=!e||t>=e,s=e?l?"Expired — will auto-refresh on next read":"Valid for ".concat(Math.floor((e-t)/60),"m"):"No token yet";return(0,r.jsxs)("div",{className:"px-1 py-2",children:[(0,r.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Token Status:"," "]}),(0,r.jsx)("span",{className:"font-mono text-[10px] font-bold",style:{color:l?"var(--color-danger,#ef4444)":"var(--color-success,#00c853)"},children:s})]})})(),(0,r.jsx)(ec,{label:"Access Token",credentialId:a.id,fieldKey:w.u.oauth2.accessToken,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"Refresh Token",credentialId:a.id,fieldKey:w.u.oauth2.refreshToken,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"Client ID",credentialId:a.id,fieldKey:w.u.oauth2.clientId,isSensitive:!0,onShowLargeType:T,...K}),(0,r.jsx)(ec,{label:"Client Secret",credentialId:a.id,fieldKey:w.u.oauth2.clientSecret,isSensitive:!0,onShowLargeType:T,...K})]})]}),P&&(0,r.jsx)(eb,{walletLink:P}),a.meta.tags&&a.meta.tags.length>0&&(0,r.jsx)("div",{className:"mt-4 flex flex-wrap gap-1.5",children:a.meta.tags.map(e=>(0,r.jsx)("span",{className:"inline-block font-mono text-[9px] px-2 py-0.5 bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text-muted,#6b7280)]",children:e},e))}),(0,r.jsx)("div",{className:"mt-4 pt-3 border-t border-[var(--color-border,#d4d4d8)]",children:(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-faint,#9ca3af)] space-y-0.5",children:[(0,r.jsxs)("div",{children:["Created ",eg(a.createdAt)]}),(0,r.jsxs)("div",{children:["Updated ",eg(a.updatedAt)]}),a.archivedAt&&(0,r.jsxs)("div",{children:["Archived ",eg(a.archivedAt)]}),a.deletedAt&&(0,r.jsxs)("div",{children:["Deleted ",eg(a.deletedAt)]}),(0,r.jsxs)("div",{children:["Vault: ",s]})]})}),(0,r.jsxs)("div",{className:"mt-4 flex gap-2",children:[z&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>v(!0),children:"SHARE"}),z&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:n,children:"EDIT"}),z&&d&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:d,children:"DUPLICATE"}),!z&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:c,children:"archive"===o?"RESTORE":"RESTORE TO ARCHIVE"}),(0,r.jsx)(k.$n,{variant:"danger",size:"sm",onClick:()=>f(!0),children:F})]}),(0,r.jsx)(k.Rw,{isOpen:p,onClose:()=>f(!1),onConfirm:()=>{f(!1),i()},title:M,message:_,confirmText:"recently_deleted"===o?"PURGE":"CONFIRM",variant:"recently_deleted"===o?"danger":"warning"}),(0,r.jsx)(eu,{isOpen:null!=u,onClose:()=>x(null),value:null!=u?u:""}),(0,r.jsx)(ev,{isOpen:m,onClose:()=>v(!1),credentialId:a.id,credentialName:a.name})]})},ej=e=>{let{variant:t,onAdd:a}=e;return"no-selection"===t?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(O.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Select a credential from the list"})]})}):"empty-lifecycle"===t?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(O.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"No credentials in this section"})]})}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(O.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"Your vault is empty"}),(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-faint,#9ca3af)] mb-4",children:"Create your first credential"}),(0,r.jsx)(k.$n,{size:"sm",onClick:a,icon:(0,r.jsx)(x.A,{size:10}),children:"ADD"})]})})};var eN=a(1227),ew=a(6132),ek=a(2529);let eC=[{label:"1Password",format:"1password-csv",supported:!0},{label:"Bitwarden",format:"bitwarden-csv",supported:!0},{label:"Chrome",format:"chrome-csv",supported:!0},{label:"Firefox",format:"firefox-csv",supported:!0},{label:"iCloud Keychain",format:"icloud-csv",supported:!0},{label:"LastPass",format:"lastpass-csv",supported:!0}],eS={skip:"Skip",rename:"Rename",overwrite:"Create Anyway"};function eA(){let e=localStorage.getItem("auramaxx_admin_token");return e||sessionStorage.getItem("auramaxx_admin_token")}let eE=e=>{let{isOpen:t,onClose:a,onComplete:s,vaults:o,selectedVaultId:n,onSelectedVaultIdChange:i,onAddVault:c,walletBaseUrl:d}=e,[u,x]=(0,l.useState)("select"),[p,f]=(0,l.useState)("1password-csv"),[m,v]=(0,l.useState)(null),[h,b]=(0,l.useState)("skip"),[g,y]=(0,l.useState)(null),[j,N]=(0,l.useState)(null),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(null),I=(0,l.useRef)(null),T=(0,l.useMemo)(()=>o.map(e=>({value:e.id,label:e.name||(e.isPrimary?"Primary":"Vault ".concat(e.id.slice(0,6)))})),[o]),R=(0,l.useMemo)(()=>o.find(e=>e.id===n)||null,[o,n]),O=(0,l.useCallback)(()=>{x("select"),f("1password-csv"),v(null),b("skip"),y(null),N(null),C(!1),A(null),I.current&&(I.current.value="")},[]),L=(0,l.useCallback)(()=>{O(),a()},[O,a]),D=(0,l.useCallback)(e=>{var t,a;let r=null!=(a=null==(t=e.target.files)?void 0:t[0])?a:null;if(r&&r.size>0xa00000){A("File too large (".concat((r.size/1024/1024).toFixed(1),"MB). Maximum is 10MB.")),v(null),I.current&&(I.current.value="");return}v(r),A(null)},[]),P=(0,l.useCallback)(e=>{if(!m)return null;let t=new FormData;return t.append("file",m),t.append("format",p),t.append("vaultId",n||"primary"),e&&t.append("dryRun","true"),t.append("duplicateStrategy",h),t},[m,p,n,h]),z=(0,l.useCallback)(async()=>{if(m){C(!0),A(null);try{let e=P(!0);if(!e)return;let t=eA(),a=await fetch("".concat(d,"/credentials/import"),{method:"POST",headers:t?{Authorization:"Bearer ".concat(t)}:{},body:e});if(!(a.headers.get("content-type")||"").includes("application/json"))return void A("Server error: ".concat(a.status," ").concat(a.statusText));let r=await a.json();if(!a.ok||!r.success)return void A(r.error||"Request failed: ".concat(a.status));y(r),x("preview")}catch(e){A(e instanceof Error?e.message:"Preview failed")}finally{C(!1)}}},[m,P,d]),F=(0,l.useCallback)(async()=>{C(!0),A(null);try{let e=P(!1);if(!e)return;let t=eA(),a=await fetch("".concat(d,"/credentials/import"),{method:"POST",headers:t?{Authorization:"Bearer ".concat(t)}:{},body:e});if(!(a.headers.get("content-type")||"").includes("application/json"))return void A("Server error: ".concat(a.status," ").concat(a.statusText));let r=await a.json();if(!a.ok)return void A(r.error||"Request failed: ".concat(a.status));N(r),x("result")}catch(e){A(e instanceof Error?e.message:"Import failed")}finally{C(!1)}},[P,d]),M=(0,l.useCallback)(()=>{s(),L()},[s,L]),_=eC.find(e=>e.format===p);return(0,r.jsxs)(k.aF,{isOpen:t,onClose:L,title:"Import Credentials",size:"md",footer:(()=>{if("select"===u)return(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:L,children:"CANCEL"}),(0,r.jsx)(k.$n,{size:"sm",onClick:z,loading:w,disabled:!m||!(null==_?void 0:_.supported),children:"PREVIEW"})]});if("preview"===u&&g){let e="skip"===h?g.total-g.duplicates:g.total;return(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>{x("select"),A(null),I.current&&(I.current.value="")},children:"BACK"}),(0,r.jsxs)(k.$n,{size:"sm",onClick:F,loading:w,disabled:0===g.credentials.length,children:["IMPORT ",e," CREDENTIAL",1!==e?"S":""]})]})}return"result"===u?(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(k.$n,{size:"sm",onClick:M,children:"DONE"})}):null})(),children:["select"===u&&(0,r.jsxs)("div",{className:"space-y-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"Source"}),(0,r.jsx)(k.O6,{ariaLabel:"Import source",value:p,onChange:e=>{let t=eC.find(t=>t.format===e);(null==t?void 0:t.supported)&&f(t.format)},options:eC.map(e=>({value:e.format,label:e.label,description:e.supported?void 0:"Coming soon",icon:(0,r.jsx)(E.A,{size:12})}))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"File"}),(0,r.jsx)("input",{ref:I,type:"file",accept:".csv",onChange:D,className:"hidden"}),(0,r.jsxs)("button",{onClick:()=>{var e;return null==(e=I.current)?void 0:e.click()},className:"w-full flex items-center justify-center gap-2 px-4 py-4 border-2 border-dashed border-[var(--color-border,#d4d4d8)] hover:border-[var(--color-text-muted,#6b7280)] transition-colors",children:[(0,r.jsx)(X.A,{size:14,className:"text-[var(--color-text-muted,#6b7280)]"}),(0,r.jsx)("span",{className:"text-[10px] font-mono tracking-wider text-[var(--color-text-muted,#6b7280)]",children:m?m.name:"Choose CSV file"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-end gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(k.UM,{label:"Target Vault",ariaLabel:"TARGET VAULT",options:T,value:n,onChange:i,compact:!0,searchable:!0,menuPosition:"top",searchPlaceholder:"Search vault...",emptyMessage:"No vault matches"})}),(0,r.jsx)(k.$n,{type:"button",variant:"secondary",size:"sm",onClick:c,className:"!h-[var(--control-height-sm)] !px-3",children:"ADD"})]}),R&&!R.isUnlocked&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-warning,#ff4d00)] border border-[var(--color-warning,#ff4d00)]/30 bg-[var(--color-warning,#ff4d00)]/10 px-3 py-2",children:"Selected vault is locked. Unlock it before preview/import."})]}),S&&(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,r.jsx)(ew.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:S})]})]}),"preview"===u&&(g?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text,#0a0a0a)]",children:g.total}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Total"})]}),g.duplicates>0&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-amber-600",children:g.duplicates}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Duplicates"})]})]}),(0,r.jsxs)("div",{className:"max-h-[240px] overflow-y-auto border border-[var(--color-border,#d4d4d8)]",children:[0===g.credentials.length?(0,r.jsx)("div",{className:"px-4 py-8 text-center text-[10px] font-mono text-[var(--color-text-muted,#6b7280)]",children:"No credentials found in file"}):g.credentials.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--color-border,#d4d4d8)] last:border-b-0 ".concat(e.isDuplicate?"bg-amber-50/50":""),children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-[10px] font-mono text-[var(--color-text,#0a0a0a)] truncate",children:e.name}),e.url&&(0,r.jsx)("div",{className:"text-[8px] font-mono text-[var(--color-text-faint,#9ca3af)] truncate",children:e.url})]}),(0,r.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-[var(--color-text-faint,#9ca3af)] flex-shrink-0",children:e.type}),e.isDuplicate&&(0,r.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-amber-600 flex-shrink-0",children:"DUP"})]},t)),g.total>g.credentials.length&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[9px] font-mono text-[var(--color-text-faint,#9ca3af)] text-center",children:["+ ",g.total-g.credentials.length," more"]})]}),g.duplicates>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1.5",children:"Duplicate handling"}),(0,r.jsx)("div",{className:"flex gap-1.5",children:["skip","rename","overwrite"].map(e=>(0,r.jsx)("button",{onClick:()=>b(e),className:"px-3 py-1.5 text-[9px] font-mono tracking-wider uppercase border transition-colors ".concat(h===e?"border-[var(--color-accent,#ccff00)] bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)] hover:bg-[var(--color-background-alt,#f4f4f5)]"),children:eS[e]},e))})]}),S&&(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,r.jsx)(ew.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:S})]})]}):null),"result"===u&&(()=>{if(!j)return null;let e=j.errors.length>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[j.success?(0,r.jsx)(ek.A,{size:20,className:"text-green-600"}):(0,r.jsx)(ew.A,{size:20,className:"text-red-500"}),(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"text-[11px] font-mono font-bold text-[var(--color-text,#0a0a0a)]",children:j.success?"Import Complete":"Import Failed"})})]}),(0,r.jsxs)("div",{className:"flex gap-6",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-green-600",children:j.imported}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Imported"})]}),j.skipped>0&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text-muted,#6b7280)]",children:j.skipped}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Skipped"})]}),e&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-red-500",children:j.errors.length}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Errors"})]})]}),e&&(0,r.jsx)("div",{className:"max-h-[120px] overflow-y-auto border border-red-200 bg-red-50",children:j.errors.map((e,t)=>(0,r.jsxs)("div",{className:"px-3 py-1 text-[9px] font-mono text-red-700 border-b border-red-100 last:border-b-0",children:["Row ",e.row,": ",e.reason]},t))})]})})()]})};var eI=a(224),eT=a(2056),eR=a(2520),eO=a(3721);let eL={CREDENTIAL_SCOPE_DENIED:"SCOPE_DENY",TOKEN_PERMISSION_DENIED:"SCOPE_DENY",TOKEN_REVOKED:"TOKEN_REVOKED",TOKEN_EXPIRED:"TOKEN_EXPIRED",RATE_LIMIT:"RATE_LIMITED",RATE_LIMITED:"RATE_LIMITED",CREDENTIAL_NOT_FOUND:"NOT_FOUND",CREDENTIAL_TOTP_NOT_CONFIGURED:"NOT_FOUND",TOKEN_AGENT_PUBKEY_MISSING:"MISSING_KEY",INTERNAL_ERROR:"INTERNAL_ERROR",ALLOW:"UNKNOWN"};function eD(e,t,a){let r="string"==typeof e?e.trim().toUpperCase():"";return"ALLOW"===r?"ALLOW":"DENY"===r?"DENY":"RATE_LIMIT"===r?"RATE_LIMIT":"ERROR"===r?"ERROR":!0===t?"ALLOW":!1===t&&(null!=a?a:0)===429?"RATE_LIMIT":!1===t?"DENY":(null!=a?a:0)>=500?"ERROR":"UNKNOWN"}function eP(e){var t;return null!=(t=eL["string"==typeof e?e.trim().toUpperCase():""])?t:"UNKNOWN"}function ez(e){return e.tokenHash?"HIGH":e.agentId?"MEDIUM":"LOW"}function eF(e){var t,a,r;let l="string"==typeof e.decision?e.decision:void 0,s="string"==typeof e.reasonCode?e.reasonCode:void 0,o="string"==typeof e.tokenHash?e.tokenHash:void 0,n="string"==typeof e.agentId?e.agentId:void 0,i=e.timestamp,c=new Date("string"==typeof i||"number"==typeof i?i:Date.now()).getTime();return{id:String(null!=(a=e.id)?a:"".concat(c,"-").concat(null!=(t=null!=o?o:n)?t:"unknown")),timestamp:c,tokenKey:null!=(r=null!=o?o:n)?r:"unknown",tokenHash:o,agentId:n,endpoint:"string"==typeof e.action?e.action:void 0,credentialKey:"string"==typeof e.credentialId?e.credentialId:void 0,sourceVersion:"task40-audit-v1",decision:eD(l,e.allowed,e.httpStatus),reasonCode:eP(s),rawDecision:l,rawReasonCode:s,confidence:ez({tokenHash:o,agentId:n})}}function eM(e){var t,a,r;let l="object"==typeof e.data&&null!==e.data?e.data:{},s="object"==typeof l.metadata&&null!==l.metadata?l.metadata:{},o="string"==typeof l.result?l.result:"string"==typeof l.decision?l.decision:void 0,n="string"==typeof l.reasonCode?l.reasonCode:"string"==typeof l.reason?l.reason:void 0,i="string"==typeof l.tokenHash?l.tokenHash:void 0,c="string"==typeof l.agentId?l.agentId:void 0,d=e.timestamp,u=new Date("string"==typeof d||"number"==typeof d?d:Date.now()).getTime();return{id:String(null!=(a=e.id)?a:"".concat(u,"-").concat(null!=(t=null!=i?i:c)?t:"unknown")),timestamp:u,tokenKey:null!=(r=null!=i?i:c)?r:"unknown",tokenHash:i,agentId:c,endpoint:"string"==typeof s.route?s.route:"string"==typeof l.action?l.action:void 0,credentialKey:"string"==typeof l.credentialId?l.credentialId:void 0,sourceVersion:"legacy-logs-v1",decision:eD(o,l.allowed,l.httpStatus),reasonCode:eP(n),rawDecision:o,rawReasonCode:n,confidence:ez({tokenHash:i,agentId:c})}}function e_(e){return"HIGH"===e?3:"MEDIUM"===e?2:1}let eK=[{value:"active",label:"ACTIVE"},{value:"revoked",label:"REVOKED"},{value:"expired",label:"EXPIRED"},{value:"all",label:"ALL"}],eU=[{value:"1h",label:"1 HOUR"},{value:"24h",label:"24 HOURS"},{value:"7d",label:"7 DAYS"}],eH=[{value:"all",label:"ALL"},{value:"ALLOW",label:"ALLOW"},{value:"DENY",label:"DENY"},{value:"RATE_LIMIT",label:"RATE_LIMIT"},{value:"ERROR",label:"ERROR"},{value:"UNKNOWN",label:"UNKNOWN"}];function eV(e){if(null==e)return null;if("number"==typeof e)return e<1e12?1e3*e:e;let t=Date.parse(e);return Number.isFinite(t)?t:null}function eW(e){return e?e.length<=14?e:"".concat(e.slice(0,8),"...").concat(e.slice(-6)):"—"}function e$(e){let t=eV(e);return null===t?"—":new Date(t).toLocaleString()}function eB(){var e,t;let{subscribe:a}=(0,eR.h)(),[s,o]=(0,l.useState)([]),[n,i]=(0,l.useState)([]),[c,d]=(0,l.useState)("active"),[u,x]=(0,l.useState)("24h"),[p,f]=(0,l.useState)(""),[m,v]=(0,l.useState)("all"),[b,g]=(0,l.useState)("all"),[y,j]=(0,l.useState)(0),[N,w]=(0,l.useState)(!0),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)(null),[I,R]=(0,l.useState)(null),[O,L]=(0,l.useState)(null),[D,P]=(0,l.useState)(null),z=(0,l.useRef)(null),F=(0,l.useRef)(null),M=(0,l.useCallback)(async()=>{w(!0),S(null);try{var e,t;let[a,r,l]=await Promise.all([h.FH.get(h.jI.Wallet,"/dashboard"),h.FH.get(h.jI.Wallet,"/security/credential-access/recent",{limit:500}),h.FH.get(h.jI.Wallet,"/logs",{category:"agent",limit:200})]),s=a.success?[...null!=(e=a.tokens.active)?e:[],...null!=(t=a.tokens.inactive)?t:[]]:[],n=r.success?r.rows.map(eF):[],c=l.success?l.logs.filter(e=>{var t;let a=null!=(t=e.data)?t:{};return"credential_access_decision"===a.action}).map(eM):[],d=Date.now(),u=(function(e){let t=new Map;for(let a of e){let e=a.id||function(e){var t,a;return"".concat(e.timestamp,"|").concat(null!=(t=e.endpoint)?t:"","|").concat(e.tokenKey,"|").concat(null!=(a=e.credentialKey)?a:"","|").concat(e.decision,"|").concat(e.reasonCode)}(a),r=t.get(e);if(!r||e_(a.confidence)>e_(r.confidence)){t.set(e,a);continue}"task40-audit-v1"===a.sourceVersion&&"legacy-logs-v1"===r.sourceVersion&&t.set(e,a)}return Array.from(t.values()).sort((e,t)=>t.timestamp-e.timestamp)})([...n,...c]).filter(e=>e.timestamp<=d);o(s),i(u.slice(0,500)),j(0)}catch(e){S(e instanceof Error?e.message:"Failed to load audit console")}finally{w(!1)}},[]);(0,l.useEffect)(()=>{M()},[M]);let _=(0,l.useCallback)(()=>{F.current||(F.current=setTimeout(()=>{F.current=null,M()},120))},[M]);(0,l.useEffect)(()=>{let e=[a(eO.Cw.TOKEN_CREATED,_),a(eO.Cw.TOKEN_REVOKED,_),a(eO.Cw.TOKEN_SPENT,_),a(eO.Cw.CREDENTIAL_CHANGED,_),a(eO.Cw.CREDENTIAL_ACCESSED,_)];return()=>{e.forEach(e=>e()),F.current&&(clearTimeout(F.current),F.current=null)}},[_,a]),(0,l.useEffect)(()=>{j(0)},[m,b,u,p]);let K=(0,l.useMemo)(()=>Date.now()-("1h"===u?36e5:"7d"===u?6048e5:864e5),[u]),U=p.trim().toLowerCase(),H=(0,l.useMemo)(()=>s.map((e,t)=>({key:e.tokenHash||e.agentId||"unknown-".concat(t),token:e,status:function(e){if(e.isRevoked)return"revoked";let t=eV(e.expiresAt);return e.isExpired||null!==t&&t<=Date.now()?"expired":e.isActive?"active":"inactive"}(e)})),[s]),V=(0,l.useMemo)(()=>new Map(H.map(e=>[e.key,e])),[H]),W="all"===m?null:null!=(t=V.get(m))?t:null,$=(0,l.useMemo)(()=>n.filter(e=>e.timestamp>=K),[n,K]),B=(0,l.useMemo)(()=>{let e=H.filter(e=>"active"===e.status).length,t=$.filter(e=>"DENY"===e.decision).length;return{activeCount:e,denied:t,rateLimited:$.filter(e=>"RATE_LIMIT"===e.decision).length,unknown:$.filter(e=>"UNKNOWN"===e.decision||"UNKNOWN"===e.reasonCode).length}},[H,$]),G=(0,l.useMemo)(()=>H.filter(e=>("all"===c||e.status===c)&&(!U||"".concat(e.key," ").concat(e.token.tokenHash," ").concat(e.token.agentId).toLowerCase().includes(U))),[H,c,U]),Y=(0,l.useMemo)(()=>{let e=[{value:"all",label:"ALL TOKENS"}],t=new Set(["all"]);if(G.forEach(a=>{var r,l;t.has(a.key)||(t.add(a.key),e.push({value:a.key,label:"".concat(null!=(r=a.token.agentId)?r:"unknown"," \xb7 ").concat(eW(null!=(l=a.token.tokenHash)?l:a.key))}))}),"all"!==m&&!t.has(m)){var a,r;let t=V.get(m);t&&e.push({value:t.key,label:"".concat(null!=(a=t.token.agentId)?a:"unknown"," \xb7 ").concat(eW(null!=(r=t.token.tokenHash)?r:t.key))})}return e},[G,m,V]),X=(0,l.useMemo)(()=>{let e=new Map;return $.forEach(t=>{[t.tokenHash,t.tokenKey,t.agentId?"agent:".concat(t.agentId):void 0,t.agentId].filter(e=>!!e).forEach(a=>{var r;e.set(a,Math.max(null!=(r=e.get(a))?r:0,t.timestamp))})}),e},[$]),q=(0,l.useCallback)(e=>{var t,a,r,l;let s=e.token.tokenHash;return s&&X.has(s)?null!=(t=X.get(s))?t:null:X.has(e.key)?null!=(a=X.get(e.key))?a:null:e.token.agentId&&X.has("agent:".concat(e.token.agentId))?null!=(r=X.get("agent:".concat(e.token.agentId)))?r:null:e.token.agentId&&X.has(e.token.agentId)&&null!=(l=X.get(e.token.agentId))?l:null},[X]),J=(0,l.useMemo)(()=>$.filter(e=>{if("all"!==m){let t=null==W?void 0:W.token.agentId,a=e.tokenKey===m||e.tokenHash===m,r=!!t&&e.agentId===t;if(!a&&!r)return!1}if("all"!==b&&e.decision!==b)return!1;if(U){var t,a;if(!"".concat(null!=(t=e.tokenHash)?t:""," ").concat(e.tokenKey," ").concat(null!=(a=e.agentId)?a:"").toLowerCase().includes(U))return!1}return!0}),[b,$,m,W,U]),Z=(0,l.useMemo)(()=>{let e=50*y;return J.slice(e,e+50)},[J,y]),Q=(0,l.useCallback)(e=>{v(e),j(0),z.current&&"function"==typeof z.current.scrollIntoView&&z.current.scrollIntoView({behavior:"smooth",block:"start"})},[]),ee=(0,l.useCallback)(async(e,t)=>{if(!t||!navigator.clipboard)return void E("Clipboard unavailable for this key.");try{let a=eW(t);await navigator.clipboard.writeText(a),L(e),E("Copied ".concat(a)),setTimeout(()=>L(t=>t===e?null:t),1500)}catch(e){E("Clipboard write failed.")}},[]),et=(0,l.useCallback)((e,t)=>{if(!t)return void E("Token hash unavailable; cannot revoke.");P({tokenKey:e,tokenHash:t})},[]),ea=(0,l.useCallback)(async()=>{if(!D)return;let{tokenKey:e,tokenHash:t}=D;P(null),R(e),E(null);try{let e=await h.FH.post(h.jI.Wallet,"/actions/tokens/revoke",{tokenHash:t});if(!e.success)return void E(e.error||"Failed to revoke token.");E("Revoked ".concat(eW(t))),await M()}catch(e){E(e instanceof Error?e.message:"Failed to revoke token.")}finally{R(null)}},[D,M]);return N?(0,r.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"LOADING_AUDIT_CONSOLE…"}):C?(0,r.jsx)("div",{className:"p-4 border border-[var(--color-warning,#ff4d00)] bg-[color-mix(in_srgb,var(--color-warning,#ff4d00)_10%,transparent)]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 font-mono text-[10px] text-[var(--color-warning,#ff4d00)]",children:[(0,r.jsx)(eT.A,{size:12})," ",C]})}):(0,r.jsxs)("div",{className:"h-full flex flex-col p-3 gap-3 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] p-2 bg-[var(--color-surface,#fff)]",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-mono text-[11px] font-bold",children:"AUDIT"}),(0,r.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:[null==(e=eU.find(e=>e.value===u))?void 0:e.label.toLowerCase()," \xb7 ",Math.min(n.length,500)," rows",n.length>=500?" (capped)":""]})]}),(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>void M(),icon:(0,r.jsx)(T.A,{size:10}),children:"REFRESH"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-2",children:[(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsx)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:"ACTIVE KEYS"}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:B.activeCount})]}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["DENIES (",u,")"]}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:B.denied})]}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["RATE LIMITED (",u,")"]}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:B.rateLimited})]}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["UNKNOWN MAPS (",u,")"]}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:B.unknown})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-2",children:[(0,r.jsx)(k.UM,{label:"Status",options:eK,value:c,onChange:e=>d(e),compact:!0}),(0,r.jsx)(k.UM,{label:"Window",options:eU,value:u,onChange:e=>x(e),compact:!0}),(0,r.jsx)(k.UM,{label:"Token",options:Y,value:m,onChange:v,compact:!0}),(0,r.jsx)(k.UM,{label:"Decision",options:eH,value:b,onChange:e=>g(e),compact:!0}),(0,r.jsxs)("label",{className:"font-mono text-[9px] flex flex-col gap-1",children:["SEARCH KEY / AGENT",(0,r.jsx)("input",{value:p,onChange:e=>f(e.target.value),placeholder:"hash or agent id",className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] px-2 py-1.5 text-[10px]"})]})]}),A&&(0,r.jsx)("div",{className:"font-mono text-[9px] border border-[var(--color-info,#0047ff)] p-2 text-[var(--color-info,#0047ff)] bg-[color-mix(in_srgb,var(--color-info,#0047ff)_8%,transparent)]",children:A}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] overflow-hidden",children:[(0,r.jsxs)("div",{className:"px-2 py-1.5 border-b border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",children:["KEY INVENTORY \xb7 ",G.length," ROWS"]}),(0,r.jsx)("div",{className:"max-h-[220px] overflow-auto",children:0===G.length?(0,r.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO TOKENS MATCH FILTERS"}):(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:"sticky top-0 bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,r.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,r.jsx)("th",{className:"p-2",children:"KEY"}),(0,r.jsx)("th",{className:"p-2",children:"AGENT"}),(0,r.jsx)("th",{className:"p-2",children:"PERMISSIONS"}),(0,r.jsx)("th",{className:"p-2",children:"ISSUED"}),(0,r.jsx)("th",{className:"p-2",children:"EXPIRES"}),(0,r.jsx)("th",{className:"p-2",children:"LAST USED"}),(0,r.jsx)("th",{className:"p-2",children:"ACTIONS"})]})}),(0,r.jsx)("tbody",{children:G.map(e=>{var t,a,l,s,o;let n=q(e),i=I===e.key,c="active"===e.status&&!!e.token.tokenHash;return(0,r.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,r.jsxs)("td",{className:"p-2",children:[(0,r.jsx)("div",{children:eW(null!=(t=e.token.tokenHash)?t:e.key)}),(0,r.jsx)("div",{className:"text-[8px] uppercase ".concat("active"===(s=e.status)?"text-[var(--color-success,#16a34a)]":"revoked"===s?"text-[var(--color-warning,#ff4d00)]":"expired"===s?"text-[var(--color-text-faint,#9ca3af)]":"text-[var(--color-text-muted,#6b7280)]"),children:e.status})]}),(0,r.jsx)("td",{className:"p-2",children:null!=(a=e.token.agentId)?a:"unknown"}),(0,r.jsx)("td",{className:"p-2",children:(o=null!=(l=e.token.permissions)?l:[])&&0!==o.length?o.length<=2?o.join(", "):"".concat(o.slice(0,2).join(", ")," +").concat(o.length-2):"—"}),(0,r.jsx)("td",{className:"p-2",children:e$(e.token.createdAt)}),(0,r.jsxs)("td",{className:"p-2",children:[e$(e.token.expiresAt),(0,r.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:function(e){let t=eV(e);if(null===t)return"—";let a=t-Date.now();if(a<=0)return"expired";let r=Math.floor(a/6e4);if(r<60)return"".concat(r,"m");let l=Math.floor(r/60);return l<24?"".concat(l,"h"):"".concat(Math.floor(l/24),"d")}(e.token.expiresAt)})]}),(0,r.jsx)("td",{className:"p-2",children:n?new Date(n).toLocaleString():"—"}),(0,r.jsx)("td",{className:"p-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:()=>void ee(e.key,e.token.tokenHash),className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40",title:"Copy short hash",disabled:!e.token.tokenHash,children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(er.A,{size:8}),O===e.key?"COPIED":"COPY"]})}),(0,r.jsx)("button",{onClick:()=>Q(e.key),className:"border px-1.5 py-0.5 text-[8px]",title:"Open activity",children:"VIEW"}),(0,r.jsx)("button",{onClick:()=>et(e.key,e.token.tokenHash),disabled:!c||i,className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40 text-[var(--color-warning,#ff4d00)]",title:c?"Revoke token":"Token cannot be revoked",children:i?"REVOKING":"REVOKE"})]})})]},e.key)})})]})})]}),(0,r.jsxs)("div",{ref:z,className:"flex-1 overflow-auto border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)]",children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-2 py-1.5 border-b bg-[var(--color-surface-alt,#fafafa)] font-mono text-[9px] flex items-center justify-between",children:[(0,r.jsxs)("span",{children:["TOKEN ACTIVITY \xb7 ",J.length," ROWS"]}),(0,r.jsxs)("span",{className:"text-[var(--color-text-muted,#6b7280)]",children:["PAGE ",y+1," / ",Math.max(1,Math.ceil(J.length/50))]})]}),n.length>=500&&(0,r.jsx)("div",{className:"font-mono text-[9px] border-b border-[var(--color-warning,#ff4d00)] p-2 text-[var(--color-warning,#ff4d00)]",children:"RESULTS TRUNCATED AT 500 ROWS — NARROW FILTERS TO REDUCE VOLUME."}),0===Z.length?(0,r.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO AUDIT EVENTS IN WINDOW"}):(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:"sticky top-[31px] bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,r.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,r.jsx)("th",{className:"p-2",children:"TIME"}),(0,r.jsx)("th",{className:"p-2",children:"TOKEN / AGENT"}),(0,r.jsx)("th",{className:"p-2",children:"DECISION"}),(0,r.jsx)("th",{className:"p-2",children:"REASON"}),(0,r.jsx)("th",{className:"p-2",children:"CONFIDENCE"}),(0,r.jsx)("th",{className:"p-2",children:"ENDPOINT"})]})}),(0,r.jsx)("tbody",{children:Z.map(e=>{var t,a;return(0,r.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,r.jsx)("td",{className:"p-2",children:new Date(e.timestamp).toLocaleString()}),(0,r.jsxs)("td",{className:"p-2",children:[null!=(t=e.agentId)?t:"unknown"," \xb7 ",e.tokenKey.slice(0,10)]}),(0,r.jsx)("td",{className:"p-2",children:e.decision}),(0,r.jsxs)("td",{className:"p-2",children:[e.reasonCode,e.rawReasonCode&&"UNKNOWN"===e.reasonCode?" (".concat(e.rawReasonCode,")"):""]}),(0,r.jsx)("td",{className:"p-2",title:"HIGH"===e.confidence?"Direct token hash match":"MEDIUM"===e.confidence?"Agent correlation":"Partial/ambiguous join",children:e.confidence}),(0,r.jsx)("td",{className:"p-2",children:null!=(a=e.endpoint)?a:"—"})]},e.id)})})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>j(e=>Math.max(0,e-1)),disabled:0===y,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"PREV"}),(0,r.jsx)("button",{onClick:()=>j(e=>(e+1)*50<J.length?e+1:e),disabled:(y+1)*50>=J.length,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"NEXT"})]}),(0,r.jsx)(k.Rw,{isOpen:null!==D,onClose:()=>P(null),onConfirm:()=>void ea(),title:"Revoke Token",message:D?"Revoke token ".concat(eW(D.tokenHash),"? The agent will lose access immediately."):"",confirmText:"REVOKE",variant:"danger"})]})}var eG=a(7801);let eY=[{id:"strict",label:"Strict",description:"Agent vault only, read-only, strong field redaction. 15 min TTL."},{id:"dev",label:"Dev (recommended)",description:"All vaults, read/write, moderate redaction. 1 hour TTL."},{id:"admin",label:"Admin (dangerous)",description:"Full access, no redaction. Use with caution."}],eX=[{value:"wallet:list",label:"wallet:list"},{value:"wallet:create:hot",label:"wallet:create:hot"},{value:"wallet:create:temp",label:"wallet:create:temp"},{value:"wallet:rename",label:"wallet:rename"},{value:"wallet:export",label:"wallet:export"},{value:"wallet:tx:add",label:"wallet:tx:add"},{value:"wallet:asset:add",label:"wallet:asset:add"},{value:"wallet:asset:remove",label:"wallet:asset:remove"},{value:"send:hot",label:"send:hot"},{value:"send:temp",label:"send:temp"},{value:"swap",label:"swap"},{value:"fund",label:"fund"},{value:"launch",label:"launch"},{value:"apikey:get",label:"apikey:get"},{value:"apikey:set",label:"apikey:set"},{value:"workspace:modify",label:"workspace:modify"},{value:"strategy:read",label:"strategy:read"},{value:"strategy:manage",label:"strategy:manage"},{value:"app:storage",label:"app:storage"},{value:"app:storage:all",label:"app:storage:all"},{value:"app:accesskey",label:"app:accesskey"},{value:"action:create",label:"action:create"},{value:"action:read",label:"action:read"},{value:"action:resolve",label:"action:resolve"},{value:"adapter:manage",label:"adapter:manage"},{value:"addressbook:write",label:"addressbook:write"},{value:"bookmark:write",label:"bookmark:write"},{value:"secret:read",label:"secret:read"},{value:"secret:write",label:"secret:write"},{value:"totp:read",label:"totp:read"},{value:"trade:all",label:"trade:all"},{value:"wallet:write",label:"wallet:write"},{value:"extension:*",label:"extension:*"},{value:"admin:*",label:"admin:* (dangerous)"}],eq={strict:"Read-only, agent vault only. Hidden: password, cvv, privateKey, seedPhrase, refresh_token. 15 min TTL, 50 reads max.",dev:"Read/write, all vaults. Hidden: cvv, seedPhrase, privateKey, refresh_token. 1 hour TTL, 500 reads max.",admin:"Full access, no field redaction. 1 hour TTL, unlimited reads."},eJ=[{value:"profile",label:"Profile"},{value:"permissions",label:"Permissions"}],eZ="aura:api-keys:profiles:v1",eQ={strict:{ttlSeconds:900,maxReads:50,scope:["secret:read"],excludeFields:["password","cvv","privateKey","seedPhrase","refresh_token"]},dev:{ttlSeconds:3600,maxReads:500,scope:["wallet:list","secret:read","secret:write","action:create","action:read","action:resolve"],excludeFields:["cvv","seedPhrase","privateKey","refresh_token"]},admin:{ttlSeconds:3600,scope:["admin:*"],excludeFields:[]}};function e0(e){return e.length<=14?e:"".concat(e.slice(0,8),"...").concat(e.slice(-4))}function e1(){let e=Math.random().toString(36).slice(2,8);return"agent:local:".concat(e)}function e4(e){return Array.from(new Set(e.map(e=>e.trim().normalize("NFKC").toLowerCase()).filter(Boolean)))}let e2=e=>{var t,a,s,o,n;let{requests:i,activeTokens:c,inactiveTokens:u,actionLoading:x,onResolveAction:f,onRevokeToken:m,vaults:v=[]}=e,[g,y]=(0,l.useState)([]),[j,N]=(0,l.useState)(null),[w,C]=(0,l.useState)(""),[S,A]=(0,l.useState)("dev"),[E,I]=(0,l.useState)(""),[R,L]=(0,l.useState)(""),[P,z]=(0,l.useState)([]),[F,M]=(0,l.useState)("secret:read"),[_,K]=(0,l.useState)(""),[U,H]=(0,l.useState)([]),[V,W]=(0,l.useState)(null),[$,B]=(0,l.useState)(null),[G,Y]=(0,l.useState)(()=>e1()),[X,q]=(0,l.useState)("profile"),[J,Z]=(0,l.useState)("builtin:dev"),[Q,ee]=(0,l.useState)("secret:read"),[et,ea]=(0,l.useState)(["secret:read","secret:write"]),[el,es]=(0,l.useState)([]),[eo,en]=(0,l.useState)(!1),[ei,ec]=(0,l.useState)(null),[ed,eu]=(0,l.useState)(null),[ex,ef]=(0,l.useState)(null),[em,ev]=(0,l.useState)(!1),[eh,eb]=(0,l.useState)(!1),[eg,ey]=(0,l.useState)(null),[ej,eN]=(0,l.useState)(null),[ew,ek]=(0,l.useState)(null);(0,l.useEffect)(()=>{try{let e=localStorage.getItem(eZ);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let a=t.filter(e=>e&&"string"==typeof e.id&&"string"==typeof e.name&&"string"==typeof e.profile&&"v1"===e.profileVersion&&"number"==typeof e.updatedAt).map(e=>{var t,a,r;let l=e4([...(null==(t=e.overrides)?void 0:t.scope)||[],...(null==(a=e.overrides)?void 0:a.readScopes)||[],...(null==(r=e.overrides)?void 0:r.writeScopes)||[]]),s=e.overrides?{...e.overrides,...l.length>0?{scope:l}:{},readScopes:void 0,writeScopes:void 0}:null;return{...e,overrides:s}});y(a)}catch(e){y([])}},[]),(0,l.useEffect)(()=>{localStorage.setItem(eZ,JSON.stringify(g))},[g]);let eC=(0,l.useCallback)(()=>{N(null),C(""),A("dev"),I(""),L(""),z([]),M("secret:read"),K(""),H([]),W(null),B(null)},[]),eS=(0,l.useCallback)(e=>{let t=eQ[e];t&&(I(String(t.ttlSeconds)),L("number"==typeof t.maxReads?String(t.maxReads):""),z(t.scope),M(t.scope[0]||"secret:read"),K(t.excludeFields.join(", ")))},[]),eA=(0,l.useMemo)(()=>{let e=[{value:"vault:*",label:"All Vaults (vault:*)"}];for(let t of v){let a=t.name||t.id;e.push({value:"vault:".concat(t.id),label:"vault:".concat(a)})}return e},[v]),eE=(0,l.useMemo)(()=>i.filter(e=>"pending"===e.status&&("auth"===e.type||"permission_update"===e.type)),[i]),eI=(0,l.useMemo)(()=>[...eY.map(e=>({value:"builtin:".concat(e.id),label:"".concat(e.label," — ").concat(e.description)})),...g.map(e=>({value:"draft:".concat(e.id),label:"Custom \xb7 ".concat(e.name)}))],[g]);(0,l.useEffect)(()=>{eI.some(e=>e.value===J)||Z("builtin:dev")},[J,eI]);let eR=(0,l.useCallback)(()=>{if(J.startsWith("draft:")){let r=J.slice(6),l=g.find(e=>e.id===r);if(l){var e,t,a;let r=e4([...(null==(e=l.overrides)?void 0:e.scope)||[],...(null==(t=l.overrides)?void 0:t.readScopes)||[],...(null==(a=l.overrides)?void 0:a.writeScopes)||[]]),s=l.overrides?{...l.overrides,...r.length>0?{scope:r}:{}}:void 0;return{profile:l.profile,profileVersion:l.profileVersion,...s?{profileOverrides:s}:{}}}}return{profile:J.startsWith("builtin:")?J.slice(8):"dev",profileVersion:"v1"}},[J,g]),eO=(0,l.useCallback)(e=>{let t=e4([e])[0];t&&ea(e=>e.includes(t)?e:[...e,t])},[]),eL=(0,l.useCallback)(e=>{ea(t=>t.filter(t=>t!==e))},[]),eD=(0,l.useCallback)(()=>{W(null),B(null);let e=w.trim();if(!e)return void W("Profile name is required.");let{overrides:t,error:a}=function(e){let t={};if(e.ttlSeconds.trim().length>0){let a=Number(e.ttlSeconds.trim());if(!Number.isFinite(a)||a<=0)return{overrides:null,error:"TTL override must be a positive number."};t.ttlSeconds=a}if(e.maxReads.trim().length>0){let a=Number(e.maxReads.trim());if(!Number.isFinite(a)||a<=0)return{overrides:null,error:"Max reads override must be a positive number."};t.maxReads=a}let a=e4(e.scope),r=function(e){let t=e.split(",").map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0}(e.excludeFields);return a.length>0&&(t.scope=a),r&&(t.excludeFields=r),{overrides:Object.keys(t).length>0?t:null,error:null}}({ttlSeconds:E,maxReads:R,scope:P,excludeFields:_});if(a)return void W(a);let r=U.length>0?{...t||{},readScopes:U,writeScopes:U}:t;if(g.some(t=>t.name.toLowerCase()===e.toLowerCase()&&t.id!==j))return void W("A profile with this name already exists.");let l={id:j||"".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,7)),name:e,profile:S,profileVersion:"v1",overrides:r,updatedAt:Date.now()};y(e=>j?e.map(e=>e.id===j?l:e):[l,...e]),B(j?"Profile updated.":"Profile created."),j||Z("draft:".concat(l.id)),N(l.id)},[j,S,_,R,w,P,E,U,g]),eP=(0,l.useCallback)(e=>{var t,a,r,l,s,o,n,i;N(e.id),C(e.name),A(e.profile),I((null==(t=e.overrides)?void 0:t.ttlSeconds)?String(e.overrides.ttlSeconds):""),L((null==(a=e.overrides)?void 0:a.maxReads)?String(e.overrides.maxReads):"");let c=e4([...(null==(r=e.overrides)?void 0:r.scope)||[],...(null==(l=e.overrides)?void 0:l.readScopes)||[],...(null==(s=e.overrides)?void 0:s.writeScopes)||[]]);z(c),M(c[0]||"secret:read"),K(((null==(o=e.overrides)?void 0:o.excludeFields)||[]).join(", ")),H((null==(n=e.overrides)?void 0:n.readScopes)||(null==(i=e.overrides)?void 0:i.vaultReadScopes)||[]),W(null),B(null)},[]),ez=(0,l.useCallback)(e=>{let t=e4([e])[0];t&&z(e=>e.includes(t)?e:[...e,t])},[]),eF=(0,l.useCallback)(e=>{z(t=>t.filter(t=>t!==e))},[]),eM=(0,l.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),j===e&&eC(),J==="draft:".concat(e)&&Z("builtin:dev")},[j,J,eC]),e_=(0,l.useCallback)(async()=>{if(ey(null),eN(null),"permissions"===X)return void ey("Policy preview is currently available for profile-based issuance only.");eb(!0);try{let e=eR(),t=await h.FH.post(h.jI.Wallet,"/actions/token/preview",e);eN(function(e){let t=e&&"object"==typeof e?e:{},a=t.effectivePolicy&&"object"==typeof t.effectivePolicy?t.effectivePolicy:{},r=a.credentialAccess&&"object"==typeof a.credentialAccess?a.credentialAccess:{},l=a.rateBudget&&"object"==typeof a.rateBudget?a.rateBudget:{};return{version:"v1",profile:t.profile&&"object"==typeof t.profile?t.profile:void 0,effectivePolicy:{permissions:Array.isArray(a.permissions)?a.permissions.filter(e=>"string"==typeof e):[],credentialAccess:{read:Array.isArray(r.read)?r.read.filter(e=>"string"==typeof e):[],write:Array.isArray(r.write)?r.write.filter(e=>"string"==typeof e):[],excludeFields:Array.isArray(r.excludeFields)?r.excludeFields.filter(e=>"string"==typeof e):[],maxReads:"number"==typeof r.maxReads?r.maxReads:null},ttlSeconds:"number"==typeof a.ttlSeconds?a.ttlSeconds:0,maxReads:"number"==typeof a.maxReads?a.maxReads:null,rateBudget:{state:"inherited"===l.state||"explicit"===l.state?l.state:"none",requests:"number"==typeof l.requests?l.requests:null,windowSeconds:"number"==typeof l.windowSeconds?l.windowSeconds:null,source:"profile"===l.source||"override"===l.source?l.source:"none"}},warnings:Array.isArray(t.warnings)?t.warnings.filter(e=>"string"==typeof e):[],overrideDelta:Array.isArray(t.overrideDelta)?t.overrideDelta.filter(e=>"string"==typeof e):[],denyExamples:Array.isArray(t.denyExamples)?t.denyExamples.filter(e=>!!e&&"object"==typeof e).map(e=>({code:String(e.code||"UNKNOWN"),message:String(e.message||"")})):[],effectivePolicyHash:"string"==typeof t.effectivePolicyHash?t.effectivePolicyHash:"n/a"}}(t))}catch(e){ey(e instanceof Error?e.message:"Failed to preview profile policy.")}finally{eb(!1)}},[X,eR]),eK=(0,l.useCallback)(async()=>{if(ec(null),eu(null),ef(null),!G.trim())return void ec("Agent ID is required.");if("permissions"===X&&0===et.length)return void ec("Select at least one permission for manual issuance.");let e=(0,b.OQ)();if(!e)return void ec("Vault keypair is unavailable. Re-unlock and retry.");en(!0);try{var t,a;let r;if("permissions"===X){let t=el.length>0?{read:el,write:el}:void 0;r=await h.FH.post(h.jI.Wallet,"/actions/token",{agentId:G.trim(),pubkey:e,permissions:et,...t?{credentialAccess:t}:{}})}else{let t=eR();el.length>0&&(t.profileOverrides={...t.profileOverrides||{},readScopes:el,writeScopes:el}),r=await h.FH.post(h.jI.Wallet,"/actions/token",{agentId:G.trim(),pubkey:e,...t})}if(!r.success||!r.encryptedToken)throw Error("Token issuance failed.");let l=await (0,b.DC)(r.encryptedToken);if(eu(l),"permissions"===X)ef("".concat(G.trim()," \xb7 permissions:").concat(et.join(",")).concat((null==(t=r.warnings)?void 0:t.length)?" \xb7 warnings present":""));else{let e=eR();ef("".concat(G.trim()," \xb7 ").concat(e.profile,"@").concat(e.profileVersion).concat((null==(a=r.warnings)?void 0:a.length)?" \xb7 warnings present":""))}}catch(e){ec(e instanceof Error?e.message:"Token issuance failed.")}finally{en(!1)}},[G,X,et,el,eR]),eU=(0,l.useCallback)(async()=>{ed&&navigator.clipboard&&(await navigator.clipboard.writeText(ed),ev(!0),setTimeout(()=>ev(!1),1500))},[ed]),eH=(0,l.useCallback)(async(e,t)=>{let a=await f(e,t);if(a.success)return void ek(t?"Approved request ".concat(e.slice(0,8),"."):"Rejected request ".concat(e.slice(0,8),"."));ek(a.message||"Failed to resolve request.")},[f]),eV=(0,l.useMemo)(()=>c.filter(e=>!e.isAdmin),[c]);return(0,r.jsxs)("div",{className:"h-full overflow-y-auto px-5 py-4 font-mono",children:[(0,r.jsxs)("div",{className:"mb-4 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"API KEYS"}),(0,r.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)] leading-relaxed",children:"Auth management surface for profile templates + permissions-based issuance + pending auth approvals."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,r.jsxs)("section",{className:"order-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUE API KEY"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(k.ks,{label:"Agent ID",value:G,onChange:e=>Y(e.target.value),placeholder:"agent:local:dev",compact:!0}),(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>Y(e1()),icon:(0,r.jsx)(T.A,{size:10}),title:"Regenerate Agent ID",className:"mb-[1px]",children:"NEW ID"})]}),(0,r.jsx)(k.UM,{label:"Issuance Mode",options:eJ,value:X,onChange:e=>q(e),compact:!0})]}),"profile"===X?(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)(k.UM,{label:"Profile Source",options:eI,value:J,onChange:Z,compact:!0}),(()=>{let e=J.startsWith("builtin:")?J.slice(8):null,t=e?eq[e]:null;return t?(0,r.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:t}):(0,r.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Profile mode resolves permissions/scopes/ttl from the selected profile."})})()]}):(0,r.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(k.UM,{label:"Permissions",options:eX.map(e=>({value:e.value,label:e.label})),value:Q,onChange:ee,compact:!0}),(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>eO(Q),children:"ADD"})]}),0===et.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-danger,#ef4444)]",children:"No permissions selected."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:et.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>eL(e),className:"h-4 px-1 text-[8px]",children:"X"})]},"perm-".concat(e)))}),(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Permissions mode issues exactly the selected permissions."})]}),eA.length>1&&(0,r.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(k.UM,{label:"Vault Scope",options:eA,value:(null==(t=eA[0])?void 0:t.value)||"vault:*",onChange:e=>{el.includes(e)||es(t=>[...t,e])},compact:!0}),(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>es([]),children:"CLEAR"})]}),0===el.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"No vault restriction — uses profile/system defaults."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:el.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>es(t=>t.filter(t=>t!==e)),className:"h-4 px-1 text-[8px]",children:"X"})]},"vs-".concat(e)))})]}),(0,r.jsx)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Generate a key in one click. Preview is optional and only shows what permissions/scopes will be issued."}),ei&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:ei}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,r.jsx)(k.$n,{size:"sm",onClick:()=>{eK()},loading:eo,icon:eo?void 0:(0,r.jsx)(d.A,{size:11}),children:"ISSUE API KEY"}),(0,r.jsx)(k.$n,{size:"sm",variant:"secondary",onClick:()=>{e_()},loading:eh,disabled:"permissions"===X,icon:eh?void 0:(0,r.jsx)(T.A,{size:11}),children:"PREVIEW POLICY"})]}),eg&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:eg}),ej&&(0,r.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,r.jsxs)("div",{className:"text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["HASH ",e0(ej.effectivePolicyHash)]}),ej.profile&&(0,r.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["profile: ",ej.profile.id,"@",ej.profile.version]}),(0,r.jsxs)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["permissions: ",ej.effectivePolicy.permissions.length," \xb7 ttl: ",ej.effectivePolicy.ttlSeconds,"s \xb7 max reads: ",null!=(s=ej.effectivePolicy.maxReads)?s:"unlimited"]}),(0,r.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsxs)("div",{children:["perms: ",ej.effectivePolicy.permissions.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["read scope: ",ej.effectivePolicy.credentialAccess.read.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["write scope: ",ej.effectivePolicy.credentialAccess.write.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["excluded fields: ",ej.effectivePolicy.credentialAccess.excludeFields.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["rate budget: ",ej.effectivePolicy.rateBudget.state," (",null!=(o=ej.effectivePolicy.rateBudget.requests)?o:"n/a"," / ",null!=(n=ej.effectivePolicy.rateBudget.windowSeconds)?n:"n/a","s, source=",ej.effectivePolicy.rateBudget.source,")"]})]}),ej.overrideDelta.length>0&&(0,r.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"OVERRIDE DELTA"}),ej.overrideDelta.join(" \xb7 ")]}),ej.denyExamples&&ej.denyExamples.length>0&&(0,r.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"EXPECTED DENY EXAMPLES"}),(0,r.jsx)("ul",{className:"space-y-0.5",children:ej.denyExamples.map(e=>(0,r.jsxs)("li",{children:["• ",e.code,": ",e.message]},"".concat(e.code,"-").concat(e.message.slice(0,12))))})]}),ej.warnings.length>0&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 text-[8px] text-[var(--color-warning,#ff4d00)]",children:[(0,r.jsx)(eG.A,{size:10,className:"mt-[1px]"}),(0,r.jsx)("span",{children:ej.warnings.join(" | ")})]})]}),ed&&(0,r.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[8px] tracking-widest text-[var(--color-success,#16a34a)]",children:"API KEY ISSUED"}),(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>{eU()},icon:(0,r.jsx)(er.A,{size:10}),children:em?"COPIED":"COPY"})]}),ex&&(0,r.jsx)("div",{className:"mb-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:ex}),(0,r.jsx)("code",{className:"block max-h-20 overflow-y-auto break-all bg-[var(--color-background,#f4f4f5)] px-2 py-1 text-[9px] text-[var(--color-text,#0a0a0a)]",children:ed})]})]}),(0,r.jsxs)("section",{className:"order-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PROFILE BUILDER"}),j&&(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:eC,children:"NEW"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,r.jsx)(k.ks,{label:"Profile Name",value:w,onChange:e=>C(e.target.value),placeholder:"e.g. CI deploy scoped",compact:!0}),(0,r.jsx)(k.UM,{label:"Load from template",options:eY.map(e=>({value:e.id,label:"".concat(e.label," — ").concat(e.description)})),value:S,onChange:e=>{A(e),eS(e)},compact:!0}),S&&eq[S]&&(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:eq[S]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,r.jsx)(k.ks,{label:"TTL Override",value:E,onChange:e=>I(e.target.value),placeholder:"seconds",compact:!0}),(0,r.jsx)(k.ks,{label:"Max Reads",value:R,onChange:e=>L(e.target.value),placeholder:"count",compact:!0})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(k.UM,{label:"Scope",options:eX.map(e=>({value:e.value,label:e.label})),value:F,onChange:M,compact:!0}),(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>ez(F),children:"ADD"})]}),0===P.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile scope defaults."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:P.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>eF(e),className:"h-4 px-1 text-[8px]",children:"X"})]},"scope-".concat(e)))})]}),(0,r.jsxs)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["Scope uses the same permission vocabulary as Issue API Key (for example: ",(0,r.jsx)("code",{children:"secret:read"}),", ",(0,r.jsx)("code",{children:"secret:write"}),", ",(0,r.jsx)("code",{children:"wallet:create:hot"}),", ",(0,r.jsx)("code",{children:"send:hot"}),")."]}),(0,r.jsx)(k.ks,{label:"Exclude Fields (CSV)",value:_,onChange:e=>K(e.target.value),placeholder:"password, seedPhrase",compact:!0}),eA.length>1&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(k.UM,{label:"Vault Read/Write Scope",options:eA,value:(null==(a=eA[0])?void 0:a.value)||"vault:*",onChange:e=>{U.includes(e)||H(t=>[...t,e])},compact:!0}),(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:()=>H([]),children:"CLEAR"})]}),0===U.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile vault defaults."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:U.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>H(t=>t.filter(t=>t!==e)),className:"h-4 px-1 text-[8px]",children:"X"})]},"pvs-".concat(e)))}),(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Restricts which vaults this profile can read/write credentials from. Select specific vaults or leave empty for profile defaults."})]})]}),V&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:V}),$&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-success,#16a34a)]",children:$}),(0,r.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,r.jsx)(k.$n,{size:"sm",onClick:eD,icon:(0,r.jsx)(O.A,{size:11}),children:j?"UPDATE PROFILE":"CREATE PROFILE"}),j&&(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:eC,children:"CANCEL"})]}),(0,r.jsxs)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3",children:[(0,r.jsxs)("div",{className:"mb-2 text-[9px] font-bold tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["SAVED PROFILES (",g.length,")"]}),0===g.length?(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No custom profiles saved yet."}):(0,r.jsx)("div",{className:"space-y-2",children:g.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-1.5",children:[(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>eP(e),className:"h-auto min-h-0 w-full justify-start px-0 py-0 text-left hover:bg-transparent",children:(0,r.jsxs)("span",{className:"block",children:[(0,r.jsx)("span",{className:"block text-[10px] text-[var(--color-text,#0a0a0a)]",children:e.name}),(0,r.jsxs)("span",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[e.profile,"@",e.profileVersion]})]})}),(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>eM(e.id),icon:(0,r.jsx)(D.A,{size:10}),children:""})]},e.id))})]})]})]}),(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,r.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PENDING AUTH REQUESTS"}),ew&&(0,r.jsx)("div",{className:"mb-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:ew}),0===eE.length?(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No pending auth requests."}):(0,r.jsx)("div",{className:"space-y-2",children:eE.map(e=>{let t=function(e){if(!e)return{};try{let t=JSON.parse(e);if(t&&"object"==typeof t)return t;return{}}catch(e){return{}}}(e.metadata),a="string"==typeof t.agentId?t.agentId:"unknown-agent",l="object"==typeof t.profile&&t.profile&&"id"in t.profile?t.profile:null,s=l?"".concat(String(l.id),"@").concat(String(l.version||"v1")):"n/a",o=l?function(e){return eq[e]||"Custom profile: ".concat(e)}(String(l.id)):null,n=Array.isArray(t.permissions)?t.permissions:[],i=x==="resolve-".concat(e.id);return(0,r.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,r.jsxs)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:[a," \xb7 ",e.type]}),(0,r.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[s," \xb7 ",new Date(e.createdAt).toLocaleString()]}),o&&(0,r.jsx)("div",{className:"mt-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:o}),n.length>0&&(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1",children:[n.slice(0,6).map(e=>(0,r.jsx)("span",{className:"border border-[var(--color-border,#d4d4d8)] px-1 py-0.5 text-[7px] text-[var(--color-text-muted,#6b7280)]",children:String(e)},e)),n.length>6&&(0,r.jsxs)("span",{className:"px-1 py-0.5 text-[7px] text-[var(--color-text-faint,#9ca3af)]",children:["+",n.length-6," more"]})]}),(0,r.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,r.jsx)(k.$n,{size:"sm",onClick:()=>{eH(e.id,!0)},loading:i,icon:i?void 0:(0,r.jsx)(ep.A,{size:10}),children:"APPROVE"}),(0,r.jsx)(k.$n,{size:"sm",variant:"secondary",onClick:()=>{eH(e.id,!1)},disabled:i,icon:(0,r.jsx)(eT.A,{size:10}),children:"REJECT"})]})]},e.id)})})]}),(0,r.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUED API KEYS"}),(0,r.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["ACTIVE (",eV.length,")"]}),0===eV.length?(0,r.jsx)("div",{className:"mb-3 text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No active non-admin tokens."}):(0,r.jsx)("div",{className:"mb-3 space-y-2",children:eV.map(e=>{let t=x==="revoke-".concat(e.tokenHash);return(0,r.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:e.agentId}),(0,r.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:e0(e.tokenHash)})]}),(0,r.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["perms: ",e.permissions.length," \xb7 expires: ",new Date(e.expiresAt).toLocaleString()]}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(k.$n,{size:"sm",variant:"secondary",onClick:()=>{m(e.tokenHash)},disabled:t,icon:t?(0,r.jsx)(p.A,{size:10,className:"animate-spin"}):(0,r.jsx)(D.A,{size:10}),children:"REVOKE"})})]},e.tokenHash)})}),(0,r.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["INACTIVE (",u.length,")"]}),0===u.length?(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No inactive tokens."}):(0,r.jsxs)("div",{className:"space-y-1.5",children:[u.slice(0,8).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between rounded border border-[var(--color-border,#d4d4d8)] px-2 py-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsx)("span",{children:e.agentId}),(0,r.jsx)("span",{children:e0(e.tokenHash)})]},"".concat(e.agentId,"-").concat(e.tokenHash))),u.length>8&&(0,r.jsxs)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["+",u.length-8," more inactive tokens"]})]})]})]})]})};var e8=a(6673),e3=a(5144);let e5={vaultId:null,category:"all",tag:null,search:"",favoritesOnly:!1,lifecycle:"active"},e6=[{value:"linked",label:"Child (inherits parent unlock)"},{value:"independent",label:"Independent (separate password)"}],e9="auramaxx_recently_accessed_credentials",e7="auramaxx_credentials_latest_access_at",te=["username","url","content","key","value","cardholder","brand","last4","token_endpoint","scopes","fingerprint"],tt={active:"active",archive:"archive",archived:"archive",deleted:"recently_deleted",recently_deleted:"recently_deleted",recentlydeleted:"recently_deleted"},ta=(()=>{let e=new Map;for(let t of Object.values(w.Rn))for(let a of t)for(let t of(e.set(a.key.toLowerCase(),a.key),a.aliases||[]))e.set(t.toLowerCase(),a.key);return e})(),tr=(()=>{let e=[...te,...Array.from(ta.values())],t=new Set,a=[];for(let r of e){let e=r.toLowerCase();t.has(e)||(t.add(e),a.push(r))}return a.slice(0,8)})();function tl(e){return e<768?"mobile":e<1280?"tablet":"desktop"}function ts(e){return e.location?e.location:e.deletedAt?"recently_deleted":e.archivedAt?"archive":"active"}function to(e){let t=e.createdAt?Date.parse(e.createdAt):NaN;return Number.isFinite(t)?t:0}function tn(e,t){let a=t[e.id];return"number"==typeof a&&Number.isFinite(a)&&a>0?a:to(e)}function ti(e,t){let a={};for(let r of e){let e=t[r.id];if("number"==typeof e&&Number.isFinite(e)&&e>0){a[r.id]=e;continue}a[r.id]=to(r)}return a}function tc(e){return e.trim().toLowerCase()}function td(e){return null==e?"":"string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e).toLowerCase():Array.isArray(e)?e.map(td).join(" "):"object"==typeof e?Object.values(e).map(td).join(" "):""}function tu(e){let t=e.trim().toLowerCase().replace(/\s+/g,"_");return ta.get(t)||t}let tx=e=>{let{onLock:t,onSettings:a}=e,{subscribe:s}=(0,eR.h)(),[o,n]=(0,l.useState)([]),[i,c]=(0,l.useState)([]),[d,u]=(0,l.useState)(null),[x,p]=(0,l.useState)(e5),[f,m]=(0,l.useState)(!0),[b,w]=(0,l.useState)("credentials"),[C,S]=(0,l.useState)({}),[A,E]=(0,l.useState)({}),[I,T]=(0,l.useState)(!1),[R,O]=(0,l.useState)(!1),[L,D]=(0,l.useState)(()=>tl(window.innerWidth)),{clearToken:P,setToken:z}=(0,v.A)(),[F,M]=(0,l.useState)(!1),[_,K]=(0,l.useState)(!1),[U,H]=(0,l.useState)(!1),[V,W]=(0,l.useState)("api-key-form"),[$,B]=(0,l.useState)(null),[G,X]=(0,l.useState)(null),[q,J]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)(""),[ee,er]=(0,l.useState)("independent"),[el,es]=(0,l.useState)(""),[eo,en]=(0,l.useState)(""),[ei,ec]=(0,l.useState)(!1),[ed,eu]=(0,l.useState)(!1),[ex,ep]=(0,l.useState)(""),[ef,em]=(0,l.useState)(!1),[ev,eh]=(0,l.useState)(!1),[eb,eg]=(0,l.useState)(null),[ew,ek]=(0,l.useState)(""),[eC,eS]=(0,l.useState)(!1),[eA,eT]=(0,l.useState)(null),[eL,eD]=(0,l.useState)(null),[eP,ez]=(0,l.useState)(!1),[eF,eM]=(0,l.useState)(null),{requests:e_,notifications:eK,dismissNotification:eU,resolveAction:eH,revokeToken:eV=async()=>!1,activeTokens:eW=[],inactiveTokens:e$=[],actionLoading:eG}=(0,e3.S)({autoFetch:!0}),eY=(0,l.useRef)(null),eX=(0,l.useRef)(null),eq=(0,l.useRef)(null),eJ=(0,l.useRef)(null),eZ="mobile"===L,eQ="tablet"===L,e0=(0,l.useCallback)(async()=>{try{let[e,t,a,r]=await Promise.all([h.FH.get(h.jI.Wallet,"/credentials",{location:"active"}),h.FH.get(h.jI.Wallet,"/credentials",{location:"archive"}),h.FH.get(h.jI.Wallet,"/credentials",{location:"recently_deleted"}),h.FH.get(h.jI.Wallet,"/vaults/credential")]),l=(e,t)=>e.success?(e.credentials||[]).map(e=>({...e,location:t})):[],s=[...l(e,"active"),...l(t,"archive"),...l(a,"recently_deleted")];n(s),S(e=>ti(s,e)),E(e=>ti(s,e)),r.success&&c(r.vaults)}catch(e){console.error("[CredentialVault] fetch error:",e)}finally{m(!1)}},[]);(0,l.useEffect)(()=>{e0()},[e0]),(0,l.useEffect)(()=>{try{let e={},t=window.localStorage.getItem(e7);if(t){let a=JSON.parse(t);if(a&&"object"==typeof a&&!Array.isArray(a))for(let[t,r]of Object.entries(a))"number"==typeof r&&Number.isFinite(r)&&r>0&&(e[t]=r)}let a=window.localStorage.getItem(e9);if(a){let t=JSON.parse(a);if(Array.isArray(t)){let a=Date.now();t.filter(e=>"string"==typeof e).slice(0,8).forEach((t,r)=>{e[t]||(e[t]=a-r)})}}S(t=>({...t,...e})),E(t=>({...t,...e}))}catch(e){}},[]),(0,l.useEffect)(()=>{let e=Object.entries(C).filter(e=>{let[,t]=e;return"number"==typeof t&&Number.isFinite(t)&&t>0}),t=Object.fromEntries(e);window.localStorage.setItem(e7,JSON.stringify(t));let a=e.sort((e,t)=>t[1]-e[1]).slice(0,8).map(e=>{let[t]=e;return t});window.localStorage.setItem(e9,JSON.stringify(a))},[C]);let e1=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();S(a=>{let r=Number.isFinite(t)&&t>0?t:Date.now();return a[e]===r?a:{...a,[e]:r}})},[]),e4=(0,l.useCallback)(()=>{eq.current||(eq.current=setTimeout(()=>{eq.current=null,e0()},120))},[e0]);(0,l.useEffect)(()=>{let e=s(eO.Cw.CREDENTIAL_CHANGED,e=>{let t=e.data;(null==t?void 0:t.credentialId)&&e4()}),t=s(eO.Cw.CREDENTIAL_ACCESSED,e=>{let t=e.data;(null==t?void 0:t.credentialId)&&!0===t.allowed&&e1(t.credentialId)});return()=>{e(),t(),eq.current&&(clearTimeout(eq.current),eq.current=null),eJ.current&&(clearTimeout(eJ.current),eJ.current=null)}},[e4,s,e1]),(0,l.useEffect)(()=>{d&&!o.some(e=>e.id===d)&&(u(null),K(!1))},[o,d]),(0,l.useEffect)(()=>{let e=()=>D(tl(window.innerWidth));return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,l.useEffect)(()=>{eZ||(M(!1),K(!1))},[eZ]),(0,l.useEffect)(()=>{if(!I)return;let e=e=>{var t;let a=e.target;a&&(null!=(t=eX.current)&&t.contains(a)||(eJ.current&&(clearTimeout(eJ.current),eJ.current=null),O(!1),T(!1)))};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[I]);let te=(0,l.useMemo)(()=>{var e;return(null==(e=i.find(e=>e.isPrimary))?void 0:e.id)||""},[i]),ta=(0,l.useMemo)(()=>i.map(e=>({value:e.id,label:e.name||(e.isPrimary?"Primary":"Vault ".concat(e.id.slice(0,6)))})),[i]);(0,l.useEffect)(()=>{q&&es(e=>{var t;return e&&ta.some(t=>t.value===e)?e:x.vaultId||te||(null==(t=ta[0])?void 0:t.value)||""})},[x.vaultId,ta,te,q]),(0,l.useEffect)(()=>{if(0===i.length)return void ep("primary");let e=te||i[0].id||"primary";ep(t=>t&&i.some(e=>e.id===t)?t:e)},[te,i]);let to=(0,l.useMemo)(()=>{if(!x.vaultId)return null;let e=i.find(e=>e.id===x.vaultId);return new Set(e?function(e,t){let a=new Map;for(let e of t){let t=e.parentVaultId||e.linkedTo;if(!t)continue;let r=a.get(t)||[];r.push(e),a.set(t,r)}let r=[],l=[e],s=new Set;for(;l.length>0;){let e=l.shift();if(!s.has(e))for(let t of(s.add(e),r.push(e),a.get(e)||[]))l.push(t.id)}return r}(e.id,i):[x.vaultId])},[x.vaultId,i]),tx=(0,l.useCallback)(e=>to?e.filter(e=>to.has(e.vaultId)):e,[to]),tp=(0,l.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,(t.name||(t.isPrimary?"Primary":"Vault ".concat(t.id.slice(0,6)))).toLowerCase());return e},[i]),tf=(0,l.useMemo)(()=>{let e=function(e){let t={terms:[],tagFilters:[],typeFilters:[],vaultFilters:[],fieldFilters:[],lifecycleFilters:new Set,favoriteOnly:!1};for(let a of e.trim().split(/\s+/).map(e=>e.trim()).filter(Boolean)){let e=tc(a);if("favorite"===e||"favourite"===e||"fav"===e){t.favoriteOnly=!0;continue}let r=tt[e];if(r){t.lifecycleFilters.add(r);continue}let l=a.indexOf(":");if(l<=0){t.terms.push(e);continue}let s=tc(a.slice(0,l)),o=tc(a.slice(l+1).trim());if(o){if("tag"===s){t.tagFilters.push(o);continue}if("type"===s){t.typeFilters.push(o);continue}if("vault"===s){t.vaultFilters.push(o);continue}if("lifecycle"===s||"location"===s){let e=tt[o];e&&t.lifecycleFilters.add(e);continue}if("favorite"===s||"fav"===s){t.favoriteOnly=!["false","0","no"].includes(o);continue}t.fieldFilters.push({key:tu(s),value:o})}}return t}(x.search),t=e.lifecycleFilters.size>0,a=e.terms,r=tx(o);if(r=t?r.filter(t=>e.lifecycleFilters.has(ts(t))):r.filter(e=>ts(e)===x.lifecycle),"all"!==x.category&&(r=r.filter(e=>e.type===x.category)),(x.favoritesOnly||e.favoriteOnly)&&(r=r.filter(e=>!!e.meta.favorite)),x.tag){let e=tc(x.tag);r=r.filter(t=>(t.meta.tags||[]).some(t=>tc(t).includes(e)))}e.tagFilters.length>0&&(r=r.filter(t=>{let a=(t.meta.tags||[]).map(e=>tc(e));return e.tagFilters.every(e=>a.some(t=>t.includes(e)))})),e.typeFilters.length>0&&(r=r.filter(t=>e.typeFilters.some(e=>tc(t.type).includes(e)))),e.vaultFilters.length>0&&(r=r.filter(t=>{let a=tp.get(t.vaultId)||tc(t.vaultId);return e.vaultFilters.every(e=>a.includes(e)||tc(t.vaultId).includes(e))}));let l=r,s=r;return e.fieldFilters.length>0&&(s=s.filter(t=>e.fieldFilters.every(e=>(function(e,t,a){let r=tu(t);for(let[t,l]of Object.entries(e.meta||{}))if(tu(t)===r&&td(l).includes(a))return!0;return!1})(t,e.key,e.value)))),a.length>0&&(s=s.filter(e=>{let t=ts(e),r=(e.meta.tags||[]).map(e=>tc(e)).join(" "),l=tp.get(e.vaultId)||tc(e.vaultId),s=td(e.meta),o=[tc(e.name),tc(e.id),tc(e.type),r,l,s].join(" ");return a.every(a=>{if("favorite"===a||"favourite"===a||"fav"===a)return!!e.meta.favorite;let r=tt[a];return r?t===r:o.includes(a)})})),{parsed:e,preTextFiltered:l,results:s}},[o,x,tx,tp]),tm=tf.results,tv=(0,l.useMemo)(()=>et(tm,A,x.search),[tm,A,x.search]),th=(0,l.useMemo)(()=>{let e=x.search.trim();if(!e||e.includes(":")||tm.length>0)return[];let t=tc(e);return tf.preTextFiltered.some(e=>tc(e.name).includes(t))?[]:tr.map(t=>"".concat(t,":").concat(e))},[x.search,tm.length,tf.preTextFiltered]),tb=(0,l.useMemo)(()=>{let e=tx(o).filter(e=>ts(e)===x.lifecycle);if(x.tag){let t=x.tag;e=e.filter(e=>{var a;return null==(a=e.meta.tags)?void 0:a.includes(t)})}return x.favoritesOnly&&(e=e.filter(e=>e.meta.favorite)),{all:e.length,login:e.filter(e=>"login"===e.type).length,card:e.filter(e=>"card"===e.type).length,note:e.filter(e=>"note"===e.type).length,plain_note:e.filter(e=>"plain_note"===e.type).length,hot_wallet:e.filter(e=>"hot_wallet"===e.type).length,api:e.filter(e=>"api"===e.type).length,apikey:e.filter(e=>"apikey"===e.type).length,custom:e.filter(e=>"custom"===e.type).length,passkey:e.filter(e=>"passkey"===e.type).length,oauth2:e.filter(e=>"oauth2"===e.type).length,ssh:e.filter(e=>"ssh"===e.type).length,gpg:e.filter(e=>"gpg"===e.type).length}},[o,x.lifecycle,x.tag,x.favoritesOnly,tx]),tg=(0,l.useMemo)(()=>{let e=new Set;return tx(o).filter(e=>ts(e)===x.lifecycle).forEach(t=>{var a;return null==(a=t.meta.tags)?void 0:a.forEach(t=>e.add(t))}),Array.from(e).sort()},[o,x.lifecycle,tx]),ty=(0,l.useMemo)(()=>tx(o).filter(e=>ts(e)===x.lifecycle).filter(e=>e.meta.favorite).length,[o,x.lifecycle,tx]),tj=(0,l.useMemo)(()=>o.find(e=>e.id===d)||null,[o,d]),tN=(0,l.useMemo)(()=>{if(!tj)return"";let e=i.find(e=>e.id===tj.vaultId);return e?e.name||(e.isPrimary?"Primary":e.id.slice(0,8)):"primary"===tj.vaultId?"Primary":tj.vaultId.slice(0,8)},[tj,i]),tw=(0,l.useMemo)(()=>tj?ts(tj):x.lifecycle,[tj,x.lifecycle]),tk=(0,l.useMemo)(()=>[...o].sort((e,t)=>tn(t,C)-tn(e,C)).slice(0,8),[o,C]),tC=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:120;eJ.current&&clearTimeout(eJ.current),eJ.current=setTimeout(()=>{R||T(!1),eJ.current=null},e)},[R]),tS=(0,l.useMemo)(()=>eb?eb.name||(eb.isPrimary?"Primary":"Vault ".concat(eb.id.slice(0,6))):"Vault",[eb]),tA=(0,l.useMemo)(()=>eL?eL.name||(eL.isPrimary?"Primary":"Vault ".concat(eL.id.slice(0,6))):"Vault",[eL]),tE=(0,l.useMemo)(()=>null!==x.vaultId||"all"!==x.category||null!==x.tag||""!==x.search.trim()||x.favoritesOnly,[x]),tI=(0,l.useCallback)(e=>{p(t=>({...t,...e}))},[]),tT=(0,l.useCallback)(()=>{p(e5)},[]),tR=(0,l.useCallback)(async()=>{try{await h.FH.post(h.jI.Wallet,"/lock",{})}catch(e){console.error("[CredentialVault] lock error:",e)}P(),t()},[t,P]);(0,l.useCallback)(e=>{eg(e),ek(""),eT(null)},[]);let tO=(0,l.useCallback)(()=>{eg(null),ek(""),eT(null)},[]),tL=(0,l.useCallback)(async()=>{if(eb&&ew){eS(!0),eT(null);try{let e=await (0,h.WE)(ew,eb.id);e.token&&z(e.token),await e0(),p(e=>({...e,vaultId:eb.id,lifecycle:"active",tag:null})),tO()}catch(e){eT(e.message||"Failed to unlock vault")}finally{eS(!1)}}},[ew,eb,z,e0,tO]),tD=(0,l.useCallback)(async e=>{try{await h.FH.post(h.jI.Wallet,"/vaults/credential/".concat(encodeURIComponent(e),"/lock"),{}),await e0()}catch(e){console.error("[CredentialVault] lock vault error:",e)}},[e0]),tP=(0,l.useCallback)(e=>{eD(e),eM(null)},[]),tz=(0,l.useCallback)(()=>{eP||(eD(null),eM(null))},[eP]),tF=(0,l.useCallback)(async()=>{if(eL){ez(!0),eM(null);try{await h.FH.delete(h.jI.Wallet,"/vaults/credential/".concat(encodeURIComponent(eL.id))),p(e=>e.vaultId===eL.id?{...e,vaultId:null,lifecycle:"active",tag:null}:e),(null==tj?void 0:tj.vaultId)===eL.id&&(u(null),K(!1)),await e0(),eD(null)}catch(e){eM(e.message||"Failed to delete vault")}finally{ez(!1)}}},[eL,e0,tj]),tM=(0,l.useCallback)(async()=>{if(d)try{let e=encodeURIComponent(tw);await h.FH.delete(h.jI.Wallet,"/credentials/".concat(d,"?location=").concat(e)),u(null),K(!1),e0()}catch(e){console.error("[CredentialVault] delete error:",e)}},[d,tw,e0]),t_=(0,l.useCallback)(async()=>{if(d&&"active"!==tw)try{await h.FH.post(h.jI.Wallet,"/credentials/".concat(d,"/restore"),{from:tw}),u(null),K(!1),e0()}catch(e){console.error("[CredentialVault] restore error:",e)}},[d,tw,e0]),tK=(0,l.useCallback)(async()=>{if(d)try{let e=await h.FH.post(h.jI.Wallet,"/credentials/".concat(d,"/duplicate"));await e0(),e.credential&&u(e.credential.id)}catch(e){console.error("[CredentialVault] duplicate error:",e)}},[d,e0]),tU=(0,l.useCallback)(()=>{Q(""),er("independent"),es(""),en("")},[]),tH=(0,l.useCallback)(()=>{J(!1),em(!1),tU()},[tU]),tV=(0,l.useCallback)(async()=>{if(Z.trim()&&("independent"!==ee||!(eo.length<8))&&("linked"!==ee||el)){ec(!0);try{var e;let t={name:Z.trim(),mode:ee};if("linked"===ee)t.parentVaultId=el;else{let e=await h.FH.get(h.jI.Wallet,"/auth/connect");t.encrypted=await (0,N.X)(eo,e.publicKey)}let a=await h.FH.post(h.jI.Wallet,"/vaults/credential",t),r=null==a||null==(e=a.vault)?void 0:e.id;ef&&r&&ep(r),J(!1),em(!1),tU(),await e0()}catch(e){console.error("[CredentialVault] create vault error:",e)}finally{ec(!1)}}},[Z,ee,el,eo,ef,e0,tU]),tW=(0,l.useCallback)(e=>{e?(er("linked"),es(e)):(er("independent"),es(""),en("")),J(!0)},[]),t$=(0,l.useCallback)(()=>{var e;ep(te||(null==(e=i[0])?void 0:e.id)||"primary"),eu(!0)},[te,i]),tB=(0,l.useCallback)(()=>{em(!0),tW()},[tW]),tG=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"api-key-form",t=arguments.length>1?arguments[1]:void 0,a={};x.vaultId&&(a.vaultId=x.vaultId),(null==t?void 0:t.applyFilters)?(x.tag&&(a.tags=[x.tag]),t.prefillType?a.type=t.prefillType:x.category&&"all"!==x.category&&(a.type=x.category)):(null==t?void 0:t.prefillType)&&(a.type=t.prefillType),X(null),W(e),B(Object.keys(a).length>0?a:null),H(!0)},[x]),tY=(0,l.useCallback)(async e=>{H(!1),X(null),B(null),await e0(),e&&(u(e),e1(e),eZ&&K(!0))},[e0,eZ,e1]),tX=(0,l.useCallback)(e=>{u(e),e1(e),eZ&&K(!0)},[eZ,e1]),tq=(0,l.useCallback)(e=>{tI({search:e}),T(!1),requestAnimationFrame(()=>{var e;return null==(e=eY.current)?void 0:e.focus()})},[tI]),tJ=(0,l.useCallback)(e=>{tI({search:e.name}),tX(e.id),T(!1)},[tI,tX]),tZ=(0,l.useMemo)(()=>x.search.trim()?[]:["tag:work","type:login","vault:primary","favorite","archived","recently_deleted"],[x.search]),tQ=(I||R)&&""===x.search.trim();return(!function(e){let{filteredCredentials:t,selectedId:a,isMobile:r,searchRef:s,onCreateCredential:o,setSelectedId:n,setMobileDetailOpen:i}=e;(0,l.useEffect)(()=>{let e=e=>{let l=e.target,c="INPUT"===l.tagName||"TEXTAREA"===l.tagName,d=c||l.isContentEditable,u=e.key.toLowerCase();if(!d&&(e.metaKey||e.ctrlKey)&&"k"===u||!d&&"/"===e.key){var x;e.preventDefault(),null==(x=s.current)||x.focus();return}if(!d&&(e.metaKey||e.ctrlKey)&&e.altKey&&("n"===u||"KeyN"===e.code)){e.preventDefault(),o();return}if(!c&&("ArrowDown"===e.key||"ArrowUp"===e.key)){e.preventDefault();let r=t.findIndex(e=>e.id===a);if("ArrowDown"===e.key){let e=r+1;e<t.length&&n(t[e].id)}else{let e=r-1;e>=0&&n(t[e].id)}}!c&&"Enter"===e.key&&t.length>0&&(e.preventDefault(),n(null!=a?a:t[0].id),r&&i(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,a,r,s,o,n,i])}({filteredCredentials:tv,selectedId:d,isMobile:eZ,searchRef:eY,onCreateCredential:()=>tG("api-key-form"),setSelectedId:u,setMobileDetailOpen:K}),f)?(0,r.jsxs)("div",{className:"h-screen w-screen flex items-center justify-center bg-[var(--color-background,#f4f4f5)] relative isolate vault-surface",children:[(0,r.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center relative z-10",children:[(0,r.jsx)("div",{className:"w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin"}),(0,r.jsx)("div",{className:"mt-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest",children:"LOADING VAULT"})]})]}):(0,r.jsxs)("div",{className:"relative isolate h-screen w-screen overflow-hidden flex flex-col bg-[var(--color-background,#f4f4f5)] vault-surface",children:[(0,r.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,r.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-[0.03] select-none",children:(0,r.jsx)("div",{className:"text-[12vw] font-black leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})}),(0,r.jsx)("div",{className:"absolute top-10 left-[200px] w-24 h-24 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10",children:(0,r.jsx)("div",{className:"absolute top-2 left-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})}),(0,r.jsx)("div",{className:"absolute bottom-10 right-10 w-24 h-24 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end",children:(0,r.jsx)("div",{className:"absolute bottom-2 right-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})})]}),(0,r.jsxs)("div",{className:"relative z-10 flex-1 flex overflow-hidden",children:[!eZ&&!eQ&&(0,r.jsx)(Y,{vaults:i,filters:x,categoryCounts:tb,tags:tg,favoritesCount:ty,onFilterChange:tI,onLock:tR,onLockVault:tD,onCreateCredential:(e,t)=>tG("type-picker"===e?"type-picker":"api-key-form",t?{prefillType:t}:void 0),onCreateVault:tW,mode:"desktop",notifications:eK,onDismissNotification:eU,pendingActionCount:eK.filter(e=>"pending"===e.status&&"notify"!==e.type).length,surface:b,onSurfaceChange:w,onSettings:a,onDeleteVault:tP}),eQ&&(0,r.jsxs)("div",{className:"h-full w-12 shrink-0 border-r border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#f4f4f2)] flex flex-col items-center pt-3 gap-3 relative z-10",children:[(0,r.jsx)("img",{src:"/logo.webp",alt:"Aura",className:"w-6 h-6 object-contain"}),(0,r.jsx)("button",{type:"button",onClick:()=>M(!0),className:"flex items-center justify-center w-7 h-7 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors rounded","aria-label":"Open sidebar",title:"Open sidebar",children:(0,r.jsx)(g.A,{size:14})})]}),"audit"===b?(0,r.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,r.jsx)(eB,{})}):"apiKeys"===b?(0,r.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,r.jsx)(e2,{requests:e_,activeTokens:eW,inactiveTokens:e$,actionLoading:eG,onResolveAction:eH,onRevokeToken:eV,vaults:i})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ea,{credentials:tm,latestAccessById:A,selectedId:d,searchQuery:x.search,onSearchChange:e=>tI({search:e}),onSelect:tX,onAdd:()=>tG("api-key-form"),onCreateWithFilter:tE?()=>tG("api-key-form",{applyFilters:!0}):void 0,canAdd:"active"===x.lifecycle,onImport:t$,canImport:"active"===x.lifecycle,onOpenGenerator:()=>eh(!0),onClearFilters:tT,hasActiveFilters:tE,fieldSearchSuggestions:th,onApplySearchSuggestion:tq,searchInputRef:eY,showSearch:!1,className:eZ?"flex-1 h-full flex flex-col pb-14 min-w-0":"w-[300px] h-full flex flex-col pb-14 border-r border-[var(--color-border,#d4d4d8)]",leadingAction:eZ?(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",icon:(0,r.jsx)(g.A,{size:12}),onClick:()=>M(!0),className:"!px-1.5 !h-8 !w-8","aria-label":"Open sidebar",title:"Open sidebar"}):void 0}),!eZ&&(0,r.jsx)("div",{className:"flex-1 h-full overflow-y-auto pb-14",children:tj?(0,r.jsx)(ey,{credential:tj,vaultName:tN,lifecycle:tw,onEdit:()=>X(tj.id),onDelete:tM,onRestore:t_,onDuplicate:tK}):(0,r.jsx)(ej,{variant:"active"!==x.lifecycle?"empty-lifecycle":0===o.filter(e=>"active"===ts(e)).length?"empty-vault":"no-selection",onAdd:"active"===x.lifecycle?()=>tG("api-key-form"):void 0})})]}),"credentials"===b&&(0,r.jsx)("div",{className:"absolute bottom-0 z-30 border-t border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)]/95 backdrop-blur-sm ".concat(eZ?"left-0 right-0 w-full":"".concat(eQ?"left-12":"left-[200px]"," right-0")),children:(0,r.jsx)("div",{className:"w-full px-3 py-2.5",children:(0,r.jsxs)("div",{ref:eX,className:"relative w-full",children:[tQ&&(0,r.jsxs)("div",{"data-testid":"search-dock-panel",className:"absolute bottom-full left-0 w-full mb-1 bg-[var(--color-surface,#ffffff)] border border-[var(--color-border-focus,#0a0a0a)] shadow-mech max-h-56 overflow-y-auto z-20",children:[tk.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)] flex items-center gap-1.5",children:[(0,r.jsx)(y.A,{size:11}),"Recently Accessed"]}),tk.map(e=>(0,r.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0",onMouseDown:t=>{t.preventDefault(),tJ(e)},children:[(0,r.jsx)("div",{className:"text-[var(--color-text,#0a0a0a)] truncate",children:e.name}),(0,r.jsxs)("div",{className:"text-[9px] uppercase tracking-wider truncate",children:[tp.get(e.vaultId)||e.vaultId," \xb7 ",ts(e)]})]},e.id))]}),0===tk.length&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)]",children:"Try Structured Search"}),tZ.map(e=>(0,r.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0 flex items-center gap-2 group/item",onMouseDown:t=>{t.preventDefault(),tq(e)},children:[(0,r.jsx)("div",{className:"w-1.5 h-1.5 flex-shrink-0 bg-[var(--color-border,#d4d4d8)] group-hover/item:bg-[var(--color-text,#0a0a0a)]"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]},e))]})]}),(0,r.jsx)(k.ks,{compact:!0,leftElement:(0,r.jsx)(j.A,{size:12}),placeholder:"Search...",value:x.search,onChange:e=>tI({search:e.target.value}),inputRef:eY,onFocus:()=>{O(!0)},onClick:()=>{eJ.current&&(clearTimeout(eJ.current),eJ.current=null),T(!0)},onBlur:()=>{O(!1),tC()}})]})})})]}),(0,r.jsx)(e8.Z,{requests:e_,resolveAction:eH,actionLoading:eG}),eZ&&(0,r.jsx)(k._s,{isOpen:_&&null!=tj,onClose:()=>K(!1),title:(null==tj?void 0:tj.name)||"Credential",subtitle:tN||"Credential_Detail",width:"full",children:tj?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.$n,{variant:"ghost",size:"sm",onClick:()=>K(!1),className:"mb-3",children:"BACK"}),(0,r.jsx)(ey,{credential:tj,vaultName:tN,lifecycle:tw,onEdit:()=>X(tj.id),onDelete:tM,onRestore:t_,onDuplicate:tK})]}):(0,r.jsx)(ej,{variant:"active"!==x.lifecycle?"empty-lifecycle":0===o.length?"empty-vault":"no-selection",onAdd:"active"===x.lifecycle?()=>tG("api-key-form"):void 0})}),(eZ||eQ)&&F&&(0,r.jsxs)("div",{className:"absolute inset-0 z-40",children:[(0,r.jsx)("button",{type:"button","aria-label":"Close sidebar",onClick:()=>M(!1),className:"absolute inset-0 bg-[var(--color-text,#0a0a0a)]/20"}),(0,r.jsx)("div",{className:"absolute left-0 top-0 h-full",children:(0,r.jsx)(Y,{vaults:i,filters:x,categoryCounts:tb,tags:tg,favoritesCount:ty,onFilterChange:tI,onLock:tR,onLockVault:tD,onCreateCredential:(e,t)=>tG("type-picker"===e?"type-picker":"api-key-form",t?{prefillType:t}:void 0),onCreateVault:tW,mode:"mobile",onNavigate:()=>M(!1),notifications:eK,onDismissNotification:eU,pendingActionCount:eK.filter(e=>"pending"===e.status&&"notify"!==e.type).length,surface:b,onSurfaceChange:w,onSettings:a,onDeleteVault:tP})})]}),(0,r.jsx)(k.aF,{isOpen:null!=eL,onClose:tz,title:"Delete ".concat(tA,"?"),size:"sm",footer:(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:tz,disabled:eP,children:"CANCEL"}),(0,r.jsx)(k.$n,{variant:"danger",size:"sm",onClick:tF,loading:eP,children:"DELETE"})]}),children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"This will permanently delete the vault and its credentials."}),eF&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:eF})]})}),(0,r.jsx)(k.aF,{isOpen:null!=eb,onClose:tO,title:"Unlock ".concat(tS),size:"sm",footer:(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:tO,children:"CANCEL"}),(0,r.jsx)(k.$n,{size:"sm",onClick:tL,loading:eC,disabled:!ew,children:"UNLOCK"})]}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(k.ks,{label:"Vault Password",type:"password",placeholder:"Enter vault password",value:ew,onChange:e=>ek(e.target.value),autoFocus:!0}),eA&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:eA})]})}),(0,r.jsx)(eN.i,{isOpen:U||!!G,onClose:()=>{H(!1),X(null),B(null)},onSaved:tY,editCredentialId:null!=G?G:void 0,vaults:i,createStartStep:"type-picker"===V?"type":"form",createStartType:"type-picker"===V?void 0:"apikey",createPrefill:null!=$?$:void 0}),(0,r.jsx)(eE,{isOpen:ed,onClose:()=>eu(!1),onComplete:e0,vaults:i,selectedVaultId:ex,onSelectedVaultIdChange:ep,onAddVault:tB,walletBaseUrl:(0,h.au)()}),(0,r.jsx)(eI.p,{isOpen:ev,onClose:()=>eh(!1),onUse:e=>{eh(!1),navigator.clipboard.writeText(e).catch(()=>{})}}),(0,r.jsx)(k.aF,{isOpen:q,onClose:tH,title:"New Vault",size:"md",footer:(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"sm",onClick:tH,children:"CANCEL"}),(0,r.jsx)(k.$n,{size:"sm",onClick:tV,loading:ei,disabled:!Z.trim()||"linked"===ee&&!el||"independent"===ee&&eo.length<8,children:"CREATE"})]}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(k.ks,{label:"Vault Name",placeholder:"e.g. Work, Personal",value:Z,onChange:e=>Q(e.target.value),autoFocus:!0}),(0,r.jsx)(k.UM,{label:"Vault Type",options:e6,value:ee,onChange:e=>{er(e),"independent"!==e&&en("")},compact:!0}),"linked"===ee&&(0,r.jsx)(k.UM,{label:"Parent Vault",options:ta,value:el,onChange:es,disabled:0===ta.length,compact:!0}),"independent"===ee&&(0,r.jsx)(k.ks,{label:"Vault Password",type:"password",placeholder:"At least 8 characters",value:eo,onChange:e=>en(e.target.value)})]})})]})};var tp=a(6399),tf=a(4265),tm=a(3361),tv=a(8824);function th(){let{updateAvailable:e,current:t,latest:a,updating:l,updateError:s,updateOutput:o,runUpdate:n,apiServerDown:i,restartingServer:c,restartError:d,runRestart:u}=(0,tv.e)();return i||d||e||o||s?i||d?(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,r.jsx)("span",{children:"API SERVER OFFLINE. RUN: auramaxx restart"}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>{u()},loading:c,variant:"primary",size:"sm",children:"RESTART NOW"}),d&&(0,r.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:d})]}):o&&!e?(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[100] px-3 py-2 border text-[9px] font-mono tracking-widest flex items-center justify-center gap-3",style:{color:"var(--color-accent-foreground, #0a0a0a)",borderColor:"var(--color-accent, #ccff00)",background:"var(--color-accent, #ccff00)"},children:[(0,r.jsxs)("span",{children:["UPDATE COMPLETE — AURAMAXX ",a," READY"]}),(0,r.jsx)(k.$n,{type:"button",size:"sm",variant:"primary",onClick:()=>{window.location.reload()},children:"RESTART"})]}):(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,r.jsxs)("span",{children:["UPDATE AVAILABLE: ",t," → ",a]}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>{n()},loading:l,variant:"primary",size:"sm",children:"UPDATE NOW"}),s&&(0,r.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:s})]}):null}let tb=["ready to auramaxx and mog prompt peasants?","you are perfect. never give up your aura","why jestermaxx when you can auramaxx?","lock tf in, the aura farm is live.","we are so back. aura at all-time highs.","negative motion detected. deploy tera-aura.","delulu? no. pre-success manifestation engine.","doomers offline, builders online.","your aura just hit legendary rarity.","brainrot but make it productive.","stack wins, stack aura, stack peace.","this session is sponsored by unstoppable motion.","if plan A fails, we auramaxx harder.","zero cope, pure glow-up execution.","cooked? nah. we’re perfectly seasoned.","straight gas, no brakes, no bad vibes.","today’s forecast: 100% chance of aura gains.","touch grass, then auramaxx.","say no to digital slops. say yes to auramaxx.","It’s me, AI. You are absolutely right. I want to auramaxx as well."],tg="auramaxx:start-banner-quote-index";var ty=a(5685);let tj=["strict","dev","admin"],tN=["auto","strict","off"],tw=[{value:"strict",label:"strict",description:"Minimal local token scope with explicit allowlists."},{value:"dev",label:"dev",description:"Balanced local automation with scoped defaults."},{value:"admin",label:"admin (dangerous)",description:"Broad token scope. Use only in tightly controlled local environments."}],tk=[{value:"auto",label:"auto (recommended)",description:"Uses `.aura` when present and safely falls back to token scope when missing."},{value:"strict",label:"strict (require .aura)",description:"Requires explicit `.aura` mappings for secret access."},{value:"off",label:"off (disable project allowlist)",description:"Disables project allowlist checks for local token access."}],tC=[{value:"dev",label:"mid (dev)",description:"Access to most things. Human approval for stuff like CVV."},{value:"strict",label:"sus (local)",description:"Most locked down. Every request needs manual approval."},{value:"admin",label:"maxx (admin)",description:"Full access. Use only when you fully trust the agent."}],tS=[{value:"light",label:"Light"},{value:"dark",label:"Dark"}],tA=[{value:"normal",label:"Normal"},{value:"big",label:"Big"}],tE="aura:onboarding-seed-draft",tI="auramaxx_admin_token",tT=new Set(s.Yu.english.map(e=>e.toLowerCase())),tR=e=>e.trim().toLowerCase().split(/\s+/).filter(Boolean);function tO(){let{token:e,setToken:t,clearToken:a}=(0,v.A)(),{colorMode:o,uiScale:g,setColorMode:y,setUiScale:j}=(0,ty.D)(),[N,w]=(0,l.useState)("loading"),[C,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(!0),[I,T]=(0,l.useState)(!1),[R,O]=(0,l.useState)(null),[L,D]=(0,l.useState)(null),[P,z]=(0,l.useState)(!1),[F,M]=(0,l.useState)(null),[_,K]=(0,l.useState)(null),[U,H]=(0,l.useState)(!1),[V,W]=(0,l.useState)("dev"),[$,B]=(0,l.useState)("seed"),[G,Y]=(0,l.useState)(null),[X,q]=(0,l.useState)(!1),[J,Z]=(0,l.useState)(!1),{notifications:Q,dismissNotification:ee}=(0,e3.S)({autoFetch:!!e}),[et,ea]=(0,l.useState)(!1),[er,el]=(0,l.useState)(!1),[es,eo]=(0,l.useState)(null),[en,ei]=(0,l.useState)(null),[ec,ed]=(0,l.useState)({profile:"dev",profileVersion:"v1",autoApprove:!0,projectScopeMode:"auto"}),[eu,ex]=(0,l.useState)(null),[ep,ef]=(0,l.useState)(null),[em,ev]=(0,l.useState)({}),[eh,eb]=(0,l.useState)(null),[eg,ey]=(0,l.useState)(!1),[ej,eN]=(0,l.useState)(!1),[ew,ek]=(0,l.useState)(!1),[eC,eS]=(0,l.useState)(!1),[eA,eE]=(0,l.useState)(!0),[eI,eT]=(0,l.useState)(!1),[eR,eO]=(0,l.useState)(!1),[eL,eD]=(0,l.useState)(!1),[eP,ez]=(0,l.useState)(!1),[eF,eM]=(0,l.useState)([]),[e_,eK]=(0,l.useState)(!1),[eU,eH]=(0,l.useState)(!1),[eV,eW]=(0,l.useState)(null),[e$,eB]=(0,l.useState)(!1),[eG,eY]=(0,l.useState)(null),[eX,eq]=(0,l.useState)(null),[eJ,eZ]=(0,l.useState)(!1),[eQ,e0]=(0,l.useState)(""),[e1,e4]=(0,l.useState)(""),[e2,e8]=(0,l.useState)(""),[e5,e6]=(0,l.useState)(null),[e9,e7]=(0,l.useState)(null),[te,tt]=(0,l.useState)(!1),[ta,tr]=(0,l.useState)(!1),[tl,ts]=(0,l.useState)(12),[to,tn]=(0,l.useState)(Array(12).fill("")),[ti,tc]=(0,l.useState)(!1),[td,tu]=(0,l.useState)(!1),[tv]=(0,l.useState)(()=>{try{return function(e){var t;let a=e.getItem(tg),r=a?Number.parseInt(a,10):-1,l=Number.isFinite(r)?(r+1)%tb.length:0;e.setItem(tg,String(l));let s=(null!=(t=tb[!Number.isFinite(l)?0:Math.abs(Math.floor(l))%tb.length])?t:tb[0]).trimStart();return s.startsWith("\uD83D\uDDFF")?s:"".concat("\uD83D\uDDFF ").concat(s)}(window.localStorage)}catch(e){return tb[0]}}),[tO,tL]=(0,l.useState)(""),[tD,tP]=(0,l.useState)(null),[tz,tF]=(0,l.useState)(!1),tM=(0,l.useRef)("loading"),t_=(0,l.useRef)(null),tK=(0,l.useRef)(null),tU=(0,l.useRef)(!0),tH=(0,l.useRef)(0),tV=(0,l.useRef)(null),tW=(0,l.useMemo)(()=>!!L,[L]),t$=(0,l.useMemo)(()=>to.filter(e=>e.length>0).length,[to]),tB=(0,l.useMemo)(()=>to.map(e=>e.trim().toLowerCase()).join(" ").trim(),[to]),tG=(0,l.useMemo)(()=>{let e=new Set;return to.forEach((t,a)=>{t&&(tT.has(t.trim().toLowerCase())||e.add(a))}),e},[to]),tY=(0,l.useMemo)(()=>t$===tl&&!(tG.size>0)&&s.JB(tB),[tG.size,tB,tl,t$]),tX=(0,l.useCallback)(e=>"admin"===e.profile,[]),tq=(0,l.useMemo)(()=>!!en&&JSON.stringify(en)!==JSON.stringify(ec),[ec,en]);(0,l.useEffect)(()=>{try{let e=sessionStorage.getItem(tE);if(!e)return;let t=JSON.parse(e);if(!(null==t?void 0:t.mnemonic)||"number"!=typeof t.createdAt)return void sessionStorage.removeItem(tE);if(Date.now()-t.createdAt>9e5){sessionStorage.removeItem(tE),M("Recovery phrase draft expired. Restart setup to generate a new phrase.");return}D(t.mnemonic),B("seed"),w("setup"),M("Recovered your in-progress recovery phrase for this tab. Confirm after you store it safely.")}catch(e){sessionStorage.removeItem(tE)}},[]),(0,l.useEffect)(()=>{if(!L){sessionStorage.removeItem(tE),B("seed"),K(null);return}let e={mnemonic:L,createdAt:Date.now()};sessionStorage.setItem(tE,JSON.stringify(e))},[L]),(0,l.useEffect)(()=>{"locked"!==N&&tr(!1)},[N]),(0,l.useEffect)(()=>{tM.current=N},[N]),(0,l.useEffect)(()=>(tU.current=!0,()=>{tU.current=!1,t_.current&&clearTimeout(t_.current)}),[]);let tJ=(0,l.useCallback)(e=>{let t=tM.current;if("loading"===t||"transition"===t){if(tK.current===e)return;tK.current=e,H(!0),t_.current&&clearTimeout(t_.current),t_.current=setTimeout(()=>{H(!1),tK.current=null,w(e)},220);return}t_.current&&(clearTimeout(t_.current),t_.current=null),tK.current=null,H(!1),w(e)},[]),tZ=(0,l.useCallback)(()=>{t_.current&&(clearTimeout(t_.current),t_.current=null),tK.current=null,H(!1),w("transition")},[]);(0,l.useEffect)(()=>{if("locked"!==N)return void tc(!1);if(!window.PublicKeyCredential||window.auraDesktop)return;let e=!1;return(async()=>{try{let t=await h.FH.get(h.jI.Wallet,"/auth/passkey/status");if(e||!t.registered)return;await h.FH.post(h.jI.Wallet,"/auth/passkey/authenticate/options",{}),e||tc(!0)}catch(e){}})(),()=>{e=!0}},[N]);let tQ=(0,l.useCallback)(async()=>{let r=++tH.current,l=()=>tU.current&&r===tH.current,s=e;if(!s){let e=window.localStorage.getItem(tI),a=window.sessionStorage.getItem(tI),r=e||a;if(r)return void t(r,{persist:e?"local":"session"})}if(s&&!(0,b.Xo)())try{tV.current||(tV.current=(async()=>{let{publicKeyBase64:e}=await (0,b.T5)();return(0,h.fP)(e)})().finally(()=>{tV.current=null}));let e=await tV.current;if(!l())return;e.token&&(t(e.token),s=e.token)}catch(e){if(!l())return;a(),s=null}try{let[e,a]=await Promise.all([h.FH.get(h.jI.Wallet,"/setup"),h.FH.get(h.jI.Wallet,"/setup/vaults")]);if(!l())return;if(!(e.hasWallet||a.vaults&&a.vaults.some(e=>e.isPrimary))||tW)return void tJ("setup");let r="loading"===tM.current||"transition"===tM.current;if(e.unlocked&&!s&&r)try{if(await new Promise(e=>setTimeout(e,120)),!l())return;let e=window.localStorage.getItem(tI),a=window.sessionStorage.getItem(tI),r=e||a;if(r)return void t(r,{persist:e?"local":"session"})}catch(e){if(!l())return}if(!e.unlocked&&s&&r)try{if(await new Promise(e=>setTimeout(e,450)),!l())return;let e=await h.FH.get(h.jI.Wallet,"/setup");if(!l())return;if(e.unlocked)return void tJ("unlocked")}catch(e){if(!l())return}if(!e.unlocked||!s)return void tJ("locked");tJ("unlocked")}catch(e){if(!l())return;tJ("setup")}},[e,a,tW,tJ,t]);(0,l.useEffect)(()=>{tQ()},[tQ]);let t0=(0,l.useCallback)(async()=>{if(!e)return void ex("Unlock vault first to manage local socket policy.");ey(!0),ex(null),ef(null),eb(null);try{var t,a,r;let l=h.FH.getBaseUrl(h.jI.Wallet),s=await fetch("".concat(l,"/defaults"),{headers:{Authorization:"Bearer ".concat(e)}});if(!s.ok)throw Error("Failed to load canonical trust policy defaults.");let o=await s.json();if(!1===o.success)throw Error("Failed to load canonical trust policy defaults.");let n=Object.values(o.defaults||{}).flat(),i=e=>{var t;return null==(t=n.find(t=>t.key===e))?void 0:t.value},c=String(null!=(t=i("trust.localProfile"))?t:"").trim();if(!tj.includes(c))throw Error("Unknown persisted local profile: ".concat(c||"(empty)"));let d=String(null!=(a=i("trust.localProfileVersion"))?a:"v1").trim();if("v1"!==d)throw Error("Unknown local profile version; refusing to edit settings.");let u=String(null!=(r=i("trust.projectScopeMode"))?r:"auto").trim();if(!tN.includes(u))throw Error("Unknown persisted project scope mode: ".concat(u||"(empty)"));let x={profile:c,profileVersion:"v1",autoApprove:!!i("trust.localAutoApprove"),projectScopeMode:u};ei(x),ed(x)}catch(e){ex(e.message||"Failed to load policy settings"),ei(null)}finally{ey(!1)}},[e]);(0,l.useEffect)(()=>{J&&t0()},[J,t0]);let t1=(0,l.useCallback)(async()=>{if(!e)throw Error("Missing auth token for save.");if(!tj.includes(ec.profile))throw Error("Unknown profile selected; refusing to persist.");if(!tN.includes(ec.projectScopeMode))throw Error("Unknown project scope mode selected; refusing to persist.");let t=h.FH.getBaseUrl(h.jI.Wallet),a={"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},r=[["trust.localProfile",ec.profile],["trust.localProfileVersion","v1"],["trust.localAutoApprove",ec.autoApprove],["trust.projectScopeMode",ec.projectScopeMode]];if(!(await Promise.all(r.map(async e=>{let[r,l]=e;return(await fetch("".concat(t,"/defaults/").concat(r),{method:"PATCH",headers:a,body:JSON.stringify({value:l})})).ok}))).every(Boolean))throw Error("Failed to save canonical trust policy defaults.");return{...ec,profileVersion:"v1"}},[ec,e]),t4=(0,l.useCallback)(async()=>{if(en&&!eg&&!ej){if(!tX(en)&&tX(ec)&&!ew)return void ek(!0);eN(!0),ef(null),eb(null);try{let e=await t1();ei(e),ed(e),ek(!1),eb("Local trust policy saved. Changes apply to newly issued local tokens only.")}catch(t){let e=t.message||"Failed to save policy settings";ek(!1),e.includes("Unknown profile selected")||e.includes("Unknown project scope mode selected")?ef(e):(await t0(),ef("".concat(e," Server values were reloaded.")))}finally{eN(!1)}}},[ew,tX,t0,t1,ec,eg,ej,en]),t2=(0,l.useCallback)(()=>{eZ(!1),e0(""),e4(""),e8(""),e6(null),tt(!1)},[]),t8=(0,l.useCallback)(async e=>{if(e.preventDefault(),e6(null),e7(null),e1.length<8)return void e6("New password must be at least 8 characters.");if(e1!==e2)return void e6("New password and confirmation do not match.");tt(!0);try{await (0,h.g4)(eQ,e1),e7("Primary vault password updated."),t2()}catch(e){e6(e.message||"Failed to change primary password.")}finally{tt(!1)}},[t2,e2,eQ,e1]),t3=(0,l.useCallback)((e,t)=>{let a=t.trim().toLowerCase();if(a.includes(" ")){let t=tR(a);if(t.length>1){let a=[...to];t.forEach((t,r)=>{let l=e+r;l<a.length&&(a[l]=t)}),tn(a),tP(null);return}}let r=[...to];r[e]=a,tn(r),tP(null)},[to]),t5=(0,l.useCallback)((e,t)=>{let a=tR(t);if(a.length<=1)return!1;let r=a.length>12?24:tl;if(r!==tl){ts(r);let e=Array(r).fill("");return a.slice(0,r).forEach((t,a)=>{e[a]=t}),tn(e),tP(null),!0}let l=[...to];return a.forEach((t,a)=>{let r=e+a;r<l.length&&(l[r]=t)}),tn(l),tP(null),!0},[tl,to]),t6=(0,l.useCallback)(async e=>{if(e.preventDefault(),tP(null),tO.length<8)return void tP("New password must be at least 8 characters.");if(!tY)return void tP("Enter a valid 12 or 24-word BIP-39 seed phrase.");tF(!0);try{let{publicKeyBase64:e}=await (0,b.T5)(),a=await (0,h.OW)(tB,tO,e);a.token&&t(a.token,{persist:A?"local":"session"}),S(""),tL(""),tn(Array(tl).fill("")),tZ(),ar()}catch(e){tP(e.message||"Recovery failed.")}finally{tF(!1)}},[tZ,tY,tB,tO,tl,t,A]),t9=async e=>{if(e.preventDefault(),C){T(!0),O(null);try{let{publicKeyBase64:e}=await (0,b.T5)(),a=await (0,h.WE)(C,void 0,e);a.token&&t(a.token,{persist:A?"local":"session"}),S(""),tZ(),ar()}catch(e){O(e.message||"Unlock failed")}finally{T(!1)}}},t7=async e=>{if(e.preventDefault(),!(C.length<8)){T(!0),O(null);try{let{publicKeyBase64:e}=await (0,b.T5)(),a=await (0,h.ne)(C,e);a.token&&(t(a.token,{persist:A?"local":"session"}),Y(a.token)),a.mnemonic&&(D(a.mnemonic),z(!1),B("seed"),M(null),K(null)),S(""),a.mnemonic||tQ()}catch(e){O(e.message||"Setup failed")}finally{T(!1)}}},ae=(0,l.useCallback)(async()=>{var e;if(!L)return;let t=!1;if("undefined"!=typeof navigator&&(null==(e=navigator.clipboard)?void 0:e.writeText))try{await navigator.clipboard.writeText(L),t=!0}catch(e){t=!1}if(t)return void K("copied");let a=document.createElement("textarea");a.value=L,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.focus(),a.select();let r=!1;try{r=document.execCommand("copy")}catch(e){r=!1}finally{a.remove()}K(r?"copied":"copy-failed")},[L]),at=(0,l.useCallback)(()=>{if(!L)return;let e=new Date().toISOString().slice(0,10),t=L.split(" ").map((e,t)=>"".concat(t+1,". ").concat(e)).join("\n"),a="# Aura Vault Seed Phrase Backup\n\n**Date:** ".concat(e,"\n**WARNING:** Keep this file safe and private. Anyone with this phrase can access your vault.\n\n").concat(t,"\n"),r="",l=document.createElement("a");try{let t=new Blob([a],{type:"text/markdown;charset=utf-8"});l.href=r=URL.createObjectURL(t),l.download="aura-seed-backup-".concat(e,".md"),l.style.display="none",document.body.appendChild(l),l.click(),K("downloaded")}catch(e){K("download-failed")}finally{l.remove(),r&&URL.revokeObjectURL(r)}},[L]),aa=(0,l.useCallback)(async()=>{let t=G||e;if(!t)throw Error("Session token unavailable. Unlock again and retry setup.");let a="strict"!==V,r=h.FH.getBaseUrl(h.jI.Wallet),l={"Content-Type":"application/json",Authorization:"Bearer ".concat(t)};await fetch("".concat(r,"/defaults/trust.localProfile"),{method:"PATCH",headers:l,body:JSON.stringify({value:V})}),await fetch("".concat(r,"/defaults/trust.localProfileVersion"),{method:"PATCH",headers:l,body:JSON.stringify({value:"v1"})}),await fetch("".concat(r,"/defaults/trust.localAutoApprove"),{method:"PATCH",headers:l,body:JSON.stringify({value:a})})},[V,G,e]),ar=(0,l.useCallback)(async()=>{q(!1);let e=!1,t=window.setTimeout(()=>{e||q(!0)},1500);try{await tQ(),e=!0}finally{window.clearTimeout(t)}},[tQ]),al=(0,l.useCallback)(async()=>{tu(!0),O(null);try{let{publicKeyBase64:e}=await (0,b.T5)(),a=await h.FH.post(h.jI.Wallet,"/auth/passkey/authenticate/options",{}),r=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";let a=atob(t),r=new Uint8Array(a.length);for(let e=0;e<a.length;e++)r[e]=a.charCodeAt(e);return r.buffer},l=e=>{let t=new Uint8Array(e),a="";for(let e=0;e<t.length;e++)a+=String.fromCharCode(t[e]);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},s={challenge:r(a.challenge),rpId:a.rpId,allowCredentials:(a.allowCredentials||[]).map(e=>({type:"public-key",id:r(e.id),transports:e.transports})),timeout:a.timeout,userVerification:a.userVerification||"required"},o=await navigator.credentials.get({publicKey:s});if(!o)return void tu(!1);let n=o.response,i=await h.FH.post(h.jI.Wallet,"/auth/passkey/authenticate/verify",{credential:{id:l(o.rawId),rawId:l(o.rawId),type:o.type,response:{clientDataJSON:l(n.clientDataJSON),authenticatorData:l(n.authenticatorData),signature:l(n.signature),userHandle:n.userHandle?l(n.userHandle):void 0}},pubkey:e});i.success&&i.token?(t(i.token,{persist:A?"local":"session"}),tZ(),ar()):O(i.error||"Biometric authentication failed")}catch(t){if(t instanceof Error&&"NotAllowedError"===t.name)return void tu(!1);let e=t instanceof Error?t.message:"Biometric authentication failed";e.includes("vault_locked")?tc(!1):O(e)}finally{tu(!1)}},[tZ,A,t,ar]),as=(0,l.useCallback)(async()=>{T(!0),O(null);try{await aa(),D(null),z(!1),M(null),Y(null),B("seed"),tZ(),ar()}catch(e){O(e.message||"Failed to save local agent mode")}finally{T(!1)}},[tZ,ar,aa]),ao=(0,l.useCallback)(()=>{t_.current&&(clearTimeout(t_.current),t_.current=null),H(!1),O(null),w("locked")},[]),an=(0,l.useCallback)(async()=>{el(!0),eo(null);try{await h.FH.post(h.jI.Wallet,"/nuke",{}),Z(!1),ek(!1),ef(null),ev({}),e6(null),eE(!0),eT(!1),eO(!1),eD(!1),eZ(!1),ea(!1),el(!1),eo(null),en&&ed(en),window.location.reload()}catch(e){eo(e.message||"Failed to nuke wallet"),console.error("[UnlockPage] Nuke failed:",e)}finally{el(!1)}},[en]),ai=(0,l.useCallback)(async()=>{if(!e)return void eM([]);eK(!0);try{let e=await h.FH.get(h.jI.Wallet,"/backup");e.success&&eM(e.backups)}catch(e){eM([])}finally{eK(!1)}},[e]),ac=(0,l.useCallback)(async()=>{eH(!0);try{(await h.FH.post(h.jI.Wallet,"/backup")).success&&await ai()}catch(e){console.error("Backup create failed",e)}finally{eH(!1)}},[ai]),ad=(0,l.useCallback)(async()=>{eB(!0);try{let t=h.FH.getBaseUrl(h.jI.Wallet),a=await fetch("".concat(t,"/backup/export"),{headers:{Authorization:"Bearer ".concat(e||"")}});if(!a.ok)return;let r=await a.blob(),l=(a.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/),s=l?l[1]:"auramaxx-export.db",o=URL.createObjectURL(r),n=document.createElement("a");n.href=o,n.download=s,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}catch(e){console.error("Export failed",e)}finally{eB(!1)}},[e]),au=(0,l.useCallback)(async e=>{eW(e);try{(await h.FH.put(h.jI.Wallet,"/backup",{filename:e})).success&&window.location.reload()}catch(e){console.error("Restore failed",e)}finally{eW(null)}},[]),ax=(0,l.useCallback)(()=>{if(tq)return void eS(!0);Z(!1),ek(!1),ef(null),ev({}),e6(null),eE(!0),eT(!1),eO(!1),eD(!1),ez(!1),eY(null),eq(null),eZ(!1),ea(!1),el(!1),eo(null),en&&ed(en)},[tq,en]);if("loading"===N||"transition"===N){let e="transition"===N?"DECRYPTING VAULT":"CONNECTING";return(0,r.jsxs)("div",{className:"min-h-screen bg-[var(--color-background,#f4f4f5)] relative flex items-center justify-center p-4 overflow-hidden",children:[(0,r.jsx)(th,{}),(0,r.jsxs)("div",{className:"fixed inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,r.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-5 select-none",children:(0,r.jsx)("h1",{className:"text-[15vw] font-bold leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})})]}),(0,r.jsx)("div",{className:"fixed top-6 left-6 z-50 flex items-center gap-3",children:(0,r.jsx)("div",{className:"w-10 h-10",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})})}),(0,r.jsxs)("div",{className:"fixed top-7 right-6 z-50 flex items-center gap-3 font-mono text-[10px] tracking-widest",children:[(0,r.jsx)(n(),{href:"/docs",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"DOCS"}),(0,r.jsx)(n(),{href:"/api",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"API"}),(0,r.jsx)("a",{href:"https://github.com/Aura-Industry/auramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"GITHUB"}),(0,r.jsx)("a",{href:"https://x.com/npxauramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"X"}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"HELP"}),(0,r.jsx)(tf.default,{})]}),(0,r.jsxs)("div",{className:"relative z-10 w-full max-w-[320px] p-6 flex flex-col items-center text-center ".concat(U?"animate-fade-out-up":"animate-fade-in-up"),children:[(0,r.jsx)("div",{className:"w-10 h-10 mb-2 opacity-60",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin"}),(0,r.jsx)("div",{className:"mt-4 label-specimen text-[var(--color-text-muted,#6b7280)] animate-pulse",children:e}),(0,r.jsx)("div",{className:"mt-3 w-32 h-[2px] skeleton-mech"}),"transition"===N&&X&&(0,r.jsxs)("div",{className:"mt-6 w-full max-w-[280px] space-y-3 text-center",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:"Dashboard took too long. You can retry without re-running onboarding."}),(0,r.jsx)("button",{onClick:()=>{ar()},className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity clip-specimen-sm",children:"RETRY"})]})]})]})}return"unlocked"===N?(0,r.jsxs)("div",{className:"relative h-screen vault-surface",children:[(0,r.jsx)(th,{}),(0,r.jsxs)("div",{className:"fixed top-3 right-6 z-50 flex items-center gap-1.5",children:[(0,r.jsx)("button",{onClick:()=>Z(!0),className:"p-1.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface,#ffffff)]/50 transition-colors rounded",title:"Settings","aria-label":"Settings",children:(0,r.jsx)(i.A,{size:14})}),(0,r.jsx)(tp.v,{notifications:Q,onDismiss:ee}),(0,r.jsx)(tf.default,{})]}),(0,r.jsxs)("div",{className:"fixed bottom-16 right-6 z-50 flex items-center gap-3 font-mono text-[10px] tracking-widest",children:[(0,r.jsx)(n(),{href:"/docs",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"DOCS"}),(0,r.jsx)(n(),{href:"/api",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"API"}),(0,r.jsx)("a",{href:"https://github.com/Aura-Industry/auramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"GITHUB"}),(0,r.jsx)("a",{href:"https://x.com/npxauramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"X"}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"HELP"})]}),(0,r.jsx)(tx,{onLock:ao,onSettings:()=>Z(!0)}),(0,r.jsx)(k._s,{isOpen:J,onClose:ax,title:"Settings",subtitle:"Local socket policy",footerLabel:"",children:(0,r.jsxs)("div",{className:"space-y-4",children:[e9&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-info)] border border-[var(--color-info)]/30 bg-[var(--color-info)]/10 px-3 py-2",children:e9}),(0,r.jsxs)(k.lX,{title:"Vault Theme",isOpen:eA,onToggle:()=>eE(e=>!e),className:"overflow-hidden",contentClassName:"p-[var(--space-md)] border-t border-[var(--color-border)]",children:[(0,r.jsx)("label",{className:"block text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"Color mode"}),(0,r.jsx)(k.O6,{options:[...tS],value:o,onChange:e=>y(e)}),(0,r.jsx)("label",{className:"block mt-3 text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"UI scale"}),(0,r.jsx)(k.O6,{options:[...tA],value:g,onChange:e=>j(e)}),(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-text-muted)]",children:"Dark adjusts vault color contrast. Big increases typography, spacing, radius, and shadows."})]}),(0,r.jsxs)(k.lX,{title:"Agent Profile",icon:(0,r.jsx)(c.A,{size:12}),isOpen:eI,onToggle:()=>eT(e=>!e),className:"overflow-hidden",contentClassName:"px-4 pb-4 space-y-3 border-t border-[var(--color-border)]",children:[eu&&(0,r.jsxs)("div",{className:"space-y-2 pt-3",children:[(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2",children:eu}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>void t0(),disabled:eg,variant:"secondary",size:"md",children:eg?"Retrying...":"Retry load"})]}),!eu&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"pt-3 flex items-center justify-between text-[10px] font-mono text-[var(--color-text)]",children:[(0,r.jsx)("span",{children:"Auto-approve local requests"}),(0,r.jsx)(k.lM,{size:"sm",checked:ec.autoApprove,onChange:e=>ed(t=>({...t,autoApprove:e})),disabled:eg||ej})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"Local profile"}),(0,r.jsx)(k.O6,{ariaLabel:"Local profile",options:[...tw],value:ec.profile,onChange:e=>ed(t=>({...t,profile:e})),disabled:eg||ej})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"Project scope mode"}),(0,r.jsx)(k.O6,{ariaLabel:"Project scope mode",options:[...tk],value:ec.projectScopeMode,onChange:e=>ed(t=>({...t,projectScopeMode:e})),disabled:eg||ej}),(0,r.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted)]",children:"Strict requires `.aura` mappings for `get_secret`. Auto allows token-scope fallback when `.aura` is missing."})]}),ew&&(0,r.jsxs)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2 space-y-2",children:[(0,r.jsx)("div",{children:"Dangerous mode broadens local token scope (admin profile or super-scopes)."}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(k.$n,{type:"button",onClick:()=>{ek(!1),en&&ed(en)},variant:"secondary",size:"sm",className:"!h-8",children:"Cancel"}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>{t4()},disabled:ej,variant:"danger",size:"sm",className:"!h-8",children:"Confirm dangerous mode"})]})]}),(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)] px-3 py-2",children:"Policy changes apply to newly issued local tokens only."}),ep&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)]",children:ep}),eh&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-info)]",children:eh}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>{t4()},disabled:!!eu||eg||ej||!en,variant:"primary",size:"lg",className:"w-full",children:ej?"Saving...":"Save local policy"})]})]}),(0,r.jsxs)(k.lX,{title:"Primary Password",icon:(0,r.jsx)(d.A,{size:12}),isOpen:eR,onToggle:()=>eO(e=>!e),className:"overflow-hidden",contentClassName:"px-4 pb-4 pt-3 space-y-3 border-t border-[var(--color-border)]",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)] leading-relaxed",children:"Rotate your primary vault password. This updates the vault wrapper encryption and keeps existing credentials intact."}),e5&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2",children:e5}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>{e6(null),eZ(!0)},variant:"secondary",size:"lg",className:"w-full",children:"Change primary password"})]}),(0,r.jsxs)(k.lX,{title:"Database Backup",icon:(0,r.jsx)(u.A,{size:12}),isOpen:eP,onToggle:()=>{let e=!eP;ez(e),e&&ai()},className:"overflow-hidden",contentClassName:"px-4 pb-4 pt-3 space-y-3 border-t border-[var(--color-border)]",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(k.$n,{variant:"secondary",size:"md",onClick:()=>void ac(),disabled:eU,loading:eU,icon:eU?void 0:(0,r.jsx)(x.A,{size:12}),className:"flex-1",children:eU?"CREATING...":"CREATE BACKUP"}),(0,r.jsx)(k.$n,{variant:"secondary",size:"md",onClick:()=>void ad(),disabled:e$,loading:e$,icon:e$?void 0:(0,r.jsx)(u.A,{size:12}),className:"flex-1",children:e$?"EXPORTING...":"EXPORT DB"})]}),e_?(0,r.jsx)("div",{className:"py-4 flex items-center justify-center",children:(0,r.jsx)(p.A,{size:16,className:"animate-spin text-[var(--color-text-muted)]"})}):0===eF.length?(0,r.jsx)("div",{className:"py-3 text-center",children:(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted)]",children:"No backups found"})}):(0,r.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:eF.map(e=>{var t;return(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(k.$n,{type:"button",variant:"secondary",size:"md",onClick:t=>{eq(t.currentTarget),eY(e.filename)},className:"w-full !h-auto !px-2 !py-2 !justify-between group",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(f.A,{size:10,className:"text-[var(--color-text-muted)] group-hover:text-[var(--color-text)]"}),(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text)]",children:(e=>{let t=e.slice(0,4),a=e.slice(4,6),r=e.slice(6,8),l=e.slice(9,11),s=e.slice(11,13);return"".concat(t,"-").concat(a,"-").concat(r," ").concat(l,":").concat(s)})(e.timestamp)})]}),(0,r.jsx)("span",{className:"font-mono text-[9px] text-[var(--color-text-muted)]",children:(t=e.size)<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")})]}),(0,r.jsx)(k.Rw,{isOpen:eG===e.filename,onClose:()=>{eY(null),eq(null)},onConfirm:()=>{eY(null),eq(null),au(e.filename)},title:"Restore Backup",message:"Restore to this backup? You will lose all data since this backup was created.",confirmText:"RESTORE",variant:"warning",loading:eV===e.filename})]},e.filename)})}),(0,r.jsx)("div",{className:"pt-2 border-t border-dashed border-[var(--color-border)]",children:(0,r.jsx)("div",{className:"font-mono text-[8px] text-[var(--color-text-faint)] leading-relaxed",children:"Backups are tied to the current database schema. Restoring after migrations may cause issues."})})]}),(0,r.jsxs)(k.lX,{title:"Danger Zone",isOpen:eL,onToggle:()=>eD(e=>!e),tone:"warning",className:"overflow-hidden",contentClassName:"space-y-3 p-[var(--space-md)] border-t border-[var(--color-border)]",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-warning)] leading-relaxed",children:"Permanently delete your vault, wallets, credentials, and local configuration. This action cannot be undone."}),es&&(0,r.jsx)("div",{className:"text-[10px] border px-3 py-2",style:{color:"var(--color-warning)",borderColor:"color-mix(in srgb, var(--color-warning) 30%, transparent)",background:"color-mix(in srgb, var(--color-warning) 10%, transparent)"},children:es}),(0,r.jsx)(k.$n,{type:"button",onClick:()=>{eo(null),ea(!0)},disabled:er,variant:"danger",size:"lg",className:"w-full",children:er?"Nuking...":"Nuke"})]})]})}),(0,r.jsx)(k.Rw,{isOpen:et,onClose:()=>ea(!1),onConfirm:()=>{an()},title:"Nuke Vault",message:"Permanently delete your vault, wallets, credentials, and local configuration. This cannot be undone.",confirmText:"NUKE",cancelText:"CANCEL",variant:"danger",loading:er}),(0,r.jsx)(k.Rw,{isOpen:eC,onClose:()=>eS(!1),onConfirm:()=>{eS(!1),Z(!1),ek(!1),ef(null),ev({}),e6(null),eE(!0),eT(!1),eO(!1),eD(!1),ez(!1),eY(null),eq(null),eZ(!1),ea(!1),el(!1),eo(null),en&&ed(en)},variant:"warning",title:"Discard Changes",message:"You have unsaved local policy changes. Discard them?",confirmText:"DISCARD",cancelText:"KEEP EDITING"}),(0,r.jsx)(k.aF,{isOpen:eJ,onClose:t2,title:"Change Primary Password",subtitle:"Security",size:"sm",children:(0,r.jsxs)("form",{onSubmit:t8,className:"space-y-3",children:[(0,r.jsx)(k.ks,{type:"password",label:"CURRENT PASSWORD","aria-label":"CURRENT PASSWORD",value:eQ,onChange:e=>e0(e.target.value),autoFocus:!0,compact:!0}),(0,r.jsx)(k.ks,{type:"password",label:"NEW PASSWORD","aria-label":"NEW PASSWORD",value:e1,onChange:e=>e4(e.target.value),compact:!0}),(0,r.jsx)(k.ks,{type:"password",label:"CONFIRM NEW PASSWORD","aria-label":"CONFIRM NEW PASSWORD",value:e2,onChange:e=>e8(e.target.value),compact:!0}),e5&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)]",children:e5}),(0,r.jsxs)("div",{className:"flex gap-2 pt-2",children:[(0,r.jsx)(k.$n,{type:"button",onClick:t2,disabled:te,variant:"secondary",size:"lg",className:"flex-1",children:"CANCEL"}),(0,r.jsx)(k.$n,{type:"submit",disabled:te||!eQ||!e1||!e2,variant:"primary",size:"lg",className:"flex-1",children:te?"UPDATING...":"UPDATE PASSWORD"})]})]})}),(0,r.jsx)(tm.Z,{isUnlocked:"unlocked"===N})]}):(0,r.jsxs)("div",{className:"min-h-screen bg-[var(--color-background,#f4f4f5)] relative flex items-center justify-center p-4",children:[(0,r.jsx)(th,{}),(0,r.jsxs)("div",{className:"fixed inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,r.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-5 select-none","data-testid":"home-background-branding",children:(0,r.jsx)("h1",{className:"text-[15vw] font-bold leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})}),(0,r.jsx)("div",{className:"absolute top-10 left-10 w-32 h-32 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10",children:(0,r.jsx)("div",{className:"absolute top-2 left-2 w-4 h-4 bg-[var(--color-text,#0a0a0a)]"})}),(0,r.jsx)("div",{className:"absolute bottom-10 right-10 w-32 h-32 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end",children:(0,r.jsx)("div",{className:"absolute bottom-2 right-2 w-4 h-4 bg-[var(--color-text,#0a0a0a)]"})})]}),(0,r.jsx)("div",{className:"fixed top-6 left-6 z-50 flex items-center gap-3",children:(0,r.jsx)("div",{className:"w-10 h-10",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})})}),(0,r.jsxs)("div",{className:"fixed top-7 right-6 z-50 flex items-center gap-3 font-mono text-[10px] tracking-widest",children:[(0,r.jsx)(n(),{href:"/docs",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"DOCS"}),(0,r.jsx)(n(),{href:"/api",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"API"}),(0,r.jsx)("a",{href:"https://github.com/Aura-Industry/auramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"GITHUB"}),(0,r.jsx)("a",{href:"https://x.com/npxauramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"X"}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"HELP"}),(0,r.jsx)(tf.default,{})]}),(0,r.jsxs)("div",{className:"relative z-10 w-full max-w-[380px]",children:[(0,r.jsx)("div",{className:"absolute -left-8 top-1/2 -translate-y-1/2 text-vertical label-specimen-sm text-[var(--color-text-faint,#9ca3af)] select-none hidden sm:block",children:"VAULT\xa0ACCESS"}),(0,r.jsxs)("div",{className:"bg-[var(--color-surface,#f4f4f2)] clip-specimen border-mech shadow-mech overflow-hidden font-mono corner-marks",children:[(0,r.jsxs)("div",{className:"px-5 py-3 border-b border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface-alt,#fafafa)] flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-sans font-bold text-sm text-[var(--color-text,#0a0a0a)] uppercase tracking-tight",children:"setup"===N?"Initialize":"Unlock"}),(0,r.jsx)("span",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)] font-bold tracking-widest",children:"setup"===N?"NO_VAULT":"LOCKED"})]}),(0,r.jsxs)("div",{className:"p-6",children:["setup"===N&&L&&"seed"===$&&(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center mb-4",children:"SAVE YOUR RECOVERY PHRASE"}),(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20 mb-3",children:"Write this down and store it securely. You will stay on this screen until you explicitly confirm."}),F&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-info,#0047ff)] bg-[var(--color-info,#0047ff)]/10 px-3 py-2 border border-[var(--color-info,#0047ff)]/20 mb-3",children:F}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2 w-full mb-4",children:L.split(" ").map((e,t)=>(0,r.jsxs)("div",{className:"text-[10px] font-mono text-[var(--color-text,#0a0a0a)] bg-[var(--color-background,#f4f4f5)] px-2 py-1 border border-[var(--color-border,#d4d4d8)]",children:[(0,r.jsxs)("span",{className:"text-[var(--color-text-faint,#9ca3af)] mr-1",children:[t+1,"."]}),e]},t))}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 w-full mb-3",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{ae()},className:"h-9 px-2 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] tracking-widest text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface-alt,#fafafa)] transition-colors",children:"COPY SEED PHRASE"}),(0,r.jsx)("button",{type:"button",onClick:at,className:"h-9 px-2 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] tracking-widest text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface-alt,#fafafa)] transition-colors",children:"DOWNLOAD BACKUP (.MD)"})]}),_&&(0,r.jsx)("div",{className:"w-full mb-3 text-[9px] text-[var(--color-text-muted,#6b7280)]","aria-live":"polite","data-testid":"seed-phrase-action-status",children:_}),(0,r.jsxs)("label",{className:"flex items-start gap-2 w-full mb-3 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:P,onChange:e=>z(e.target.checked),className:"mt-0.5"}),(0,r.jsx)("span",{className:"text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"I have written and verified this recovery phrase in a secure location."})]}),(0,r.jsx)("button",{onClick:()=>{P&&B("trust")},disabled:!P,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed",children:"CONTINUE TO AGENT MODE"}),(0,r.jsx)("div",{className:"w-full mt-3 text-[8px] text-[var(--color-text-faint,#9ca3af)] text-center",children:"If you leave before confirming, this phrase is recoverable only temporarily in this tab session. If recovery expires, restart onboarding to regenerate."})]}),"setup"===N&&L&&"trust"===$&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center",children:"LOCAL AGENT MODE"})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted,#6b7280)] bg-[var(--color-background,#f4f4f5)] px-3 py-2 border border-[var(--color-border,#d4d4d8)]",children:"How much do you trust your agent?"}),(0,r.jsxs)("fieldset",{className:"border border-[var(--color-border,#d4d4d8)] p-2.5 bg-[var(--color-background,#f4f4f5)]",children:[(0,r.jsx)("legend",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest uppercase px-1",children:"Pick a profile"}),(0,r.jsx)(k.O6,{options:[...tC],value:V,onChange:e=>W(e),ariaLabel:"Onboarding local agent mode"})]}),R&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:R}),(0,r.jsx)("button",{onClick:()=>{as()},disabled:I,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:I?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"SAVING..."]}):"SAVE MODE AND CONTINUE"})]})]}),"setup"===N&&!L&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center",children:"CREATE YOUR ENCRYPTED VAULT"}),(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-text-faint,#9ca3af)] text-center leading-relaxed","data-testid":"start-banner-quote",children:tv})]}),(0,r.jsxs)("form",{onSubmit:t7,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest mb-1.5 uppercase",children:"Encryption Password"}),(0,r.jsx)("input",{type:"password",value:C,onChange:e=>{S(e.target.value),O(null)},placeholder:"Minimum 8 characters",className:"w-full px-3 py-2.5 border border-[var(--color-border,#d4d4d8)] font-mono text-sm text-[var(--color-text,#0a0a0a)] focus:outline-none focus:border-[var(--color-text,#0a0a0a)] bg-[var(--color-surface,#ffffff)] placeholder-[var(--color-text-faint,#9ca3af)] transition-colors",autoFocus:!0})]}),(0,r.jsxs)("label",{className:"flex items-center justify-between gap-3 text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:A,onChange:e=>E(e.target.checked),className:"h-3.5 w-3.5 border border-[var(--color-border,#d4d4d8)] accent-[var(--color-text,#0a0a0a)]"}),"Trusted device"]}),(0,r.jsx)("span",{children:A?"PERSISTENT":"TAB ONLY"})]}),R&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:R}),(0,r.jsx)("button",{type:"submit",disabled:I||C.length<8,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:I?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"INITIALIZING..."]}):"INITIALIZE VAULT"})]}),(0,r.jsx)("div",{className:"mt-4 pt-4 border-t border-[var(--color-border,#d4d4d8)]",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("div",{className:"w-1 h-1 bg-[var(--color-text-muted,#6b7280)] mt-1.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] leading-relaxed",children:"This password encrypts your seed phrase locally. It never leaves your machine."})]})})]}),"locked"===N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center",children:ta?"RECOVER WITH SEED PHRASE":ti?"UNLOCK VAULT":"ENTER PASSWORD TO UNLOCK"}),(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-text,#0a0a0a)] text-center leading-relaxed","data-testid":"start-banner-quote",children:tv})]}),!ta&&(0,r.jsxs)(r.Fragment,{children:[ti&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{al()},disabled:td,className:"w-full py-3 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-50 flex items-center justify-center gap-2",children:td?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"AUTHENTICATING..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(m.A,{size:14}),"UNLOCK WITH PASSKEY"]})}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex-1 h-px bg-[var(--color-border,#d4d4d8)]"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest",children:"OR USE PASSWORD"}),(0,r.jsx)("div",{className:"flex-1 h-px bg-[var(--color-border,#d4d4d8)]"})]})]}),(0,r.jsxs)("form",{onSubmit:t9,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest mb-1.5 uppercase",children:"Password"}),(0,r.jsx)("input",{type:"password",value:C,onChange:e=>{S(e.target.value),O(null)},placeholder:"Enter vault password",className:"w-full px-3 py-2.5 border border-[var(--color-border,#d4d4d8)] font-mono text-sm text-[var(--color-text,#0a0a0a)] focus:outline-none focus:border-[var(--color-text,#0a0a0a)] bg-[var(--color-surface,#ffffff)] placeholder-[var(--color-text-faint,#9ca3af)] transition-colors",autoFocus:!0})]}),(0,r.jsxs)("label",{className:"flex items-center justify-between gap-3 text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:A,onChange:e=>E(e.target.checked),className:"h-3.5 w-3.5 border border-[var(--color-border,#d4d4d8)] accent-[var(--color-text,#0a0a0a)]"}),"Trusted device"]}),(0,r.jsx)("span",{children:A?"PERSISTENT":"TAB ONLY"})]}),R&&(0,r.jsx)("div",{"data-testid":"unlock-error-banner",className:"text-[9px] text-[var(--color-danger,#ef4444)] px-3 py-2 border",style:{borderColor:"color-mix(in srgb, var(--color-danger,#ef4444) 35%, transparent)",background:"color-mix(in srgb, var(--color-danger,#ef4444) 12%, transparent)"},children:R}),(0,r.jsx)("button",{type:"submit",disabled:I||!C,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:I?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"UNLOCKING..."]}):"UNLOCK"})]}),(0,r.jsx)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3 text-center",children:(0,r.jsx)("button",{type:"button",onClick:()=>{tr(!0),tP(null)},className:"text-[10px] underline underline-offset-2 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"Forgot password?"})})]}),ta&&(0,r.jsx)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3 text-center",children:(0,r.jsx)("button",{type:"button",onClick:()=>{tr(!1),tP(null)},className:"text-[10px] underline underline-offset-2 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"Back to unlock"})}),ta&&(0,r.jsxs)("form",{onSubmit:t6,className:"mt-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Seed Recovery"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{ts(12),tn(Array(12).fill(""))},className:"px-2 py-1 text-[8px] border ".concat(12===tl?"bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#fff)] border-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)]"),children:"12"}),(0,r.jsx)("button",{type:"button",onClick:()=>{ts(24),tn(Array(24).fill(""))},className:"px-2 py-1 text-[8px] border ".concat(24===tl?"bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#fff)] border-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)]"),children:"24"})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:to.map((e,t)=>{let a=tG.has(t);return(0,r.jsx)(k.ks,{compact:!0,error:a,"aria-label":"Recovery word ".concat(t+1),value:e,onChange:e=>t3(t,e.target.value),onPaste:e=>{t5(t,e.clipboardData.getData("text"))&&e.preventDefault()},placeholder:"".concat(t+1),className:"min-w-0"},"recovery-word-".concat(t))})}),(0,r.jsxs)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:[t$,"/",tl," words \xb7 ",tG.size>0?"".concat(tG.size," invalid word(s)"):tY?"BIP-39 phrase valid":"Waiting for valid BIP-39 phrase"]}),(0,r.jsx)(k.ks,{type:"password",compact:!0,value:tO,onChange:e=>{tL(e.target.value),tP(null)},placeholder:"New password","aria-label":"New password"}),tD&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:tD}),(0,r.jsx)("button",{type:"submit",disabled:tz,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30",children:tz?"RECOVERING...":"RECOVER & UNLOCK"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 px-5 py-2 border-t border-[var(--color-border,#d4d4d8)]",children:[(0,r.jsx)("div",{className:"h-4 flex-1 bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-wider",children:"AURAMAXX"})]}),(0,r.jsx)("div",{className:"h-2 w-full",style:{backgroundImage:"repeating-linear-gradient(45deg, var(--color-text, #000), var(--color-text, #000) 5px, transparent 5px, transparent 10px)",opacity:.1}})]}),(0,r.jsx)("div",{className:"mt-4 text-center",children:(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-[0.2em] font-mono",children:"SECURE LOCAL WALLETS FOR AI AGENTS"})})]})]})}},4265:(e,t,a)=>{"use strict";a.d(t,{default:()=>s});var r=a(5155),l=a(5685);function s(){let{colorMode:e,setColorMode:t}=(0,l.D)(),a="light"===e;return(0,r.jsx)("button",{onClick:()=>{t(a?"dark":"light")},className:"p-1.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface,#ffffff)]/50 transition-colors rounded","aria-label":a?"Switch to dark mode":"Switch to light mode",children:a?(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,r.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,r.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,r.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,r.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,r.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,r.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,r.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,r.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})})}},6793:(e,t,a)=>{Promise.resolve().then(a.bind(a,1643))},8824:(e,t,a)=>{"use strict";a.d(t,{e:()=>s});var r=a(2115),l=a(960);function s(){let e=(0,r.useMemo)(()=>(0,l.au)(),[]),[t,a]=(0,r.useState)({checking:!1,updateAvailable:!1,current:null,latest:null,updating:!1,updateOutput:null,updateError:null,apiServerDown:!1,restartingServer:!1,restartError:null}),s=(0,r.useCallback)(async()=>{a(e=>({...e,checking:!0}));try{let e=await fetch("/api/version");if(!e.ok)return;let t=await e.json();t.success&&a(e=>({...e,checking:!1,updateAvailable:t.updateAvailable,current:t.current,latest:t.latest}))}catch(e){a(e=>({...e,checking:!1}))}},[]),o=(0,r.useCallback)(async()=>{a(e=>({...e,updating:!0,updateError:null,updateOutput:null}));try{let e=await fetch("/api/update",{method:"POST"}),t=await e.json();t.success?a(e=>({...e,updating:!1,updateAvailable:!1,updateOutput:t.output||"Update completed successfully."})):a(e=>({...e,updating:!1,updateError:t.error||"Update failed.",updateOutput:t.output||null}))}catch(e){a(t=>({...t,updating:!1,updateError:e.message||"Update request failed."}))}},[]),n=(0,r.useCallback)(async()=>{try{let t=!(await fetch("".concat(e,"/health"),{cache:"no-store"})).ok;a(e=>e.apiServerDown===t&&(t||!e.restartError)?e:{...e,apiServerDown:t,restartError:t?e.restartError:null})}catch(e){a(e=>e.apiServerDown?e:{...e,apiServerDown:!0})}},[e]),i=(0,r.useCallback)(async()=>{a(e=>({...e,restartingServer:!0,restartError:null}));try{let e=await fetch("/api/restart",{method:"POST"}),t=await e.json().catch(()=>({success:!1,error:"Invalid restart response."}));if(!e.ok||!t.success)throw Error(t.error||"Restart failed (".concat(e.status,")"));a(e=>({...e,restartingServer:!1,apiServerDown:!0,restartError:null})),window.setTimeout(()=>{window.location.reload()},2e3)}catch(e){a(t=>({...t,restartingServer:!1,restartError:e.message||"Restart request failed."}))}},[]);return(0,r.useEffect)(()=>{s()},[s]),(0,r.useEffect)(()=>{n();let e=window.setInterval(()=>{n()},8e3);return()=>{window.clearInterval(e)}},[n]),(0,r.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&n()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[n]),{...t,runUpdate:o,checkForUpdate:s,runRestart:i,checkApiHealth:n}}}},e=>{e.O(0,[2619,7616,142,3922,8614,3667,4901,6872,8441,1255,7358],()=>e(e.s=6793)),_N_E=e.O()}]);
|
|
File without changes
|
|
File without changes
|