@miravo/cli-linux-arm64-musl 0.10.0 → 0.11.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 (140) hide show
  1. package/console-dist/assets/{AnimatePresence-BZCmb1bq.js → AnimatePresence-BSSlw02V.js} +3 -3
  2. package/console-dist/assets/{activity-Cn48I9qe.js → activity-Cy_niK56.js} +1 -1
  3. package/console-dist/assets/{api-kPM52mb-.js → api-B2QJEzbS.js} +1 -1
  4. package/console-dist/assets/api-Vq4lny_H.js +1 -0
  5. package/console-dist/assets/arrow-up-right-CwPw_2U1.js +1 -0
  6. package/console-dist/assets/asset-detail-E-TllNHT.js +1 -0
  7. package/console-dist/assets/asset-detail-actions-jjbvaDES.js +1 -0
  8. package/console-dist/assets/asset-panel-DDziFlFl.js +1 -0
  9. package/console-dist/assets/{auth-screen-backdrop-hcEYy3K4.js → auth-screen-backdrop-CEykEbfF.js} +1 -1
  10. package/console-dist/assets/backup-power-BDMAO2bO.js +1 -0
  11. package/console-dist/assets/badge-Bk1DaL6C.js +1 -0
  12. package/console-dist/assets/boiler-CWAR1Nq2.js +1 -0
  13. package/console-dist/assets/by-path-VBqTBdlG.js +1 -0
  14. package/console-dist/assets/catalog-BlkPPAWE.js +1 -0
  15. package/console-dist/assets/catalog-CQopEu5C.js +1 -0
  16. package/console-dist/assets/{catalog-source-2aT9qob-.js → catalog-source-B4L5N-a1.js} +1 -1
  17. package/console-dist/assets/catalog-template-icons-BOSywIKV.js +1 -0
  18. package/console-dist/assets/check-B-yvIfMj.js +1 -0
  19. package/console-dist/assets/checkbox-DEAkDfFr.js +1 -0
  20. package/console-dist/assets/chevron-down-x70Pto6j.js +1 -0
  21. package/console-dist/assets/chevron-left-XHFooLn1.js +1 -0
  22. package/console-dist/assets/chevron-right-CMSQPSEo.js +1 -0
  23. package/console-dist/assets/chiller-BSx8eUMN.js +1 -0
  24. package/console-dist/assets/{circle-x-CGcRflg7.js → circle-x-_o0nl0Rg.js} +1 -1
  25. package/console-dist/assets/combobox-B8h0-NHs.js +1 -0
  26. package/console-dist/assets/commercial-building-CNvi6IZK.js +1 -0
  27. package/console-dist/assets/compressor-D63w6Ir2.js +1 -0
  28. package/console-dist/assets/console-panel-CMDoBJiO.js +1 -0
  29. package/console-dist/assets/control-CBviLxJB.js +1 -0
  30. package/console-dist/assets/control-jNqzZWa9.js +1 -0
  31. package/console-dist/assets/copy-button-CSUP1VjU.js +1 -0
  32. package/console-dist/assets/{dialog-Di9Bs0FH.js → dialog-B5PqrKVw.js} +1 -1
  33. package/console-dist/assets/district-heating-Cr4CrgCA.js +1 -0
  34. package/console-dist/assets/dom-Cm_OH5jc.js +1 -0
  35. package/console-dist/assets/{download-B9e1wNK4.js → download-i8CTJ7oi.js} +1 -1
  36. package/console-dist/assets/{local-flag-CPAqDO-L.js → dropdown-menu-B_MMNbTy.js} +1 -1
  37. package/console-dist/assets/events-D531_1EZ.js +1 -0
  38. package/console-dist/assets/events-RmbRTKFV.js +1 -0
  39. package/console-dist/assets/events-format-C5HTkIsC.js +1 -0
  40. package/console-dist/assets/export-tab-fZDO4r2u.js +1 -0
  41. package/console-dist/assets/factory-C2OucdpQ.js +1 -0
  42. package/console-dist/assets/factory-CgSIjU5V.js +1 -0
  43. package/console-dist/assets/factory-DLE12zAd.js +1 -0
  44. package/console-dist/assets/floor-page-D0mX5OuA.js +1 -0
  45. package/console-dist/assets/floor-page-E-0txA4z.css +1 -0
  46. package/console-dist/assets/format-Bx7DF-TB.js +1 -0
  47. package/console-dist/assets/genset-BRgqR1AT.js +1 -0
  48. package/console-dist/assets/{get-error-message-eGdenTLv.js → get-error-message-dM0BMfdP.js} +1 -1
  49. package/console-dist/assets/index-CrLa65Ur.css +2 -0
  50. package/console-dist/assets/index-CvuwOe37.js +12 -0
  51. package/console-dist/assets/{integration-api-Bg7D1eQc.js → integration-api-D2tA69Yb.js} +1 -1
  52. package/console-dist/assets/integrations-BLG4PT3c.js +1 -0
  53. package/console-dist/assets/integrations-iAjWxaDS.js +1 -0
  54. package/console-dist/assets/{label-DWyy9MeT.js → label-2sIXTEUK.js} +1 -1
  55. package/console-dist/assets/loader-circle-DjgHgHHl.js +1 -0
  56. package/console-dist/assets/{login-BZKYK0yZ.js → login-DpNKicxy.js} +1 -1
  57. package/console-dist/assets/minus-CaT9UaQx.js +1 -0
  58. package/console-dist/assets/model-schemas-3w38IPdc.js +1 -0
  59. package/console-dist/assets/models-CMN9Eppf.js +1 -0
  60. package/console-dist/assets/models-I_V8J5Y0.js +1 -0
  61. package/console-dist/assets/not-found-C4YVKP97.js +1 -0
  62. package/console-dist/assets/pause-CqW7v5Dc.js +1 -0
  63. package/console-dist/assets/pharma-cleanroom-ClJRwROz.js +1 -0
  64. package/console-dist/assets/play-kg50os4l.js +1 -0
  65. package/console-dist/assets/plus-Cl4Ay5Ry.js +1 -0
  66. package/console-dist/assets/protocol-card-ARSwIjkN.js +1 -0
  67. package/console-dist/assets/proxy-CWZabK8f.js +1 -0
  68. package/console-dist/assets/query-fetch-error-CWLZA2L5.js +1 -0
  69. package/console-dist/assets/{radio-DRkzblxj.js → radio-BxpVYiyS.js} +1 -1
  70. package/console-dist/assets/registry-Dau_GjK6.js +2 -0
  71. package/console-dist/assets/{rocket-807Pf7C1.js → rocket-KZ5oHK1G.js} +1 -1
  72. package/console-dist/assets/rtu-D-1lltcO.js +1 -0
  73. package/console-dist/assets/select-BWlrSYlA.js +1 -0
  74. package/console-dist/assets/{select-display-items-D-L3PesO.js → select-display-items-DN2G8DNG.js} +1 -1
  75. package/console-dist/assets/{server-CS2Tw__K.js → server-BVem_egD.js} +1 -1
  76. package/console-dist/assets/sliders-horizontal-BNKmYQgd.js +1 -0
  77. package/console-dist/assets/smart-factory-cem4tLAv.js +1 -0
  78. package/console-dist/assets/{source-host-miravo-D_AecPVc.js → source-host-miravo-B8eM2IHw.js} +1 -1
  79. package/console-dist/assets/stages-hidkaJPI.js +1 -0
  80. package/console-dist/assets/status-CZFZLqVk.js +1 -0
  81. package/console-dist/assets/tabs-BbQkzBZZ.js +1 -0
  82. package/console-dist/assets/tags-BBz30-eV.js +4 -0
  83. package/console-dist/assets/tags-K96jT8PY.js +1 -0
  84. package/console-dist/assets/tank-THHXGdzg.js +1 -0
  85. package/console-dist/assets/tooltip-B3vOB1Vu.js +1 -0
  86. package/console-dist/assets/{transition-nav-link-cn4KZD6W.js → transition-nav-link-B11-gXld.js} +1 -1
  87. package/console-dist/assets/{trash-2-BJ-1df0F.js → trash-2-BH9HDsZv.js} +1 -1
  88. package/console-dist/assets/{triangle-alert-D1AraFcP.js → triangle-alert-DoAwrRgk.js} +1 -1
  89. package/console-dist/assets/use-engine-command-mutation-CHqjOqfS.js +1 -0
  90. package/console-dist/assets/use-transition-navigate-B-nk4aWh.js +2 -0
  91. package/console-dist/assets/useQuery-M9KTdi7Q.js +1 -0
  92. package/console-dist/assets/validation-BkfmaBBi.js +1 -0
  93. package/console-dist/assets/water-treatment-CfVR0p0L.js +1 -0
  94. package/console-dist/index.html +68 -54
  95. package/miravo +2 -2
  96. package/package.json +1 -1
  97. package/console-dist/assets/api-DybIIqOe.js +0 -1
  98. package/console-dist/assets/asset-detail-tmOrYE8x.js +0 -1
  99. package/console-dist/assets/badge-D4jktT8T.js +0 -1
  100. package/console-dist/assets/catalog-DN-klsod.js +0 -1
  101. package/console-dist/assets/catalog-M-k7Y9Sp.js +0 -1
  102. package/console-dist/assets/catalog-template-icons-C7KJdJJX.js +0 -1
  103. package/console-dist/assets/checkbox-AaJhjtZk.js +0 -1
  104. package/console-dist/assets/chevron-down-CAk5w9Wt.js +0 -1
  105. package/console-dist/assets/chevron-right-BfZjrUWh.js +0 -1
  106. package/console-dist/assets/combobox-BFEY6lgO.js +0 -1
  107. package/console-dist/assets/control-CD9UoTvu.js +0 -1
  108. package/console-dist/assets/control-DHa2-a2v.js +0 -1
  109. package/console-dist/assets/copy-button-DHm7RGJ5.js +0 -1
  110. package/console-dist/assets/events-D19CzgoQ.js +0 -1
  111. package/console-dist/assets/events-DmftG8n5.js +0 -1
  112. package/console-dist/assets/export-tab-ouFgYEU_.js +0 -1
  113. package/console-dist/assets/factory-CT2VYi0n.js +0 -1
  114. package/console-dist/assets/factory-DSrBtcG2.js +0 -1
  115. package/console-dist/assets/format-OUFL_tef.js +0 -1
  116. package/console-dist/assets/index-DuJJSpJp.js +0 -12
  117. package/console-dist/assets/index-iEV9hU2I.css +0 -2
  118. package/console-dist/assets/integrations-DWW9HjH0.js +0 -1
  119. package/console-dist/assets/integrations-DoXNrzD5.js +0 -1
  120. package/console-dist/assets/models-CrDBHBV5.js +0 -1
  121. package/console-dist/assets/models-jBVcY8Xd.js +0 -1
  122. package/console-dist/assets/not-found-BqVny4Md.js +0 -1
  123. package/console-dist/assets/play-TTg_EXSa.js +0 -1
  124. package/console-dist/assets/plus-BbVbvFTe.js +0 -1
  125. package/console-dist/assets/protocol-card-B2SpAJKe.js +0 -1
  126. package/console-dist/assets/query-fetch-error-C2Ec4RQS.js +0 -1
  127. package/console-dist/assets/select-Bg6PPro0.js +0 -1
  128. package/console-dist/assets/tabs-bI9sskHy.js +0 -1
  129. package/console-dist/assets/tags-B7e7VYVW.js +0 -1
  130. package/console-dist/assets/tags-DJJKQRZZ.js +0 -4
  131. package/console-dist/assets/use-engine-command-mutation-DMkQxmt9.js +0 -1
  132. package/console-dist/assets/use-transition-navigate-BiV2QCcA.js +0 -2
  133. package/console-dist/assets/validation-q38DYDwu.js +0 -1
  134. /package/console-dist/assets/{chunk-OE4NN4TA-Q4iNR9l9.js → chunk-OE4NN4TA-DBWZidbW.js} +0 -0
  135. /package/console-dist/assets/{dist-CtuJWBnP.js → dist-xY0pK9Wy.js} +0 -0
  136. /package/console-dist/assets/{integration-targets-BehiqWyT.js → integration-targets-Byvdd3Or.js} +0 -0
  137. /package/console-dist/assets/{runtime-link-ChF8TM68.js → runtime-link-vBANRqcD.js} +0 -0
  138. /package/console-dist/assets/{transition-types-049V0Kr0.js → transition-types-BKZuWApE.js} +0 -0
  139. /package/console-dist/assets/{utils-BO2u-wC_.js → utils-XFKvwlFT.js} +0 -0
  140. /package/console-dist/assets/{vendor-table-Br-cHaxY.js → vendor-table-B0Z9e_sn.js} +0 -0
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,v as a}from"./api-kPM52mb-.js";import{i as o,t as s}from"./query-fetch-error-C2Ec4RQS.js";import{n as c,t as l}from"./badge-D4jktT8T.js";import{t as u}from"./AnimatePresence-BZCmb1bq.js";import{c as d,h as f,s as p}from"./format-OUFL_tef.js";import{n as m,t as h}from"./utils-BO2u-wC_.js";import{t as g}from"./chevron-down-CAk5w9Wt.js";import{t as _}from"./chevron-right-BfZjrUWh.js";import{t as v}from"./copy-button-DHm7RGJ5.js";import{i as y,n as b,r as x,t as S}from"./tabs-bI9sskHy.js";import{c as C,d as w,f as T,l as E,s as ee,t as D,u as O}from"./export-tab-ouFgYEU_.js";import{n as k}from"./get-error-message-eGdenTLv.js";import{a as A}from"./use-engine-command-mutation-DMkQxmt9.js";var j=m(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),M=m(`droplet`,[[`path`,{d:`M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z`,key:`c7niix`}]]),N=m(`factory`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),P=m(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),F=m(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),I=m(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),L=m(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),R=m(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),z=m(`thermometer-sun`,[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 8a4 4 0 0 0-1.645 7.647`,key:`wz5p04`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 14.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0z`,key:`yu0u2z`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}]]),B=m(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),V=e(t(),1),H=n(),U=20,W=14,G=`flex w-3.5 shrink-0 items-center justify-center`;function K({asset:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,H.jsxs)(H.Fragment,{children:[l.map(a=>(0,H.jsx)(q,{member:a,depth:t,area:n,line:r,assetId:e.id,detail:i},a.name)),!a&&u>0&&(0,H.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 border-t border-border/30 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-muted/40 touch-manipulation sm:min-h-0 sm:py-1.5`,style:{paddingLeft:`${t*14+U}px`},onClick:()=>o(!0),children:[(0,H.jsx)(`span`,{className:G,"aria-hidden":!0}),(0,H.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 border-t border-border/30 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-muted/40 touch-manipulation sm:min-h-0 sm:py-1.5`,style:{paddingLeft:`${t*14+U}px`},onClick:()=>c(e=>!e),children:[(0,H.jsx)(`span`,{className:G,"aria-hidden":!0,children:s?(0,H.jsx)(g,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,H.jsx)(_,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,H.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,H.jsx)(q,{member:a,depth:t,area:n,line:r,assetId:e.id,detail:i},a.name))]})]})}function q({member:e,depth:t,area:n,line:r,assetId:i,detail:a}){let o=e.kind===`property`,s=t*14+U+(o?W:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,H.jsx)(v,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:()=>(0,H.jsxs)(`button`,{type:`button`,className:h(`flex w-full cursor-pointer flex-col gap-1 border-t border-border/25 py-2 text-left font-mono text-xs hover:bg-muted/35 touch-manipulation sm:min-h-0 sm:flex-row sm:items-center sm:gap-1.5 sm:py-1.5`,o&&`opacity-65`),style:{paddingLeft:`${s}px`},children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,H.jsx)(`span`,{className:G,"aria-hidden":!0,children:(0,H.jsx)(`span`,{className:h(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,H.jsx)(`span`,{title:e.name,className:h(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:d(e.name)}),o&&(0,H.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] bg-muted/60 px-1 py-px text-[10px] text-muted-foreground`,children:`PROP`})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 pl-0 sm:ml-auto sm:flex-1 sm:justify-end sm:pl-0 sm:pr-1`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,H.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,H.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground`,children:[`[`,e.euRange[0],`–`,e.euRange[1],`]`]})]})]})})}function J({depth:e,label:t,labelTitle:n,tag:r,tagKind:i,subtitle:a,subtitleTitle:o,count:s,expanded:c,onToggle:l,hasChildren:u}){let d=c?g:_,f=i===`area`?`text-primary`:`text-foreground`;return(0,H.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full flex-col gap-1 border-t border-border/35 py-2 pr-2 text-left text-xs transition-colors touch-manipulation first:border-t-0 hover:bg-muted/40 sm:min-h-0 sm:flex-row sm:flex-wrap sm:items-center sm:gap-1.5 sm:gap-y-0 sm:py-1.5`,style:{paddingLeft:`${12+e*14}px`},onClick:l,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 w-full items-center gap-1.5 sm:w-auto sm:flex-1 sm:flex-wrap sm:items-center`,children:[u?(0,H.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,H.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,H.jsx)(`span`,{title:n??void 0,className:h(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,H.jsx)(`span`,{title:o??void 0,className:`hidden min-w-0 max-w-[min(11rem,38vw)] shrink truncate font-mono text-xs text-muted-foreground sm:inline`,children:a}),s!==void 0&&(0,H.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,H.jsx)(`span`,{title:o??void 0,className:`min-w-0 truncate pl-7 font-mono text-xs text-muted-foreground sm:hidden`,children:a})]})}function Y(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function X(e,t,n){let r=[];for(let i of e){let e=Y(i.model),a=t.get(i.model),o=[],s=[];if(a)for(let[e,t]of Object.entries(a.members)){let n={name:e,kind:t.kind,dataType:t.dataType,unit:t.unit,euRange:t.euRange};t.kind===`property`?s.push(n):o.push(n)}for(let t=0;t<i.count;t++){let t=(n.get(i.model)??0)+1;n.set(i.model,t),r.push({id:`${e}-${String(t).padStart(3,`0`)}`,model:i.model,tags:o,properties:s})}}return r}function Z({detail:e}){let[t,n]=(0,V.useState)(new Set),c=(0,V.useRef)(null),l=(0,V.useMemo)(()=>[...new Set(e.models)],[e.models]),u=l.join(`,`),d=o({queryKey:a.catalog.modelSchemasBatch(u),queryFn:async()=>Promise.all(l.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail)))}),m=d.isPending&&!d.data,h=(0,V.useMemo)(()=>{let e=new Map;if(!d.data)return e;for(let[t,n]of d.data.entries())e.set(l[t],n);return e},[d.data,l]),g=(0,V.useMemo)(()=>{let t=new Map,n=new Map;for(let r of e.topology)for(let e of r.lines)n.set(`${r.name}/${e.name}`,X(e.assets,h,t));return n},[e.topology,h]);(0,V.useEffect)(()=>{if(m)return;let t=e.name;if(c.current===t)return;let r=new Set;for(let t of e.topology){r.add(`area:${t.name}`);for(let e of t.lines)r.add(`line:${t.name}/${e.name}`)}outer:for(let t of e.topology)for(let e of t.lines){let n=(g.get(`${t.name}/${e.name}`)??[])[0];if(n){r.add(`inst:${t.name}/${e.name}/${n.id}`);break outer}}n(r),c.current=t},[m,e.name,e.topology,g]);let _=(0,V.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return m?null:d.isError&&!d.data?(0,H.jsx)(s,{message:k(d.error,`Failed to load model schemas.`),onRetry:()=>void d.refetch(),isRetrying:d.isFetching&&!d.isPending}):(0,H.jsx)(`div`,{className:`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 py-2 pl-1 pr-2 touch-manipulation sm:py-2.5 sm:pl-1.5 sm:pr-2.5`,children:e.topology.map(n=>{let r=`area:${n.name}`,i=t.has(r);return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(J,{depth:0,label:f(n.name),labelTitle:n.name,tag:`AREA`,tagKind:`area`,expanded:i,onToggle:()=>_(r),hasChildren:!0}),i&&n.lines.map(r=>{let i=`line:${n.name}/${r.name}`,a=t.has(i),o=g.get(`${n.name}/${r.name}`)??[];return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(J,{depth:1,label:f(r.name),labelTitle:r.name,tag:`LINE`,tagKind:`line`,count:o.length,expanded:a,onToggle:()=>_(i),hasChildren:!0}),a&&o.map(i=>{let a=`inst:${n.name}/${r.name}/${i.id}`,o=t.has(a);return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(J,{depth:2,label:p(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:f(i.model),subtitleTitle:i.model,count:i.tags.length+i.properties.length,expanded:o,onToggle:()=>_(a),hasChildren:i.tags.length+i.properties.length>0}),o&&(0,H.jsx)(K,{asset:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}function Q(e){return o({queryKey:a.catalog.modelSchemasBatch(e.join(`,`)),queryFn:()=>Promise.all(e.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail))),enabled:e.length>0})}function te(e){return e.lines.reduce((e,t)=>e+t.assets.reduce((e,t)=>e+t.count,0),0)}function ne(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function re(e,t){let n=0;for(let r of e.topology)for(let e of r.lines)for(let r of e.assets){let e=t.get(r.model),i=e?ne(e):0;n+=r.count*i}return n}var $=`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`;function ie({templateId:e,onClose:t,live:n,fallbackTitle:u}){let[d,f]=(0,V.useState)(new Set),p=o({queryKey:a.catalog.templateDetail(e??``),queryFn:()=>i(`/catalog/templates/${e}`,r.catalogTemplateDetail),enabled:e!==null}),m=p.data,g=p.isPending&&!m,_=p.isError,v=k(p.error,`Failed to load template.`),A=Q(m?.models??[]),j=(0,V.useMemo)(()=>{if(!m||!A.data)return null;let e=new Map;for(let[t,n]of A.data.entries())e.set(m.models[t],n);return re(m,e)},[m,A.data]);(0,V.useEffect)(()=>{e&&m&&f(new Set(m.topology.map(e=>e.name)))},[e,m]);let M=(0,V.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,H.jsx)(ee,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,H.jsx)(C,{side:`right`,className:h(`flex w-full flex-col gap-4 touch-manipulation`,n&&`data-[side=right]:max-w-3xl`),children:g?null:_&&!m&&n?(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,H.jsx)(O,{className:`gap-1 pb-0 pe-12`,children:(0,H.jsx)(w,{className:`font-heading text-base uppercase tracking-wide`,children:u})}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-4`,children:n})]}):_&&!m?(0,H.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,H.jsx)(s,{message:v,onRetry:()=>void p.refetch(),isRetrying:p.isFetching})}):m?(0,H.jsxs)(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,H.jsxs)(O,{className:`gap-1 pb-0 pe-12`,children:[(0,H.jsx)(w,{className:`font-heading text-base uppercase tracking-wide`,children:m.name}),m.description&&(0,H.jsx)(E,{className:`text-xs leading-relaxed text-foreground/88`,children:m.description})]}),(0,H.jsxs)(S,{defaultValue:n?`live`:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,H.jsxs)(x,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[n?(0,H.jsx)(y,{value:`live`,className:$,children:`Live`}):null,(0,H.jsx)(y,{value:`overview`,className:$,children:`Overview`}),(0,H.jsx)(y,{value:`uns`,className:$,children:`UNS`}),(0,H.jsx)(y,{value:`export`,className:$,children:`Export`})]}),n?(0,H.jsx)(b,{value:`live`,className:`flex min-h-0 flex-1 flex-col`,children:(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pt-1 pb-4`,children:n})}):null,(0,H.jsx)(b,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(l,{variant:`outline`,className:`font-mono text-xs`,children:[m.topology.length,` areas`]}),(0,H.jsxs)(l,{variant:`outline`,className:`font-mono text-xs`,children:[m.assetCount,` assets`]}),(0,H.jsxs)(l,{variant:`outline`,className:`font-mono text-xs`,children:[m.models.length,` models`]}),j!==null&&(0,H.jsxs)(l,{variant:`outline`,className:`font-mono text-xs`,children:[j,` tags`]}),m.settings?.tickIntervalMs&&(0,H.jsxs)(l,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,m.settings.tickIntervalMs,`ms`]}),m.settings?.timeMultiplier&&m.settings.timeMultiplier!==1&&(0,H.jsxs)(l,{variant:`outline`,className:`font-mono text-xs`,children:[m.settings.timeMultiplier,`× speed`]})]}),m.namespace&&(m.namespace.enterprise||m.namespace.site||m.namespace.prefix)&&(0,H.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,H.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,H.jsxs)(`dl`,{className:`mt-1 grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-2`,children:[m.namespace.enterprise&&(0,H.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,H.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,H.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:m.namespace.enterprise})]}),m.namespace.site&&(0,H.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,H.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,H.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:m.namespace.site})]}),m.namespace.prefix&&(0,H.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,H.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,H.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:m.namespace.prefix})]})]})]}),m.topology.map(e=>(0,H.jsx)(ae,{area:e,expanded:d.has(e.name),onToggle:()=>M(e.name)},e.name)),m.settings&&(0,H.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,H.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-heading text-xs font-semibold uppercase tracking-[0.12em] text-warning`,children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),(0,H.jsx)(`span`,{children:`Settings`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,H.jsxs)(`span`,{className:`text-foreground`,children:[m.settings.tickIntervalMs??1e3,`ms`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,H.jsxs)(`span`,{className:`text-foreground`,children:[m.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,H.jsx)(b,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,H.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,H.jsx)(Z,{detail:m})})})})}),(0,H.jsx)(b,{value:`export`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,H.jsx)(D,{kind:`template`,id:m.id,yamlPath:`/catalog/templates/${m.id}/yaml`,yamlFilename:`${m.id}.miravo.yaml`})})})]})]},m.id):(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Template not found`})})})}function ae({area:e,expanded:t,onToggle:n}){let r=te(e);return(0,H.jsxs)(`div`,{className:A,children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 px-2.5 py-2 text-left text-xs font-medium transition-colors hover:bg-muted/30 touch-manipulation sm:min-h-0 sm:py-1.5`,onClick:n,children:[(0,H.jsx)(F,{className:`size-3.5 text-primary`}),(0,H.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:f(e.name)}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,H.jsxs)(l,{variant:`secondary`,className:`text-xs`,children:[r,` assets`]}),(0,H.jsxs)(l,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,H.jsx)(g,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,H.jsx)(u,{initial:!1,children:t&&(0,H.jsx)(c.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,H.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,H.jsx)(oe,{line:e},e.name))})},`content`)})]})}function oe({line:e}){return(0,H.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,H.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,H.jsx)(R,{className:`size-3.5`}),(0,H.jsx)(`span`,{title:e.name,children:f(e.name)}),(0,H.jsx)(I,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.assets.reduce((e,t)=>e+t.count,0),` assets`]})]}),(0,H.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.assets.map(e=>(0,H.jsx)(se,{assignment:e},`${e.model}-${e.count}`))})]})}function se({assignment:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,H.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,H.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:f(e.model)}),(0,H.jsxs)(l,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,H.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-4 gap-y-1 border-t border-border/20 pt-1.5 font-mono text-xs`,children:Object.entries(e.parameters).map(([e,t])=>(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,H.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}function ce({id:e,className:t}){let n=h(`shrink-0 text-primary`,t);switch(e){case`smart-factory`:return(0,H.jsx)(N,{className:n,"aria-hidden":!0});case`water-treatment`:return(0,H.jsx)(M,{className:n,"aria-hidden":!0});case`commercial-building`:return(0,H.jsx)(j,{className:n,"aria-hidden":!0});case`backup-power`:return(0,H.jsx)(B,{className:n,"aria-hidden":!0});case`district-heating`:return(0,H.jsx)(z,{className:n,"aria-hidden":!0});case`pharma-cleanroom`:return(0,H.jsx)(P,{className:n,"aria-hidden":!0});default:return(0,H.jsx)(L,{className:n,"aria-hidden":!0})}}export{I as a,B as i,ie as n,Q as r,ce as t};
@@ -1 +0,0 @@
1
- import{_ as e,ot as t,v as n}from"./vendor-ui-D8j69UH4.js";import{E as r}from"./format-OUFL_tef.js";import{t as i}from"./utils-BO2u-wC_.js";var a=t();function o({className:t,...o}){return(0,a.jsx)(n,{"data-slot":`checkbox`,className:i(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary bg-input/30 aria-invalid:border-destructive/50 aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground data-checked:bg-primary`,t),...o,children:(0,a.jsx)(e,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,a.jsx)(r,{})})})}export{o as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./utils-BO2u-wC_.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]);export{t};
@@ -1 +0,0 @@
1
- import{n as e}from"./utils-BO2u-wC_.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-COnpUsM8.js";import{c as e}from"./vendor-charts-95ykyDlI.js";import{C as t,E as n,S as r,T as i,b as a,g as o,h as s,ot as c,w as l,x as u,y as d}from"./vendor-ui-D8j69UH4.js";import{C as f,D as p,E as m,S as h,T as g}from"./format-OUFL_tef.js";import{t as _}from"./utils-BO2u-wC_.js";import{t as v}from"./chevron-down-CAk5w9Wt.js";var y=c();function b({className:e,size:t=`default`,...n}){return(0,y.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:_(`group/card flex flex-col gap-4 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border bg-card py-4 text-sm text-card-foreground has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-[var(--miravo-radius-stadium-sm)] *:[img:last-child]:rounded-b-[var(--miravo-radius-stadium-sm)]`,e),...n})}function x({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`card-header`,className:_(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-[var(--miravo-radius-stadium-sm)] px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t})}function S({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`card-title`,className:_(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function C({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`card-content`,className:_(`px-4 group-data-[size=sm]/card:px-3`,e),...t})}e();function w({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:_(`group/input-group relative flex h-8 w-full min-w-0 items-center gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border border-input bg-input/30 transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 hover:bg-input/50 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-primary/35 has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-primary/22 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var T=p(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-xs font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function E({className:e,align:t=`inline-start`,...n}){return(0,y.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:_(T({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var D=p(`flex items-center gap-2 text-xs shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[var(--miravo-radius-stadium-sm)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[var(--miravo-radius-stadium-sm)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function O({className:e,type:t=`button`,variant:n=`ghost`,size:r=`xs`,...i}){return(0,y.jsx)(f,{type:t,"data-size":r,variant:n,className:_(D({size:r}),e),...i})}function k({className:e,...t}){return(0,y.jsx)(h,{"data-slot":`input-group-control`,className:_(`min-w-0 flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 hover:bg-transparent disabled:bg-transparent aria-invalid:ring-0 dark:hover:bg-transparent dark:disabled:bg-transparent`,e),...t})}var A=o;function j({className:e,children:t,...r}){return(0,y.jsxs)(n,{"data-slot":`combobox-trigger`,className:_(`[&_svg:not([class*='size-'])]:size-4`,e),...r,children:[t,(0,y.jsx)(v,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function M({className:e,...t}){return(0,y.jsx)(l,{"data-slot":`combobox-clear`,render:(0,y.jsx)(O,{variant:`ghost`,size:`icon-xs`,"aria-label":`Clear selection`}),className:_(e),...t,children:(0,y.jsx)(g,{className:`pointer-events-none`})})}function N({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:a=!1,...o}){return(0,y.jsxs)(w,{className:_(`w-auto`,e),children:[(0,y.jsx)(i,{render:(0,y.jsx)(k,{disabled:n}),...o}),(0,y.jsxs)(E,{align:`inline-end`,children:[r&&(0,y.jsx)(O,{size:`icon-xs`,variant:`ghost`,render:(0,y.jsx)(j,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n,"aria-label":`Toggle options`}),a&&(0,y.jsx)(M,{disabled:n})]}),t]})}function P({className:e,side:t=`bottom`,sideOffset:n=6,align:i=`start`,alignOffset:o=0,anchor:s,...c}){return(0,y.jsx)(r,{children:(0,y.jsx)(u,{side:t,sideOffset:n,align:i,alignOffset:o,anchor:s,className:`isolate z-50`,children:(0,y.jsx)(a,{"data-slot":`combobox-content`,"data-chips":!!s,className:_(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-[var(--miravo-radius-tight)] bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:data-open:duration-0 motion-reduce:data-closed:duration-0`,e),...c})})})}function F({className:e,...n}){return(0,y.jsx)(t,{"data-slot":`combobox-list`,className:_(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,e),...n})}function I({className:e,children:t,...n}){return(0,y.jsxs)(d,{"data-slot":`combobox-item`,className:_(`relative flex w-full cursor-pointer items-center gap-1.5 rounded-[var(--miravo-radius-tight)] py-1 pr-8 pl-1.5 text-xs outline-hidden select-none data-[highlighted]:bg-sidebar-accent data-[highlighted]:text-sidebar-accent-foreground not-data-[variant=destructive]:data-[highlighted]:**:text-sidebar-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,y.jsx)(s,{render:(0,y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,y.jsx)(m,{className:`pointer-events-none`})})]})}export{F as a,x as c,I as i,S as l,P as n,b as o,N as r,C as s,A as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{B as r,ot as i}from"./api-kPM52mb-.js";import{n as a,t as o}from"./badge-D4jktT8T.js";import{t as s}from"./AnimatePresence-BZCmb1bq.js";import{i as c,r as l}from"./dist-CtuJWBnP.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./dialog-Di9Bs0FH.js";import{a as g,n as _,o as ee,r as v,s as y}from"./protocol-card-B2SpAJKe.js";import{C as b,S as x,d as S,l as C}from"./format-OUFL_tef.js";import{n as w,t as T}from"./utils-BO2u-wC_.js";import{n as E}from"./server-CS2Tw__K.js";import{n as D}from"./circle-x-CGcRflg7.js";import{a as te,n as ne,r as re}from"./copy-button-DHm7RGJ5.js";import{a as ie,n as ae,o as oe,r as O,s as k,t as A}from"./validation-q38DYDwu.js";import{i as j,n as M,r as N,t as P}from"./tabs-bI9sskHy.js";import{t as F}from"./play-TTg_EXSa.js";import{t as I}from"./rocket-807Pf7C1.js";import{t as L}from"./triangle-alert-D1AraFcP.js";import{t as R}from"./label-DWyy9MeT.js";import{a as z,t as B}from"./use-engine-command-mutation-DMkQxmt9.js";import{a as V,c as H,i as U,l as W,n as G,o as K,r as q,s as J,t as se}from"./combobox-BFEY6lgO.js";import{c as ce,i as le,n as ue,s as de,t as fe}from"./select-Bg6PPro0.js";var pe=w(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),me=w(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Y=w(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),X=e(t(),1),Z=n();function he(){let{assets:e,models:t}=i(y(e=>({assets:e.assets,models:e.models}))),n=B(),[r,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(``),p=(0,X.useMemo)(()=>d?e.filter(e=>e.id.toLowerCase().includes(d.toLowerCase())):e,[e,d]),m=(0,X.useMemo)(()=>{let n=e.find(e=>e.id===r);return n?t.find(e=>e.name===n.model)?.faultNames??[]:[]},[r,e,t]),h=(0,X.useMemo)(()=>e.filter(e=>e.activeFaults.length>0),[e]),g=h.reduce((e,t)=>e+t.activeFaults.length,0);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(L,{className:`size-3.5 ${g>0?`text-destructive`:`text-muted-foreground`}`}),`Fault Lab`,(0,Z.jsx)(s,{children:g>0&&(0,Z.jsx)(a.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},children:(0,Z.jsxs)(o,{variant:`destructive`,className:`text-[10px]`,children:[g,` active`]})},`fault-count`)})]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(se,{value:r||null,onValueChange:e=>{c(e??``),u(``)},onInputValueChange:f,children:[(0,Z.jsx)(q,{placeholder:`Select asset`,"aria-label":`Fault asset`,className:`h-8 min-h-11 w-full min-w-0 touch-manipulation sm:min-h-8`,showClear:!!r}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[p.map(e=>(0,Z.jsxs)(U,{value:e.id,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id}),e.activeFaults.length>0&&(0,Z.jsx)(o,{variant:`destructive`,className:`ml-auto text-[10px]`,children:e.activeFaults.length})]},e.id)),p.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No assets found`})]})})]}),(0,Z.jsxs)(fe,{value:l,onValueChange:e=>u(e??``),children:[(0,Z.jsx)(de,{className:`h-8 min-h-11 w-full touch-manipulation sm:min-h-8`,"aria-label":`Fault type`,children:(0,Z.jsx)(ce,{placeholder:r?`Select fault`:`Pick asset first`})}),(0,Z.jsx)(ue,{alignItemWithTrigger:!1,align:`start`,children:m.map(e=>(0,Z.jsx)(le,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(b,{variant:`destructive`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!l,onClick:()=>{let e=O(A,{assetId:r,fault:l});e&&n.mutate({type:`triggerFault`,...e})},children:`Trigger`}),(0,Z.jsx)(b,{variant:`secondary`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!l,onClick:()=>{let e=O(A,{assetId:r,fault:l});e&&n.mutate({type:`clearFault`,...e})},children:`Clear`})]}),(0,Z.jsx)(ie,{}),(0,Z.jsx)(s,{mode:`wait`,initial:!1,children:h.length>0?(0,Z.jsxs)(a.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Faulted Assets`}),(0,Z.jsx)(s,{initial:!1,children:h.map(e=>(0,Z.jsx)(a.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:6,transition:{duration:.1}},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full touch-manipulation items-center justify-between rounded-[var(--miravo-radius-tight)] border border-destructive/20 bg-destructive/5 px-2.5 py-1.5 text-left transition-colors hover:bg-destructive/10 sm:min-h-0`,onClick:()=>{c(e.id),u(``)},children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-destructive`,children:e.activeFaults.join(`, `)})]})},e.id))})]},`faulted`):(0,Z.jsxs)(a.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex items-center gap-2 py-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(D,{className:`size-3.5 text-success`}),`All clear — no active faults`]},`all-clear`)})]})]})}function ge(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function _e(e){if(!Number.isFinite(e)||e<=0)return`0s`;if(e<60)return`${e.toFixed(1)}s`;let t=Math.floor(e),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?r>0?`${n}d ${r}h`:i>0?`${n}d ${i}m`:`${n}d`:r>0?`${r}h ${i}m`:i>0?`${i}m ${a}s`:`${a}s`}function ve({data:e}){let t=(0,X.useMemo)(()=>{if(e.length<2)return null;let t=e.map(e=>e.tps),n=Math.max(...t,.1),r=Math.min(...t,0),i=n-r||1;return{points:t.map((e,n)=>{let a=n/(t.length-1)*200,o=2+(1-(e-r)/i)*28;return`${n===0?`M`:`L`}${a.toFixed(1)},${o.toFixed(1)}`}).join(` `),min:r,max:n}},[e]);return t?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`svg`,{viewBox:`0 0 200 32`,className:`h-8 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":`TPS trend sparkline`,children:[(0,Z.jsx)(`line`,{x1:`0`,y1:`10.7`,x2:`200`,y2:`10.7`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`line`,{x1:`0`,y1:`21.3`,x2:`200`,y2:`21.3`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`path`,{d:t.points,fill:`none`,stroke:`var(--primary)`,strokeWidth:`1.5`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`60s ago · `,t.min.toFixed(1)]}),(0,Z.jsxs)(`span`,{children:[t.max.toFixed(1),` · now`]})]})]}):(0,Z.jsx)(`div`,{className:`flex h-8 items-center text-[10px] text-muted-foreground`,children:`Collecting...`})}var ye={running:`bg-success`,paused:`bg-warning`,idle:`bg-muted-foreground`,stopped:`bg-destructive`};function be({state:e}){let t=ye[e]??`bg-muted-foreground`,n=e===`running`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`size-2.5 rounded-full ${t}`}),n&&(0,Z.jsx)(`span`,{className:`absolute size-2.5 animate-ping rounded-full ${t} opacity-40`})]}),(0,Z.jsx)(s,{mode:`wait`,initial:!1,children:(0,Z.jsx)(a.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{type:`spring`,stiffness:500,damping:30},className:`font-mono text-lg font-bold uppercase tracking-wider`,children:e},e)})]})}function Q({label:e,tooltip:t,tooltipClassName:n}){return(0,Z.jsxs)(`div`,{className:`inline-flex w-fit min-w-0 max-w-full items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`blueprint-title min-w-0 shrink text-[11px] leading-tight text-muted-foreground`,children:e}),(0,Z.jsxs)(ne,{children:[(0,Z.jsx)(te,{className:`inline-flex size-4 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border-0 bg-transparent p-0 text-muted-foreground shadow-none outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring`,render:(0,Z.jsx)(`button`,{type:`button`}),"aria-label":`About ${e}`,children:(0,Z.jsx)(E,{className:`size-3`,"aria-hidden":!0})}),(0,Z.jsx)(re,{side:`top`,className:T(`max-w-xs`,n),children:t})]})]})}function $(){let{engineState:e,connectionState:t}=i(y(e=>({engineState:e.engineState,connectionState:e.connectionState}))),n=B();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Run state`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Whether the scheduler is running, paused, idle, or stopped. Pause freezes simulated time; resume continues from the same tick.`})}),(0,Z.jsx)(be,{state:e}),t===`live`&&(e===`running`||e===`paused`)&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-2`,children:(0,Z.jsxs)(b,{type:`button`,size:`sm`,variant:e===`paused`?`default`:`outline`,className:T(`h-8 min-h-11 w-fit touch-manipulation gap-1.5 px-3 text-xs sm:min-h-8`,e===`running`&&`border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 hover:text-warning focus-visible:border-warning/50 focus-visible:ring-warning/25 border-warning/35`),onClick:()=>n.mutate({type:e===`paused`?`resume`:`pause`}),children:[e===`paused`?(0,Z.jsx)(F,{className:`size-3`}):(0,Z.jsx)(me,{className:`size-3`}),e===`paused`?`Resume`:`Pause`]})})]})}function xe(){let{speedMultiplier:e,connectionState:t}=i(y(e=>({speedMultiplier:e.speedMultiplier,connectionState:e.connectionState}))),n=B(),[r,a]=(0,X.useState)(String(e)),o=t===`live`;return(0,X.useEffect)(()=>{a(String(e))},[e]),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Speed`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Runs the factory at this multiple of real time. 1× is real time; higher values speed up the model. Change it with the field and Set.`})}),(0,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[e,`x`]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(R,{htmlFor:`speed-multiplier`,className:`sr-only`,children:`Speed multiplier`}),(0,Z.jsx)(x,{id:`speed-multiplier`,type:`number`,value:r,onChange:e=>a(e.target.value),className:`h-8 min-h-11 w-[4.75rem] touch-manipulation font-mono text-xs tabular-nums sm:min-h-8`,min:`1`,max:`1000`,disabled:!o}),(0,Z.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 min-h-11 touch-manipulation px-3 text-xs sm:min-h-8`,disabled:!o,onClick:()=>{let e=O(ae,{multiplier:Number(r)});e&&n.mutate({type:`setSpeed`,multiplier:e.multiplier})},children:`Set`})]})]})}function Se(){let{tick:e,simulationTime:t,tps:n,tpsHistory:r,uptimeMs:a,assetCount:o,memberValueCount:s}=i(y(e=>({tick:e.tick,simulationTime:e.simulationTime,tps:e.tps,tpsHistory:e.tpsHistory,uptimeMs:e.uptimeMs,assetCount:e.assetCount,memberValueCount:e.memberValueCount})));return(0,Z.jsxs)(`div`,{className:T(z,`px-4 py-3`),children:[(0,Z.jsxs)(`header`,{className:`mb-3 border-b border-border/60 pb-2`,children:[(0,Z.jsx)(`h2`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Engine vitals`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Scheduler, speed, cycle count, and throughput for this session.`})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-2 gap-3 @2xl/main:gap-4 @3xl/main:grid-cols-3 @5xl/main:grid-cols-6`,children:[(0,Z.jsx)($,{}),(0,Z.jsx)(xe,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Cycle`,tooltipClassName:`flex flex-col items-start gap-2 text-left`,tooltip:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Cycle`}),` compares simulated progress with wall time: how many steps ran, how much model time advanced, and how long this session has been open.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[`The number is `,(0,Z.jsx)(`span`,{className:`font-medium`,children:`tick`}),` count — completed scheduler steps since this run. Each tick refreshes the plant model and live tags.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Sim`}),` is simulated elapsed time. Each tick adds (tick interval × speed) to this clock. Generators, lifecycle, and in-model timestamps use Sim, not your system clock. It stops advancing while paused.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Real`}),` is wall-clock uptime since the run started (real time).`]})]})}),(0,Z.jsx)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:C(e)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex w-full min-w-0 flex-col gap-0.5 leading-tight`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Sim`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:_e(t)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Real`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:ge(a)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Throughput`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Ticks per second: how fast the engine is stepping. Rises and falls with workload, speed setting, and CPU headroom.`})}),(0,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[n.toFixed(1),` tps`]}),(0,Z.jsxs)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[o,` inst · `,S(s),` tags`]})]}),(0,Z.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`TPS Trend`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Recent ticks-per-second samples over about the last minute. Flat or noisy lines usually mean load or speed changes.`})}),(0,Z.jsx)(ve,{data:r})]})]})]})}function Ce({enabled:e,total:t}){return(0,Z.jsxs)(ee,{tone:t===0?`off`:e===0?`idle`:`live`,children:[(0,Z.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`mx-1 text-muted-foreground/60`,children:`/`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:t}),(0,Z.jsx)(`span`,{className:`ml-1.5`}),(0,Z.jsx)(g,{children:`active`})]})}function we(){let{availableAdapters:e,adapterMetrics:t}=i(y(e=>({availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled).length;return(0,Z.jsxs)(v,{icon:Y,title:`Protocol Gateway`,description:`Northbound adapters publishing engine telemetry to external systems.`,aside:(0,Z.jsx)(Ce,{enabled:n,total:e.length}),bodyClassName:`p-0`,children:[e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 px-4 py-4`,children:(0,Z.jsx)(s,{children:e.map((e,n)=>{let r=t.find(t=>t.name===e.name)?.metrics;return(0,Z.jsx)(a.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{type:`spring`,stiffness:380,damping:30,delay:n*.05},children:(0,Z.jsx)(_,{adapter:e,metrics:r})},e.name)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 border-t border-border/60 bg-background/40 px-4 py-2.5`,role:`status`,"aria-label":`Upcoming protocol adapters`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(I,{className:`size-3 text-muted-foreground/70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Roadmap`})]}),(0,Z.jsx)(`span`,{className:`font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground`,children:`More protocols to come`})]})]})}function Te(){let{assets:e,templates:t}=i(y(e=>({assets:e.assets,templates:e.templates}))),n=B(),[r,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(K,{className:`min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(pe,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Danger Zone`]})}),(0,Z.jsx)(J,{className:`flex flex-1 flex-col`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-3 @2xl/main:flex-row @2xl/main:items-center @2xl/main:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Reset factory`}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Unloads `,t.length,` template`,t.length===1?``:`s`,` and removes`,` `,e.length,` asset`,e.length===1?``:`s`,`, including standalone ones.`]})]}),(0,Z.jsx)(b,{className:`min-h-11 w-full shrink-0 touch-manipulation @2xl/main:w-auto sm:min-h-7`,variant:`destructive`,size:`sm`,onClick:()=>a(!0),children:`Reset`})]})})]}),(0,Z.jsx)(h,{open:r,onOpenChange:a,children:(0,Z.jsxs)(f,{children:[(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:`Reset Factory`}),(0,Z.jsx)(m,{children:`Unloads every template and removes every asset, including standalone ones. With persistence on, the empty factory is saved and stays empty after a restart.`})]}),(0,Z.jsxs)(d,{children:[(0,Z.jsx)(b,{variant:`outline`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,onClick:()=>a(!1),disabled:o,children:`Cancel`}),(0,Z.jsx)(b,{variant:`destructive`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,disabled:o,onClick:async()=>{s(!0);try{await n.mutateAsync({type:`resetFactory`}),a(!1)}catch{}finally{s(!1)}},children:o?`Resetting...`:`Confirm Reset`})]})]})})]})}function Ee(){let[e,t]=c(`tab`,l([`monitor`,`operate`]).withDefault(`monitor`));return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Mission Control`}),(0,Z.jsxs)(o,{variant:`outline`,title:`Miravo version ${r}`,className:`font-mono text-[10px] leading-none text-muted-foreground`,children:[`v`,r]})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Engine telemetry, protocol management, and fault operations.`})]}),(0,Z.jsxs)(P,{value:e,onValueChange:e=>{t(e)},className:`min-h-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,Z.jsxs)(N,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Z.jsxs)(j,{value:`monitor`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(k,{className:`size-3.5 shrink-0`}),`Monitor`]}),(0,Z.jsxs)(j,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(oe,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,Z.jsx)(M,{value:`monitor`,className:`flex-1 py-2`,children:(0,Z.jsxs)(a.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col gap-5 sm:gap-6`,children:[(0,Z.jsx)(Se,{}),(0,Z.jsx)(we,{})]},`monitor`)}),(0,Z.jsx)(M,{value:`operate`,className:`flex-1 py-2`,children:(0,Z.jsxs)(a.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`grid min-h-0 min-w-0 grid-cols-1 items-start gap-5 @2xl/main:grid-cols-2 @2xl/main:gap-4`,children:[(0,Z.jsx)(he,{}),(0,Z.jsx)(Te,{})]},`operate`)})]})]})}export{Y as n,Ee as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./control-CD9UoTvu.js";export{e as ControlPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{G as n,H as r,K as i,U as a,V as o,W as s,ot as c,q as l}from"./vendor-ui-D8j69UH4.js";import{c as u}from"./dialog-Di9Bs0FH.js";import{E as d}from"./format-OUFL_tef.js";import{n as f,t as p}from"./utils-BO2u-wC_.js";var m=f(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),h=e(t(),1),g=c();function _({delay:e=0,...t}){return(0,g.jsx)(o,{"data-slot":`tooltip-provider`,delay:e,...t})}function v({...e}){return(0,g.jsx)(l,{"data-slot":`tooltip`,...e})}function y({...e}){return(0,g.jsx)(i,{"data-slot":`tooltip-trigger`,...e})}function b({className:e,side:t=`top`,sideOffset:i=3,align:o=`center`,alignOffset:c=0,children:l,...u}){return(0,g.jsx)(n,{children:(0,g.jsx)(s,{align:o,alignOffset:c,side:t,sideOffset:i,className:`isolate z-50`,children:(0,g.jsxs)(a,{"data-slot":`tooltip-content`,className:p(`z-50 inline-flex w-fit max-w-[min(18rem,85vw)] origin-(--transform-origin) items-center gap-1 rounded-[var(--miravo-radius-tight)] bg-tooltip px-2 py-1 text-[11px] leading-tight text-tooltip-foreground shadow-md shadow-black/25 has-data-[slot=kbd]:pr-1 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-[var(--miravo-radius-tight)] data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...u,children:[l,(0,g.jsx)(r,{className:`z-50 size-2 translate-y-[calc(-50%-1px)] rotate-45 rounded-[1px] bg-tooltip fill-tooltip data-[side=bottom]:top-0.5 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-0.5 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-0.5 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-0.5 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-0.5 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2`})]})})})}function x(e,t){if(!t?.body||!t.createElement||typeof t.execCommand!=`function`)return!1;let n=t.createElement(`textarea`),r=t.activeElement;n.value=e,n.setAttribute(`readonly`,``),n.setAttribute(`aria-hidden`,`true`),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`-9999px`,n.style.opacity=`0`,t.body.appendChild(n),n.focus(),n.select(),n.setSelectionRange(0,n.value.length);try{return t.execCommand(`copy`)}finally{t.body.removeChild(n),r?.focus?.()}}async function S(e,t=globalThis){let n=t.navigator?.clipboard?.writeText;if(n)try{await n(e);return}catch{if(x(e,t.document))return;throw Error(`Clipboard write failed`)}if(!x(e,t.document))throw Error(`Clipboard API unavailable`)}function C({value:e,label:t=`Copy`,className:n,successMessage:r=`Copied to clipboard`,successDescription:i,tooltipSide:a=`right`,render:o}){let[s,c]=(0,h.useState)(!1),l=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>clearTimeout(l.current),[]);let f=(0,h.useCallback)(async t=>{t.stopPropagation();try{await S(e),c(!0),u.success(r,{description:i}),clearTimeout(l.current),l.current=setTimeout(()=>c(!1),1500)}catch{u.error(`Failed to copy`)}},[i,r,e]),_=s?(0,g.jsx)(d,{className:`size-3 text-success`}):(0,g.jsx)(m,{className:`size-3`}),x=o?.({copied:s,icon:_});return(0,g.jsxs)(v,{children:[(0,g.jsx)(y,{className:x?void 0:p(`relative inline-flex size-6 items-center justify-center rounded-[var(--miravo-radius-tight)] text-muted-foreground hover:bg-muted hover:text-foreground before:absolute before:inset-[-10px] before:content-['']`,n),onClick:f,closeOnClick:!1,"aria-label":t,render:x,children:_}),(0,g.jsx)(b,{side:a,children:s?`Copied!`:t})]})}export{y as a,_ as i,v as n,b as r,C as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,ot as a,v as o}from"./api-kPM52mb-.js";import{h as s,i as c,t as l}from"./query-fetch-error-C2Ec4RQS.js";import{n as u,t as d}from"./badge-D4jktT8T.js";import{t as f}from"./AnimatePresence-BZCmb1bq.js";import{u as ee}from"./chunk-OE4NN4TA-Q4iNR9l9.js";import{C as te,g as p,t as m}from"./format-OUFL_tef.js";import{n as h,t as ne}from"./use-transition-navigate-BiV2QCcA.js";import{n as re}from"./transition-types-049V0Kr0.js";import{n as ie}from"./auth-screen-backdrop-hcEYy3K4.js";import{n as g}from"./get-error-message-eGdenTLv.js";import{r as ae}from"./runtime-link-ChF8TM68.js";import{a as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./combobox-BFEY6lgO.js";import{c as pe,i as _,n as me,s as he,t as ge}from"./select-Bg6PPro0.js";import{a as v,c as y,i as _e,o as b,r as ve,s as ye,t as be}from"./select-display-items-D-L3PesO.js";var x=e(t(),1);function xe(e){return e.includes(`triggered`)?`destructive`:e.includes(`cleared`)||e.includes(`created`)?`default`:e.includes(`removed`)||e.includes(`lifecycle`)?`secondary`:(e.includes(`state-changed`),`outline`)}function Se(e){return e.includes(`state-changed`)?`border-info/30 bg-info/20 text-info hover:bg-info/20`:``}function Ce(e){return e.type===`integration:operation`||e.type===`integration:resource`}function we(e,t){let n=new Date(e);return n.toDateString()===t.toDateString()?n.toLocaleTimeString(m):n.toLocaleString(m,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function S(e){if(`assetId`in e&&typeof e.assetId==`string`)return e.assetId}function C(e){return S(e)}function w(e){return`fault`in e?p(e.fault):`from`in e&&`to`in e?`${p(e.from)} \u2192 ${p(e.to)}`:``}function T(e,t,n){let r=new URLSearchParams;return r.set(`limit`,`50`),e!==`all`&&r.set(`type`,e),t&&r.set(`assetId`,t),n!==null&&r.set(`cursor`,String(n)),`/events?${r.toString()}`}var E=n(),D=1500;function O(){let e=s(),[t]=ee(),n=t.get(`type`)??`all`,p=t.get(`assetId`)??``,[m,O]=(0,x.useState)(n),[k,A]=(0,x.useState)(p),[j,Te]=(0,x.useState)(!0),M=ae(a(e=>e.connectionState))===null,N=a(e=>e.events.length),P=(0,x.useRef)(!1),F=a(e=>e.assets),Ee=ne(),I=c({queryKey:o.events(m,k),queryFn:()=>i(T(m,k,null),r.events),refetchInterval:j&&M?D:!1,staleTime:5e3}),[De,L]=(0,x.useState)([]),[R,z]=(0,x.useState)(!1),[Oe,B]=(0,x.useState)(null),V=`${m}::${k}`,H=(0,x.useRef)(V);(0,x.useEffect)(()=>{V!==H.current&&(H.current=V,L([]),B(null),W(!1))},[V]),(0,x.useEffect)(()=>{O(e=>e===n?e:n)},[n]),(0,x.useEffect)(()=>{A(e=>e===p?e:p)},[p]);let[U,W]=(0,x.useState)(()=>(I.data?.events.length??0)>0),G=I.data?[I.data,...De]:[],K=G.flatMap(e=>e.events).filter(e=>!Ce(e)),q=G[G.length-1],ke=q?.hasMore??!1;(0,x.useEffect)(()=>{K.length>0&&!U&&W(!0)},[K.length,U]);let J=(0,x.useRef)(N);(0,x.useEffect)(()=>{N!==J.current&&(J.current=N,j&&M?(e.invalidateQueries({queryKey:o.events(m,k)}),P.current=!1):j&&(P.current=!0))},[N,j,M,e,m,k]),(0,x.useEffect)(()=>{!j||!M||!P.current||(P.current=!1,e.invalidateQueries({queryKey:o.events(m,k)}))},[j,M,e,m,k]);let[Y,Ae]=(0,x.useState)(``),X=(0,x.useMemo)(()=>Y?F.filter(e=>e.id.toLowerCase().includes(Y.toLowerCase())):F,[F,Y]),Z=I.isPending&&!I.data&&!I.isError,je=j&&!Z&&!U&&K.length===0,Q=I.error??Oe,Me=I.isError&&!I.data,$=(0,x.useCallback)(()=>{I.refetch()},[I]),Ne=async()=>{if(q?.nextCursor){z(!0),B(null);try{let e=await i(T(m,k,q.nextCursor),r.events);L(t=>[...t,e])}catch(e){B(e instanceof Error?e:Error(g(e,`Failed to fetch events.`)))}finally{z(!1)}}};if(Me)return(0,E.jsx)(ie,{className:`min-h-full`,children:(0,E.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,E.jsx)(`div`,{className:`w-full max-w-md`,children:(0,E.jsx)(l,{message:g(Q,`Failed to fetch events.`),onRetry:$,isRetrying:I.isFetching})})})});let Pe=new Date;return(0,E.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[Q&&K.length>0?(0,E.jsx)(l,{message:`${g(Q,`Failed to fetch events.`)} Showing cached events.`,onRetry:$,isRetrying:I.isFetching}):null,(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:flex-row lg:items-center lg:justify-between lg:gap-4`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,E.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Event Log`}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Real-time event stream from the engine.`}),j&&!M?(0,E.jsx)(`p`,{className:`text-xs text-warning`,role:`status`,children:`Live refresh pauses until the Miravo link is live again.`}):null]}),(0,E.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-2 sm:flex-row sm:flex-nowrap sm:items-center sm:gap-2 lg:w-auto lg:max-w-full`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>Te(e=>!e),className:`flex h-7 shrink-0 items-center self-start overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/40 px-2 py-1 text-xs transition-colors hover:bg-muted sm:self-auto`,children:(0,E.jsx)(f,{mode:`wait`,initial:!1,children:j?(0,E.jsxs)(u.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-success`}),(0,E.jsx)(`span`,{className:`font-medium text-success`,children:`LIVE`})]},`live`):(0,E.jsxs)(u.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`}),(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`Paused`})]},`paused`)})}),(0,E.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,E.jsxs)(fe,{value:k||null,onValueChange:e=>{A(e??``)},onInputValueChange:Ae,children:[(0,E.jsx)(ue,{placeholder:`All assets`,className:`h-8 w-full min-w-0`,showClear:!!k}),(0,E.jsx)(ce,{children:(0,E.jsxs)(oe,{children:[X.map(e=>(0,E.jsx)(se,{value:e.id,children:(0,E.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),X.length===0&&(0,E.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No assets found`})]})})]})}),(0,E.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,E.jsxs)(ge,{value:m,onValueChange:e=>{O(e??`all`)},items:be,children:[(0,E.jsx)(he,{className:`w-full min-w-0 lg:w-48`,"aria-label":`Event type filter`,children:(0,E.jsx)(pe,{placeholder:`Filter by type`})}),(0,E.jsxs)(me,{alignItemWithTrigger:!1,align:`start`,children:[(0,E.jsx)(_,{value:`all`,children:`All events`}),(0,E.jsx)(_,{value:`fault:triggered`,children:`Fault Triggered`}),(0,E.jsx)(_,{value:`fault:cleared`,children:`Fault Cleared`}),(0,E.jsx)(_,{value:`lifecycle:changed`,children:`Lifecycle Changed`}),(0,E.jsx)(_,{value:`asset:maintenance`,children:`Maintenance`}),(0,E.jsx)(_,{value:`asset:created`,children:`Asset Created`}),(0,E.jsx)(_,{value:`asset:removed`,children:`Asset Removed`}),(0,E.jsx)(_,{value:`engine:state-changed`,children:`Engine State`})]})]})})]})]}),(0,E.jsx)(le,{className:`min-w-0 py-0`,children:(0,E.jsx)(de,{className:`p-0`,children:(0,E.jsxs)(ve,{children:[(0,E.jsx)(ye,{children:(0,E.jsxs)(y,{children:[(0,E.jsx)(b,{className:`hidden w-12 sm:table-cell`,children:`#`}),(0,E.jsx)(b,{children:`Type`}),(0,E.jsx)(b,{children:`Context`}),(0,E.jsx)(b,{children:`Details`}),(0,E.jsx)(b,{className:`hidden text-right md:table-cell`,children:`Cycle #`}),(0,E.jsx)(b,{className:`hidden text-right sm:table-cell`,children:`Wall Clock`})]})}),(0,E.jsxs)(_e,{children:[K.map(e=>{let t=S(e),n=C(e);return(0,E.jsxs)(y,{className:t?`transition-colors`:``,onMouseEnter:t?()=>h(`/asset/${t}`):void 0,children:[(0,E.jsx)(v,{className:`hidden font-mono text-xs text-muted-foreground sm:table-cell`,children:e.id}),(0,E.jsx)(v,{children:(0,E.jsx)(d,{variant:xe(e.type),className:`text-xs ${Se(e.type)}`,children:e.type})}),(0,E.jsx)(v,{className:`font-mono text-xs`,children:t?(0,E.jsx)(`button`,{type:`button`,className:`rounded-[var(--miravo-radius-tight)] text-left text-primary outline-none underline-offset-4 hover:underline focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onFocus:()=>h(`/asset/${t}`),onClick:()=>Ee(`/asset/${t}`,{transitionType:re}),children:n??t}):n??`—`}),(0,E.jsx)(v,{className:`max-w-xs truncate font-mono text-xs`,children:w(e)||(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,E.jsx)(v,{className:`hidden text-right font-mono text-xs md:table-cell`,children:e.tick}),(0,E.jsx)(v,{className:`hidden text-right text-xs text-muted-foreground sm:table-cell`,children:we(e.timestamp,Pe)})]},e.id)}),!Z&&K.length===0&&(0,E.jsx)(y,{children:(0,E.jsx)(v,{colSpan:6,className:`py-8 text-center text-muted-foreground`,children:je?`Listening for events…`:`No events`})})]})]})})}),ke&&(0,E.jsx)(`div`,{className:`flex justify-center border-t border-border/40 pt-4`,children:(0,E.jsx)(te,{variant:`outline`,size:`sm`,onClick:()=>void Ne(),disabled:R,children:`Load older events`})})]})}export{O as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./events-D19CzgoQ.js";export{e as EventsPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{$ as n,J as r,Q as i,X as a,Y as o,Z as s,et as c,ot as l}from"./vendor-ui-D8j69UH4.js";import{H as u,L as d,S as f,a as p,o as m,s as h}from"./api-kPM52mb-.js";import{a as g,c as _,i as v,n as y,o as b,r as x,t as ee}from"./dialog-Di9Bs0FH.js";import{C as S,S as C,T as w}from"./format-OUFL_tef.js";import{n as T,t as E}from"./utils-BO2u-wC_.js";import{t as D}from"./chevron-down-CAk5w9Wt.js";import{t as O}from"./download-B9e1wNK4.js";import{n as k,t as A}from"./source-host-miravo-D_AecPVc.js";import{a as j}from"./tabs-bI9sskHy.js";import{t as M}from"./label-DWyy9MeT.js";import"./use-engine-command-mutation-DMkQxmt9.js";var N=T(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),P=l();function F({...e}){return(0,P.jsx)(o,{"data-slot":`sheet`,...e})}function I({...e}){return(0,P.jsx)(a,{"data-slot":`sheet-portal`,...e})}function L({className:e,...t}){return(0,P.jsx)(c,{"data-slot":`sheet-overlay`,className:E(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,e),...t})}function R({className:e,children:t,side:r=`right`,showCloseButton:i=!0,...a}){return(0,P.jsxs)(I,{children:[(0,P.jsx)(L,{}),(0,P.jsxs)(s,{"data-slot":`sheet-content`,"data-side":r,className:E(`fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-[calc(100vw-1rem)] data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-[calc(100vw-1rem)] data-[side=right]:max-w-xl data-[side=right]:border-l data-[side=right]:pl-1 data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem]`,e),...a,children:[t,i&&(0,P.jsxs)(n,{"data-slot":`sheet-close`,render:(0,P.jsx)(S,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,P.jsx)(w,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function z({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`sheet-header`,className:E(`flex flex-col gap-0.5 p-2`,e),...t})}function B({className:e,...t}){return(0,P.jsx)(r,{"data-slot":`sheet-title`,className:E(`text-base font-medium text-foreground`,e),...t})}function V({className:e,...t}){return(0,P.jsx)(i,{"data-slot":`sheet-description`,className:E(`text-sm text-muted-foreground`,e),...t})}var H=e(t(),1);function U({format:e,kind:t}){return e===`source-yaml`?t===`model`?`Raw asset model definition. Edit locally, version-control, or use as input for the CLI.`:`Raw factory definition with topology and namespace. Edit, share, or apply via CLI.`:e===`litmus-edge`?t===`model`?`Litmus Edge Digital Twin JSON for manual import via the Litmus Edge UI.`:`Litmus Edge template JSON (DeviceHub devices + Digital Twins). Import directly via the Litmus Edge UI.`:`Select a format to download.`}function W({children:e,className:t}){return(0,P.jsx)(`div`,{className:E(`max-h-[min(36rem,75vh)] min-h-0 overflow-y-auto rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 p-4 sm:p-5`,t),children:e})}var G=[`modbus`,`opcua`,`mqtt`],K={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`};function q(e){return e===``?null:!/^\d+$/.test(e)||!u(Number(e))?`Use a port from 1 to 65535.`:null}function J(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,String(t)]))}function Y(e,t,n){let r={...e};for(let e of n){let n=(t[e]??``).trim();if(q(n))return null;n===``?delete r[e]:r[e]=Number(n)}return r}function X({open:e,onOpenChange:t,protocols:n,values:r,onChange:i,hint:a}){let o=(0,H.useId)();return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),"aria-expanded":e,className:`flex w-full items-center gap-1 text-left text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[(0,P.jsx)(D,{className:E(`size-3 transition-transform`,!e&&`-rotate-90`),"aria-hidden":!0}),`Miravo ports remapped (Docker)?`]}),e?(0,P.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:a}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:n.map(e=>{let t=r[e]??``,n=q(t.trim());return(0,P.jsxs)(`div`,{className:`w-24 space-y-1`,children:[(0,P.jsx)(M,{htmlFor:`${o}-${e}`,className:`text-[11px] text-muted-foreground`,children:K[e]}),(0,P.jsx)(C,{id:`${o}-${e}`,inputMode:`numeric`,placeholder:String(d[e]),value:t,"aria-invalid":n!==null,onChange:t=>i({...r,[e]:t.currentTarget.value}),className:`h-8 font-mono text-[12px]`}),n?(0,P.jsx)(`p`,{className:`text-[10px] text-destructive`,children:n}):null]},e)})})]}):null]})}var Z=`172.17.0.1`;async function Q(e){let t=await m(`/catalog/models/${encodeURIComponent(e)}/le-dt.json`,f.catalogModelLeDt);return JSON.stringify(t,null,2)}async function te(e,t={host:Z}){let n=f.catalogTemplateLeTemplateJson.query;if(!n)throw Error(`Missing query schema for ${f.catalogTemplateLeTemplateJson.method} ${f.catalogTemplateLeTemplateJson.path}`);let r=n.safeParse({host:t.host,protocol:t.protocol,modbusPort:t.exposedPorts?.modbus,opcuaPort:t.exposedPorts?.opcua,mqttPort:t.exposedPorts?.mqtt});if(!r.success)throw Error(`Invalid request for ${f.catalogTemplateLeTemplateJson.method} ${f.catalogTemplateLeTemplateJson.path}: ${r.error.message}`);return p(ne(e,r.data),f.catalogTemplateLeTemplateJson)}function ne(e,t){return`/catalog/templates/${encodeURIComponent(e)}/le-template.json${re(t)}`}function re(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&r!==``&&t.set(n,String(r));return t.size>0?`?${t.toString()}`:``}function $(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n),_.success(`Exported ${t}`)}function ie({kind:e,id:t,yamlPath:n,yamlFilename:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(Z),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)({}),[p,m]=(0,H.useState)(!1),w=(0,H.useCallback)(async()=>{try{let t=await h(n,e===`model`?f.catalogModelYaml:f.catalogTemplateYaml);$(new Blob([t],{type:`text/yaml`}),r)}catch{_.error(`Failed to export YAML`)}},[e,n,r]),T=(0,H.useCallback)(async()=>{try{let e=await Q(t);$(new Blob([e],{type:`application/json`}),`${t}.le-dt.json`)}catch{_.error(`Failed to export integration format`)}},[t]),E=(0,H.useCallback)(async(e,n)=>{try{let r=e.trim();return $(await te(t,{host:r.length>0?r:Z,exposedPorts:n}),`${t}.le-template.json`),!0}catch{return _.error(`Failed to export integration format`),!1}},[t]),D=(0,H.useCallback)(()=>{s(Z),d({}),l(!1),a(!0)},[]),N=(0,H.useCallback)(async()=>{let e=Y(void 0,u,G);if(!e){l(!0);return}m(!0);try{await E(o,e)&&a(!1)}finally{m(!1)}},[u,o,E]);return(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pb-2`,children:[[{key:`source-yaml`,label:e===`model`?`Source YAML (.asset.yaml)`:`Source YAML (.miravo.yaml)`,onDownload:()=>void w()},{key:`litmus-edge`,label:e===`model`?`Litmus Edge Digital Twin (JSON)`:`Litmus Edge template (JSON)`,onDownload:e===`model`?()=>void T():D}].map(t=>(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 p-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:t.label}),(0,P.jsxs)(S,{variant:`outline`,size:`sm`,className:`h-8 shrink-0 gap-1.5 text-xs`,"aria-label":`Download ${t.label}`,onClick:t.onDownload,children:[(0,P.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]}),(0,P.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/70`,children:(0,P.jsx)(U,{format:t.key,kind:e})})]},t.key)),(0,P.jsx)(ee,{open:i,onOpenChange:a,children:(0,P.jsxs)(y,{className:`sm:max-w-md`,children:[(0,P.jsxs)(g,{children:[(0,P.jsx)(b,{children:`Download Litmus Edge Template`}),(0,P.jsx)(x,{children:A})]}),(0,P.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,P.jsx)(M,{htmlFor:`export-source-host`,children:k}),(0,P.jsx)(C,{id:`export-source-host`,value:o,onChange:e=>s(e.target.value),placeholder:Z,autoComplete:`off`,className:`font-mono text-sm`}),(0,P.jsxs)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Use an IP or hostname reachable from Litmus Edge (e.g.`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:Z}),` for Docker bridge).`]}),(0,P.jsx)(X,{open:c,onOpenChange:l,protocols:G,values:u,onChange:d,hint:`Enter the host port Litmus Edge should dial. Leave blank to use Miravo's own port.`})]}),(0,P.jsxs)(v,{className:`gap-2 sm:gap-0`,children:[(0,P.jsx)(S,{type:`button`,variant:`outline`,onClick:()=>a(!1),disabled:p,children:`Cancel`}),(0,P.jsxs)(S,{type:`button`,className:`gap-1.5`,onClick:()=>void N(),disabled:p,"aria-busy":p,children:[p?(0,P.jsx)(j,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,P.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]})]})})]})}export{J as a,R as c,B as d,N as f,Y as i,V as l,X as n,W as o,G as r,F as s,ie as t,z as u};
@@ -1 +0,0 @@
1
- import{t as e}from"./factory-DSrBtcG2.js";export{e as FactoryPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{Dt as r,S as i,St as a,_t as o,ft as s,o as c,ot as l,v as u,y as d,yt as f}from"./api-kPM52mb-.js";import{c as p,d as m,f as h,g,h as _,i as v,l as y,o as b,p as x,s as ee,t as S,u as C}from"./query-fetch-error-C2Ec4RQS.js";import{d as w,n as T,t as E}from"./badge-D4jktT8T.js";import{t as D}from"./AnimatePresence-BZCmb1bq.js";import{i as O,n as k,r as A}from"./dist-CtuJWBnP.js";import{n as j,s as te}from"./chunk-OE4NN4TA-Q4iNR9l9.js";import{a as M,i as ne,n as re,o as ie,r as ae,t as oe}from"./dialog-Di9Bs0FH.js";import{a as N,i as P,o as F,r as se,s as I,t as ce}from"./protocol-card-B2SpAJKe.js";import{C as L,E as le,S as ue,T as de,_ as fe,c as pe,d as me,g as he,h as R,l as ge,m as _e,p as ve,s as ye,u as z,v as be,w as B,y as xe}from"./format-OUFL_tef.js";import{n as V,t as H}from"./utils-BO2u-wC_.js";import{t as Se}from"./activity-Cn48I9qe.js";import{n as Ce,r as we,t as Te}from"./server-CS2Tw__K.js";import{a as Ee,d as De,i as Oe,n as ke,r as Ae,s as je,t as Me,u as Ne}from"./local-flag-CPAqDO-L.js";import{a as Pe,n as Fe,r as Ie,t as Le}from"./catalog-template-icons-C7KJdJJX.js";import{t as Re}from"./chevron-down-CAk5w9Wt.js";import{t as ze}from"./chevron-right-BfZjrUWh.js";import{n as Be,t as Ve}from"./circle-x-CGcRflg7.js";import{a as He,c as Ue,i as We,l as Ge,o as Ke,p as qe,s as Je,t as Ye,u as Xe}from"./integration-api-Bg7D1eQc.js";import{a as U,n as W,r as G,t as Ze}from"./copy-button-DHm7RGJ5.js";import{n as Qe,r as $e,t as et}from"./source-host-miravo-D_AecPVc.js";import{a as K,i as tt,n as nt,r as rt,t as it}from"./tabs-bI9sskHy.js";import{t as at}from"./plus-BbVbvFTe.js";import{t as ot}from"./radio-DRkzblxj.js";import{t as st}from"./rocket-807Pf7C1.js";import{a as ct,f as lt,i as ut,n as dt,o as ft,r as pt}from"./export-tab-ouFgYEU_.js";import{t as mt}from"./trash-2-BJ-1df0F.js";import{t as ht}from"./triangle-alert-D1AraFcP.js";import{n as gt,t as _t}from"./use-transition-navigate-BiV2QCcA.js";import{n as vt}from"./transition-types-049V0Kr0.js";import{t as yt}from"./label-DWyy9MeT.js";import{n as bt,t as xt}from"./get-error-message-eGdenTLv.js";import{i as St,o as Ct,t as wt}from"./use-engine-command-mutation-DMkQxmt9.js";import{a as Tt,i as Et,n as Dt,o as Ot,r as kt,s as At,t as jt}from"./combobox-BFEY6lgO.js";import{c as Mt,i as q,n as Nt,s as Pt,t as Ft}from"./select-Bg6PPro0.js";import{a as J,c as It,i as Lt,n as Rt,o as zt,r as Bt,s as Vt}from"./select-display-items-D-L3PesO.js";import{t as Ht}from"./checkbox-AaJhjtZk.js";import{n as Ut,r as Wt,t as Gt}from"./integration-targets-BehiqWyT.js";function Kt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function qt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Jt=class extends r{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,s.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,o=n.some((t,n)=>t!==e[n]),s=i||o,c=s?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!a(e,n)});!s&&!c||(s&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(s&&(Kt(e,n).forEach(e=>{e.destroy()}),Kt(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=f(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new g(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=qt(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&s.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Y=e(t(),1);function Yt({queries:e,...t},n){let r=_(n),i=x(),a=h(),c=Y.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);c.forEach(e=>{b(e),y(e,a,r.getQueryCache().get(e.queryHash))}),m(a);let[l]=Y.useState(()=>new Jt(r,c,t)),[u,d,f]=l.getOptimisticResult(c,t.combine),v=!i&&t.subscribed!==!1;Y.useSyncExternalStore(Y.useCallback(e=>v?l.subscribe(s.batchCalls(e)):o,[l,v]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Y.useEffect(()=>{l.setQueries(c,t)},[c,t,l]);let S=u.some((e,t)=>p(c[t],e))?u.flatMap((e,t)=>{let n=c[t];return n&&p(n,e)?ee(n,new g(r,n),a):[]}):[];if(S.length>0)throw Promise.all(S);let w=u.find((e,t)=>{let n=c[t];return n&&C({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(w?.error)throw w.error;return d(f())}var Xt=V(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Zt=V(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Qt=V(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),$t=V(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),en=V(`circle-alert`,[[`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`}]]),tn=V(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),nn=V(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),rn=V(`component`,[[`path`,{d:`M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1uwlt4`}],[`path`,{d:`M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z`,key:`10291m`}],[`path`,{d:`M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z`,key:`1tqoq1`}],[`path`,{d:`M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1x6lto`}]]),an=V(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),on=V(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),sn=V(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),cn=V(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),ln=V(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),un=V(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),X=n();function Z({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`skeleton`,className:H(`animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted`,e),...t})}var dn=`https://miravo.dev/docs`;function fn(){let{adapters:e,metrics:t}=l(I(e=>({adapters:e.availableAdapters,metrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled&&!e.pending&&e.endpoint),r=e.filter(e=>!n.includes(e)),i=e=>t.find(t=>t.name===e)?.metrics.clients?.active??0,a=n.reduce((e,t)=>e+i(t.name),0);return(0,X.jsxs)(se,{id:`connect`,icon:cn,title:`Connect`,description:`Point a client here to read live values.`,aside:(0,X.jsxs)(F,{tone:a>0?`live`:n.length>0?`idle`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:a}),(0,X.jsx)(N,{children:a===1?`client`:`clients`})]}),bodyClassName:`gap-2`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(j,{to:`/control`,className:P,children:[`Configure protocols`,(0,X.jsx)(we,{className:`size-3`,"aria-hidden":!0})]}),(0,X.jsxs)(`a`,{href:`${dn}/protocols`,target:`_blank`,rel:`noopener noreferrer`,className:H(P,`ml-auto`),children:[(0,X.jsx)(Zt,{className:`size-3`,"aria-hidden":!0}),`Protocol docs`]})]}),children:[n.length===0&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No protocol is serving yet.`}),n.map(e=>{let t=i(e.name),n=ce[e.name]??e.name;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-[var(--miravo-radius-stadium-sm)] border border-muted-foreground/20 bg-background/40 px-3 py-2.5 transition-colors hover:border-muted-foreground/25`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 shrink-0 rounded-full`,t>0?`bg-success`:`bg-muted-foreground/55`)}),(0,X.jsx)(`span`,{className:`text-sm font-medium tracking-tight`,children:n}),(0,X.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:t>0?`text-foreground`:void 0,children:t}),` `,`connected`]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 pl-3.5`,children:[(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,X.jsx)(Ze,{value:e.endpoint??``,label:`Copy ${n} endpoint`})]})]},e.name)}),r.length>0&&(0,X.jsxs)(`p`,{className:`pt-1 text-xs text-muted-foreground`,children:[r.map(e=>ce[e.name]??e.name).join(`, `),` `,r.length===1?`is`:`are`,` off.`]})]})}var pn=500;function mn(e){return e.kind===`template`?`template:${e.templateId}`:`asset:${e.assetId}`}function hn(e,t){return`${mn(e)}|${t}`}function gn(e){return e.operationType===`apply`?e.status===`success`||e.status===`partial`||e.status===`noop`?`applied`:`failed`:e.status===`success`||e.status===`noop`?`none`:`failed`}function _n(e,t){let n=new Map;for(let r of e){if(r.factoryName!==t)continue;let e=r.templateId===void 0?r.assetId===void 0?null:{kind:`asset`,assetId:r.assetId,protocol:`modbus`}:{kind:`template`,templateId:r.templateId};if(!e)continue;let i=hn(e,r.targetId);n.has(i)||n.set(i,{status:gn(r),operationType:r.operationType,targetId:r.targetId,targetLabel:r.targetLabel,completedAt:r.completedAt,error:r.error})}return n}function vn(e,t){let n=0,r=0;for(let i of e.values())t!==void 0&&i.targetId!==t||(i.status===`applied`?n+=1:i.status===`failed`&&(r+=1));return{applied:n,failed:r}}function yn(){let e=l(e=>e.factoryName),t=v({queryKey:u.integrations.operationsFactory(),queryFn:()=>He({limit:pn})});return{query:t,cells:(0,Y.useMemo)(()=>_n(t.data?.operations??[],e),[t.data,e])}}function bn(e){return e?`/?tab=integrations&integration=${e}`:`/?tab=integrations`}var xn=`miravo:factory-getting-started:dismissed`;function Sn({step:e,primary:t}){let n=H(B({size:`sm`,variant:t?`default`:`outline`}),!t&&`border-border bg-muted/40 text-primary shadow-none hover:border-muted-foreground/30 hover:bg-muted/60 hover:text-primary focus-visible:border-ring border-border bg-muted/30 hover:border-muted-foreground/35 hover:bg-muted/45 [&_svg]:text-primary`,`w-fit`);return e.href.startsWith(`#`)?(0,X.jsx)(`a`,{href:e.href,className:n,children:e.action}):(0,X.jsx)(j,{to:e.href,className:n,onClick:e.id===`tags`?()=>Ae(Me):void 0,children:e.action})}function Cn(){let{loaded:e,connected:t}=l(I(e=>({loaded:e.templates.length>0||e.assets.length>0,connected:e.adapterMetrics.some(e=>(e.metrics.clients?.active??0)>0)}))),{cells:n}=yn(),[r,i]=(0,Y.useState)(()=>ke(xn)),a=[{id:`load`,title:`Load a template`,hint:`Pick a plant from the catalog. Areas, lines and assets start running.`,done:e,action:`Open catalog`,href:`/catalog`},{id:`connect`,title:`Connect a client`,hint:`Point an MQTT, OPC UA or Modbus client at an endpoint in Connect.`,done:t,action:`Show endpoints`,href:`#connect`},{id:`tags`,title:`Explore live tags`,hint:`Browse every value the factory publishes, with its address per protocol.`,done:ke(Me),action:`Open tags`,href:`/tags`},{id:`edge`,title:`Send to Litmus Edge`,hint:`Apply a template to a Litmus Edge device: devices, tags and flows.`,done:n.size>0,optional:!0,action:`Set up`,href:bn(`litmus-edge`)}],o=a.filter(e=>!e.optional),s=o.filter(e=>e.done).length;if(r||s===o.length)return null;let c=a.find(e=>!e.done);return(0,X.jsx)(se,{icon:sn,title:`Getting started`,description:`From an empty factory to live data in your own tools.`,aside:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(F,{tone:`idle`,children:[(0,X.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:s}),(0,X.jsx)(`span`,{className:`mx-1 text-muted-foreground/60`,children:`/`}),(0,X.jsx)(`span`,{className:`mr-1.5 font-mono tabular-nums`,children:o.length}),(0,X.jsx)(N,{children:`done`})]}),(0,X.jsx)(L,{size:`icon-sm`,variant:`ghost`,"aria-label":`Dismiss getting started`,onClick:()=>{Ae(xn),i(!0)},children:(0,X.jsx)(de,{"aria-hidden":!0})})]}),children:(0,X.jsx)(`ol`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:a.map((e,t)=>(0,X.jsxs)(`li`,{className:H(`flex min-w-0 flex-col gap-2 rounded-[var(--miravo-radius-stadium-sm)] border px-3 py-3`,e===c?`border-primary/35 bg-primary/5`:`border-border/55`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`flex size-5 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border font-mono text-[10px] tabular-nums`,e.done?`border-success/40 bg-success/15 text-success`:`border-border text-muted-foreground`),children:e.done?(0,X.jsx)(le,{className:`size-3`}):`0${t+1}`}),(0,X.jsx)(`span`,{className:H(`truncate text-sm font-medium`,e.done&&`text-muted-foreground`),children:e.title}),e.optional&&(0,X.jsx)(`span`,{className:`ml-auto text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:`Optional`})]}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.hint}),e.done?(0,X.jsx)(`span`,{className:`mt-auto font-mono text-[11px] text-success`,children:`Done`}):(0,X.jsx)(`div`,{className:`mt-auto`,children:(0,X.jsx)(Sn,{step:e,primary:e===c})})]},e.id))})})}var wn=[`devices`,`models`,`assets`],Tn=[`assets`,`models`,`devices`],En={devices:`DeviceHub devices`,models:`Digital Twins models`,assets:`Digital Twins instances`},Dn={devices:{apply:`DeviceHub device records and settings on Litmus Edge.`,cleanup:`Remove DeviceHub device records managed from Miravo.`},models:{apply:`Digital Twins model definitions synced to the integration.`,cleanup:`Remove Digital Twins model definitions created by Miravo.`},assets:{apply:`Digital Twins instances bound to DeviceHub devices.`,cleanup:`Remove Digital Twins instances deployed for this target.`}},On=`Miravo calls this API.`,kn={assets:`models`};function An(e,t){let n=new Set(e);if(n.has(t)){n.delete(t);for(let[e,r]of Object.entries(kn))r===t&&n.delete(e)}else{n.add(t);let e=kn[t];e&&n.add(e)}return n}var jn=[{value:`fail`,title:`Fail if unmanaged exists`,hint:`Stop if the target has unmanaged resources.`},{value:`skip`,title:`Skip unmanaged resources`,hint:`Only update resources managed by Miravo.`}];function Mn({open:e,onOpenChange:t,isApply:n,scopeOptions:r,scope:i,onToggleScope:a,ifUnmanaged:o,onIfUnmanagedChange:s}){let c=(0,Y.useId)(),l=`if-unmanaged-${c}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center justify-between gap-2 rounded-[var(--miravo-radius-tight)] bg-muted/40 px-2.5 py-2 text-left text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/55 aria-expanded:text-foreground`,onClick:()=>t(!e),"aria-expanded":e,children:[`Advanced`,(0,X.jsx)(Re,{className:H(`size-3.5 shrink-0 text-muted-foreground transition-transform ease-out group-hover:text-foreground/80`,e?`duration-500 rotate-180 text-foreground/80`:`duration-280`),"aria-hidden":!0})]}),(0,X.jsxs)(T.div,{initial:!1,animate:{maxHeight:e?520:0,opacity:+!!e},transition:{maxHeight:{duration:e?.52:.28,ease:e?[.16,1,.3,1]:[.4,0,.2,1]},opacity:{duration:e?.42:.24,ease:e?[.16,1,.3,1]:[.4,0,.2,1]}},className:H(`overflow-hidden`,!e&&`pointer-events-none`),"aria-hidden":!e,inert:!e,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-1 pt-px`,children:r.map(e=>{let t=Object.entries(kn).find(([t,n])=>n===e)?.[0],r=t!==void 0&&i.has(t),o=n?Dn[e].apply:Dn[e].cleanup;return(0,X.jsxs)(yt,{htmlFor:`scope-${e}`,className:H(`flex min-h-9 cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border border-border/40 bg-muted/10 px-2.5 py-1.5 text-[11px] transition-colors`,r?`opacity-95`:`hover:bg-muted/25`),children:[(0,X.jsx)(`span`,{className:`pt-0.5`,children:(0,X.jsx)(Ht,{id:`scope-${e}`,checked:i.has(e),disabled:r,onCheckedChange:()=>a(e)})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 leading-snug`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:En[e]}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[11px] font-normal leading-tight text-muted-foreground`,children:o})]}),r?(0,X.jsx)(`span`,{className:`shrink-0 self-start rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-primary/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-primary`,title:`Required when Digital Twins instances are selected (models must stay in scope).`,children:`Required`}):null]},e)})}),n&&(0,X.jsxs)(`div`,{className:`mt-2.5 space-y-1.5 border-t border-border/40 pt-2`,children:[(0,X.jsx)(`p`,{id:`${c}-legend`,className:`text-[11px] font-medium uppercase tracking-wide text-foreground/80`,children:`Collision policy`}),(0,X.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-legend`,className:`flex flex-col gap-1`,children:jn.map(e=>(0,X.jsxs)(yt,{htmlFor:`if-unmanaged-${e.value}`,className:H(`flex cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-[11px] transition-colors`,o===e.value?`border-primary/45 bg-primary/8`:`border-border/40 bg-muted/10 hover:bg-muted/25`),children:[(0,X.jsx)(`input`,{id:`if-unmanaged-${e.value}`,type:`radio`,name:l,value:e.value,checked:o===e.value,onChange:()=>s(e.value),className:`mt-0.5 size-3.5 shrink-0 accent-primary`}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`mt-px block text-[11px] leading-tight text-foreground/74`,children:e.hint})]})]},e.value))})]})]})]})}function Nn({label:e,help:t,mono:n=!1,children:r}){return(0,X.jsxs)(`div`,{className:`grid grid-cols-2 items-start gap-x-4 border-b border-border/35 py-2.5 first:pt-0`,children:[t?(0,X.jsx)(`dt`,{className:`min-w-0 pt-px`,children:(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium leading-snug text-muted-foreground`,children:e}),(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{type:`button`,className:`inline-flex size-5 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`About ${e}`,children:(0,X.jsx)(qe,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(G,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:t})]})]})}):(0,X.jsx)(`dt`,{className:`min-w-0 pt-px text-[11px] font-medium text-muted-foreground`,children:e}),n?(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[11px] leading-normal text-foreground/90`,children:r}):(0,X.jsx)(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground`,children:r})]})}function Pn({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId,protocol:t.protocol},scope:n.scope,ifUnmanaged:n.ifUnmanaged,exposedPorts:n.exposedPorts}}function Fn({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId},scope:n.scope}}var In=/^\(?unchanged\)?$/i,Ln=/^device=(\S+)/;function Rn(e){let t=e.blockReason??e.detail;if(!(!t||In.test(t)))return t.replace(/^\((.*)\)$/,`$1`)}function zn(e){let t=new Map;for(let n of e)n.resourceType===`param-sync`&&t.set(n.name,n);let n=[],r=new Set;for(let i of e){if(i.resourceType===`param-sync`)continue;let e=i.resourceType===`asset`?t.get(i.name):void 0;e&&r.add(i.name);let a=e!==void 0&&i.action===`noop`&&e.action!==`noop`;n.push({action:a?e.action:i.action,resourceType:i.resourceType,name:i.name,protocol:i.protocol,note:a?`device binding changes`:Rn(i),boundDevice:e?.detail?.match(Ln)?.[1]})}for(let[e,i]of t)r.has(e)||n.push({action:i.action,resourceType:`asset`,name:e,note:Rn(i),boundDevice:i.detail?.match(Ln)?.[1]});return n}function Bn(e){let t=new Map;for(let n of e){let e=t.get(n.action);e?e.push(n):t.set(n.action,[n])}return t}function Vn(e){return zn(e).filter(e=>e.action!==`noop`&&e.action!==`blocked`).length}var Hn={create:{label:`Create`,phrase:`to create`,dot:`bg-success`,text:`text-success`},update:{label:`Update`,phrase:`to update`,dot:`bg-info`,text:`text-info`},replace:{label:`Replace`,phrase:`to replace`,dot:`bg-chart-2`,text:`text-chart-2`},delete:{label:`Remove`,phrase:`to remove`,dot:`bg-destructive`,text:`text-destructive`},blocked:{label:`Skipped`,phrase:`skipped`,dot:`bg-warning`,text:`text-warning`},noop:{label:`Unchanged`,phrase:`unchanged`,dot:`bg-muted-foreground/40`,text:`text-muted-foreground`}},Un=[`create`,`update`,`replace`,`delete`,`noop`],Wn=[`create`,`update`,`replace`,`delete`],Gn=6,Kn={device:[`device`,`devices`],model:[`twin model`,`twin models`],asset:[`twin instance`,`twin instances`]};function qn(e,[t,n]){return`${e} ${e===1?t:n}`}function Jn(e){let t=new Map;for(let n of e){let e=t.get(n.resourceType);e?e.push(n):t.set(n.resourceType,[n])}return[...t]}function Yn(e){return Jn(e).map(([e,t])=>qn(t.length,Kn[e])).join(` · `)}function Xn(e){return`${e.action}-${e.resourceType}-${e.name}-${e.protocol??``}`}function Zn(e){return e.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)}function Qn({groups:e}){return(0,X.jsx)(`div`,{"aria-hidden":!0,className:`flex h-1.5 w-full gap-0.5 overflow-hidden rounded-full`,children:[`blocked`,...Un].map(t=>{let n=e.get(t)?.length??0;return n>0?(0,X.jsx)(`span`,{className:H(`h-full rounded-full`,Hn[t].dot),style:{flexGrow:n}},t):null})})}function $n({entry:e}){let{note:t}=e;return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 py-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11.5px] text-foreground`,title:e.name,children:e.name}),e.protocol?(0,X.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] border border-border/60 px-1 font-mono text-[9.5px] uppercase text-muted-foreground`,children:e.protocol}):null,e.boundDevice?(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[10.5px] text-muted-foreground`,title:`Device this twin instance reads from`,children:[`→ `,e.boundDevice]}):null,t?(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted-foreground`,title:t,children:t}):null]})}function er({action:e,entries:t,open:n,onToggle:r}){let i=Hn[e];return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`group flex w-full min-w-0 items-center gap-3 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-2 shrink-0 rounded-full`,i.dot)}),(0,X.jsx)(`span`,{className:H(`w-20 shrink-0 text-sm font-medium`,e===`noop`?`text-muted-foreground`:`text-foreground`),children:i.label}),(0,X.jsx)(`span`,{className:H(`w-8 shrink-0 font-mono text-sm tabular-nums`,i.text),children:t.length}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:Yn(t)}),(0,X.jsx)(ze,{"aria-hidden":!0,className:H(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200`,n&&`rotate-90`)})]}),n?(0,X.jsx)(`div`,{className:`mb-2 ml-[1.1rem] flex flex-col gap-2 border-l border-border/60 pt-1 pl-[1.9rem]`,children:Jn(t).map(([e,t])=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:Kn[e][1]}),(0,X.jsx)(`ul`,{children:t.map(e=>(0,X.jsx)($n,{entry:e},Xn(e)))})]},e))}):null]})}function tr({entries:e}){return(0,X.jsxs)(`div`,{role:`note`,className:`rounded-[var(--miravo-radius-tight)] border border-warning/30 bg-warning/8 px-3 py-2.5`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,X.jsx)(ht,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),e.length,` `,e.length===1?`resource is`:`resources are`,` skipped`]}),(0,X.jsx)(`ul`,{className:`mt-1 pl-5.5`,children:e.map(e=>(0,X.jsx)($n,{entry:e},Xn(e)))})]})}function nr({groups:e,planKind:t}){let n=Wn.filter(t=>(e.get(t)?.length??0)>0);return n.length===0?(0,X.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:t===`cleanup`?`Nothing to remove`:`Nothing to change`}):(0,X.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:n.map((t,n)=>(0,X.jsxs)(Y.Fragment,{children:[n>0?(0,X.jsx)(`span`,{className:`mx-1.5 font-normal text-muted-foreground/60`,children:`·`}):null,(0,X.jsx)(`span`,{className:H(`font-mono tabular-nums`,Hn[t].text),children:e.get(t)?.length}),` `,(0,X.jsx)(`span`,{className:`font-normal text-foreground/90`,children:Hn[t].phrase})]},t))})}function rr({plan:e,planKind:t=`apply`}){let n=zn(e.entries),r=Bn(n),i=Wn.reduce((e,t)=>e+(r.get(t)?.length??0),0),[a,o]=(0,Y.useState)(()=>new Set(i<=Gn?Wn:[])),s=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=r.get(`blocked`)??[],l=r.get(`noop`)?.length??0;return(0,X.jsxs)(`section`,{"aria-label":`Dry run`,className:`flex flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 p-4`,children:[(0,X.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:[t===`cleanup`?`Expected removals`:`Expected changes`,(0,X.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/80`,children:`dry run · nothing runs until you confirm`})]}),(0,X.jsx)(nr,{groups:r,planKind:t}),(0,X.jsxs)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:[l>0?`${l} already in place · `:``,Zn(e.scope)]})]})}),n.length>0?(0,X.jsx)(Qn,{groups:r}):null,c.length>0?(0,X.jsx)(tr,{entries:c}):null,n.length>0?(0,X.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:Un.map(e=>{let t=r.get(e);return t?(0,X.jsx)(er,{action:e,entries:t,open:a.has(e),onToggle:()=>s(e)},e):null})}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t===`cleanup`?`No Miravo-managed resources matched this scope on the target.`:`The target already matches this template.`})]})}var ir=[`a`,`b`,`c`];function ar(){return(0,X.jsxs)(`div`,{role:`status`,"aria-busy":!0,"aria-label":`Loading dry run`,className:`flex flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 p-4`,children:[(0,X.jsx)(Z,{className:`h-2.5 w-28`}),(0,X.jsx)(Z,{className:`h-5 w-56`}),(0,X.jsx)(Z,{className:`h-3 w-40`}),(0,X.jsx)(Z,{className:`h-1.5 w-full rounded-full`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-1`,children:ir.map(e=>(0,X.jsx)(Z,{className:`h-7 w-full`},e))})]})}var or={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`},sr=pt.map(e=>({value:e,label:or[e]}));function cr({open:e,onOpenChange:t,action:n,subject:r,label:i,target:a,stream:o}){let s=n===`apply`,c=s?wn:Tn,[l,d]=(0,Y.useState)(new Set(c)),[f,p]=(0,Y.useState)(`fail`),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(Object.keys(a.exposedPorts??{}).length>0),[y,b]=(0,Y.useState)(ct(a.exposedPorts)),[x,ee]=(0,Y.useState)(r.kind===`asset`?r.protocol:pt[0]??`modbus`),S=r.kind===`asset`?{kind:`asset`,assetId:r.assetId,protocol:x}:r,C=r.kind===`asset`?[x]:pt,w=s?ut(a.exposedPorts,y,C):{},T=c.filter(e=>l.has(e)),E=T.length>0&&w!==null,D={scope:T,ifUnmanaged:f,...s&&w?{exposedPorts:w}:{}},O=Pn({targetId:a.id,subject:S,result:D}),k=Fn({targetId:a.id,subject:S,result:D}),A=v({queryKey:u.integrations.plan(n,JSON.stringify(s?O:k)),queryFn:({signal:e})=>s?Ue(O,{signal:e}):Je(k,{signal:e}),enabled:e&&E,retry:!1,gcTime:0}),j=o.status===`running`,te=()=>{E&&(o.operation&&o.status!==`running`&&o.reset(),s?o.startApply(O):o.startCleanup(k),t(!1))},M=A.data?.plan,N=M?Vn(M.entries):null,P;P=s?N===null?`Apply`:N===0?`Re-apply anyway`:`Apply ${N} ${N===1?`change`:`changes`}`:N?`Clean up ${N} ${N===1?`resource`:`resources`}`:`Clean up`;let F=A.error?[bt(A.error,`Plan failed`),xt(A.error)].filter(Boolean).join(`. `):null;return(0,X.jsx)(oe,{open:e,onOpenChange:t,children:(0,X.jsxs)(re,{showCloseButton:!0,className:`flex max-h-[90vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-3xl`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,X.jsxs)(ie,{className:`flex items-center gap-2 text-sm font-semibold leading-snug`,children:[s?(0,X.jsx)(st,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(mt,{className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),s?`Apply`:`Clean up`,` `,i,` `,s?`to`:`from`,` `,a.label]}),(0,X.jsxs)(ae,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[a.hostname,s?(0,X.jsx)(`span`,{className:`font-sans`,children:` · reaches Miravo at `}):null,s?a.sourceHostname:null]})]}),(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-4 pb-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[s&&r.kind===`asset`?(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Protocol`}),(0,X.jsxs)(Ft,{value:x,onValueChange:e=>e&&ee(e),items:sr,children:[(0,X.jsx)(Pt,{size:`sm`,className:`w-32`,"aria-label":`Protocol`,children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Nt,{alignItemWithTrigger:!1,align:`start`,children:sr.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]})]}):null,E?F?(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-xs`,children:[(0,X.jsxs)(`p`,{className:`text-destructive`,children:[`Dry run failed: `,F]}),(0,X.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void A.refetch(),children:`Retry dry run`})]}):M?(0,X.jsx)(rr,{plan:M,planKind:n}):(0,X.jsx)(ar,{}):(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:T.length===0?`Select at least one scope under Advanced.`:`Fix the invalid host port under Advanced.`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(Mn,{open:m,onOpenChange:h,isApply:s,scopeOptions:c,scope:l,onToggleScope:e=>d(t=>An(t,e)),ifUnmanaged:f,onIfUnmanagedChange:p}),m?(0,X.jsxs)(`dl`,{className:`flex flex-col gap-0 text-xs leading-snug`,children:[(0,X.jsx)(Nn,{label:`Litmus Edge API`,help:On,mono:!0,children:a.hostname}),(0,X.jsx)(Nn,{label:Qe,help:et,mono:!0,children:a.sourceHostname}),s?(0,X.jsx)(`div`,{className:`border-b border-border/35 py-2.5`,children:(0,X.jsx)(dt,{open:g,onOpenChange:_,protocols:C,values:y,onChange:b,hint:`Enter the host port Litmus Edge should dial. Leave blank to use Miravo's own port. Saved for this target.`})}):null]}):null]})]})}),(0,X.jsxs)(ne,{className:`mx-0 mb-0 shrink-0 flex flex-col gap-2 border-t border-border/60 px-5 py-4 sm:flex-row sm:justify-end`,children:[(0,X.jsx)(L,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsxs)(L,{type:`button`,variant:s?`default`:`destructive`,onClick:te,disabled:!E||j,children:[s?(0,X.jsx)(st,{className:`size-3`,"aria-hidden":!0}):(0,X.jsx)(mt,{className:`size-3`,"aria-hidden":!0}),P]})]})]})})}function lr(e,t,n){let r=new Set,i=[];for(let a of e){if(a.targetId!==t||a.factoryName!==n)continue;let e=a.templateId===void 0?`asset`:`template`,o=a.templateId??a.assetId;if(o===void 0)continue;let s=`${e}:${o}`;r.has(s)||(r.add(s),a.operationType===`apply`?a.status===`success`||a.status===`partial`||a.status===`noop`?i.push({subjectId:o,kind:e,completedAt:a.completedAt}):r.delete(s):a.status!==`success`&&a.status!==`noop`&&r.delete(s))}return i}var ur=5,dr=`grid min-h-11 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2 @lg/deploy:grid-cols-[minmax(0,1fr)_minmax(9rem,auto)_6.5rem]`;function fr(e){return e.kind===`template`?e.templateId:e.assetId}function pr({row:e}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[e.subject.kind===`template`?(0,X.jsx)(Le,{id:e.subject.templateId,className:`size-3.5 shrink-0 text-primary`}):(0,X.jsx)(rn,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.label}),e.detail?(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.detail}):null]})]})}function mr({cell:e,running:t}){if(t)return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-primary`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-primary`}),`Running…`]});if(!e||e.status===`none`)return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full border border-muted-foreground/60`}),`Not applied`]});let n=e.status===`applied`;return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs`,title:e.error??void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 shrink-0 rounded-full`,n?`bg-success`:`bg-destructive`)}),(0,X.jsx)(`span`,{className:n?`text-foreground`:`text-destructive`,children:n?`Applied`:e.operationType===`cleanup`?`Clean up failed`:`Failed`}),(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:_e(e.completedAt)})]})}function hr({row:e,target:t,cell:n,running:r,disabled:i,indent:a,onAction:o}){let s=`${e.label} on ${t.label}`,c=n?.status===`applied`||n?.status===`failed`;return(0,X.jsxs)(`li`,{className:H(dr,`transition-colors hover:bg-muted/20`,a&&`pl-9`),children:[(0,X.jsx)(pr,{row:e}),(0,X.jsxs)(`div`,{className:`col-start-1 row-start-2 @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,X.jsx)(mr,{cell:n,running:r}),n?.status===`failed`&&n.error?(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-[11px] text-destructive/80`,children:n.error}):null]}),(0,X.jsxs)(`div`,{className:`col-start-2 row-span-2 row-start-1 flex items-center justify-end gap-1 @lg/deploy:col-start-auto @lg/deploy:row-span-1 @lg/deploy:row-start-auto`,children:[n?.status===`applied`?null:(0,X.jsx)(L,{size:`xs`,variant:`outline`,disabled:i,"aria-label":`${n?.status===`failed`?`Retry`:`Apply`} ${s}`,className:St,onClick:()=>o(`apply`),children:n?.status===`failed`?`Retry`:`Apply`}),c?(0,X.jsxs)(Oe,{children:[(0,X.jsx)(Ne,{render:(0,X.jsx)(L,{size:`icon-xs`,variant:`ghost`,disabled:i,"aria-label":`More actions for ${s}`,className:`text-muted-foreground hover:text-foreground`}),children:(0,X.jsx)(an,{"aria-hidden":!0})}),(0,X.jsxs)(Ee,{align:`end`,className:`min-w-40`,children:[(0,X.jsxs)(je,{className:`gap-2 text-xs`,onClick:()=>o(`apply`),children:[(0,X.jsx)(un,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Re-apply`]}),(0,X.jsxs)(je,{variant:`destructive`,className:`gap-2 text-xs`,onClick:()=>o(`cleanup`),children:[(0,X.jsx)(mt,{className:`size-3.5`,"aria-hidden":!0}),`Clean up`]})]})]}):null]})]})}function gr({target:e,running:t,disabled:n,onCleanup:r}){let i=l(e=>e.factoryName),a=lr(v({queryKey:u.integrations.operationsForTarget(e.id),queryFn:()=>We(e.id)}).data??[],e.id,i).filter(e=>!t.has(e.subjectId));return a.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`li`,{className:`bg-muted/20 px-4 pt-2.5 pb-1.5`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:`No longer running`}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:[`Still on `,e.label,` from an earlier apply. Clean up removes what Miravo created.`]})]}),a.map(t=>{let i=t.kind===`template`?{subject:{kind:`template`,templateId:t.subjectId},label:t.subjectId}:{subject:{kind:`asset`,assetId:t.subjectId,protocol:`modbus`},label:t.subjectId};return(0,X.jsxs)(`li`,{className:H(dr,`bg-muted/20`),children:[(0,X.jsx)(pr,{row:i}),(0,X.jsxs)(`span`,{className:`col-start-1 row-start-2 inline-flex items-center gap-1.5 text-xs text-muted-foreground @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-muted-foreground/60`}),`Applied`,(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:_e(t.completedAt)})]}),(0,X.jsx)(`div`,{className:`col-start-2 row-span-2 row-start-1 flex justify-end @lg/deploy:col-start-auto @lg/deploy:row-span-1 @lg/deploy:row-start-auto`,children:(0,X.jsxs)(L,{size:`xs`,variant:`ghost`,disabled:n,"aria-label":`Clean up ${t.subjectId} on ${e.label}`,className:`text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>r(i),children:[(0,X.jsx)(mt,{className:`size-3`,"aria-hidden":!0}),`Clean up`]})})]},`${t.kind}:${t.subjectId}`)})]})}function _r(e,t){return t>0?`fault`:e>0?`live`:`off`}function vr({target:e,templates:t,assets:n,running:r,cells:i,stream:a,onAction:o}){let[s,c]=(0,Y.useState)(!1),{applied:l,failed:u}=vn(i,e.id),d=a.status===`running`,f=t=>i.get(hn(t.subject,e.id)),p=n.length>ur,m=n.filter(e=>f(e)?.status===`applied`).length,h=(t,n=!1)=>{let r=a.operation,i=d&&r?.label===fr(t.subject)&&(r.targetLabel===e.label||r.targetLabel===e.id);return(0,X.jsx)(hr,{row:t,target:e,cell:f(t),running:i,disabled:d,indent:n,onAction:n=>o(t,e,n)},`${t.subject.kind}:${t.label}`)};return(0,X.jsx)(se,{icon:Te,title:e.label,description:(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.hostname}),aside:(0,X.jsxs)(F,{tone:_r(l,u),children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:l}),(0,X.jsx)(N,{children:`applied`}),u>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mx-1.5 text-muted-foreground/60`,children:`·`}),(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:u}),(0,X.jsx)(N,{children:`failed`})]}):null]}),className:`@container/deploy`,bodyClassName:`p-0`,children:(0,X.jsxs)(`ul`,{className:`divide-y divide-border/50 py-1`,children:[t.length===0&&n.length===0?(0,X.jsx)(`li`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`Nothing is running. Load a template to send it to Litmus Edge.`}):null,t.map(e=>h(e)),p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`li`,{className:dr,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,className:`flex min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(ze,{className:H(`size-3.5 shrink-0 text-muted-foreground transition-transform`,s&&`rotate-90`),"aria-hidden":!0}),`Standalone assets`,(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:n.length})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m>0?`${m} applied`:`Not applied`})]}),s?n.map(e=>h(e,!0)):null]}):n.map(e=>h(e)),(0,X.jsx)(gr,{target:e,running:r,disabled:d,onCleanup:t=>o(t,e,`cleanup`)})]})})}function yr({targets:e,cells:t,stream:n}){let{templates:r,assets:i}=l(I(e=>({templates:e.templates,assets:e.assets}))),[a,o]=(0,Y.useState)(null);if(e.length===0)return(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(Te,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`No Litmus Edge target yet`]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add a device with its hostname and an API token. Then apply templates and assets to it from here.`}),(0,X.jsxs)(j,{to:`/integrations`,className:B({size:`sm`}),children:[(0,X.jsx)(at,{className:`size-3.5`,"aria-hidden":!0}),`Add target`]})]});let s=new Set(r.flatMap(e=>e.assetIds)),c=r.map(e=>({subject:{kind:`template`,templateId:e.templateId},label:e.templateName,detail:e.templateId})),u=i.filter(e=>!s.has(e.id)).map(e=>({subject:{kind:`asset`,assetId:e.id,protocol:`modbus`},label:e.id})),d=new Set([...r.map(e=>e.templateId),...i.map(e=>e.id)]);return(0,X.jsxs)(`section`,{"aria-label":`Deployments`,className:H(`grid items-start gap-4`,e.length>1&&`@5xl/main:grid-cols-2`),children:[e.map(e=>(0,X.jsx)(vr,{target:e,templates:c,assets:u,running:d,cells:t,stream:n,onAction:(e,t,n)=>o({row:e,target:t,action:n})},e.id)),a?(0,X.jsx)(cr,{open:!0,onOpenChange:e=>!e&&o(null),action:a.action,subject:a.row.subject,label:a.row.label,target:a.target,stream:n}):null]})}var br={status:`idle`,operation:null,error:null,logs:[],cancelRequested:!1},xr=200;function Sr(){let[e,t]=(0,Y.useState)(br),n=(0,Y.useRef)(null),r=(0,Y.useRef)(0),i=_(),a=(0,Y.useRef)(0),o=(0,Y.useCallback)(e=>{let n=bt(e,`Integration operation failed.`),r=xt(e),i=r?`${n} ${r}`:n;t(e=>({...e,status:`error`,cancelRequested:!1,error:i,operation:e.operation?{...e.operation,status:`error`,error:i}:null}))},[]),s=(0,Y.useCallback)(e=>{switch(e.event){case`accepted`:Cr(e.data,t);break;case`log`:Tr({...e.data,id:`log-${r.current++}`},t);break;case`started`:Er(e.data,t);break;case`phase`:Dr(e.data,t);break;case`resource`:Or(e.data,t);break;case`complete`:kr(e.data,t);break;case`cancelled`:jr(e.data,t);break;case`retrying`:Mr(e.data,t);break;case`error`:o(Error(e.data.message));break}},[o]),c=(0,Y.useCallback)(e=>{let c=++a.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=Ge(e,e=>{a.current===c&&(s(e),Pr(e)&&(i.invalidateQueries({queryKey:u.integrations.targets()}),i.invalidateQueries({queryKey:u.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,o(e))})},[s,o,i]),l=(0,Y.useCallback)(e=>{let c=++a.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=Xe(e,e=>{a.current===c&&(s(e),Pr(e)&&(i.invalidateQueries({queryKey:u.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,o(e))})},[s,o,i]),d=(0,Y.useCallback)(()=>{a.current++,n.current?.abort(),n.current=null,t(br)},[]),f=(0,Y.useCallback)(async()=>{let n=e.operation?.operationId;if(!(!n||e.status!==`running`||e.cancelRequested)){t(e=>Ar(e,n));try{await Ye(n)||o(Error(`Operation finished before cancellation was accepted.`))}catch(e){o(e instanceof Error?e:Error(`Cancellation failed.`))}}},[e.operation?.operationId,e.status,e.cancelRequested,o]);return(0,Y.useEffect)(()=>()=>{a.current++,n.current?.abort(),n.current=null},[]),{...e,startApply:c,startCleanup:l,reset:d,cancel:f}}function Cr(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:e.templateId??e.assetId??(e.type===`apply`?`Preparing apply`:`Preparing cleanup`),targetLabel:e.targetId??`Resolving target`,totalPlanned:0,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now()}}))}function wr(e){return e.templateId??e.assetId??`unknown`}function Tr(e,t){t(t=>({...t,logs:[...t.logs,e].slice(-xr)}))}function Er(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:wr(e),targetLabel:e.targetLabel,totalPlanned:e.totalPlanned,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now(),attempt:e.attempt,maxAttempts:e.maxAttempts}}))}function Dr(e,t){t(t=>{if(!Nr(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e),r=n.findIndex(t=>t.name===e.phase),i=r>=0?n.map((t,n)=>n===r?{...t,status:`active`,total:e.total}:t):[...n,{name:e.phase,total:e.total,resources:[],status:`active`}];return{...t,operation:{...t.operation,phases:i}}})}function Or(e,t){t(t=>{if(!Nr(t,e.operationId))return t;let n={name:e.name,action:e.action,status:e.status,error:e.error},r=t.operation.phases.map(t=>t.name===e.phase&&t.status===`active`?{...t,resources:[...t.resources,n]}:t);return{...t,operation:{...t.operation,phases:r,applied:t.operation.applied+ +(e.status===`success`&&e.action!==`noop`),failed:t.operation.failed+ +(e.status===`failed`)}}})}function kr(e,t){t(t=>{if(!Nr(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...t,status:`complete`,cancelRequested:!1,error:null,operation:{...t.operation,phases:n,applied:e.applied??e.deleted??0,failed:e.failed,duration:e.duration,status:`complete`}}})}function Ar(e,t){return!Nr(e,t)||e.status!==`running`?e:{...e,cancelRequested:!0}}function jr(e,t){t(t=>{if(!Nr(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...t,status:`complete`,cancelRequested:!1,error:null,operation:{...t.operation,phases:n,applied:e.applied??e.deleted??0,failed:e.failed,duration:e.duration,status:`cancelled`}}})}function Mr(e,t){t(t=>Nr(t,e.operationId)?{...t,status:`running`,cancelRequested:!1,error:null,operation:{...t.operation,status:`running`,retryPending:!0,retryDelayMs:e.delayMs,attempt:e.attempt,maxAttempts:e.maxAttempts,error:e.error,applied:0,failed:0,phases:[]}}:t)}function Nr(e,t){return e.operation?.operationId===t}function Pr(e){return e.event===`complete`||e.event===`cancelled`||e.event===`error`}var Fr={initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,originY:0},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:350,damping:40}},Ir={initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{type:`tween`,duration:.22,ease:[.16,1,.3,1]}};function Lr({children:e,variant:t=`default`}){let n=t===`default`;return(0,X.jsx)(T.div,{...n?Fr:Ir,layout:n,className:`mx-auto w-full`,children:e})}var Rr=Y.memo(({children:e,className:t,delay:n=1e3,...r})=>{let[i,a]=(0,Y.useState)(0),o=(0,Y.useMemo)(()=>Y.Children.toArray(e),[e]);(0,Y.useEffect)(()=>{let e=null;return i<o.length-1&&(e=setTimeout(()=>{a(e=>(e+1)%o.length)},n)),()=>{e!==null&&clearTimeout(e)}},[i,n,o.length]);let s=(0,Y.useMemo)(()=>o.slice(0,i+1).reverse(),[i,o]);return(0,X.jsx)(`div`,{className:H(`flex flex-col items-center gap-4`,t),...r,children:(0,X.jsx)(D,{children:s.map(e=>(0,X.jsx)(Lr,{children:e},e.key))})})});Rr.displayName=`AnimatedList`;function zr({type:e,errorMessage:t,className:n}){return null}var Br=`text-destructive hover:bg-destructive/25 hover:text-foreground`,Vr={device:`Devices`,tags:`Tags`,model:`Models`,asset:`Assets`,"param-sync":`Parameters`};function Hr(e){return Vr[e]??e}function Ur(e){switch(e){case`create`:return`border border-success/30 bg-success/15 text-success`;case`update`:return`border border-chart-3/30 bg-chart-3/15 text-chart-3`;case`replace`:return`border border-warning/30 bg-warning/15 text-warning`;case`delete`:return`border border-destructive/30 bg-destructive/15 text-destructive`;case`noop`:return`border border-border/60 bg-muted/70 text-foreground/75`;default:return`border border-border/50 bg-muted/80 text-foreground/85`}}function Wr(e){return e===`noop`?`no-op`:e}function Gr({status:e}){switch(e){case`success`:return(0,X.jsx)(Be,{className:`size-3.5 shrink-0 text-success`});case`failed`:return(0,X.jsx)(Ve,{className:`size-3.5 shrink-0 text-destructive`});case`pending`:return(0,X.jsx)(K,{className:`size-3.5 shrink-0 animate-spin text-primary/90`})}}function Kr({status:e}){switch(e){case`done`:return(0,X.jsx)(Be,{className:`size-3.5 text-success`});case`active`:return(0,X.jsx)(K,{className:`size-3.5 animate-spin text-primary`});case`pending`:return(0,X.jsx)(tn,{className:`size-3.5 text-foreground/55`})}}function qr({entry:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,className:H(`flex items-center gap-2 rounded-[var(--miravo-radius-tight)] px-2 py-1 text-left transition-colors`,e.error?`cursor-pointer hover:bg-muted/40`:`cursor-default`),onClick:()=>e.error&&n(!t),disabled:!e.error,children:[(0,X.jsx)(Gr,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground`,children:e.name}),(0,X.jsx)(`span`,{className:H(`inline-flex rounded-[var(--miravo-radius-tight)] px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,Ur(e.action)),children:Wr(e.action)}),e.error&&(0,X.jsx)(Re,{className:H(`size-3 text-foreground/75 transition-transform`,t&&`rotate-180`)})]}),(0,X.jsx)(D,{initial:!1,children:t&&e.error&&(0,X.jsxs)(T.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.18},className:`overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`mb-0 flex min-w-0 w-full items-center gap-1.5 rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/15 px-2.5 py-1.5 text-[10px] font-medium leading-relaxed`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error}),(0,X.jsx)(Ze,{value:e.error,label:`Copy error`,className:H(Br,`shrink-0`)})]}),(0,X.jsx)(zr,{type:`apply`,errorMessage:e.error,className:`mb-1 mt-2.5 w-full min-w-0`})]})})]})}function Jr({phase:e,open:t,onOpenChange:n}){let r=e.resources.length,i=r===e.total,a=e.resources.length>0;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,className:H(`flex w-full items-center gap-2 rounded-[var(--miravo-radius-tight)] px-1 py-1 text-left transition-colors`,a&&`hover:bg-muted/40`,!a&&`cursor-default`),disabled:!a,"aria-expanded":a?t:void 0,onClick:()=>a&&n(!t),children:[(0,X.jsx)(Kr,{status:e.status}),(0,X.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-foreground`,children:Hr(e.name)}),(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-foreground/70`,children:[r,`/`,e.total]}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[i&&e.status===`done`&&(0,X.jsx)(Be,{className:`size-3 text-success`}),a&&(0,X.jsx)(Re,{className:H(`size-3 text-foreground/75 transition-transform`,!t&&`-rotate-90`),"aria-hidden":!0})]})]}),(0,X.jsx)(D,{initial:!1,children:a&&t&&(0,X.jsx)(T.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,X.jsx)(`div`,{className:`ml-2 flex min-w-0 flex-col border-l border-border/55 pl-2.5 pr-1.5 pb-1 pt-0.5`,children:(0,X.jsx)(w.Provider,{value:null,children:e.resources.map((e,t)=>(0,X.jsx)(Lr,{variant:`subtle`,children:(0,X.jsx)(qr,{entry:e})},`${e.name}-${t}`))})})})})]})}function Yr({operation:e}){let t=e.status===`complete`,n=e.status===`cancelled`,r=e.failed>0,i=e.totalPlanned>0?Math.min(100,Zr(e)/e.totalPlanned*100):0;return(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,role:`progressbar`,"aria-valuenow":Math.round(i),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Operation progress`,children:(0,X.jsx)(T.div,{"aria-hidden":`true`,className:H(`h-full rounded-full transition-colors duration-500`,n?`bg-foreground/30`:t&&!r?`bg-success`:`bg-warning`),initial:{width:`0%`},animate:{width:`${i}%`},transition:{duration:.4,ease:[.25,.1,.25,1]}})})}function Xr(e){return e.duration==null?(Date.now()-e.startedAt)/1e3:e.duration/1e3}function Zr(e){let t=e.applied+e.failed;return e.totalPlanned>0?Math.min(t,e.totalPlanned):t}var Qr={complete:{Icon:Be,className:`size-4 text-success`},partial:{Icon:en,className:`size-4 text-warning`},cancelled:{Icon:Xt,className:`size-4 text-foreground/65`},error:{Icon:Ve,className:`size-4 text-destructive`},running:{Icon:K,className:`size-4 animate-spin text-warning`}};function $r({icon:e,className:t}){return(0,X.jsx)(T.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},className:`shrink-0`,children:(0,X.jsx)(e,{className:t})})}function ei({operation:e,sourceLabel:t,isAllExpanded:n,onToggleAll:r}){let i=Xr(e),a=Zr(e),o=e.status===`complete`,s=e.status===`cancelled`,c=e.status===`error`,l=e.failed>0,u=o&&!l?`complete`:o&&l?`partial`:s?`cancelled`:c?`error`:`running`,d=Qr[u];return(0,X.jsxs)(`div`,{className:H(`sticky top-0 z-10 flex min-w-0 w-full flex-col gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border px-3 pt-2.5 pb-3.5 backdrop-blur-sm transition-colors duration-500`,o&&!l&&`border-success/30 bg-success/5`,o&&l&&`border-warning/30 bg-warning/5`,s&&`border-border/60 bg-muted/50`,c&&`border-destructive/30 bg-destructive/5`,!o&&!s&&!c&&`border-warning/20 bg-warning/5`),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(D,{mode:`wait`,initial:!1,children:(0,X.jsx)($r,{icon:d.Icon,className:d.className},u)}),(0,X.jsx)(`span`,{className:`text-xs font-medium leading-none text-foreground`,children:s?`Cancelled`:o?l?`Completed with errors`:`Complete`:c?`Failed`:e.retryPending?`Failed, retrying attempt ${e.attempt?e.attempt+1:2}/${e.maxAttempts} in ${e.retryDelayMs?e.retryDelayMs/1e3:3}s...`:e.attempt&&e.maxAttempts&&e.attempt>1?`Retrying attempt ${e.attempt}/${e.maxAttempts}...`:e.type===`apply`?`Applying...`:`Cleaning up...`}),(0,X.jsxs)(`span`,{className:`w-full min-w-0 text-[10px] leading-tight text-foreground/78`,children:[(0,X.jsx)(`span`,{className:`font-sans break-words`,children:t}),(0,X.jsx)(`span`,{className:`font-mono break-words`,children:` → ${e.targetLabel}`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(E,{variant:`secondary`,className:`h-5 min-h-5 gap-0 overflow-hidden border border-border/50 bg-muted/70 px-1.5 !py-0 font-mono text-[10px] leading-none text-foreground shadow-sm [&>span]:inline-flex [&>span]:items-center`,children:(0,X.jsxs)(`span`,{className:`gap-1`,children:[(0,X.jsx)(D,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(T.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`inline tabular-nums`,children:a},a)}),`/`,e.totalPlanned,(0,X.jsx)(`span`,{className:`text-foreground/72`,children:e.type===`apply`?`applied`:`deleted`})]})}),(0,X.jsx)(D,{initial:!1,children:e.failed>0&&(0,X.jsx)(T.div,{className:`inline-flex items-center`,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:500,damping:30},children:(0,X.jsxs)(E,{variant:`destructive`,className:`h-5 min-h-5 gap-0 border border-destructive/35 bg-destructive/20 px-1.5 !py-0 font-mono text-[10px] font-semibold leading-none text-destructive`,children:[e.failed,` failed`]})})})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] leading-none text-foreground/75`,children:[(0,X.jsx)(nn,{className:`size-3 shrink-0 block text-foreground/65`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`tabular-nums leading-none`,children:typeof i==`number`?`${i.toFixed(1)}s`:`...`})]}),r&&(0,X.jsx)(`div`,{className:`flex items-center border-l border-border/40 pl-2`,children:(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`flex size-4.5 items-center justify-center rounded-[var(--miravo-radius-tight)] text-foreground/55 transition-colors hover:bg-muted/60 hover:text-foreground`,"aria-label":n?`Collapse all phases`:`Expand all phases`,title:n?`Collapse all`:`Expand all`,children:(0,X.jsx)($t,{className:H(`size-3.5 transition-transform duration-300`,!n&&`opacity-70 scale-y-[-1]`)})})})]})]}),(0,X.jsx)(Yr,{operation:e})]})]})}function ti(e){return e?e.closest(`[data-edge-op-scroll]`)??e.closest(`.overflow-y-auto`):null}var ni=350;function ri(e){e?.scrollIntoView({block:`end`,behavior:`auto`,inline:`nearest`})}function ii(e){let t=()=>ri(e);t(),requestAnimationFrame(t),requestAnimationFrame(()=>requestAnimationFrame(t)),window.setTimeout(t,0),window.setTimeout(t,48),window.setTimeout(t,120)}function ai({logs:e}){return e.length===0?null:(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5 px-2 pb-2`,children:e.map(e=>(0,X.jsxs)(`div`,{className:H(`flex min-w-0 items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-xs`,e.level===`error`?`border-destructive/35 bg-destructive/12 text-destructive`:e.level===`warn`?`border-warning/35 bg-warning/12 text-warning`:`border-primary/25 bg-primary/8 text-foreground/82`),children:[e.level===`info`?(0,X.jsx)(Ce,{className:`mt-0.5 size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(en,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:e.message})]},e.id))})}function oi({operation:e,logs:t}){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(!0),a=(0,Y.useRef)(e.status);a.current=e.status;let o=(0,Y.useRef)(!1),[s,c]=(0,Y.useState)(new Set),l=e.label;(0,Y.useLayoutEffect)(()=>{let e=ti(n.current);if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<ni};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,Y.useLayoutEffect)(()=>{if(e.status===`running`){i.current&&ri(r.current),o.current=!0;return}o.current&&=(ii(r.current),!1)},[e.status,e.applied,e.failed,e.phases]),(0,Y.useEffect)(()=>{if(e.status!==`running`)return;let t=n.current;if(!t)return;let o=0,s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{a.current===`running`&&i.current&&ri(r.current)})});return s.observe(t),i.current&&ri(r.current),()=>{s.disconnect(),cancelAnimationFrame(o)}},[e.status]);let u=e.phases.length>0,d=s.size===0;return(0,X.jsxs)(`div`,{ref:n,className:`flex min-w-0 w-full flex-col gap-2`,children:[(0,X.jsx)(ei,{operation:e,sourceLabel:l,isAllExpanded:d,onToggleAll:u?()=>{c(d?new Set(e.phases.map(e=>e.name)):new Set)}:void 0}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1 px-2 pt-2 pb-4`,children:e.phases.map(e=>(0,X.jsx)(`div`,{children:(0,X.jsx)(Jr,{phase:e,open:!s.has(e.name),onOpenChange:t=>{c(n=>{let r=new Set(n);return t?r.delete(e.name):r.add(e.name),r})}})},e.name))}),(0,X.jsx)(D,{initial:!1,children:e.error&&e.retryPending&&(0,X.jsxs)(T.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`sticky bottom-2 z-20 mx-2 mt-auto mb-2 flex items-center gap-2 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-destructive/40 bg-destructive/15 px-3 py-2 text-xs font-medium text-destructive shadow-md backdrop-blur-md`,children:[(0,X.jsx)(K,{className:`size-4 shrink-0 animate-spin`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.error})]})}),(0,X.jsx)(D,{initial:!1,children:e.error&&e.status===`error`&&(0,X.jsxs)(T.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:`auto`,marginTop:8},exit:{opacity:0,height:0,marginTop:0},transition:{duration:.2},className:`mx-2 mb-4 flex min-w-0 flex-col gap-0 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-destructive/40 bg-destructive/15 px-3 py-2 text-xs font-medium`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left wrap-anywhere text-destructive`,children:e.error}),(0,X.jsx)(Ze,{value:e.error,label:`Copy error`,className:H(Br,`shrink-0`)})]}),(0,X.jsx)(zr,{type:e.type,errorMessage:e.error,className:`mt-3 w-full min-w-0`})]})}),t&&t.length>0?(0,X.jsx)(ai,{logs:t}):null,(0,X.jsx)(`div`,{ref:r,className:`h-px w-full shrink-0`,"aria-hidden":!0})]})}function si({title:e,subtitle:t,footerAction:n,canDismiss:r=!0,onDismiss:i,children:a}){return(0,Y.useEffect)(()=>{function e(e){e.key===`Escape`&&r&&i()}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r,i]),(0,X.jsx)(T.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:16},transition:{type:`spring`,stiffness:380,damping:30},className:`pointer-events-none fixed bottom-4 left-4 right-4 z-[60] sm:left-auto sm:w-full sm:max-w-md`,children:(0,X.jsxs)(ft,{className:`pointer-events-auto flex flex-col overflow-hidden border-border/70 bg-background p-0 shadow-lg shadow-black/15 ring-1 ring-border/50 backdrop-blur-sm sm:p-0 bg-background shadow-black/50`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-border/45 p-2.5 pb-2 sm:p-3 sm:pb-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(ot,{className:`size-4 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`font-heading text-xs font-semibold tracking-tight text-foreground`,children:e}),t?(0,X.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/80`,children:t}):null]})]}),r?(0,X.jsx)(L,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0 text-foreground/70 hover:bg-muted/80 hover:text-foreground`,onClick:i,"aria-label":`Dismiss operation panel`,children:(0,X.jsx)(de,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2.5 pt-2.5 sm:px-3 sm:pt-3`,"data-edge-op-scroll":``,children:a}),n?(0,X.jsx)(`div`,{className:`flex w-full shrink-0 min-w-0 items-center gap-2 border-t border-border/40 bg-muted/15 p-2.5 sm:p-3`,children:n}):null]})})}function ci(e){let t=e.operation,n=t?.type===`apply`?`apply`:`cleanup`;switch(e.status){case`running`:return{title:`Operation in progress`,subtitle:`Streaming ${n} steps to Litmus Edge`};case`complete`:return t?.status===`cancelled`?{title:`Operation cancelled`,subtitle:`Stopped — resources created so far remain in Litmus Edge.`}:{title:`Operation complete`,subtitle:n===`apply`?`Apply finished — review the summary below.`:`Cleanup finished — review the summary below.`};case`error`:return{title:`Operation failed`,subtitle:e.error??t?.error??`The operation ended with an error.`};default:return{title:`Operation`,subtitle:``}}}function li({stream:e,onReset:t}){if(!e.operation&&e.status!==`running`)return null;let{title:n,subtitle:r}=ci(e),i=e.status===`complete`,a=e.status===`error`,o=e.status===`running`,s=i||a,c=e.cancelRequested;async function l(){await e.cancel().catch(()=>{})}return(0,X.jsx)(si,{title:n,subtitle:r,canDismiss:!o,footerAction:o&&e.operation?.operationId?(0,X.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:c,"aria-busy":c,className:H(B({variant:`outline`,size:`sm`}),`group h-8 gap-1.5 px-3 text-xs`,c?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),children:c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(T.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(de,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,X.jsx)(T.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):s?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 w-full flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,X.jsxs)(j,{to:`/integrations?tab=activity`,className:H(B({variant:`ghost`,size:`xs`}),`group inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-[11px] font-medium text-foreground/80`,`hover:bg-primary/12 hover:text-primary`),children:[(0,X.jsx)(Se,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,X.jsx)(ze,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,X.jsx)(L,{type:`button`,variant:`secondary`,size:`xs`,className:`h-6 px-2.5 text-[11px] font-medium`,onClick:t,children:`Close`})})]}),e.operation?.status===`cancelled`||a&&e.operation?(0,X.jsx)(zr,{type:e.operation.type,errorMessage:e.operation.error,className:`mt-2.5 w-full min-w-0`}):null]}):void 0,onDismiss:t,children:e.operation?(0,X.jsx)(oi,{operation:e.operation,logs:e.logs}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(K,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,X.jsx)(T.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})})}function ui({targetCount:e,applied:t,failed:n,lastOp:r}){return(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.jsx)(`div`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-background/70 text-primary`,children:(0,X.jsx)(Te,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Litmus Edge`}),(0,X.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-pretty text-xs text-muted-foreground`,children:`Send running templates and assets to Litmus Edge devices: devices, tags and flows. Each change is planned before it runs, and clean up removes only what Miravo created.`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(F,{tone:e>0?`live`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,X.jsx)(N,{children:e===1?`target`:`targets`})]}),(0,X.jsxs)(F,{tone:t>0?`live`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:t}),(0,X.jsx)(N,{children:`applied`})]}),n>0?(0,X.jsxs)(F,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:n}),(0,X.jsx)(N,{children:`failed`})]}):null,r?(0,X.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`last run `,_e(r.completedAt)]}):null,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(j,{to:`/integrations`,className:P+` text-xs text-muted-foreground`,children:[(0,X.jsx)(lt,{className:`size-3`,"aria-hidden":!0}),`Manage targets`]}),(0,X.jsxs)(j,{to:`/integrations?tab=activity`,className:P+` text-xs text-muted-foreground`,children:[(0,X.jsx)(Se,{className:`size-3`,"aria-hidden":!0}),`Activity`]}),(0,X.jsxs)(`a`,{href:`${dn}/integrations/litmus-edge`,target:`_blank`,rel:`noopener noreferrer`,className:P+` text-xs text-muted-foreground`,children:[(0,X.jsx)(Zt,{className:`size-3`,"aria-hidden":!0}),`Docs`]})]})]})}function di(){let e=Sr(),t=v({queryKey:u.integrations.targets(),queryFn:()=>Ke()}),{query:n,cells:r}=yn(),i=t.data,a=n.data?.operations;if(!i||!a){let e=t.error??n.error;return e?(0,X.jsx)(S,{message:bt(e,`Could not load Litmus Edge status.`),onRetry:()=>{t.refetch(),n.refetch()},isRetrying:t.isFetching||n.isFetching}):(0,X.jsx)(Z,{className:`h-64 w-full`})}let{applied:o,failed:s}=vn(r),c=a[0];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(ui,{targetCount:i.length,applied:o,failed:s,lastOp:c}),(0,X.jsx)(yr,{targets:i,cells:r,stream:e}),e.operation||e.status===`running`?(0,X.jsx)(li,{stream:e,onReset:e.reset}):null]})}function fi(){let e=v({queryKey:u.integrations.targets(),queryFn:()=>Ke()}),{cells:t}=yn(),n=e.data?.length??0,{applied:r,failed:i}=vn(t);return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 shrink-0 rounded-full`,i>0?`bg-destructive`:r>0?`bg-success`:`bg-muted-foreground/50`)}),n===0?(0,X.jsx)(`span`,{className:`font-sans`,children:`No target yet`}):(0,X.jsxs)(`span`,{className:`truncate`,children:[n,` `,n===1?`target`:`targets`,` ·`,` `,(0,X.jsx)(`span`,{className:`text-foreground`,children:r}),` applied`,i>0?(0,X.jsxs)(`span`,{className:`text-destructive`,children:[` · `,i,` failed`]}):null]})]})}var pi={"litmus-edge":{icon:Te,Panel:di,Summary:fi}};function mi(){return(0,X.jsxs)(se,{icon:ln,title:`Integrations`,description:`Send this factory to the platforms you build on.`,bodyClassName:`gap-1 px-2 py-2`,footer:(0,X.jsxs)(j,{to:bn(),className:P,children:[`Open integrations`,(0,X.jsx)(we,{className:`size-3`,"aria-hidden":!0})]}),children:[Gt.map(e=>{let{icon:t,Summary:n}=pi[e.id];return(0,X.jsxs)(j,{to:bn(e.id),className:`group flex min-w-0 items-center gap-3 rounded-[var(--miravo-radius-tight)] px-2 py-2 outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(t,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.label}),(0,X.jsx)(n,{})]}),(0,X.jsx)(ze,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]},e.id)}),(0,X.jsxs)(`p`,{className:`px-2 pt-1 pb-0.5 text-[11px] text-muted-foreground`,children:[`Coming soon: `,Ut.map(e=>e.label).join(`, `),`.`]})]})}function hi(e){return d.prefetchQuery({queryKey:u.assets.detail(e),queryFn:()=>c(`/assets/${e}`,i.assetDetail),staleTime:2e3})}var gi=`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function _i(e,t,n,r){let i=n===`asc`?1:-1;return[...e].sort((e,n)=>{switch(t){case`id`:return e.id.localeCompare(n.id)*i;case`template`:return(r.get(e.id)??``).localeCompare(r.get(n.id)??``)*i;case`model`:return e.model.localeCompare(n.model)*i;case`lifecycle`:return e.lifecycleStage.localeCompare(n.lifecycleStage)*i;case`hours`:return(e.operatingHours-n.operatingHours)*i;case`faults`:return(e.activeFaults.length-n.activeFaults.length)*i;case`status`:{let t=e=>e.isQuarantined?2:+(e.activeFaults.length>0);return(t(e)-t(n))*i}default:return 0}})}function vi(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var yi={healthy:{pip:`bg-success`,ring:`border-success/40 text-success`,label:`healthy`,help:`No active faults, not quarantined.`},faulted:{pip:`bg-warning`,ring:`border-warning/40 text-warning`,label:`faulted`,help:`One or more active faults; asset is still running.`},quarantined:{pip:`bg-destructive`,ring:`border-destructive/40 text-destructive`,label:`quarantined`,help:`Asset isolated from production flows pending review.`}};function bi({state:e}){let t=yi[e];return(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{render:(0,X.jsx)(`span`,{className:H(`inline-flex h-5 items-center gap-1.5 rounded-(--miravo-radius-pill) border bg-background/30 px-2 text-[11px] font-medium`,t.ring)}),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,X.jsx)(`span`,{children:pe(t.label)})]}),(0,X.jsx)(G,{side:`top`,children:t.help})]})}function Q({label:e,sortKey:t,subtitle:n,tooltip:r,current:i,direction:a,onSort:o,className:s}){let c=i===t,l=c?a===`asc`?`ascending`:`descending`:`none`,u=(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 whitespace-nowrap rounded-(--miravo-radius-tight) text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onClick:()=>o(t),children:[(0,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,X.jsx)(`span`,{children:e}),n&&(0,X.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,X.jsx)(De,{className:H(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,X.jsx)(zt,{className:s,"aria-sort":l,children:r?(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{render:u}),(0,X.jsx)(G,{side:`top`,children:r})]}):u})}function xi({title:e,body:t,action:n}){return(0,X.jsx)(It,{children:(0,X.jsx)(J,{colSpan:8,className:`py-10`,children:(0,X.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,X.jsxs)(j,{to:n.href,className:`mt-1 inline-flex items-center gap-1 rounded-(--miravo-radius-tight) text-xs font-medium text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,children:[n.label,(0,X.jsx)(we,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Si({assets:e,state:t,templateByAsset:n,sortKey:r,sortDir:i,onSort:a,onOpenAsset:o}){return(0,X.jsx)(Ot,{className:`py-0`,children:(0,X.jsx)(At,{className:`p-0 [&_thead_tr_th:last-child]:w-6 [&_thead_tr_th:last-child]:px-1 sm:[&_thead_tr_th:last-child]:w-8 sm:[&_thead_tr_th:last-child]:px-2 [&_tbody_tr_td:last-child]:px-1 sm:[&_tbody_tr_td:last-child]:px-2`,children:(0,X.jsxs)(Bt,{children:[(0,X.jsx)(Vt,{children:(0,X.jsxs)(It,{children:[(0,X.jsx)(Q,{label:`Asset`,sortKey:`id`,current:r,direction:i,onSort:a}),(0,X.jsx)(Q,{label:`Template`,sortKey:`template`,current:r,direction:i,onSort:a,className:`hidden md:table-cell`}),(0,X.jsx)(Q,{label:`Model`,sortKey:`model`,current:r,direction:i,onSort:a,className:`hidden sm:table-cell`}),(0,X.jsx)(Q,{label:`Lifecycle`,sortKey:`lifecycle`,current:r,direction:i,onSort:a,tooltip:gi}),(0,X.jsx)(Q,{label:`Operating age`,sortKey:`hours`,current:r,direction:i,onSort:a,tooltip:`Cumulative operating hours since the asset started running.`,className:`hidden text-right md:table-cell`}),(0,X.jsx)(Q,{label:`Faults`,sortKey:`faults`,current:r,direction:i,onSort:a,tooltip:`Count of active (uncleared) faults on this asset.`}),(0,X.jsx)(Q,{label:`Status`,sortKey:`status`,current:r,direction:i,onSort:a}),(0,X.jsx)(zt,{children:(0,X.jsx)(`span`,{className:`sr-only`,children:`Navigate to asset`})})]})}),(0,X.jsx)(Lt,{children:t===`connecting`?(0,X.jsx)(xi,{title:`Connecting to runtime`,body:`Live asset data will appear once the connection is up.`}):t===`empty`?(0,X.jsx)(xi,{title:`No running assets`,body:`Start a factory from the Catalog to see assets.`,action:{label:`Open Catalog`,href:`/catalog`}}):e.length===0?(0,X.jsx)(xi,{title:`No matches`,body:`Adjust filters or clear them to see all assets.`}):e.map(e=>{let t=vi(e),r=ye(e.id);return(0,X.jsxs)(It,{tabIndex:0,"aria-label":`Open asset ${r}`,className:H(`group cursor-pointer outline-none transition-colors`,`focus-visible:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset`),onClick:()=>o(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.id))},onMouseEnter:()=>{gt(`/asset/${e.id}`),hi(e.id)},onFocus:()=>{gt(`/asset/${e.id}`),hi(e.id)},children:[(0,X.jsx)(J,{className:`text-sm`,children:(0,X.jsx)(Y.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,X.jsx)(`span`,{className:`inline-flex max-w-full truncate rounded-(--miravo-radius-tight) text-left`,title:e.id,children:r})})}),(0,X.jsx)(J,{className:`hidden text-sm text-muted-foreground md:table-cell`,children:n.get(e.id)??`Standalone`}),(0,X.jsx)(J,{className:`hidden text-sm sm:table-cell`,children:z(e.model)}),(0,X.jsx)(J,{children:(0,X.jsx)(E,{variant:`secondary`,className:`text-xs`,children:he(e.lifecycleStage)})}),(0,X.jsx)(J,{className:`hidden font-mono text-sm md:table-cell`,children:ve(e.operatingHours)}),(0,X.jsx)(J,{children:e.activeFaults.length>0?(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{render:(0,X.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-(--miravo-radius-pill) bg-destructive/15 px-1.5 font-mono text-[11px] font-semibold tabular-nums text-destructive`}),children:e.activeFaults.length}),(0,X.jsxs)(G,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,X.jsx)(J,{children:(0,X.jsx)(bi,{state:t})}),(0,X.jsx)(J,{children:(0,X.jsx)(we,{className:`size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,"aria-hidden":!0})})]},e.id)})})]})})})}var Ci=`~all`,wi=`~standalone`;function Ti(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function Ei(){let{assets:e,templates:t,connectionState:n}=l(I(e=>({assets:e.assets,templates:e.templates,connectionState:e.connectionState}))),[r,i]=O(`q`,k.withDefault(``)),[a,o]=O(`model`,k.withDefault(``)),[s,c]=O(`lifecycle`,k.withDefault(``)),[u,d]=O(`template`,k.withDefault(``)),[f,p]=O(`standalone`,k.withDefault(``)),m=f===`1`,[h,g]=O(`status`,k.withDefault(``)),_=Ti(h)?h:``,[v,y]=(0,Y.useState)(`id`),[b,x]=(0,Y.useState)(`asc`),ee=(0,Y.useRef)(null),S=_t(),[C,w]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),ee.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let T=(0,Y.useCallback)(e=>{e===v?x(e=>e===`asc`?`desc`:`asc`):(y(e),x(`asc`))},[v]),E=(0,Y.useMemo)(()=>{let e=new Map;for(let n of t)for(let t of n.assetIds)e.set(t,n.templateName);return e},[t]),D=(0,Y.useMemo)(()=>[{value:Ci,label:`All templates`},{value:wi,label:`Standalone`},...t.map(e=>({value:e.templateId,label:e.templateName}))],[t]),A=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.model,(t.get(n.model)??0)+1);return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[e]),j=(0,Y.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),te=(0,Y.useMemo)(()=>[{value:`all`,label:`All stages`},...j.map(e=>({value:e,label:he(e)}))],[j]),M=(0,Y.useMemo)(()=>C?A.filter(([e])=>xe(e,C)):A,[A,C]),ne=(0,Y.useMemo)(()=>a?{value:a,label:z(a)}:null,[a]),re=(0,Y.useMemo)(()=>{let n=e;if(m)n=n.filter(e=>!E.has(e.id));else if(u){let e=new Set(t.find(e=>e.templateId===u)?.assetIds);n=n.filter(t=>e.has(t.id))}return a&&(n=n.filter(e=>e.model===a)),s&&(n=n.filter(e=>e.lifecycleStage===s)),r&&(n=n.filter(e=>be(e.id,r)||xe(e.model,r))),_===`faulted`&&(n=n.filter(e=>e.activeFaults.length>0)),_===`quarantined`&&(n=n.filter(e=>e.isQuarantined)),_===`healthy`&&(n=n.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),_i(n,v,b,E)},[e,t,E,u,m,r,_,a,s,v,b]),ie=_!==``||u!==``||m||a!==``||s!==``||r!==``,ae=(0,Y.useCallback)(()=>{i(``),g(``),d(``),p(``),o(``),c(``)},[i,g,d,p,o,c]),oe=(0,Y.useCallback)(e=>{S(`/asset/${e}`,{transitionType:vt})},[S]),N=e.length>0?`rows`:n===`live`?`empty`:`connecting`;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.length>0&&(0,X.jsxs)(Ft,{value:m?wi:u||Ci,onValueChange:e=>{p(e===wi?`1`:``),d(!e||e===Ci||e===wi?``:e)},items:D,children:[(0,X.jsx)(Pt,{className:`h-8 w-44`,"aria-label":`Template filter`,children:(0,X.jsx)(Mt,{placeholder:`All templates`})}),(0,X.jsx)(Nt,{alignItemWithTrigger:!1,align:`start`,children:D.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]}),(0,X.jsxs)(jt,{value:ne,onValueChange:e=>void o(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:w,children:[(0,X.jsx)(kt,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!a}),(0,X.jsx)(Dt,{children:(0,X.jsxs)(Tt,{children:[M.map(([e,t])=>(0,X.jsxs)(Et,{value:{value:e,label:z(e)},children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:z(e)}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),M.length===0&&(0,X.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),j.length>1&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(Ft,{value:s||`all`,onValueChange:e=>void c(!e||e===`all`?``:e),items:te,children:[(0,X.jsx)(Pt,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,X.jsx)(Mt,{placeholder:`All stages`})}),(0,X.jsxs)(Nt,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All stages`}),j.map(e=>(0,X.jsx)(q,{value:e,children:he(e)},e))]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{render:(0,X.jsx)(`button`,{type:`button`,"aria-label":`About lifecycle stages`,className:`flex size-6 items-center justify-center rounded-(--miravo-radius-tight) text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,X.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(G,{side:`top`,children:`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`})]})]}),(0,X.jsxs)(Ft,{value:_||`all`,onValueChange:e=>void g(!e||e===`all`?``:e),items:Rt,children:[(0,X.jsx)(Pt,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,X.jsx)(Mt,{placeholder:`All status`})}),(0,X.jsxs)(Nt,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All status`}),(0,X.jsx)(q,{value:`healthy`,children:`Healthy`}),(0,X.jsx)(q,{value:`faulted`,children:`Faulted`}),(0,X.jsx)(q,{value:`quarantined`,children:`Quarantined`})]})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(ue,{ref:ee,placeholder:`Search...`,value:r,onChange:e=>void i(e.target.value),"aria-label":`Search assets by id or model`,className:`h-8 w-40 pr-7 text-xs`}),!r&&(0,X.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-(--miravo-radius-tight) border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),ie&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:ae,className:`flex items-center gap-1 rounded-(--miravo-radius-tight) px-1 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(de,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[re.length,` of `,e.length]})]})]}),(0,X.jsx)(Si,{assets:re,state:N,templateByAsset:E,sortKey:v,sortDir:b,onSort:T,onOpenAsset:oe})]})}var Di={running:`live`,paused:`idle`,stopped:`fault`};function Oi(){let{factoryName:e,engineState:t,seed:n,speed:r,bootTemplate:i}=l(I(e=>({factoryName:e.factoryName,engineState:e.engineState,seed:e.seed,speed:e.speedMultiplier,bootTemplate:e.bootTemplate})));return(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:e||`Factory`}),(0,X.jsx)(F,{tone:Di[t]??`off`,children:(0,X.jsx)(N,{children:t})})]}),(0,X.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[`seed `,(0,X.jsx)(`span`,{className:`text-foreground`,children:n??`-`})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`span`,{className:`text-foreground`,children:[r,`×`]}),` speed`]}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(`span`,{children:[`booted with `,(0,X.jsx)(`span`,{className:`text-foreground`,children:i.name})]})]}):null]})]}),(0,X.jsxs)(j,{to:`/catalog`,className:B({size:`sm`}),children:[(0,X.jsx)(at,{className:`size-3.5`,"aria-hidden":!0}),`Load template`]})]})}var ki=Gt.map(e=>e.id),Ai=`inline-flex h-8 shrink-0 items-center gap-2 rounded-[var(--miravo-radius-pill)] border px-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring`;function ji(){let[e,t]=O(`integration`,A(ki).withDefault(Wt.id)),{Panel:n}=pi[e];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`nav`,{"aria-label":`Integrations`,className:`flex flex-wrap gap-2`,children:[Gt.map(n=>{let{icon:r}=pi[n.id],i=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>void t(n.id),className:H(Ai,i?`border-primary/45 bg-primary/10 text-foreground`:`border-border/60 text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:[(0,X.jsx)(r,{className:H(`size-3.5`,i&&`text-primary`),"aria-hidden":!0}),n.label]},n.id)}),Ut.map(e=>(0,X.jsxs)(`span`,{"aria-disabled":!0,className:H(Ai,`cursor-default border-dashed border-border/60 text-muted-foreground/70`),children:[(0,X.jsx)(ln,{className:`size-3.5`,"aria-hidden":!0}),e.label,(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Soon`})]},e.id))]}),(0,X.jsx)(n,{})]})}function Mi(e={}){let t=new URLSearchParams({tab:`assets`});return e.template&&t.set(`template`,e.template),e.standalone&&t.set(`standalone`,`1`),e.model&&t.set(`model`,e.model),e.status&&t.set(`status`,e.status),`/?${t.toString()}`}var Ni={healthy:`border-muted-foreground/25 bg-muted/40 text-foreground/90 hover:border-muted-foreground/50`,faulted:`border-destructive/40 bg-destructive/10 text-destructive hover:border-destructive/70`,quarantined:`border-warning/40 bg-warning/10 text-warning hover:border-warning/70`},Pi={healthy:`bg-success`,faulted:`bg-destructive`,quarantined:`bg-warning`};function Fi({group:e,label:t,templateId:n}){let[r]=e.ids;return(0,X.jsxs)(j,{to:e.ids.length===1&&r?`/asset/${r}`:Mi({model:e.model,template:n}),title:e.ids.join(`, `),className:H(`inline-flex h-6 items-center gap-1.5 rounded-[var(--miravo-radius-tight)] border px-1.5 font-mono text-[11px] outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,Ni[e.health]),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 shrink-0 rounded-full`,Pi[e.health])}),t,e.ids.length>1&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.ids.length]}),e.health!==`healthy`&&(0,X.jsxs)(`span`,{className:`sr-only`,children:[`, `,e.health]})]})}function Ii(e,t){let n=new Set(e.assetIds);return new Map(t.filter(e=>e.stations.some(e=>n.has(e.id))).map(e=>[e.line,e]))}var Li={healthy:0,faulted:1,quarantined:2};function $(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}function Ri(e){let t=[];for(let n of e){let e=$(n),r=t.at(-1);r&&r.model===n.model?(r.ids.push(n.id),Li[e]>Li[r.health]&&(r.health=e)):t.push({model:n.model,ids:[n.id],health:e})}return t}function zi(e,t,n){let r=new Set(e.assetIds),i=new Map,a=new Map;for(let t of e.areas)a.set(t.name,new Map(t.lines.map(e=>[e,[]])));for(let e of t){if(!r.has(e.id))continue;i.set(e.id,e);let t=e.browsePath.at(-3)??``,n=e.browsePath.at(-2)??``,o=a.get(t);o||(o=new Map,a.set(t,o));let s=o.get(n);s?s.push(e):o.set(n,[e])}let o=Ii(e,n);return[...a].map(([e,t])=>({name:e,lines:[...t].map(([t,n])=>{let r=o.get(`${e}/${t}`),a=r?r.stations.flatMap(e=>{let t=i.get(e.id);return t?[t]:[]}):n;return{name:t,flow:r!==void 0,groups:Ri(a)}})}))}var Bi=24;function Vi(){let{assets:e,templates:t}=l(I(e=>({assets:e.assets,templates:e.templates}))),[n,r]=(0,Y.useState)(!1),i=new Set(t.flatMap(e=>e.assetIds)),a=e.filter(e=>!i.has(e.id));if(a.length===0)return null;let o=n?a:a.slice(0,Bi);return(0,X.jsxs)(`section`,{"aria-label":`Standalone assets`,className:H(Ct,`flex flex-col gap-4 p-5`),children:[(0,X.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(rn,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:`Standalone assets`}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/75`,children:`Spawned from a model, outside any template.`})]})]}),(0,X.jsxs)(`ul`,{className:`flex flex-wrap gap-1.5`,children:[o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Fi,{group:{model:e.model,ids:[e.id],health:$(e)},label:e.id})},e.id)),a.length>Bi&&(0,X.jsx)(`li`,{children:(0,X.jsx)(L,{size:`xs`,variant:`ghost`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`+${a.length-Bi} more`})})]}),(0,X.jsxs)(`div`,{className:`mt-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:a.length}),` asset`,a.length===1?``:`s`]}),(0,X.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(j,{to:Mi({standalone:!0}),className:H(B({size:`sm`,variant:`outline`}),St),children:[(0,X.jsx)(Qt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),(0,X.jsxs)(j,{to:`/models`,className:H(B({size:`sm`,variant:`ghost`}),`ml-auto text-muted-foreground`),children:[(0,X.jsx)(at,{className:`size-3.5`,"aria-hidden":!0}),`Spawn asset`]})]})]})}function Hi(e){let t=Math.abs(e);return t>=100?e.toFixed(0):t>=10?e.toFixed(1):e.toFixed(2)}function Ui(e){let t=e?.get(`availability_state`)?.value;return typeof t==`string`?t:void 0}function Wi(e,t){return $(e)!==`healthy`||Ui(t)===`faulted`}function Gi(e){let t=Ui(e);return t===`running`||t===`steady`}function Ki(e){let t=e.match(/-(\d+)$/)?.[1];return t?`#${t}`:e}function qi({reading:e,value:t}){let n=e.max-e.min,r=t===void 0?0:Math.min(1,Math.max(0,(t-e.min)/n)),i=fe(e.unit);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[10px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-muted-foreground`,children:pe(e.member)}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:t===void 0?`–`:Hi(t)}),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i})]})]}),(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,title:`Range ${e.min}–${e.max} ${i}`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-primary/75 transition-[width] duration-700 ease-out`,style:{width:`${r*100}%`}})})]})}function Ji({asset:e,readings:t,values:n}){let r=$(e),i=Ui(n),a=e.activeFaults[0],o=r===`faulted`||i===`faulted`?`bg-destructive`:r===`quarantined`?`bg-warning`:Gi(n)?`bg-success`:`bg-muted-foreground/50`;return(0,X.jsxs)(j,{to:`/asset/${e.id}`,className:H(`flex min-w-0 flex-col gap-2 rounded-[var(--miravo-radius-tight)] border px-3 py-2.5 outline-none transition-colors hover:border-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring`,Wi(e,n)?`border-destructive/40`:`border-border/50`),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-2 shrink-0`,children:[(0,X.jsx)(`span`,{className:H(`size-2 rounded-full`,o)}),i===`running`&&r===`healthy`?(0,X.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-success/50`}):null]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:z(e.model)}),(0,X.jsx)(`span`,{className:H(`shrink-0 text-[10px]`,a||i===`faulted`?`text-destructive`:`text-muted-foreground`),children:a?R(a):i?pe(i):null})]}),(0,X.jsxs)(`span`,{className:`-mt-1 truncate text-[10px] text-muted-foreground`,title:e.id,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:Ki(e.id)}),` ·`,` `,pe(e.lifecycleStage),` ·`,` `,ve(e.operatingHours)]}),t.map(e=>{let t=n?.get(e.member)?.value;return(0,X.jsx)(qi,{reading:e,value:typeof t==`number`?t:void 0},e.member)})]})}function Yi({name:e,assets:t,readingsByModel:n,memberValues:r}){let i=t.filter(e=>Gi(r.get(e.id))).length;return(0,X.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-2.5 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 px-3.5 py-3`,style:{flex:`${t.length} 1 ${Math.min(t.length,3)*14}rem`},children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium`,title:e,children:e}),(0,X.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:i}),`/`,t.length,` operating`]})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:t.map(e=>(0,X.jsx)(Ji,{asset:e,readings:n.get(e.model)??[],values:r.get(e.id)},e.id))})]})}var Xi=new Set([`Boolean`,`String`]),Zi=/_(command|reference|setpoint|sp|target)$/,Qi=`pu`;function $i(e,t=2){if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.members))r.kind!==`variable`||r.access!==`read`||Xi.has(r.dataType)||Zi.test(t)||!r.unit||!r.euRange||r.euRange[1]<=r.euRange[0]||n.push({member:t,unit:r.unit,min:r.euRange[0],max:r.euRange[1]});return[...n.filter(e=>e.unit!==Qi),...n.filter(e=>e.unit===Qi)].slice(0,t)}var ea=5*6e4,ta=6e4,na=15e3,ra=1e4,ia=2e3;function aa(e,t){let n=e.at(-1),r=n&&t.good<n.good?[]:[...e];return n&&n.good===t.good&&t.t-n.t<1e3?r:(r.push(t),r.filter(e=>t.t-e.t<=ea))}function oa(e){let t=e.at(-1);if(!t)return null;let n=e.find(e=>t.t-e.t<=ta);return!n||t.t-n.t<na?null:(t.good-n.good)*6e4/(t.t-n.t)}function sa(e){let t=new Map;for(let n of e)t.set(Math.floor(n.t/ra),n);let n=[...t.values()],r=[];for(let e=1;e<n.length;e++){let t=n[e-1],i=n[e];t&&i&&i.t>t.t&&r.push((i.good-t.good)*6e4/(i.t-t.t))}return r}var ca=new Map;function la(e,t){let n=(0,Y.useRef)(t);n.current=t;let[,r]=(0,Y.useState)(0);return(0,Y.useEffect)(()=>{let t=()=>{let t=ca.get(e)??[];ca.set(e,aa(t,{t:Date.now(),good:n.current})),r(e=>e+1)};t();let i=setInterval(t,ia);return()=>clearInterval(i)},[e]),ca.get(e)??[]}var ua={running:{label:`Running`,ring:`border-success/70`,text:`text-success`,dot:`bg-success`},idle:{label:`Idle`,ring:`border-muted-foreground/40`,text:`text-muted-foreground`,dot:`bg-muted-foreground/60`},starved:{label:`Starved`,ring:`border-warning/70 border-dashed`,text:`text-warning`,dot:`bg-warning`},blocked:{label:`Blocked`,ring:`border-warning/70`,text:`text-warning`,dot:`bg-warning`},down_planned:{label:`Planned stop`,ring:`border-info/70`,text:`text-info`,dot:`bg-info`},down_unplanned:{label:`Down`,ring:`border-destructive/80`,text:`text-destructive`,dot:`bg-destructive`},off_shift:{label:`Off shift`,ring:`border-border`,text:`text-muted-foreground/70`,dot:`bg-muted-foreground/30`}},da=[`running`,`starved`,`blocked`,`down_unplanned`,`down_planned`],fa={healthy:`border-success/50`,faulted:`border-destructive/80`,quarantined:`border-warning/70`},pa=.6;function ma(e){return ua[e]??ua.idle}function ha(e){let t=e.split(`-`).filter(Boolean);return(t.length>1?t.slice(0,2).map(e=>e[0]):[e.slice(0,2)]).join(``).toUpperCase()}function ga(e,t){return{...e,stations:e.stations.map(e=>{let n=t.get(e.id),r=n?.get(`state_label`)?.value,i=n?.get(`good_count`)?.value,a=n?.get(`scrap_count`)?.value;return{...e,state:typeof r==`string`?r:e.state,good:typeof i==`number`?i:e.good,scrap:typeof a==`number`?a:e.scrap}})}}function _a(e,t){let n=new Map;for(let r of e){if(!r)continue;let e=new Map;for(let[t,n]of Object.entries(r.members))n.value!==null&&e.set(t,{value:n.value,quality:n.quality});for(let[n,i]of t.get(r.id)??[])e.set(n,i);n.set(r.id,e)}for(let[e,r]of t)n.has(e)||n.set(e,r);return n}var va=12;function ya({values:e}){let t=e.slice(-va),n=Math.max(...t,1);return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex h-2 items-end gap-px`,children:Array.from({length:va},(e,n)=>t[n-(va-t.length)]).map((e,t)=>(0,X.jsx)(`span`,{className:H(`w-[3px] rounded-[1px]`,e===void 0?`bg-muted-foreground/20`:`bg-primary/80`),style:{height:e===void 0?2:`${Math.max(2,e/n*8)}px`}},t))})}function ba({station:e,asset:t,bottleneck:n}){let r=ma(e.state),i=t?$(t):`healthy`,a=t?.model??e.id,o=t?.activeFaults[0],s=e.state===`running`;return(0,X.jsxs)(j,{to:`/asset/${e.id}`,"aria-label":`${z(a)}, ${o?R(o):r.label}${n?`, likely bottleneck`:``}`,title:`${e.id} · ${o?R(o):r.label}`,className:`group flex w-[5.25rem] shrink-0 flex-col items-center gap-1.5 rounded-[var(--miravo-radius-tight)] py-1 text-center outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsxs)(`span`,{className:H(`relative flex size-12 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border-2 bg-background/70 font-mono text-xs font-semibold text-foreground transition-transform group-hover:-translate-y-0.5`,i===`healthy`?r.ring:fa[i]),children:[ha(a),n?(0,X.jsx)(`span`,{className:`absolute -bottom-1.5 left-1/2 -translate-x-1/2 rounded-full border border-warning/60 bg-background px-1.5 text-[8px] leading-3.5 font-medium uppercase tracking-[0.12em] text-warning`,children:`Bottleneck`}):null,s?(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -top-1 -right-1 size-2.5 rounded-full border-2 border-background bg-success`,children:(0,X.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-success/60`})}):null]}),(0,X.jsx)(`span`,{className:`w-full truncate text-[11px] text-foreground/85`,children:z(a)}),(0,X.jsx)(`span`,{className:H(`text-[10px] leading-none`,o?`text-destructive`:r.text),children:o?R(o):r.label}),(0,X.jsxs)(`span`,{className:`font-mono text-[10px] leading-none text-muted-foreground`,children:[me(e.good),` good`]})]})}function xa({flowing:e,buffer:t}){let n=t?Math.min(1,t.level/t.capacity):0;return(0,X.jsxs)(`div`,{className:`relative mt-[calc(1.75rem-1px)] h-[2px] min-w-10 flex-1`,"aria-hidden":!0,children:[(0,X.jsx)(`div`,{className:H(`absolute inset-0 rounded-full bg-border`,e&&`conveyor-flow`)}),t?(0,X.jsxs)(`div`,{className:`absolute top-2 left-1/2 flex -translate-x-1/2 flex-col items-center gap-1`,title:`Buffer: ${t.level} of ${t.capacity} parts waiting`,children:[(0,X.jsx)(`div`,{className:`h-1.5 w-7 overflow-hidden rounded-full border border-muted-foreground/40 bg-background`,children:(0,X.jsx)(`div`,{className:H(`h-full rounded-full transition-[width] duration-500`,n>=pa?`bg-warning`:`bg-muted-foreground/70`),style:{width:`${n*100}%`}})}),(0,X.jsxs)(`span`,{className:`font-mono text-[9px] leading-none text-muted-foreground`,children:[t.level,`/`,t.capacity]})]}):null]})}function Sa({lineKey:e,name:t,summary:n,assetsById:r}){let i=n.stations.at(-1)?.good??0,a=n.stations.reduce((e,t)=>e+t.scrap,0),o=la(e,i),s=oa(o),c=new Map(n.buffers.map(e=>[e.after,e])),l=n.buffers.reduce((e,t)=>!e||t.level/t.capacity>e.level/e.capacity?t:e,void 0),u=l&&l.level/l.capacity>=pa?n.stations.findIndex(e=>e.id===l.after)+1:-1,d=new Map;for(let e of n.stations)d.set(e.state,(d.get(e.state)??0)+1);let f=i+a>0?i/(i+a)*100:null;return(0,X.jsxs)(`li`,{className:`flex basis-full flex-col gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 px-3.5 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-0.5`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:t}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:[...d].map(([e,t])=>`${t} ${ma(e).label.toLowerCase()}`).join(` · `)})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline gap-3 font-mono text-[11px] text-muted-foreground`,children:[f===null?null:(0,X.jsxs)(`span`,{title:`Good parts out of all finished parts`,children:[(0,X.jsxs)(`span`,{className:`text-foreground`,children:[f.toFixed(1),`%`]}),` yield`]}),(0,X.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,title:`Good parts per minute, last 2 minutes`,children:[(0,X.jsx)(ya,{values:sa(o)}),(0,X.jsx)(`span`,{className:`text-foreground`,children:s===null?`–`:s.toFixed(1)}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`/min`})]})]})]}),(0,X.jsx)(`ol`,{className:`flex items-start overflow-x-auto pb-1`,children:n.stations.map((e,t)=>(0,X.jsxs)(`li`,{className:H(`flex items-start`,t>0&&`flex-1`),children:[t>0?(0,X.jsx)(xa,{flowing:n.stations[t-1]?.state===`running`,buffer:c.get(n.stations[t-1]?.id??``)}):null,(0,X.jsx)(ba,{station:e,asset:r.get(e.id),bottleneck:t===u&&e.state!==`starved`})]},e.id))})]})}function Ca({label:e,value:t,tone:n}){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:H(`font-mono text-lg font-semibold tabular-nums`,n),children:t})]})}function wa({template:e}){let{assets:t,lines:n,liveValues:r}=l(I(e=>({assets:e.assets,lines:e.lines,liveValues:e.memberValues}))),a=_a(Yt({queries:e.assetIds.map(e=>({queryKey:u.assets.detail(e),queryFn:()=>c(`/assets/${e}`,i.assetDetail),staleTime:1/0}))}).map(e=>e.data),r),o=Ie(e.models),s=(0,Y.useMemo)(()=>zi(e,t,n),[e,t,n]),d=(0,Y.useMemo)(()=>new Map(e.models.map((e,t)=>[e,$i(o.data?.[t])])),[e.models,o.data]),f=new Map([...Ii(e,n)].map(([e,t])=>[e,ga(t,a)])),p=new Set(e.assetIds),m=new Map(t.filter(e=>p.has(e.id)).map(e=>[e.id,e])),h=[...m.values()],g=[...f.values()].flatMap(e=>e.stations),_=[...f.values()].reduce((e,t)=>e+(t.stations.at(-1)?.good??0),0),v=g.reduce((e,t)=>e+t.scrap,0),y=h.filter(e=>Wi(e,a.get(e.id))).length,b=h.filter(e=>Gi(a.get(e.id))).length,x=s.reduce((e,t)=>e+t.lines.length,0);return s.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No areas or lines.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`div`,{className:H(`grid gap-2`,g.length>0?`grid-cols-2 sm:grid-cols-4`:`grid-cols-3`),children:[(0,X.jsx)(Ca,{label:`Assets operating`,value:`${b}/${h.length}`}),(0,X.jsx)(Ca,{label:`Faulted`,value:String(y),tone:y>0?`text-destructive`:void 0}),g.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ca,{label:`Good parts`,value:me(_)}),(0,X.jsx)(Ca,{label:`Yield`,value:_+v>0?`${(_/(_+v)*100).toFixed(1)}%`:`–`})]}):(0,X.jsx)(Ca,{label:`Lines`,value:String(x)})]}),g.length>0?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground`,children:[da.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 rounded-full`,ma(e).dot)}),ma(e).label]},e)),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-1.5 w-4 overflow-hidden rounded-full border border-muted-foreground/40`,children:(0,X.jsx)(`span`,{className:`block h-full w-1/3 bg-muted-foreground/70`})}),`Buffer`]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-1.5 w-4 overflow-hidden rounded-full border border-muted-foreground/40`,children:(0,X.jsx)(`span`,{className:`block h-full w-3/4 bg-warning`})}),`Backing up`]})]}):null,s.map(t=>(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:R(t.name)}),(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-2.5`,children:t.lines.map(n=>{let r=`${t.name}/${n.name}`,i=f.get(r),o=R(n.name);return i?(0,X.jsx)(Sa,{lineKey:`${e.templateId}:${r}`,name:o,summary:i,assetsById:m},n.name):(0,X.jsx)(Yi,{name:o,readingsByModel:d,memberValues:a,assets:n.groups.flatMap(e=>e.ids.flatMap(e=>{let t=m.get(e);return t?[t]:[]}))},n.name)})})]},t.name))]})}function Ta({template:e,open:t,onOpenChange:n}){let r=wt(),[i,a]=(0,Y.useState)(!1);return(0,X.jsx)(oe,{open:t,onOpenChange:n,children:(0,X.jsxs)(re,{children:[(0,X.jsxs)(M,{children:[(0,X.jsxs)(ie,{children:[`Unload `,e.templateName]}),(0,X.jsxs)(ae,{children:[`Removes its `,e.assetIds.length,` asset`,e.assetIds.length===1?``:`s`,`. Standalone assets stay.`]})]}),(0,X.jsxs)(ne,{children:[(0,X.jsx)(L,{variant:`outline`,onClick:()=>n(!1),disabled:i,children:`Cancel`}),(0,X.jsx)(L,{variant:`destructive`,disabled:i,onClick:async()=>{a(!0);try{await r.mutateAsync({type:`unloadTemplate`,templateId:e.templateId}),n(!1)}catch{}finally{a(!1)}},children:`Unload`})]})]})})}function Ea({value:e,label:t}){return(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e}),` `,t,e===1?``:`s`]})}function Da(e,t){let n=new Set(e.assetIds),r=new Set;for(let e of t)n.has(e.id)&&$(e)!==`healthy`&&r.add(z(e.model));return[...r]}function Oa({template:e,highlighted:t=!1}){let{assets:n,engineState:r}=l(I(e=>({assets:e.assets,engineState:e.engineState}))),a=v({queryKey:u.catalog.templates(),queryFn:()=>c(`/catalog/templates`,i.catalogTemplates)}),[o,s]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=a.data?.find(t=>t.id===e.templateId)?.description,m=new Set(e.assetIds),h=n.filter(e=>m.has(e.id)&&$(e)!==`healthy`).length,g=h>0?Da(e,n):[],_=e.areas.reduce((e,t)=>e+t.lines.length,0);return(0,X.jsxs)(`section`,{id:`template-${e.templateId}`,"aria-label":e.templateName,className:H(Ct,`flex scroll-mt-4 flex-col gap-4 p-5 transition-shadow`,t&&`ring-2 ring-ring`),children:[(0,X.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(Le,{id:e.templateId,className:`size-5`})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:e.templateName}),(0,X.jsx)(`span`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.templateId})]}),h>0?(0,X.jsxs)(F,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:h}),` `,(0,X.jsx)(N,{children:`faulted`})]}):(0,X.jsx)(F,{tone:r===`running`?`live`:`idle`,children:(0,X.jsx)(N,{children:r===`running`?`running`:`paused`})})]}),p?(0,X.jsx)(`p`,{className:`line-clamp-2 text-pretty text-xs leading-relaxed text-muted-foreground`,children:p}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(Ea,{value:e.areas.length,label:`area`}),(0,X.jsx)(Ea,{value:_,label:`line`}),(0,X.jsx)(Ea,{value:e.assetIds.length,label:`asset`}),(0,X.jsx)(Ea,{value:e.models.length,label:`model`})]}),g.length>0?(0,X.jsxs)(j,{to:Mi({template:e.templateId,status:`faulted`}),className:`flex min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] border border-destructive/30 bg-destructive/8 px-2.5 py-1.5 text-xs text-destructive outline-none transition-colors hover:border-destructive/60 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(ht,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[h,` faulted:`]}),` `,g.join(`, `)]})]}):null,(0,X.jsxs)(`footer`,{className:`mt-auto flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(L,{type:`button`,size:`sm`,variant:`outline`,className:St,onClick:()=>f(!0),children:[(0,X.jsx)($e,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),(0,X.jsxs)(j,{to:Mi({template:e.templateId}),className:B({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Qt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),(0,X.jsx)(L,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>s(!0),children:`Unload`})]}),(0,X.jsx)(Ta,{template:e,open:o,onOpenChange:s}),(0,X.jsx)(Fe,{templateId:d?e.templateId:null,onClose:()=>f(!1),live:(0,X.jsx)(wa,{template:e}),fallbackTitle:e.templateName})]})}var ka={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},Aa={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},ja={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function Ma({label:e,pip:t,pulse:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,X.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,X.jsx)(`span`,{className:H(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,ka[t])}),(0,X.jsx)(`span`,{className:H(`relative inline-flex size-1.5 rounded-full`,ka[t])})]}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:H(`size-1.5 shrink-0 rounded-full`,ka[t])})),(0,X.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function Na({children:e,tone:t=`foreground`,live:n}){return(0,X.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:H(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,Aa[t]),children:e})}function Pa({children:e}){return(0,X.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function Fa(e,t){return e===t?``:t}function Ia({statusFilter:e,onStatusFilter:t}){let{assets:n,tps:r,memberValueCount:i,availableAdapters:a,adapterMetrics:o}=l(I(e=>({assets:e.assets,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),s=(0,Y.useMemo)(()=>{let e=n.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,t=n.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,r=n.filter(e=>e.isQuarantined).length,i=n.length;return{healthy:e,faulted:t,quarantined:r,total:i,pct:i>0?Math.round(e/i*100):100,activeFaultCount:n.reduce((e,t)=>e+t.activeFaults.length,0),modelCount:new Set(n.map(e=>e.model)).size,affectedCount:new Set(n.filter(e=>e.activeFaults.length>0).map(e=>e.id)).size}},[n]),c=(0,Y.useMemo)(()=>{let e=a.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(o.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(o.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>ja[e.name]??e.name)}},[a,o]),u=s.activeFaultCount>0,d=u?`destructive`:s.quarantined>0?`warning`:`success`,f=u?`faulted`:`healthy`;return(0,X.jsxs)(`section`,{"aria-label":`Asset status`,className:`grid w-full min-w-0 max-w-full grid-cols-2 overflow-hidden rounded-(--miravo-radius-stadium-sm) border *:border-border/40 *:odd:border-r *:nth-[-n+2]:border-b @2xl/main:grid-cols-4 @2xl/main:*:border-b-0 @2xl/main:*:not-last:border-r`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(Fa(e,f)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":u?`Filter to faulted assets`:`Filter to healthy assets`,className:H(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,(e===`healthy`||e===`faulted`)&&`bg-muted/50`),children:[(0,X.jsx)(Ma,{label:`Health`,pip:d}),(0,X.jsxs)(Na,{tone:u?`destructive`:`success`,children:[s.pct,`%`]}),(0,X.jsx)(Pa,{children:s.total===0?`No assets`:[`${s.total} asset${s.total===1?``:`s`}`,s.faulted>0&&`${s.faulted} faulted`,s.quarantined>0&&`${s.quarantined} quarantined`,`${s.modelCount} model${s.modelCount===1?``:`s`}`].filter(Boolean).join(` · `)})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted assets`,className:H(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,e===`faulted`&&`bg-muted/50`),children:[(0,X.jsx)(Ma,{label:`Faults`,pip:u?`destructive`:`success`}),(0,X.jsx)(Na,{tone:u?`destructive`:`foreground`,live:!0,children:s.activeFaultCount}),(0,X.jsx)(Pa,{children:u?`${s.affectedCount} asset${s.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{render:(0,X.jsx)(j,{to:`/tags`,"aria-label":`Open tag stream`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,X.jsx)(Ma,{label:`Tags`,pip:`primary`,pulse:!0}),(0,X.jsx)(Na,{children:me(i)}),(0,X.jsxs)(Pa,{children:[(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,X.jsx)(G,{side:`bottom`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,X.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[ge(i),` tags`]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),c.enabled.length>0&&(0,X.jsx)(La,{labels:c.labels,totalMessages:c.totalMessages,totalErrors:c.totalErrors,perAdapter:c.enabled.map(e=>({name:ja[e.name]??e.name,metrics:o.find(t=>t.name===e.name)?.metrics}))})]})}function La({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{render:(0,X.jsx)(j,{to:`/control`,"aria-label":`Open control — protocol adapters`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,X.jsx)(Ma,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,X.jsx)(Na,{tone:n>0?`warning`:`foreground`,live:!0,children:me(t)}),(0,X.jsxs)(Pa,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,X.jsx)(G,{side:`bottom`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,X.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[ge(t),` total`]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,X.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[ge(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var Ra=2500,za=[`overview`,`assets`,`integrations`];function Ba({value:e}){return(0,X.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 font-mono text-[10px] leading-4 tabular-nums text-muted-foreground`,children:e})}function Va({children:e}){return(0,X.jsx)(T.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e})}function Ha(){return(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(on,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`Nothing is running yet`]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Load a template from the catalog. Its areas, lines and assets show up here, live.`}),(0,X.jsx)(j,{to:`/catalog`,className:B({size:`sm`}),children:`Open catalog`})]})}function Ua({highlight:e}){let{templates:t,assetCount:n}=l(I(e=>({templates:e.templates,assetCount:e.assets.length}))),r=t.length===0&&n===0;return(0,X.jsxs)(`div`,{className:`@container/overview flex flex-col gap-5`,children:[(0,X.jsx)(Cn,{}),(0,X.jsxs)(`div`,{className:`grid items-start gap-5 @3xl/overview:grid-cols-[minmax(0,1fr)_20rem] @7xl/overview:grid-cols-[minmax(0,1fr)_22rem]`,children:[r?(0,X.jsx)(Ha,{}):(0,X.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,22rem),1fr))] gap-4`,children:[t.map(t=>(0,X.jsx)(Oa,{template:t,highlighted:t.templateId===e},t.templateId)),(0,X.jsx)(Vi,{})]}),(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-5 @xl/overview:grid-cols-2 @3xl/overview:sticky @3xl/overview:top-4 @3xl/overview:grid-cols-1`,children:[(0,X.jsx)(fn,{}),(0,X.jsx)(mi,{})]})]})]})}function Wa(){let{hash:e}=te(),{templates:t,assetCount:n}=l(I(e=>({templates:e.templates,assetCount:e.assets.length}))),[r,i]=O(`tab`,A(za).withDefault(`overview`)),[a,o]=O(`highlight`,k.withDefault(``)),[s,c]=O(`status`,k.withDefault(``)),u=s===`healthy`||s===`faulted`||s===`quarantined`?s:``;(0,Y.useEffect)(()=>{if(!e)return;e===`#connect`&&i(null);let t=setTimeout(()=>{let t=document.getElementById(e.slice(1));t?.scrollIntoView({behavior:`smooth`,block:`start`}),t?.focus({preventScroll:!0})},50);return()=>clearTimeout(t)},[e,i]);let d=t.some(e=>e.templateId===a);return(0,Y.useEffect)(()=>{if(!a||!d)return;document.getElementById(`template-${a}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=setTimeout(()=>void o(null,{history:`replace`}),Ra);return()=>clearTimeout(e)},[a,d,o]),(0,X.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,X.jsx)(Oi,{}),(0,X.jsx)(Ia,{statusFilter:u,onStatusFilter:e=>{c(e||null),e!==``&&i(`assets`)}}),(0,X.jsxs)(it,{value:r,onValueChange:e=>void i(e),children:[(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(rt,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,X.jsxs)(tt,{value:`overview`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Pe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Overview`,(0,X.jsx)(Ba,{value:t.length})]}),(0,X.jsxs)(tt,{value:`assets`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Qt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Assets`,(0,X.jsx)(Ba,{value:n})]}),(0,X.jsxs)(tt,{value:`integrations`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(ln,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Integrations`]})]})}),(0,X.jsx)(nt,{value:`overview`,className:`py-2`,children:(0,X.jsx)(Va,{children:(0,X.jsx)(Ua,{highlight:a})})}),(0,X.jsx)(nt,{value:`assets`,className:`py-2`,children:(0,X.jsx)(Va,{children:(0,X.jsx)(Ei,{})})}),(0,X.jsx)(nt,{value:`integrations`,className:`py-2`,children:(0,X.jsx)(Va,{children:(0,X.jsx)(ji,{})})})]})]})}export{tn as a,on as i,dn as n,Qt as o,ln as r,Zt as s,Wa as t};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-COnpUsM8.js";import{c as e,s as t}from"./vendor-charts-95ykyDlI.js";import{nt as n,ot as r,rt as i}from"./vendor-ui-D8j69UH4.js";import{n as a,t as o}from"./utils-BO2u-wC_.js";var s=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,c=t,l=(e,t)=>n=>{if(t?.variants==null)return c(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=s(t)||s(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return c(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},u=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),d=a(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),f=r(),p=l(`group/button inline-flex shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:border-destructive/50 aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground border-input bg-input/30 hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 bg-destructive/20 hover:bg-destructive/30 focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[var(--miravo-radius-tight)] px-2 text-xs in-data-[slot=button-group]:rounded-[var(--miravo-radius-stadium-sm)] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[var(--miravo-radius-tight)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-[var(--miravo-radius-stadium-sm)] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`,icon:`size-8`,"icon-xs":`relative size-6 rounded-[var(--miravo-radius-tight)] in-data-[slot=button-group]:rounded-[var(--miravo-radius-stadium-sm)] [&_svg:not([class*='size-'])]:size-3 before:absolute before:inset-[-10px] before:content-['']`,"icon-sm":`relative size-7 rounded-[var(--miravo-radius-tight)] in-data-[slot=button-group]:rounded-[var(--miravo-radius-stadium-sm)] before:absolute before:inset-[-10px] before:content-['']`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function m({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,f.jsx)(i,{"data-slot":`button`,className:o(p({variant:t,size:n,className:e})),...r})}e();function h({className:e,type:t,...r}){return(0,f.jsx)(n,{type:t,"data-slot":`input`,className:o(`h-8 w-full min-w-0 rounded-[var(--miravo-radius-stadium-sm)] border border-input bg-input/30 px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium file:text-foreground placeholder:text-muted-foreground hover:bg-input/50 focus-visible:border-primary/35 focus-visible:ring-2 focus-visible:ring-primary/22 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...r})}var g=new Map([[`ac`,`AC`],[`ach`,`ACH`],[`ahu`,`AHU`],[`cip`,`CIP`],[`cnc`,`CNC`],[`dp`,`DP`],[`eu`,`EU`],[`hepa`,`HEPA`],[`hvac`,`HVAC`],[`hx`,`HX`],[`kva`,`kVA`],[`kw`,`kW`],[`plc`,`PLC`],[`rh`,`RH`],[`rpm`,`RPM`],[`rtu`,`RTU`],[`ups`,`UPS`],[`vfd`,`VFD`]]);function _(e){return g.get(e.toLowerCase())??e.charAt(0).toUpperCase()+e.slice(1)}function v(e){return e.split(`-`).map(_).join(` `)}function y(e,t){let n=t.trim().toLowerCase();return n?e.toLowerCase().includes(n)||v(e).toLowerCase().includes(n):!0}function b(e,t){let n=t.trim().toLowerCase();return n?e.toLowerCase().includes(n)||A(e).toLowerCase().includes(n):!0}function x(e){return e.split(`_`).map(_).join(` `)}function S(e){let t=e.trim();return t&&(t.includes(`_`)?x(t):/^[A-Z][A-Z0-9_-]*$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase())}function C(e){return e.includes(`_`)?S(e):v(e)}var w={degC:`°C`,"m3/h":`m³/h`,"mm/s":`mm/s`,pu:`pu`,"%":`%`};function T(e){return e?w[e]??e:``}var E=`en-US`;function D(e){let t=Math.max(0,Math.trunc(e));return t<1e6?t.toLocaleString(E):new Intl.NumberFormat(E,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1}).format(t)}function O(e){return Number.isInteger(e)?Math.abs(e)>=1e4?e.toLocaleString(E):String(e):Math.abs(e)>=100?e.toFixed(1):Math.abs(e)>=1?e.toFixed(2):e.toFixed(3)}function k(e){return e.toLocaleString(E)}function A(e){let t=e.match(/^(.+)-(\d{3,})$/);if(!t)return v(e);let[,n,r]=t;return n?`${v(n)} ${r}`:v(e)}function j(e){return e.join(`/`)}function M(e,t){return`${j(e)}/${t}`}function N(e){let t=Math.round((Number.isFinite(e)&&e>=0?e:0)*60),n=1440,r=Math.floor(t/n),i=t%n,a=Math.floor(i/60),o=i%60;if(r>=365){let e=Math.floor(r/365),t=r%365,n=[`${e}y`];return t>0&&n.push(`${t}d`),a>0&&n.push(`${a}h`),o>0&&n.push(`${o}m`),n.join(` `)}if(r>0){let e=[`${r}d`];return a>0&&e.push(`${a}h`),o>0&&e.push(`${o}m`),e.join(` `)}return a>0?o>0?`${a}h ${o}m`:`${a}h`:o>0?`${o}m`:`0h`}function P(e){return new Date(e).toLocaleString(E)}function F(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return`just now`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toLocaleDateString(E,{month:`short`,day:`numeric`})}var I=new Set([`faulted`,`critical`,`stopped`,`emergency`]),L=new Set([`degraded`,`uncertain`]);function R(e){return I.has(e)?`bad`:L.has(e)?`warn`:`neutral`}var z=4;function B(e){return e.length<=z?e.join(`, `):`${e.slice(0,z-1).join(`, `)} ... ${e[e.length-1]}`}export{m as C,l as D,u as E,h as S,d as T,T as _,j as a,R as b,S as c,D as d,O as f,x as g,C as h,M as i,k as l,F as m,I as n,P as o,N as p,L as r,A as s,E as t,v as u,b as v,p as w,B as x,y};