@tapflowio/relay 0.24.0 → 0.25.0

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 (148) hide show
  1. package/dist/RelayServer.d.ts +45 -0
  2. package/dist/RelayServer.d.ts.map +1 -1
  3. package/dist/RelayServer.js +245 -30
  4. package/dist/RelayServer.js.map +1 -1
  5. package/dist/api/apps.d.ts.map +1 -1
  6. package/dist/api/apps.js +6 -16
  7. package/dist/api/apps.js.map +1 -1
  8. package/dist/api/auth.d.ts.map +1 -1
  9. package/dist/api/auth.js +3 -12
  10. package/dist/api/auth.js.map +1 -1
  11. package/dist/api/builds.d.ts.map +1 -1
  12. package/dist/api/builds.js +7 -5
  13. package/dist/api/builds.js.map +1 -1
  14. package/dist/api/comments.d.ts.map +1 -1
  15. package/dist/api/comments.js +41 -15
  16. package/dist/api/comments.js.map +1 -1
  17. package/dist/api/invitations.d.ts +1 -1
  18. package/dist/api/invitations.d.ts.map +1 -1
  19. package/dist/api/invitations.js +7 -3
  20. package/dist/api/invitations.js.map +1 -1
  21. package/dist/api/passwordReset.js +2 -2
  22. package/dist/api/team.d.ts +2 -2
  23. package/dist/api/team.d.ts.map +1 -1
  24. package/dist/api/team.js +6 -2
  25. package/dist/api/team.js.map +1 -1
  26. package/dist/api/tokens.d.ts +1 -1
  27. package/dist/api/tokens.d.ts.map +1 -1
  28. package/dist/api/tokens.js +26 -7
  29. package/dist/api/tokens.js.map +1 -1
  30. package/dist/api/webhooks.d.ts.map +1 -1
  31. package/dist/api/webhooks.js +11 -5
  32. package/dist/api/webhooks.js.map +1 -1
  33. package/dist/lib/clientAddress.d.ts +7 -0
  34. package/dist/lib/clientAddress.d.ts.map +1 -1
  35. package/dist/lib/clientAddress.js +15 -0
  36. package/dist/lib/clientAddress.js.map +1 -1
  37. package/dist/lib/connectionAuth.d.ts +57 -2
  38. package/dist/lib/connectionAuth.d.ts.map +1 -1
  39. package/dist/lib/connectionAuth.js +65 -6
  40. package/dist/lib/connectionAuth.js.map +1 -1
  41. package/dist/middleware/auth.d.ts +44 -4
  42. package/dist/middleware/auth.d.ts.map +1 -1
  43. package/dist/middleware/auth.js +99 -27
  44. package/dist/middleware/auth.js.map +1 -1
  45. package/package.json +3 -3
  46. package/public/assets/AppCenter-D_1rFI40.js +26 -0
  47. package/public/assets/AppCenter-D_1rFI40.js.br +0 -0
  48. package/public/assets/AppCenter-D_1rFI40.js.gz +0 -0
  49. package/public/assets/Default-DF_X2_3I.js +1 -0
  50. package/public/assets/Default-DF_X2_3I.js.br +0 -0
  51. package/public/assets/Default-DF_X2_3I.js.gz +0 -0
  52. package/public/assets/{Invite-EVMTsuNz.js → Invite-DETTWdYp.js} +1 -1
  53. package/public/assets/Invite-DETTWdYp.js.br +0 -0
  54. package/public/assets/Invite-DETTWdYp.js.gz +0 -0
  55. package/public/assets/{MacResources-fCn40Tf5.js → MacResources--1Enisxs.js} +1 -1
  56. package/public/assets/MacResources--1Enisxs.js.br +0 -0
  57. package/public/assets/MacResources--1Enisxs.js.gz +0 -0
  58. package/public/assets/{QASession-CL-eyFxG.js → QASession-BjoD9Toj.js} +3 -3
  59. package/public/assets/QASession-BjoD9Toj.js.br +0 -0
  60. package/public/assets/QASession-BjoD9Toj.js.gz +0 -0
  61. package/public/assets/{ResetPassword-D-SFg4ap.js → ResetPassword-B9miyXTP.js} +1 -1
  62. package/public/assets/ResetPassword-B9miyXTP.js.br +0 -0
  63. package/public/assets/ResetPassword-B9miyXTP.js.gz +0 -0
  64. package/public/assets/{Setup-ULjvIfAi.js → Setup-CywZCqHU.js} +1 -1
  65. package/public/assets/Setup-CywZCqHU.js.br +0 -0
  66. package/public/assets/Setup-CywZCqHU.js.gz +0 -0
  67. package/public/assets/{Team-DH91GD4w.js → Team-CxdX_9mY.js} +2 -2
  68. package/public/assets/Team-CxdX_9mY.js.br +0 -0
  69. package/public/assets/Team-CxdX_9mY.js.gz +0 -0
  70. package/public/assets/Tokens-BQnnawvG.js +1 -0
  71. package/public/assets/Tokens-BQnnawvG.js.br +0 -0
  72. package/public/assets/Tokens-BQnnawvG.js.gz +0 -0
  73. package/public/assets/alert-dialog-CuPdBkxF.js +1 -0
  74. package/public/assets/alert-dialog-CuPdBkxF.js.br +0 -0
  75. package/public/assets/alert-dialog-CuPdBkxF.js.gz +0 -0
  76. package/public/assets/{badge-B4QAWrzA.js → badge-CSVsKOK_.js} +1 -1
  77. package/public/assets/badge-CSVsKOK_.js.br +0 -0
  78. package/public/assets/badge-CSVsKOK_.js.gz +0 -0
  79. package/public/assets/{build-format-CtmRXihN.js → build-format-l9BrlbZl.js} +1 -1
  80. package/public/assets/build-format-l9BrlbZl.js.br +0 -0
  81. package/public/assets/build-format-l9BrlbZl.js.gz +0 -0
  82. package/public/assets/{dialog-BAFN_ONP.js → dialog-B6jt7-2f.js} +3 -3
  83. package/public/assets/dialog-B6jt7-2f.js.br +0 -0
  84. package/public/assets/dialog-B6jt7-2f.js.gz +0 -0
  85. package/public/assets/{index-COOWQXpW.js → index-Cm17I31a.js} +32 -32
  86. package/public/assets/index-Cm17I31a.js.br +0 -0
  87. package/public/assets/index-Cm17I31a.js.gz +0 -0
  88. package/public/assets/index-D_P99bPX.css +1 -0
  89. package/public/assets/index-D_P99bPX.css.br +0 -0
  90. package/public/assets/{index-ozCdBYxk.css.gz → index-D_P99bPX.css.gz} +0 -0
  91. package/public/assets/{list-view-Rrqp8TkG.js → list-view-Bp6pvsde.js} +1 -1
  92. package/public/assets/list-view-Bp6pvsde.js.br +0 -0
  93. package/public/assets/list-view-Bp6pvsde.js.gz +0 -0
  94. package/public/assets/{pencil-CAHyK7Qf.js → pencil-g-WiK1F2.js} +1 -1
  95. package/public/assets/pencil-g-WiK1F2.js.br +0 -0
  96. package/public/assets/pencil-g-WiK1F2.js.gz +0 -0
  97. package/public/assets/resource-health-BbeyA8an.js +1 -0
  98. package/public/assets/resource-health-BbeyA8an.js.br +0 -0
  99. package/public/assets/resource-health-BbeyA8an.js.gz +0 -0
  100. package/public/assets/{trash-CkO-5TRA.js → trash-DHPg15P4.js} +1 -1
  101. package/public/assets/trash-DHPg15P4.js.br +0 -0
  102. package/public/assets/trash-DHPg15P4.js.gz +0 -0
  103. package/public/index.html +2 -2
  104. package/public/index.html.br +0 -0
  105. package/public/index.html.gz +0 -0
  106. package/public/assets/AppCenter-BHz6vh5p.js +0 -26
  107. package/public/assets/AppCenter-BHz6vh5p.js.br +0 -0
  108. package/public/assets/AppCenter-BHz6vh5p.js.gz +0 -0
  109. package/public/assets/Default-bCqU0Qz9.js +0 -1
  110. package/public/assets/Default-bCqU0Qz9.js.br +0 -0
  111. package/public/assets/Default-bCqU0Qz9.js.gz +0 -0
  112. package/public/assets/Invite-EVMTsuNz.js.br +0 -0
  113. package/public/assets/Invite-EVMTsuNz.js.gz +0 -0
  114. package/public/assets/MacResources-fCn40Tf5.js.br +0 -0
  115. package/public/assets/MacResources-fCn40Tf5.js.gz +0 -0
  116. package/public/assets/QASession-CL-eyFxG.js.br +0 -0
  117. package/public/assets/QASession-CL-eyFxG.js.gz +0 -0
  118. package/public/assets/ResetPassword-D-SFg4ap.js.br +0 -0
  119. package/public/assets/ResetPassword-D-SFg4ap.js.gz +0 -0
  120. package/public/assets/Setup-ULjvIfAi.js.br +0 -0
  121. package/public/assets/Setup-ULjvIfAi.js.gz +0 -0
  122. package/public/assets/Team-DH91GD4w.js.br +0 -0
  123. package/public/assets/Team-DH91GD4w.js.gz +0 -0
  124. package/public/assets/Tokens-DImLpOVZ.js +0 -1
  125. package/public/assets/Tokens-DImLpOVZ.js.br +0 -0
  126. package/public/assets/Tokens-DImLpOVZ.js.gz +0 -0
  127. package/public/assets/alert-dialog-CwcUyDZQ.js +0 -1
  128. package/public/assets/alert-dialog-CwcUyDZQ.js.br +0 -0
  129. package/public/assets/alert-dialog-CwcUyDZQ.js.gz +0 -0
  130. package/public/assets/badge-B4QAWrzA.js.br +0 -0
  131. package/public/assets/badge-B4QAWrzA.js.gz +0 -0
  132. package/public/assets/build-format-CtmRXihN.js.br +0 -0
  133. package/public/assets/build-format-CtmRXihN.js.gz +0 -0
  134. package/public/assets/dialog-BAFN_ONP.js.br +0 -0
  135. package/public/assets/dialog-BAFN_ONP.js.gz +0 -0
  136. package/public/assets/index-COOWQXpW.js.br +0 -0
  137. package/public/assets/index-COOWQXpW.js.gz +0 -0
  138. package/public/assets/index-ozCdBYxk.css +0 -1
  139. package/public/assets/index-ozCdBYxk.css.br +0 -0
  140. package/public/assets/list-view-Rrqp8TkG.js.br +0 -0
  141. package/public/assets/list-view-Rrqp8TkG.js.gz +0 -0
  142. package/public/assets/pencil-CAHyK7Qf.js.br +0 -0
  143. package/public/assets/pencil-CAHyK7Qf.js.gz +0 -0
  144. package/public/assets/resource-health-BRpSwarg.js +0 -1
  145. package/public/assets/resource-health-BRpSwarg.js.br +0 -0
  146. package/public/assets/resource-health-BRpSwarg.js.gz +0 -0
  147. package/public/assets/trash-CkO-5TRA.js.br +0 -0
  148. package/public/assets/trash-CkO-5TRA.js.gz +0 -0
