import{c as Va,a as D,d as aa,f as y}from"../chunks/8V7BUHOp.js";import{f as ta,p as sa,c as e,r as a,s as t,t as oe,a as ra,u as Wa,e as h,b as de,g as x}from"../chunks/CwuLZfOX.js";import{s as n}from"../chunks/CaaTB9LM.js";import{i as Xe}from"../chunks/ChcH33Yj.js";import{I as Xa,f as Ya,j as le,s as et,a as f}from"../chunks/CQEIL4Zf.js";import{a as r,m as at}from"../chunks/BbeM5ayP.js";import{p as tt}from"../chunks/XMP94Xkj.js";import"../chunks/DUxDMF0-.js";import{H as st,b as Ye,T as ea,D as rt,a as nt,S as it}from"../chunks/D09EVxHf.js";import{G as vt}from"../chunks/_nb-9GJW.js";import"../chunks/DrQE6hIy.js";import{l as ct,s as dt}from"../chunks/CNkT2fMe.js";import{T as lt}from"../chunks/CwwF0xKi.js";function ot(d,i){const s=ct(i,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.511.0 - ISC
 *
 * ISC License
 *
 * Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 */const m=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];Xa(d,dt({name:"activity"},()=>s,{get iconNode(){return m},children:(p,_)=>{var u=Va(),l=ta(u);Ya(l,i,"default",{}),D(p,u)},$$slots:{default:!0}}))}var ut=(d,i)=>{var s;return(s=i.onAbort)==null?void 0:s.call(i)},pt=(d,i)=>{var s;return(s=i.onOk)==null?void 0:s.call(i)},_t=y('<div class="modal modal-open"><div class="modal-box"><h3 class="text-lg font-bold"> </h3> <p class="py-4">Be sure the AHU is not running!</p> <div class="modal-action"><button class="btn rounded-full">Abort</button> <button class="btn btn-primary rounded-full">OK</button></div></div></div>');function mt(d,i){sa(i,!0);var s=_t(),m=e(s),p=e(m),_=e(p);a(p);var u=t(p,4),l=e(u);l.__click=[ut,i];var A=t(l,2);A.__click=[pt,i],a(u),a(m),a(s),oe(()=>n(_,`Are you sure you want to test damper ${i.damper??""}?`)),D(d,s),ra()}aa(["click"]);var gt=d=>d.stopPropagation(),bt=y("<span><!> </span>"),xt=(d,i)=>i("A"),ft=(d,i)=>i("B"),ht=y("--> <!>",1),Dt=y('<section><div class="container mx-auto"><div class="flex items-center sticky bg-base-100 z-40 pb-2" style="top:4.11rem"><!></div> <div class="card bg-base-200 shadow-sm border border-base-300 rounded-2xl"><div class="m-2 p-1"><div><div class="flex items-center justify-between"><h2 class="text-2xl font-semibold"> </h2> <a class="btn btn-primary btn-sm rounded-full">Edit</a></div> <div class="flex items-center gap-3 mt-2"><span class="badge badge-secondary"> </span> <span class="badge badge-secondary"> </span> <span><!> </span> <div class="flex items-center gap-4"><!></div></div> <h3 class="text-l">Location: <span class="text-gray-400"> </span></h3></div> <div class="grid grid-cols-1 xl:grid-cols-3 gap-4 mt-0"><div class="xl:col-span-2 grid grid-cols-1 lg:grid-cols-2 gap-4"><div class="card bg-base-100 border border-base-300 rounded-2xl mt-2"><div class="card-body p-4"><div class="flex items-center justify-between"><h3 class="badge badge-secondary">Damper A</h3> <span> </span></div> <h3 class="text-l">Name: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Supplies: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Location: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Description: <span class="text-gray-400"> </span></h3> <div class="flex items-center justify-between"><span>Teststatus: <span class="text-gray-400"> </span></span> <button class="btn btn-primary btn-sm">Run test</button></div></div></div> <div class="card bg-base-100 border border-base-300 rounded-2xl"><div class="card-body p-4"><div class="flex items-center justify-between"><h3 class="badge badge-secondary">Damper B</h3> <span> </span></div> <h3 class="text-l">Name: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Supplies: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Location: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Description: <span class="text-gray-400"> </span></h3> <div class="flex items-center justify-between"><span>Teststatus: <span class="text-gray-400"> </span></span> <button class="btn btn-primary btn-sm">Run test</button></div></div></div></div> <div class="card bg-base-100 border border-base-300 rounded-2xl"><div class="card-body gap-2 p-4"><div class="space-y-3"><div class="flex items-start justify-between"><div><div class="text-sm">Digital Input: <span class="text-gray-400"> </span></div></div> <span> </span></div> <div class="flex items-start justify-between"><div><div class="text-sm">Digital Output: <span class="text-gray-400"> </span></div></div> <span> </span></div></div></div></div></div> <h3 class="text-xs mt-2">Serial Number: <span class="text-gray-400"> </span></h3></div></div> <!></div></section>');function Ft(d,i){sa(i,!0);let s=tt.params.id;const m=new r(`Devices/${s}/SerialNumber`),p=new r(`Devices/${s}/Settings/Name`),_=new r(`Devices/${s}/Settings/Zone`),u=new r(`Devices/${s}/Health`);let l=de(null);const A=new r(`Devices/${s}/Settings/Location`),ue=new r(`Devices/${s}/Settings/DiName`),$=new r(`Devices/${s}/Settings/DiFunc`),g=new r(`Devices/${s}/DigitalInput`),pe=new r(`Devices/${s}/Settings/DoName`),_e=new r(`Devices/${s}/Settings/DoFunc`),N=new r(`Devices/${s}/DigitalOutput`),B=new r(`Devices/${s}/DmpA/Status`),me=new r(`Devices/${s}/DmpA/TestStatus`),na=new r(`Devices/${s}/Settings/DmpAName`),ia=new r(`Devices/${s}/Settings/DmpADesc`),va=new r(`Devices/${s}/Settings/DmpALocation`),ca=new r(`Devices/${s}/Settings/DmpASupply`),da=new r(`Devices/${s}/DmpB/Status`),ge=new r(`Devices/${s}/DmpB/TestStatus`),la=new r(`Devices/${s}/Settings/DmpBName`),oa=new r(`Devices/${s}/Settings/DmpBDesc`),ua=new r(`Devices/${s}/Settings/DmpBLocation`),pa=new r(`Devices/${s}/Settings/DmpBSupply`);Wa(()=>{parseInt(_.value)>0&&parseInt(_.value)<=100&&h(l,new r(`Zones/${_.value}/${s}/Status`),!0)});let S=de(!1),k=de("A");function be(v){h(k,v,!0),h(S,!0)}function _a(){at.publish(x(k)==="A"?me.topic:ge.topic,"2"),h(S,!1)}function ma(v){switch(v){case"1":return"badge-success";case"2":return"badge-warning";case"3":return"badge-error";default:return""}}function ga(v){if(v===void 0)return"badge badge-error";switch(v.value){case"1":return"badge badge-success";case"2":case"3":case"4":return"badge badge-error";default:return""}}function xe(v){if(!v)return"badge";const c=Number(v);return c>=5?"badge badge-error":c===1?"badge badge-success":"badge badge-warning"}function ba(){switch($.value){case"1":return"-";case"2":case"3":case"4":case"5":return o(g.value)?"Alarm":"Normal";case"6":case"7":return o(g.value)?"Test triggered":"Test untriggered";case"8":case"9":return o(g.value)?"AHU Running":"AHU Stopped";default:return"Error"}}function xa(){switch($.value){case"1":return"-";case"2":case"3":case"4":case"5":return o(g.value)?"badge-error":"badge-ghost";case"6":case"7":return o(g.value)?"badge-success":"badge-ghost";case"8":case"9":return o(g.value)?"badge-success":"badge-ghost";default:return"badge-error"}}function fe(){switch(_e.value){case"1":return"-";case"2":case"3":return o(N.value)?"Zone Alarm":"Zone Normal";case"4":case"5":return o(N.value)?"AHU Stop":"AHU Start";case"6":return o(N.value)?"Internal Error":"OK";default:return"Error"}}const o=v=>(v??"").toLowerCase()==="true";var T=Dt(),he=e(T),H=e(he),fa=e(H);vt(fa),a(H);var L=t(H,2),De=e(L),I=e(De),j=e(I),F=e(j),ha=e(F,!0);a(F);var Se=t(F,2);Se.__click=[gt],a(j);var O=t(j,2),C=e(O),Da=e(C);a(C);var U=t(C,2),Sa=e(U);a(U);var w=t(U,2),we=e(w);ot(we,{class:"w-4 h-4 mr-1"});var wa=t(we);a(w);var ye=t(w,2),ya=e(ye);{var Aa=v=>{var c=bt(),b=e(c);lt(b,{class:"w-4 h-4 mr-1"});var ve=t(b);a(c),oe(ce=>{f(c,1,ce),n(ve,` ${it[x(l).value??""]??"—"??""}`)},[()=>le(ga(x(l)))]),D(v,c)};Xe(ya,v=>{x(l)!==null&&v(Aa)})}a(ye),a(O);var Ae=t(O,2),$e=t(e(Ae)),$a=e($e,!0);a($e),a(Ae),a(I);var Z=t(I,2),E=e(Z),M=e(E),Ne=e(M),R=e(Ne),z=t(e(R),2),Na=e(z,!0);a(z),a(R);var G=t(R,2),Be=t(e(G)),Ba=e(Be,!0);a(Be),a(G);var K=t(G,2),ke=t(e(K)),ka=e(ke,!0);a(ke),a(K);var P=t(K,2),Te=t(e(P)),Ta=e(Te,!0);a(Te),a(P);var q=t(P,2),He=t(e(q)),Ha=e(He,!0);a(He),a(q);var Le=t(q,2),J=e(Le),Ie=t(e(J)),La=e(Ie,!0);a(Ie),a(J);var Ia=t(J,2);Ia.__click=[xt,be],a(Le),a(Ne),a(M);var je=t(M,2),Fe=e(je),Q=e(Fe),V=t(e(Q),2),ja=e(V,!0);a(V),a(Q);var W=t(Q,2),Oe=t(e(W)),Fa=e(Oe,!0);a(Oe),a(W);var X=t(W,2),Ce=t(e(X)),Oa=e(Ce,!0);a(Ce),a(X);var Y=t(X,2),Ue=t(e(Y)),Ca=e(Ue,!0);a(Ue),a(Y);var ee=t(Y,2),Ze=t(e(ee)),Ua=e(Ze,!0);a(Ze),a(ee);var Ee=t(ee,2),ae=e(Ee),Me=t(e(ae)),Za=e(Me,!0);a(Me),a(ae);var Ea=t(ae,2);Ea.__click=[ft,be],a(Ee),a(Fe),a(je),a(E);var Re=t(E,2),ze=e(Re),Ge=e(ze),te=e(Ge),se=e(te),Ke=e(se),Pe=t(e(Ke)),Ma=e(Pe,!0);a(Pe),a(Ke),a(se);var re=t(se,2),Ra=e(re,!0);a(re),a(te);var qe=t(te,2),ne=e(qe),Je=e(ne),Qe=t(e(Je)),za=e(Qe,!0);a(Qe),a(Je),a(ne);var ie=t(ne,2),Ga=e(ie,!0);a(ie),a(qe),a(Ge),a(ze),a(Re),a(Z);var Ve=t(Z,2),We=t(e(Ve)),Ka=e(We,!0);a(We),a(Ve),a(De),a(L);var Pa=t(L,2);{var qa=v=>{var c=ht(),b=t(ta(c));mt(b,{get damper(){return x(k)},onAbort:()=>{h(S,!1)},onOk:()=>{_a()}}),D(v,c)};Xe(Pa,v=>{x(S)&&v(qa)})}a(he),a(T),oe((v,c,b,ve,ce,Ja,Qa)=>{n(ha,p.value),et(Se,"href","/devices/"+s+"/edit"),n(Da,`ID ${s??""}`),n(Sa,`Zone ${_.value??""}`),f(w,1,v),n(wa,` ${st[u.value??""]??"Unknown"??""}`),n($a,A.value),f(z,1,c),n(Na,Ye[B.value??""]??"1"),n(Ba,na.value),n(ka,ca.value),n(Ta,va.value),n(Ha,ia.value),n(La,ea[me.value]),f(V,1,b),n(ja,Ye[B.value??""]??"1"),n(Fa,la.value),n(Oa,pa.value),n(Ca,ua.value),n(Ua,oa.value),n(Za,ea[ge.value]),n(Ma,ue.value.length?ue.value:rt[$.value??""]??"—"),f(re,1,ve),n(Ra,ce),n(za,pe.value.length?pe.value:nt[_e.value??""]??"—"),f(ie,1,Ja),n(Ga,Qa),n(Ka,m.value)},[()=>"badge "+ma(u.value),()=>le(xe(B.value)),()=>le(xe(da.value)),()=>"badge "+xa(),ba,()=>"badge "+fe(),fe]),D(d,T),ra()}aa(["click"]);export{Ft as component};
