@tapflowio/relay 0.27.0 → 0.27.1

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 (136) hide show
  1. package/dist/RelayServer.d.ts +20 -0
  2. package/dist/RelayServer.d.ts.map +1 -1
  3. package/dist/RelayServer.js +98 -6
  4. package/dist/RelayServer.js.map +1 -1
  5. package/dist/api/builds.d.ts.map +1 -1
  6. package/dist/api/builds.js +13 -8
  7. package/dist/api/builds.js.map +1 -1
  8. package/dist/api/comments.d.ts.map +1 -1
  9. package/dist/api/comments.js +5 -7
  10. package/dist/api/comments.js.map +1 -1
  11. package/dist/api/invitations.d.ts.map +1 -1
  12. package/dist/api/invitations.js +3 -0
  13. package/dist/api/invitations.js.map +1 -1
  14. package/dist/api/profile.d.ts.map +1 -1
  15. package/dist/api/profile.js +28 -9
  16. package/dist/api/profile.js.map +1 -1
  17. package/dist/api/recordings.d.ts.map +1 -1
  18. package/dist/api/recordings.js +5 -6
  19. package/dist/api/recordings.js.map +1 -1
  20. package/dist/api/settings.d.ts.map +1 -1
  21. package/dist/api/settings.js +28 -9
  22. package/dist/api/settings.js.map +1 -1
  23. package/dist/lib/clientAddress.d.ts +12 -0
  24. package/dist/lib/clientAddress.d.ts.map +1 -1
  25. package/dist/lib/clientAddress.js +22 -0
  26. package/dist/lib/clientAddress.js.map +1 -1
  27. package/dist/lib/uploads.d.ts +13 -0
  28. package/dist/lib/uploads.d.ts.map +1 -1
  29. package/dist/lib/uploads.js +41 -0
  30. package/dist/lib/uploads.js.map +1 -1
  31. package/package.json +3 -3
  32. package/public/assets/{AppCenter-BMdYtQbV.js → AppCenter-CeLjUbnR.js} +1 -1
  33. package/public/assets/AppCenter-CeLjUbnR.js.br +0 -0
  34. package/public/assets/AppCenter-CeLjUbnR.js.gz +0 -0
  35. package/public/assets/{Default-0DHHVGaN.js → Default-UB0Pa3lN.js} +1 -1
  36. package/public/assets/Default-UB0Pa3lN.js.br +0 -0
  37. package/public/assets/Default-UB0Pa3lN.js.gz +0 -0
  38. package/public/assets/{Invite-C0ZB_HiU.js → Invite-Dv3omu3x.js} +1 -1
  39. package/public/assets/Invite-Dv3omu3x.js.br +0 -0
  40. package/public/assets/Invite-Dv3omu3x.js.gz +0 -0
  41. package/public/assets/{MacResources-DmY5pRV2.js → MacResources-CY4-OdGt.js} +1 -1
  42. package/public/assets/MacResources-CY4-OdGt.js.br +0 -0
  43. package/public/assets/MacResources-CY4-OdGt.js.gz +0 -0
  44. package/public/assets/QASession-H5eRSwZv.js +150 -0
  45. package/public/assets/QASession-H5eRSwZv.js.br +0 -0
  46. package/public/assets/QASession-H5eRSwZv.js.gz +0 -0
  47. package/public/assets/{ResetPassword-jNRuertx.js → ResetPassword-nFTigYt2.js} +1 -1
  48. package/public/assets/ResetPassword-nFTigYt2.js.br +0 -0
  49. package/public/assets/ResetPassword-nFTigYt2.js.gz +0 -0
  50. package/public/assets/{Setup-CF_FN9Dt.js → Setup-UmLtF2PF.js} +1 -1
  51. package/public/assets/Setup-UmLtF2PF.js.br +0 -0
  52. package/public/assets/Setup-UmLtF2PF.js.gz +0 -0
  53. package/public/assets/{Team-BbiyOGau.js → Team-DW40kt3H.js} +1 -1
  54. package/public/assets/Team-DW40kt3H.js.br +0 -0
  55. package/public/assets/Team-DW40kt3H.js.gz +0 -0
  56. package/public/assets/{Tokens-CZo4sPTx.js → Tokens-B1a4ChJK.js} +1 -1
  57. package/public/assets/Tokens-B1a4ChJK.js.br +0 -0
  58. package/public/assets/Tokens-B1a4ChJK.js.gz +0 -0
  59. package/public/assets/{alert-dialog-DFz8G_zu.js → alert-dialog-aoqYdAwx.js} +1 -1
  60. package/public/assets/alert-dialog-aoqYdAwx.js.br +0 -0
  61. package/public/assets/alert-dialog-aoqYdAwx.js.gz +0 -0
  62. package/public/assets/{badge-B3vaBVIQ.js → badge-DNaS0Mu3.js} +1 -1
  63. package/public/assets/badge-DNaS0Mu3.js.br +0 -0
  64. package/public/assets/badge-DNaS0Mu3.js.gz +0 -0
  65. package/public/assets/{build-format-dbQPU3A4.js → build-format-DF5aFcag.js} +1 -1
  66. package/public/assets/build-format-DF5aFcag.js.br +0 -0
  67. package/public/assets/build-format-DF5aFcag.js.gz +0 -0
  68. package/public/assets/{dialog-DeBPk-I3.js → dialog-DE2WUMuX.js} +1 -1
  69. package/public/assets/dialog-DE2WUMuX.js.br +0 -0
  70. package/public/assets/dialog-DE2WUMuX.js.gz +0 -0
  71. package/public/assets/{field-hint-CMKmbVpy.js → field-hint-Csb40Gzp.js} +1 -1
  72. package/public/assets/field-hint-Csb40Gzp.js.br +2 -0
  73. package/public/assets/field-hint-Csb40Gzp.js.gz +0 -0
  74. package/public/assets/index-BbCkTtjO.css +1 -0
  75. package/public/assets/index-BbCkTtjO.css.br +0 -0
  76. package/public/assets/index-BbCkTtjO.css.gz +0 -0
  77. package/public/assets/{index-B4w4Lh3e.js → index-DSW9h8XX.js} +2 -2
  78. package/public/assets/index-DSW9h8XX.js.br +0 -0
  79. package/public/assets/index-DSW9h8XX.js.gz +0 -0
  80. package/public/assets/{list-view-BvINA5t4.js → list-view-C0w97ltJ.js} +1 -1
  81. package/public/assets/list-view-C0w97ltJ.js.br +0 -0
  82. package/public/assets/list-view-C0w97ltJ.js.gz +0 -0
  83. package/public/assets/{pencil-CycAOoC_.js → pencil-BN18R4oa.js} +1 -1
  84. package/public/assets/pencil-BN18R4oa.js.br +0 -0
  85. package/public/assets/pencil-BN18R4oa.js.gz +0 -0
  86. package/public/assets/{resource-health-C1qSG3MK.js → resource-health-Bi20EUDs.js} +1 -1
  87. package/public/assets/resource-health-Bi20EUDs.js.br +0 -0
  88. package/public/assets/resource-health-Bi20EUDs.js.gz +0 -0
  89. package/public/assets/{trash-BXQnOI5U.js → trash-D1l1Fm-Z.js} +1 -1
  90. package/public/assets/trash-D1l1Fm-Z.js.br +0 -0
  91. package/public/assets/trash-D1l1Fm-Z.js.gz +0 -0
  92. package/public/index.html +2 -2
  93. package/public/index.html.br +0 -0
  94. package/public/index.html.gz +0 -0
  95. package/public/assets/AppCenter-BMdYtQbV.js.br +0 -0
  96. package/public/assets/AppCenter-BMdYtQbV.js.gz +0 -0
  97. package/public/assets/Default-0DHHVGaN.js.br +0 -0
  98. package/public/assets/Default-0DHHVGaN.js.gz +0 -0
  99. package/public/assets/Invite-C0ZB_HiU.js.br +0 -0
  100. package/public/assets/Invite-C0ZB_HiU.js.gz +0 -0
  101. package/public/assets/MacResources-DmY5pRV2.js.br +0 -0
  102. package/public/assets/MacResources-DmY5pRV2.js.gz +0 -0
  103. package/public/assets/QASession-2QogWEX7.js +0 -150
  104. package/public/assets/QASession-2QogWEX7.js.br +0 -0
  105. package/public/assets/QASession-2QogWEX7.js.gz +0 -0
  106. package/public/assets/ResetPassword-jNRuertx.js.br +0 -0
  107. package/public/assets/ResetPassword-jNRuertx.js.gz +0 -0
  108. package/public/assets/Setup-CF_FN9Dt.js.br +0 -0
  109. package/public/assets/Setup-CF_FN9Dt.js.gz +0 -0
  110. package/public/assets/Team-BbiyOGau.js.br +0 -0
  111. package/public/assets/Team-BbiyOGau.js.gz +0 -0
  112. package/public/assets/Tokens-CZo4sPTx.js.br +0 -0
  113. package/public/assets/Tokens-CZo4sPTx.js.gz +0 -0
  114. package/public/assets/alert-dialog-DFz8G_zu.js.br +0 -0
  115. package/public/assets/alert-dialog-DFz8G_zu.js.gz +0 -0
  116. package/public/assets/badge-B3vaBVIQ.js.br +0 -0
  117. package/public/assets/badge-B3vaBVIQ.js.gz +0 -0
  118. package/public/assets/build-format-dbQPU3A4.js.br +0 -0
  119. package/public/assets/build-format-dbQPU3A4.js.gz +0 -0
  120. package/public/assets/dialog-DeBPk-I3.js.br +0 -0
  121. package/public/assets/dialog-DeBPk-I3.js.gz +0 -0
  122. package/public/assets/field-hint-CMKmbVpy.js.br +0 -0
  123. package/public/assets/field-hint-CMKmbVpy.js.gz +0 -0
  124. package/public/assets/index-B4w4Lh3e.js.br +0 -0
  125. package/public/assets/index-B4w4Lh3e.js.gz +0 -0
  126. package/public/assets/index-CDWu0GQL.css +0 -1
  127. package/public/assets/index-CDWu0GQL.css.br +0 -0
  128. package/public/assets/index-CDWu0GQL.css.gz +0 -0
  129. package/public/assets/list-view-BvINA5t4.js.br +0 -0
  130. package/public/assets/list-view-BvINA5t4.js.gz +0 -0
  131. package/public/assets/pencil-CycAOoC_.js.br +0 -0
  132. package/public/assets/pencil-CycAOoC_.js.gz +0 -0
  133. package/public/assets/resource-health-C1qSG3MK.js.br +0 -0
  134. package/public/assets/resource-health-C1qSG3MK.js.gz +0 -0
  135. package/public/assets/trash-BXQnOI5U.js.br +0 -0
  136. package/public/assets/trash-BXQnOI5U.js.gz +0 -0
@@ -11,4 +11,45 @@ export function unlinkSafe(filePath, label) {
11
11
  }
12
12
  }
13
13
  }
