@hot-updater/console 1.0.0-rc.10 → 1.0.0-rc.14

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.
Files changed (83) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/HashValueDisplay-BkarjfEW.js +1 -0
  3. package/.output/public/assets/{api-keys-BgtcYhLe.js → api-keys-GeDujku_.js} +1 -1
  4. package/.output/public/assets/{index-CxpJzE_i.js → index-Cw9mgjav.js} +3 -3
  5. package/.output/public/assets/insights-BjH5onm2.js +1 -0
  6. package/.output/public/assets/{insights-DhR4KTLp.js → insights-cxnK3-N5.js} +2 -2
  7. package/.output/public/assets/{insights-usage-rpc-Ob4s-bZN.js → insights-usage-rpc-D-oeE3q8.js} +1 -1
  8. package/.output/public/assets/{insights_.distribution-C4NYWmQ7.js → insights_.distribution-CCqlg56e.js} +1 -1
  9. package/.output/public/assets/{insights_.distribution-Db-BBoaj.js → insights_.distribution-Crgzlafn.js} +2 -2
  10. package/.output/public/assets/installations-CBMbn6Uo.js +1 -0
  11. package/.output/public/assets/{installations-DnrgOdjn.js → installations-FozyoIFu.js} +2 -2
  12. package/.output/public/assets/{routes-CWiXnn8g.js → routes-BUai8pD_.js} +2 -2
  13. package/.output/public/assets/routes-BczoUy9K.js +1 -0
  14. package/.output/public/assets/{signing-B89So28X.js → signing-DDVww_Hc.js} +1 -1
  15. package/.output/public/assets/styles--R3OJpRa.css +2 -0
  16. package/.output/server/{__23tanstack-start-server-fn-resolver-DDABhh9f.mjs → __23tanstack-start-server-fn-resolver-CWQEQCIx.mjs} +35 -35
  17. package/.output/server/_libs/@tanstack/react-router+[...].mjs +31 -1
  18. package/.output/server/_ssr/{HashValueDisplay-CNyIhgfT.mjs → HashValueDisplay-DazXN2Rs.mjs} +2 -2
  19. package/.output/server/_ssr/{InsightsPageHeader-Dp3LCaut.mjs → InsightsPageHeader-CmHc5ITC.mjs} +4 -4
  20. package/.output/server/_ssr/{api-t38lU_R4.mjs → api-5EZ5CoKH.mjs} +2 -2
  21. package/.output/server/_ssr/{api-keys-api-BBQDjcJQ.mjs → api-keys-api-CCpNe4ZE.mjs} +3 -3
  22. package/.output/server/_ssr/{api-keys-rpc-DIIxk2Tl.mjs → api-keys-rpc-Cub_orJL.mjs} +3 -3
  23. package/.output/server/_ssr/{api-keys-D0sY865c.mjs → api-keys-sAYdJKd8.mjs} +7 -7
  24. package/.output/server/_ssr/{api-rpc-BxBnKmWl.mjs → api-rpc-DawrYMst.mjs} +22 -23
  25. package/.output/server/_ssr/{auth-rpc-CzpN-PAx.mjs → auth-rpc-Cxu9cUQt.mjs} +2 -2
  26. package/.output/server/_ssr/{bundle-signing-rpc-iELMdd_9.mjs → bundle-signing-rpc-CSlOtJFu.mjs} +2 -2
  27. package/.output/server/_ssr/{bundleActivity-pBrPSG01.mjs → bundleActivity-DxYzBdCl.mjs} +2 -2
  28. package/.output/server/_ssr/{card-MXBIE2ub.mjs → card-Bkd7qiBl.mjs} +1 -1
  29. package/.output/server/_ssr/{config.server-BaZOoAvo.mjs → config.server-0Z6FNCgl.mjs} +6 -7
  30. package/.output/server/_ssr/{createSsrRpc-D6Cvyuao.mjs → createSsrRpc-BhVNSGmj.mjs} +2 -2
  31. package/.output/server/_ssr/databaseRows-5bCRTxm-.mjs +45 -2
  32. package/.output/server/_ssr/{dialog-C8PKdqzP.mjs → dialog-jr4rubwt.mjs} +1 -1
  33. package/.output/server/_ssr/{field-DJLaHtqE.mjs → field-DlQk9xy0.mjs} +2 -2
  34. package/.output/server/_ssr/{input-group-CpzkvDzk.mjs → input-group-Dfwqc5As.mjs} +1 -1
  35. package/.output/server/_ssr/{insights-dusvTJIS.mjs → insights-BaCJM3qM.mjs} +257 -229
  36. package/.output/server/_ssr/{insights-CKsYLZjd.mjs → insights-DJ4R9LQh.mjs} +3 -3
  37. package/.output/server/_ssr/{insights-recovery-rpc-DmhNc8oV.mjs → insights-recovery-rpc-CkrXdS-K.mjs} +3 -3
  38. package/.output/server/_ssr/{insights-rpc-RAvOGJCo.mjs → insights-rpc-Df32WQVc.mjs} +2 -2
  39. package/.output/server/_ssr/{insights-usage-rpc-D-Wlepxc.mjs → insights-usage-rpc-BSrTZ06Z.mjs} +2 -2
  40. package/.output/server/_ssr/{insights-usage-rpc-BIfpgQs7.mjs → insights-usage-rpc-CFJKWx-I.mjs} +2 -2
  41. package/.output/server/_ssr/insightsContract-c0M9QrJv.mjs +14 -0
  42. package/.output/server/_ssr/{insightsRecovery-CaghWL2t.mjs → insightsRecovery-CWd6G5cP.mjs} +32 -7
  43. package/.output/server/_ssr/{insightsUsage-DNIj6jxF.mjs → insightsUsage-DqXeKIlf.mjs} +5 -2
  44. package/.output/server/_ssr/{insights_.distribution-Dr1ejjGs.mjs → insights_.distribution-C-9YL0uC.mjs} +9 -9
  45. package/.output/server/_ssr/{insights_.distribution-DJUt6y8m.mjs → insights_.distribution-wPvelHft.mjs} +3 -3
  46. package/.output/server/_ssr/{installations-Cc0roWvR.mjs → installations-B2vJoWK6.mjs} +66 -47
  47. package/.output/server/_ssr/{installations-DTWJCxaK.mjs → installations-FM-5jCVZ.mjs} +3 -3
  48. package/.output/server/_ssr/{router-xxcksRNO.mjs → router-Ri4gCN8f.mjs} +12 -12
  49. package/.output/server/_ssr/{routes-Bgr6OKrf.mjs → routes-5trouIuR.mjs} +70 -65
  50. package/.output/server/_ssr/{routes-C0ddIJvE.mjs → routes-WrRv4idV.mjs} +3 -3
  51. package/.output/server/_ssr/{runtime.server-CsiKFp_Z.mjs → runtime.server-DvTeSEmG.mjs} +46 -25
  52. package/.output/server/_ssr/{select-BJe4U42x.mjs → select-Da1-TC3y.mjs} +1 -1
  53. package/.output/server/_ssr/{server-BzRSMfki.mjs → server-BxsJT1tM.mjs} +4 -4
  54. package/.output/server/_ssr/{signing-CqGFb1dE.mjs → signing-CyNtrSAx.mjs} +3 -3
  55. package/.output/server/_ssr/ssr.mjs +1 -1
  56. package/.output/server/_ssr/{table-SuvYfkKs.mjs → table-C9fL7u-s.mjs} +1 -1
  57. package/.output/server/{_tanstack-start-manifest_v-DppNScGz.mjs → _tanstack-start-manifest_v-BAg_n52B.mjs} +25 -25
  58. package/.output/server/index.mjs +146 -146
  59. package/package.json +7 -7
  60. package/src/components/features/bundles/BundleActivityChart.tsx +13 -3
  61. package/src/components/features/bundles/BundleInsightsSummary.tsx +47 -31
  62. package/src/components/features/insights/EventDetails.tsx +26 -7
  63. package/src/components/features/insights/EventHistoryCard.tsx +5 -0
  64. package/src/components/features/insights/InsightsOverview.tsx +88 -74
  65. package/src/components/features/insights/InstallationHistoryCard.tsx +22 -1
  66. package/src/lib/insights-recovery.ts +6 -0
  67. package/src/lib/insights-view.ts +1 -0
  68. package/src/lib/server/insightsRecovery.ts +62 -7
  69. package/src/lib/server/insightsUsage.ts +8 -3
  70. package/src/routes/-installations-search.ts +12 -0
  71. package/src/routes/installations.tsx +67 -37
  72. package/.output/public/assets/HashValueDisplay-9UC7oXzV.js +0 -1
  73. package/.output/public/assets/insights-TOl16cSC.js +0 -1
  74. package/.output/public/assets/installations-Bn5vpRN7.js +0 -1
  75. package/.output/public/assets/routes-CCnhYSZB.js +0 -1
  76. package/.output/public/assets/styles-DoqiGRqi.css +0 -2
  77. package/.output/server/_ssr/databaseJsonValue-d6I3nAS4.mjs +0 -45
  78. package/.output/server/_ssr/insightsContract-B09K_Px1.mjs +0 -303
  79. /package/.output/public/assets/{api-keys-api-70Cr1Dg1.js → api-keys-api-fTlE9kZ0.js} +0 -0
  80. /package/.output/public/assets/{dialog-BUg5G6nI.js → dialog-BWyxWCS0.js} +0 -0
  81. /package/.output/public/assets/{info-CqaZEAm3.js → info-q-U-lZ4Z.js} +0 -0
  82. /package/.output/public/assets/{loader-circle-v05mmo6I.js → loader-circle-CTeMgMQU.js} +0 -0
  83. /package/.output/public/assets/{refresh-cw-DcqrNjan.js → refresh-cw-vHZshcF5.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "date": "2026-09-08T08:49:38.021Z",
2
+ "date": "2026-09-10T12:02:25.745Z",
3
3
  "preset": "node-server",
4
4
  "framework": {
5
5
  "name": "nitro",
@@ -0,0 +1 @@
1
+ import{Rn as e,_ as t,b as n,fr as r,or as i,v as a}from"./createServerFn-3eh2iYmC.js";import{n as o}from"./dist-pm9AGSU8.js";var s=i(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),c=i(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),l=r(),u=(e,t=12)=>e.length>t?`${e.slice(0,Math.max(1,t-4))}…${e.slice(-4)}`:e;function d({value:r,maxLength:i=12,className:s,buttonClassName:c}){let d=r.length>i,f=u(r,i),p=async()=>{try{await navigator.clipboard.writeText(r),o.success(`Copied to clipboard`,{description:r})}catch{o.error(`Failed to copy value`)}},m=e=>{e.preventDefault(),e.stopPropagation(),p()},h=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),p())},g=(0,l.jsx)(`span`,{translate:`no`,className:e(`font-mono text-xs tabular-nums whitespace-nowrap`,s),children:f});return(0,l.jsxs)(t,{children:[(0,l.jsx)(n,{render:(0,l.jsx)(`button`,{type:`button`,"aria-label":`Copy full value: ${r}`,translate:`no`,className:e(`ring-ring/30 bg-muted/40 border-border/70 inline-flex min-w-0 max-w-full cursor-pointer items-center rounded-md border px-1.5 py-0.5 align-top shadow-xs outline-none transition-[background-color,border-color,transform,box-shadow]`,`hover:bg-muted/70 active:scale-[0.98] active:bg-muted/85 focus-visible:ring-[2px]`,`touch-manipulation select-none motion-reduce:transition-none motion-reduce:active:scale-100`,!d&&`cursor-copy`,c),onClick:m,onKeyDown:h}),children:g}),(0,l.jsx)(a,{hidden:!d,children:(0,l.jsx)(`p`,{translate:`no`,className:`break-all font-mono text-xs tabular-nums`,children:r})})]})}export{s as i,u as n,c as r,d as t};
@@ -1 +1 @@
1
- import{Fn as e,Gr as t,Hr as n,In as r,T as i,ar as a,fr as o,m as s,or as c}from"./createServerFn-3eh2iYmC.js";import{a as l,i as u,n as d,r as f,s as p,t as m}from"./field-Cj65X7Cp.js";import{a as h,i as g,o as _,r as v}from"./api-keys-api-70Cr1Dg1.js";import{t as y}from"./loader-circle-v05mmo6I.js";import{_ as b,a as x,c as S,d as ee,f as te,g as ne,h as C,i as w,l as T,m as E,n as D,o as O,p as k,r as A,t as j,u as M,v as N}from"./dialog-BUg5G6nI.js";import{t as P}from"./refresh-cw-DcqrNjan.js";import{n as F}from"./dist-pm9AGSU8.js";import{a as I,c as L,d as R,l as re,n as z,o as B,s as V,t as H,u as U}from"./card-6aoLhJF_.js";import{a as W,i as G,n as K,o as q,r as J,t as Y}from"./table-Pfo8zTqD.js";var X=c(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),Z=c(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Q=t(n(),1),$=o(),ie=e=>new Date(e).toISOString().slice(0,10);function ae(){let[t,n]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(null),c=g(),h=i.trim(),v=h.length>64?`Name must be 64 characters or fewer.`:null,b=()=>{a(``),s(null),c.reset()},S=e=>{n(e),e||b()};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(r,{onClick:()=>n(!0),children:[(0,$.jsx)(N,{"data-icon":`inline-start`}),`Create API key`]}),(0,$.jsx)(j,{open:t,onOpenChange:S,children:(0,$.jsxs)(D,{showCloseButton:o===null,children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(O,{children:o===null?`Create API key`:`Save your API key`}),(0,$.jsx)(A,{children:o===null?`Name the app or environment that will use this key.`:`This key is shown once. Store it securely before closing.`})]}),o===null?(0,$.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!(h.length===0||v!==null))try{s((await c.mutateAsync(h)).apiKey),F.success(`API key created`)}catch(e){F.error(e instanceof Error?e.message:`Unable to create API key`)}},children:[(0,$.jsx)(u,{children:(0,$.jsxs)(m,{"data-invalid":v!==null||void 0,children:[(0,$.jsx)(l,{htmlFor:`api-key-name`,children:`Name`}),(0,$.jsx)(e,{id:`api-key-name`,autoComplete:`off`,maxLength:65,onChange:e=>a(e.target.value),placeholder:`Production app`,value:i}),(0,$.jsx)(d,{children:`Use a name you can identify before revoking the key.`}),(0,$.jsx)(f,{children:v})]})}),(0,$.jsx)(w,{className:`mt-4`,children:(0,$.jsxs)(r,{disabled:c.isPending||h.length===0||v!==null,type:`submit`,children:[c.isPending?(0,$.jsx)(y,{"data-icon":`inline-start`,className:`animate-spin`}):(0,$.jsx)(_,{"data-icon":`inline-start`}),`Create API key`]})})]}):(0,$.jsxs)(u,{children:[(0,$.jsxs)(m,{children:[(0,$.jsx)(l,{htmlFor:`created-api-key`,children:`API key`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(e,{id:`created-api-key`,className:`font-mono`,readOnly:!0,value:o}),(0,$.jsxs)(r,{onClick:async()=>{if(o!==null)try{await navigator.clipboard.writeText(o),F.success(`API key copied`)}catch{F.error(`Unable to copy API key`)}},type:`button`,variant:`outline`,children:[(0,$.jsx)(X,{"data-icon":`inline-start`}),`Copy`]})]})]}),(0,$.jsx)(w,{children:(0,$.jsxs)(r,{onClick:()=>S(!1),children:[(0,$.jsx)(p,{"data-icon":`inline-start`}),`Done`]})})]})]})})]})}function oe({record:e}){let[t,n]=(0,Q.useState)(!1),i=h(),a=async t=>{t.preventDefault();try{await i.mutateAsync(e.id),n(!1),F.success(`API key revoked`)}catch(e){F.error(e instanceof Error?e.message:`Unable to revoke API key`)}};return(0,$.jsxs)(S,{open:t,onOpenChange:e=>{i.isPending||n(e)},children:[(0,$.jsxs)(b,{render:(0,$.jsx)(r,{size:`sm`,variant:`ghost`}),children:[(0,$.jsx)(Z,{"data-icon":`inline-start`}),`Revoke`]}),(0,$.jsxs)(ee,{children:[(0,$.jsxs)(E,{children:[(0,$.jsx)(C,{children:(0,$.jsx)(Z,{})}),(0,$.jsxs)(ne,{children:[`Revoke `,e.name,`?`]}),(0,$.jsxs)(te,{children:[`Apps using `,e.prefix,`… will immediately lose OTA update and insights access. This action cannot be undone.`]})]}),(0,$.jsxs)(k,{children:[(0,$.jsx)(M,{disabled:i.isPending,children:`Cancel`}),(0,$.jsx)(T,{disabled:i.isPending,onClick:e=>void a(e),variant:`destructive`,children:`Revoke API key`})]})]})]})}function se(){let e=v();return(0,$.jsxs)(H,{className:`overflow-hidden shadow-sm`,children:[(0,$.jsxs)(I,{className:`flex-row items-center justify-between space-y-0 border-b px-4 py-3`,children:[(0,$.jsx)(B,{className:`text-sm`,children:(0,$.jsx)(`h2`,{children:`API keys`})}),(0,$.jsx)(ae,{})]}),(0,$.jsx)(z,{className:`p-0`,children:e.isError?(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsxs)(L,{variant:`destructive`,children:[(0,$.jsx)(a,{}),(0,$.jsx)(R,{children:`API keys couldn't be loaded`}),(0,$.jsx)(U,{children:`Check your connection and try again.`}),(0,$.jsx)(re,{children:(0,$.jsxs)(r,{onClick:()=>void e.refetch(),size:`xs`,variant:`outline`,children:[(0,$.jsx)(P,{"data-icon":`inline-start`}),`Retry`]})})]})}):(0,$.jsxs)(Y,{"aria-label":`API keys`,className:`table-fixed`,children:[(0,$.jsx)(W,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(G,{children:`Key`}),(0,$.jsx)(G,{className:`w-32`,children:`Created`}),(0,$.jsx)(G,{className:`w-24 text-right`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,$.jsx)(K,{children:e.isLoading?Array.from({length:3},(e,t)=>(0,$.jsxs)(q,{children:[(0,$.jsxs)(J,{className:`space-y-2 py-3`,children:[t===0?(0,$.jsx)(`span`,{className:`sr-only`,children:`Loading API keys`}):null,(0,$.jsx)(i,{className:`h-3.5 w-32`}),(0,$.jsx)(i,{className:`h-3 w-20`})]}),(0,$.jsx)(J,{children:(0,$.jsx)(i,{className:`h-3.5 w-20`})}),(0,$.jsx)(J,{children:(0,$.jsx)(i,{className:`ml-auto h-6 w-16`})})]},t)):e.data?.length===0?(0,$.jsx)(q,{children:(0,$.jsx)(J,{colSpan:3,className:`h-40 text-center text-muted-foreground`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-xs flex-col items-center gap-2`,children:[(0,$.jsx)(_,{className:`size-5`}),(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:`No API keys`}),(0,$.jsx)(`p`,{children:`Create an API key to connect an app.`})]})})}):e.data?.map(e=>(0,$.jsxs)(q,{className:e.revoked_at_ms===null?void 0:`text-muted-foreground`,children:[(0,$.jsx)(J,{className:`whitespace-normal py-3`,children:(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsx)(`p`,{className:`break-words font-medium text-foreground`,children:e.name}),(0,$.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[e.prefix,`…`]})]})}),(0,$.jsx)(J,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(`time`,{dateTime:new Date(e.created_at_ms).toISOString(),children:ie(e.created_at_ms)})}),(0,$.jsx)(J,{className:`text-right`,children:e.revoked_at_ms===null?(0,$.jsx)(oe,{record:e}):(0,$.jsx)(V,{variant:`outline`,children:`Revoked`})})]},e.id))})]})})]})}function ce(){return(0,$.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b bg-background px-3 py-3 sm:min-h-12 sm:flex-nowrap sm:bg-card/70 sm:px-4 sm:backdrop-blur-sm`,children:[(0,$.jsx)(s,{className:`-ml-1`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-medium`,children:`API keys`})]}),(0,$.jsx)(`p`,{className:`basis-full pl-9 text-xs text-muted-foreground sm:basis-auto sm:pl-0`,children:`API keys can download OTA updates and submit insights only.`})]}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-5xl`,children:(0,$.jsx)(se,{})})})]})}export{ce as component};
1
+ import{Fn as e,Gr as t,Hr as n,In as r,T as i,ar as a,fr as o,m as s,or as c}from"./createServerFn-3eh2iYmC.js";import{a as l,i as u,n as d,r as f,s as p,t as m}from"./field-Cj65X7Cp.js";import{a as h,i as g,o as _,r as v}from"./api-keys-api-fTlE9kZ0.js";import{t as y}from"./loader-circle-CTeMgMQU.js";import{_ as b,a as x,c as S,d as ee,f as te,g as ne,h as C,i as w,l as T,m as E,n as D,o as O,p as k,r as A,t as j,u as M,v as N}from"./dialog-BWyxWCS0.js";import{t as P}from"./refresh-cw-vHZshcF5.js";import{n as F}from"./dist-pm9AGSU8.js";import{a as I,c as L,d as R,l as re,n as z,o as B,s as V,t as H,u as U}from"./card-6aoLhJF_.js";import{a as W,i as G,n as K,o as q,r as J,t as Y}from"./table-Pfo8zTqD.js";var X=c(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),Z=c(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Q=t(n(),1),$=o(),ie=e=>new Date(e).toISOString().slice(0,10);function ae(){let[t,n]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(null),c=g(),h=i.trim(),v=h.length>64?`Name must be 64 characters or fewer.`:null,b=()=>{a(``),s(null),c.reset()},S=e=>{n(e),e||b()};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(r,{onClick:()=>n(!0),children:[(0,$.jsx)(N,{"data-icon":`inline-start`}),`Create API key`]}),(0,$.jsx)(j,{open:t,onOpenChange:S,children:(0,$.jsxs)(D,{showCloseButton:o===null,children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(O,{children:o===null?`Create API key`:`Save your API key`}),(0,$.jsx)(A,{children:o===null?`Name the app or environment that will use this key.`:`This key is shown once. Store it securely before closing.`})]}),o===null?(0,$.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!(h.length===0||v!==null))try{s((await c.mutateAsync(h)).apiKey),F.success(`API key created`)}catch(e){F.error(e instanceof Error?e.message:`Unable to create API key`)}},children:[(0,$.jsx)(u,{children:(0,$.jsxs)(m,{"data-invalid":v!==null||void 0,children:[(0,$.jsx)(l,{htmlFor:`api-key-name`,children:`Name`}),(0,$.jsx)(e,{id:`api-key-name`,autoComplete:`off`,maxLength:65,onChange:e=>a(e.target.value),placeholder:`Production app`,value:i}),(0,$.jsx)(d,{children:`Use a name you can identify before revoking the key.`}),(0,$.jsx)(f,{children:v})]})}),(0,$.jsx)(w,{className:`mt-4`,children:(0,$.jsxs)(r,{disabled:c.isPending||h.length===0||v!==null,type:`submit`,children:[c.isPending?(0,$.jsx)(y,{"data-icon":`inline-start`,className:`animate-spin`}):(0,$.jsx)(_,{"data-icon":`inline-start`}),`Create API key`]})})]}):(0,$.jsxs)(u,{children:[(0,$.jsxs)(m,{children:[(0,$.jsx)(l,{htmlFor:`created-api-key`,children:`API key`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(e,{id:`created-api-key`,className:`font-mono`,readOnly:!0,value:o}),(0,$.jsxs)(r,{onClick:async()=>{if(o!==null)try{await navigator.clipboard.writeText(o),F.success(`API key copied`)}catch{F.error(`Unable to copy API key`)}},type:`button`,variant:`outline`,children:[(0,$.jsx)(X,{"data-icon":`inline-start`}),`Copy`]})]})]}),(0,$.jsx)(w,{children:(0,$.jsxs)(r,{onClick:()=>S(!1),children:[(0,$.jsx)(p,{"data-icon":`inline-start`}),`Done`]})})]})]})})]})}function oe({record:e}){let[t,n]=(0,Q.useState)(!1),i=h(),a=async t=>{t.preventDefault();try{await i.mutateAsync(e.id),n(!1),F.success(`API key revoked`)}catch(e){F.error(e instanceof Error?e.message:`Unable to revoke API key`)}};return(0,$.jsxs)(S,{open:t,onOpenChange:e=>{i.isPending||n(e)},children:[(0,$.jsxs)(b,{render:(0,$.jsx)(r,{size:`sm`,variant:`ghost`}),children:[(0,$.jsx)(Z,{"data-icon":`inline-start`}),`Revoke`]}),(0,$.jsxs)(ee,{children:[(0,$.jsxs)(E,{children:[(0,$.jsx)(C,{children:(0,$.jsx)(Z,{})}),(0,$.jsxs)(ne,{children:[`Revoke `,e.name,`?`]}),(0,$.jsxs)(te,{children:[`Apps using `,e.prefix,`… will immediately lose OTA update and insights access. This action cannot be undone.`]})]}),(0,$.jsxs)(k,{children:[(0,$.jsx)(M,{disabled:i.isPending,children:`Cancel`}),(0,$.jsx)(T,{disabled:i.isPending,onClick:e=>void a(e),variant:`destructive`,children:`Revoke API key`})]})]})]})}function se(){let e=v();return(0,$.jsxs)(H,{className:`overflow-hidden shadow-sm`,children:[(0,$.jsxs)(I,{className:`flex-row items-center justify-between space-y-0 border-b px-4 py-3`,children:[(0,$.jsx)(B,{className:`text-sm`,children:(0,$.jsx)(`h2`,{children:`API keys`})}),(0,$.jsx)(ae,{})]}),(0,$.jsx)(z,{className:`p-0`,children:e.isError?(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsxs)(L,{variant:`destructive`,children:[(0,$.jsx)(a,{}),(0,$.jsx)(R,{children:`API keys couldn't be loaded`}),(0,$.jsx)(U,{children:`Check your connection and try again.`}),(0,$.jsx)(re,{children:(0,$.jsxs)(r,{onClick:()=>void e.refetch(),size:`xs`,variant:`outline`,children:[(0,$.jsx)(P,{"data-icon":`inline-start`}),`Retry`]})})]})}):(0,$.jsxs)(Y,{"aria-label":`API keys`,className:`table-fixed`,children:[(0,$.jsx)(W,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(G,{children:`Key`}),(0,$.jsx)(G,{className:`w-32`,children:`Created`}),(0,$.jsx)(G,{className:`w-24 text-right`,children:(0,$.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,$.jsx)(K,{children:e.isLoading?Array.from({length:3},(e,t)=>(0,$.jsxs)(q,{children:[(0,$.jsxs)(J,{className:`space-y-2 py-3`,children:[t===0?(0,$.jsx)(`span`,{className:`sr-only`,children:`Loading API keys`}):null,(0,$.jsx)(i,{className:`h-3.5 w-32`}),(0,$.jsx)(i,{className:`h-3 w-20`})]}),(0,$.jsx)(J,{children:(0,$.jsx)(i,{className:`h-3.5 w-20`})}),(0,$.jsx)(J,{children:(0,$.jsx)(i,{className:`ml-auto h-6 w-16`})})]},t)):e.data?.length===0?(0,$.jsx)(q,{children:(0,$.jsx)(J,{colSpan:3,className:`h-40 text-center text-muted-foreground`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-xs flex-col items-center gap-2`,children:[(0,$.jsx)(_,{className:`size-5`}),(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:`No API keys`}),(0,$.jsx)(`p`,{children:`Create an API key to connect an app.`})]})})}):e.data?.map(e=>(0,$.jsxs)(q,{className:e.revoked_at_ms===null?void 0:`text-muted-foreground`,children:[(0,$.jsx)(J,{className:`whitespace-normal py-3`,children:(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsx)(`p`,{className:`break-words font-medium text-foreground`,children:e.name}),(0,$.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[e.prefix,`…`]})]})}),(0,$.jsx)(J,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(`time`,{dateTime:new Date(e.created_at_ms).toISOString(),children:ie(e.created_at_ms)})}),(0,$.jsx)(J,{className:`text-right`,children:e.revoked_at_ms===null?(0,$.jsx)(oe,{record:e}):(0,$.jsx)(V,{variant:`outline`,children:`Revoked`})})]},e.id))})]})})]})}function ce(){return(0,$.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b bg-background px-3 py-3 sm:min-h-12 sm:flex-nowrap sm:bg-card/70 sm:px-4 sm:backdrop-blur-sm`,children:[(0,$.jsx)(s,{className:`-ml-1`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-medium`,children:`API keys`})]}),(0,$.jsx)(`p`,{className:`basis-full pl-9 text-xs text-muted-foreground sm:basis-auto sm:pl-0`,children:`API keys can download OTA updates and submit insights only.`})]}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-5xl`,children:(0,$.jsx)(se,{})})})]})}export{ce as component};