@miravo/cli-linux-arm64-musl 0.7.9 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/console-dist/assets/{api-Bf6pFRhP.js → api-2XqCNjt9.js} +1 -1
- package/console-dist/assets/api-DlgMZi_j.js +1 -0
- package/console-dist/assets/catalog-B1GRab9-.js +1 -0
- package/console-dist/assets/{catalog-DqOwOydE.js → catalog-rF7BRyRf.js} +1 -1
- package/console-dist/assets/{catalog-source-W3TI0pmx.js → catalog-source-wSZa7UAP.js} +1 -1
- package/console-dist/assets/control-BOmPym_s.js +1 -0
- package/console-dist/assets/{control-BLUTBbet.js → control-RK2dbhks.js} +1 -1
- package/console-dist/assets/{events-BTqDmbVu.js → events-B8fp1TQW.js} +1 -1
- package/console-dist/assets/events-CVYbXGE4.js +1 -0
- package/console-dist/assets/{fleet-C20wXA8E.js → fleet-CHhiI7Fk.js} +1 -1
- package/console-dist/assets/fleet-DxLj0dPT.js +1 -0
- package/console-dist/assets/{get-error-message-yQcVJ-Ja.js → get-error-message-BanmV5rD.js} +1 -1
- package/console-dist/assets/{index-B_Xu4s7C.js → index-MRs9-toM.js} +3 -3
- package/console-dist/assets/{instance-detail-STqgvf7K.js → instance-detail-CKgv3XYh.js} +1 -1
- package/console-dist/assets/{login-BJaFYYGh.js → login-BaheB47i.js} +1 -1
- package/console-dist/assets/{models-DhRo1Ytd.js → models-BygeZ9lv.js} +1 -1
- package/console-dist/assets/models-CTVXBFYW.js +1 -0
- package/console-dist/assets/platforms-BHZA9Eg3.js +1 -0
- package/console-dist/assets/{platforms-DbzXekvY.js → platforms-BXHQU4vT.js} +1 -1
- package/console-dist/assets/{query-fetch-error-BqiDQT2r.js → query-fetch-error-xB4By0m0.js} +1 -1
- package/console-dist/assets/{tabs-CCixnxMe.js → tabs-CDS57-lB.js} +1 -1
- package/console-dist/assets/{tags-DAJ-rQYR.js → tags-CeGPTgMJ.js} +1 -1
- package/console-dist/assets/tags-CmPY4kaf.js +1 -0
- package/console-dist/assets/{transition-nav-link-Bf02_OAE.js → transition-nav-link-BtuFK_Y8.js} +1 -1
- package/console-dist/assets/{use-engine-command-mutation-RvjgD8uv.js → use-engine-command-mutation-Ct9NCDug.js} +1 -1
- package/console-dist/assets/{use-platform-stream-BVf5gGJM.js → use-platform-stream-BzqGhuJn.js} +1 -1
- package/console-dist/assets/{use-transition-navigate-DtyJz2Z1.js → use-transition-navigate-D3JSD38W.js} +2 -2
- package/console-dist/assets/{validation-_QtRYqIT.js → validation-CCE5LmjQ.js} +1 -1
- package/console-dist/index.html +18 -18
- package/miravo +0 -0
- package/package.json +1 -1
- package/console-dist/assets/api-wyOH3ffs.js +0 -1
- package/console-dist/assets/catalog-CTpesUtM.js +0 -1
- package/console-dist/assets/control-UqwbqlvO.js +0 -1
- package/console-dist/assets/events-Z0rGFYfs.js +0 -1
- package/console-dist/assets/fleet-BNba_zGa.js +0 -1
- package/console-dist/assets/models-2VnPNXiF.js +0 -1
- package/console-dist/assets/platforms-DrKstIAm.js +0 -1
- package/console-dist/assets/tags-CNJIRrPw.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{S as r,at as i,o as a,ot as o,st as s,v as c,y as l}from"./api-Bf6pFRhP.js";import{a as u,c as d,i as f,r as p,t as m}from"./query-fetch-error-BqiDQT2r.js";import{t as h}from"./proxy-Be4WzmcS.js";import{t as g}from"./AnimatePresence-CPmH1DMY.js";import{i as _,r as v}from"./dist-xY0pK9Wy.js";import{n as y}from"./chunk-OE4NN4TA-DBWZidbW.js";import{a as b,i as x,l as S,n as C,o as w,r as ee,s as T,t as E}from"./copy-button-DnGsXbVV.js";import{C as D,S as O,T as k,d as A,h as j,o as M,w as N}from"./format-B9CcV2dj.js";import{n as P,t as F}from"./utils-XFKvwlFT.js";import{t as I}from"./activity-Cy_niK56.js";import{t as L}from"./arrow-right-BjBb4z7g.js";import{A as R,D as z,E as B,M as V,N as te,S as ne,_ as re,a as ie,b as ae,c as H,d as U,f as oe,g as se,h as ce,i as le,j as ue,k as de,l as fe,m as W,n as pe,o as me,p as he,r as ge,s as _e,t as ve,u as ye,v as be,x as xe}from"./use-platform-stream-BVf5gGJM.js";import{n as Se,t as Ce}from"./catalog-template-icons-3S8RvUxD.js";import{c as we,i as G,l as Te,n as Ee,s as De,t as Oe}from"./select-CMOnuEoT.js";import{a as ke,i as Ae,r as K}from"./platform-targets-BIQ1lKOg.js";import{c as je,i as Me,n as Ne,o as Pe,r as Fe,s as Ie,t as Le}from"./tabs-CCixnxMe.js";import{i as Re,n as q,r as ze,t as Be}from"./checkbox-C84IyqEB.js";import{t as Ve}from"./layers-1figUpjG.js";import{t as He}from"./triangle-alert-BXrJNk3g.js";import{i as Ue,n as We,t as Ge}from"./tooltip-D1ydB4g3.js";import{t as Ke}from"./badge-i00PiRCo.js";import{a as qe,i as Je,n as Ye,o as Xe,r as Ze,s as Qe,t as $e}from"./dropdown-menu-82O7jPU6.js";import{t as et}from"./label-DTHSKF2S.js";import{n as J,t as tt}from"./get-error-message-yQcVJ-Ja.js";var nt=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:s()})}getOptimisticResult(e){return e.behavior=s(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:a,isRefetching:s,isError:c,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=a&&u===`forward`,p=c&&u===`backward`,m=a&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:i(t,n.data),hasPreviousPage:o(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function rt(e,t){return u(e,nt,t)}var it=P(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),at=P(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ot=P(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),st=P(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Y=e(t(),1),X=n(),ct=`rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/55 bg-muted/10`;function lt(){return(0,X.jsx)(`p`,{className:`mt-2 text-pretty text-sm leading-relaxed text-muted-foreground`,children:`Add a target to get started.`})}function ut({onClick:e}){return(0,X.jsxs)(D,{type:`button`,size:`sm`,className:`h-7 shrink-0 gap-1.5 text-xs`,onClick:e,children:[(0,X.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),`Add Target`]})}function dt({titleId:e,frameIcon:t,description:n,children:r}){return(0,X.jsx)(`section`,{"aria-labelledby":e,className:ct,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-4 py-10 text-center`,children:[(0,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/50`,children:t}),(0,X.jsxs)(`div`,{className:`max-w-sm`,children:[(0,X.jsx)(`h2`,{id:e,className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`No targets yet`}),n]}),r]})})}function ft({stream:e,onReset:t,catalogTemplates:n}){if(!e.operation&&e.status!==`running`)return null;let{title:r,subtitle:i}=_e(e),a=e.status===`complete`,o=e.status===`error`,s=e.status===`running`,c=a||o,l=e.cancelRequested;async function u(){await e.cancel().catch(()=>{})}return(0,X.jsx)(re,{title:r,subtitle:i,canDismiss:!s,footerAction:s&&e.operation?.operationId?(0,X.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,X.jsx)(`button`,{type:`button`,onClick:u,disabled:l,"aria-busy":l,className:F(N({variant:`outline`,size:`sm`}),`group h-8 gap-1.5 px-3 text-xs`,l?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),children:l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pe,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(h.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,X.jsx)(h.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):c?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 w-full flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,X.jsxs)(y,{to:`/platforms?tab=activity`,className:F(N({variant:`ghost`,size:`xs`}),`group inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-[11px] font-medium text-foreground/80`,`hover:bg-primary/12 hover:text-primary`),children:[(0,X.jsx)(I,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,X.jsx)(ke,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,X.jsx)(D,{type:`button`,variant:`secondary`,size:`xs`,className:`h-6 px-2.5 text-[11px] font-medium`,onClick:t,children:`Close`})})]}),e.operation?.status===`cancelled`||o&&e.operation?(0,X.jsx)(xe,{type:e.operation.type,errorMessage:e.operation.error,className:`mt-2.5 w-full min-w-0`}):null]}):void 0,onDismiss:t,children:e.operation?(0,X.jsx)(ae,{operation:e.operation,catalogTemplates:n,logs:e.logs}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Pe,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,X.jsx)(h.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})})}var pt=`miravo:platforms:recent-template-ids`,mt=8,ht=`miravo:platforms:last-target-id`;function Z(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(pt),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function gt(e){if(typeof window>`u`)return;let t=[e,...Z().filter(t=>t!==e)].slice(0,mt);try{window.localStorage.setItem(pt,JSON.stringify(t))}catch{}}function _t(){if(!(typeof window>`u`))try{return window.localStorage.getItem(ht)??void 0}catch{return}}function vt(e){if(!(typeof window>`u`))try{window.localStorage.setItem(ht,e)}catch{}}var yt=50;function bt({open:e,type:t,targetLabel:n,targetHostname:r,templates:i,templatesLoading:a,templatesError:o,onRetryTemplates:s,onOpenChange:c,onSelect:l}){let[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(Z),m=(0,Y.useDeferredValue)(u);(0,Y.useEffect)(()=>{e&&(d(``),p(Z()))},[e]);let h=(0,Y.useMemo)(()=>{let e=m.trim().toLowerCase(),t=new Map(f.map((e,t)=>[e,t])),n=[],r=new Set;for(let t of i){if(r.has(t.id))continue;r.add(t.id);let i=[t.name,t.id,t.category,t.description??``,t.models.join(` `)].join(` `).toLowerCase();e!==``&&!i.includes(e)||n.push(t)}return n.sort((e,n)=>{let r=t.get(e.id)??1/0,i=t.get(n.id)??1/0;return r===i?e.name.localeCompare(n.name):r-i}),{items:n.slice(0,yt),total:n.length,recentRank:t}},[i,m,f]),g=t===`apply`?`Apply environment`:`Cleanup environment`,_=e=>{gt(e.id),l(e)};return(0,X.jsx)(C,{open:e,onOpenChange:c,children:(0,X.jsxs)(ee,{className:`flex max-h-[82vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,X.jsx)(T,{className:`text-sm font-semibold`,children:g}),(0,X.jsxs)(x,{className:`mt-1 text-xs`,children:[n,` / `,r]})]}),(0,X.jsx)(`div`,{className:`shrink-0 border-b border-border/45 px-5 py-3`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(ue,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(O,{value:u,onChange:e=>d(e.currentTarget.value),className:`h-9 pl-8`,placeholder:`Search environments`,autoFocus:!0})]})}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:a&&i.length===0?(0,X.jsx)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`Loading environments...`}):o&&i.length===0?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--miravo-radius-tight)] border border-warning/25 bg-warning/5 px-3 py-2 text-xs text-warning`,children:[(0,X.jsx)(`span`,{children:`Could not load environments.`}),(0,X.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-warning hover:text-warning`,onClick:s,children:`Retry`})]}):h.items.length===0?(0,X.jsx)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No matching environments.`}):(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:h.items.map(e=>{let t=h.recentRank.has(e.id);return(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left text-xs transition-colors hover:bg-muted/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70`,onClick:()=>_(e),children:[(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/35 bg-muted/25 text-primary`,children:(0,X.jsx)(Ce,{id:e.id,className:`size-3.5`})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.name}),t?(0,X.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] border border-primary/25 bg-primary/8 px-1.5 py-px font-mono text-[9px] uppercase tracking-wider text-primary`,children:`Recent`}):null]}),(0,X.jsxs)(`span`,{className:`mt-0.5 block truncate font-mono text-[11px] text-muted-foreground`,children:[e.id,` / `,e.instanceCount,` instances`]})]})]},e.id)})})}),h.total>h.items.length?(0,X.jsxs)(`div`,{className:`shrink-0 border-t border-border/45 px-5 py-2 text-[11px] text-muted-foreground`,children:[`Showing `,h.items.length,` of `,h.total,`. Refine search.`]}):null]})})}function xt({targets:e,stream:t}){let[n,i]=(0,Y.useState)(`apply`),[o,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),[ee]=(0,Y.useState)(_t),T=(0,Y.useRef)(0),E=(0,Y.useRef)(null),O=t.status===`running`,A=n===`apply`,j=f({queryKey:c.catalog.templates(),queryFn:()=>a(`/catalog/templates`,r.catalogTemplates)}),M=j.data??[],N=M.find(e=>e.id===l),P=e.find(e=>e.id===o),I=A?!!o&&!!l:!!o&&(d||!!l),L=(0,Y.useCallback)(()=>{T.current+=1,E.current?.abort(),E.current=null,y(!1),_(null)},[]);(0,Y.useEffect)(()=>{if(!(l||M.length===0||d))for(let e of Z()){let t=M.find(t=>t.id===e);if(t){u(t.id);return}}},[l,M,d]);let V=(0,Y.useCallback)(()=>{L(),S.message(`Preview cancelled`)},[L]),te=e=>{O||(i(e),L(),p(!1))},re=(0,Y.useCallback)(async(e,n)=>{if(e===`apply`){if(!o||!l)return}else if(!o||!d&&!l)return;t.operation&&t.status!==`running`&&t.reset(),E.current?.abort(),T.current+=1;let r=T.current,i=new AbortController;E.current=i,y(!0),_(null);try{let t=e===`apply`?await he(B({targetId:o,template:l,result:n}),{signal:i.signal}):await oe(z({targetId:o,template:l,allManaged:d,result:n}),{signal:i.signal});if(r!==T.current)return;_(t.plan)}catch(t){if(r!==T.current||ie(t))return;let n=J(t,e===`apply`?`Plan failed`:`Cleanup plan failed`),i=tt(t);S.error(n,i?{description:i}:void 0)}finally{r===T.current&&y(!1)}},[o,l,d,t]),ae=(0,Y.useCallback)(e=>{x(!1),L(),vt(o),l&>(l),n===`apply`?t.startApply(B({targetId:o,template:l,result:e})):t.startCleanup(z({targetId:o,template:l,allManaged:d,result:e}))},[n,o,l,d,t,L]),H=!A&&d,U=I&&!O,se=A?ze:R,ue=`Awaiting selection`;U&&(ue=A?`Review apply`:`Review cleanup`);let fe=H?`All managed resources`:N?.name??`Select environment`,W=(0,X.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0});H?W=(0,X.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}):N&&(W=(0,X.jsx)(Ce,{id:N.id,className:`size-3.5`}));let me=A?`Provisions devices, tags, and Digital Twin models from the selected environment on the selected target.`:`Removes Miravo-managed resources for this environment from the selected target.`;H&&(me=`Removes all Miravo-managed resources from the target (ignores environment scope).`);let _e=P?`${P.label} / ${fe}`:`Select target and environment`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`div`,{role:`toolbar`,"aria-label":`Operation mode`,className:`inline-flex items-center gap-0.5 rounded-[var(--miravo-radius-pill)] border border-border/50 bg-muted/15 p-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":A,className:F(`relative flex items-center gap-1.5 rounded-[var(--miravo-radius-pill)] px-4 py-1.5 text-xs font-medium transition-colors`,A?`text-primary`:`text-muted-foreground hover:text-foreground`),onClick:()=>te(`apply`),disabled:O,children:[A&&(0,X.jsx)(h.span,{layoutId:`mode-pill`,className:`absolute inset-0 rounded-[var(--miravo-radius-pill)] bg-primary/15 shadow-sm`,transition:{type:`spring`,stiffness:500,damping:40}}),(0,X.jsx)(st,{className:`relative z-10 size-3.5`}),(0,X.jsx)(`span`,{className:`relative z-10`,children:`Apply`})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!A,className:F(`relative flex items-center gap-1.5 rounded-[var(--miravo-radius-pill)] px-4 py-1.5 text-xs font-medium transition-colors`,A?`text-muted-foreground hover:text-foreground`:`text-destructive`),onClick:()=>te(`cleanup`),disabled:O,children:[!A&&(0,X.jsx)(h.span,{layoutId:`mode-pill`,className:`absolute inset-0 rounded-[var(--miravo-radius-pill)] bg-destructive/15 shadow-sm`,transition:{type:`spring`,stiffness:500,damping:40}}),(0,X.jsx)(R,{className:`relative z-10 size-3.5`}),(0,X.jsx)(`span`,{className:`relative z-10`,children:`Cleanup`})]})]}),(0,X.jsx)(pe,{stream:t})]}),(0,X.jsx)(be,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/25 pb-3`,children:[(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-primary/25 bg-primary/9 shadow-[inset_0_1px_0_0_var(--miravo-inset-highlight)]`,children:(0,X.jsx)(Ve,{className:`size-4 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground`,children:`Litmus Edge`}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-muted-foreground`,children:me})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(et,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Target`}),(0,X.jsx)(ce,{targets:e,value:o,onValueChange:e=>{s(e),vt(e),L()},preferredTargetId:ee,disabled:O,size:`sm`,className:`min-w-0 w-full text-xs`})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(et,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Environment`}),j.isError&&!j.data&&(0,X.jsx)(m,{message:J(j.error,`Failed to load environments.`),onRetry:()=>void j.refetch(),isRetrying:j.isFetching&&!j.isPending}),(0,X.jsxs)(`button`,{type:`button`,disabled:H||O||!P,onClick:()=>w(!0),className:F(`flex h-9 min-h-9 w-full min-w-0 items-center justify-between gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border border-input bg-input/30 px-2.5 py-0 text-left text-xs outline-none transition-colors select-none`,`hover:bg-input/50 focus-visible:border-primary/35 focus-visible:ring-2 focus-visible:ring-primary/22`,`disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50`),"aria-label":`Environment`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/35 bg-muted/25 text-primary`,children:W}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:fe})]}),(0,X.jsx)(Te,{className:`pointer-events-none size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})]}),(0,X.jsxs)(`button`,{type:`button`,disabled:!U||v,onClick:()=>x(!0),className:F(`group flex w-full min-h-14 min-w-0 items-stretch overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] text-left outline-none`,`transition-[border-color,box-shadow,background-color] duration-200 ease-out`,`focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:pointer-events-none disabled:opacity-55`,U?[`border-2 border-primary/40 bg-background`,`bg-linear-to-r from-primary/12 via-background to-background`,`shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025)]`,`hover:border-primary/56 hover:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025),0_0_14px_-8px_color-mix(in_srgb,var(--primary)_18%,transparent),0_0_22px_-12px_color-mix(in_srgb,var(--primary)_8%,transparent)]`]:[`border border-dashed border-border/65 bg-muted/15`,`hover:bg-muted/22`]),children:[(0,X.jsx)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:(0,X.jsx)(se,{className:F(`relative size-5`,U?`text-primary`:`text-muted-foreground`)})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-0.5 overflow-hidden px-3 py-2.5 sm:px-4`,children:[(0,X.jsx)(`span`,{className:F(`font-heading text-[11px] font-semibold uppercase tracking-[0.18em]`,U?`text-primary`:`text-muted-foreground`),children:ue}),(0,X.jsx)(`span`,{className:F(`truncate font-mono text-[13px] leading-tight tracking-tight`,U?`text-foreground`:`text-muted-foreground`),children:_e})]}),(0,X.jsx)(`span`,{className:F(`flex shrink-0 items-center pr-2.5 sm:pr-3`,U&&`pl-1`),children:(0,X.jsx)(`span`,{className:F(`flex size-9 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border bg-transparent transition-[border-color,color] duration-200`,U?`border-primary/40 text-primary group-hover:border-primary/55`:`border-border/45 text-muted-foreground`),"aria-hidden":!0,children:(0,X.jsx)(ke,{className:`size-4`,strokeWidth:2.25})})})]}),!A&&(0,X.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-end gap-2`,children:(0,X.jsxs)(et,{id:`all-managed-label`,htmlFor:`all-managed`,"aria-disabled":O,className:F(`inline-flex h-8 w-fit max-w-full cursor-pointer items-center gap-2 text-xs font-medium leading-none`,O&&`pointer-events-none opacity-40`),children:[(0,X.jsx)(Be,{id:`all-managed`,checked:d,onCheckedChange:e=>{p(e===!0),L()},disabled:O}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Remove all Miravo managed resources`})]})})]})}),(v||g)&&!O&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v&&(0,X.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-end gap-2`,children:(0,X.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:V,children:[(0,X.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),`Cancel preview`]})}),v&&(0,X.jsx)(le,{}),g&&!v&&(0,X.jsx)(ge,{plan:g,planKind:A?`apply`:`cleanup`,onCloseTable:L})]}),P&&C?(0,X.jsx)(bt,{open:!0,type:n,targetLabel:P.label,targetHostname:P.hostname,templates:M,templatesLoading:j.isPending&&j.data===void 0,templatesError:j.isError&&M.length===0,onRetryTemplates:()=>void j.refetch(),onOpenChange:w,onSelect:e=>{u(e.id),gt(e.id),p(!1),L(),A&&t.reset(),w(!1)}}):null,P&&(0,X.jsx)(ne,{open:b,onOpenChange:x,type:n,label:H?`All managed resources`:N?.name??l,targetLabel:P.label,hostname:P.hostname,sourceHostname:P.sourceHostname,onConfirm:ae,defaultNamePrefix:A?l:void 0,metadata:de,applyPreview:A?{onPreview:e=>void re(`apply`,e),planLoading:v,disabled:!o||!l||O}:void 0,cleanupPreview:A?void 0:{onPreview:e=>void re(`cleanup`,e),planLoading:v,disabled:!o||!d&&!l||O}})]})}function St(){return(0,X.jsx)(`section`,{"aria-labelledby":`platforms-operation-log-empty-title`,className:ct,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-4 py-8 text-center sm:py-10`,children:[(0,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/50`,children:(0,X.jsx)(I,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`max-w-sm`,children:[(0,X.jsx)(`h2`,{id:`platforms-operation-log-empty-title`,className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`No operations yet`}),(0,X.jsx)(`p`,{className:`mt-2 text-pretty text-sm leading-relaxed text-muted-foreground`,children:`Run apply or cleanup from the Operations tab. Finished runs show up here with full detail.`})]})]})})}function Ct(e){let t=new Date(e),n=new Date,r=new Date(n);return r.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?`Today`:t.toDateString()===r.toDateString()?`Yesterday`:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`})}function wt(e){let t=new Map;for(let n of e){let e=new Date(n.completedAt).toDateString(),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([,e])=>({label:Ct(e[0]?.completedAt??Date.now()),ops:e}))}function Tt(e,t){return e===`device`?t.operationType===`apply`?`Tag/register writes per device step—not a device count.`:`One count per device removed from DeviceHub.`:e===`model`?`One count per model in this run.`:e===`instance`?`One count per twin instance in this run.`:`Sets the device parameter to the bound DeviceHub device.`}var Et={devices:`Devices`,models:`DT models`,instances:`DT instances`},Q={create:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-success/35 bg-success/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-success`,update:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-primary/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-primary`,replace:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-chart-2/35 bg-chart-2/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-chart-2`,delete:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/35 bg-destructive/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-destructive`,noop:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-border/55 bg-muted/55 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-foreground/78`,failed:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/18 px-1.5 py-0.5 font-mono text-[10px] font-semibold tabular-nums text-destructive`};function Dt(e){return[{key:`device`,title:`DeviceHub — protocol tags`,subtitle:Tt(`device`,e),counts:e.resourceCounts.device},{key:`model`,title:`Digital Twin models`,subtitle:Tt(`model`,e),counts:e.resourceCounts.model},{key:`instance`,title:`Twin instances`,subtitle:Tt(`instance`,e),counts:e.resourceCounts.instance},{key:`param-sync`,title:`Parameter sync`,subtitle:Tt(`param-sync`,e),counts:e.resourceCounts[`param-sync`]}].filter(e=>e.counts.total>0||e.counts.failed>0)}function Ot(e){return e.length===0?`Default (devices, models, instances)`:e.map(e=>Et[e]??e).join(` · `)}function kt(e){let t=[];return e.filters.area&&t.push(`Area ${e.filters.area}`),e.filters.line&&t.push(`Line ${e.filters.line}`),e.filters.instance&&t.push(`Instance ${e.filters.instance}`),t.length>0?t.join(` · `):null}function $(e,t,n){if(e===`device`)switch(t){case`create`:return`+${n} tags (new device)`;case`update`:return`${n} tags rewritten`;case`replace`:return`↻${n} tags (device replaced)`;case`delete`:return`−${n} removed`;case`noop`:return`=${n} unchanged`}switch(t){case`create`:return`+${n} created`;case`update`:return`${n} updated`;case`replace`:return`↻${n} replaced`;case`delete`:return`−${n} removed`;case`noop`:return`=${n} unchanged`}}function At({row:e}){let{key:t,counts:n}=e;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1.5`,children:[n.create>0&&(0,X.jsx)(`span`,{className:Q.create,children:$(t,`create`,n.create)}),n.update>0&&(0,X.jsx)(`span`,{className:Q.update,children:$(t,`update`,n.update)}),n.replace>0&&(0,X.jsx)(`span`,{className:Q.replace,children:$(t,`replace`,n.replace)}),n.delete>0&&(0,X.jsx)(`span`,{className:Q.delete,children:$(t,`delete`,n.delete)}),n.noop>0&&(0,X.jsx)(`span`,{className:Q.noop,children:$(t,`noop`,n.noop)}),n.failed>0&&(0,X.jsx)(`span`,{className:Q.failed,children:`${n.failed} failed`})]})}function jt(e){return e.resourceCounts.device.noop+e.resourceCounts.model.noop+e.resourceCounts.instance.noop+e.resourceCounts[`param-sync`].noop}function Mt({op:e}){let t=kt(e),n=jt(e);return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 bg-muted/25 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.16em] text-foreground/72`,children:`Run context`}),(0,X.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[minmax(0,7.5rem)_1fr] gap-x-3 gap-y-1.5 text-xs sm:grid-cols-[9rem_1fr]`,children:[(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Operation`}),(0,X.jsx)(`dd`,{className:`font-medium capitalize text-foreground`,children:e.operationType}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Target host`}),(0,X.jsx)(`dd`,{className:`break-all font-mono text-[11px] text-foreground`,children:e.hostname}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Scope`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:Ot(e.scope)}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Filters`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:t})]}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Duration`}),(0,X.jsxs)(`dd`,{className:`tabular-nums text-foreground`,children:[(e.durationMs/1e3).toFixed(1),`s`]}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Outcome`}),(0,X.jsxs)(`dd`,{className:`text-foreground`,children:[(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.successCount}),` steps succeeded`,n>0&&(0,X.jsxs)(`span`,{className:`text-foreground/72`,children:[` `,`· `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:n}),` unchanged`]}),e.failedCount>0&&(0,X.jsxs)(`span`,{className:`text-destructive`,children:[` `,`· `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.failedCount}),` failed`]}),e.blockedCount>0&&(0,X.jsxs)(`span`,{className:`text-warning`,children:[` `,`· `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.blockedCount}),` blocked in plan`]})]})]})]})}function Nt({status:e}){switch(e){case`success`:return(0,X.jsx)(je,{className:`mt-px size-4 shrink-0 text-success`});case`failed`:return(0,X.jsx)(Ie,{className:`mt-px size-4 shrink-0 text-destructive`});case`partial`:case`blocked`:return(0,X.jsx)(He,{className:`mt-px size-4 shrink-0 text-warning`});case`noop`:return(0,X.jsx)(it,{className:`mt-px size-4 shrink-0 text-foreground/55`})}}function Pt(e){let t=e.operationType===`apply`?`Applied`:`Cleaned up`,n=`${(e.durationMs/1e3).toFixed(1)}s`,r=[];e.successCount>0&&r.push(`${e.successCount} resources`);let i=jt(e);return i>0&&r.push(`${i} unchanged`),e.failedCount>0&&r.push(`${e.failedCount} failed`),e.blockedCount>0&&r.push(`${e.blockedCount} blocked`),r.length===0?`${t} · no changes · ${n}`:`${t} · ${r.join(`, `)} · ${n}`}function Ft(e){return e.operationType===`cleanup`&&e.successCount===0&&e.failedCount===0&&e.blockedCount===0?`No Miravo-managed resources were found to clean up.`:e.failedCount>0&&e.blockedCount>0?`No per-phase counts — failures and blocked plan entries.`:e.failedCount>0?`No per-phase counts — run failed.`:e.blockedCount>0?`No per-phase counts — blocked plan entries.`:jt(e)>0?`No resources were mutated. Existing managed resources already matched the desired state.`:`No per-phase counts recorded.`}function It({op:e}){let t=Dt(e);return t.length===0?(0,X.jsx)(`p`,{className:`py-1 text-sm text-foreground/75`,children:Ft(e)}):(0,X.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,X.jsx)(`div`,{className:`flex flex-col divide-y divide-border/45 rounded-[var(--miravo-radius-tight)] border border-border/50`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2.5 sm:flex-row sm:items-start sm:gap-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 shrink-0 sm:w-[11.5rem]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium leading-snug text-foreground`,children:e.title}),(0,X.jsxs)(Ge,{children:[(0,X.jsx)(Ue,{type:`button`,className:`inline-flex shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] p-0.5 text-foreground/60 hover:bg-muted/50 hover:text-foreground`,"aria-label":`About ${e.title}`,children:(0,X.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(We,{side:`top`,className:`max-w-xs text-left`,children:e.subtitle})]})]}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-foreground/72 sm:hidden`,children:e.subtitle})]}),(0,X.jsx)(At,{row:e})]},e.key))}),e.blockedCount>0&&(0,X.jsxs)(`p`,{className:`rounded-[var(--miravo-radius-tight)] border border-warning/20 bg-warning/5 px-2.5 py-1.5 text-[11px] text-warning`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.blockedCount}),` plan entries were blocked (skipped). Open a `,(0,X.jsx)(`span`,{className:`font-medium`,children:`deploy preview`}),` before running to see block reasons.`]})]})}function Lt({operation:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:F(`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/55`,`transition-colors duration-150`),children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:F(`flex w-full items-start gap-3 p-3.5 text-left`,`transition-colors duration-100`,`hover:bg-muted/25`,t&&`bg-muted/18`),children:[(0,X.jsx)(Nt,{status:e.status}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 truncate text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:A(e.templateId)}),(0,X.jsx)(`span`,{className:`mx-1.5 text-foreground/50`,children:`→`}),(0,X.jsx)(`span`,{className:`text-foreground/82`,children:e.targetLabel})]}),(0,X.jsx)(`time`,{dateTime:new Date(e.completedAt).toISOString(),title:M(e.completedAt),className:`shrink-0 text-xs text-foreground/75`,children:j(e.completedAt)})]}),(0,X.jsx)(`p`,{className:`text-xs text-foreground/78`,children:Pt(e)}),(e.failedCount>0||e.status===`failed`)&&(0,X.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/72`,children:e.error??`The operation ended with an error.`})]}),(0,X.jsx)(Te,{className:F(`mt-0.5 size-3.5 shrink-0 text-foreground/55 transition-transform duration-150`,t&&`rotate-180`)})]}),(0,X.jsx)(g,{initial:!1,children:t&&(0,X.jsx)(h.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`space-y-3 border-t border-border/45 px-4 pb-3 pt-3`,children:[(0,X.jsx)(Mt,{op:e}),e.error&&(0,X.jsxs)(`div`,{className:`relative rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/15 px-3 py-2 pr-10 text-xs font-medium`,children:[(0,X.jsx)(`div`,{className:`absolute top-1.5 right-1.5 z-10`,children:(0,X.jsx)(E,{value:e.error,label:`Copy error`,className:`text-destructive hover:bg-destructive/25 hover:text-foreground`})}),(0,X.jsx)(`p`,{className:`whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error})]}),(0,X.jsx)(It,{op:e})]})})})]})}function Rt({label:e}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border/65`}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-foreground/78`,children:e}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border/65`})]})}var zt={type:``,status:``,target:``,search:``},Bt={_all:`All types`,apply:`Apply`,cleanup:`Cleanup`},Vt={_all:`All statuses`,success:`Success`,partial:`Partial`,failed:`Failed`,blocked:`Blocked`,noop:`No-op`},Ht=`h-7 min-h-7 gap-1.5 border-border/50 bg-transparent px-2 text-xs hover:bg-muted/30 focus:ring-0`;function Ut({filters:e,targetOptions:t,hasFilters:n,searchRef:r,onTypeChange:i,onStatusChange:a,onTargetChange:o,onSearchChange:s,onClear:c}){return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border/50 px-3 py-2`,children:[(0,X.jsxs)(Oe,{value:e.type||`_all`,onValueChange:e=>e&&i(e===`_all`?``:e),children:[(0,X.jsx)(De,{size:`sm`,className:Ht,"aria-label":`Operation type`,children:(0,X.jsx)(we,{children:e=>Bt[e??`_all`]??Bt._all})}),(0,X.jsxs)(Ee,{children:[(0,X.jsx)(G,{value:`_all`,children:`All types`}),(0,X.jsx)(G,{value:`apply`,children:`Apply`}),(0,X.jsx)(G,{value:`cleanup`,children:`Cleanup`})]})]}),(0,X.jsxs)(Oe,{value:e.status||`_all`,onValueChange:e=>e&&a(e===`_all`?``:e),children:[(0,X.jsx)(De,{size:`sm`,className:Ht,"aria-label":`Operation status`,children:(0,X.jsx)(we,{children:e=>Vt[e??`_all`]??Vt._all})}),(0,X.jsxs)(Ee,{children:[(0,X.jsx)(G,{value:`_all`,children:`All statuses`}),(0,X.jsx)(G,{value:`success`,children:`Success`}),(0,X.jsx)(G,{value:`partial`,children:`Partial`}),(0,X.jsx)(G,{value:`failed`,children:`Failed`}),(0,X.jsx)(G,{value:`blocked`,children:`Blocked`}),(0,X.jsx)(G,{value:`noop`,children:`No-op`})]})]}),t.length>1&&(0,X.jsxs)(Oe,{value:e.target||`_all`,onValueChange:e=>e&&o(e===`_all`?``:e),children:[(0,X.jsx)(De,{size:`sm`,className:Ht,"aria-label":`Target filter`,children:(0,X.jsx)(we,{children:e=>!e||e===`_all`?`All targets`:e})}),(0,X.jsxs)(Ee,{children:[(0,X.jsx)(G,{value:`_all`,children:`All targets`}),t.map(e=>(0,X.jsx)(G,{value:e,children:e},e))]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-w-[140px] flex-1 items-center`,children:[(0,X.jsx)(`input`,{ref:r,type:`search`,value:e.search,onChange:e=>s(e.target.value),placeholder:`Search environment or target…`,"aria-describedby":`ops-search-shortcut`,className:F(`h-7 w-full rounded-[var(--miravo-radius-tight)] border border-border/50 bg-transparent pl-2 pr-7 text-xs`,`placeholder:text-foreground/60 focus:outline-none focus:ring-1 focus:ring-ring/40`,e.search&&`pr-2`)}),(0,X.jsx)(`span`,{id:`ops-search-shortcut`,className:`sr-only`,children:`Press slash to focus search`}),!e.search&&(0,X.jsx)(`kbd`,{"aria-hidden":!0,className:`pointer-events-none absolute right-2 flex h-4 items-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/50 px-1 font-mono text-[10px] text-foreground/65`,children:`/`})]}),n&&(0,X.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-7 items-center gap-1 rounded-[var(--miravo-radius-tight)] px-2 text-xs text-foreground/72 transition-colors hover:bg-muted/40 hover:text-foreground`,children:[(0,X.jsx)(k,{className:`size-3`}),`Clear`]})]})}function Wt({operations:e,totalKnown:t,isLoading:n,error:r,onRefresh:i,hasNextPage:a=!1,isFetchingNextPage:o=!1,loadMoreError:s=null,onRetryLoadMore:c,onLoadMore:l}){let[u,d]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(zt),_=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),_.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let v=()=>{d(!0),i(),S.success(`Operations refreshed`),setTimeout(()=>d(!1),600)},y=(0,Y.useMemo)(()=>{let t=new Set;for(let n of e){let e=n.targetLabel;t.add(e)}return[...t].sort()},[e]),b=(0,Y.useMemo)(()=>{let t=e;if(f.type&&(t=t.filter(e=>e.operationType===f.type)),f.status&&(t=t.filter(e=>e.status===f.status)),f.target&&(t=t.filter(e=>e.targetLabel===f.target)),f.search){let e=f.search.toLowerCase();t=t.filter(t=>{let n=t.targetLabel;return t.templateId.toLowerCase().includes(e)||A(t.templateId).toLowerCase().includes(e)||n.toLowerCase().includes(e)})}return t},[e,f]),x=f.type!==``||f.status!==``||f.target!==``||f.search!==``,C=(0,Y.useMemo)(()=>wt(b),[b]);return(0,X.jsxs)(`div`,{className:`flex h-full flex-col rounded-[var(--miravo-radius-stadium-sm)] border border-border/55`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3.5 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Operation log`}),e.length>0&&(0,X.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-foreground/75`,children:typeof t==`number`&&t>0&&e.length<t?`${e.length} / ${t}`:String(e.length)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:v,disabled:u,"aria-label":`Refresh operation list`,className:`relative rounded-[var(--miravo-radius-tight)] p-1 text-foreground/70 transition-colors before:absolute before:inset-[-10px] before:content-[''] hover:bg-muted/50 hover:text-foreground disabled:pointer-events-none`,children:(0,X.jsx)(p,{className:F(`size-3.5`,u&&`animate-spin`),"aria-hidden":!0})})]}),(0,X.jsx)(Ut,{filters:f,targetOptions:y,hasFilters:x,searchRef:_,onTypeChange:e=>m(t=>({...t,type:e})),onStatusChange:e=>m(t=>({...t,status:e})),onTargetChange:e=>m(t=>({...t,target:e})),onSearchChange:e=>m(t=>({...t,search:e})),onClear:()=>m(zt)}),(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto overscroll-y-contain p-3`,children:[r&&(0,X.jsxs)(`p`,{className:`py-2 text-xs text-destructive`,children:[`✕ `,r.message]}),n&&e.length===0&&!r&&(0,X.jsx)(`p`,{className:`py-4 text-sm text-foreground/75`,children:`Loading…`}),!n&&e.length===0&&!r&&(0,X.jsx)(St,{}),!n&&e.length>0&&b.length===0&&(0,X.jsxs)(`p`,{className:`py-6 text-center text-sm text-foreground/75`,children:[`No operations match your filters.`,` `,(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(zt),className:`text-primary hover:underline`,children:`Clear filters`})]}),x&&b.length>0&&b.length!==e.length&&(0,X.jsxs)(`p`,{className:`text-xs text-foreground/75`,children:[`Showing`,` `,(0,X.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:b.length}),` of`,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.length}),` loaded`]}),!x&&typeof t==`number`&&t>0&&e.length<t&&(0,X.jsxs)(`p`,{className:`text-xs text-foreground/75`,children:[`Showing`,` `,(0,X.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:e.length}),` `,`of `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:t}),`. Load more for older entries.`]}),(0,X.jsx)(g,{initial:!1,children:C.map(e=>(0,X.jsxs)(h.div,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(Rt,{label:e.label}),(0,X.jsx)(g,{initial:!1,children:e.ops.map(e=>(0,X.jsx)(h.div,{initial:b.length>40?!1:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{type:`spring`,stiffness:400,damping:35},children:(0,X.jsx)(Lt,{operation:e})},`${e.operationId}-${e.completedAt}`))})]},e.label))}),s?(0,X.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-col items-center gap-2 border-t border-border/50 pt-3 pb-1 text-center`,children:[(0,X.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Could not load older entries: `,s.message]}),c?(0,X.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:`Retry`}):null]}):a&&l?(0,X.jsx)(`div`,{className:`flex shrink-0 justify-center border-t border-border/50 pt-3 pb-1`,children:(0,X.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`min-w-[7rem]`,disabled:o,"aria-busy":o,"aria-label":o?`Loading older operations`:`Load older operations`,onClick:l,children:o?`Loading…`:`Load more`})}):null]})]})}function Gt({target:e,templates:t,templatesLoading:n,templatesError:r,isStreaming:i,onRetryTemplates:a,onSelect:o}){let s=t.length===0&&!n&&!r,[c,l]=(0,Y.useState)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute right-3 top-3 z-20`,children:(0,X.jsxs)($e,{children:[(0,X.jsx)(Qe,{render:(0,X.jsx)(D,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:i,className:`border border-border/45 bg-background/70 text-muted-foreground shadow-[inset_0_1px_0_0_var(--miravo-inset-highlight)] hover:border-primary/30 hover:bg-muted/55 hover:text-foreground`,"aria-label":`Open quick actions for ${e.label}`}),children:(0,X.jsx)(at,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(Ye,{align:`end`,sideOffset:6,className:`min-w-56`,children:(0,X.jsxs)(Ze,{children:[(0,X.jsx)(qe,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Quick actions`}),(0,X.jsx)(Xe,{className:`bg-border/60`}),(0,X.jsxs)(Je,{disabled:s,className:`h-9 gap-2 text-xs`,onClick:()=>l(`apply`),children:[(0,X.jsx)(ze,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Apply environment...`})]}),(0,X.jsxs)(Je,{disabled:s,className:`h-9 gap-2 text-xs`,onClick:()=>l(`cleanup`),children:[(0,X.jsx)(R,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Cleanup environment...`})]}),(0,X.jsx)(Xe,{className:`bg-border/60`}),(0,X.jsxs)(Je,{variant:`destructive`,className:`h-9 gap-2 text-xs`,onClick:()=>o({type:`cleanup`,target:e,allManaged:!0}),children:[(0,X.jsx)(R,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Cleanup all managed`})]})]})})]})}),c?(0,X.jsx)(bt,{open:!0,type:c,targetLabel:e.label,targetHostname:e.hostname,templates:t,templatesLoading:n,templatesError:r,onRetryTemplates:a,onOpenChange:e=>{e||l(null)},onSelect:t=>{o({type:c,target:e,templateId:t.id}),l(null)}},c):null]})}function Kt({selection:e,templates:t,stream:n,onSelectionChange:r}){let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(0),d=(0,Y.useRef)(null),f=(0,Y.useRef)(!1),p=n.status===`running`,m=(0,Y.useCallback)(()=>{u.current+=1,f.current=!1,d.current?.abort(),d.current=null,l(!1),s(null)},[]);(0,Y.useEffect)(()=>{e&&(m(),a(!0))},[e,m]),(0,Y.useEffect)(()=>()=>{u.current+=1,f.current=!1,d.current?.abort(),d.current=null},[]);let h=e?.templateId==null?void 0:t.find(t=>t.id===e.templateId)?.name??e.templateId,g=e?.type===`cleanup`&&e.allManaged?`All managed resources`:h??``,_=(0,Y.useCallback)(async t=>{if(!e)return;let r=e.templateId;if(e.type===`apply`&&!r||e.type===`cleanup`&&!e.allManaged&&!r)return;n.operation&&n.status!==`running`&&n.reset(),f.current=!0,d.current?.abort(),u.current+=1;let i=u.current,a=new AbortController;d.current=a,l(!0),s(null);try{let n;if(e.type===`apply`){if(!r)return;n=await he(B({targetId:e.target.id,template:r,result:t}),{signal:a.signal})}else n=await oe(z({targetId:e.target.id,template:r,allManaged:e.allManaged,result:t}),{signal:a.signal});if(i!==u.current)return;s(n.plan)}catch(t){if(i!==u.current||ie(t))return;let n=J(t,e.type===`apply`?`Plan failed`:`Cleanup plan failed`),r=tt(t);S.error(n,r?{description:r}:void 0)}finally{i===u.current&&(l(!1),f.current=!1)}},[e,n]),v=(0,Y.useCallback)(t=>{if(e){if(a(!1),m(),r(null),e.type===`apply`){if(!e.templateId)return;n.startApply(B({targetId:e.target.id,template:e.templateId,result:t}));return}n.startCleanup(z({targetId:e.target.id,template:e.templateId,allManaged:e.allManaged,result:t}))}},[e,n,m,r]),y=e=>{a(e),!(e||f.current)&&(m(),r(null))},b=()=>{m(),r(null)};return(0,X.jsxs)(X.Fragment,{children:[e&&(0,X.jsx)(ne,{open:i,onOpenChange:y,type:e.type,label:g,targetLabel:e.target.label,hostname:e.target.hostname,sourceHostname:e.target.sourceHostname,onConfirm:v,defaultNamePrefix:e.type===`apply`?e.templateId:void 0,metadata:de,applyPreview:e.type===`apply`?{onPreview:e=>void _(e),planLoading:c,disabled:!e.templateId||p}:void 0,cleanupPreview:e.type===`cleanup`?{onPreview:e=>void _(e),planLoading:c,disabled:!e.allManaged&&!e.templateId||p}:void 0}),(c||o)&&!p&&e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,X.jsx)(te,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`Preview for `,e.target.label,`: `,g]})]}),(0,X.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:b,children:[(0,X.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),`Close preview`]})]}),c?(0,X.jsx)(le,{}):o?(0,X.jsx)(ge,{plan:o,planKind:e.type,onCloseTable:b}):null]}):null]})}function qt(e){return Ae.find(t=>t.id===e)?.label??e}function Jt(e){if(!e)return`var(--tooltip-border)`;switch(e.status){case`success`:return`var(--success)`;case`partial`:case`blocked`:return`var(--warning)`;case`noop`:return`var(--muted-foreground)`;case`failed`:return`var(--destructive)`}}function Yt({status:e}){switch(e){case`success`:return(0,X.jsx)(je,{className:`size-3 text-success`});case`partial`:case`blocked`:return(0,X.jsx)(He,{className:`size-3 text-warning`});case`noop`:return(0,X.jsx)(it,{className:`size-3 text-muted-foreground`});case`failed`:return(0,X.jsx)(Ie,{className:`size-3 text-destructive`})}}function Xt({target:e,lastOp:t,onEdit:n,onDelete:r,quickActions:i}){return(0,X.jsxs)(`div`,{className:`env-orbital relative overflow-hidden border`,style:{"--_status":Jt(t)},children:[i,(0,X.jsx)(`div`,{className:`relative z-10 px-4 pt-3.5 pb-3 pr-12`,children:(0,X.jsx)(`p`,{className:`font-heading text-[13px] font-semibold leading-tight tracking-tight text-foreground`,children:e.label})}),(0,X.jsx)(`div`,{className:`relative z-10 px-4 py-0.5`,children:(0,X.jsx)(`p`,{className:`font-mono text-xs tracking-tight text-muted-foreground`,children:e.hostname})}),(0,X.jsxs)(`div`,{className:`relative z-10 mx-4 mb-3 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,children:e.sourceHostname}),(0,X.jsx)(`div`,{className:`env-orbital-path min-w-6 flex-1`}),(0,X.jsx)(L,{className:`size-3 shrink-0 text-muted-foreground`})]}),(0,X.jsxs)(`div`,{className:`relative z-10 flex items-center gap-2 border-t border-border/30 px-3 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border/40 px-2 py-0.5`,children:[(0,X.jsx)(`span`,{className:`protocol-card-live-dot size-[5px]`}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium tracking-wide text-muted-foreground`,children:qt(e.platformId)})]}),t&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 truncate text-[11px] text-muted-foreground`,children:[(0,X.jsx)(Yt,{status:t.status}),t.operationType===`apply`?`Applied`:`Cleaned`,` `,(0,X.jsx)(`time`,{dateTime:new Date(t.completedAt).toISOString(),title:M(t.completedAt),children:j(t.completedAt)})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(D,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit target`,onClick:n,children:(0,X.jsx)(ot,{className:`size-3`})}),(0,X.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete target`,onClick:r,children:(0,X.jsx)(R,{className:`size-3`})})]})]})]})}function Zt({onClick:e}){return(0,X.jsxs)(`button`,{type:`button`,onClick:e,className:`env-orbital group h-full w-full flex flex-col items-center justify-center gap-2 border border-dashed py-10 text-muted-foreground transition-colors hover:border-primary/30 hover:text-primary`,style:{"--_status":`var(--tooltip-border)`},children:[(0,X.jsx)(V,{className:`size-5 transition-transform group-hover:scale-110`}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Add Target`})]})}function Qt({targets:e,onMutate:t,lastOpByTarget:n,templates:r,templatesLoading:i,templatesError:a,onRetryTemplates:o,stream:s}){let[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(K.id),[m,_]=(0,Y.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[v,y]=(0,Y.useState)(!1),[E,O]=(0,Y.useState)(!1),{testing:k,runTest:A,cancelInFlight:j}=me(),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),I=s.status===`running`,L=f===K.id&&m.hostname.trim().length>0&&m.sourceHostname.trim().length>0&&(u!==null||m.apiToken.trim().length>0),R=()=>{d(null),p(K.id),_({label:``,hostname:``,apiToken:``,sourceHostname:``}),O(!1),l(!0)},z=e=>{d(e.id),p(Ae.some(t=>t.id===e.platformId)?e.platformId:K.id),_({label:e.label,hostname:e.hostname,apiToken:``,sourceHostname:e.sourceHostname}),O(!1),l(!0)},B=async()=>{if(f!==K.id){S.error(`${qt(f)} target setup is coming soon.`);return}if(!m.label||!m.hostname||!m.sourceHostname){S.error(`Label, hostname, and source host are required.`);return}if(!u&&!m.apiToken){S.error(`API token is required for new targets.`);return}y(!0);try{u?(await W(u,{platformId:f,label:m.label,hostname:m.hostname,sourceHostname:m.sourceHostname,...m.apiToken?{apiToken:m.apiToken}:{}}),S.success(`Target updated.`)):(await H({...m,platformId:f}),S.success(`Target added.`)),l(!1),t()}catch(e){S.error(J(e,`Failed to save target.`))}finally{y(!1)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`flex h-5 items-center text-xs font-medium leading-none uppercase tracking-wider text-muted-foreground`,children:`Platform Targets`}),e.length>0?(0,X.jsx)(Ke,{variant:`secondary`,className:`relative -top-px h-5 shrink-0 px-1.5 py-0 font-mono text-[10px] leading-none tabular-nums`,children:e.length}):null]}),(0,X.jsxs)(D,{size:`sm`,className:`h-7 shrink-0 gap-1.5 text-xs`,onClick:R,children:[(0,X.jsx)(V,{className:`size-3.5`}),` Add Target`]})]}),e.length===0?(0,X.jsx)(dt,{titleId:`platforms-targets-empty-title`,frameIcon:(0,X.jsx)(q,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0}),description:(0,X.jsx)(lt,{}),children:(0,X.jsx)(ut,{onClick:R})}):(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-3 @2xl/main:grid-cols-2 @5xl/main:grid-cols-3`,children:(0,X.jsxs)(g,{children:[e.map((e,t)=>(0,X.jsx)(h.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},children:(0,X.jsx)(Xt,{target:e,lastOp:n.get(e.id),onEdit:()=>z(e),onDelete:()=>N(e),quickActions:(0,X.jsx)(Gt,{target:e,templates:r,templatesLoading:i,templatesError:a,isStreaming:I,onRetryTemplates:o,onSelect:F})})},e.id)),(0,X.jsx)(h.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:380,damping:30,delay:e.length*.04},children:(0,X.jsx)(Zt,{onClick:R})},`add-card`)]})}),(0,X.jsx)(Kt,{selection:P,templates:r,stream:s,onSelectionChange:F}),(0,X.jsx)(se,{open:c,editing:u!==null,platformId:f,form:m,showToken:E,saving:v,testing:k,canTestConnection:L,onOpenChange:l,onPlatformChange:p,onFormChange:_,onShowTokenChange:O,onSave:()=>void B(),onTestConnection:()=>{L&&A({...u?{targetId:u}:{},hostname:m.hostname.trim(),sourceHostname:m.sourceHostname.trim(),...m.apiToken.trim()?{apiToken:m.apiToken.trim()}:{}})},onCancelInFlight:j}),(0,X.jsx)(C,{open:M!==null,onOpenChange:e=>!e&&N(null),children:(0,X.jsxs)(ee,{children:[(0,X.jsxs)(w,{children:[(0,X.jsx)(T,{children:`Remove Target`}),(0,X.jsxs)(x,{children:[`Remove “`,M?.label,`”? This only deletes the saved credentials — it does not affect resources on the target platform.`]})]}),(0,X.jsxs)(b,{children:[(0,X.jsx)(D,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,X.jsx)(D,{variant:`destructive`,onClick:async()=>{if(!M)return;let e=M.id;N(null);try{await fe(e),S.success(`Target removed.`),t()}catch(e){S.error(J(e,`Failed to remove target.`))}},children:`Remove`})]})]})})]})}var $t=25;function en({status:e}){switch(e){case`success`:return(0,X.jsx)(je,{className:`size-3 text-success`});case`partial`:case`blocked`:return(0,X.jsx)(He,{className:`size-3 text-warning`});case`noop`:return(0,X.jsx)(it,{className:`size-3 text-muted-foreground`});case`failed`:return(0,X.jsx)(Ie,{className:`size-3 text-destructive`})}}function tn({targetCount:e,opCount:t,lastOp:n}){return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(q,{className:`size-3`}),(0,X.jsx)(`span`,{className:`font-mono`,children:e}),` target`,e===1?``:`s`]}),(0,X.jsx)(`span`,{className:`hidden h-3 w-px bg-border/40 sm:inline-block`}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(g,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(h.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`font-mono tabular-nums`,children:t},t)}),` `,`operation`,t===1?``:`s`]}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`hidden h-3 w-px bg-border/40 sm:inline-block`}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(en,{status:n.status}),(0,X.jsxs)(`span`,{children:[n.operationType===`apply`?`Applied`:`Cleaned`,` `,(0,X.jsx)(`time`,{dateTime:new Date(n.completedAt).toISOString(),title:M(n.completedAt),children:j(n.completedAt)})]})]})]})]})}function nn(){let e=f({queryKey:c.platforms.targets(),queryFn:()=>U()}),t=e.data??[],n=rt({queryKey:c.platforms.operationsList(),queryFn:({pageParam:e})=>ye({limit:$t,offset:e}),initialPageParam:0,getNextPageParam:(e,t,n)=>e.hasMore&&e.operations.length>0?n+$t:void 0}),i=(0,Y.useMemo)(()=>n.data?.pages.flatMap(e=>e.operations)??[],[n.data]),o=n.data?.pages[0]?.total??0,s=f({queryKey:c.catalog.templates(),queryFn:()=>a(`/catalog/templates`,r.catalogTemplates)}),u=s.data??[],d=ve(),p=(0,Y.useRef)(d.status);(0,Y.useEffect)(()=>{let e=p.current;p.current=d.status,e===`running`&&d.status===`complete`&&l.invalidateQueries({queryKey:c.platforms.operationsList()})},[d.status]);let y=(0,Y.useMemo)(()=>{let e=new Map;for(let t of i)e.has(t.targetId)||e.set(t.targetId,t);return e},[i]),[b,x]=_(`tab`,v([`targets`,`operations`,`activity`]).withDefault(`targets`)),S;return S=e.isPending&&e.data===void 0?null:e.isError&&e.data===void 0?(0,X.jsx)(m,{message:J(e.error,`Could not load targets.`),onRetry:()=>void e.refetch(),isRetrying:e.isFetching&&!e.isPending}):t.length===0?(0,X.jsx)(dt,{titleId:`platforms-operations-empty-title`,frameIcon:(0,X.jsx)(q,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0}),description:(0,X.jsx)(lt,{}),children:(0,X.jsx)(ut,{onClick:()=>void x(`targets`)})}):(0,X.jsx)(xt,{targets:t,stream:d}),(0,X.jsxs)(`div`,{className:`mx-auto flex h-full w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Platforms`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect Platforms as targets, then apply templates or run cleanup from Operations.`}),(0,X.jsx)(tn,{targetCount:t.length,opCount:o,lastOp:i[0]})]}),(0,X.jsxs)(Le,{value:b,onValueChange:e=>{x(e)},className:`flex-1 min-h-0`,children:[(0,X.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,X.jsxs)(Fe,{variant:`line`,className:`h-10! gap-0.5 min-w-max`,children:[(0,X.jsxs)(Me,{value:`targets`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(q,{className:`size-3.5 shrink-0`}),`Targets`]}),(0,X.jsxs)(Me,{value:`operations`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Se,{className:`size-3.5 shrink-0`}),`Operations`]}),(0,X.jsxs)(Me,{value:`activity`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(I,{className:`size-3.5 shrink-0`}),`Activity`]})]})}),(0,X.jsx)(Ne,{value:`targets`,className:`flex-1 py-2`,children:(0,X.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e.isError&&e.data===void 0?(0,X.jsx)(m,{message:J(e.error,`Failed to load targets.`),onRetry:()=>void e.refetch(),isRetrying:e.isFetching&&!e.isPending}):(0,X.jsx)(Qt,{targets:t,onMutate:()=>void e.refetch(),lastOpByTarget:y,templates:u,templatesLoading:s.isPending&&s.data===void 0,templatesError:s.isError&&u.length===0,onRetryTemplates:()=>void s.refetch(),stream:d})},`targets`)}),(0,X.jsx)(Ne,{value:`operations`,className:`flex-1 py-2`,children:(0,X.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:S},`operations`)}),(0,X.jsx)(Ne,{value:`activity`,className:`flex flex-col flex-1 min-h-0 py-2`,children:(0,X.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col flex-1 min-h-0`,children:(0,X.jsx)(Wt,{operations:i,totalKnown:o,isLoading:n.isPending&&!n.data,error:n.error,onRefresh:()=>void l.invalidateQueries({queryKey:c.platforms.operationsList()}),hasNextPage:n.hasNextPage,isFetchingNextPage:n.isFetchingNextPage,loadMoreError:n.isFetchNextPageError&&n.error instanceof Error?n.error:null,onRetryLoadMore:()=>void n.fetchNextPage(),onLoadMore:()=>void n.fetchNextPage()})},`activity`)})]}),(0,X.jsx)(g,{children:d.operation||d.status===`running`?(0,X.jsx)(ft,{stream:d,onReset:d.reset,catalogTemplates:u}):null})]})}export{nn as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{S as r,at as i,o as a,ot as o,st as s,v as c,y as l}from"./api-2XqCNjt9.js";import{a as u,c as d,i as f,r as p,t as m}from"./query-fetch-error-xB4By0m0.js";import{t as h}from"./proxy-Be4WzmcS.js";import{t as g}from"./AnimatePresence-CPmH1DMY.js";import{i as _,r as v}from"./dist-xY0pK9Wy.js";import{n as y}from"./chunk-OE4NN4TA-DBWZidbW.js";import{a as b,i as x,l as S,n as C,o as w,r as ee,s as T,t as E}from"./copy-button-DnGsXbVV.js";import{C as D,S as O,T as k,d as A,h as j,o as M,w as N}from"./format-B9CcV2dj.js";import{n as P,t as F}from"./utils-XFKvwlFT.js";import{t as I}from"./activity-Cy_niK56.js";import{t as L}from"./arrow-right-BjBb4z7g.js";import{A as R,D as z,E as B,M as V,N as te,S as ne,_ as re,a as ie,b as ae,c as H,d as U,f as oe,g as se,h as ce,i as le,j as ue,k as de,l as fe,m as W,n as pe,o as me,p as he,r as ge,s as _e,t as ve,u as ye,v as be,x as xe}from"./use-platform-stream-BzqGhuJn.js";import{n as Se,t as Ce}from"./catalog-template-icons-3S8RvUxD.js";import{c as we,i as G,l as Te,n as Ee,s as De,t as Oe}from"./select-CMOnuEoT.js";import{a as ke,i as Ae,r as K}from"./platform-targets-BIQ1lKOg.js";import{c as je,i as Me,n as Ne,o as Pe,r as Fe,s as Ie,t as Le}from"./tabs-CDS57-lB.js";import{i as Re,n as q,r as ze,t as Be}from"./checkbox-C84IyqEB.js";import{t as Ve}from"./layers-1figUpjG.js";import{t as He}from"./triangle-alert-BXrJNk3g.js";import{i as Ue,n as We,t as Ge}from"./tooltip-D1ydB4g3.js";import{t as Ke}from"./badge-i00PiRCo.js";import{a as qe,i as Je,n as Ye,o as Xe,r as Ze,s as Qe,t as $e}from"./dropdown-menu-82O7jPU6.js";import{t as et}from"./label-DTHSKF2S.js";import{n as J,t as tt}from"./get-error-message-BanmV5rD.js";var nt=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:s()})}getOptimisticResult(e){return e.behavior=s(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:a,isRefetching:s,isError:c,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=a&&u===`forward`,p=c&&u===`backward`,m=a&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:i(t,n.data),hasPreviousPage:o(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function rt(e,t){return u(e,nt,t)}var it=P(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),at=P(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ot=P(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),st=P(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Y=e(t(),1),X=n(),ct=`rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/55 bg-muted/10`;function lt(){return(0,X.jsx)(`p`,{className:`mt-2 text-pretty text-sm leading-relaxed text-muted-foreground`,children:`Add a target to get started.`})}function ut({onClick:e}){return(0,X.jsxs)(D,{type:`button`,size:`sm`,className:`h-7 shrink-0 gap-1.5 text-xs`,onClick:e,children:[(0,X.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),`Add Target`]})}function dt({titleId:e,frameIcon:t,description:n,children:r}){return(0,X.jsx)(`section`,{"aria-labelledby":e,className:ct,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-4 py-10 text-center`,children:[(0,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/50`,children:t}),(0,X.jsxs)(`div`,{className:`max-w-sm`,children:[(0,X.jsx)(`h2`,{id:e,className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`No targets yet`}),n]}),r]})})}function ft({stream:e,onReset:t,catalogTemplates:n}){if(!e.operation&&e.status!==`running`)return null;let{title:r,subtitle:i}=_e(e),a=e.status===`complete`,o=e.status===`error`,s=e.status===`running`,c=a||o,l=e.cancelRequested;async function u(){await e.cancel().catch(()=>{})}return(0,X.jsx)(re,{title:r,subtitle:i,canDismiss:!s,footerAction:s&&e.operation?.operationId?(0,X.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,X.jsx)(`button`,{type:`button`,onClick:u,disabled:l,"aria-busy":l,className:F(N({variant:`outline`,size:`sm`}),`group h-8 gap-1.5 px-3 text-xs`,l?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),children:l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pe,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(h.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,X.jsx)(h.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):c?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 w-full flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,X.jsxs)(y,{to:`/platforms?tab=activity`,className:F(N({variant:`ghost`,size:`xs`}),`group inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-[11px] font-medium text-foreground/80`,`hover:bg-primary/12 hover:text-primary`),children:[(0,X.jsx)(I,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,X.jsx)(ke,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,X.jsx)(D,{type:`button`,variant:`secondary`,size:`xs`,className:`h-6 px-2.5 text-[11px] font-medium`,onClick:t,children:`Close`})})]}),e.operation?.status===`cancelled`||o&&e.operation?(0,X.jsx)(xe,{type:e.operation.type,errorMessage:e.operation.error,className:`mt-2.5 w-full min-w-0`}):null]}):void 0,onDismiss:t,children:e.operation?(0,X.jsx)(ae,{operation:e.operation,catalogTemplates:n,logs:e.logs}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Pe,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,X.jsx)(h.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})})}var pt=`miravo:platforms:recent-template-ids`,mt=8,ht=`miravo:platforms:last-target-id`;function Z(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(pt),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function gt(e){if(typeof window>`u`)return;let t=[e,...Z().filter(t=>t!==e)].slice(0,mt);try{window.localStorage.setItem(pt,JSON.stringify(t))}catch{}}function _t(){if(!(typeof window>`u`))try{return window.localStorage.getItem(ht)??void 0}catch{return}}function vt(e){if(!(typeof window>`u`))try{window.localStorage.setItem(ht,e)}catch{}}var yt=50;function bt({open:e,type:t,targetLabel:n,targetHostname:r,templates:i,templatesLoading:a,templatesError:o,onRetryTemplates:s,onOpenChange:c,onSelect:l}){let[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(Z),m=(0,Y.useDeferredValue)(u);(0,Y.useEffect)(()=>{e&&(d(``),p(Z()))},[e]);let h=(0,Y.useMemo)(()=>{let e=m.trim().toLowerCase(),t=new Map(f.map((e,t)=>[e,t])),n=[],r=new Set;for(let t of i){if(r.has(t.id))continue;r.add(t.id);let i=[t.name,t.id,t.category,t.description??``,t.models.join(` `)].join(` `).toLowerCase();e!==``&&!i.includes(e)||n.push(t)}return n.sort((e,n)=>{let r=t.get(e.id)??1/0,i=t.get(n.id)??1/0;return r===i?e.name.localeCompare(n.name):r-i}),{items:n.slice(0,yt),total:n.length,recentRank:t}},[i,m,f]),g=t===`apply`?`Apply environment`:`Cleanup environment`,_=e=>{gt(e.id),l(e)};return(0,X.jsx)(C,{open:e,onOpenChange:c,children:(0,X.jsxs)(ee,{className:`flex max-h-[82vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,X.jsx)(T,{className:`text-sm font-semibold`,children:g}),(0,X.jsxs)(x,{className:`mt-1 text-xs`,children:[n,` / `,r]})]}),(0,X.jsx)(`div`,{className:`shrink-0 border-b border-border/45 px-5 py-3`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(ue,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(O,{value:u,onChange:e=>d(e.currentTarget.value),className:`h-9 pl-8`,placeholder:`Search environments`,autoFocus:!0})]})}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:a&&i.length===0?(0,X.jsx)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`Loading environments...`}):o&&i.length===0?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--miravo-radius-tight)] border border-warning/25 bg-warning/5 px-3 py-2 text-xs text-warning`,children:[(0,X.jsx)(`span`,{children:`Could not load environments.`}),(0,X.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-warning hover:text-warning`,onClick:s,children:`Retry`})]}):h.items.length===0?(0,X.jsx)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No matching environments.`}):(0,X.jsx)(`div`,{className:`flex flex-col gap-1`,children:h.items.map(e=>{let t=h.recentRank.has(e.id);return(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left text-xs transition-colors hover:bg-muted/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70`,onClick:()=>_(e),children:[(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/35 bg-muted/25 text-primary`,children:(0,X.jsx)(Ce,{id:e.id,className:`size-3.5`})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.name}),t?(0,X.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] border border-primary/25 bg-primary/8 px-1.5 py-px font-mono text-[9px] uppercase tracking-wider text-primary`,children:`Recent`}):null]}),(0,X.jsxs)(`span`,{className:`mt-0.5 block truncate font-mono text-[11px] text-muted-foreground`,children:[e.id,` / `,e.instanceCount,` instances`]})]})]},e.id)})})}),h.total>h.items.length?(0,X.jsxs)(`div`,{className:`shrink-0 border-t border-border/45 px-5 py-2 text-[11px] text-muted-foreground`,children:[`Showing `,h.items.length,` of `,h.total,`. Refine search.`]}):null]})})}function xt({targets:e,stream:t}){let[n,i]=(0,Y.useState)(`apply`),[o,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),[ee]=(0,Y.useState)(_t),T=(0,Y.useRef)(0),E=(0,Y.useRef)(null),O=t.status===`running`,A=n===`apply`,j=f({queryKey:c.catalog.templates(),queryFn:()=>a(`/catalog/templates`,r.catalogTemplates)}),M=j.data??[],N=M.find(e=>e.id===l),P=e.find(e=>e.id===o),I=A?!!o&&!!l:!!o&&(d||!!l),L=(0,Y.useCallback)(()=>{T.current+=1,E.current?.abort(),E.current=null,y(!1),_(null)},[]);(0,Y.useEffect)(()=>{if(!(l||M.length===0||d))for(let e of Z()){let t=M.find(t=>t.id===e);if(t){u(t.id);return}}},[l,M,d]);let V=(0,Y.useCallback)(()=>{L(),S.message(`Preview cancelled`)},[L]),te=e=>{O||(i(e),L(),p(!1))},re=(0,Y.useCallback)(async(e,n)=>{if(e===`apply`){if(!o||!l)return}else if(!o||!d&&!l)return;t.operation&&t.status!==`running`&&t.reset(),E.current?.abort(),T.current+=1;let r=T.current,i=new AbortController;E.current=i,y(!0),_(null);try{let t=e===`apply`?await he(B({targetId:o,template:l,result:n}),{signal:i.signal}):await oe(z({targetId:o,template:l,allManaged:d,result:n}),{signal:i.signal});if(r!==T.current)return;_(t.plan)}catch(t){if(r!==T.current||ie(t))return;let n=J(t,e===`apply`?`Plan failed`:`Cleanup plan failed`),i=tt(t);S.error(n,i?{description:i}:void 0)}finally{r===T.current&&y(!1)}},[o,l,d,t]),ae=(0,Y.useCallback)(e=>{x(!1),L(),vt(o),l&>(l),n===`apply`?t.startApply(B({targetId:o,template:l,result:e})):t.startCleanup(z({targetId:o,template:l,allManaged:d,result:e}))},[n,o,l,d,t,L]),H=!A&&d,U=I&&!O,se=A?ze:R,ue=`Awaiting selection`;U&&(ue=A?`Review apply`:`Review cleanup`);let fe=H?`All managed resources`:N?.name??`Select environment`,W=(0,X.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0});H?W=(0,X.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}):N&&(W=(0,X.jsx)(Ce,{id:N.id,className:`size-3.5`}));let me=A?`Provisions devices, tags, and Digital Twin models from the selected environment on the selected target.`:`Removes Miravo-managed resources for this environment from the selected target.`;H&&(me=`Removes all Miravo-managed resources from the target (ignores environment scope).`);let _e=P?`${P.label} / ${fe}`:`Select target and environment`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`div`,{role:`toolbar`,"aria-label":`Operation mode`,className:`inline-flex items-center gap-0.5 rounded-[var(--miravo-radius-pill)] border border-border/50 bg-muted/15 p-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":A,className:F(`relative flex items-center gap-1.5 rounded-[var(--miravo-radius-pill)] px-4 py-1.5 text-xs font-medium transition-colors`,A?`text-primary`:`text-muted-foreground hover:text-foreground`),onClick:()=>te(`apply`),disabled:O,children:[A&&(0,X.jsx)(h.span,{layoutId:`mode-pill`,className:`absolute inset-0 rounded-[var(--miravo-radius-pill)] bg-primary/15 shadow-sm`,transition:{type:`spring`,stiffness:500,damping:40}}),(0,X.jsx)(st,{className:`relative z-10 size-3.5`}),(0,X.jsx)(`span`,{className:`relative z-10`,children:`Apply`})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!A,className:F(`relative flex items-center gap-1.5 rounded-[var(--miravo-radius-pill)] px-4 py-1.5 text-xs font-medium transition-colors`,A?`text-muted-foreground hover:text-foreground`:`text-destructive`),onClick:()=>te(`cleanup`),disabled:O,children:[!A&&(0,X.jsx)(h.span,{layoutId:`mode-pill`,className:`absolute inset-0 rounded-[var(--miravo-radius-pill)] bg-destructive/15 shadow-sm`,transition:{type:`spring`,stiffness:500,damping:40}}),(0,X.jsx)(R,{className:`relative z-10 size-3.5`}),(0,X.jsx)(`span`,{className:`relative z-10`,children:`Cleanup`})]})]}),(0,X.jsx)(pe,{stream:t})]}),(0,X.jsx)(be,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/25 pb-3`,children:[(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-primary/25 bg-primary/9 shadow-[inset_0_1px_0_0_var(--miravo-inset-highlight)]`,children:(0,X.jsx)(Ve,{className:`size-4 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground`,children:`Litmus Edge`}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-muted-foreground`,children:me})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(et,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Target`}),(0,X.jsx)(ce,{targets:e,value:o,onValueChange:e=>{s(e),vt(e),L()},preferredTargetId:ee,disabled:O,size:`sm`,className:`min-w-0 w-full text-xs`})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(et,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Environment`}),j.isError&&!j.data&&(0,X.jsx)(m,{message:J(j.error,`Failed to load environments.`),onRetry:()=>void j.refetch(),isRetrying:j.isFetching&&!j.isPending}),(0,X.jsxs)(`button`,{type:`button`,disabled:H||O||!P,onClick:()=>w(!0),className:F(`flex h-9 min-h-9 w-full min-w-0 items-center justify-between gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border border-input bg-input/30 px-2.5 py-0 text-left text-xs outline-none transition-colors select-none`,`hover:bg-input/50 focus-visible:border-primary/35 focus-visible:ring-2 focus-visible:ring-primary/22`,`disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50`),"aria-label":`Environment`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/35 bg-muted/25 text-primary`,children:W}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:fe})]}),(0,X.jsx)(Te,{className:`pointer-events-none size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})]}),(0,X.jsxs)(`button`,{type:`button`,disabled:!U||v,onClick:()=>x(!0),className:F(`group flex w-full min-h-14 min-w-0 items-stretch overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] text-left outline-none`,`transition-[border-color,box-shadow,background-color] duration-200 ease-out`,`focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:pointer-events-none disabled:opacity-55`,U?[`border-2 border-primary/40 bg-background`,`bg-linear-to-r from-primary/12 via-background to-background`,`shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025)]`,`hover:border-primary/56 hover:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025),0_0_14px_-8px_color-mix(in_srgb,var(--primary)_18%,transparent),0_0_22px_-12px_color-mix(in_srgb,var(--primary)_8%,transparent)]`]:[`border border-dashed border-border/65 bg-muted/15`,`hover:bg-muted/22`]),children:[(0,X.jsx)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:(0,X.jsx)(se,{className:F(`relative size-5`,U?`text-primary`:`text-muted-foreground`)})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-0.5 overflow-hidden px-3 py-2.5 sm:px-4`,children:[(0,X.jsx)(`span`,{className:F(`font-heading text-[11px] font-semibold uppercase tracking-[0.18em]`,U?`text-primary`:`text-muted-foreground`),children:ue}),(0,X.jsx)(`span`,{className:F(`truncate font-mono text-[13px] leading-tight tracking-tight`,U?`text-foreground`:`text-muted-foreground`),children:_e})]}),(0,X.jsx)(`span`,{className:F(`flex shrink-0 items-center pr-2.5 sm:pr-3`,U&&`pl-1`),children:(0,X.jsx)(`span`,{className:F(`flex size-9 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border bg-transparent transition-[border-color,color] duration-200`,U?`border-primary/40 text-primary group-hover:border-primary/55`:`border-border/45 text-muted-foreground`),"aria-hidden":!0,children:(0,X.jsx)(ke,{className:`size-4`,strokeWidth:2.25})})})]}),!A&&(0,X.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-end gap-2`,children:(0,X.jsxs)(et,{id:`all-managed-label`,htmlFor:`all-managed`,"aria-disabled":O,className:F(`inline-flex h-8 w-fit max-w-full cursor-pointer items-center gap-2 text-xs font-medium leading-none`,O&&`pointer-events-none opacity-40`),children:[(0,X.jsx)(Be,{id:`all-managed`,checked:d,onCheckedChange:e=>{p(e===!0),L()},disabled:O}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Remove all Miravo managed resources`})]})})]})}),(v||g)&&!O&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v&&(0,X.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-end gap-2`,children:(0,X.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:V,children:[(0,X.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),`Cancel preview`]})}),v&&(0,X.jsx)(le,{}),g&&!v&&(0,X.jsx)(ge,{plan:g,planKind:A?`apply`:`cleanup`,onCloseTable:L})]}),P&&C?(0,X.jsx)(bt,{open:!0,type:n,targetLabel:P.label,targetHostname:P.hostname,templates:M,templatesLoading:j.isPending&&j.data===void 0,templatesError:j.isError&&M.length===0,onRetryTemplates:()=>void j.refetch(),onOpenChange:w,onSelect:e=>{u(e.id),gt(e.id),p(!1),L(),A&&t.reset(),w(!1)}}):null,P&&(0,X.jsx)(ne,{open:b,onOpenChange:x,type:n,label:H?`All managed resources`:N?.name??l,targetLabel:P.label,hostname:P.hostname,sourceHostname:P.sourceHostname,onConfirm:ae,defaultNamePrefix:A?l:void 0,metadata:de,applyPreview:A?{onPreview:e=>void re(`apply`,e),planLoading:v,disabled:!o||!l||O}:void 0,cleanupPreview:A?void 0:{onPreview:e=>void re(`cleanup`,e),planLoading:v,disabled:!o||!d&&!l||O}})]})}function St(){return(0,X.jsx)(`section`,{"aria-labelledby":`platforms-operation-log-empty-title`,className:ct,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-4 py-8 text-center sm:py-10`,children:[(0,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/50`,children:(0,X.jsx)(I,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`max-w-sm`,children:[(0,X.jsx)(`h2`,{id:`platforms-operation-log-empty-title`,className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`No operations yet`}),(0,X.jsx)(`p`,{className:`mt-2 text-pretty text-sm leading-relaxed text-muted-foreground`,children:`Run apply or cleanup from the Operations tab. Finished runs show up here with full detail.`})]})]})})}function Ct(e){let t=new Date(e),n=new Date,r=new Date(n);return r.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?`Today`:t.toDateString()===r.toDateString()?`Yesterday`:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`})}function wt(e){let t=new Map;for(let n of e){let e=new Date(n.completedAt).toDateString(),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([,e])=>({label:Ct(e[0]?.completedAt??Date.now()),ops:e}))}function Tt(e,t){return e===`device`?t.operationType===`apply`?`Tag/register writes per device step—not a device count.`:`One count per device removed from DeviceHub.`:e===`model`?`One count per model in this run.`:e===`instance`?`One count per twin instance in this run.`:`Sets the device parameter to the bound DeviceHub device.`}var Et={devices:`Devices`,models:`DT models`,instances:`DT instances`},Q={create:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-success/35 bg-success/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-success`,update:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-primary/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-primary`,replace:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-chart-2/35 bg-chart-2/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-chart-2`,delete:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/35 bg-destructive/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-destructive`,noop:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-border/55 bg-muted/55 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-foreground/78`,failed:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/18 px-1.5 py-0.5 font-mono text-[10px] font-semibold tabular-nums text-destructive`};function Dt(e){return[{key:`device`,title:`DeviceHub — protocol tags`,subtitle:Tt(`device`,e),counts:e.resourceCounts.device},{key:`model`,title:`Digital Twin models`,subtitle:Tt(`model`,e),counts:e.resourceCounts.model},{key:`instance`,title:`Twin instances`,subtitle:Tt(`instance`,e),counts:e.resourceCounts.instance},{key:`param-sync`,title:`Parameter sync`,subtitle:Tt(`param-sync`,e),counts:e.resourceCounts[`param-sync`]}].filter(e=>e.counts.total>0||e.counts.failed>0)}function Ot(e){return e.length===0?`Default (devices, models, instances)`:e.map(e=>Et[e]??e).join(` · `)}function kt(e){let t=[];return e.filters.area&&t.push(`Area ${e.filters.area}`),e.filters.line&&t.push(`Line ${e.filters.line}`),e.filters.instance&&t.push(`Instance ${e.filters.instance}`),t.length>0?t.join(` · `):null}function $(e,t,n){if(e===`device`)switch(t){case`create`:return`+${n} tags (new device)`;case`update`:return`${n} tags rewritten`;case`replace`:return`↻${n} tags (device replaced)`;case`delete`:return`−${n} removed`;case`noop`:return`=${n} unchanged`}switch(t){case`create`:return`+${n} created`;case`update`:return`${n} updated`;case`replace`:return`↻${n} replaced`;case`delete`:return`−${n} removed`;case`noop`:return`=${n} unchanged`}}function At({row:e}){let{key:t,counts:n}=e;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1.5`,children:[n.create>0&&(0,X.jsx)(`span`,{className:Q.create,children:$(t,`create`,n.create)}),n.update>0&&(0,X.jsx)(`span`,{className:Q.update,children:$(t,`update`,n.update)}),n.replace>0&&(0,X.jsx)(`span`,{className:Q.replace,children:$(t,`replace`,n.replace)}),n.delete>0&&(0,X.jsx)(`span`,{className:Q.delete,children:$(t,`delete`,n.delete)}),n.noop>0&&(0,X.jsx)(`span`,{className:Q.noop,children:$(t,`noop`,n.noop)}),n.failed>0&&(0,X.jsx)(`span`,{className:Q.failed,children:`${n.failed} failed`})]})}function jt(e){return e.resourceCounts.device.noop+e.resourceCounts.model.noop+e.resourceCounts.instance.noop+e.resourceCounts[`param-sync`].noop}function Mt({op:e}){let t=kt(e),n=jt(e);return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 bg-muted/25 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.16em] text-foreground/72`,children:`Run context`}),(0,X.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[minmax(0,7.5rem)_1fr] gap-x-3 gap-y-1.5 text-xs sm:grid-cols-[9rem_1fr]`,children:[(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Operation`}),(0,X.jsx)(`dd`,{className:`font-medium capitalize text-foreground`,children:e.operationType}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Target host`}),(0,X.jsx)(`dd`,{className:`break-all font-mono text-[11px] text-foreground`,children:e.hostname}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Scope`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:Ot(e.scope)}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Filters`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:t})]}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Duration`}),(0,X.jsxs)(`dd`,{className:`tabular-nums text-foreground`,children:[(e.durationMs/1e3).toFixed(1),`s`]}),(0,X.jsx)(`dt`,{className:`text-foreground/70`,children:`Outcome`}),(0,X.jsxs)(`dd`,{className:`text-foreground`,children:[(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.successCount}),` steps succeeded`,n>0&&(0,X.jsxs)(`span`,{className:`text-foreground/72`,children:[` `,`· `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:n}),` unchanged`]}),e.failedCount>0&&(0,X.jsxs)(`span`,{className:`text-destructive`,children:[` `,`· `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.failedCount}),` failed`]}),e.blockedCount>0&&(0,X.jsxs)(`span`,{className:`text-warning`,children:[` `,`· `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.blockedCount}),` blocked in plan`]})]})]})]})}function Nt({status:e}){switch(e){case`success`:return(0,X.jsx)(je,{className:`mt-px size-4 shrink-0 text-success`});case`failed`:return(0,X.jsx)(Ie,{className:`mt-px size-4 shrink-0 text-destructive`});case`partial`:case`blocked`:return(0,X.jsx)(He,{className:`mt-px size-4 shrink-0 text-warning`});case`noop`:return(0,X.jsx)(it,{className:`mt-px size-4 shrink-0 text-foreground/55`})}}function Pt(e){let t=e.operationType===`apply`?`Applied`:`Cleaned up`,n=`${(e.durationMs/1e3).toFixed(1)}s`,r=[];e.successCount>0&&r.push(`${e.successCount} resources`);let i=jt(e);return i>0&&r.push(`${i} unchanged`),e.failedCount>0&&r.push(`${e.failedCount} failed`),e.blockedCount>0&&r.push(`${e.blockedCount} blocked`),r.length===0?`${t} · no changes · ${n}`:`${t} · ${r.join(`, `)} · ${n}`}function Ft(e){return e.operationType===`cleanup`&&e.successCount===0&&e.failedCount===0&&e.blockedCount===0?`No Miravo-managed resources were found to clean up.`:e.failedCount>0&&e.blockedCount>0?`No per-phase counts — failures and blocked plan entries.`:e.failedCount>0?`No per-phase counts — run failed.`:e.blockedCount>0?`No per-phase counts — blocked plan entries.`:jt(e)>0?`No resources were mutated. Existing managed resources already matched the desired state.`:`No per-phase counts recorded.`}function It({op:e}){let t=Dt(e);return t.length===0?(0,X.jsx)(`p`,{className:`py-1 text-sm text-foreground/75`,children:Ft(e)}):(0,X.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,X.jsx)(`div`,{className:`flex flex-col divide-y divide-border/45 rounded-[var(--miravo-radius-tight)] border border-border/50`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2.5 sm:flex-row sm:items-start sm:gap-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 shrink-0 sm:w-[11.5rem]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium leading-snug text-foreground`,children:e.title}),(0,X.jsxs)(Ge,{children:[(0,X.jsx)(Ue,{type:`button`,className:`inline-flex shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] p-0.5 text-foreground/60 hover:bg-muted/50 hover:text-foreground`,"aria-label":`About ${e.title}`,children:(0,X.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(We,{side:`top`,className:`max-w-xs text-left`,children:e.subtitle})]})]}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-foreground/72 sm:hidden`,children:e.subtitle})]}),(0,X.jsx)(At,{row:e})]},e.key))}),e.blockedCount>0&&(0,X.jsxs)(`p`,{className:`rounded-[var(--miravo-radius-tight)] border border-warning/20 bg-warning/5 px-2.5 py-1.5 text-[11px] text-warning`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.blockedCount}),` plan entries were blocked (skipped). Open a `,(0,X.jsx)(`span`,{className:`font-medium`,children:`deploy preview`}),` before running to see block reasons.`]})]})}function Lt({operation:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:F(`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/55`,`transition-colors duration-150`),children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:F(`flex w-full items-start gap-3 p-3.5 text-left`,`transition-colors duration-100`,`hover:bg-muted/25`,t&&`bg-muted/18`),children:[(0,X.jsx)(Nt,{status:e.status}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 truncate text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:A(e.templateId)}),(0,X.jsx)(`span`,{className:`mx-1.5 text-foreground/50`,children:`→`}),(0,X.jsx)(`span`,{className:`text-foreground/82`,children:e.targetLabel})]}),(0,X.jsx)(`time`,{dateTime:new Date(e.completedAt).toISOString(),title:M(e.completedAt),className:`shrink-0 text-xs text-foreground/75`,children:j(e.completedAt)})]}),(0,X.jsx)(`p`,{className:`text-xs text-foreground/78`,children:Pt(e)}),(e.failedCount>0||e.status===`failed`)&&(0,X.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/72`,children:e.error??`The operation ended with an error.`})]}),(0,X.jsx)(Te,{className:F(`mt-0.5 size-3.5 shrink-0 text-foreground/55 transition-transform duration-150`,t&&`rotate-180`)})]}),(0,X.jsx)(g,{initial:!1,children:t&&(0,X.jsx)(h.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`space-y-3 border-t border-border/45 px-4 pb-3 pt-3`,children:[(0,X.jsx)(Mt,{op:e}),e.error&&(0,X.jsxs)(`div`,{className:`relative rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/15 px-3 py-2 pr-10 text-xs font-medium`,children:[(0,X.jsx)(`div`,{className:`absolute top-1.5 right-1.5 z-10`,children:(0,X.jsx)(E,{value:e.error,label:`Copy error`,className:`text-destructive hover:bg-destructive/25 hover:text-foreground`})}),(0,X.jsx)(`p`,{className:`whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error})]}),(0,X.jsx)(It,{op:e})]})})})]})}function Rt({label:e}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border/65`}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-foreground/78`,children:e}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border/65`})]})}var zt={type:``,status:``,target:``,search:``},Bt={_all:`All types`,apply:`Apply`,cleanup:`Cleanup`},Vt={_all:`All statuses`,success:`Success`,partial:`Partial`,failed:`Failed`,blocked:`Blocked`,noop:`No-op`},Ht=`h-7 min-h-7 gap-1.5 border-border/50 bg-transparent px-2 text-xs hover:bg-muted/30 focus:ring-0`;function Ut({filters:e,targetOptions:t,hasFilters:n,searchRef:r,onTypeChange:i,onStatusChange:a,onTargetChange:o,onSearchChange:s,onClear:c}){return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border/50 px-3 py-2`,children:[(0,X.jsxs)(Oe,{value:e.type||`_all`,onValueChange:e=>e&&i(e===`_all`?``:e),children:[(0,X.jsx)(De,{size:`sm`,className:Ht,"aria-label":`Operation type`,children:(0,X.jsx)(we,{children:e=>Bt[e??`_all`]??Bt._all})}),(0,X.jsxs)(Ee,{children:[(0,X.jsx)(G,{value:`_all`,children:`All types`}),(0,X.jsx)(G,{value:`apply`,children:`Apply`}),(0,X.jsx)(G,{value:`cleanup`,children:`Cleanup`})]})]}),(0,X.jsxs)(Oe,{value:e.status||`_all`,onValueChange:e=>e&&a(e===`_all`?``:e),children:[(0,X.jsx)(De,{size:`sm`,className:Ht,"aria-label":`Operation status`,children:(0,X.jsx)(we,{children:e=>Vt[e??`_all`]??Vt._all})}),(0,X.jsxs)(Ee,{children:[(0,X.jsx)(G,{value:`_all`,children:`All statuses`}),(0,X.jsx)(G,{value:`success`,children:`Success`}),(0,X.jsx)(G,{value:`partial`,children:`Partial`}),(0,X.jsx)(G,{value:`failed`,children:`Failed`}),(0,X.jsx)(G,{value:`blocked`,children:`Blocked`}),(0,X.jsx)(G,{value:`noop`,children:`No-op`})]})]}),t.length>1&&(0,X.jsxs)(Oe,{value:e.target||`_all`,onValueChange:e=>e&&o(e===`_all`?``:e),children:[(0,X.jsx)(De,{size:`sm`,className:Ht,"aria-label":`Target filter`,children:(0,X.jsx)(we,{children:e=>!e||e===`_all`?`All targets`:e})}),(0,X.jsxs)(Ee,{children:[(0,X.jsx)(G,{value:`_all`,children:`All targets`}),t.map(e=>(0,X.jsx)(G,{value:e,children:e},e))]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-w-[140px] flex-1 items-center`,children:[(0,X.jsx)(`input`,{ref:r,type:`search`,value:e.search,onChange:e=>s(e.target.value),placeholder:`Search environment or target…`,"aria-describedby":`ops-search-shortcut`,className:F(`h-7 w-full rounded-[var(--miravo-radius-tight)] border border-border/50 bg-transparent pl-2 pr-7 text-xs`,`placeholder:text-foreground/60 focus:outline-none focus:ring-1 focus:ring-ring/40`,e.search&&`pr-2`)}),(0,X.jsx)(`span`,{id:`ops-search-shortcut`,className:`sr-only`,children:`Press slash to focus search`}),!e.search&&(0,X.jsx)(`kbd`,{"aria-hidden":!0,className:`pointer-events-none absolute right-2 flex h-4 items-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/50 px-1 font-mono text-[10px] text-foreground/65`,children:`/`})]}),n&&(0,X.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-7 items-center gap-1 rounded-[var(--miravo-radius-tight)] px-2 text-xs text-foreground/72 transition-colors hover:bg-muted/40 hover:text-foreground`,children:[(0,X.jsx)(k,{className:`size-3`}),`Clear`]})]})}function Wt({operations:e,totalKnown:t,isLoading:n,error:r,onRefresh:i,hasNextPage:a=!1,isFetchingNextPage:o=!1,loadMoreError:s=null,onRetryLoadMore:c,onLoadMore:l}){let[u,d]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(zt),_=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),_.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let v=()=>{d(!0),i(),S.success(`Operations refreshed`),setTimeout(()=>d(!1),600)},y=(0,Y.useMemo)(()=>{let t=new Set;for(let n of e){let e=n.targetLabel;t.add(e)}return[...t].sort()},[e]),b=(0,Y.useMemo)(()=>{let t=e;if(f.type&&(t=t.filter(e=>e.operationType===f.type)),f.status&&(t=t.filter(e=>e.status===f.status)),f.target&&(t=t.filter(e=>e.targetLabel===f.target)),f.search){let e=f.search.toLowerCase();t=t.filter(t=>{let n=t.targetLabel;return t.templateId.toLowerCase().includes(e)||A(t.templateId).toLowerCase().includes(e)||n.toLowerCase().includes(e)})}return t},[e,f]),x=f.type!==``||f.status!==``||f.target!==``||f.search!==``,C=(0,Y.useMemo)(()=>wt(b),[b]);return(0,X.jsxs)(`div`,{className:`flex h-full flex-col rounded-[var(--miravo-radius-stadium-sm)] border border-border/55`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3.5 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Operation log`}),e.length>0&&(0,X.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-foreground/75`,children:typeof t==`number`&&t>0&&e.length<t?`${e.length} / ${t}`:String(e.length)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:v,disabled:u,"aria-label":`Refresh operation list`,className:`relative rounded-[var(--miravo-radius-tight)] p-1 text-foreground/70 transition-colors before:absolute before:inset-[-10px] before:content-[''] hover:bg-muted/50 hover:text-foreground disabled:pointer-events-none`,children:(0,X.jsx)(p,{className:F(`size-3.5`,u&&`animate-spin`),"aria-hidden":!0})})]}),(0,X.jsx)(Ut,{filters:f,targetOptions:y,hasFilters:x,searchRef:_,onTypeChange:e=>m(t=>({...t,type:e})),onStatusChange:e=>m(t=>({...t,status:e})),onTargetChange:e=>m(t=>({...t,target:e})),onSearchChange:e=>m(t=>({...t,search:e})),onClear:()=>m(zt)}),(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto overscroll-y-contain p-3`,children:[r&&(0,X.jsxs)(`p`,{className:`py-2 text-xs text-destructive`,children:[`✕ `,r.message]}),n&&e.length===0&&!r&&(0,X.jsx)(`p`,{className:`py-4 text-sm text-foreground/75`,children:`Loading…`}),!n&&e.length===0&&!r&&(0,X.jsx)(St,{}),!n&&e.length>0&&b.length===0&&(0,X.jsxs)(`p`,{className:`py-6 text-center text-sm text-foreground/75`,children:[`No operations match your filters.`,` `,(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(zt),className:`text-primary hover:underline`,children:`Clear filters`})]}),x&&b.length>0&&b.length!==e.length&&(0,X.jsxs)(`p`,{className:`text-xs text-foreground/75`,children:[`Showing`,` `,(0,X.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:b.length}),` of`,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.length}),` loaded`]}),!x&&typeof t==`number`&&t>0&&e.length<t&&(0,X.jsxs)(`p`,{className:`text-xs text-foreground/75`,children:[`Showing`,` `,(0,X.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:e.length}),` `,`of `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:t}),`. Load more for older entries.`]}),(0,X.jsx)(g,{initial:!1,children:C.map(e=>(0,X.jsxs)(h.div,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(Rt,{label:e.label}),(0,X.jsx)(g,{initial:!1,children:e.ops.map(e=>(0,X.jsx)(h.div,{initial:b.length>40?!1:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{type:`spring`,stiffness:400,damping:35},children:(0,X.jsx)(Lt,{operation:e})},`${e.operationId}-${e.completedAt}`))})]},e.label))}),s?(0,X.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-col items-center gap-2 border-t border-border/50 pt-3 pb-1 text-center`,children:[(0,X.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Could not load older entries: `,s.message]}),c?(0,X.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:`Retry`}):null]}):a&&l?(0,X.jsx)(`div`,{className:`flex shrink-0 justify-center border-t border-border/50 pt-3 pb-1`,children:(0,X.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`min-w-[7rem]`,disabled:o,"aria-busy":o,"aria-label":o?`Loading older operations`:`Load older operations`,onClick:l,children:o?`Loading…`:`Load more`})}):null]})]})}function Gt({target:e,templates:t,templatesLoading:n,templatesError:r,isStreaming:i,onRetryTemplates:a,onSelect:o}){let s=t.length===0&&!n&&!r,[c,l]=(0,Y.useState)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute right-3 top-3 z-20`,children:(0,X.jsxs)($e,{children:[(0,X.jsx)(Qe,{render:(0,X.jsx)(D,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:i,className:`border border-border/45 bg-background/70 text-muted-foreground shadow-[inset_0_1px_0_0_var(--miravo-inset-highlight)] hover:border-primary/30 hover:bg-muted/55 hover:text-foreground`,"aria-label":`Open quick actions for ${e.label}`}),children:(0,X.jsx)(at,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(Ye,{align:`end`,sideOffset:6,className:`min-w-56`,children:(0,X.jsxs)(Ze,{children:[(0,X.jsx)(qe,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Quick actions`}),(0,X.jsx)(Xe,{className:`bg-border/60`}),(0,X.jsxs)(Je,{disabled:s,className:`h-9 gap-2 text-xs`,onClick:()=>l(`apply`),children:[(0,X.jsx)(ze,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Apply environment...`})]}),(0,X.jsxs)(Je,{disabled:s,className:`h-9 gap-2 text-xs`,onClick:()=>l(`cleanup`),children:[(0,X.jsx)(R,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Cleanup environment...`})]}),(0,X.jsx)(Xe,{className:`bg-border/60`}),(0,X.jsxs)(Je,{variant:`destructive`,className:`h-9 gap-2 text-xs`,onClick:()=>o({type:`cleanup`,target:e,allManaged:!0}),children:[(0,X.jsx)(R,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Cleanup all managed`})]})]})})]})}),c?(0,X.jsx)(bt,{open:!0,type:c,targetLabel:e.label,targetHostname:e.hostname,templates:t,templatesLoading:n,templatesError:r,onRetryTemplates:a,onOpenChange:e=>{e||l(null)},onSelect:t=>{o({type:c,target:e,templateId:t.id}),l(null)}},c):null]})}function Kt({selection:e,templates:t,stream:n,onSelectionChange:r}){let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(0),d=(0,Y.useRef)(null),f=(0,Y.useRef)(!1),p=n.status===`running`,m=(0,Y.useCallback)(()=>{u.current+=1,f.current=!1,d.current?.abort(),d.current=null,l(!1),s(null)},[]);(0,Y.useEffect)(()=>{e&&(m(),a(!0))},[e,m]),(0,Y.useEffect)(()=>()=>{u.current+=1,f.current=!1,d.current?.abort(),d.current=null},[]);let h=e?.templateId==null?void 0:t.find(t=>t.id===e.templateId)?.name??e.templateId,g=e?.type===`cleanup`&&e.allManaged?`All managed resources`:h??``,_=(0,Y.useCallback)(async t=>{if(!e)return;let r=e.templateId;if(e.type===`apply`&&!r||e.type===`cleanup`&&!e.allManaged&&!r)return;n.operation&&n.status!==`running`&&n.reset(),f.current=!0,d.current?.abort(),u.current+=1;let i=u.current,a=new AbortController;d.current=a,l(!0),s(null);try{let n;if(e.type===`apply`){if(!r)return;n=await he(B({targetId:e.target.id,template:r,result:t}),{signal:a.signal})}else n=await oe(z({targetId:e.target.id,template:r,allManaged:e.allManaged,result:t}),{signal:a.signal});if(i!==u.current)return;s(n.plan)}catch(t){if(i!==u.current||ie(t))return;let n=J(t,e.type===`apply`?`Plan failed`:`Cleanup plan failed`),r=tt(t);S.error(n,r?{description:r}:void 0)}finally{i===u.current&&(l(!1),f.current=!1)}},[e,n]),v=(0,Y.useCallback)(t=>{if(e){if(a(!1),m(),r(null),e.type===`apply`){if(!e.templateId)return;n.startApply(B({targetId:e.target.id,template:e.templateId,result:t}));return}n.startCleanup(z({targetId:e.target.id,template:e.templateId,allManaged:e.allManaged,result:t}))}},[e,n,m,r]),y=e=>{a(e),!(e||f.current)&&(m(),r(null))},b=()=>{m(),r(null)};return(0,X.jsxs)(X.Fragment,{children:[e&&(0,X.jsx)(ne,{open:i,onOpenChange:y,type:e.type,label:g,targetLabel:e.target.label,hostname:e.target.hostname,sourceHostname:e.target.sourceHostname,onConfirm:v,defaultNamePrefix:e.type===`apply`?e.templateId:void 0,metadata:de,applyPreview:e.type===`apply`?{onPreview:e=>void _(e),planLoading:c,disabled:!e.templateId||p}:void 0,cleanupPreview:e.type===`cleanup`?{onPreview:e=>void _(e),planLoading:c,disabled:!e.allManaged&&!e.templateId||p}:void 0}),(c||o)&&!p&&e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,X.jsx)(te,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`Preview for `,e.target.label,`: `,g]})]}),(0,X.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:b,children:[(0,X.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),`Close preview`]})]}),c?(0,X.jsx)(le,{}):o?(0,X.jsx)(ge,{plan:o,planKind:e.type,onCloseTable:b}):null]}):null]})}function qt(e){return Ae.find(t=>t.id===e)?.label??e}function Jt(e){if(!e)return`var(--tooltip-border)`;switch(e.status){case`success`:return`var(--success)`;case`partial`:case`blocked`:return`var(--warning)`;case`noop`:return`var(--muted-foreground)`;case`failed`:return`var(--destructive)`}}function Yt({status:e}){switch(e){case`success`:return(0,X.jsx)(je,{className:`size-3 text-success`});case`partial`:case`blocked`:return(0,X.jsx)(He,{className:`size-3 text-warning`});case`noop`:return(0,X.jsx)(it,{className:`size-3 text-muted-foreground`});case`failed`:return(0,X.jsx)(Ie,{className:`size-3 text-destructive`})}}function Xt({target:e,lastOp:t,onEdit:n,onDelete:r,quickActions:i}){return(0,X.jsxs)(`div`,{className:`env-orbital relative overflow-hidden border`,style:{"--_status":Jt(t)},children:[i,(0,X.jsx)(`div`,{className:`relative z-10 px-4 pt-3.5 pb-3 pr-12`,children:(0,X.jsx)(`p`,{className:`font-heading text-[13px] font-semibold leading-tight tracking-tight text-foreground`,children:e.label})}),(0,X.jsx)(`div`,{className:`relative z-10 px-4 py-0.5`,children:(0,X.jsx)(`p`,{className:`font-mono text-xs tracking-tight text-muted-foreground`,children:e.hostname})}),(0,X.jsxs)(`div`,{className:`relative z-10 mx-4 mb-3 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,children:e.sourceHostname}),(0,X.jsx)(`div`,{className:`env-orbital-path min-w-6 flex-1`}),(0,X.jsx)(L,{className:`size-3 shrink-0 text-muted-foreground`})]}),(0,X.jsxs)(`div`,{className:`relative z-10 flex items-center gap-2 border-t border-border/30 px-3 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border/40 px-2 py-0.5`,children:[(0,X.jsx)(`span`,{className:`protocol-card-live-dot size-[5px]`}),(0,X.jsx)(`span`,{className:`text-[11px] font-medium tracking-wide text-muted-foreground`,children:qt(e.platformId)})]}),t&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 truncate text-[11px] text-muted-foreground`,children:[(0,X.jsx)(Yt,{status:t.status}),t.operationType===`apply`?`Applied`:`Cleaned`,` `,(0,X.jsx)(`time`,{dateTime:new Date(t.completedAt).toISOString(),title:M(t.completedAt),children:j(t.completedAt)})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(D,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit target`,onClick:n,children:(0,X.jsx)(ot,{className:`size-3`})}),(0,X.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete target`,onClick:r,children:(0,X.jsx)(R,{className:`size-3`})})]})]})]})}function Zt({onClick:e}){return(0,X.jsxs)(`button`,{type:`button`,onClick:e,className:`env-orbital group h-full w-full flex flex-col items-center justify-center gap-2 border border-dashed py-10 text-muted-foreground transition-colors hover:border-primary/30 hover:text-primary`,style:{"--_status":`var(--tooltip-border)`},children:[(0,X.jsx)(V,{className:`size-5 transition-transform group-hover:scale-110`}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Add Target`})]})}function Qt({targets:e,onMutate:t,lastOpByTarget:n,templates:r,templatesLoading:i,templatesError:a,onRetryTemplates:o,stream:s}){let[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(K.id),[m,_]=(0,Y.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[v,y]=(0,Y.useState)(!1),[E,O]=(0,Y.useState)(!1),{testing:k,runTest:A,cancelInFlight:j}=me(),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),I=s.status===`running`,L=f===K.id&&m.hostname.trim().length>0&&m.sourceHostname.trim().length>0&&(u!==null||m.apiToken.trim().length>0),R=()=>{d(null),p(K.id),_({label:``,hostname:``,apiToken:``,sourceHostname:``}),O(!1),l(!0)},z=e=>{d(e.id),p(Ae.some(t=>t.id===e.platformId)?e.platformId:K.id),_({label:e.label,hostname:e.hostname,apiToken:``,sourceHostname:e.sourceHostname}),O(!1),l(!0)},B=async()=>{if(f!==K.id){S.error(`${qt(f)} target setup is coming soon.`);return}if(!m.label||!m.hostname||!m.sourceHostname){S.error(`Label, hostname, and source host are required.`);return}if(!u&&!m.apiToken){S.error(`API token is required for new targets.`);return}y(!0);try{u?(await W(u,{platformId:f,label:m.label,hostname:m.hostname,sourceHostname:m.sourceHostname,...m.apiToken?{apiToken:m.apiToken}:{}}),S.success(`Target updated.`)):(await H({...m,platformId:f}),S.success(`Target added.`)),l(!1),t()}catch(e){S.error(J(e,`Failed to save target.`))}finally{y(!1)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`flex h-5 items-center text-xs font-medium leading-none uppercase tracking-wider text-muted-foreground`,children:`Platform Targets`}),e.length>0?(0,X.jsx)(Ke,{variant:`secondary`,className:`relative -top-px h-5 shrink-0 px-1.5 py-0 font-mono text-[10px] leading-none tabular-nums`,children:e.length}):null]}),(0,X.jsxs)(D,{size:`sm`,className:`h-7 shrink-0 gap-1.5 text-xs`,onClick:R,children:[(0,X.jsx)(V,{className:`size-3.5`}),` Add Target`]})]}),e.length===0?(0,X.jsx)(dt,{titleId:`platforms-targets-empty-title`,frameIcon:(0,X.jsx)(q,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0}),description:(0,X.jsx)(lt,{}),children:(0,X.jsx)(ut,{onClick:R})}):(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-3 @2xl/main:grid-cols-2 @5xl/main:grid-cols-3`,children:(0,X.jsxs)(g,{children:[e.map((e,t)=>(0,X.jsx)(h.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},children:(0,X.jsx)(Xt,{target:e,lastOp:n.get(e.id),onEdit:()=>z(e),onDelete:()=>N(e),quickActions:(0,X.jsx)(Gt,{target:e,templates:r,templatesLoading:i,templatesError:a,isStreaming:I,onRetryTemplates:o,onSelect:F})})},e.id)),(0,X.jsx)(h.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:380,damping:30,delay:e.length*.04},children:(0,X.jsx)(Zt,{onClick:R})},`add-card`)]})}),(0,X.jsx)(Kt,{selection:P,templates:r,stream:s,onSelectionChange:F}),(0,X.jsx)(se,{open:c,editing:u!==null,platformId:f,form:m,showToken:E,saving:v,testing:k,canTestConnection:L,onOpenChange:l,onPlatformChange:p,onFormChange:_,onShowTokenChange:O,onSave:()=>void B(),onTestConnection:()=>{L&&A({...u?{targetId:u}:{},hostname:m.hostname.trim(),sourceHostname:m.sourceHostname.trim(),...m.apiToken.trim()?{apiToken:m.apiToken.trim()}:{}})},onCancelInFlight:j}),(0,X.jsx)(C,{open:M!==null,onOpenChange:e=>!e&&N(null),children:(0,X.jsxs)(ee,{children:[(0,X.jsxs)(w,{children:[(0,X.jsx)(T,{children:`Remove Target`}),(0,X.jsxs)(x,{children:[`Remove “`,M?.label,`”? This only deletes the saved credentials — it does not affect resources on the target platform.`]})]}),(0,X.jsxs)(b,{children:[(0,X.jsx)(D,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,X.jsx)(D,{variant:`destructive`,onClick:async()=>{if(!M)return;let e=M.id;N(null);try{await fe(e),S.success(`Target removed.`),t()}catch(e){S.error(J(e,`Failed to remove target.`))}},children:`Remove`})]})]})})]})}var $t=25;function en({status:e}){switch(e){case`success`:return(0,X.jsx)(je,{className:`size-3 text-success`});case`partial`:case`blocked`:return(0,X.jsx)(He,{className:`size-3 text-warning`});case`noop`:return(0,X.jsx)(it,{className:`size-3 text-muted-foreground`});case`failed`:return(0,X.jsx)(Ie,{className:`size-3 text-destructive`})}}function tn({targetCount:e,opCount:t,lastOp:n}){return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(q,{className:`size-3`}),(0,X.jsx)(`span`,{className:`font-mono`,children:e}),` target`,e===1?``:`s`]}),(0,X.jsx)(`span`,{className:`hidden h-3 w-px bg-border/40 sm:inline-block`}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(g,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(h.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`font-mono tabular-nums`,children:t},t)}),` `,`operation`,t===1?``:`s`]}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`hidden h-3 w-px bg-border/40 sm:inline-block`}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(en,{status:n.status}),(0,X.jsxs)(`span`,{children:[n.operationType===`apply`?`Applied`:`Cleaned`,` `,(0,X.jsx)(`time`,{dateTime:new Date(n.completedAt).toISOString(),title:M(n.completedAt),children:j(n.completedAt)})]})]})]})]})}function nn(){let e=f({queryKey:c.platforms.targets(),queryFn:()=>U()}),t=e.data??[],n=rt({queryKey:c.platforms.operationsList(),queryFn:({pageParam:e})=>ye({limit:$t,offset:e}),initialPageParam:0,getNextPageParam:(e,t,n)=>e.hasMore&&e.operations.length>0?n+$t:void 0}),i=(0,Y.useMemo)(()=>n.data?.pages.flatMap(e=>e.operations)??[],[n.data]),o=n.data?.pages[0]?.total??0,s=f({queryKey:c.catalog.templates(),queryFn:()=>a(`/catalog/templates`,r.catalogTemplates)}),u=s.data??[],d=ve(),p=(0,Y.useRef)(d.status);(0,Y.useEffect)(()=>{let e=p.current;p.current=d.status,e===`running`&&d.status===`complete`&&l.invalidateQueries({queryKey:c.platforms.operationsList()})},[d.status]);let y=(0,Y.useMemo)(()=>{let e=new Map;for(let t of i)e.has(t.targetId)||e.set(t.targetId,t);return e},[i]),[b,x]=_(`tab`,v([`targets`,`operations`,`activity`]).withDefault(`targets`)),S;return S=e.isPending&&e.data===void 0?null:e.isError&&e.data===void 0?(0,X.jsx)(m,{message:J(e.error,`Could not load targets.`),onRetry:()=>void e.refetch(),isRetrying:e.isFetching&&!e.isPending}):t.length===0?(0,X.jsx)(dt,{titleId:`platforms-operations-empty-title`,frameIcon:(0,X.jsx)(q,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0}),description:(0,X.jsx)(lt,{}),children:(0,X.jsx)(ut,{onClick:()=>void x(`targets`)})}):(0,X.jsx)(xt,{targets:t,stream:d}),(0,X.jsxs)(`div`,{className:`mx-auto flex h-full w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Platforms`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect Platforms as targets, then apply templates or run cleanup from Operations.`}),(0,X.jsx)(tn,{targetCount:t.length,opCount:o,lastOp:i[0]})]}),(0,X.jsxs)(Le,{value:b,onValueChange:e=>{x(e)},className:`flex-1 min-h-0`,children:[(0,X.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,X.jsxs)(Fe,{variant:`line`,className:`h-10! gap-0.5 min-w-max`,children:[(0,X.jsxs)(Me,{value:`targets`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(q,{className:`size-3.5 shrink-0`}),`Targets`]}),(0,X.jsxs)(Me,{value:`operations`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Se,{className:`size-3.5 shrink-0`}),`Operations`]}),(0,X.jsxs)(Me,{value:`activity`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(I,{className:`size-3.5 shrink-0`}),`Activity`]})]})}),(0,X.jsx)(Ne,{value:`targets`,className:`flex-1 py-2`,children:(0,X.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e.isError&&e.data===void 0?(0,X.jsx)(m,{message:J(e.error,`Failed to load targets.`),onRetry:()=>void e.refetch(),isRetrying:e.isFetching&&!e.isPending}):(0,X.jsx)(Qt,{targets:t,onMutate:()=>void e.refetch(),lastOpByTarget:y,templates:u,templatesLoading:s.isPending&&s.data===void 0,templatesError:s.isError&&u.length===0,onRetryTemplates:()=>void s.refetch(),stream:d})},`targets`)}),(0,X.jsx)(Ne,{value:`operations`,className:`flex-1 py-2`,children:(0,X.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:S},`operations`)}),(0,X.jsx)(Ne,{value:`activity`,className:`flex flex-col flex-1 min-h-0 py-2`,children:(0,X.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col flex-1 min-h-0`,children:(0,X.jsx)(Wt,{operations:i,totalKnown:o,isLoading:n.isPending&&!n.data,error:n.error,onRefresh:()=>void l.invalidateQueries({queryKey:c.platforms.operationsList()}),hasNextPage:n.hasNextPage,isFetchingNextPage:n.isFetchingNextPage,loadMoreError:n.isFetchNextPageError&&n.error instanceof Error?n.error:null,onRetryLoadMore:()=>void n.fetchNextPage(),onLoadMore:()=>void n.fetchNextPage()})},`activity`)})]}),(0,X.jsx)(g,{children:d.operation||d.status===`running`?(0,X.jsx)(ft,{stream:d,onReset:d.reset,catalogTemplates:u}):null})]})}export{nn as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{Ct as r,St as i,_t as a,bt as o,ct as s,dt as c,ft as l,gt as u,ht as d,lt as f,mt as p,ut as m,vt as h,xt as g,yt as _}from"./api-Bf6pFRhP.js";import{C as v}from"./format-B9CcV2dj.js";import{n as y,t as b}from"./utils-XFKvwlFT.js";var x=class extends r{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=m(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),C(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return w(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return w(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof u(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!h(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&T(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||u(this.options.enabled,this.#t)!==u(t.enabled,this.#t)||a(this.options.staleTime,this.#t)!==a(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||u(this.options.enabled,this.#t)!==u(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return D(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(p)),t}#g(){this.#b();let e=a(this.options.staleTime,this.#t);if(c.isServer()||this.#r.isStale||!l(e))return;let t=o(this.#r.dataUpdatedAt,e)+1;this.#d=g.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(c.isServer()||u(this.options.enabled,this.#t)===!1||!l(this.#p)||this.#p===0)&&(this.#f=g.setInterval(()=>{(this.options.refetchIntervalInBackground||i.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(g.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(g.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,c=e===n?this.#n:e.state,{state:l}=e,f={...l},p=!1,h;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&C(e,t),o=i&&T(e,n,t,r);(a||o)&&(f={...f,...s(l.data,e.options)}),t._optimisticResults===`isRestoring`&&(f.fetchStatus=`idle`)}let{error:g,errorUpdatedAt:_,status:v}=f;h=f.data;let y=!1;if(t.placeholderData!==void 0&&h===void 0&&v===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,y=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(v=`success`,h=d(i?.data,e,t),p=!0)}if(t.select&&h!==void 0&&!y)if(i&&h===a?.data&&t.select===this.#c)h=this.#l;else try{this.#c=t.select,h=t.select(h),h=d(i?.data,h,t),this.#l=h,this.#s=null}catch(e){this.#s=e}this.#s&&(g=this.#s,h=this.#l,_=Date.now(),v=`error`);let b=f.fetchStatus===`fetching`,x=v===`pending`,S=v===`error`,w=x&&b,D=h!==void 0,O={status:v,fetchStatus:f.fetchStatus,isPending:x,isSuccess:v===`success`,isError:S,isInitialLoading:w,isLoading:w,data:h,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:_,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:f.dataUpdateCount>c.dataUpdateCount||f.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!x,isLoadingError:S&&!D,isPaused:f.fetchStatus===`paused`,isPlaceholderData:p,isRefetchError:S&&D,isStale:E(e,t),refetch:this.refetch,promise:this.#o,isEnabled:u(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=O.data!==void 0,r=O.status===`error`&&!t,i=e=>{r?e.reject(O.error):t&&e.resolve(O.data)},a=()=>{i(this.#o=O.promise=m())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||O.data!==o.value)&&a();break;case`rejected`:(!r||O.error!==o.reason)&&a();break}}return O}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!h(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){f.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function S(e,t){return u(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function C(e,t){return S(e,t)||e.state.data!==void 0&&w(e,t,t.refetchOnMount)}function w(e,t,n){if(u(t.enabled,e)!==!1&&a(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&E(e,t)}return!1}function T(e,t,n,r){return(e!==t||u(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&E(e,n)}function E(e,t){return u(t.enabled,e)!==!1&&e.isStaleByTime(a(t.staleTime,e))}function D(e,t){return!h(e.getCurrentResult(),t)}var O=e(t(),1),k=n(),A=O.createContext(void 0),j=e=>{let t=O.useContext(A);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},M=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(A.Provider,{value:e,children:t})),N=O.createContext(!1),P=()=>O.useContext(N);N.Provider;function F(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var I=O.createContext(F()),L=()=>O.useContext(I),R=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?_(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},z=e=>{O.useEffect(()=>{e.clearReset()},[e])},B=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||_(n,[e.error,r])),V=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},H=(e,t)=>e.isLoading&&e.isFetching&&!t,U=(e,t)=>e?.suspense&&t.isPending,W=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function G(e,t,n){let r=P(),i=L(),a=j(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,V(o),R(o,i,s),z(i);let l=!a.getQueryCache().get(o.queryHash),[u]=O.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),m=!r&&e.subscribed!==!1;if(O.useSyncExternalStore(O.useCallback(e=>{let t=m?u.subscribe(f.batchCalls(e)):p;return u.updateResult(),t},[u,m]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),O.useEffect(()=>{u.setOptions(o)},[o,u]),U(o,d))throw W(o,u,i);if(B({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!c.isServer()&&H(d,r)&&(l?W(o,u,i):s?.promise)?.catch(p).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function K(e,t){return G(e,x,t)}var q=y(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);function J({role:e=`status`,"aria-live":t=`polite`,"aria-atomic":n=!0,className:r,eyebrow:i,stamp:a,title:o,children:s,detailLabel:c=`Technical detail`,detail:l,primaryLabel:u,onPrimary:d,primaryIcon:f,primaryDisabled:p,primaryBusy:m,secondaryLabel:h,onSecondary:g}){return(0,k.jsx)(`div`,{role:e,"aria-live":t,"aria-atomic":n,className:b(`relative overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] border border-primary/20 bg-transparent`,r),children:(0,k.jsx)(`div`,{className:`p-5 sm:p-6`,children:(0,k.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`p`,{className:`font-mono text-[0.65rem] uppercase tracking-[0.38em] text-muted-foreground`,children:i}),(0,k.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,k.jsx)(`span`,{className:`font-heading text-3xl font-black leading-none tracking-[-0.06em] text-transparent [-webkit-text-stroke:1px_color-mix(in_srgb,var(--primary)_50%,transparent)] sm:text-4xl`,"aria-hidden":!0,children:a}),(0,k.jsx)(`div`,{className:`mb-1.5 h-px min-w-8 flex-1 bg-linear-to-r from-primary/55 to-transparent`})]}),(0,k.jsx)(`h2`,{className:`text-lg font-semibold tracking-[-0.03em] text-foreground sm:text-xl`,children:o}),s?(0,k.jsx)(`div`,{className:`space-y-2 text-sm leading-relaxed text-muted-foreground`,children:s}):null]}),(0,k.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border border-border/80 bg-background/55 p-4 backdrop-blur-sm`,children:[(0,k.jsx)(`div`,{className:`mb-2 font-mono text-[0.65rem] uppercase tracking-[0.28em] text-muted-foreground`,children:c}),(0,k.jsx)(`p`,{className:`wrap-break-word font-mono text-sm leading-relaxed text-primary`,children:l})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[(0,k.jsxs)(v,{type:`button`,onClick:d,disabled:!!(p||m),"aria-busy":m,className:b(`inline-flex w-full items-center justify-center gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-foreground/15 bg-foreground px-4 py-2.5 font-medium text-background shadow-none transition hover:bg-foreground/90 sm:w-auto`,m&&`pointer-events-none opacity-90`),children:[f,u]}),h&&g?(0,k.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`sm:self-center`,onClick:g,children:h}):null]})]})})})}function Y({message:e,onRetry:t,isRetrying:n}){return(0,k.jsxs)(J,{role:`alert`,eyebrow:`Data link fault`,stamp:`ERR`,title:`Couldn't reach Miravo`,detail:e,primaryLabel:`Retry request`,onPrimary:t,primaryBusy:!!n,primaryIcon:(0,k.jsx)(q,{className:b(`size-4 shrink-0`,n&&`animate-spin`),"aria-hidden":!0}),children:[(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-foreground`,children:`Most often:`}),` the Miravo admin server isn't running, or this browser can't reach it (wrong host, port, or firewall).`]}),(0,k.jsx)(`p`,{children:`Start or restart Miravo if needed, use the correct link to the Miravo Console, then try again.`})]})}export{G as a,x as c,K as i,J as n,M as o,q as r,j as s,Y as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{Ct as r,St as i,_t as a,bt as o,ct as s,dt as c,ft as l,gt as u,ht as d,lt as f,mt as p,ut as m,vt as h,xt as g,yt as _}from"./api-2XqCNjt9.js";import{C as v}from"./format-B9CcV2dj.js";import{n as y,t as b}from"./utils-XFKvwlFT.js";var x=class extends r{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=m(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),C(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return w(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return w(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof u(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!h(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&T(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||u(this.options.enabled,this.#t)!==u(t.enabled,this.#t)||a(this.options.staleTime,this.#t)!==a(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||u(this.options.enabled,this.#t)!==u(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return D(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(p)),t}#g(){this.#b();let e=a(this.options.staleTime,this.#t);if(c.isServer()||this.#r.isStale||!l(e))return;let t=o(this.#r.dataUpdatedAt,e)+1;this.#d=g.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(c.isServer()||u(this.options.enabled,this.#t)===!1||!l(this.#p)||this.#p===0)&&(this.#f=g.setInterval(()=>{(this.options.refetchIntervalInBackground||i.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(g.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(g.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,c=e===n?this.#n:e.state,{state:l}=e,f={...l},p=!1,h;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&C(e,t),o=i&&T(e,n,t,r);(a||o)&&(f={...f,...s(l.data,e.options)}),t._optimisticResults===`isRestoring`&&(f.fetchStatus=`idle`)}let{error:g,errorUpdatedAt:_,status:v}=f;h=f.data;let y=!1;if(t.placeholderData!==void 0&&h===void 0&&v===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,y=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(v=`success`,h=d(i?.data,e,t),p=!0)}if(t.select&&h!==void 0&&!y)if(i&&h===a?.data&&t.select===this.#c)h=this.#l;else try{this.#c=t.select,h=t.select(h),h=d(i?.data,h,t),this.#l=h,this.#s=null}catch(e){this.#s=e}this.#s&&(g=this.#s,h=this.#l,_=Date.now(),v=`error`);let b=f.fetchStatus===`fetching`,x=v===`pending`,S=v===`error`,w=x&&b,D=h!==void 0,O={status:v,fetchStatus:f.fetchStatus,isPending:x,isSuccess:v===`success`,isError:S,isInitialLoading:w,isLoading:w,data:h,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:_,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:f.dataUpdateCount>c.dataUpdateCount||f.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!x,isLoadingError:S&&!D,isPaused:f.fetchStatus===`paused`,isPlaceholderData:p,isRefetchError:S&&D,isStale:E(e,t),refetch:this.refetch,promise:this.#o,isEnabled:u(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=O.data!==void 0,r=O.status===`error`&&!t,i=e=>{r?e.reject(O.error):t&&e.resolve(O.data)},a=()=>{i(this.#o=O.promise=m())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||O.data!==o.value)&&a();break;case`rejected`:(!r||O.error!==o.reason)&&a();break}}return O}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!h(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){f.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function S(e,t){return u(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function C(e,t){return S(e,t)||e.state.data!==void 0&&w(e,t,t.refetchOnMount)}function w(e,t,n){if(u(t.enabled,e)!==!1&&a(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&E(e,t)}return!1}function T(e,t,n,r){return(e!==t||u(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&E(e,n)}function E(e,t){return u(t.enabled,e)!==!1&&e.isStaleByTime(a(t.staleTime,e))}function D(e,t){return!h(e.getCurrentResult(),t)}var O=e(t(),1),k=n(),A=O.createContext(void 0),j=e=>{let t=O.useContext(A);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},M=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(A.Provider,{value:e,children:t})),N=O.createContext(!1),P=()=>O.useContext(N);N.Provider;function F(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var I=O.createContext(F()),L=()=>O.useContext(I),R=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?_(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},z=e=>{O.useEffect(()=>{e.clearReset()},[e])},B=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||_(n,[e.error,r])),V=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},H=(e,t)=>e.isLoading&&e.isFetching&&!t,U=(e,t)=>e?.suspense&&t.isPending,W=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function G(e,t,n){let r=P(),i=L(),a=j(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,V(o),R(o,i,s),z(i);let l=!a.getQueryCache().get(o.queryHash),[u]=O.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),m=!r&&e.subscribed!==!1;if(O.useSyncExternalStore(O.useCallback(e=>{let t=m?u.subscribe(f.batchCalls(e)):p;return u.updateResult(),t},[u,m]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),O.useEffect(()=>{u.setOptions(o)},[o,u]),U(o,d))throw W(o,u,i);if(B({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!c.isServer()&&H(d,r)&&(l?W(o,u,i):s?.promise)?.catch(p).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function K(e,t){return G(e,x,t)}var q=y(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);function J({role:e=`status`,"aria-live":t=`polite`,"aria-atomic":n=!0,className:r,eyebrow:i,stamp:a,title:o,children:s,detailLabel:c=`Technical detail`,detail:l,primaryLabel:u,onPrimary:d,primaryIcon:f,primaryDisabled:p,primaryBusy:m,secondaryLabel:h,onSecondary:g}){return(0,k.jsx)(`div`,{role:e,"aria-live":t,"aria-atomic":n,className:b(`relative overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] border border-primary/20 bg-transparent`,r),children:(0,k.jsx)(`div`,{className:`p-5 sm:p-6`,children:(0,k.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`p`,{className:`font-mono text-[0.65rem] uppercase tracking-[0.38em] text-muted-foreground`,children:i}),(0,k.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,k.jsx)(`span`,{className:`font-heading text-3xl font-black leading-none tracking-[-0.06em] text-transparent [-webkit-text-stroke:1px_color-mix(in_srgb,var(--primary)_50%,transparent)] sm:text-4xl`,"aria-hidden":!0,children:a}),(0,k.jsx)(`div`,{className:`mb-1.5 h-px min-w-8 flex-1 bg-linear-to-r from-primary/55 to-transparent`})]}),(0,k.jsx)(`h2`,{className:`text-lg font-semibold tracking-[-0.03em] text-foreground sm:text-xl`,children:o}),s?(0,k.jsx)(`div`,{className:`space-y-2 text-sm leading-relaxed text-muted-foreground`,children:s}):null]}),(0,k.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border border-border/80 bg-background/55 p-4 backdrop-blur-sm`,children:[(0,k.jsx)(`div`,{className:`mb-2 font-mono text-[0.65rem] uppercase tracking-[0.28em] text-muted-foreground`,children:c}),(0,k.jsx)(`p`,{className:`wrap-break-word font-mono text-sm leading-relaxed text-primary`,children:l})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[(0,k.jsxs)(v,{type:`button`,onClick:d,disabled:!!(p||m),"aria-busy":m,className:b(`inline-flex w-full items-center justify-center gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-foreground/15 bg-foreground px-4 py-2.5 font-medium text-background shadow-none transition hover:bg-foreground/90 sm:w-auto`,m&&`pointer-events-none opacity-90`),children:[f,u]}),h&&g?(0,k.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`sm:self-center`,onClick:g,children:h}):null]})]})})})}function Y({message:e,onRetry:t,isRetrying:n}){return(0,k.jsxs)(J,{role:`alert`,eyebrow:`Data link fault`,stamp:`ERR`,title:`Couldn't reach Miravo`,detail:e,primaryLabel:`Retry request`,onPrimary:t,primaryBusy:!!n,primaryIcon:(0,k.jsx)(q,{className:b(`size-4 shrink-0`,n&&`animate-spin`),"aria-hidden":!0}),children:[(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-foreground`,children:`Most often:`}),` the Miravo admin server isn't running, or this browser can't reach it (wrong host, port, or firewall).`]}),(0,k.jsx)(`p`,{children:`Start or restart Miravo if needed, use the correct link to the Miravo Console, then try again.`})]})}export{G as a,x as c,K as i,J as n,M as o,q as r,j as s,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{at as e,d as t,f as n,m as r,p as i}from"./vendor-ui-CWUk2ulb.js";import{$ as a,B as o,E as s,G as c,H as l,J as u,K as d,L as f,Q as p,U as m,V as h,W as g,X as _,Y as v,Z as y,et as b,q as x}from"./api-Bf6pFRhP.js";import{D as ee}from"./format-B9CcV2dj.js";import{n as S,t as C}from"./utils-XFKvwlFT.js";var te=S(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ne=S(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),re=S(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),ie=S(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]);u({path:_().min(1),name:_().min(1),description:_().optional(),memberCount:x().int().nonnegative(),methodCount:x().int().nonnegative(),faultCount:x().int().nonnegative(),hasLifecycle:l(),lifecycleStageCount:x().int().nonnegative()}),u({path:_().min(1),id:_().min(1),name:_().min(1),description:_().optional(),areaCount:x().int().nonnegative(),twinAssignmentCount:x().int().nonnegative(),uniqueModelCount:x().int().nonnegative(),modelNames:h(_().min(1)),totalTwinCount:x().int().nonnegative()});var ae=u({severity:g([`error`,`warning`]),message:_(),fix:_()});u({valid:l(),templatePath:_(),issues:h(ae)});var w=`%.A.Hz.L.L/h.L/min.L/s.N.V.bar.cfm.count.degC.h.kN.kVA.kW.kWh.m.m/s.m3.m3/h.mm.mm/min.mm/s.ppm.pu.rpm.s`.split(`.`),T=g(w);new Set(w);var oe=_().min(1).max(128).regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/),E=g([`Boolean`,`Int32`,`UInt16`,`UInt32`,`Double`,`Float`,`String`]);g([`variable`,`property`]);var D=g([`read`,`readwrite`,`write`]),O=g([`>`,`>=`,`<`,`<=`,`==`,`!=`]),k=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,se=m(`type`,[u({type:d(`threshold`),member:_().regex(f,k),operator:O,threshold:x().finite()}).strict(),u({type:d(`lifecycle-stage`)}).strict(),u({type:d(`health-state`)}).strict(),u({type:d(`fault-active`)}).strict(),u({type:d(`fault-count`)}).strict(),u({type:d(`active-fault-code`),fallback:_().default(``)}).strict(),u({type:d(`availability-state`),member:_().regex(f,k),operator:O.default(`>`),threshold:x().finite().default(0),running_state:_().default(`running`),stopped_state:_().default(`stopped`),faulted_state:_().default(`faulted`)}).strict()]),A=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,j=h(_().min(1)).min(1),ce=u({data_type:E,unit:T.optional(),description:_().optional(),enum_values:j.optional()}).strict(),le=p([u({member:_().regex(f,A),value:p([x(),_(),l()])}).strict(),u({member:_().regex(f,A),argument:_().regex(f,A)}).strict()]),ue=u({type:d(`set-members`),writes:h(le).min(1)}).strict(),de=p([u({parameter:_().regex(f,A),value:x().finite()}).strict(),u({parameter:_().regex(f,A),argument:_().regex(f,A)}).strict()]),fe=m(`type`,[ue,u({type:d(`set-parameters`),writes:h(de).min(1)}).strict(),u({type:d(`clear-faults`)}).strict()]),pe=u({description:_().optional(),input_arguments:v(_().regex(f,A),ce).optional(),output_arguments:v(_().regex(f,A),ce).optional(),runtime:fe.optional()}).strict(),me=v(_().regex(f,A),pe);function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){if(typeof e==`string`)return o.exec(e)?.[1]}function P(e,t,n){if(!M(e)||e.type!==`weighted-sum`)return;let r=e.terms;if(Array.isArray(r))for(let e=0;e<r.length;e++){let i=r[e];M(i)&&n(i,[...t,`terms`,e])}}function he(e,t,n){if(!M(e))return;let r=[...t,`member`],i=[...t,`previous_member`],a=[...t,`param`],o=[...t,`generator`];typeof e.member==`string`&&n.onMember?.(e.member,r),typeof e.previous_member==`string`&&n.onPreviousMember?.(e.previous_member,i),typeof e.param==`string`&&n.onParam?.(e.param,a),`generator`in e&&n.onGenerator?.(e.generator,o)}function ge(e,t,n,r){return{onMember:e,onPreviousMember:t,onParam:n,onGenerator:r}}function _e(e,t,n,r,i,a){he(e,t,ge(n,r,i,a))}function F(e){return e===`Double`||e===`Float`||e===`Int32`||e===`UInt16`||e===`UInt32`}function ve(e){return e===`Int32`||e===`UInt16`||e===`UInt32`}function I(e,t){switch(t){case`Boolean`:return typeof e==`boolean`;case`String`:return typeof e==`string`;case`Double`:case`Float`:return typeof e==`number`&&Number.isFinite(e);case`Int32`:return typeof e==`number`&&Number.isSafeInteger(e)&&e>=-2147483648&&e<=2147483647;case`UInt16`:return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0&&e<=65535;case`UInt32`:return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0&&e<=4294967295;default:return!1}}function ye(e,t,n){e.unit!==void 0&&(e.data_type===`Boolean`||e.data_type===`String`)&&t.addIssue({code:b.custom,path:[...n,`unit`],message:`Members with data_type "${e.data_type}" must not declare engineering units. Fix: remove the unit or use a numeric data_type.`}),e.enum_values&&e.data_type!==`String`&&t.addIssue({code:b.custom,path:[...n,`enum_values`],message:`enum_values is only valid for String members. Fix: remove enum_values or change data_type to "String".`})}function L(e,t,n,r){if(M(e)&&typeof e.type==`string`)switch(e.type){case`correlated`:typeof e.source==`string`&&n.push({member:e.source,path:[...t,`source`],previousTick:!1}),z(e.factor,[...t,`factor`],r),z(e.offset,[...t,`offset`],r);return;case`sine`:case`noise`:case`waveform`:case`chirp`:z(e.center,[...t,`center`],r);return;case`mean-reverting-noise`:z(e.mean,[...t,`mean`],r);return;case`first-order-lag`:case`second-order`:z(e.gain,[...t,`gain`],r),z(e.bias,[...t,`bias`],r),R(e.input,[...t,`input`],n,r);return;case`transport-delay`:z(e.delay,[...t,`delay`],r),R(e.input,[...t,`input`],n,r);return;case`slew-rate-limiter`:case`integrator`:R(e.input,[...t,`input`],n,r);return;case`hysteresis-relay`:z(e.on_threshold,[...t,`on_threshold`],r),z(e.off_threshold,[...t,`off_threshold`],r),R(e.input,[...t,`input`],n,r);return;case`weighted-sum`:z(e.bias,[...t,`bias`],r),P(e,t,(e,t)=>{z(e.weight,[...t,`weight`],r),R(e.input,[...t,`input`],n,r)});return;case`gate`:n.push({member:String(e.enabled_member),path:[...t,`enabled_member`],previousTick:!1}),R(e.input,[...t,`input`],n,r);return;case`health-dependent`:{let i=e.stages;if(!M(i))return;for(let[e,a]of Object.entries(i))L(a,[...t,`stages`,e],n,r);return}default:return}}function R(e,t,n,r){_e(e,t,(e,t)=>n.push({member:e,path:t,previousTick:!1}),(e,t)=>n.push({member:e,path:t,previousTick:!0}),(e,t)=>r.push({param:e,path:t}),(e,t)=>L(e,t,n,r))}function z(e,t,n){let r=N(e);r!==void 0&&n.push({param:r,path:t})}function be(e,t,n){if(!M(e))return;let r=e.type;(r===`threshold`||r===`availability-state`)&&typeof e.member==`string`&&n.push({member:e.member,path:[...t,`member`],previousTick:!1})}function B(e,t,n){if(!M(e))return;let r=e.type;if(typeof r!=`string`)return;if(r===`integrator`&&e.wrap===!0&&(typeof e.wrap_at!=`number`||!Number.isFinite(e.wrap_at)||e.wrap_at<=0)&&n.addIssue({code:b.custom,path:[...t,`wrap_at`],message:`wrap_at must be a finite number greater than 0 when wrap is true. Fix: Set wrap_at to a positive number, or set wrap to false.`}),r===`health-dependent`){let r=e.stages;if(M(r))for(let[e,i]of Object.entries(r))B(i,[...t,`stages`,e],n)}function i(e,t){!M(e)||!(`generator`in e)||B(e.generator,[...t,`generator`],n)}i(e.input,[...t,`input`]),P(e,t,(e,t)=>{i(e.input,[...t,`input`])})}function xe(e){switch(e){case`Boolean`:return!1;case`String`:return``;case`Double`:case`Float`:case`Int32`:case`UInt16`:case`UInt32`:return 0;default:return 0}}var Se=h(m(`type`,[u({type:d(`white_noise`),strength:x().min(0).max(1),scale:x().positive().optional()}).strict(),u({type:d(`drift`),tau:x().positive(),sigma:x().min(0).max(1),scale:x().positive().optional()}).strict(),u({type:d(`outlier`),probability:x().min(0).max(1),magnitude:x().positive(),scale:x().positive().optional()}).strict(),u({type:d(`gap`),probability:x().min(0).max(1),duration:x().int().positive().default(10)}).strict(),u({type:d(`noise_burst`),probability:x().min(0).max(1),duration:x().int().positive().default(5),strength:x().min(0).max(1),scale:x().positive().optional()}).strict()])).min(1).optional(),V=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`;g([`float`,`int`,`string`,`bool`]);var Ce=m(`type`,[u({type:d(`float`),default:x().finite(),min:x().finite().optional(),max:x().finite().optional(),unit:T.optional()}),u({type:d(`int`),default:x().int().safe(),min:x().int().safe().optional(),max:x().int().safe().optional(),unit:T.optional()}),u({type:d(`string`),default:_(),unit:T.optional()}),u({type:d(`bool`),default:l(),unit:T.optional()})]),H=p([u({member:_()}).strict(),u({previous_member:_()}).strict(),u({param:_()}).strict(),u({generator:c(()=>We)}).strict()]),U=_().regex(o,`Must be a $param.X parameter reference`),W=p([x(),U]),G=p([x().finite(),U]),K={initial_value:x().default(0),gain:W.default(1),bias:W.default(0),min:x().nullable().default(null),max:x().nullable().default(null),input:H},q=u({type:d(`sine`),center:W,amplitude:x().positive(),period:x().positive()}).strict(),J=u({type:d(`random-walk`),min:x(),max:x(),step:x().positive()}).strict(),we=u({type:d(`noise`),center:W,stddev:x().positive()}).strict(),Te=u({type:d(`step`),values:h(x()).min(1),interval:x().positive()}).strict(),Ee=u({type:d(`correlated`),source:_().regex(f,V),factor:G,offset:G,power:x().int().positive().optional()}).strict(),De=u({from:_(),to:_(),probability:x().min(0).max(1).optional(),on:_().optional()}).strict(),Y=u({type:d(`state-machine`),states:h(_()).min(1),initial:_(),transitions:h(De).min(1)}).strict();function X(e,t){let n=new Set(e.states);n.has(e.initial)||t.addIssue({code:b.custom,path:[`initial`],message:`State machine initial state "${e.initial}" is not in states. Fix: Set initial to one of: ${e.states.join(`, `)}.`});for(let r=0;r<e.transitions.length;r++){let i=e.transitions[r];i&&(n.has(i.from)||t.addIssue({code:b.custom,path:[`transitions`,r,`from`],message:`State machine transition from "${i.from}" references a state that is not in states. Fix: Add "${i.from}" to states or change transition.from to one of: ${e.states.join(`, `)}.`}),n.has(i.to)||t.addIssue({code:b.custom,path:[`transitions`,r,`to`],message:`State machine transition to "${i.to}" references a state that is not in states. Fix: Add "${i.to}" to states or change transition.to to one of: ${e.states.join(`, `)}.`}))}}Y.superRefine(X);var Oe=u({type:d(`ramp`),start_value:x().default(0),rate:x(),duration:x().nonnegative(),start_time:x().default(0),min:x().nullable().default(null),max:x().nullable().default(null)}).strict(),ke=u({type:d(`mean-reverting-noise`),mean:W,tau:x().positive(),sigma:x().positive(),initial_value:x().optional(),min:x().nullable().default(null),max:x().nullable().default(null)}).strict(),Ae=u({time:x().nonnegative(),value:x()}),je=u({type:d(`timetable`),points:h(Ae).min(2),repeat:l().default(!1),interpolation:g([`linear`,`step`]).default(`linear`)}).strict(),Me=u({type:d(`waveform`),shape:g([`sawtooth`,`triangle`,`square`,`pulse`]),center:W,amplitude:x().positive(),period:x().positive(),duty_cycle:x().min(0).max(1).default(.5)}).strict(),Ne=u({type:d(`chirp`),center:W,amplitude:x().positive(),start_freq_hz:x().positive(),end_freq_hz:x().positive(),sweep_duration:x().positive(),sweep:g([`linear`,`exponential`]).default(`linear`),repeat:l().default(!0)}).strict(),Z=u({type:d(`impulse`),baseline:x().default(0),amplitude:x(),probability:x().min(0).max(1).optional(),interval:x().positive().optional(),decay:x().min(0).max(1).optional(),duration:x().int().positive().default(1)}).strict();function Q(e,t){e.probability===void 0&&e.interval===void 0&&t.addIssue({code:b.custom,path:[`probability`],message:`Impulse generator requires either probability or interval. Fix: Add probability: 0.01 (per-tick chance) or interval: 60 (seconds between triggers).`}),e.probability!==void 0&&e.interval!==void 0&&t.addIssue({code:b.custom,path:[`interval`],message:`Impulse generator cannot have both probability and interval. Fix: Remove one: use probability for random triggers, or interval for periodic triggers.`})}Z.superRefine(Q);var Pe=u({type:d(`first-order-lag`),tau:x().positive(),...K}).strict(),Fe=u({type:d(`integrator`),initial_value:x().default(0),gain:x().default(1),bias_rate:x().default(0),min:x().default(-1/0),max:x().default(1/0),wrap:l().default(!1),wrap_at:x().nullable().default(null),input:H}).strict(),Ie=u({type:d(`transport-delay`),delay:p([x().nonnegative(),U]),initial_value:x().default(0),interpolation:g([`linear`,`zoh`]).default(`linear`),input:H}).strict(),Le=u({type:d(`slew-rate-limiter`),rate_up:x().positive(),rate_down:x().positive().optional(),initial_value:x().default(0),min:x().nullable().default(null),max:x().nullable().default(null),input:H}).strict(),Re=u({type:d(`second-order`),natural_freq_hz:x().positive(),damping_ratio:x().positive(),initial_velocity:x().default(0),...K}).strict(),ze=u({type:d(`hysteresis-relay`),on_threshold:W,off_threshold:W,output_on:p([x(),_()]).default(1),output_off:p([x(),_()]).default(0),initial_state:g([`on`,`off`]).default(`off`),mode:g([`rising`,`falling`]).default(`rising`),input:H}).strict(),Be=u({weight:W.default(1),input:H}),Ve=u({type:d(`weighted-sum`),bias:W.default(0),terms:h(Be).min(1),min:x().nullable().default(null),max:x().nullable().default(null)}).strict(),He=u({type:d(`gate`),enabled_member:_().regex(f,V),input:H,disabled_value:p([x(),_(),l()])}).strict(),Ue=m(`type`,[q,J,we,Te,Ee,Y,Oe,ke,je,Me,Ne,Z]).superRefine((e,t)=>{e.type===`state-machine`&&X(e,t),e.type===`impulse`&&Q(e,t)}),We=m(`type`,[q,J,we,Te,Ee,Y,Oe,ke,je,Me,Ne,Z,u({type:d(`health-dependent`),stages:v(_(),Ue)}).strict(),Pe,Fe,Ie,Le,Re,ze,Ve,He]).superRefine((e,t)=>{e.type===`state-machine`&&X(e,t),e.type===`impulse`&&Q(e,t)}),Ge=u({multiplier:x().finite().optional(),offset:x().finite().optional()}).strict(),Ke=u({stages:h(u({name:_().min(1),duration_hours:y([x().nonnegative(),x().nonnegative()]).refine(([e,t])=>e<=t,{message:`duration_hours max must be greater than or equal to min.`}),effects:v(_(),Ge)})).min(1)}).superRefine((e,t)=>{let n=new Set;for(let r=0;r<e.stages.length;r++){let i=e.stages[r];i&&(n.has(i.name)&&t.addIssue({code:b.custom,path:[`stages`,r,`name`],message:`Lifecycle stage names must be unique. Duplicate "${i.name}". Fix: Rename one stage so each lifecycle stage has a unique name.`}),n.add(i.name))}}),qe=u({multiplier:x().finite().optional(),offset:x().finite().optional(),spike:x().finite().optional(),duration_ticks:x().int().positive().optional(),onset_ticks:x().int().positive().optional(),recovery_ticks:x().int().positive().optional()}).strict(),Je=u({condition:_().optional(),lifecycle_stage:_().optional(),probability:x().min(0).max(1)}),Ye=u({name:_().regex(f,V),trigger:Je,effects:v(_(),p([qe,_()]))}),Xe=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,Ze=new Set([`enterprise`,`site`,`area`,`line`,`prefix`]),Qe=_().regex(o,`Must be a $param.X parameter reference`),$e=p([x(),_(),l()]),et=u({name:_().regex(f,Xe),description:_().optional(),namespace:_().optional()}).strict(),tt=m(`kind`,[u({kind:d(`variable`),data_type:E,access:D,unit:T.optional(),enum_values:j.optional(),eu_range:y([x(),x()]).refine(([e,t])=>e<=t,{message:`eu_range[0] (min) must be <= eu_range[1] (max).`}).optional(),generator:We.optional(),binding:se.optional(),default:$e.optional(),observation_effects:Se}).strict(),u({kind:d(`property`),data_type:E,access:D,unit:T.optional(),enum_values:j.optional(),default:p([$e,Qe]).optional()}).strict()]);function nt(e){return v(_().regex(f,Xe),tt).refine(e=>Object.keys(e).length>=1,{message:`Members map must have at least 1 member.`}).refine(t=>Object.keys(t).length<=e,{message:`Members map must have at most ${e} members.`}).refine(e=>!Object.keys(e).some(e=>Ze.has(e)),{message:`Member names cannot use reserved env keys: enterprise/site/area/line/prefix`})}function rt(e={}){let t=nt(e.maxMembersPerModel??1e3);return u({schema_version:d(`2`),model:et,parameters:v(_(),Ce).optional(),members:t,methods:me.optional(),lifecycle:Ke.optional(),faults:h(Ye).optional()}).strict().superRefine((e,t)=>{let n=Object.keys(e.members),r=new Map;for(let e=0;e<n.length;e++){let t=n[e];t!==void 0&&r.set(t,e)}let i=new Set(Object.keys(e.parameters??{})),a=new Set(Object.entries(e.parameters??{}).filter(([,e])=>e.type===`float`||e.type===`int`).map(([e])=>e));for(let o=0;o<n.length;o++){let s=n[o];if(s===void 0)continue;let c=e.members[s];if(!c||(ye(c,t,[`members`,s]),c.kind===`variable`&&c.generator!==void 0&&c.binding!==void 0&&t.addIssue({code:b.custom,path:[`members`,s,`binding`],message:`Variable members cannot define both "generator" and "binding". Fix: keep one source of value generation.`}),c.kind===`variable`&&c.binding!==void 0&&c.access!==`read`&&t.addIssue({code:b.custom,path:[`members`,s,`access`],message:`Variable members with a "binding" must use access "read". Fix: change access to "read" or remove the binding.`}),c.kind!==`variable`||!c.generator&&!c.binding))continue;let l=[],u=[],d=[`members`,s,`generator`];if(c.generator&&L(c.generator,d,l,u),c.binding&&be(c.binding,[`members`,s,`binding`],l),c.generator&&(B(c.generator,d,t),c.generator.type===`gate`)){let n=e.members[c.generator.enabled_member];n&&n.data_type!==`Boolean`&&t.addIssue({code:b.custom,path:[`members`,s,`generator`,`enabled_member`],message:`Gate generator for "${s}" references "${c.generator.enabled_member}", but "${c.generator.enabled_member}" is not Boolean. Fix: use a Boolean command/state member for enabled_member.`}),I(c.generator.disabled_value,c.data_type)||t.addIssue({code:b.custom,path:[`members`,s,`generator`,`disabled_value`],message:`Gate generator disabled_value for "${s}" does not match data_type "${c.data_type}". Fix: use a compatible disabled_value literal.`})}for(let e of l){let n=r.get(e.member);if(n===void 0){t.addIssue({code:b.custom,path:[...e.path],message:`Member "${s}" references member "${e.member}", but "${e.member}" is not defined. Fix: Define "${e.member}" in members, or change the reference to a parameter.`});continue}!e.previousTick&&n>=o&&t.addIssue({code:b.custom,path:[...e.path],message:`Member "${s}" references member "${e.member}" which is defined later (or is itself). Members are evaluated in declaration order. Fix: Move "${e.member}" above "${s}".`})}for(let n of u)i.has(n.param)?a.has(n.param)||t.addIssue({code:b.custom,path:[...n.path],message:`Member "${s}" references parameter "${n.param}" in a numeric position, but "${n.param}" has type "${e.parameters?.[n.param]?.type}". Only float and int parameters can be used as generator coefficients or inputs. Fix: Change "${n.param}" to type "float" or "int".`}):t.addIssue({code:b.custom,path:[...n.path],message:`Member "${s}" references parameter "${n.param}", but "${n.param}" is not defined. Fix: Define "${n.param}" under parameters, or replace "$param.${n.param}" with a literal value.`});if(c.binding)switch(c.binding.type){case`threshold`:c.data_type!==`Boolean`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "threshold" must use data_type "Boolean". Fix: change data_type to "Boolean".`}),it(s,c.binding.member,e,t,[`members`,s,`binding`,`member`]);break;case`availability-state`:c.data_type!==`String`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "availability-state" must use data_type "String". Fix: change data_type to "String".`}),it(s,c.binding.member,e,t,[`members`,s,`binding`,`member`]);break;case`lifecycle-stage`:case`health-state`:case`active-fault-code`:c.data_type!==`String`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "${c.binding.type}" must use data_type "String". Fix: change data_type to "String".`});break;case`fault-active`:c.data_type!==`Boolean`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "fault-active" must use data_type "Boolean". Fix: change data_type to "Boolean".`});break;case`fault-count`:c.data_type!==`Int32`&&c.data_type!==`UInt16`&&c.data_type!==`UInt32`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "fault-count" must use an integer data_type (Int32, UInt16, or UInt32). Fix: change data_type to an integer type.`});break;default:c.binding}if(c.kind===`variable`&&c.observation_effects){F(c.data_type)||t.addIssue({code:b.custom,path:[`members`,s,`observation_effects`],message:`Observation effects on "${s}" require a numeric data_type (Double, Float, Int32, UInt16, or UInt32). Member has data_type "${c.data_type}", which cannot be degraded by noise, gaps, or drift. Fix: remove observation_effects, or change data_type to a numeric type.`}),c.access!==`read`&&t.addIssue({code:b.custom,path:[`members`,s,`observation_effects`],message:`Observation effects on "${s}" require access "read". Observation effects corrupt values — they must not be applied to command targets or setpoints. Fix: change access to "read" or remove observation_effects.`});for(let e=0;e<c.observation_effects.length;e++){let n=c.observation_effects[e];n&&(n.type===`white_noise`||n.type===`drift`||n.type===`outlier`||n.type===`noise_burst`)&&!(`scale`in n&&n.scale!==void 0)&&!c.eu_range&&t.addIssue({code:b.custom,path:[`members`,s,`observation_effects`,e],message:`Member "${s}" uses relative observation effect "${n.type}" but has no eu_range and no explicit scale. Fix: add eu_range: [min, max] to the member, or add scale: <number> to the effect.`})}}}function o(n,i,a){if(!r.has(n)){t.addIssue({code:b.custom,path:[...i],message:`${a} has effect on "${n}", but "${n}" is not a defined member. Fix: Change "${n}" to a valid member name.`});return}let o=e.members[n];o&&o.kind!==`variable`&&t.addIssue({code:b.custom,path:[...i],message:`${a} has effect on "${n}", but "${n}" is a property (kind: "property"). Effects can only target variable members.`})}if(e.lifecycle){let t=[`lifecycle`,`stages`];for(let n of e.lifecycle.stages)for(let e of Object.keys(n.effects))o(e,t,`Lifecycle stage "${n.name}"`)}if(e.faults){let n=new Set;for(let r=0;r<e.faults.length;r++){let i=e.faults[r];if(!i)continue;n.has(i.name)&&t.addIssue({code:b.custom,path:[`faults`,r,`name`],message:`Fault names must be unique. Duplicate "${i.name}". Fix: Rename one fault so each fault has a unique name.`}),n.add(i.name);let a=[`faults`,r,`effects`];for(let e of Object.keys(i.effects))o(e,a,`Fault "${i.name}"`)}}for(let r of n){let n=e.members[r];if(!n||n.kind!==`property`||typeof n.default!=`string`)continue;let a=N(n.default);a!==void 0&&!i.has(a)&&t.addIssue({code:b.custom,path:[`members`,r,`default`],message:`Property "${r}" default references parameter "${a}", but "${a}" is not defined. Fix: Define "${a}" under parameters, or use a literal value.`})}if(e.methods)for(let[n,r]of Object.entries(e.methods))at(n,r.input_arguments,t,[`methods`,n,`input_arguments`]),at(n,r.output_arguments,t,[`methods`,n,`output_arguments`]),ot(n,r,e,t,[`methods`,n,`runtime`])})}function it(e,t,n,r,i){let a=n.members[t];a&&(F(a.data_type)||r.addIssue({code:b.custom,path:[...i],message:`Member "${e}" binding references "${t}", but "${t}" is not numeric. Fix: bind to a numeric member or change the source member data_type.`}))}function at(e,t,n,r){if(t)for(let[i,a]of Object.entries(t))a.unit!==void 0&&(a.data_type===`Boolean`||a.data_type===`String`)&&n.addIssue({code:b.custom,path:[...r,i,`unit`],message:`Method "${e}" argument "${i}" uses data_type "${a.data_type}" and must not declare an engineering unit. Fix: remove the unit or use a numeric data_type.`}),a.enum_values&&a.data_type!==`String`&&n.addIssue({code:b.custom,path:[...r,i,`enum_values`],message:`Method "${e}" argument "${i}" can only use enum_values with data_type "String". Fix: remove enum_values or change the data_type.`})}function ot(e,t,n,r,i){let a=t.runtime;if(a)switch(a.type){case`clear-faults`:return;case`set-parameters`:for(let o=0;o<a.writes.length;o++){let s=a.writes[o];if(!s)continue;let c=[...i,`writes`,o],l=n.parameters?.[s.parameter];if(!l){r.addIssue({code:b.custom,path:[...c,`parameter`],message:`Method "${e}" runtime targets parameter "${s.parameter}", but "${s.parameter}" is not defined. Fix: target a declared parameter.`});continue}if(l.type!==`float`&&l.type!==`int`){r.addIssue({code:b.custom,path:[...c,`parameter`],message:`Method "${e}" runtime targets parameter "${s.parameter}" of type "${l.type}". Fix: use set-parameters only with float or int parameters.`});continue}if(`argument`in s){let n=t.input_arguments?.[s.argument];if(!n){r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime references input argument "${s.argument}", but that argument is not defined. Fix: declare the input argument or use a literal value.`});continue}F(n.data_type)||r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" must be numeric to write parameter "${s.parameter}". Fix: use Double, Float, Int32, UInt16, or UInt32.`}),l.type===`int`&&!ve(n.data_type)&&r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" uses data_type "${n.data_type}" but parameter "${s.parameter}" is type "int". Fix: use Int32, UInt16, or UInt32 so runtime writes stay integer-safe.`});continue}l.type===`int`&&!Number.isSafeInteger(s.value)&&r.addIssue({code:b.custom,path:[...c,`value`],message:`Method "${e}" runtime literal for integer parameter "${s.parameter}" must be a safe integer. Fix: use a whole-number literal.`})}return;case`set-members`:for(let o=0;o<a.writes.length;o++){let s=a.writes[o];if(!s)continue;let c=[...i,`writes`,o],l=n.members[s.member];if(!l){r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets member "${s.member}", but "${s.member}" is not defined. Fix: target a declared member.`});continue}if(l.kind!==`variable`&&r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets "${s.member}", but "${s.member}" is a property. Fix: target a writable variable member.`}),l.access!==`readwrite`&&l.access!==`write`&&r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets "${s.member}", but "${s.member}" is not writable. Fix: set access to "readwrite" or "write".`}),l.kind===`variable`&&l.binding&&r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets "${s.member}", but bound members are computed at runtime. Fix: write to a command/setpoint member without a binding.`}),`argument`in s){let n=t.input_arguments?.[s.argument];if(!n){r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime references input argument "${s.argument}", but that argument is not defined. Fix: declare the input argument or use a literal value.`});continue}if(I(xe(n.data_type),l.data_type)||r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" uses data_type "${n.data_type}" which does not match target member "${s.member}" data_type "${l.data_type}". Fix: align the argument and target member data types.`}),n.enum_values&&l.enum_values){let t=n.enum_values.filter(e=>!l.enum_values?.includes(e));t.length>0&&r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" allows values [${t.join(`, `)}] that are not valid for target member "${s.member}". Fix: align enum_values between the argument and target member.`})}continue}I(s.value,l.data_type)||r.addIssue({code:b.custom,path:[...c,`value`],message:`Method "${e}" runtime literal for "${s.member}" does not match data_type "${l.data_type}". Fix: use a compatible literal value.`}),l.enum_values&&typeof s.value==`string`&&!l.enum_values.includes(s.value)&&r.addIssue({code:b.custom,path:[...c,`value`],message:`Method "${e}" runtime literal "${s.value}" is not allowed for member "${s.member}". Fix: use one of [${l.enum_values.join(`, `)}].`})}return;default:}}rt();var st=p([x().finite(),_(),l()]),ct=_().regex(/^[a-f0-9]{64}$/),lt=u({id:_().min(1),model:_().min(1),browsePath:h(_().min(1)).min(1),parameters:v(_(),st),lifecycleStage:_().min(1),operatingHours:x().finite().nonnegative(),activeFaults:h(_().min(1)),templateRunId:x().int().positive().optional(),protocolScope:h(s).min(1).optional(),observationState:v(_(),v(_(),a())).optional().default({}),faultState:v(_(),u({remaining:x().int(),elapsed:x().int(),recovering:l(),recoveryElapsed:x().int(),recoveryTicks:x().int()})).optional().default({})}),ut=u({templateRunId:x().int().positive(),templateName:_().min(1),templatePath:_(),entryHash:ct.optional()}),dt=u({name:_().min(1),enabled:l(),config:v(_(),a())});u({version:d(2),savedAt:_().min(1),environmentName:oe,models:h(_().min(1)),instances:h(lt),templateRuns:h(ut),adapters:h(dt).default([])});var $=e();function ft({className:e,orientation:t=`horizontal`,...n}){return(0,$.jsx)(r,{"data-slot":`tabs`,"data-orientation":t,className:C(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var pt=ee(`group/tabs-list inline-flex w-fit items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-0 border-b border-border/50 bg-transparent p-0 shadow-none group-data-horizontal/tabs:h-auto group-data-horizontal/tabs:min-h-8`}},defaultVariants:{variant:`default`}});function mt({className:e,variant:n=`default`,...r}){return(0,$.jsx)(t,{"data-slot":`tabs-list`,"data-variant":n,className:C(pt({variant:n}),e),...r})}function ht({className:e,...t}){return(0,$.jsx)(i,{"data-slot":`tabs-trigger`,className:C(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-[var(--miravo-radius-tight)] border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-muted-foreground transition-[color,box-shadow,transform] duration-200 ease-out group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:font-heading group-data-[variant=line]/tabs-list:tracking-tight group-data-[variant=line]/tabs-list:text-sm group-data-[variant=line]/tabs-list:text-muted-foreground group-data-[variant=line]/tabs-list:hover:text-foreground group-data-[variant=line]/tabs-list:data-active:font-semibold group-data-[variant=line]/tabs-list:data-active:text-foreground`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent group-data-[variant=line]/tabs-list:data-active:border-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`group-data-[variant=line]/tabs-list:rounded-none group-data-[variant=line]/tabs-list:px-3 group-data-[variant=line]/tabs-list:py-2`,`data-active:bg-background data-active:text-foreground data-active:border-input data-active:bg-input/30 data-active:text-foreground`,`after:pointer-events-none after:absolute after:bg-foreground after:opacity-0 after:transition-[opacity,transform] after:duration-300 after:ease-out group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5`,`group-data-[variant=line]/tabs-list:after:bg-primary group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:after:bottom-0 group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:after:h-[2px] group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:after:rounded-sm group-data-[variant=line]/tabs-list:data-active:after:opacity-100 group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:data-active:after:shadow-[0_0_14px_-3px_color-mix(in_srgb,var(--primary)_50%,transparent)]`,e),...t})}function gt({className:e,...t}){return(0,$.jsx)(n,{"data-slot":`tabs-content`,className:C(`flex-1 text-sm outline-none py-2`,e),...t})}export{ie as a,te as c,ht as i,gt as n,re as o,mt as r,ne as s,ft as t};
|
|
1
|
+
import{at as e,d as t,f as n,m as r,p as i}from"./vendor-ui-CWUk2ulb.js";import{$ as a,B as o,E as s,G as c,H as l,J as u,K as d,L as f,Q as p,U as m,V as h,W as g,X as _,Y as v,Z as y,et as b,q as x}from"./api-2XqCNjt9.js";import{D as ee}from"./format-B9CcV2dj.js";import{n as S,t as C}from"./utils-XFKvwlFT.js";var te=S(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ne=S(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),re=S(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),ie=S(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]);u({path:_().min(1),name:_().min(1),description:_().optional(),memberCount:x().int().nonnegative(),methodCount:x().int().nonnegative(),faultCount:x().int().nonnegative(),hasLifecycle:l(),lifecycleStageCount:x().int().nonnegative()}),u({path:_().min(1),id:_().min(1),name:_().min(1),description:_().optional(),areaCount:x().int().nonnegative(),twinAssignmentCount:x().int().nonnegative(),uniqueModelCount:x().int().nonnegative(),modelNames:h(_().min(1)),totalTwinCount:x().int().nonnegative()});var ae=u({severity:g([`error`,`warning`]),message:_(),fix:_()});u({valid:l(),templatePath:_(),issues:h(ae)});var w=`%.A.Hz.L.L/h.L/min.L/s.N.V.bar.cfm.count.degC.h.kN.kVA.kW.kWh.m.m/s.m3.m3/h.mm.mm/min.mm/s.ppm.pu.rpm.s`.split(`.`),T=g(w);new Set(w);var oe=_().min(1).max(128).regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/),E=g([`Boolean`,`Int32`,`UInt16`,`UInt32`,`Double`,`Float`,`String`]);g([`variable`,`property`]);var D=g([`read`,`readwrite`,`write`]),O=g([`>`,`>=`,`<`,`<=`,`==`,`!=`]),k=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,se=m(`type`,[u({type:d(`threshold`),member:_().regex(f,k),operator:O,threshold:x().finite()}).strict(),u({type:d(`lifecycle-stage`)}).strict(),u({type:d(`health-state`)}).strict(),u({type:d(`fault-active`)}).strict(),u({type:d(`fault-count`)}).strict(),u({type:d(`active-fault-code`),fallback:_().default(``)}).strict(),u({type:d(`availability-state`),member:_().regex(f,k),operator:O.default(`>`),threshold:x().finite().default(0),running_state:_().default(`running`),stopped_state:_().default(`stopped`),faulted_state:_().default(`faulted`)}).strict()]),A=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,j=h(_().min(1)).min(1),ce=u({data_type:E,unit:T.optional(),description:_().optional(),enum_values:j.optional()}).strict(),le=p([u({member:_().regex(f,A),value:p([x(),_(),l()])}).strict(),u({member:_().regex(f,A),argument:_().regex(f,A)}).strict()]),ue=u({type:d(`set-members`),writes:h(le).min(1)}).strict(),de=p([u({parameter:_().regex(f,A),value:x().finite()}).strict(),u({parameter:_().regex(f,A),argument:_().regex(f,A)}).strict()]),fe=m(`type`,[ue,u({type:d(`set-parameters`),writes:h(de).min(1)}).strict(),u({type:d(`clear-faults`)}).strict()]),pe=u({description:_().optional(),input_arguments:v(_().regex(f,A),ce).optional(),output_arguments:v(_().regex(f,A),ce).optional(),runtime:fe.optional()}).strict(),me=v(_().regex(f,A),pe);function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){if(typeof e==`string`)return o.exec(e)?.[1]}function P(e,t,n){if(!M(e)||e.type!==`weighted-sum`)return;let r=e.terms;if(Array.isArray(r))for(let e=0;e<r.length;e++){let i=r[e];M(i)&&n(i,[...t,`terms`,e])}}function he(e,t,n){if(!M(e))return;let r=[...t,`member`],i=[...t,`previous_member`],a=[...t,`param`],o=[...t,`generator`];typeof e.member==`string`&&n.onMember?.(e.member,r),typeof e.previous_member==`string`&&n.onPreviousMember?.(e.previous_member,i),typeof e.param==`string`&&n.onParam?.(e.param,a),`generator`in e&&n.onGenerator?.(e.generator,o)}function ge(e,t,n,r){return{onMember:e,onPreviousMember:t,onParam:n,onGenerator:r}}function _e(e,t,n,r,i,a){he(e,t,ge(n,r,i,a))}function F(e){return e===`Double`||e===`Float`||e===`Int32`||e===`UInt16`||e===`UInt32`}function ve(e){return e===`Int32`||e===`UInt16`||e===`UInt32`}function I(e,t){switch(t){case`Boolean`:return typeof e==`boolean`;case`String`:return typeof e==`string`;case`Double`:case`Float`:return typeof e==`number`&&Number.isFinite(e);case`Int32`:return typeof e==`number`&&Number.isSafeInteger(e)&&e>=-2147483648&&e<=2147483647;case`UInt16`:return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0&&e<=65535;case`UInt32`:return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0&&e<=4294967295;default:return!1}}function ye(e,t,n){e.unit!==void 0&&(e.data_type===`Boolean`||e.data_type===`String`)&&t.addIssue({code:b.custom,path:[...n,`unit`],message:`Members with data_type "${e.data_type}" must not declare engineering units. Fix: remove the unit or use a numeric data_type.`}),e.enum_values&&e.data_type!==`String`&&t.addIssue({code:b.custom,path:[...n,`enum_values`],message:`enum_values is only valid for String members. Fix: remove enum_values or change data_type to "String".`})}function L(e,t,n,r){if(M(e)&&typeof e.type==`string`)switch(e.type){case`correlated`:typeof e.source==`string`&&n.push({member:e.source,path:[...t,`source`],previousTick:!1}),z(e.factor,[...t,`factor`],r),z(e.offset,[...t,`offset`],r);return;case`sine`:case`noise`:case`waveform`:case`chirp`:z(e.center,[...t,`center`],r);return;case`mean-reverting-noise`:z(e.mean,[...t,`mean`],r);return;case`first-order-lag`:case`second-order`:z(e.gain,[...t,`gain`],r),z(e.bias,[...t,`bias`],r),R(e.input,[...t,`input`],n,r);return;case`transport-delay`:z(e.delay,[...t,`delay`],r),R(e.input,[...t,`input`],n,r);return;case`slew-rate-limiter`:case`integrator`:R(e.input,[...t,`input`],n,r);return;case`hysteresis-relay`:z(e.on_threshold,[...t,`on_threshold`],r),z(e.off_threshold,[...t,`off_threshold`],r),R(e.input,[...t,`input`],n,r);return;case`weighted-sum`:z(e.bias,[...t,`bias`],r),P(e,t,(e,t)=>{z(e.weight,[...t,`weight`],r),R(e.input,[...t,`input`],n,r)});return;case`gate`:n.push({member:String(e.enabled_member),path:[...t,`enabled_member`],previousTick:!1}),R(e.input,[...t,`input`],n,r);return;case`health-dependent`:{let i=e.stages;if(!M(i))return;for(let[e,a]of Object.entries(i))L(a,[...t,`stages`,e],n,r);return}default:return}}function R(e,t,n,r){_e(e,t,(e,t)=>n.push({member:e,path:t,previousTick:!1}),(e,t)=>n.push({member:e,path:t,previousTick:!0}),(e,t)=>r.push({param:e,path:t}),(e,t)=>L(e,t,n,r))}function z(e,t,n){let r=N(e);r!==void 0&&n.push({param:r,path:t})}function be(e,t,n){if(!M(e))return;let r=e.type;(r===`threshold`||r===`availability-state`)&&typeof e.member==`string`&&n.push({member:e.member,path:[...t,`member`],previousTick:!1})}function B(e,t,n){if(!M(e))return;let r=e.type;if(typeof r!=`string`)return;if(r===`integrator`&&e.wrap===!0&&(typeof e.wrap_at!=`number`||!Number.isFinite(e.wrap_at)||e.wrap_at<=0)&&n.addIssue({code:b.custom,path:[...t,`wrap_at`],message:`wrap_at must be a finite number greater than 0 when wrap is true. Fix: Set wrap_at to a positive number, or set wrap to false.`}),r===`health-dependent`){let r=e.stages;if(M(r))for(let[e,i]of Object.entries(r))B(i,[...t,`stages`,e],n)}function i(e,t){!M(e)||!(`generator`in e)||B(e.generator,[...t,`generator`],n)}i(e.input,[...t,`input`]),P(e,t,(e,t)=>{i(e.input,[...t,`input`])})}function xe(e){switch(e){case`Boolean`:return!1;case`String`:return``;case`Double`:case`Float`:case`Int32`:case`UInt16`:case`UInt32`:return 0;default:return 0}}var Se=h(m(`type`,[u({type:d(`white_noise`),strength:x().min(0).max(1),scale:x().positive().optional()}).strict(),u({type:d(`drift`),tau:x().positive(),sigma:x().min(0).max(1),scale:x().positive().optional()}).strict(),u({type:d(`outlier`),probability:x().min(0).max(1),magnitude:x().positive(),scale:x().positive().optional()}).strict(),u({type:d(`gap`),probability:x().min(0).max(1),duration:x().int().positive().default(10)}).strict(),u({type:d(`noise_burst`),probability:x().min(0).max(1),duration:x().int().positive().default(5),strength:x().min(0).max(1),scale:x().positive().optional()}).strict()])).min(1).optional(),V=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`;g([`float`,`int`,`string`,`bool`]);var Ce=m(`type`,[u({type:d(`float`),default:x().finite(),min:x().finite().optional(),max:x().finite().optional(),unit:T.optional()}),u({type:d(`int`),default:x().int().safe(),min:x().int().safe().optional(),max:x().int().safe().optional(),unit:T.optional()}),u({type:d(`string`),default:_(),unit:T.optional()}),u({type:d(`bool`),default:l(),unit:T.optional()})]),H=p([u({member:_()}).strict(),u({previous_member:_()}).strict(),u({param:_()}).strict(),u({generator:c(()=>We)}).strict()]),U=_().regex(o,`Must be a $param.X parameter reference`),W=p([x(),U]),G=p([x().finite(),U]),K={initial_value:x().default(0),gain:W.default(1),bias:W.default(0),min:x().nullable().default(null),max:x().nullable().default(null),input:H},q=u({type:d(`sine`),center:W,amplitude:x().positive(),period:x().positive()}).strict(),J=u({type:d(`random-walk`),min:x(),max:x(),step:x().positive()}).strict(),we=u({type:d(`noise`),center:W,stddev:x().positive()}).strict(),Te=u({type:d(`step`),values:h(x()).min(1),interval:x().positive()}).strict(),Ee=u({type:d(`correlated`),source:_().regex(f,V),factor:G,offset:G,power:x().int().positive().optional()}).strict(),De=u({from:_(),to:_(),probability:x().min(0).max(1).optional(),on:_().optional()}).strict(),Y=u({type:d(`state-machine`),states:h(_()).min(1),initial:_(),transitions:h(De).min(1)}).strict();function X(e,t){let n=new Set(e.states);n.has(e.initial)||t.addIssue({code:b.custom,path:[`initial`],message:`State machine initial state "${e.initial}" is not in states. Fix: Set initial to one of: ${e.states.join(`, `)}.`});for(let r=0;r<e.transitions.length;r++){let i=e.transitions[r];i&&(n.has(i.from)||t.addIssue({code:b.custom,path:[`transitions`,r,`from`],message:`State machine transition from "${i.from}" references a state that is not in states. Fix: Add "${i.from}" to states or change transition.from to one of: ${e.states.join(`, `)}.`}),n.has(i.to)||t.addIssue({code:b.custom,path:[`transitions`,r,`to`],message:`State machine transition to "${i.to}" references a state that is not in states. Fix: Add "${i.to}" to states or change transition.to to one of: ${e.states.join(`, `)}.`}))}}Y.superRefine(X);var Oe=u({type:d(`ramp`),start_value:x().default(0),rate:x(),duration:x().nonnegative(),start_time:x().default(0),min:x().nullable().default(null),max:x().nullable().default(null)}).strict(),ke=u({type:d(`mean-reverting-noise`),mean:W,tau:x().positive(),sigma:x().positive(),initial_value:x().optional(),min:x().nullable().default(null),max:x().nullable().default(null)}).strict(),Ae=u({time:x().nonnegative(),value:x()}),je=u({type:d(`timetable`),points:h(Ae).min(2),repeat:l().default(!1),interpolation:g([`linear`,`step`]).default(`linear`)}).strict(),Me=u({type:d(`waveform`),shape:g([`sawtooth`,`triangle`,`square`,`pulse`]),center:W,amplitude:x().positive(),period:x().positive(),duty_cycle:x().min(0).max(1).default(.5)}).strict(),Ne=u({type:d(`chirp`),center:W,amplitude:x().positive(),start_freq_hz:x().positive(),end_freq_hz:x().positive(),sweep_duration:x().positive(),sweep:g([`linear`,`exponential`]).default(`linear`),repeat:l().default(!0)}).strict(),Z=u({type:d(`impulse`),baseline:x().default(0),amplitude:x(),probability:x().min(0).max(1).optional(),interval:x().positive().optional(),decay:x().min(0).max(1).optional(),duration:x().int().positive().default(1)}).strict();function Q(e,t){e.probability===void 0&&e.interval===void 0&&t.addIssue({code:b.custom,path:[`probability`],message:`Impulse generator requires either probability or interval. Fix: Add probability: 0.01 (per-tick chance) or interval: 60 (seconds between triggers).`}),e.probability!==void 0&&e.interval!==void 0&&t.addIssue({code:b.custom,path:[`interval`],message:`Impulse generator cannot have both probability and interval. Fix: Remove one: use probability for random triggers, or interval for periodic triggers.`})}Z.superRefine(Q);var Pe=u({type:d(`first-order-lag`),tau:x().positive(),...K}).strict(),Fe=u({type:d(`integrator`),initial_value:x().default(0),gain:x().default(1),bias_rate:x().default(0),min:x().default(-1/0),max:x().default(1/0),wrap:l().default(!1),wrap_at:x().nullable().default(null),input:H}).strict(),Ie=u({type:d(`transport-delay`),delay:p([x().nonnegative(),U]),initial_value:x().default(0),interpolation:g([`linear`,`zoh`]).default(`linear`),input:H}).strict(),Le=u({type:d(`slew-rate-limiter`),rate_up:x().positive(),rate_down:x().positive().optional(),initial_value:x().default(0),min:x().nullable().default(null),max:x().nullable().default(null),input:H}).strict(),Re=u({type:d(`second-order`),natural_freq_hz:x().positive(),damping_ratio:x().positive(),initial_velocity:x().default(0),...K}).strict(),ze=u({type:d(`hysteresis-relay`),on_threshold:W,off_threshold:W,output_on:p([x(),_()]).default(1),output_off:p([x(),_()]).default(0),initial_state:g([`on`,`off`]).default(`off`),mode:g([`rising`,`falling`]).default(`rising`),input:H}).strict(),Be=u({weight:W.default(1),input:H}),Ve=u({type:d(`weighted-sum`),bias:W.default(0),terms:h(Be).min(1),min:x().nullable().default(null),max:x().nullable().default(null)}).strict(),He=u({type:d(`gate`),enabled_member:_().regex(f,V),input:H,disabled_value:p([x(),_(),l()])}).strict(),Ue=m(`type`,[q,J,we,Te,Ee,Y,Oe,ke,je,Me,Ne,Z]).superRefine((e,t)=>{e.type===`state-machine`&&X(e,t),e.type===`impulse`&&Q(e,t)}),We=m(`type`,[q,J,we,Te,Ee,Y,Oe,ke,je,Me,Ne,Z,u({type:d(`health-dependent`),stages:v(_(),Ue)}).strict(),Pe,Fe,Ie,Le,Re,ze,Ve,He]).superRefine((e,t)=>{e.type===`state-machine`&&X(e,t),e.type===`impulse`&&Q(e,t)}),Ge=u({multiplier:x().finite().optional(),offset:x().finite().optional()}).strict(),Ke=u({stages:h(u({name:_().min(1),duration_hours:y([x().nonnegative(),x().nonnegative()]).refine(([e,t])=>e<=t,{message:`duration_hours max must be greater than or equal to min.`}),effects:v(_(),Ge)})).min(1)}).superRefine((e,t)=>{let n=new Set;for(let r=0;r<e.stages.length;r++){let i=e.stages[r];i&&(n.has(i.name)&&t.addIssue({code:b.custom,path:[`stages`,r,`name`],message:`Lifecycle stage names must be unique. Duplicate "${i.name}". Fix: Rename one stage so each lifecycle stage has a unique name.`}),n.add(i.name))}}),qe=u({multiplier:x().finite().optional(),offset:x().finite().optional(),spike:x().finite().optional(),duration_ticks:x().int().positive().optional(),onset_ticks:x().int().positive().optional(),recovery_ticks:x().int().positive().optional()}).strict(),Je=u({condition:_().optional(),lifecycle_stage:_().optional(),probability:x().min(0).max(1)}),Ye=u({name:_().regex(f,V),trigger:Je,effects:v(_(),p([qe,_()]))}),Xe=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,Ze=new Set([`enterprise`,`site`,`area`,`line`,`prefix`]),Qe=_().regex(o,`Must be a $param.X parameter reference`),$e=p([x(),_(),l()]),et=u({name:_().regex(f,Xe),description:_().optional(),namespace:_().optional()}).strict(),tt=m(`kind`,[u({kind:d(`variable`),data_type:E,access:D,unit:T.optional(),enum_values:j.optional(),eu_range:y([x(),x()]).refine(([e,t])=>e<=t,{message:`eu_range[0] (min) must be <= eu_range[1] (max).`}).optional(),generator:We.optional(),binding:se.optional(),default:$e.optional(),observation_effects:Se}).strict(),u({kind:d(`property`),data_type:E,access:D,unit:T.optional(),enum_values:j.optional(),default:p([$e,Qe]).optional()}).strict()]);function nt(e){return v(_().regex(f,Xe),tt).refine(e=>Object.keys(e).length>=1,{message:`Members map must have at least 1 member.`}).refine(t=>Object.keys(t).length<=e,{message:`Members map must have at most ${e} members.`}).refine(e=>!Object.keys(e).some(e=>Ze.has(e)),{message:`Member names cannot use reserved env keys: enterprise/site/area/line/prefix`})}function rt(e={}){let t=nt(e.maxMembersPerModel??1e3);return u({schema_version:d(`2`),model:et,parameters:v(_(),Ce).optional(),members:t,methods:me.optional(),lifecycle:Ke.optional(),faults:h(Ye).optional()}).strict().superRefine((e,t)=>{let n=Object.keys(e.members),r=new Map;for(let e=0;e<n.length;e++){let t=n[e];t!==void 0&&r.set(t,e)}let i=new Set(Object.keys(e.parameters??{})),a=new Set(Object.entries(e.parameters??{}).filter(([,e])=>e.type===`float`||e.type===`int`).map(([e])=>e));for(let o=0;o<n.length;o++){let s=n[o];if(s===void 0)continue;let c=e.members[s];if(!c||(ye(c,t,[`members`,s]),c.kind===`variable`&&c.generator!==void 0&&c.binding!==void 0&&t.addIssue({code:b.custom,path:[`members`,s,`binding`],message:`Variable members cannot define both "generator" and "binding". Fix: keep one source of value generation.`}),c.kind===`variable`&&c.binding!==void 0&&c.access!==`read`&&t.addIssue({code:b.custom,path:[`members`,s,`access`],message:`Variable members with a "binding" must use access "read". Fix: change access to "read" or remove the binding.`}),c.kind!==`variable`||!c.generator&&!c.binding))continue;let l=[],u=[],d=[`members`,s,`generator`];if(c.generator&&L(c.generator,d,l,u),c.binding&&be(c.binding,[`members`,s,`binding`],l),c.generator&&(B(c.generator,d,t),c.generator.type===`gate`)){let n=e.members[c.generator.enabled_member];n&&n.data_type!==`Boolean`&&t.addIssue({code:b.custom,path:[`members`,s,`generator`,`enabled_member`],message:`Gate generator for "${s}" references "${c.generator.enabled_member}", but "${c.generator.enabled_member}" is not Boolean. Fix: use a Boolean command/state member for enabled_member.`}),I(c.generator.disabled_value,c.data_type)||t.addIssue({code:b.custom,path:[`members`,s,`generator`,`disabled_value`],message:`Gate generator disabled_value for "${s}" does not match data_type "${c.data_type}". Fix: use a compatible disabled_value literal.`})}for(let e of l){let n=r.get(e.member);if(n===void 0){t.addIssue({code:b.custom,path:[...e.path],message:`Member "${s}" references member "${e.member}", but "${e.member}" is not defined. Fix: Define "${e.member}" in members, or change the reference to a parameter.`});continue}!e.previousTick&&n>=o&&t.addIssue({code:b.custom,path:[...e.path],message:`Member "${s}" references member "${e.member}" which is defined later (or is itself). Members are evaluated in declaration order. Fix: Move "${e.member}" above "${s}".`})}for(let n of u)i.has(n.param)?a.has(n.param)||t.addIssue({code:b.custom,path:[...n.path],message:`Member "${s}" references parameter "${n.param}" in a numeric position, but "${n.param}" has type "${e.parameters?.[n.param]?.type}". Only float and int parameters can be used as generator coefficients or inputs. Fix: Change "${n.param}" to type "float" or "int".`}):t.addIssue({code:b.custom,path:[...n.path],message:`Member "${s}" references parameter "${n.param}", but "${n.param}" is not defined. Fix: Define "${n.param}" under parameters, or replace "$param.${n.param}" with a literal value.`});if(c.binding)switch(c.binding.type){case`threshold`:c.data_type!==`Boolean`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "threshold" must use data_type "Boolean". Fix: change data_type to "Boolean".`}),it(s,c.binding.member,e,t,[`members`,s,`binding`,`member`]);break;case`availability-state`:c.data_type!==`String`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "availability-state" must use data_type "String". Fix: change data_type to "String".`}),it(s,c.binding.member,e,t,[`members`,s,`binding`,`member`]);break;case`lifecycle-stage`:case`health-state`:case`active-fault-code`:c.data_type!==`String`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "${c.binding.type}" must use data_type "String". Fix: change data_type to "String".`});break;case`fault-active`:c.data_type!==`Boolean`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "fault-active" must use data_type "Boolean". Fix: change data_type to "Boolean".`});break;case`fault-count`:c.data_type!==`Int32`&&c.data_type!==`UInt16`&&c.data_type!==`UInt32`&&t.addIssue({code:b.custom,path:[`members`,s,`data_type`],message:`Members using binding.type "fault-count" must use an integer data_type (Int32, UInt16, or UInt32). Fix: change data_type to an integer type.`});break;default:c.binding}if(c.kind===`variable`&&c.observation_effects){F(c.data_type)||t.addIssue({code:b.custom,path:[`members`,s,`observation_effects`],message:`Observation effects on "${s}" require a numeric data_type (Double, Float, Int32, UInt16, or UInt32). Member has data_type "${c.data_type}", which cannot be degraded by noise, gaps, or drift. Fix: remove observation_effects, or change data_type to a numeric type.`}),c.access!==`read`&&t.addIssue({code:b.custom,path:[`members`,s,`observation_effects`],message:`Observation effects on "${s}" require access "read". Observation effects corrupt values — they must not be applied to command targets or setpoints. Fix: change access to "read" or remove observation_effects.`});for(let e=0;e<c.observation_effects.length;e++){let n=c.observation_effects[e];n&&(n.type===`white_noise`||n.type===`drift`||n.type===`outlier`||n.type===`noise_burst`)&&!(`scale`in n&&n.scale!==void 0)&&!c.eu_range&&t.addIssue({code:b.custom,path:[`members`,s,`observation_effects`,e],message:`Member "${s}" uses relative observation effect "${n.type}" but has no eu_range and no explicit scale. Fix: add eu_range: [min, max] to the member, or add scale: <number> to the effect.`})}}}function o(n,i,a){if(!r.has(n)){t.addIssue({code:b.custom,path:[...i],message:`${a} has effect on "${n}", but "${n}" is not a defined member. Fix: Change "${n}" to a valid member name.`});return}let o=e.members[n];o&&o.kind!==`variable`&&t.addIssue({code:b.custom,path:[...i],message:`${a} has effect on "${n}", but "${n}" is a property (kind: "property"). Effects can only target variable members.`})}if(e.lifecycle){let t=[`lifecycle`,`stages`];for(let n of e.lifecycle.stages)for(let e of Object.keys(n.effects))o(e,t,`Lifecycle stage "${n.name}"`)}if(e.faults){let n=new Set;for(let r=0;r<e.faults.length;r++){let i=e.faults[r];if(!i)continue;n.has(i.name)&&t.addIssue({code:b.custom,path:[`faults`,r,`name`],message:`Fault names must be unique. Duplicate "${i.name}". Fix: Rename one fault so each fault has a unique name.`}),n.add(i.name);let a=[`faults`,r,`effects`];for(let e of Object.keys(i.effects))o(e,a,`Fault "${i.name}"`)}}for(let r of n){let n=e.members[r];if(!n||n.kind!==`property`||typeof n.default!=`string`)continue;let a=N(n.default);a!==void 0&&!i.has(a)&&t.addIssue({code:b.custom,path:[`members`,r,`default`],message:`Property "${r}" default references parameter "${a}", but "${a}" is not defined. Fix: Define "${a}" under parameters, or use a literal value.`})}if(e.methods)for(let[n,r]of Object.entries(e.methods))at(n,r.input_arguments,t,[`methods`,n,`input_arguments`]),at(n,r.output_arguments,t,[`methods`,n,`output_arguments`]),ot(n,r,e,t,[`methods`,n,`runtime`])})}function it(e,t,n,r,i){let a=n.members[t];a&&(F(a.data_type)||r.addIssue({code:b.custom,path:[...i],message:`Member "${e}" binding references "${t}", but "${t}" is not numeric. Fix: bind to a numeric member or change the source member data_type.`}))}function at(e,t,n,r){if(t)for(let[i,a]of Object.entries(t))a.unit!==void 0&&(a.data_type===`Boolean`||a.data_type===`String`)&&n.addIssue({code:b.custom,path:[...r,i,`unit`],message:`Method "${e}" argument "${i}" uses data_type "${a.data_type}" and must not declare an engineering unit. Fix: remove the unit or use a numeric data_type.`}),a.enum_values&&a.data_type!==`String`&&n.addIssue({code:b.custom,path:[...r,i,`enum_values`],message:`Method "${e}" argument "${i}" can only use enum_values with data_type "String". Fix: remove enum_values or change the data_type.`})}function ot(e,t,n,r,i){let a=t.runtime;if(a)switch(a.type){case`clear-faults`:return;case`set-parameters`:for(let o=0;o<a.writes.length;o++){let s=a.writes[o];if(!s)continue;let c=[...i,`writes`,o],l=n.parameters?.[s.parameter];if(!l){r.addIssue({code:b.custom,path:[...c,`parameter`],message:`Method "${e}" runtime targets parameter "${s.parameter}", but "${s.parameter}" is not defined. Fix: target a declared parameter.`});continue}if(l.type!==`float`&&l.type!==`int`){r.addIssue({code:b.custom,path:[...c,`parameter`],message:`Method "${e}" runtime targets parameter "${s.parameter}" of type "${l.type}". Fix: use set-parameters only with float or int parameters.`});continue}if(`argument`in s){let n=t.input_arguments?.[s.argument];if(!n){r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime references input argument "${s.argument}", but that argument is not defined. Fix: declare the input argument or use a literal value.`});continue}F(n.data_type)||r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" must be numeric to write parameter "${s.parameter}". Fix: use Double, Float, Int32, UInt16, or UInt32.`}),l.type===`int`&&!ve(n.data_type)&&r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" uses data_type "${n.data_type}" but parameter "${s.parameter}" is type "int". Fix: use Int32, UInt16, or UInt32 so runtime writes stay integer-safe.`});continue}l.type===`int`&&!Number.isSafeInteger(s.value)&&r.addIssue({code:b.custom,path:[...c,`value`],message:`Method "${e}" runtime literal for integer parameter "${s.parameter}" must be a safe integer. Fix: use a whole-number literal.`})}return;case`set-members`:for(let o=0;o<a.writes.length;o++){let s=a.writes[o];if(!s)continue;let c=[...i,`writes`,o],l=n.members[s.member];if(!l){r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets member "${s.member}", but "${s.member}" is not defined. Fix: target a declared member.`});continue}if(l.kind!==`variable`&&r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets "${s.member}", but "${s.member}" is a property. Fix: target a writable variable member.`}),l.access!==`readwrite`&&l.access!==`write`&&r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets "${s.member}", but "${s.member}" is not writable. Fix: set access to "readwrite" or "write".`}),l.kind===`variable`&&l.binding&&r.addIssue({code:b.custom,path:[...c,`member`],message:`Method "${e}" runtime targets "${s.member}", but bound members are computed at runtime. Fix: write to a command/setpoint member without a binding.`}),`argument`in s){let n=t.input_arguments?.[s.argument];if(!n){r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime references input argument "${s.argument}", but that argument is not defined. Fix: declare the input argument or use a literal value.`});continue}if(I(xe(n.data_type),l.data_type)||r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" uses data_type "${n.data_type}" which does not match target member "${s.member}" data_type "${l.data_type}". Fix: align the argument and target member data types.`}),n.enum_values&&l.enum_values){let t=n.enum_values.filter(e=>!l.enum_values?.includes(e));t.length>0&&r.addIssue({code:b.custom,path:[...c,`argument`],message:`Method "${e}" runtime argument "${s.argument}" allows values [${t.join(`, `)}] that are not valid for target member "${s.member}". Fix: align enum_values between the argument and target member.`})}continue}I(s.value,l.data_type)||r.addIssue({code:b.custom,path:[...c,`value`],message:`Method "${e}" runtime literal for "${s.member}" does not match data_type "${l.data_type}". Fix: use a compatible literal value.`}),l.enum_values&&typeof s.value==`string`&&!l.enum_values.includes(s.value)&&r.addIssue({code:b.custom,path:[...c,`value`],message:`Method "${e}" runtime literal "${s.value}" is not allowed for member "${s.member}". Fix: use one of [${l.enum_values.join(`, `)}].`})}return;default:}}rt();var st=p([x().finite(),_(),l()]),ct=_().regex(/^[a-f0-9]{64}$/),lt=u({id:_().min(1),model:_().min(1),browsePath:h(_().min(1)).min(1),parameters:v(_(),st),lifecycleStage:_().min(1),operatingHours:x().finite().nonnegative(),activeFaults:h(_().min(1)),templateRunId:x().int().positive().optional(),protocolScope:h(s).min(1).optional(),observationState:v(_(),v(_(),a())).optional().default({}),faultState:v(_(),u({remaining:x().int(),elapsed:x().int(),recovering:l(),recoveryElapsed:x().int(),recoveryTicks:x().int()})).optional().default({})}),ut=u({templateRunId:x().int().positive(),templateName:_().min(1),templatePath:_(),entryHash:ct.optional()}),dt=u({name:_().min(1),enabled:l(),config:v(_(),a())});u({version:d(2),savedAt:_().min(1),environmentName:oe,models:h(_().min(1)),instances:h(lt),templateRuns:h(ut),adapters:h(dt).default([])});var $=e();function ft({className:e,orientation:t=`horizontal`,...n}){return(0,$.jsx)(r,{"data-slot":`tabs`,"data-orientation":t,className:C(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var pt=ee(`group/tabs-list inline-flex w-fit items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-0 border-b border-border/50 bg-transparent p-0 shadow-none group-data-horizontal/tabs:h-auto group-data-horizontal/tabs:min-h-8`}},defaultVariants:{variant:`default`}});function mt({className:e,variant:n=`default`,...r}){return(0,$.jsx)(t,{"data-slot":`tabs-list`,"data-variant":n,className:C(pt({variant:n}),e),...r})}function ht({className:e,...t}){return(0,$.jsx)(i,{"data-slot":`tabs-trigger`,className:C(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-[var(--miravo-radius-tight)] border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-muted-foreground transition-[color,box-shadow,transform] duration-200 ease-out group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:font-heading group-data-[variant=line]/tabs-list:tracking-tight group-data-[variant=line]/tabs-list:text-sm group-data-[variant=line]/tabs-list:text-muted-foreground group-data-[variant=line]/tabs-list:hover:text-foreground group-data-[variant=line]/tabs-list:data-active:font-semibold group-data-[variant=line]/tabs-list:data-active:text-foreground`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent group-data-[variant=line]/tabs-list:data-active:border-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`group-data-[variant=line]/tabs-list:rounded-none group-data-[variant=line]/tabs-list:px-3 group-data-[variant=line]/tabs-list:py-2`,`data-active:bg-background data-active:text-foreground data-active:border-input data-active:bg-input/30 data-active:text-foreground`,`after:pointer-events-none after:absolute after:bg-foreground after:opacity-0 after:transition-[opacity,transform] after:duration-300 after:ease-out group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5`,`group-data-[variant=line]/tabs-list:after:bg-primary group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:after:bottom-0 group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:after:h-[2px] group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:after:rounded-sm group-data-[variant=line]/tabs-list:data-active:after:opacity-100 group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:data-active:after:shadow-[0_0_14px_-3px_color-mix(in_srgb,var(--primary)_50%,transparent)]`,e),...t})}function gt({className:e,...t}){return(0,$.jsx)(n,{"data-slot":`tabs-content`,className:C(`flex-1 text-sm outline-none py-2`,e),...t})}export{ie as a,te as c,ht as i,gt as n,re as o,mt as r,ne as s,ft as t};
|