@@ -0,0 +1,26 @@
1
+ var Ue=l=>{throw TypeError(l)};var Ee=(l,e,s)=>e.has(l)||Ue("Cannot "+s);var k=(l,e,s)=>(Ee(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)=>(Ee(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),he=(l,e,s)=>(Ee(l,e,"access private method"),s);import{k as c,f as pe,j as t}from"./vendor-react-BlPSzrEe.js";import{z as xt,as as gt,ak as Ve,ac as bt,ao as et,aJ as tt,an as jt,at as yt,a2 as ve,av as J,B as re,L as ye,W as vt,I as He,F as St,Z as Nt,S as wt,G as Dt,T as kt,H as Ct,E as _t,f as At,ay as It,aI as We,aj as Et,Q as Ot,ar as Rt,ax as Ft,r as Tt,aq as $t,a7 as Mt,am as Pt,aa as Bt}from"./index-Cm17I31a.js";import{f as zt,d as Fe,S as Lt,P as qt,b as Qt,e as Kt}from"./build-format-l9BrlbZl.js";import{f as st,d as at,e as lt,i as ke,j as Ce,g as _e,h as F,S as Ae,a as nt,D as rt,C as Ut}from"./dialog-B6jt7-2f.js";import{P as Vt,T as Ht}from"./trash-DHPg15P4.js";import{B as Oe}from"./badge-CSVsKOK_.js";import{f as Wt,g as Jt,d as Gt,b as Xt,c as Yt,e as Zt,a as es,A as ts}from"./alert-dialog-CuPdBkxF.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=k(this,le).defaultMutationOptions(e),gt(this.options,s)||k(this,le).getMutationCache().notify({type:"observerOptionsUpdated",mutation:k(this,M),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Ve(s.mutationKey)!==Ve(this.options.mutationKey)?this.reset():((a=k(this,M))==null?void 0:a.state.status)==="pending"&&k(this,M).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&k(this,M)&&(k(this,M).addObserver(this),he(this,se,je).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=k(this,M))==null||e.removeObserver(this)}onMutationUpdate(e){he(this,se,je).call(this),he(this,se,Te).call(this,e)}getCurrentResult(){return k(this,de)}reset(){var e;(e=k(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=k(this,M))==null||a.removeObserver(this),me(this,M,k(this,le).getMutationCache().build(k(this,le),this.options)),k(this,M).addObserver(this),k(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=k(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(k(this,ne)&&this.hasListeners()){const d=k(this,de).variables,y=k(this,de).context,p={client:k(this,le),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(a=(s=k(this,ne)).onSuccess)==null||a.call(s,e.data,d,y,p)}catch(r){Promise.reject(r)}try{(u=(i=k(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=k(this,ne)).onError)==null||j.call(f,e.error,d,y,p)}catch(r){Promise.reject(r)}try{(m=(b=k(this,ne)).onSettled)==null||m.call(b,void 0,e.error,d,y,p)}catch(r){Promise.reject(r)}}}this.listeners.forEach(d=>{d(k(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
+ * @license lucide-react v1.47.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const it={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};it.node;const rs=ve(it);/**
7
+ * @license lucide-react v1.47.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ot={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};ot.node;const is=ve(ot);/**
12
+ * @license lucide-react v1.47.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ct={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};ct.node;const os=ve(ct);/**
17
+ * @license lucide-react v1.47.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const dt={name:"timer-off",size:24,node:[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]};dt.node;const cs=ve(dt);/**
22
+ * @license lucide-react v1.47.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ut={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};ut.node;const Je=ve(ut);function ds(l){const e=pe.c(37),{onSuccess:s,appId:a,canWrite:i}=l,[u,f]=c.useState(!1),[j,b]=c.useState(null),[m,d]=c.useState("none"),y=c.useRef(null);let p;e[0]!==a||e[1]!==j||e[2]!==s||e[3]!==m?(p=function(D){if(D.preventDefault(),!j)return;const O=new FormData;O.append("file",j),m!=="none"&&O.append("status",m),a&&O.append("app_id",String(a));const Z=fetch("/api/v1/builds",{method:"POST",credentials:"include",body:O}).then(async V=>{if(!V.ok){const ue=await V.json().catch(ms);throw new Error(ue.error??"Upload failed. Check the file format.")}s()});J.promise(Z,{loading:"Uploading build…",success:"Build uploaded",error:fs}),f(!1),b(null),d("none")},e[0]=a,e[1]=j,e[2]=s,e[3]=m,e[4]=p):p=e[4];const r=p;let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=function(D){f(D),D||(b(null),d("none"))},e[5]=N):N=e[5];const v=N;if(!i){let w;return e[6]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsxs(re,{size:"sm",onClick:hs,children:[t.jsx(Je,{className:"mr-2 h-4 w-4"}),"Upload build"]}),e[6]=w):w=e[6],w}let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(st,{asChild:!0,children:t.jsxs(re,{size:"sm",children:[t.jsx(Je,{className:"mr-2 h-4 w-4"}),"Upload build"]})}),e[7]=g):g=e[7];let C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(at,{children:t.jsx(lt,{children:"Upload build"})}),e[8]=C):C=e[8];let E;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(ye,{children:"File"}),e[9]=E):E=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{var w;return(w=y.current)==null?void 0:w.click()},e[10]=x):x=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=w=>{w.preventDefault();const D=w.dataTransfer.files[0];D&&b(D)},e[11]=_):_=e[11];const P=j?j.name:"Click or drag to upload";let T;e[12]!==P?(T=t.jsx("div",{className:"flex h-24 cursor-pointer items-center justify-center rounded-md border-2 border-dashed text-sm text-muted-foreground hover:border-primary",onClick:x,onDragOver:us,onDrop:_,children:P}),e[12]=P,e[13]=T):T=e[13];let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx("input",{ref:y,type:"file",accept:".zip,.apk,.tgz,.tar.gz,application/gzip,application/x-gzip",className:"hidden",onChange:w=>{var D;return b(((D=w.target.files)==null?void 0:D[0])??null)}}),e[14]=B):B=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx("code",{children:".app.zip"}),e[15]=L):L=e[15];let G;e[16]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsx("code",{children:".tar.gz"}),e[16]=G):G=e[16];let X;e[17]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx("code",{children:".tgz"}),e[17]=X):X=e[17];let H;e[18]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsxs("p",{className:"text-xs text-muted-foreground",children:["iOS: ",L," or ",G," / ",X," (e.g. an EAS simulator build)  · Android: ",t.jsx("code",{children:".apk"})]}),e[18]=H):H=e[18];let q;e[19]!==T?(q=t.jsxs("div",{className:"grid gap-2",children:[E,T,B,H]}),e[19]=T,e[20]=q):q=e[20];let Q;e[21]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsxs(ye,{children:["Status ",t.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e[21]=Q):Q=e[21];let Y;e[22]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx(ke,{children:t.jsx(Ce,{})}),e[22]=Y):Y=e[22];let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsxs(_e,{children:[t.jsx(F,{value:"none",children:"None"}),t.jsx(F,{value:"Backlog",children:"Backlog"}),t.jsx(F,{value:"In Progress",children:"In Progress"}),t.jsx(F,{value:"Done",children:"Done"}),t.jsx(F,{value:"Rejected",children:"Rejected"})]}),e[23]=K):K=e[23];let z;e[24]!==m?(z=t.jsxs("div",{className:"grid gap-2",children:[Q,t.jsxs(Ae,{value:m,onValueChange:d,children:[Y,K]})]}),e[24]=m,e[25]=z):z=e[25];let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx(re,{type:"button",variant:"outline",className:"w-24",onClick:()=>f(!1),children:"Cancel"}),e[26]=U):U=e[26];const W=!j;let A;e[27]!==W?(A=t.jsxs("div",{className:"flex justify-end gap-2",children:[U,t.jsx(re,{type:"submit",className:"w-24",disabled:W,children:"Upload"})]}),e[27]=W,e[28]=A):A=e[28];let $;e[29]!==r||e[30]!==q||e[31]!==z||e[32]!==A?($=t.jsxs(nt,{className:"sm:max-w-md",children:[C,t.jsxs("form",{onSubmit:r,className:"flex flex-col gap-4 pt-2",children:[q,z,A]})]}),e[29]=r,e[30]=q,e[31]=z,e[32]=A,e[33]=$):$=e[33];let R;return e[34]!==u||e[35]!==$?(R=t.jsxs(rt,{open:u,onOpenChange:v,children:[g,$]}),e[34]=u,e[35]=$,e[36]=R):R=e[36],R}function us(l){return l.preventDefault()}function hs(){return J.error("Viewers can't upload builds. Ask an Admin for QA or Developer access.")}function fs(l){return l instanceof Error?l.message:"Failed to upload build"}function ms(){return{}}function De(l){const e=pe.c(8);let s,a;e[0]!==l?({className:s,...a}=l,e[0]=l,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let i;e[3]!==s?(i=vt("font-mono text-xs tabular-nums tracking-tight",s),e[3]=s,e[4]=i):i=e[4];let u;return e[5]!==a||e[6]!==i?(u=t.jsx("span",{className:i,...a}),e[5]=a,e[6]=i,e[7]=u):u=e[7],u}function ps({onSuccess:l,canWrite:e}){const[s,a]=c.useState(!1),[i,u]=c.useState(""),[f,j]=c.useState(""),[b,m]=c.useState("ios"),[d,y]=c.useState(""),[p,r]=c.useState(!1);async function N(g){g.preventDefault(),y(""),r(!0);try{const C=await Nt({name:i.trim(),bundle_id_key:f.trim(),platform:b});if(!C){y("Failed to create app");return}if("error"in C){y(C.error);return}a(!1),u(""),j(""),m("ios"),J.success("App created"),l()}catch{y("Failed to create app — check your network"),J.error("Failed to create app — check your network")}finally{r(!1)}}const v=g=>t.jsxs("button",{type:"button",onClick:g,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:[t.jsx(Vt,{className:"size-3.5 shrink-0"}),t.jsx("span",{children:"Add App"})]});return e?t.jsxs(rt,{open:s,onOpenChange:a,children:[t.jsx(st,{asChild:!0,children:v()}),t.jsxs(nt,{className:"sm:max-w-sm",children:[t.jsx(at,{children:t.jsx(lt,{children:"Add App"})}),t.jsxs("form",{onSubmit:N,className:"flex flex-col gap-4 pt-2",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ye,{htmlFor:"app-name",children:"Name"}),t.jsx(He,{id:"app-name",value:i,onChange:g=>u(g.target.value),placeholder:"My App",required:!0})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ye,{htmlFor:"bundle-id",children:"Bundle ID"}),t.jsx(He,{id:"bundle-id",value:f,onChange:g=>j(g.target.value),placeholder:"com.example.myapp",required:!0})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(ye,{htmlFor:"platform",children:"Platform"}),t.jsxs(Ae,{value:b,onValueChange:g=>m(g),children:[t.jsx(ke,{id:"platform",children:t.jsx(Ce,{})}),t.jsxs(_e,{children:[t.jsx(F,{value:"ios",children:"iOS"}),t.jsx(F,{value:"android",children:"Android"}),t.jsx(F,{value:"both",children:"Both"})]})]})]}),t.jsx(St,{assertive:!0,id:"add-app-error",message:d||void 0}),t.jsx(re,{type:"submit",disabled:p,className:"w-full",children:p?"Creating…":"Create App"})]})]})]}):v(()=>J.error("Viewers can't add apps. Ask an Admin for QA or Developer access."))}function xs(l){const e=pe.c(17),{apps:s,selectedAppId:a,onSelect:i,onAdd:u,canWrite:f}=l;let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("span",{className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Apps"}),e[0]=j):j=e[0];let b;e[1]!==s.length?(b=s.length===0&&t.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:"No apps yet"}),e[1]=s.length,e[2]=b):b=e[2];let m;if(e[3]!==s||e[4]!==i||e[5]!==a){let p;e[7]!==i||e[8]!==a?(p=r=>t.jsxs("button",{onClick:()=>i(r.id),className:["flex flex-col gap-0.5 rounded-md px-2 py-2 text-left text-sm hover:bg-accent overflow-hidden",r.id===a?"bg-accent font-medium":""].join(" "),children:[t.jsx("span",{className:"truncate",children:r.name}),t.jsx(De,{className:"text-muted-foreground truncate",children:r.bundle_id_key})]},r.id),e[7]=i,e[8]=a,e[9]=p):p=e[9],m=s.map(p),e[3]=s,e[4]=i,e[5]=a,e[6]=m}else m=e[6];let d;e[10]!==f||e[11]!==u?(d=t.jsx("div",{className:"mt-1 border-t pt-1",children:t.jsx(ps,{onSuccess:u,canWrite:f})}),e[10]=f,e[11]=u,e[12]=d):d=e[12];let y;return e[13]!==b||e[14]!==m||e[15]!==d?(y=t.jsxs("aside",{className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[j,b,m,d]}),e[13]=b,e[14]=m,e[15]=d,e[16]=y):y=e[16],y}function gs(l){const e=pe.c(70),{build:s,isLast:a,onNavigate:i,onStatusChange:u,onScheduleDeletion:f,onCancelDeletion:j,canWrite:b,statusDescribedBy:m}=l,[d,y]=c.useState(!1),p=c.useRef(null),r=s.status_label==="Done";let N;e[0]!==s.delete_after?(N=s.delete_after?zt(s.delete_after):null,e[0]=s.delete_after,e[1]=N):N=e[1];const v=N;let g;e[2]!==s?(g=Fe(s),e[2]=s,e[3]=g):g=e[3];const C=g;let E;e[4]!==s.id||e[5]!==u?(E=function(ce){u(s.id,ce==="none"?null:ce)},e[4]=s.id,e[5]=u,e[6]=E):E=e[6];const x=E;let _;e[7]===Symbol.for("react.memo_cache_sentinel")?(_=xe=>{var ce;xe.preventDefault(),(ce=p.current)==null||ce.focus()},e[7]=_):_=e[7];let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsxs(Wt,{children:[t.jsx(Jt,{children:"Schedule deletion?"}),t.jsx(Gt,{children:"Build files will be deleted after 7 days. You can cancel the scheduled deletion anytime before then."})]}),e[8]=P):P=e[8];let T;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Xt,{children:"Cancel"}),e[9]=T):T=e[9];let B;e[10]!==s.id||e[11]!==f?(B=t.jsxs(Yt,{onCloseAutoFocus:_,children:[P,t.jsxs(Zt,{children:[T,t.jsx(es,{onClick:()=>{f(s.id),y(!1)},children:"Schedule deletion"})]})]}),e[10]=s.id,e[11]=f,e[12]=B):B=e[12];let L;e[13]!==d||e[14]!==B?(L=t.jsx(ts,{open:d,onOpenChange:y,children:B}),e[13]=d,e[14]=B,e[15]=L):L=e[15];const G=a?"":"border-b";let X;e[16]!==G?(X=["flex items-center gap-3 px-4 py-3",G],e[16]=G,e[17]=X):X=e[17];const H=X.join(" "),q=s.build_number??"—";let Q;e[18]!==q?(Q=t.jsxs("span",{className:"text-sm font-medium",children:["build ",t.jsx(De,{children:q})]}),e[18]=q,e[19]=Q):Q=e[19];const Y=s.platform==="ios"?"ios":"android";let K;e[20]!==s.platform||e[21]!==Y?(K=t.jsx(Oe,{tone:Y,className:"text-xs capitalize",children:s.platform}),e[20]=s.platform,e[21]=Y,e[22]=K):K=e[22];let z;e[23]!==s.status_label?(z=s.status_label&&t.jsx(Oe,{tone:Lt[s.status_label],className:"text-xs",children:s.status_label}),e[23]=s.status_label,e[24]=z):z=e[24];let U;e[25]!==v?(U=v&&t.jsx(Oe,{tone:v.urgent?"rejected":"backlog",className:"text-xs",children:v.label}),e[25]=v,e[26]=U):U=e[26];let W;e[27]!==Q||e[28]!==K||e[29]!==z||e[30]!==U?(W=t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Q,K,z,U]}),e[27]=Q,e[28]=K,e[29]=z,e[30]=U,e[31]=W):W=e[31];let A;e[32]===Symbol.for("react.memo_cache_sentinel")?(A={display:"flex",flexDirection:"row",gap:"14px",marginTop:"0.7rem",alignItems:"center"},e[32]=A):A=e[32];let $;e[33]!==s.uploader?($=s.uploader&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:s.uploader}),t.jsx(wt,{orientation:"vertical",className:"h-3"})]}),e[33]=s.uploader,e[34]=$):$=e[34];let R;e[35]!==s.uploaded_at?(R=new Date(s.uploaded_at).toLocaleDateString(),e[35]=s.uploaded_at,e[36]=R):R=e[36];let w;e[37]!==R?(w=t.jsx(De,{children:R}),e[37]=R,e[38]=w):w=e[38];let D;e[39]!==$||e[40]!==w?(D=t.jsxs("div",{style:A,className:"text-xs text-muted-foreground",children:[$,w]}),e[39]=$,e[40]=w,e[41]=D):D=e[41];let O;e[42]!==W||e[43]!==D?(O=t.jsxs("div",{className:"flex-1 min-w-0",children:[W,D]}),e[42]=W,e[43]=D,e[44]=O):O=e[44];let Z;e[45]!==s.id||e[46]!==s.status_label||e[47]!==b||e[48]!==v||e[49]!==x||e[50]!==j||e[51]!==C||e[52]!==m?(Z=b&&t.jsxs(t.Fragment,{children:[t.jsxs(Ae,{value:s.status_label??"none",onValueChange:x,children:[t.jsx(ke,{className:"h-9 w-32 text-xs","aria-label":`Status for ${C}`,"aria-describedby":m,"data-status-trigger":s.id,children:t.jsx(Ce,{})}),t.jsxs(_e,{children:[t.jsx(F,{value:"none",children:t.jsx("span",{className:"text-muted-foreground",children:"—"})}),t.jsx(F,{value:"Backlog",children:"Backlog"}),t.jsx(F,{value:"In Progress",children:"In Progress"}),t.jsx(F,{value:"Done",children:"Done"}),t.jsx(F,{value:"Rejected",children:"Rejected"})]})]}),t.jsx(Dt,{delayDuration:400,children:t.jsxs(kt,{children:[t.jsx(Ct,{asChild:!0,children:v?t.jsx(re,{ref:p,size:"icon-sm",variant:"outline",onClick:()=>j(s.id),"aria-label":`Cancel scheduled deletion of ${C}`,children:t.jsx(cs,{className:"h-3.5 w-3.5","aria-hidden":!0})}):t.jsx(re,{ref:p,size:"icon-sm",variant:"destructive",onClick:()=>y(!0),"aria-label":`Schedule deletion of ${C}`,children:t.jsx(Ht,{className:"h-3.5 w-3.5","aria-hidden":!0})})}),t.jsx(_t,{children:v?"Cancel scheduled deletion":"Schedule deletion"})]})})]}),e[45]=s.id,e[46]=s.status_label,e[47]=b,e[48]=v,e[49]=x,e[50]=j,e[51]=C,e[52]=m,e[53]=Z):Z=e[53];let V;e[54]!==s.id||e[55]!==i?(V=()=>i(s.id),e[54]=s.id,e[55]=i,e[56]=V):V=e[56];const ue=`Start QA on ${C}`;let ie;e[57]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx(qt,{className:"mr-1.5 h-3.5 w-3.5"}),e[57]=ie):ie=e[57];let oe;e[58]!==r||e[59]!==V||e[60]!==ue?(oe=t.jsxs(re,{size:"sm",onClick:V,disabled:r,"aria-label":ue,children:[ie,"Start QA"]}),e[58]=r,e[59]=V,e[60]=ue,e[61]=oe):oe=e[61];let ae;e[62]!==H||e[63]!==O||e[64]!==Z||e[65]!==oe?(ae=t.jsxs("div",{className:H,children:[O,Z,oe]}),e[62]=H,e[63]=O,e[64]=Z,e[65]=oe,e[66]=ae):ae=e[66];let te;return e[67]!==ae||e[68]!==L?(te=t.jsxs(t.Fragment,{children:[L,ae]}),e[67]=ae,e[68]=L,e[69]=te):te=e[69],te}function bs(l){const e=pe.c(29),{versionName:s,builds:a,isOpen:i,onToggle:u,onNavigate:f,onStatusChange:j,onScheduleDeletion:b,onCancelDeletion:m,canWrite:d,describedBy:y,rowNote:p}=l,r=c.useId(),N=i?r:void 0;let v;e[0]!==i?(v=i?t.jsx(Ut,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):t.jsx(At,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[0]=i,e[1]=v):v=e[1];let g;e[2]!==s?(g=t.jsx(De,{className:"font-medium text-sm text-foreground",children:s}),e[2]=s,e[3]=g):g=e[3];const C=a.length>1?"s":"";let E;e[4]!==a.length||e[5]!==C?(E=t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",a.length," build",C,")"]}),e[4]=a.length,e[5]=C,e[6]=E):E=e[6];let x;e[7]!==y||e[8]!==i||e[9]!==u||e[10]!==N||e[11]!==v||e[12]!==g||e[13]!==E||e[14]!==s?(x=t.jsx("h2",{children:t.jsxs("button",{className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent/50 bg-card focus-visible:outline-none focus-visible:outline-offset-[-2px] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:u,"aria-expanded":i,"aria-controls":N,"aria-describedby":y,"data-release-header":s,children:[v,g,E]})}),e[7]=y,e[8]=i,e[9]=u,e[10]=N,e[11]=v,e[12]=g,e[13]=E,e[14]=s,e[15]=x):x=e[15];let _;e[16]!==a||e[17]!==d||e[18]!==i||e[19]!==m||e[20]!==f||e[21]!==b||e[22]!==j||e[23]!==r||e[24]!==p?(_=i&&t.jsx("div",{id:r,className:"border-t bg-card",children:a.map((T,B)=>t.jsx(gs,{build:T,isLast:B===a.length-1,onNavigate:f,onStatusChange:j,onScheduleDeletion:b,onCancelDeletion:m,canWrite:d,statusDescribedBy:(p==null?void 0:p.buildId)===T.id?p.id:void 0},T.id))}),e[16]=a,e[17]=d,e[18]=i,e[19]=m,e[20]=f,e[21]=b,e[22]=j,e[23]=r,e[24]=p,e[25]=_):_=e[25];let P;return e[26]!==x||e[27]!==_?(P=t.jsxs("div",{className:"rounded-lg shadow-card-2 overflow-hidden",children:[x,_]}),e[26]=x,e[27]=_,e[28]=P):P=e[28],P}const ht="tapflow-app-center-releases:";function js(l){try{const e=JSON.parse(localStorage.getItem(ht+l)??"[]");return Array.isArray(e)?e.filter(s=>Array.isArray(s)&&s.length===2&&typeof s[0]=="string"&&typeof s[1]=="boolean"):[]}catch{return[]}}function ys(l,e){try{localStorage.setItem(ht+l,JSON.stringify(e))}catch{}}function vs(l,e){const s=pe.c(13),[a,i]=c.useState(Ss);let u;s[0]!==l||s[1]!==a?(u=l===null?[]:a.get(l)??js(l),s[0]=l,s[1]=a,s[2]=u):u=s[2];const f=u,j=e[0];let b;s[3]!==j||s[4]!==f?(b=r=>{var N;return((N=f.find(v=>{const[g]=v;return g===r}))==null?void 0:N[1])??r===j},s[3]=j,s[4]=f,s[5]=b):b=s[5];const m=b;let d;s[6]!==l||s[7]!==m||s[8]!==f?(d=r=>{if(l===null)return;const N=[...f.filter(v=>{const[g]=v;return g!==r}),[r,!m(r)]].slice(-200);ys(l,N),i(v=>new Map(v).set(l,N))},s[6]=l,s[7]=m,s[8]=f,s[9]=d):d=s[9];const y=d;let p;return s[10]!==m||s[11]!==y?(p={isOpen:m,toggle:y},s[10]=m,s[11]=y,s[12]=p):p=s[12],p}function Ss(){return new Map}const Ne=l=>`row:${l}`,we=l=>`release:${l}`;function Ge(l){return l instanceof HTMLElement?l.dataset.statusTrigger!==void 0?Ne(Number(l.dataset.statusTrigger)):l.dataset.releaseHeader!==void 0?we(l.dataset.releaseHeader):null:null}function Xe(l,e){const s=new Set(JSON.parse(e));return l.find(a=>s.has(a))??null}function Ye(l,e){return l.map((s,a)=>({item:s,d:a>e?2*(a-e)-1:2*(e-a)})).filter(({d:s})=>s>0).sort((s,a)=>s.d-a.d).map(({item:s})=>s)}function Rs(){var Qe;const l=as(),[e,s]=ls(),a=tt(),{user:i}=It(),u=(i==null?void 0:i.role)!=="Viewer",[f,j]=c.useState(""),[b,m]=c.useState(""),[d,y]=c.useState("all");c.useEffect(()=>{const n=setTimeout(()=>m(f),250);return()=>clearTimeout(n)},[f]);const p=e.get("appId"),r=p!==null&&/^[1-9][0-9]*$/.test(p)?Number(p):null,N=We({queryKey:["apps"],queryFn:Mt}),v=N.data??[],g=v.find(n=>n.id===r)??null,C=["builds",r,b,d],E=JSON.stringify(C),x=We({queryKey:C,queryFn:()=>Bt({appId:r,search:b,statusFilter:d}),enabled:r!==null,placeholderData:Pt}),_=x.data??[];c.useEffect(()=>{!N.data||e.get("appId")||N.data.length===0||s({appId:String(N.data[0].id)},{replace:!0})},[N.data,e,s]);const[P,T]=c.useState(null),[B,L]=c.useState(!1);c.useEffect(()=>{x.isRefetchError&&J.error("Couldn't refresh builds — showing the last list",{id:"builds:refresh"})},[x.isRefetchError]);const G=c.useRef(null);c.useEffect(()=>{r===null||x.isPlaceholderData||!x.data||G.current!==r&&(G.current=r,T(r))},[r,x.isPlaceholderData,x.data]);function X(n){s({appId:String(n)})}function H(n,h){return{onMutate:async o=>{const S=C;await a.cancelQueries({queryKey:S});const I=a.getQueryData(S);return a.setQueryData(S,ee=>ee&&n(ee,o)),{previous:I,key:S}},onError:(o,S,I)=>{if(I!=null&&I.previous&&a.setQueryData(I.key,I.previous),o instanceof Tt){a.invalidateQueries({queryKey:$t.me}),J.error(o.message);return}J.error(h)},onSettled:()=>{a.invalidateQueries({queryKey:["builds"]})}}}const q=H((n,h)=>n.map(o=>o.id===h.buildId?{...o,status_label:h.status}:o),"Failed to update status"),Q=Re({mutationFn:({buildId:n,status:h})=>Ft(n,h),...q,onError:(n,h,o)=>{var S;q.onError(n,h,o),((S=R.current)==null?void 0:S.leaving)===h.buildId&&(R.current=null,O(null))}}),Y=(n,h)=>{var S;const o=(S=a.getQueryData(n))==null?void 0:S.find(I=>I.id===h);return o?Fe(o):"the build"},K=Re({mutationFn:n=>Rt(n),...H((n,h)=>n.map(o=>o.id===h?{...o,delete_after:new Date().toISOString()}:o),"Failed to schedule deletion"),onSuccess:(n,h,o)=>{o&&(a.setQueryData(o.key,S=>S==null?void 0:S.map(I=>I.id===h?{...I,delete_after:n}:I)),J.success(`Deletion scheduled for ${Y(o.key,h)} — it will be deleted ${Kt(n)}`))}}),z=Re({mutationFn:n=>Ot(n),...H((n,h)=>n.map(o=>o.id===h?{...o,delete_after:null}:o),"Failed to cancel scheduled deletion"),onSuccess:(n,h,o)=>{J.success(`Scheduled deletion cancelled for ${o?Y(o.key,h):"the build"}`)}}),U=n=>K.mutate(n),W=n=>z.mutate(n),A=Et(_),$=vs(((Qe=_[0])==null?void 0:Qe.app_id)??null,A.map(n=>n.versionName)),R=c.useRef(null),w=c.useRef(null),[D,O]=c.useState(null),Z=c.useRef(null),V=c.useId();function ue(n){const h=A.findIndex(S=>S.builds.some(I=>I.id===n));if(h<0)return[];const o=A[h].builds;return[...Ye(o,o.findIndex(S=>S.id===n)).map(S=>Ne(S.id)),...Ye(A,h).map(S=>we(S.versionName))]}const ie=JSON.stringify(A.flatMap(n=>[we(n.versionName),...$.isOpen(n.versionName)?n.builds.map(h=>Ne(h.id)):[]])),oe=(n,h)=>{const o=_.find(ee=>ee.id===n),I=d!=="all"&&h!==d?ue(n):[];if(o&&I.length>0){const ee=`${Fe(o)} was set to ${h??"no status"}, so the ${d} filter no longer shows it.`,Ke={leaving:n,candidates:I,text:ee,key:E};R.current=Ke,w.current=null,O(Ke)}Q.mutate({buildId:n,status:h})},ae=D!==null&&!_.some(n=>n.id===D.leaving),te=ae?Xe(D.candidates,ie):null,xe=x.data,ce=x.isRefetchError;c.useLayoutEffect(()=>{var I;const n=R.current;if(!n)return;if(n.key!==E||ce){R.current=null,O(null);return}if((xe??[]).some(ee=>ee.id===n.leaving))return;R.current=null;const h=Xe(n.candidates,ie);if(!h||document.activeElement!==null&&document.activeElement!==document.body){J.success(n.text),O(null);return}const o=((I=Z.current)==null?void 0:I.querySelectorAll("[data-status-trigger], [data-release-header]"))??[],S=Array.from(o).find(ee=>Ge(ee)===h);S instanceof HTMLElement?(w.current=h,S.focus()):(J.success(n.text),O(null))},[E,ce,xe,ie]),c.useEffect(()=>{if(!D)return;const n=h=>{const o=Ge(h.target);if(w.current!==null){o!==w.current&&O(null);return}o!==Ne(D.leaving)&&(o===null||!D.candidates.includes(o))&&O(null)};return document.addEventListener("focusin",n),()=>document.removeEventListener("focusin",n)},[D]);const ge=(g==null?void 0:g.name)??"this app",Ie=b!==""||d!=="all",$e=x.isPlaceholderData&&P!==r,ft=x.isFetchedAfterMount&&(x.isPlaceholderData||x.isLoading),be=B||ft,Se=x.isLoadingError||be?"error":x.isLoading||A.length===0&&$e?"loading":A.length===0?"empty":"list",Me=c.useRef(null),mt=ss(Se,Me),Pe=c.useId(),Be=c.useId(),ze=c.useId(),Le=c.useId(),qe=c.useId(),pt=r===null?"":x.isLoadingError?`Couldn't load builds for ${ge}`:x.isLoading||$e||be?`Loading builds for ${ge}`:A.length>0?`Showing ${_.length} build${_.length===1?"":"s"} for ${ge}`:Ie?`No builds match the current filters for ${ge}`:`No builds for ${ge}`;return t.jsxs("div",{className:"flex h-full gap-0",children:[t.jsx(xs,{apps:v,selectedAppId:r,onSelect:X,onAdd:()=>a.invalidateQueries({queryKey:["apps"]}),canWrite:u}),t.jsxs("div",{className:"flex-1 flex flex-col gap-4 p-4 overflow-y-auto min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[t.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:g?g.name:"App Center"}),t.jsx(ds,{onSuccess:()=>{a.invalidateQueries({queryKey:["apps"]}),a.invalidateQueries({queryKey:["builds"]})},appId:r,canWrite:u})]}),t.jsx("p",{id:qe,role:"status",className:"sr-only",children:pt}),r===null?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[t.jsx(is,{className:"w-8 h-8 text-muted-foreground/40"}),t.jsx("p",{className:"text-sm font-medium",children:"No app selected"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose an app from the sidebar to view its builds."})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Qt,{ref:Me,"aria-describedby":`${Le} ${ze}`,"aria-label":"Search versions",placeholder:"Search version…",value:f,onChange:j}),t.jsxs(Ae,{value:d,onValueChange:y,children:[t.jsx(ke,{className:"h-8 w-36","aria-label":"Filter by status",children:t.jsx(Ce,{placeholder:"Status"})}),t.jsxs(_e,{children:[t.jsx(F,{value:"all",children:"All statuses"}),t.jsx(F,{value:"Backlog",children:"Backlog"}),t.jsx(F,{value:"In Progress",children:"In Progress"}),t.jsx(F,{value:"Done",children:"Done"}),t.jsx(F,{value:"Rejected",children:"Rejected"})]})]}),x.isRefetchError&&t.jsx("p",{className:"text-sm text-muted-foreground self-center",children:"Showing the last list — refresh failed."})]}),t.jsx("div",{...mt,className:"contents",children:Se==="error"?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[t.jsx(rs,{className:"w-8 h-8 text-muted-foreground/40"}),t.jsx("p",{id:Pe,className:"text-sm font-medium",children:"Couldn't load builds"}),t.jsx("p",{id:Be,className:"text-sm text-muted-foreground",children:"Check that the relay is reachable."}),t.jsx(re,{variant:"outline",size:"sm",className:"mt-1 aria-disabled:opacity-50","aria-describedby":`${Pe} ${Be}`,"aria-disabled":be,onClick:()=>{be||(L(!0),x.refetch().finally(()=>L(!1)))},children:be?"Trying…":"Try again"})]}):Se==="loading"?t.jsx("p",{id:Le,className:"text-sm text-muted-foreground",children:"Loading…"}):Se==="empty"?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[t.jsx(os,{className:"w-8 h-8 text-muted-foreground/40"}),t.jsx("p",{id:ze,className:"text-sm font-medium",children:Ie?"No matching builds":"No builds yet"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:Ie?"No build matches the search and status filters.":u?"Upload the first build to get started.":"Builds appear here once a teammate uploads one."})]}):t.jsxs("div",{ref:Z,className:"flex flex-col gap-2","aria-busy":x.isPlaceholderData,children:[ae&&t.jsx("p",{id:V,hidden:!0,children:D.text}),A.map(({versionName:n,builds:h},o)=>t.jsx(bs,{describedBy:[o===0&&!x.isPlaceholderData?qe:null,te===we(n)?V:null].filter(Boolean).join(" ")||void 0,rowNote:te!=null&&te.startsWith("row:")?{buildId:Number(te.slice(4)),id:V}:void 0,versionName:n,builds:h,isOpen:$.isOpen(n),onToggle:()=>$.toggle(n),onNavigate:S=>l(`/app-center/build?id=${S}`),onStatusChange:oe,onScheduleDeletion:U,onCancelDeletion:W,canWrite:u},n))]})})]})]})]})}export{Rs as AppCenter};
@@ -0,0 +1 @@
1
+ import{k as m,j as e}from"./vendor-react-BlPSzrEe.js";import{aO as ce,ay as me,aJ as ue,aI as $,aF as A,aw as k,aL as pe,C as y,c as b,d as N,a as S,L as c,I as u,F as p,S as Y,h as G,av as i,B as f,K as ge,W as fe,O as he,aq as g,ap as F,J as Z,au as h,ag as xe,a7 as je}from"./index-Cm17I31a.js";import{B as ve}from"./badge-CSVsKOK_.js";import{A as we,h as ye,c as be,f as Ne,g as Se,d as Pe,e as Ce,b as Ae,a as ke}from"./alert-dialog-CuPdBkxF.js";import{P as X}from"./pencil-g-WiK1F2.js";import"./vendor-router-B_lVHrKl.js";const Fe=F({teamName:h().min(1,"Team name is required"),logo:Z(File).nullable().optional()}),De=F({displayName:h().min(1,"Display name is required"),avatar:Z(File).nullable().optional()}),qe=F({currentPassword:h().min(1,"Enter your current password"),newPassword:h().min(8,"Password must be at least 8 characters"),confirmPassword:h()}).refine(x=>x.newPassword===x.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function _e(){var K,U,W,H,M,V,J;const{resolvedTheme:x}=ce(),I=x==="dark"?"/logo-dark.svg":"/logo.svg",{user:t}=me(),D=(t==null?void 0:t.role)==="Admin",q=(t==null?void 0:t.role)==="Admin"||(t==null?void 0:t.role)==="Developer"||(t==null?void 0:t.role)==="QA",j=ue(),P=$({queryKey:g.settings,queryFn:xe,enabled:D}),[ee,se]=m.useState(null),re=ee??((K=P.data)==null?void 0:K.logo_url)??null,T=m.useRef(null),d=A({resolver:k(Fe),defaultValues:{teamName:"",logo:null},values:P.data?{teamName:P.data.team_name,logo:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ae(s){const r=new FormData;r.append("team_name",s.teamName),s.logo&&r.append("logo",s.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update workspace");return}i.success("Workspace updated"),j.invalidateQueries({queryKey:g.settings})}catch{i.error("Failed to update workspace")}}const[te,oe]=m.useState(null),L=te??(t==null?void 0:t.avatarUrl)??null,Q=m.useRef(null),l=A({resolver:k(De),defaultValues:{displayName:"",avatar:null},values:t?{displayName:t.displayName??"",avatar:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ie(s){const r=new FormData;r.append("display_name",s.displayName),s.avatar&&r.append("avatar",s.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update profile");return}i.success("Profile updated"),j.invalidateQueries({queryKey:g.me})}catch{i.error("Failed to update profile")}}const o=A({resolver:k(qe)});async function ne(s){try{const r=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:s.currentPassword,newPassword:s.newPassword})});if(!r.ok){const a=await r.json();o.setError("root",{message:a.error??"Failed to change password"});return}o.reset(),i.success("Password changed")}catch{o.setError("root",{message:"Network error"})}}const C=$({queryKey:g.apps,queryFn:je,enabled:q}).data??[],[E,z]=m.useState({}),[O,R]=m.useState({}),[_,B]=m.useState({});async function le(s){B(r=>({...r,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"DELETE",credentials:"include"})).ok){i.error("Failed to delete app");return}j.invalidateQueries({queryKey:g.apps}),i.success("App deleted")}catch{i.error("Failed to delete app")}finally{B(r=>({...r,[s]:!1}))}}async function de(s){var r;R(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E[s]??((r=C.find(n=>n.id===s))==null?void 0:r.name)})})).ok){i.error("Failed to update app");return}i.success("App updated"),z(({[s]:n,...w})=>w),j.invalidateQueries({queryKey:g.apps})}catch{i.error("Failed to update app")}finally{R(a=>({...a,[s]:!1}))}}const v=pe({control:l.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"}),D&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Workspace"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:d.handleSubmit(ae),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:(U=d.formState.errors.teamName)==null?void 0:U.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(G,{name:"logo",control:d.control,render:({field:s})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:re??I,alt:"Workspace logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button","aria-label":"Change logo",onClick:()=>{var r;return(r=T.current)==null?void 0:r.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:T,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:r=>{var n;const a=(n=r.target.files)==null?void 0:n[0];if(a&&a.size>2*1024*1024){i.error("Image must be 2MB or less");return}a&&(s.onChange(a),se(URL.createObjectURL(a)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Profile"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:l.handleSubmit(ie),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":!!l.formState.errors.displayName,"aria-describedby":l.formState.errors.displayName?"displayName-error":void 0,...l.register("displayName")}),e.jsx(p,{id:"displayName-error",message:(W=l.formState.errors.displayName)==null?void 0:W.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(G,{name:"avatar",control:l.control,render:({field:s})=>{var r;return e.jsxs("div",{className:"relative w-14 h-14",children:[L?e.jsx("img",{src:L,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=ge(v||(t==null?void 0:t.email)||"");return{backgroundColor:a.bg,color:a.fg}})(),children:((r=v==null?void 0:v[0])==null?void 0:r.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":"Change avatar",onClick:()=>{var a;return(a=Q.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:Q,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var w;const n=(w=a.target.files)==null?void 0:w[0];if(n&&n.size>2*1024*1024){i.error("Image must be 2MB or less");return}n&&(s.onChange(n),oe(URL.createObjectURL(n)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:l.formState.isSubmitting,children:l.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Password"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:o.handleSubmit(ne),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":!!o.formState.errors.currentPassword,"aria-describedby":o.formState.errors.currentPassword?"currentPassword-error":void 0,...o.register("currentPassword")}),e.jsx(p,{id:"currentPassword-error",message:(H=o.formState.errors.currentPassword)==null?void 0:H.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":!!o.formState.errors.newPassword,"aria-describedby":o.formState.errors.newPassword?"newPassword-error":void 0,...o.register("newPassword")}),e.jsx(p,{id:"newPassword-error",message:(M=o.formState.errors.newPassword)==null?void 0:M.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":!!o.formState.errors.confirmPassword,"aria-describedby":o.formState.errors.confirmPassword?"confirmPassword-error":void 0,...o.register("confirmPassword")}),e.jsx(p,{id:"confirmPassword-error",message:(V=o.formState.errors.confirmPassword)==null?void 0:V.message})]}),e.jsx(p,{assertive:!0,id:"default-error",message:(J=o.formState.errors.root)==null?void 0:J.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:o.formState.isSubmitting,children:o.formState.isSubmitting?"Saving…":"Change password"})})]})})]}),q&&C.length>0&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Apps"})}),e.jsx(S,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:C.map(s=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(c,{htmlFor:`app-${s.id}`,children:"App Name"}),e.jsx(u,{id:`app-${s.id}`,value:E[s.id]??s.name,onChange:r=>z(a=>({...a,[s.id]:r.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:s.bundle_id_key}),e.jsx(ve,{tone:s.platform==="ios"?"ios":s.platform==="android"?"android":void 0,variant:s.platform==="both"?"secondary":void 0,className:"capitalize",children:s.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(f,{size:"sm",variant:"outline",disabled:O[s.id],onClick:()=>de(s.id),children:O[s.id]?"Saving…":"Save"}),e.jsxs(we,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(f,{size:"sm",variant:"destructive",disabled:_[s.id],children:_[s.id]?"Deleting…":"Delete"})}),e.jsxs(be,{children:[e.jsxs(Ne,{children:[e.jsx(Se,{children:"Delete app?"}),e.jsxs(Pe,{children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(Ce,{children:[e.jsx(Ae,{className:"w-24",children:"Cancel"}),e.jsx(ke,{className:fe(he({variant:"destructive"}),"w-24"),onClick:()=>le(s.id),children:"Delete"})]})]})]})]})]})]},s.id))})})]})]})}export{_e as DefaultSettings};
@@ -1 +1 @@
1
- import{k as S,j as e}from"./vendor-react-BlPSzrEe.js";import{aD as H,au as M,aJ as Q,aH as U,aG as _,C as F,c as q,d as I,b as R,a as O,L as d,I as v,h as Y,H as z,F as c,S as G,B as J,ao as T,an as V,as as h,_ as W,aK as X}from"./index-COOWQXpW.js";import{b as Z,c as $}from"./vendor-router-B_lVHrKl.js";import{P as ee}from"./pencil-CAHyK7Qf.js";const ae=V({displayName:h().optional(),avatar:W(File).nullable().optional(),password:h().min(8,"Password must be at least 8 characters"),confirm:h()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ne(){var y,b,N,C,k;const o=Z(),[E]=$(),t=E.get("token")??"",[f,A]=S.useState(null),x=S.useRef(null),{register:m,handleSubmit:B,control:g,setError:u,formState:{errors:s,isSubmitting:j}}=H({resolver:M(ae),defaultValues:{displayName:"",avatar:null}}),l=Q({control:g,name:"displayName"})??"",K=U(),p=_({queryKey:T.inviteToken(t),queryFn:()=>X(t),enabled:t!=="",staleTime:1/0}),w=!t||p.isError?"invalid":p.isPending?"loading":"valid",L=((y=p.data)==null?void 0:y.role)??"";async function D(r){var i;try{const a=new FormData;if(a.append("token",t),a.append("password",r.password),(i=r.displayName)!=null&&i.trim()&&a.append("display_name",r.displayName.trim()),r.avatar&&a.append("avatar",r.avatar),!(await fetch("/api/v1/invitations/accept",{method:"POST",body:a})).ok){u("root",{message:"Failed to accept invitation"});return}K.removeQueries({queryKey:T.inviteToken(t)}),o("/app-center",{replace:!0})}catch{u("root",{message:"Network error. Please try again."})}}return w==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):w==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(F,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(q,{children:[e.jsx(I,{children:"Invitation expired"}),e.jsx(R,{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(F,{level:4,className:"w-full max-w-sm",children:[e.jsxs(q,{className:"text-center",children:[e.jsx(I,{children:"Set up your account"}),e.jsxs(R,{children:["You're joining as ",e.jsx("strong",{children:L})]})]}),e.jsx(O,{children:e.jsxs("form",{onSubmit:B(D),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(v,{id:"display-name",placeholder:"Your name",...m("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(Y,{name:"avatar",control:g,render:({field:r})=>{var i;return e.jsxs("div",{className:"relative w-14 h-14",children:[f?e.jsx("img",{src:f,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 a=z(l);return{backgroundColor:a.bg,color:a.fg}})(),children:((i=l==null?void 0:l[0])==null?void 0:i.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":s.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":s.avatar?"avatar-error":void 0,onClick:()=>{var a;return(a=x.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(ee,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:a=>{var P;const n=(P=a.target.files)==null?void 0:P[0];if(n){if(n.size>2*1024*1024){u("avatar",{message:"Max 2MB for avatar"});return}r.onChange(n),A(URL.createObjectURL(n))}}})]})}}),e.jsx(c,{assertive:!0,id:"avatar-error",message:(b=s.avatar)==null?void 0:b.message})]}),e.jsx(G,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"password",children:"Password"}),e.jsx(v,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,...m("password")}),e.jsx(c,{id:"password-error",message:(N=s.password)==null?void 0:N.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(v,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.confirm,"aria-describedby":s.confirm?"confirm-error":void 0,...m("confirm")}),e.jsx(c,{id:"confirm-error",message:(C=s.confirm)==null?void 0:C.message})]}),e.jsx(c,{assertive:!0,id:"invite-error",message:(k=s.root)==null?void 0:k.message}),e.jsx(J,{type:"submit",disabled:j,className:"w-full",children:j?"Creating account…":"Create account"})]})})]})})}export{ne as Invite};
1
+ import{k as F,j as e}from"./vendor-react-BlPSzrEe.js";import{aF as Q,aw as U,aL as D,aJ as J,aI as O,C as S,c as q,d as I,b as R,a as Y,L as d,I as v,h as _,K as z,F as c,S as H,B as V,aq as T,ap as W,au as h,J as G,aM as X}from"./index-Cm17I31a.js";import{b as Z,c as $}from"./vendor-router-B_lVHrKl.js";import{P as ee}from"./pencil-g-WiK1F2.js";const ae=W({displayName:h().optional(),avatar:G(File).nullable().optional(),password:h().min(8,"Password must be at least 8 characters"),confirm:h()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ne(){var y,b,N,C,k;const o=Z(),[E]=$(),t=E.get("token")??"",[f,L]=F.useState(null),x=F.useRef(null),{register:m,handleSubmit:A,control:g,setError:u,formState:{errors:s,isSubmitting:j}}=Q({resolver:U(ae),defaultValues:{displayName:"",avatar:null}}),l=D({control:g,name:"displayName"})??"",B=J(),p=O({queryKey:T.inviteToken(t),queryFn:()=>X(t),enabled:t!=="",staleTime:1/0}),w=!t||p.isError?"invalid":p.isPending?"loading":"valid",K=((y=p.data)==null?void 0:y.role)??"";async function M(r){var i;try{const a=new FormData;if(a.append("token",t),a.append("password",r.password),(i=r.displayName)!=null&&i.trim()&&a.append("display_name",r.displayName.trim()),r.avatar&&a.append("avatar",r.avatar),!(await fetch("/api/v1/invitations/accept",{method:"POST",body:a})).ok){u("root",{message:"Failed to accept invitation"});return}B.removeQueries({queryKey:T.inviteToken(t)}),o("/app-center",{replace:!0})}catch{u("root",{message:"Network error. Please try again."})}}return w==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):w==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(S,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(q,{children:[e.jsx(I,{children:"Invitation expired"}),e.jsx(R,{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(S,{level:4,className:"w-full max-w-sm",children:[e.jsxs(q,{className:"text-center",children:[e.jsx(I,{children:"Set up your account"}),e.jsxs(R,{children:["You're joining as ",e.jsx("strong",{children:K})]})]}),e.jsx(Y,{children:e.jsxs("form",{onSubmit:A(M),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(v,{id:"display-name",placeholder:"Your name",...m("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(_,{name:"avatar",control:g,render:({field:r})=>{var i;return e.jsxs("div",{className:"relative w-14 h-14",children:[f?e.jsx("img",{src:f,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 a=z(l);return{backgroundColor:a.bg,color:a.fg}})(),children:((i=l==null?void 0:l[0])==null?void 0:i.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":s.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":s.avatar?"avatar-error":void 0,onClick:()=>{var a;return(a=x.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(ee,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:a=>{var P;const n=(P=a.target.files)==null?void 0:P[0];if(n){if(n.size>2*1024*1024){u("avatar",{message:"Max 2MB for avatar"});return}r.onChange(n),L(URL.createObjectURL(n))}}})]})}}),e.jsx(c,{assertive:!0,id:"avatar-error",message:(b=s.avatar)==null?void 0:b.message})]}),e.jsx(H,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"password",children:"Password"}),e.jsx(v,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,...m("password")}),e.jsx(c,{id:"password-error",message:(N=s.password)==null?void 0:N.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(v,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.confirm,"aria-describedby":s.confirm?"confirm-error":void 0,...m("confirm")}),e.jsx(c,{id:"confirm-error",message:(C=s.confirm)==null?void 0:C.message})]}),e.jsx(c,{assertive:!0,id:"invite-error",message:(k=s.root)==null?void 0:k.message}),e.jsx(V,{type:"submit",disabled:j,className:"w-full",children:j?"Creating account…":"Create account"})]})})]})})}export{ne as Invite};
@@ -1 +1 @@
1
- import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{ax as Lt,aG as bt,aH as Et,M as Tt,ab as Rt,ao as Qe,ad as Ot}from"./index-COOWQXpW.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-BRpSwarg.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 Ls(){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"),O=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,O),{setNode:b}=Lt();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:E,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==E?(ie=()=>{if(!T)return;E({type:"agents:list"});const u=setInterval(()=>E({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,E],t[7]=T,t[8]=E,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:Rt,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=Et();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:L}=u;return Ot(l,n,L)},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]!==O?(P=()=>{if(!l||!O)return;const u=Qe.resourceHistory(l,n),L=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,L-(Date.now()-ae)):0;let de;const re=()=>{q(),de=setInterval(q,L)},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,O,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=O,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 L=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 ${L?"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:L?"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:O}=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]!==O||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:E,height:T}=Q;return E>0&&T>0?s.jsx(js,{width:E,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:O,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=O,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:O,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,E]=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=O,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,L=a=>{const R=r[a];R&&(C(R.live?"live":R.t),E(!0),ie({now:a,text:u(R)}))};let q;e[8]===Symbol.for("react.memo_cache_sentinel")?(q=()=>E(!1),e[8]=q):q=e[8];const g=q;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=R=>{R.key==="Escape"&&E(!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 R=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,R-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,R+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),L(Fe))},re=a=>{const R=Gt(a);if(!R)return;const Fe=R.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&&L(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 Le;e[79]!==l?(Le=s.jsx(Yt,{scale:l,tickValues:Ge,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Le):Le=e[80];let Ee;e[81]!==G||e[82]!==Y||e[83]!==n||e[84]!==S?(Ee=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]=Ee):Ee=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 Re;e[92]!==_||e[93]!==L?(Re=()=>{le(!0),L(_)},e[92]=_,e[93]=L,e[94]=Re):Re=e[94];let Oe;e[95]!==g?(Oe=()=>{g(),le(!1)},e[95]=g,e[96]=Oe):Oe=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]!==Re||e[108]!==Oe?(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:Re,onBlur:Oe,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]=Re,e[108]=Oe,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Le||e[114]!==Ee||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Le,Ee,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Le,e[114]=Ee,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,Ls as MacResources};
1
+ import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{az as Lt,aI as bt,aJ as Et,M as Tt,ad as Rt,aq as Qe,af as Ot}from"./index-Cm17I31a.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-BbeyA8an.js";import{t as Ft,i as jt,j as Ht,h as Ut,g as Bt,f as _t,l as qt,P as Gt,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 Ls(){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"),O=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,O),{setNode:b}=Lt();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:E,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==E?(ie=()=>{if(!T)return;E({type:"agents:list"});const u=setInterval(()=>E({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,E],t[7]=T,t[8]=E,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:Rt,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=Et();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:L}=u;return Ot(l,n,L)},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]!==O?(P=()=>{if(!l||!O)return;const u=Qe.resourceHistory(l,n),L=fs[n],G=()=>{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,L-(Date.now()-ae)):0;let de;const re=()=>{G(),de=setInterval(G,L)},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,O,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=O,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 q=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 L=w.has(u),G=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":G?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",G?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${L?"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:L?"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]!==q||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…"}):q.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:q,dataKey:"cpu",range:n,now:x,live:(f==null?void 0:f.cpu)??null}),s.jsx(Nt,{title:"RAM %",color:"mem",data:q,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]=q,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:O}=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]!==O||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(Gt,{children:Q=>{const{width:E,height:T}=Q;return E>0&&T>0?s.jsx(js,{width:E,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:O,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=O,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:O,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,E]=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=O,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),q=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,L=a=>{const R=r[a];R&&(C(R.live?"live":R.t),E(!0),ie({now:a,text:u(R)}))};let G;e[8]===Symbol.for("react.memo_cache_sentinel")?(G=()=>E(!1),e[8]=G):G=e[8];const g=G;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=R=>{R.key==="Escape"&&E(!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 R=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,R-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,R+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),L(Fe))},re=a=>{const R=qt(a);if(!R)return;const Fe=R.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&&L(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 qe;e[78]===Symbol.for("react.memo_cache_sentinel")?(qe=[0,25,50,75,100],e[78]=qe):qe=e[78];let Le;e[79]!==l?(Le=s.jsx(Yt,{scale:l,tickValues:qe,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Le):Le=e[80];let Ee;e[81]!==q||e[82]!==Y||e[83]!==n||e[84]!==S?(Ee=S&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:q,cy:Y,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:q,cy:Y,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=q,e[82]=Y,e[83]=n,e[84]=S,e[85]=Ee):Ee=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 Re;e[92]!==_||e[93]!==L?(Re=()=>{le(!0),L(_)},e[92]=_,e[93]=L,e[94]=Re):Re=e[94];let Oe;e[95]!==g?(Oe=()=>{g(),le(!1)},e[95]=g,e[96]=Oe):Oe=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]!==Re||e[108]!==Oe?(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:Re,onBlur:Oe,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]=Re,e[108]=Oe,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Le||e[114]!==Ee||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Le,Ee,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Le,e[114]=Ee,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 Ge;return e[135]!==Ie||e[136]!==Pe||e[137]!==Ke?(Ge=s.jsxs(s.Fragment,{children:[Ie,Pe,Ke]}),e[135]=Ie,e[136]=Pe,e[137]=Ke,e[138]=Ge):Ge=e[138],Ge}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,Ls as MacResources};