@miravo/cli-linux-arm64-musl 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/console-dist/assets/api-Bp-mG9Rs.js +1 -0
  2. package/console-dist/assets/{api-GfuYYI6q.js → api-CtMmjN9m.js} +1 -1
  3. package/console-dist/assets/{asset-detail-CbRJwcZg.js → asset-detail-JDx-26wg.js} +1 -1
  4. package/console-dist/assets/{asset-detail-actions-Ceb1_r18.js → asset-detail-actions-BrLTJCzY.js} +1 -1
  5. package/console-dist/assets/{backup-power-qtHJlSI4.js → backup-power-B1THpfxc.js} +1 -1
  6. package/console-dist/assets/{by-path-CKZo157c.js → by-path-CGbqDnvK.js} +1 -1
  7. package/console-dist/assets/catalog-B3KfEJkB.js +1 -0
  8. package/console-dist/assets/{catalog-Lt1tguKF.js → catalog-Whukru3I.js} +1 -1
  9. package/console-dist/assets/{catalog-template-icons-DvKspieo.js → catalog-template-icons-GGQGFjA8.js} +1 -1
  10. package/console-dist/assets/{commercial-building-Bk4sBQtx.js → commercial-building-BeGD1bPV.js} +1 -1
  11. package/console-dist/assets/{console-panel-DOt0r_Oz.js → console-panel-DXk4doxV.js} +1 -1
  12. package/console-dist/assets/control-BeyuTMD5.js +1 -0
  13. package/console-dist/assets/{control-89sOxkPx.js → control-HoYOjLyM.js} +1 -1
  14. package/console-dist/assets/{district-heating-BofEIyfg.js → district-heating-MuLRna9G.js} +1 -1
  15. package/console-dist/assets/events-C2Q9HRYG.js +1 -0
  16. package/console-dist/assets/{events-NZs3OoQw.js → events-Cb1faGh2.js} +1 -1
  17. package/console-dist/assets/{export-tab-R8Oac9J5.js → export-tab-CtH28h1G.js} +1 -1
  18. package/console-dist/assets/{factory-BYX8AmsW.js → factory-Boh-9Tjz.js} +1 -1
  19. package/console-dist/assets/factory-CpziAEBj.js +1 -0
  20. package/console-dist/assets/{floor-page-CiS52QbQ.js → floor-page-Bxq5t8Yi.js} +1 -1
  21. package/console-dist/assets/{get-error-message-DJGhcwLn.js → get-error-message-D800c4Uu.js} +1 -1
  22. package/console-dist/assets/{index-B8B-S-lq.js → index-CHgd8U-y.js} +3 -3
  23. package/console-dist/assets/{integration-api-B5s7_LWo.js → integration-api-DnCoHAoa.js} +1 -1
  24. package/console-dist/assets/integrations-DYDSuhVG.js +1 -0
  25. package/console-dist/assets/{integrations-Bg7xzjIj.js → integrations-DlVDmGqI.js} +1 -1
  26. package/console-dist/assets/{login-Dq1AJRqO.js → login-D6-swZqz.js} +1 -1
  27. package/console-dist/assets/models-C1sVJK7p.js +1 -0
  28. package/console-dist/assets/{models-BYr_QK_5.js → models-CDGbNOUr.js} +1 -1
  29. package/console-dist/assets/{pharma-cleanroom-oxgPn6h6.js → pharma-cleanroom-DnxAzkeg.js} +1 -1
  30. package/console-dist/assets/{protocol-card-1DCkgN_l.js → protocol-card-Bf06qKjE.js} +1 -1
  31. package/console-dist/assets/{registry-BqqyCPJz.js → registry-BKilgP4M.js} +2 -2
  32. package/console-dist/assets/{status-kit-Darp7bPB.js → status-kit-eQF95zN0.js} +1 -1
  33. package/console-dist/assets/tags-BPR9ZiaM.js +1 -0
  34. package/console-dist/assets/{tags-r7Fx_0yG.js → tags-DtfR_AgF.js} +1 -1
  35. package/console-dist/assets/{transition-nav-link-DIx78Lol.js → transition-nav-link-ZpTbW2Hm.js} +1 -1
  36. package/console-dist/assets/{use-engine-command-mutation-CTbPh58S.js → use-engine-command-mutation-5q_LI_xT.js} +1 -1
  37. package/console-dist/assets/{use-transition-navigate-aOjMH_eS.js → use-transition-navigate-5-QJHk2I.js} +2 -2
  38. package/console-dist/assets/{useQuery-BfWNkVkT.js → useQuery-Dxp3WSXF.js} +1 -1
  39. package/console-dist/assets/{validation-DSsZ8qyt.js → validation-BSQDilvJ.js} +1 -1
  40. package/console-dist/assets/{water-treatment-COXMW4qC.js → water-treatment-CAxvQSI-.js} +1 -1
  41. package/console-dist/index.html +23 -23
  42. package/miravo +1 -1
  43. package/package.json +1 -1
  44. package/console-dist/assets/api-DEoRnScz.js +0 -1
  45. package/console-dist/assets/catalog-CshTwzQu.js +0 -1
  46. package/console-dist/assets/control-BBMXQRSU.js +0 -1
  47. package/console-dist/assets/events-DFkG5maw.js +0 -1
  48. package/console-dist/assets/factory-Cp52pnAL.js +0 -1
  49. package/console-dist/assets/integrations-CG1fPcwM.js +0 -1
  50. package/console-dist/assets/models-jmRXhSoh.js +0 -1
  51. package/console-dist/assets/tags-DlnWXo4p.js +0 -1
