@miravo/cli-linux-arm64-musl 0.11.0 → 0.12.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.
- package/console-dist/assets/api-Dw9ti2cu.js +1 -0
- package/console-dist/assets/{api-B2QJEzbS.js → api-tM5PSXjr.js} +1 -1
- package/console-dist/assets/asset-detail-C4zF_8rm.js +1 -0
- package/console-dist/assets/asset-detail-actions-Dv9g2Z9t.js +1 -0
- package/console-dist/assets/{backup-power-BDMAO2bO.js → backup-power-CAc85zvh.js} +1 -1
- package/console-dist/assets/{boiler-CWAR1Nq2.js → boiler-BQwqgoVY.js} +1 -1
- package/console-dist/assets/by-path-DmADo_qX.js +1 -0
- package/console-dist/assets/catalog-BMLSbdye.js +1 -0
- package/console-dist/assets/catalog-Ccubt-hm.js +1 -0
- package/console-dist/assets/catalog-template-icons-DGyxSm-F.js +1 -0
- package/console-dist/assets/chevron-right-CrNKVFcI.js +1 -0
- package/console-dist/assets/{chiller-BSx8eUMN.js → chiller-Jug0vRg-.js} +1 -1
- package/console-dist/assets/{commercial-building-CNvi6IZK.js → commercial-building-CINKWcQV.js} +1 -1
- package/console-dist/assets/{compressor-D63w6Ir2.js → compressor-BkWNdwvy.js} +1 -1
- package/console-dist/assets/{console-panel-CMDoBJiO.js → console-panel-Cg2sBJcN.js} +1 -1
- package/console-dist/assets/control-B-TcWj5c.js +1 -0
- package/console-dist/assets/control-DXA-_1Gu.js +1 -0
- package/console-dist/assets/{district-heating-Cr4CrgCA.js → district-heating-DqGtrEKq.js} +1 -1
- package/console-dist/assets/{events-RmbRTKFV.js → events-Dz_zsLGE.js} +1 -1
- package/console-dist/assets/events-iYGC0JpW.js +1 -0
- package/console-dist/assets/{export-tab-fZDO4r2u.js → export-tab-BS4GlLBV.js} +1 -1
- package/console-dist/assets/factory-BCPLmUx4.js +1 -0
- package/console-dist/assets/factory-CBXx3oBo.js +1 -0
- package/console-dist/assets/floor-page-BOlkyLaW.js +1 -0
- package/console-dist/assets/{genset-BRgqR1AT.js → genset-DBpkUT9p.js} +1 -1
- package/console-dist/assets/{get-error-message-dM0BMfdP.js → get-error-message-CEvauOXv.js} +1 -1
- package/console-dist/assets/{index-CvuwOe37.js → index-B7ZG1VO6.js} +3 -3
- package/console-dist/assets/{integration-api-D2tA69Yb.js → integration-api-iM6SWQ6d.js} +1 -1
- package/console-dist/assets/integrations-Bw0jY-xH.js +1 -0
- package/console-dist/assets/{integrations-iAjWxaDS.js → integrations-NcPRP3je.js} +1 -1
- package/console-dist/assets/{login-DpNKicxy.js → login-snbitj6V.js} +1 -1
- package/console-dist/assets/models-CsdLFBfC.js +1 -0
- package/console-dist/assets/models-Dy_JFNac.js +1 -0
- package/console-dist/assets/{pharma-cleanroom-ClJRwROz.js → pharma-cleanroom-CBgNUnIv.js} +1 -1
- package/console-dist/assets/protocol-card-Cp8O59cX.js +1 -0
- package/console-dist/assets/registry-Kj-oMlVm.js +2 -0
- package/console-dist/assets/{rtu-D-1lltcO.js → rtu-BR4DhLbE.js} +1 -1
- package/console-dist/assets/shallow-Cin0mLuv.js +1 -0
- package/console-dist/assets/{smart-factory-cem4tLAv.js → smart-factory-DozakG3N.js} +1 -1
- package/console-dist/assets/{stages-hidkaJPI.js → stages-C0cErwSQ.js} +1 -1
- package/console-dist/assets/{status-CZFZLqVk.js → status-DNfdEhTs.js} +1 -1
- package/console-dist/assets/status-kit-BLG7OeIE.js +1 -0
- package/console-dist/assets/tags-BRYVC9vb.js +1 -0
- package/console-dist/assets/{tags-BBz30-eV.js → tags-bloWH2Qa.js} +1 -1
- package/console-dist/assets/{tank-THHXGdzg.js → tank-xgQfMS2d.js} +1 -1
- package/console-dist/assets/{transition-nav-link-B11-gXld.js → transition-nav-link-CBN2nulP.js} +1 -1
- package/console-dist/assets/use-engine-command-mutation-oLQW2r4F.js +1 -0
- package/console-dist/assets/use-transition-navigate-BDkvJJsk.js +2 -0
- package/console-dist/assets/{useQuery-M9KTdi7Q.js → useQuery-smgfSdOx.js} +1 -1
- package/console-dist/assets/{validation-BkfmaBBi.js → validation-BOdAwXQ_.js} +1 -1
- package/console-dist/assets/{water-treatment-CfVR0p0L.js → water-treatment-BJXMtYlP.js} +1 -1
- package/console-dist/index.html +30 -30
- package/miravo +1 -1
- package/package.json +1 -1
- package/console-dist/assets/api-Vq4lny_H.js +0 -1
- package/console-dist/assets/asset-detail-E-TllNHT.js +0 -1
- package/console-dist/assets/asset-detail-actions-jjbvaDES.js +0 -1
- package/console-dist/assets/asset-panel-DDziFlFl.js +0 -1
- package/console-dist/assets/by-path-VBqTBdlG.js +0 -1
- package/console-dist/assets/catalog-BlkPPAWE.js +0 -1
- package/console-dist/assets/catalog-CQopEu5C.js +0 -1
- package/console-dist/assets/catalog-template-icons-BOSywIKV.js +0 -1
- package/console-dist/assets/chevron-left-XHFooLn1.js +0 -1
- package/console-dist/assets/chevron-right-CMSQPSEo.js +0 -1
- package/console-dist/assets/control-CBviLxJB.js +0 -1
- package/console-dist/assets/control-jNqzZWa9.js +0 -1
- package/console-dist/assets/events-D531_1EZ.js +0 -1
- package/console-dist/assets/factory-C2OucdpQ.js +0 -1
- package/console-dist/assets/factory-CgSIjU5V.js +0 -1
- package/console-dist/assets/factory-DLE12zAd.js +0 -1
- package/console-dist/assets/floor-page-D0mX5OuA.js +0 -1
- package/console-dist/assets/integrations-BLG4PT3c.js +0 -1
- package/console-dist/assets/model-schemas-3w38IPdc.js +0 -1
- package/console-dist/assets/models-CMN9Eppf.js +0 -1
- package/console-dist/assets/models-I_V8J5Y0.js +0 -1
- package/console-dist/assets/play-kg50os4l.js +0 -1
- package/console-dist/assets/protocol-card-ARSwIjkN.js +0 -1
- package/console-dist/assets/registry-Dau_GjK6.js +0 -2
- package/console-dist/assets/tags-K96jT8PY.js +0 -1
- package/console-dist/assets/use-engine-command-mutation-CHqjOqfS.js +0 -1
- package/console-dist/assets/use-transition-navigate-B-nk4aWh.js +0 -2
- /package/console-dist/assets/{circle-x-_o0nl0Rg.js → circle-x-6JtFdy1_.js} +0 -0
- /package/console-dist/assets/{dom-Cm_OH5jc.js → dom-CQuChC3G.js} +0 -0
- /package/console-dist/assets/{not-found-C4YVKP97.js → not-found-Cc35S-lZ.js} +0 -0
- /package/console-dist/assets/{runtime-link-vBANRqcD.js → runtime-link-BRnaEnOm.js} +0 -0
- /package/console-dist/assets/{tabs-BbQkzBZZ.js → tabs-Ch_VG8_S.js} +0 -0
- /package/console-dist/assets/{vendor-table-B0Z9e_sn.js → vendor-table-BQAIXM34.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{a as t,c as n,i as r,n as i,o as a,r as o,t as s}from"./vendor-charts-95ykyDlI.js";import{ot as c}from"./vendor-ui-D8j69UH4.js";import{S as l,o as u,ot as d,v as f}from"./api-B2QJEzbS.js";import{t as p}from"./useQuery-M9KTdi7Q.js";import{t as m}from"./proxy-CWZabK8f.js";import{i as h,r as ee}from"./dist-xY0pK9Wy.js";import{c as te,l as ne}from"./chunk-OE4NN4TA-DBWZidbW.js";import{n as g,o as _,r as v,t as y}from"./dialog-B5PqrKVw.js";import{C as re,_ as b,a as x,b as S,c as C,f as w,g as T,i as E,n as D,p as ie,r as O,s as ae,u as k}from"./format-Bx7DF-TB.js";import{n as A,t as j}from"./utils-XFKvwlFT.js";import{t as M}from"./activity-Cy_niK56.js";import{t as N}from"./copy-button-CSUP1VjU.js";import{n as oe,t as se}from"./sliders-horizontal-BNKmYQgd.js";import{t as P}from"./radio-BxpVYiyS.js";import{n as ce,t as le}from"./query-fetch-error-CWLZA2L5.js";import{t as F}from"./triangle-alert-DoAwrRgk.js";import{i as I,n as L,t as R}from"./tooltip-B3vOB1Vu.js";import{t as z}from"./badge-Bk1DaL6C.js";import{t as ue}from"./transition-types-BKZuWApE.js";import{n as B}from"./auth-screen-backdrop-CEykEbfF.js";import{n as de}from"./get-error-message-dM0BMfdP.js";import{n as V,r as fe}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as H,n as U,r as pe,t as me}from"./tabs-BbQkzBZZ.js";import{i as he,n as ge,r as _e,t as ve}from"./asset-detail-actions-jjbvaDES.js";var ye=A(`layers-2`,[[`path`,{d:`M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z`,key:`15q6uc`}],[`path`,{d:`m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845`,key:`byia6g`}]]),be=A(`signal`,[[`path`,{d:`M2 20h.01`,key:`4haj6o`}],[`path`,{d:`M7 20v-4`,key:`j294jx`}],[`path`,{d:`M12 20v-8`,key:`i3yub9`}],[`path`,{d:`M17 20V8`,key:`1tkaf5`}],[`path`,{d:`M22 4v16`,key:`sih9yq`}]]),xe=A(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),W=e(n(),1),G=c();function K({detail:e,tick:t,activeFaults:n,memberValues:r,onBack:i}){let a=n.length,o=e.isQuarantined,s=`OK`,c=`ok`;a>0?(s=`FAULT`,c=`bad`):o&&(s=`QRTN`,c=`warn`);let l=0;if(r)for(let e of r.values())e.quality!==`good`&&l++;let u=Object.keys(e.members).length,d=r?.get(`availability_state`)?.value,f=e.members.availability_state?.value,p=typeof d==`string`?d:typeof f==`string`?f:`unknown`,m=p===`running`?{dot:`bg-success`,pulse:`bg-success/60`,animate:!0}:p===`faulted`?{dot:`bg-destructive`,pulse:`bg-destructive/60`,animate:!0}:p===`stopped`?{dot:`bg-warning`,pulse:`bg-warning/60`,animate:!0}:{dot:`bg-muted-foreground/60`,pulse:`bg-muted-foreground/50`,animate:!1},h=p===`running`?`Availability state is running — the asset is available and in service.`:p===`faulted`?`Availability state is faulted — the asset is unavailable because a fault is active.`:p===`stopped`?`Availability state is stopped — the asset is available but not running.`:`Availability state is not available for this asset yet.`;return(0,G.jsxs)(`header`,{className:j(fe,`flex w-full min-w-0 flex-col`),children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`transition-colors hover:text-foreground`,children:`Assets`}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,G.jsx)(`span`,{className:`truncate`,children:k(e.assetType)})]}),(0,G.jsx)(W.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,G.jsx)(`h1`,{className:`font-heading mt-1 text-2xl font-semibold uppercase leading-tight tracking-wide`,children:ae(e.id)})}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`p`,{className:`m-0 min-w-0 flex-1 font-mono text-[10px] leading-tight tracking-tight text-muted-foreground`,children:(0,G.jsx)(`span`,{className:`break-all`,children:e.browsePath.join(` / `)})}),(0,G.jsx)(`span`,{className:`inline-flex shrink-0`,children:(0,G.jsx)(N,{value:x(e.browsePath),label:`Copy Topic / UNS path`})})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 self-end font-mono text-xs sm:self-start`,children:[(0,G.jsx)(P,{className:`size-3.5 animate-pulse text-primary`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`font-medium text-primary`,children:`LIVE`}),(0,G.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[`t=`,t]}),(0,G.jsxs)(R,{children:[(0,G.jsx)(I,{render:(0,G.jsx)(`span`,{className:`inline-flex size-3.5 items-center justify-center outline-none focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,G.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,G.jsx)(`span`,{className:j(`relative inline-flex size-1.5 rounded-full`,m.dot)}),m.animate&&(0,G.jsx)(`span`,{className:j(`absolute inline-flex size-2.5 animate-ping rounded-full opacity-75`,m.pulse)})]})}),(0,G.jsx)(L,{side:`top`,align:`end`,children:(0,G.jsxs)(`span`,{className:`block max-w-[16rem] text-[11px] leading-snug`,children:[(0,G.jsx)(`span`,{className:`font-medium uppercase tracking-[0.08em]`,children:`Availability`}),` `,(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`— `,h]})]})})]})]})]}),(0,G.jsxs)(`fieldset`,{"aria-label":`Asset status`,className:`m-0 flex flex-col border-0 border-t border-border/50 p-0`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-px bg-transparent`,children:[(0,G.jsx)(q,{variant:`primary`,icon:M,label:`Health`,value:s,tone:c,tooltip:`Rolls up active faults and quarantine into a single status — OK when nothing is asserted, FAULT when any fault is active, QRTN when the asset is excluded from the running factory.`}),(0,G.jsx)(q,{variant:`primary`,icon:F,label:`Active faults`,labelCompact:`Faults`,value:String(a),tone:a>0?`bad`:`neutral`,tooltip:`Fault codes currently asserted on this asset. Clear or inject faults from the Alarms section below.`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-px border-t border-border/50 bg-transparent sm:grid-cols-4`,children:[(0,G.jsx)(q,{variant:`compact`,icon:ye,label:`Lifecycle`,labelCompact:`Life`,value:C(e.lifecycleStage),tone:S(e.lifecycleStage),tooltip:`Where this asset sits in its operational lifecycle (e.g. commissioning, operating, maintenance, retired).`}),(0,G.jsx)(q,{variant:`compact`,icon:oe,label:`Tags`,value:String(u),tone:`neutral`,tooltip:`Total members exposed by this asset — process variables, state flags, counters, commands, and reference fields combined.`}),(0,G.jsx)(q,{variant:`compact`,icon:be,label:`Bad quality`,value:String(l),tone:l>0?`warn`:`neutral`,tooltip:`Members whose quality stamp is anything other than good (uncertain or bad). A healthy asset reads 0.`}),(0,G.jsx)(q,{variant:`compact`,icon:xe,label:`Operating age`,value:ie(e.operatingHours),tone:`neutral`,tooltip:`Total operating age on this asset, including any factory-seeded starting hours plus simulated runtime elapsed in this session.`})]})]})]})}function q({icon:e,label:t,labelCompact:n,value:r,suffix:i,tone:a,variant:o=`compact`,tooltip:s}){let c=o===`primary`;return(0,G.jsxs)(`div`,{className:j(`relative flex min-w-0 flex-col justify-center`,c?`min-h-20 gap-1.5 px-4 py-4 sm:min-h-24 sm:px-6 sm:py-5 lg:min-h-28 lg:px-8`:`min-h-12 gap-1 px-3 py-2.5 sm:min-h-13 sm:px-4 lg:min-h-14 lg:px-5`),children:[(0,G.jsx)(`div`,{className:`flex min-h-0 min-w-0 items-center gap-2`,children:(0,G.jsxs)(R,{children:[(0,G.jsxs)(I,{className:`flex min-h-0 min-w-0 flex-1 cursor-default items-center gap-2 text-left`,render:(0,G.jsx)(`div`,{}),children:[(0,G.jsx)(e,{className:j(`shrink-0 text-muted-foreground`,c?`size-4`:`size-3.5`),"aria-hidden":!0}),(0,G.jsxs)(`span`,{className:j(`min-w-0 flex-1 font-medium tracking-wide text-muted-foreground uppercase 2xl:tracking-wider`,c?`text-[11px] leading-snug sm:text-[12px]`:`text-[9px] leading-snug sm:text-[10px]`),children:[(0,G.jsx)(`span`,{className:`block wrap-break-word 2xl:hidden`,children:n??t}),(0,G.jsx)(`span`,{className:`hidden wrap-break-word 2xl:block`,children:t})]})]}),(0,G.jsx)(L,{side:`top`,align:`start`,sideOffset:6,className:`max-w-xs`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:s??t})]})})]})}),(0,G.jsxs)(`p`,{className:j(`min-w-0 wrap-break-word font-mono font-semibold leading-tight tracking-tight tabular-nums`,c?`text-2xl sm:text-3xl lg:text-4xl`:`text-base lg:text-lg`,a===`ok`&&`text-success`,a===`warn`&&`text-warning`,a===`bad`&&`text-destructive`,a===`neutral`&&`text-foreground`),children:[r,i?(0,G.jsx)(`span`,{className:j(`ml-0.5 font-medium text-muted-foreground`,c?`text-base lg:text-lg`:`text-xs lg:text-sm`),children:i}):null]})]})}function J({title:e,subtitle:t,children:n,className:r,id:i}){return(0,G.jsxs)(`section`,{id:i,className:j(V,r),children:[(0,G.jsxs)(`div`,{className:`border-b border-border/60 px-4 py-3`,children:[(0,G.jsx)(`h2`,{className:`blueprint-title text-foreground`,children:e}),t?(0,G.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t}):null]}),(0,G.jsx)(`div`,{className:`overflow-hidden p-0`,children:n})]})}var Se=new Set([`pu`,`h`]),Ce=[`_reference`,`_baseline`,`_setpoint`,`_command`],Y=`var(--color-primary)`,we=`var(--color-background)`,Te=60,Ee=1e-4;function X(e,t,n){let r=e?.get(t);return{value:r?.value??n.value,quality:r?.quality??n.quality}}function De(e){return Object.entries(e.members).filter(([e,t])=>t.meta.kind===`variable`&&t.meta.access===`read`&&t.meta.dataType===`Double`&&t.meta.euRange!==null&&!Se.has(t.meta.unit??``)&&!Ce.some(t=>e.endsWith(t)))}function Oe(e,t){if(e.length<2)return!1;let n=t-Te,r;for(let t of e)if(!(t.tick<n)){if(r===void 0){r=t.value;continue}if(Math.abs(t.value-r)>Ee)return!0}return!1}function ke({data:e,chartHeight:n=34,live:c=!1}){let l=(0,W.useId)(),[u,d]=(0,W.useState)(null),f=1/0,p=-1/0;for(let t of e)t.value<f&&(f=t.value),t.value>p&&(p=t.value);let m=e[e.length-1];return(0,G.jsxs)(`div`,{className:`flex min-h-0 w-full flex-col overflow-hidden`,style:{height:n+14},children:[(0,G.jsx)(`div`,{style:{height:n,width:`100%`},children:(0,G.jsx)(t,{width:`100%`,height:n,children:(0,G.jsxs)(s,{data:e,margin:{top:3,right:4,bottom:2,left:0},onMouseMove:e=>{let t=e?.activePayload?.[0]?.value;typeof t==`number`&&d(t)},onMouseLeave:()=>d(null),children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:l,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:Y,stopOpacity:.32}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:Y,stopOpacity:0})]})}),(0,G.jsx)(i,{domain:[`auto`,`auto`],hide:!0}),(0,G.jsx)(a,{content:()=>null,cursor:!1}),(0,G.jsx)(o,{type:`monotone`,dataKey:`value`,stroke:Y,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`url(#${l})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,fill:Y,stroke:we,strokeWidth:1}}),m?(0,G.jsx)(r,{x:m.tick,y:m.value,r:2.25,fill:Y,stroke:we,strokeWidth:1.25,isFront:!0,ifOverflow:`extendDomain`}):null]})})}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] leading-none tabular-nums text-muted-foreground`,children:[c?(0,G.jsxs)(`span`,{"aria-hidden":!0,className:`relative inline-flex size-1.5 shrink-0 items-center justify-center`,children:[(0,G.jsx)(`span`,{className:`absolute inline-flex size-2 animate-ping rounded-full bg-primary/50`}),(0,G.jsx)(`span`,{className:`relative inline-flex size-1.5 rounded-full bg-primary`})]}):null,u===null?(0,G.jsxs)(`span`,{children:[w(f),`–`,w(p)]}):(0,G.jsx)(`span`,{className:`font-medium text-primary`,children:w(u)})]})]})}function Ae({detail:e,processVariables:t,memberValues:n,historyRef:r,tick:i,showQuality:a}){let{liveMap:o,orderedVariables:s}=(0,W.useMemo)(()=>{let e=new Map,n=[],a=[];for(let o of t){let t=Oe(r.current.get(o[0])??[],i);e.set(o[0],t),(t?n:a).push(o)}return{liveMap:e,orderedVariables:[...n,...a]}},[t,n,i,r]);return t.length===0?(0,G.jsx)(J,{title:`Process`,subtitle:`No continuous analog readings defined for this asset`,className:`opacity-90`,children:(0,G.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-muted-foreground`,children:`This asset exposes no continuous process variables. Discrete states, flags, and commands are available in the Tags section below.`})}):(0,G.jsx)(J,{title:`Process`,subtitle:`Live tag readings — trend is ~2 min at 1 Hz`,children:(0,G.jsx)(`ul`,{className:`divide-y divide-border/40`,children:s.map(([t,i])=>{let{value:s,quality:c}=X(n,t,i),l=r.current.get(t)??[],u=E(e.browsePath,t),d=o.get(t)??!1,f=l.length>=2,p=b(i.meta.unit),h=T(t);return(0,G.jsxs)(m.li,{layout:`position`,transition:{duration:.36,ease:[.22,1,.36,1]},className:`flex flex-col gap-2.5 bg-background px-4 py-3 sm:flex-row sm:items-center sm:gap-5 sm:py-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 sm:w-44 sm:shrink-0`,children:[(0,G.jsxs)(R,{children:[(0,G.jsx)(I,{className:`min-w-0 flex-1 cursor-default truncate text-left text-[11px] font-medium uppercase tracking-[var(--miravo-tracking-eyebrow)] text-muted-foreground`,render:(0,G.jsx)(`span`,{}),children:h}),(0,G.jsx)(L,{side:`top`,align:`start`,className:`max-w-xs`,children:h})]}),(0,G.jsx)(N,{value:u,label:`Copy Topic / UNS path`})]}),(0,G.jsxs)(`div`,{className:`relative h-[56px] min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-x-0 top-1/2 h-px -translate-y-1/2 bg-border/30`}),f?(0,G.jsx)(ke,{data:l,chartHeight:42,live:d}):(0,G.jsx)(`p`,{className:`flex h-full items-center text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Collecting trend…`})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 sm:min-w-36 sm:shrink-0 sm:justify-end`,children:[(0,G.jsx)(`span`,{className:`blueprint-stat text-2xl font-semibold leading-none tabular-nums text-foreground`,children:typeof s==`number`?w(s):String(s)}),p&&(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:p}),a&&c!==`good`&&(0,G.jsx)(z,{variant:c===`uncertain`?`secondary`:`destructive`,className:`shrink-0 text-[10px]`,children:c})]})]},t)})})})}function je({name:e,value:t,dataType:n,unit:r,access:i}){let a=T(e),o=i===`readwrite`;if(n===`Boolean`||typeof t==`boolean`||r===`pu`&&(t===0||t===1)){let n=t===!0||t===`true`||t===1,r=e.includes(`fault`);return(0,G.jsxs)(`div`,{className:`flex min-h-9 min-w-0 items-center justify-between gap-2 rounded-[var(--miravo-radius-tight)] border px-2 py-1 ${r&&n?`border-destructive/30 bg-transparent`:``}`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[10px] leading-snug text-muted-foreground`,children:[a,o&&(0,G.jsx)(`span`,{className:`ml-1 text-[8px] text-primary`,children:`CMD`})]}),(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-medium tabular-nums ${r&&n?`text-destructive`:n?`text-success`:`text-muted-foreground`}`,children:n?`ON`:`OFF`})]})}if(n===`String`){let n=String(t),r=n===`none`||n===``,i=D.has(n)||e.includes(`fault_code`)&&!r,o=!i&&O.has(n);return(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col justify-center gap-1 rounded-[var(--miravo-radius-tight)] border px-2 py-2 ${i?`border-destructive/30 bg-transparent`:o?`border-warning/30 bg-warning/5`:``}`,children:[(0,G.jsx)(`span`,{className:`wrap-break-word text-[10px] leading-tight text-muted-foreground`,children:a}),r?(0,G.jsx)(`span`,{className:`wrap-break-word font-mono text-sm font-medium leading-snug text-muted-foreground`,children:`—`}):(0,G.jsx)(`span`,{title:n,className:`wrap-break-word font-mono text-sm font-medium leading-snug ${i?`text-destructive`:o?`text-warning`:`text-foreground`}`,children:C(n)})]})}return(0,G.jsxs)(`div`,{className:`flex min-h-9 min-w-0 items-center justify-between gap-2 rounded-[var(--miravo-radius-tight)] border px-2 py-1`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[10px] leading-snug text-muted-foreground`,children:[a,o&&(0,G.jsx)(`span`,{className:`ml-1 text-[8px] text-primary`,children:`CMD`})]}),(0,G.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-xs font-medium tabular-nums`,children:[typeof t==`number`?w(t):String(t),r&&(0,G.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:b(r)})]})]})}function Me(e){return[...e].sort((e,t)=>{let n=e[1].meta.access===`readwrite`;return n===(t[1].meta.access===`readwrite`)?e[0].localeCompare(t[0]):n?-1:1})}function Ne({stringEnumMembers:e,nonStringOperationalMembers:t,memberValues:n,className:r}){let i=(0,W.useMemo)(()=>Me(e),[e]),a=(0,W.useMemo)(()=>Me(t),[t]),o=`grid min-w-0 gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(100%,12.5rem),1fr))]`;return(0,G.jsx)(J,{title:`Tags`,subtitle:`Mode, status flags, and control tags`,className:r,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5 p-4`,children:[i.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.length>0&&(0,G.jsx)(`h3`,{className:`blueprint-title text-muted-foreground`,children:`States`}),(0,G.jsx)(`div`,{className:o,children:i.map(([e,t])=>{let{value:r}=X(n,e,t);return(0,G.jsx)(je,{name:e,value:r,dataType:t.meta.dataType,unit:t.meta.unit,access:t.meta.access},e)})})]}),a.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.length>0&&(0,G.jsx)(`h3`,{className:`blueprint-title text-muted-foreground`,children:`Flags & commands`}),(0,G.jsx)(`div`,{className:o,children:a.map(([e,t])=>{let{value:r}=X(n,e,t);return(0,G.jsx)(je,{name:e,value:r,dataType:t.meta.dataType,unit:t.meta.unit,access:t.meta.access},e)})})]})]})})}function Z({className:e,counters:t,memberValues:n}){return(0,G.jsx)(J,{title:`Counters`,subtitle:`Totals, hours, and accumulators`,className:e,children:(0,G.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,children:t.map(([e,t])=>{let{value:r}=X(n,e,t);return(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-[var(--miravo-radius-tight)] border border-border/60 bg-transparent px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:T(e)}),(0,G.jsxs)(`span`,{className:`blueprint-stat text-sm font-medium`,children:[typeof r==`number`?w(r):String(r),t.meta.unit&&(0,G.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:b(t.meta.unit)})]})]},e)})})})}function Q({className:e,detail:t,referenceMembers:n,memberValues:r}){let i=Object.keys(t.parameters).length>0,a=n.length>0;return!i&&!a?null:(0,G.jsx)(J,{title:`Nameplate & configuration`,subtitle:`Design parameters, identity, and reference values`,className:e,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[i&&(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:Object.entries(t.parameters).map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:T(e)}),(0,G.jsxs)(`span`,{className:`font-mono text-sm font-medium`,children:[typeof t.value==`number`?w(t.value):String(t.value),t.unit&&(0,G.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:b(t.unit)})]})]},e))}),a&&(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:n.map(([e,t])=>{let{value:n}=X(r,e,t);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-[var(--miravo-radius-tight)] border border-border/60 bg-transparent p-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:T(e)}),(0,G.jsxs)(`span`,{className:`font-mono text-sm font-medium`,children:[typeof n==`number`?w(n):String(n),t.meta.unit&&(0,G.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:b(t.meta.unit)})]})]},e)})})]})})}function Pe({detail:e,memberValues:t}){if(!e.members.state_label)return null;let n=n=>t?.get(n)?.value??e.members[n]?.value;return(0,G.jsxs)(`section`,{className:`flex flex-wrap items-center gap-3 text-sm`,"aria-label":`Station production`,children:[(0,G.jsx)(z,{variant:`secondary`,children:String(n(`state_label`)??`idle`)}),(0,G.jsxs)(`span`,{children:[`Good: `,w(Number(n(`good_count`)??0))]}),(0,G.jsxs)(`span`,{children:[`Scrap: `,w(Number(n(`scrap_count`)??0))]}),n(`stop_reason`)&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:String(n(`stop_reason`))})]})}var Fe=120,Ie=`gap-4 sm:gap-5 lg:gap-x-6 lg:gap-y-5 xl:gap-x-8`,$=`asset-detail-page relative isolate mx-auto flex min-h-full w-full max-w-screen-2xl flex-col gap-6 p-4 sm:gap-8 sm:p-6`;function Le(e){return e instanceof Error&&`code`in e&&e.code===`NOT_FOUND`?!0:e instanceof Error&&/^404\b/.test(e.message.trim())}function Re(){let{id:e}=ne(),t=te(),n=(0,W.useCallback)(()=>{(0,W.startTransition)(()=>{(0,W.addTransitionType)(ue),t(`/?tab=assets`)})},[t]),[r,i]=(0,W.useState)(!1),[a,o]=h(`tab`,ee([`hmi`,`operate`,`data`,`operations`]).withDefault(`hmi`)),s=a===`data`||a===`operations`?`operate`:a;(0,W.useEffect)(()=>{(a===`data`||a===`operations`)&&o(`operate`)},[a,o]);let c=(0,W.useCallback)(e=>{o(`operate`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})})},[o]);(0,W.useEffect)(()=>{let e=null,t=!1,r=()=>{t=!1,e&&=(clearTimeout(e),null)},a=a=>{if(a.metaKey||a.ctrlKey||a.altKey)return;let o=a.target;if(o){let e=o.tagName;if(e===`INPUT`||e===`TEXTAREA`||e===`SELECT`||o.isContentEditable)return}if(t){a.key===`f`?(c(`faults`),a.preventDefault()):a.key===`c`&&(c(`commands`),a.preventDefault()),r();return}if(a.key===`g`){t=!0,e=setTimeout(r,1200);return}a.key===`b`&&!a.shiftKey?(n(),a.preventDefault()):a.key===`?`&&(i(!0),a.preventDefault())};return window.addEventListener(`keydown`,a),()=>{window.removeEventListener(`keydown`,a),r()}},[n,c]);let g=p({queryKey:f.assets.detail(e??``),queryFn:()=>u(`/assets/${e}`,l.assetDetail),enabled:e!==void 0}),_=(0,W.useDeferredValue)(g.data??null),v=g.isError,y=d(t=>e?t.memberValues.get(e):void 0),b=d(e=>e.models),x=d(e=>e.assets),S=(0,W.useMemo)(()=>x.find(t=>t.id===e),[x,e]),C=S?.activeFaults,w=(0,W.useRef)(new Map),T=d(e=>e.tick);(0,W.useEffect)(()=>{if(!y||!e)return;let t=w.current;for(let[e,n]of y){if(typeof n.value!=`number`)continue;let r=t.get(e)??[];if(r[r.length-1]?.tick===T)continue;let i=r.length>=Fe?r.slice(r.length-Fe+1):r;t.set(e,[...i,{value:n.value,tick:T}])}},[y,T,e]);let E=(0,W.useMemo)(()=>_?De(_):[],[_]),D=(0,W.useMemo)(()=>{if(!_)return{operational:[],counters:[],reference:[]};let e=new Set(E.map(([e])=>e)),t=Object.entries(_.members).filter(([t])=>!e.has(t)),n=[],r=[],i=[];for(let e of t){let[,t]=e,a=t.meta.dataType,o=t.meta.kind,s=t.meta.unit,c=s===`pu`&&t.meta.euRange?.[0]===0&&t.meta.euRange?.[1]===1;o===`property`?i.push(e):a===`Boolean`||a===`String`||c?n.push(e):s===`count`||a===`UInt16`||a===`UInt32`?r.push(e):t.meta.access===`readwrite`||Ce.some(t=>e[0].endsWith(t))?n.push(e):s===`pu`||s===`h`?r.push(e):i.push(e)}return{operational:n,counters:r,reference:i}},[_,E]),ie=(0,W.useMemo)(()=>_?b.find(e=>e.name===_.assetType)?.faultNames??[]:[],[_,b]),O=C??_?.activeFaults??[],ae=(0,W.useMemo)(()=>{if(!y)return O.length>0;for(let[,e]of y)if(e.quality!==`good`)return!0;return!1},[y,O.length]),k=(0,W.useMemo)(()=>D.operational.filter(([,e])=>e.meta.dataType===`String`),[D.operational]),A=(0,W.useMemo)(()=>D.operational.filter(([,e])=>e.meta.dataType!==`String`),[D.operational]),M=he(e,_,()=>g.refetch());if(!_)return v?Le(g.error)?(0,G.jsx)(B,{className:`min-h-full`,children:(0,G.jsx)(`div`,{className:`flex min-h-[40vh] items-center justify-center p-6 sm:p-12`,children:(0,G.jsx)(`div`,{className:`w-full max-w-md`,children:(0,G.jsxs)(ce,{eyebrow:`Asset lookup`,stamp:`404`,title:`Asset not found`,detail:e??`Unknown asset id`,detailLabel:`Requested asset`,primaryLabel:`Back to Assets`,onPrimary:n,children:[(0,G.jsx)(`p`,{children:`The requested asset is no longer in the running factory or the URL is wrong.`}),(0,G.jsx)(`p`,{children:`Return to Assets and pick a live asset from the current factory.`})]})})})}):(0,G.jsx)(B,{className:`min-h-full`,children:(0,G.jsxs)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center gap-4 p-6 sm:p-12`,children:[(0,G.jsx)(`div`,{className:`w-full max-w-md`,children:(0,G.jsx)(le,{message:de(g.error,`Could not load asset.`),onRetry:()=>void g.refetch(),isRetrying:g.isFetching})}),(0,G.jsx)(re,{variant:`outline`,size:`sm`,onClick:n,children:`Back to Assets`})]})}):S?(0,G.jsx)(`div`,{className:$,children:(0,G.jsx)(K,{detail:{id:S.id,assetType:S.model,browsePath:S.browsePath,lifecycleStage:S.lifecycleStage,operatingHours:S.operatingHours,activeFaults:S.activeFaults,isQuarantined:S.isQuarantined,parameters:{},inputs:{},members:{},methods:{}},tick:T,activeFaults:O,memberValues:y,onBack:n})}):null;let N=D.operational.length>0,P=D.counters.length>0,F=D.reference.length>0||Object.keys(_.parameters).length>0,I=N||P||F,L=Object.keys(_.methods).length>0,R=N&&!P&&!F,z=N&&P&&F;return(0,G.jsxs)(`div`,{className:$,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 -z-10 hidden select-none overflow-hidden md:block`,children:(0,G.jsx)(`span`,{className:`absolute -top-2 left-0 whitespace-nowrap uppercase leading-none opacity-35 blur-[2px]`,style:{fontFamily:`var(--miravo-font-heading)`,fontSize:`clamp(5rem, 14vw, 12rem)`,fontWeight:`var(--miravo-weight-medium)`,letterSpacing:`var(--miravo-tracking-heading)`,color:`var(--miravo-ghost)`},children:_.assetType.replace(/_/g,` `)})}),(0,G.jsx)(K,{detail:_,tick:T,activeFaults:O,memberValues:y,onBack:n}),(0,G.jsx)(Pe,{detail:_,memberValues:y}),(0,G.jsx)(W.ViewTransition,{enter:`fade-in`,default:`none`,children:(0,G.jsxs)(me,{value:s,onValueChange:e=>{o(e)},className:`min-h-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,G.jsxs)(pe,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,G.jsxs)(H,{value:`hmi`,className:`gap-1.5 px-3 text-sm`,children:[(0,G.jsx)(oe,{className:`size-3.5 shrink-0`}),`HMI`]}),(0,G.jsxs)(H,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,G.jsx)(se,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,G.jsx)(U,{value:`hmi`,className:`flex-1 py-2`,children:(0,G.jsx)(m.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:(0,G.jsx)(Ae,{detail:_,processVariables:E,memberValues:y,historyRef:w,tick:T,showQuality:ae})},`hmi`)}),(0,G.jsx)(U,{value:`operate`,className:`flex-1 py-2`,children:(0,G.jsxs)(m.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex min-w-0 flex-col gap-4`,children:[I&&(0,G.jsxs)(`section`,{"aria-label":`Data`,className:j(`grid min-w-0 grid-cols-1`,Ie,z&&`lg:grid-cols-2 lg:grid-rows-[auto_auto] lg:items-start`,!z&&N&&(P||F)&&`lg:grid-cols-2 lg:items-start`),children:[N&&(0,G.jsx)(Ne,{stringEnumMembers:k,nonStringOperationalMembers:A,memberValues:y,className:j(`min-h-0 min-w-0 self-stretch`,R&&`lg:col-span-2`,z&&`lg:row-span-2`)}),!N&&P&&F&&(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col gap-6 lg:col-span-2`,children:[(0,G.jsx)(Z,{counters:D.counters,memberValues:y}),(0,G.jsx)(Q,{detail:_,referenceMembers:D.reference,memberValues:y})]}),!N&&P&&!F&&(0,G.jsx)(Z,{className:`lg:col-span-2`,counters:D.counters,memberValues:y}),!N&&!P&&F&&(0,G.jsx)(Q,{className:`lg:col-span-2`,detail:_,referenceMembers:D.reference,memberValues:y}),N&&P&&(0,G.jsx)(Z,{className:`min-h-0 min-w-0 self-stretch lg:col-start-2 lg:row-start-1`,counters:D.counters,memberValues:y}),N&&F&&(0,G.jsx)(Q,{className:j(`min-h-0 min-w-0 self-stretch lg:col-start-2`,z?`lg:row-start-2`:`lg:row-start-1`),detail:_,referenceMembers:D.reference,memberValues:y})]}),(0,G.jsxs)(`section`,{"aria-label":`Operations`,className:j(V,`grid grid-cols-1`,L&&`lg:grid-cols-2`),children:[(0,G.jsx)(ge,{activeFaults:O,availableFaults:ie,onTriggerFault:M.triggerFault,onClearFault:M.clearFault}),L&&(0,G.jsx)(`div`,{className:`border-t border-border/50 lg:border-l lg:border-t-0`,children:(0,G.jsx)(ve,{detail:_,methodArgs:M.methodArgs,setMethodArgs:M.setMethodArgs,onInvoke:M.invoke,isPending:M.isPending,pendingMethod:M.pendingMethod})})]}),(0,G.jsx)(_e,{assetId:_.id,onRemoved:n})]},`operate`)})]})}),(0,G.jsx)(ze,{open:r,onOpenChange:i})]})}function ze({open:e,onOpenChange:t}){return(0,G.jsx)(y,{open:e,onOpenChange:t,children:(0,G.jsxs)(g,{children:[(0,G.jsx)(_,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,G.jsx)(v,{className:`text-sm text-muted-foreground`,children:`Navigate this asset without leaving the keyboard.`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-2 pt-1`,children:[{keys:[`g`,`f`],label:`Jump to Alarms`},{keys:[`g`,`c`],label:`Jump to Commands`},{keys:[`b`],label:`Back to Assets`},{keys:[`?`],label:`Show this sheet`}].map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),(0,G.jsx)(`span`,{className:`flex items-center gap-1`,children:e.keys.map((t,n)=>(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`kbd`,{className:`rounded-[var(--miravo-radius-tight)] border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground`,children:t}),n<e.keys.length-1&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`then`})]},`${e.label}-${t}`))})]},e.label))})]})})}export{Re as AssetDetailPage};
|
|
@@ -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{ot as r}from"./api-B2QJEzbS.js";import{i,n as a,o,r as s,t as c}from"./dialog-B5PqrKVw.js";import{C as l,S as u,c as d}from"./format-Bx7DF-TB.js";import{t as f}from"./utils-XFKvwlFT.js";import{n as p,t as m}from"./circle-x-_o0nl0Rg.js";import{t as h}from"./loader-circle-DjgHgHHl.js";import{t as g}from"./play-kg50os4l.js";import{t as _}from"./trash-2-BH9HDsZv.js";import{t as v}from"./triangle-alert-DoAwrRgk.js";import{a as y,i as b}from"./validation-BkfmaBBi.js";import{i as x,n as S,t as C}from"./tooltip-B3vOB1Vu.js";import{t as w}from"./badge-Bk1DaL6C.js";import{t as T}from"./use-engine-command-mutation-CHqjOqfS.js";var E=e(t(),1);function D(e,t,n){let[r,i]=(0,E.useState)({}),[a,o]=(0,E.useState)(null),s=T();(0,E.useEffect)(()=>{s.isPending||o(null)},[s.isPending]);let c=e=>{s.mutateAsync(e).then(n).catch(()=>{})};return{methodArgs:r,setMethodArgs:i,pendingMethod:a,isPending:s.isPending,invoke:n=>{if(!e)return;let i={},a=t?.methods[n];if(a)for(let e of a.inputArguments){let t=r[n]?.[e.name]??``,a=b(e.name,t,e.dataType);if(!a)return;i[e.name]=a.value}o(n),c({type:`invokeMethod`,assetId:e,method:n,arguments:i})},triggerFault:t=>{e&&c({type:`triggerFault`,assetId:e,fault:t})},clearFault:t=>{e&&c({type:`clearFault`,assetId:e,fault:t})}}}var O=n(),k=`bg-transparent bg-transparent`,A=`blueprint-title text-foreground`;function j(e,t){return t.includes(`rpm`)||t.includes(`speed`)?`e.g. 2500`:t.includes(`temp`)?`e.g. 70.0`:t.includes(`pressure`)?`e.g. 4.5`:e===`Boolean`?`true / false`:e===`String`?`value`:`e.g. 100`}function M({detail:e,methodArgs:t,setMethodArgs:n,onInvoke:r,isPending:i=!1,pendingMethod:a=null}){let o=Object.entries(e.methods);if(o.length===0)return null;let s=o.filter(([,e])=>e.inputArguments.length===0),c=o.filter(([,e])=>e.inputArguments.length>0);return(0,O.jsxs)(`div`,{id:`commands`,className:`flex min-w-0 flex-col gap-3 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,O.jsx)(`h2`,{className:A,children:`Commands`}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground/75`,children:`Executable methods on this asset`})]}),s.length>0&&(0,O.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s.map(([e,t])=>{let n=a===e&&i,o=n?h:g;return t.description?(0,O.jsxs)(C,{children:[(0,O.jsx)(x,{render:(0,O.jsxs)(l,{size:`sm`,variant:`outline`,disabled:i,title:e,className:f(`h-8 gap-1.5 font-mono text-xs`,k),onClick:()=>r(e),children:[(0,O.jsx)(o,{className:f(`size-3`,n&&`animate-spin`),"aria-hidden":!0}),d(e)]})}),(0,O.jsx)(S,{side:`bottom`,className:`max-w-xs`,children:t.description})]},e):(0,O.jsxs)(l,{size:`sm`,variant:`outline`,disabled:i,title:e,className:f(`h-8 gap-1.5 font-mono text-xs`,k),onClick:()=>r(e),children:[(0,O.jsx)(o,{className:f(`size-3`,n&&`animate-spin`),"aria-hidden":!0}),d(e)]},e)})}),c.length>0&&s.length>0&&(0,O.jsx)(y,{className:`bg-border/60`}),c.map(([e,o])=>{let s=a===e&&i;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{title:e,className:`font-mono text-sm font-medium`,children:d(e)}),o.description&&(0,O.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:o.description})]}),(0,O.jsxs)(l,{size:`sm`,variant:`default`,disabled:i,className:`shrink-0`,onClick:()=>r(e),children:[s?(0,O.jsx)(h,{className:`mr-1 size-3 animate-spin`,"aria-hidden":!0}):(0,O.jsx)(g,{className:`mr-1 size-3`,"aria-hidden":!0}),`Execute`]})]}),(0,O.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5 border-t border-border/50 pt-3`,children:o.inputArguments.map(r=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(`span`,{title:r.name,className:`w-28 shrink-0 truncate pt-1.5 font-mono text-[10px] leading-tight text-muted-foreground`,children:d(r.name)}),(0,O.jsx)(u,{className:`h-7 flex-1 font-mono text-xs`,placeholder:j(r.dataType,r.name),value:t[e]?.[r.name]??``,onChange:t=>n(n=>({...n,[e]:{...n[e],[r.name]:t.target.value}}))})]},r.name))})]},e)})]})}function N({activeFaults:e,availableFaults:t,onTriggerFault:n,onClearFault:r}){let u=e.length>0,[h,g]=(0,E.useState)(null);return(0,O.jsxs)(`div`,{id:`faults`,className:`flex min-w-0 flex-col gap-3 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,O.jsx)(`h2`,{className:A,children:`Alarms`}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground/75`,children:`Active faults and injectable failure modes (factory)`})]}),u?(0,O.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[var(--miravo-radius-tight)] border border-destructive/30 bg-transparent py-2.5 pl-3 pr-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(v,{className:`size-4 shrink-0 text-destructive`}),(0,O.jsx)(`span`,{title:e,className:`font-mono text-sm font-medium text-destructive`,children:d(e)})]}),(0,O.jsxs)(l,{size:`sm`,variant:`outline`,className:f(`h-8 shrink-0 gap-1 border-destructive/30 px-2.5 font-mono text-[0.75rem] text-destructive shadow-none`,`hover:border-destructive/45 hover:bg-destructive/5 hover:text-destructive`,`focus-visible:border-destructive/40 focus-visible:ring-destructive/20`,k),onClick:()=>r(e),children:[(0,O.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),`Clear`]})]},e))}):(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(p,{className:`size-4 text-success`}),`All clear — no active faults`]}),t.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(y,{className:`bg-border/60`}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`p`,{className:f(A,`mb-2`),children:[`Inject fault`,(0,O.jsxs)(w,{variant:`secondary`,className:`ml-2 text-[10px]`,children:[t.filter(t=>!e.includes(t)).length,` available`]})]}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.filter(t=>!e.includes(t)).map(e=>(0,O.jsx)(l,{size:`sm`,variant:`outline`,title:e,className:f(`h-7 font-mono text-[10px]`,k),onClick:()=>g(e),children:d(e)},e))})]})]}),(0,O.jsx)(c,{open:h!==null,onOpenChange:e=>{e||g(null)},children:(0,O.jsxs)(a,{children:[(0,O.jsx)(o,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Inject fault?`}),(0,O.jsxs)(s,{className:`text-sm text-muted-foreground`,children:[`This asserts`,` `,(0,O.jsx)(`span`,{title:h??void 0,className:`font-mono text-foreground`,children:h?d(h):``}),` `,`on the running factory. Downstream consumers will see the fault immediately. Clear it from the active list when you're done.`]}),(0,O.jsxs)(i,{children:[(0,O.jsx)(l,{variant:`outline`,onClick:()=>g(null),children:`Cancel`}),(0,O.jsxs)(l,{variant:`destructive`,onClick:()=>{h&&n(h),g(null)},children:[(0,O.jsx)(v,{className:`mr-1 size-3.5`,"aria-hidden":!0}),`Inject fault`]})]})]})})]})}function P({assetId:e,onRemoved:t}){let[n,u]=(0,E.useState)(!1),[d,f]=(0,E.useState)(!1),p=T(),m=r(t=>t.templates.find(t=>t.assetIds.includes(e))),h=r(t=>t.lines.find(t=>t.stations.some(t=>t.id===e))?.line);return h?(0,O.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-4`,children:[(0,O.jsx)(`h2`,{className:A,children:`Remove asset`}),(0,O.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/75`,children:[`This asset is a station on line `,h,`. Unload`,` `,m?.templateName??`its template`,` to remove the line.`]})]}):(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h2`,{className:A,children:`Remove asset`}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground/75`,children:m?`Removes this asset from the running factory. ${m.templateName} stays loaded without it.`:`Removes this standalone asset from the running factory.`})]}),(0,O.jsxs)(l,{size:`sm`,variant:`destructive`,className:`shrink-0`,onClick:()=>u(!0),children:[(0,O.jsx)(_,{className:`mr-1 size-3.5`,"aria-hidden":!0}),`Remove`]}),(0,O.jsx)(c,{open:n,onOpenChange:u,children:(0,O.jsxs)(a,{children:[(0,O.jsxs)(o,{className:`font-heading text-lg font-semibold tracking-tight`,children:[`Remove `,e,`?`]}),(0,O.jsx)(s,{className:`text-sm text-muted-foreground`,children:`The asset and its live values are removed from the factory. With persistence on, the change is saved.`}),(0,O.jsxs)(i,{children:[(0,O.jsx)(l,{variant:`outline`,onClick:()=>u(!1),disabled:d,children:`Cancel`}),(0,O.jsx)(l,{variant:`destructive`,onClick:async()=>{f(!0);try{await p.mutateAsync({type:`removeAsset`,assetId:e}),u(!1),t()}catch{}finally{f(!1)}},disabled:d,children:`Remove asset`})]})]})})]})}export{D as i,N as n,P as r,M 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-B2QJEzbS.js";import{t as s}from"./useQuery-M9KTdi7Q.js";import{n as c}from"./chunk-OE4NN4TA-DBWZidbW.js";import{C as l,_ as u,d,f,g as p,w as m}from"./format-Bx7DF-TB.js";import{t as h}from"./arrow-up-right-CwPw_2U1.js";import{t as g}from"./chevron-left-XHFooLn1.js";import{t as _}from"./model-schemas-3w38IPdc.js";import{i as v,r as y}from"./console-panel-CMDoBJiO.js";import{i as b,n as x,t as S}from"./asset-detail-actions-jjbvaDES.js";var C=e(t(),1),w=n(),T=new Set([`off_shift`,`down_planned`,`stopped`,`idle`,`steady`]),E=new Set([`down`,`fault`,`failed`]);function D(e,t){return t?`fault`:e?e===`running`||e===`filling`?`live`:E.has(e)?`fault`:T.has(e)?`off`:`idle`:`off`}function O(e){return e?e.replace(/_/g,` `):`–`}var k=new Set([`Boolean`,`String`]),A=/_(command|reference|setpoint|sp|target)$/,j=`pu`;function M(e,t=2){if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.members))r.kind!==`variable`||r.access!==`read`||k.has(r.dataType)||A.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!==j),...n.filter(e=>e.unit===j)].slice(0,t)}function N(e,t,n){let r=(0,C.useRef)(new Map),i=(0,C.useRef)(n);i.current=n;let[,o]=(0,C.useState)(0),s=t.join(`|`);return(0,C.useEffect)(()=>{if(r.current=new Map,!e)return;let t=s.split(`|`).filter(Boolean);return a.subscribe((n,a)=>{if(n.tick===a.tick)return;let s=n.memberValues.get(e);for(let e of t){let t=r.current.get(e)??[],n=s?.get(e)?.value,a=typeof n==`number`?n:t.at(-1)??i.current(e);a!==void 0&&(t.push(a),t.length>90&&t.shift(),r.current.set(e,t))}o(e=>e+1)})},[e,s]),r.current}var P=100,F=22;function I(e,t,n){if(e.length<2)return``;let r=n-t||1,i=90-e.length;return e.map((e,a)=>{let o=(i+a)/89*P,s=F-3-(Math.min(n,Math.max(t,e))-t)/r*(F-6);return`${a?`L`:`M`}${o.toFixed(1)} ${s.toFixed(1)}`}).join(``)}function L({reading:e,value:t,series:n}){let{member:r,unit:i,min:a,max:o}=e,s=t===void 0?0:Math.max(0,Math.min(1,(t-a)/(o-a)));return(0,w.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,w.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:p(r)}),(0,w.jsxs)(`span`,{className:`shrink-0 font-mono text-sm font-semibold tabular-nums`,children:[t===void 0?`–`:f(t),(0,w.jsx)(`span`,{className:`ml-1 text-[10px] font-medium text-muted-foreground`,children:u(i)})]})]}),(0,w.jsxs)(`svg`,{viewBox:`0 0 ${P} ${F}`,preserveAspectRatio:`none`,className:`h-6 w-full overflow-visible`,role:`img`,"aria-label":`${r} trend`,children:[(0,w.jsx)(`rect`,{x:`0`,y:F-1.2,width:P,height:`1.2`,className:`fill-border`}),(0,w.jsx)(`rect`,{x:`0`,y:F-1.2,width:s*P,height:`1.2`,className:`fill-info/70`}),(0,w.jsx)(`path`,{d:I(n,a,o),className:`fill-none stroke-info`,strokeWidth:`1`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})]})]})}var R=6;function z({title:e,note:t,children:n}){return(0,w.jsxs)(`section`,{className:`flex flex-col gap-3 border-t border-border/50 px-4 py-4`,children:[(0,w.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,w.jsx)(`h3`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e}),t?(0,w.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]}),n]})}function B({name:e,sub:t,pill:n,onBack:r}){return(0,w.jsxs)(`header`,{className:`flex flex-col gap-2 px-4 pt-3 pb-4`,children:[(0,w.jsxs)(l,{size:`sm`,variant:`ghost`,className:`-ml-2 h-7 w-fit gap-1 px-2 text-xs text-muted-foreground`,onClick:r,children:[(0,w.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),`Line`]}),(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,w.jsx)(`h2`,{className:`truncate font-heading text-lg font-medium tracking-tight`,children:e}),(0,w.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:t})]}),n]})]})}function V({label:e,value:t}){return(0,w.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,w.jsx)(`span`,{className:`font-mono text-lg font-semibold tabular-nums`,children:t})]})}function H({thing:e,assetId:t,line:n,basis:l,onBack:u}){let f=s({queryKey:o.assets.detail(t),queryFn:()=>i(`/assets/${t}`,r.assetDetail)}),p=f.data,g=a(e=>e.assets.find(e=>e.id===t)),C=a(e=>e.models),T=a(e=>e.memberValues.get(t)),E=g?.model??p?.assetType,k=M(_(E?[E]:[]).data?.[0],R),A=b(t,p,()=>f.refetch()),j=g?.activeFaults??[],P=C.find(e=>e.name===E)?.faultNames??[],F=n?.stations.find(e=>e.id===t),I=n?.buffers.find(e=>e.after===t),H=T?.get(`availability_state`)?.value,U=F?.state??(l===`availability`&&typeof H==`string`?H:T?.get(`run_command`)?.value===!1?`stopped`:`running`),W=F?.good??0,G=F?.scrap??0,K=e=>{let t=T?.get(e)?.value??p?.members[e]?.value;return typeof t==`number`?t:void 0},q=N(t,k.map(e=>e.member),K);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(B,{name:e.name,sub:`${t} · ${E??`…`}`,onBack:u,pill:(0,w.jsx)(v,{tone:D(U,j.length>0),children:(0,w.jsx)(y,{children:j.length>0?`fault`:O(U)})})}),F?(0,w.jsx)(z,{title:`Production`,note:I?`buffer ${I.level}/${I.capacity}`:`end of line`,children:(0,w.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,w.jsx)(V,{label:`Good`,value:d(W)}),(0,w.jsx)(V,{label:`Scrap`,value:d(G)}),(0,w.jsx)(V,{label:`Yield`,value:W+G>0?`${(W/(W+G)*100).toFixed(1)}%`:`–`})]})}):null,k.length>0?(0,w.jsx)(z,{title:`Live`,note:`last 90 ticks`,children:(0,w.jsx)(`div`,{className:`flex flex-col gap-3`,children:k.map(e=>(0,w.jsx)(L,{reading:e,value:K(e.member),series:q.get(e.member)??[]},e.member))})}):null,p&&Object.keys(p.methods).length>0?(0,w.jsx)(`div`,{className:`border-t border-border/50 [&>#commands]:px-4`,children:(0,w.jsx)(S,{detail:p,methodArgs:A.methodArgs,setMethodArgs:A.setMethodArgs,onInvoke:A.invoke,isPending:A.isPending,pendingMethod:A.pendingMethod})}):null,(0,w.jsx)(`div`,{className:`border-t border-border/50`,children:(0,w.jsx)(x,{activeFaults:j,availableFaults:P,onTriggerFault:A.triggerFault,onClearFault:A.clearFault})}),(0,w.jsx)(`div`,{className:`border-t border-border/50 px-4 py-3`,children:(0,w.jsxs)(c,{to:`/asset/${encodeURIComponent(t)}`,className:m({size:`sm`,variant:`ghost`,className:`-ml-2 gap-1`}),children:[`Open asset page`,(0,w.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})]})})]})}export{D as i,z as n,O as r,H as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ot as e}from"./vendor-ui-D8j69UH4.js";import{ot as t}from"./api-B2QJEzbS.js";import{t as n}from"./utils-XFKvwlFT.js";import{t as r}from"./chevron-right-CMSQPSEo.js";import{n as i,r as a}from"./asset-panel-DDziFlFl.js";var o=e(),s={g:`bg-success`,a:`bg-warning`,r:`bg-destructive`,"":`bg-muted-foreground/50`};function c({label:e,value:t}){return(0,o.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,o.jsx)(`span`,{className:`font-mono text-lg font-semibold tabular-nums`,children:t})]})}function l({name:e,level:t}){return(0,o.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,o.jsx)(`span`,{className:`w-28 shrink-0 truncate text-xs text-muted-foreground`,children:e}),(0,o.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,o.jsx)(`span`,{className:`block h-full rounded-full bg-info`,style:{width:`${Math.max(0,Math.min(100,t))}%`}})}),(0,o.jsxs)(`span`,{className:`w-10 shrink-0 text-right font-mono text-[11px] tabular-nums`,children:[t.toFixed(0),` %`]})]})}function u({things:e,status:u,onSelect:d}){let f=t(e=>e.memberValues),p=e.map(e=>({thing:e,status:u(e.key)})),m=p.filter(e=>e.status[1]===`r`).length,h=p.filter(e=>e.status[0]===`stopped`).length,g=p.length-m-h,_=e.flatMap(e=>{let t=f.get(e.assetId)?.get(`level_percent`)?.value;return typeof t==`number`?[{name:e.name,level:t}]:[]}),v=[...new Set(e.map(e=>e.area??``))];return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 px-4 pt-4 pb-5`,children:[(0,o.jsx)(c,{label:`Online`,value:String(g)}),(0,o.jsx)(c,{label:`Stopped`,value:String(h)}),(0,o.jsx)(c,{label:`Faulted`,value:String(m)})]}),_.length>0?(0,o.jsx)(i,{title:`Levels`,note:`live`,children:(0,o.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:_.map(e=>(0,o.jsx)(l,{name:e.name,level:e.level},e.name))})}):null,v.map(e=>(0,o.jsx)(i,{title:e,note:`flow order`,children:(0,o.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:p.filter(t=>(t.thing.area??``)===e).map(({thing:e,status:[t,i]})=>(0,o.jsx)(`li`,{children:(0,o.jsxs)(`button`,{type:`button`,onClick:()=>d(e.key),className:`group flex w-full items-center gap-2.5 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,o.jsx)(`span`,{className:n(`size-1.5 shrink-0 rounded-full`,s[i])}),(0,o.jsx)(`span`,{className:`min-w-0 shrink text-sm`,children:e.name}),(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground tabular-nums`,children:a(t)}),(0,o.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground/60 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})},e.key))})},e))]})}function d(e,{template:t,assets:n}){let r=new Set(t.assetIds),i=n.filter(e=>r.has(e.id)),a=new Map;for(let[,t,n,r]of e){let e=`${t}|${n}|${r}`;a.set(e,(a.get(e)??0)+1)}let o={};for(let[t,n,r,s,c]of e){let e=i.filter(e=>e.model===n&&e.browsePath?.[2]===r&&e.browsePath?.[3]===s).map(e=>e.id).sort(),l=e[c];if(!l||e.length!==a.get(`${n}|${r}|${s}`))return{status:`mismatch`};o[t]=l}return{status:`ready`,ids:o}}export{u as n,d 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-B2QJEzbS.js";import{t as s}from"./useQuery-M9KTdi7Q.js";import{t as c}from"./proxy-CWZabK8f.js";import{t as l}from"./AnimatePresence-BSSlw02V.js";import{c as u,n as d}from"./chunk-OE4NN4TA-DBWZidbW.js";import{a as ee,c as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-B5PqrKVw.js";import{C as v,S as y,u as b,w as x}from"./format-Bx7DF-TB.js";import{n as S,t as C}from"./utils-XFKvwlFT.js";import{n as w,t as T}from"./catalog-template-icons-BOSywIKV.js";import{r as E}from"./source-host-miravo-B8eM2IHw.js";import{t as D}from"./play-kg50os4l.js";import{t as O}from"./query-fetch-error-CWLZA2L5.js";import{t as k}from"./rocket-KZ5oHK1G.js";import{i as A,n as j,r as M,t as N}from"./catalog-source-B4L5N-a1.js";import{t as P}from"./badge-Bk1DaL6C.js";import{n as te}from"./get-error-message-dM0BMfdP.js";import{a as ne,i as F,o as I,t as L}from"./use-engine-command-mutation-CHqjOqfS.js";var R=S(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),z=e(t(),1),B=n(),V=[`builtin`,`personal`];function H(){let[e,t]=(0,z.useState)(``),[n,d]=(0,z.useState)(`all`),[x,S]=(0,z.useState)(null),[T,E]=(0,z.useState)(null),[D,j]=(0,z.useState)(null),N=(0,z.useRef)(null),F=L(),I=u(),R=a(e=>e.templates),H=(0,z.useMemo)(()=>new Set(R.map(e=>e.templateId)),[R]);(0,z.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(),N.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let W=s({queryKey:o.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),K=W.data??[],q=T===null?null:K.find(e=>e.id===T)??null,J=W.isPending&&!W.data,Y=W.isError&&!W.data,X=W.isError&&!!W.data,Z=te(W.error,`Failed to load templates.`),re=(0,z.useCallback)(e=>{j(e)},[]),ie=(0,z.useCallback)(e=>{E(e)},[]),ae=async e=>{S(e);try{return await F.mutateAsync({type:`loadTemplate`,templatePath:e}),f(`Next: connect a client`),I(`/?highlight=${encodeURIComponent(e)}`),!0}catch{return!1}finally{S(null)}},oe=(0,z.useMemo)(()=>{let e={all:K.length};for(let t of V)e[t]=0;for(let t of K){let n=M(t.source);e[n]=(e[n]??0)+1}return e},[K]),Q=e.toLowerCase(),$=K.filter(e=>n===`all`||M(e.source)===n).filter(e=>Q?e.name.toLowerCase().includes(Q)||e.id.toLowerCase().includes(Q)||(e.description?.toLowerCase().includes(Q)??!1):!0);return(0,B.jsxs)(`div`,{className:`@container/templates mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Template Catalog`}),(0,B.jsx)(P,{variant:`outline`,className:`text-xs`,children:Y?(0,B.jsx)(`span`,{className:`text-destructive`,children:`Unavailable`}):J&&K.length===0?(0,B.jsx)(B.Fragment,{children:`Loading...`}):(0,B.jsxs)(B.Fragment,{children:[new Set(K.map(e=>e.id)).size,` templates`]})})]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose a template to launch a realistic industrial system. Each template includes pre-configured asset models with realistic physics, lifecycle degradation, and fault modes.`})]}),Y&&(0,B.jsx)(O,{message:Z,onRetry:()=>void W.refetch(),isRetrying:W.isFetching}),X&&(0,B.jsx)(O,{message:`${Z} Showing cached templates.`,onRetry:()=>void W.refetch(),isRetrying:W.isFetching}),!Y&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative max-w-xs flex-1 min-w-[14rem]`,children:[(0,B.jsx)(A,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,B.jsx)(y,{ref:N,placeholder:`Filter templates...`,value:e,onChange:e=>t(e.target.value),className:`pl-9 pr-7`}),!e&&(0,B.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-[var(--miravo-radius-tight)] border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),(0,B.jsx)(G,{value:n,counts:oe,onChange:d})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @[720px]/templates:grid-cols-2`,"aria-busy":J&&!Y,children:Y?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(l,{children:$.map((e,t)=>(0,B.jsx)(c.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.96,transition:{duration:.15}},transition:{type:`spring`,stiffness:380,damping:30,delay:t*.04},className:`grid`,children:(0,B.jsx)(U,{template:e,launching:x===e.id,loaded:H.has(e.id),onInspect:re,onLaunch:ie})},`${e.source}:${e.id}`))}),$.length===0&&K.length>0&&(0,B.jsx)(`p`,{className:`col-span-full py-8 text-center text-sm text-muted-foreground`,children:`No templates match the current filters.`})]})}),K.length>0&&(0,B.jsx)(`div`,{className:C(ne,`p-0`),children:(0,B.jsx)(`div`,{className:`community-teaser relative overflow-hidden rounded-[inherit]`,children:(0,B.jsx)(`div`,{className:`relative z-10 mx-auto max-w-3xl px-5 py-10 sm:px-10 sm:py-12`,children:(0,B.jsxs)(`div`,{className:`grid items-center gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,17rem)]`,children:[(0,B.jsxs)(`div`,{className:`order-2 flex min-w-0 flex-col gap-4 lg:order-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,B.jsx)(`p`,{className:`blueprint-title text-primary`,children:`Future channel`}),(0,B.jsx)(`span`,{className:`blueprint-stat text-[10px] text-muted-foreground`,children:`MIRAVO_REGISTRY · NOT_CONNECTED`})]}),(0,B.jsx)(`h2`,{className:`font-heading text-xl font-semibold tracking-tight sm:text-2xl`,children:`Community Templates`}),(0,B.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:`Share your industrial templates with the Miravo community. Publish custom templates, discover configurations from other engineers, and fork them as your starting point.`}),(0,B.jsx)(`div`,{children:(0,B.jsx)(P,{variant:`outline`,className:`community-teaser-soon border-primary/35 bg-primary/5 text-[10px] text-primary`,children:`Coming Soon`})})]}),(0,B.jsx)(`div`,{className:`order-1 flex justify-center lg:order-2 lg:justify-end`,children:(0,B.jsxs)(`div`,{className:`community-teaser-module relative flex w-full max-w-[14rem] flex-col items-center justify-center gap-3 border border-primary/15 bg-muted/15 py-8 sm:max-w-[15.5rem] sm:py-10`,"aria-hidden":!0,children:[(0,B.jsx)(`div`,{className:`community-teaser-icon-ring relative z-[1] flex size-[4.25rem] items-center justify-center rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-gradient-to-br from-primary/18 to-primary/5`,children:(0,B.jsx)(k,{className:`size-9 text-primary`,"aria-hidden":!0})}),(0,B.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] tracking-[0.18em] text-muted-foreground`,children:`AWAITING SIGNAL`}),(0,B.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] text-muted-foreground`,children:`Uplink idle`})]})})]})})})}),(0,B.jsx)(_,{open:T!==null,onOpenChange:e=>{e||E(null)},children:(0,B.jsxs)(m,{className:`min-w-0 sm:max-w-md`,children:[(0,B.jsxs)(ee,{children:[(0,B.jsx)(h,{children:`Launch template?`}),(0,B.jsx)(g,{children:q!==null&&(0,B.jsxs)(B.Fragment,{children:[`This loads`,` `,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:b(q.name)}),` `,`into the running factory.`]})})]}),(0,B.jsxs)(p,{children:[(0,B.jsx)(v,{variant:`outline`,disabled:x!==null,onClick:()=>E(null),children:`Cancel`}),(0,B.jsx)(v,{disabled:x!==null||q===null,onClick:async()=>{q!==null&&await ae(q.id)&&E(null)},children:x===q?.id?`Launching...`:`Launch`})]})]})}),(0,B.jsx)(w,{templateId:D?.id??null,onClose:()=>j(null)})]})}var U=(0,z.memo)(function({template:e,launching:t,loaded:n,onInspect:r,onLaunch:i}){return(0,B.jsxs)(`div`,{className:C(I,`flex flex-col gap-4 p-5`),children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.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,B.jsx)(T,{id:e.id,className:`size-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`font-heading text-sm font-semibold uppercase tracking-wide`,children:b(e.name)}),(0,B.jsx)(`p`,{className:`line-clamp-3 text-xs leading-relaxed text-foreground/75`,children:e.description??`Industrial template.`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id})]})]}),(0,B.jsx)(`div`,{className:`px-3 py-2`,children:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.models.map(e=>(0,B.jsx)(P,{variant:`outline`,className:`h-auto min-h-5 rounded-[var(--miravo-radius-tight)] px-1.5 py-0 font-mono text-[10px] font-normal text-primary`,children:e},e))})}),(0,B.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-4 font-mono text-[11px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-foreground`,children:e.assetCount}),` assets`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-foreground`,children:e.models.length}),` models`]}),e.memberCount>0&&(0,B.jsxs)(`span`,{children:[`~`,(0,B.jsx)(`span`,{className:`text-foreground`,children:W(e.memberCount)}),` tags/cycle`]}),n&&(0,B.jsx)(P,{variant:`outline`,className:`ml-auto shrink-0 border-success/40 bg-success/10 font-sans text-[10px] font-medium uppercase tracking-wide text-success`,children:`Loaded`}),(0,B.jsx)(P,{variant:`outline`,className:C(`shrink-0 font-sans text-[10px] font-medium uppercase tracking-wide`,!n&&`ml-auto`,N(e.source)),children:j(e.source)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,B.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e),className:F,children:[(0,B.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),n?(0,B.jsxs)(d,{to:`/`,className:C(x({size:`sm`}),`ml-auto`),children:[(0,B.jsx)(R,{className:`mr-1 size-3`,"aria-hidden":!0}),`Open`]}):(0,B.jsxs)(v,{size:`sm`,className:`ml-auto`,disabled:t,onClick:()=>i(e.id),children:[(0,B.jsx)(D,{className:`mr-1 size-3`}),t?`...`:`Launch`]})]})]})});function W(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function G({value:e,counts:t,onChange:n}){return(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`radiogroup`,"aria-label":`Filter by source`,children:[{id:`all`,label:`All`},...V.map(e=>({id:e,label:j(e)}))].map(r=>{let i=e===r.id,a=t[r.id]??0,o=r.id!==`all`&&a===0;return(0,B.jsxs)(`label`,{className:C(`inline-flex h-7 items-center gap-1.5 rounded-[var(--miravo-radius-pill)] border px-3 text-xs font-medium transition-colors`,i?`border-primary/60 bg-primary/15 text-primary`:`border-border/60 bg-card/30 text-muted-foreground hover:border-border hover:bg-muted/40 hover:text-foreground`,o?`cursor-not-allowed opacity-40 hover:border-border/60 hover:bg-card/30 hover:text-muted-foreground`:`cursor-pointer`),children:[(0,B.jsx)(`input`,{type:`radio`,name:`catalog-source-filter`,value:r.id,checked:i,disabled:o,onChange:()=>n(r.id),className:`sr-only`}),(0,B.jsx)(`span`,{children:r.label}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] opacity-70`,children:a})]},r.id)})})}export{R as n,H as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./catalog-BlkPPAWE.js";export{e as CatalogPage};
|
|
@@ -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-B2QJEzbS.js";import{t as o}from"./useQuery-M9KTdi7Q.js";import{t as s}from"./proxy-CWZabK8f.js";import{t as c}from"./AnimatePresence-BSSlw02V.js";import{c as l,h as u,s as d}from"./format-Bx7DF-TB.js";import{n as f,t as p}from"./utils-XFKvwlFT.js";import{t as m}from"./chevron-down-x70Pto6j.js";import{t as h}from"./chevron-right-CMSQPSEo.js";import{t as g}from"./copy-button-CSUP1VjU.js";import{t as _}from"./factory-DLE12zAd.js";import{t as v}from"./query-fetch-error-CWLZA2L5.js";import{c as y,d as b,f as x,l as S,s as C,t as w,u as T}from"./export-tab-fZDO4r2u.js";import{t as E}from"./badge-Bk1DaL6C.js";import{n as D}from"./get-error-message-dM0BMfdP.js";import{a as O}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as k,n as A,r as j,t as M}from"./tabs-BbQkzBZZ.js";import{t as N}from"./model-schemas-3w38IPdc.js";var P=f(`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`}]]),ee=f(`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`}]]),te=f(`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=f(`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=f(`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=f(`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=f(`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=f(`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=f(`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)(m,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,H.jsx)(h,{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,u=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,H.jsx)(g,{value:u,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:u,tooltipSide:`top`,render:()=>(0,H.jsxs)(`button`,{type:`button`,className:p(`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:p(`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:p(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:l(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?m:h,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:p(`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),s=(0,V.useRef)(null),c=(0,V.useMemo)(()=>[...new Set(e.models)],[e.models]),l=c.join(`,`),f=o({queryKey:a.catalog.modelSchemasBatch(l),queryFn:async()=>Promise.all(c.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail)))}),p=f.isPending&&!f.data,m=(0,V.useMemo)(()=>{let e=new Map;if(!f.data)return e;for(let[t,n]of f.data.entries())e.set(c[t],n);return e},[f.data,c]),h=(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,m,t));return n},[e.topology,m]);(0,V.useEffect)(()=>{if(p)return;let t=e.name;if(s.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=(h.get(`${t.name}/${e.name}`)??[])[0];if(n){r.add(`inst:${t.name}/${e.name}/${n.id}`);break outer}}n(r),s.current=t},[p,e.name,e.topology,h]);let g=(0,V.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return p?null:f.isError&&!f.data?(0,H.jsx)(v,{message:D(f.error,`Failed to load model schemas.`),onRetry:()=>void f.refetch(),isRetrying:f.isFetching&&!f.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:u(n.name),labelTitle:n.name,tag:`AREA`,tagKind:`area`,expanded:i,onToggle:()=>g(r),hasChildren:!0}),i&&n.lines.map(r=>{let i=`line:${n.name}/${r.name}`,a=t.has(i),o=h.get(`${n.name}/${r.name}`)??[];return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(J,{depth:1,label:u(r.name),labelTitle:r.name,tag:`LINE`,tagKind:`line`,count:o.length,expanded:a,onToggle:()=>g(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:d(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:u(i.model),subtitleTitle:i.model,count:i.tags.length+i.properties.length,expanded:o,onToggle:()=>g(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 ne(e){return e.lines.reduce((e,t)=>e+t.assets.reduce((e,t)=>e+t.count,0),0)}function re(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function Q(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?re(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,actions:n,fallbackTitle:c}){let[l,u]=(0,V.useState)(new Set),d=o({queryKey:a.catalog.templateDetail(e??``),queryFn:()=>i(`/catalog/templates/${e}`,r.catalogTemplateDetail),enabled:e!==null}),f=d.data,p=d.isPending&&!f,m=d.isError,h=D(d.error,`Failed to load template.`),g=N(f?.models??[]),_=(0,V.useMemo)(()=>{if(!f||!g.data)return null;let e=new Map;for(let[t,n]of g.data.entries())e.set(f.models[t],n);return Q(f,e)},[f,g.data]);(0,V.useEffect)(()=>{e&&f&&u(new Set(f.topology.map(e=>e.name)))},[e,f]);let O=(0,V.useCallback)(e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,H.jsx)(C,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,H.jsx)(y,{side:`right`,className:`flex w-full flex-col gap-4 touch-manipulation`,children:p?null:m&&!f&&n?(0,H.jsxs)(T,{className:`gap-2 pb-0 pe-12`,children:[(0,H.jsx)(b,{className:`font-heading text-base uppercase tracking-wide`,children:c}),(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n})]}):m&&!f?(0,H.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,H.jsx)(v,{message:h,onRetry:()=>void d.refetch(),isRetrying:d.isFetching})}):f?(0,H.jsxs)(s.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)(T,{className:`gap-1 pb-0 pe-12`,children:[(0,H.jsx)(b,{className:`font-heading text-base uppercase tracking-wide`,children:f.name}),f.description&&(0,H.jsx)(S,{className:`text-xs leading-relaxed text-foreground/88`,children:f.description}),n?(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:n}):null]}),(0,H.jsxs)(M,{defaultValue:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,H.jsxs)(j,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[(0,H.jsx)(k,{value:`overview`,className:$,children:`Overview`}),(0,H.jsx)(k,{value:`uns`,className:$,children:`UNS`}),(0,H.jsx)(k,{value:`export`,className:$,children:`Export`})]}),(0,H.jsx)(A,{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)(E,{variant:`outline`,className:`font-mono text-xs`,children:[f.topology.length,` areas`]}),(0,H.jsxs)(E,{variant:`outline`,className:`font-mono text-xs`,children:[f.assetCount,` assets`]}),(0,H.jsxs)(E,{variant:`outline`,className:`font-mono text-xs`,children:[f.models.length,` models`]}),_!==null&&(0,H.jsxs)(E,{variant:`outline`,className:`font-mono text-xs`,children:[_,` tags`]}),f.settings?.tickIntervalMs&&(0,H.jsxs)(E,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,f.settings.tickIntervalMs,`ms`]}),f.settings?.timeMultiplier&&f.settings.timeMultiplier!==1&&(0,H.jsxs)(E,{variant:`outline`,className:`font-mono text-xs`,children:[f.settings.timeMultiplier,`× speed`]})]}),f.namespace&&(f.namespace.enterprise||f.namespace.site||f.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:[f.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:f.namespace.enterprise})]}),f.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:f.namespace.site})]}),f.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:f.namespace.prefix})]})]})]}),f.topology.map(e=>(0,H.jsx)(ae,{area:e,expanded:l.has(e.name),onToggle:()=>O(e.name)},e.name)),f.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)(x,{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:[f.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:[f.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,H.jsx)(A,{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:f})})})})}),(0,H.jsx)(A,{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)(w,{kind:`template`,id:f.id,yamlPath:`/catalog/templates/${f.id}/yaml`,yamlFilename:`${f.id}.miravo.yaml`})})})]})]},f.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=ne(e);return(0,H.jsxs)(`div`,{className:O,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:u(e.name)}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,H.jsxs)(E,{variant:`secondary`,className:`text-xs`,children:[r,` assets`]}),(0,H.jsxs)(E,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,H.jsx)(m,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,H.jsx)(c,{initial:!1,children:t&&(0,H.jsx)(s.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:u(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:u(e.model)}),(0,H.jsxs)(E,{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=p(`shrink-0 text-primary`,t);switch(e){case`smart-factory`:return(0,H.jsx)(_,{className:n,"aria-hidden":!0});case`water-treatment`:return(0,H.jsx)(ee,{className:n,"aria-hidden":!0});case`commercial-building`:return(0,H.jsx)(P,{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)(te,{className:n,"aria-hidden":!0});default:return(0,H.jsx)(L,{className:n,"aria-hidden":!0})}}export{I as i,ie as n,B as r,ce as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./utils-XFKvwlFT.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./utils-XFKvwlFT.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./control-jNqzZWa9.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{ot as n}from"./vendor-ui-D8j69UH4.js";import{B as r,ot as i}from"./api-B2QJEzbS.js";import{t as a}from"./proxy-CWZabK8f.js";import{t as o}from"./AnimatePresence-BSSlw02V.js";import{i as s,r as c}from"./dist-xY0pK9Wy.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./dialog-B5PqrKVw.js";import{n as h,r as g}from"./protocol-card-ARSwIjkN.js";import{C as _,S as ee,d as v,l as te}from"./format-Bx7DF-TB.js";import{n as y,t as b}from"./utils-XFKvwlFT.js";import{n as x}from"./server-BVem_egD.js";import{n as S}from"./circle-x-_o0nl0Rg.js";import{n as C,t as w}from"./sliders-horizontal-BNKmYQgd.js";import{t as T}from"./pause-CqW7v5Dc.js";import{t as E}from"./play-kg50os4l.js";import{t as ne}from"./rocket-KZ5oHK1G.js";import{t as re}from"./triangle-alert-DoAwrRgk.js";import{a as ie,n as ae,r as D,t as O}from"./validation-BkfmaBBi.js";import{i as oe,n as k,t as A}from"./tooltip-B3vOB1Vu.js";import{t as j}from"./badge-Bk1DaL6C.js";import{t as M}from"./label-2sIXTEUK.js";import{a as N,t as P}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as F,n as I,r as L,t as R}from"./tabs-BbQkzBZZ.js";import{i as z,r as B,t as V}from"./console-panel-CMDoBJiO.js";import{a as H,c as U,i as W,l as G,n as K,o as q,r as se,s as J,t as ce}from"./combobox-B8h0-NHs.js";import{c as le,i as ue,n as de,s as fe,t as pe}from"./select-BWlrSYlA.js";var me=y(`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`}]]),Y=y(`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(g(e=>({assets:e.assets,models:e.models}))),n=P(),[r,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),f=(0,X.useMemo)(()=>u?e.filter(e=>e.id.toLowerCase().includes(u.toLowerCase())):e,[e,u]),p=(0,X.useMemo)(()=>{let n=e.find(e=>e.id===r);return n?t.find(e=>e.name===n.model)?.faultNames??[]:[]},[r,e,t]),m=(0,X.useMemo)(()=>e.filter(e=>e.activeFaults.length>0),[e]),h=m.reduce((e,t)=>e+t.activeFaults.length,0);return(0,Z.jsxs)(q,{className:`h-full min-w-0`,children:[(0,Z.jsx)(U,{className:`pb-3`,children:(0,Z.jsxs)(G,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(re,{className:`size-3.5 ${h>0?`text-destructive`:`text-muted-foreground`}`}),`Fault Lab`,(0,Z.jsx)(o,{children:h>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)(j,{variant:`destructive`,className:`text-[10px]`,children:[h,` 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)(ce,{value:r||null,onValueChange:e=>{s(e??``),l(``)},onInputValueChange:d,children:[(0,Z.jsx)(se,{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)(K,{children:(0,Z.jsxs)(H,{children:[f.map(e=>(0,Z.jsxs)(W,{value:e.id,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id}),e.activeFaults.length>0&&(0,Z.jsx)(j,{variant:`destructive`,className:`ml-auto text-[10px]`,children:e.activeFaults.length})]},e.id)),f.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No assets found`})]})})]}),(0,Z.jsxs)(pe,{value:c,onValueChange:e=>l(e??``),children:[(0,Z.jsx)(fe,{className:`h-8 min-h-11 w-full touch-manipulation sm:min-h-8`,"aria-label":`Fault type`,children:(0,Z.jsx)(le,{placeholder:r?`Select fault`:`Pick asset first`})}),(0,Z.jsx)(de,{alignItemWithTrigger:!1,align:`start`,children:p.map(e=>(0,Z.jsx)(ue,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(_,{variant:`destructive`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!c,onClick:()=>{let e=D(O,{assetId:r,fault:c});e&&n.mutate({type:`triggerFault`,...e})},children:`Trigger`}),(0,Z.jsx)(_,{variant:`secondary`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!c,onClick:()=>{let e=D(O,{assetId:r,fault:c});e&&n.mutate({type:`clearFault`,...e})},children:`Clear`})]}),(0,Z.jsx)(ie,{}),(0,Z.jsx)(o,{mode:`wait`,initial:!1,children:m.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)(o,{initial:!1,children:m.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:()=>{s(e.id),l(``)},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)(S,{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)(o,{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)(A,{children:[(0,Z.jsx)(oe,{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)(x,{className:`size-3`,"aria-hidden":!0})}),(0,Z.jsx)(k,{side:`top`,className:b(`max-w-xs`,n),children:t})]})]})}function $(){let{engineState:e,connectionState:t}=i(g(e=>({engineState:e.engineState,connectionState:e.connectionState}))),n=P();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)(_,{type:`button`,size:`sm`,variant:e===`paused`?`default`:`outline`,className:b(`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)(E,{className:`size-3`}):(0,Z.jsx)(T,{className:`size-3`}),e===`paused`?`Resume`:`Pause`]})})]})}function xe(){let{speedMultiplier:e,connectionState:t}=i(g(e=>({speedMultiplier:e.speedMultiplier,connectionState:e.connectionState}))),n=P(),[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)(M,{htmlFor:`speed-multiplier`,className:`sr-only`,children:`Speed multiplier`}),(0,Z.jsx)(ee,{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)(_,{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=D(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(g(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:b(N,`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:te(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 · `,v(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)(z,{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)(B,{children:`active`})]})}function we(){let{availableAdapters:e,adapterMetrics:t}=i(g(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)(o,{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)(h,{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)(ne,{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(g(e=>({assets:e.assets,templates:e.templates}))),n=P(),[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)(q,{className:`min-w-0`,children:[(0,Z.jsx)(U,{className:`pb-3`,children:(0,Z.jsxs)(G,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(me,{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)(_,{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)(m,{open:r,onOpenChange:a,children:(0,Z.jsxs)(d,{children:[(0,Z.jsxs)(l,{children:[(0,Z.jsx)(f,{children:`Reset Factory`}),(0,Z.jsx)(p,{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)(u,{children:[(0,Z.jsx)(_,{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)(_,{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]=s(`tab`,c([`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)(j,{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)(R,{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)(L,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Z.jsxs)(F,{value:`monitor`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(C,{className:`size-3.5 shrink-0`}),`Monitor`]}),(0,Z.jsxs)(F,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(w,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,Z.jsx)(I,{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)(I,{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"./events-RmbRTKFV.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{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,ot as a,v as o,y as s}from"./api-B2QJEzbS.js";import{f as c,t as l}from"./useQuery-M9KTdi7Q.js";import{t as u,u as d}from"./proxy-CWZabK8f.js";import{t as f}from"./AnimatePresence-BSSlw02V.js";import{i as p,n as m,r as h}from"./dist-xY0pK9Wy.js";import{n as g,s as _}from"./chunk-OE4NN4TA-DBWZidbW.js";import{a as v,i as y,n as b,o as ee,r as x,t as te}from"./dialog-B5PqrKVw.js";import{r as S,t as C}from"./protocol-card-ARSwIjkN.js";import{C as w,S as ne,T as re,c as T,d as E,g as D,h as O,l as k,m as A,p as j,s as M,u as N,v as ie,w as P,y as F}from"./format-Bx7DF-TB.js";import{n as I,t as L}from"./utils-XFKvwlFT.js";import{t as R}from"./activity-Cy_niK56.js";import{n as ae,r as oe,t as z}from"./server-BVem_egD.js";import{c as se,i as ce,n as le,s as ue,t as de}from"./dropdown-menu-B_MMNbTy.js";import{i as fe,n as pe,t as me}from"./catalog-template-icons-BOSywIKV.js";import{t as he}from"./chevron-down-x70Pto6j.js";import{t as ge}from"./chevron-right-CMSQPSEo.js";import{n as _e,t as ve}from"./circle-x-_o0nl0Rg.js";import{a as ye,c as be,i as xe,l as Se,o as Ce,p as we,s as Te,t as Ee,u as De}from"./integration-api-D2tA69Yb.js";import{t as Oe}from"./copy-button-CSUP1VjU.js";import{n as ke,r as Ae,t as je}from"./source-host-miravo-B8eM2IHw.js";import{t as Me}from"./factory-DLE12zAd.js";import{t as B}from"./loader-circle-DjgHgHHl.js";import{t as Ne}from"./plus-Cl4Ay5Ry.js";import{t as Pe}from"./radio-BxpVYiyS.js";import{t as Fe}from"./query-fetch-error-CWLZA2L5.js";import{t as Ie}from"./rocket-KZ5oHK1G.js";import{a as Le,f as Re,i as ze,n as Be,o as Ve,r as He}from"./export-tab-fZDO4r2u.js";import{t as Ue}from"./trash-2-BH9HDsZv.js";import{t as We}from"./triangle-alert-DoAwrRgk.js";import{i as V,n as H,t as U}from"./tooltip-B3vOB1Vu.js";import{n as Ge,t as Ke}from"./use-transition-navigate-B-nk4aWh.js";import{t as qe}from"./badge-Bk1DaL6C.js";import{n as Je}from"./transition-types-BKZuWApE.js";import{t as Ye}from"./label-2sIXTEUK.js";import{n as Xe,t as Ze}from"./get-error-message-dM0BMfdP.js";import{c as Qe,i as $e,o as et,t as tt}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as nt,n as rt,r as it,t as at}from"./tabs-BbQkzBZZ.js";import{i as W,n as G,r as K,t as ot}from"./console-panel-CMDoBJiO.js";import{a as st,i as ct,n as lt,o as ut,r as dt,s as ft,t as pt}from"./combobox-B8h0-NHs.js";import{c as mt,i as q,n as ht,s as gt,t as _t}from"./select-BWlrSYlA.js";import{a as J,c as vt,i as yt,n as bt,o as xt,r as St,s as Ct}from"./select-display-items-DN2G8DNG.js";import{t as wt}from"./checkbox-DEAkDfFr.js";import{n as Tt,r as Et,t as Dt}from"./integration-targets-Byvdd3Or.js";import{n as Ot,t as kt}from"./registry-Dau_GjK6.js";var At=I(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),jt=I(`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`}]]),Mt=I(`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`}]]),Nt=I(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Pt=I(`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`}]]),Ft=I(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),It=I(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Lt=I(`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`}]]),Rt=I(`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`}]]),zt=I(`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`}]]),Bt=I(`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`}]]),Vt=I(`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`}]]),Ht=I(`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`}]]),Y=e(t(),1),X=n();function Z({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`skeleton`,className:L(`animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted`,e),...t})}var Ut=`https://miravo.dev/docs`;function Wt(){let{adapters:e,metrics:t}=a(S(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,o=n.reduce((e,t)=>e+i(t.name),0);return(0,X.jsxs)(ot,{id:`connect`,icon:Bt,title:`Connect`,description:`Point a client here to read live values.`,aside:(0,X.jsxs)(W,{tone:o>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:o}),(0,X.jsx)(K,{children:o===1?`client`:`clients`})]}),bodyClassName:`gap-2`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(g,{to:`/control`,className:G,children:[`Configure protocols`,(0,X.jsx)(oe,{className:`size-3`,"aria-hidden":!0})]}),(0,X.jsxs)(`a`,{href:`${Ut}/protocols`,target:`_blank`,rel:`noopener noreferrer`,className:L(G,`ml-auto`),children:[(0,X.jsx)(jt,{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=C[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:L(`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)(Oe,{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=>C[e.name]??e.name).join(`, `),` `,r.length===1?`is`:`are`,` off.`]})]})}var Gt=[`devices`,`models`,`assets`],Kt=[`assets`,`models`,`devices`],qt={devices:`DeviceHub devices`,models:`Digital Twins models`,assets:`Digital Twins instances`},Jt={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.`}},Yt=`Miravo calls this API.`,Xt={assets:`models`};function Zt(e,t){let n=new Set(e);if(n.has(t)){n.delete(t);for(let[e,r]of Object.entries(Xt))r===t&&n.delete(e)}else{n.add(t);let e=Xt[t];e&&n.add(e)}return n}var Qt=[{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 $t({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)(he,{className:L(`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)(u.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:L(`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(Xt).find(([t,n])=>n===e)?.[0],r=t!==void 0&&i.has(t),o=n?Jt[e].apply:Jt[e].cleanup;return(0,X.jsxs)(Ye,{htmlFor:`scope-${e}`,className:L(`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)(wt,{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:qt[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:Qt.map(e=>(0,X.jsxs)(Ye,{htmlFor:`if-unmanaged-${e.value}`,className:L(`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 en({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)(U,{children:[(0,X.jsx)(V,{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)(we,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{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 tn({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 nn({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId},scope:n.scope}}var rn=/^\(?unchanged\)?$/i,an=/^device=(\S+)/;function on(e){let t=e.blockReason??e.detail;if(!(!t||rn.test(t)))return t.replace(/^\((.*)\)$/,`$1`)}function sn(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`:on(i),boundDevice:e?.detail?.match(an)?.[1]})}for(let[e,i]of t)r.has(e)||n.push({action:i.action,resourceType:`asset`,name:e,note:on(i),boundDevice:i.detail?.match(an)?.[1]});return n}function cn(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 ln(e){return sn(e).filter(e=>e.action!==`noop`&&e.action!==`blocked`).length}var un={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`}},dn=[`create`,`update`,`replace`,`delete`,`noop`],fn=[`create`,`update`,`replace`,`delete`],pn=6,mn={device:[`device`,`devices`],model:[`twin model`,`twin models`],asset:[`twin instance`,`twin instances`]};function hn(e,[t,n]){return`${e} ${e===1?t:n}`}function gn(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 _n(e){return gn(e).map(([e,t])=>hn(t.length,mn[e])).join(` · `)}function vn(e){return`${e.action}-${e.resourceType}-${e.name}-${e.protocol??``}`}function yn(e){return e.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)}function bn({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`,...dn].map(t=>{let n=e.get(t)?.length??0;return n>0?(0,X.jsx)(`span`,{className:L(`h-full rounded-full`,un[t].dot),style:{flexGrow:n}},t):null})})}function xn({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 Sn({action:e,entries:t,open:n,onToggle:r}){let i=un[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:L(`size-2 shrink-0 rounded-full`,i.dot)}),(0,X.jsx)(`span`,{className:L(`w-20 shrink-0 text-sm font-medium`,e===`noop`?`text-muted-foreground`:`text-foreground`),children:i.label}),(0,X.jsx)(`span`,{className:L(`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:_n(t)}),(0,X.jsx)(ge,{"aria-hidden":!0,className:L(`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:gn(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:mn[e][1]}),(0,X.jsx)(`ul`,{children:t.map(e=>(0,X.jsx)(xn,{entry:e},vn(e)))})]},e))}):null]})}function Cn({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)(We,{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)(xn,{entry:e},vn(e)))})]})}function wn({groups:e,planKind:t}){let n=fn.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:L(`font-mono tabular-nums`,un[t].text),children:e.get(t)?.length}),` `,(0,X.jsx)(`span`,{className:`font-normal text-foreground/90`,children:un[t].phrase})]},t))})}function Tn({plan:e,planKind:t=`apply`}){let n=sn(e.entries),r=cn(n),i=fn.reduce((e,t)=>e+(r.get(t)?.length??0),0),[a,o]=(0,Y.useState)(()=>new Set(i<=pn?fn:[])),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)(wn,{groups:r,planKind:t}),(0,X.jsxs)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:[l>0?`${l} already in place · `:``,yn(e.scope)]})]})}),n.length>0?(0,X.jsx)(bn,{groups:r}):null,c.length>0?(0,X.jsx)(Cn,{entries:c}):null,n.length>0?(0,X.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:dn.map(e=>{let t=r.get(e);return t?(0,X.jsx)(Sn,{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 En=[`a`,`b`,`c`];function Dn(){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:En.map(e=>(0,X.jsx)(Z,{className:`h-7 w-full`},e))})]})}var On={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`},kn=He.map(e=>({value:e,label:On[e]}));function An({open:e,onOpenChange:t,action:n,subject:r,label:i,target:a,stream:s}){let c=n===`apply`,u=c?Gt:Kt,[d,f]=(0,Y.useState)(new Set(u)),[p,m]=(0,Y.useState)(`fail`),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(Object.keys(a.exposedPorts??{}).length>0),[S,C]=(0,Y.useState)(Le(a.exposedPorts)),[ne,re]=(0,Y.useState)(r.kind===`asset`?r.protocol:He[0]??`modbus`),T=r.kind===`asset`?{kind:`asset`,assetId:r.assetId,protocol:ne}:r,E=r.kind===`asset`?[ne]:He,D=c?ze(a.exposedPorts,S,E):{},O=u.filter(e=>d.has(e)),k=O.length>0&&D!==null,A={scope:O,ifUnmanaged:p,...c&&D?{exposedPorts:D}:{}},j=tn({targetId:a.id,subject:T,result:A}),M=nn({targetId:a.id,subject:T,result:A}),N=l({queryKey:o.integrations.plan(n,JSON.stringify(c?j:M)),queryFn:({signal:e})=>c?be(j,{signal:e}):Te(M,{signal:e}),enabled:e&&k,retry:!1,gcTime:0}),ie=s.status===`running`,P=()=>{k&&(s.operation&&s.status!==`running`&&s.reset(),c?s.startApply(j):s.startCleanup(M),t(!1))},F=N.data?.plan,I=F?ln(F.entries):null,L;L=c?I===null?`Apply`:I===0?`Re-apply anyway`:`Apply ${I} ${I===1?`change`:`changes`}`:I?`Clean up ${I} ${I===1?`resource`:`resources`}`:`Clean up`;let R=N.error?[Xe(N.error,`Plan failed`),Ze(N.error)].filter(Boolean).join(`. `):null;return(0,X.jsx)(te,{open:e,onOpenChange:t,children:(0,X.jsxs)(b,{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)(ee,{className:`flex items-center gap-2 text-sm font-semibold leading-snug`,children:[c?(0,X.jsx)(Ie,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(Ue,{className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),c?`Apply`:`Clean up`,` `,i,` `,c?`to`:`from`,` `,a.label]}),(0,X.jsxs)(x,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[a.hostname,c?(0,X.jsx)(`span`,{className:`font-sans`,children:` · reaches Miravo at `}):null,c?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:[c&&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)(_t,{value:ne,onValueChange:e=>e&&re(e),items:kn,children:[(0,X.jsx)(gt,{size:`sm`,className:`w-32`,"aria-label":`Protocol`,children:(0,X.jsx)(mt,{})}),(0,X.jsx)(ht,{alignItemWithTrigger:!1,align:`start`,children:kn.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]})]}):null,k?R?(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: `,R]}),(0,X.jsx)(w,{size:`sm`,variant:`outline`,onClick:()=>void N.refetch(),children:`Retry dry run`})]}):F?(0,X.jsx)(Tn,{plan:F,planKind:n}):(0,X.jsx)(Dn,{}):(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:O.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)($t,{open:h,onOpenChange:g,isApply:c,scopeOptions:u,scope:d,onToggleScope:e=>f(t=>Zt(t,e)),ifUnmanaged:p,onIfUnmanagedChange:m}),h?(0,X.jsxs)(`dl`,{className:`flex flex-col gap-0 text-xs leading-snug`,children:[(0,X.jsx)(en,{label:`Litmus Edge API`,help:Yt,mono:!0,children:a.hostname}),(0,X.jsx)(en,{label:ke,help:je,mono:!0,children:a.sourceHostname}),c?(0,X.jsx)(`div`,{className:`border-b border-border/35 py-2.5`,children:(0,X.jsx)(Be,{open:_,onOpenChange:v,protocols:E,values:S,onChange:C,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)(y,{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)(w,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsxs)(w,{type:`button`,variant:c?`default`:`destructive`,onClick:P,disabled:!k||ie,children:[c?(0,X.jsx)(Ie,{className:`size-3`,"aria-hidden":!0}):(0,X.jsx)(Ue,{className:`size-3`,"aria-hidden":!0}),L]})]})]})})}function jn(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 Mn=500;function Nn(e){return e.kind===`template`?`template:${e.templateId}`:`asset:${e.assetId}`}function Pn(e,t){return`${Nn(e)}|${t}`}function Fn(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 In(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=Pn(e,r.targetId);n.has(i)||n.set(i,{status:Fn(r),operationType:r.operationType,targetId:r.targetId,targetLabel:r.targetLabel,completedAt:r.completedAt,error:r.error})}return n}function Ln(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 Rn(){let e=a(e=>e.factoryName),t=l({queryKey:o.integrations.operationsFactory(),queryFn:()=>ye({limit:Mn})});return{query:t,cells:(0,Y.useMemo)(()=>In(t.data?.operations??[],e),[t.data,e])}}var zn=5,Bn=`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 Vn(e){return e.kind===`template`?e.templateId:e.assetId}function Hn({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)(me,{id:e.subject.templateId,className:`size-3.5 shrink-0 text-primary`}):(0,X.jsx)(Lt,{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 Un({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:L(`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:A(e.completedAt)})]})}function Wn({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:L(Bn,`transition-colors hover:bg-muted/20`,a&&`pl-9`),children:[(0,X.jsx)(Hn,{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)(Un,{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)(w,{size:`xs`,variant:`outline`,disabled:i,"aria-label":`${n?.status===`failed`?`Retry`:`Apply`} ${s}`,className:$e,onClick:()=>o(`apply`),children:n?.status===`failed`?`Retry`:`Apply`}),c?(0,X.jsxs)(de,{children:[(0,X.jsx)(ue,{render:(0,X.jsx)(w,{size:`icon-xs`,variant:`ghost`,disabled:i,"aria-label":`More actions for ${s}`,className:`text-muted-foreground hover:text-foreground`}),children:(0,X.jsx)(Rt,{"aria-hidden":!0})}),(0,X.jsxs)(le,{align:`end`,className:`min-w-40`,children:[(0,X.jsxs)(ce,{className:`gap-2 text-xs`,onClick:()=>o(`apply`),children:[(0,X.jsx)(Ht,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Re-apply`]}),(0,X.jsxs)(ce,{variant:`destructive`,className:`gap-2 text-xs`,onClick:()=>o(`cleanup`),children:[(0,X.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),`Clean up`]})]})]}):null]})]})}function Gn({target:e,running:t,disabled:n,onCleanup:r}){let i=a(e=>e.factoryName),s=jn(l({queryKey:o.integrations.operationsForTarget(e.id),queryFn:()=>xe(e.id)}).data??[],e.id,i).filter(e=>!t.has(e.subjectId));return s.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.`]})]}),s.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:L(Bn,`bg-muted/20`),children:[(0,X.jsx)(Hn,{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:A(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)(w,{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)(Ue,{className:`size-3`,"aria-hidden":!0}),`Clean up`]})})]},`${t.kind}:${t.subjectId}`)})]})}function Kn(e,t){return t>0?`fault`:e>0?`live`:`off`}function qn({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}=Ln(i,e.id),d=a.status===`running`,f=t=>i.get(Pn(t.subject,e.id)),p=n.length>zn,m=n.filter(e=>f(e)?.status===`applied`).length,h=(t,n=!1)=>{let r=a.operation,i=d&&r?.label===Vn(t.subject)&&(r.targetLabel===e.label||r.targetLabel===e.id);return(0,X.jsx)(Wn,{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)(ot,{icon:z,title:e.label,description:(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.hostname}),aside:(0,X.jsxs)(W,{tone:Kn(l,u),children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:l}),(0,X.jsx)(K,{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)(K,{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:Bn,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)(ge,{className:L(`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)(Gn,{target:e,running:r,disabled:d,onCleanup:t=>o(t,e,`cleanup`)})]})})}function Jn({targets:e,cells:t,stream:n}){let{templates:r,assets:i}=a(S(e=>({templates:e.templates,assets:e.assets}))),[o,s]=(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)(z,{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)(g,{to:`/integrations`,className:P({size:`sm`}),children:[(0,X.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),`Add target`]})]});let c=new Set(r.flatMap(e=>e.assetIds)),l=r.map(e=>({subject:{kind:`template`,templateId:e.templateId},label:e.templateName,detail:e.templateId})),u=i.filter(e=>!c.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:L(`grid items-start gap-4`,e.length>1&&`@5xl/main:grid-cols-2`),children:[e.map(e=>(0,X.jsx)(qn,{target:e,templates:l,assets:u,running:d,cells:t,stream:n,onAction:(e,t,n)=>s({row:e,target:t,action:n})},e.id)),o?(0,X.jsx)(An,{open:!0,onOpenChange:e=>!e&&s(null),action:o.action,subject:o.row.subject,label:o.row.label,target:o.target,stream:n}):null]})}var Yn={status:`idle`,operation:null,error:null,logs:[],cancelRequested:!1},Xn=200;function Zn(){let[e,t]=(0,Y.useState)(Yn),n=(0,Y.useRef)(null),r=(0,Y.useRef)(0),i=c(),a=(0,Y.useRef)(0),s=(0,Y.useCallback)(e=>{let n=Xe(e,`Integration operation failed.`),r=Ze(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}))},[]),l=(0,Y.useCallback)(e=>{switch(e.event){case`accepted`:Qn(e.data,t);break;case`log`:er({...e.data,id:`log-${r.current++}`},t);break;case`started`:tr(e.data,t);break;case`phase`:nr(e.data,t);break;case`resource`:rr(e.data,t);break;case`complete`:ir(e.data,t);break;case`cancelled`:or(e.data,t);break;case`retrying`:sr(e.data,t);break;case`error`:s(Error(e.data.message));break}},[s]),u=(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=Se(e,e=>{a.current===c&&(l(e),cr(e)&&(i.invalidateQueries({queryKey:o.integrations.targets()}),i.invalidateQueries({queryKey:o.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,s(e))})},[l,s,i]),d=(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=De(e,e=>{a.current===c&&(l(e),cr(e)&&(i.invalidateQueries({queryKey:o.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,s(e))})},[l,s,i]),f=(0,Y.useCallback)(()=>{a.current++,n.current?.abort(),n.current=null,t(Yn)},[]),p=(0,Y.useCallback)(async()=>{let n=e.operation?.operationId;if(!(!n||e.status!==`running`||e.cancelRequested)){t(e=>ar(e,n));try{await Ee(n)||s(Error(`Operation finished before cancellation was accepted.`))}catch(e){s(e instanceof Error?e:Error(`Cancellation failed.`))}}},[e.operation?.operationId,e.status,e.cancelRequested,s]);return(0,Y.useEffect)(()=>()=>{a.current++,n.current?.abort(),n.current=null},[]),{...e,startApply:u,startCleanup:d,reset:f,cancel:p}}function Qn(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 $n(e){return e.templateId??e.assetId??`unknown`}function er(e,t){t(t=>({...t,logs:[...t.logs,e].slice(-Xn)}))}function tr(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:$n(e),targetLabel:e.targetLabel,totalPlanned:e.totalPlanned,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now(),attempt:e.attempt,maxAttempts:e.maxAttempts}}))}function nr(e,t){t(t=>{if(!Q(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 rr(e,t){t(t=>{if(!Q(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 ir(e,t){t(t=>{if(!Q(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!Q(e,t)||e.status!==`running`?e:{...e,cancelRequested:!0}}function or(e,t){t(t=>{if(!Q(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 sr(e,t){t(t=>Q(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 Q(e,t){return e.operation?.operationId===t}function cr(e){return e.event===`complete`||e.event===`cancelled`||e.event===`error`}var lr={initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,originY:0},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:350,damping:40}},ur={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 dr({children:e,variant:t=`default`}){let n=t===`default`;return(0,X.jsx)(u.div,{...n?lr:ur,layout:n,className:`mx-auto w-full`,children:e})}var fr=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:L(`flex flex-col items-center gap-4`,t),...r,children:(0,X.jsx)(f,{children:s.map(e=>(0,X.jsx)(dr,{children:e},e.key))})})});fr.displayName=`AnimatedList`;function pr({type:e,errorMessage:t,className:n}){return null}var mr=`text-destructive hover:bg-destructive/25 hover:text-foreground`,hr={device:`Devices`,tags:`Tags`,model:`Models`,asset:`Assets`,"param-sync":`Parameters`};function gr(e){return hr[e]??e}function _r(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 vr(e){return e===`noop`?`no-op`:e}function yr({status:e}){switch(e){case`success`:return(0,X.jsx)(_e,{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)(B,{className:`size-3.5 shrink-0 animate-spin text-primary/90`})}}function br({status:e}){switch(e){case`done`:return(0,X.jsx)(_e,{className:`size-3.5 text-success`});case`active`:return(0,X.jsx)(B,{className:`size-3.5 animate-spin text-primary`});case`pending`:return(0,X.jsx)(Ft,{className:`size-3.5 text-foreground/55`})}}function xr({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:L(`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)(yr,{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:L(`inline-flex rounded-[var(--miravo-radius-tight)] px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,_r(e.action)),children:vr(e.action)}),e.error&&(0,X.jsx)(he,{className:L(`size-3 text-foreground/75 transition-transform`,t&&`rotate-180`)})]}),(0,X.jsx)(f,{initial:!1,children:t&&e.error&&(0,X.jsxs)(u.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)(Oe,{value:e.error,label:`Copy error`,className:L(mr,`shrink-0`)})]}),(0,X.jsx)(pr,{type:`apply`,errorMessage:e.error,className:`mb-1 mt-2.5 w-full min-w-0`})]})})]})}function Sr({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:L(`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)(br,{status:e.status}),(0,X.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-foreground`,children:gr(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)(_e,{className:`size-3 text-success`}),a&&(0,X.jsx)(he,{className:L(`size-3 text-foreground/75 transition-transform`,!t&&`-rotate-90`),"aria-hidden":!0})]})]}),(0,X.jsx)(f,{initial:!1,children:a&&t&&(0,X.jsx)(u.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)(d.Provider,{value:null,children:e.resources.map((e,t)=>(0,X.jsx)(dr,{variant:`subtle`,children:(0,X.jsx)(xr,{entry:e})},`${e.name}-${t}`))})})})})]})}function Cr({operation:e}){let t=e.status===`complete`,n=e.status===`cancelled`,r=e.failed>0,i=e.totalPlanned>0?Math.min(100,Tr(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)(u.div,{"aria-hidden":`true`,className:L(`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 wr(e){return e.duration==null?(Date.now()-e.startedAt)/1e3:e.duration/1e3}function Tr(e){let t=e.applied+e.failed;return e.totalPlanned>0?Math.min(t,e.totalPlanned):t}var Er={complete:{Icon:_e,className:`size-4 text-success`},partial:{Icon:Pt,className:`size-4 text-warning`},cancelled:{Icon:At,className:`size-4 text-foreground/65`},error:{Icon:ve,className:`size-4 text-destructive`},running:{Icon:B,className:`size-4 animate-spin text-warning`}};function Dr({icon:e,className:t}){return(0,X.jsx)(u.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 Or({operation:e,sourceLabel:t,isAllExpanded:n,onToggleAll:r}){let i=wr(e),a=Tr(e),o=e.status===`complete`,s=e.status===`cancelled`,c=e.status===`error`,l=e.failed>0,d=o&&!l?`complete`:o&&l?`partial`:s?`cancelled`:c?`error`:`running`,p=Er[d];return(0,X.jsxs)(`div`,{className:L(`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)(f,{mode:`wait`,initial:!1,children:(0,X.jsx)(Dr,{icon:p.Icon,className:p.className},d)}),(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)(qe,{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)(f,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(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:`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)(f,{initial:!1,children:e.failed>0&&(0,X.jsx)(u.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)(qe,{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)(It,{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)(Nt,{className:L(`size-3.5 transition-transform duration-300`,!n&&`opacity-70 scale-y-[-1]`)})})})]})]}),(0,X.jsx)(Cr,{operation:e})]})]})}function kr(e){return e?e.closest(`[data-edge-op-scroll]`)??e.closest(`.overflow-y-auto`):null}var Ar=350;function jr(e){e?.scrollIntoView({block:`end`,behavior:`auto`,inline:`nearest`})}function Mr(e){let t=()=>jr(e);t(),requestAnimationFrame(t),requestAnimationFrame(()=>requestAnimationFrame(t)),window.setTimeout(t,0),window.setTimeout(t,48),window.setTimeout(t,120)}function Nr({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:L(`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)(ae,{className:`mt-0.5 size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(Pt,{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 Pr({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=kr(n.current);if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<Ar};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,Y.useLayoutEffect)(()=>{if(e.status===`running`){i.current&&jr(r.current),o.current=!0;return}o.current&&=(Mr(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&&jr(r.current)})});return s.observe(t),i.current&&jr(r.current),()=>{s.disconnect(),cancelAnimationFrame(o)}},[e.status]);let d=e.phases.length>0,p=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)(Or,{operation:e,sourceLabel:l,isAllExpanded:p,onToggleAll:d?()=>{c(p?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)(Sr,{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)(f,{initial:!1,children:e.error&&e.retryPending&&(0,X.jsxs)(u.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)(B,{className:`size-4 shrink-0 animate-spin`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.error})]})}),(0,X.jsx)(f,{initial:!1,children:e.error&&e.status===`error`&&(0,X.jsxs)(u.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)(Oe,{value:e.error,label:`Copy error`,className:L(mr,`shrink-0`)})]}),(0,X.jsx)(pr,{type:e.type,errorMessage:e.error,className:`mt-3 w-full min-w-0`})]})}),t&&t.length>0?(0,X.jsx)(Nr,{logs:t}):null,(0,X.jsx)(`div`,{ref:r,className:`h-px w-full shrink-0`,"aria-hidden":!0})]})}function Fr({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)(u.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)(Ve,{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)(Pe,{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)(w,{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)(re,{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 Ir(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 Lr({stream:e,onReset:t}){if(!e.operation&&e.status!==`running`)return null;let{title:n,subtitle:r}=Ir(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)(Fr,{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:L(P({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)(B,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(u.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)(re,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,X.jsx)(u.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)(g,{to:`/integrations?tab=activity`,className:L(P({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)(R,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,X.jsx)(ge,{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)(w,{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)(pr,{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)(Pr,{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)(B,{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)(u.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 Rr({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)(z,{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)(W,{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)(K,{children:e===1?`target`:`targets`})]}),(0,X.jsxs)(W,{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)(K,{children:`applied`})]}),n>0?(0,X.jsxs)(W,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:n}),(0,X.jsx)(K,{children:`failed`})]}):null,r?(0,X.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`last run `,A(r.completedAt)]}):null,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(g,{to:`/integrations`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(Re,{className:`size-3`,"aria-hidden":!0}),`Manage targets`]}),(0,X.jsxs)(g,{to:`/integrations?tab=activity`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(R,{className:`size-3`,"aria-hidden":!0}),`Activity`]}),(0,X.jsxs)(`a`,{href:`${Ut}/integrations/litmus-edge`,target:`_blank`,rel:`noopener noreferrer`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(jt,{className:`size-3`,"aria-hidden":!0}),`Docs`]})]})]})}function zr(){let e=Zn(),t=l({queryKey:o.integrations.targets(),queryFn:()=>Ce()}),{query:n,cells:r}=Rn(),i=t.data,a=n.data?.operations;if(!i||!a){let e=t.error??n.error;return e?(0,X.jsx)(Fe,{message:Xe(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:s,failed:c}=Ln(r),u=a[0];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(Rr,{targetCount:i.length,applied:s,failed:c,lastOp:u}),(0,X.jsx)(Jn,{targets:i,cells:r,stream:e}),e.operation||e.status===`running`?(0,X.jsx)(Lr,{stream:e,onReset:e.reset}):null]})}function Br(){let e=l({queryKey:o.integrations.targets(),queryFn:()=>Ce()}),{cells:t}=Rn(),n=e.data?.length??0,{applied:r,failed:i}=Ln(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:L(`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 Vr={"litmus-edge":{icon:z,Panel:zr,Summary:Br}};function Hr(e){return e?`/?tab=integrations&integration=${e}`:`/?tab=integrations`}function Ur(){return(0,X.jsxs)(ot,{icon:Vt,title:`Integrations`,description:`Send this factory to the platforms you build on.`,bodyClassName:`gap-1 px-2 py-2`,footer:(0,X.jsxs)(g,{to:Hr(),className:G,children:[`Open integrations`,(0,X.jsx)(oe,{className:`size-3`,"aria-hidden":!0})]}),children:[Dt.map(e=>{let{icon:t,Summary:n}=Vr[e.id];return(0,X.jsxs)(g,{to:Hr(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)(ge,{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: `,Tt.map(e=>e.label).join(`, `),`.`]})]})}function Wr(e){return s.prefetchQuery({queryKey:o.assets.detail(e),queryFn:()=>i(`/assets/${e}`,r.assetDetail),staleTime:2e3})}var Gr=`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function Kr(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 qr(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var Jr={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 Yr({state:e}){let t=Jr[e];return(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(`span`,{className:L(`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:L(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,X.jsx)(`span`,{children:T(t.label)})]}),(0,X.jsx)(H,{side:`top`,children:t.help})]})}function $({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)(se,{className:L(`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)(xt,{className:s,"aria-sort":l,children:r?(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:u}),(0,X.jsx)(H,{side:`top`,children:r})]}):u})}function Xr({title:e,body:t,action:n}){return(0,X.jsx)(vt,{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)(g,{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)(oe,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Zr({assets:e,state:t,templateByAsset:n,sortKey:r,sortDir:i,onSort:a,onOpenAsset:o}){return(0,X.jsx)(ut,{className:`py-0`,children:(0,X.jsx)(ft,{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)(St,{children:[(0,X.jsx)(Ct,{children:(0,X.jsxs)(vt,{children:[(0,X.jsx)($,{label:`Asset`,sortKey:`id`,current:r,direction:i,onSort:a}),(0,X.jsx)($,{label:`Template`,sortKey:`template`,current:r,direction:i,onSort:a,className:`hidden md:table-cell`}),(0,X.jsx)($,{label:`Model`,sortKey:`model`,current:r,direction:i,onSort:a,className:`hidden sm:table-cell`}),(0,X.jsx)($,{label:`Lifecycle`,sortKey:`lifecycle`,current:r,direction:i,onSort:a,tooltip:Gr}),(0,X.jsx)($,{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)($,{label:`Faults`,sortKey:`faults`,current:r,direction:i,onSort:a,tooltip:`Count of active (uncleared) faults on this asset.`}),(0,X.jsx)($,{label:`Status`,sortKey:`status`,current:r,direction:i,onSort:a}),(0,X.jsx)(xt,{children:(0,X.jsx)(`span`,{className:`sr-only`,children:`Navigate to asset`})})]})}),(0,X.jsx)(yt,{children:t===`connecting`?(0,X.jsx)(Xr,{title:`Connecting to runtime`,body:`Live asset data will appear once the connection is up.`}):t===`empty`?(0,X.jsx)(Xr,{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)(Xr,{title:`No matches`,body:`Adjust filters or clear them to see all assets.`}):e.map(e=>{let t=qr(e),r=M(e.id);return(0,X.jsxs)(vt,{tabIndex:0,"aria-label":`Open asset ${r}`,className:L(`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:()=>{Ge(`/asset/${e.id}`),Wr(e.id)},onFocus:()=>{Ge(`/asset/${e.id}`),Wr(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:N(e.model)}),(0,X.jsx)(J,{children:(0,X.jsx)(qe,{variant:`secondary`,className:`text-xs`,children:D(e.lifecycleStage)})}),(0,X.jsx)(J,{className:`hidden font-mono text-sm md:table-cell`,children:j(e.operatingHours)}),(0,X.jsx)(J,{children:e.activeFaults.length>0?(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{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)(H,{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)(Yr,{state:t})}),(0,X.jsx)(J,{children:(0,X.jsx)(oe,{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 Qr=`~all`,$r=`~standalone`;function ei(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function ti(){let{assets:e,templates:t,connectionState:n}=a(S(e=>({assets:e.assets,templates:e.templates,connectionState:e.connectionState}))),[r,i]=p(`q`,m.withDefault(``)),[o,s]=p(`model`,m.withDefault(``)),[c,l]=p(`lifecycle`,m.withDefault(``)),[u,d]=p(`template`,m.withDefault(``)),[f,h]=p(`standalone`,m.withDefault(``)),g=f===`1`,[_,v]=p(`status`,m.withDefault(``)),y=ei(_)?_:``,[b,ee]=(0,Y.useState)(`id`),[x,te]=(0,Y.useState)(`asc`),C=(0,Y.useRef)(null),w=Ke(),[T,E]=(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(),C.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let O=(0,Y.useCallback)(e=>{e===b?te(e=>e===`asc`?`desc`:`asc`):(ee(e),te(`asc`))},[b]),k=(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]),A=(0,Y.useMemo)(()=>[{value:Qr,label:`All templates`},{value:$r,label:`Standalone`},...t.map(e=>({value:e.templateId,label:e.templateName}))],[t]),j=(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]),M=(0,Y.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),P=(0,Y.useMemo)(()=>[{value:`all`,label:`All stages`},...M.map(e=>({value:e,label:D(e)}))],[M]),I=(0,Y.useMemo)(()=>T?j.filter(([e])=>F(e,T)):j,[j,T]),L=(0,Y.useMemo)(()=>o?{value:o,label:N(o)}:null,[o]),R=(0,Y.useMemo)(()=>{let n=e;if(g)n=n.filter(e=>!k.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 o&&(n=n.filter(e=>e.model===o)),c&&(n=n.filter(e=>e.lifecycleStage===c)),r&&(n=n.filter(e=>ie(e.id,r)||F(e.model,r))),y===`faulted`&&(n=n.filter(e=>e.activeFaults.length>0)),y===`quarantined`&&(n=n.filter(e=>e.isQuarantined)),y===`healthy`&&(n=n.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),Kr(n,b,x,k)},[e,t,k,u,g,r,y,o,c,b,x]),ae=y!==``||u!==``||g||o!==``||c!==``||r!==``,oe=(0,Y.useCallback)(()=>{i(``),v(``),d(``),h(``),s(``),l(``)},[i,v,d,h,s,l]),z=(0,Y.useCallback)(e=>{w(`/asset/${e}`,{transitionType:Je})},[w]),se=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)(_t,{value:g?$r:u||Qr,onValueChange:e=>{h(e===$r?`1`:``),d(!e||e===Qr||e===$r?``:e)},items:A,children:[(0,X.jsx)(gt,{className:`h-8 w-44`,"aria-label":`Template filter`,children:(0,X.jsx)(mt,{placeholder:`All templates`})}),(0,X.jsx)(ht,{alignItemWithTrigger:!1,align:`start`,children:A.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]}),(0,X.jsxs)(pt,{value:L,onValueChange:e=>void s(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:E,children:[(0,X.jsx)(dt,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!o}),(0,X.jsx)(lt,{children:(0,X.jsxs)(st,{children:[I.map(([e,t])=>(0,X.jsxs)(ct,{value:{value:e,label:N(e)},children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:N(e)}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),I.length===0&&(0,X.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),M.length>1&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(_t,{value:c||`all`,onValueChange:e=>void l(!e||e===`all`?``:e),items:P,children:[(0,X.jsx)(gt,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,X.jsx)(mt,{placeholder:`All stages`})}),(0,X.jsxs)(ht,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All stages`}),M.map(e=>(0,X.jsx)(q,{value:e,children:D(e)},e))]})]}),(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{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)(we,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,children:`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`})]})]}),(0,X.jsxs)(_t,{value:y||`all`,onValueChange:e=>void v(!e||e===`all`?``:e),items:bt,children:[(0,X.jsx)(gt,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,X.jsx)(mt,{placeholder:`All status`})}),(0,X.jsxs)(ht,{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)(ne,{ref:C,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:`/`})]}),ae&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:oe,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)(re,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[R.length,` of `,e.length]})]})]}),(0,X.jsx)(Zr,{assets:R,state:se,templateByAsset:k,sortKey:b,sortDir:x,onSort:O,onOpenAsset:z})]})}var ni={running:`live`,paused:`idle`,stopped:`fault`};function ri(){let{factoryName:e,engineState:t,seed:n,speed:r,bootTemplate:i}=a(S(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&&!Qe(e)?O(e):`Factory`}),(0,X.jsx)(W,{tone:ni[t]??`off`,children:(0,X.jsx)(K,{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:[e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{children:[`id `,(0,X.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`})]}):null,(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)(g,{to:`/catalog`,className:P({size:`sm`}),children:[(0,X.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),`Load template`]})]})}var ii=Dt.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 oi(){let[e,t]=p(`integration`,h(ii).withDefault(Et.id)),{Panel:n}=Vr[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:[Dt.map(n=>{let{icon:r}=Vr[n.id],i=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>void t(n.id),className:L(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:L(`size-3.5`,i&&`text-primary`),"aria-hidden":!0}),n.label]},n.id)}),Tt.map(e=>(0,X.jsxs)(`span`,{"aria-disabled":!0,className:L(ai,`cursor-default border-dashed border-border/60 text-muted-foreground/70`),children:[(0,X.jsx)(Vt,{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 si(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 ci={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`},li={healthy:`bg-success`,faulted:`bg-destructive`,quarantined:`bg-warning`};function ui({group:e,label:t,templateId:n}){let[r]=e.ids;return(0,X.jsxs)(g,{to:e.ids.length===1&&r?`/asset/${r}`:si({model:e.model,template:n}),title:e.ids.join(`, `),className:L(`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`,ci[e.health]),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,li[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 di(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var fi=24;function pi(){let{assets:e,templates:t}=a(S(e=>({assets:e.assets,templates:e.templates}))),[n,r]=(0,Y.useState)(!1),i=new Set(t.flatMap(e=>e.assetIds)),o=e.filter(e=>!i.has(e.id));if(o.length===0)return null;let s=n?o:o.slice(0,fi);return(0,X.jsxs)(`section`,{"aria-label":`Standalone assets`,className:L(et,`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)(Lt,{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:[s.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(ui,{group:{model:e.model,ids:[e.id],health:di(e)},label:e.id})},e.id)),o.length>fi&&(0,X.jsx)(`li`,{children:(0,X.jsx)(w,{size:`xs`,variant:`ghost`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`+${o.length-fi} more`})})]}),(0,X.jsxs)(`div`,{className:`mt-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:o.length}),` asset`,o.length===1?``:`s`]}),(0,X.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(g,{to:si({standalone:!0}),className:L(P({size:`sm`,variant:`outline`}),$e),children:[(0,X.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),(0,X.jsxs)(g,{to:`/models`,className:L(P({size:`sm`,variant:`ghost`}),`ml-auto text-muted-foreground`),children:[(0,X.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),`Spawn asset`]})]})]})}function mi({template:e,open:t,onOpenChange:n}){let r=tt(),[i,a]=(0,Y.useState)(!1);return(0,X.jsx)(te,{open:t,onOpenChange:n,children:(0,X.jsxs)(b,{children:[(0,X.jsxs)(v,{children:[(0,X.jsxs)(ee,{children:[`Unload `,e.templateName]}),(0,X.jsxs)(x,{children:[`Removes its `,e.assetIds.length,` asset`,e.assetIds.length===1?``:`s`,`. Standalone assets stay.`]})]}),(0,X.jsxs)(y,{children:[(0,X.jsx)(w,{variant:`outline`,onClick:()=>n(!1),disabled:i,children:`Cancel`}),(0,X.jsx)(w,{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 hi({value:e,label:t}){return(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e}),` `,t,e===1?``:`s`]})}function gi(e,t){let n=new Set(e.assetIds),r=new Set;for(let e of t)n.has(e.id)&&di(e)!==`healthy`&&r.add(N(e.model));return[...r]}function _i({template:e,highlighted:t=!1}){let{assets:n,engineState:s}=a(S(e=>({assets:e.assets,engineState:e.engineState}))),c=l({queryKey:o.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=c.data?.find(t=>t.id===e.templateId)?.description,h=new Set(e.assetIds),_=n.filter(e=>h.has(e.id)&&di(e)!==`healthy`).length,v=_>0?gi(e,n):[],y=e.areas.reduce((e,t)=>e+t.lines.length,0);return(0,X.jsxs)(`section`,{id:`template-${e.templateId}`,"aria-label":e.templateName,className:L(et,`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)(me,{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})]}),_>0?(0,X.jsxs)(W,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:_}),` `,(0,X.jsx)(K,{children:`faulted`})]}):(0,X.jsx)(W,{tone:s===`running`?`live`:`idle`,children:(0,X.jsx)(K,{children:s===`running`?`running`:`paused`})})]}),m?(0,X.jsx)(`p`,{className:`line-clamp-2 text-pretty text-xs leading-relaxed text-muted-foreground`,children:m}):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)(hi,{value:e.areas.length,label:`area`}),(0,X.jsx)(hi,{value:y,label:`line`}),(0,X.jsx)(hi,{value:e.assetIds.length,label:`asset`}),(0,X.jsx)(hi,{value:e.models.length,label:`model`})]}),v.length>0?(0,X.jsxs)(g,{to:si({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)(We,{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:[_,` faulted:`]}),` `,v.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)(w,{type:`button`,size:`sm`,variant:`outline`,className:$e,onClick:()=>p(!0),children:[(0,X.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),Ot(e.templateId)?(0,X.jsxs)(g,{to:kt(e.templateId),className:P({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Me,{className:`size-3.5`,"aria-hidden":!0}),`Open floor`]}):null,(0,X.jsx)(w,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>d(!0),children:`Unload`})]}),(0,X.jsx)(mi,{template:e,open:u,onOpenChange:d}),(0,X.jsx)(pe,{templateId:f?e.templateId:null,onClose:()=>p(!1),actions:(0,X.jsxs)(g,{to:si({template:e.templateId}),className:P({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),fallbackTitle:e.templateName})]})}var vi={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},yi={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},bi={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function xi({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:L(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,vi[t])}),(0,X.jsx)(`span`,{className:L(`relative inline-flex size-1.5 rounded-full`,vi[t])})]}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,vi[t])})),(0,X.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function Si({children:e,tone:t=`foreground`,live:n}){return(0,X.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:L(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,yi[t]),children:e})}function Ci({children:e}){return(0,X.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function wi(e,t){return e===t?``:t}function Ti({statusFilter:e,onStatusFilter:t}){let{assets:n,tps:r,memberValueCount:i,availableAdapters:o,adapterMetrics:s}=a(S(e=>({assets:e.assets,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),c=(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]),l=(0,Y.useMemo)(()=>{let e=o.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>bi[e.name]??e.name)}},[o,s]),u=c.activeFaultCount>0,d=u?`destructive`:c.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(wi(e,f)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":u?`Filter to faulted assets`:`Filter to healthy assets`,className:L(`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)(xi,{label:`Health`,pip:d}),(0,X.jsxs)(Si,{tone:u?`destructive`:`success`,children:[c.pct,`%`]}),(0,X.jsx)(Ci,{children:c.total===0?`No assets`:[`${c.total} asset${c.total===1?``:`s`}`,c.faulted>0&&`${c.faulted} faulted`,c.quarantined>0&&`${c.quarantined} quarantined`,`${c.modelCount} model${c.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:L(`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)(xi,{label:`Faults`,pip:u?`destructive`:`success`}),(0,X.jsx)(Si,{tone:u?`destructive`:`foreground`,live:!0,children:c.activeFaultCount}),(0,X.jsx)(Ci,{children:u?`${c.affectedCount} asset${c.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(g,{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)(xi,{label:`Tags`,pip:`primary`,pulse:!0}),(0,X.jsx)(Si,{children:E(i)}),(0,X.jsxs)(Ci,{children:[(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,X.jsx)(H,{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:[k(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.`]})]})})]}),l.enabled.length>0&&(0,X.jsx)(Ei,{labels:l.labels,totalMessages:l.totalMessages,totalErrors:l.totalErrors,perAdapter:l.enabled.map(e=>({name:bi[e.name]??e.name,metrics:s.find(t=>t.name===e.name)?.metrics}))})]})}function Ei({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(g,{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)(xi,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,X.jsx)(Si,{tone:n>0?`warning`:`foreground`,live:!0,children:E(t)}),(0,X.jsxs)(Ci,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,X.jsx)(H,{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:[k(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:[k(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 Di=2500,Oi=[`overview`,`assets`,`integrations`];function ki({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 Ai({children:e}){return(0,X.jsx)(u.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e})}function ji(){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)(zt,{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)(g,{to:`/catalog`,className:P({size:`sm`}),children:`Open catalog`})]})}function Mi({highlight:e}){let{templates:t,assetCount:n}=a(S(e=>({templates:e.templates,assetCount:e.assets.length})));return(0,X.jsx)(`div`,{className:`@container/overview`,children:(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:[t.length===0&&n===0?(0,X.jsx)(ji,{}):(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)(_i,{template:t,highlighted:t.templateId===e},t.templateId)),(0,X.jsx)(pi,{})]}),(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)(Wt,{}),(0,X.jsx)(Ur,{})]})]})})}function Ni(){let{hash:e}=_(),{templates:t,assetCount:n}=a(S(e=>({templates:e.templates,assetCount:e.assets.length}))),[r,i]=p(`tab`,h(Oi).withDefault(`overview`)),[o,s]=p(`highlight`,m.withDefault(``)),[c,l]=p(`status`,m.withDefault(``)),u=c===`healthy`||c===`faulted`||c===`quarantined`?c:``;(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===o);return(0,Y.useEffect)(()=>{if(!o||!d)return;document.getElementById(`template-${o}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=setTimeout(()=>void s(null,{history:`replace`}),Di);return()=>clearTimeout(e)},[o,d,s]),(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)(ri,{}),(0,X.jsx)(Ti,{statusFilter:u,onStatusFilter:e=>{l(e||null),e!==``&&i(`assets`)}}),(0,X.jsxs)(at,{value:r,onValueChange:e=>void i(e),children:[(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(it,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,X.jsxs)(nt,{value:`overview`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(fe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Overview`,(0,X.jsx)(ki,{value:t.length})]}),(0,X.jsxs)(nt,{value:`assets`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Mt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Assets`,(0,X.jsx)(ki,{value:n})]}),(0,X.jsxs)(nt,{value:`integrations`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Vt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Integrations`]})]})}),(0,X.jsx)(rt,{value:`overview`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(Mi,{highlight:o})})}),(0,X.jsx)(rt,{value:`assets`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(ti,{})})}),(0,X.jsx)(rt,{value:`integrations`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(oi,{})})})]})]})}export{Ft as a,zt as i,Ut as n,Mt as o,Vt as r,jt as s,Ni as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./factory-C2OucdpQ.js";export{e as FactoryPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./utils-XFKvwlFT.js";var t=e(`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`}]]);export{t};
|