@health-samurai/aidbox-ui 0.0.0-stage → 1.2611.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 (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -2
  3. package/dist/assets/active-tabs-CF26H_DO.js +1 -0
  4. package/dist/assets/analytics-2HqmAKtT.js +1 -0
  5. package/dist/assets/analytics.index-B3niNGbb.js +1 -0
  6. package/dist/assets/analytics.queries-CsERDqyU.js +1 -0
  7. package/dist/assets/analytics.queries.create-Crh5s2u8.js +1 -0
  8. package/dist/assets/analytics.queries.edit._id-BkT-n8QV.js +1 -0
  9. package/dist/assets/analytics.sqlview-CsERDqyU.js +1 -0
  10. package/dist/assets/analytics.sqlview.create-CD-lfTql.js +1 -0
  11. package/dist/assets/analytics.sqlview.edit._id-DF8xigDA.js +1 -0
  12. package/dist/assets/analytics.views-CsERDqyU.js +1 -0
  13. package/dist/assets/analytics.views.create-Cskmbuxn.js +1 -0
  14. package/dist/assets/analytics.views.edit._id-BHf8RQjI.js +1 -0
  15. package/dist/assets/async-operations-BpSP1qqB.js +1 -0
  16. package/dist/assets/async-operations._operationId-Bur4DQCk.js +1 -0
  17. package/dist/assets/async-operations.index-CzrszYmS.js +1 -0
  18. package/dist/assets/audit-events-sRY6d8Yh.js +1 -0
  19. package/dist/assets/circle-alert-DvbmPbYC.js +1 -0
  20. package/dist/assets/circle-x-DwhdsFBE.js +1 -0
  21. package/dist/assets/confirm-dialog-v51h4XIn.js +1 -0
  22. package/dist/assets/cubic-M4WADWPw.js +1 -0
  23. package/dist/assets/database-C0DdBzuW.js +1 -0
  24. package/dist/assets/database.index-DGrCKToV.js +1 -0
  25. package/dist/assets/database.schema._schema._table-xTYNw2lk.js +1 -0
  26. package/dist/assets/date-picker-input-DmdIedlu.js +1 -0
  27. package/dist/assets/db-console-Bvi9FEwR.js +10 -0
  28. package/dist/assets/ellipsis-vertical-X8Fhf-lM.js +1 -0
  29. package/dist/assets/empty-state-BWk8zyoq.js +1 -0
  30. package/dist/assets/file-text-C04rYizE.js +1 -0
  31. package/dist/assets/footer-ChV5nI8s.js +1 -0
  32. package/dist/assets/format-D6Wtr7C_.js +3 -0
  33. package/dist/assets/fuse-Dw8P0qyA.js +1 -0
  34. package/dist/assets/fuzzy-search-k3hoA2E3.js +1 -0
  35. package/dist/assets/git-branch-CiASwpN0.js +1 -0
  36. package/dist/assets/globe-DBDBwwHA.js +1 -0
  37. package/dist/assets/ig-DRINkP3B.js +1 -0
  38. package/dist/assets/ig._packageId-DL6p24s_.js +1 -0
  39. package/dist/assets/ig._packageId.index-5yiL72vR.js +1 -0
  40. package/dist/assets/ig._packageId.resource._resourceType._resourceId-CqMQTYaU.js +1 -0
  41. package/dist/assets/ig.add-DuiK6_Ew.js +1 -0
  42. package/dist/assets/ig.index-DPrEz1VN.js +1 -0
  43. package/dist/assets/index-BQAJMQWp.css +1 -0
  44. package/dist/assets/index-CeYTjZBm.js +508 -0
  45. package/dist/assets/index-DuRA56KI.js +12 -0
  46. package/dist/assets/index-pE48Lea6.js +1 -0
  47. package/dist/assets/json-path-offset-CJVk8j-G.js +8 -0
  48. package/dist/assets/link-2-BcU0xDrw.js +1 -0
  49. package/dist/assets/minimize-2-BKSKBXgc.js +1 -0
  50. package/dist/assets/notebook-editor-_U89iND8.js +6 -0
  51. package/dist/assets/notebooks-DRINkP3B.js +1 -0
  52. package/dist/assets/notebooks._id-Cfr2BFg_.js +10 -0
  53. package/dist/assets/notebooks._id_.edit-DVX__FV5.js +1 -0
  54. package/dist/assets/notebooks.index-8DWLtoIo.js +1 -0
  55. package/dist/assets/notebooks.new-Cag2Zl60.js +1 -0
  56. package/dist/assets/page-BPJSQdrp.js +140 -0
  57. package/dist/assets/page-gv5ICvTq.css +1 -0
  58. package/dist/assets/pin-CjCDk2YF.js +1 -0
  59. package/dist/assets/refresh-cw-D5TWZXee.js +1 -0
  60. package/dist/assets/resource-DRINkP3B.js +1 -0
  61. package/dist/assets/resource._resourceType-DGqRT_Cx.js +1 -0
  62. package/dist/assets/resource._resourceType.create-cQvK8neA.js +1 -0
  63. package/dist/assets/resource._resourceType.edit._id-BSahyhaN.js +1 -0
  64. package/dist/assets/resource._resourceType.index-BwXmLCeX.js +1 -0
  65. package/dist/assets/resource.index-GLZB-j9S.js +1 -0
  66. package/dist/assets/rest-F-Ht76sJ.js +32 -0
  67. package/dist/assets/save-BVL6EWGk.js +1 -0
  68. package/dist/assets/schemas-C_YrO33d.js +1 -0
  69. package/dist/assets/settings-BC6RL7RW.js +2 -0
  70. package/dist/assets/shield-check-dcbIrNXu.js +1 -0
  71. package/dist/assets/tag-search-JTYqX0HY.js +1 -0
  72. package/dist/assets/text-align-start-Ce0773HM.js +1 -0
  73. package/dist/assets/trash-2-BDrajHic.js +1 -0
  74. package/dist/assets/upload-luqqIJD8.js +1 -0
  75. package/dist/assets/url-autocomplete-DJjdwAEw.js +1 -0
  76. package/dist/assets/useDebounce-BS2wroQC.js +1 -0
  77. package/dist/assets/user-D_lRSvKb.js +1 -0
  78. package/dist/assets/utils-DZ5fqOJB.js +1 -0
  79. package/dist/assets/vega-lite-chart-B2zd5HK5.js +196 -0
  80. package/dist/assets/worker-CmOMeqJg.js +76 -0
  81. package/dist/favicon/android-chrome-192x192.png +0 -0
  82. package/dist/favicon/android-chrome-512x512.png +0 -0
  83. package/dist/favicon/apple-touch-icon.png +0 -0
  84. package/dist/favicon/favicon-16x16.png +0 -0
  85. package/dist/favicon/favicon-32x32.png +0 -0
  86. package/dist/favicon/favicon.ico +0 -0
  87. package/dist/favicon/mstile-144x144.png +0 -0
  88. package/dist/favicon/mstile-150x150.png +0 -0
  89. package/dist/favicon/mstile-310x150.png +0 -0
  90. package/dist/favicon/mstile-310x310.png +0 -0
  91. package/dist/favicon/mstile-70x70.png +0 -0
  92. package/dist/favicon/safari-pinned-tab.svg +30 -0
  93. package/dist/fonts/Inter/Inter-Black.woff2 +0 -0
  94. package/dist/fonts/Inter/Inter-BlackItalic.woff2 +0 -0
  95. package/dist/fonts/Inter/Inter-Bold.woff2 +0 -0
  96. package/dist/fonts/Inter/Inter-BoldItalic.woff2 +0 -0
  97. package/dist/fonts/Inter/Inter-ExtraBold.woff2 +0 -0
  98. package/dist/fonts/Inter/Inter-ExtraBoldItalic.woff2 +0 -0
  99. package/dist/fonts/Inter/Inter-ExtraLight.woff2 +0 -0
  100. package/dist/fonts/Inter/Inter-ExtraLightItalic.woff2 +0 -0
  101. package/dist/fonts/Inter/Inter-Italic.woff2 +0 -0
  102. package/dist/fonts/Inter/Inter-Light.woff2 +0 -0
  103. package/dist/fonts/Inter/Inter-LightItalic.woff2 +0 -0
  104. package/dist/fonts/Inter/Inter-Medium.woff2 +0 -0
  105. package/dist/fonts/Inter/Inter-MediumItalic.woff2 +0 -0
  106. package/dist/fonts/Inter/Inter-Regular.woff2 +0 -0
  107. package/dist/fonts/Inter/Inter-SemiBold.woff2 +0 -0
  108. package/dist/fonts/Inter/Inter-SemiBoldItalic.woff2 +0 -0
  109. package/dist/fonts/Inter/Inter-Thin.woff2 +0 -0
  110. package/dist/fonts/Inter/Inter-ThinItalic.woff2 +0 -0
  111. package/dist/fonts/Inter/InterDisplay-Black.woff2 +0 -0
  112. package/dist/fonts/Inter/InterDisplay-BlackItalic.woff2 +0 -0
  113. package/dist/fonts/Inter/InterDisplay-Bold.woff2 +0 -0
  114. package/dist/fonts/Inter/InterDisplay-BoldItalic.woff2 +0 -0
  115. package/dist/fonts/Inter/InterDisplay-ExtraBold.woff2 +0 -0
  116. package/dist/fonts/Inter/InterDisplay-ExtraBoldItalic.woff2 +0 -0
  117. package/dist/fonts/Inter/InterDisplay-ExtraLight.woff2 +0 -0
  118. package/dist/fonts/Inter/InterDisplay-ExtraLightItalic.woff2 +0 -0
  119. package/dist/fonts/Inter/InterDisplay-Italic.woff2 +0 -0
  120. package/dist/fonts/Inter/InterDisplay-Light.woff2 +0 -0
  121. package/dist/fonts/Inter/InterDisplay-LightItalic.woff2 +0 -0
  122. package/dist/fonts/Inter/InterDisplay-Medium.woff2 +0 -0
  123. package/dist/fonts/Inter/InterDisplay-MediumItalic.woff2 +0 -0
  124. package/dist/fonts/Inter/InterDisplay-Regular.woff2 +0 -0
  125. package/dist/fonts/Inter/InterDisplay-SemiBold.woff2 +0 -0
  126. package/dist/fonts/Inter/InterDisplay-SemiBoldItalic.woff2 +0 -0
  127. package/dist/fonts/Inter/InterDisplay-Thin.woff2 +0 -0
  128. package/dist/fonts/Inter/InterDisplay-ThinItalic.woff2 +0 -0
  129. package/dist/fonts/Inter/InterVariable-Italic.woff2 +0 -0
  130. package/dist/fonts/Inter/InterVariable.woff2 +0 -0
  131. package/dist/fonts/Inter/index.css +148 -0
  132. package/dist/fonts/JetBrainsMono/JetBrainsMono-Bold-Italic.woff2 +0 -0
  133. package/dist/fonts/JetBrainsMono/JetBrainsMono-Bold.woff2 +0 -0
  134. package/dist/fonts/JetBrainsMono/JetBrainsMono-ExtraBold-Italic.woff2 +0 -0
  135. package/dist/fonts/JetBrainsMono/JetBrainsMono-ExtraBold.woff2 +0 -0
  136. package/dist/fonts/JetBrainsMono/JetBrainsMono-Italic.woff2 +0 -0
  137. package/dist/fonts/JetBrainsMono/JetBrainsMono-Medium-Italic.woff2 +0 -0
  138. package/dist/fonts/JetBrainsMono/JetBrainsMono-Medium.woff2 +0 -0
  139. package/dist/fonts/JetBrainsMono/JetBrainsMono-Regular.woff2 +0 -0
  140. package/dist/fonts/JetBrainsMono/index.css +63 -0
  141. package/dist/index.html +71 -0
  142. package/dist/no-resources.svg +9 -0
  143. package/dist/site.webmanifest +19 -0
  144. package/package.json +77 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Health Samurai Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src=".github/logo.svg" width="64" height="64" alt="Health Samurai">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">Aidbox UI</h1>
6
+
7
+ <p align="center">
8
+ The administration console for <a href="https://www.health-samurai.io/aidbox">Aidbox</a> — a FHIR-first platform for healthcare application development.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/HealthSamurai/aidbox-ui/actions/workflows/ci.yaml"><img src="https://github.com/HealthSamurai/aidbox-ui/actions/workflows/ci.yaml/badge.svg" alt="CI"></a>
13
+ </p>
14
+
15
+ ## Getting started
16
+
17
+ ```bash
18
+ # requires pnpm 10+ and Node.js 18+
19
+ git clone git@github.com:HealthSamurai/aidbox-ui.git
20
+ cd aidbox-ui
21
+ pnpm install
22
+ pnpm dev
23
+ ```
24
+
25
+ The app expects Aidbox running on `http://localhost:8765`.
26
+ Configure via `VITE_AIDBOX_BASE_URL` environment variable if needed.
27
+
28
+ ## Development
29
+
30
+ | Command | Description |
31
+ |---------|-------------|
32
+ | `pnpm dev` | Start Vite dev server |
33
+ | `pnpm build` | Production build |
34
+ | `pnpm typecheck` | Type-check the project |
35
+ | `pnpm lint:fix` | Lint and auto-fix with Biome |
36
+ | `pnpm all` | Format + typecheck + lint |
37
+ | `pnpm hooks` | Install git pre-commit hooks |
38
+
39
+ ## Tech stack
40
+
41
+ - **React 19** with React Compiler
42
+ - **TanStack Router** — file-based routing with auto code splitting
43
+ - **TanStack Query** — server state management
44
+ - **Tailwind CSS 4** — styling via design tokens from react-components
45
+ - **Vite** — bundler and dev server
46
+ - **Biome** — linting and formatting
47
+ - **TypeScript** in strict mode
48
+
49
+ ## Contributing
50
+
51
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, workflow, and code style details.
52
+
53
+ ## Security
54
+
55
+ See [SECURITY.md](SECURITY.md) for our security policy and how to report vulnerabilities.
56
+
57
+ ## License
58
+
59
+ [MIT](LICENSE)
@@ -0,0 +1 @@
1
+ import{b8 as U,ao as E,a as v,j as c,b9 as F,ba as Q,z as $,bb as D,bc as G,bd as J,ag as Y,be as z,bf as K,F as P}from"./index-CeYTjZBm.js";const R="",k="sql-tab-default",L={rowLimit:10,timeoutSec:U,autocommit:!0,readOnly:!1,asyncMode:!1};function ae(n){return{...L,...n?.settings??{}}}const B={id:k,query:R,selected:!0,settings:L},q="dbConsole.tabs";function ce(n){if(n.length===0)return;const e=localStorage.getItem(q);let t=[];try{const a=e?JSON.parse(e):null;Array.isArray(a)&&(t=a)}catch{t=[]}t.length===0&&(t=[B]);const s=n.map((a,i)=>({id:E(),query:a,selected:i===n.length-1,settings:L})),l=[...t.map(a=>({...a,selected:!1})),...s];localStorage.setItem(q,JSON.stringify(l))}function H(n,e){const t={id:E(),query:R,selected:!0,settings:L};return e([...n.map(s=>({...s,selected:!1})),t]),t}function O(n,e){if(!n.some(s=>s.selected)&&n.length>0){const s=Math.min(e,n.length-1);return n.map((l,a)=>a===s?{...l,selected:!0}:{...l,selected:!1})}return n}function V(n,e,t){const s=n.filter(l=>l.id!==e);if(s.length===0)t([{...B,id:E()}]);else{const l=s.some(i=>i.selected);let a=s;if(!l){const i=n.findIndex(f=>f.id===e),r=i>0?i-1:0,d=Math.min(r,s.length-1);a=s.map((f,h)=>h===d?{...f,selected:!0}:{...f,selected:!1})}t(a)}}function W(n,e,t){t(e.map(s=>({...s,selected:s.id===n})))}function X(n,e=30){const t=n.trim().replace(/\s+/g," ");return t?t.length<=e?t:`${t.slice(0,e)}…`:"New query"}function N(n){const e=v.c(4),{tab:t}=n;let s;e[0]!==t.query?(s=X(t.query),e[0]=t.query,e[1]=s):s=e[1];let l;return e[2]!==s?(l=c.jsx("span",{className:"truncate typo-body-xs leading-4!",children:s}),e[2]=s,e[3]=l):l=e[3],l}function Z(n){const e=v.c(39),{tab:t,tabs:s,setTabs:l,handleCloseTab:a,onTabsRemoved:i}=n;let r;e[0]!==t.id?(r=_=>_.id===t.id,e[0]=t.id,e[1]=r):r=e[1];const d=s.findIndex(r);let f;e[2]!==l||e[3]!==t||e[4]!==s?(f=()=>{const _={...t,id:E(),selected:!0};l([...s.map(ne),_])},e[2]=l,e[3]=t,e[4]=s,e[5]=f):f=e[5];const h=f;let j;e[6]!==i||e[7]!==l||e[8]!==d||e[9]!==s?(j=()=>{const _=s.filter((M,I)=>I<d).map(se),A=s.filter((M,I)=>I>=d);l(O(A,0)),i?.(_)},e[6]=i,e[7]=l,e[8]=d,e[9]=s,e[10]=j):j=e[10];const p=j;let b;e[11]!==i||e[12]!==l||e[13]!==d||e[14]!==s?(b=()=>{const _=s.filter((M,I)=>I>d).map(te),A=s.filter((M,I)=>I<=d);l(O(A,d)),i?.(_)},e[11]=i,e[12]=l,e[13]=d,e[14]=s,e[15]=b):b=e[15];const x=b;let m;e[16]!==i||e[17]!==l||e[18]!==t||e[19]!==s?(m=()=>{const _=s.filter(A=>A.id!==t.id).map(ee);l([{...t,selected:!0}]),i?.(_)},e[16]=i,e[17]=l,e[18]=t,e[19]=s,e[20]=m):m=e[20];const g=m;let u;e[21]!==h?(u=c.jsx(D,{onClick:h,children:"Duplicate tab"}),e[21]=h,e[22]=u):u=e[22];let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=c.jsx(G,{}),e[23]=S):S=e[23];let o;e[24]!==a||e[25]!==t.id?(o=c.jsx(D,{onClick:()=>a(t.id),children:"Close tab"}),e[24]=a,e[25]=t.id,e[26]=o):o=e[26];let T;e[27]!==g?(T=c.jsx(D,{onClick:g,children:"Close other tabs"}),e[27]=g,e[28]=T):T=e[28];let y;e[29]!==p?(y=c.jsx(D,{onClick:p,children:"Close tabs to left"}),e[29]=p,e[30]=y):y=e[30];let C;e[31]!==x?(C=c.jsx(D,{onClick:x,children:"Close tabs to right"}),e[31]=x,e[32]=C):C=e[32];let w;return e[33]!==y||e[34]!==C||e[35]!==u||e[36]!==o||e[37]!==T?(w=c.jsxs(J,{className:"w-50",children:[u,S,o,T,y,C]}),e[33]=y,e[34]=C,e[35]=u,e[36]=o,e[37]=T,e[38]=w):w=e[38],w}function ee(n){return n.id}function te(n){return n.id}function se(n){return n.id}function ne(n){return{...n,selected:!1}}function re(n){const e=v.c(35),{tabs:t,setTabs:s,onTabsRemoved:l}=n,a=t.find(oe)?.id||k;let i;e[0]!==l||e[1]!==s||e[2]!==t?(i=o=>{V(t,o,s),l?.([o])},e[0]=l,e[1]=s,e[2]=t,e[3]=i):i=e[3];const r=i;let d;e[4]!==s||e[5]!==t?(d=o=>{W(o,t,s)},e[4]=s,e[5]=t,e[6]=d):d=e[6];const f=d;let h;e[7]!==r?(h=(o,T)=>{o.button===1&&(o.preventDefault(),o.stopPropagation(),r(T))},e[7]=r,e[8]=h):h=e[8];const j=h;let p;e[9]!==s?(p=(o,T)=>{s(y=>{const C=[...y],[w]=C.splice(o,1);return w&&C.splice(T,0,w),C})},e[9]=s,e[10]=p):p=e[10];let b;e[11]!==r||e[12]!==j||e[13]!==f||e[14]!==l||e[15]!==s||e[16]!==t?(b=t.map(o=>c.jsxs(F,{children:[c.jsx(Q,{children:c.jsx($,{value:o.id,...t.length>1&&{onClose:()=>r(o.id)},onClick:()=>f(o.id),onMouseDown:T=>j(T,o.id),children:c.jsx(N,{tab:o})})}),c.jsx(Z,{tab:o,tabs:t,setTabs:s,handleCloseTab:r,onTabsRemoved:l})]},o.id)),e[11]=r,e[12]=j,e[13]=f,e[14]=l,e[15]=s,e[16]=t,e[17]=b):b=e[17];let x;e[18]!==p||e[19]!==b?(x=c.jsx(Y,{onReorder:p,children:b}),e[18]=p,e[19]=b,e[20]=x):x=e[20];let m;e[21]!==s||e[22]!==t?(m=c.jsx(z,{onClick:()=>H(t,s)}),e[21]=s,e[22]=t,e[23]=m):m=e[23];let g;e[24]!==t?(g=t.map(le),e[24]=t,e[25]=g):g=e[25];let u;e[26]!==r||e[27]!==f||e[28]!==g?(u=c.jsx(K,{tabs:g,handleTabSelect:f,handleCloseTab:r}),e[26]=r,e[27]=f,e[28]=g,e[29]=u):u=e[29];let S;return e[30]!==a||e[31]!==x||e[32]!==m||e[33]!==u?(S=c.jsxs(P,{variant:"browser",value:a,children:[x,m,u]}),e[30]=a,e[31]=x,e[32]=m,e[33]=u,e[34]=S):S=e[34],S}function le(n){return{id:n.id,content:c.jsx(N,{tab:n})}}function oe(n){return n.selected}export{B as D,re as S,H as a,ce as b,O as f,ae as t};
@@ -0,0 +1 @@
1
+ import{a as n,j as o,O as s}from"./index-CeYTjZBm.js";function a(){const t=n.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"h-full",children:o.jsx(s,{})}),t[0]=e):e=t[0],e}const i=a;export{i as component};
@@ -0,0 +1 @@
1
+ import{d as F,u as De,b7 as pe,b as Te,aQ as ie,bu as W,bv as X,bw as Z,r as N,j as s,B as T,aL as A,$ as Y,Y as H,Z as O,_ as q,q as Ae,n as Re,k as Qe,g as Le,h as $e,a4 as Me,l as Ie,i as Ve,m as ze,a as k,bx as Ke,by as me,e as J,bz as Ue,a5 as le,w as Fe,x as Pe,y as Be,s as Ye,v as K,t as He}from"./index-CeYTjZBm.js";import{F as Oe}from"./fuse-Dw8P0qyA.js";import{E as U}from"./empty-state-BWk8zyoq.js";import{t as S,f as ce,p as Ge,h as oe}from"./tag-search-JTYqX0HY.js";import{E as We}from"./ellipsis-vertical-X8Fhf-lM.js";import{G as Xe}from"./git-branch-CiASwpN0.js";import{T as Ze}from"./trash-2-BDrajHic.js";const Je="https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes|sql-query",et="https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes|sql-view",ee={view:"ViewDefinition",query:"SQLQuery","sql-view":"SQLView"},R={view:{label:"VIEW",accentClass:"text-text-info-primary",Icon:Z},query:{label:"SQLQuery",accentClass:"text-text-warning-primary",Icon:X},"sql-view":{label:"SQLView",accentClass:"text-text-success-primary",Icon:W}},tt={view:"analytics-recent-views",query:"analytics-recent-queries","sql-view":"analytics-recent-sql-views"};function G(t){return t==="view"?"/analytics/views/edit/$id":t==="sql-view"?"/analytics/sqlview/edit/$id":"/analytics/queries/edit/$id"}const ue={tab:"builder",mode:"json",builderTab:"form"},de={tab:"sqlquery",mode:"json",builderTab:"form"};function te(t){return t.title||t.name||t.id||"(unnamed)"}function st(){const t=k.c(3),e=F();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=["analytics-recent-views"],t[0]=r):r=t[0];let a;return t[1]!==e?(a={queryKey:r,queryFn:async()=>{const c=await e.request({method:"GET",url:"/fhir/ViewDefinition",params:[["_count","1000"],["_sort","-_lastUpdated"]]});return c.isErr()?[]:(c.value.resource.entry??[]).flatMap(rt)}},t[1]=e,t[2]=a):a=t[2],J(a)}function rt(t){const e=t.resource;return e?.id?[{kind:"view",id:e.id,url:e.url,resource:e.resource,label:te(e),description:e.description,lastUpdated:e.meta?.lastUpdated}]:[]}function at(){const t=k.c(3),e=F();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=["analytics-recent-queries"],t[0]=r):r=t[0];let a;return t[1]!==e?(a={queryKey:r,queryFn:async()=>{const c=await e.request({method:"GET",url:"/fhir/Library",params:[["_count","1000"],["_sort","-_lastUpdated"],["type",Je]]});return c.isErr()?[]:(c.value.resource.entry??[]).flatMap(nt)}},t[1]=e,t[2]=a):a=t[2],J(a)}function nt(t){const e=t.resource;if(!e?.id)return[];const r=(e.relatedArtifact??[]).flatMap(it);return[{kind:"query",id:e.id,url:e.url,relatedArtifacts:r.length>0?r:void 0,label:te(e),description:e.description,lastUpdated:e.meta?.lastUpdated}]}function it(t){return t.resource?[{url:t.resource,label:t.label}]:[]}function lt(){const t=k.c(3),e=F();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=["analytics-recent-sql-views"],t[0]=r):r=t[0];let a;return t[1]!==e?(a={queryKey:r,queryFn:async()=>{const c=await e.request({method:"GET",url:"/fhir/Library",params:[["_count","1000"],["_sort","-_lastUpdated"],["type",et]]});return c.isErr()?[]:(c.value.resource.entry??[]).flatMap(ct)}},t[1]=e,t[2]=a):a=t[2],J(a)}function ct(t){const e=t.resource;if(!e?.id)return[];const r=(e.relatedArtifact??[]).flatMap(ot);return[{kind:"sql-view",id:e.id,url:e.url,relatedArtifacts:r.length>0?r:void 0,label:te(e),description:e.description,lastUpdated:e.meta?.lastUpdated}]}function ot(t){return t.resource?[{url:t.resource,label:t.label}]:[]}function ut(t,e){const r=[S(t.label)];if(t.resource&&r.push(S(t.resource)),t.relatedArtifacts)for(const a of t.relatedArtifacts){const o=e(a.url)?.label??a.label??a.url;r.push(S(o))}return r}function dt(t,e,r){return e.length===0?t:t.filter(a=>{const c=ut(a,r);return e.every(o=>c.some(u=>u===o))})}function ft(t,e){const r=S(t);for(const a of e)if(S(a.label)===r)return a.kind==="view"?"bg-blue-50 text-text-info-primary":a.kind==="sql-view"?"bg-green-50 text-text-success-primary":"bg-yellow-50 text-text-warning-primary";for(const a of e)if(a.resource&&S(a.resource)===r)return"bg-green-50 text-text-success-primary";return"bg-bg-tertiary text-text-primary"}function fe(t){const e=k.c(9),{text:r,accentClass:a,onClick:c}=t,o=`shrink-0 text-[11px] leading-4 normal-case whitespace-nowrap ${a}`;if(c){let i;e[0]!==c?(i=m=>{m.preventDefault(),m.stopPropagation(),c()},e[0]=c,e[1]=i):i=e[1];const l=`${o} cursor-pointer hover:underline`;let f;return e[2]!==i||e[3]!==l||e[4]!==r?(f=s.jsxs("button",{type:"button",onClick:i,className:l,children:["#",r]}),e[2]=i,e[3]=l,e[4]=r,e[5]=f):f=e[5],f}let u;return e[6]!==o||e[7]!==r?(u=s.jsxs("span",{className:o,children:["#",r]}),e[6]=o,e[7]=r,e[8]=u):u=e[8],u}function pt({item:t,lookup:e,showKindLabel:r=!0,onTagClick:a}){const c=t.kind==="view",{Icon:o,label:u,accentClass:i}=R[t.kind],l=[];if(c&&t.resource){const f=t.resource;l.push(s.jsx(fe,{text:f,accentClass:"text-text-success-primary",onClick:a?()=>a(f):void 0},"resource"))}if(!c&&t.relatedArtifacts)for(const f of t.relatedArtifacts){const m=e(f.url),p=m?.label??f.label??f.url,x=m?R[m.kind].accentClass:f.url.includes("/ViewDefinition/")?R.view.accentClass:R.query.accentClass;l.push(s.jsx(fe,{text:p,accentClass:x,onClick:a?()=>a(p):void 0},f.url))}return s.jsxs("div",{className:"flex flex-col pl-3.5 pr-4 py-3 min-w-0",children:[r&&s.jsxs("div",{className:`flex items-center gap-1.5 typo-label-tiny uppercase tracking-wide ${i}`,children:[s.jsx(o,{className:"size-3.5 shrink-0"}),s.jsx("span",{children:u})]}),s.jsx("div",{className:`typo-body text-text-primary truncate first-letter:uppercase ${r?"mt-0.5":""}`,children:oe(t.label,t.labelMatches)}),t.description&&s.jsx("div",{className:"typo-body-xs text-text-secondary mt-0.5 line-clamp-1",children:oe(t.description,t.descriptionMatches)}),l.length>0&&s.jsx("div",{className:"flex flex-wrap gap-x-2 gap-y-0.5 mt-2",children:l})]})}const mt={tab:"builder",mode:"json",builderTab:"form"},xe={tab:"sqlquery",mode:"json",builderTab:"form"},xt=xe;function yt(t){const e=k.c(29),{chips:r,textPart:a,placeholder:c,allItems:o,inputRef:u,onTextChange:i,onRemoveChip:l,onClear:f,onInputKeyDown:m}=t;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(Fe,{className:"size-4 text-text-tertiary shrink-0"}),e[0]=p):p=e[0];let x;if(e[1]!==o||e[2]!==r||e[3]!==l){let w;e[5]!==o||e[6]!==l?(w=v=>s.jsxs("button",{type:"button","aria-label":`Remove tag ${v}`,onClick:()=>l(v),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] leading-4 whitespace-nowrap cursor-pointer ${ft(v,o)}`,children:["#",v,s.jsx(le,{className:"size-3 opacity-70"})]},v),e[5]=o,e[6]=l,e[7]=w):w=e[7],x=r.map(w),e[1]=o,e[2]=r,e[3]=l,e[4]=x}else x=e[4];let j;e[8]!==i?(j=w=>i(w.target.value),e[8]=i,e[9]=j):j=e[9];let g;e[10]!==r||e[11]!==m||e[12]!==l||e[13]!==a?(g=w=>{const v=r[r.length-1];if(w.key==="Backspace"&&a===""&&v){w.preventDefault(),l(v);return}m?.(w)},e[10]=r,e[11]=m,e[12]=l,e[13]=a,e[14]=g):g=e[14];const y=r.length===0?c:"";let h;e[15]!==u||e[16]!==j||e[17]!==g||e[18]!==y||e[19]!==a?(h=s.jsx("input",{ref:u,value:a,onChange:j,onKeyDown:g,placeholder:y,className:"flex-1 min-w-[80px] bg-transparent outline-none typo-body text-text-primary placeholder:text-text-tertiary"}),e[15]=u,e[16]=j,e[17]=g,e[18]=y,e[19]=a,e[20]=h):h=e[20];let E;e[21]!==r.length||e[22]!==f||e[23]!==a?(E=(r.length>0||a.length>0)&&s.jsx(Ue,{variant:"link","aria-label":"Clear",onClick:f,icon:s.jsx(le,{})}),e[21]=r.length,e[22]=f,e[23]=a,e[24]=E):E=e[24];let D;return e[25]!==x||e[26]!==h||e[27]!==E?(D=s.jsxs("div",{className:"flex flex-1 items-center gap-2 min-h-9 px-3 py-1 rounded-lg border border-border-primary bg-bg-primary flex-wrap",children:[p,x,h,E]}),e[25]=x,e[26]=h,e[27]=E,e[28]=D):D=e[28],D}const ht=t=>{const e=k.c(10),{searchTerms:r,kind:a,createFns:c}=t;if(r){const u=`“${r}”`;let i;return e[0]!==u?(i=s.jsx(U,{grayscale:!0,title:"Nothing matches",description:u}),e[0]=u,e[1]=i):i=e[1],i}if(a){const u=ee[a],i=`No ${u}s yet`,l=`Create your first ${u}.`,f=c[a];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(A,{className:"size-4 text-text-info-primary"}),e[2]=m):m=e[2];let p;e[3]!==f?(p=s.jsxs(T,{variant:"secondary",onClick:f,children:[m,"Create"]}),e[3]=f,e[4]=p):p=e[4];let x;return e[5]!==i||e[6]!==l||e[7]!==p?(x=s.jsx(U,{grayscale:!0,title:i,description:l,action:p}),e[5]=i,e[6]=l,e[7]=p,e[8]=x):x=e[8],x}let o;return e[9]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(U,{grayscale:!0,title:"Nothing to show"}),e[9]=o):o=e[9],o};function bt(t){const e=k.c(7),{kind:r,setKind:a}=t,c=r?ee[r]:"all";let o;e[0]!==a?(o=f=>a(me[f]),e[0]=a,e[1]=o):o=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Pe,{className:"w-44 h-9 shrink-0",children:s.jsx(Be,{placeholder:"Type"})}),e[2]=u):u=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsxs(Ye,{children:[s.jsx(K,{value:"all",children:"All types"}),s.jsx(K,{value:"ViewDefinition",className:"text-text-info-primary!",children:"ViewDefinition"}),s.jsx(K,{value:"SQLQuery",className:"text-text-warning-primary!",children:"SQLQuery"}),s.jsx(K,{value:"SQLView",className:"text-text-success-primary!",children:"SQLView"})]}),e[3]=i):i=e[3];let l;return e[4]!==c||e[5]!==o?(l=s.jsxs(He,{value:c,onValueChange:o,children:[u,i]}),e[4]=c,e[5]=o,e[6]=l):l=e[6],l}function gt({kind:t,tags:e,text:r,setTags:a,setText:c,setKind:o}){const u=st(),i=at(),l=lt(),f=F(),m=De(),p=pe(),x=Te({mutationFn:async n=>{const d=n.kind==="view"?`/fhir/ViewDefinition/${n.id}`:`/fhir/Library/${n.id}`,b=await f.request({method:"DELETE",url:d});if(b.isErr())throw new Error("Delete failed");return b.value},onSuccess:(n,d)=>{m.invalidateQueries({queryKey:[tt[d.kind]]}),ie.success(`${R[d.kind].label} deleted`)},onError:()=>{ie.error("Failed to delete")}}),[j,g]=N.useState(null),[y,h]=N.useState(null),E=n=>{p({to:G(n.kind),params:{id:n.id},search:{tab:"lineage",mode:"json",builderTab:"form"}})},D=N.useRef(!1),w=N.useCallback(n=>{n&&!D.current&&(n.focus(),D.current=!0)},[]),v=[...u.data??[],...i.data??[],...l.data??[]],ye=(t==="view"?u.data??[]:t==="query"?i.data??[]:t==="sql-view"?l.data??[]:v).slice().sort((n,d)=>{const b=n.lastUpdated?new Date(n.lastUpdated).getTime():0;return(d.lastUpdated?new Date(d.lastUpdated).getTime():0)-b}),se=N.useMemo(()=>{const n=new Map;for(const d of[...u.data??[],...i.data??[],...l.data??[]])d.url&&n.set(d.url,d);return d=>n.get(d)},[u.data,i.data,l.data]),he=e.map(S),be=r,P=dt(ye,he,se),ge=N.useMemo(()=>new Oe(P,{keys:["label","description"],includeMatches:!0,threshold:.3,ignoreLocation:!0,minMatchCharLength:1}),[P]),I=be,Q=I?ge.search(I).map(n=>{const d=n.matches?.find(C=>C.key==="label"),b=n.matches?.find(C=>C.key==="description");return{...n.item,labelMatches:ce(I,d?.indices),descriptionMatches:ce(I,b?.indices)}}):P,je=t?R[t].label:"view, query or SQL view",we=v.length===0&&e.length===0&&!r,ve=[...e.map(n=>`#${n}`),r].filter(Boolean).join(" "),Ce="Search by name or description…",L=()=>p({to:"/analytics/views/create",search:mt}),$=()=>p({to:"/analytics/queries/create",search:xe}),B=()=>p({to:"/analytics/sqlview/create",search:xt}),Se=n=>{const d=S(n);e.some(b=>S(b)===d)||a([...e,n])},Ne=n=>{a(e.filter(d=>d!==n))},_e=n=>{let d=n,b="";if(!/\s$/.test(n)){const _=n.match(/^(.*\s)(\S*)$/);_?(d=_[1]??"",b=_[2]??""):(d="",b=n)}const C=Ge(d);if(C.chips.length>0){const _=new Set(e.map(S)),M=[];for(const ae of C.chips){const ne=S(ae);_.has(ne)||(M.push(ae),_.add(ne))}M.length>0&&a([...e,...M]),c([C.text,b].filter(Boolean).join(" "))}else c(n)},Ee=()=>{a([]),c("")},[V,z]=N.useState(-1),re=N.useRef(null);N.useEffect(()=>{re.current?.scrollIntoView({block:"nearest"})},[V]),N.useEffect(()=>{r&&Q.length>0?z(0):z(-1)},[r,Q.length]);const qe=n=>{p({to:G(n.kind),params:{id:n.id},search:n.kind==="view"?ue:de})},ke=n=>{if(n.key==="ArrowDown"||n.key==="Tab"&&!n.shiftKey)n.preventDefault(),z(d=>Math.min(d+1,Q.length-1));else if(n.key==="ArrowUp"||n.key==="Tab"&&n.shiftKey)n.preventDefault(),z(d=>Math.max(d-1,-1));else if(n.key==="Enter"){if(V<0)return;const d=Q[V];if(!d)return;n.preventDefault(),qe(d)}};return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsx("div",{className:"bg-bg-primary py-4 shadow-[0_10px_10px_0_var(--color-bg-primary)]",children:s.jsxs("div",{className:"mx-auto max-w-[990px] px-8 flex items-center gap-2",children:[s.jsx(yt,{chips:e,textPart:r,placeholder:Ce,allItems:v,inputRef:w,onTextChange:_e,onRemoveChip:Ne,onClear:Ee,onInputKeyDown:ke}),o&&s.jsx(bt,{kind:t,setKind:o}),t==="view"?s.jsxs(T,{variant:"secondary",onClick:L,children:[s.jsx(A,{className:"size-4 text-text-info-primary"}),"Create"]}):t==="query"?s.jsxs(T,{variant:"secondary",onClick:$,children:[s.jsx(A,{className:"size-4 text-text-info-primary"}),"Create"]}):s.jsxs(Y,{children:[s.jsx(H,{asChild:!0,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(A,{className:"size-4 text-text-info-primary"}),"Create"]})}),s.jsxs(O,{align:"end",children:[s.jsxs(q,{className:"justify-start! text-text-info-primary!",onSelect:L,children:[s.jsx(Z,{className:"size-4 text-text-info-primary"}),"ViewDefinition"]}),s.jsxs(q,{className:"justify-start! text-text-warning-primary!",onSelect:$,children:[s.jsx(X,{className:"size-4 text-text-warning-primary"}),"SQLQuery"]}),s.jsxs(q,{className:"justify-start! text-text-success-primary!",onSelect:B,children:[s.jsx(W,{className:"size-4 text-text-success-primary"}),"SQLView"]})]})]})]})}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pb-[250px]",children:we?s.jsx(U,{title:"Analytics",description:`Create your first ${je}.`,action:t==="view"?s.jsxs(T,{variant:"secondary",onClick:L,children:[s.jsx(A,{className:"size-4 text-text-info-primary"}),"Create"]}):t==="query"?s.jsxs(T,{variant:"secondary",onClick:$,children:[s.jsx(A,{className:"size-4 text-text-info-primary"}),"Create"]}):s.jsxs(Y,{children:[s.jsx(H,{asChild:!0,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(A,{className:"size-4 text-text-info-primary"}),"Create"]})}),s.jsxs(O,{align:"end",children:[s.jsxs(q,{className:"justify-start! text-text-info-primary!",onSelect:L,children:[s.jsx(Z,{className:"size-4 text-text-info-primary"}),"ViewDefinition"]}),s.jsxs(q,{className:"justify-start! text-text-warning-primary!",onSelect:$,children:[s.jsx(X,{className:"size-4 text-text-warning-primary"}),"SQLQuery"]}),s.jsxs(q,{className:"justify-start! text-text-success-primary!",onSelect:B,children:[s.jsx(W,{className:"size-4 text-text-success-primary"}),"SQLView"]})]})]})}):Q.length===0?s.jsx(ht,{searchTerms:ve,kind:t,createFns:{view:L,query:$,"sql-view":B}}):s.jsx("ul",{className:"mx-auto max-w-[990px] px-8 bg-bg-primary divide-y divide-border-default",children:Q.map((n,d)=>{const b=`${n.kind}-${n.id}`,C=j===b,_=d===V;return s.jsxs("li",{ref:_?re:void 0,className:`relative group/row transition-colors hover:bg-bg-secondary first:rounded-t-lg last:rounded-b-lg ${_?"bg-bg-secondary":""}`,children:[s.jsx(Ae,{to:G(n.kind),params:{id:n.id},search:n.kind==="view"?ue:de,className:"block",children:s.jsx(pt,{item:n,lookup:se,showKindLabel:!t,onTagClick:Se})}),s.jsx("div",{className:`${C?"block":"hidden group-hover/row:block focus-within:block"} absolute top-2 right-2`,children:s.jsxs(Y,{open:C,onOpenChange:M=>g(M?b:null),children:[s.jsx(H,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":"More actions",className:"size-7 flex items-center justify-center rounded hover:bg-bg-tertiary text-text-secondary",children:s.jsx(We,{className:"size-4"})})}),s.jsxs(O,{align:"end",children:[s.jsxs(q,{className:"justify-start!",onSelect:()=>E(n),children:[s.jsx(Xe,{className:"size-4"}),"Lineage"]}),s.jsxs(q,{className:"justify-start!",variant:"destructive",onSelect:()=>h(n),children:[s.jsx(Ze,{className:"size-4"}),"Delete"]})]})]})})]},b)})})}),s.jsx(Re,{open:!!y,onOpenChange:n=>{n||h(null)},children:s.jsxs(Qe,{children:[s.jsx(Le,{children:s.jsxs($e,{children:["Delete"," ",y?R[y.kind].label:""]})}),s.jsxs(Me,{children:["Are you sure you want to delete"," ",s.jsx("span",{className:"font-medium text-text-primary",children:y?.label}),"? This action cannot be undone."]}),s.jsxs(Ie,{children:[s.jsx(Ve,{children:"Cancel"}),s.jsx(ze,{danger:!0,onClick:()=>{y&&x.mutate(y),h(null)},children:"Delete"})]})]})})]})}function Et(){const t=k.c(16),e=Ke.useSearch(),r=e.q??"";let a;t[0]!==e.tags?(a=e.tags??[],t[0]=e.tags,t[1]=a):a=t[1];const c=a,o=e.type?me[e.type]:void 0;let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u={from:"/analytics/"},t[2]=u):u=t[2];const i=pe(u);let l;t[3]!==i?(l=y=>i({search:h=>({...h,q:y||void 0}),replace:!0}),t[3]=i,t[4]=l):l=t[4];const f=l;let m;t[5]!==i?(m=y=>i({search:h=>({...h,tags:y.length>0?y:void 0}),replace:!0}),t[5]=i,t[6]=m):m=t[6];const p=m;let x;t[7]!==i?(x=y=>i({search:h=>({...h,type:y?ee[y]:void 0}),replace:!0}),t[7]=i,t[8]=x):x=t[8];const j=x;let g;return t[9]!==o||t[10]!==j||t[11]!==p||t[12]!==f||t[13]!==c||t[14]!==r?(g=s.jsx(gt,{kind:o,text:r,tags:c,setText:f,setTags:p,setKind:j}),t[9]=o,t[10]=j,t[11]=p,t[12]=f,t[13]=c,t[14]=r,t[15]=g):g=t[15],g}export{gt as AnalyticsListPage,Et as component};
@@ -0,0 +1 @@
1
+ import{a as o,j as s,O as n}from"./index-CeYTjZBm.js";const r=()=>{const e=o.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(n,{}),e[0]=t):t=e[0],t};export{r as component};
@@ -0,0 +1 @@
1
+ import{a as p,b7 as a,bA as n,j as c}from"./index-CeYTjZBm.js";import{R as l}from"./page-BPJSQdrp.js";import"./json-path-offset-CJVk8j-G.js";import"./trash-2-BDrajHic.js";import"./schemas-C_YrO33d.js";import"./url-autocomplete-DJjdwAEw.js";import"./text-align-start-Ce0773HM.js";import"./save-BVL6EWGk.js";import"./date-picker-input-DmdIedlu.js";import"./link-2-BcU0xDrw.js";import"./file-text-C04rYizE.js";import"./empty-state-BWk8zyoq.js";import"./refresh-cw-D5TWZXee.js";import"./useDebounce-BS2wroQC.js";import"./confirm-dialog-v51h4XIn.js";import"./footer-ChV5nI8s.js";import"./minimize-2-BKSKBXgc.js";import"./cubic-M4WADWPw.js";import"./circle-alert-DvbmPbYC.js";import"./shield-check-dcbIrNXu.js";const u={resourceType:"Library",meta:{profile:["https://sql-on-fhir.org/ig/StructureDefinition/SQLQuery"]},status:"active",type:{coding:[{system:"https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes",code:"sql-query"}]}},D=()=>{const t=p.c(8),e=a();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/analytics/queries/create"},t[0]=r):r=t[0];const{tab:s,mode:m}=n(r);let o;t[1]!==e?(o=()=>e({to:"/analytics"}),t[1]=e,t[2]=o):o=t[2];let i;return t[3]!==m||t[4]!==e||t[5]!==o||t[6]!==s?(i=c.jsx(l,{initialResource:u,resourceType:"Library",tab:s,mode:m,navigate:e,onCreated:o}),t[3]=m,t[4]=e,t[5]=o,t[6]=s,t[7]=i):i=t[7],i};export{D as component};
@@ -0,0 +1 @@
1
+ import{a as c,eo as n,b7 as l,bA as u,j as d}from"./index-CeYTjZBm.js";import{a as f}from"./page-BPJSQdrp.js";import"./json-path-offset-CJVk8j-G.js";import"./trash-2-BDrajHic.js";import"./schemas-C_YrO33d.js";import"./url-autocomplete-DJjdwAEw.js";import"./text-align-start-Ce0773HM.js";import"./save-BVL6EWGk.js";import"./date-picker-input-DmdIedlu.js";import"./link-2-BcU0xDrw.js";import"./file-text-C04rYizE.js";import"./empty-state-BWk8zyoq.js";import"./refresh-cw-D5TWZXee.js";import"./useDebounce-BS2wroQC.js";import"./confirm-dialog-v51h4XIn.js";import"./footer-ChV5nI8s.js";import"./minimize-2-BKSKBXgc.js";import"./cubic-M4WADWPw.js";import"./circle-alert-DvbmPbYC.js";import"./shield-check-dcbIrNXu.js";const W=()=>{const e=c.c(10),{id:s}=n.useParams();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/analytics/queries/edit/$id"},e[0]=r):r=e[0];const t=l(r);let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/analytics/queries/edit/$id"},e[1]=i):i=e[1];const{tab:a,mode:p}=u(i);let o;e[2]!==t?(o=()=>t({to:"/analytics/queries",search:{q:void 0}}),e[2]=t,e[3]=o):o=e[3];let m;return e[4]!==s||e[5]!==p||e[6]!==t||e[7]!==o||e[8]!==a?(m=d.jsx(f,{id:s,resourceType:"Library",tab:a,mode:p,navigate:t,onDeleted:o}),e[4]=s,e[5]=p,e[6]=t,e[7]=o,e[8]=a,e[9]=m):m=e[9],m};export{W as component};
@@ -0,0 +1 @@
1
+ import{a as o,j as s,O as n}from"./index-CeYTjZBm.js";const r=()=>{const e=o.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(n,{}),e[0]=t):t=e[0],t};export{r as component};
@@ -0,0 +1 @@
1
+ import{a as p,b7 as a,bA as n,j as c}from"./index-CeYTjZBm.js";import{R as l}from"./page-BPJSQdrp.js";import"./json-path-offset-CJVk8j-G.js";import"./trash-2-BDrajHic.js";import"./schemas-C_YrO33d.js";import"./url-autocomplete-DJjdwAEw.js";import"./text-align-start-Ce0773HM.js";import"./save-BVL6EWGk.js";import"./date-picker-input-DmdIedlu.js";import"./link-2-BcU0xDrw.js";import"./file-text-C04rYizE.js";import"./empty-state-BWk8zyoq.js";import"./refresh-cw-D5TWZXee.js";import"./useDebounce-BS2wroQC.js";import"./confirm-dialog-v51h4XIn.js";import"./footer-ChV5nI8s.js";import"./minimize-2-BKSKBXgc.js";import"./cubic-M4WADWPw.js";import"./circle-alert-DvbmPbYC.js";import"./shield-check-dcbIrNXu.js";const u={resourceType:"Library",meta:{profile:["https://sql-on-fhir.org/ig/StructureDefinition/SQLView"]},status:"active",type:{coding:[{system:"https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes",code:"sql-view"}]}},D=()=>{const t=p.c(8),e=a();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/analytics/sqlview/create"},t[0]=r):r=t[0];const{tab:s,mode:m}=n(r);let o;t[1]!==e?(o=()=>e({to:"/analytics"}),t[1]=e,t[2]=o):o=t[2];let i;return t[3]!==m||t[4]!==e||t[5]!==o||t[6]!==s?(i=c.jsx(l,{initialResource:u,resourceType:"Library",tab:s,mode:m,navigate:e,onCreated:o}),t[3]=m,t[4]=e,t[5]=o,t[6]=s,t[7]=i):i=t[7],i};export{D as component};
@@ -0,0 +1 @@
1
+ import{a as n,ep as c,b7 as l,bA as f,j as d}from"./index-CeYTjZBm.js";import{a as u}from"./page-BPJSQdrp.js";import"./json-path-offset-CJVk8j-G.js";import"./trash-2-BDrajHic.js";import"./schemas-C_YrO33d.js";import"./url-autocomplete-DJjdwAEw.js";import"./text-align-start-Ce0773HM.js";import"./save-BVL6EWGk.js";import"./date-picker-input-DmdIedlu.js";import"./link-2-BcU0xDrw.js";import"./file-text-C04rYizE.js";import"./empty-state-BWk8zyoq.js";import"./refresh-cw-D5TWZXee.js";import"./useDebounce-BS2wroQC.js";import"./confirm-dialog-v51h4XIn.js";import"./footer-ChV5nI8s.js";import"./minimize-2-BKSKBXgc.js";import"./cubic-M4WADWPw.js";import"./circle-alert-DvbmPbYC.js";import"./shield-check-dcbIrNXu.js";const T=()=>{const t=n.c(10),{id:s}=c.useParams();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/analytics/sqlview/edit/$id"},t[0]=i):i=t[0];const e=l(i);let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/analytics/sqlview/edit/$id"},t[1]=r):r=t[1];const{tab:a,mode:p}=f(r);let o;t[2]!==e?(o=()=>e({to:"/analytics"}),t[2]=e,t[3]=o):o=t[3];let m;return t[4]!==s||t[5]!==p||t[6]!==e||t[7]!==o||t[8]!==a?(m=d.jsx(u,{id:s,resourceType:"Library",tab:a,mode:p,navigate:e,onDeleted:o}),t[4]=s,t[5]=p,t[6]=e,t[7]=o,t[8]=a,t[9]=m):m=t[9],m};export{T as component};
@@ -0,0 +1 @@
1
+ import{a as o,j as s,O as n}from"./index-CeYTjZBm.js";const r=()=>{const e=o.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(n,{}),e[0]=t):t=e[0],t};export{r as component};
@@ -0,0 +1 @@
1
+ import{a as p,b7 as a,bA as n,j as c}from"./index-CeYTjZBm.js";import{R as l}from"./page-BPJSQdrp.js";import"./json-path-offset-CJVk8j-G.js";import"./trash-2-BDrajHic.js";import"./schemas-C_YrO33d.js";import"./url-autocomplete-DJjdwAEw.js";import"./text-align-start-Ce0773HM.js";import"./save-BVL6EWGk.js";import"./date-picker-input-DmdIedlu.js";import"./link-2-BcU0xDrw.js";import"./file-text-C04rYizE.js";import"./empty-state-BWk8zyoq.js";import"./refresh-cw-D5TWZXee.js";import"./useDebounce-BS2wroQC.js";import"./confirm-dialog-v51h4XIn.js";import"./footer-ChV5nI8s.js";import"./minimize-2-BKSKBXgc.js";import"./cubic-M4WADWPw.js";import"./circle-alert-DvbmPbYC.js";import"./shield-check-dcbIrNXu.js";const u={resource:"Patient",resourceType:"ViewDefinition",status:"draft",select:[]},N=()=>{const t=p.c(8),e=a();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/analytics/views/create"},t[0]=i):i=t[0];const{tab:m,mode:s}=n(i);let o;t[1]!==e?(o=()=>e({to:"/analytics"}),t[1]=e,t[2]=o):o=t[2];let r;return t[3]!==s||t[4]!==e||t[5]!==o||t[6]!==m?(r=c.jsx(l,{initialResource:u,resourceType:"ViewDefinition",tab:m,mode:s,navigate:e,onCreated:o}),t[3]=s,t[4]=e,t[5]=o,t[6]=m,t[7]=r):r=t[7],r};export{N as component};
@@ -0,0 +1 @@
1
+ import{a as n,eq as c,b7 as l,bA as f,j as d}from"./index-CeYTjZBm.js";import{a as u}from"./page-BPJSQdrp.js";import"./json-path-offset-CJVk8j-G.js";import"./trash-2-BDrajHic.js";import"./schemas-C_YrO33d.js";import"./url-autocomplete-DJjdwAEw.js";import"./text-align-start-Ce0773HM.js";import"./save-BVL6EWGk.js";import"./date-picker-input-DmdIedlu.js";import"./link-2-BcU0xDrw.js";import"./file-text-C04rYizE.js";import"./empty-state-BWk8zyoq.js";import"./refresh-cw-D5TWZXee.js";import"./useDebounce-BS2wroQC.js";import"./confirm-dialog-v51h4XIn.js";import"./footer-ChV5nI8s.js";import"./minimize-2-BKSKBXgc.js";import"./cubic-M4WADWPw.js";import"./circle-alert-DvbmPbYC.js";import"./shield-check-dcbIrNXu.js";const T=()=>{const t=n.c(10),{id:s}=c.useParams();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/analytics/views/edit/$id"},t[0]=i):i=t[0];const e=l(i);let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/analytics/views/edit/$id"},t[1]=r):r=t[1];const{tab:a,mode:p}=f(r);let o;t[2]!==e?(o=()=>e({to:"/analytics/views",search:{q:void 0}}),t[2]=e,t[3]=o):o=t[3];let m;return t[4]!==s||t[5]!==p||t[6]!==e||t[7]!==o||t[8]!==a?(m=d.jsx(u,{id:s,resourceType:"ViewDefinition",tab:a,mode:p,navigate:e,onDeleted:o}),t[4]=s,t[5]=p,t[6]=e,t[7]=o,t[8]=a,t[9]=m):m=t[9],m};export{T as component};
@@ -0,0 +1 @@
1
+ import{a as o,j as s,O as n}from"./index-CeYTjZBm.js";const r=()=>{const e=o.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(n,{}),e[0]=t):t=e[0],t};export{r as component};
@@ -0,0 +1 @@
1
+ import{c as O,r as m,aa as U,j as t,B as g,bD as H,A as J,bE as Z,f as A,bC as X,au as Y,av as E,H as D,aw as q,a as P,C as Q,a5 as W,L as ee,bF as te}from"./index-CeYTjZBm.js";import{C as ae}from"./confirm-dialog-v51h4XIn.js";import{D as se}from"./footer-ChV5nI8s.js";import{c as ne,e as le,b as re,d as ie}from"./utils-DZ5fqOJB.js";import{R as ce}from"./refresh-cw-D5TWZXee.js";import{C as oe}from"./circle-alert-DvbmPbYC.js";const de=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],ue=O("ban",de);const me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],xe=O("clock",me),fe=30,he="async-operations:tasks-page-size";function y(e){return e.success===!0?"succeeded":e.success===!1?"failed":e.picked===!0||!!e.picked_by||!!e.time_started?"running":"pending"}function x(e){return e?new Date(e).getTime():null}function R(e){const a=Math.max(0,Math.floor(e/1e3));return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m ${a%60}s`:`${Math.floor(a/3600)}h ${Math.floor(a%3600/60)}m`}function pe(e){if(y(e)==="pending")return null;const a=x(e.time_started??e.execution_time);if(a===null)return null;const l=x(e.time_done)??(e.success==null?Date.now():null);return l===null?null:l-a}function be(e){const a=P.c(4),{task:l}=e,o=y(l);if(o==="succeeded"){let s;return a[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex items-center gap-1 text-utility-green",children:[t.jsx(Q,{className:"size-4"}),"Succeeded"]}),a[0]=s):s=a[0],s}if(o==="failed"){let s;return a[1]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex items-center gap-1 text-utility-red",children:[t.jsx(W,{className:"size-4"}),"Failed"]}),a[1]=s):s=a[1],s}if(o==="pending"){let s;return a[2]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex items-center gap-1 text-text-secondary",children:[t.jsx(xe,{className:"size-4"}),"Pending"]}),a[2]=s):s=a[2],s}let c;return a[3]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsxs("span",{className:"flex items-center gap-1 text-utility-blue",children:[t.jsx(ee,{className:"size-4 animate-spin"}),"Running"]}),a[3]=c):c=a[3],c}const ge=[{id:"status",header:"Status",sortable:!0,maxSize:140,cell:e=>t.jsx(be,{task:e})},{id:"task_instance",header:"Task instance",sortable:!0,maxSize:400,cell:e=>t.jsx("span",{className:"font-mono",children:e.task_instance})},{id:"task_name",header:"Task name",sortable:!0,maxSize:220,cell:e=>e.task_name},{id:"attempt",header:"Attempt",sortable:!0,maxSize:100,cell:e=>e.attempt??"—"},{id:"started",header:"Started",sortable:!0,maxSize:260,cell:e=>y(e)==="pending"?"—":e.time_started??e.execution_time??"—"},{id:"done",header:"Done",sortable:!0,maxSize:260,cell:e=>e.time_done??"—"},{id:"duration",header:"Duration",sortable:!0,maxSize:140,cell:e=>{const a=pe(e);return a===null?"—":R(a)}},{id:"execution_time",header:"Execution time",sortable:!0,maxSize:260,cell:e=>e.execution_time??"—"},{id:"executed_by",header:"Executed by",sortable:!0,maxSize:220,cell:e=>e.executed_by??"—"},{id:"picked_by",header:"Picked by",sortable:!0,maxSize:180,cell:e=>e.picked_by??"—"},{id:"last_heartbeat",header:"Last heartbeat",sortable:!0,maxSize:260,cell:e=>e.last_heartbeat??"—"},{id:"last_success",header:"Last success",sortable:!0,maxSize:260,cell:e=>e.last_success??"—"},{id:"last_failure",header:"Last failure",sortable:!0,maxSize:260,cell:e=>e.last_failure??"—"},{id:"consecutive_failures",header:"Consecutive failures",sortable:!0,maxSize:170,cell:e=>e.consecutive_failures??"—"},{id:"priority",header:"Priority",sortable:!0,maxSize:100,cell:e=>e.priority??"—"},{id:"version",header:"Version",sortable:!0,maxSize:100,cell:e=>e.version??"—"}];function ye({operationId:e}){const a=ne(),[l,o]=m.useState(!1),[c,s]=m.useState({column:"started",direction:"desc"}),[f,d]=m.useState(1),[h,L]=U({key:he,getInitialValueInEffect:!1,defaultValue:fe}),{data:r,isLoading:w,isFetching:j,refetch:S,error:M}=le(e,{page:f,pageSize:h,sortField:c?.column??"started",sortOrder:c?.direction??"desc"}),_=m.useRef(e);_.current!==e&&(_.current=e,d(1));const u=r?.total??0,N=Math.max(1,Math.ceil(u/h));if(u>0&&f>N&&d(N),w)return t.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"Loading..."});if(M||!r)return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-text-secondary",children:[t.jsx("div",{children:"Failed to load operation"}),t.jsx(g,{variant:"secondary",size:"small",onClick:()=>S(),children:"Retry"})]});const p=r.status,v=p==="in-progress",$=r.tasks??[],i=r.counts??{total:0,succeeded:0,failed:0,running:0,pending:0},b=r.failure,z=r["task-name"]??"—",F=r["created-at"]??"—",B=r["last-updated"]??"—",k=x(r["started-at"]),I=x(r["last-updated"]),C=v?Date.now():I,V=k!==null&&C!==null?R(C-k):"—",G=n=>{d(1),s(T=>T?.column===n?{column:n,direction:T.direction==="asc"?"desc":"asc"}:{column:n,direction:"asc"})},K=[{label:"Duration",value:V},{label:"Total",value:i.total},{label:"Succeeded",value:i.succeeded},...i.failed>0?[{label:"Failed",value:i.failed}]:[],...i.running>0?[{label:"Running",value:i.running}]:[],...i.pending>0?[{label:"Pending",value:i.pending}]:[],{label:"Created",value:F},{label:"Updated",value:B}];return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsxs("div",{className:"flex items-center gap-4 bg-bg-secondary flex-none h-10 border-b border-border-secondary px-4",children:[t.jsxs(g,{variant:"ghost",size:"small",className:"px-0! hover:bg-bg-secondary!",disabled:j,onClick:()=>S(),children:[t.jsx(ce,{className:`size-4 ${j?"animate-spin":""}`}),"Refresh"]}),v?t.jsxs(g,{variant:"ghost",danger:!0,size:"small",className:"px-0! hover:bg-bg-secondary!",disabled:a.isPending,onClick:()=>o(!0),children:[t.jsx(ue,{className:"size-4"}),"Terminate"]}):null]}),t.jsxs("div",{className:"flex flex-col px-4 py-3 border-b border-border-secondary",children:[t.jsx(re,{status:ie(p,i.running,i.running+i.pending)}),t.jsx("h1",{className:"mt-1.5 text-lg font-semibold text-text-primary truncate",title:z,children:z}),t.jsx("div",{className:"mt-3 flex items-center gap-2 flex-wrap",children:K.map(n=>t.jsxs(H,{variant:"outline",className:"border-transparent gap-1.5 font-normal bg-neutral-100 text-neutral-600",children:[t.jsx("span",{className:"opacity-70",children:n.label}),t.jsx("span",{className:"font-medium tabular-nums",children:n.value})]},n.label))})]}),b?t.jsxs(J,{variant:"critical",className:"mx-4 mt-3",children:[t.jsx(oe,{}),t.jsx(Z,{children:p==="failed"?"Operation failed":"A task failed"}),t.jsx(A,{className:"break-words",children:b.message}),t.jsx(A,{className:"text-text-secondary text-xs font-mono break-all",children:b["task-instance"]})]}):null,t.jsx("div",{className:"flex-1 overflow-auto [&_tbody_tr:last-child]:border-b [&_tbody_tr:last-child]:border-border-secondary",children:t.jsx(X,{data:$,columns:ge,rowKey:n=>n.task_instance,resizable:!0,zebra:!1,sort:c,onSortToggle:G,tableId:"async-operation-tasks",renderExpandedRow:n=>t.jsx("div",{className:"h-80 w-full",children:t.jsxs(Y,{direction:"horizontal",className:"size-full",children:[t.jsxs(E,{defaultSize:50,minSize:20,className:"flex flex-col overflow-hidden",children:[t.jsx("div",{className:"shrink-0 pl-7 pt-2 pb-1 text-sm text-text-secondary",children:"Input"}),t.jsx("div",{className:"flex-1 min-h-0 px-3",children:t.jsx(D,{readOnly:!0,mode:"json",currentValue:JSON.stringify(n.task_data??null,null,2)})})]}),t.jsx(q,{}),t.jsxs(E,{defaultSize:50,minSize:20,className:"flex flex-col overflow-hidden",children:[t.jsx("div",{className:"shrink-0 pl-7 pt-2 pb-1 text-sm text-text-secondary",children:"Output"}),t.jsx("div",{className:"flex-1 min-h-0 px-3",children:t.jsx(D,{readOnly:!0,mode:"json",currentValue:JSON.stringify(n.task_outcome??null,null,2)})})]})]})}),emptyState:t.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"No tasks recorded for this operation"})})}),u>0?t.jsx(se,{total:u,currentPage:f,pageSize:h,selectedCount:0,onPageChange:d,onPageSizeChange:n=>{L(n),d(1)}}):null,t.jsx(ae,{open:l,onOpenChange:o,title:"Terminate operation",description:"Active tasks will be removed. This cannot be undone.",confirmLabel:"Terminate",danger:!0,onConfirm:()=>a.mutate(e)})]})}function ke(){const e=P.c(2),{operationId:a}=te.useParams();let l;return e[0]!==a?(l=t.jsx(ye,{operationId:a}),e[0]=a,e[1]=l):l=e[1],l}export{ke as component};
@@ -0,0 +1 @@
1
+ import{a as fe,bA as pe,b7 as xe,r as Q,aa as he,j as t,s as Se,bB as be,a5 as ye,v as ge,x as je,y as Ne,t as _e,bC as Te,a8 as ve,a6 as ke,a7 as Oe,q as Fe}from"./index-CeYTjZBm.js";import{D as we}from"./footer-ChV5nI8s.js";import{u as Ce,S as ze,a as Y,D as ne,b as Ie,d as Le}from"./utils-DZ5fqOJB.js";const De={created:"created-at",lastUpdated:"last-updated"},Ee={"created-at":"created","last-updated":"lastUpdated"},ce=e=>e?new Date(e).getTime():null;function Me(e){const s=Math.max(0,Math.floor(e/1e3));return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${s%60}s`:`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`}function Pe(){const e=fe.c(69);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={from:"/async-operations/"},e[0]=s):s=e[0];const oe=pe(s);let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T={from:"/async-operations/"},e[1]=T):T=e[1];const d=xe(T);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v={sortField:ne.sortField,sortOrder:ne.sortOrder},e[2]=v):v=e[2];const[m,de]=Q.useState(v),[n,u]=Q.useState(1);let k;e[3]===Symbol.for("react.memo_cache_sentinel")?(k={key:"async-operations:list-page-size",getInitialValueInEffect:!1,defaultValue:ne.pageSize},e[3]=k):k=e[3];const[o,G]=he(k),H=oe.status??"all",J=oe.task??"";let O;e[4]!==n||e[5]!==o||e[6]!==m.sortField||e[7]!==m.sortOrder||e[8]!==H||e[9]!==J?(O={statusFilter:H,taskName:J,sortField:m.sortField,sortOrder:m.sortOrder,page:n,pageSize:o},e[4]=n,e[5]=o,e[6]=m.sortField,e[7]=m.sortOrder,e[8]=H,e[9]=J,e[10]=O):O=e[10];const r=O,{data:i,isLoading:W}=Ce(r);let F;e[11]!==i?.operations?(F=i?.operations??[],e[11]=i?.operations,e[12]=F):F=e[12];const c=F;let w;e[13]!==i?(w=i?.["task-names"]??[],e[13]=i,e[14]=w):w=e[14];const Z=w,f=i?.total??0,ie=Math.max(1,Math.ceil(f/o));f>0&&n>ie&&u(ie);const[ee,me]=Q.useState(Ye);let C,z;e[15]!==c?(z=()=>{if(!c.some(Qe))return;const a=setInterval(()=>me(Date.now()),1e3);return()=>clearInterval(a)},C=[c],e[15]=c,e[16]=C,e[17]=z):(C=e[16],z=e[17]),Q.useEffect(z,C);let I;e[18]!==d?(I=a=>{u(1),d({search:l=>({...l,status:a==="all"||a===""?void 0:a})})},e[18]=d,e[19]=I):I=e[19];const te=I;let L;e[20]!==d?(L=a=>{u(1),d({search:l=>({...l,task:a||void 0})})},e[20]=d,e[21]=L):L=e[21];const p=L,se=Ee[r.sortField];let D;e[22]!==r.sortOrder||e[23]!==se?(D={column:se,direction:r.sortOrder},e[22]=r.sortOrder,e[23]=se,e[24]=D):D=e[24];const ae=D;let E;e[25]===Symbol.for("react.memo_cache_sentinel")?(E=a=>{const l=De[a];l&&(u(1),de(_=>_.sortField===l?{..._,sortOrder:_.sortOrder==="asc"?"desc":"asc"}:{sortField:l,sortOrder:"desc"}))},e[25]=E):E=e[25];const ue=E;let M,P,U;e[26]===Symbol.for("react.memo_cache_sentinel")?(M={id:"operation",header:"Operation",maxSize:400,cell:Ke},P={id:"status",header:"Status",maxSize:180,cell:Xe},U={id:"task",header:"Task",maxSize:300,cell:Be},e[26]=M,e[27]=P,e[28]=U):(M=e[26],P=e[27],U=e[28]);let x;e[29]!==ee?(x={id:"duration",header:"Duration",maxSize:160,cell:a=>{const l=ce(a["started-at"]);if(l===null)return"—";const _=a.status==="in-progress"?ee:ce(a["last-updated"]);return _===null?"—":t.jsx("span",{className:"text-text-secondary tabular-nums",children:Me(_-l)})}},e[29]=ee,e[30]=x):x=e[30];let A,R,$;e[31]===Symbol.for("react.memo_cache_sentinel")?(A={id:"tasks",header:"Tasks",maxSize:180,cell:qe},R={id:"created",header:"Created",sortable:!0,maxSize:320,cell:Ve},$={id:"lastUpdated",header:"Last updated",sortable:!0,maxSize:320,cell:$e},e[31]=A,e[32]=R,e[33]=$):(A=e[31],R=e[32],$=e[33]);let V;e[34]!==x?(V=[M,P,U,x,A,R,$],e[34]=x,e[35]=V):V=e[35];const re=V,le=r.statusFilter==="all"?"":r.statusFilter;let q;e[36]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx(je,{className:"w-44 h-8",children:t.jsx(Ne,{placeholder:"Status"})}),e[36]=q):q=e[36];let B;e[37]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx(Se,{children:ze.map(Re)}),e[37]=B):B=e[37];let h;e[38]!==te||e[39]!==le?(h=t.jsxs(_e,{value:le,onValueChange:te,children:[q,B]}),e[38]=te,e[39]=le,e[40]=h):h=e[40];let S;e[41]!==Z?(S=Z.map(Ae),e[41]=Z,e[42]=S):S=e[42];let b;e[43]!==r.taskName||e[44]!==p||e[45]!==S?(b=t.jsx(be,{options:S,value:r.taskName,onValueChange:p,placeholder:"Task",searchPlaceholder:"Search task...",emptyText:"No tasks found.",className:"w-56 h-8"}),e[43]=r.taskName,e[44]=p,e[45]=S,e[46]=b):b=e[46];let y;e[47]!==r.taskName||e[48]!==p?(y=r.taskName?t.jsx("button",{type:"button",onClick:()=>p(void 0),"aria-label":"Clear task filter",className:"-ml-2 flex items-center justify-center size-8 shrink-0 cursor-pointer text-text-tertiary hover:text-text-primary",children:t.jsx(ye,{className:"size-4"})}):null,e[47]=r.taskName,e[48]=p,e[49]=y):y=e[49];let g;e[50]!==h||e[51]!==b||e[52]!==y?(g=t.jsx("div",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-border-secondary bg-bg-primary",children:t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[h,b,y]})}),e[50]=h,e[51]=b,e[52]=y,e[53]=g):g=e[53];let X;e[54]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"No async operations found"}),e[54]=X):X=e[54];let j;e[55]!==re||e[56]!==W||e[57]!==c||e[58]!==ae?(j=t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx(Te,{data:c,columns:re,rowKey:Ue,loading:W,sort:ae,onSortToggle:ue,resizable:!0,tableId:"async-operations",emptyState:X})}),e[55]=re,e[56]=W,e[57]=c,e[58]=ae,e[59]=j):j=e[59];let N;e[60]!==n||e[61]!==o||e[62]!==G||e[63]!==f?(N=f>0?t.jsx(we,{total:f,currentPage:n,pageSize:o,selectedCount:0,onPageChange:u,onPageSizeChange:a=>{G(a),u(1)}}):null,e[60]=n,e[61]=o,e[62]=G,e[63]=f,e[64]=N):N=e[64];let K;return e[65]!==g||e[66]!==j||e[67]!==N?(K=t.jsxs("div",{className:"flex flex-col h-full",children:[g,j,N]}),e[65]=g,e[66]=j,e[67]=N,e[68]=K):K=e[68],K}function Ue(e){return e["operation-id"]}function Ae(e){return{value:e,label:e}}function Re(e){return t.jsx(ge,{value:e.value,className:e.value==="all"?void 0:Y[e.value],children:e.label},e.value)}function $e(e){return t.jsx("span",{className:"text-text-secondary whitespace-nowrap",children:e["last-updated"]})}function Ve(e){return t.jsx("span",{className:"text-text-secondary whitespace-nowrap",children:e["created-at"]})}function qe(e){return t.jsxs(ve,{children:[t.jsx(ke,{asChild:!0,children:t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[e.succeeded,"/",e.total]})}),t.jsx(Oe,{side:"bottom",style:{fontFamily:"var(--font-family-mono)"},className:"bg-bg-primary text-text-primary border border-border-primary shadow-md font-medium",children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex justify-between gap-4",children:[t.jsx("span",{className:Y["in-progress"],children:"Active"}),t.jsx("span",{className:"tabular-nums",children:e.active})]}),t.jsxs("div",{className:"flex justify-between gap-4",children:[t.jsx("span",{className:Y.completed,children:"Succeeded"}),t.jsx("span",{className:"tabular-nums",children:e.succeeded})]}),t.jsxs("div",{className:"flex justify-between gap-4",children:[t.jsx("span",{className:Y.failed,children:"Failed"}),t.jsx("span",{className:"tabular-nums",children:e.failed})]})]})})]})}function Be(e){return e["task-name"]??"—"}function Xe(e){return t.jsx(Ie,{status:Le(e.status,e.running,e.active)})}function Ke(e){const s=e["operation-id"];return t.jsx(Fe,{to:"/async-operations/$operationId",params:{operationId:s},className:"text-text-link hover:underline font-medium",title:s,children:s})}function Qe(e){return e.status==="in-progress"}function Ye(){return Date.now()}const We=Pe;export{We as component};
@@ -0,0 +1 @@
1
+ import{c as xe,a as O,j as s,s as he,t as pe,r as X,v as ye,w as ge,I as K,x as je,y as be,T as ve,z as se,E as le,F as Ne,q as ie,G as we,H as Ce,J as _e,K as ce,M as B,N as Se,P as Ie,Q as G,R as re,V as oe,d as Te,W as $e,e as ke,X as Ee,Y as Pe,B as ee,Z as De,_ as Ae,$ as Fe,a0 as Re}from"./index-CeYTjZBm.js";import{D as ne}from"./date-picker-input-DmdIedlu.js";import{C as qe}from"./circle-x-DwhdsFBE.js";const Le=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ue=xe("circle-check-big",Le),de=50,ze=[10,20,30,50,100],te="all",Oe=[{value:te,label:"All categories"},{value:"data-access",label:"data-access"},{value:"data-modification",label:"data-modification"},{value:"sql-interaction",label:"sql-interaction"},{value:"configuration",label:"configuration"},{value:"security",label:"security"}],Me={search:"",dateFrom:"",dateTo:"",userId:"",patientId:"",clientId:"",category:te};function Ve(a){return a?.find(e=>e.requestor===!0)}function fe(a){return a?.find(e=>e.type?.coding?.some(t=>t.code==="110153"))}function ue(a){const e=Ve(a.agent);if(!e)return{display:""};const t=e.who?.identifier,l=t?.type?.coding?.[0]?.code,i=e.altId||t?.value||e.who?.display||"";return l==="UID"&&i?{display:`User/${i}`,resourceType:"User",id:i}:l==="portal-user-username"&&i?{display:i}:{display:i}}function Be(a){const e=fe(a.agent);return e&&e.who?.identifier?.value||null}function Ge(a){const e=a.type?.code,t=a.subtype?.map(l=>l.code).filter(Boolean)??[];return e==="rest"?t.some(l=>l==="search"||l==="read")?"data-access":t.some(l=>l==="create"||l==="update"||l==="delete")?"data-modification":"data-access":e==="110112"&&t.includes("sql")?"sql-interaction":a.type?.display?.toLowerCase()??"unknown"}function He(a){const e=a.outcome==="0"?"successful":"failed",t=a.subtype?.[0]?.display??"",l=a.entity?.find(i=>i.type?.code!=="XrequestId");if(l?.description){const i=l.description;if(a.type?.code==="rest"){const c=i.match(/\/(?:fhir\/)?(\w+)/)?.[1]??"";return l.what?.reference?`${e} ${t} of ${l.what.reference.split("/").pop()}`:`${e} ${t} over ${c}`}if(a.type?.code==="110112")return`${e} execution of ${a.subtype?.[0]?.display??"query"} operation`}return l?.what?.reference?`${e} ${t} of ${l.what.reference}`:`${e} ${t}`}function Xe(a){const e=a.entity?.find(t=>t.type?.code!=="XrequestId");return e?e.description?{text:e.description,url:e.description}:e.what?.reference?{text:e.what.reference,url:e.what.reference}:null:null}function Qe(a){return a.entity?.find(t=>t.type?.code==="XrequestId")?.what?.identifier?.value??""}function We(a){const t=a.entity?.find(i=>i.what?.reference?.startsWith("Patient/"))?.what?.reference;if(!t)return null;const l=t.split("/")[1]??t;return{display:t,id:l}}function Ze(a){return fe(a.agent)?.network?.address??""}function me(a){if(!a)return{date:"",time:""};const e=new Date(a);return{date:e.toLocaleDateString(),time:e.toLocaleTimeString()}}function ae(a){if(!a)return null;const e=a.split(".");if(e.length===3){const[l,i,n]=e,c=new Date(`${n}-${i}-${l}`);if(!Number.isNaN(c.getTime()))return`${n}-${i}-${l}`}const t=new Date(a);return Number.isNaN(t.getTime())?null:t.toISOString().slice(0,10)}function Je(a,e,t=de){const l=["_sort=-createdAt",`_count=${t}`,`_page=${e}`];if(a.search&&l.push(`_ilike=${encodeURIComponent(a.search)}`),a.dateFrom){const i=ae(a.dateFrom);i&&l.push(`date=ge${i}`)}if(a.dateTo){const i=ae(a.dateTo);i&&l.push(`date=le${i}`)}if(a.userId&&l.push(`altid=${encodeURIComponent(a.userId)}`),a.patientId&&l.push(`patient=${encodeURIComponent(a.patientId)}`),a.clientId&&l.push(`agent:identifier=${encodeURIComponent(a.clientId)}`),a.category&&a.category!==te){const n={"data-access":"search,read","data-modification":"create,update,delete","sql-interaction":"sql",configuration:"transaction",security:"110114"}[a.category];n&&l.push(`subtype=${n}`)}return l.join("&")}function Y(a,e,t){const l=O.c(9),i=300,[n,c]=X.useState(a),d=X.useRef(void 0);let x,y;l[0]!==a?(x=()=>{c(a)},y=[a],l[0]=a,l[1]=x,l[2]=y):(x=l[1],y=l[2]),X.useEffect(x,y);let u;l[3]!==i||l[4]!==e?(u=m=>{c(m),clearTimeout(d.current),d.current=setTimeout(()=>e(m),i)},l[3]=i,l[4]=e,l[5]=u):u=l[5];const p=u;let f;return l[6]!==p||l[7]!==n?(f=[n,p],l[6]=p,l[7]=n,l[8]=f):f=l[8],f}function Ke(a){const e=O.c(69),{filters:t,onFiltersChange:l}=a;let i;e[0]!==t||e[1]!==l?(i=T=>{l({...t,...T})},e[0]=t,e[1]=l,e[2]=i):i=e[2];const n=i;let c;e[3]!==n?(c=T=>n({search:T}),e[3]=n,e[4]=c):c=e[4];const[d,x]=Y(t.search,c);let y;e[5]!==n?(y=T=>n({userId:T}),e[5]=n,e[6]=y):y=e[6];const[u,p]=Y(t.userId,y);let f;e[7]!==n?(f=T=>n({clientId:T}),e[7]=n,e[8]=f):f=e[8];const[m,g]=Y(t.clientId,f);let r;e[9]!==n?(r=T=>n({patientId:T}),e[9]=n,e[10]=r):r=e[10];const[o,h]=Y(t.patientId,r);let b;e[11]!==x?(b=T=>x(T.target.value),e[11]=x,e[12]=b):b=e[12];let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(ge,{}),e[13]=_):_=e[13];let v;e[14]!==d||e[15]!==b?(v=s.jsx(K,{placeholder:"Search",value:d,onChange:b,leftSlot:_}),e[14]=d,e[15]=b,e[16]=v):v=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx("span",{className:"typo-label-xs text-text-secondary",children:"Date range"}),e[17]=w):w=e[17];let N;e[18]!==n?(N=T=>n({dateFrom:T}),e[18]=n,e[19]=N):N=e[19];let S;e[20]!==t.dateFrom||e[21]!==N?(S=s.jsx(ne,{value:t.dateFrom,onChange:N,className:"w-44"}),e[20]=t.dateFrom,e[21]=N,e[22]=S):S=e[22];let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx("span",{className:"text-text-secondary text-xs px-1",children:"—"}),e[23]=k):k=e[23];let j;e[24]!==n?(j=T=>n({dateTo:T}),e[24]=n,e[25]=j):j=e[25];let C;e[26]!==t.dateTo||e[27]!==j?(C=s.jsx(ne,{value:t.dateTo,onChange:j,className:"w-44"}),e[26]=t.dateTo,e[27]=j,e[28]=C):C=e[28];let $;e[29]!==S||e[30]!==C?($=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,s.jsxs("div",{className:"flex items-center",children:[S,k,C]})]}),e[29]=S,e[30]=C,e[31]=$):$=e[31];let D;e[32]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("span",{className:"typo-label-xs text-text-secondary",children:"User"}),e[32]=D):D=e[32];let A;e[33]!==p?(A=T=>p(T.target.value),e[33]=p,e[34]=A):A=e[34];let E;e[35]!==A||e[36]!==u?(E=s.jsxs("div",{className:"flex flex-col gap-1",children:[D,s.jsx(K,{placeholder:"User ID",value:u,onChange:A,className:"w-44"})]}),e[35]=A,e[36]=u,e[37]=E):E=e[37];let R;e[38]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx("span",{className:"typo-label-xs text-text-secondary",children:"Client"}),e[38]=R):R=e[38];let P;e[39]!==g?(P=T=>g(T.target.value),e[39]=g,e[40]=P):P=e[40];let q;e[41]!==m||e[42]!==P?(q=s.jsxs("div",{className:"flex flex-col gap-1",children:[R,s.jsx(K,{placeholder:"Client ID",value:m,onChange:P,className:"w-44"})]}),e[41]=m,e[42]=P,e[43]=q):q=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx("span",{className:"typo-label-xs text-text-secondary",children:"Patient"}),e[44]=F):F=e[44];let L;e[45]!==h?(L=T=>h(T.target.value),e[45]=h,e[46]=L):L=e[46];let U;e[47]!==o||e[48]!==L?(U=s.jsxs("div",{className:"flex flex-col gap-1",children:[F,s.jsx(K,{placeholder:"Patient ID",value:o,onChange:L,className:"w-44"})]}),e[47]=o,e[48]=L,e[49]=U):U=e[49];let z;e[50]!==E||e[51]!==q||e[52]!==U?(z=s.jsxs("div",{className:"flex items-end gap-4",children:[E,q,U]}),e[50]=E,e[51]=q,e[52]=U,e[53]=z):z=e[53];let M;e[54]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx("span",{className:"typo-label-xs text-text-secondary",children:"Category"}),e[54]=M):M=e[54];let I;e[55]!==n?(I=T=>n({category:T}),e[55]=n,e[56]=I):I=e[56];let V;e[57]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(je,{className:"w-44",children:s.jsx(be,{placeholder:"All categories"})}),e[57]=V):V=e[57];let Z;e[58]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(he,{children:Oe.map(Ye)}),e[58]=Z):Z=e[58];let Q;e[59]!==t.category||e[60]!==I?(Q=s.jsxs("div",{className:"flex flex-col gap-1",children:[M,s.jsxs(pe,{value:t.category,onValueChange:I,children:[V,Z]})]}),e[59]=t.category,e[60]=I,e[61]=Q):Q=e[61];let W;e[62]!==$||e[63]!==z||e[64]!==Q?(W=s.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[$,z,Q]}),e[62]=$,e[63]=z,e[64]=Q,e[65]=W):W=e[65];let J;return e[66]!==W||e[67]!==v?(J=s.jsxs("div",{className:"flex flex-col gap-3 px-4 py-3 border-b border-border-secondary",children:[v,W]}),e[66]=W,e[67]=v,e[68]=J):J=e[68],J}function Ye(a){return s.jsx(ye,{value:a.value,children:a.label},a.value)}function H(a){const e=O.c(7),{label:t,children:l}=a;let i;e[0]!==t?(i=s.jsx("dt",{className:"text-text-secondary typo-label-xs whitespace-nowrap pt-0.5",children:t}),e[0]=t,e[1]=i):i=e[1];let n;e[2]!==l?(n=s.jsx("dd",{className:"text-text-primary text-sm break-all",children:l}),e[2]=l,e[3]=n):n=e[3];let c;return e[4]!==i||e[5]!==n?(c=s.jsxs(s.Fragment,{children:[i,n]}),e[4]=i,e[5]=n,e[6]=c):c=e[6],c}function et(a){const e=O.c(41),{resource:t}=a;let l;e[0]!==t.recorded?(l=me(t.recorded),e[0]=t.recorded,e[1]=l):l=e[1];const{date:i,time:n}=l;let c;e[2]!==t?(c=Xe(t),e[2]=t,e[3]=c):c=e[3];const d=c;let x;e[4]!==t?(x=ue(t),e[4]=t,e[5]=x):x=e[5];const y=x;let u;e[6]!==t?(u=Ze(t),e[6]=t,e[7]=u):u=e[7];const p=u;let f;e[8]!==t?(f=Qe(t),e[8]=t,e[9]=f):f=e[9];const m=f,g=t.outcome==="0";let r;e[10]!==t.id?(r={resourceType:"AuditEvent",id:t.id},e[10]=t.id,e[11]=r):r=e[11];let o;e[12]===Symbol.for("react.memo_cache_sentinel")?(o={tab:"edit",mode:"json",builderTab:"code"},e[12]=o):o=e[12];let h;e[13]!==t.id||e[14]!==r?(h=s.jsx(H,{label:"Event id",children:s.jsxs(ie,{to:"/resource/$resourceType/edit/$id",params:r,search:o,className:"text-text-link hover:underline",children:["AuditEvent/",t.id]})}),e[13]=t.id,e[14]=r,e[15]=h):h=e[15];const b=t.type?.display??t.type?.code??"—";let _;e[16]!==b?(_=s.jsx(H,{label:"Event type",children:b}),e[16]=b,e[17]=_):_=e[17];let v;e[18]!==i||e[19]!==n?(v=s.jsxs(H,{label:"Occured datetime",children:[i," ",n]}),e[18]=i,e[19]=n,e[20]=v):v=e[20];let w;e[21]!==g?(w=g?s.jsx(Ue,{className:"size-4 text-utility-green"}):s.jsx(qe,{className:"size-4 text-utility-red"}),e[21]=g,e[22]=w):w=e[22];let N;e[23]!==t.outcome||e[24]!==w?(N=s.jsx(H,{label:"Outcome",children:s.jsxs("span",{className:"inline-flex items-center gap-1",children:[w,t.outcome]})}),e[23]=t.outcome,e[24]=w,e[25]=N):N=e[25];let S;e[26]!==d||e[27]!==m?(S=d&&s.jsx(H,{label:"Entity",children:s.jsxs("div",{children:[d.url?s.jsx("span",{className:"text-text-link break-all",children:d.text}):s.jsx("span",{children:d.text}),m&&s.jsxs("div",{className:"text-text-secondary text-xs mt-0.5",children:["Unknown type with identifier: |",m]})]})}),e[26]=d,e[27]=m,e[28]=S):S=e[28];const k=y.display||"—";let j;e[29]!==k?(j=s.jsx(H,{label:"User",children:k}),e[29]=k,e[30]=j):j=e[30];let C;e[31]!==p?(C=p&&s.jsx(H,{label:"Request from IP address",children:s.jsx("code",{className:"font-mono",children:p})}),e[31]=p,e[32]=C):C=e[32];let $;return e[33]!==_||e[34]!==v||e[35]!==N||e[36]!==S||e[37]!==j||e[38]!==C||e[39]!==h?($=s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-6 gap-y-2 p-4 pl-[48px] min-h-80",children:[h,_,v,N,S,j,C]}),e[33]=_,e[34]=v,e[35]=N,e[36]=S,e[37]=j,e[38]=C,e[39]=h,e[40]=$):$=e[40],$}function tt(a){const e=O.c(6),{resource:t}=a;let l;try{let c;if(e[0]!==t){const{resourceType:d,...x}=t;c=we({...x,resourceType:t.resourceType},{indent:2,lineWidth:-1}),e[0]=t,e[1]=c}else c=e[1];l=c}catch{let c;e[2]!==t?(c=JSON.stringify(t,null,2),e[2]=t,e[3]=c):c=e[3],l=c}const i=l;let n;return e[4]!==i?(n=s.jsx("div",{className:"h-80 overflow-hidden max-w-full pl-[30px]",children:s.jsx(Ce,{readOnly:!0,currentValue:i,mode:"yaml"})}),e[4]=i,e[5]=n):n=e[5],n}function st(a){const e=O.c(8),{resource:t}=a;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs(ve,{className:"w-full! flex-none! pl-[34px]!",children:[s.jsx(se,{value:"default",className:"flex-none!",children:"Default"}),s.jsx(se,{value:"raw",className:"flex-none!",children:"Raw"})]}),e[0]=l):l=e[0];let i;e[1]!==t?(i=s.jsx(le,{value:"default",className:"bg-bg-primary",children:s.jsx(et,{resource:t})}),e[1]=t,e[2]=i):i=e[2];let n;e[3]!==t?(n=s.jsx(le,{value:"raw",className:"bg-bg-primary",children:s.jsx(tt,{resource:t})}),e[3]=t,e[4]=n):n=e[4];let c;return e[5]!==i||e[6]!==n?(c=s.jsxs(Ne,{variant:"tertiary",defaultValue:"default",className:"w-full",children:[l,i,n]}),e[5]=i,e[6]=n,e[7]=c):c=e[7],c}function lt(a){const e=O.c(18),{events:t,isLoading:l,onUserClick:i,onPatientClick:n,onClientClick:c}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[0]=d):d=e[0];const[x,y]=X.useState(d);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=r=>{y(o=>{const h=new Set(o);return h.has(r)?h.delete(r):h.add(r),h})},e[1]=u):u=e[1];const p=u;if(l){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"Loading..."}),e[2]=r):r=e[2],r}if(t.length===0){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"No audit events found"}),e[3]=r):r=e[3],r}let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_e,{children:s.jsxs(ce,{children:[s.jsx(B,{className:"w-8"}),s.jsx(B,{className:"whitespace-nowrap",children:"Date/time"}),s.jsx(B,{children:"User"}),s.jsx(B,{className:"whitespace-nowrap",children:"Client"}),s.jsx(B,{children:"Patient"}),s.jsx(B,{className:"whitespace-nowrap",children:"Category"}),s.jsx(B,{children:"Details"})]})}),e[4]=f):f=e[4];let m;if(e[5]!==t||e[6]!==x||e[7]!==c||e[8]!==n||e[9]!==i){let r;e[11]!==x||e[12]!==c||e[13]!==n||e[14]!==i?(r=o=>{const h=x.has(o.id),{date:b,time:_}=me(o.recorded),v=ue(o),w=Be(o),N=Ge(o),S=He(o);return s.jsx(nt,{event:o,isExpanded:h,date:b,time:_,user:v,clientId:w,category:N,details:S,onToggle:p,onUserClick:i,onPatientClick:n,onClientClick:c},o.id)},e[11]=x,e[12]=c,e[13]=n,e[14]=i,e[15]=r):r=e[15],m=t.map(r),e[5]=t,e[6]=x,e[7]=c,e[8]=n,e[9]=i,e[10]=m}else m=e[10];let g;return e[16]!==m?(g=s.jsxs(Se,{stickyHeader:!0,children:[f,s.jsx(Ie,{children:m})]}),e[16]=m,e[17]=g):g=e[17],g}function nt(a){const e=O.c(50),{event:t,isExpanded:l,date:i,time:n,user:c,clientId:d,category:x,details:y,onToggle:u,onUserClick:p,onPatientClick:f,onClientClick:m}=a,g=`cursor-pointer ${l?"border-b-0 bg-bg-secondary!":""}`;let r;e[0]!==t.id||e[1]!==u?(r=()=>u(t.id),e[0]=t.id,e[1]=u,e[2]=r):r=e[2];let o;e[3]!==l?(o=s.jsx(G,{className:"w-8 px-2",children:l?s.jsx(re,{className:"size-4 text-text-secondary"}):s.jsx(oe,{className:"size-4 text-text-secondary"})}),e[3]=l,e[4]=o):o=e[4];let h;e[5]!==i?(h=s.jsx("span",{children:i}),e[5]=i,e[6]=h):h=e[6];let b;e[7]!==n?(b=s.jsx("span",{className:"text-text-secondary text-xs",children:n}),e[7]=n,e[8]=b):b=e[8];let _;e[9]!==h||e[10]!==b?(_=s.jsx(G,{children:s.jsxs("div",{className:"flex flex-col",children:[h,b]})}),e[9]=h,e[10]=b,e[11]=_):_=e[11];let v;e[12]!==p||e[13]!==c.display||e[14]!==c.id?(v=c.id&&p?s.jsx("button",{type:"button",className:"text-text-link hover:underline truncate",onClick:F=>{F.stopPropagation(),p(c.id)},children:c.display}):c.display,e[12]=p,e[13]=c.display,e[14]=c.id,e[15]=v):v=e[15];let w;e[16]!==v?(w=s.jsx(G,{className:"truncate max-w-0 w-[20%]",children:v}),e[16]=v,e[17]=w):w=e[17];let N;e[18]!==d||e[19]!==m?(N=d&&m?s.jsxs("button",{type:"button",className:"text-text-link hover:underline truncate",onClick:F=>{F.stopPropagation(),m(d)},children:["Client/",d]}):d?`Client/${d}`:null,e[18]=d,e[19]=m,e[20]=N):N=e[20];let S;e[21]!==N?(S=s.jsx(G,{className:"whitespace-nowrap",children:N}),e[21]=N,e[22]=S):S=e[22];let k;e[23]!==t?(k=We(t),e[23]=t,e[24]=k):k=e[24];const j=k;let C;e[25]!==f||e[26]!==j?(C=j&&f?s.jsx("button",{type:"button",className:"text-text-link hover:underline truncate",onClick:F=>{F.stopPropagation(),f(j.id)},children:j.display}):j?j.display:null,e[25]=f,e[26]=j,e[27]=C):C=e[27];const $=C;let D;e[28]!==$?(D=s.jsx(G,{children:$}),e[28]=$,e[29]=D):D=e[29];let A;e[30]!==x?(A=s.jsx(G,{className:"whitespace-nowrap",children:x}),e[30]=x,e[31]=A):A=e[31];let E;e[32]!==y?(E=s.jsx(G,{className:"truncate max-w-0 w-[35%]",children:y}),e[32]=y,e[33]=E):E=e[33];let R;e[34]!==g||e[35]!==S||e[36]!==D||e[37]!==A||e[38]!==E||e[39]!==r||e[40]!==o||e[41]!==_||e[42]!==w?(R=s.jsxs(ce,{className:g,onClick:r,children:[o,_,w,S,D,A,E]}),e[34]=g,e[35]=S,e[36]=D,e[37]=A,e[38]=E,e[39]=r,e[40]=o,e[41]=_,e[42]=w,e[43]=R):R=e[43];let P;e[44]!==t||e[45]!==l?(P=l&&s.jsx("tr",{className:"hover:bg-transparent",children:s.jsx("td",{colSpan:7,className:"p-0 border-b border-border-secondary max-w-0",children:s.jsx(st,{resource:t})})}),e[44]=t,e[45]=l,e[46]=P):P=e[46];let q;return e[47]!==R||e[48]!==P?(q=s.jsxs(s.Fragment,{children:[R,P]}),e[47]=R,e[48]=P,e[49]=q):q=e[49],q}function at(){const a=O.c(5),e=Te(),{data:t,isLoading:l}=$e();if(l){let n;return a[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"Loading..."}),a[0]=n):n=a[0],n}if(!t){let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"text-lg mb-2",children:"Audit logging is disabled"}),a[1]=n):n=a[1];let c;return a[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:s.jsxs("div",{className:"text-center",children:[n,s.jsxs("div",{className:"text-sm",children:['Enable "FHIR Audit Log" in'," ",s.jsx(ie,{to:"/settings",className:"text-text-link hover:underline",children:"Settings"})," ","to start collecting audit events."]})]})}),a[2]=c):c=a[2],c}let i;return a[3]!==e?(i=s.jsx(it,{client:e}),a[3]=e,a[4]=i):i=a[4],i}function it(a){const e=O.c(50),{client:t}=a,[l,i]=X.useState(Me),[n,c]=X.useState(1),[d,x]=X.useState(de);let y;e[0]!==l||e[1]!==n||e[2]!==d?(y=Je(l,n,d),e[0]=l,e[1]=n,e[2]=d,e[3]=y):y=e[3];const u=y;let p;e[4]!==u?(p=["audit-events",u],e[4]=u,e[5]=p):p=e[5];let f;e[6]!==t||e[7]!==u?(f=async()=>{const I=await t.searchType({type:"AuditEvent",query:Ee(u)});if(I.isErr())throw new Error("Failed to fetch audit events",{cause:I.value.resource});const V=I.value.resource;return{total:V?.total??0,events:V?.entry?.flatMap(ct)??[]}},e[6]=t,e[7]=u,e[8]=f):f=e[8];let m;e[9]!==p||e[10]!==f?(m={queryKey:p,queryFn:f},e[9]=p,e[10]=f,e[11]=m):m=e[11];const{data:g,isLoading:r}=ke(m),o=g?.total??0;let h;e[12]!==g?.events?(h=g?.events??[],e[12]=g?.events,e[13]=h):h=e[13];const b=h,_=Math.max(1,Math.ceil(o/d));let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=I=>{i(I),c(1)},e[14]=v):v=e[14];const w=v;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=I=>{x(I),c(1)},e[15]=N):N=e[15];const S=N;let k;e[16]!==l?(k=s.jsx(Ke,{filters:l,onFiltersChange:w}),e[16]=l,e[17]=k):k=e[17];let j,C,$;e[18]!==l?($=I=>w({...l,userId:I}),j=I=>w({...l,patientId:I}),C=I=>w({...l,clientId:I}),e[18]=l,e[19]=j,e[20]=C,e[21]=$):(j=e[19],C=e[20],$=e[21]);let D;e[22]!==b||e[23]!==r||e[24]!==j||e[25]!==C||e[26]!==$?(D=s.jsx("div",{className:"flex-1 overflow-auto",children:s.jsx(lt,{events:b,isLoading:r,onUserClick:$,onPatientClick:j,onClientClick:C})}),e[22]=b,e[23]=r,e[24]=j,e[25]=C,e[26]=$,e[27]=D):D=e[27];const A=o!==1?"s":"";let E;e[28]!==A||e[29]!==o?(E=s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("span",{className:"text-text-secondary text-sm",children:[o," event",A]})}),e[28]=A,e[29]=o,e[30]=E):E=e[30];let R;e[31]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(re,{size:14}),e[31]=R):R=e[31];let P;e[32]!==d?(P=s.jsx(Pe,{asChild:!0,children:s.jsxs(ee,{variant:"ghost",size:"small",children:[d,"/page",R]})}),e[32]=d,e[33]=P):P=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(De,{align:"end",children:ze.map(I=>s.jsxs(Ae,{onClick:()=>S(I),children:[I,"/page"]},I))}),e[34]=q):q=e[34];let F;e[35]!==P?(F=s.jsxs(Fe,{children:[P,q]}),e[35]=P,e[36]=F):F=e[36];let L;e[37]!==n||e[38]!==_?(L=s.jsx(rt,{currentPage:n,totalPages:_,onPageChange:c}),e[37]=n,e[38]=_,e[39]=L):L=e[39];let U;e[40]!==F||e[41]!==L?(U=s.jsxs("div",{className:"flex items-center gap-4",children:[F,L]}),e[40]=F,e[41]=L,e[42]=U):U=e[42];let z;e[43]!==E||e[44]!==U?(z=s.jsxs("div",{className:"flex items-center justify-between border-t bg-bg-secondary px-4 h-10",children:[E,U]}),e[43]=E,e[44]=U,e[45]=z):z=e[45];let M;return e[46]!==D||e[47]!==z||e[48]!==k?(M=s.jsxs("div",{className:"flex flex-col h-full",children:[k,D,z]}),e[46]=D,e[47]=z,e[48]=k,e[49]=M):M=e[49],M}function ct(a){return a.resource?[a.resource]:[]}function rt(a){const e=O.c(25),{currentPage:t,totalPages:l,onPageChange:i}=a;let n;if(e[0]!==t||e[1]!==l){if(n=[],l<=7)for(let o=1;o<=l;o++)n.push(o);else{n.push(1),t>3&&n.push("ellipsis-start");const o=Math.max(2,t-1),h=Math.min(l-1,t+1);for(let b=o;b<=h;b++)n.push(b);t<l-2&&n.push("ellipsis-end"),n.push(l)}e[0]=t,e[1]=l,e[2]=n}else n=e[2];const c=t<=1;let d;e[3]!==t||e[4]!==i?(d=()=>i(t-1),e[3]=t,e[4]=i,e[5]=d):d=e[5];let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Re,{size:16}),e[6]=x):x=e[6];let y;e[7]!==c||e[8]!==d?(y=s.jsx(ee,{variant:"ghost",size:"small",disabled:c,onClick:d,children:x}),e[7]=c,e[8]=d,e[9]=y):y=e[9];let u;e[10]!==t||e[11]!==i||e[12]!==n?(u=n.map(o=>typeof o=="string"?s.jsx("span",{className:"px-1 text-elements-assistive",children:"..."},o):s.jsx(ee,{variant:o===t?"secondary":"ghost",size:"small",onClick:()=>i(o),children:o},o)),e[10]=t,e[11]=i,e[12]=n,e[13]=u):u=e[13];const p=t>=l;let f;e[14]!==t||e[15]!==i?(f=()=>i(t+1),e[14]=t,e[15]=i,e[16]=f):f=e[16];let m;e[17]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(oe,{size:16}),e[17]=m):m=e[17];let g;e[18]!==p||e[19]!==f?(g=s.jsx(ee,{variant:"ghost",size:"small",disabled:p,onClick:f,children:m}),e[18]=p,e[19]=f,e[20]=g):g=e[20];let r;return e[21]!==y||e[22]!==u||e[23]!==g?(r=s.jsxs("div",{className:"flex items-center gap-1",children:[y,u,g]}),e[21]=y,e[22]=u,e[23]=g,e[24]=r):r=e[24],r}const ut=at;export{ut as component};
@@ -0,0 +1 @@
1
+ import{c as e}from"./index-CeYTjZBm.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],y=e("circle-alert",c);export{y as C};
@@ -0,0 +1 @@
1
+ import{c}from"./index-CeYTjZBm.js";const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],o=c("circle-x",e);export{o as C};
@@ -0,0 +1 @@
1
+ import{j as l,n as c,k as x,g as j,h as D,a4 as g,l as m,i as A,m as d}from"./index-CeYTjZBm.js";function h({open:r,onOpenChange:a,title:s,description:i,confirmLabel:e="Confirm",cancelLabel:o="Cancel",danger:t=!1,onConfirm:n}){return l.jsx(c,{open:r,onOpenChange:a,children:l.jsxs(x,{className:"max-w-lg",children:[l.jsx(j,{children:l.jsx(D,{children:s})}),i&&l.jsx(g,{children:i}),l.jsxs(m,{children:[l.jsx(A,{onClick:()=>a(!1),children:o}),l.jsx(d,{variant:"primary",danger:t,onClick:()=>{n(),a(!1)},children:e})]})]})})}export{h as C};
@@ -0,0 +1 @@
1
+ function te(e,n,r){e.prototype=n.prototype=r,r.constructor=e}function be(e,n){var r=Object.create(e.prototype);for(var t in n)r[t]=n[t];return r}function O(){}var X=.7,P=1/X,N="\\s*([+-]?\\d+)\\s*",I="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",m="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Oe=/^#([0-9a-f]{3,8})$/,je=new RegExp(`^rgb\\(${N},${N},${N}\\)$`),Ce=new RegExp(`^rgb\\(${m},${m},${m}\\)$`),De=new RegExp(`^rgba\\(${N},${N},${N},${I}\\)$`),Ye=new RegExp(`^rgba\\(${m},${m},${m},${I}\\)$`),Pe=new RegExp(`^hsl\\(${I},${m},${m}\\)$`),ze=new RegExp(`^hsla\\(${I},${m},${m},${I}\\)$`),oe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};te(O,S,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:se,formatHex:se,formatHex8:Be,formatHsl:Fe,formatRgb:ue,toString:ue});function se(){return this.rgb().formatHex()}function Be(){return this.rgb().formatHex8()}function Fe(){return ve(this).formatHsl()}function ue(){return this.rgb().formatRgb()}function S(e){var n,r;return e=(e+"").trim().toLowerCase(),(n=Oe.exec(e))?(r=n[1].length,n=parseInt(n[1],16),r===6?le(n):r===3?new g(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?j(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?j(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=je.exec(e))?new g(n[1],n[2],n[3],1):(n=Ce.exec(e))?new g(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=De.exec(e))?j(n[1],n[2],n[3],n[4]):(n=Ye.exec(e))?j(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=Pe.exec(e))?xe(n[1],n[2]/100,n[3]/100,1):(n=ze.exec(e))?xe(n[1],n[2]/100,n[3]/100,n[4]):oe.hasOwnProperty(e)?le(oe[e]):e==="transparent"?new g(NaN,NaN,NaN,0):null}function le(e){return new g(e>>16&255,e>>8&255,e&255,1)}function j(e,n,r,t){return t<=0&&(e=n=r=NaN),new g(e,n,r,t)}function Ve(e){return e instanceof O||(e=S(e)),e?(e=e.rgb(),new g(e.r,e.g,e.b,e.opacity)):new g}function z(e,n,r,t){return arguments.length===1?Ve(e):new g(e,n,r,t??1)}function g(e,n,r,t){this.r=+e,this.g=+n,this.b=+r,this.opacity=+t}te(g,z,be(O,{brighter(e){return e=e==null?P:Math.pow(P,e),new g(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?X:Math.pow(X,e),new g(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new g($(this.r),$(this.g),$(this.b),B(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ce,formatHex:ce,formatHex8:Le,formatRgb:he,toString:he}));function ce(){return`#${v(this.r)}${v(this.g)}${v(this.b)}`}function Le(){return`#${v(this.r)}${v(this.g)}${v(this.b)}${v((isNaN(this.opacity)?1:this.opacity)*255)}`}function he(){const e=B(this.opacity);return`${e===1?"rgb(":"rgba("}${$(this.r)}, ${$(this.g)}, ${$(this.b)}${e===1?")":`, ${e})`}`}function B(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function $(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function v(e){return e=$(e),(e<16?"0":"")+e.toString(16)}function xe(e,n,r,t){return t<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new w(e,n,r,t)}function ve(e){if(e instanceof w)return new w(e.h,e.s,e.l,e.opacity);if(e instanceof O||(e=S(e)),!e)return new w;if(e instanceof w)return e;e=e.rgb();var n=e.r/255,r=e.g/255,t=e.b/255,i=Math.min(n,r,t),a=Math.max(n,r,t),f=NaN,o=a-i,l=(a+i)/2;return o?(n===a?f=(r-t)/o+(r<t)*6:r===a?f=(t-n)/o+2:f=(n-r)/o+4,o/=l<.5?a+i:2-a-i,f*=60):o=l>0&&l<1?0:f,new w(f,o,l,e.opacity)}function Qe(e,n,r,t){return arguments.length===1?ve(e):new w(e,n,r,t??1)}function w(e,n,r,t){this.h=+e,this.s=+n,this.l=+r,this.opacity=+t}te(w,Qe,be(O,{brighter(e){return e=e==null?P:Math.pow(P,e),new w(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?X:Math.pow(X,e),new w(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,t=r+(r<.5?r:1-r)*n,i=2*r-t;return new g(Z(e>=240?e-240:e+120,i,t),Z(e,i,t),Z(e<120?e+240:e-120,i,t),this.opacity)},clamp(){return new w(ge(this.h),C(this.s),C(this.l),B(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=B(this.opacity);return`${e===1?"hsl(":"hsla("}${ge(this.h)}, ${C(this.s)*100}%, ${C(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ge(e){return e=(e||0)%360,e<0?e+360:e}function C(e){return Math.max(0,Math.min(1,e||0))}function Z(e,n,r){return(e<60?n+(r-n)*e/60:e<180?r:e<240?n+(r-n)*(240-e)/60:n)*255}function $e(e,n,r,t,i){var a=e*e,f=a*e;return((1-3*e+3*a-f)*n+(4-6*a+3*f)*r+(1+3*e+3*a-3*f)*t+f*i)/6}function Ge(e){var n=e.length-1;return function(r){var t=r<=0?r=0:r>=1?(r=1,n-1):Math.floor(r*n),i=e[t],a=e[t+1],f=t>0?e[t-1]:2*i-a,o=t<n-1?e[t+2]:2*a-i;return $e((r-t/n)*n,f,i,a,o)}}function Ke(e){var n=e.length;return function(r){var t=Math.floor(((r%=1)<0?++r:r)*n),i=e[(t+n-1)%n],a=e[t%n],f=e[(t+1)%n],o=e[(t+2)%n];return $e((r-t/n)*n,i,a,f,o)}}const L=e=>()=>e;function Me(e,n){return function(r){return e+r*n}}function We(e,n,r){return e=Math.pow(e,r),n=Math.pow(n,r)-e,r=1/r,function(t){return Math.pow(e+t*n,r)}}function mn(e,n){var r=n-e;return r?Me(e,r>180||r<-180?r-360*Math.round(r/360):r):L(isNaN(e)?n:e)}function Ze(e){return(e=+e)==1?Ne:function(n,r){return r-n?We(n,r,e):L(isNaN(n)?r:n)}}function Ne(e,n){var r=n-e;return r?Me(e,r):L(isNaN(e)?n:e)}const de=(function e(n){var r=Ze(n);function t(i,a){var f=r((i=z(i)).r,(a=z(a)).r),o=r(i.g,a.g),l=r(i.b,a.b),s=Ne(i.opacity,a.opacity);return function(u){return i.r=f(u),i.g=o(u),i.b=l(u),i.opacity=s(u),i+""}}return t.gamma=e,t})(1);function ke(e){return function(n){var r=n.length,t=new Array(r),i=new Array(r),a=new Array(r),f,o;for(f=0;f<r;++f)o=z(n[f]),t[f]=o.r||0,i[f]=o.g||0,a[f]=o.b||0;return t=e(t),i=e(i),a=e(a),o.opacity=1,function(l){return o.r=t(l),o.g=i(l),o.b=a(l),o+""}}}var yn=ke(Ge),bn=ke(Ke);function _e(e,n){n||(n=[]);var r=e?Math.min(n.length,e.length):0,t=n.slice(),i;return function(a){for(i=0;i<r;++i)t[i]=e[i]*(1-a)+n[i]*a;return t}}function Re(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vn(e,n){return(Re(n)?_e:qe)(e,n)}function qe(e,n){var r=n?n.length:0,t=e?Math.min(r,e.length):0,i=new Array(t),a=new Array(r),f;for(f=0;f<t;++f)i[f]=He(e[f],n[f]);for(;f<r;++f)a[f]=n[f];return function(o){for(f=0;f<t;++f)a[f]=i[f](o);return a}}function Je(e,n){var r=new Date;return e=+e,n=+n,function(t){return r.setTime(e*(1-t)+n*t),r}}function y(e,n){return e=+e,n=+n,function(r){return e*(1-r)+n*r}}function Ue(e,n){var r={},t={},i;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(i in n)i in e?r[i]=He(e[i],n[i]):t[i]=n[i];return function(a){for(i in r)t[i]=r[i](a);return t}}var U=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,J=new RegExp(U.source,"g");function en(e){return function(){return e}}function nn(e){return function(n){return e(n)+""}}function rn(e,n){var r=U.lastIndex=J.lastIndex=0,t,i,a,f=-1,o=[],l=[];for(e=e+"",n=n+"";(t=U.exec(e))&&(i=J.exec(n));)(a=i.index)>r&&(a=n.slice(r,a),o[f]?o[f]+=a:o[++f]=a),(t=t[0])===(i=i[0])?o[f]?o[f]+=i:o[++f]=i:(o[++f]=null,l.push({i:f,x:y(t,i)})),r=J.lastIndex;return r<n.length&&(a=n.slice(r),o[f]?o[f]+=a:o[++f]=a),o.length<2?l[0]?nn(l[0].x):en(n):(n=l.length,function(s){for(var u=0,c;u<n;++u)o[(c=l[u]).i]=c.x(s);return o.join("")})}function He(e,n){var r=typeof n,t;return n==null||r==="boolean"?L(n):(r==="number"?y:r==="string"?(t=S(n))?(n=t,de):rn:n instanceof S?de:n instanceof Date?Je:Re(n)?_e:Array.isArray(n)?qe:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?Ue:y)(e,n)}var pe=180/Math.PI,ee={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ee(e,n,r,t,i,a){var f,o,l;return(f=Math.sqrt(e*e+n*n))&&(e/=f,n/=f),(l=e*r+n*t)&&(r-=e*l,t-=n*l),(o=Math.sqrt(r*r+t*t))&&(r/=o,t/=o,l/=o),e*t<n*r&&(e=-e,n=-n,l=-l,f=-f),{translateX:i,translateY:a,rotate:Math.atan2(n,e)*pe,skewX:Math.atan(l)*pe,scaleX:f,scaleY:o}}var D;function tn(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?ee:Ee(n.a,n.b,n.c,n.d,n.e,n.f)}function fn(e){return e==null||(D||(D=document.createElementNS("http://www.w3.org/2000/svg","g")),D.setAttribute("transform",e),!(e=D.transform.baseVal.consolidate()))?ee:(e=e.matrix,Ee(e.a,e.b,e.c,e.d,e.e,e.f))}function Ae(e,n,r,t){function i(s){return s.length?s.pop()+" ":""}function a(s,u,c,h,x,p){if(s!==c||u!==h){var d=x.push("translate(",null,n,null,r);p.push({i:d-4,x:y(s,c)},{i:d-2,x:y(u,h)})}else(c||h)&&x.push("translate("+c+n+h+r)}function f(s,u,c,h){s!==u?(s-u>180?u+=360:u-s>180&&(s+=360),h.push({i:c.push(i(c)+"rotate(",null,t)-2,x:y(s,u)})):u&&c.push(i(c)+"rotate("+u+t)}function o(s,u,c,h){s!==u?h.push({i:c.push(i(c)+"skewX(",null,t)-2,x:y(s,u)}):u&&c.push(i(c)+"skewX("+u+t)}function l(s,u,c,h,x,p){if(s!==c||u!==h){var d=x.push(i(x)+"scale(",null,",",null,")");p.push({i:d-4,x:y(s,c)},{i:d-2,x:y(u,h)})}else(c!==1||h!==1)&&x.push(i(x)+"scale("+c+","+h+")")}return function(s,u){var c=[],h=[];return s=e(s),u=e(u),a(s.translateX,s.translateY,u.translateX,u.translateY,c,h),f(s.rotate,u.rotate,c,h),o(s.skewX,u.skewX,c,h),l(s.scaleX,s.scaleY,u.scaleX,u.scaleY,c,h),s=u=null,function(x){for(var p=-1,d=h.length,b;++p<d;)c[(b=h[p]).i]=b.x(x);return c.join("")}}}var $n=Ae(tn,"px, ","px)","deg)"),Mn=Ae(fn,", ",")",")"),an=1e-12;function we(e){return((e=Math.exp(e))+1/e)/2}function on(e){return((e=Math.exp(e))-1/e)/2}function sn(e){return((e=Math.exp(2*e))-1)/(e+1)}const Nn=(function e(n,r,t){function i(a,f){var o=a[0],l=a[1],s=a[2],u=f[0],c=f[1],h=f[2],x=u-o,p=c-l,d=x*x+p*p,b,_;if(d<an)_=Math.log(h/s)/n,b=function(q){return[o+q*x,l+q*p,s*Math.exp(n*q*_)]};else{var G=Math.sqrt(d),K=(h*h-s*s+t*d)/(2*s*r*G),W=(h*h-s*s-t*d)/(2*h*r*G),R=Math.log(Math.sqrt(K*K+1)-K),Te=Math.log(Math.sqrt(W*W+1)-W);_=(Te-R)/n,b=function(q){var ie=q*_,fe=we(R),ae=s/(r*G)*(fe*sn(n*ie+R)-on(R));return[o+ae*x,l+ae*p,s*fe/we(n*ie+R)]}}return b.duration=_*1e3*n/Math.SQRT2,b}return i.rho=function(a){var f=Math.max(.001,+a),o=f*f,l=o*o;return e(f,o,l)},i})(Math.SQRT2,2,4);var un={value:()=>{}};function ln(){for(var e=0,n=arguments.length,r={},t;e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Y(r)}function Y(e){this._=e}function cn(e,n){return e.trim().split(/^|\s+/).map(function(r){var t="",i=r.indexOf(".");if(i>=0&&(t=r.slice(i+1),r=r.slice(0,i)),r&&!n.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:t}})}Y.prototype=ln.prototype={constructor:Y,on:function(e,n){var r=this._,t=cn(e+"",r),i,a=-1,f=t.length;if(arguments.length<2){for(;++a<f;)if((i=(e=t[a]).type)&&(i=hn(r[i],e.name)))return i;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++a<f;)if(i=(e=t[a]).type)r[i]=me(r[i],e.name,n);else if(n==null)for(i in r)r[i]=me(r[i],e.name,null);return this},copy:function(){var e={},n=this._;for(var r in n)e[r]=n[r].slice();return new Y(e)},call:function(e,n){if((i=arguments.length-2)>0)for(var r=new Array(i),t=0,i,a;t<i;++t)r[t]=arguments[t+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],t=0,i=a.length;t<i;++t)a[t].value.apply(n,r)},apply:function(e,n,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var t=this._[e],i=0,a=t.length;i<a;++i)t[i].value.apply(n,r)}};function hn(e,n){for(var r=0,t=e.length,i;r<t;++r)if((i=e[r]).name===n)return i.value}function me(e,n,r){for(var t=0,i=e.length;t<i;++t)if(e[t].name===n){e[t]=un,e=e.slice(0,t).concat(e.slice(t+1));break}return r!=null&&e.push({name:n,value:r}),e}var k=0,E=0,H=0,Xe=1e3,F,A,V=0,M=0,Q=0,T=typeof performance=="object"&&performance.now?performance:Date,Ie=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Se(){return M||(Ie(xn),M=T.now()+Q)}function xn(){M=0}function ne(){this._call=this._time=this._next=null}ne.prototype=gn.prototype={constructor:ne,restart:function(e,n,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?Se():+r)+(n==null?0:+n),!this._next&&A!==this&&(A?A._next=this:F=this,A=this),this._call=e,this._time=r,re()},stop:function(){this._call&&(this._call=null,this._time=1/0,re())}};function gn(e,n,r){var t=new ne;return t.restart(e,n,r),t}function dn(){Se(),++k;for(var e=F,n;e;)(n=M-e._time)>=0&&e._call.call(void 0,n),e=e._next;--k}function ye(){M=(V=T.now())+Q,k=E=0;try{dn()}finally{k=0,wn(),M=0}}function pn(){var e=T.now(),n=e-V;n>Xe&&(Q-=n,V=e)}function wn(){for(var e,n=F,r,t=1/0;n;)n._call?(t>n._time&&(t=n._time),e=n,n=n._next):(r=n._next,n._next=null,n=e?e._next=r:F=r);A=e,re(t)}function re(e){if(!k){E&&(E=clearTimeout(E));var n=e-M;n>24?(e<1/0&&(E=setTimeout(ye,e-T.now()-Q)),H&&(H=clearInterval(H))):(H||(V=T.now(),H=setInterval(pn,Xe)),k=1,Ie(ye))}}function kn(e){return e*e*e}function _n(e){return--e*e*e+1}function Rn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}export{yn as A,bn as B,O as C,z as D,_n as E,kn as F,g as R,ne as T,de as a,rn as b,S as c,ln as d,Mn as e,$n as f,Rn as g,Nn as h,y as i,He as j,te as k,be as l,X as m,Se as n,P as o,mn as p,Qe as q,Ve as r,Ne as s,gn as t,vn as u,Ge as v,Ke as w,Je as x,_e as y,Ue as z};
@@ -0,0 +1 @@
1
+ import{a as o,j as s,O as n}from"./index-CeYTjZBm.js";const r=()=>{const e=o.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(n,{}),e[0]=t):t=e[0],t};export{r as component};
@@ -0,0 +1 @@
1
+ import{bG as Ke,bH as Ce,bI as Ue,bJ as Ge,bK as Me,u as We,bL as Ye,bM as Ze,r as b,bN as Je,bO as Xe,bP as et,bQ as tt,bR as Re,bS as st,bT as rt,a as _e,j as t,H as Qe,bU as at,bV as nt,B as we,bD as lt,a3 as it,$ as ot,Y as ct,Z as ut,_ as Oe,bC as Te,bW as mt,bX as dt,bY as ht,bZ as ft,b_ as pt,g as bt,h as xt,a4 as _t,i as yt,l as gt,m as wt,k as St,n as vt,b6 as jt,t as Ct,x as Tt,y as Nt,s as kt,v as De,I as Le,ab as Se,q as qe,d as Rt,bB as Ot,b7 as Dt,bA as zt,T as $t,z as ve,E as je,F as At}from"./index-CeYTjZBm.js";import{u as Et,a as It,b as Pt,c as Mt,E as ze,f as $e,d as be,e as Qt,g as Lt,h as qt,i as Ft}from"./format-D6Wtr7C_.js";import{E as Bt}from"./ellipsis-vertical-X8Fhf-lM.js";import{c as Ht}from"./fuzzy-search-k3hoA2E3.js";import{D as Vt}from"./footer-ChV5nI8s.js";import{T as Kt}from"./trash-2-BDrajHic.js";import"./fuse-Dw8P0qyA.js";function Ae(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function Ut(e,s,r){const o=e.slice(0);return o[s]=r,o}var Gt=class extends Ke{#r;#e;#a;#n;#t;#s;#l;#i;#o;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#a=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#h(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#a=e,this.#n=s,Ce.batch(()=>{const r=this.#t,o=this.#d(this.#a);o.forEach(c=>c.observer.setOptions(c.defaultedQueryOptions));const n=o.map(c=>c.observer),i=n.map(c=>c.getCurrentResult()),l=r.length!==n.length,u=n.some((c,y)=>c!==r[y]),m=l||u,x=m?!0:i.some((c,y)=>{const S=this.#e[y];return!S||!Ue(c,S)});!m&&!x||(m&&(this.#c=o,this.#t=n),this.#e=i,this.hasListeners()&&(m&&(Ae(r,n).forEach(c=>{c.destroy()}),Ae(n,r).forEach(c=>{c.subscribe(y=>{this.#h(c,y)})})),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#d(e),o=r.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),n=r.map(i=>i.defaultedQueryOptions.queryHash);return[o,i=>this.#m(i??o,s,n),()=>this.#u(o,r)]}#u(e,s){return s.map((r,o)=>{const n=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?n:r.observer.trackResult(n,i=>{s.forEach(l=>{l.observer.trackProp(i)})})})}#m(e,s,r){if(s){const o=this.#o,n=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((i,l)=>i!==o[l]));return(!this.#s||this.#e!==this.#i||n||s!==this.#l)&&(this.#l=s,this.#i=this.#e,r!==void 0&&(this.#o=r),this.#s=Ge(this.#s,s(e))),this.#s}return e}#d(e){const s=new Map;this.#t.forEach(o=>{const n=o.options.queryHash;if(!n)return;const i=s.get(n);i?i.push(o):s.set(n,[o])});const r=[];return e.forEach(o=>{const n=this.#r.defaultQueryOptions(o),l=s.get(n.queryHash)?.shift()??new Me(this.#r,n);r.push({defaultedQueryOptions:n,observer:l})}),r}#h(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Ut(this.#e,r,s),this.#f())}#f(){if(this.hasListeners()){const e=this.#s,s=this.#u(this.#e,this.#c),r=this.#m(s,this.#n?.combine);e!==r&&Ce.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function Wt({queries:e,...s},r){const o=We(),n=Ye(),i=Ze(),l=b.useMemo(()=>e.map(g=>{const a=o.defaultQueryOptions(g);return a._optimisticResults=n?"isRestoring":"optimistic",a}),[e,o,n]);l.forEach(g=>{Je(g);const a=o.getQueryCache().get(g.queryHash);Xe(g,i,a)}),et(i);const[u]=b.useState(()=>new Gt(o,l,s)),[m,x,c]=u.getOptimisticResult(l,s.combine),y=!n&&s.subscribed!==!1;b.useSyncExternalStore(b.useCallback(g=>y?u.subscribe(Ce.batchCalls(g)):tt,[u,y]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),b.useEffect(()=>{u.setQueries(l,s)},[l,s,u]);const w=m.some((g,a)=>Re(l[a],g))?m.flatMap((g,a)=>{const h=l[a];if(h&&Re(h,g)){const _=new Me(o,h);return st(h,_,i)}return[]}):[];if(w.length>0)throw Promise.all(w);const N=m.find((g,a)=>{const h=l[a];return h&&rt({result:g,errorResetBoundary:i,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(N?.error)throw N.error;return x(c())}function Fe(e){return e==null?"—":e<60?`${e.toFixed(0)}s`:e<3600?`${Math.floor(e/60)}m ${Math.floor(e%60)}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Yt(e){return e.trim().replace(/\s+/g," ")}function Zt(e){try{return it(e,{language:"postgresql",indentStyle:"tabularRight"})}catch{return e}}function Jt(e){return[["PID",String(e.pid)],["State",e.state],["Duration",Fe(e.duration)],["User",e.usename??"—"],["Wait",e.wait_event?`${e.wait_event_type??""}:${e.wait_event}`:"—"],["Started",e.query_start]]}function Xt(e,s){return e==null&&s==null?0:e==null?1:s==null?-1:typeof e=="number"&&typeof s=="number"?e-s:String(e).localeCompare(String(s))}function es(e){const s=_e.c(7),{row:r,onOpen:o}=e;let n;s[0]!==r.query?(n=Yt(r.query),s[0]=r.query,s[1]=n):n=s[1];const i=n;let l;s[2]!==i?(l=t.jsx("span",{className:"absolute inset-0",children:t.jsx(Qe,{defaultValue:i,currentValue:i,mode:"sql",readOnly:!0,lineNumbers:!1,foldGutter:!1})}),s[2]=i,s[3]=l):l=s[3];let u;return s[4]!==o||s[5]!==l?(u=t.jsx("button",{type:"button",onClick:o,title:"Click to view full query",className:"relative block h-5 w-full text-left cursor-pointer [&_*]:pointer-events-none [&_.cm-editor]:!bg-transparent [&_.cm-editor]:!text-sm [&_.cm-scroller]:!overflow-hidden [&_.cm-scroller]:!py-0 [&_.cm-content]:!pr-0 [&_.cm-scroller]:[mask-image:linear-gradient(to_right,black_calc(100%_-_1.25rem),transparent)] [&_.cm-scroller]:[-webkit-mask-image:linear-gradient(to_right,black_calc(100%_-_1.25rem),transparent)]",children:l}),s[4]=o,s[5]=l,s[6]=u):u=s[6],u}function ts(){const e=_e.c(54);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={column:"duration",direction:"desc"},e[0]=s):s=e[0];const[r,o]=b.useState(s),[n,i]=b.useState(null),[l,u]=b.useState(null),{data:m,isLoading:x}=Et(5e3),c=It(),y=Pt();let S;e:{let p;if(e[1]!==m||e[2]!==r){const Q=m??[];if(!r){S=Q;break e}const F=r.column,J=r.direction==="asc"?1:-1;let B;e[5]!==F||e[6]!==J?(B=(te,se)=>Xt(te[F],se[F])*J,e[5]=F,e[6]=J,e[7]=B):B=e[7],p=[...Q].sort(B),e[1]=m,e[2]=r,e[3]=p,e[4]=S}else p=e[3],S=e[4];S=p}const w=S;let N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=p=>{o(Q=>Q?.column!==p?{column:p,direction:"desc"}:Q.direction==="desc"?{column:p,direction:"asc"}:null)},e[8]=N):N=e[8];const g=N;let a,h,_,j,C;e[9]===Symbol.for("react.memo_cache_sentinel")?(a={id:"duration",header:"Duration",sortable:!0,reverseIcon:!0,width:"w-[100px]",className:"text-right tabular-nums",cell:os},h={id:"pid",header:"PID",sortable:!0,reverseIcon:!0,width:"w-[80px]",className:"text-right tabular-nums",cell:is},_={id:"usename",header:"User",sortable:!0,width:"w-[120px]",cell:ls},j={id:"wait_event",header:"Wait",sortable:!0,width:"w-[160px]",cell:ns},C={id:"application_name",header:"App",sortable:!0,width:"w-[140px]",cell:as},e[9]=a,e[10]=h,e[11]=_,e[12]=j,e[13]=C):(a=e[9],h=e[10],_=e[11],j=e[12],C=e[13]);let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v={id:"query",header:"Query",grow:!0,cell:p=>t.jsx(es,{row:p,onOpen:()=>i(p)})},e[14]=v):v=e[14];let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=[a,h,_,j,C,v,{id:"actions",header:"",minSize:0,maxSize:40,className:"px-1",cell:p=>t.jsx("div",{className:"flex justify-end",children:t.jsxs(ot,{children:[t.jsx(ct,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Query actions",className:"size-7 flex items-center justify-center rounded hover:bg-bg-tertiary text-text-secondary",children:t.jsx(Bt,{className:"size-4"})})}),t.jsxs(ut,{align:"end",children:[t.jsx(Oe,{className:"justify-start!",variant:"destructive",onSelect:()=>u({kind:"cancel",pid:p.pid}),children:"Cancel"}),t.jsx(Oe,{className:"justify-start!",variant:"destructive",onSelect:()=>u({kind:"terminate",pid:p.pid}),children:"Terminate"})]})]})})}],e[15]=f):f=e[15];const k=f;let R;e[16]!==c||e[17]!==l||e[18]!==y?(R=()=>{l&&(l.kind==="cancel"?c.mutate(l.pid):y.mutate(l.pid),u(null))},e[16]=c,e[17]=l,e[18]=y,e[19]=R):R=e[19];const X=R;let H;e[20]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"No active queries."}),e[20]=H):H=e[20];let O;e[21]!==x||e[22]!==r||e[23]!==w?(O=t.jsx("div",{className:"flex-1 overflow-auto pr-1.5",children:t.jsx(Te,{data:w,columns:k,rowKey:rs,loading:x,resizable:!0,tableId:"database-running-queries",sort:r,onSortToggle:g,onRowClick:i,emptyState:H})}),e[21]=x,e[22]=r,e[23]=w,e[24]=O):O=e[24];const V=!!n;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=p=>!p&&i(null),e[25]=K):K=e[25];let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsxs(mt,{children:[t.jsx(dt,{children:"Query info"}),t.jsx(ht,{children:"Active PostgreSQL backend — details and full statement."})]}),e[26]=U):U=e[26];let E;e[27]!==n?(E=n&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Jt(n).map(ss)}),t.jsx("div",{className:"max-h-[50vh] overflow-auto rounded-md border border-border-primary [&_.cm-editor]:h-auto!",children:t.jsx(Qe,{currentValue:Zt(n.query),mode:"sql",readOnly:!0})}),t.jsxs(at,{children:[t.jsx(nt,{asChild:!0,children:t.jsx(we,{variant:"secondary",className:"sm:mr-auto",children:"Close"})}),t.jsx(we,{variant:"primary",danger:!0,onClick:()=>{u({kind:"cancel",pid:n.pid}),i(null)},children:"Cancel query"}),t.jsx(we,{variant:"primary",danger:!0,onClick:()=>{u({kind:"terminate",pid:n.pid}),i(null)},children:"Terminate query"})]})]}),e[27]=n,e[28]=E):E=e[28];let D;e[29]!==E?(D=t.jsxs(ft,{className:"max-w-[60rem]!",children:[U,E]}),e[29]=E,e[30]=D):D=e[30];let I;e[31]!==V||e[32]!==D?(I=t.jsx(pt,{open:V,onOpenChange:K,children:D}),e[31]=V,e[32]=D,e[33]=I):I=e[33];const L=!!l;let G;e[34]===Symbol.for("react.memo_cache_sentinel")?(G=p=>!p&&u(null),e[34]=G):G=e[34];const W=l?.kind==="cancel"?"Cancel query?":"Terminate backend?";let z;e[35]!==W?(z=t.jsx(bt,{children:t.jsx(xt,{children:W})}),e[35]=W,e[36]=z):z=e[36];const Y=l?.kind==="cancel"?`pg_cancel_backend(${l?.pid}). Asks the backend to stop the running statement.`:`pg_terminate_backend(${l?.pid}). Kills the entire connection — clients will see "terminating connection".`;let P;e[37]!==Y?(P=t.jsx(_t,{children:Y}),e[37]=Y,e[38]=P):P=e[38];let q;e[39]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx(yt,{children:"Dismiss"}),e[39]=q):q=e[39];const M=l?.kind==="cancel"?"Cancel query":"Terminate";let $;e[40]!==X||e[41]!==M?($=t.jsxs(gt,{children:[q,t.jsx(wt,{variant:"primary",danger:!0,onClick:X,children:M})]}),e[40]=X,e[41]=M,e[42]=$):$=e[42];let Z;e[43]!==z||e[44]!==P||e[45]!==$?(Z=t.jsxs(St,{children:[z,P,$]}),e[43]=z,e[44]=P,e[45]=$,e[46]=Z):Z=e[46];let T;e[47]!==L||e[48]!==Z?(T=t.jsx(vt,{open:L,onOpenChange:G,children:Z}),e[47]=L,e[48]=Z,e[49]=T):T=e[49];let A;return e[50]!==O||e[51]!==I||e[52]!==T?(A=t.jsxs("div",{className:"h-full flex flex-col",children:[O,I,T]}),e[50]=O,e[51]=I,e[52]=T,e[53]=A):A=e[53],A}function ss(e){const[s,r]=e;return t.jsxs(lt,{variant:"outline",className:"border-transparent gap-1.5 font-normal bg-neutral-100 text-neutral-600",children:[t.jsx("span",{className:"opacity-70",children:s}),t.jsx("span",{className:"font-medium tabular-nums",title:r,children:r})]},s)}function rs(e){return String(e.pid)}function as(e){return t.jsx("span",{className:"font-mono truncate",children:e.application_name?.trim()||"—"})}function ns(e){return e.wait_event?`${e.wait_event_type??""}:${e.wait_event}`:"—"}function ls(e){return e.usename??"—"}function is(e){return t.jsxs("div",{className:"group/pid flex items-center justify-end gap-1",children:[t.jsx("span",{className:"opacity-0 group-hover/pid:opacity-100 transition-opacity [&_svg]:size-3.5 text-text-tertiary hover:text-text-primary",children:t.jsx(jt,{text:String(e.pid),tooltipText:"Copy PID",showToast:!1})}),e.pid]})}function os(e){return t.jsx("span",{className:e.duration>30?"text-text-warning-primary":"text-text-secondary",children:Fe(e.duration)})}function cs(e,s){return e===s?0:e==="public"?-1:s==="public"?1:e.localeCompare(s)}function Ee(e,s){return e==null&&s==null?0:e==null?1:s==null?-1:typeof e=="number"&&typeof s=="number"?e-s:String(e).localeCompare(String(s))}function us(e){return`${e.table_schema}.${e.table_name}`}const xe="__all__";function ms(){const[e,s]=b.useState(""),[r,o]=b.useState({column:"total_size",direction:"desc"}),[n,i]=b.useState(null),{data:l,isLoading:u}=Mt({limit:5e3,allSchemas:!0}),m=b.useMemo(()=>l?Ht(l,{keys:[{name:"table_name",weight:2},{name:"table_schema",weight:1}],minMatchCharLength:2,threshold:.2}):()=>[],[l]),x=e.trim().length>0,c=b.useMemo(()=>{const a=new Set;for(const f of l??[])a.add(f.table_schema);const h=x?m(e):l??[],_=new Map;for(const f of h){const k=_.get(f.table_schema)??[];k.push(f),_.set(f.table_schema,k)}const j=[...a].sort(cs),C=r?.direction==="asc"?1:-1,v=r?.column;for(const f of j){const k=_.get(f);k&&v&&k.sort((R,X)=>Ee(R[v],X[v])*C)}return j.map(f=>({schema:f,rows:_.get(f)??[]}))},[l,x,m,e,r]);b.useEffect(()=>{c.length===0||n!==null||i(xe)},[c,n]);const y=a=>{o(h=>h?.column!==a?{column:a,direction:"desc"}:h.direction==="desc"?{column:a,direction:"asc"}:null)},S=[{id:"table_schema",header:"Schema",sortable:!0,minSize:100,maxSize:200,className:"font-mono",cell:a=>a.table_schema},{id:"table_name",header:"Table",sortable:!0,minSize:200,maxSize:500,cell:a=>t.jsx(qe,{to:"/database/schema/$schema/$table",params:{schema:a.table_schema,table:a.table_name},className:"font-mono text-text-link hover:underline",children:a.table_name})},{id:"num_rows",header:"Rows",sortable:!0,width:"w-[100px]",className:"text-right tabular-nums",reverseIcon:!0,cell:a=>a.num_rows==null||a.num_rows<0?$e(a.num_rows):t.jsx("span",{title:`${Math.round(a.num_rows).toLocaleString()} rows`,children:$e(a.num_rows)})},{id:"total_size",header:"Total size",sortable:!0,width:"w-[120px]",className:"text-right tabular-nums",reverseIcon:!0,cell:a=>a.total},{id:"index_size",header:"Index",headerTooltip:"Index storage size",sortable:!0,width:"w-[100px]",className:"text-right tabular-nums",reverseIcon:!0,cell:a=>a.index},{id:"index_part",header:"Index %",headerTooltip:"Index share of the table's total disk footprint.",sortable:!0,width:"w-[90px]",className:"text-right tabular-nums",reverseIcon:!0,cell:a=>a.index_part==null?ze:`${a.index_part}%`},{id:"toast_size",header:"Toast",headerTooltip:"TOAST = PG out-of-line storage for oversized field values.",sortable:!0,width:"w-[100px]",className:"text-right tabular-nums",reverseIcon:!0,cell:a=>a.toast},{id:"toast_part",header:"Toast %",headerTooltip:"TOAST share of the table's total disk footprint.",sortable:!0,width:"w-[80px]",className:"text-right tabular-nums",reverseIcon:!0,cell:a=>a.toast_part==null?ze:`${a.toast_part}%`},{id:"last_autovacuum",header:"Auto-vacuum",headerTooltip:"Time since last autovacuum.",sortable:!0,width:"w-[120px]",cell:a=>be(a.last_autovacuum)},{id:"last_vacuum",header:"Vacuum",headerTooltip:"Time since last manual VACUUM.",sortable:!0,width:"w-[100px]",cell:a=>be(a.last_vacuum)},{id:"last_autoanalyze",header:"Auto-analyze",headerTooltip:"Time since last autoanalyze.",sortable:!0,width:"w-[120px]",cell:a=>be(a.last_autoanalyze)},{id:"last_analyze",header:"Analyze",headerTooltip:"Time since last manual ANALYZE.",sortable:!0,width:"w-[100px]",cell:a=>be(a.last_analyze)}],w=n??xe,N=b.useMemo(()=>{const a=c.flatMap(j=>j.rows),h=r?.direction==="asc"?1:-1,_=r?.column;return _?[...a].sort((j,C)=>Ee(j[_],C[_])*h):a},[c,r]),g=w===xe?N:c.find(a=>a.schema===w)?.rows??[];return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"px-4 py-3 border-b border-border-secondary",children:t.jsxs("div",{className:"flex",children:[t.jsxs(Ct,{value:w,onValueChange:i,children:[t.jsx(Tt,{className:"w-[150px] shrink-0 rounded-r-none border-r-0",children:t.jsx(Nt,{})}),t.jsxs(kt,{children:[t.jsx(De,{value:xe,children:"All"}),c.map(({schema:a})=>t.jsx(De,{value:a,children:a},a))]})]}),t.jsx(Le,{className:"rounded-l-none",placeholder:"Search tables",value:e,onChange:a=>s(a.target.value)})]})}),t.jsx("div",{className:"flex-1 overflow-auto",children:u?t.jsxs("div",{className:"p-4 space-y-2",children:[t.jsx(Se,{className:"h-6 w-full"}),t.jsx(Se,{className:"h-6 w-full"}),t.jsx(Se,{className:"h-6 w-full"})]}):t.jsx(Te,{data:g,columns:S,rowKey:a=>us(a),resizable:!0,zebra:!0,sort:r,onSortToggle:y,tableId:"database-schema-tables",emptyState:t.jsx("div",{className:"flex items-center justify-center py-8 text-text-secondary",children:"No tables found."})})})]})}function ye(e){return e==null?"—":e<1?`${e.toFixed(2)} ms`:e<1e3?`${e.toFixed(1)} ms`:`${(e/1e3).toFixed(2)} s`}function ds(e){return e==null?"—":e.toLocaleString()}function Ie(e){return`${e.resource_type}:${e.search_param??(e.search_params??[]).join(",")}`}const Pe={resource_type:"resource-type",search_param:"search-param",calls:"calls",mean_time_ms:"mean-time-ms",total_time_ms:"total-time-ms",min_time_ms:"min-time-ms",max_time_ms:"max-time-ms",last_used_at:"last-used"},hs=30;function fs(e){const s=Rt(),r=b.useMemo(()=>Array.from(new Set(e.map(n=>n.resource_type))).sort(),[e]),o=Wt({queries:r.map(n=>({queryKey:["search-parameter-id-lookup",n],queryFn:async()=>{const l=await(await s.rawRequest({method:"GET",url:`/fhir/SearchParameter?base=${n}&_count=500&_elements=id,code`,headers:{"Content-Type":"application/json"}})).response.json(),u={};for(const m of l.entry??[]){const x=m.resource?.id,c=m.resource?.code;x&&c&&(u[c]=x)}return u},staleTime:5*6e4,retry:!1}))});return b.useMemo(()=>{const n={};return r.forEach((i,l)=>{const u=o[l]?.data;if(u)for(const[m,x]of Object.entries(u))n[`${i}:${m}`]=x}),n},[r,o])}function ps(){const e=_e.c(75);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={column:"calls",direction:"desc"},e[0]=s):s=e[0];const[r,o]=b.useState(s),[n,i]=b.useState(1),[l,u]=b.useState(hs),[m,x]=b.useState(""),[c,y]=b.useState("");let S;e[1]===Symbol.for("react.memo_cache_sentinel")?(S=new Set,e[1]=S):S=e[1];const[w,N]=b.useState(S),g=r?Pe[r.column]??"calls":"calls",a=r?.direction??"desc",h=m||void 0;let _;e[2]!==c?(_=c.trim()||void 0,e[2]=c,e[3]=_):_=e[3];const j=(n-1)*l;let C;e[4]!==g||e[5]!==a||e[6]!==l||e[7]!==h||e[8]!==_||e[9]!==j?(C={by:"param",resourceType:h,searchParamLike:_,orderBy:g,orderDir:a,limit:l,offset:j},e[4]=g,e[5]=a,e[6]=l,e[7]=h,e[8]=_,e[9]=j,e[10]=C):C=e[10];const v=C,{data:f,isLoading:k}=Qt(v);let R;e[11]!==v.resourceType||e[12]!==v.searchParamLike?(R={by:"param",resourceType:v.resourceType,searchParamLike:v.searchParamLike},e[11]=v.resourceType,e[12]=v.searchParamLike,e[13]=R):R=e[13];const{data:X}=Lt(R),{data:H}=qt();let O;e[14]===Symbol.for("react.memo_cache_sentinel")?(O={value:"",label:"All resource types"},e[14]=O):O=e[14];let V;e[15]!==H?(V=[O,...(H??[]).map(Ts)],e[15]=H,e[16]=V):V=e[16];const K=V,U=Ft(),E=X?.total??0;let D;e[17]!==f?(D=f??[],e[17]=f,e[18]=D):D=e[18];const I=fs(D);let L;if(e[19]!==f){L=new Map;for(const d of f??[])L.set(Ie(d),d);e[19]=f,e[20]=L}else L=e[20];const G=L;let W;e[21]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(Kt,{className:"size-3.5"}),e[21]=W):W=e[21];let z;e[22]===Symbol.for("react.memo_cache_sentinel")?(z={title:"Drop stats for selected params?",description:"Removes collected stats for the selected (resource, search param) rows. Counters restart from zero.",actionLabel:"Drop"},e[22]=z):z=e[22];let Y;e[23]!==U||e[24]!==G||e[25]!==w?(Y=[{id:"drop",label:"Drop stats",icon:W,variant:"danger",confirm:z,onClick:()=>{const d=[...w].map(ee=>G.get(ee)).filter(Cs).map(js);d.length!==0&&U.mutate(d,{onSuccess:()=>N(new Set)})}}],e[23]=U,e[24]=G,e[25]=w,e[26]=Y):Y=e[26];const P=Y;let q;e[27]!==I?(q=(d,ee)=>{const Ne=d.search_param,ke=Ne?I[`${d.resource_type}:${Ne}`]:void 0;return ke?t.jsx(qe,{to:"/resource/$resourceType/edit/$id",params:{resourceType:"SearchParameter",id:ke},search:{tab:"builder",mode:"json",builderTab:"form"},className:"font-mono text-text-link hover:underline",onClick:vs,children:ee}):t.jsx("span",{className:"font-mono",children:ee})},e[27]=I,e[28]=q):q=e[28];const M=q;let $;e[29]===Symbol.for("react.memo_cache_sentinel")?($=d=>{Pe[d]&&(i(1),o(ee=>ee?.column!==d?{column:d,direction:"desc"}:ee.direction==="desc"?{column:d,direction:"asc"}:null))},e[29]=$):$=e[29];const Z=$;let T;e[30]!==M?(T={id:"resource_type",header:"Resource",sortable:!0,width:"w-[180px]",cell:d=>M(d,d.resource_type)},e[30]=M,e[31]=T):T=e[31];let A;e[32]!==M?(A={id:"search_param",header:"Search param",sortable:!0,width:"w-[200px]",cell:d=>M(d,d.search_param??"—")},e[32]=M,e[33]=A):A=e[33];let p,Q,F,J,B,te,se;e[34]===Symbol.for("react.memo_cache_sentinel")?(p={id:"calls",header:"Calls",sortable:!0,reverseIcon:!0,width:"w-[100px]",className:"text-right tabular-nums",cell:Ss},Q={id:"mean_time_ms",header:"Mean",sortable:!0,reverseIcon:!0,width:"w-[120px]",className:"text-right tabular-nums",cell:ws},F={id:"total_time_ms",header:"Total",sortable:!0,reverseIcon:!0,width:"w-[120px]",className:"text-right tabular-nums",cell:gs},J={id:"min_time_ms",header:"Min",sortable:!0,reverseIcon:!0,width:"w-[100px]",className:"text-right tabular-nums",cell:ys},B={id:"max_time_ms",header:"Max",sortable:!0,reverseIcon:!0,width:"w-[100px]",className:"text-right tabular-nums",cell:_s},te={id:"has_index",header:"Has index",width:"w-[80px]",cell:xs},se={id:"last_used_at",header:"Last used",sortable:!0,width:"w-[180px]",cell:bs},e[34]=p,e[35]=Q,e[36]=F,e[37]=J,e[38]=B,e[39]=te,e[40]=se):(p=e[34],Q=e[35],F=e[36],J=e[37],B=e[38],te=e[39],se=e[40]);let ce;e[41]!==T||e[42]!==A?(ce=[T,A,p,Q,F,J,B,te,se],e[41]=T,e[42]=A,e[43]=ce):ce=e[43];const ge=ce;let ue;e[44]===Symbol.for("react.memo_cache_sentinel")?(ue=d=>{i(1),x(d)},e[44]=ue):ue=e[44];const Be=ue;let me;e[45]===Symbol.for("react.memo_cache_sentinel")?(me=d=>{i(1),y(d)},e[45]=me):me=e[45];const He=me;let de;e[46]===Symbol.for("react.memo_cache_sentinel")?(de=d=>{i(1),u(d)},e[46]=de):de=e[46];const Ve=de;let re;e[47]!==m||e[48]!==K?(re=t.jsx(Ot,{options:K,value:m,onValueChange:Be,placeholder:"All resource types",searchPlaceholder:"Search resource types…",emptyText:"No resource types found.",className:"w-fit shrink-0 rounded-r-none border-r-0"}),e[47]=m,e[48]=K,e[49]=re):re=e[49];let he;e[50]===Symbol.for("react.memo_cache_sentinel")?(he=d=>He(d.target.value),e[50]=he):he=e[50];let ae;e[51]!==c?(ae=t.jsx(Le,{placeholder:"Search param",value:c,onChange:he,className:"flex-1 rounded-l-none"}),e[51]=c,e[52]=ae):ae=e[52];let ne;e[53]!==re||e[54]!==ae?(ne=t.jsx("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border-secondary",children:t.jsxs("div",{className:"flex flex-1",children:[re,ae]})}),e[53]=re,e[54]=ae,e[55]=ne):ne=e[55];let le;e[56]!==f?(le=f??[],e[56]=f,e[57]=le):le=e[57];let fe;e[58]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"No search-param stats match. Run some FHIR searches or adjust filters."}),e[58]=fe):fe=e[58];let ie;e[59]!==ge||e[60]!==k||e[61]!==w||e[62]!==r||e[63]!==le?(ie=t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx(Te,{data:le,columns:ge,rowKey:Ie,loading:k,resizable:!0,tableId:"database-search-params",sort:r,onSortToggle:Z,selectable:!0,selectedIds:w,onSelectionChange:N,emptyState:fe})}),e[59]=ge,e[60]=k,e[61]=w,e[62]=r,e[63]=le,e[64]=ie):ie=e[64];let oe;e[65]!==P||e[66]!==n||e[67]!==l||e[68]!==w.size||e[69]!==E?(oe=t.jsx(Vt,{total:E,currentPage:n,pageSize:l,selectedCount:w.size,bulkActions:P,onPageChange:i,onPageSizeChange:Ve}),e[65]=P,e[66]=n,e[67]=l,e[68]=w.size,e[69]=E,e[70]=oe):oe=e[70];let pe;return e[71]!==ne||e[72]!==ie||e[73]!==oe?(pe=t.jsxs("div",{className:"h-full flex flex-col",children:[ne,ie,oe]}),e[71]=ne,e[72]=ie,e[73]=oe,e[74]=pe):pe=e[74],pe}function bs(e){return e.last_used_at??"—"}function xs(e){return e.has_index?"yes":"no"}function _s(e){return ye(e.max_time_ms)}function ys(e){return ye(e.min_time_ms)}function gs(e){return ye(e.total_time_ms)}function ws(e){return ye(e.mean_time_ms)}function Ss(e){return ds(e.calls)}function vs(e){return e.stopPropagation()}function js(e){return{resourceType:e.resource_type,searchParam:e.search_param}}function Cs(e){return!!e?.search_param}function Ts(e){return{value:e,label:e}}function Ns(){const e=_e.c(10),s=Dt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},e[0]=r):r=e[0];const n=zt(r).tab||"schema";let i;e[1]!==s?(i=S=>{s({to:"/database",search:{tab:S}})},e[1]=s,e[2]=i):i=e[2];const l=i;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("div",{className:"border-b w-full h-10",children:t.jsxs($t,{className:"px-4",children:[t.jsx(ve,{value:"schema",children:"Schema explorer"}),t.jsx(ve,{value:"queries",children:"Running queries"}),t.jsx(ve,{value:"search-params",children:"Search params stats"})]})}),e[3]=u):u=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(je,{value:"schema",className:"overflow-hidden",children:t.jsx(ms,{})}),e[4]=m):m=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(je,{value:"queries",className:"overflow-hidden",children:t.jsx(ts,{})}),e[5]=x):x=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(je,{value:"search-params",className:"overflow-hidden",children:t.jsx(ps,{})}),e[6]=c):c=e[6];let y;return e[7]!==n||e[8]!==l?(y=t.jsxs(At,{value:n,onValueChange:l,children:[u,m,x,c]}),e[7]=n,e[8]=l,e[9]=y):y=e[9],y}const Es=Ns;export{Es as component};
@@ -0,0 +1 @@
1
+ import{a as U,r as F,j as l,bC as X,H as Y,bD as K,B,g as Z,h as G,a4 as J,i as Q,l as W,m as ee,k as ae,n as le,er as te}from"./index-CeYTjZBm.js";import{j as se,k as ne,l as ie,m as re,E as O,f as oe,d as w,t as ce}from"./format-D6Wtr7C_.js";function ue(a){const e=[];return a.num_rows!=null&&a.num_rows>=0&&e.push({label:"Rows",value:oe(a.num_rows)}),a.total&&e.push({label:"Total size",value:a.total}),a.index&&e.push({label:"Index size",value:a.index}),a.index_part!=null&&e.push({label:"Index %",value:`${a.index_part}%`}),a.toast&&e.push({label:"Toast size",value:a.toast}),a.toast_part!=null&&e.push({label:"Toast %",value:`${a.toast_part}%`}),a.last_autovacuum!=null&&e.push({label:"Auto-vacuum",value:w(a.last_autovacuum)}),a.last_vacuum!=null&&e.push({label:"Vacuum",value:w(a.last_vacuum)}),a.last_autoanalyze!=null&&e.push({label:"Auto-analyze",value:w(a.last_autoanalyze)}),a.last_analyze!=null&&e.push({label:"Analyze",value:w(a.last_analyze)}),e}function H(a){const e=U.c(7),{label:s,value:t}=a;let r;e[0]!==s?(r=l.jsx("span",{className:"opacity-70",children:s}),e[0]=s,e[1]=r):r=e[1];let n;e[2]!==t?(n=l.jsx("span",{className:"font-medium tabular-nums",children:t}),e[2]=t,e[3]=n):n=e[3];let c;return e[4]!==r||e[5]!==n?(c=l.jsxs(K,{variant:"outline",className:"border-transparent gap-1.5 font-normal bg-neutral-100 text-neutral-600",children:[r,n]}),e[4]=r,e[5]=n,e[6]=c):c=e[6],c}const de=[{id:"index_name",header:"Name",minSize:200,maxSize:600,cell:a=>l.jsx("span",{className:"font-mono",children:a.index_name})},{id:"index_type",header:"Type",maxSize:120,cell:a=>a.index_type??O},{id:"index_size",header:"Size",maxSize:120,className:"text-right tabular-nums",cell:a=>a.index_size},{id:"unique",header:"Unique",maxSize:100,cell:a=>a.unique==="Y"?"yes":"no"},{id:"number_of_scans",header:"Scans",maxSize:120,className:"text-right tabular-nums",cell:a=>a.number_of_scans?.toLocaleString()??O},{id:"tuples_read",header:"Reads",maxSize:120,className:"text-right tabular-nums",cell:a=>a.tuples_read?.toLocaleString()??O}];function me(a){const e=U.c(53),{schema:s,table:t}=a;let r;e[0]!==s||e[1]!==t?(r={schema:s,table:t},e[0]=s,e[1]=t,e[2]=r):r=e[2];const{data:n,isLoading:c}=se(r),E=ne(),$=ie(),k=re(),[i,j]=F.useState(null),L=i==="vacuum"?"Vacuum table?":i==="analyze"?"Analyze table?":"Reindex table?";let g;e[3]!==i||e[4]!==s||e[5]!==t?(g=()=>{const o=`"${s}"."${t}"`;return i==="reindex"?`REINDEX TABLE ${o}. Rebuilds all indexes — locks the table for writes.`:i==="vacuum"?`VACUUM ${o}. Reclaims dead-tuple space. Runs concurrently with reads/writes.`:`ANALYZE ${o}. Refreshes planner stats.`},e[3]=i,e[4]=s,e[5]=t,e[6]=g):g=e[6];const P=g;let N;e[7]!==$||e[8]!==i||e[9]!==k||e[10]!==s||e[11]!==t||e[12]!==E?(N=()=>{if(!i)return;const o={schema:s,table:t};i==="vacuum"?E.mutate(o):i==="analyze"?$.mutate(o):k.mutate(o),j(null)},e[7]=$,e[8]=i,e[9]=k,e[10]=s,e[11]=t,e[12]=E,e[13]=N):N=e[13];const I=N;let z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=l.jsx(B,{variant:"ghost",size:"small",className:"px-2! hover:bg-bg-tertiary!",onClick:()=>j("vacuum"),children:"Vacuum"}),e[14]=z):z=e[14];let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=l.jsx(B,{variant:"ghost",size:"small",className:"px-2! hover:bg-bg-tertiary!",onClick:()=>j("analyze"),children:"Analyze"}),e[15]=A):A=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=l.jsxs("div",{className:"flex items-center gap-1 bg-bg-secondary flex-none h-10 border-b border-border-secondary px-4",children:[z,A,l.jsx(B,{variant:"ghost",size:"small",className:"px-2! hover:bg-bg-tertiary!",onClick:()=>j("reindex"),children:"Reindex"})]}),e[16]=S):S=e[16];const M=`${s}.${t}`;let u;e[17]!==s?(u=l.jsx("span",{className:"text-text-secondary",children:s}),e[17]=s,e[18]=u):u=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=l.jsx("span",{className:"text-text-tertiary",children:"."}),e[19]=R):R=e[19];let d;e[20]!==t?(d=l.jsx("span",{className:"text-text-primary",children:t}),e[20]=t,e[21]=d):d=e[21];let m;e[22]!==d||e[23]!==M||e[24]!==u?(m=l.jsxs("h1",{className:"text-lg font-semibold font-mono truncate",title:M,children:[u,R,d]}),e[22]=d,e[23]=M,e[24]=u,e[25]=m):m=e[25];let x;e[26]!==n?(x=n&&l.jsxs("div",{className:"mt-3 flex items-center gap-2 flex-wrap",children:[ue(n.table).map(he),(n.table.options??[]).map(be)]}),e[26]=n,e[27]=x):x=e[27];let f;e[28]!==m||e[29]!==x?(f=l.jsxs("div",{className:"flex flex-col px-4 py-3 border-b border-border-secondary",children:[m,x]}),e[28]=m,e[29]=x,e[30]=f):f=e[30];let b;e[31]!==n||e[32]!==c?(b=l.jsx("div",{className:"flex-1 overflow-auto [&_tbody_tr:last-child]:border-b [&_tbody_tr:last-child]:border-border-secondary",children:c?l.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"Loading..."}):n?l.jsxs("div",{className:"py-4",children:[l.jsx("div",{className:"typo-label-xs text-text-tertiary uppercase mb-2 px-4",children:"Indexes"}),n.indexes.length===0?l.jsx("div",{className:"px-4 typo-body-sm text-text-secondary",children:"No indexes."}):l.jsx(X,{data:n.indexes,columns:de,rowKey:fe,resizable:!0,zebra:!1,tableId:"table-indexes",renderExpandedRow:xe})]}):l.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary",children:"Table not found."})}),e[31]=n,e[32]=c,e[33]=b):b=e[33];const V=!!i;let D;e[34]===Symbol.for("react.memo_cache_sentinel")?(D=o=>!o&&j(null),e[34]=D):D=e[34];let h;e[35]!==L?(h=l.jsx(Z,{children:l.jsx(G,{children:L})}),e[35]=L,e[36]=h):h=e[36];const q=P();let p;e[37]!==q?(p=l.jsx(J,{children:q}),e[37]=q,e[38]=p):p=e[38];let C;e[39]===Symbol.for("react.memo_cache_sentinel")?(C=l.jsx(Q,{children:"Cancel"}),e[39]=C):C=e[39];let y;e[40]!==I?(y=l.jsxs(W,{children:[C,l.jsx(ee,{variant:"primary",onClick:I,children:"Run"})]}),e[40]=I,e[41]=y):y=e[41];let _;e[42]!==h||e[43]!==p||e[44]!==y?(_=l.jsxs(ae,{children:[h,p,y]}),e[42]=h,e[43]=p,e[44]=y,e[45]=_):_=e[45];let v;e[46]!==V||e[47]!==_?(v=l.jsx(le,{open:V,onOpenChange:D,children:_}),e[46]=V,e[47]=_,e[48]=v):v=e[48];let T;return e[49]!==f||e[50]!==b||e[51]!==v?(T=l.jsxs("div",{className:"flex flex-col h-full",children:[S,f,b,v]}),e[49]=f,e[50]=b,e[51]=v,e[52]=T):T=e[52],T}function xe(a){return a.index_def?l.jsx("div",{className:"h-64 border-t border-border-secondary",children:l.jsx(Y,{readOnly:!0,mode:"sql",currentValue:ce(a.index_def)})}):l.jsx("div",{className:"px-7 py-3 typo-body-sm text-text-secondary",children:"No definition available."})}function fe(a){return a.index_name}function be(a){return l.jsx(H,{label:"Option",value:a},a)}function he(a){return l.jsx(H,{label:a.label,value:a.value},a.label)}function _e(){const a=U.c(3),{schema:e,table:s}=te.useParams();let t;return a[0]!==e||a[1]!==s?(t=l.jsx(me,{schema:e,table:s}),a[0]=e,a[1]=s,a[2]=t):t=a[2],t}export{_e as component};