@@ -1 +1 @@
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,v as d,vt as f}from"./api-GfuYYI6q.js";import{t as p}from"./useQuery-BfWNkVkT.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 re,t as v}from"./dialog-B5PqrKVw.js";import{C as ie,_ as y,a as b,b as x,c as S,f as C,g as w,i as T,n as E,p as ae,r as D,s as O,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 P,t as oe}from"./sliders-horizontal-BNKmYQgd.js";import{n as F,r as I}from"./use-engine-command-mutation-CTbPh58S.js";import{t as L}from"./radio-BxpVYiyS.js";import{n as se,t as ce}from"./query-fetch-error-CWLZA2L5.js";import{t as R}from"./triangle-alert-DoAwrRgk.js";import{i as z,n as B,t as V}from"./tooltip-B3vOB1Vu.js";import{t as H}from"./badge-Bk1DaL6C.js";import{t as le}from"./transition-types-BKZuWApE.js";import{n as U}from"./auth-screen-backdrop-CEykEbfF.js";import{n as ue}from"./get-error-message-DJGhcwLn.js";import{i as de,n as fe,r as pe,t as me}from"./asset-detail-actions-Ceb1_r18.js";import{i as W,n as G,r as he,t as ge}from"./tabs-Ch_VG8_S.js";var _e=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`}]]),ve=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`}]]),ye=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`}]]),K=e(n(),1),q=c();function be({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,q.jsxs)(`header`,{className:j(I,`flex w-full min-w-0 flex-col`),children:[(0,q.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,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:i,className:`transition-colors hover:text-foreground`,children:`Assets`}),(0,q.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,q.jsx)(`span`,{className:`truncate`,children:k(e.assetType)})]}),(0,q.jsx)(K.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,q.jsx)(`h1`,{className:`font-heading mt-1 text-2xl font-semibold uppercase leading-tight tracking-wide`,children:O(e.id)})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`p`,{className:`m-0 min-w-0 flex-1 font-mono text-[10px] leading-tight tracking-tight text-muted-foreground`,children:(0,q.jsx)(`span`,{className:`break-all`,children:e.browsePath.join(` / `)})}),(0,q.jsx)(`span`,{className:`inline-flex shrink-0`,children:(0,q.jsx)(N,{value:b(e.browsePath),label:`Copy Topic / UNS path`})})]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 self-end font-mono text-xs sm:self-start`,children:[(0,q.jsx)(L,{className:`size-3.5 animate-pulse text-primary`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`font-medium text-primary`,children:`LIVE`}),(0,q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[`t=`,t]}),(0,q.jsxs)(V,{children:[(0,q.jsx)(z,{render:(0,q.jsx)(`span`,{className:`inline-flex size-3.5 items-center justify-center outline-none focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,q.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,q.jsx)(`span`,{className:j(`relative inline-flex size-1.5 rounded-full`,m.dot)}),m.animate&&(0,q.jsx)(`span`,{className:j(`absolute inline-flex size-2.5 animate-ping rounded-full opacity-75`,m.pulse)})]})}),(0,q.jsx)(B,{side:`top`,align:`end`,children:(0,q.jsxs)(`span`,{className:`block max-w-[16rem] text-[11px] leading-snug`,children:[(0,q.jsx)(`span`,{className:`font-medium uppercase tracking-[0.08em]`,children:`Availability`}),` `,(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`— `,h]})]})})]})]})]}),(0,q.jsxs)(`fieldset`,{"aria-label":`Asset status`,className:`m-0 flex flex-col border-0 border-t border-border/50 p-0`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-px bg-transparent`,children:[(0,q.jsx)(J,{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,q.jsx)(J,{variant:`primary`,icon:R,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,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-px border-t border-border/50 bg-transparent sm:grid-cols-4`,children:[(0,q.jsx)(J,{variant:`compact`,icon:_e,label:`Lifecycle`,labelCompact:`Life`,value:S(e.lifecycleStage),tone:x(e.lifecycleStage),tooltip:`Where this asset sits in its operational lifecycle (e.g. commissioning, operating, maintenance, retired).`}),(0,q.jsx)(J,{variant:`compact`,icon:P,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,q.jsx)(J,{variant:`compact`,icon:ve,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,q.jsx)(J,{variant:`compact`,icon:ye,label:`Operating age`,value:ae(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 J({icon:e,label:t,labelCompact:n,value:r,suffix:i,tone:a,variant:o=`compact`,tooltip:s}){let c=o===`primary`;return(0,q.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,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 items-center gap-2`,children:(0,q.jsxs)(V,{children:[(0,q.jsxs)(z,{className:`flex min-h-0 min-w-0 flex-1 cursor-default items-center gap-2 text-left`,render:(0,q.jsx)(`div`,{}),children:[(0,q.jsx)(e,{className:j(`shrink-0 text-muted-foreground`,c?`size-4`:`size-3.5`),"aria-hidden":!0}),(0,q.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,q.jsx)(`span`,{className:`block wrap-break-word 2xl:hidden`,children:n??t}),(0,q.jsx)(`span`,{className:`hidden wrap-break-word 2xl:block`,children:t})]})]}),(0,q.jsx)(B,{side:`top`,align:`start`,sideOffset:6,className:`max-w-xs`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:s??t})]})})]})}),(0,q.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,q.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 Y({title:e,subtitle:t,children:n,className:r,id:i}){return(0,q.jsxs)(`section`,{id:i,className:j(F,r),children:[(0,q.jsxs)(`div`,{className:`border-b border-border/60 px-4 py-3`,children:[(0,q.jsx)(`h2`,{className:`blueprint-title text-foreground`,children:e}),t?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t}):null]}),(0,q.jsx)(`div`,{className:`overflow-hidden p-0`,children:n})]})}var xe=new Set([`pu`,`h`]),Se=[`_reference`,`_baseline`,`_setpoint`,`_command`],X=`var(--color-primary)`,Ce=`var(--color-background)`,we=60,Te=1e-4;function Z(e,t,n){let r=e?.get(t);return{value:r?.value??n.value,quality:r?.quality??n.quality}}function Ee(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&&!xe.has(t.meta.unit??``)&&!Se.some(t=>e.endsWith(t)))}function De(e,t){if(e.length<2)return!1;let n=t-we,r;for(let t of e)if(!(t.tick<n)){if(r===void 0){r=t.value;continue}if(Math.abs(t.value-r)>Te)return!0}return!1}function Oe({data:e,chartHeight:n=34,live:c=!1}){let l=(0,K.useId)(),[u,d]=(0,K.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,q.jsxs)(`div`,{className:`flex min-h-0 w-full flex-col overflow-hidden`,style:{height:n+14},children:[(0,q.jsx)(`div`,{style:{height:n,width:`100%`},children:(0,q.jsx)(t,{width:`100%`,height:n,children:(0,q.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,q.jsx)(`defs`,{children:(0,q.jsxs)(`linearGradient`,{id:l,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:X,stopOpacity:.32}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:X,stopOpacity:0})]})}),(0,q.jsx)(i,{domain:[`auto`,`auto`],hide:!0}),(0,q.jsx)(a,{content:()=>null,cursor:!1}),(0,q.jsx)(o,{type:`monotone`,dataKey:`value`,stroke:X,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`url(#${l})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,fill:X,stroke:Ce,strokeWidth:1}}),m?(0,q.jsx)(r,{x:m.tick,y:m.value,r:2.25,fill:X,stroke:Ce,strokeWidth:1.25,isFront:!0,ifOverflow:`extendDomain`}):null]})})}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] leading-none tabular-nums text-muted-foreground`,children:[c?(0,q.jsxs)(`span`,{"aria-hidden":!0,className:`relative inline-flex size-1.5 shrink-0 items-center justify-center`,children:[(0,q.jsx)(`span`,{className:`absolute inline-flex size-2 animate-ping rounded-full bg-primary/50`}),(0,q.jsx)(`span`,{className:`relative inline-flex size-1.5 rounded-full bg-primary`})]}):null,u===null?(0,q.jsxs)(`span`,{children:[C(f),`–`,C(p)]}):(0,q.jsx)(`span`,{className:`font-medium text-primary`,children:C(u)})]})]})}function ke({detail:e,processVariables:t,memberValues:n,historyRef:r,tick:i,showQuality:a}){let{liveMap:o,orderedVariables:s}=(0,K.useMemo)(()=>{let e=new Map,n=[],a=[];for(let o of t){let t=De(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,q.jsx)(Y,{title:`Process`,subtitle:`No continuous analog readings defined for this asset`,className:`opacity-90`,children:(0,q.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,q.jsx)(Y,{title:`Process`,subtitle:`Live tag readings — trend is ~2 min at 1 Hz`,children:(0,q.jsx)(`ul`,{className:`divide-y divide-border/40`,children:s.map(([t,i])=>{let{value:s,quality:c}=Z(n,t,i),l=r.current.get(t)??[],u=T(e.browsePath,t),d=o.get(t)??!1,f=l.length>=2,p=y(i.meta.unit),h=w(t);return(0,q.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,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 sm:w-44 sm:shrink-0`,children:[(0,q.jsxs)(V,{children:[(0,q.jsx)(z,{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,q.jsx)(`span`,{}),children:h}),(0,q.jsx)(B,{side:`top`,align:`start`,className:`max-w-xs`,children:h})]}),(0,q.jsx)(N,{value:u,label:`Copy Topic / UNS path`})]}),(0,q.jsxs)(`div`,{className:`relative h-[56px] min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-x-0 top-1/2 h-px -translate-y-1/2 bg-border/30`}),f?(0,q.jsx)(Oe,{data:l,chartHeight:42,live:d}):(0,q.jsx)(`p`,{className:`flex h-full items-center text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Collecting trend…`})]}),(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2 sm:min-w-36 sm:shrink-0 sm:justify-end`,children:[(0,q.jsx)(`span`,{className:`blueprint-stat text-2xl font-semibold leading-none tabular-nums text-foreground`,children:typeof s==`number`?C(s):String(s)}),p&&(0,q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:p}),a&&c!==`good`&&(0,q.jsx)(H,{variant:c===`uncertain`?`secondary`:`destructive`,className:`shrink-0 text-[10px]`,children:c})]})]},t)})})})}function Ae({name:e,value:t,dataType:n,unit:r,access:i}){let a=w(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,q.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,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[10px] leading-snug text-muted-foreground`,children:[a,o&&(0,q.jsx)(`span`,{className:`ml-1 text-[8px] text-primary`,children:`CMD`})]}),(0,q.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=E.has(n)||e.includes(`fault_code`)&&!r,o=!i&&D.has(n);return(0,q.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,q.jsx)(`span`,{className:`wrap-break-word text-[10px] leading-tight text-muted-foreground`,children:a}),r?(0,q.jsx)(`span`,{className:`wrap-break-word font-mono text-sm font-medium leading-snug text-muted-foreground`,children:`—`}):(0,q.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:S(n)})]})}return(0,q.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,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[10px] leading-snug text-muted-foreground`,children:[a,o&&(0,q.jsx)(`span`,{className:`ml-1 text-[8px] text-primary`,children:`CMD`})]}),(0,q.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-xs font-medium tabular-nums`,children:[typeof t==`number`?C(t):String(t),r&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(r)})]})]})}function je(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 Me({stringEnumMembers:e,nonStringOperationalMembers:t,memberValues:n,className:r}){let i=(0,K.useMemo)(()=>je(e),[e]),a=(0,K.useMemo)(()=>je(t),[t]),o=`grid min-w-0 gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(100%,12.5rem),1fr))]`;return(0,q.jsx)(Y,{title:`Tags`,subtitle:`Mode, status flags, and control tags`,className:r,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5 p-4`,children:[i.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.length>0&&(0,q.jsx)(`h3`,{className:`blueprint-title text-muted-foreground`,children:`States`}),(0,q.jsx)(`div`,{className:o,children:i.map(([e,t])=>{let{value:r}=Z(n,e,t);return(0,q.jsx)(Ae,{name:e,value:r,dataType:t.meta.dataType,unit:t.meta.unit,access:t.meta.access},e)})})]}),a.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.length>0&&(0,q.jsx)(`h3`,{className:`blueprint-title text-muted-foreground`,children:`Flags & commands`}),(0,q.jsx)(`div`,{className:o,children:a.map(([e,t])=>{let{value:r}=Z(n,e,t);return(0,q.jsx)(Ae,{name:e,value:r,dataType:t.meta.dataType,unit:t.meta.unit,access:t.meta.access},e)})})]})]})})}function Q({className:e,counters:t,memberValues:n}){return(0,q.jsx)(Y,{title:`Counters`,subtitle:`Totals, hours, and accumulators`,className:e,children:(0,q.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,children:t.map(([e,t])=>{let{value:r}=Z(n,e,t);return(0,q.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,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:w(e)}),(0,q.jsxs)(`span`,{className:`blueprint-stat text-sm font-medium`,children:[typeof r==`number`?C(r):String(r),t.meta.unit&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(t.meta.unit)})]})]},e)})})})}function $({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,q.jsx)(Y,{title:`Nameplate & configuration`,subtitle:`Design parameters, identity, and reference values`,className:e,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[i&&(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:Object.entries(t.parameters).map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 py-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:w(e)}),(0,q.jsxs)(`span`,{className:`font-mono text-sm font-medium`,children:[typeof t.value==`number`?C(t.value):String(t.value),t.unit&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(t.unit)})]})]},e))}),a&&(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:n.map(([e,t])=>{let{value:n}=Z(r,e,t);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-[var(--miravo-radius-tight)] border border-border/60 bg-transparent p-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:w(e)}),(0,q.jsxs)(`span`,{className:`font-mono text-sm font-medium`,children:[typeof n==`number`?C(n):String(n),t.meta.unit&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(t.meta.unit)})]})]},e)})})]})})}function Ne({detail:e,memberValues:t}){if(!e.members.state_label)return null;let n=n=>t?.get(n)?.value??e.members[n]?.value;return(0,q.jsxs)(`section`,{className:`flex flex-wrap items-center gap-3 text-sm`,"aria-label":`Station production`,children:[(0,q.jsx)(H,{variant:`secondary`,children:String(n(`state_label`)??`idle`)}),(0,q.jsxs)(`span`,{children:[`Good: `,C(Number(n(`good_count`)??0))]}),(0,q.jsxs)(`span`,{children:[`Scrap: `,C(Number(n(`scrap_count`)??0))]}),n(`stop_reason`)&&(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:String(n(`stop_reason`))})]})}var Pe=120,Fe=`gap-4 sm:gap-5 lg:gap-x-6 lg:gap-y-5 xl:gap-x-8`,Ie=`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,K.useCallback)(()=>{(0,K.startTransition)(()=>{(0,K.addTransitionType)(le),t(`/?tab=assets`)})},[t]),[r,i]=(0,K.useState)(!1),[a,o]=h(`tab`,ee([`hmi`,`operate`,`data`,`operations`]).withDefault(`hmi`)),s=a===`data`||a===`operations`?`operate`:a;(0,K.useEffect)(()=>{(a===`data`||a===`operations`)&&o(`operate`)},[a,o]);let c=(0,K.useCallback)(e=>{o(`operate`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})})},[o]);(0,K.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:d.assets.detail(e??``),queryFn:()=>u(`/assets/${e}`,l.assetDetail),enabled:e!==void 0}),_=(0,K.useDeferredValue)(g.data??null),re=g.isError,v=f(t=>e?t.memberValues.get(e):void 0),y=f(e=>e.models),b=f(e=>e.assets),x=(0,K.useMemo)(()=>b.find(t=>t.id===e),[b,e]),S=x?.activeFaults,C=(0,K.useRef)(new Map),w=f(e=>e.tick);(0,K.useEffect)(()=>{if(!v||!e)return;let t=C.current;for(let[e,n]of v){if(typeof n.value!=`number`)continue;let r=t.get(e)??[];if(r[r.length-1]?.tick===w)continue;let i=r.length>=Pe?r.slice(r.length-Pe+1):r;t.set(e,[...i,{value:n.value,tick:w}])}},[v,w,e]);let T=(0,K.useMemo)(()=>_?Ee(_):[],[_]),E=(0,K.useMemo)(()=>{if(!_)return{operational:[],counters:[],reference:[]};let e=new Set(T.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`||Se.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}},[_,T]),ae=(0,K.useMemo)(()=>_?y.find(e=>e.name===_.assetType)?.faultNames??[]:[],[_,y]),D=S??_?.activeFaults??[],O=(0,K.useMemo)(()=>{if(!v)return D.length>0;for(let[,e]of v)if(e.quality!==`good`)return!0;return!1},[v,D.length]),k=(0,K.useMemo)(()=>E.operational.filter(([,e])=>e.meta.dataType===`String`),[E.operational]),A=(0,K.useMemo)(()=>E.operational.filter(([,e])=>e.meta.dataType!==`String`),[E.operational]),M=de(e,_,()=>g.refetch());if(!_)return re?Le(g.error)?(0,q.jsx)(U,{className:`min-h-full`,children:(0,q.jsx)(`div`,{className:`flex min-h-[40vh] items-center justify-center p-6 sm:p-12`,children:(0,q.jsx)(`div`,{className:`w-full max-w-md`,children:(0,q.jsxs)(se,{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,q.jsx)(`p`,{children:`The requested asset is no longer in the running factory or the URL is wrong.`}),(0,q.jsx)(`p`,{children:`Return to Assets and pick a live asset from the current factory.`})]})})})}):(0,q.jsx)(U,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center gap-4 p-6 sm:p-12`,children:[(0,q.jsx)(`div`,{className:`w-full max-w-md`,children:(0,q.jsx)(ce,{message:ue(g.error,`Could not load asset.`),onRetry:()=>void g.refetch(),isRetrying:g.isFetching})}),(0,q.jsx)(ie,{variant:`outline`,size:`sm`,onClick:n,children:`Back to Assets`})]})}):x?(0,q.jsx)(`div`,{className:Ie,children:(0,q.jsx)(be,{detail:{id:x.id,assetType:x.model,browsePath:x.browsePath,lifecycleStage:x.lifecycleStage,operatingHours:x.operatingHours,activeFaults:x.activeFaults,isQuarantined:x.isQuarantined,parameters:{},inputs:{},members:{},methods:{}},tick:w,activeFaults:D,memberValues:v,onBack:n})}):null;let N=E.operational.length>0,I=E.counters.length>0,L=E.reference.length>0||Object.keys(_.parameters).length>0,R=N||I||L,z=Object.keys(_.methods).length>0,B=N&&!I&&!L,V=N&&I&&L;return(0,q.jsxs)(`div`,{className:Ie,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 -z-10 hidden select-none overflow-hidden md:block`,children:(0,q.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,q.jsx)(be,{detail:_,tick:w,activeFaults:D,memberValues:v,onBack:n}),(0,q.jsx)(Ne,{detail:_,memberValues:v}),(0,q.jsx)(K.ViewTransition,{enter:`fade-in`,default:`none`,children:(0,q.jsxs)(ge,{value:s,onValueChange:e=>{o(e)},className:`min-h-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,q.jsxs)(he,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,q.jsxs)(W,{value:`hmi`,className:`gap-1.5 px-3 text-sm`,children:[(0,q.jsx)(P,{className:`size-3.5 shrink-0`}),`HMI`]}),(0,q.jsxs)(W,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,q.jsx)(oe,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,q.jsx)(G,{value:`hmi`,className:`flex-1 py-2`,children:(0,q.jsx)(m.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:(0,q.jsx)(ke,{detail:_,processVariables:T,memberValues:v,historyRef:C,tick:w,showQuality:O})},`hmi`)}),(0,q.jsx)(G,{value:`operate`,className:`flex-1 py-2`,children:(0,q.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:[R&&(0,q.jsxs)(`section`,{"aria-label":`Data`,className:j(`grid min-w-0 grid-cols-1`,Fe,V&&`lg:grid-cols-2 lg:grid-rows-[auto_auto] lg:items-start`,!V&&N&&(I||L)&&`lg:grid-cols-2 lg:items-start`),children:[N&&(0,q.jsx)(Me,{stringEnumMembers:k,nonStringOperationalMembers:A,memberValues:v,className:j(`min-h-0 min-w-0 self-stretch`,B&&`lg:col-span-2`,V&&`lg:row-span-2`)}),!N&&I&&L&&(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col gap-6 lg:col-span-2`,children:[(0,q.jsx)(Q,{counters:E.counters,memberValues:v}),(0,q.jsx)($,{detail:_,referenceMembers:E.reference,memberValues:v})]}),!N&&I&&!L&&(0,q.jsx)(Q,{className:`lg:col-span-2`,counters:E.counters,memberValues:v}),!N&&!I&&L&&(0,q.jsx)($,{className:`lg:col-span-2`,detail:_,referenceMembers:E.reference,memberValues:v}),N&&I&&(0,q.jsx)(Q,{className:`min-h-0 min-w-0 self-stretch lg:col-start-2 lg:row-start-1`,counters:E.counters,memberValues:v}),N&&L&&(0,q.jsx)($,{className:j(`min-h-0 min-w-0 self-stretch lg:col-start-2`,V?`lg:row-start-2`:`lg:row-start-1`),detail:_,referenceMembers:E.reference,memberValues:v})]}),(0,q.jsxs)(`section`,{"aria-label":`Operations`,className:j(F,`grid grid-cols-1`,z&&`lg:grid-cols-2`),children:[(0,q.jsx)(fe,{activeFaults:D,availableFaults:ae,onTriggerFault:M.triggerFault,onClearFault:M.clearFault}),z&&(0,q.jsx)(`div`,{className:`border-t border-border/50 lg:border-l lg:border-t-0`,children:(0,q.jsx)(me,{detail:_,methodArgs:M.methodArgs,setMethodArgs:M.setMethodArgs,onInvoke:M.invoke,isPending:M.isPending,pendingMethod:M.pendingMethod})})]}),(0,q.jsx)(pe,{assetId:_.id,onRemoved:n})]},`operate`)})]})}),(0,q.jsx)(ze,{open:r,onOpenChange:i})]})}function ze({open:e,onOpenChange:t}){return(0,q.jsx)(v,{open:e,onOpenChange:t,children:(0,q.jsxs)(g,{children:[(0,q.jsx)(_,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,q.jsx)(re,{className:`text-sm text-muted-foreground`,children:`Navigate this asset without leaving the keyboard.`}),(0,q.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,q.jsxs)(`li`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),(0,q.jsx)(`span`,{className:`flex items-center gap-1`,children:e.keys.map((t,n)=>(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.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,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`then`})]},`${e.label}-${t}`))})]},e.label))})]})})}export{Re as AssetDetailPage};
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,v as d,vt as f}from"./api-CtMmjN9m.js";import{t as p}from"./useQuery-Dxp3WSXF.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 re,t as v}from"./dialog-B5PqrKVw.js";import{C as ie,_ as y,a as b,b as x,c as S,f as C,g as w,i as T,n as E,p as ae,r as D,s as O,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 P,t as oe}from"./sliders-horizontal-BNKmYQgd.js";import{n as F,r as I}from"./use-engine-command-mutation-5q_LI_xT.js";import{t as L}from"./radio-BxpVYiyS.js";import{n as se,t as ce}from"./query-fetch-error-CWLZA2L5.js";import{t as R}from"./triangle-alert-DoAwrRgk.js";import{i as z,n as B,t as V}from"./tooltip-B3vOB1Vu.js";import{t as H}from"./badge-Bk1DaL6C.js";import{t as le}from"./transition-types-BKZuWApE.js";import{n as U}from"./auth-screen-backdrop-CEykEbfF.js";import{n as ue}from"./get-error-message-D800c4Uu.js";import{i as de,n as fe,r as pe,t as me}from"./asset-detail-actions-BrLTJCzY.js";import{i as W,n as G,r as he,t as ge}from"./tabs-Ch_VG8_S.js";var _e=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`}]]),ve=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`}]]),ye=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`}]]),K=e(n(),1),q=c();function be({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,q.jsxs)(`header`,{className:j(I,`flex w-full min-w-0 flex-col`),children:[(0,q.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,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:i,className:`transition-colors hover:text-foreground`,children:`Assets`}),(0,q.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,q.jsx)(`span`,{className:`truncate`,children:k(e.assetType)})]}),(0,q.jsx)(K.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,q.jsx)(`h1`,{className:`font-heading mt-1 text-2xl font-semibold uppercase leading-tight tracking-wide`,children:O(e.id)})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`p`,{className:`m-0 min-w-0 flex-1 font-mono text-[10px] leading-tight tracking-tight text-muted-foreground`,children:(0,q.jsx)(`span`,{className:`break-all`,children:e.browsePath.join(` / `)})}),(0,q.jsx)(`span`,{className:`inline-flex shrink-0`,children:(0,q.jsx)(N,{value:b(e.browsePath),label:`Copy Topic / UNS path`})})]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 self-end font-mono text-xs sm:self-start`,children:[(0,q.jsx)(L,{className:`size-3.5 animate-pulse text-primary`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`font-medium text-primary`,children:`LIVE`}),(0,q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[`t=`,t]}),(0,q.jsxs)(V,{children:[(0,q.jsx)(z,{render:(0,q.jsx)(`span`,{className:`inline-flex size-3.5 items-center justify-center outline-none focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,q.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,q.jsx)(`span`,{className:j(`relative inline-flex size-1.5 rounded-full`,m.dot)}),m.animate&&(0,q.jsx)(`span`,{className:j(`absolute inline-flex size-2.5 animate-ping rounded-full opacity-75`,m.pulse)})]})}),(0,q.jsx)(B,{side:`top`,align:`end`,children:(0,q.jsxs)(`span`,{className:`block max-w-[16rem] text-[11px] leading-snug`,children:[(0,q.jsx)(`span`,{className:`font-medium uppercase tracking-[0.08em]`,children:`Availability`}),` `,(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`— `,h]})]})})]})]})]}),(0,q.jsxs)(`fieldset`,{"aria-label":`Asset status`,className:`m-0 flex flex-col border-0 border-t border-border/50 p-0`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-px bg-transparent`,children:[(0,q.jsx)(J,{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,q.jsx)(J,{variant:`primary`,icon:R,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,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-px border-t border-border/50 bg-transparent sm:grid-cols-4`,children:[(0,q.jsx)(J,{variant:`compact`,icon:_e,label:`Lifecycle`,labelCompact:`Life`,value:S(e.lifecycleStage),tone:x(e.lifecycleStage),tooltip:`Where this asset sits in its operational lifecycle (e.g. commissioning, operating, maintenance, retired).`}),(0,q.jsx)(J,{variant:`compact`,icon:P,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,q.jsx)(J,{variant:`compact`,icon:ve,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,q.jsx)(J,{variant:`compact`,icon:ye,label:`Operating age`,value:ae(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 J({icon:e,label:t,labelCompact:n,value:r,suffix:i,tone:a,variant:o=`compact`,tooltip:s}){let c=o===`primary`;return(0,q.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,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 items-center gap-2`,children:(0,q.jsxs)(V,{children:[(0,q.jsxs)(z,{className:`flex min-h-0 min-w-0 flex-1 cursor-default items-center gap-2 text-left`,render:(0,q.jsx)(`div`,{}),children:[(0,q.jsx)(e,{className:j(`shrink-0 text-muted-foreground`,c?`size-4`:`size-3.5`),"aria-hidden":!0}),(0,q.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,q.jsx)(`span`,{className:`block wrap-break-word 2xl:hidden`,children:n??t}),(0,q.jsx)(`span`,{className:`hidden wrap-break-word 2xl:block`,children:t})]})]}),(0,q.jsx)(B,{side:`top`,align:`start`,sideOffset:6,className:`max-w-xs`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:s??t})]})})]})}),(0,q.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,q.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 Y({title:e,subtitle:t,children:n,className:r,id:i}){return(0,q.jsxs)(`section`,{id:i,className:j(F,r),children:[(0,q.jsxs)(`div`,{className:`border-b border-border/60 px-4 py-3`,children:[(0,q.jsx)(`h2`,{className:`blueprint-title text-foreground`,children:e}),t?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t}):null]}),(0,q.jsx)(`div`,{className:`overflow-hidden p-0`,children:n})]})}var xe=new Set([`pu`,`h`]),Se=[`_reference`,`_baseline`,`_setpoint`,`_command`],X=`var(--color-primary)`,Ce=`var(--color-background)`,we=60,Te=1e-4;function Z(e,t,n){let r=e?.get(t);return{value:r?.value??n.value,quality:r?.quality??n.quality}}function Ee(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&&!xe.has(t.meta.unit??``)&&!Se.some(t=>e.endsWith(t)))}function De(e,t){if(e.length<2)return!1;let n=t-we,r;for(let t of e)if(!(t.tick<n)){if(r===void 0){r=t.value;continue}if(Math.abs(t.value-r)>Te)return!0}return!1}function Oe({data:e,chartHeight:n=34,live:c=!1}){let l=(0,K.useId)(),[u,d]=(0,K.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,q.jsxs)(`div`,{className:`flex min-h-0 w-full flex-col overflow-hidden`,style:{height:n+14},children:[(0,q.jsx)(`div`,{style:{height:n,width:`100%`},children:(0,q.jsx)(t,{width:`100%`,height:n,children:(0,q.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,q.jsx)(`defs`,{children:(0,q.jsxs)(`linearGradient`,{id:l,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:X,stopOpacity:.32}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:X,stopOpacity:0})]})}),(0,q.jsx)(i,{domain:[`auto`,`auto`],hide:!0}),(0,q.jsx)(a,{content:()=>null,cursor:!1}),(0,q.jsx)(o,{type:`monotone`,dataKey:`value`,stroke:X,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`url(#${l})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,fill:X,stroke:Ce,strokeWidth:1}}),m?(0,q.jsx)(r,{x:m.tick,y:m.value,r:2.25,fill:X,stroke:Ce,strokeWidth:1.25,isFront:!0,ifOverflow:`extendDomain`}):null]})})}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] leading-none tabular-nums text-muted-foreground`,children:[c?(0,q.jsxs)(`span`,{"aria-hidden":!0,className:`relative inline-flex size-1.5 shrink-0 items-center justify-center`,children:[(0,q.jsx)(`span`,{className:`absolute inline-flex size-2 animate-ping rounded-full bg-primary/50`}),(0,q.jsx)(`span`,{className:`relative inline-flex size-1.5 rounded-full bg-primary`})]}):null,u===null?(0,q.jsxs)(`span`,{children:[C(f),`–`,C(p)]}):(0,q.jsx)(`span`,{className:`font-medium text-primary`,children:C(u)})]})]})}function ke({detail:e,processVariables:t,memberValues:n,historyRef:r,tick:i,showQuality:a}){let{liveMap:o,orderedVariables:s}=(0,K.useMemo)(()=>{let e=new Map,n=[],a=[];for(let o of t){let t=De(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,q.jsx)(Y,{title:`Process`,subtitle:`No continuous analog readings defined for this asset`,className:`opacity-90`,children:(0,q.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,q.jsx)(Y,{title:`Process`,subtitle:`Live tag readings — trend is ~2 min at 1 Hz`,children:(0,q.jsx)(`ul`,{className:`divide-y divide-border/40`,children:s.map(([t,i])=>{let{value:s,quality:c}=Z(n,t,i),l=r.current.get(t)??[],u=T(e.browsePath,t),d=o.get(t)??!1,f=l.length>=2,p=y(i.meta.unit),h=w(t);return(0,q.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,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 sm:w-44 sm:shrink-0`,children:[(0,q.jsxs)(V,{children:[(0,q.jsx)(z,{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,q.jsx)(`span`,{}),children:h}),(0,q.jsx)(B,{side:`top`,align:`start`,className:`max-w-xs`,children:h})]}),(0,q.jsx)(N,{value:u,label:`Copy Topic / UNS path`})]}),(0,q.jsxs)(`div`,{className:`relative h-[56px] min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-x-0 top-1/2 h-px -translate-y-1/2 bg-border/30`}),f?(0,q.jsx)(Oe,{data:l,chartHeight:42,live:d}):(0,q.jsx)(`p`,{className:`flex h-full items-center text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Collecting trend…`})]}),(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2 sm:min-w-36 sm:shrink-0 sm:justify-end`,children:[(0,q.jsx)(`span`,{className:`blueprint-stat text-2xl font-semibold leading-none tabular-nums text-foreground`,children:typeof s==`number`?C(s):String(s)}),p&&(0,q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:p}),a&&c!==`good`&&(0,q.jsx)(H,{variant:c===`uncertain`?`secondary`:`destructive`,className:`shrink-0 text-[10px]`,children:c})]})]},t)})})})}function Ae({name:e,value:t,dataType:n,unit:r,access:i}){let a=w(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,q.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,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[10px] leading-snug text-muted-foreground`,children:[a,o&&(0,q.jsx)(`span`,{className:`ml-1 text-[8px] text-primary`,children:`CMD`})]}),(0,q.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=E.has(n)||e.includes(`fault_code`)&&!r,o=!i&&D.has(n);return(0,q.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,q.jsx)(`span`,{className:`wrap-break-word text-[10px] leading-tight text-muted-foreground`,children:a}),r?(0,q.jsx)(`span`,{className:`wrap-break-word font-mono text-sm font-medium leading-snug text-muted-foreground`,children:`—`}):(0,q.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:S(n)})]})}return(0,q.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,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[10px] leading-snug text-muted-foreground`,children:[a,o&&(0,q.jsx)(`span`,{className:`ml-1 text-[8px] text-primary`,children:`CMD`})]}),(0,q.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-xs font-medium tabular-nums`,children:[typeof t==`number`?C(t):String(t),r&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(r)})]})]})}function je(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 Me({stringEnumMembers:e,nonStringOperationalMembers:t,memberValues:n,className:r}){let i=(0,K.useMemo)(()=>je(e),[e]),a=(0,K.useMemo)(()=>je(t),[t]),o=`grid min-w-0 gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(100%,12.5rem),1fr))]`;return(0,q.jsx)(Y,{title:`Tags`,subtitle:`Mode, status flags, and control tags`,className:r,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5 p-4`,children:[i.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.length>0&&(0,q.jsx)(`h3`,{className:`blueprint-title text-muted-foreground`,children:`States`}),(0,q.jsx)(`div`,{className:o,children:i.map(([e,t])=>{let{value:r}=Z(n,e,t);return(0,q.jsx)(Ae,{name:e,value:r,dataType:t.meta.dataType,unit:t.meta.unit,access:t.meta.access},e)})})]}),a.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.length>0&&(0,q.jsx)(`h3`,{className:`blueprint-title text-muted-foreground`,children:`Flags & commands`}),(0,q.jsx)(`div`,{className:o,children:a.map(([e,t])=>{let{value:r}=Z(n,e,t);return(0,q.jsx)(Ae,{name:e,value:r,dataType:t.meta.dataType,unit:t.meta.unit,access:t.meta.access},e)})})]})]})})}function Q({className:e,counters:t,memberValues:n}){return(0,q.jsx)(Y,{title:`Counters`,subtitle:`Totals, hours, and accumulators`,className:e,children:(0,q.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,children:t.map(([e,t])=>{let{value:r}=Z(n,e,t);return(0,q.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,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:w(e)}),(0,q.jsxs)(`span`,{className:`blueprint-stat text-sm font-medium`,children:[typeof r==`number`?C(r):String(r),t.meta.unit&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(t.meta.unit)})]})]},e)})})})}function $({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,q.jsx)(Y,{title:`Nameplate & configuration`,subtitle:`Design parameters, identity, and reference values`,className:e,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[i&&(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:Object.entries(t.parameters).map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 py-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:w(e)}),(0,q.jsxs)(`span`,{className:`font-mono text-sm font-medium`,children:[typeof t.value==`number`?C(t.value):String(t.value),t.unit&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(t.unit)})]})]},e))}),a&&(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:n.map(([e,t])=>{let{value:n}=Z(r,e,t);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-[var(--miravo-radius-tight)] border border-border/60 bg-transparent p-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:w(e)}),(0,q.jsxs)(`span`,{className:`font-mono text-sm font-medium`,children:[typeof n==`number`?C(n):String(n),t.meta.unit&&(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:y(t.meta.unit)})]})]},e)})})]})})}function Ne({detail:e,memberValues:t}){if(!e.members.state_label)return null;let n=n=>t?.get(n)?.value??e.members[n]?.value;return(0,q.jsxs)(`section`,{className:`flex flex-wrap items-center gap-3 text-sm`,"aria-label":`Station production`,children:[(0,q.jsx)(H,{variant:`secondary`,children:String(n(`state_label`)??`idle`)}),(0,q.jsxs)(`span`,{children:[`Good: `,C(Number(n(`good_count`)??0))]}),(0,q.jsxs)(`span`,{children:[`Scrap: `,C(Number(n(`scrap_count`)??0))]}),n(`stop_reason`)&&(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:String(n(`stop_reason`))})]})}var Pe=120,Fe=`gap-4 sm:gap-5 lg:gap-x-6 lg:gap-y-5 xl:gap-x-8`,Ie=`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,K.useCallback)(()=>{(0,K.startTransition)(()=>{(0,K.addTransitionType)(le),t(`/?tab=assets`)})},[t]),[r,i]=(0,K.useState)(!1),[a,o]=h(`tab`,ee([`hmi`,`operate`,`data`,`operations`]).withDefault(`hmi`)),s=a===`data`||a===`operations`?`operate`:a;(0,K.useEffect)(()=>{(a===`data`||a===`operations`)&&o(`operate`)},[a,o]);let c=(0,K.useCallback)(e=>{o(`operate`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})})},[o]);(0,K.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:d.assets.detail(e??``),queryFn:()=>u(`/assets/${e}`,l.assetDetail),enabled:e!==void 0}),_=(0,K.useDeferredValue)(g.data??null),re=g.isError,v=f(t=>e?t.memberValues.get(e):void 0),y=f(e=>e.models),b=f(e=>e.assets),x=(0,K.useMemo)(()=>b.find(t=>t.id===e),[b,e]),S=x?.activeFaults,C=(0,K.useRef)(new Map),w=f(e=>e.tick);(0,K.useEffect)(()=>{if(!v||!e)return;let t=C.current;for(let[e,n]of v){if(typeof n.value!=`number`)continue;let r=t.get(e)??[];if(r[r.length-1]?.tick===w)continue;let i=r.length>=Pe?r.slice(r.length-Pe+1):r;t.set(e,[...i,{value:n.value,tick:w}])}},[v,w,e]);let T=(0,K.useMemo)(()=>_?Ee(_):[],[_]),E=(0,K.useMemo)(()=>{if(!_)return{operational:[],counters:[],reference:[]};let e=new Set(T.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`||Se.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}},[_,T]),ae=(0,K.useMemo)(()=>_?y.find(e=>e.name===_.assetType)?.faultNames??[]:[],[_,y]),D=S??_?.activeFaults??[],O=(0,K.useMemo)(()=>{if(!v)return D.length>0;for(let[,e]of v)if(e.quality!==`good`)return!0;return!1},[v,D.length]),k=(0,K.useMemo)(()=>E.operational.filter(([,e])=>e.meta.dataType===`String`),[E.operational]),A=(0,K.useMemo)(()=>E.operational.filter(([,e])=>e.meta.dataType!==`String`),[E.operational]),M=de(e,_,()=>g.refetch());if(!_)return re?Le(g.error)?(0,q.jsx)(U,{className:`min-h-full`,children:(0,q.jsx)(`div`,{className:`flex min-h-[40vh] items-center justify-center p-6 sm:p-12`,children:(0,q.jsx)(`div`,{className:`w-full max-w-md`,children:(0,q.jsxs)(se,{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,q.jsx)(`p`,{children:`The requested asset is no longer in the running factory or the URL is wrong.`}),(0,q.jsx)(`p`,{children:`Return to Assets and pick a live asset from the current factory.`})]})})})}):(0,q.jsx)(U,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center gap-4 p-6 sm:p-12`,children:[(0,q.jsx)(`div`,{className:`w-full max-w-md`,children:(0,q.jsx)(ce,{message:ue(g.error,`Could not load asset.`),onRetry:()=>void g.refetch(),isRetrying:g.isFetching})}),(0,q.jsx)(ie,{variant:`outline`,size:`sm`,onClick:n,children:`Back to Assets`})]})}):x?(0,q.jsx)(`div`,{className:Ie,children:(0,q.jsx)(be,{detail:{id:x.id,assetType:x.model,browsePath:x.browsePath,lifecycleStage:x.lifecycleStage,operatingHours:x.operatingHours,activeFaults:x.activeFaults,isQuarantined:x.isQuarantined,parameters:{},inputs:{},members:{},methods:{}},tick:w,activeFaults:D,memberValues:v,onBack:n})}):null;let N=E.operational.length>0,I=E.counters.length>0,L=E.reference.length>0||Object.keys(_.parameters).length>0,R=N||I||L,z=Object.keys(_.methods).length>0,B=N&&!I&&!L,V=N&&I&&L;return(0,q.jsxs)(`div`,{className:Ie,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 -z-10 hidden select-none overflow-hidden md:block`,children:(0,q.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,q.jsx)(be,{detail:_,tick:w,activeFaults:D,memberValues:v,onBack:n}),(0,q.jsx)(Ne,{detail:_,memberValues:v}),(0,q.jsx)(K.ViewTransition,{enter:`fade-in`,default:`none`,children:(0,q.jsxs)(ge,{value:s,onValueChange:e=>{o(e)},className:`min-h-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,q.jsxs)(he,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,q.jsxs)(W,{value:`hmi`,className:`gap-1.5 px-3 text-sm`,children:[(0,q.jsx)(P,{className:`size-3.5 shrink-0`}),`HMI`]}),(0,q.jsxs)(W,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,q.jsx)(oe,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,q.jsx)(G,{value:`hmi`,className:`flex-1 py-2`,children:(0,q.jsx)(m.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:(0,q.jsx)(ke,{detail:_,processVariables:T,memberValues:v,historyRef:C,tick:w,showQuality:O})},`hmi`)}),(0,q.jsx)(G,{value:`operate`,className:`flex-1 py-2`,children:(0,q.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:[R&&(0,q.jsxs)(`section`,{"aria-label":`Data`,className:j(`grid min-w-0 grid-cols-1`,Fe,V&&`lg:grid-cols-2 lg:grid-rows-[auto_auto] lg:items-start`,!V&&N&&(I||L)&&`lg:grid-cols-2 lg:items-start`),children:[N&&(0,q.jsx)(Me,{stringEnumMembers:k,nonStringOperationalMembers:A,memberValues:v,className:j(`min-h-0 min-w-0 self-stretch`,B&&`lg:col-span-2`,V&&`lg:row-span-2`)}),!N&&I&&L&&(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col gap-6 lg:col-span-2`,children:[(0,q.jsx)(Q,{counters:E.counters,memberValues:v}),(0,q.jsx)($,{detail:_,referenceMembers:E.reference,memberValues:v})]}),!N&&I&&!L&&(0,q.jsx)(Q,{className:`lg:col-span-2`,counters:E.counters,memberValues:v}),!N&&!I&&L&&(0,q.jsx)($,{className:`lg:col-span-2`,detail:_,referenceMembers:E.reference,memberValues:v}),N&&I&&(0,q.jsx)(Q,{className:`min-h-0 min-w-0 self-stretch lg:col-start-2 lg:row-start-1`,counters:E.counters,memberValues:v}),N&&L&&(0,q.jsx)($,{className:j(`min-h-0 min-w-0 self-stretch lg:col-start-2`,V?`lg:row-start-2`:`lg:row-start-1`),detail:_,referenceMembers:E.reference,memberValues:v})]}),(0,q.jsxs)(`section`,{"aria-label":`Operations`,className:j(F,`grid grid-cols-1`,z&&`lg:grid-cols-2`),children:[(0,q.jsx)(fe,{activeFaults:D,availableFaults:ae,onTriggerFault:M.triggerFault,onClearFault:M.clearFault}),z&&(0,q.jsx)(`div`,{className:`border-t border-border/50 lg:border-l lg:border-t-0`,children:(0,q.jsx)(me,{detail:_,methodArgs:M.methodArgs,setMethodArgs:M.setMethodArgs,onInvoke:M.invoke,isPending:M.isPending,pendingMethod:M.pendingMethod})})]}),(0,q.jsx)(pe,{assetId:_.id,onRemoved:n})]},`operate`)})]})}),(0,q.jsx)(ze,{open:r,onOpenChange:i})]})}function ze({open:e,onOpenChange:t}){return(0,q.jsx)(v,{open:e,onOpenChange:t,children:(0,q.jsxs)(g,{children:[(0,q.jsx)(_,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,q.jsx)(re,{className:`text-sm text-muted-foreground`,children:`Navigate this asset without leaving the keyboard.`}),(0,q.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,q.jsxs)(`li`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),(0,q.jsx)(`span`,{className:`flex items-center gap-1`,children:e.keys.map((t,n)=>(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.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,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`then`})]},`${e.label}-${t}`))})]},e.label))})]})})}export{Re as AssetDetailPage};
@@ -1 +1 @@
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{vt as r}from"./api-GfuYYI6q.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-6JtFdy1_.js";import{t as h}from"./loader-circle-DjgHgHHl.js";import{l as g,t as _}from"./use-engine-command-mutation-CTbPh58S.js";import{t as v}from"./trash-2-BH9HDsZv.js";import{t as y}from"./triangle-alert-DoAwrRgk.js";import{a as b,i as x}from"./validation-DSsZ8qyt.js";import{i as S,n as C,t as w}from"./tooltip-B3vOB1Vu.js";import{t as T}from"./badge-Bk1DaL6C.js";var E=e(t(),1);function D(e,t,n){let[r,i]=(0,E.useState)({}),[a,o]=(0,E.useState)(null),s=_();(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=x(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)(w,{children:[(0,O.jsx)(S,{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)(C,{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)(b,{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)(y,{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)(b,{className:`bg-border/60`}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`p`,{className:f(A,`mb-2`),children:[`Inject fault`,(0,O.jsxs)(T,{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)(y,{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=_(),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)(v,{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
+ 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{vt as r}from"./api-CtMmjN9m.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-6JtFdy1_.js";import{t as h}from"./loader-circle-DjgHgHHl.js";import{l as g,t as _}from"./use-engine-command-mutation-5q_LI_xT.js";import{t as v}from"./trash-2-BH9HDsZv.js";import{t as y}from"./triangle-alert-DoAwrRgk.js";import{a as b,i as x}from"./validation-BSQDilvJ.js";import{i as S,n as C,t as w}from"./tooltip-B3vOB1Vu.js";import{t as T}from"./badge-Bk1DaL6C.js";var E=e(t(),1);function D(e,t,n){let[r,i]=(0,E.useState)({}),[a,o]=(0,E.useState)(null),s=_();(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=x(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)(w,{children:[(0,O.jsx)(S,{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)(C,{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)(b,{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)(y,{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)(b,{className:`bg-border/60`}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`p`,{className:f(A,`mb-2`),children:[`Inject fault`,(0,O.jsxs)(T,{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)(y,{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=_(),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)(v,{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 +1 @@
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,d as i,f as a,l as o,m as s}from"./dom-CQuChC3G.js";import{n as c,t as l}from"./by-path-CKZo157c.js";import{A as u,D as d,E as f,F as p,H as m,L as h,O as g,P as ee,V as _,X as te,a as v,b as ne,g as re,i as ie,j as ae,k as y,n as oe,o as se,r as ce,t as le}from"./status-DNfdEhTs.js";import{r as ue,t as de}from"./chiller-Jug0vRg-.js";import{n as fe,t as pe}from"./compressor-BkWNdwvy.js";import{a as me,i as b,n as he,o as ge,r as _e,s as ve,t as ye}from"./genset-DBpkUT9p.js";import{i as be,n as xe,r as Se,t as Ce}from"./tank-xgQfMS2d.js";import{t as we}from"./stages-C0cErwSQ.js";var Te=[[`genA`,`diesel-generator`,`power`,`gensets`,0],[`genB`,`diesel-generator`,`power`,`gensets`,1],[`genC`,`diesel-generator`,`power`,`gensets`,2],[`bulk`,`storage-tank`,`fuel`,`storage`,0],[`day`,`storage-tank`,`fuel`,`storage`,1],[`chillerA`,`industrial-chiller`,`cooling`,`chiller-plant`,0],[`chillerB`,`industrial-chiller`,`cooling`,`chiller-plant`,1],[`pumpA`,`centrifugal-pump`,`cooling`,`chilled-water`,0],[`pumpB`,`centrifugal-pump`,`cooling`,`chilled-water`,1],[`compressor`,`air-compressor`,`support`,`start-air`,0],[`fan`,`ac-induction-motor`,`support`,`ventilation`,0]],Ee=e=>l(Te,e);function De(e){let t=(e,t,n)=>({key:e,assetId:e,name:t,kind:`utility`,area:n});return[t(e.genA,`Genset A (primary)`,`Power`),t(e.genB,`Genset B`,`Power`),t(e.genC,`Genset C (reserve)`,`Power`),t(e.bulk,`Bulk fuel tank`,`Fuel`),t(e.day,`Day tank`,`Fuel`),t(e.chillerA,`Chiller A`,`Cooling`),t(e.chillerB,`Chiller B`,`Cooling`),t(e.pumpA,`Chilled-water pump 1`,`Cooling`),t(e.pumpB,`Chilled-water pump 2`,`Cooling`),t(e.compressor,`Start-air compressor`,`Support`),t(e.fan,`Hall ventilation fan`,`Support`)]}var Oe=e(t(),1),x=64,ke=2.2;function Ae(e,t,n){let{k:r,G:i,P:a,S:o,L:s,D:c,slab:l,cyl:u}=e,d=[],f=t.y+t.d,p=t.x+t.w,m=e=>s(e,{tone:`faint`}),h=[];for(let e=t.x+11;e<p-4;e+=11)h.push(r.segment([e,f,3],[e,f,x-9],a));for(let e=t.y+11;e<f-4;e+=11)h.push(r.segment([p,e,3],[p,e,x-9],a));let g=[];for(let e of[x-7,x-5,x-3])g.push(r.segment([t.x+4,f,e],[p-4,f,e],a)),g.push(r.segment([p,t.y+4,e],[p,f-4,e],a));d.push(l({x:t.x-1.6,y:t.y-1.6,w:t.w+3.2,d:t.d+3.2,r:2},0,3,{tone:`lo`},2,.3)),d.push(o(r.slabOf(t,0,x,a,2,.6),{tone:`lo`,inner:m(h.join(``))+s(g.join(``),{tone:`lo`})+m(r.sideSeam(t,3,a,2))})),d.push(s(r.planOutline(r.insetPlan(t,2),x,a,2),{tone:`lo`}));let ee=(e,t,n,i,o)=>{d.push(l({x:e-1,y:t-1,w:n+2,d:i+2,r:1},x,3,{tone:`lo`},2,.3)),d.push(l({x:e,y:t,w:n,d:i,r:1},x+3,o,{tone:`mid`},2,.3));let c=[];for(let s=x+5;s<x+3+o-1;s+=2.4)c.push(r.segment([e+2,t+i,s],[e+n-2,t+i,s],a));d.push(s(c.join(``),{tone:`faint`}));let u=x+3+o;for(let o of[e+n*.3,e+n*.7]){let e=t+i/2,n=[r.ring(o,e,i*.36,u,a,24),r.ring(o,e,i*.16,u,a,16)];for(let t=0;t<4;t++){let s=t/4*Math.PI*2+.4;n.push(r.segment([o+Math.cos(s)*i*.16,e+Math.sin(s)*i*.16,u],[o+Math.cos(s)*i*.36,e+Math.sin(s)*i*.36,u],a))}d.push(s(n.join(``),{tone:`mid`}))}};ee(t.x+12,t.y+t.d-52,34,18,10),ee(t.x+60,t.y+t.d-44,34,18,10),d.push(u(t.x+t.w-16,t.y+22,4,x,11,{tone:`mid`},20),u(t.x+t.w-16,t.y+22,5,x+10.4,1.6,{tone:`mid`},20),l({x:t.x+14,y:t.y+14,w:14,d:10,r:.8},x,5,{tone:`mid`},2,.3));let _=t.x+6;d.push(l({x:_-1.4,y:f,w:24.8,d:.8,r:.2},0,31.8,{tone:`lo`},2,0),`<g transform="${e.front(f+.9)}"><path class="sf-plate" d="M${_} -30H${_+22}V0H${_}Z"/>${Array.from({length:9},(e,t)=>`<path class="iso-line" data-tone="faint" d="M${_} ${-(3+t*3)}H${_+22}"/>`).join(``)}<path class="iso-line" data-tone="mid" d="M${_} -30H${_+22}V0H${_}Z"/></g>`,l({x:_,y:f+.8,w:22,d:1,r:.2},0,2.4,{tone:`mid`},2,0)),d.push(l({x:_-1,y:f,w:24,d:.9,r:.2},38,16,{tone:`lo`},2,0));let te=[];for(let e=40;e<53.5;e+=1.8)te.push(r.segment([_+.6,f+.9,e],[_+22-.6,f+.9,e],a));d.push(s(te.join(``),{tone:`mid`})),d.push(u(_+22+3.6,f+1.2,1.2,28,2.2,{tone:`mid`},10));let v=t.y+36;d.push(l({x:p,y:v-1.2,w:.9,d:12.4,r:.2},0,25,{tone:`lo`},2,0),l({x:p+.9,y:v,w:.5,d:10,r:.2},0,22.4,{tone:`mid`},2,0),l({x:p,y:v-3,w:4.4,d:16,r:.4},26,1.4,{tone:`mid`},2,.2),u(p+1.4,v+12.4,1.1,14,2,{tone:`mid`},10)),d.push(s(r.segment([p+1.4,v+1.2,13],[p+1.4,v+1.2,19],a)+r.segment([p+1.4,v+2,3],[p+1.4,v+9,3],a),{tone:`hi`}));let ne=t.y+72;d.push(l({x:p,y:ne,w:.9,d:30,r:.2},22,26,{tone:`lo`},2,0));let re=[];for(let e=24;e<47.5;e+=1.8)re.push(r.segment([p+.9,ne+1.4,e],[p+.9,ne+28.6,e],a));d.push(s(re.join(``),{tone:`mid`}));for(let{x:t,z:r,r:s}of n){let n=i.frameAlong([t,f,r],[0,1,0]);d.push(o(i.disc(0,1.2,s+2.8,n,a),{tone:`mid`}),o(i.disc(1.2,ke,s+1.4,n,a),{tone:`mid`}),c([0,1,2,3,4,5].map(n=>e.at([t+Math.cos(n*1.047)*(s+2),f+1.2,r+Math.sin(n*1.047)*(s+2)])),{size:.4}))}return d.join(``)}function je(e,t){let{k:n,P:r,L:i,slab:a}=e,o=[];for(let e of t){o.push(a(e,0,1.4,{tone:`lo`},2,.2));let t=[];if(e.w>=e.d)for(let i=e.x+9;i<e.x+e.w-2;i+=9)t.push(n.lineOnTop([i,e.y+.8],[i,e.y+e.d-.8],1.5,r));else for(let i=e.y+9;i<e.y+e.d-2;i+=9)t.push(n.lineOnTop([e.x+.8,i],[e.x+e.w-.8,i],1.5,r));o.push(i(t.join(``)+n.planOutline(n.insetPlan(e,.8),1.5,r,2),{tone:`faint`}))}return o.join(``)}function Me(e,t,n,r){let{k:i,P:a,S:o,L:s,slab:c}=e,l=[],u=t.y+t.d;for(let e=t.x+14;e<t.x+t.w-4;e+=14)l.push(i.segment([e,u,3],[e,u,n-5],a));let d=[o(i.slabOf(t,0,n,a,2,.4),{tone:`lo`,inner:s(l.join(``)+i.sideSeam(t,4,a,2),{tone:`faint`})}),c({x:t.x-1.5,y:t.y-1.5,w:t.w+3,d:t.d+3,r:.4},n,2.2,{tone:`mid`},2,.2)];for(let t of r){let r=[];for(let e=22;e<=n-12;e+=3)r.push(`<path class="iso-line" data-tone="lo" d="M${t-20} ${-e}H${t+20}"/>`);d.push(`<g transform="${e.front(u+.1)}"><path class="sf-plate" d="M${t-21} ${-(n-9)}H${t+21}V-18H${t-21}Z"/>${r.join(``)}</g>`)}return d.join(``)}function Ne(e,t,n){let{k:r,P:i,slab:a,L:o}=e,s=(n===`back`?[{x:t.x,y:t.y,w:t.w,d:3,r:.4},{x:t.x,y:t.y+3,w:3,d:t.d-6,r:.4}]:[{x:t.x,y:t.y+t.d-3,w:t.w,d:3,r:.4},{x:t.x+t.w-3,y:t.y+3,w:3,d:t.d-6,r:.4}]).map(e=>a(e,0,9,{tone:`mid`},2,.3));return n===`front`&&s.push(o(r.segment([t.x+3,t.y+t.d,4.4],[t.x+t.w,t.y+t.d,4.4],i)+r.segment([t.x+t.w,t.y+3,4.4],[t.x+t.w,t.y+t.d,4.4],i),{tone:`faint`})),s.join(``)}function Pe(e,[t,n,r]){let{G:i,P:a,S:o,cyl:s,slab:c,screws:l}=e,u=i.frameAlong([t,n,r],[0,1,0]);return[o(i.solidOf([[0,3.8],[1.6,5.2],[2.6,5.2],[3.6,4.2],[10.4,4.2],[11.4,5.2],[12.4,5.2],[14,3.8]],u,a),{tone:`mid`}),s(t,n+14/2,2.4,r+3.6,6,{tone:`mid`,crease:`none`},14),c({x:t-4.6,y:n+14/2-3.6,w:9.2,d:7.2,r:1},r+9.6,9,{tone:`mid`},2,.4),s(t,n+14/2,2.6,r+18.6,1.8,{tone:`lo`},14),l([[t-3.4,n+14/2+3.7],[t+3.4,n+14/2+3.7]],r+15)].join(``)}var S=16,C=56,Fe=3;function Ie(e,t,n,r){let{faceRule:i}=e,a=S-3,o=C-12,s=n+1.5,c=`<g transform="${e.front(t)}"><path class="iso-line" data-tone="lo" d="M${s} ${-o}H${s+a}V-5H${s}Z"/>`,l=``;if(r===0)l+=`<path class="sf-plate" d="M${s+2} ${-(o-3)}H${s+a-2}V${-(o-19)}H${s+2}Z"/>`,l+=`<path class="iso-line" data-tone="mid" d="M${s+4} ${-(o-6)}H${s+a/2}M${s+a-4} ${-(o-6)}H${s+a/2}M${s+a/2} ${-(o-6)}V${-(o-16)}"/>`;else if(r===1)for(let e=0;e<3;e++)l+=`<path class="sf-plate" d="M${s+2} ${-(o-4-e*9)}H${s+a-2}V${-(o-10-e*9)}H${s+2}Z"/><path class="iso-line" data-tone="mid" d="M${s+a/2-2} ${-(o-7-e*9)}H${s+a/2+2}"/>`;else for(let e=0;e<8;e++)l+=`<path class="iso-line" data-tone="faint" d="M${s+2} ${-(o-3-e*2.4)}H${s+a-2}"/>`;let u=`<path class="iso-line" data-tone="hi" d="M${s+a-2.6} -19V-27"/>`;return`${c}${l}${u}</g>${i(t,s+2,7,a-4,4)}`}function Le(e,t,n){let{k:r,P:i,L:a,slab:o,cyl:s,screws:c}=e,l=[],u=t.y+t.d;l.push(o({x:t.x-2,y:t.y-2,w:t.w+4,d:t.d+4,r:1},0,2,{tone:`lo`},2,.2));for(let n=0;n<Fe;n++){let d=t.x+n*S,f={x:d,y:t.y,w:S,d:t.d,r:.6};l.push(o(f,2,C-2,{tone:`mid`},2,.4)),l.push(o({x:d+1,y:t.y+1,w:S-2,d:t.d-2,r:.6},C,3,{tone:`mid`},2,.3)),l.push(a(r.segment([d+4,u-4,C+3.2],[d+S-4,u-4,C+3.2],i),{tone:`faint`}),s(d+3,t.y+4,1,C+3,2,{tone:`mid`},10),s(d+S-3,t.y+4,1,C+3,2,{tone:`mid`},10)),l.push(Ie(e,u,d,n)),l.push(c([[d+1.4,u-.2],[d+S-1.4,u-.2]],C-2))}let d=t.x+t.w-8,f=t.y+t.d/2-4,p=C+3.4,m=[];for(let e=d+2;e<n-1;e+=3)m.push(r.segment([e,f+.6,p+.6],[e,f+7.4,p+.6],i));return l.push(o({x:d,y:f,w:n-d,d:.9,r:.2},p,2,{tone:`mid`},2,.1),o({x:d,y:f+7.1,w:n-d,d:.9,r:.2},p,2,{tone:`mid`},2,.1),a(m.join(``),{tone:`mid`}),s(n-6,f+4,.9,0,p,{tone:`mid`,crease:`none`},10),o({x:n-8.6,y:f+1.4,w:5.2,d:5.2,r:.5},0,1.2,{tone:`lo`},2,.1),o({x:n-1.6,y:f-.6,w:1.6,d:9.2,r:.3},p-1,4,{tone:`mid`},2,.1)),l.join(``)}var Re={x:-15,y:0,w:30,d:14,r:1.5},w=30,T=12.5,ze=2.2,E=11;function Be(e,t){let{k:n,G:r,P:i,L:a,D:o,S:s,slab:c,cyl:l,screws:u,faceRule:d}=e,f=[],p=r.frameAlong([0,0,w],[0,1,0]);f.push(c({x:-15,y:0,w:30,d:9,r:1},0,1.4,{tone:`lo`},2,.3)),f.push(u(n.corners({x:-15,y:0,w:30,d:9},1.6),1.4));for(let e of[-11,8])f.push(c({x:e,y:0,w:3,d:7,r:.5},1.4,w-15-1.4+.4,{tone:`mid`},2,.2));f.push(c({x:-14.5,y:0,w:29,d:ze,r:1},w-15,30,{tone:`mid`},2,.3)),f.push(o([[-12.4,13.2],[12.4,13.2],[-12.4,-13.2],[12.4,-13.2]].map(([e=0,t=0])=>n.iso([e,ze+.1,w+t],i)),{size:.45})),f.push(s(r.disc(ze,E,T,p,i),{tone:`mid`}));for(let e of[5.4,8.2])f.push(a(n.sideRing([0,e,w],T,`y`,i,32),{tone:`faint`}));f.push(s(r.disc(E-1.8,E,T+1.2,p,i),{tone:`mid`})),f.push(s(r.disc(E-.4,E,T-1.6,p,i),{tone:`lo`})),f.push(`<path class="gs-blade" data-vfan="0,${E+.3},${w},${T-2.6}" data-top="0,${E},${w+T+4}" data-bearing="0,${E-3},${w+T}" d=""/>`),f.push(s(r.disc(E,E+2.4,3,p,i),{tone:`mid`}),s(r.disc(E+2.2,E+3,1.6,p,i),{tone:`lo`}));let m=[],h=E+1.6;for(let e of[5.5,T-2])m.push(n.sideRing([0,h,w],e,`y`,i,28));for(let e=0;e<8;e++){let t=e/8*Math.PI*2;m.push(n.segment([Math.cos(t)*3,h,w+Math.sin(t)*3],[Math.cos(t)*(T-2),h,w+Math.sin(t)*(T-2)],i))}return f.push(a(m.join(``),{tone:`mid`})),f.push(c({x:-4.5,y:3,w:9,d:6,r:.8},w+T-.6,6,{tone:`mid`},2,.3),l(0,6,1.1,w+T+5.4,2.2,{tone:`mid`},10),d(9.1,-3,w+T+1,6,2.4)),f.join(``)}var Ve=1e3,He={x:-500,y:-395,w:810,d:189,r:8},Ue={x:-380,y:-120,w:680,d:180,r:8},We={x:-520,y:-415,w:850,d:495,r:16},Ge=r([...s(We,-21,-14),...s(He,-14,140),...s(Ue,-14,100)],Ve,620,{pad:22,azimuth:60}),Ke=-300,D=[[-268,Ke],[-108,Ke],[52,Ke]],qe=(e,t)=>[e[0]+t[0],e[1]+t[1],t[2]],Je=e=>qe(D[e]??[0,0],me),Ye=e=>qe(D[e]??[0,0],_e),Xe={x:-340,y:-338,w:470,d:4,r:0},O=[-434,-340],Ze={r:32,h:104,nozzles:[{angle:90,z:14,r:2,role:`outlet`}]},k={x:-486,y:-392,w:104,d:104,r:0},A=[-434,-232],j={r:17,h:62,windowX:8,panelX:-26,nozzles:[{angle:270,z:14,r:2,role:`inlet`},{angle:0,z:7,r:2,role:`outlet`}]},M=A[0],Qe=-284,$e={x:132,y:-330,w:48,d:25,r:1},N={x:204,y:-395,w:104,d:145,r:2},et=[293,N.y+N.d],tt=[-202,-135,0],nt=[[-65,-62],[-169,-62]],rt=[-34,36.6,40],it=[-20,36.6,40],at=[94,-130,0],ot=.8,st=[[47,36],[157,36]],ct=e=>[(e[0]-at[0])*ot,(e[1]-at[1])*ot,e[2]*ot],lt=ct(ee),ut=ct(u),dt=[{x:-318,y:-262,w:462,d:8,r:0},...D.map(([e])=>({x:e-48,y:-290,w:6,d:32,r:0})),{x:137,y:-308,w:6,d:54,r:0}],ft=[-67,-132,0],pt=[-292,-62],mt=[-110,-114,24],ht=we([...D.map((e,t)=>({key:`gen${t}`,at:e,h:126})),{key:`bund-back`,at:[O[0],k.y+2],h:12},{key:`bulk`,at:O,h:Ze.h+12},{key:`bund-front`,at:[O[0],k.y+k.d-2],h:12},{key:`valve`,at:[M,Qe+7],h:30},{key:`day`,at:A,h:j.h+12},{key:`vent`,at:[et[0],et[1]+6],h:50},{key:`lineup`,at:[$e.x+$e.w/2,$e.y+$e.d/2],h:62},{key:`hall`,at:[N.x+N.w/2,N.y+N.d/2],h:76},...nt.map((e,t)=>({key:`chiller${t}`,at:e,h:56})),...st.map((e,t)=>({key:`pump${t}`,at:e,h:45*ot})),{key:`compressor`,at:pt,h:46}],Ge),gt=ht.order,_t=ht.slotDepths,vt=ht.depth,yt=(e,t)=>[e[0]+t[0],e[1]+t[1],t[2]],P=(e,t,n,r)=>[t??e[0],n??e[1],r??e[2]],bt=(e,t,n)=>{let r=e.nozzles[n];return r?yt(t,Se(e,r)):[0,0,0]},F=6,xt=bt(Ze,O,0),St=bt(j,A,0),Ct=bt(j,A,1),I=Ct[1],[wt,Tt,Et]=[0,1,2].map(Je),[L,Dt,Ot]=[0,1,2].map(Ye),kt=Qe+14,At=-366,R=-250,z=L[2],jt=16,Mt=[pt[0]+mt[0]-ft[0],pt[1]+mt[1]-ft[1],mt[2]],Nt=Mt[1]+jt,[B=[0,0],Pt=[0,0]]=nt,[V=[0,0],H=[0,0]]=st,U=e=>yt(e,ut),W=e=>yt(e,lt),G=e=>yt(e,rt),K=e=>yt(e,it),q=W(V)[2],J=B[1]+61,Y=72,X=B[1]+48,Ft=84,It=V[1]-34,Lt=W(H)[0]+13,Rt=W(V)[0]+8,zt=6,Bt=K(B)[0]+40,Vt=N.y+N.d+ke,Ht=[{id:`xfer:a`,medium:`fuel`,r:2,pts:[xt,[M,Qe,14]]},{id:`xfer:b`,medium:`fuel`,r:2,pts:[[M,kt,14],St]},{id:`fuel:all`,medium:`fuel`,r:2,pts:[Ct,[wt[0],I,F]]},{id:`fuel:bc`,medium:`fuel`,r:2,pts:[[wt[0],I,F],[Tt[0],I,F]]},{id:`fuel:c`,medium:`fuel`,r:2,pts:[[Tt[0],I,F],[Et[0],I,F],Et]},{id:`fuel:a`,medium:`fuel`,r:2,pts:[[wt[0],I,F],wt]},{id:`fuel:b`,medium:`fuel`,r:2,pts:[[Tt[0],I,F],Tt]},{id:`air:main`,medium:`air`,r:b,bend:8,pts:[Mt,P(Mt,null,Nt,null),[At,Nt,Mt[2]],[At,Nt,z],[At,R,z],[L[0],R,z]]},{id:`air:ab`,medium:`air`,r:b,pts:[[L[0],R,z],[Dt[0],R,z]]},{id:`air:c`,medium:`air`,r:b,pts:[[Dt[0],R,z],[Ot[0],R,z],Ot]},{id:`air:a`,medium:`air`,r:b,pts:[[L[0],R,z],L]},{id:`air:b`,medium:`air`,r:b,pts:[[Dt[0],R,z],Dt]},{id:`suction`,medium:`coolantret`,r:2.6,pts:[[265,Vt,q],[265,It,q],[Lt,It,q]]},{id:`suction:standby`,medium:`coolantret`,r:2.6,pts:[[Lt,It,q],P(W(H),Lt,null,null),W(H)]},{id:`suction:duty`,medium:`coolantret`,r:2.6,pts:[[Lt,It,q],[Rt,It,q],P(W(V),Rt,null,null),W(V)]},...[[`a`,B],[`b`,Pt]].map(([e,t])=>({id:`out:${e}`,medium:`coolant`,r:2.2,pts:[K(t),P(K(t),null,X,null),P(K(t),null,X,Ft)]})),{id:`chws:b`,medium:`coolant`,r:2.6,blind:[!0,!1],pts:[[K(Pt)[0]-zt,X,Ft],[K(B)[0],X,Ft]]},{id:`chws`,medium:`coolant`,r:2.6,pts:[[K(B)[0],X,Ft],[Bt,X,Ft],[Bt,X,40],[240,X,40],[240,Vt,40]]},...[[`duty`,V],[`standby`,H]].map(([e,t])=>({id:`discharge:${e}`,medium:`coolantret`,r:2.6,fromStub:!0,pts:[U(t),P(U(t),null,null,Y),P(U(t),null,J,Y)]})),{id:`header:standby`,medium:`coolantret`,r:2.6,blind:[!0,!1],pts:[[U(H)[0]+zt,J,Y],[U(V)[0],J,Y]]},{id:`header`,medium:`coolantret`,r:2.6,pts:[[U(V)[0],J,Y],[G(B)[0],J,Y]]},{id:`header:b`,medium:`coolantret`,r:2.6,blind:[!1,!0],pts:[[G(B)[0],J,Y],[G(Pt)[0]-zt,J,Y]]},...[[`a`,B],[`b`,Pt]].map(([e,t])=>({id:`in:${e}`,medium:`coolantret`,r:2.2,pts:[P(G(t),null,J,Y),P(G(t),null,J,null),G(t)]}))],Ut=(e,t)=>[He,Ue].some(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.d),Z=(e,t,n,r)=>[e,t,n,r,Ut(e,t)?0:-14],Wt={z:10,flanged:!0,routes:Ht,posts:[...[-395,-330,-215,-60].map(e=>Z(e,I,2,F)),Z(M,-294,2,14),...[-70,-140,-190,R].map(e=>Z(At,e,b,z)),...[-300,-155,10].map(e=>Z(e,R,b,z)),...[-225,-150,-90,-35].map(e=>Z(240,e,2.6,40)),...[-225,-150,-90,-35,20].map(e=>Z(265,e,2.6,q)),...[-20,100,215].map(e=>Z(e,X,2.6,40)),...[-150,-20,130].map(e=>Z(e,J,2.6,Y))]},Q=n(),Gt={x:-248,y:-164,w:92,d:58,r:3},Kt={x:-136,y:-152,w:138,d:40,r:3},qt=xe(Ze),Jt=xe(j),Yt=(e,t)=>p(e,t,`coolantret`,!0),Xt=(e,t)=>be(e,t,Ze),Zt=(e,t)=>be(e,t,j),Qt=(e,t)=>fe(e,t,{barFull:10,dialFull:12}),$t=e=>Ae(e,N,[{x:240,z:40,r:2.6},{x:265,z:lt[2],r:2.6}]),en=e=>Le(e,$e,N.x),tn=e=>Pe(e,[M,Qe,14]),nn=e=>Ne(e,k,`back`),rn=e=>Ne(e,k,`front`);function an({ids:e}){let t=a(),n=f(Wt,vt),r=(0,Oe.useMemo)(()=>h(t,We)+t.plinth(He)+t.plinth(Ue)+je(t,dt)+Me(t,Xe,62,D.map(([e])=>e)),[t]),s=e=>(0,Q.jsx)(i,{html:`${n.layers[e]??``}<g data-flows="${e}" data-depth="${e===0?-1e9:_t[e-1]??0}"></g>`,data:{pipes:``}},`pipes-${e}`),c=[e.genA,e.genB,e.genC],l={"bund-back":(0,Q.jsx)(g,{build:nn,intro:1}),bulk:(0,Q.jsx)(`g`,{className:`fuel-tank`,children:(0,Q.jsx)(d,{to:y(O),children:(0,Q.jsx)(o,{id:e.bulk,plan:qt,intro:2,draw:Xt})})}),"bund-front":(0,Q.jsx)(g,{build:rn,intro:2}),valve:(0,Q.jsx)(g,{build:tn,intro:3}),day:(0,Q.jsx)(`g`,{className:`fuel-tank`,children:(0,Q.jsx)(d,{to:y(A),children:(0,Q.jsx)(o,{id:e.day,plan:Jt,intro:3,draw:Zt})})}),vent:(0,Q.jsx)(d,{to:y(et),children:(0,Q.jsx)(o,{id:e.fan,plan:Re,intro:9,draw:Be})}),lineup:(0,Q.jsx)(g,{build:en,intro:8}),hall:(0,Q.jsx)(g,{build:$t,intro:8}),compressor:(0,Q.jsx)(d,{from:ft,to:y(pt),children:(0,Q.jsx)(o,{id:e.compressor,plan:Kt,intro:13,draw:Qt})})};for(let[e,t]of D.entries())l[`gen${e}`]=(0,Q.jsx)(`g`,{className:`gen-set`,children:(0,Q.jsx)(d,{to:y(t),children:(0,Q.jsx)(o,{id:c[e]??``,plan:ge,intro:4+e,draw:ve})})});for(let[t,n]of nt.entries())l[`chiller${t}`]=(0,Q.jsx)(d,{from:tt,to:y(n),children:(0,Q.jsx)(o,{id:t?e.chillerB:e.chillerA,plan:Gt,intro:10+t,draw:ue})});for(let[t,n]of st.entries())l[`pump${t}`]=(0,Q.jsx)(d,{from:at,to:y(n),scale:ot,children:(0,Q.jsx)(o,{id:t?e.pumpB:e.pumpA,plan:ae,intro:12+t,draw:Yt})});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(i,{html:r,data:{plinth:``}}),s(0),gt.flatMap((e,t)=>[(0,Q.jsx)(`g`,{children:l[e.key]},e.key),s(t+1)])]})}var $=e=>e>.002?6+26*re(e*2):0,on=e=>{let{svg:t,feed:n,ids:r}=e,i=ne(t),a=ye(e,i),o=Ce(e),s=de(e,i),c=ce(e,i),l=pe(e,i),u=[a,o,s,c,l,he(e,i)],d=ie(e,e=>oe(n,e,`availability`)),f=se(e,{needle:e=>l.needle(e)??s.needle(e)??0,bar:e=>u.reduce((t,n)=>t??n.bar(e),void 0)??0,alertsHigh:()=>!0,ready:()=>!0}),p=()=>{let e=n.param(r.day,`max_inflow_lps`,0);return e>0?re(n.num(r.day,`inflow_rate`)/e):0},m=(...e)=>re(e.reduce((e,t)=>e+a.fuelPu(t),0)),h=()=>c.flowPu(r.pumpA)+c.flowPu(r.pumpB),g=e=>{let t=[r.chillerA,r.chillerB].filter(e=>n.num(e,`coolant_flow_rate`)>0);return t.includes(e)?h()/t.length:0},ee=v(e,({id:e})=>{switch(e){case`xfer:a`:case`xfer:b`:return $(p());case`fuel:all`:return $(m(r.genA,r.genB,r.genC));case`fuel:bc`:return $(m(r.genB,r.genC));case`fuel:c`:return $(m(r.genC));case`fuel:a`:return $(m(r.genA));case`fuel:b`:return $(m(r.genB));case`air:main`:case`air:ab`:case`air:c`:case`air:a`:case`air:b`:return $(l.deliveredPu(r.compressor));case`suction`:case`chws`:case`header`:return $(h());case`suction:duty`:case`discharge:duty`:return $(c.flowPu(r.pumpA));case`suction:standby`:case`discharge:standby`:case`header:standby`:return $(c.flowPu(r.pumpB));case`in:a`:case`out:a`:return $(g(r.chillerA));case`in:b`:case`out:b`:case`header:b`:case`chws:b`:return $(g(r.chillerB));default:return 0}});return{data(e){d.draw(e)},draw({sdt:e,t,introDone:n}){ee.draw(e),f.draw(e,t);for(let r of u)r.draw(e,t,n)},resync(){},status:e=>le(n,e,`availability`)}},sn=_(Ge),cn=m(sn,Wt,vt),ln=te({layout:{width:Ve,height:620,label:`Isometric model of the Backup Power facility: along the back, the fuel yard with its bulk tank in a bund and the day tank, three diesel gen sets side by side with their exhaust stacks and radiators, the electrical lineup and the data hall they back up; along the front, the start-air compressor, two chillers and two chilled-water pumps whose loop runs to the hall. Pipes carry fuel, start air and chilled water between them. Every moving part follows live values from the running engine.`,kit:sn,flows:cn.flows,joints:cn.joints,Scene:an,compose:on},resolve:Ee,things:De,caption:`generation · fuel · cooling`,mismatch:`This floor expects the Backup Power facility: three diesel gensets, the bulk and day fuel tanks, two chillers with two chilled-water pumps, the start-air compressor and the hall ventilation motor, by area and line.`,statusBasis:`availability`,Overview:c,tab:`Plant`});export{ln as backupFloor};
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,d as i,f as a,l as o,m as s}from"./dom-CQuChC3G.js";import{n as c,t as l}from"./by-path-CGbqDnvK.js";import{A as u,D as d,E as f,F as p,H as m,L as h,O as g,P as ee,V as _,X as te,a as v,b as ne,g as re,i as ie,j as ae,k as y,n as oe,o as se,r as ce,t as le}from"./status-DNfdEhTs.js";import{r as ue,t as de}from"./chiller-Jug0vRg-.js";import{n as fe,t as pe}from"./compressor-BkWNdwvy.js";import{a as me,i as b,n as he,o as ge,r as _e,s as ve,t as ye}from"./genset-DBpkUT9p.js";import{i as be,n as xe,r as Se,t as Ce}from"./tank-xgQfMS2d.js";import{t as we}from"./stages-C0cErwSQ.js";var Te=[[`genA`,`diesel-generator`,`power`,`gensets`,0],[`genB`,`diesel-generator`,`power`,`gensets`,1],[`genC`,`diesel-generator`,`power`,`gensets`,2],[`bulk`,`storage-tank`,`fuel`,`storage`,0],[`day`,`storage-tank`,`fuel`,`storage`,1],[`chillerA`,`industrial-chiller`,`cooling`,`chiller-plant`,0],[`chillerB`,`industrial-chiller`,`cooling`,`chiller-plant`,1],[`pumpA`,`centrifugal-pump`,`cooling`,`chilled-water`,0],[`pumpB`,`centrifugal-pump`,`cooling`,`chilled-water`,1],[`compressor`,`air-compressor`,`support`,`start-air`,0],[`fan`,`ac-induction-motor`,`support`,`ventilation`,0]],Ee=e=>l(Te,e);function De(e){let t=(e,t,n)=>({key:e,assetId:e,name:t,kind:`utility`,area:n});return[t(e.genA,`Genset A (primary)`,`Power`),t(e.genB,`Genset B`,`Power`),t(e.genC,`Genset C (reserve)`,`Power`),t(e.bulk,`Bulk fuel tank`,`Fuel`),t(e.day,`Day tank`,`Fuel`),t(e.chillerA,`Chiller A`,`Cooling`),t(e.chillerB,`Chiller B`,`Cooling`),t(e.pumpA,`Chilled-water pump 1`,`Cooling`),t(e.pumpB,`Chilled-water pump 2`,`Cooling`),t(e.compressor,`Start-air compressor`,`Support`),t(e.fan,`Hall ventilation fan`,`Support`)]}var Oe=e(t(),1),x=64,ke=2.2;function Ae(e,t,n){let{k:r,G:i,P:a,S:o,L:s,D:c,slab:l,cyl:u}=e,d=[],f=t.y+t.d,p=t.x+t.w,m=e=>s(e,{tone:`faint`}),h=[];for(let e=t.x+11;e<p-4;e+=11)h.push(r.segment([e,f,3],[e,f,x-9],a));for(let e=t.y+11;e<f-4;e+=11)h.push(r.segment([p,e,3],[p,e,x-9],a));let g=[];for(let e of[x-7,x-5,x-3])g.push(r.segment([t.x+4,f,e],[p-4,f,e],a)),g.push(r.segment([p,t.y+4,e],[p,f-4,e],a));d.push(l({x:t.x-1.6,y:t.y-1.6,w:t.w+3.2,d:t.d+3.2,r:2},0,3,{tone:`lo`},2,.3)),d.push(o(r.slabOf(t,0,x,a,2,.6),{tone:`lo`,inner:m(h.join(``))+s(g.join(``),{tone:`lo`})+m(r.sideSeam(t,3,a,2))})),d.push(s(r.planOutline(r.insetPlan(t,2),x,a,2),{tone:`lo`}));let ee=(e,t,n,i,o)=>{d.push(l({x:e-1,y:t-1,w:n+2,d:i+2,r:1},x,3,{tone:`lo`},2,.3)),d.push(l({x:e,y:t,w:n,d:i,r:1},x+3,o,{tone:`mid`},2,.3));let c=[];for(let s=x+5;s<x+3+o-1;s+=2.4)c.push(r.segment([e+2,t+i,s],[e+n-2,t+i,s],a));d.push(s(c.join(``),{tone:`faint`}));let u=x+3+o;for(let o of[e+n*.3,e+n*.7]){let e=t+i/2,n=[r.ring(o,e,i*.36,u,a,24),r.ring(o,e,i*.16,u,a,16)];for(let t=0;t<4;t++){let s=t/4*Math.PI*2+.4;n.push(r.segment([o+Math.cos(s)*i*.16,e+Math.sin(s)*i*.16,u],[o+Math.cos(s)*i*.36,e+Math.sin(s)*i*.36,u],a))}d.push(s(n.join(``),{tone:`mid`}))}};ee(t.x+12,t.y+t.d-52,34,18,10),ee(t.x+60,t.y+t.d-44,34,18,10),d.push(u(t.x+t.w-16,t.y+22,4,x,11,{tone:`mid`},20),u(t.x+t.w-16,t.y+22,5,x+10.4,1.6,{tone:`mid`},20),l({x:t.x+14,y:t.y+14,w:14,d:10,r:.8},x,5,{tone:`mid`},2,.3));let _=t.x+6;d.push(l({x:_-1.4,y:f,w:24.8,d:.8,r:.2},0,31.8,{tone:`lo`},2,0),`<g transform="${e.front(f+.9)}"><path class="sf-plate" d="M${_} -30H${_+22}V0H${_}Z"/>${Array.from({length:9},(e,t)=>`<path class="iso-line" data-tone="faint" d="M${_} ${-(3+t*3)}H${_+22}"/>`).join(``)}<path class="iso-line" data-tone="mid" d="M${_} -30H${_+22}V0H${_}Z"/></g>`,l({x:_,y:f+.8,w:22,d:1,r:.2},0,2.4,{tone:`mid`},2,0)),d.push(l({x:_-1,y:f,w:24,d:.9,r:.2},38,16,{tone:`lo`},2,0));let te=[];for(let e=40;e<53.5;e+=1.8)te.push(r.segment([_+.6,f+.9,e],[_+22-.6,f+.9,e],a));d.push(s(te.join(``),{tone:`mid`})),d.push(u(_+22+3.6,f+1.2,1.2,28,2.2,{tone:`mid`},10));let v=t.y+36;d.push(l({x:p,y:v-1.2,w:.9,d:12.4,r:.2},0,25,{tone:`lo`},2,0),l({x:p+.9,y:v,w:.5,d:10,r:.2},0,22.4,{tone:`mid`},2,0),l({x:p,y:v-3,w:4.4,d:16,r:.4},26,1.4,{tone:`mid`},2,.2),u(p+1.4,v+12.4,1.1,14,2,{tone:`mid`},10)),d.push(s(r.segment([p+1.4,v+1.2,13],[p+1.4,v+1.2,19],a)+r.segment([p+1.4,v+2,3],[p+1.4,v+9,3],a),{tone:`hi`}));let ne=t.y+72;d.push(l({x:p,y:ne,w:.9,d:30,r:.2},22,26,{tone:`lo`},2,0));let re=[];for(let e=24;e<47.5;e+=1.8)re.push(r.segment([p+.9,ne+1.4,e],[p+.9,ne+28.6,e],a));d.push(s(re.join(``),{tone:`mid`}));for(let{x:t,z:r,r:s}of n){let n=i.frameAlong([t,f,r],[0,1,0]);d.push(o(i.disc(0,1.2,s+2.8,n,a),{tone:`mid`}),o(i.disc(1.2,ke,s+1.4,n,a),{tone:`mid`}),c([0,1,2,3,4,5].map(n=>e.at([t+Math.cos(n*1.047)*(s+2),f+1.2,r+Math.sin(n*1.047)*(s+2)])),{size:.4}))}return d.join(``)}function je(e,t){let{k:n,P:r,L:i,slab:a}=e,o=[];for(let e of t){o.push(a(e,0,1.4,{tone:`lo`},2,.2));let t=[];if(e.w>=e.d)for(let i=e.x+9;i<e.x+e.w-2;i+=9)t.push(n.lineOnTop([i,e.y+.8],[i,e.y+e.d-.8],1.5,r));else for(let i=e.y+9;i<e.y+e.d-2;i+=9)t.push(n.lineOnTop([e.x+.8,i],[e.x+e.w-.8,i],1.5,r));o.push(i(t.join(``)+n.planOutline(n.insetPlan(e,.8),1.5,r,2),{tone:`faint`}))}return o.join(``)}function Me(e,t,n,r){let{k:i,P:a,S:o,L:s,slab:c}=e,l=[],u=t.y+t.d;for(let e=t.x+14;e<t.x+t.w-4;e+=14)l.push(i.segment([e,u,3],[e,u,n-5],a));let d=[o(i.slabOf(t,0,n,a,2,.4),{tone:`lo`,inner:s(l.join(``)+i.sideSeam(t,4,a,2),{tone:`faint`})}),c({x:t.x-1.5,y:t.y-1.5,w:t.w+3,d:t.d+3,r:.4},n,2.2,{tone:`mid`},2,.2)];for(let t of r){let r=[];for(let e=22;e<=n-12;e+=3)r.push(`<path class="iso-line" data-tone="lo" d="M${t-20} ${-e}H${t+20}"/>`);d.push(`<g transform="${e.front(u+.1)}"><path class="sf-plate" d="M${t-21} ${-(n-9)}H${t+21}V-18H${t-21}Z"/>${r.join(``)}</g>`)}return d.join(``)}function Ne(e,t,n){let{k:r,P:i,slab:a,L:o}=e,s=(n===`back`?[{x:t.x,y:t.y,w:t.w,d:3,r:.4},{x:t.x,y:t.y+3,w:3,d:t.d-6,r:.4}]:[{x:t.x,y:t.y+t.d-3,w:t.w,d:3,r:.4},{x:t.x+t.w-3,y:t.y+3,w:3,d:t.d-6,r:.4}]).map(e=>a(e,0,9,{tone:`mid`},2,.3));return n===`front`&&s.push(o(r.segment([t.x+3,t.y+t.d,4.4],[t.x+t.w,t.y+t.d,4.4],i)+r.segment([t.x+t.w,t.y+3,4.4],[t.x+t.w,t.y+t.d,4.4],i),{tone:`faint`})),s.join(``)}function Pe(e,[t,n,r]){let{G:i,P:a,S:o,cyl:s,slab:c,screws:l}=e,u=i.frameAlong([t,n,r],[0,1,0]);return[o(i.solidOf([[0,3.8],[1.6,5.2],[2.6,5.2],[3.6,4.2],[10.4,4.2],[11.4,5.2],[12.4,5.2],[14,3.8]],u,a),{tone:`mid`}),s(t,n+14/2,2.4,r+3.6,6,{tone:`mid`,crease:`none`},14),c({x:t-4.6,y:n+14/2-3.6,w:9.2,d:7.2,r:1},r+9.6,9,{tone:`mid`},2,.4),s(t,n+14/2,2.6,r+18.6,1.8,{tone:`lo`},14),l([[t-3.4,n+14/2+3.7],[t+3.4,n+14/2+3.7]],r+15)].join(``)}var S=16,C=56,Fe=3;function Ie(e,t,n,r){let{faceRule:i}=e,a=S-3,o=C-12,s=n+1.5,c=`<g transform="${e.front(t)}"><path class="iso-line" data-tone="lo" d="M${s} ${-o}H${s+a}V-5H${s}Z"/>`,l=``;if(r===0)l+=`<path class="sf-plate" d="M${s+2} ${-(o-3)}H${s+a-2}V${-(o-19)}H${s+2}Z"/>`,l+=`<path class="iso-line" data-tone="mid" d="M${s+4} ${-(o-6)}H${s+a/2}M${s+a-4} ${-(o-6)}H${s+a/2}M${s+a/2} ${-(o-6)}V${-(o-16)}"/>`;else if(r===1)for(let e=0;e<3;e++)l+=`<path class="sf-plate" d="M${s+2} ${-(o-4-e*9)}H${s+a-2}V${-(o-10-e*9)}H${s+2}Z"/><path class="iso-line" data-tone="mid" d="M${s+a/2-2} ${-(o-7-e*9)}H${s+a/2+2}"/>`;else for(let e=0;e<8;e++)l+=`<path class="iso-line" data-tone="faint" d="M${s+2} ${-(o-3-e*2.4)}H${s+a-2}"/>`;let u=`<path class="iso-line" data-tone="hi" d="M${s+a-2.6} -19V-27"/>`;return`${c}${l}${u}</g>${i(t,s+2,7,a-4,4)}`}function Le(e,t,n){let{k:r,P:i,L:a,slab:o,cyl:s,screws:c}=e,l=[],u=t.y+t.d;l.push(o({x:t.x-2,y:t.y-2,w:t.w+4,d:t.d+4,r:1},0,2,{tone:`lo`},2,.2));for(let n=0;n<Fe;n++){let d=t.x+n*S,f={x:d,y:t.y,w:S,d:t.d,r:.6};l.push(o(f,2,C-2,{tone:`mid`},2,.4)),l.push(o({x:d+1,y:t.y+1,w:S-2,d:t.d-2,r:.6},C,3,{tone:`mid`},2,.3)),l.push(a(r.segment([d+4,u-4,C+3.2],[d+S-4,u-4,C+3.2],i),{tone:`faint`}),s(d+3,t.y+4,1,C+3,2,{tone:`mid`},10),s(d+S-3,t.y+4,1,C+3,2,{tone:`mid`},10)),l.push(Ie(e,u,d,n)),l.push(c([[d+1.4,u-.2],[d+S-1.4,u-.2]],C-2))}let d=t.x+t.w-8,f=t.y+t.d/2-4,p=C+3.4,m=[];for(let e=d+2;e<n-1;e+=3)m.push(r.segment([e,f+.6,p+.6],[e,f+7.4,p+.6],i));return l.push(o({x:d,y:f,w:n-d,d:.9,r:.2},p,2,{tone:`mid`},2,.1),o({x:d,y:f+7.1,w:n-d,d:.9,r:.2},p,2,{tone:`mid`},2,.1),a(m.join(``),{tone:`mid`}),s(n-6,f+4,.9,0,p,{tone:`mid`,crease:`none`},10),o({x:n-8.6,y:f+1.4,w:5.2,d:5.2,r:.5},0,1.2,{tone:`lo`},2,.1),o({x:n-1.6,y:f-.6,w:1.6,d:9.2,r:.3},p-1,4,{tone:`mid`},2,.1)),l.join(``)}var Re={x:-15,y:0,w:30,d:14,r:1.5},w=30,T=12.5,ze=2.2,E=11;function Be(e,t){let{k:n,G:r,P:i,L:a,D:o,S:s,slab:c,cyl:l,screws:u,faceRule:d}=e,f=[],p=r.frameAlong([0,0,w],[0,1,0]);f.push(c({x:-15,y:0,w:30,d:9,r:1},0,1.4,{tone:`lo`},2,.3)),f.push(u(n.corners({x:-15,y:0,w:30,d:9},1.6),1.4));for(let e of[-11,8])f.push(c({x:e,y:0,w:3,d:7,r:.5},1.4,w-15-1.4+.4,{tone:`mid`},2,.2));f.push(c({x:-14.5,y:0,w:29,d:ze,r:1},w-15,30,{tone:`mid`},2,.3)),f.push(o([[-12.4,13.2],[12.4,13.2],[-12.4,-13.2],[12.4,-13.2]].map(([e=0,t=0])=>n.iso([e,ze+.1,w+t],i)),{size:.45})),f.push(s(r.disc(ze,E,T,p,i),{tone:`mid`}));for(let e of[5.4,8.2])f.push(a(n.sideRing([0,e,w],T,`y`,i,32),{tone:`faint`}));f.push(s(r.disc(E-1.8,E,T+1.2,p,i),{tone:`mid`})),f.push(s(r.disc(E-.4,E,T-1.6,p,i),{tone:`lo`})),f.push(`<path class="gs-blade" data-vfan="0,${E+.3},${w},${T-2.6}" data-top="0,${E},${w+T+4}" data-bearing="0,${E-3},${w+T}" d=""/>`),f.push(s(r.disc(E,E+2.4,3,p,i),{tone:`mid`}),s(r.disc(E+2.2,E+3,1.6,p,i),{tone:`lo`}));let m=[],h=E+1.6;for(let e of[5.5,T-2])m.push(n.sideRing([0,h,w],e,`y`,i,28));for(let e=0;e<8;e++){let t=e/8*Math.PI*2;m.push(n.segment([Math.cos(t)*3,h,w+Math.sin(t)*3],[Math.cos(t)*(T-2),h,w+Math.sin(t)*(T-2)],i))}return f.push(a(m.join(``),{tone:`mid`})),f.push(c({x:-4.5,y:3,w:9,d:6,r:.8},w+T-.6,6,{tone:`mid`},2,.3),l(0,6,1.1,w+T+5.4,2.2,{tone:`mid`},10),d(9.1,-3,w+T+1,6,2.4)),f.join(``)}var Ve=1e3,He={x:-500,y:-395,w:810,d:189,r:8},Ue={x:-380,y:-120,w:680,d:180,r:8},We={x:-520,y:-415,w:850,d:495,r:16},Ge=r([...s(We,-21,-14),...s(He,-14,140),...s(Ue,-14,100)],Ve,620,{pad:22,azimuth:60}),Ke=-300,D=[[-268,Ke],[-108,Ke],[52,Ke]],qe=(e,t)=>[e[0]+t[0],e[1]+t[1],t[2]],Je=e=>qe(D[e]??[0,0],me),Ye=e=>qe(D[e]??[0,0],_e),Xe={x:-340,y:-338,w:470,d:4,r:0},O=[-434,-340],Ze={r:32,h:104,nozzles:[{angle:90,z:14,r:2,role:`outlet`}]},k={x:-486,y:-392,w:104,d:104,r:0},A=[-434,-232],j={r:17,h:62,windowX:8,panelX:-26,nozzles:[{angle:270,z:14,r:2,role:`inlet`},{angle:0,z:7,r:2,role:`outlet`}]},M=A[0],Qe=-284,$e={x:132,y:-330,w:48,d:25,r:1},N={x:204,y:-395,w:104,d:145,r:2},et=[293,N.y+N.d],tt=[-202,-135,0],nt=[[-65,-62],[-169,-62]],rt=[-34,36.6,40],it=[-20,36.6,40],at=[94,-130,0],ot=.8,st=[[47,36],[157,36]],ct=e=>[(e[0]-at[0])*ot,(e[1]-at[1])*ot,e[2]*ot],lt=ct(ee),ut=ct(u),dt=[{x:-318,y:-262,w:462,d:8,r:0},...D.map(([e])=>({x:e-48,y:-290,w:6,d:32,r:0})),{x:137,y:-308,w:6,d:54,r:0}],ft=[-67,-132,0],pt=[-292,-62],mt=[-110,-114,24],ht=we([...D.map((e,t)=>({key:`gen${t}`,at:e,h:126})),{key:`bund-back`,at:[O[0],k.y+2],h:12},{key:`bulk`,at:O,h:Ze.h+12},{key:`bund-front`,at:[O[0],k.y+k.d-2],h:12},{key:`valve`,at:[M,Qe+7],h:30},{key:`day`,at:A,h:j.h+12},{key:`vent`,at:[et[0],et[1]+6],h:50},{key:`lineup`,at:[$e.x+$e.w/2,$e.y+$e.d/2],h:62},{key:`hall`,at:[N.x+N.w/2,N.y+N.d/2],h:76},...nt.map((e,t)=>({key:`chiller${t}`,at:e,h:56})),...st.map((e,t)=>({key:`pump${t}`,at:e,h:45*ot})),{key:`compressor`,at:pt,h:46}],Ge),gt=ht.order,_t=ht.slotDepths,vt=ht.depth,yt=(e,t)=>[e[0]+t[0],e[1]+t[1],t[2]],P=(e,t,n,r)=>[t??e[0],n??e[1],r??e[2]],bt=(e,t,n)=>{let r=e.nozzles[n];return r?yt(t,Se(e,r)):[0,0,0]},F=6,xt=bt(Ze,O,0),St=bt(j,A,0),Ct=bt(j,A,1),I=Ct[1],[wt,Tt,Et]=[0,1,2].map(Je),[L,Dt,Ot]=[0,1,2].map(Ye),kt=Qe+14,At=-366,R=-250,z=L[2],jt=16,Mt=[pt[0]+mt[0]-ft[0],pt[1]+mt[1]-ft[1],mt[2]],Nt=Mt[1]+jt,[B=[0,0],Pt=[0,0]]=nt,[V=[0,0],H=[0,0]]=st,U=e=>yt(e,ut),W=e=>yt(e,lt),G=e=>yt(e,rt),K=e=>yt(e,it),q=W(V)[2],J=B[1]+61,Y=72,X=B[1]+48,Ft=84,It=V[1]-34,Lt=W(H)[0]+13,Rt=W(V)[0]+8,zt=6,Bt=K(B)[0]+40,Vt=N.y+N.d+ke,Ht=[{id:`xfer:a`,medium:`fuel`,r:2,pts:[xt,[M,Qe,14]]},{id:`xfer:b`,medium:`fuel`,r:2,pts:[[M,kt,14],St]},{id:`fuel:all`,medium:`fuel`,r:2,pts:[Ct,[wt[0],I,F]]},{id:`fuel:bc`,medium:`fuel`,r:2,pts:[[wt[0],I,F],[Tt[0],I,F]]},{id:`fuel:c`,medium:`fuel`,r:2,pts:[[Tt[0],I,F],[Et[0],I,F],Et]},{id:`fuel:a`,medium:`fuel`,r:2,pts:[[wt[0],I,F],wt]},{id:`fuel:b`,medium:`fuel`,r:2,pts:[[Tt[0],I,F],Tt]},{id:`air:main`,medium:`air`,r:b,bend:8,pts:[Mt,P(Mt,null,Nt,null),[At,Nt,Mt[2]],[At,Nt,z],[At,R,z],[L[0],R,z]]},{id:`air:ab`,medium:`air`,r:b,pts:[[L[0],R,z],[Dt[0],R,z]]},{id:`air:c`,medium:`air`,r:b,pts:[[Dt[0],R,z],[Ot[0],R,z],Ot]},{id:`air:a`,medium:`air`,r:b,pts:[[L[0],R,z],L]},{id:`air:b`,medium:`air`,r:b,pts:[[Dt[0],R,z],Dt]},{id:`suction`,medium:`coolantret`,r:2.6,pts:[[265,Vt,q],[265,It,q],[Lt,It,q]]},{id:`suction:standby`,medium:`coolantret`,r:2.6,pts:[[Lt,It,q],P(W(H),Lt,null,null),W(H)]},{id:`suction:duty`,medium:`coolantret`,r:2.6,pts:[[Lt,It,q],[Rt,It,q],P(W(V),Rt,null,null),W(V)]},...[[`a`,B],[`b`,Pt]].map(([e,t])=>({id:`out:${e}`,medium:`coolant`,r:2.2,pts:[K(t),P(K(t),null,X,null),P(K(t),null,X,Ft)]})),{id:`chws:b`,medium:`coolant`,r:2.6,blind:[!0,!1],pts:[[K(Pt)[0]-zt,X,Ft],[K(B)[0],X,Ft]]},{id:`chws`,medium:`coolant`,r:2.6,pts:[[K(B)[0],X,Ft],[Bt,X,Ft],[Bt,X,40],[240,X,40],[240,Vt,40]]},...[[`duty`,V],[`standby`,H]].map(([e,t])=>({id:`discharge:${e}`,medium:`coolantret`,r:2.6,fromStub:!0,pts:[U(t),P(U(t),null,null,Y),P(U(t),null,J,Y)]})),{id:`header:standby`,medium:`coolantret`,r:2.6,blind:[!0,!1],pts:[[U(H)[0]+zt,J,Y],[U(V)[0],J,Y]]},{id:`header`,medium:`coolantret`,r:2.6,pts:[[U(V)[0],J,Y],[G(B)[0],J,Y]]},{id:`header:b`,medium:`coolantret`,r:2.6,blind:[!1,!0],pts:[[G(B)[0],J,Y],[G(Pt)[0]-zt,J,Y]]},...[[`a`,B],[`b`,Pt]].map(([e,t])=>({id:`in:${e}`,medium:`coolantret`,r:2.2,pts:[P(G(t),null,J,Y),P(G(t),null,J,null),G(t)]}))],Ut=(e,t)=>[He,Ue].some(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.d),Z=(e,t,n,r)=>[e,t,n,r,Ut(e,t)?0:-14],Wt={z:10,flanged:!0,routes:Ht,posts:[...[-395,-330,-215,-60].map(e=>Z(e,I,2,F)),Z(M,-294,2,14),...[-70,-140,-190,R].map(e=>Z(At,e,b,z)),...[-300,-155,10].map(e=>Z(e,R,b,z)),...[-225,-150,-90,-35].map(e=>Z(240,e,2.6,40)),...[-225,-150,-90,-35,20].map(e=>Z(265,e,2.6,q)),...[-20,100,215].map(e=>Z(e,X,2.6,40)),...[-150,-20,130].map(e=>Z(e,J,2.6,Y))]},Q=n(),Gt={x:-248,y:-164,w:92,d:58,r:3},Kt={x:-136,y:-152,w:138,d:40,r:3},qt=xe(Ze),Jt=xe(j),Yt=(e,t)=>p(e,t,`coolantret`,!0),Xt=(e,t)=>be(e,t,Ze),Zt=(e,t)=>be(e,t,j),Qt=(e,t)=>fe(e,t,{barFull:10,dialFull:12}),$t=e=>Ae(e,N,[{x:240,z:40,r:2.6},{x:265,z:lt[2],r:2.6}]),en=e=>Le(e,$e,N.x),tn=e=>Pe(e,[M,Qe,14]),nn=e=>Ne(e,k,`back`),rn=e=>Ne(e,k,`front`);function an({ids:e}){let t=a(),n=f(Wt,vt),r=(0,Oe.useMemo)(()=>h(t,We)+t.plinth(He)+t.plinth(Ue)+je(t,dt)+Me(t,Xe,62,D.map(([e])=>e)),[t]),s=e=>(0,Q.jsx)(i,{html:`${n.layers[e]??``}<g data-flows="${e}" data-depth="${e===0?-1e9:_t[e-1]??0}"></g>`,data:{pipes:``}},`pipes-${e}`),c=[e.genA,e.genB,e.genC],l={"bund-back":(0,Q.jsx)(g,{build:nn,intro:1}),bulk:(0,Q.jsx)(`g`,{className:`fuel-tank`,children:(0,Q.jsx)(d,{to:y(O),children:(0,Q.jsx)(o,{id:e.bulk,plan:qt,intro:2,draw:Xt})})}),"bund-front":(0,Q.jsx)(g,{build:rn,intro:2}),valve:(0,Q.jsx)(g,{build:tn,intro:3}),day:(0,Q.jsx)(`g`,{className:`fuel-tank`,children:(0,Q.jsx)(d,{to:y(A),children:(0,Q.jsx)(o,{id:e.day,plan:Jt,intro:3,draw:Zt})})}),vent:(0,Q.jsx)(d,{to:y(et),children:(0,Q.jsx)(o,{id:e.fan,plan:Re,intro:9,draw:Be})}),lineup:(0,Q.jsx)(g,{build:en,intro:8}),hall:(0,Q.jsx)(g,{build:$t,intro:8}),compressor:(0,Q.jsx)(d,{from:ft,to:y(pt),children:(0,Q.jsx)(o,{id:e.compressor,plan:Kt,intro:13,draw:Qt})})};for(let[e,t]of D.entries())l[`gen${e}`]=(0,Q.jsx)(`g`,{className:`gen-set`,children:(0,Q.jsx)(d,{to:y(t),children:(0,Q.jsx)(o,{id:c[e]??``,plan:ge,intro:4+e,draw:ve})})});for(let[t,n]of nt.entries())l[`chiller${t}`]=(0,Q.jsx)(d,{from:tt,to:y(n),children:(0,Q.jsx)(o,{id:t?e.chillerB:e.chillerA,plan:Gt,intro:10+t,draw:ue})});for(let[t,n]of st.entries())l[`pump${t}`]=(0,Q.jsx)(d,{from:at,to:y(n),scale:ot,children:(0,Q.jsx)(o,{id:t?e.pumpB:e.pumpA,plan:ae,intro:12+t,draw:Yt})});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(i,{html:r,data:{plinth:``}}),s(0),gt.flatMap((e,t)=>[(0,Q.jsx)(`g`,{children:l[e.key]},e.key),s(t+1)])]})}var $=e=>e>.002?6+26*re(e*2):0,on=e=>{let{svg:t,feed:n,ids:r}=e,i=ne(t),a=ye(e,i),o=Ce(e),s=de(e,i),c=ce(e,i),l=pe(e,i),u=[a,o,s,c,l,he(e,i)],d=ie(e,e=>oe(n,e,`availability`)),f=se(e,{needle:e=>l.needle(e)??s.needle(e)??0,bar:e=>u.reduce((t,n)=>t??n.bar(e),void 0)??0,alertsHigh:()=>!0,ready:()=>!0}),p=()=>{let e=n.param(r.day,`max_inflow_lps`,0);return e>0?re(n.num(r.day,`inflow_rate`)/e):0},m=(...e)=>re(e.reduce((e,t)=>e+a.fuelPu(t),0)),h=()=>c.flowPu(r.pumpA)+c.flowPu(r.pumpB),g=e=>{let t=[r.chillerA,r.chillerB].filter(e=>n.num(e,`coolant_flow_rate`)>0);return t.includes(e)?h()/t.length:0},ee=v(e,({id:e})=>{switch(e){case`xfer:a`:case`xfer:b`:return $(p());case`fuel:all`:return $(m(r.genA,r.genB,r.genC));case`fuel:bc`:return $(m(r.genB,r.genC));case`fuel:c`:return $(m(r.genC));case`fuel:a`:return $(m(r.genA));case`fuel:b`:return $(m(r.genB));case`air:main`:case`air:ab`:case`air:c`:case`air:a`:case`air:b`:return $(l.deliveredPu(r.compressor));case`suction`:case`chws`:case`header`:return $(h());case`suction:duty`:case`discharge:duty`:return $(c.flowPu(r.pumpA));case`suction:standby`:case`discharge:standby`:case`header:standby`:return $(c.flowPu(r.pumpB));case`in:a`:case`out:a`:return $(g(r.chillerA));case`in:b`:case`out:b`:case`header:b`:case`chws:b`:return $(g(r.chillerB));default:return 0}});return{data(e){d.draw(e)},draw({sdt:e,t,introDone:n}){ee.draw(e),f.draw(e,t);for(let r of u)r.draw(e,t,n)},resync(){},status:e=>le(n,e,`availability`)}},sn=_(Ge),cn=m(sn,Wt,vt),ln=te({layout:{width:Ve,height:620,label:`Isometric model of the Backup Power facility: along the back, the fuel yard with its bulk tank in a bund and the day tank, three diesel gen sets side by side with their exhaust stacks and radiators, the electrical lineup and the data hall they back up; along the front, the start-air compressor, two chillers and two chilled-water pumps whose loop runs to the hall. Pipes carry fuel, start air and chilled water between them. Every moving part follows live values from the running engine.`,kit:sn,flows:cn.flows,joints:cn.joints,Scene:an,compose:on},resolve:Ee,things:De,caption:`generation · fuel · cooling`,mismatch:`This floor expects the Backup Power facility: three diesel gensets, the bulk and day fuel tanks, two chillers with two chilled-water pumps, the start-air compressor and the hall ventilation motor, by area and line.`,statusBasis:`availability`,Overview:c,tab:`Plant`});export{ln as backupFloor};
@@ -1 +1 @@
1
- import{ot as e}from"./vendor-ui-D8j69UH4.js";import{vt as t}from"./api-GfuYYI6q.js";import{a as n,i as r,n as i,t as a}from"./status-kit-Darp7bPB.js";var o=e(),s={g:`live`,a:`idle`,r:`fault`,"":`off`};function c({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 l({things:e,status:l,onSelect:u}){let d=t(e=>e.memberValues),f=e.map(e=>({thing:e,status:l(e.key)})),p=f.filter(e=>e.status[1]===`r`).length,m=f.filter(e=>e.status[0]===`stopped`).length,h=f.length-p-m,g=e.flatMap(e=>{let t=d.get(e.assetId)?.get(`level_percent`)?.value;return typeof t==`number`?[{name:e.name,level:t}]:[]}),_=[...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)(a,{label:`Online`,value:String(h)}),(0,o.jsx)(a,{label:`Stopped`,value:String(m)}),(0,o.jsx)(a,{label:`Faulted`,value:String(p)})]}),g.length>0?(0,o.jsx)(r,{title:`Levels`,note:`live`,children:(0,o.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:g.map(e=>(0,o.jsx)(c,{name:e.name,level:e.level},e.name))})}):null,_.map(e=>(0,o.jsx)(r,{title:e,note:`flow order`,children:(0,o.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:f.filter(t=>(t.thing.area??``)===e).map(({thing:e,status:[t,r]})=>(0,o.jsx)(i,{tone:s[r],name:e.name,note:n(t),onSelect:()=>u(e.key)},e.key))})},e))]})}function u(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{l as n,u as t};
1
+ import{ot as e}from"./vendor-ui-D8j69UH4.js";import{vt as t}from"./api-CtMmjN9m.js";import{a as n,i as r,n as i,t as a}from"./status-kit-eQF95zN0.js";var o=e(),s={g:`live`,a:`idle`,r:`fault`,"":`off`};function c({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 l({things:e,status:l,onSelect:u}){let d=t(e=>e.memberValues),f=e.map(e=>({thing:e,status:l(e.key)})),p=f.filter(e=>e.status[1]===`r`).length,m=f.filter(e=>e.status[0]===`stopped`).length,h=f.length-p-m,g=e.flatMap(e=>{let t=d.get(e.assetId)?.get(`level_percent`)?.value;return typeof t==`number`?[{name:e.name,level:t}]:[]}),_=[...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)(a,{label:`Online`,value:String(h)}),(0,o.jsx)(a,{label:`Stopped`,value:String(m)}),(0,o.jsx)(a,{label:`Faulted`,value:String(p)})]}),g.length>0?(0,o.jsx)(r,{title:`Levels`,note:`live`,children:(0,o.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:g.map(e=>(0,o.jsx)(c,{name:e.name,level:e.level},e.name))})}):null,_.map(e=>(0,o.jsx)(r,{title:e,note:`flow order`,children:(0,o.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:f.filter(t=>(t.thing.area??``)===e).map(({thing:e,status:[t,r]})=>(0,o.jsx)(i,{tone:s[r],name:e.name,note:n(t),onSelect:()=>u(e.key)},e.key))})},e))]})}function u(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{l as n,u as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./catalog-Whukru3I.js";export{e as CatalogPage};
@@ -1 +1 @@
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,vt as o}from"./api-GfuYYI6q.js";import{t as s}from"./useQuery-BfWNkVkT.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 f,c as ee,i as p,n as m,o as h,r as g,t as _}from"./dialog-B5PqrKVw.js";import{C as v,S as te,u as y,w as b}from"./format-Bx7DF-TB.js";import{n as x,t as S}from"./utils-XFKvwlFT.js";import{n as C,t as w}from"./catalog-template-icons-DvKspieo.js";import{r as T}from"./source-host-miravo-B8eM2IHw.js";import{a as E,i as D,l as O,o as k,t as A}from"./use-engine-command-mutation-CTbPh58S.js";import{t as j}from"./query-fetch-error-CWLZA2L5.js";import{t as M}from"./rocket-KZ5oHK1G.js";import{i as ne,n as N,r as P,t as F}from"./catalog-source-B4L5N-a1.js";import{t as I}from"./badge-Bk1DaL6C.js";import{n as L}from"./get-error-message-DJGhcwLn.js";var R=x(`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`),[b,x]=(0,z.useState)(null),[w,T]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),k=(0,z.useRef)(null),N=A(),F=u(),R=o(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(),k.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let W=s({queryKey:a.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),K=W.data??[],q=w===null?null:K.find(e=>e.id===w)??null,J=W.isPending&&!W.data,Y=W.isError&&!W.data,X=W.isError&&!!W.data,Z=L(W.error,`Failed to load templates.`),re=(0,z.useCallback)(e=>{O(e)},[]),ie=(0,z.useCallback)(e=>{T(e)},[]),ae=async e=>{x(e);try{return await N.mutateAsync({type:`loadTemplate`,templatePath:e}),ee(`Next: connect a client`),F(`/?highlight=${encodeURIComponent(e)}`),!0}catch{return!1}finally{x(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=P(t.source);e[n]=(e[n]??0)+1}return e},[K]),Q=e.toLowerCase(),$=K.filter(e=>n===`all`||P(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)(I,{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)(j,{message:Z,onRetry:()=>void W.refetch(),isRetrying:W.isFetching}),X&&(0,B.jsx)(j,{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)(ne,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,B.jsx)(te,{ref:k,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:b===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:S(E,`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)(I,{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)(M,{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:w!==null,onOpenChange:e=>{e||T(null)},children:(0,B.jsxs)(m,{className:`min-w-0 sm:max-w-md`,children:[(0,B.jsxs)(f,{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:y(q.name)}),` `,`into the running factory.`]})})]}),(0,B.jsxs)(p,{children:[(0,B.jsx)(v,{variant:`outline`,disabled:b!==null,onClick:()=>T(null),children:`Cancel`}),(0,B.jsx)(v,{disabled:b!==null||q===null,onClick:async()=>{q!==null&&await ae(q.id)&&T(null)},children:b===q?.id?`Launching...`:`Launch`})]})]})}),(0,B.jsx)(C,{templateId:D?.id??null,onClose:()=>O(null)})]})}var U=(0,z.memo)(function({template:e,launching:t,loaded:n,onInspect:r,onLaunch:i}){return(0,B.jsxs)(`div`,{className:S(k,`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)(w,{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:y(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)(I,{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)(I,{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)(I,{variant:`outline`,className:S(`shrink-0 font-sans text-[10px] font-medium uppercase tracking-wide`,!n&&`ml-auto`,F(e.source)),children:N(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:D,children:[(0,B.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),n?(0,B.jsxs)(d,{to:`/`,className:S(b({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)(O,{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:N(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:S(`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
+ 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,vt as o}from"./api-CtMmjN9m.js";import{t as s}from"./useQuery-Dxp3WSXF.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 f,c as ee,i as p,n as m,o as h,r as g,t as _}from"./dialog-B5PqrKVw.js";import{C as v,S as te,u as y,w as b}from"./format-Bx7DF-TB.js";import{n as x,t as S}from"./utils-XFKvwlFT.js";import{n as C,t as w}from"./catalog-template-icons-GGQGFjA8.js";import{r as T}from"./source-host-miravo-B8eM2IHw.js";import{a as E,i as D,l as O,o as k,t as A}from"./use-engine-command-mutation-5q_LI_xT.js";import{t as j}from"./query-fetch-error-CWLZA2L5.js";import{t as M}from"./rocket-KZ5oHK1G.js";import{i as ne,n as N,r as P,t as F}from"./catalog-source-B4L5N-a1.js";import{t as I}from"./badge-Bk1DaL6C.js";import{n as L}from"./get-error-message-D800c4Uu.js";var R=x(`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`),[b,x]=(0,z.useState)(null),[w,T]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),k=(0,z.useRef)(null),N=A(),F=u(),R=o(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(),k.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let W=s({queryKey:a.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),K=W.data??[],q=w===null?null:K.find(e=>e.id===w)??null,J=W.isPending&&!W.data,Y=W.isError&&!W.data,X=W.isError&&!!W.data,Z=L(W.error,`Failed to load templates.`),re=(0,z.useCallback)(e=>{O(e)},[]),ie=(0,z.useCallback)(e=>{T(e)},[]),ae=async e=>{x(e);try{return await N.mutateAsync({type:`loadTemplate`,templatePath:e}),ee(`Next: connect a client`),F(`/?highlight=${encodeURIComponent(e)}`),!0}catch{return!1}finally{x(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=P(t.source);e[n]=(e[n]??0)+1}return e},[K]),Q=e.toLowerCase(),$=K.filter(e=>n===`all`||P(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)(I,{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)(j,{message:Z,onRetry:()=>void W.refetch(),isRetrying:W.isFetching}),X&&(0,B.jsx)(j,{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)(ne,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,B.jsx)(te,{ref:k,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:b===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:S(E,`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)(I,{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)(M,{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:w!==null,onOpenChange:e=>{e||T(null)},children:(0,B.jsxs)(m,{className:`min-w-0 sm:max-w-md`,children:[(0,B.jsxs)(f,{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:y(q.name)}),` `,`into the running factory.`]})})]}),(0,B.jsxs)(p,{children:[(0,B.jsx)(v,{variant:`outline`,disabled:b!==null,onClick:()=>T(null),children:`Cancel`}),(0,B.jsx)(v,{disabled:b!==null||q===null,onClick:async()=>{q!==null&&await ae(q.id)&&T(null)},children:b===q?.id?`Launching...`:`Launch`})]})]})}),(0,B.jsx)(C,{templateId:D?.id??null,onClose:()=>O(null)})]})}var U=(0,z.memo)(function({template:e,launching:t,loaded:n,onInspect:r,onLaunch:i}){return(0,B.jsxs)(`div`,{className:S(k,`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)(w,{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:y(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)(I,{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)(I,{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)(I,{variant:`outline`,className:S(`shrink-0 font-sans text-[10px] font-medium uppercase tracking-wide`,!n&&`ml-auto`,F(e.source)),children:N(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:D,children:[(0,B.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),n?(0,B.jsxs)(d,{to:`/`,className:S(b({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)(O,{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:N(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:S(`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 +1 @@
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,vt as o}from"./api-GfuYYI6q.js";import{t as s}from"./useQuery-BfWNkVkT.js";import{t as c}from"./proxy-CWZabK8f.js";import{t as l}from"./AnimatePresence-BSSlw02V.js";import{c as u}from"./chunk-OE4NN4TA-DBWZidbW.js";import{t as d}from"./shallow-Cin0mLuv.js";import{c as f,h as p,s as m}from"./format-Bx7DF-TB.js";import{n as h,t as g}from"./utils-XFKvwlFT.js";import{t as _}from"./chevron-down-x70Pto6j.js";import{t as v}from"./chevron-right-CrNKVFcI.js";import{t as y}from"./copy-button-CSUP1VjU.js";import{i as b,n as x,t as S}from"./registry-BqqyCPJz.js";import{a as ee}from"./use-engine-command-mutation-CTbPh58S.js";import{t as C}from"./query-fetch-error-CWLZA2L5.js";import{c as te,d as w,f as ne,l as T,s as E,t as D,u as O}from"./export-tab-R8Oac9J5.js";import{t as k}from"./badge-Bk1DaL6C.js";import{n as A}from"./get-error-message-DJGhcwLn.js";import{a as re,c as ie,i as ae,n as oe,o as se,s as ce,t as le}from"./status-kit-Darp7bPB.js";import{i as j,n as M,r as N,t as P}from"./tabs-Ch_VG8_S.js";var F=h(`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`}]]),I=h(`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`}]]),L=h(`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`}]]),R=h(`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`}]]),z=h(`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`}]]),B=h(`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`}]]),V=h(`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`}]]),H=h(`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`}]]),U=h(`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`}]]),W=e(t(),1),G=n(),K=20,ue=14,q=`flex w-3.5 shrink-0 items-center justify-center`;function de({asset:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,G.jsxs)(G.Fragment,{children:[l.map(a=>(0,G.jsx)(J,{member:a,depth:t,area:n,line:r,assetId:e.id,detail:i},a.name)),!a&&u>0&&(0,G.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+K}px`},onClick:()=>o(!0),children:[(0,G.jsx)(`span`,{className:q,"aria-hidden":!0}),(0,G.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.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+K}px`},onClick:()=>c(e=>!e),children:[(0,G.jsx)(`span`,{className:q,"aria-hidden":!0,children:s?(0,G.jsx)(_,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,G.jsx)(v,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,G.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,G.jsx)(J,{member:a,depth:t,area:n,line:r,assetId:e.id,detail:i},a.name))]})]})}function J({member:e,depth:t,area:n,line:r,assetId:i,detail:a}){let o=e.kind===`property`,s=t*14+K+(o?ue:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,G.jsx)(y,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:()=>(0,G.jsxs)(`button`,{type:`button`,className:g(`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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:q,"aria-hidden":!0,children:(0,G.jsx)(`span`,{className:g(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,G.jsx)(`span`,{title:e.name,className:g(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:f(e.name)}),o&&(0,G.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,G.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,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground`,children:[`[`,e.euRange[0],`–`,e.euRange[1],`]`]})]})]})})}function Y({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?_:v,f=i===`area`?`text-primary`:`text-foreground`;return(0,G.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,G.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,G.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,G.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,G.jsx)(`span`,{title:n??void 0,className:g(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,G.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,G.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,G.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 fe(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function pe(e,t,n){let r=[];for(let i of e){let e=fe(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 me({detail:e}){let[t,n]=(0,W.useState)(new Set),o=(0,W.useRef)(null),c=(0,W.useMemo)(()=>[...new Set(e.models)],[e.models]),l=c.join(`,`),u=s({queryKey:a.catalog.modelSchemasBatch(l),queryFn:async()=>Promise.all(c.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail)))}),d=u.isPending&&!u.data,f=(0,W.useMemo)(()=>{let e=new Map;if(!u.data)return e;for(let[t,n]of u.data.entries())e.set(c[t],n);return e},[u.data,c]),h=(0,W.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}`,pe(e.assets,f,t));return n},[e.topology,f]);(0,W.useEffect)(()=>{if(d)return;let t=e.name;if(o.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),o.current=t},[d,e.name,e.topology,h]);let g=(0,W.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return d?null:u.isError&&!u.data?(0,G.jsx)(C,{message:A(u.error,`Failed to load model schemas.`),onRetry:()=>void u.refetch(),isRetrying:u.isFetching&&!u.isPending}):(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(Y,{depth:0,label:p(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,G.jsxs)(`div`,{children:[(0,G.jsx)(Y,{depth:1,label:p(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,G.jsxs)(`div`,{children:[(0,G.jsx)(Y,{depth:2,label:m(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:p(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,G.jsx)(de,{asset:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}var X=`Other assets`;function he(e,t){let n=Math.abs(e)>=100?0:Math.abs(e)>=10?1:2;return`${e.toFixed(n)} ${t}`}function Z(e){return e.length>=3?e.at(-3)??X:X}function ge(e){let t=new Set(e.assetIds),n=new Map(e.lines.flatMap(e=>e.stations.filter(e=>t.has(e.id)).map(e=>[e.id,e]))),r=e.assets.filter(e=>t.has(e.id)),i=new Map;for(let t of r){let r=e.memberValues.get(t.id),a=t.activeFaults.length>0,o=n.get(t.id),s=r?.get(`availability_state`)?.value,c=r?.get(`run_command`)?.value,l=o?.state??`running`;a?l=`fault`:!o&&typeof s==`string`?l=s:!o&&c!==void 0&&Number(c)===0&&(l=`stopped`);let u=ie(e.schemas.get(t.model),1)[0],d=u?r?.get(u.member)?.value:void 0,f={id:t.id,tone:se(l,a||l===`faulted`),state:re(l),reading:u&&typeof d==`number`?he(d,u.unit):null},p=Z(t.browsePath);i.set(p,[...i.get(p)??[],f])}let a=[...i.values()].flat(),o=a.filter(e=>e.tone===`fault`).length,s=e.lines.filter(e=>e.stations.some(e=>n.has(e.id))),c;if(s.length>0){let e=s.reduce((e,t)=>e+(t.stations.at(-1)?.good??0),0),t=s.reduce((e,t)=>e+t.stations.reduce((e,t)=>e+t.scrap,0),0);c=[{label:`Shipped`,value:String(e)},{label:`Yield`,value:e+t>0?`${(e/(e+t)*100).toFixed(1)}%`:`–`},{label:`Faulted`,value:String(o)}]}else{let e=a.filter(e=>e.state===`stopped`).length;c=[{label:`Online`,value:String(a.length-o-e)},{label:`Stopped`,value:String(e)},{label:`Faulted`,value:String(o)}]}return{kpis:c,areas:[...i].map(([e,t])=>({name:e,rows:t}))}}function Q({templateId:e,assetIds:t,schemas:n}){let r=u(),{assets:i,lines:a,memberValues:s}=o(d(e=>({assets:e.assets,lines:e.lines,memberValues:e.memberValues}))),c=ge({assetIds:t,assets:i,lines:a,memberValues:s,schemas:n}),l=x(e);return(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-3 px-4 pt-4 pb-5`,children:c.kpis.map(e=>(0,G.jsx)(le,{label:e.label,value:e.value},e.label))}),c.areas.map(t=>(0,G.jsx)(ae,{title:t.name,note:`${t.rows.length} assets`,children:(0,G.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:t.rows.map(t=>(0,G.jsx)(oe,{tone:t.tone,name:t.id,note:t.reading?`${t.state} · ${t.reading}`:t.state,onSelect:l?()=>void r(`${S(e)}?asset=${encodeURIComponent(t.id)}`):void 0},t.id))})},t.name))]})}function _e(e){return e.lines.reduce((e,t)=>e+t.assets.reduce((e,t)=>e+t.count,0),0)}function ve(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function ye(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?ve(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 be({templateId:e,onClose:t,actions:n,live:o,fallbackTitle:l}){let[u,d]=(0,W.useState)(new Set),f=s({queryKey:a.catalog.templateDetail(e??``),queryFn:()=>i(`/catalog/templates/${e}`,r.catalogTemplateDetail),enabled:e!==null}),p=f.data,m=f.isPending&&!p,h=f.isError,g=A(f.error,`Failed to load template.`),_=p?.models??o?.models??[],v=ce(_),y=(0,W.useMemo)(()=>{let e=new Map;for(let[t,n]of(v.data??[]).entries())e.set(_[t]??``,n);return e},[_,v.data]),b=(0,W.useMemo)(()=>p&&v.data?ye(p,y):null,[p,v.data,y]);(0,W.useEffect)(()=>{e&&p&&d(new Set(p.topology.map(e=>e.name)))},[e,p]);let x=(0,W.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,G.jsx)(E,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,G.jsx)(te,{side:`right`,className:`flex w-full flex-col gap-4 touch-manipulation`,children:m?null:h&&!p&&n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(O,{className:`gap-2 pb-0 pe-12`,children:[(0,G.jsx)(w,{className:`font-heading text-base uppercase tracking-wide`,children:l}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n})]}),o&&e?(0,G.jsx)(Q,{templateId:e,assetIds:o.assetIds,schemas:y}):null]}):h&&!p?(0,G.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,G.jsx)(C,{message:g,onRetry:()=>void f.refetch(),isRetrying:f.isFetching})}):p?(0,G.jsxs)(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,G.jsxs)(O,{className:`gap-1 pb-0 pe-12`,children:[(0,G.jsx)(w,{className:`font-heading text-base uppercase tracking-wide`,children:p.name}),p.description&&(0,G.jsx)(T,{className:`text-xs leading-relaxed text-foreground/88`,children:p.description}),n?(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:n}):null]}),(0,G.jsxs)(P,{defaultValue:o?`live`:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,G.jsxs)(N,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[o?(0,G.jsx)(j,{value:`live`,className:$,children:`Live`}):null,(0,G.jsx)(j,{value:`overview`,className:$,children:`Overview`}),(0,G.jsx)(j,{value:`uns`,className:$,children:`UNS`}),(0,G.jsx)(j,{value:`export`,className:$,children:`Export`})]}),o?(0,G.jsx)(M,{value:`live`,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(Q,{templateId:p.id,assetIds:o.assetIds,schemas:y})}):null,(0,G.jsx)(M,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.topology.length,` areas`]}),(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.assetCount,` assets`]}),(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.models.length,` models`]}),b!==null&&(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[b,` tags`]}),p.settings?.tickIntervalMs&&(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,p.settings.tickIntervalMs,`ms`]}),p.settings?.timeMultiplier&&p.settings.timeMultiplier!==1&&(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.settings.timeMultiplier,`× speed`]})]}),p.namespace&&(p.namespace.enterprise||p.namespace.site||p.namespace.prefix)&&(0,G.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,G.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,G.jsxs)(`dl`,{className:`mt-1 grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-2`,children:[p.namespace.enterprise&&(0,G.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,G.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,G.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:p.namespace.enterprise})]}),p.namespace.site&&(0,G.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,G.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,G.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:p.namespace.site})]}),p.namespace.prefix&&(0,G.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,G.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:p.namespace.prefix})]})]})]}),p.topology.map(e=>(0,G.jsx)(xe,{area:e,expanded:u.has(e.name),onToggle:()=>x(e.name)},e.name)),p.settings&&(0,G.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,G.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,G.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:`Settings`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,G.jsxs)(`span`,{className:`text-foreground`,children:[p.settings.tickIntervalMs??1e3,`ms`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,G.jsxs)(`span`,{className:`text-foreground`,children:[p.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,G.jsx)(M,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,G.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,G.jsx)(me,{detail:p})})})})}),(0,G.jsx)(M,{value:`export`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,G.jsx)(D,{kind:`template`,id:p.id,yamlPath:`/catalog/templates/${p.id}/yaml`,yamlFilename:`${p.id}.miravo.yaml`})})})]})]},p.id):(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Template not found`})})})}function xe({area:e,expanded:t,onToggle:n}){let r=_e(e);return(0,G.jsxs)(`div`,{className:ee,children:[(0,G.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,G.jsx)(R,{className:`size-3.5 text-primary`}),(0,G.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:p(e.name)}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsxs)(k,{variant:`secondary`,className:`text-xs`,children:[r,` assets`]}),(0,G.jsxs)(k,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,G.jsx)(_,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,G.jsx)(l,{initial:!1,children:t&&(0,G.jsx)(c.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,G.jsx)(Se,{line:e},e.name))})},`content`)})]})}function Se({line:e}){return(0,G.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,G.jsx)(V,{className:`size-3.5`}),(0,G.jsx)(`span`,{title:e.name,children:p(e.name)}),(0,G.jsx)(z,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.assets.reduce((e,t)=>e+t.count,0),` assets`]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.assets.map(e=>(0,G.jsx)(Ce,{assignment:e},`${e.model}-${e.count}`))})]})}function Ce({assignment:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,G.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,G.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:p(e.model)}),(0,G.jsxs)(k,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}function we({id:e,className:t}){let n=g(`shrink-0 text-primary`,t);switch(e){case`smart-factory`:return(0,G.jsx)(b,{className:n,"aria-hidden":!0});case`water-treatment`:return(0,G.jsx)(I,{className:n,"aria-hidden":!0});case`commercial-building`:return(0,G.jsx)(F,{className:n,"aria-hidden":!0});case`backup-power`:return(0,G.jsx)(U,{className:n,"aria-hidden":!0});case`district-heating`:return(0,G.jsx)(H,{className:n,"aria-hidden":!0});case`pharma-cleanroom`:return(0,G.jsx)(L,{className:n,"aria-hidden":!0});default:return(0,G.jsx)(B,{className:n,"aria-hidden":!0})}}export{z as i,be as n,U as r,we as t};
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,vt as o}from"./api-CtMmjN9m.js";import{t as s}from"./useQuery-Dxp3WSXF.js";import{t as c}from"./proxy-CWZabK8f.js";import{t as l}from"./AnimatePresence-BSSlw02V.js";import{c as u}from"./chunk-OE4NN4TA-DBWZidbW.js";import{t as d}from"./shallow-Cin0mLuv.js";import{c as f,h as p,s as m}from"./format-Bx7DF-TB.js";import{n as h,t as g}from"./utils-XFKvwlFT.js";import{t as _}from"./chevron-down-x70Pto6j.js";import{t as v}from"./chevron-right-CrNKVFcI.js";import{t as y}from"./copy-button-CSUP1VjU.js";import{i as b,n as x,t as S}from"./registry-BKilgP4M.js";import{a as ee}from"./use-engine-command-mutation-5q_LI_xT.js";import{t as C}from"./query-fetch-error-CWLZA2L5.js";import{c as te,d as w,f as ne,l as T,s as E,t as D,u as O}from"./export-tab-CtH28h1G.js";import{t as k}from"./badge-Bk1DaL6C.js";import{n as A}from"./get-error-message-D800c4Uu.js";import{a as re,c as ie,i as ae,n as oe,o as se,s as ce,t as le}from"./status-kit-eQF95zN0.js";import{i as j,n as M,r as N,t as P}from"./tabs-Ch_VG8_S.js";var F=h(`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`}]]),I=h(`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`}]]),L=h(`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`}]]),R=h(`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`}]]),z=h(`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`}]]),B=h(`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`}]]),V=h(`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`}]]),H=h(`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`}]]),U=h(`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`}]]),W=e(t(),1),G=n(),K=20,ue=14,q=`flex w-3.5 shrink-0 items-center justify-center`;function de({asset:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,G.jsxs)(G.Fragment,{children:[l.map(a=>(0,G.jsx)(J,{member:a,depth:t,area:n,line:r,assetId:e.id,detail:i},a.name)),!a&&u>0&&(0,G.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+K}px`},onClick:()=>o(!0),children:[(0,G.jsx)(`span`,{className:q,"aria-hidden":!0}),(0,G.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.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+K}px`},onClick:()=>c(e=>!e),children:[(0,G.jsx)(`span`,{className:q,"aria-hidden":!0,children:s?(0,G.jsx)(_,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,G.jsx)(v,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,G.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,G.jsx)(J,{member:a,depth:t,area:n,line:r,assetId:e.id,detail:i},a.name))]})]})}function J({member:e,depth:t,area:n,line:r,assetId:i,detail:a}){let o=e.kind===`property`,s=t*14+K+(o?ue:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,G.jsx)(y,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:()=>(0,G.jsxs)(`button`,{type:`button`,className:g(`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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:q,"aria-hidden":!0,children:(0,G.jsx)(`span`,{className:g(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,G.jsx)(`span`,{title:e.name,className:g(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:f(e.name)}),o&&(0,G.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,G.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,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground`,children:[`[`,e.euRange[0],`–`,e.euRange[1],`]`]})]})]})})}function Y({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?_:v,f=i===`area`?`text-primary`:`text-foreground`;return(0,G.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,G.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,G.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,G.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,G.jsx)(`span`,{title:n??void 0,className:g(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,G.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,G.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,G.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 fe(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function pe(e,t,n){let r=[];for(let i of e){let e=fe(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 me({detail:e}){let[t,n]=(0,W.useState)(new Set),o=(0,W.useRef)(null),c=(0,W.useMemo)(()=>[...new Set(e.models)],[e.models]),l=c.join(`,`),u=s({queryKey:a.catalog.modelSchemasBatch(l),queryFn:async()=>Promise.all(c.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail)))}),d=u.isPending&&!u.data,f=(0,W.useMemo)(()=>{let e=new Map;if(!u.data)return e;for(let[t,n]of u.data.entries())e.set(c[t],n);return e},[u.data,c]),h=(0,W.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}`,pe(e.assets,f,t));return n},[e.topology,f]);(0,W.useEffect)(()=>{if(d)return;let t=e.name;if(o.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),o.current=t},[d,e.name,e.topology,h]);let g=(0,W.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return d?null:u.isError&&!u.data?(0,G.jsx)(C,{message:A(u.error,`Failed to load model schemas.`),onRetry:()=>void u.refetch(),isRetrying:u.isFetching&&!u.isPending}):(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(Y,{depth:0,label:p(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,G.jsxs)(`div`,{children:[(0,G.jsx)(Y,{depth:1,label:p(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,G.jsxs)(`div`,{children:[(0,G.jsx)(Y,{depth:2,label:m(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:p(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,G.jsx)(de,{asset:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}var X=`Other assets`;function he(e,t){let n=Math.abs(e)>=100?0:Math.abs(e)>=10?1:2;return`${e.toFixed(n)} ${t}`}function Z(e){return e.length>=3?e.at(-3)??X:X}function ge(e){let t=new Set(e.assetIds),n=new Map(e.lines.flatMap(e=>e.stations.filter(e=>t.has(e.id)).map(e=>[e.id,e]))),r=e.assets.filter(e=>t.has(e.id)),i=new Map;for(let t of r){let r=e.memberValues.get(t.id),a=t.activeFaults.length>0,o=n.get(t.id),s=r?.get(`availability_state`)?.value,c=r?.get(`run_command`)?.value,l=o?.state??`running`;a?l=`fault`:!o&&typeof s==`string`?l=s:!o&&c!==void 0&&Number(c)===0&&(l=`stopped`);let u=ie(e.schemas.get(t.model),1)[0],d=u?r?.get(u.member)?.value:void 0,f={id:t.id,tone:se(l,a||l===`faulted`),state:re(l),reading:u&&typeof d==`number`?he(d,u.unit):null},p=Z(t.browsePath);i.set(p,[...i.get(p)??[],f])}let a=[...i.values()].flat(),o=a.filter(e=>e.tone===`fault`).length,s=e.lines.filter(e=>e.stations.some(e=>n.has(e.id))),c;if(s.length>0){let e=s.reduce((e,t)=>e+(t.stations.at(-1)?.good??0),0),t=s.reduce((e,t)=>e+t.stations.reduce((e,t)=>e+t.scrap,0),0);c=[{label:`Shipped`,value:String(e)},{label:`Yield`,value:e+t>0?`${(e/(e+t)*100).toFixed(1)}%`:`–`},{label:`Faulted`,value:String(o)}]}else{let e=a.filter(e=>e.state===`stopped`).length;c=[{label:`Online`,value:String(a.length-o-e)},{label:`Stopped`,value:String(e)},{label:`Faulted`,value:String(o)}]}return{kpis:c,areas:[...i].map(([e,t])=>({name:e,rows:t}))}}function Q({templateId:e,assetIds:t,schemas:n}){let r=u(),{assets:i,lines:a,memberValues:s}=o(d(e=>({assets:e.assets,lines:e.lines,memberValues:e.memberValues}))),c=ge({assetIds:t,assets:i,lines:a,memberValues:s,schemas:n}),l=x(e);return(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-3 px-4 pt-4 pb-5`,children:c.kpis.map(e=>(0,G.jsx)(le,{label:e.label,value:e.value},e.label))}),c.areas.map(t=>(0,G.jsx)(ae,{title:t.name,note:`${t.rows.length} assets`,children:(0,G.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:t.rows.map(t=>(0,G.jsx)(oe,{tone:t.tone,name:t.id,note:t.reading?`${t.state} · ${t.reading}`:t.state,onSelect:l?()=>void r(`${S(e)}?asset=${encodeURIComponent(t.id)}`):void 0},t.id))})},t.name))]})}function _e(e){return e.lines.reduce((e,t)=>e+t.assets.reduce((e,t)=>e+t.count,0),0)}function ve(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function ye(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?ve(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 be({templateId:e,onClose:t,actions:n,live:o,fallbackTitle:l}){let[u,d]=(0,W.useState)(new Set),f=s({queryKey:a.catalog.templateDetail(e??``),queryFn:()=>i(`/catalog/templates/${e}`,r.catalogTemplateDetail),enabled:e!==null}),p=f.data,m=f.isPending&&!p,h=f.isError,g=A(f.error,`Failed to load template.`),_=p?.models??o?.models??[],v=ce(_),y=(0,W.useMemo)(()=>{let e=new Map;for(let[t,n]of(v.data??[]).entries())e.set(_[t]??``,n);return e},[_,v.data]),b=(0,W.useMemo)(()=>p&&v.data?ye(p,y):null,[p,v.data,y]);(0,W.useEffect)(()=>{e&&p&&d(new Set(p.topology.map(e=>e.name)))},[e,p]);let x=(0,W.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,G.jsx)(E,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,G.jsx)(te,{side:`right`,className:`flex w-full flex-col gap-4 touch-manipulation`,children:m?null:h&&!p&&n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(O,{className:`gap-2 pb-0 pe-12`,children:[(0,G.jsx)(w,{className:`font-heading text-base uppercase tracking-wide`,children:l}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n})]}),o&&e?(0,G.jsx)(Q,{templateId:e,assetIds:o.assetIds,schemas:y}):null]}):h&&!p?(0,G.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,G.jsx)(C,{message:g,onRetry:()=>void f.refetch(),isRetrying:f.isFetching})}):p?(0,G.jsxs)(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,G.jsxs)(O,{className:`gap-1 pb-0 pe-12`,children:[(0,G.jsx)(w,{className:`font-heading text-base uppercase tracking-wide`,children:p.name}),p.description&&(0,G.jsx)(T,{className:`text-xs leading-relaxed text-foreground/88`,children:p.description}),n?(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:n}):null]}),(0,G.jsxs)(P,{defaultValue:o?`live`:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,G.jsxs)(N,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[o?(0,G.jsx)(j,{value:`live`,className:$,children:`Live`}):null,(0,G.jsx)(j,{value:`overview`,className:$,children:`Overview`}),(0,G.jsx)(j,{value:`uns`,className:$,children:`UNS`}),(0,G.jsx)(j,{value:`export`,className:$,children:`Export`})]}),o?(0,G.jsx)(M,{value:`live`,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(Q,{templateId:p.id,assetIds:o.assetIds,schemas:y})}):null,(0,G.jsx)(M,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.topology.length,` areas`]}),(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.assetCount,` assets`]}),(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.models.length,` models`]}),b!==null&&(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[b,` tags`]}),p.settings?.tickIntervalMs&&(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,p.settings.tickIntervalMs,`ms`]}),p.settings?.timeMultiplier&&p.settings.timeMultiplier!==1&&(0,G.jsxs)(k,{variant:`outline`,className:`font-mono text-xs`,children:[p.settings.timeMultiplier,`× speed`]})]}),p.namespace&&(p.namespace.enterprise||p.namespace.site||p.namespace.prefix)&&(0,G.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,G.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,G.jsxs)(`dl`,{className:`mt-1 grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-2`,children:[p.namespace.enterprise&&(0,G.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,G.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,G.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:p.namespace.enterprise})]}),p.namespace.site&&(0,G.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,G.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,G.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:p.namespace.site})]}),p.namespace.prefix&&(0,G.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,G.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:p.namespace.prefix})]})]})]}),p.topology.map(e=>(0,G.jsx)(xe,{area:e,expanded:u.has(e.name),onToggle:()=>x(e.name)},e.name)),p.settings&&(0,G.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,G.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,G.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:`Settings`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,G.jsxs)(`span`,{className:`text-foreground`,children:[p.settings.tickIntervalMs??1e3,`ms`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,G.jsxs)(`span`,{className:`text-foreground`,children:[p.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,G.jsx)(M,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,G.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,G.jsx)(me,{detail:p})})})})}),(0,G.jsx)(M,{value:`export`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,G.jsx)(D,{kind:`template`,id:p.id,yamlPath:`/catalog/templates/${p.id}/yaml`,yamlFilename:`${p.id}.miravo.yaml`})})})]})]},p.id):(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Template not found`})})})}function xe({area:e,expanded:t,onToggle:n}){let r=_e(e);return(0,G.jsxs)(`div`,{className:ee,children:[(0,G.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,G.jsx)(R,{className:`size-3.5 text-primary`}),(0,G.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:p(e.name)}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsxs)(k,{variant:`secondary`,className:`text-xs`,children:[r,` assets`]}),(0,G.jsxs)(k,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,G.jsx)(_,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,G.jsx)(l,{initial:!1,children:t&&(0,G.jsx)(c.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,G.jsx)(Se,{line:e},e.name))})},`content`)})]})}function Se({line:e}){return(0,G.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,G.jsx)(V,{className:`size-3.5`}),(0,G.jsx)(`span`,{title:e.name,children:p(e.name)}),(0,G.jsx)(z,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.assets.reduce((e,t)=>e+t.count,0),` assets`]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.assets.map(e=>(0,G.jsx)(Ce,{assignment:e},`${e.model}-${e.count}`))})]})}function Ce({assignment:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,G.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,G.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:p(e.model)}),(0,G.jsxs)(k,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}function we({id:e,className:t}){let n=g(`shrink-0 text-primary`,t);switch(e){case`smart-factory`:return(0,G.jsx)(b,{className:n,"aria-hidden":!0});case`water-treatment`:return(0,G.jsx)(I,{className:n,"aria-hidden":!0});case`commercial-building`:return(0,G.jsx)(F,{className:n,"aria-hidden":!0});case`backup-power`:return(0,G.jsx)(U,{className:n,"aria-hidden":!0});case`district-heating`:return(0,G.jsx)(H,{className:n,"aria-hidden":!0});case`pharma-cleanroom`:return(0,G.jsx)(L,{className:n,"aria-hidden":!0});default:return(0,G.jsx)(B,{className:n,"aria-hidden":!0})}}export{z as i,be as n,U as r,we as t};