@clef-sh/cli 0.1.11-beta.71 → 0.1.11-beta.74

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.
@@ -23,4 +23,4 @@ Error generating stack: `+e.message+`
23
23
  }`:u===`yaml`?`DB_HOST: localhost
24
24
  DB_PORT: '5432'`:`DB_HOST=localhost
25
25
  DB_PORT=5432
26
- # Comments are ignored`,rows:12,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:14,fontFamily:v.mono,fontSize:12,color:v.text,resize:`vertical`,outline:`none`,boxSizing:`border-box`}})]}),(0,D.jsx)(`div`,{style:{marginBottom:24,padding:`10px 14px`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,fontFamily:v.sans,fontSize:11,color:v.textMuted,lineHeight:1.5},children:`Values are sent directly to the local Clef server (127.0.0.1) and encrypted immediately. They are never stored in browser memory beyond this session.`}),(0,D.jsx)(M,{variant:`primary`,onClick:O,disabled:b||!c.trim(),children:b?`Previewing...`:`Next: Preview`})]}),n===2&&f&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.textMuted,marginBottom:20},children:[`Importing to`,` `,(0,D.jsxs)(`span`,{style:{color:v.accent,fontWeight:600},children:[i,`/`,o]}),`. `,f.totalKeys,` key`,f.totalKeys===1?``:`s`,` parsed.`]}),f.warnings.length>0&&(0,D.jsx)(`div`,{style:{marginBottom:16},children:f.warnings.map((e,t)=>(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.yellow,marginBottom:4},children:[`⚠ `,e]},t))}),f.wouldImport.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.green,children:[`New keys (`,f.wouldImport.length,`)`]}),f.wouldImport.map(e=>(0,D.jsx)(me,{icon:`\\u2192`,iconColor:v.green,label:e},e))]}),f.wouldSkip.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.yellow,children:[`Already exists (`,f.wouldSkip.length,`) — toggle to overwrite`]}),f.wouldSkip.map(({key:e,reason:t})=>{let n=m.includes(e);return(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`6px 10px`,borderRadius:6,marginBottom:4,background:n?v.yellowDim:`transparent`,border:`1px solid ${n?v.yellow+`44`:v.border}`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>N(e),style:{accentColor:v.yellow},id:`overwrite-${e}`}),(0,D.jsx)(`label`,{htmlFor:`overwrite-${e}`,style:{fontFamily:v.mono,fontSize:12,color:n?v.yellow:v.textMuted,flex:1,cursor:`pointer`},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontSize:11,color:v.textDim},children:t})]},e)})]}),f.wouldImport.length===0&&f.wouldSkip.length===0&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.textMuted,padding:`24px 0`,textAlign:`center`},children:`No importable keys found.`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:24},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:()=>r(1),children:`Back`}),(0,D.jsx)(M,{variant:`primary`,onClick:k,disabled:b||P===0,children:b?`Importing...`:`Import ${P} key${P===1?``:`s`}`})]})]}),n===3&&_&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,paddingTop:20,paddingBottom:32},children:[(0,D.jsx)(`div`,{style:{width:56,height:56,borderRadius:`50%`,background:_.failed.length>0?v.redDim:v.greenDim,border:`1px solid ${_.failed.length>0?v.red+`44`:v.green+`44`}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:24,color:_.failed.length>0?v.red:v.green,marginBottom:16},children:_.failed.length>0?`⚠`:`✓`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontWeight:600,fontSize:16,color:_.failed.length>0?v.yellow:v.green,marginBottom:8},children:_.failed.length>0?`Import completed with errors`:`Import complete`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[_.imported.length,` imported, `,_.skipped.length,` skipped,`,` `,_.failed.length,` failed`]})]}),_.imported.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.green,children:[`Imported (`,_.imported.length,`)`]}),_.imported.map(e=>(0,D.jsx)(me,{icon:`\\u2713`,iconColor:v.green,label:e},e))]}),_.failed.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.red,children:[`Failed (`,_.failed.length,`)`]}),_.failed.map(({key:e,error:t})=>(0,D.jsx)(me,{icon:`\\u2717`,iconColor:v.red,label:e,note:t},e))]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:24},children:[(0,D.jsx)(M,{variant:`primary`,onClick:()=>t(`matrix`),children:`View in Matrix`}),(0,D.jsx)(M,{variant:`ghost`,onClick:j,children:`Import more`})]})]})]})})]})}function ue({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:8,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function de({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,color:v.textDim,marginBottom:4},children:e})}function fe({value:e,onChange:t,children:n}){return(0,D.jsx)(`select`,{value:e,onChange:t,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`7px 10px`,fontFamily:v.sans,fontSize:13,color:v.text,outline:`none`,cursor:`pointer`},children:n})}function pe({children:e,color:t}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,fontWeight:600,color:t,letterSpacing:`0.06em`,textTransform:`uppercase`,marginBottom:8},children:e})}function me({icon:e,iconColor:t,label:n,note:r}){return(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`5px 10px`,borderRadius:6,marginBottom:3},children:[(0,D.jsx)(`span`,{style:{color:t,fontFamily:v.mono,fontSize:13},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:12,color:v.text,flex:1},children:n}),r&&(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontSize:11,color:v.textDim},children:r})]})}function he({manifest:e,setView:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(!1),[_,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(0),[w,E]=(0,g.useState)(!1),[O,k]=(0,g.useState)(null),j=(0,g.useRef)(null),N=(0,g.useCallback)(async()=>{try{let e=await T(`/api/recipients`);if(e.ok){let t=await e.json();r(t.recipients),a(t.totalFiles)}}catch{}},[]);(0,g.useEffect)(()=>{N()},[N]),(0,g.useEffect)(()=>{if(!c.trim()){p(null);return}return j.current&&clearTimeout(j.current),j.current=setTimeout(async()=>{try{let e=await T(`/api/recipients/validate?key=${encodeURIComponent(c.trim())}`);e.ok&&p(await e.json())}catch{}},300),()=>{j.current&&clearTimeout(j.current)}},[c]);let P=async()=>{if(f?.valid){h(!0),y(null);try{let e=await T(`/api/recipients/add`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:c.trim(),label:u.trim()||void 0})});if(!e.ok){y((await e.json()).error??`Failed to add recipient`);return}r((await e.json()).recipients),s(!1),l(``),d(``),p(null)}catch(e){y(e instanceof Error?e.message:`Failed to add recipient`)}finally{h(!1)}}},F=e=>{x(e),C(1),E(!1)},ee=()=>{x(null),C(0),E(!1)},te=async()=>{if(b){h(!0),y(null);try{let e=await T(`/api/recipients/remove`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:b.key})});if(!e.ok){y((await e.json()).error??`Failed to remove recipient`);return}let t=await e.json();r(t.recipients),k({name:b.label??b.preview,targets:t.rotationReminder??[]}),ee()}catch(e){y(e instanceof Error?e.message:`Failed to remove recipient`)}finally{h(!1)}}};return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Recipients`,subtitle:`clef recipients -- manage age encryption keys`,actions:!o&&S===0?(0,D.jsx)(M,{variant:`primary`,onClick:()=>s(!0),children:`+ Add recipient`}):void 0}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[_&&(0,D.jsx)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16,fontFamily:v.sans,fontSize:13,color:v.red},children:_}),O&&(0,D.jsxs)(`div`,{"data-testid":`rotation-banner`,style:{background:v.yellowDim,border:`1px solid ${v.yellow}44`,borderRadius:8,padding:`14px 18px`,marginBottom:20},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,fontWeight:600,color:v.yellow,marginBottom:8},children:`Rotation reminder`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.text,marginBottom:10,lineHeight:1.5},children:[(0,D.jsx)(`strong`,{children:O.name}),` has been removed and files re-encrypted. However, the removed key may still decrypt old versions of these files from git history. Rotate secret values in the following targets to complete revocation:`]}),O.targets.length>0&&(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,marginBottom:12,paddingLeft:12},children:O.targets.map(e=>(0,D.jsx)(`div`,{style:{marginBottom:2},children:e},e))}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`primary`,onClick:()=>t(`matrix`),children:`Go to Matrix to rotate`}),(0,D.jsx)(M,{variant:`ghost`,onClick:()=>k(null),children:`Dismiss`})]})]}),o&&(0,D.jsxs)(`div`,{"data-testid":`add-form`,style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:10,padding:20,marginBottom:24},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,fontWeight:600,color:v.text,marginBottom:16},children:`Add recipient`}),(0,D.jsxs)(`div`,{style:{marginBottom:14},children:[(0,D.jsx)(ge,{children:`Age public key`}),(0,D.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`age1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq`,"data-testid":`add-key-input`,style:{width:`100%`,background:v.bg,border:`1px solid ${f?f.valid?v.green+`66`:v.red+`66`:v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.mono,fontSize:12,color:v.text,outline:`none`,boxSizing:`border-box`}}),f&&!f.valid&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,color:v.red,marginTop:4},children:f.error}),f?.valid&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,color:v.green,marginTop:4},children:`Valid age public key`})]}),(0,D.jsxs)(`div`,{style:{marginBottom:14},children:[(0,D.jsx)(ge,{children:`Label (optional)`}),(0,D.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`e.g. alice@example.com`,"data-testid":`add-label-input`,style:{width:`100%`,background:v.bg,border:`1px solid ${v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.sans,fontSize:13,color:v.text,outline:`none`,boxSizing:`border-box`}})]}),(0,D.jsxs)(`div`,{style:{marginBottom:16,padding:`10px 14px`,background:v.yellowDim,border:`1px solid ${v.yellow}44`,borderRadius:6,fontFamily:v.sans,fontSize:12,color:v.yellow,lineHeight:1.5},children:[`Adding a recipient will re-encrypt `,i,` file`,i===1?``:`s`,`. This may take a moment.`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:()=>{s(!1),l(``),d(``),p(null),y(null)},children:`Cancel`}),(0,D.jsx)(M,{variant:`primary`,onClick:P,disabled:m||!f?.valid,children:m?`Re-encrypting...`:`Add and re-encrypt`})]})]}),S===1&&b&&(0,D.jsxs)(`div`,{"data-testid":`remove-dialog`,style:{background:v.surface,border:`1px solid ${v.red}44`,borderRadius:10,padding:20,marginBottom:24},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,fontWeight:600,color:v.red,marginBottom:12},children:`Remove recipient`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.text,lineHeight:1.6,marginBottom:16},children:[`You are about to remove`,` `,(0,D.jsx)(`strong`,{style:{color:v.accent},children:b.label??b.preview}),` `,`(`,b.preview,`). All `,i,` encrypted file`,i===1?``:`s`,` will be re-encrypted without this key.`]}),(0,D.jsxs)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:6,padding:`12px 14px`,marginBottom:16,fontFamily:v.sans,fontSize:12,color:v.red,lineHeight:1.5},children:[`Re-encryption only removes `,(0,D.jsx)(`em`,{children:`future`}),` access. The removed key can still decrypt old versions from git history. You must rotate all secret values after removal.`]}),(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:v.text,marginBottom:16},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>E(e.target.checked),"data-testid":`acknowledge-checkbox`,style:{accentColor:v.red,marginTop:2}}),`I understand — I will rotate secrets after removal`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Cancel`}),(0,D.jsx)(M,{variant:`danger`,onClick:()=>C(2),disabled:!w,children:`Continue`})]})]}),S===2&&b&&(0,D.jsxs)(`div`,{"data-testid":`remove-confirm-dialog`,style:{background:v.surface,border:`1px solid ${v.red}44`,borderRadius:10,padding:20,marginBottom:24},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,fontWeight:600,color:v.red,marginBottom:12},children:`Confirm removal`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.text,lineHeight:1.6,marginBottom:16},children:[`This will remove`,` `,(0,D.jsx)(`strong`,{style:{color:v.accent},children:b.label??b.preview}),` `,`and re-encrypt all `,i,` file`,i===1?``:`s`,`. This cannot be undone.`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Cancel`}),(0,D.jsx)(M,{variant:`danger`,onClick:te,disabled:m,children:m?`Re-encrypting...`:`Remove and re-encrypt`})]})]}),n.length===0&&!o&&(0,D.jsx)(`div`,{style:{textAlign:`center`,paddingTop:40,fontFamily:v.sans,fontSize:14,color:v.textMuted},children:`No recipients configured. Add an age public key to get started.`}),n.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,letterSpacing:`0.05em`,textTransform:`uppercase`,marginBottom:10},children:[`Recipients (`,n.length,`)`]}),n.map(e=>(0,D.jsxs)(`div`,{"data-testid":`recipient-row`,style:{display:`flex`,alignItems:`center`,gap:14,padding:`12px 16px`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,marginBottom:8},children:[(0,D.jsx)(`div`,{style:{width:32,height:32,borderRadius:6,background:v.accentDim,border:`1px solid ${v.accent}44`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:14,flexShrink:0},children:`🔑`}),(0,D.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[e.label&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,fontWeight:600,color:v.text,marginBottom:2},children:e.label}),(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.preview})]}),(0,D.jsx)(M,{variant:`ghost`,onClick:()=>F(e),disabled:S!==0||m,children:`Remove`})]},e.key)),(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textDim,marginTop:12},children:[i,` encrypted file`,i===1?``:`s`,` in the matrix`]})]})]})})]})}function ge({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:6,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function _e({manifest:e}){let[t,n]=(0,g.useState)(`list`),[r,i]=(0,g.useState)([]),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(new Set),[h,_]=(0,g.useState)({}),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)({}),[E,O]=(0,g.useState)(``),[k,j]=(0,g.useState)({}),[P,F]=(0,g.useState)(!1),[ee,te]=(0,g.useState)(``),[ne,I]=(0,g.useState)(void 0),[re,ae]=(0,g.useState)({}),[oe,se]=(0,g.useState)(!1),[ce,le]=(0,g.useState)(``),L=(0,g.useCallback)(async()=>{try{let e=await T(`/api/service-identities`);e.ok&&i((await e.json()).identities)}catch{}},[]);(0,g.useEffect)(()=>{L()},[L]);let ue=r.find(e=>e.name===a),de=(0,g.useCallback)(()=>{u(``),f(``),m(new Set);let t={};for(let n of e?.environments??[])t[n.name]={type:`age`,provider:`aws`,keyId:``};_(t),S(``),n(`create`)},[e]),fe=(0,g.useCallback)(e=>{let t={};for(let[n,r]of Object.entries(e.environments)){let e=r.type===`kms`?`kms`:`age`;t[n]={type:e,provider:r.kms?.provider??`aws`,keyId:r.kms?.keyId??``,originalType:e,originalKeyId:r.kms?.keyId??``}}j(t),te(``),n(`update`)},[]),pe=(0,g.useCallback)(()=>{o(null),c(``),n(`list`)},[]),me=(0,g.useCallback)(()=>{c(``),le(``),n(`detail`)},[]);async function he(){b(!0),S(``);try{let e={};for(let[t,n]of Object.entries(h))n.type===`kms`&&(e[t]={provider:n.provider,keyId:n.keyId});let t={name:l.trim(),description:d.trim(),namespaces:Array.from(p)};Object.keys(e).length>0&&(t.kmsEnvConfigs=e);let r=await T(`/api/service-identities`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),i=await r.json();if(!r.ok){S(i.error??`Failed to create service identity.`);return}O(i.identity.name),w(i.privateKeys??{}),n(`keys`)}catch{S(`Network error. Check that the UI server is running.`)}finally{b(!1)}}async function ge(){if(a){F(!0),te(``);try{let e={};for(let[t,n]of Object.entries(k))n.type===`kms`&&(n.originalType!==`kms`||n.keyId!==n.originalKeyId)&&(e[t]={provider:n.provider,keyId:n.keyId});if(Object.keys(e).length===0){te(`No changes to apply.`);return}let t=await T(`/api/service-identities/${encodeURIComponent(a)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kmsEnvConfigs:e})}),n=await t.json();if(!t.ok){te(n.error??`Failed to update service identity.`);return}await L(),me()}catch{te(`Network error. Check that the UI server is running.`)}finally{F(!1)}}}async function _e(e){if(a){I(e),c(``);try{let t=await T(`/api/service-identities/${encodeURIComponent(a)}/rotate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({environment:e})}),r=await t.json();if(!t.ok){c(r.error??`Failed to rotate key.`);return}ae(r.privateKeys??{}),await L(),n(`rotate-keys`)}catch{c(`Network error. Check that the UI server is running.`)}finally{I(void 0)}}}async function Se(){if(a){se(!0),le(``);try{let e=await T(`/api/service-identities/${encodeURIComponent(a)}`,{method:`DELETE`});if(!e.ok){le((await e.json()).error??`Failed to delete service identity.`);return}await L(),pe()}catch{le(`Network error. Check that the UI server is running.`)}finally{se(!1)}}}if(t===`list`)return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Service Identities`,subtitle:`Per-service cryptographic access scoping`,actions:e&&(0,D.jsx)(M,{variant:`primary`,onClick:de,children:`+ New identity`})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[s&&(0,D.jsx)(be,{children:s}),r.length===0&&(0,D.jsxs)(`div`,{style:{textAlign:`center`,padding:`48px 24px`,color:v.textMuted,fontFamily:v.sans,fontSize:13},children:[(0,D.jsx)(`div`,{style:{fontSize:28,marginBottom:12,opacity:.4},children:`🔑`}),`No service identities configured.`,e&&(0,D.jsx)(`div`,{style:{marginTop:16},children:(0,D.jsx)(M,{variant:`primary`,onClick:de,children:`Create the first one`})})]}),r.map(e=>(0,D.jsxs)(`div`,{role:`button`,tabIndex:0,"data-testid":`si-${e.name}`,onClick:()=>{o(e.name),c(``),n(`detail`)},onKeyDown:t=>{t.key===`Enter`&&(o(e.name),n(`detail`))},style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`16px 20px`,marginBottom:8,cursor:`pointer`,transition:`all 0.12s`},onMouseEnter:e=>{e.currentTarget.style.borderColor=v.borderLight},onMouseLeave:e=>{e.currentTarget.style.borderColor=v.border},children:[(0,D.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:8},children:(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontWeight:600,fontSize:14,color:v.text},children:e.name})}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:10},children:[`Scoped to: `,(0,D.jsx)(`span`,{style:{color:v.text},children:e.namespaces.join(`, `)})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:Object.entries(e.environments).map(([e,t])=>(0,D.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,D.jsx)(N,{env:e,small:!0}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:9,color:t.type===`kms`?v.purple:v.textDim},children:t.type===`kms`?`KMS`:`age`})]},e))})]},e.name))]})})]});if(t===`detail`)return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:ue?.name??a??``,subtitle:ue?.description,actions:(0,D.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[ue&&(0,D.jsx)(M,{"data-testid":`update-backends-btn`,variant:`ghost`,onClick:()=>fe(ue),children:`Update backends`}),(0,D.jsxs)(`button`,{"data-testid":`back-button`,onClick:pe,style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:6,padding:`4px 12px`,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.textMuted,transition:`all 0.12s`},children:[`←`,` Back`]})]})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[s&&(0,D.jsx)(be,{children:s}),ue&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(ve,{children:`Scoped namespaces`}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:6},children:ue.namespaces.map(e=>(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:11,color:v.accent,background:v.accentDim,border:`1px solid ${v.accent}33`,borderRadius:4,padding:`2px 8px`},children:e},e))})]}),(0,D.jsx)(ve,{children:`Environment keys`}),e?.environments.map(e=>{let t=ue.environments[e.name];if(!t)return null;let n=t.protected??!1,r=ne===e.name;return(0,D.jsxs)(`div`,{"data-testid":`env-${e.name}`,style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`16px 20px`,marginBottom:10},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:12},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,D.jsx)(N,{env:e.name}),n&&(0,D.jsx)(`span`,{style:{fontSize:12,color:v.red},children:`🔒`}),t.type===`kms`&&(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:10,color:v.purple,background:v.purpleDim,border:`1px solid ${v.purple}33`,borderRadius:3,padding:`1px 6px`},children:`KMS`})]}),t.type===`age`&&(0,D.jsx)(`button`,{"data-testid":`rotate-${e.name}`,disabled:r,onClick:()=>_e(e.name),style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:5,padding:`3px 10px`,cursor:r?`default`:`pointer`,fontFamily:v.sans,fontSize:11,color:r?v.textDim:v.textMuted,opacity:r?.5:1},children:r?`Rotating…`:`Rotate key`})]}),t.type===`kms`&&t.kms&&(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted},children:[(0,D.jsxs)(`div`,{style:{marginBottom:8},children:[`Authentication: `,(0,D.jsx)(`span`,{style:{color:v.purple},children:`IAM + KMS`})]}),(0,D.jsxs)(`div`,{children:[`Provider:`,` `,(0,D.jsx)(`span`,{style:{color:v.text},children:t.kms.provider})]}),(0,D.jsxs)(`div`,{style:{marginTop:4},children:[`Key ID:`,` `,(0,D.jsx)(`span`,{style:{color:v.text,wordBreak:`break-all`},children:t.kms.keyId})]}),(0,D.jsx)(`div`,{style:{marginTop:10,padding:`8px 12px`,background:v.purpleDim,border:`1px solid ${v.purple}33`,borderRadius:4,fontSize:11,color:v.purple,fontFamily:v.sans},children:`No keys to provision. CI and runtime authenticate via IAM role with kms:Decrypt permission.`})]}),t.type===`age`&&(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted},children:[(0,D.jsxs)(`div`,{style:{marginBottom:8},children:[`Authentication: `,(0,D.jsx)(`span`,{style:{color:v.green},children:`age key`})]}),(0,D.jsxs)(`div`,{children:[`Public key:`,` `,(0,D.jsx)(`span`,{style:{color:v.text},children:t.publicKey?`${t.publicKey.slice(0,12)}...${t.publicKey.slice(-6)}`:`unknown`})]})]})]},e.name)}),(0,D.jsx)(`div`,{style:{marginTop:32,paddingTop:20,borderTop:`1px solid ${v.border}`,display:`flex`,justifyContent:`flex-end`},children:(0,D.jsx)(M,{"data-testid":`delete-identity-btn`,variant:`danger`,onClick:()=>{le(``),n(`delete-confirm`)},children:`Delete identity`})})]})]})})]});if(t===`delete-confirm`)return(0,D.jsxs)(`div`,{"data-testid":`delete-confirm-view`,style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Delete service identity`,subtitle:`This action cannot be undone`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:560,margin:`0 auto`},children:[ce&&(0,D.jsx)(be,{children:ce}),(0,D.jsxs)(`div`,{style:{background:`#1a0a0a`,border:`1px solid ${v.red}55`,borderRadius:8,padding:`16px 20px`,marginBottom:24,fontFamily:v.sans,fontSize:13,color:v.red},children:[(0,D.jsxs)(`div`,{style:{fontWeight:600,marginBottom:8},children:[`Delete `,(0,D.jsx)(`span`,{style:{fontFamily:v.mono},children:a}),`?`]}),(0,D.jsxs)(`div`,{style:{color:v.textMuted,fontSize:12,lineHeight:1.6},children:[`This will remove the identity from`,` `,(0,D.jsx)(`span`,{style:{fontFamily:v.mono},children:`clef.yaml`}),` and de-register its recipients from all scoped encrypted files. Any runtimes currently using this identity's private key will lose access on the next artifact refresh.`]})]}),(0,D.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,D.jsx)(M,{"data-testid":`cancel-delete-btn`,variant:`ghost`,onClick:me,disabled:oe,children:`Cancel`}),(0,D.jsx)(M,{"data-testid":`confirm-delete-btn`,variant:`danger`,onClick:Se,disabled:oe,children:oe?`Deleting…`:`Delete identity`})]})]})})]});if(t===`rotate-keys`)return(0,D.jsxs)(`div`,{"data-testid":`rotate-keys-view`,style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Key rotated`,subtitle:`New keys for ${a}`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[(0,D.jsxs)(`div`,{style:{background:`#1a1200`,border:`1px solid ${v.yellow}55`,borderRadius:8,padding:`14px 18px`,marginBottom:20,fontFamily:v.sans,fontSize:13,color:v.yellow,display:`flex`,gap:10,alignItems:`flex-start`},children:[(0,D.jsx)(`span`,{style:{fontSize:16,flexShrink:0},children:`⚠`}),(0,D.jsx)(`span`,{children:`Copy the new private key now — it will not be shown again. Provision it to the runtime and invalidate the old key.`})]}),(0,D.jsx)(ve,{children:`New private keys`}),Object.entries(re).map(([e,t])=>(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 18px`,marginBottom:10},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:10},children:[(0,D.jsx)(N,{env:e}),(0,D.jsx)(ie,{text:t})]}),(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,wordBreak:`break-all`,background:v.bg,borderRadius:4,padding:`8px 10px`},children:t})]},e)),(0,D.jsx)(`div`,{style:{marginTop:8,display:`flex`,justifyContent:`flex-end`},children:(0,D.jsx)(M,{"data-testid":`rotate-done-btn`,variant:`primary`,onClick:me,children:`Done`})})]})})]});if(t===`update`){let t=e?.environments??[],n=Object.values(k).filter(e=>e.type===`kms`?e.originalType!==`kms`||e.keyId!==e.originalKeyId:!1).length>0&&Object.entries(k).every(([,e])=>e.type===`kms`?e.keyId.trim()!==``:!0);return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Update backends`,subtitle:`Environment backends for ${a}`,actions:(0,D.jsxs)(`button`,{onClick:me,style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:6,padding:`4px 12px`,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.textMuted},children:[`←`,` Cancel`]})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:560,margin:`0 auto`},children:[ee&&(0,D.jsx)(be,{children:ee}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:16,lineHeight:1.6},children:`Switch age environments to KMS, or update an existing KMS key ID. To revert KMS to age, delete and recreate the identity.`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginBottom:28},children:t.map(e=>{let t=k[e.name];return t?(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 16px`},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:t.type===`kms`?12:0},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,D.jsx)(N,{env:e.name}),e.protected&&(0,D.jsx)(`span`,{style:{fontSize:11,color:v.red},children:`🔒`})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:[`age`,`kms`].map(n=>{let r=t.originalType===`kms`&&n===`age`;return(0,D.jsx)(`button`,{"data-testid":n===`kms`?`update-kms-toggle-${e.name}`:void 0,disabled:r,onClick:()=>{r||j(r=>({...r,[e.name]:{...t,type:n}}))},title:r?`KMS → age requires delete and recreate`:void 0,style:{background:t.type===n?n===`kms`?v.purple:v.accent:`transparent`,border:`1px solid ${t.type===n?n===`kms`?v.purple:v.accent:v.border}`,borderRadius:4,padding:`3px 10px`,cursor:r?`not-allowed`:`pointer`,fontFamily:v.mono,fontSize:11,color:t.type===n?`#fff`:v.textMuted,opacity:r?.4:1,transition:`all 0.1s`},children:n.toUpperCase()},n)})})]}),t.type===`kms`&&(0,D.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,D.jsxs)(`select`,{value:t.provider,onChange:n=>j(r=>({...r,[e.name]:{...t,provider:n.target.value}})),style:{...xe,width:90,flexShrink:0,padding:`7px 8px`},children:[(0,D.jsx)(`option`,{value:`aws`,children:`AWS`}),(0,D.jsx)(`option`,{value:`gcp`,children:`GCP`}),(0,D.jsx)(`option`,{value:`azure`,children:`Azure`})]}),(0,D.jsx)(`input`,{"data-testid":`update-keyid-${e.name}`,value:t.keyId,onChange:n=>j(r=>({...r,[e.name]:{...t,keyId:n.target.value}})),placeholder:`arn:aws:kms:… or key resource ID`,style:{...xe,flex:1}})]})]},e.name):null})}),(0,D.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,D.jsx)(M,{"data-testid":`update-cancel-btn`,variant:`ghost`,onClick:me,disabled:P,children:`Cancel`}),(0,D.jsx)(M,{"data-testid":`update-submit-btn`,variant:`primary`,onClick:ge,disabled:!n||P,children:P?`Saving…`:`Save changes`})]})]})})]})}if(t===`keys`){let e=Object.keys(C).length>0;return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`${E} created`,subtitle:`Service identity ready`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[e&&(0,D.jsxs)(`div`,{style:{background:`#1a1200`,border:`1px solid ${v.yellow}55`,borderRadius:8,padding:`14px 18px`,marginBottom:20,fontFamily:v.sans,fontSize:13,color:v.yellow,display:`flex`,gap:10,alignItems:`flex-start`},children:[(0,D.jsx)(`span`,{style:{fontSize:16,flexShrink:0},children:`⚠`}),(0,D.jsx)(`span`,{children:`Copy these private keys now — they will not be shown again. Store each key securely and provision it to the relevant runtime.`})]}),!e&&(0,D.jsx)(`div`,{style:{background:v.purpleDim,border:`1px solid ${v.purple}44`,borderRadius:8,padding:`14px 18px`,marginBottom:20,fontFamily:v.sans,fontSize:13,color:v.purple},children:`All environments use KMS. No private keys to provision — runtimes authenticate via IAM role.`}),(0,D.jsx)(ve,{children:`Private keys`}),Object.entries(C).map(([e,t])=>(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 18px`,marginBottom:10},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:10},children:[(0,D.jsx)(N,{env:e}),(0,D.jsx)(ie,{text:t})]}),(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,wordBreak:`break-all`,background:v.bg,borderRadius:4,padding:`8px 10px`},children:t})]},e)),(0,D.jsx)(`div`,{style:{marginTop:8,display:`flex`,justifyContent:`flex-end`},children:(0,D.jsx)(M,{variant:`primary`,onClick:()=>{L(),pe()},children:`Done`})})]})})]})}let Ce=e?.namespaces??[],we=e?.environments??[],Te=l.trim()&&r.some(e=>e.name===l.trim())?`A service identity with this name already exists.`:``,Ee=l.trim()!==``&&!Te&&p.size>0&&we.every(e=>{let t=h[e.name];return t?.type===`age`||t?.type===`kms`&&t.provider&&t.keyId.trim()});return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`New service identity`,subtitle:`Scope cryptographic access to specific namespaces`,actions:(0,D.jsxs)(`button`,{onClick:pe,style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:6,padding:`4px 12px`,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.textMuted},children:[`←`,` Cancel`]})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:560,margin:`0 auto`},children:[x&&(0,D.jsx)(be,{children:x}),(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(ye,{children:`Name`}),(0,D.jsx)(`input`,{"data-testid":`si-name-input`,value:l,onChange:e=>u(e.target.value),placeholder:`e.g. api-gateway`,style:xe}),Te&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.red,marginTop:6},children:Te})]}),(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(ye,{children:`Description (optional)`}),(0,D.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`e.g. API gateway service account`,style:xe})]}),(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(ye,{children:`Namespaces`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:10},children:`This identity can decrypt secrets only from the selected namespaces.`}),Ce.length===0&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textDim},children:`No namespaces defined in manifest.`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:Ce.map(e=>{let t=p.has(e.name);return(0,D.jsxs)(`label`,{"data-testid":`ns-checkbox-${e.name}`,style:{display:`flex`,alignItems:`center`,gap:10,padding:`10px 14px`,background:t?v.accentDim:v.surface,border:`1px solid ${t?v.accent+`55`:v.border}`,borderRadius:6,cursor:`pointer`,transition:`all 0.1s`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>{let n=new Set(p);t.target.checked?n.add(e.name):n.delete(e.name),m(n)},style:{accentColor:v.accent}}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:12,color:t?v.accent:v.text},children:e.name}),e.description&&(0,D.jsxs)(`span`,{style:{fontFamily:v.sans,fontSize:11,color:v.textMuted},children:[`— `,e.description]})]},e.name)})})]}),(0,D.jsxs)(`div`,{style:{marginBottom:28},children:[(0,D.jsx)(ye,{children:`Environment backends`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:10},children:`Age generates a key pair per environment. KMS uses your cloud provider — no key material is provisioned.`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:we.map(e=>{let t=h[e.name]??{type:`age`,provider:`aws`,keyId:``};return(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 16px`},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:t.type===`kms`?12:0},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,D.jsx)(N,{env:e.name}),e.protected&&(0,D.jsx)(`span`,{style:{fontSize:11,color:v.red},children:`🔒`})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:[`age`,`kms`].map(n=>(0,D.jsx)(`button`,{onClick:()=>_(r=>({...r,[e.name]:{...t,type:n}})),style:{background:t.type===n?n===`kms`?v.purple:v.accent:`transparent`,border:`1px solid ${t.type===n?n===`kms`?v.purple:v.accent:v.border}`,borderRadius:4,padding:`3px 10px`,cursor:`pointer`,fontFamily:v.mono,fontSize:11,color:t.type===n?`#fff`:v.textMuted,transition:`all 0.1s`},children:n.toUpperCase()},n))})]}),t.type===`kms`&&(0,D.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,D.jsxs)(`select`,{value:t.provider,onChange:n=>_(r=>({...r,[e.name]:{...t,provider:n.target.value}})),style:{...xe,width:90,flexShrink:0,padding:`7px 8px`},children:[(0,D.jsx)(`option`,{value:`aws`,children:`AWS`}),(0,D.jsx)(`option`,{value:`gcp`,children:`GCP`}),(0,D.jsx)(`option`,{value:`azure`,children:`Azure`})]}),(0,D.jsx)(`input`,{value:t.keyId,onChange:n=>_(r=>({...r,[e.name]:{...t,keyId:n.target.value}})),placeholder:`arn:aws:kms:… or key resource ID`,style:{...xe,flex:1}})]})]},e.name)})})]}),(0,D.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:pe,disabled:y,children:`Cancel`}),(0,D.jsx)(M,{"data-testid":`create-si-submit`,variant:`primary`,onClick:he,disabled:!Ee||y,children:y?`Creating…`:`Create identity`})]})]})})]})}function ve({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:6,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function ye({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:6},children:e})}function be({children:e}){return(0,D.jsx)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16,fontFamily:v.sans,fontSize:13,color:v.red},children:e})}var xe={width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.mono,fontSize:12,color:v.text,outline:`none`,boxSizing:`border-box`},Se={age:`age`,awskms:`AWS KMS`,gcpkms:`GCP KMS`,azurekv:`Azure Key Vault`,pgp:`PGP`},Ce={awskms:`arn:aws:kms:region:account:key/id`,gcpkms:`projects/.../locations/.../keyRings/.../cryptoKeys/...`,azurekv:`https://vault-name.vault.azure.net/keys/key-name/version`,pgp:`PGP fingerprint`},we=[`age`,`awskms`,`gcpkms`,`azurekv`,`pgp`];function Te({manifest:e,setView:t,reloadManifest:n}){let[r,i]=(0,g.useState)(1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(`age`),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(`all`),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(null),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null),[E,O]=(0,g.useState)(!1),[k,j]=(0,g.useState)(null);(0,g.useEffect)(()=>{N()},[]),(0,g.useEffect)(()=>{e&&e.environments.length>0&&!p&&m(e.environments[0].name)},[e,p]);let N=async()=>{try{let e=await T(`/api/backend-config`);e.ok&&o(await e.json())}catch{}},P=async(e=!1)=>{O(!0),j(null);let t={target:{backend:s,key:s===`age`?void 0:l},environment:d===`single`?p:void 0,confirmed:e||void 0};try{let e=await T(`/api/migrate-backend/preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(e.status===409){b(!0),O(!1);return}if(!e.ok){j((await e.json()).error??`Preview failed`),O(!1);return}_(await e.json()),b(!1),S(!1),i(2)}catch(e){j(e instanceof Error?e.message:`Preview failed`)}finally{O(!1)}},F=async()=>{i(3),j(null);let e={target:{backend:s,key:s===`age`?void 0:l},environment:d===`single`?p:void 0,confirmed:!0};try{let t=await T(`/api/migrate-backend/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){j((await t.json()).error??`Migration failed`),i(2);return}w(await t.json()),n(),i(4)}catch(e){j(e instanceof Error?e.message:`Migration failed`),i(2)}},ee=()=>{i(1),_(null),w(null),b(!1),S(!1),j(null),N()},te=e?.environments??[],ne=h?.events.filter(e=>e.type===`info`&&e.message.startsWith(`Would`)).length??0;return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Backend`,subtitle:`clef migrate-backend — change encryption backend`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[(0,D.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:0,marginBottom:32},children:[1,2,3,4].map((e,t)=>(0,D.jsxs)(g.Fragment,{children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,D.jsx)(`div`,{style:{width:24,height:24,borderRadius:`50%`,background:r>=e?v.accent:v.surface,border:`1px solid ${r>=e?v.accent:v.border}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontFamily:v.mono,fontSize:11,fontWeight:700,color:r>=e?`#000`:v.textDim},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontSize:12,color:r>=e?v.text:v.textDim,fontWeight:r===e?600:400},children:e===1?`Configure`:e===2?`Preview`:e===3?`Migrate`:`Done`})]}),t<3&&(0,D.jsx)(`div`,{style:{flex:1,height:1,background:r>e?v.accent:v.border,margin:`0 12px`,minWidth:20}})]},e))}),k&&(0,D.jsx)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16,fontFamily:v.sans,fontSize:13,color:v.red},children:k}),r===1&&(0,D.jsxs)(`div`,{children:[a&&(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(Ee,{children:`Current Configuration`}),(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:14},children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.text,marginBottom:8},children:[`Default backend:`,` `,(0,D.jsx)(`span`,{style:{color:v.accent,fontWeight:600},children:Se[a.global.default_backend]})]}),a.environments.map(e=>(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontFamily:v.mono,fontSize:11,color:v.textMuted,marginBottom:2},children:[(0,D.jsxs)(`span`,{children:[e.protected?`🔒 `:``,e.name]}),(0,D.jsx)(`span`,{style:{color:v.textDim},children:`→`}),(0,D.jsxs)(`span`,{style:{color:e.hasOverride?v.yellow:v.textMuted},children:[Se[e.effective.backend],e.hasOverride?` (override)`:``]})]},e.name))]})]}),(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(Ee,{children:`Target Backend`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:we.map(e=>(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:s===e?v.text:v.textMuted},children:[(0,D.jsx)(`input`,{type:`radio`,name:`backend`,value:e,checked:s===e,onChange:()=>{c(e),u(``)},style:{accentColor:v.accent},"data-testid":`backend-radio-${e}`}),Se[e]]},e))})]}),s!==`age`&&(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(Ee,{children:`Key Identifier`}),(0,D.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:Ce[s],"data-testid":`backend-key-input`,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.mono,fontSize:12,color:v.text,outline:`none`,boxSizing:`border-box`}})]}),(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(Ee,{children:`Scope`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:16,marginBottom:8},children:[(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:d===`all`?v.text:v.textMuted},children:[(0,D.jsx)(`input`,{type:`radio`,name:`scope`,checked:d===`all`,onChange:()=>f(`all`),style:{accentColor:v.accent}}),`All environments`]}),(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:d===`single`?v.text:v.textMuted},children:[(0,D.jsx)(`input`,{type:`radio`,name:`scope`,checked:d===`single`,onChange:()=>f(`single`),style:{accentColor:v.accent}}),`Single environment`]})]}),d===`single`&&(0,D.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),"data-testid":`env-select`,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`7px 10px`,fontFamily:v.sans,fontSize:13,color:v.text,outline:`none`,cursor:`pointer`},children:te.map(e=>(0,D.jsxs)(`option`,{value:e.name,children:[e.name,e.protected?` (protected)`:``]},e.name))})]}),y&&(0,D.jsxs)(`div`,{style:{background:v.yellowDim,border:`1px solid ${v.yellow}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.yellow,marginBottom:8},children:`This migration affects protected environments.`}),(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.text},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),style:{accentColor:v.yellow},"data-testid":`protected-confirm`}),`I understand and want to proceed`]})]}),(0,D.jsx)(M,{variant:`primary`,onClick:()=>P(x),disabled:E||s!==`age`&&!l.trim(),children:E?`Loading...`:y&&x?`Confirm & Preview`:`Preview`})]}),r===2&&h&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.textMuted,marginBottom:20},children:[`Migrating to`,` `,(0,D.jsx)(`span`,{style:{color:v.accent,fontWeight:600},children:Se[s]}),d===`single`?` (${p} only)`:` (all environments)`]}),h.events.filter(e=>e.type===`info`).length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(De,{color:v.green,children:[`Files to migrate (`,h.events.filter(e=>e.type===`info`).length,`)`]}),h.events.filter(e=>e.type===`info`).map((e,t)=>(0,D.jsx)(Oe,{icon:`→`,iconColor:v.green,label:e.message},t))]}),h.events.filter(e=>e.type===`skip`).length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(De,{color:v.textDim,children:[`Already on target (`,h.events.filter(e=>e.type===`skip`).length,`)`]}),h.events.filter(e=>e.type===`skip`).map((e,t)=>(0,D.jsx)(Oe,{icon:`↷`,iconColor:v.textDim,label:e.message},t))]}),h.result.warnings.length>0&&(0,D.jsx)(`div`,{style:{marginBottom:16},children:h.result.warnings.map((e,t)=>(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.yellow,marginBottom:4},children:[`⚠`,` `,e]},t))}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:24},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Back`}),(0,D.jsxs)(M,{variant:`primary`,onClick:F,disabled:ne===0,"data-testid":`apply-button`,children:[`Migrate `,ne,` file`,ne===1?``:`s`]})]})]}),r===3&&(0,D.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,paddingTop:40},children:[(0,D.jsx)(`div`,{style:{width:40,height:40,border:`3px solid ${v.border}`,borderTopColor:v.accent,borderRadius:`50%`,animation:`spin 1s linear infinite`,marginBottom:16}}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,color:v.textMuted},children:`Migrating... this may take a moment`}),(0,D.jsx)(`style`,{children:`@keyframes spin { to { transform: rotate(360deg); } }`})]}),r===4&&C&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,paddingTop:20,paddingBottom:32},children:[(0,D.jsx)(`div`,{style:{width:56,height:56,borderRadius:`50%`,background:C.result.rolledBack?v.redDim:v.greenDim,border:`1px solid ${C.result.rolledBack?v.red+`44`:v.green+`44`}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:24,color:C.result.rolledBack?v.red:v.green,marginBottom:16},children:C.result.rolledBack?`⚠`:`✓`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontWeight:600,fontSize:16,color:C.result.rolledBack?v.red:v.green,marginBottom:8},children:C.result.rolledBack?`Migration failed`:`Migration complete`}),C.result.rolledBack&&C.result.error&&(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.red,marginBottom:8,textAlign:`center`},children:C.result.error}),C.result.rolledBack&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:8},children:`All changes have been rolled back.`}),!C.result.rolledBack&&(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[C.result.migratedFiles.length,` migrated,`,` `,C.result.skippedFiles.length,` skipped,`,` `,C.result.verifiedFiles.length,` verified`]})]}),C.result.warnings.length>0&&(0,D.jsx)(`div`,{style:{marginBottom:16},children:C.result.warnings.map((e,t)=>(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.yellow,marginBottom:4},children:[`⚠`,` `,e]},t))}),!C.result.rolledBack&&(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`10px 14px`,marginBottom:24,fontFamily:v.mono,fontSize:11,color:v.textMuted},children:[`git add clef.yaml .sops.yaml secrets/ && git commit -m "chore: migrate backend to`,` `,s,`"`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`primary`,onClick:()=>t(`matrix`),children:`View in Matrix`}),(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Migrate again`})]})]})]})})]})}function Ee({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:8,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function De({children:e,color:t}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,fontWeight:600,color:t,letterSpacing:`0.06em`,textTransform:`uppercase`,marginBottom:8},children:e})}function Oe({icon:e,iconColor:t,label:n}){return(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`5px 10px`,borderRadius:6,marginBottom:3},children:[(0,D.jsx)(`span`,{style:{color:t,fontFamily:v.mono,fontSize:13},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:12,color:v.text},children:n})]})}function ke({manifest:e}){let t=e?.namespaces??[],n=e?.environments??[],[r,i]=(0,g.useState)(t[0]?.name??``),[a,o]=(0,g.useState)(n[0]?.name??``),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null);(0,g.useEffect)(()=>{t.length>0&&!r&&i(t[0].name),n.length>0&&!a&&o(n[0].name)},[t,n,r,a]);let p=(0,g.useCallback)(async()=>{if(!(!r||!a)){u(!0),f(null);try{let e=await T(`/api/git/log/${r}/${a}`);e.ok?c((await e.json()).log):(f((await e.json().catch(()=>({}))).error??`Failed to load history`),c([]))}catch{f(`Network error — could not load history`),c([])}finally{u(!1)}}},[r,a]);return(0,g.useEffect)(()=>{p()},[p]),(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`History`,subtitle:`Commit log per encrypted file`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:12,padding:`16px 24px`,borderBottom:`1px solid ${v.border}`},children:[(0,D.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[`Namespace`,(0,D.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),style:{fontFamily:v.mono,fontSize:12,background:v.surface,color:v.text,border:`1px solid ${v.border}`,borderRadius:4,padding:`3px 8px`},children:t.map(e=>(0,D.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),(0,D.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[`Environment`,(0,D.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),style:{fontFamily:v.mono,fontSize:12,background:v.surface,color:v.text,border:`1px solid ${v.border}`,borderRadius:4,padding:`3px 8px`},children:n.map(e=>(0,D.jsx)(`option`,{value:e.name,children:e.name},e.name))})]})]}),(0,D.jsxs)(`div`,{style:{flex:1,overflow:`auto`,padding:`0 24px 24px`},children:[l&&(0,D.jsx)(`div`,{style:{padding:24,color:v.textMuted,fontFamily:v.mono,fontSize:12},children:`Loading…`}),!l&&d&&(0,D.jsx)(`div`,{style:{padding:24,color:v.red,fontFamily:v.mono,fontSize:12},children:d}),!l&&!d&&s.length===0&&(0,D.jsxs)(`div`,{style:{padding:24,color:v.textMuted,fontFamily:v.mono,fontSize:12},children:[`No commits found for `,r,`/`,a,`.`]}),!l&&!d&&s.length>0&&(0,D.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`,fontFamily:v.mono,fontSize:12,marginTop:16},children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{style:{borderBottom:`1px solid ${v.border}`,color:v.textDim},children:[(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px 6px 0`,fontWeight:600},children:`Hash`}),(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px`,fontWeight:600},children:`Date`}),(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px`,fontWeight:600},children:`Author`}),(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 0`,fontWeight:600},children:`Message`})]})}),(0,D.jsx)(`tbody`,{children:s.map(e=>(0,D.jsxs)(`tr`,{style:{borderBottom:`1px solid ${v.border}22`},children:[(0,D.jsx)(`td`,{style:{padding:`8px 12px 8px 0`,color:v.accent},children:e.hash.slice(0,7)}),(0,D.jsx)(`td`,{style:{padding:`8px 12px`,color:v.textMuted,whiteSpace:`nowrap`},children:new Date(e.date).toLocaleDateString()}),(0,D.jsx)(`td`,{style:{padding:`8px 12px`,color:v.textMuted},children:e.author}),(0,D.jsx)(`td`,{style:{padding:`8px 0`,color:v.text},children:e.message})]},e.hash))})]})]})]})}function Ae(){let[e,t]=(0,g.useState)(`matrix`),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(!0),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(0),[m,h]=(0,g.useState)(0),_=(0,g.useCallback)(async()=>{try{let e=await T(`/api/manifest`);if(e.ok){let t=await e.json();s(t),r(e=>e||(t.namespaces[0]?.name??``))}}catch{}finally{a(!1)}},[]),y=(0,g.useCallback)(async()=>{try{let e=await T(`/api/matrix`);e.ok&&l(await e.json())}catch{}},[]),b=(0,g.useCallback)(async()=>{try{let e=await T(`/api/git/status`);e.ok&&d(await e.json())}catch{}},[]),x=(0,g.useCallback)(async()=>{try{let e=await T(`/api/lint`);e.ok&&p((await e.json()).issues.filter(e=>e.severity===`error`).length)}catch{}},[]),S=(0,g.useCallback)(async()=>{try{let e=await T(`/api/scan/status`);if(e.ok){let t=await e.json();t.lastRun&&h((t.lastRun.matches?.length??0)+(t.lastRun.unencryptedMatrixFiles?.length??0))}}catch{}},[]);return(0,g.useEffect)(()=>{_(),y(),b(),x(),S()},[_,y,b,x,S]),(0,g.useEffect)(()=>{_(),y()},[e,_,y]),i?(0,D.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100vh`,background:v.bg,color:v.textMuted,fontFamily:v.sans},children:(0,D.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,D.jsx)(`div`,{style:{fontSize:24,color:v.accent,marginBottom:12},children:`♪`}),(0,D.jsx)(`div`,{style:{fontSize:13},children:`Loading...`})]})}):(0,D.jsxs)(`div`,{style:{display:`flex`,height:`100vh`,background:v.bg,color:v.text,fontFamily:v.sans,overflow:`hidden`},children:[(0,D.jsx)(O,{activeView:e,setView:t,activeNs:n,setNs:r,manifest:o,matrixStatuses:c,gitStatus:u,lintErrorCount:f,scanIssueCount:m}),(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[e===`matrix`&&(0,D.jsx)(I,{setView:t,setNs:r,manifest:o,matrixStatuses:c}),e===`editor`&&(0,D.jsx)(re,{ns:n,manifest:o,onCommit:async e=>{try{await T(`/api/git/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e})}),await Promise.all([b(),y()])}catch{}}}),e===`diff`&&(0,D.jsx)(oe,{manifest:o}),e===`lint`&&(0,D.jsx)(se,{setView:t,setNs:r}),e===`scan`&&(0,D.jsx)(ce,{}),e===`import`&&(0,D.jsx)(L,{manifest:o,setView:t}),e===`recipients`&&(0,D.jsx)(he,{manifest:o,setView:t}),e===`identities`&&(0,D.jsx)(_e,{manifest:o}),e===`backend`&&(0,D.jsx)(Te,{manifest:o,setView:t,reloadManifest:_}),e===`history`&&(0,D.jsx)(ke,{manifest:o})]})]})}w();var je=document.getElementById(`root`);je&&_.createRoot(je).render((0,D.jsx)(g.StrictMode,{children:(0,D.jsx)(Ae,{})}));
26
+ # Comments are ignored`,rows:12,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:14,fontFamily:v.mono,fontSize:12,color:v.text,resize:`vertical`,outline:`none`,boxSizing:`border-box`}})]}),(0,D.jsx)(`div`,{style:{marginBottom:24,padding:`10px 14px`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,fontFamily:v.sans,fontSize:11,color:v.textMuted,lineHeight:1.5},children:`Values are sent directly to the local Clef server (127.0.0.1) and encrypted immediately. They are never stored in browser memory beyond this session.`}),(0,D.jsx)(M,{variant:`primary`,onClick:O,disabled:b||!c.trim(),children:b?`Previewing...`:`Next: Preview`})]}),n===2&&f&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.textMuted,marginBottom:20},children:[`Importing to`,` `,(0,D.jsxs)(`span`,{style:{color:v.accent,fontWeight:600},children:[i,`/`,o]}),`. `,f.totalKeys,` key`,f.totalKeys===1?``:`s`,` parsed.`]}),f.warnings.length>0&&(0,D.jsx)(`div`,{style:{marginBottom:16},children:f.warnings.map((e,t)=>(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.yellow,marginBottom:4},children:[`⚠ `,e]},t))}),f.wouldImport.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.green,children:[`New keys (`,f.wouldImport.length,`)`]}),f.wouldImport.map(e=>(0,D.jsx)(me,{icon:`\\u2192`,iconColor:v.green,label:e},e))]}),f.wouldSkip.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.yellow,children:[`Already exists (`,f.wouldSkip.length,`) — toggle to overwrite`]}),f.wouldSkip.map(({key:e,reason:t})=>{let n=m.includes(e);return(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`6px 10px`,borderRadius:6,marginBottom:4,background:n?v.yellowDim:`transparent`,border:`1px solid ${n?v.yellow+`44`:v.border}`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>N(e),style:{accentColor:v.yellow},id:`overwrite-${e}`}),(0,D.jsx)(`label`,{htmlFor:`overwrite-${e}`,style:{fontFamily:v.mono,fontSize:12,color:n?v.yellow:v.textMuted,flex:1,cursor:`pointer`},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontSize:11,color:v.textDim},children:t})]},e)})]}),f.wouldImport.length===0&&f.wouldSkip.length===0&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.textMuted,padding:`24px 0`,textAlign:`center`},children:`No importable keys found.`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:24},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:()=>r(1),children:`Back`}),(0,D.jsx)(M,{variant:`primary`,onClick:k,disabled:b||P===0,children:b?`Importing...`:`Import ${P} key${P===1?``:`s`}`})]})]}),n===3&&_&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,paddingTop:20,paddingBottom:32},children:[(0,D.jsx)(`div`,{style:{width:56,height:56,borderRadius:`50%`,background:_.failed.length>0?v.redDim:v.greenDim,border:`1px solid ${_.failed.length>0?v.red+`44`:v.green+`44`}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:24,color:_.failed.length>0?v.red:v.green,marginBottom:16},children:_.failed.length>0?`⚠`:`✓`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontWeight:600,fontSize:16,color:_.failed.length>0?v.yellow:v.green,marginBottom:8},children:_.failed.length>0?`Import completed with errors`:`Import complete`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[_.imported.length,` imported, `,_.skipped.length,` skipped,`,` `,_.failed.length,` failed`]})]}),_.imported.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.green,children:[`Imported (`,_.imported.length,`)`]}),_.imported.map(e=>(0,D.jsx)(me,{icon:`\\u2713`,iconColor:v.green,label:e},e))]}),_.failed.length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(pe,{color:v.red,children:[`Failed (`,_.failed.length,`)`]}),_.failed.map(({key:e,error:t})=>(0,D.jsx)(me,{icon:`\\u2717`,iconColor:v.red,label:e,note:t},e))]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:24},children:[(0,D.jsx)(M,{variant:`primary`,onClick:()=>t(`matrix`),children:`View in Matrix`}),(0,D.jsx)(M,{variant:`ghost`,onClick:j,children:`Import more`})]})]})]})})]})}function ue({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:8,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function de({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,color:v.textDim,marginBottom:4},children:e})}function fe({value:e,onChange:t,children:n}){return(0,D.jsx)(`select`,{value:e,onChange:t,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`7px 10px`,fontFamily:v.sans,fontSize:13,color:v.text,outline:`none`,cursor:`pointer`},children:n})}function pe({children:e,color:t}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,fontWeight:600,color:t,letterSpacing:`0.06em`,textTransform:`uppercase`,marginBottom:8},children:e})}function me({icon:e,iconColor:t,label:n,note:r}){return(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`5px 10px`,borderRadius:6,marginBottom:3},children:[(0,D.jsx)(`span`,{style:{color:t,fontFamily:v.mono,fontSize:13},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:12,color:v.text,flex:1},children:n}),r&&(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontSize:11,color:v.textDim},children:r})]})}function he({manifest:e,setView:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(!1),[_,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(0),[w,E]=(0,g.useState)(!1),[O,k]=(0,g.useState)(null),j=(0,g.useRef)(null),N=(0,g.useCallback)(async()=>{try{let e=await T(`/api/recipients`);if(e.ok){let t=await e.json();r(t.recipients),a(t.totalFiles)}}catch{}},[]);(0,g.useEffect)(()=>{N()},[N]),(0,g.useEffect)(()=>{if(!c.trim()){p(null);return}return j.current&&clearTimeout(j.current),j.current=setTimeout(async()=>{try{let e=await T(`/api/recipients/validate?key=${encodeURIComponent(c.trim())}`);e.ok&&p(await e.json())}catch{}},300),()=>{j.current&&clearTimeout(j.current)}},[c]);let P=async()=>{if(f?.valid){h(!0),y(null);try{let e=await T(`/api/recipients/add`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:c.trim(),label:u.trim()||void 0})});if(!e.ok){y((await e.json()).error??`Failed to add recipient`);return}r((await e.json()).recipients),s(!1),l(``),d(``),p(null)}catch(e){y(e instanceof Error?e.message:`Failed to add recipient`)}finally{h(!1)}}},F=e=>{x(e),C(1),E(!1)},ee=()=>{x(null),C(0),E(!1)},te=async()=>{if(b){h(!0),y(null);try{let e=await T(`/api/recipients/remove`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:b.key})});if(!e.ok){y((await e.json()).error??`Failed to remove recipient`);return}let t=await e.json();r(t.recipients),k({name:b.label??b.preview,targets:t.rotationReminder??[]}),ee()}catch(e){y(e instanceof Error?e.message:`Failed to remove recipient`)}finally{h(!1)}}};return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Recipients`,subtitle:`clef recipients -- manage age encryption keys`,actions:!o&&S===0?(0,D.jsx)(M,{variant:`primary`,onClick:()=>s(!0),children:`+ Add recipient`}):void 0}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[_&&(0,D.jsx)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16,fontFamily:v.sans,fontSize:13,color:v.red},children:_}),O&&(0,D.jsxs)(`div`,{"data-testid":`rotation-banner`,style:{background:v.yellowDim,border:`1px solid ${v.yellow}44`,borderRadius:8,padding:`14px 18px`,marginBottom:20},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,fontWeight:600,color:v.yellow,marginBottom:8},children:`Rotation reminder`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.text,marginBottom:10,lineHeight:1.5},children:[(0,D.jsx)(`strong`,{children:O.name}),` has been removed and files re-encrypted. However, the removed key may still decrypt old versions of these files from git history. Rotate secret values in the following targets to complete revocation:`]}),O.targets.length>0&&(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,marginBottom:12,paddingLeft:12},children:O.targets.map(e=>(0,D.jsx)(`div`,{style:{marginBottom:2},children:e},e))}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`primary`,onClick:()=>t(`matrix`),children:`Go to Matrix to rotate`}),(0,D.jsx)(M,{variant:`ghost`,onClick:()=>k(null),children:`Dismiss`})]})]}),o&&(0,D.jsxs)(`div`,{"data-testid":`add-form`,style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:10,padding:20,marginBottom:24},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,fontWeight:600,color:v.text,marginBottom:16},children:`Add recipient`}),(0,D.jsxs)(`div`,{style:{marginBottom:14},children:[(0,D.jsx)(ge,{children:`Age public key`}),(0,D.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`age1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq`,"data-testid":`add-key-input`,style:{width:`100%`,background:v.bg,border:`1px solid ${f?f.valid?v.green+`66`:v.red+`66`:v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.mono,fontSize:12,color:v.text,outline:`none`,boxSizing:`border-box`}}),f&&!f.valid&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,color:v.red,marginTop:4},children:f.error}),f?.valid&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,color:v.green,marginTop:4},children:`Valid age public key`})]}),(0,D.jsxs)(`div`,{style:{marginBottom:14},children:[(0,D.jsx)(ge,{children:`Label (optional)`}),(0,D.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`e.g. alice@example.com`,"data-testid":`add-label-input`,style:{width:`100%`,background:v.bg,border:`1px solid ${v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.sans,fontSize:13,color:v.text,outline:`none`,boxSizing:`border-box`}})]}),(0,D.jsxs)(`div`,{style:{marginBottom:16,padding:`10px 14px`,background:v.yellowDim,border:`1px solid ${v.yellow}44`,borderRadius:6,fontFamily:v.sans,fontSize:12,color:v.yellow,lineHeight:1.5},children:[`Adding a recipient will re-encrypt `,i,` file`,i===1?``:`s`,`. This may take a moment.`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:()=>{s(!1),l(``),d(``),p(null),y(null)},children:`Cancel`}),(0,D.jsx)(M,{variant:`primary`,onClick:P,disabled:m||!f?.valid,children:m?`Re-encrypting...`:`Add and re-encrypt`})]})]}),S===1&&b&&(0,D.jsxs)(`div`,{"data-testid":`remove-dialog`,style:{background:v.surface,border:`1px solid ${v.red}44`,borderRadius:10,padding:20,marginBottom:24},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,fontWeight:600,color:v.red,marginBottom:12},children:`Remove recipient`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.text,lineHeight:1.6,marginBottom:16},children:[`You are about to remove`,` `,(0,D.jsx)(`strong`,{style:{color:v.accent},children:b.label??b.preview}),` `,`(`,b.preview,`). All `,i,` encrypted file`,i===1?``:`s`,` will be re-encrypted without this key.`]}),(0,D.jsxs)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:6,padding:`12px 14px`,marginBottom:16,fontFamily:v.sans,fontSize:12,color:v.red,lineHeight:1.5},children:[`Re-encryption only removes `,(0,D.jsx)(`em`,{children:`future`}),` access. The removed key can still decrypt old versions from git history. You must rotate all secret values after removal.`]}),(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:v.text,marginBottom:16},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>E(e.target.checked),"data-testid":`acknowledge-checkbox`,style:{accentColor:v.red,marginTop:2}}),`I understand — I will rotate secrets after removal`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Cancel`}),(0,D.jsx)(M,{variant:`danger`,onClick:()=>C(2),disabled:!w,children:`Continue`})]})]}),S===2&&b&&(0,D.jsxs)(`div`,{"data-testid":`remove-confirm-dialog`,style:{background:v.surface,border:`1px solid ${v.red}44`,borderRadius:10,padding:20,marginBottom:24},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,fontWeight:600,color:v.red,marginBottom:12},children:`Confirm removal`}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.text,lineHeight:1.6,marginBottom:16},children:[`This will remove`,` `,(0,D.jsx)(`strong`,{style:{color:v.accent},children:b.label??b.preview}),` `,`and re-encrypt all `,i,` file`,i===1?``:`s`,`. This cannot be undone.`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Cancel`}),(0,D.jsx)(M,{variant:`danger`,onClick:te,disabled:m,children:m?`Re-encrypting...`:`Remove and re-encrypt`})]})]}),n.length===0&&!o&&(0,D.jsx)(`div`,{style:{textAlign:`center`,paddingTop:40,fontFamily:v.sans,fontSize:14,color:v.textMuted},children:`No recipients configured. Add an age public key to get started.`}),n.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,letterSpacing:`0.05em`,textTransform:`uppercase`,marginBottom:10},children:[`Recipients (`,n.length,`)`]}),n.map(e=>(0,D.jsxs)(`div`,{"data-testid":`recipient-row`,style:{display:`flex`,alignItems:`center`,gap:14,padding:`12px 16px`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,marginBottom:8},children:[(0,D.jsx)(`div`,{style:{width:32,height:32,borderRadius:6,background:v.accentDim,border:`1px solid ${v.accent}44`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:14,flexShrink:0},children:`🔑`}),(0,D.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[e.label&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,fontWeight:600,color:v.text,marginBottom:2},children:e.label}),(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.preview})]}),(0,D.jsx)(M,{variant:`ghost`,onClick:()=>F(e),disabled:S!==0||m,children:`Remove`})]},e.key)),(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textDim,marginTop:12},children:[i,` encrypted file`,i===1?``:`s`,` in the matrix`]})]})]})})]})}function ge({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:6,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function _e({manifest:e}){let[t,n]=(0,g.useState)(`list`),[r,i]=(0,g.useState)([]),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(new Set),[h,_]=(0,g.useState)({}),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)({}),[E,O]=(0,g.useState)(``),[k,j]=(0,g.useState)({}),[P,F]=(0,g.useState)(!1),[ee,te]=(0,g.useState)(``),[ne,I]=(0,g.useState)(void 0),[re,ae]=(0,g.useState)({}),[oe,se]=(0,g.useState)(!1),[ce,le]=(0,g.useState)(``),L=(0,g.useCallback)(async()=>{try{let e=await T(`/api/service-identities`);e.ok&&i((await e.json()).identities)}catch{}},[]);(0,g.useEffect)(()=>{L()},[L]);let ue=r.find(e=>e.name===a),de=(0,g.useCallback)(()=>{u(``),f(``),m(new Set);let t={};for(let n of e?.environments??[])t[n.name]={type:`age`,provider:`aws`,keyId:``};_(t),S(``),n(`create`)},[e]),fe=(0,g.useCallback)(e=>{let t={};for(let[n,r]of Object.entries(e.environments)){let e=r.type===`kms`?`kms`:`age`;t[n]={type:e,provider:r.kms?.provider??`aws`,keyId:r.kms?.keyId??``,originalType:e,originalKeyId:r.kms?.keyId??``}}j(t),te(``),n(`update`)},[]),pe=(0,g.useCallback)(()=>{o(null),c(``),n(`list`)},[]),me=(0,g.useCallback)(()=>{c(``),le(``),n(`detail`)},[]);async function he(){b(!0),S(``);try{let e={};for(let[t,n]of Object.entries(h))n.type===`kms`&&(e[t]={provider:n.provider,keyId:n.keyId});let t={name:l.trim(),description:d.trim(),namespaces:Array.from(p)};Object.keys(e).length>0&&(t.kmsEnvConfigs=e);let r=await T(`/api/service-identities`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),i=await r.json();if(!r.ok){S(i.error??`Failed to create service identity.`);return}O(i.identity.name),w(i.privateKeys??{}),n(`keys`)}catch{S(`Network error. Check that the UI server is running.`)}finally{b(!1)}}async function ge(){if(a){F(!0),te(``);try{let e={};for(let[t,n]of Object.entries(k))n.type===`kms`&&(n.originalType!==`kms`||n.keyId!==n.originalKeyId)&&(e[t]={provider:n.provider,keyId:n.keyId});if(Object.keys(e).length===0){te(`No changes to apply.`);return}let t=await T(`/api/service-identities/${encodeURIComponent(a)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kmsEnvConfigs:e})}),n=await t.json();if(!t.ok){te(n.error??`Failed to update service identity.`);return}await L(),me()}catch{te(`Network error. Check that the UI server is running.`)}finally{F(!1)}}}async function _e(e){if(a){I(e),c(``);try{let t=await T(`/api/service-identities/${encodeURIComponent(a)}/rotate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({environment:e})}),r=await t.json();if(!t.ok){c(r.error??`Failed to rotate key.`);return}ae(r.privateKeys??{}),await L(),n(`rotate-keys`)}catch{c(`Network error. Check that the UI server is running.`)}finally{I(void 0)}}}async function Se(){if(a){se(!0),le(``);try{let e=await T(`/api/service-identities/${encodeURIComponent(a)}`,{method:`DELETE`});if(!e.ok){le((await e.json()).error??`Failed to delete service identity.`);return}await L(),pe()}catch{le(`Network error. Check that the UI server is running.`)}finally{se(!1)}}}if(t===`list`)return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Service Identities`,subtitle:`Per-service cryptographic access scoping`,actions:e&&(0,D.jsx)(M,{variant:`primary`,onClick:de,children:`+ New identity`})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[s&&(0,D.jsx)(be,{children:s}),r.length===0&&(0,D.jsxs)(`div`,{style:{textAlign:`center`,padding:`48px 24px`,color:v.textMuted,fontFamily:v.sans,fontSize:13},children:[(0,D.jsx)(`div`,{style:{fontSize:28,marginBottom:12,opacity:.4},children:`🔑`}),`No service identities configured.`,e&&(0,D.jsx)(`div`,{style:{marginTop:16},children:(0,D.jsx)(M,{variant:`primary`,onClick:de,children:`Create the first one`})})]}),r.map(e=>(0,D.jsxs)(`div`,{role:`button`,tabIndex:0,"data-testid":`si-${e.name}`,onClick:()=>{o(e.name),c(``),n(`detail`)},onKeyDown:t=>{t.key===`Enter`&&(o(e.name),n(`detail`))},style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`16px 20px`,marginBottom:8,cursor:`pointer`,transition:`all 0.12s`},onMouseEnter:e=>{e.currentTarget.style.borderColor=v.borderLight},onMouseLeave:e=>{e.currentTarget.style.borderColor=v.border},children:[(0,D.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:8},children:(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontWeight:600,fontSize:14,color:v.text},children:e.name})}),(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:10},children:[`Scoped to: `,(0,D.jsx)(`span`,{style:{color:v.text},children:e.namespaces.join(`, `)})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:Object.entries(e.environments).map(([e,t])=>(0,D.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,D.jsx)(N,{env:e,small:!0}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:9,color:t.type===`kms`?v.purple:v.textDim},children:t.type===`kms`?`KMS`:`age`})]},e))})]},e.name))]})})]});if(t===`detail`)return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:ue?.name??a??``,subtitle:ue?.description,actions:(0,D.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[ue&&(0,D.jsx)(M,{"data-testid":`update-backends-btn`,variant:`ghost`,onClick:()=>fe(ue),children:`Update backends`}),(0,D.jsxs)(`button`,{"data-testid":`back-button`,onClick:pe,style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:6,padding:`4px 12px`,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.textMuted,transition:`all 0.12s`},children:[`←`,` Back`]})]})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[s&&(0,D.jsx)(be,{children:s}),ue&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(ve,{children:`Scoped namespaces`}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:6},children:ue.namespaces.map(e=>(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:11,color:v.accent,background:v.accentDim,border:`1px solid ${v.accent}33`,borderRadius:4,padding:`2px 8px`},children:e},e))})]}),(0,D.jsx)(ve,{children:`Environment keys`}),e?.environments.map(e=>{let t=ue.environments[e.name];if(!t)return null;let n=t.protected??!1,r=ne===e.name;return(0,D.jsxs)(`div`,{"data-testid":`env-${e.name}`,style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`16px 20px`,marginBottom:10},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:12},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,D.jsx)(N,{env:e.name}),n&&(0,D.jsx)(`span`,{style:{fontSize:12,color:v.red},children:`🔒`}),t.type===`kms`&&(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:10,color:v.purple,background:v.purpleDim,border:`1px solid ${v.purple}33`,borderRadius:3,padding:`1px 6px`},children:`KMS`})]}),t.type===`age`&&(0,D.jsx)(`button`,{"data-testid":`rotate-${e.name}`,disabled:r,onClick:()=>_e(e.name),style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:5,padding:`3px 10px`,cursor:r?`default`:`pointer`,fontFamily:v.sans,fontSize:11,color:r?v.textDim:v.textMuted,opacity:r?.5:1},children:r?`Rotating…`:`Rotate key`})]}),t.type===`kms`&&t.kms&&(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted},children:[(0,D.jsxs)(`div`,{style:{marginBottom:8},children:[`Authentication: `,(0,D.jsx)(`span`,{style:{color:v.purple},children:`IAM + KMS`})]}),(0,D.jsxs)(`div`,{children:[`Provider:`,` `,(0,D.jsx)(`span`,{style:{color:v.text},children:t.kms.provider})]}),(0,D.jsxs)(`div`,{style:{marginTop:4},children:[`Key ID:`,` `,(0,D.jsx)(`span`,{style:{color:v.text,wordBreak:`break-all`},children:t.kms.keyId})]}),(0,D.jsx)(`div`,{style:{marginTop:10,padding:`8px 12px`,background:v.purpleDim,border:`1px solid ${v.purple}33`,borderRadius:4,fontSize:11,color:v.purple,fontFamily:v.sans},children:`No keys to provision. CI and runtime authenticate via IAM role with kms:Decrypt permission.`})]}),t.type===`age`&&(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted},children:[(0,D.jsxs)(`div`,{style:{marginBottom:8},children:[`Authentication: `,(0,D.jsx)(`span`,{style:{color:v.green},children:`age key`})]}),(0,D.jsxs)(`div`,{children:[`Public key:`,` `,(0,D.jsx)(`span`,{style:{color:v.text},children:t.publicKey?`${t.publicKey.slice(0,12)}...${t.publicKey.slice(-6)}`:`unknown`})]})]})]},e.name)}),(0,D.jsx)(`div`,{style:{marginTop:32,paddingTop:20,borderTop:`1px solid ${v.border}`,display:`flex`,justifyContent:`flex-end`},children:(0,D.jsx)(M,{"data-testid":`delete-identity-btn`,variant:`danger`,onClick:()=>{le(``),n(`delete-confirm`)},children:`Delete identity`})})]})]})})]});if(t===`delete-confirm`)return(0,D.jsxs)(`div`,{"data-testid":`delete-confirm-view`,style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Delete service identity`,subtitle:`This action cannot be undone`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:560,margin:`0 auto`},children:[ce&&(0,D.jsx)(be,{children:ce}),(0,D.jsxs)(`div`,{style:{background:`#1a0a0a`,border:`1px solid ${v.red}55`,borderRadius:8,padding:`16px 20px`,marginBottom:24,fontFamily:v.sans,fontSize:13,color:v.red},children:[(0,D.jsxs)(`div`,{style:{fontWeight:600,marginBottom:8},children:[`Delete `,(0,D.jsx)(`span`,{style:{fontFamily:v.mono},children:a}),`?`]}),(0,D.jsxs)(`div`,{style:{color:v.textMuted,fontSize:12,lineHeight:1.6},children:[`This will remove the identity from`,` `,(0,D.jsx)(`span`,{style:{fontFamily:v.mono},children:`clef.yaml`}),` and de-register its recipients from all scoped encrypted files. Any runtimes currently using this identity's private key will lose access on the next artifact refresh.`]})]}),(0,D.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,D.jsx)(M,{"data-testid":`cancel-delete-btn`,variant:`ghost`,onClick:me,disabled:oe,children:`Cancel`}),(0,D.jsx)(M,{"data-testid":`confirm-delete-btn`,variant:`danger`,onClick:Se,disabled:oe,children:oe?`Deleting…`:`Delete identity`})]})]})})]});if(t===`rotate-keys`)return(0,D.jsxs)(`div`,{"data-testid":`rotate-keys-view`,style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Key rotated`,subtitle:`New keys for ${a}`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[(0,D.jsxs)(`div`,{style:{background:`#1a1200`,border:`1px solid ${v.yellow}55`,borderRadius:8,padding:`14px 18px`,marginBottom:20,fontFamily:v.sans,fontSize:13,color:v.yellow,display:`flex`,gap:10,alignItems:`flex-start`},children:[(0,D.jsx)(`span`,{style:{fontSize:16,flexShrink:0},children:`⚠`}),(0,D.jsx)(`span`,{children:`Copy the new private key now — it will not be shown again. Provision it to the runtime and invalidate the old key.`})]}),(0,D.jsx)(ve,{children:`New private keys`}),Object.entries(re).map(([e,t])=>(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 18px`,marginBottom:10},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:10},children:[(0,D.jsx)(N,{env:e}),(0,D.jsx)(ie,{text:t})]}),(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,wordBreak:`break-all`,background:v.bg,borderRadius:4,padding:`8px 10px`},children:t})]},e)),(0,D.jsx)(`div`,{style:{marginTop:8,display:`flex`,justifyContent:`flex-end`},children:(0,D.jsx)(M,{"data-testid":`rotate-done-btn`,variant:`primary`,onClick:me,children:`Done`})})]})})]});if(t===`update`){let t=e?.environments??[],n=Object.values(k).filter(e=>e.type===`kms`?e.originalType!==`kms`||e.keyId!==e.originalKeyId:!1).length>0&&Object.entries(k).every(([,e])=>e.type===`kms`?e.keyId.trim()!==``:!0);return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Update backends`,subtitle:`Environment backends for ${a}`,actions:(0,D.jsxs)(`button`,{onClick:me,style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:6,padding:`4px 12px`,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.textMuted},children:[`←`,` Cancel`]})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:560,margin:`0 auto`},children:[ee&&(0,D.jsx)(be,{children:ee}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:16,lineHeight:1.6},children:`Switch age environments to KMS, or update an existing KMS key ID. To revert KMS to age, delete and recreate the identity.`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8,marginBottom:28},children:t.map(e=>{let t=k[e.name];return t?(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 16px`},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:t.type===`kms`?12:0},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,D.jsx)(N,{env:e.name}),e.protected&&(0,D.jsx)(`span`,{style:{fontSize:11,color:v.red},children:`🔒`})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:[`age`,`kms`].map(n=>{let r=t.originalType===`kms`&&n===`age`;return(0,D.jsx)(`button`,{"data-testid":n===`kms`?`update-kms-toggle-${e.name}`:void 0,disabled:r,onClick:()=>{r||j(r=>({...r,[e.name]:{...t,type:n}}))},title:r?`KMS → age requires delete and recreate`:void 0,style:{background:t.type===n?n===`kms`?v.purple:v.accent:`transparent`,border:`1px solid ${t.type===n?n===`kms`?v.purple:v.accent:v.border}`,borderRadius:4,padding:`3px 10px`,cursor:r?`not-allowed`:`pointer`,fontFamily:v.mono,fontSize:11,color:t.type===n?`#fff`:v.textMuted,opacity:r?.4:1,transition:`all 0.1s`},children:n.toUpperCase()},n)})})]}),t.type===`kms`&&(0,D.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,D.jsxs)(`select`,{value:t.provider,onChange:n=>j(r=>({...r,[e.name]:{...t,provider:n.target.value}})),style:{...xe,width:90,flexShrink:0,padding:`7px 8px`},children:[(0,D.jsx)(`option`,{value:`aws`,children:`AWS`}),(0,D.jsx)(`option`,{value:`gcp`,children:`GCP`}),(0,D.jsx)(`option`,{value:`azure`,children:`Azure`})]}),(0,D.jsx)(`input`,{"data-testid":`update-keyid-${e.name}`,value:t.keyId,onChange:n=>j(r=>({...r,[e.name]:{...t,keyId:n.target.value}})),placeholder:`arn:aws:kms:… or key resource ID`,style:{...xe,flex:1}})]})]},e.name):null})}),(0,D.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,D.jsx)(M,{"data-testid":`update-cancel-btn`,variant:`ghost`,onClick:me,disabled:P,children:`Cancel`}),(0,D.jsx)(M,{"data-testid":`update-submit-btn`,variant:`primary`,onClick:ge,disabled:!n||P,children:P?`Saving…`:`Save changes`})]})]})})]})}if(t===`keys`){let e=Object.keys(C).length>0;return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`${E} created`,subtitle:`Service identity ready`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[e&&(0,D.jsxs)(`div`,{style:{background:`#1a1200`,border:`1px solid ${v.yellow}55`,borderRadius:8,padding:`14px 18px`,marginBottom:20,fontFamily:v.sans,fontSize:13,color:v.yellow,display:`flex`,gap:10,alignItems:`flex-start`},children:[(0,D.jsx)(`span`,{style:{fontSize:16,flexShrink:0},children:`⚠`}),(0,D.jsx)(`span`,{children:`Copy these private keys now — they will not be shown again. Store each key securely and provision it to the relevant runtime.`})]}),!e&&(0,D.jsx)(`div`,{style:{background:v.purpleDim,border:`1px solid ${v.purple}44`,borderRadius:8,padding:`14px 18px`,marginBottom:20,fontFamily:v.sans,fontSize:13,color:v.purple},children:`All environments use KMS. No private keys to provision — runtimes authenticate via IAM role.`}),(0,D.jsx)(ve,{children:`Private keys`}),Object.entries(C).map(([e,t])=>(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 18px`,marginBottom:10},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:10},children:[(0,D.jsx)(N,{env:e}),(0,D.jsx)(ie,{text:t})]}),(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.textMuted,wordBreak:`break-all`,background:v.bg,borderRadius:4,padding:`8px 10px`},children:t})]},e)),(0,D.jsx)(`div`,{style:{marginTop:8,display:`flex`,justifyContent:`flex-end`},children:(0,D.jsx)(M,{variant:`primary`,onClick:()=>{L(),pe()},children:`Done`})})]})})]})}let Ce=e?.namespaces??[],we=e?.environments??[],Te=l.trim()&&r.some(e=>e.name===l.trim())?`A service identity with this name already exists.`:``,Ee=l.trim()!==``&&!Te&&p.size>0&&we.every(e=>{let t=h[e.name];return t?.type===`age`||t?.type===`kms`&&t.provider&&t.keyId.trim()});return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`New service identity`,subtitle:`Scope cryptographic access to specific namespaces`,actions:(0,D.jsxs)(`button`,{onClick:pe,style:{background:`none`,border:`1px solid ${v.borderLight}`,borderRadius:6,padding:`4px 12px`,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.textMuted},children:[`←`,` Cancel`]})}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:560,margin:`0 auto`},children:[x&&(0,D.jsx)(be,{children:x}),(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(ye,{children:`Name`}),(0,D.jsx)(`input`,{"data-testid":`si-name-input`,value:l,onChange:e=>u(e.target.value),placeholder:`e.g. api-gateway`,style:xe}),Te&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.red,marginTop:6},children:Te})]}),(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(ye,{children:`Description (optional)`}),(0,D.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`e.g. API gateway service account`,style:xe})]}),(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(ye,{children:`Namespaces`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:10},children:`This identity can decrypt secrets only from the selected namespaces.`}),Ce.length===0&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textDim},children:`No namespaces defined in manifest.`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:Ce.map(e=>{let t=p.has(e.name);return(0,D.jsxs)(`label`,{"data-testid":`ns-checkbox-${e.name}`,style:{display:`flex`,alignItems:`center`,gap:10,padding:`10px 14px`,background:t?v.accentDim:v.surface,border:`1px solid ${t?v.accent+`55`:v.border}`,borderRadius:6,cursor:`pointer`,transition:`all 0.1s`},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>{let n=new Set(p);t.target.checked?n.add(e.name):n.delete(e.name),m(n)},style:{accentColor:v.accent}}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:12,color:t?v.accent:v.text},children:e.name}),e.description&&(0,D.jsxs)(`span`,{style:{fontFamily:v.sans,fontSize:11,color:v.textMuted},children:[`— `,e.description]})]},e.name)})})]}),(0,D.jsxs)(`div`,{style:{marginBottom:28},children:[(0,D.jsx)(ye,{children:`Environment backends`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:10},children:`Age generates a key pair per environment. KMS uses your cloud provider — no key material is provisioned.`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:we.map(e=>{let t=h[e.name]??{type:`age`,provider:`aws`,keyId:``};return(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:`14px 16px`},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:t.type===`kms`?12:0},children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,D.jsx)(N,{env:e.name}),e.protected&&(0,D.jsx)(`span`,{style:{fontSize:11,color:v.red},children:`🔒`})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:[`age`,`kms`].map(n=>(0,D.jsx)(`button`,{onClick:()=>_(r=>({...r,[e.name]:{...t,type:n}})),style:{background:t.type===n?n===`kms`?v.purple:v.accent:`transparent`,border:`1px solid ${t.type===n?n===`kms`?v.purple:v.accent:v.border}`,borderRadius:4,padding:`3px 10px`,cursor:`pointer`,fontFamily:v.mono,fontSize:11,color:t.type===n?`#fff`:v.textMuted,transition:`all 0.1s`},children:n.toUpperCase()},n))})]}),t.type===`kms`&&(0,D.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,D.jsxs)(`select`,{value:t.provider,onChange:n=>_(r=>({...r,[e.name]:{...t,provider:n.target.value}})),style:{...xe,width:90,flexShrink:0,padding:`7px 8px`},children:[(0,D.jsx)(`option`,{value:`aws`,children:`AWS`}),(0,D.jsx)(`option`,{value:`gcp`,children:`GCP`}),(0,D.jsx)(`option`,{value:`azure`,children:`Azure`})]}),(0,D.jsx)(`input`,{value:t.keyId,onChange:n=>_(r=>({...r,[e.name]:{...t,keyId:n.target.value}})),placeholder:`arn:aws:kms:… or key resource ID`,style:{...xe,flex:1}})]})]},e.name)})})]}),(0,D.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:pe,disabled:y,children:`Cancel`}),(0,D.jsx)(M,{"data-testid":`create-si-submit`,variant:`primary`,onClick:he,disabled:!Ee||y,children:y?`Creating…`:`Create identity`})]})]})})]})}function ve({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:6,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function ye({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:6},children:e})}function be({children:e}){return(0,D.jsx)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16,fontFamily:v.sans,fontSize:13,color:v.red},children:e})}var xe={width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.mono,fontSize:12,color:v.text,outline:`none`,boxSizing:`border-box`},Se={age:`age`,awskms:`AWS KMS`,gcpkms:`GCP KMS`,azurekv:`Azure Key Vault`,pgp:`PGP`,cloud:`Clef Cloud`},Ce={awskms:`arn:aws:kms:region:account:key/id`,gcpkms:`projects/.../locations/.../keyRings/.../cryptoKeys/...`,azurekv:`https://vault-name.vault.azure.net/keys/key-name/version`,pgp:`PGP fingerprint`},we=[`age`,`awskms`,`gcpkms`,`azurekv`,`pgp`];function Te({manifest:e,setView:t,reloadManifest:n}){let[r,i]=(0,g.useState)(1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(`age`),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(`all`),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(null),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null),[E,O]=(0,g.useState)(!1),[k,j]=(0,g.useState)(null);(0,g.useEffect)(()=>{N()},[]),(0,g.useEffect)(()=>{e&&e.environments.length>0&&!p&&m(e.environments[0].name)},[e,p]);let N=async()=>{try{let e=await T(`/api/backend-config`);e.ok&&o(await e.json())}catch{}},P=async(e=!1)=>{O(!0),j(null);let t={target:{backend:s,key:s===`age`?void 0:l},environment:d===`single`?p:void 0,confirmed:e||void 0};try{let e=await T(`/api/migrate-backend/preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(e.status===409){b(!0),O(!1);return}if(!e.ok){j((await e.json()).error??`Preview failed`),O(!1);return}_(await e.json()),b(!1),S(!1),i(2)}catch(e){j(e instanceof Error?e.message:`Preview failed`)}finally{O(!1)}},F=async()=>{i(3),j(null);let e={target:{backend:s,key:s===`age`?void 0:l},environment:d===`single`?p:void 0,confirmed:!0};try{let t=await T(`/api/migrate-backend/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){j((await t.json()).error??`Migration failed`),i(2);return}w(await t.json()),n(),i(4)}catch(e){j(e instanceof Error?e.message:`Migration failed`),i(2)}},ee=()=>{i(1),_(null),w(null),b(!1),S(!1),j(null),N()},te=e?.environments??[],ne=h?.events.filter(e=>e.type===`info`&&e.message.startsWith(`Would`)).length??0;return(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`Backend`,subtitle:`clef migrate-backend — change encryption backend`}),(0,D.jsx)(`div`,{style:{flex:1,overflow:`auto`,padding:24},children:(0,D.jsxs)(`div`,{style:{maxWidth:620,margin:`0 auto`},children:[(0,D.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:0,marginBottom:32},children:[1,2,3,4].map((e,t)=>(0,D.jsxs)(g.Fragment,{children:[(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,D.jsx)(`div`,{style:{width:24,height:24,borderRadius:`50%`,background:r>=e?v.accent:v.surface,border:`1px solid ${r>=e?v.accent:v.border}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontFamily:v.mono,fontSize:11,fontWeight:700,color:r>=e?`#000`:v.textDim},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.sans,fontSize:12,color:r>=e?v.text:v.textDim,fontWeight:r===e?600:400},children:e===1?`Configure`:e===2?`Preview`:e===3?`Migrate`:`Done`})]}),t<3&&(0,D.jsx)(`div`,{style:{flex:1,height:1,background:r>e?v.accent:v.border,margin:`0 12px`,minWidth:20}})]},e))}),k&&(0,D.jsx)(`div`,{style:{background:v.redDim,border:`1px solid ${v.red}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16,fontFamily:v.sans,fontSize:13,color:v.red},children:k}),r===1&&(0,D.jsxs)(`div`,{children:[a&&(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(Ee,{children:`Current Configuration`}),(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:8,padding:14},children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.text,marginBottom:8},children:[`Default backend:`,` `,(0,D.jsx)(`span`,{style:{color:v.accent,fontWeight:600},children:Se[a.global.default_backend]})]}),a.environments.map(e=>(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontFamily:v.mono,fontSize:11,color:v.textMuted,marginBottom:2},children:[(0,D.jsxs)(`span`,{children:[e.protected?`🔒 `:``,e.name]}),(0,D.jsx)(`span`,{style:{color:v.textDim},children:`→`}),(0,D.jsxs)(`span`,{style:{color:e.hasOverride?v.yellow:v.textMuted},children:[Se[e.effective.backend],e.hasOverride?` (override)`:``]})]},e.name))]})]}),(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(Ee,{children:`Target Backend`}),(0,D.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:we.map(e=>(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:s===e?v.text:v.textMuted},children:[(0,D.jsx)(`input`,{type:`radio`,name:`backend`,value:e,checked:s===e,onChange:()=>{c(e),u(``)},style:{accentColor:v.accent},"data-testid":`backend-radio-${e}`}),Se[e]]},e))})]}),s!==`age`&&(0,D.jsxs)(`div`,{style:{marginBottom:20},children:[(0,D.jsx)(Ee,{children:`Key Identifier`}),(0,D.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:Ce[s],"data-testid":`backend-key-input`,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`8px 12px`,fontFamily:v.mono,fontSize:12,color:v.text,outline:`none`,boxSizing:`border-box`}})]}),(0,D.jsxs)(`div`,{style:{marginBottom:24},children:[(0,D.jsx)(Ee,{children:`Scope`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:16,marginBottom:8},children:[(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:d===`all`?v.text:v.textMuted},children:[(0,D.jsx)(`input`,{type:`radio`,name:`scope`,checked:d===`all`,onChange:()=>f(`all`),style:{accentColor:v.accent}}),`All environments`]}),(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontFamily:v.sans,fontSize:13,color:d===`single`?v.text:v.textMuted},children:[(0,D.jsx)(`input`,{type:`radio`,name:`scope`,checked:d===`single`,onChange:()=>f(`single`),style:{accentColor:v.accent}}),`Single environment`]})]}),d===`single`&&(0,D.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),"data-testid":`env-select`,style:{width:`100%`,background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`7px 10px`,fontFamily:v.sans,fontSize:13,color:v.text,outline:`none`,cursor:`pointer`},children:te.map(e=>(0,D.jsxs)(`option`,{value:e.name,children:[e.name,e.protected?` (protected)`:``]},e.name))})]}),y&&(0,D.jsxs)(`div`,{style:{background:v.yellowDim,border:`1px solid ${v.yellow}44`,borderRadius:8,padding:`12px 16px`,marginBottom:16},children:[(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.yellow,marginBottom:8},children:`This migration affects protected environments.`}),(0,D.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontFamily:v.sans,fontSize:12,color:v.text},children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),style:{accentColor:v.yellow},"data-testid":`protected-confirm`}),`I understand and want to proceed`]})]}),(0,D.jsx)(M,{variant:`primary`,onClick:()=>P(x),disabled:E||s!==`age`&&!l.trim(),children:E?`Loading...`:y&&x?`Confirm & Preview`:`Preview`})]}),r===2&&h&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{fontFamily:v.sans,fontSize:13,color:v.textMuted,marginBottom:20},children:[`Migrating to`,` `,(0,D.jsx)(`span`,{style:{color:v.accent,fontWeight:600},children:Se[s]}),d===`single`?` (${p} only)`:` (all environments)`]}),h.events.filter(e=>e.type===`info`).length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(De,{color:v.green,children:[`Files to migrate (`,h.events.filter(e=>e.type===`info`).length,`)`]}),h.events.filter(e=>e.type===`info`).map((e,t)=>(0,D.jsx)(Oe,{icon:`→`,iconColor:v.green,label:e.message},t))]}),h.events.filter(e=>e.type===`skip`).length>0&&(0,D.jsxs)(`div`,{style:{marginBottom:16},children:[(0,D.jsxs)(De,{color:v.textDim,children:[`Already on target (`,h.events.filter(e=>e.type===`skip`).length,`)`]}),h.events.filter(e=>e.type===`skip`).map((e,t)=>(0,D.jsx)(Oe,{icon:`↷`,iconColor:v.textDim,label:e.message},t))]}),h.result.warnings.length>0&&(0,D.jsx)(`div`,{style:{marginBottom:16},children:h.result.warnings.map((e,t)=>(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.yellow,marginBottom:4},children:[`⚠`,` `,e]},t))}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10,marginTop:24},children:[(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Back`}),(0,D.jsxs)(M,{variant:`primary`,onClick:F,disabled:ne===0,"data-testid":`apply-button`,children:[`Migrate `,ne,` file`,ne===1?``:`s`]})]})]}),r===3&&(0,D.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,paddingTop:40},children:[(0,D.jsx)(`div`,{style:{width:40,height:40,border:`3px solid ${v.border}`,borderTopColor:v.accent,borderRadius:`50%`,animation:`spin 1s linear infinite`,marginBottom:16}}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:14,color:v.textMuted},children:`Migrating... this may take a moment`}),(0,D.jsx)(`style`,{children:`@keyframes spin { to { transform: rotate(360deg); } }`})]}),r===4&&C&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,paddingTop:20,paddingBottom:32},children:[(0,D.jsx)(`div`,{style:{width:56,height:56,borderRadius:`50%`,background:C.result.rolledBack?v.redDim:v.greenDim,border:`1px solid ${C.result.rolledBack?v.red+`44`:v.green+`44`}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:24,color:C.result.rolledBack?v.red:v.green,marginBottom:16},children:C.result.rolledBack?`⚠`:`✓`}),(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontWeight:600,fontSize:16,color:C.result.rolledBack?v.red:v.green,marginBottom:8},children:C.result.rolledBack?`Migration failed`:`Migration complete`}),C.result.rolledBack&&C.result.error&&(0,D.jsx)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.red,marginBottom:8,textAlign:`center`},children:C.result.error}),C.result.rolledBack&&(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,color:v.textMuted,marginBottom:8},children:`All changes have been rolled back.`}),!C.result.rolledBack&&(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[C.result.migratedFiles.length,` migrated,`,` `,C.result.skippedFiles.length,` skipped,`,` `,C.result.verifiedFiles.length,` verified`]})]}),C.result.warnings.length>0&&(0,D.jsx)(`div`,{style:{marginBottom:16},children:C.result.warnings.map((e,t)=>(0,D.jsxs)(`div`,{style:{fontFamily:v.mono,fontSize:11,color:v.yellow,marginBottom:4},children:[`⚠`,` `,e]},t))}),!C.result.rolledBack&&(0,D.jsxs)(`div`,{style:{background:v.surface,border:`1px solid ${v.border}`,borderRadius:6,padding:`10px 14px`,marginBottom:24,fontFamily:v.mono,fontSize:11,color:v.textMuted},children:[`git add clef.yaml .sops.yaml secrets/ && git commit -m "chore: migrate backend to`,` `,s,`"`]}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:10},children:[(0,D.jsx)(M,{variant:`primary`,onClick:()=>t(`matrix`),children:`View in Matrix`}),(0,D.jsx)(M,{variant:`ghost`,onClick:ee,children:`Migrate again`})]})]})]})})]})}function Ee({children:e}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:12,fontWeight:600,color:v.textMuted,marginBottom:8,letterSpacing:`0.05em`,textTransform:`uppercase`},children:e})}function De({children:e,color:t}){return(0,D.jsx)(`div`,{style:{fontFamily:v.sans,fontSize:11,fontWeight:600,color:t,letterSpacing:`0.06em`,textTransform:`uppercase`,marginBottom:8},children:e})}function Oe({icon:e,iconColor:t,label:n}){return(0,D.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`5px 10px`,borderRadius:6,marginBottom:3},children:[(0,D.jsx)(`span`,{style:{color:t,fontFamily:v.mono,fontSize:13},children:e}),(0,D.jsx)(`span`,{style:{fontFamily:v.mono,fontSize:12,color:v.text},children:n})]})}function ke({manifest:e}){let t=e?.namespaces??[],n=e?.environments??[],[r,i]=(0,g.useState)(t[0]?.name??``),[a,o]=(0,g.useState)(n[0]?.name??``),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null);(0,g.useEffect)(()=>{t.length>0&&!r&&i(t[0].name),n.length>0&&!a&&o(n[0].name)},[t,n,r,a]);let p=(0,g.useCallback)(async()=>{if(!(!r||!a)){u(!0),f(null);try{let e=await T(`/api/git/log/${r}/${a}`);e.ok?c((await e.json()).log):(f((await e.json().catch(()=>({}))).error??`Failed to load history`),c([]))}catch{f(`Network error — could not load history`),c([])}finally{u(!1)}}},[r,a]);return(0,g.useEffect)(()=>{p()},[p]),(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,D.jsx)(A,{title:`History`,subtitle:`Commit log per encrypted file`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:12,padding:`16px 24px`,borderBottom:`1px solid ${v.border}`},children:[(0,D.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[`Namespace`,(0,D.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),style:{fontFamily:v.mono,fontSize:12,background:v.surface,color:v.text,border:`1px solid ${v.border}`,borderRadius:4,padding:`3px 8px`},children:t.map(e=>(0,D.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),(0,D.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,fontFamily:v.mono,fontSize:12,color:v.textMuted},children:[`Environment`,(0,D.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),style:{fontFamily:v.mono,fontSize:12,background:v.surface,color:v.text,border:`1px solid ${v.border}`,borderRadius:4,padding:`3px 8px`},children:n.map(e=>(0,D.jsx)(`option`,{value:e.name,children:e.name},e.name))})]})]}),(0,D.jsxs)(`div`,{style:{flex:1,overflow:`auto`,padding:`0 24px 24px`},children:[l&&(0,D.jsx)(`div`,{style:{padding:24,color:v.textMuted,fontFamily:v.mono,fontSize:12},children:`Loading…`}),!l&&d&&(0,D.jsx)(`div`,{style:{padding:24,color:v.red,fontFamily:v.mono,fontSize:12},children:d}),!l&&!d&&s.length===0&&(0,D.jsxs)(`div`,{style:{padding:24,color:v.textMuted,fontFamily:v.mono,fontSize:12},children:[`No commits found for `,r,`/`,a,`.`]}),!l&&!d&&s.length>0&&(0,D.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`,fontFamily:v.mono,fontSize:12,marginTop:16},children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{style:{borderBottom:`1px solid ${v.border}`,color:v.textDim},children:[(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px 6px 0`,fontWeight:600},children:`Hash`}),(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px`,fontWeight:600},children:`Date`}),(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px`,fontWeight:600},children:`Author`}),(0,D.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 0`,fontWeight:600},children:`Message`})]})}),(0,D.jsx)(`tbody`,{children:s.map(e=>(0,D.jsxs)(`tr`,{style:{borderBottom:`1px solid ${v.border}22`},children:[(0,D.jsx)(`td`,{style:{padding:`8px 12px 8px 0`,color:v.accent},children:e.hash.slice(0,7)}),(0,D.jsx)(`td`,{style:{padding:`8px 12px`,color:v.textMuted,whiteSpace:`nowrap`},children:new Date(e.date).toLocaleDateString()}),(0,D.jsx)(`td`,{style:{padding:`8px 12px`,color:v.textMuted},children:e.author}),(0,D.jsx)(`td`,{style:{padding:`8px 0`,color:v.text},children:e.message})]},e.hash))})]})]})]})}function Ae(){let[e,t]=(0,g.useState)(`matrix`),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(!0),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(0),[m,h]=(0,g.useState)(0),_=(0,g.useCallback)(async()=>{try{let e=await T(`/api/manifest`);if(e.ok){let t=await e.json();s(t),r(e=>e||(t.namespaces[0]?.name??``))}}catch{}finally{a(!1)}},[]),y=(0,g.useCallback)(async()=>{try{let e=await T(`/api/matrix`);e.ok&&l(await e.json())}catch{}},[]),b=(0,g.useCallback)(async()=>{try{let e=await T(`/api/git/status`);e.ok&&d(await e.json())}catch{}},[]),x=(0,g.useCallback)(async()=>{try{let e=await T(`/api/lint`);e.ok&&p((await e.json()).issues.filter(e=>e.severity===`error`).length)}catch{}},[]),S=(0,g.useCallback)(async()=>{try{let e=await T(`/api/scan/status`);if(e.ok){let t=await e.json();t.lastRun&&h((t.lastRun.matches?.length??0)+(t.lastRun.unencryptedMatrixFiles?.length??0))}}catch{}},[]);return(0,g.useEffect)(()=>{_(),y(),b(),x(),S()},[_,y,b,x,S]),(0,g.useEffect)(()=>{_(),y()},[e,_,y]),i?(0,D.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100vh`,background:v.bg,color:v.textMuted,fontFamily:v.sans},children:(0,D.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,D.jsx)(`div`,{style:{fontSize:24,color:v.accent,marginBottom:12},children:`♪`}),(0,D.jsx)(`div`,{style:{fontSize:13},children:`Loading...`})]})}):(0,D.jsxs)(`div`,{style:{display:`flex`,height:`100vh`,background:v.bg,color:v.text,fontFamily:v.sans,overflow:`hidden`},children:[(0,D.jsx)(O,{activeView:e,setView:t,activeNs:n,setNs:r,manifest:o,matrixStatuses:c,gitStatus:u,lintErrorCount:f,scanIssueCount:m}),(0,D.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[e===`matrix`&&(0,D.jsx)(I,{setView:t,setNs:r,manifest:o,matrixStatuses:c}),e===`editor`&&(0,D.jsx)(re,{ns:n,manifest:o,onCommit:async e=>{try{await T(`/api/git/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e})}),await Promise.all([b(),y()])}catch{}}}),e===`diff`&&(0,D.jsx)(oe,{manifest:o}),e===`lint`&&(0,D.jsx)(se,{setView:t,setNs:r}),e===`scan`&&(0,D.jsx)(ce,{}),e===`import`&&(0,D.jsx)(L,{manifest:o,setView:t}),e===`recipients`&&(0,D.jsx)(he,{manifest:o,setView:t}),e===`identities`&&(0,D.jsx)(_e,{manifest:o}),e===`backend`&&(0,D.jsx)(Te,{manifest:o,setView:t,reloadManifest:_}),e===`history`&&(0,D.jsx)(ke,{manifest:o})]})]})}w();var je=document.getElementById(`root`);je&&_.createRoot(je).render((0,D.jsx)(g.StrictMode,{children:(0,D.jsx)(Ae,{})}));
@@ -42,7 +42,7 @@
42
42
  color: #3d4455;
43
43
  }
44
44
  </style>
45
- <script type="module" crossorigin src="/assets/index-BEZELuvA.js"></script>
45
+ <script type="module" crossorigin src="/assets/index-DIdlUkv9.js"></script>
46
46
  </head>
47
47
  <body>
48
48
  <div id="root"></div>