14
+ /**
15
+ * Writes an uploaded file to `dest`. Resolves once it is on disk; on a failed upload or write, closes the
16
+ * writer, removes what was written and rejects.
17
+ *
18
+ * `stream.pipe(writer)` does neither: when busboy destroys a file's stream — a body that ends inside the
19
+ * part — the writer stays open and the partial file stays on disk, once per failed upload.
20
+ *
21
+ * The rejection is marked handled here, for the case where nobody awaits it: a failed part also fails the
22
+ * parser, whose `'error'` handler answers the request, and the route's `'finish'` never runs. A failed
23
+ * *write* (a full disk) is different — the parser still finishes and the route awaits a rejection, so every
24
+ * caller catches it.
25
+ */
26
+ export function pipeUpload(stream, dest, label) {
27
+ const writer = fs.createWriteStream(dest);
28
+ const written = new Promise((resolve, reject) => {
29
+ let failed = false;
30
+ const fail = (err) => {
31
+ if (failed)
32
+ return;
33
+ failed = true;
34
+ // Keep reading the upload: a writer error unpipes it, and a part nobody reads holds the parser short
35
+ // of `'finish'`, so the route would never answer.
36
+ stream.resume();
37
+ // Remove the file once the writer has closed it: Windows refuses to delete an open file, and an error
38
+ // before the open completes would otherwise delete nothing and leave the file it then creates.
39
+ const remove = () => { unlinkSafe(dest, label); reject(err); };
40
+ if (writer.closed)
41
+ remove();
42
+ else {
43
+ writer.once('close', remove);
44
+ writer.destroy();
45
+ }
46
+ };
47
+ writer.on('finish', resolve);
48
+ writer.on('error', fail);
49
+ stream.on('error', fail);
50
+ });
51
+ written.catch(() => { });
52
+ stream.pipe(writer);
53
+ return written;
54
+ }
14
55
  //# sourceMappingURL=uploads.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploads.js","sourceRoot":"","sources":["../../src/lib/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,yDAAyD;AACzD,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,KAAa;IACxD,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC,8BAA8B,KAAK,EAAE,EAAG,GAAa,CAAC,OAAO,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"uploads.js","sourceRoot":"","sources":["../../src/lib/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,yDAAyD;AACzD,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,KAAa;IACxD,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC,8BAA8B,KAAK,EAAE,EAAG,GAAa,CAAC,OAAO,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,MAA6B,EAAE,IAAY,EAAE,KAAa;IACnF,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpD,IAAI,MAAM,GAAG,KAAK,CAAA;QAClB,MAAM,IAAI,GAAG,CAAC,GAAY,EAAE,EAAE;YAC5B,IAAI,MAAM;gBAAE,OAAM;YAClB,MAAM,GAAG,IAAI,CAAA;YACb,qGAAqG;YACrG,kDAAkD;YAClD,MAAM,CAAC,MAAM,EAAE,CAAA;YACf,sGAAsG;YACtG,+FAA+F;YAC/F,MAAM,MAAM,GAAG,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC,CAAA;YAC7D,IAAI,MAAM,CAAC,MAAM;gBAAE,MAAM,EAAE,CAAA;iBACtB,CAAC;gBAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YAAC,CAAC;QACzD,CAAC,CAAA;QACD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAC5B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACxB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1B,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACvB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnB,OAAO,OAAO,CAAA;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapflowio/relay",
3
- "version": "0.27.0",
3
+ "version": "0.27.1",
4
4
  "description": "WebSocket relay server for tapflow — NAT traversal, session routing, JWT auth, bundled dashboard",
5
5
  "keywords": [
6
6
  "tapflow",
@@ -52,8 +52,8 @@
52
52
  "nodemailer": "^10.0.11",
53
53
  "ws": "^8.22.0",
54
54
  "zod": "^4.6.5",
55
- "@tapflowio/agent-core": "0.27.0",
56
- "@tapflowio/protocol": "0.27.0"
55
+ "@tapflowio/agent-core": "0.27.1",
56
+ "@tapflowio/protocol": "0.27.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/better-sqlite3": "^7.6.13",
@@ -1,4 +1,4 @@
1
- var Ue=l=>{throw TypeError(l)};var Oe=(l,e,s)=>e.has(l)||Ue("Cannot "+s);var C=(l,e,s)=>(Oe(l,e,"read from private field"),s?s.call(l):e.get(l)),fe=(l,e,s)=>e.has(l)?Ue("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,s),me=(l,e,s,a)=>(Oe(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),he=(l,e,s)=>(Oe(l,e,"access private method"),s);import{k as c,f as pe,j as t}from"./vendor-react-BlPSzrEe.js";import{J as xt,ax as gt,ap as Ve,ah as bt,at as et,aO as tt,as as jt,ay as yt,a6 as ve,aA as W,B as re,L as ye,a0 as vt,I as He,F as St,a2 as Nt,S as wt,N as Dt,T as Ct,O as kt,K as _t,f as At,aD as It,aN as Je,ao as Ot,$ as Et,aw as Rt,aC as Ft,r as Tt,av as $t,ac as Mt,ar as Pt,af as Bt}from"./index-B4w4Lh3e.js";import{f as zt,d as Fe,S as Lt,P as qt,b as Kt,e as Qt}from"./build-format-dbQPU3A4.js";import{f as st,d as at,e as lt,i as Ce,j as ke,g as _e,h as F,S as Ae,a as nt,D as rt,C as Ut}from"./dialog-DeBPk-I3.js";import{P as Vt,T as Ht}from"./trash-BXQnOI5U.js";import{B as Ee}from"./badge-B3vaBVIQ.js";import{f as Jt,g as Wt,d as Gt,b as Xt,c as Yt,e as Zt,a as es,A as ts}from"./alert-dialog-DFz8G_zu.js";import{u as ss}from"./useFocusAfterSwap-BY3N9f9v.js";import{b as as,c as ls}from"./vendor-router-B_lVHrKl.js";var le,de,M,ne,se,je,Te,Ze,ns=(Ze=class extends xt{constructor(e,s){super();fe(this,se);fe(this,le);fe(this,de);fe(this,M);fe(this,ne);me(this,le,e),this.setOptions(s),this.bindMethods(),he(this,se,je).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var a;const s=this.options;this.options=C(this,le).defaultMutationOptions(e),gt(this.options,s)||C(this,le).getMutationCache().notify({type:"observerOptionsUpdated",mutation:C(this,M),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Ve(s.mutationKey)!==Ve(this.options.mutationKey)?this.reset():((a=C(this,M))==null?void 0:a.state.status)==="pending"&&C(this,M).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&C(this,M)&&(C(this,M).addObserver(this),he(this,se,je).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=C(this,M))==null||e.removeObserver(this)}onMutationUpdate(e){he(this,se,je).call(this),he(this,se,Te).call(this,e)}getCurrentResult(){return C(this,de)}reset(){var e;(e=C(this,M))==null||e.removeObserver(this),me(this,M,void 0),he(this,se,je).call(this),he(this,se,Te).call(this)}mutate(e,s){var a;return me(this,ne,s),(a=C(this,M))==null||a.removeObserver(this),me(this,M,C(this,le).getMutationCache().build(C(this,le),this.options)),C(this,M).addObserver(this),C(this,M).execute(e)}},le=new WeakMap,de=new WeakMap,M=new WeakMap,ne=new WeakMap,se=new WeakSet,je=function(){var s;const e=((s=C(this,M))==null?void 0:s.state)??bt();me(this,de,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Te=function(e){et.batch(()=>{var s,a,i,u,f,j,b,m;if(C(this,ne)&&this.hasListeners()){const d=C(this,de).variables,y=C(this,de).context,p={client:C(this,le),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(a=(s=C(this,ne)).onSuccess)==null||a.call(s,e.data,d,y,p)}catch(r){Promise.reject(r)}try{(u=(i=C(this,ne)).onSettled)==null||u.call(i,e.data,null,d,y,p)}catch(r){Promise.reject(r)}}else if((e==null?void 0:e.type)==="error"){try{(j=(f=C(this,ne)).onError)==null||j.call(f,e.error,d,y,p)}catch(r){Promise.reject(r)}try{(m=(b=C(this,ne)).onSettled)==null||m.call(b,void 0,e.error,d,y,p)}catch(r){Promise.reject(r)}}}this.listeners.forEach(d=>{d(C(this,de))})})},Ze);function Re(l,e){const s=tt(),[a]=c.useState(()=>new ns(s,l));c.useEffect(()=>{a.setOptions(l)},[a,l]);const i=c.useSyncExternalStore(c.useCallback(f=>a.subscribe(et.batchCalls(f)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),u=c.useCallback((...f)=>{a.mutate(f[0],f[1]).catch(jt)},[a]);if(i.error&&yt(a.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:u,mutateAsync:i.mutate}}/**
1
+ var Ue=l=>{throw TypeError(l)};var Oe=(l,e,s)=>e.has(l)||Ue("Cannot "+s);var C=(l,e,s)=>(Oe(l,e,"read from private field"),s?s.call(l):e.get(l)),fe=(l,e,s)=>e.has(l)?Ue("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,s),me=(l,e,s,a)=>(Oe(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),he=(l,e,s)=>(Oe(l,e,"access private method"),s);import{k as c,f as pe,j as t}from"./vendor-react-BlPSzrEe.js";import{J as xt,ax as gt,ap as Ve,ah as bt,at as et,aO as tt,as as jt,ay as yt,a6 as ve,aA as W,B as re,L as ye,a0 as vt,I as He,F as St,a2 as Nt,S as wt,N as Dt,T as Ct,O as kt,K as _t,f as At,aD as It,aN as Je,ao as Ot,$ as Et,aw as Rt,aC as Ft,r as Tt,av as $t,ac as Mt,ar as Pt,af as Bt}from"./index-DSW9h8XX.js";import{f as zt,d as Fe,S as Lt,P as qt,b as Kt,e as Qt}from"./build-format-DF5aFcag.js";import{f as st,d as at,e as lt,i as Ce,j as ke,g as _e,h as F,S as Ae,a as nt,D as rt,C as Ut}from"./dialog-DE2WUMuX.js";import{P as Vt,T as Ht}from"./trash-D1l1Fm-Z.js";import{B as Ee}from"./badge-DNaS0Mu3.js";import{f as Jt,g as Wt,d as Gt,b as Xt,c as Yt,e as Zt,a as es,A as ts}from"./alert-dialog-aoqYdAwx.js";import{u as ss}from"./useFocusAfterSwap-BY3N9f9v.js";import{b as as,c as ls}from"./vendor-router-B_lVHrKl.js";var le,de,M,ne,se,je,Te,Ze,ns=(Ze=class extends xt{constructor(e,s){super();fe(this,se);fe(this,le);fe(this,de);fe(this,M);fe(this,ne);me(this,le,e),this.setOptions(s),this.bindMethods(),he(this,se,je).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var a;const s=this.options;this.options=C(this,le).defaultMutationOptions(e),gt(this.options,s)||C(this,le).getMutationCache().notify({type:"observerOptionsUpdated",mutation:C(this,M),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Ve(s.mutationKey)!==Ve(this.options.mutationKey)?this.reset():((a=C(this,M))==null?void 0:a.state.status)==="pending"&&C(this,M).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&C(this,M)&&(C(this,M).addObserver(this),he(this,se,je).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=C(this,M))==null||e.removeObserver(this)}onMutationUpdate(e){he(this,se,je).call(this),he(this,se,Te).call(this,e)}getCurrentResult(){return C(this,de)}reset(){var e;(e=C(this,M))==null||e.removeObserver(this),me(this,M,void 0),he(this,se,je).call(this),he(this,se,Te).call(this)}mutate(e,s){var a;return me(this,ne,s),(a=C(this,M))==null||a.removeObserver(this),me(this,M,C(this,le).getMutationCache().build(C(this,le),this.options)),C(this,M).addObserver(this),C(this,M).execute(e)}},le=new WeakMap,de=new WeakMap,M=new WeakMap,ne=new WeakMap,se=new WeakSet,je=function(){var s;const e=((s=C(this,M))==null?void 0:s.state)??bt();me(this,de,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Te=function(e){et.batch(()=>{var s,a,i,u,f,j,b,m;if(C(this,ne)&&this.hasListeners()){const d=C(this,de).variables,y=C(this,de).context,p={client:C(this,le),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(a=(s=C(this,ne)).onSuccess)==null||a.call(s,e.data,d,y,p)}catch(r){Promise.reject(r)}try{(u=(i=C(this,ne)).onSettled)==null||u.call(i,e.data,null,d,y,p)}catch(r){Promise.reject(r)}}else if((e==null?void 0:e.type)==="error"){try{(j=(f=C(this,ne)).onError)==null||j.call(f,e.error,d,y,p)}catch(r){Promise.reject(r)}try{(m=(b=C(this,ne)).onSettled)==null||m.call(b,void 0,e.error,d,y,p)}catch(r){Promise.reject(r)}}}this.listeners.forEach(d=>{d(C(this,de))})})},Ze);function Re(l,e){const s=tt(),[a]=c.useState(()=>new ns(s,l));c.useEffect(()=>{a.setOptions(l)},[a,l]);const i=c.useSyncExternalStore(c.useCallback(f=>a.subscribe(et.batchCalls(f)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),u=c.useCallback((...f)=>{a.mutate(f[0],f[1]).catch(jt)},[a]);if(i.error&&yt(a.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:u,mutateAsync:i.mutate}}/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{k as m,j as e}from"./vendor-react-BlPSzrEe.js";import{aT as me,aD as ue,aO as pe,aN as G,aK as A,aB as F,aQ as fe,C as y,c as b,d as S,a as N,L as c,I as u,F as p,S as Y,h as Z,aA as i,B as h,s as k,W as he,ab as ge,P as xe,a0 as je,Z as we,av as f,au as D,Q as I,az as g,v as ve,w as ye,al as be,ac as Se}from"./index-B4w4Lh3e.js";import{F as Ne}from"./field-hint-CMKmbVpy.js";import{B as Pe}from"./badge-B3vaBVIQ.js";import{A as Ce,h as Ae,c as Fe,f as ke,g as De,d as Te,e as qe,b as Ee,a as Oe}from"./alert-dialog-DFz8G_zu.js";import{P as X}from"./pencil-CycAOoC_.js";import"./vendor-router-B_lVHrKl.js";const _e=D({teamName:g().min(1,"Team name is required"),logo:I(File).nullable().optional()}),Qe=D({displayName:g().min(1,"Display name is required"),avatar:I(File).nullable().optional()}),Re=D({currentPassword:g().min(1,"Enter your current password"),newPassword:g().min(ve,ye),confirmPassword:g()}).refine(x=>x.newPassword===x.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function Ve(){var W,K,U,M,V,$,J;const{resolvedTheme:x}=me(),ee=x==="dark"?"/logo-dark.svg":"/logo.svg",{user:o}=ue(),T=(o==null?void 0:o.role)==="Admin",q=(o==null?void 0:o.role)==="Admin"||(o==null?void 0:o.role)==="Developer"||(o==null?void 0:o.role)==="QA",j=pe(),P=G({queryKey:f.settings,queryFn:be,enabled:T}),[re,se]=m.useState(null),ae=re??((W=P.data)==null?void 0:W.logo_url)??null,E=m.useRef(null),d=A({shouldFocusError:!1,resolver:F(_e),defaultValues:{teamName:"",logo:null},values:P.data?{teamName:P.data.team_name,logo:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function te(r){const s=new FormData;s.append("team_name",r.teamName),r.logo&&s.append("logo",r.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:s})).ok){i.error("Failed to update workspace");return}i.success("Workspace updated"),j.invalidateQueries({queryKey:f.settings})}catch{i.error("Failed to update workspace")}}const[oe,ie]=m.useState(null),O=oe??(o==null?void 0:o.avatarUrl)??null,_=m.useRef(null),n=A({shouldFocusError:!1,resolver:F(Qe),defaultValues:{displayName:"",avatar:null},values:o?{displayName:o.displayName??"",avatar:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ne(r){const s=new FormData;s.append("display_name",r.displayName),r.avatar&&s.append("avatar",r.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:s})).ok){i.error("Failed to update profile");return}i.success("Profile updated"),j.invalidateQueries({queryKey:f.me})}catch{i.error("Failed to update profile")}}const t=A({shouldFocusError:!1,resolver:F(Re)});async function le(r){try{const s=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:r.currentPassword,newPassword:r.newPassword})});if(!s.ok){const a=await s.json();t.setError("root",{message:a.error??"Failed to change password"});return}t.reset(),i.success("Password changed")}catch{t.setError("root",{message:"Network error"})}}const C=G({queryKey:f.apps,queryFn:Se,enabled:q}).data??[],[Q,R]=m.useState({}),[L,z]=m.useState({}),[B,H]=m.useState({});async function de(r){H(s=>({...s,[r]:!0}));try{if(!(await fetch(`/api/v1/apps/${r}`,{method:"DELETE",credentials:"include"})).ok){i.error("Failed to delete app");return}j.invalidateQueries({queryKey:f.apps}),i.success("App deleted")}catch{i.error("Failed to delete app")}finally{H(s=>({...s,[r]:!1}))}}async function ce(r){var s;z(a=>({...a,[r]:!0}));try{if(!(await fetch(`/api/v1/apps/${r}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Q[r]??((s=C.find(l=>l.id===r))==null?void 0:s.name)})})).ok){i.error("Failed to update app");return}i.success("App updated"),R(({[r]:l,...v})=>v),j.invalidateQueries({queryKey:f.apps})}catch{i.error("Failed to update app")}finally{z(a=>({...a,[r]:!1}))}}const w=fe({control:n.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),T&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Workspace"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:d.handleSubmit(te),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team","aria-required":"true","aria-invalid":!!d.formState.errors.teamName,"aria-describedby":d.formState.errors.teamName?"teamName-error":void 0,...d.register("teamName")}),e.jsx(p,{id:"teamName-error",message:(K=d.formState.errors.teamName)==null?void 0:K.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(Z,{name:"logo",control:d.control,render:({field:r})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:ae??ee,alt:"Workspace logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button","aria-label":"Change logo",onClick:()=>{var s;return(s=E.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:E,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:s=>{var l;const a=(l=s.target.files)==null?void 0:l[0];if(a&&a.size>2*1024*1024){i.error("Image must be 2MB or less");return}a&&(r.onChange(a),se(URL.createObjectURL(a)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})}),e.jsx(k,{errors:d.formState.errors,submitCount:d.formState.submitCount})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Profile"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:n.handleSubmit(ne),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name","aria-required":"true","aria-invalid":!!n.formState.errors.displayName,"aria-describedby":n.formState.errors.displayName?"displayName-error":void 0,...n.register("displayName")}),e.jsx(p,{id:"displayName-error",message:(U=n.formState.errors.displayName)==null?void 0:U.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(Z,{name:"avatar",control:n.control,render:({field:r})=>{var s;return e.jsxs("div",{className:"relative w-14 h-14",children:[O?e.jsx("img",{src:O,alt:"Profile avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const a=he(w||(o==null?void 0:o.email)||"");return{backgroundColor:a.bg,color:a.fg}})(),children:((s=w==null?void 0:w[0])==null?void 0:s.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":"Change avatar",onClick:()=>{var a;return(a=_.current)==null?void 0:a.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:_,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var v;const l=(v=a.target.files)==null?void 0:v[0];if(l&&l.size>2*1024*1024){i.error("Image must be 2MB or less");return}l&&(r.onChange(l),ie(URL.createObjectURL(l)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:n.formState.isSubmitting,children:n.formState.isSubmitting?"Saving…":"Save changes"})}),e.jsx(k,{errors:n.formState.errors,submitCount:n.formState.submitCount})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Password"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:t.handleSubmit(le),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password","aria-required":"true",autoComplete:"current-password","aria-invalid":!!t.formState.errors.currentPassword,"aria-describedby":t.formState.errors.currentPassword?"currentPassword-error":void 0,...t.register("currentPassword")}),e.jsx(p,{id:"currentPassword-error",message:(M=t.formState.errors.currentPassword)==null?void 0:M.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!t.formState.errors.newPassword,"aria-describedby":ge("newPassword-hint","newPassword-error",!!t.formState.errors.newPassword),...t.register("newPassword")}),!t.formState.errors.newPassword&&e.jsx(Ne,{id:"newPassword-hint",children:xe}),e.jsx(p,{id:"newPassword-error",message:(V=t.formState.errors.newPassword)==null?void 0:V.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!t.formState.errors.confirmPassword,"aria-describedby":t.formState.errors.confirmPassword?"confirmPassword-error":void 0,...t.register("confirmPassword")}),e.jsx(p,{id:"confirmPassword-error",message:($=t.formState.errors.confirmPassword)==null?void 0:$.message})]}),e.jsx(p,{assertive:!0,id:"default-error",message:(J=t.formState.errors.root)==null?void 0:J.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:t.formState.isSubmitting,children:t.formState.isSubmitting?"Saving…":"Change password"})}),e.jsx(k,{errors:t.formState.errors,submitCount:t.formState.submitCount})]})})]}),q&&C.length>0&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Apps"})}),e.jsx(N,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:C.map(r=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(c,{htmlFor:`app-${r.id}`,children:"App Name"}),e.jsx(u,{id:`app-${r.id}`,value:Q[r.id]??r.name,onChange:s=>R(a=>({...a,[r.id]:s.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:r.bundle_id_key}),e.jsx(Pe,{tone:r.platform==="ios"?"ios":r.platform==="android"?"android":void 0,variant:r.platform==="both"?"secondary":void 0,className:"capitalize",children:r.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",disabled:L[r.id],onClick:()=>ce(r.id),children:L[r.id]?"Saving…":"Save"}),e.jsxs(Ce,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"destructive",disabled:B[r.id],children:B[r.id]?"Deleting…":"Delete"})}),e.jsxs(Fe,{children:[e.jsxs(ke,{children:[e.jsx(De,{children:"Delete app?"}),e.jsxs(Te,{children:["This will permanently delete ",e.jsx("strong",{children:r.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(qe,{children:[e.jsx(Ee,{className:"w-24",children:"Cancel"}),e.jsx(Oe,{className:je(we({variant:"destructive"}),"w-24"),onClick:()=>de(r.id),children:"Delete"})]})]})]})]})]})]},r.id))})})]})]})}export{Ve as DefaultSettings};
1
+ import{k as m,j as e}from"./vendor-react-BlPSzrEe.js";import{aT as me,aD as ue,aO as pe,aN as G,aK as A,aB as F,aQ as fe,C as y,c as b,d as S,a as N,L as c,I as u,F as p,S as Y,h as Z,aA as i,B as h,s as k,W as he,ab as ge,P as xe,a0 as je,Z as we,av as f,au as D,Q as I,az as g,v as ve,w as ye,al as be,ac as Se}from"./index-DSW9h8XX.js";import{F as Ne}from"./field-hint-Csb40Gzp.js";import{B as Pe}from"./badge-DNaS0Mu3.js";import{A as Ce,h as Ae,c as Fe,f as ke,g as De,d as Te,e as qe,b as Ee,a as Oe}from"./alert-dialog-aoqYdAwx.js";import{P as X}from"./pencil-BN18R4oa.js";import"./vendor-router-B_lVHrKl.js";const _e=D({teamName:g().min(1,"Team name is required"),logo:I(File).nullable().optional()}),Qe=D({displayName:g().min(1,"Display name is required"),avatar:I(File).nullable().optional()}),Re=D({currentPassword:g().min(1,"Enter your current password"),newPassword:g().min(ve,ye),confirmPassword:g()}).refine(x=>x.newPassword===x.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function Ve(){var W,K,U,M,V,$,J;const{resolvedTheme:x}=me(),ee=x==="dark"?"/logo-dark.svg":"/logo.svg",{user:o}=ue(),T=(o==null?void 0:o.role)==="Admin",q=(o==null?void 0:o.role)==="Admin"||(o==null?void 0:o.role)==="Developer"||(o==null?void 0:o.role)==="QA",j=pe(),P=G({queryKey:f.settings,queryFn:be,enabled:T}),[re,se]=m.useState(null),ae=re??((W=P.data)==null?void 0:W.logo_url)??null,E=m.useRef(null),d=A({shouldFocusError:!1,resolver:F(_e),defaultValues:{teamName:"",logo:null},values:P.data?{teamName:P.data.team_name,logo:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function te(r){const s=new FormData;s.append("team_name",r.teamName),r.logo&&s.append("logo",r.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:s})).ok){i.error("Failed to update workspace");return}i.success("Workspace updated"),j.invalidateQueries({queryKey:f.settings})}catch{i.error("Failed to update workspace")}}const[oe,ie]=m.useState(null),O=oe??(o==null?void 0:o.avatarUrl)??null,_=m.useRef(null),n=A({shouldFocusError:!1,resolver:F(Qe),defaultValues:{displayName:"",avatar:null},values:o?{displayName:o.displayName??"",avatar:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ne(r){const s=new FormData;s.append("display_name",r.displayName),r.avatar&&s.append("avatar",r.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:s})).ok){i.error("Failed to update profile");return}i.success("Profile updated"),j.invalidateQueries({queryKey:f.me})}catch{i.error("Failed to update profile")}}const t=A({shouldFocusError:!1,resolver:F(Re)});async function le(r){try{const s=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:r.currentPassword,newPassword:r.newPassword})});if(!s.ok){const a=await s.json();t.setError("root",{message:a.error??"Failed to change password"});return}t.reset(),i.success("Password changed")}catch{t.setError("root",{message:"Network error"})}}const C=G({queryKey:f.apps,queryFn:Se,enabled:q}).data??[],[Q,R]=m.useState({}),[L,z]=m.useState({}),[B,H]=m.useState({});async function de(r){H(s=>({...s,[r]:!0}));try{if(!(await fetch(`/api/v1/apps/${r}`,{method:"DELETE",credentials:"include"})).ok){i.error("Failed to delete app");return}j.invalidateQueries({queryKey:f.apps}),i.success("App deleted")}catch{i.error("Failed to delete app")}finally{H(s=>({...s,[r]:!1}))}}async function ce(r){var s;z(a=>({...a,[r]:!0}));try{if(!(await fetch(`/api/v1/apps/${r}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Q[r]??((s=C.find(l=>l.id===r))==null?void 0:s.name)})})).ok){i.error("Failed to update app");return}i.success("App updated"),R(({[r]:l,...v})=>v),j.invalidateQueries({queryKey:f.apps})}catch{i.error("Failed to update app")}finally{z(a=>({...a,[r]:!1}))}}const w=fe({control:n.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),T&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Workspace"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:d.handleSubmit(te),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team","aria-required":"true","aria-invalid":!!d.formState.errors.teamName,"aria-describedby":d.formState.errors.teamName?"teamName-error":void 0,...d.register("teamName")}),e.jsx(p,{id:"teamName-error",message:(K=d.formState.errors.teamName)==null?void 0:K.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(Z,{name:"logo",control:d.control,render:({field:r})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:ae??ee,alt:"Workspace logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button","aria-label":"Change logo",onClick:()=>{var s;return(s=E.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:E,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:s=>{var l;const a=(l=s.target.files)==null?void 0:l[0];if(a&&a.size>2*1024*1024){i.error("Image must be 2MB or less");return}a&&(r.onChange(a),se(URL.createObjectURL(a)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})}),e.jsx(k,{errors:d.formState.errors,submitCount:d.formState.submitCount})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Profile"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:n.handleSubmit(ne),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name","aria-required":"true","aria-invalid":!!n.formState.errors.displayName,"aria-describedby":n.formState.errors.displayName?"displayName-error":void 0,...n.register("displayName")}),e.jsx(p,{id:"displayName-error",message:(U=n.formState.errors.displayName)==null?void 0:U.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(Z,{name:"avatar",control:n.control,render:({field:r})=>{var s;return e.jsxs("div",{className:"relative w-14 h-14",children:[O?e.jsx("img",{src:O,alt:"Profile avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const a=he(w||(o==null?void 0:o.email)||"");return{backgroundColor:a.bg,color:a.fg}})(),children:((s=w==null?void 0:w[0])==null?void 0:s.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":"Change avatar",onClick:()=>{var a;return(a=_.current)==null?void 0:a.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:_,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var v;const l=(v=a.target.files)==null?void 0:v[0];if(l&&l.size>2*1024*1024){i.error("Image must be 2MB or less");return}l&&(r.onChange(l),ie(URL.createObjectURL(l)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:n.formState.isSubmitting,children:n.formState.isSubmitting?"Saving…":"Save changes"})}),e.jsx(k,{errors:n.formState.errors,submitCount:n.formState.submitCount})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Password"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:t.handleSubmit(le),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password","aria-required":"true",autoComplete:"current-password","aria-invalid":!!t.formState.errors.currentPassword,"aria-describedby":t.formState.errors.currentPassword?"currentPassword-error":void 0,...t.register("currentPassword")}),e.jsx(p,{id:"currentPassword-error",message:(M=t.formState.errors.currentPassword)==null?void 0:M.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!t.formState.errors.newPassword,"aria-describedby":ge("newPassword-hint","newPassword-error",!!t.formState.errors.newPassword),...t.register("newPassword")}),!t.formState.errors.newPassword&&e.jsx(Ne,{id:"newPassword-hint",children:xe}),e.jsx(p,{id:"newPassword-error",message:(V=t.formState.errors.newPassword)==null?void 0:V.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!t.formState.errors.confirmPassword,"aria-describedby":t.formState.errors.confirmPassword?"confirmPassword-error":void 0,...t.register("confirmPassword")}),e.jsx(p,{id:"confirmPassword-error",message:($=t.formState.errors.confirmPassword)==null?void 0:$.message})]}),e.jsx(p,{assertive:!0,id:"default-error",message:(J=t.formState.errors.root)==null?void 0:J.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:t.formState.isSubmitting,children:t.formState.isSubmitting?"Saving…":"Change password"})}),e.jsx(k,{errors:t.formState.errors,submitCount:t.formState.submitCount})]})})]}),q&&C.length>0&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(S,{children:"Apps"})}),e.jsx(N,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:C.map(r=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(c,{htmlFor:`app-${r.id}`,children:"App Name"}),e.jsx(u,{id:`app-${r.id}`,value:Q[r.id]??r.name,onChange:s=>R(a=>({...a,[r.id]:s.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:r.bundle_id_key}),e.jsx(Pe,{tone:r.platform==="ios"?"ios":r.platform==="android"?"android":void 0,variant:r.platform==="both"?"secondary":void 0,className:"capitalize",children:r.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",disabled:L[r.id],onClick:()=>ce(r.id),children:L[r.id]?"Saving…":"Save"}),e.jsxs(Ce,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"destructive",disabled:B[r.id],children:B[r.id]?"Deleting…":"Delete"})}),e.jsxs(Fe,{children:[e.jsxs(ke,{children:[e.jsx(De,{children:"Delete app?"}),e.jsxs(Te,{children:["This will permanently delete ",e.jsx("strong",{children:r.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(qe,{children:[e.jsx(Ee,{className:"w-24",children:"Cancel"}),e.jsx(Oe,{className:je(we({variant:"destructive"}),"w-24"),onClick:()=>de(r.id),children:"Delete"})]})]})]})]})]})]},r.id))})})]})]})}export{Ve as DefaultSettings};
@@ -1 +1 @@
1
- import{k as F,j as e}from"./vendor-react-BlPSzrEe.js";import{aK as Q,aB as W,aQ as K,aO as M,aN as U,C as R,c as T,d as O,b as E,a as z,L as m,I as f,h as G,W as Y,F as u,S as V,ab as J,P as X,B as Z,s as $,av as I,au as ee,az as v,v as ae,w as se,Q as re,aR as te}from"./index-B4w4Lh3e.js";import{F as ie}from"./field-hint-CMKmbVpy.js";import{b as ne,c as oe,L as de}from"./vendor-router-B_lVHrKl.js";import{P as le}from"./pencil-CycAOoC_.js";const ce=ee({displayName:v().optional(),avatar:re(File).nullable().optional(),password:v().min(ae,se),confirm:v()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ve(){var b,N,C,S,k,P;const o=ne(),[q]=oe(),i=q.get("token")??"",[x,A]=F.useState(null),g=F.useRef(null),{register:p,handleSubmit:L,control:j,setError:d,formState:{errors:a,isSubmitting:w,submitCount:_}}=Q({shouldFocusError:!1,resolver:W(ce),defaultValues:{displayName:"",avatar:null}}),l=K({control:j,name:"displayName"})??"",B=M(),h=U({queryKey:I.inviteToken(i),queryFn:()=>te(i),enabled:i!=="",staleTime:1/0}),y=!i||h.isError?"invalid":h.isPending?"loading":"valid",D=((b=h.data)==null?void 0:b.role)??"";async function H(t){var n;try{const s=new FormData;s.append("token",i),s.append("password",t.password),(n=t.displayName)!=null&&n.trim()&&s.append("display_name",t.displayName.trim()),t.avatar&&s.append("avatar",t.avatar);const r=await fetch("/api/v1/invitations/accept",{method:"POST",body:s});if(r.status===409){d("root",{type:"already-member",message:"This email already has an account. Sign in instead, or ask your admin for a password reset link."});return}if(!r.ok){const c=await r.json().catch(()=>({}));d("root",{message:c.error??"Failed to accept invitation"});return}B.removeQueries({queryKey:I.inviteToken(i)}),o("/app-center",{replace:!0})}catch{d("root",{message:"Network error. Please try again."})}}return y==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):y==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(R,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(T,{children:[e.jsx(O,{children:"Invitation expired"}),e.jsx(E,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(R,{level:4,className:"w-full max-w-sm",children:[e.jsxs(T,{className:"text-center",children:[e.jsx(O,{children:"Set up your account"}),e.jsxs(E,{children:["You're joining as ",e.jsx("strong",{children:D})]})]}),e.jsx(z,{children:e.jsxs("form",{onSubmit:L(H),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(f,{id:"display-name",placeholder:"Your name",...p("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(G,{name:"avatar",control:j,render:({field:t})=>{var n;return e.jsxs("div",{className:"relative w-14 h-14",children:[x?e.jsx("img",{src:x,alt:"Avatar preview",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const s=Y(l);return{backgroundColor:s.bg,color:s.fg}})(),children:((n=l==null?void 0:l[0])==null?void 0:n.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":a.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":a.avatar?"avatar-error":void 0,onClick:()=>{var s;return(s=g.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(le,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:s=>{var c;const r=(c=s.target.files)==null?void 0:c[0];if(r){if(r.size>2*1024*1024){d("avatar",{message:"Max 2MB for avatar"});return}t.onChange(r),A(URL.createObjectURL(r))}}})]})}}),e.jsx(u,{assertive:!0,id:"avatar-error",message:(N=a.avatar)==null?void 0:N.message})]}),e.jsx(V,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),e.jsx(f,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.password,"aria-describedby":J("password-hint","password-error",!!a.password),...p("password")}),!a.password&&e.jsx(ie,{id:"password-hint",children:X}),e.jsx(u,{id:"password-error",message:(C=a.password)==null?void 0:C.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(f,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.confirm,"aria-describedby":a.confirm?"confirm-error":void 0,...p("confirm")}),e.jsx(u,{id:"confirm-error",message:(S=a.confirm)==null?void 0:S.message})]}),e.jsx(u,{assertive:!0,id:"invite-error",message:(k=a.root)==null?void 0:k.message}),((P=a.root)==null?void 0:P.type)==="already-member"&&e.jsx(de,{to:"/login",className:"text-sm text-center underline underline-offset-4",children:"Go to sign in"}),e.jsx(Z,{type:"submit",disabled:w,className:"w-full",children:w?"Creating account…":"Create account"}),e.jsx($,{errors:a,submitCount:_})]})})]})})}export{ve as Invite};
1
+ import{k as F,j as e}from"./vendor-react-BlPSzrEe.js";import{aK as Q,aB as W,aQ as K,aO as M,aN as U,C as R,c as T,d as O,b as E,a as z,L as m,I as f,h as G,W as Y,F as u,S as V,ab as J,P as X,B as Z,s as $,av as I,au as ee,az as v,v as ae,w as se,Q as re,aR as te}from"./index-DSW9h8XX.js";import{F as ie}from"./field-hint-Csb40Gzp.js";import{b as ne,c as oe,L as de}from"./vendor-router-B_lVHrKl.js";import{P as le}from"./pencil-BN18R4oa.js";const ce=ee({displayName:v().optional(),avatar:re(File).nullable().optional(),password:v().min(ae,se),confirm:v()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ve(){var b,N,C,S,k,P;const o=ne(),[q]=oe(),i=q.get("token")??"",[x,A]=F.useState(null),g=F.useRef(null),{register:p,handleSubmit:L,control:j,setError:d,formState:{errors:a,isSubmitting:w,submitCount:_}}=Q({shouldFocusError:!1,resolver:W(ce),defaultValues:{displayName:"",avatar:null}}),l=K({control:j,name:"displayName"})??"",B=M(),h=U({queryKey:I.inviteToken(i),queryFn:()=>te(i),enabled:i!=="",staleTime:1/0}),y=!i||h.isError?"invalid":h.isPending?"loading":"valid",D=((b=h.data)==null?void 0:b.role)??"";async function H(t){var n;try{const s=new FormData;s.append("token",i),s.append("password",t.password),(n=t.displayName)!=null&&n.trim()&&s.append("display_name",t.displayName.trim()),t.avatar&&s.append("avatar",t.avatar);const r=await fetch("/api/v1/invitations/accept",{method:"POST",body:s});if(r.status===409){d("root",{type:"already-member",message:"This email already has an account. Sign in instead, or ask your admin for a password reset link."});return}if(!r.ok){const c=await r.json().catch(()=>({}));d("root",{message:c.error??"Failed to accept invitation"});return}B.removeQueries({queryKey:I.inviteToken(i)}),o("/app-center",{replace:!0})}catch{d("root",{message:"Network error. Please try again."})}}return y==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):y==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(R,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(T,{children:[e.jsx(O,{children:"Invitation expired"}),e.jsx(E,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(R,{level:4,className:"w-full max-w-sm",children:[e.jsxs(T,{className:"text-center",children:[e.jsx(O,{children:"Set up your account"}),e.jsxs(E,{children:["You're joining as ",e.jsx("strong",{children:D})]})]}),e.jsx(z,{children:e.jsxs("form",{onSubmit:L(H),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(f,{id:"display-name",placeholder:"Your name",...p("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(G,{name:"avatar",control:j,render:({field:t})=>{var n;return e.jsxs("div",{className:"relative w-14 h-14",children:[x?e.jsx("img",{src:x,alt:"Avatar preview",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const s=Y(l);return{backgroundColor:s.bg,color:s.fg}})(),children:((n=l==null?void 0:l[0])==null?void 0:n.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":a.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":a.avatar?"avatar-error":void 0,onClick:()=>{var s;return(s=g.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(le,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:s=>{var c;const r=(c=s.target.files)==null?void 0:c[0];if(r){if(r.size>2*1024*1024){d("avatar",{message:"Max 2MB for avatar"});return}t.onChange(r),A(URL.createObjectURL(r))}}})]})}}),e.jsx(u,{assertive:!0,id:"avatar-error",message:(N=a.avatar)==null?void 0:N.message})]}),e.jsx(V,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),e.jsx(f,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.password,"aria-describedby":J("password-hint","password-error",!!a.password),...p("password")}),!a.password&&e.jsx(ie,{id:"password-hint",children:X}),e.jsx(u,{id:"password-error",message:(C=a.password)==null?void 0:C.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(f,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.confirm,"aria-describedby":a.confirm?"confirm-error":void 0,...p("confirm")}),e.jsx(u,{id:"confirm-error",message:(S=a.confirm)==null?void 0:S.message})]}),e.jsx(u,{assertive:!0,id:"invite-error",message:(k=a.root)==null?void 0:k.message}),((P=a.root)==null?void 0:P.type)==="already-member"&&e.jsx(de,{to:"/login",className:"text-sm text-center underline underline-offset-4",children:"Go to sign in"}),e.jsx(Z,{type:"submit",disabled:w,className:"w-full",children:w?"Creating account…":"Create account"}),e.jsx($,{errors:a,submitCount:_})]})})]})})}export{ve as Invite};
@@ -1 +1 @@
1
- import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{aE as Et,aN as bt,aO as Lt,M as Tt,ai as Ot,av as Qe,ak as Rt}from"./index-B4w4Lh3e.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-C1qSG3MK.js";import{t as Ft,i as jt,j as Ht,h as Ut,g as Bt,f as _t,l as Gt,P as qt,e as Qt,G as Wt,A as Xt,m as wt,d as Vt,a as zt,b as Yt,L as Jt,B as Zt,c as es}from"./vendor-charts-BykzUV2D.js";import"./vendor-router-B_lVHrKl.js";const ts=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function ss(){return N.useSyncExternalStore(ts,ls,ns)}function ns(){return!0}function ls(){return document.visibilityState!=="hidden"}function os(t,e){const o=Xe.c(4),[m,y]=N.useState(as);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;y(Date.now());const h=setInterval(()=>y(Date.now()),t);return()=>clearInterval(h)},n=[t,e],o[0]=e,o[1]=t,o[2]=i,o[3]=n):(i=o[2],n=o[3]),N.useEffect(i,n),m}function as(){return Date.now()}const xt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},rs={"1h":Ht.every(10),"6h":jt,"24h":jt.every(3),"7d":Ft};function is(t,e,o){return rs[o].range(new Date(t),new Date(e+1))}function cs(t,e){const o=new Date(t);return e==="7d"?`${o.getMonth()+1}/${o.getDate()}`:`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`}const ds=2e3;function us(t){return Math.min(1e4,Math.max(1e3,xt[t]/ds))}const fs={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},pt=t=>Math.round(t*10)/10;function ms(t,e,o){let m;for(const i of t){const n=i.agentName===e?i.resources:void 0;n&&(!m||n.reportedAt>m.reportedAt)&&(m=n)}if(!m||o-m.reportedAt>Ct)return null;const y=i=>Number.isFinite(i)?pt(i):null;return{cpu:y(m.cpuPercent),mem:y(m.memUsedMB/m.memTotalMB*100)}}const $t={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},At={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Es(){const t=Xe.c(65);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=N.useState(e),[y,i]=N.useState(null),[n,h]=N.useState("24h"),R=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,R),{setNode:b}=Et();let p,j;t[3]!==b?(p=()=>(b(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>b(null)),j=[b],t[3]=b,t[4]=p,t[5]=j):(p=t[4],j=t[5]),N.useEffect(p,j);let C;t[6]===Symbol.for("react.memo_cache_sentinel")?(C=u=>{u.type==="agents:listed"&&m(u.sessions??[])},t[6]=C):C=t[6];const Q=C,{send:L,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==L?(ie=()=>{if(!T)return;L({type:"agents:list"});const u=setInterval(()=>L({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,L],t[7]=T,t[8]=L,t[9]=ie,t[10]=ce):(ie=t[9],ce=t[10]),N.useEffect(ie,ce);let le;t[11]===Symbol.for("react.memo_cache_sentinel")?(le={queryKey:Qe.agents,queryFn:Ot,refetchOnWindowFocus:!1},t[11]=le):le=t[11];const W=bt(le);let c,d,F,oe;t[12]!==W.data||t[13]!==o?(F=W.data??[],d=o.map(ps).filter(Boolean),c=[...new Set([...d,...F])],oe=new Set(d),t[12]=W.data,t[13]=o,t[14]=c,t[15]=d,t[16]=F,t[17]=oe):(c=t[14],d=t[15],F=t[16],oe=t[17]);const w=oe,l=y??(W.isPending?null:F[0]??d[0]??null),H=Lt();let Z;t[18]!==n||t[19]!==l?(Z=l?Qe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=Z):Z=t[20];const ee=Z;let D;t[21]!==ee||t[22]!==n?(D=ee??Qe.resourceHistory("",n),t[21]=ee,t[22]=n,t[23]=D):D=t[23];let U;t[24]!==n||t[25]!==l?(U=u=>{const{signal:E}=u;return Rt(l,n,E)},t[24]=n,t[25]=l,t[26]=U):U=t[26];let X;t[27]!==D||t[28]!==U?(X={queryKey:D,queryFn:U,enabled:!1},t[27]=D,t[28]=U,t[29]=X):X=t[29];const I=bt(X),B=I.refetch;let P,V;t[30]!==H||t[31]!==n||t[32]!==B||t[33]!==l||t[34]!==R?(P=()=>{if(!l||!R)return;const u=Qe.resourceHistory(l,n),E=fs[n],q=()=>{const ne=H.getQueryState(u);(ne==null?void 0:ne.fetchStatus)==="fetching"&&ne.data===void 0?H.cancelQueries({queryKey:u,exact:!0}).then(()=>B()):B({cancelRefetch:!0})},g=H.getQueryState(u),ae=Math.max((g==null?void 0:g.dataUpdatedAt)??0,(g==null?void 0:g.errorUpdatedAt)??0),se=(g==null?void 0:g.data)!==void 0&&ae>0?Math.max(0,E-(Date.now()-ae)):0;let de;const re=()=>{q(),de=setInterval(q,E)},Ve=se>0?setTimeout(re,se):void 0;return se===0&&re(),()=>{clearTimeout(Ve),clearInterval(de),H.cancelQueries({queryKey:u,exact:!0})}},V=[l,n,R,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=R,t[35]=P,t[36]=V):(P=t[35],V=t[36]),N.useEffect(P,V);const S=I.data!==void 0||I.isError,te=ee!==null&&!S;let r;t[37]!==I.data?(r=I.data??[],t[37]=I.data,t[38]=r):r=t[38];let z;t[39]!==r?(z=r.map(xs),t[39]=r,t[40]=z):z=t[40];const G=z;let Y;t[41]!==x||t[42]!==l||t[43]!==o?(Y=l?ms(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=Y):Y=t[44];const f=Y;let _;t[45]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=_):_=t[45];let v;t[46]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("h2",{id:"macs-heading",className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Macs"}),t[46]=v):v=t[46];let M;t[47]!==c||t[48]!==T||t[49]!==w||t[50]!==l?(M=c.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:T?"No agents yet.":"Connecting…"}):c.map(u=>{const E=w.has(u),q=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":q?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",q?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${E?"bg-emerald-400":"bg-muted-foreground/40"}`,"aria-hidden":"true"}),s.jsx("span",{className:"truncate min-w-0",children:u}),s.jsx("span",{className:"sr-only",children:E?"Online":"Offline"})]},u)}),t[47]=c,t[48]=T,t[49]=w,t[50]=l,t[51]=M):M=t[51];let $;t[52]!==M?($=s.jsxs("aside",{"aria-labelledby":"macs-heading",className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[v,M]}),t[52]=M,t[53]=$):$=t[53];let A;t[54]!==G||t[55]!==(f==null?void 0:f.cpu)||t[56]!==(f==null?void 0:f.mem)||t[57]!==te||t[58]!==x||t[59]!==n||t[60]!==l?(A=s.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:l?s.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-base font-semibold",children:l}),s.jsx(It,{value:n,onValueChange:u=>h(u),children:s.jsx(Pt,{children:Object.keys(At).map(hs)})})]}),te?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading…"}):G.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No data yet for this range. Data is collected every minute while the agent is connected."}):s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Nt,{title:"CPU %",color:"cpu",data:G,dataKey:"cpu",range:n,now:x,live:(f==null?void 0:f.cpu)??null}),s.jsx(Nt,{title:"RAM %",color:"mem",data:G,dataKey:"mem",range:n,now:x,live:(f==null?void 0:f.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Tt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=G,t[55]=f==null?void 0:f.cpu,t[56]=f==null?void 0:f.mem,t[57]=te,t[58]=x,t[59]=n,t[60]=l,t[61]=A):A=t[61];let J;return t[62]!==$||t[63]!==A?(J=s.jsxs("div",{className:"flex h-full min-h-0",children:[_,$,A]}),t[62]=$,t[63]=A,t[64]=J):J=t[64],J}function hs(t){return s.jsx(Kt,{value:t,children:At[t]},t)}function xs(t){return{time:t.recorded_at,cpu:pt(t.cpu_percent),mem:pt(t.mem_percent)}}function ps(t){return t.agentName}const gt=t=>new Date(t.time).getTime(),St=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),We=t=>`${Math.round(t*10)/10}%`,gs=_t(gt).left,ys=_t(t=>t.t).left,K={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,vs=20,bs=40;function Nt(t){const e=Xe.c(18),{title:o,color:m,data:y,dataKey:i,range:n,now:h,live:R}=t,k=$t[m].color;let x;e[0]!==k?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:k}}),e[0]=k,e[1]=x):x=e[1];let b;e[2]!==o?(b=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=b):b=e[3];let p;e[4]!==x||e[5]!==b?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[4]=x,e[5]=b,e[6]=p):p=e[6];let j;e[7]!==y||e[8]!==i||e[9]!==k||e[10]!==R||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(qt,{children:Q=>{const{width:L,height:T}=Q;return L>0&&T>0?s.jsx(js,{width:L,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:R,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=R,e[11]=h,e[12]=n,e[13]=o,e[14]=j):j=e[14];let C;return e[15]!==p||e[16]!==j?(C=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3",children:[p,j]}),e[15]=p,e[16]=j,e[17]=C):C=e[17],C}function js(t){const e=Xe.c(139),{width:o,height:m,data:y,dataKey:i,hex:n,range:h,now:R,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,L]=N.useState(!1),[T,ie]=N.useState(null),[ce,le]=N.useState(!1),W=ce?T:null,c=o-K.left-K.right,d=m-K.top-K.bottom,F=R,oe=F-xt[h],w=Ut({domain:[oe,F],range:[0,Math.max(0,c)]}),l=Bt({domain:[0,100],range:[d,kt]}),H=c>0?vs/c*xt[h]:0,Z=oe-H,ee=F+H;let D;e[0]!==h||e[1]!==Z||e[2]!==ee?(D=is(Z,ee,h),e[0]=h,e[1]=Z,e[2]=ee,e[3]=D):D=e[3];const U=D,X=c>0?Math.min(.5,bs/c):0,I=`fill-${i}`,B=`plot-${i}`,P=`axis-fade-${i}`,V=y[y.length-1],S=b!==null&&V?{t:Math.max(F,gt(V)+1),v:b,live:!0}:null;let te;e[4]!==i?(te=a=>({t:gt(a),v:a[i]}),e[4]=i,e[5]=te):te=e[5];const r=y.map(te);S&&r.push(S);const z=a=>Math.min(w(a),c),G=S?z(S.t):0,Y=S?l(S.v):0,f=Math.max(0,y.length-1),_=j===null?Math.max(0,r.length-1):j==="live"?S?r.length-1:f:Math.min(gs(y,j),f),v=Q?r[_]:void 0,M=v?z(v.t):0,$=v?l(v.v):0,A=$t[i].label;let J;e[6]!==A?(J=a=>`${A}, ${St(a.t)}, ${a.live?"latest, ":""}${We(a.v)}`,e[6]=A,e[7]=J):J=e[7];const u=J,E=a=>{const O=r[a];O&&(C(O.live?"live":O.t),L(!0),ie({now:a,text:u(O)}))};let q;e[8]===Symbol.for("react.memo_cache_sentinel")?(q=()=>L(!1),e[8]=q):q=e[8];const g=q;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=O=>{O.key==="Escape"&&L(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},se=[Q],e[9]=Q,e[10]=ae,e[11]=se):(ae=e[10],se=e[11]),N.useEffect(ae,se);const de=a=>{if(r.length===0)return;const O=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,O-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,O+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),E(Fe))},re=a=>{const O=Gt(a);if(!O)return;const Fe=O.x-K.left,yt=ys(r,w.invert(Fe).getTime()),vt=[r[yt-1],r[yt],S].reduce((mt,ht)=>ht&&(!mt||Math.abs(z(ht.t)-Fe)<=Math.abs(z(mt.t)-Fe))?ht:mt,void 0);vt&&E(r.indexOf(vt))},Ve="group",ne=S?`${x}, last ${h}. Now ${We(S.v)}.`:V?`${x}, last ${h}. Latest ${We(V[i])}.`:`${x}, last ${h}. No samples.`;let ue;e[12]!==I||e[13]!==n?(ue=s.jsx(Qt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=ue):ue=e[14];const ze=Math.max(0,c),Ye=Math.max(0,d);let fe;e[15]!==ze||e[16]!==Ye?(fe=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=fe):fe=e[17];let me;e[18]!==B||e[19]!==fe?(me=s.jsx("clipPath",{id:B,children:fe}),e[18]=B,e[19]=fe,e[20]=me):me=e[20];const Je=`${P}-grad`,Ze=Math.max(0,c);let He;e[21]===Symbol.for("react.memo_cache_sentinel")?(He=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=He):He=e[21];let he;e[22]!==X?(he=s.jsx("stop",{offset:X,stopColor:"white",stopOpacity:1}),e[22]=X,e[23]=he):he=e[23];const et=1-X;let xe;e[24]!==et?(xe=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=xe):xe=e[25];let Ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=Ue):Ue=e[26];let pe;e[27]!==Je||e[28]!==Ze||e[29]!==he||e[30]!==xe?(pe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[He,he,xe,Ue]}),e[27]=Je,e[28]=Ze,e[29]=he,e[30]=xe,e[31]=pe):pe=e[31];const tt=Math.max(0,c),st=Math.max(0,c),nt=`url(#${P}-grad)`;let ge;e[32]!==d||e[33]!==st||e[34]!==nt?(ge=s.jsx("rect",{x:0,y:d,width:st,height:K.bottom*2,fill:nt}),e[32]=d,e[33]=st,e[34]=nt,e[35]=ge):ge=e[35];let ye;e[36]!==P||e[37]!==d||e[38]!==tt||e[39]!==ge?(ye=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:d,width:tt,height:K.bottom*2,children:ge}),e[36]=P,e[37]=d,e[38]=tt,e[39]=ge,e[40]=ye):ye=e[40];let Be;e[41]===Symbol.for("react.memo_cache_sentinel")?(Be=[0,25,50,75,100],e[41]=Be):Be=e[41];let ve;e[42]!==c||e[43]!==l?(ve=s.jsx(Wt,{scale:l,width:c,tickValues:Be,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=c,e[43]=l,e[44]=ve):ve=e[44];const lt=`url(#${B})`;let be;e[45]!==w?(be=a=>w(a.t),e[45]=w,e[46]=be):be=e[46];let je;e[47]!==l?(je=a=>l(a.v),e[47]=l,e[48]=je):je=e[48];const ot=`url(#${I})`;let we;e[49]!==r||e[50]!==be||e[51]!==je||e[52]!==ot||e[53]!==l?(we=s.jsx(Xt,{data:r,x:be,y:je,yScale:l,curve:wt,fill:ot}),e[49]=r,e[50]=be,e[51]=je,e[52]=ot,e[53]=l,e[54]=we):we=e[54];let Se;e[55]!==w?(Se=a=>w(a.t),e[55]=w,e[56]=Se):Se=e[56];let ke;e[57]!==l?(ke=a=>l(a.v),e[57]=l,e[58]=ke):ke=e[58];let Me;e[59]!==n||e[60]!==r||e[61]!==Se||e[62]!==ke?(Me=s.jsx(Vt,{data:r,x:Se,y:ke,curve:wt,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=r,e[61]=Se,e[62]=ke,e[63]=Me):Me=e[63];let Ne;e[64]!==lt||e[65]!==we||e[66]!==Me?(Ne=s.jsxs("g",{clipPath:lt,children:[we,Me]}),e[64]=lt,e[65]=we,e[66]=Me,e[67]=Ne):Ne=e[67];const at=`url(#${P})`;let _e;e[68]!==h?(_e=a=>cs(+a,h),e[68]=h,e[69]=_e):_e=e[69];let $e;e[70]!==d||e[71]!==_e||e[72]!==U||e[73]!==w?($e=s.jsx(zt,{top:d,scale:w,tickValues:U,tickFormat:_e,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:ks}),e[70]=d,e[71]=_e,e[72]=U,e[73]=w,e[74]=$e):$e=e[74];let Ae;e[75]!==at||e[76]!==$e?(Ae=s.jsx("g",{mask:at,children:$e}),e[75]=at,e[76]=$e,e[77]=Ae):Ae=e[77];let Ge;e[78]===Symbol.for("react.memo_cache_sentinel")?(Ge=[0,25,50,75,100],e[78]=Ge):Ge=e[78];let Ee;e[79]!==l?(Ee=s.jsx(Yt,{scale:l,tickValues:Ge,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Ee):Ee=e[80];let Le;e[81]!==G||e[82]!==Y||e[83]!==n||e[84]!==S?(Le=S&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:G,cy:Y,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:G,cy:Y,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=G,e[82]=Y,e[83]=n,e[84]=S,e[85]=Le):Le=e[85];let Te;e[86]!==n||e[87]!==d||e[88]!==v||e[89]!==M||e[90]!==$?(Te=v&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${M}px)`},pointerEvents:"none",children:[s.jsx(Jt,{from:{x:0,y:kt},to:{x:0,y:d},stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:0,cy:0,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5,style:{transition:"transform 0.25s ease-out",transform:`translateY(${$}px)`}})]}),e[86]=n,e[87]=d,e[88]=v,e[89]=M,e[90]=$,e[91]=Te):Te=e[91];const rt=Math.max(0,c)+Mt,it=Math.max(0,d),ct=`${x} samples`,dt=Math.max(0,r.length-1),ut=W?Math.min(W.now,Math.max(0,r.length-1)):_,ft=W?W.text:r[_]?u(r[_]):void 0;let Oe;e[92]!==_||e[93]!==E?(Oe=()=>{le(!0),E(_)},e[92]=_,e[93]=E,e[94]=Oe):Oe=e[94];let Re;e[95]!==g?(Re=()=>{g(),le(!1)},e[95]=g,e[96]=Re):Re=e[96];let Ce;e[97]!==de||e[98]!==re||e[99]!==g||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Oe||e[108]!==Re?(Ce=s.jsx(Zt,{x:0,y:0,width:rt,height:it,fill:"transparent",tabIndex:0,role:"slider","aria-label":ct,"aria-valuemin":0,"aria-valuemax":dt,"aria-valuenow":ut,"aria-valuetext":ft,"aria-describedby":p,className:"outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",onFocus:Oe,onBlur:Re,onKeyDown:de,onMouseMove:re,onMouseLeave:g,onTouchMove:re,onTouchEnd:g,onTouchCancel:g}),e[97]=de,e[98]=re,e[99]=g,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Oe,e[108]=Re,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Ee||e[114]!==Le||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Ee,Le,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Ee,e[114]=Le,e[115]=Te,e[116]=Ce,e[117]=De):De=e[117];let Ie;e[118]!==m||e[119]!==ne||e[120]!==ue||e[121]!==me||e[122]!==pe||e[123]!==ye||e[124]!==De||e[125]!==o?(Ie=s.jsxs("svg",{width:o,height:m,role:Ve,"aria-label":ne,children:[ue,me,pe,ye,De]}),e[118]=m,e[119]=ne,e[120]=ue,e[121]=me,e[122]=pe,e[123]=ye,e[124]=De,e[125]=o,e[126]=Ie):Ie=e[126];let Pe;e[127]!==p?(Pe=s.jsx("p",{id:p,className:"sr-only",children:"Use the arrow keys to read individual samples, and End for the latest value. Escape hides the reading."}),e[127]=p,e[128]=Pe):Pe=e[128];let Ke;e[129]!==c||e[130]!==A||e[131]!==v||e[132]!==M||e[133]!==$?(Ke=v&&s.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 whitespace-nowrap rounded-lg border bg-background px-3 py-2 text-xs text-foreground shadow-md",style:{transform:`translate(${M+K.left}px, ${$+K.top}px) translate(${M>c*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",St(v.t)]}),s.jsxs("p",{children:[A,": ",We(v.v)]})]}),e[129]=c,e[130]=A,e[131]=v,e[132]=M,e[133]=$,e[134]=Ke):Ke=e[134];let qe;return e[135]!==Ie||e[136]!==Pe||e[137]!==Ke?(qe=s.jsxs(s.Fragment,{children:[Ie,Pe,Ke]}),e[135]=Ie,e[136]=Pe,e[137]=Ke,e[138]=qe):qe=e[138],qe}function ws(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function Ss(t){return`${t}%`}function ks(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{js as AreaChartInner,Es as MacResources};
1
+ import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{aE as Et,aN as bt,aO as Lt,M as Tt,ai as Ot,av as Qe,ak as Rt}from"./index-DSW9h8XX.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-Bi20EUDs.js";import{t as Ft,i as jt,j as Ht,h as Ut,g as Bt,f as _t,l as Gt,P as qt,e as Qt,G as Wt,A as Xt,m as wt,d as Vt,a as zt,b as Yt,L as Jt,B as Zt,c as es}from"./vendor-charts-BykzUV2D.js";import"./vendor-router-B_lVHrKl.js";const ts=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function ss(){return N.useSyncExternalStore(ts,ls,ns)}function ns(){return!0}function ls(){return document.visibilityState!=="hidden"}function os(t,e){const o=Xe.c(4),[m,y]=N.useState(as);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;y(Date.now());const h=setInterval(()=>y(Date.now()),t);return()=>clearInterval(h)},n=[t,e],o[0]=e,o[1]=t,o[2]=i,o[3]=n):(i=o[2],n=o[3]),N.useEffect(i,n),m}function as(){return Date.now()}const xt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},rs={"1h":Ht.every(10),"6h":jt,"24h":jt.every(3),"7d":Ft};function is(t,e,o){return rs[o].range(new Date(t),new Date(e+1))}function cs(t,e){const o=new Date(t);return e==="7d"?`${o.getMonth()+1}/${o.getDate()}`:`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`}const ds=2e3;function us(t){return Math.min(1e4,Math.max(1e3,xt[t]/ds))}const fs={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},pt=t=>Math.round(t*10)/10;function ms(t,e,o){let m;for(const i of t){const n=i.agentName===e?i.resources:void 0;n&&(!m||n.reportedAt>m.reportedAt)&&(m=n)}if(!m||o-m.reportedAt>Ct)return null;const y=i=>Number.isFinite(i)?pt(i):null;return{cpu:y(m.cpuPercent),mem:y(m.memUsedMB/m.memTotalMB*100)}}const $t={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},At={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Es(){const t=Xe.c(65);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=N.useState(e),[y,i]=N.useState(null),[n,h]=N.useState("24h"),R=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,R),{setNode:b}=Et();let p,j;t[3]!==b?(p=()=>(b(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>b(null)),j=[b],t[3]=b,t[4]=p,t[5]=j):(p=t[4],j=t[5]),N.useEffect(p,j);let C;t[6]===Symbol.for("react.memo_cache_sentinel")?(C=u=>{u.type==="agents:listed"&&m(u.sessions??[])},t[6]=C):C=t[6];const Q=C,{send:L,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==L?(ie=()=>{if(!T)return;L({type:"agents:list"});const u=setInterval(()=>L({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,L],t[7]=T,t[8]=L,t[9]=ie,t[10]=ce):(ie=t[9],ce=t[10]),N.useEffect(ie,ce);let le;t[11]===Symbol.for("react.memo_cache_sentinel")?(le={queryKey:Qe.agents,queryFn:Ot,refetchOnWindowFocus:!1},t[11]=le):le=t[11];const W=bt(le);let c,d,F,oe;t[12]!==W.data||t[13]!==o?(F=W.data??[],d=o.map(ps).filter(Boolean),c=[...new Set([...d,...F])],oe=new Set(d),t[12]=W.data,t[13]=o,t[14]=c,t[15]=d,t[16]=F,t[17]=oe):(c=t[14],d=t[15],F=t[16],oe=t[17]);const w=oe,l=y??(W.isPending?null:F[0]??d[0]??null),H=Lt();let Z;t[18]!==n||t[19]!==l?(Z=l?Qe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=Z):Z=t[20];const ee=Z;let D;t[21]!==ee||t[22]!==n?(D=ee??Qe.resourceHistory("",n),t[21]=ee,t[22]=n,t[23]=D):D=t[23];let U;t[24]!==n||t[25]!==l?(U=u=>{const{signal:E}=u;return Rt(l,n,E)},t[24]=n,t[25]=l,t[26]=U):U=t[26];let X;t[27]!==D||t[28]!==U?(X={queryKey:D,queryFn:U,enabled:!1},t[27]=D,t[28]=U,t[29]=X):X=t[29];const I=bt(X),B=I.refetch;let P,V;t[30]!==H||t[31]!==n||t[32]!==B||t[33]!==l||t[34]!==R?(P=()=>{if(!l||!R)return;const u=Qe.resourceHistory(l,n),E=fs[n],q=()=>{const ne=H.getQueryState(u);(ne==null?void 0:ne.fetchStatus)==="fetching"&&ne.data===void 0?H.cancelQueries({queryKey:u,exact:!0}).then(()=>B()):B({cancelRefetch:!0})},g=H.getQueryState(u),ae=Math.max((g==null?void 0:g.dataUpdatedAt)??0,(g==null?void 0:g.errorUpdatedAt)??0),se=(g==null?void 0:g.data)!==void 0&&ae>0?Math.max(0,E-(Date.now()-ae)):0;let de;const re=()=>{q(),de=setInterval(q,E)},Ve=se>0?setTimeout(re,se):void 0;return se===0&&re(),()=>{clearTimeout(Ve),clearInterval(de),H.cancelQueries({queryKey:u,exact:!0})}},V=[l,n,R,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=R,t[35]=P,t[36]=V):(P=t[35],V=t[36]),N.useEffect(P,V);const S=I.data!==void 0||I.isError,te=ee!==null&&!S;let r;t[37]!==I.data?(r=I.data??[],t[37]=I.data,t[38]=r):r=t[38];let z;t[39]!==r?(z=r.map(xs),t[39]=r,t[40]=z):z=t[40];const G=z;let Y;t[41]!==x||t[42]!==l||t[43]!==o?(Y=l?ms(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=Y):Y=t[44];const f=Y;let _;t[45]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=_):_=t[45];let v;t[46]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("h2",{id:"macs-heading",className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Macs"}),t[46]=v):v=t[46];let M;t[47]!==c||t[48]!==T||t[49]!==w||t[50]!==l?(M=c.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:T?"No agents yet.":"Connecting…"}):c.map(u=>{const E=w.has(u),q=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":q?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",q?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${E?"bg-emerald-400":"bg-muted-foreground/40"}`,"aria-hidden":"true"}),s.jsx("span",{className:"truncate min-w-0",children:u}),s.jsx("span",{className:"sr-only",children:E?"Online":"Offline"})]},u)}),t[47]=c,t[48]=T,t[49]=w,t[50]=l,t[51]=M):M=t[51];let $;t[52]!==M?($=s.jsxs("aside",{"aria-labelledby":"macs-heading",className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[v,M]}),t[52]=M,t[53]=$):$=t[53];let A;t[54]!==G||t[55]!==(f==null?void 0:f.cpu)||t[56]!==(f==null?void 0:f.mem)||t[57]!==te||t[58]!==x||t[59]!==n||t[60]!==l?(A=s.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:l?s.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-base font-semibold",children:l}),s.jsx(It,{value:n,onValueChange:u=>h(u),children:s.jsx(Pt,{children:Object.keys(At).map(hs)})})]}),te?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading…"}):G.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No data yet for this range. Data is collected every minute while the agent is connected."}):s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Nt,{title:"CPU %",color:"cpu",data:G,dataKey:"cpu",range:n,now:x,live:(f==null?void 0:f.cpu)??null}),s.jsx(Nt,{title:"RAM %",color:"mem",data:G,dataKey:"mem",range:n,now:x,live:(f==null?void 0:f.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Tt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=G,t[55]=f==null?void 0:f.cpu,t[56]=f==null?void 0:f.mem,t[57]=te,t[58]=x,t[59]=n,t[60]=l,t[61]=A):A=t[61];let J;return t[62]!==$||t[63]!==A?(J=s.jsxs("div",{className:"flex h-full min-h-0",children:[_,$,A]}),t[62]=$,t[63]=A,t[64]=J):J=t[64],J}function hs(t){return s.jsx(Kt,{value:t,children:At[t]},t)}function xs(t){return{time:t.recorded_at,cpu:pt(t.cpu_percent),mem:pt(t.mem_percent)}}function ps(t){return t.agentName}const gt=t=>new Date(t.time).getTime(),St=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),We=t=>`${Math.round(t*10)/10}%`,gs=_t(gt).left,ys=_t(t=>t.t).left,K={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,vs=20,bs=40;function Nt(t){const e=Xe.c(18),{title:o,color:m,data:y,dataKey:i,range:n,now:h,live:R}=t,k=$t[m].color;let x;e[0]!==k?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:k}}),e[0]=k,e[1]=x):x=e[1];let b;e[2]!==o?(b=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=b):b=e[3];let p;e[4]!==x||e[5]!==b?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[4]=x,e[5]=b,e[6]=p):p=e[6];let j;e[7]!==y||e[8]!==i||e[9]!==k||e[10]!==R||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(qt,{children:Q=>{const{width:L,height:T}=Q;return L>0&&T>0?s.jsx(js,{width:L,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:R,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=R,e[11]=h,e[12]=n,e[13]=o,e[14]=j):j=e[14];let C;return e[15]!==p||e[16]!==j?(C=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3",children:[p,j]}),e[15]=p,e[16]=j,e[17]=C):C=e[17],C}function js(t){const e=Xe.c(139),{width:o,height:m,data:y,dataKey:i,hex:n,range:h,now:R,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,L]=N.useState(!1),[T,ie]=N.useState(null),[ce,le]=N.useState(!1),W=ce?T:null,c=o-K.left-K.right,d=m-K.top-K.bottom,F=R,oe=F-xt[h],w=Ut({domain:[oe,F],range:[0,Math.max(0,c)]}),l=Bt({domain:[0,100],range:[d,kt]}),H=c>0?vs/c*xt[h]:0,Z=oe-H,ee=F+H;let D;e[0]!==h||e[1]!==Z||e[2]!==ee?(D=is(Z,ee,h),e[0]=h,e[1]=Z,e[2]=ee,e[3]=D):D=e[3];const U=D,X=c>0?Math.min(.5,bs/c):0,I=`fill-${i}`,B=`plot-${i}`,P=`axis-fade-${i}`,V=y[y.length-1],S=b!==null&&V?{t:Math.max(F,gt(V)+1),v:b,live:!0}:null;let te;e[4]!==i?(te=a=>({t:gt(a),v:a[i]}),e[4]=i,e[5]=te):te=e[5];const r=y.map(te);S&&r.push(S);const z=a=>Math.min(w(a),c),G=S?z(S.t):0,Y=S?l(S.v):0,f=Math.max(0,y.length-1),_=j===null?Math.max(0,r.length-1):j==="live"?S?r.length-1:f:Math.min(gs(y,j),f),v=Q?r[_]:void 0,M=v?z(v.t):0,$=v?l(v.v):0,A=$t[i].label;let J;e[6]!==A?(J=a=>`${A}, ${St(a.t)}, ${a.live?"latest, ":""}${We(a.v)}`,e[6]=A,e[7]=J):J=e[7];const u=J,E=a=>{const O=r[a];O&&(C(O.live?"live":O.t),L(!0),ie({now:a,text:u(O)}))};let q;e[8]===Symbol.for("react.memo_cache_sentinel")?(q=()=>L(!1),e[8]=q):q=e[8];const g=q;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=O=>{O.key==="Escape"&&L(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},se=[Q],e[9]=Q,e[10]=ae,e[11]=se):(ae=e[10],se=e[11]),N.useEffect(ae,se);const de=a=>{if(r.length===0)return;const O=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,O-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,O+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),E(Fe))},re=a=>{const O=Gt(a);if(!O)return;const Fe=O.x-K.left,yt=ys(r,w.invert(Fe).getTime()),vt=[r[yt-1],r[yt],S].reduce((mt,ht)=>ht&&(!mt||Math.abs(z(ht.t)-Fe)<=Math.abs(z(mt.t)-Fe))?ht:mt,void 0);vt&&E(r.indexOf(vt))},Ve="group",ne=S?`${x}, last ${h}. Now ${We(S.v)}.`:V?`${x}, last ${h}. Latest ${We(V[i])}.`:`${x}, last ${h}. No samples.`;let ue;e[12]!==I||e[13]!==n?(ue=s.jsx(Qt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=ue):ue=e[14];const ze=Math.max(0,c),Ye=Math.max(0,d);let fe;e[15]!==ze||e[16]!==Ye?(fe=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=fe):fe=e[17];let me;e[18]!==B||e[19]!==fe?(me=s.jsx("clipPath",{id:B,children:fe}),e[18]=B,e[19]=fe,e[20]=me):me=e[20];const Je=`${P}-grad`,Ze=Math.max(0,c);let He;e[21]===Symbol.for("react.memo_cache_sentinel")?(He=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=He):He=e[21];let he;e[22]!==X?(he=s.jsx("stop",{offset:X,stopColor:"white",stopOpacity:1}),e[22]=X,e[23]=he):he=e[23];const et=1-X;let xe;e[24]!==et?(xe=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=xe):xe=e[25];let Ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=Ue):Ue=e[26];let pe;e[27]!==Je||e[28]!==Ze||e[29]!==he||e[30]!==xe?(pe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[He,he,xe,Ue]}),e[27]=Je,e[28]=Ze,e[29]=he,e[30]=xe,e[31]=pe):pe=e[31];const tt=Math.max(0,c),st=Math.max(0,c),nt=`url(#${P}-grad)`;let ge;e[32]!==d||e[33]!==st||e[34]!==nt?(ge=s.jsx("rect",{x:0,y:d,width:st,height:K.bottom*2,fill:nt}),e[32]=d,e[33]=st,e[34]=nt,e[35]=ge):ge=e[35];let ye;e[36]!==P||e[37]!==d||e[38]!==tt||e[39]!==ge?(ye=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:d,width:tt,height:K.bottom*2,children:ge}),e[36]=P,e[37]=d,e[38]=tt,e[39]=ge,e[40]=ye):ye=e[40];let Be;e[41]===Symbol.for("react.memo_cache_sentinel")?(Be=[0,25,50,75,100],e[41]=Be):Be=e[41];let ve;e[42]!==c||e[43]!==l?(ve=s.jsx(Wt,{scale:l,width:c,tickValues:Be,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=c,e[43]=l,e[44]=ve):ve=e[44];const lt=`url(#${B})`;let be;e[45]!==w?(be=a=>w(a.t),e[45]=w,e[46]=be):be=e[46];let je;e[47]!==l?(je=a=>l(a.v),e[47]=l,e[48]=je):je=e[48];const ot=`url(#${I})`;let we;e[49]!==r||e[50]!==be||e[51]!==je||e[52]!==ot||e[53]!==l?(we=s.jsx(Xt,{data:r,x:be,y:je,yScale:l,curve:wt,fill:ot}),e[49]=r,e[50]=be,e[51]=je,e[52]=ot,e[53]=l,e[54]=we):we=e[54];let Se;e[55]!==w?(Se=a=>w(a.t),e[55]=w,e[56]=Se):Se=e[56];let ke;e[57]!==l?(ke=a=>l(a.v),e[57]=l,e[58]=ke):ke=e[58];let Me;e[59]!==n||e[60]!==r||e[61]!==Se||e[62]!==ke?(Me=s.jsx(Vt,{data:r,x:Se,y:ke,curve:wt,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=r,e[61]=Se,e[62]=ke,e[63]=Me):Me=e[63];let Ne;e[64]!==lt||e[65]!==we||e[66]!==Me?(Ne=s.jsxs("g",{clipPath:lt,children:[we,Me]}),e[64]=lt,e[65]=we,e[66]=Me,e[67]=Ne):Ne=e[67];const at=`url(#${P})`;let _e;e[68]!==h?(_e=a=>cs(+a,h),e[68]=h,e[69]=_e):_e=e[69];let $e;e[70]!==d||e[71]!==_e||e[72]!==U||e[73]!==w?($e=s.jsx(zt,{top:d,scale:w,tickValues:U,tickFormat:_e,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:ks}),e[70]=d,e[71]=_e,e[72]=U,e[73]=w,e[74]=$e):$e=e[74];let Ae;e[75]!==at||e[76]!==$e?(Ae=s.jsx("g",{mask:at,children:$e}),e[75]=at,e[76]=$e,e[77]=Ae):Ae=e[77];let Ge;e[78]===Symbol.for("react.memo_cache_sentinel")?(Ge=[0,25,50,75,100],e[78]=Ge):Ge=e[78];let Ee;e[79]!==l?(Ee=s.jsx(Yt,{scale:l,tickValues:Ge,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Ee):Ee=e[80];let Le;e[81]!==G||e[82]!==Y||e[83]!==n||e[84]!==S?(Le=S&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:G,cy:Y,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:G,cy:Y,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=G,e[82]=Y,e[83]=n,e[84]=S,e[85]=Le):Le=e[85];let Te;e[86]!==n||e[87]!==d||e[88]!==v||e[89]!==M||e[90]!==$?(Te=v&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${M}px)`},pointerEvents:"none",children:[s.jsx(Jt,{from:{x:0,y:kt},to:{x:0,y:d},stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:0,cy:0,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5,style:{transition:"transform 0.25s ease-out",transform:`translateY(${$}px)`}})]}),e[86]=n,e[87]=d,e[88]=v,e[89]=M,e[90]=$,e[91]=Te):Te=e[91];const rt=Math.max(0,c)+Mt,it=Math.max(0,d),ct=`${x} samples`,dt=Math.max(0,r.length-1),ut=W?Math.min(W.now,Math.max(0,r.length-1)):_,ft=W?W.text:r[_]?u(r[_]):void 0;let Oe;e[92]!==_||e[93]!==E?(Oe=()=>{le(!0),E(_)},e[92]=_,e[93]=E,e[94]=Oe):Oe=e[94];let Re;e[95]!==g?(Re=()=>{g(),le(!1)},e[95]=g,e[96]=Re):Re=e[96];let Ce;e[97]!==de||e[98]!==re||e[99]!==g||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Oe||e[108]!==Re?(Ce=s.jsx(Zt,{x:0,y:0,width:rt,height:it,fill:"transparent",tabIndex:0,role:"slider","aria-label":ct,"aria-valuemin":0,"aria-valuemax":dt,"aria-valuenow":ut,"aria-valuetext":ft,"aria-describedby":p,className:"outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",onFocus:Oe,onBlur:Re,onKeyDown:de,onMouseMove:re,onMouseLeave:g,onTouchMove:re,onTouchEnd:g,onTouchCancel:g}),e[97]=de,e[98]=re,e[99]=g,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Oe,e[108]=Re,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Ee||e[114]!==Le||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Ee,Le,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Ee,e[114]=Le,e[115]=Te,e[116]=Ce,e[117]=De):De=e[117];let Ie;e[118]!==m||e[119]!==ne||e[120]!==ue||e[121]!==me||e[122]!==pe||e[123]!==ye||e[124]!==De||e[125]!==o?(Ie=s.jsxs("svg",{width:o,height:m,role:Ve,"aria-label":ne,children:[ue,me,pe,ye,De]}),e[118]=m,e[119]=ne,e[120]=ue,e[121]=me,e[122]=pe,e[123]=ye,e[124]=De,e[125]=o,e[126]=Ie):Ie=e[126];let Pe;e[127]!==p?(Pe=s.jsx("p",{id:p,className:"sr-only",children:"Use the arrow keys to read individual samples, and End for the latest value. Escape hides the reading."}),e[127]=p,e[128]=Pe):Pe=e[128];let Ke;e[129]!==c||e[130]!==A||e[131]!==v||e[132]!==M||e[133]!==$?(Ke=v&&s.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 whitespace-nowrap rounded-lg border bg-background px-3 py-2 text-xs text-foreground shadow-md",style:{transform:`translate(${M+K.left}px, ${$+K.top}px) translate(${M>c*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",St(v.t)]}),s.jsxs("p",{children:[A,": ",We(v.v)]})]}),e[129]=c,e[130]=A,e[131]=v,e[132]=M,e[133]=$,e[134]=Ke):Ke=e[134];let qe;return e[135]!==Ie||e[136]!==Pe||e[137]!==Ke?(qe=s.jsxs(s.Fragment,{children:[Ie,Pe,Ke]}),e[135]=Ie,e[136]=Pe,e[137]=Ke,e[138]=qe):qe=e[138],qe}function ws(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function Ss(t){return`${t}%`}function ks(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{js as AreaChartInner,Es as MacResources};